[SCM] dvbcut/master: remove traces of the included copy of ffmpeg

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Fri Jan 20 19:25:29 UTC 2012


The following commit has been merged in the master branch:
commit 752697bd91498763e69a53b96179240150c0734a
Author: Reinhard Tartler <siretart at tauware.de>
Date:   Fri Jan 20 20:15:10 2012 +0100

    remove traces of the included copy of ffmpeg

diff --git a/debian/docs b/debian/docs
index 6e03dbf..5ea26e0 100644
--- a/debian/docs
+++ b/debian/docs
@@ -1,4 +1,3 @@
 README
-README.ffmpeg
 README.icons
 CREDITS
diff --git a/debian/rules b/debian/rules
index 0a874ec..36b18f5 100755
--- a/debian/rules
+++ b/debian/rules
@@ -21,6 +21,8 @@ clean:
 	dh_testdir
 	dh_testroot
 	rm -rf build
+	rm -rf ffmpeg.src
+	rm -rf ffmpeg-patches
 	dh_clean build-stamp
 
 install: build
diff --git a/ffmpeg-patches/cvs20050918.deletefiles b/ffmpeg-patches/cvs20050918.deletefiles
deleted file mode 100644
index dc164b2..0000000
--- a/ffmpeg-patches/cvs20050918.deletefiles
+++ /dev/null
@@ -1,184 +0,0 @@
-Doxyfile
-INSTALL
-build_avopt
-clean-diff
-cmdutils.c
-cmdutils.h
-cws2fws.c
-doc/
-ffinstall.nsi
-ffmpeg.c
-ffplay.c
-ffserver.c
-ffserver.h
-libavcodec/4xm.c
-libavcodec/8bps.c
-libavcodec/aasc.c
-libavcodec/ac3dec.c
-libavcodec/alac.c
-libavcodec/amr.c
-libavcodec/apiexample.c
-libavcodec/asv1.c
-libavcodec/beosthread.c
-libavcodec/cinepak.c
-libavcodec/cljr.c
-libavcodec/cyuv.c
-libavcodec/dct-test.c
-libavcodec/dv.c
-libavcodec/faac.c
-libavcodec/faad.c
-libavcodec/fdctref.c
-libavcodec/fft-test.c
-libavcodec/ffv1.c
-libavcodec/flac.c
-libavcodec/flicvideo.c
-libavcodec/fraps.c
-libavcodec/h261.c
-libavcodec/h264.c
-libavcodec/huffyuv.c
-libavcodec/idcinvideo.c
-libavcodec/indeo2.c
-libavcodec/indeo2data.h
-libavcodec/indeo3.c
-libavcodec/indeo3data.h
-libavcodec/interplayvideo.c
-libavcodec/lcl.c
-libavcodec/libgsm.c
-libavcodec/libpostproc/Makefile
-libavcodec/libpostproc/postprocess.c
-libavcodec/libpostproc/postprocess.h
-libavcodec/libpostproc/postprocess_altivec_template.c
-libavcodec/libpostproc/postprocess_internal.h
-libavcodec/libpostproc/postprocess_template.c
-libavcodec/loco.c
-libavcodec/mace.c
-libavcodec/motion_test.c
-libavcodec/mp3lameaudio.c
-libavcodec/msrle.c
-libavcodec/msvideo1.c
-libavcodec/oggtheora.c
-libavcodec/oggvorbis.c
-libavcodec/png.c
-libavcodec/pthread.c
-libavcodec/qdrw.c
-libavcodec/qpeg.c
-libavcodec/qtrle.c
-libavcodec/ra144.c
-libavcodec/ra144.h
-libavcodec/ra288.c
-libavcodec/ra288.h
-libavcodec/roqvideo.c
-libavcodec/rpza.c
-libavcodec/rv10.c
-libavcodec/shorten.c
-libavcodec/smc.c
-libavcodec/snow.c
-libavcodec/sonic.c
-libavcodec/svq1.c
-libavcodec/svq1_vlc.h
-libavcodec/svq3.c
-libavcodec/truemotion1.c
-libavcodec/truemotion1data.h
-libavcodec/tscc.c
-libavcodec/ulti.c
-libavcodec/ulti_cb.h
-libavcodec/vc9.c
-libavcodec/vcr1.c
-libavcodec/vmdav.c
-libavcodec/vorbis.c
-libavcodec/vorbis.h
-libavcodec/vp3.c
-libavcodec/vp3data.h
-libavcodec/vqavideo.c
-libavcodec/w32thread.c
-libavcodec/wmadec.c
-libavcodec/wnv1.c
-libavcodec/ws-snd1.c
-libavcodec/x264.c
-libavcodec/xan.c
-libavcodec/xl.c
-libavcodec/xvidff.c
-libavcodec/xvmcvideo.c
-libavformat/4xm.c
-libavformat/amr.c
-libavformat/asf-enc.c
-libavformat/asf.c
-libavformat/asf.h
-libavformat/au.c
-libavformat/audio.c
-libavformat/avi.h
-libavformat/avidec.c
-libavformat/avienc.c
-libavformat/barpainet.c
-libavformat/barpainet.h
-libavformat/beosaudio.cpp
-libavformat/crc.c
-libavformat/daud.c
-libavformat/dc1394.c
-libavformat/dv.c
-libavformat/dv.h
-libavformat/dv1394.c
-libavformat/dv1394.h
-libavformat/electronicarts.c
-libavformat/ffm.c
-libavformat/flic.c
-libavformat/flvdec.c
-libavformat/flvenc.c
-libavformat/framehook.c
-libavformat/framehook.h
-libavformat/gif.c
-libavformat/gifdec.c
-libavformat/grab.c
-libavformat/grab_bktr.c
-libavformat/http.c
-libavformat/idcin.c
-libavformat/idroq.c
-libavformat/img.c
-libavformat/img2.c
-libavformat/ipmovie.c
-libavformat/jpeg.c
-libavformat/matroska.c
-libavformat/mmf.c
-libavformat/mov.c
-libavformat/movenc.c
-libavformat/mp3.c
-libavformat/mpjpeg.c
-libavformat/nsvdec.c
-libavformat/nut.c
-libavformat/ogg.c
-libavformat/ogg2.c
-libavformat/ogg2.h
-libavformat/oggparseflac.c
-libavformat/oggparsetheora.c
-libavformat/oggparsevorbis.c
-libavformat/png.c
-libavformat/pnm.c
-libavformat/psxstr.c
-libavformat/qtpalette.h
-libavformat/raw.c
-libavformat/rm.c
-libavformat/rtp.c
-libavformat/rtp.h
-libavformat/rtpproto.c
-libavformat/rtsp.c
-libavformat/rtsp.h
-libavformat/rtspcodes.h
-libavformat/segafilm.c
-libavformat/sgi.c
-libavformat/sierravmd.c
-libavformat/sol.c
-libavformat/swf.c
-libavformat/tcp.c
-libavformat/udp.c
-libavformat/wav.c
-libavformat/wc3movie.c
-libavformat/westwood.c
-libavformat/yuv.c
-libavformat/yuv4mpeg.c
-output_example.c
-pktdumper.c
-qt-faststart.c
-tests/
-unwrap-diff
-vhook/
-xvmc_render.h
diff --git a/ffmpeg-patches/cvs20050918.diff b/ffmpeg-patches/cvs20050918.diff
deleted file mode 100644
index 9bd0115..0000000
--- a/ffmpeg-patches/cvs20050918.diff
+++ /dev/null
@@ -1,2086 +0,0 @@
-diff -urN ffmpeg.orig/Makefile ffmpeg.src/Makefile
---- ffmpeg.orig/Makefile	2005-08-11 14:12:24.000000000 +0200
-+++ ffmpeg.src/Makefile	2005-11-27 16:34:24.164554736 +0100
-@@ -7,7 +7,10 @@
- VPATH=$(SRC_PATH)
- 
- CFLAGS=$(OPTFLAGS) -I. -I$(SRC_PATH) -I$(SRC_PATH)/libavutil -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavformat -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE
--LDFLAGS+= -g 
-+
-+ifeq ($(DVBCUT_NO_DEBUG),)
-+LDFLAGS+= -g
-+endif
- 
- ifeq ($(TARGET_GPROF),yes)
- CFLAGS+=-p
-@@ -188,11 +191,10 @@
- 	@test -f .libs || touch .libs
- 	@for i in $(DEP_LIBS) ; do if $(TEST) $$i -nt .libs ; then touch .libs; fi ; done
- 
--clean: $(CLEANVHOOK)
-+clean:
- 	$(MAKE) -C libavutil clean
- 	$(MAKE) -C libavcodec clean
- 	$(MAKE) -C libavformat clean
--	$(MAKE) -C tests clean
- 	rm -f *.o *.d *~ .libs .depend gmon.out TAGS ffmpeg_g$(EXESUF) \
- 	   ffplay_g$(EXESUF) $(PROG) $(PROGTEST) $(QTFASTSTART)
- 
-diff -urN ffmpeg.orig/libavcodec/Makefile ffmpeg.src/libavcodec/Makefile
---- ffmpeg.orig/libavcodec/Makefile	2005-09-13 19:32:01.000000000 +0200
-+++ ffmpeg.src/libavcodec/Makefile	2005-11-27 16:34:24.165554584 +0100
-@@ -17,213 +17,9 @@
-       ratecontrol.o adpcm.o eval.o error_resilience.o \
-       fft.o mdct.o raw.o golomb.o cabac.o\
-       dpcm.o adx.o faandct.o parser.o g726.o \
--      vp3dsp.o h264idct.o rangecoder.o pnm.o h263.o msmpeg4.o h263dec.o dvdsub.o dvbsub.o dvbsubdec.o\
-+      vp3dsp.o h264idct.o rangecoder.o pnm.o h263.o msmpeg4.o h263dec.o \
-       opt.o
- 
--ifeq ($(CONFIG_AASC_DECODER),yes)
--    OBJS+= aasc.o
--endif
--ifeq ($(CONFIG_ALAC_DECODER),yes)
--    OBJS+= alac.o
--endif
--ifneq ($(CONFIG_ASV1_DECODER)$(CONFIG_ASV1_ENCODER)$(CONFIG_ASV2_DECODER)$(CONFIG_ASV2_ENCODER),)
--    OBJS+= asv1.o
--endif
--ifeq ($(CONFIG_CINEPAK_DECODER),yes)
--    OBJS+= cinepak.o
--endif
--ifneq ($(CONFIG_CLJR_DECODER)$(CONFIG_CLJR_ENCODER),)
--    OBJS+= cljr.o
--endif
--ifeq ($(CONFIG_CYUV_DECODER),yes)
--    OBJS+= cyuv.o
--endif
--ifneq ($(CONFIG_DVVIDEO_DECODER)$(CONFIG_DVVIDEO_ENCODER),)
--    OBJS+= dv.o
--endif
--ifeq ($(CONFIG_EIGHTBPS_DECODER),yes)
--    OBJS+= 8bps.o
--endif
--ifneq ($(CONFIG_FFV1_DECODER)$(CONFIG_FFV1_ENCODER),)
--    OBJS+= ffv1.o
--endif
--ifeq ($(CONFIG_FLAC_DECODER),yes)
--    OBJS+= flac.o
--endif
--ifeq ($(CONFIG_FLIC_DECODER),yes)
--    OBJS+= flicvideo.o
--endif
--ifeq ($(CONFIG_FOURXM_DECODER),yes)
--    OBJS+= 4xm.o
--endif
--ifeq ($(CONFIG_FRAPS_DECODER),yes)
--    OBJS+= fraps.o
--endif
--ifneq ($(CONFIG_H261_DECODER)$(CONFIG_H261_ENCODER),)
--    OBJS+= h261.o
--endif
--ifneq ($(CONFIG_H264_DECODER)$(CONFIG_SVQ3_DECODER),)
--    OBJS+= h264.o
--endif
--ifneq ($(CONFIG_HUFFYUV_DECODER)$(CONFIG_HUFFYUV_ENCODER)$(CONFIG_FFVHUFF_DECODER)$(CONFIG_FFVHUFF_ENCODER),)
--    OBJS+= huffyuv.o
--endif
--ifeq ($(CONFIG_IDCIN_DECODER),yes)
--    OBJS+= idcinvideo.o
--endif
--ifeq ($(CONFIG_INDEO2_DECODER),yes)
--    OBJS+= indeo2.o
--endif
--ifeq ($(CONFIG_INDEO3_DECODER),yes)
--    OBJS+= indeo3.o
--endif
--ifeq ($(CONFIG_INTERPLAY_VIDEO_DECODER),yes)
--    OBJS+= interplayvideo.o
--endif
--ifneq ($(CONFIG_MSZH_DECODER)$(CONFIG_ZLIB_DECODER)$(CONFIG_ZLIB_ENCODER),)
--    OBJS+= lcl.o
--endif
--ifeq ($(CONFIG_LOCO_DECODER),yes)
--    OBJS+= loco.o
--endif
--ifneq ($(CONFIG_MACE3_DECODER)$(CONFIG_MACE6_DECODER),)
--    OBJS+= mace.o
--endif
--ifeq ($(CONFIG_MSRLE_DECODER),yes)
--    OBJS+= msrle.o
--endif
--ifeq ($(CONFIG_MSVIDEO1_DECODER),yes)
--    OBJS+= msvideo1.o
--endif
--ifneq ($(CONFIG_PNG_DECODER)$(CONFIG_PNG_ENCODER),)
--    OBJS+= png.o
--endif
--ifeq ($(CONFIG_QDRAW_DECODER),yes)
--    OBJS+= qdrw.o
--endif
--ifeq ($(CONFIG_QPEG_DECODER),yes)
--    OBJS+= qpeg.o
--endif
--ifeq ($(CONFIG_QTRLE_DECODER),yes)
--    OBJS+= qtrle.o
--endif
--ifeq ($(CONFIG_RA_144_DECODER),yes)
--    OBJS+= ra144.o
--endif
--ifeq ($(CONFIG_RA_288_DECODER),yes)
--    OBJS+= ra288.o
--endif
--ifeq ($(CONFIG_ROQ_DECODER),yes)
--    OBJS+= roqvideo.o
--endif
--ifeq ($(CONFIG_RPZA_DECODER),yes)
--    OBJS+= rpza.o
--endif
--ifneq ($(CONFIG_RV10_DECODER)$(CONFIG_RV20_DECODER)$(CONFIG_RV10_ENCODER)$(CONFIG_RV20_ENCODER),)
--    OBJS+= rv10.o
--endif
--ifeq ($(CONFIG_SHORTEN_DECODER),yes)
--    OBJS+= shorten.o
--endif
--ifeq ($(CONFIG_SMC_DECODER),yes)
--    OBJS+= smc.o
--endif
--ifneq ($(CONFIG_SNOW_DECODER)$(CONFIG_SNOW_ENCODER),)
--    OBJS+= snow.o
--endif
--ifneq ($(CONFIG_SONIC_DECODER)$(CONFIG_SONIC_ENCODER)$(CONFIG_SONIC_LS_ENCODER),)
--    OBJS+= sonic.o
--endif
--ifneq ($(CONFIG_SVQ1_DECODER)$(CONFIG_SVQ1_ENCODER),)
--    OBJS+= svq1.o
--endif
--ifeq ($(CONFIG_TRUEMOTION1_DECODER),yes)
--    OBJS+= truemotion1.o
--endif
--ifeq ($(CONFIG_TSCC_DECODER),yes)
--    OBJS+= tscc.o
--endif
--ifeq ($(CONFIG_ULTI_DECODER),yes)
--    OBJS+= ulti.o
--endif
--ifneq ($(CONFIG_VC9_DECODER)$(CONFIG_WMV3_DECODER),)
--    OBJS+= vc9.o
--endif
--ifneq ($(CONFIG_VCR1_DECODER)$(CONFIG_VCR1_ENCODER),)
--    OBJS+= vcr1.o
--endif
--ifneq ($(CONFIG_VMDVIDEO_DECODER)$(CONFIG_VMDAUDIO_DECODER),)
--    OBJS+= vmdav.o
--endif
--ifeq ($(CONFIG_VORBIS_DECODER),yes)
--    OBJS+= vorbis.o
--endif
--ifneq ($(CONFIG_VP3_DECODER)$(CONFIG_THEORA_DECODER),)
--    OBJS+= vp3.o
--endif
--ifeq ($(CONFIG_VQA_DECODER),yes)
--    OBJS+= vqavideo.o
--endif
--ifneq ($(CONFIG_WMAV1_DECODER)$(CONFIG_WMAV2_DECODER),)
--    OBJS+= wmadec.o
--endif
--ifeq ($(CONFIG_WNV1_DECODER),yes)
--    OBJS+= wnv1.o
--endif
--ifeq ($(CONFIG_WS_SND1_DECODER),yes)
--    OBJS+= ws-snd1.o
--endif
--ifneq ($(CONFIG_XAN_WC3_DECODER)$(CONFIG_XAN_WC4_DECODER),)
--    OBJS+= xan.o
--endif
--ifeq ($(CONFIG_XL_DECODER),yes)
--    OBJS+= xl.o
--endif
--      
--      
--AMROBJS=
--ifeq ($(AMR_NB),yes)
--ifeq ($(AMR_NB_FIXED),yes)
--AMROBJS= amr.o
--AMREXTRALIBS+= amr/*.o
--AMRLIBS=amrlibs
--CLEANAMR=cleanamr
--else
--AMROBJS= amr.o
--OBJS+= amr_float/sp_dec.o amr_float/sp_enc.o amr_float/interf_dec.o amr_float/interf_enc.o
--CLEANAMR=cleanamrfloat
--endif
--endif
--
--ifeq ($(HAVE_PTHREADS),yes)
--OBJS+= pthread.o
--endif
--
--ifeq ($(HAVE_W32THREADS),yes)
--OBJS+= w32thread.o
--endif
--
--ifeq ($(HAVE_BEOSTHREADS),yes)
--OBJS+= beosthread.o
--endif
--
--ifeq ($(AMR_WB),yes)
--AMROBJS= amr.o
--OBJS+= amrwb_float/dec_acelp.o amrwb_float/dec_dtx.o amrwb_float/dec_gain.o \
--		amrwb_float/dec_if.o amrwb_float/dec_lpc.o amrwb_float/dec_main.o \
--		amrwb_float/dec_rom.o amrwb_float/dec_util.o amrwb_float/enc_acelp.o \
--		amrwb_float/enc_dtx.o amrwb_float/enc_gain.o amrwb_float/enc_if.o \
--		amrwb_float/enc_lpc.o amrwb_float/enc_main.o amrwb_float/enc_rom.o \
--		amrwb_float/enc_util.o amrwb_float/if_rom.o
--endif
--OBJS+= $(AMROBJS)
--CLEANAMRWB=cleanamrwbfloat
--ASM_OBJS=
--
--ifeq ($(HAVE_XVMC_ACCEL),yes)
--OBJS+= xvmcvideo.o
--endif
--
- # currently using liba52 for ac3 decoding
- ifeq ($(CONFIG_AC3),yes)
- OBJS+= a52dec.o
-@@ -244,61 +40,6 @@
- EXTRALIBS += -ldts
- endif
- 
--ifeq ($(CONFIG_FAAD),yes)
--OBJS+= faad.o
--ifeq ($(CONFIG_FAADBIN),yes)
--# no libs needed
--else
--EXTRALIBS += -lfaad
--endif
--endif
--
--ifeq ($(CONFIG_FAAC),yes)
--OBJS+= faac.o
--EXTRALIBS += -lfaac
--endif
--
--ifeq ($(CONFIG_XVID),yes)
--OBJS+= xvidff.o
--EXTRALIBS += -lxvidcore
--endif
--
--ifeq ($(CONFIG_X264),yes)
--OBJS+= x264.o
--EXTRALIBS += -lx264
--endif
--
--ifeq ($(CONFIG_PP),yes)
--ifeq ($(SHARED_PP),yes)
--EXTRALIBS += -Llibpostproc -lpostproc$(BUILDSUF)
--else
--# LIBS += libpostproc/libpostproc.a ... should be fixed
--OBJS += libpostproc/postprocess.o
--endif
--endif
--
--ifeq ($(CONFIG_MP3LAME),yes)
--OBJS += mp3lameaudio.o
--EXTRALIBS += -lmp3lame
--endif
--
--ifeq ($(CONFIG_LIBOGG),yes)
--ifeq ($(CONFIG_LIBVORBIS),yes)
--OBJS += oggvorbis.o
--EXTRALIBS += -lvorbisenc -lvorbis
--endif
--ifeq ($(CONFIG_LIBTHEORA), yes)
--OBJS += oggtheora.o
--EXTRALIBS += -ltheora
--endif
--EXTRALIBS += -logg
--endif
--
--ifeq ($(CONFIG_LIBGSM),yes)
--OBJS += libgsm.o
--EXTRALIBS += -lgsm
--endif
--
- ifeq ($(TARGET_GPROF),yes)
- CFLAGS+=-p
- LDFLAGS+=-p
-@@ -400,9 +141,6 @@
- 	$(RANLIB) $@
- 
- $(SLIB): $(OBJS)
--ifeq ($(CONFIG_PP),yes)
--	$(MAKE) -C libpostproc
--endif
- ifeq ($(CONFIG_WIN32),yes)
- 	$(CC) $(SHFLAGS) -Wl,--output-def,$(@:.dll=.def) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS)
- 	-lib /machine:i386 /def:$(@:.dll=.def)
-@@ -412,9 +150,6 @@
- 
- dsputil.o: dsputil.c dsputil.h
- 
--libpostproc/libpostproc.a:
--	$(MAKE) -C libpostproc
--
- %.o: %.c
- 	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $< 
- 
-@@ -437,7 +172,6 @@
- 	   sparc/*.o sparc/*~ \
- 	   liba52/*.o liba52/*~ \
- 	   apiexample $(TESTS)
--	$(MAKE) -C libpostproc clean
- 
- distclean: clean
- 	rm -f Makefile.bak .depend
-@@ -483,9 +217,6 @@
- 	ln -sf libavcodec-$(VERSION).so $(libdir)/libavcodec.so
- 	$(LDCONFIG) || true
- endif
--ifeq ($(CONFIG_PP),yes)
--	$(MAKE) -C libpostproc $@
--endif
- else
- install:
- endif
-diff -urN ffmpeg.orig/libavcodec/allcodecs.c ffmpeg.src/libavcodec/allcodecs.c
---- ffmpeg.orig/libavcodec/allcodecs.c	2005-09-13 19:32:01.000000000 +0200
-+++ ffmpeg.src/libavcodec/allcodecs.c	2005-11-27 16:36:00.214952856 +0100
-@@ -1,3 +1,4 @@
-+
- /*
-  * Utils for libavcodec
-  * Copyright (c) 2002 Fabrice Bellard.
-@@ -38,552 +39,22 @@
- 	return;
-     inited = 1;
- 
--    /* encoders */
--#ifdef CONFIG_ENCODERS
--#ifdef CONFIG_AC3_ENCODER
--    register_avcodec(&ac3_encoder);
--#endif //CONFIG_AC3_ENCODER
--#ifdef CONFIG_MP2_ENCODER
--    register_avcodec(&mp2_encoder);
--#endif //CONFIG_MP2_ENCODER
--#ifdef CONFIG_MP3LAME
--#ifdef CONFIG_MP3LAME_ENCODER
--    register_avcodec(&mp3lame_encoder);
--#endif //CONFIG_MP3LAME_ENCODER
--#endif
--#ifdef CONFIG_LIBVORBIS
--#ifdef CONFIG_OGGVORBIS_ENCODER
--    register_avcodec(&oggvorbis_encoder);
--#endif //CONFIG_OGGVORBIS_ENCODER
--#if (defined CONFIG_OGGVORBIS_DECODER && !defined CONFIG_VORBIS_DECODER)
--    register_avcodec(&oggvorbis_decoder);
--#endif //CONFIG_OGGVORBIS_DECODER
--#endif
--#ifdef CONFIG_LIBTHEORA
--#ifdef CONFIG_OGGTHEORA_ENCODER
--//    register_avcodec(&oggtheora_encoder);
--#endif //CONFIG_OGGTHEORA_ENCODER
--#ifdef CONFIG_OGGTHEORA_DECODER
--    register_avcodec(&oggtheora_decoder);
--#endif //CONFIG_OGGTHEORA_DECODER
--#endif
--#ifdef CONFIG_FAAC
--#ifdef CONFIG_FAAC_ENCODER
--    register_avcodec(&faac_encoder);
--#endif //CONFIG_FAAC_ENCODER
--#endif
--#ifdef CONFIG_XVID
--#ifdef CONFIG_XVID_ENCODER
--    register_avcodec(&xvid_encoder);
--#endif //CONFIG_XVID_ENCODER
--#endif
--#ifdef CONFIG_MPEG1VIDEO_ENCODER
--    register_avcodec(&mpeg1video_encoder);
--#endif //CONFIG_MPEG1VIDEO_ENCODER
--#ifdef CONFIG_H264_ENCODER
--//    register_avcodec(&h264_encoder);
--#endif //CONFIG_H264_ENCODER
--#ifdef CONFIG_MPEG2VIDEO_ENCODER
-     register_avcodec(&mpeg2video_encoder);
--#endif //CONFIG_MPEG2VIDEO_ENCODER
--#ifdef CONFIG_H261_ENCODER
--    register_avcodec(&h261_encoder);
--#endif //CONFIG_H261_ENCODER
--#ifdef CONFIG_H263_ENCODER
--    register_avcodec(&h263_encoder);
--#endif //CONFIG_H263_ENCODER
--#ifdef CONFIG_H263P_ENCODER
--    register_avcodec(&h263p_encoder);
--#endif //CONFIG_H263P_ENCODER
--#ifdef CONFIG_FLV_ENCODER
--    register_avcodec(&flv_encoder);
--#endif //CONFIG_FLV_ENCODER
--#ifdef CONFIG_RV10_ENCODER
--    register_avcodec(&rv10_encoder);
--#endif //CONFIG_RV10_ENCODER
--#ifdef CONFIG_RV20_ENCODER
--    register_avcodec(&rv20_encoder);
--#endif //CONFIG_RV20_ENCODER
--#ifdef CONFIG_MPEG4_ENCODER
--    register_avcodec(&mpeg4_encoder);
--#endif //CONFIG_MPEG4_ENCODER
--#ifdef CONFIG_MSMPEG4V1_ENCODER
--    register_avcodec(&msmpeg4v1_encoder);
--#endif //CONFIG_MSMPEG4V1_ENCODER
--#ifdef CONFIG_MSMPEG4V2_ENCODER
--    register_avcodec(&msmpeg4v2_encoder);
--#endif //CONFIG_MSMPEG4V2_ENCODER
--#ifdef CONFIG_MSMPEG4V3_ENCODER
--    register_avcodec(&msmpeg4v3_encoder);
--#endif //CONFIG_MSMPEG4V3_ENCODER
--#ifdef CONFIG_WMV1_ENCODER
--    register_avcodec(&wmv1_encoder);
--#endif //CONFIG_WMV1_ENCODER
--#ifdef CONFIG_WMV2_ENCODER
--    register_avcodec(&wmv2_encoder);
--#endif //CONFIG_WMV2_ENCODER
--#ifdef CONFIG_SVQ1_ENCODER
--    register_avcodec(&svq1_encoder);
--#endif //CONFIG_SVQ1_ENCODER
--#ifdef CONFIG_MJPEG_ENCODER
--    register_avcodec(&mjpeg_encoder);
--#endif //CONFIG_MJPEG_ENCODER
--#ifdef CONFIG_LJPEG_ENCODER
--    register_avcodec(&ljpeg_encoder);
--#endif //CONFIG_LJPEG_ENCODER
--#ifdef CONFIG_ZLIB
--#ifdef CONFIG_PNG_ENCODER
--    register_avcodec(&png_encoder);
--#endif //CONFIG_PNG_ENCODER
--#endif
--#ifdef CONFIG_PPM_ENCODER
--    register_avcodec(&ppm_encoder);
--#endif //CONFIG_PPM_ENCODER
--#ifdef CONFIG_PGM_ENCODER
--    register_avcodec(&pgm_encoder);
--#endif //CONFIG_PGM_ENCODER
--#ifdef CONFIG_PGMYUV_ENCODER
--    register_avcodec(&pgmyuv_encoder);
--#endif //CONFIG_PGMYUV_ENCODER
--#ifdef CONFIG_PBM_ENCODER
--    register_avcodec(&pbm_encoder);
--#endif //CONFIG_PBM_ENCODER
--#ifdef CONFIG_PAM_ENCODER
--    register_avcodec(&pam_encoder);
--#endif //CONFIG_PAM_ENCODER
--#ifdef CONFIG_HUFFYUV_ENCODER
--    register_avcodec(&huffyuv_encoder);
--#endif //CONFIG_HUFFYUV_ENCODER
--#ifdef CONFIG_FFVHUFF_ENCODER
--    register_avcodec(&ffvhuff_encoder);
--#endif //CONFIG_FFVHUFF_ENCODER
--#ifdef CONFIG_ASV1_ENCODER
--    register_avcodec(&asv1_encoder);
--#endif //CONFIG_ASV1_ENCODER
--#ifdef CONFIG_ASV2_ENCODER
--    register_avcodec(&asv2_encoder);
--#endif //CONFIG_ASV2_ENCODER
--#ifdef CONFIG_FFV1_ENCODER
--    register_avcodec(&ffv1_encoder);
--#endif //CONFIG_FFV1_ENCODER
--#ifdef CONFIG_SNOW_ENCODER
--    register_avcodec(&snow_encoder);
--#endif //CONFIG_SNOW_ENCODER
--#ifdef CONFIG_ZLIB_ENCODER
--    register_avcodec(&zlib_encoder);
--#endif //CONFIG_ZLIB_ENCODER
--#ifdef CONFIG_DVVIDEO_ENCODER
--    register_avcodec(&dvvideo_encoder);
--#endif //CONFIG_DVVIDEO_ENCODER
--#ifdef CONFIG_SONIC_ENCODER
--    register_avcodec(&sonic_encoder);
--#endif //CONFIG_SONIC_ENCODER
--#ifdef CONFIG_SONIC_LS_ENCODER
--    register_avcodec(&sonic_ls_encoder);
--#endif //CONFIG_SONIC_LS_ENCODER
--#ifdef CONFIG_X264
--#ifdef CONFIG_X264_ENCODER
--    register_avcodec(&x264_encoder);
--#endif //CONFIG_X264_ENCODER
--#endif
--#ifdef CONFIG_LIBGSM
--    register_avcodec(&libgsm_encoder);
--#endif //CONFIG_LIBGSM
--#endif /* CONFIG_ENCODERS */
--#ifdef CONFIG_RAWVIDEO_ENCODER
--    register_avcodec(&rawvideo_encoder);
--#endif //CONFIG_RAWVIDEO_ENCODER
--#ifdef CONFIG_RAWVIDEO_DECODER
--    register_avcodec(&rawvideo_decoder);
--#endif //CONFIG_RAWVIDEO_DECODER
--
--    /* decoders */
--#ifdef CONFIG_DECODERS
--#ifdef CONFIG_H263_DECODER
--    register_avcodec(&h263_decoder);
--#endif //CONFIG_H263_DECODER
--#ifdef CONFIG_H261_DECODER
--    register_avcodec(&h261_decoder);
--#endif //CONFIG_H261_DECODER
--#ifdef CONFIG_MPEG4_DECODER
--    register_avcodec(&mpeg4_decoder);
--#endif //CONFIG_MPEG4_DECODER
--#ifdef CONFIG_MSMPEG4V1_DECODER
--    register_avcodec(&msmpeg4v1_decoder);
--#endif //CONFIG_MSMPEG4V1_DECODER
--#ifdef CONFIG_MSMPEG4V2_DECODER
--    register_avcodec(&msmpeg4v2_decoder);
--#endif //CONFIG_MSMPEG4V2_DECODER
--#ifdef CONFIG_MSMPEG4V3_DECODER
--    register_avcodec(&msmpeg4v3_decoder);
--#endif //CONFIG_MSMPEG4V3_DECODER
--#ifdef CONFIG_WMV1_DECODER
--    register_avcodec(&wmv1_decoder);
--#endif //CONFIG_WMV1_DECODER
--#ifdef CONFIG_WMV2_DECODER
--    register_avcodec(&wmv2_decoder);
--#endif //CONFIG_WMV2_DECODER
--#ifdef CONFIG_VC9_DECODER
--    register_avcodec(&vc9_decoder);
--#endif //CONFIG_VC9_DECODER
--#ifdef CONFIG_WMV3_DECODER
--    register_avcodec(&wmv3_decoder);
--#endif //CONFIG_WMV3_DECODER
--#ifdef CONFIG_H263I_DECODER
--    register_avcodec(&h263i_decoder);
--#endif //CONFIG_H263I_DECODER
--#ifdef CONFIG_FLV_DECODER
--    register_avcodec(&flv_decoder);
--#endif //CONFIG_FLV_DECODER
--#ifdef CONFIG_RV10_DECODER
--    register_avcodec(&rv10_decoder);
--#endif //CONFIG_RV10_DECODER
--#ifdef CONFIG_RV20_DECODER
--    register_avcodec(&rv20_decoder);
--#endif //CONFIG_RV20_DECODER
--#ifdef CONFIG_SVQ1_DECODER
--    register_avcodec(&svq1_decoder);
--#endif //CONFIG_SVQ1_DECODER
--#ifdef CONFIG_SVQ3_DECODER
--    register_avcodec(&svq3_decoder);
--#endif //CONFIG_SVQ3_DECODER
--#ifdef CONFIG_WMAV1_DECODER
--    register_avcodec(&wmav1_decoder);
--#endif //CONFIG_WMAV1_DECODER
--#ifdef CONFIG_WMAV2_DECODER
--    register_avcodec(&wmav2_decoder);
--#endif //CONFIG_WMAV2_DECODER
--#ifdef CONFIG_INDEO2_DECODER
--    register_avcodec(&indeo2_decoder);
--#endif //CONFIG_INDEO2_DECODER
--#ifdef CONFIG_INDEO3_DECODER
--    register_avcodec(&indeo3_decoder);
--#endif //CONFIG_INDEO3_DECODER
--#ifdef CONFIG_TSCC_DECODER
--    register_avcodec(&tscc_decoder);
--#endif //CONFIG_TSCC_DECODER
--#ifdef CONFIG_ULTI_DECODER
--    register_avcodec(&ulti_decoder);
--#endif //CONFIG_ULTI_DECODER
--#ifdef CONFIG_QDRAW_DECODER
--    register_avcodec(&qdraw_decoder);
--#endif //CONFIG_QDRAW_DECODER
--#ifdef CONFIG_XL_DECODER
--    register_avcodec(&xl_decoder);
--#endif //CONFIG_XL_DECODER
--#ifdef CONFIG_QPEG_DECODER
--    register_avcodec(&qpeg_decoder);
--#endif //CONFIG_QPEG_DECODER
--#ifdef CONFIG_LOCO_DECODER
--    register_avcodec(&loco_decoder);
--#endif //CONFIG_LOCO_DECODER
--#ifdef CONFIG_WNV1_DECODER
--    register_avcodec(&wnv1_decoder);
--#endif //CONFIG_WNV1_DECODER
--#ifdef CONFIG_AASC_DECODER
--    register_avcodec(&aasc_decoder);
--#endif //CONFIG_AASC_DECODER
--#ifdef CONFIG_FRAPS_DECODER
--    register_avcodec(&fraps_decoder);
--#endif //CONFIG_FRAPS_DECODER
--#ifdef CONFIG_FAAD
--#ifdef CONFIG_AAC_DECODER
--    register_avcodec(&aac_decoder);
--#endif //CONFIG_AAC_DECODER
--#ifdef CONFIG_MPEG4AAC_DECODER
--    register_avcodec(&mpeg4aac_decoder);
--#endif //CONFIG_MPEG4AAC_DECODER
--#endif
--#ifdef CONFIG_MPEG1VIDEO_DECODER
--    register_avcodec(&mpeg1video_decoder);
--#endif //CONFIG_MPEG1VIDEO_DECODER
--#ifdef CONFIG_MPEG2VIDEO_DECODER
-     register_avcodec(&mpeg2video_decoder);
--#endif //CONFIG_MPEG2VIDEO_DECODER
--#ifdef CONFIG_MPEGVIDEO_DECODER
--    register_avcodec(&mpegvideo_decoder);
--#endif //CONFIG_MPEGVIDEO_DECODER
--#ifdef HAVE_XVMC
--#ifdef CONFIG_MPEG_XVMC_DECODER
--    register_avcodec(&mpeg_xvmc_decoder);
--#endif //CONFIG_MPEG_XVMC_DECODER
--#endif
--#ifdef CONFIG_DVVIDEO_DECODER
--    register_avcodec(&dvvideo_decoder);
--#endif //CONFIG_DVVIDEO_DECODER
--#ifdef CONFIG_MJPEG_DECODER
--    register_avcodec(&mjpeg_decoder);
--#endif //CONFIG_MJPEG_DECODER
--#ifdef CONFIG_MJPEGB_DECODER
--    register_avcodec(&mjpegb_decoder);
--#endif //CONFIG_MJPEGB_DECODER
--#ifdef CONFIG_SP5X_DECODER
--    register_avcodec(&sp5x_decoder);
--#endif //CONFIG_SP5X_DECODER
--#ifdef CONFIG_ZLIB
--#ifdef CONFIG_PNG_DECODER
--    register_avcodec(&png_decoder);
--#endif //CONFIG_PNG_DECODER
--#endif
--#ifdef CONFIG_MP2_DECODER
-+    register_avcodec(&mp2_encoder);
-     register_avcodec(&mp2_decoder);
--#endif //CONFIG_MP2_DECODER
--#ifdef CONFIG_MP3_DECODER
-     register_avcodec(&mp3_decoder);
--#endif //CONFIG_MP3_DECODER
--#ifdef CONFIG_MP3ADU_DECODER
--    register_avcodec(&mp3adu_decoder);
--#endif //CONFIG_MP3ADU_DECODER
--#ifdef CONFIG_MP3ON4_DECODER
--    register_avcodec(&mp3on4_decoder);
--#endif //CONFIG_MP3ON4_DECODER
--#ifdef CONFIG_MACE3_DECODER
--    register_avcodec(&mace3_decoder);
--#endif //CONFIG_MACE3_DECODER
--#ifdef CONFIG_MACE6_DECODER
--    register_avcodec(&mace6_decoder);
--#endif //CONFIG_MACE6_DECODER
--#ifdef CONFIG_HUFFYUV_DECODER
--    register_avcodec(&huffyuv_decoder);
--#endif //CONFIG_HUFFYUV_DECODER
--#ifdef CONFIG_FFVHUFF_DECODER
--    register_avcodec(&ffvhuff_decoder);
--#endif //CONFIG_FFVHUFF_DECODER
--#ifdef CONFIG_FFV1_DECODER
--    register_avcodec(&ffv1_decoder);
--#endif //CONFIG_FFV1_DECODER
--#ifdef CONFIG_SNOW_DECODER
--    register_avcodec(&snow_decoder);
--#endif //CONFIG_SNOW_DECODER
--#ifdef CONFIG_CYUV_DECODER
--    register_avcodec(&cyuv_decoder);
--#endif //CONFIG_CYUV_DECODER
--#ifdef CONFIG_H264_DECODER
--    register_avcodec(&h264_decoder);
--#endif //CONFIG_H264_DECODER
--#ifdef CONFIG_VP3_DECODER
--    register_avcodec(&vp3_decoder);
--#endif //CONFIG_VP3_DECODER
--#if (defined CONFIG_THEORA_DECODER && !defined CONFIG_LIBTHEORA)
--    register_avcodec(&theora_decoder);
--#endif //CONFIG_THEORA_DECODER
--#ifdef CONFIG_ASV1_DECODER
--    register_avcodec(&asv1_decoder);
--#endif //CONFIG_ASV1_DECODER
--#ifdef CONFIG_ASV2_DECODER
--    register_avcodec(&asv2_decoder);
--#endif //CONFIG_ASV2_DECODER
--#ifdef CONFIG_VCR1_DECODER
--    register_avcodec(&vcr1_decoder);
--#endif //CONFIG_VCR1_DECODER
--#ifdef CONFIG_CLJR_DECODER
--    register_avcodec(&cljr_decoder);
--#endif //CONFIG_CLJR_DECODER
--#ifdef CONFIG_FOURXM_DECODER
--    register_avcodec(&fourxm_decoder);
--#endif //CONFIG_FOURXM_DECODER
--#ifdef CONFIG_MDEC_DECODER
--    register_avcodec(&mdec_decoder);
--#endif //CONFIG_MDEC_DECODER
--#ifdef CONFIG_ROQ_DECODER
--    register_avcodec(&roq_decoder);
--#endif //CONFIG_ROQ_DECODER
--#ifdef CONFIG_INTERPLAY_VIDEO_DECODER
--    register_avcodec(&interplay_video_decoder);
--#endif //CONFIG_INTERPLAY_VIDEO_DECODER
--#ifdef CONFIG_XAN_WC3_DECODER
--    register_avcodec(&xan_wc3_decoder);
--#endif //CONFIG_XAN_WC3_DECODER
--#ifdef CONFIG_RPZA_DECODER
--    register_avcodec(&rpza_decoder);
--#endif //CONFIG_RPZA_DECODER
--#ifdef CONFIG_CINEPAK_DECODER
--    register_avcodec(&cinepak_decoder);
--#endif //CONFIG_CINEPAK_DECODER
--#ifdef CONFIG_MSRLE_DECODER
--    register_avcodec(&msrle_decoder);
--#endif //CONFIG_MSRLE_DECODER
--#ifdef CONFIG_MSVIDEO1_DECODER
--    register_avcodec(&msvideo1_decoder);
--#endif //CONFIG_MSVIDEO1_DECODER
--#ifdef CONFIG_VQA_DECODER
--    register_avcodec(&vqa_decoder);
--#endif //CONFIG_VQA_DECODER
--#ifdef CONFIG_IDCIN_DECODER
--    register_avcodec(&idcin_decoder);
--#endif //CONFIG_IDCIN_DECODER
--#ifdef CONFIG_EIGHTBPS_DECODER
--    register_avcodec(&eightbps_decoder);
--#endif //CONFIG_EIGHTBPS_DECODER
--#ifdef CONFIG_SMC_DECODER
--    register_avcodec(&smc_decoder);
--#endif //CONFIG_SMC_DECODER
--#ifdef CONFIG_FLIC_DECODER
--    register_avcodec(&flic_decoder);
--#endif //CONFIG_FLIC_DECODER
--#ifdef CONFIG_TRUEMOTION1_DECODER
--    register_avcodec(&truemotion1_decoder);
--#endif //CONFIG_TRUEMOTION1_DECODER
--#ifdef CONFIG_VMDVIDEO_DECODER
--    register_avcodec(&vmdvideo_decoder);
--#endif //CONFIG_VMDVIDEO_DECODER
--#ifdef CONFIG_VMDAUDIO_DECODER
--    register_avcodec(&vmdaudio_decoder);
--#endif //CONFIG_VMDAUDIO_DECODER
--#ifdef CONFIG_MSZH_DECODER
--    register_avcodec(&mszh_decoder);
--#endif //CONFIG_MSZH_DECODER
--#ifdef CONFIG_ZLIB_DECODER
--    register_avcodec(&zlib_decoder);
--#endif //CONFIG_ZLIB_DECODER
--#ifdef CONFIG_SONIC_DECODER
--    register_avcodec(&sonic_decoder);
--#endif //CONFIG_SONIC_DECODER
-+
- #ifdef CONFIG_AC3
--#ifdef CONFIG_AC3_DECODER
-+    register_avcodec(&ac3_encoder);
-     register_avcodec(&ac3_decoder);
--#endif //CONFIG_AC3_DECODER
- #endif
-+
- #ifdef CONFIG_DTS
--#ifdef CONFIG_DTS_DECODER
-     register_avcodec(&dts_decoder);
--#endif //CONFIG_DTS_DECODER
- #endif
--#ifdef CONFIG_RA_144_DECODER
--    register_avcodec(&ra_144_decoder);
--#endif //CONFIG_RA_144_DECODER
--#ifdef CONFIG_RA_288_DECODER
--    register_avcodec(&ra_288_decoder);
--#endif //CONFIG_RA_288_DECODER
--#ifdef CONFIG_ROQ_DPCM_DECODER
--    register_avcodec(&roq_dpcm_decoder);
--#endif //CONFIG_ROQ_DPCM_DECODER
--#ifdef CONFIG_INTERPLAY_DPCM_DECODER
--    register_avcodec(&interplay_dpcm_decoder);
--#endif //CONFIG_INTERPLAY_DPCM_DECODER
--#ifdef CONFIG_XAN_DPCM_DECODER
--    register_avcodec(&xan_dpcm_decoder);
--#endif //CONFIG_XAN_DPCM_DECODER
--#ifdef CONFIG_SOL_DPCM_DECODER
--    register_avcodec(&sol_dpcm_decoder);
--#endif //CONFIG_SOL_DPCM_DECODER
--#ifdef CONFIG_QTRLE_DECODER
--    register_avcodec(&qtrle_decoder);
--#endif //CONFIG_QTRLE_DECODER
--#ifdef CONFIG_FLAC_DECODER
--    register_avcodec(&flac_decoder);
--#endif //CONFIG_FLAC_DECODER
--#ifdef CONFIG_SHORTEN_DECODER
--    register_avcodec(&shorten_decoder);
--#endif //CONFIG_SHORTEN_DECODER
--#ifdef CONFIG_ALAC_DECODER
--    register_avcodec(&alac_decoder);
--#endif //CONFIG_ALAC_DECODER
--#ifdef CONFIG_WS_SND1_DECODER
--    register_avcodec(&ws_snd1_decoder);
--#endif //CONFIG_WS_SND1_DECODER
--#ifdef CONFIG_VORBIS_DECODER
--    register_avcodec(&vorbis_decoder);
--#endif
--#ifdef CONFIG_LIBGSM
--    register_avcodec(&libgsm_decoder);
--#endif //CONFIG_LIBGSM
--#endif /* CONFIG_DECODERS */
--
--#ifdef AMR_NB
--#ifdef CONFIG_AMR_NB_DECODER
--    register_avcodec(&amr_nb_decoder);
--#endif //CONFIG_AMR_NB_DECODER
--#ifdef CONFIG_ENCODERS
--#ifdef CONFIG_AMR_NB_ENCODER
--    register_avcodec(&amr_nb_encoder);
--#endif //CONFIG_AMR_NB_ENCODER
--#endif //CONFIG_ENCODERS
--#endif /* AMR_NB */
--
--#ifdef AMR_WB
--#ifdef CONFIG_AMR_WB_DECODER
--    register_avcodec(&amr_wb_decoder);
--#endif //CONFIG_AMR_WB_DECODER
--#ifdef CONFIG_ENCODERS
--#ifdef CONFIG_AMR_WB_ENCODER
--    register_avcodec(&amr_wb_encoder);
--#endif //CONFIG_AMR_WB_ENCODER
--#endif //CONFIG_ENCODERS
--#endif /* AMR_WB */
--
--    /* pcm codecs */
--
--#ifdef CONFIG_ENCODERS
--#define PCM_CODEC(id, name) \
--    register_avcodec(& name ## _encoder); \
--    register_avcodec(& name ## _decoder); \
--
--#else
--#define PCM_CODEC(id, name) \
--    register_avcodec(& name ## _decoder);
--#endif
--
--PCM_CODEC(CODEC_ID_PCM_S32LE, pcm_s32le);
--PCM_CODEC(CODEC_ID_PCM_S32BE, pcm_s32be);
--PCM_CODEC(CODEC_ID_PCM_U32LE, pcm_u32le);
--PCM_CODEC(CODEC_ID_PCM_U32BE, pcm_u32be);
--PCM_CODEC(CODEC_ID_PCM_S24LE, pcm_s24le);
--PCM_CODEC(CODEC_ID_PCM_S24BE, pcm_s24be);
--PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le);
--PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be);
--PCM_CODEC(CODEC_ID_PCM_S24DAUD, pcm_s24daud);
--PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
--PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
--PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
--PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
--PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
--PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
--PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
--PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
--
--    /* adpcm codecs */
--PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
--PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
--PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
--PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
--PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
--PCM_CODEC(CODEC_ID_ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg);
--PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
--PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
--PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
--PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
--PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
--PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
--PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
--PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
--PCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);
--
--#undef PCM_CODEC
--
--    /* subtitles */ 
--    register_avcodec(&dvdsub_decoder);
--    register_avcodec(&dvbsub_encoder);
--    register_avcodec(&dvbsub_decoder);
--
--    /* parsers */ 
--    av_register_codec_parser(&mpegvideo_parser);
--    av_register_codec_parser(&mpeg4video_parser);
--#if defined(CONFIG_H261_DECODER) || defined(CONFIG_H261_ENCODER)
--    av_register_codec_parser(&h261_parser);
--#endif
--    av_register_codec_parser(&h263_parser);
--#ifdef CONFIG_H264_DECODER
--    av_register_codec_parser(&h264_parser);
--#endif
--    av_register_codec_parser(&mjpeg_parser);
--    av_register_codec_parser(&pnm_parser);
--
-+    
-     av_register_codec_parser(&mpegaudio_parser);
--#ifdef CONFIG_AC3
--    av_register_codec_parser(&ac3_parser);
--#endif
--    av_register_codec_parser(&dvdsub_parser);
--    av_register_codec_parser(&dvbsub_parser);
-+//     av_register_codec_parser(&ac3_parser);
- }
- 
-diff -urN ffmpeg.orig/libavcodec/mpegvideo.c ffmpeg.src/libavcodec/mpegvideo.c
---- ffmpeg.orig/libavcodec/mpegvideo.c	2005-09-13 19:32:02.000000000 +0200
-+++ ffmpeg.src/libavcodec/mpegvideo.c	2005-11-27 16:34:24.175553064 +0100
-@@ -1103,145 +1103,145 @@
-     s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
- 
-     switch(avctx->codec->id) {
--    case CODEC_ID_MPEG1VIDEO:
--        s->out_format = FMT_MPEG1;
--        s->low_delay= 0; //s->max_b_frames ? 0 : 1;
--        avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
--        break;
-+//     case CODEC_ID_MPEG1VIDEO:
-+//         s->out_format = FMT_MPEG1;
-+//         s->low_delay= 0; //s->max_b_frames ? 0 : 1;
-+//         avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
-+//         break;
-     case CODEC_ID_MPEG2VIDEO:
-         s->out_format = FMT_MPEG1;
-         s->low_delay= 0; //s->max_b_frames ? 0 : 1;
-         avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
-         s->rtp_mode= 1;
-         break;
--    case CODEC_ID_LJPEG:
--    case CODEC_ID_MJPEG:
--        s->out_format = FMT_MJPEG;
--        s->intra_only = 1; /* force intra only for jpeg */
--        s->mjpeg_write_tables = 1; /* write all tables */
--	s->mjpeg_data_only_frames = 0; /* write all the needed headers */
--        s->mjpeg_vsample[0] = 1<<chroma_v_shift;
--        s->mjpeg_vsample[1] = 1;
--        s->mjpeg_vsample[2] = 1; 
--        s->mjpeg_hsample[0] = 1<<chroma_h_shift;
--        s->mjpeg_hsample[1] = 1; 
--        s->mjpeg_hsample[2] = 1; 
--        if (mjpeg_init(s) < 0)
--            return -1;
--        avctx->delay=0;
--        s->low_delay=1;
--        break;
--    case CODEC_ID_H261:
--        s->out_format = FMT_H261;
--        avctx->delay=0;
--        s->low_delay=1;
--        break;
--    case CODEC_ID_H263:
--        if (h263_get_picture_format(s->width, s->height) == 7) {
--            av_log(avctx, AV_LOG_INFO, "Input picture size isn't suitable for h263 codec! try h263+\n");
--            return -1;
--        }
--        s->out_format = FMT_H263;
--	s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
--        avctx->delay=0;
--        s->low_delay=1;
--        break;
--    case CODEC_ID_H263P:
--        s->out_format = FMT_H263;
--        s->h263_plus = 1;
--	/* Fx */
--        s->umvplus = (avctx->flags & CODEC_FLAG_H263P_UMV) ? 1:0;
--	s->h263_aic= (avctx->flags & CODEC_FLAG_H263P_AIC) ? 1:0;
--	s->modified_quant= s->h263_aic;
--	s->alt_inter_vlc= (avctx->flags & CODEC_FLAG_H263P_AIV) ? 1:0;
--	s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
--	s->loop_filter= (avctx->flags & CODEC_FLAG_LOOP_FILTER) ? 1:0;
--	s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus;
--        s->h263_slice_structured= (s->flags & CODEC_FLAG_H263P_SLICE_STRUCT) ? 1:0;
--
--	/* /Fx */
--        /* These are just to be sure */
--        avctx->delay=0;
--        s->low_delay=1;
--        break;
--    case CODEC_ID_FLV1:
--        s->out_format = FMT_H263;
--        s->h263_flv = 2; /* format = 1; 11-bit codes */
--        s->unrestricted_mv = 1;
--        s->rtp_mode=0; /* don't allow GOB */
--        avctx->delay=0;
--        s->low_delay=1;
--        break;
--    case CODEC_ID_RV10:
--        s->out_format = FMT_H263;
--        avctx->delay=0;
--        s->low_delay=1;
--        break;
--    case CODEC_ID_RV20:
--        s->out_format = FMT_H263;
--        avctx->delay=0;
--        s->low_delay=1;
--        s->modified_quant=1;
--        s->h263_aic=1;
--        s->h263_plus=1;
--        s->loop_filter=1;
--        s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus;
--        break;
--    case CODEC_ID_MPEG4:
--        s->out_format = FMT_H263;
--        s->h263_pred = 1;
--        s->unrestricted_mv = 1;
--        s->low_delay= s->max_b_frames ? 0 : 1;
--        avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
--        break;
--    case CODEC_ID_MSMPEG4V1:
--        s->out_format = FMT_H263;
--        s->h263_msmpeg4 = 1;
--        s->h263_pred = 1;
--        s->unrestricted_mv = 1;
--        s->msmpeg4_version= 1;
--        avctx->delay=0;
--        s->low_delay=1;
--        break;
--    case CODEC_ID_MSMPEG4V2:
--        s->out_format = FMT_H263;
--        s->h263_msmpeg4 = 1;
--        s->h263_pred = 1;
--        s->unrestricted_mv = 1;
--        s->msmpeg4_version= 2;
--        avctx->delay=0;
--        s->low_delay=1;
--        break;
--    case CODEC_ID_MSMPEG4V3:
--        s->out_format = FMT_H263;
--        s->h263_msmpeg4 = 1;
--        s->h263_pred = 1;
--        s->unrestricted_mv = 1;
--        s->msmpeg4_version= 3;
--        s->flipflop_rounding=1;
--        avctx->delay=0;
--        s->low_delay=1;
--        break;
--    case CODEC_ID_WMV1:
--        s->out_format = FMT_H263;
--        s->h263_msmpeg4 = 1;
--        s->h263_pred = 1;
--        s->unrestricted_mv = 1;
--        s->msmpeg4_version= 4;
--        s->flipflop_rounding=1;
--        avctx->delay=0;
--        s->low_delay=1;
--        break;
--    case CODEC_ID_WMV2:
--        s->out_format = FMT_H263;
--        s->h263_msmpeg4 = 1;
--        s->h263_pred = 1;
--        s->unrestricted_mv = 1;
--        s->msmpeg4_version= 5;
--        s->flipflop_rounding=1;
--        avctx->delay=0;
--        s->low_delay=1;
--        break;
-+//     case CODEC_ID_LJPEG:
-+//     case CODEC_ID_MJPEG:
-+//         s->out_format = FMT_MJPEG;
-+//         s->intra_only = 1; /* force intra only for jpeg */
-+//         s->mjpeg_write_tables = 1; /* write all tables */
-+// 	s->mjpeg_data_only_frames = 0; /* write all the needed headers */
-+//         s->mjpeg_vsample[0] = 1<<chroma_v_shift;
-+//         s->mjpeg_vsample[1] = 1;
-+//         s->mjpeg_vsample[2] = 1; 
-+//         s->mjpeg_hsample[0] = 1<<chroma_h_shift;
-+//         s->mjpeg_hsample[1] = 1; 
-+//         s->mjpeg_hsample[2] = 1; 
-+//         if (mjpeg_init(s) < 0)
-+//             return -1;
-+//         avctx->delay=0;
-+//         s->low_delay=1;
-+//         break;
-+//     case CODEC_ID_H261:
-+//         s->out_format = FMT_H261;
-+//         avctx->delay=0;
-+//         s->low_delay=1;
-+//         break;
-+//     case CODEC_ID_H263:
-+//         if (h263_get_picture_format(s->width, s->height) == 7) {
-+//             av_log(avctx, AV_LOG_INFO, "Input picture size isn't suitable for h263 codec! try h263+\n");
-+//             return -1;
-+//         }
-+//         s->out_format = FMT_H263;
-+// 	s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
-+//         avctx->delay=0;
-+//         s->low_delay=1;
-+//         break;
-+//     case CODEC_ID_H263P:
-+//         s->out_format = FMT_H263;
-+//         s->h263_plus = 1;
-+// 	/* Fx */
-+//         s->umvplus = (avctx->flags & CODEC_FLAG_H263P_UMV) ? 1:0;
-+// 	s->h263_aic= (avctx->flags & CODEC_FLAG_H263P_AIC) ? 1:0;
-+// 	s->modified_quant= s->h263_aic;
-+// 	s->alt_inter_vlc= (avctx->flags & CODEC_FLAG_H263P_AIV) ? 1:0;
-+// 	s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
-+// 	s->loop_filter= (avctx->flags & CODEC_FLAG_LOOP_FILTER) ? 1:0;
-+// 	s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus;
-+//         s->h263_slice_structured= (s->flags & CODEC_FLAG_H263P_SLICE_STRUCT) ? 1:0;
-+// 
-+// 	/* /Fx */
-+//         /* These are just to be sure */
-+//         avctx->delay=0;
-+//         s->low_delay=1;
-+//         break;
-+//     case CODEC_ID_FLV1:
-+//         s->out_format = FMT_H263;
-+//         s->h263_flv = 2; /* format = 1; 11-bit codes */
-+//         s->unrestricted_mv = 1;
-+//         s->rtp_mode=0; /* don't allow GOB */
-+//         avctx->delay=0;
-+//         s->low_delay=1;
-+//         break;
-+//     case CODEC_ID_RV10:
-+//         s->out_format = FMT_H263;
-+//         avctx->delay=0;
-+//         s->low_delay=1;
-+//         break;
-+//     case CODEC_ID_RV20:
-+//         s->out_format = FMT_H263;
-+//         avctx->delay=0;
-+//         s->low_delay=1;
-+//         s->modified_quant=1;
-+//         s->h263_aic=1;
-+//         s->h263_plus=1;
-+//         s->loop_filter=1;
-+//         s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus;
-+//         break;
-+//     case CODEC_ID_MPEG4:
-+//         s->out_format = FMT_H263;
-+//         s->h263_pred = 1;
-+//         s->unrestricted_mv = 1;
-+//         s->low_delay= s->max_b_frames ? 0 : 1;
-+//         avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
-+//         break;
-+//     case CODEC_ID_MSMPEG4V1:
-+//         s->out_format = FMT_H263;
-+//         s->h263_msmpeg4 = 1;
-+//         s->h263_pred = 1;
-+//         s->unrestricted_mv = 1;
-+//         s->msmpeg4_version= 1;
-+//         avctx->delay=0;
-+//         s->low_delay=1;
-+//         break;
-+//     case CODEC_ID_MSMPEG4V2:
-+//         s->out_format = FMT_H263;
-+//         s->h263_msmpeg4 = 1;
-+//         s->h263_pred = 1;
-+//         s->unrestricted_mv = 1;
-+//         s->msmpeg4_version= 2;
-+//         avctx->delay=0;
-+//         s->low_delay=1;
-+//         break;
-+//     case CODEC_ID_MSMPEG4V3:
-+//         s->out_format = FMT_H263;
-+//         s->h263_msmpeg4 = 1;
-+//         s->h263_pred = 1;
-+//         s->unrestricted_mv = 1;
-+//         s->msmpeg4_version= 3;
-+//         s->flipflop_rounding=1;
-+//         avctx->delay=0;
-+//         s->low_delay=1;
-+//         break;
-+//     case CODEC_ID_WMV1:
-+//         s->out_format = FMT_H263;
-+//         s->h263_msmpeg4 = 1;
-+//         s->h263_pred = 1;
-+//         s->unrestricted_mv = 1;
-+//         s->msmpeg4_version= 4;
-+//         s->flipflop_rounding=1;
-+//         avctx->delay=0;
-+//         s->low_delay=1;
-+//         break;
-+//     case CODEC_ID_WMV2:
-+//         s->out_format = FMT_H263;
-+//         s->h263_msmpeg4 = 1;
-+//         s->h263_pred = 1;
-+//         s->unrestricted_mv = 1;
-+//         s->msmpeg4_version= 5;
-+//         s->flipflop_rounding=1;
-+//         avctx->delay=0;
-+//         s->low_delay=1;
-+//         break;
-     default:
-         return -1;
-     }
-@@ -1277,13 +1277,13 @@
-     /* init q matrix */
-     for(i=0;i<64;i++) {
-         int j= s->dsp.idct_permutation[i];
--        if(s->codec_id==CODEC_ID_MPEG4 && s->mpeg_quant){
--            s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i];
--            s->inter_matrix[j] = ff_mpeg4_default_non_intra_matrix[i];
--        }else if(s->out_format == FMT_H263 || s->out_format == FMT_H261){
--            s->intra_matrix[j] =
--            s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];
--        }else
-+//         if(s->codec_id==CODEC_ID_MPEG4 && s->mpeg_quant){
-+//             s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i];
-+//             s->inter_matrix[j] = ff_mpeg4_default_non_intra_matrix[i];
-+//         }else if(s->out_format == FMT_H263 || s->out_format == FMT_H261){
-+//             s->intra_matrix[j] =
-+//             s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];
-+//         }else
-         { /* mpeg1/2 */
-             s->intra_matrix[j] = ff_mpeg1_default_intra_matrix[i];
-             s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];
-@@ -1553,12 +1553,12 @@
-     if(s->mpeg_quant || s->codec_id == CODEC_ID_MPEG2VIDEO){
-         s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
-         s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
--    }else if(s->out_format == FMT_H263 || s->out_format == FMT_H261){
--        s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
--        s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
--    }else{
--        s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
--        s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
-+//     }else if(s->out_format == FMT_H263 || s->out_format == FMT_H261){
-+//         s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
-+//         s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
-+//     }else{
-+//         s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
-+//         s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
-     }
- 
-     if(s->dct_error_sum){
-@@ -2379,14 +2379,14 @@
-                     put_bits(&s->pb, 8, 0);
-                 }
-             break;
--            case CODEC_ID_MPEG4:
--                put_bits(&s->pb, 16, 0);
--                put_bits(&s->pb, 16, 0x1C3);
--                stuffing_count -= 4;
--                while(stuffing_count--){
--                    put_bits(&s->pb, 8, 0xFF);
--                }
--            break;
-+//             case CODEC_ID_MPEG4:
-+//                 put_bits(&s->pb, 16, 0);
-+//                 put_bits(&s->pb, 16, 0x1C3);
-+//                 stuffing_count -= 4;
-+//                 while(stuffing_count--){
-+//                     put_bits(&s->pb, 8, 0xFF);
-+//                 }
-+//             break;
-             default:
-                 av_log(s->avctx, AV_LOG_ERROR, "vbv buffer overflow\n");
-             }
-@@ -3797,7 +3797,8 @@
-                     add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
-                     add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
-                 }
--            } else if(s->codec_id != CODEC_ID_WMV2){
-+            } 
-+	    else if(s->codec_id != CODEC_ID_WMV2){
-                 add_dct(s, block[0], 0, dest_y                          , dct_linesize);
-                 add_dct(s, block[1], 1, dest_y              + block_size, dct_linesize);
-                 add_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize);
-@@ -3825,9 +3826,9 @@
-                     }
-                 }//fi gray
-             }
--            else{
--                ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr);
--            }
-+//             else{
-+//                 ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr);
-+//             }
-         } else {
-             /* dct only in intra block */
-             if(s->encoding || !(s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO)){
-@@ -4087,18 +4088,18 @@
-             if(s->out_format==FMT_H263){
-                 s->dquant= clip(s->dquant, -2, 2); //FIXME RD
-             
--                if(s->codec_id==CODEC_ID_MPEG4){        
--                    if(!s->mb_intra){
--                        if(s->pict_type == B_TYPE){
--                            if(s->dquant&1) 
--                                s->dquant= (s->dquant/2)*2;
--                            if(s->mv_dir&MV_DIRECT)
--                                s->dquant= 0;
--                        }
--                        if(s->mv_type==MV_TYPE_8X8)
--                            s->dquant=0;
--                    }
--                }
-+//                 if(s->codec_id==CODEC_ID_MPEG4){        
-+//                     if(!s->mb_intra){
-+//                         if(s->pict_type == B_TYPE){
-+//                             if(s->dquant&1) 
-+//                                 s->dquant= (s->dquant/2)*2;
-+//                             if(s->mv_dir&MV_DIRECT)
-+//                                 s->dquant= 0;
-+//                         }
-+//                         if(s->mv_type==MV_TYPE_8X8)
-+//                             s->dquant=0;
-+//                     }
-+//                 }
-             }
-         }
-         ff_set_qscale(s, last_qp + s->dquant);
-@@ -4297,26 +4298,26 @@
-     case CODEC_ID_MPEG1VIDEO:
-     case CODEC_ID_MPEG2VIDEO:
-         mpeg1_encode_mb(s, s->block, motion_x, motion_y); break;
--    case CODEC_ID_MPEG4:
--        mpeg4_encode_mb(s, s->block, motion_x, motion_y); break;
--    case CODEC_ID_MSMPEG4V2:
--    case CODEC_ID_MSMPEG4V3:
--    case CODEC_ID_WMV1:
--        msmpeg4_encode_mb(s, s->block, motion_x, motion_y); break;
--    case CODEC_ID_WMV2:
--         ff_wmv2_encode_mb(s, s->block, motion_x, motion_y); break;
--#ifdef CONFIG_H261_ENCODER
--    case CODEC_ID_H261:
--        ff_h261_encode_mb(s, s->block, motion_x, motion_y); break;
--#endif
--    case CODEC_ID_H263:
--    case CODEC_ID_H263P:
--    case CODEC_ID_FLV1:
--    case CODEC_ID_RV10:
--    case CODEC_ID_RV20:
--        h263_encode_mb(s, s->block, motion_x, motion_y); break;
--    case CODEC_ID_MJPEG:
--        mjpeg_encode_mb(s, s->block); break;
-+//     case CODEC_ID_MPEG4:
-+//         mpeg4_encode_mb(s, s->block, motion_x, motion_y); break;
-+//     case CODEC_ID_MSMPEG4V2:
-+//     case CODEC_ID_MSMPEG4V3:
-+//     case CODEC_ID_WMV1:
-+//         msmpeg4_encode_mb(s, s->block, motion_x, motion_y); break;
-+//     case CODEC_ID_WMV2:
-+//          ff_wmv2_encode_mb(s, s->block, motion_x, motion_y); break;
-+// #ifdef CONFIG_H261_ENCODER
-+//     case CODEC_ID_H261:
-+//         ff_h261_encode_mb(s, s->block, motion_x, motion_y); break;
-+// #endif
-+//     case CODEC_ID_H263:
-+//     case CODEC_ID_H263P:
-+//     case CODEC_ID_FLV1:
-+//     case CODEC_ID_RV10:
-+//     case CODEC_ID_RV20:
-+//         h263_encode_mb(s, s->block, motion_x, motion_y); break;
-+//     case CODEC_ID_MJPEG:
-+//         mjpeg_encode_mb(s, s->block); break;
-     default:
-         assert(0);
-     }
-@@ -4599,15 +4600,15 @@
- }
- 
- static void write_slice_end(MpegEncContext *s){
--    if(s->codec_id==CODEC_ID_MPEG4){
--        if(s->partitioned_frame){
--            ff_mpeg4_merge_partitions(s);
--        }
--    
--        ff_mpeg4_stuffing(&s->pb);
--    }else if(s->out_format == FMT_MJPEG){
--        ff_mjpeg_stuffing(&s->pb);
--    }
-+//     if(s->codec_id==CODEC_ID_MPEG4){
-+//         if(s->partitioned_frame){
-+//             ff_mpeg4_merge_partitions(s);
-+//         }
-+//     
-+//         ff_mpeg4_stuffing(&s->pb);
-+//     }else if(s->out_format == FMT_MJPEG){
-+//         ff_mjpeg_stuffing(&s->pb);
-+//     }
- 
-     align_put_bits(&s->pb);
-     flush_put_bits(&s->pb);
-@@ -4655,17 +4656,17 @@
-      
-     s->last_mv_dir = 0;
- 
--    switch(s->codec_id){
--    case CODEC_ID_H263:
--    case CODEC_ID_H263P:
--    case CODEC_ID_FLV1:
--        s->gob_index = ff_h263_get_gob_height(s);
--        break;
--    case CODEC_ID_MPEG4:
--        if(s->partitioned_frame)
--            ff_mpeg4_init_partitions(s);
--        break;
--    }
-+//     switch(s->codec_id){
-+//     case CODEC_ID_H263:
-+//     case CODEC_ID_H263P:
-+//     case CODEC_ID_FLV1:
-+//         s->gob_index = ff_h263_get_gob_height(s);
-+//         break;
-+//     case CODEC_ID_MPEG4:
-+//         if(s->partitioned_frame)
-+//             ff_mpeg4_init_partitions(s);
-+//         break;
-+//     }
- 
-     s->resync_mb_x=0;
-     s->resync_mb_y=0; 
-@@ -4703,11 +4704,11 @@
-             ff_update_block_index(s);
- 
- #ifdef CONFIG_H261_ENCODER
--            if(s->codec_id == CODEC_ID_H261){
--                ff_h261_reorder_mb_index(s);
--                xy= s->mb_y*s->mb_stride + s->mb_x;
--                mb_type= s->mb_type[xy];
--            }
-+//             if(s->codec_id == CODEC_ID_H261){
-+//                 ff_h261_reorder_mb_index(s);
-+//                 xy= s->mb_y*s->mb_stride + s->mb_x;
-+//                 mb_type= s->mb_type[xy];
-+//             }
- #endif
- 
-             /* write gob / video packet header  */
-@@ -4721,11 +4722,11 @@
-                 if(s->start_mb_y == mb_y && mb_y > 0 && mb_x==0) is_gob_start=1;
-                 
-                 switch(s->codec_id){
--                case CODEC_ID_H263:
--                case CODEC_ID_H263P:
--                    if(!s->h263_slice_structured)
--                        if(s->mb_x || s->mb_y%s->gob_index) is_gob_start=0;
--                    break;
-+//                 case CODEC_ID_H263:
-+//                 case CODEC_ID_H263P:
-+//                     if(!s->h263_slice_structured)
-+//                         if(s->mb_x || s->mb_y%s->gob_index) is_gob_start=0;
-+//                     break;
-                 case CODEC_ID_MPEG2VIDEO:
-                     if(s->mb_x==0 && s->mb_y!=0) is_gob_start=1;
-                 case CODEC_ID_MPEG1VIDEO:
-@@ -4737,9 +4738,9 @@
-                     if(s->start_mb_y != mb_y || mb_x!=0){
-                         write_slice_end(s);
- 
--                        if(s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame){
--                            ff_mpeg4_init_partitions(s);
--                        }
-+//                         if(s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame){
-+//                             ff_mpeg4_init_partitions(s);
-+//                         }
-                     }
-                 
-                     assert((put_bits_count(&s->pb)&7) == 0);
-@@ -4763,19 +4764,19 @@
-                     }
-                     
-                     switch(s->codec_id){
--                    case CODEC_ID_MPEG4:
--                        ff_mpeg4_encode_video_packet_header(s);
--                        ff_mpeg4_clean_buffers(s);
--                    break;
-+//                     case CODEC_ID_MPEG4:
-+//                         ff_mpeg4_encode_video_packet_header(s);
-+//                         ff_mpeg4_clean_buffers(s);
-+//                     break;
-                     case CODEC_ID_MPEG1VIDEO:
-                     case CODEC_ID_MPEG2VIDEO:
-                         ff_mpeg1_encode_slice_header(s);
-                         ff_mpeg1_clean_buffers(s);
-                     break;
--                    case CODEC_ID_H263:
--                    case CODEC_ID_H263P:
--                        h263_encode_gob_header(s, mb_y);                       
--                    break;
-+//                     case CODEC_ID_H263:
-+//                     case CODEC_ID_H263P:
-+//                         h263_encode_gob_header(s, mb_y);                       
-+//                     break;
-                     }
- 
-                     if(s->flags&CODEC_FLAG_PASS1){
-@@ -5364,14 +5365,14 @@
- 
-     if(s->adaptive_quant){
-         switch(s->codec_id){
--        case CODEC_ID_MPEG4:
--            ff_clean_mpeg4_qscales(s);
--            break;
--        case CODEC_ID_H263:
--        case CODEC_ID_H263P:
--        case CODEC_ID_FLV1:
--            ff_clean_h263_qscales(s);
--            break;
-+//         case CODEC_ID_MPEG4:
-+//             ff_clean_mpeg4_qscales(s);
-+//             break;
-+//         case CODEC_ID_H263:
-+//         case CODEC_ID_H263P:
-+//         case CODEC_ID_FLV1:
-+//             ff_clean_h263_qscales(s);
-+//             break;
-         }
- 
-         s->lambda= s->lambda_table[0];
-@@ -5408,39 +5409,39 @@
- 
-     s->last_bits= put_bits_count(&s->pb);
-     switch(s->out_format) {
--    case FMT_MJPEG:
--        mjpeg_picture_header(s);
--        break;
--#ifdef CONFIG_H261_ENCODER
--    case FMT_H261:
--        ff_h261_encode_picture_header(s, picture_number);
--        break;
--#endif
--    case FMT_H263:
--        if (s->codec_id == CODEC_ID_WMV2) 
--            ff_wmv2_encode_picture_header(s, picture_number);
--        else if (s->h263_msmpeg4) 
--            msmpeg4_encode_picture_header(s, picture_number);
--        else if (s->h263_pred)
--            mpeg4_encode_picture_header(s, picture_number);
--#ifdef CONFIG_RV10_ENCODER
--        else if (s->codec_id == CODEC_ID_RV10) 
--            rv10_encode_picture_header(s, picture_number);
--#endif
--#ifdef CONFIG_RV20_ENCODER
--        else if (s->codec_id == CODEC_ID_RV20) 
--            rv20_encode_picture_header(s, picture_number);
--#endif
--        else if (s->codec_id == CODEC_ID_FLV1)
--            ff_flv_encode_picture_header(s, picture_number);
--        else
--            h263_encode_picture_header(s, picture_number);
--        break;
-+//     case FMT_MJPEG:
-+//         mjpeg_picture_header(s);
-+//         break;
-+// #ifdef CONFIG_H261_ENCODER
-+//     case FMT_H261:
-+//         ff_h261_encode_picture_header(s, picture_number);
-+//         break;
-+// #endif
-+//     case FMT_H263:
-+//         if (s->codec_id == CODEC_ID_WMV2) 
-+//             ff_wmv2_encode_picture_header(s, picture_number);
-+//         else if (s->h263_msmpeg4) 
-+//             msmpeg4_encode_picture_header(s, picture_number);
-+//         else if (s->h263_pred)
-+//             mpeg4_encode_picture_header(s, picture_number);
-+// #ifdef CONFIG_RV10_ENCODER
-+//         else if (s->codec_id == CODEC_ID_RV10) 
-+//             rv10_encode_picture_header(s, picture_number);
-+// #endif
-+// #ifdef CONFIG_RV20_ENCODER
-+//         else if (s->codec_id == CODEC_ID_RV20) 
-+//             rv20_encode_picture_header(s, picture_number);
-+// #endif
-+//         else if (s->codec_id == CODEC_ID_FLV1)
-+//             ff_flv_encode_picture_header(s, picture_number);
-+//         else
-+//             h263_encode_picture_header(s, picture_number);
-+//         break;
-     case FMT_MPEG1:
-         mpeg1_encode_picture_header(s, picture_number);
-         break;
--    case FMT_H264:
--        break;
-+//     case FMT_H264:
-+//         break;
-     default:
-         assert(0);
-     }
-@@ -6439,126 +6440,126 @@
- }
- 
- #ifdef CONFIG_ENCODERS
--AVCodec h263_encoder = {
--    "h263",
--    CODEC_TYPE_VIDEO,
--    CODEC_ID_H263,
--    sizeof(MpegEncContext),
--    MPV_encode_init,
--    MPV_encode_picture,
--    MPV_encode_end,
--    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
--};
--
--AVCodec h263p_encoder = {
--    "h263p",
--    CODEC_TYPE_VIDEO,
--    CODEC_ID_H263P,
--    sizeof(MpegEncContext),
--    MPV_encode_init,
--    MPV_encode_picture,
--    MPV_encode_end,
--    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
--};
--
--AVCodec flv_encoder = {
--    "flv",
--    CODEC_TYPE_VIDEO,
--    CODEC_ID_FLV1,
--    sizeof(MpegEncContext),
--    MPV_encode_init,
--    MPV_encode_picture,
--    MPV_encode_end,
--    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
--};
--
--AVCodec rv10_encoder = {
--    "rv10",
--    CODEC_TYPE_VIDEO,
--    CODEC_ID_RV10,
--    sizeof(MpegEncContext),
--    MPV_encode_init,
--    MPV_encode_picture,
--    MPV_encode_end,
--    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
--};
--
--AVCodec rv20_encoder = {
--    "rv20",
--    CODEC_TYPE_VIDEO,
--    CODEC_ID_RV20,
--    sizeof(MpegEncContext),
--    MPV_encode_init,
--    MPV_encode_picture,
--    MPV_encode_end,
--    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
--};
--
--AVCodec mpeg4_encoder = {
--    "mpeg4",
--    CODEC_TYPE_VIDEO,
--    CODEC_ID_MPEG4,
--    sizeof(MpegEncContext),
--    MPV_encode_init,
--    MPV_encode_picture,
--    MPV_encode_end,
--    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
--    .capabilities= CODEC_CAP_DELAY,
--};
--
--AVCodec msmpeg4v1_encoder = {
--    "msmpeg4v1",
--    CODEC_TYPE_VIDEO,
--    CODEC_ID_MSMPEG4V1,
--    sizeof(MpegEncContext),
--    MPV_encode_init,
--    MPV_encode_picture,
--    MPV_encode_end,
--    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
--};
--
--AVCodec msmpeg4v2_encoder = {
--    "msmpeg4v2",
--    CODEC_TYPE_VIDEO,
--    CODEC_ID_MSMPEG4V2,
--    sizeof(MpegEncContext),
--    MPV_encode_init,
--    MPV_encode_picture,
--    MPV_encode_end,
--    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
--};
--
--AVCodec msmpeg4v3_encoder = {
--    "msmpeg4",
--    CODEC_TYPE_VIDEO,
--    CODEC_ID_MSMPEG4V3,
--    sizeof(MpegEncContext),
--    MPV_encode_init,
--    MPV_encode_picture,
--    MPV_encode_end,
--    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
--};
--
--AVCodec wmv1_encoder = {
--    "wmv1",
--    CODEC_TYPE_VIDEO,
--    CODEC_ID_WMV1,
--    sizeof(MpegEncContext),
--    MPV_encode_init,
--    MPV_encode_picture,
--    MPV_encode_end,
--    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
--};
--
--AVCodec mjpeg_encoder = {
--    "mjpeg",
--    CODEC_TYPE_VIDEO,
--    CODEC_ID_MJPEG,
--    sizeof(MpegEncContext),
--    MPV_encode_init,
--    MPV_encode_picture,
--    MPV_encode_end,
--    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUVJ420P, -1},
--};
-+// AVCodec h263_encoder = {
-+//     "h263",
-+//     CODEC_TYPE_VIDEO,
-+//     CODEC_ID_H263,
-+//     sizeof(MpegEncContext),
-+//     MPV_encode_init,
-+//     MPV_encode_picture,
-+//     MPV_encode_end,
-+//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-+// };
-+// 
-+// AVCodec h263p_encoder = {
-+//     "h263p",
-+//     CODEC_TYPE_VIDEO,
-+//     CODEC_ID_H263P,
-+//     sizeof(MpegEncContext),
-+//     MPV_encode_init,
-+//     MPV_encode_picture,
-+//     MPV_encode_end,
-+//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-+// };
-+// 
-+// AVCodec flv_encoder = {
-+//     "flv",
-+//     CODEC_TYPE_VIDEO,
-+//     CODEC_ID_FLV1,
-+//     sizeof(MpegEncContext),
-+//     MPV_encode_init,
-+//     MPV_encode_picture,
-+//     MPV_encode_end,
-+//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-+// };
-+// 
-+// AVCodec rv10_encoder = {
-+//     "rv10",
-+//     CODEC_TYPE_VIDEO,
-+//     CODEC_ID_RV10,
-+//     sizeof(MpegEncContext),
-+//     MPV_encode_init,
-+//     MPV_encode_picture,
-+//     MPV_encode_end,
-+//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-+// };
-+// 
-+// AVCodec rv20_encoder = {
-+//     "rv20",
-+//     CODEC_TYPE_VIDEO,
-+//     CODEC_ID_RV20,
-+//     sizeof(MpegEncContext),
-+//     MPV_encode_init,
-+//     MPV_encode_picture,
-+//     MPV_encode_end,
-+//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-+// };
-+// 
-+// AVCodec mpeg4_encoder = {
-+//     "mpeg4",
-+//     CODEC_TYPE_VIDEO,
-+//     CODEC_ID_MPEG4,
-+//     sizeof(MpegEncContext),
-+//     MPV_encode_init,
-+//     MPV_encode_picture,
-+//     MPV_encode_end,
-+//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-+//     .capabilities= CODEC_CAP_DELAY,
-+// };
-+// 
-+// AVCodec msmpeg4v1_encoder = {
-+//     "msmpeg4v1",
-+//     CODEC_TYPE_VIDEO,
-+//     CODEC_ID_MSMPEG4V1,
-+//     sizeof(MpegEncContext),
-+//     MPV_encode_init,
-+//     MPV_encode_picture,
-+//     MPV_encode_end,
-+//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-+// };
-+// 
-+// AVCodec msmpeg4v2_encoder = {
-+//     "msmpeg4v2",
-+//     CODEC_TYPE_VIDEO,
-+//     CODEC_ID_MSMPEG4V2,
-+//     sizeof(MpegEncContext),
-+//     MPV_encode_init,
-+//     MPV_encode_picture,
-+//     MPV_encode_end,
-+//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-+// };
-+// 
-+// AVCodec msmpeg4v3_encoder = {
-+//     "msmpeg4",
-+//     CODEC_TYPE_VIDEO,
-+//     CODEC_ID_MSMPEG4V3,
-+//     sizeof(MpegEncContext),
-+//     MPV_encode_init,
-+//     MPV_encode_picture,
-+//     MPV_encode_end,
-+//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-+// };
-+// 
-+// AVCodec wmv1_encoder = {
-+//     "wmv1",
-+//     CODEC_TYPE_VIDEO,
-+//     CODEC_ID_WMV1,
-+//     sizeof(MpegEncContext),
-+//     MPV_encode_init,
-+//     MPV_encode_picture,
-+//     MPV_encode_end,
-+//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-+// };
-+// 
-+// AVCodec mjpeg_encoder = {
-+//     "mjpeg",
-+//     CODEC_TYPE_VIDEO,
-+//     CODEC_ID_MJPEG,
-+//     sizeof(MpegEncContext),
-+//     MPV_encode_init,
-+//     MPV_encode_picture,
-+//     MPV_encode_end,
-+//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUVJ420P, -1},
-+// };
- 
- #endif //CONFIG_ENCODERS
-diff -urN ffmpeg.orig/libavformat/Makefile ffmpeg.src/libavformat/Makefile
---- ffmpeg.orig/libavformat/Makefile	2005-09-13 19:32:04.000000000 +0200
-+++ ffmpeg.src/libavformat/Makefile	2005-11-27 16:34:24.178552608 +0100
-@@ -12,69 +12,13 @@
- PPOBJS=
- 
- # mux and demuxes
--OBJS+=mpeg.o mpegts.o mpegtsenc.o ffm.o crc.o img.o img2.o raw.o rm.o \
--      avienc.o avidec.o wav.o mmf.o swf.o au.o gif.o mov.o mpjpeg.o dv.o \
--      yuv4mpeg.o 4xm.o flvenc.o flvdec.o movenc.o psxstr.o idroq.o ipmovie.o \
--      nut.o wc3movie.o mp3.o westwood.o segafilm.o idcin.o flic.o \
--      sierravmd.o matroska.o sol.o electronicarts.o nsvdec.o asf.o asf-enc.o \
--      ogg2.o oggparsevorbis.o oggparsetheora.o oggparseflac.o daud.o
--AMROBJS=
--ifeq ($(AMR_NB),yes)
--AMROBJS= amr.o
--endif
--ifeq ($(AMR_NB_FIXED),yes)
--AMROBJS= amr.o
--endif
--ifeq ($(AMR_WB),yes)
--AMROBJS= amr.o
--endif
--OBJS+= $(AMROBJS)
-+OBJS+=mpeg.o mpegts.o mpegtsenc.o 
- 
--# image formats
--OBJS+= pnm.o yuv.o png.o jpeg.o gifdec.o sgi.o
- # file I/O
- OBJS+= avio.o aviobuf.o file.o 
--OBJS+= framehook.o 
--
--ifeq ($(CONFIG_VIDEO4LINUX),yes)
--OBJS+= grab.o
--endif
--
--ifeq ($(CONFIG_BKTR),yes)
--OBJS+= grab_bktr.o
--endif
--
--ifeq ($(CONFIG_DV1394),yes)
--OBJS+= dv1394.o
--endif
--
--ifeq ($(CONFIG_DC1394),yes)
--OBJS+= dc1394.o
--endif
--
--ifeq ($(CONFIG_AUDIO_OSS),yes)
--OBJS+= audio.o 
--endif
- 
- EXTRALIBS += -L../libavutil -lavutil$(BUILDSUF)
- 
--ifeq ($(CONFIG_AUDIO_BEOS),yes)
--PPOBJS+= beosaudio.o
--EXTRALIBS+=-lbe -lmedia
--endif
--
--ifeq ($(CONFIG_NETWORK),yes)
--OBJS+= udp.o tcp.o http.o rtsp.o rtp.o rtpproto.o
--# BeOS and Darwin network stuff
--ifeq ($(NEED_INET_ATON),yes)
--OBJS+= barpainet.o
--endif
--endif
--
--ifeq ($(CONFIG_LIBOGG),yes)
--OBJS+= ogg.o
--endif
--
- ifeq ($(TARGET_ARCH_SPARC64),yes)
- CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc
- endif
-@@ -129,9 +73,9 @@
- install-headers:
- 	mkdir -p "$(prefix)/include/ffmpeg"
- 	install -m 644 $(SRC_PATH)/libavformat/avformat.h $(SRC_PATH)/libavformat/avio.h \
--                $(SRC_PATH)/libavformat/rtp.h $(SRC_PATH)/libavformat/rtsp.h \
--                $(SRC_PATH)/libavformat/rtspcodes.h \
-                 "$(prefix)/include/ffmpeg"
-+#                $(SRC_PATH)/libavformat/rtp.h $(SRC_PATH)/libavformat/rtsp.h 
-+#                $(SRC_PATH)/libavformat/rtspcodes.h 
- 	install -d $(libdir)/pkgconfig
- 	install -m 644 ../libavformat.pc $(libdir)/pkgconfig
- 
-diff -urN ffmpeg.orig/libavformat/allformats.c ffmpeg.src/libavformat/allformats.c
---- ffmpeg.orig/libavformat/allformats.c	2005-09-13 19:32:04.000000000 +0200
-+++ ffmpeg.src/libavformat/allformats.c	2005-11-27 16:34:24.179552456 +0100
-@@ -37,108 +37,8 @@
- 
-     mpegps_init();
-     mpegts_init();
--#ifdef CONFIG_ENCODERS
--    crc_init();
--    img_init();
--    img2_init();
--#endif //CONFIG_ENCODERS
--    raw_init();
--    mp3_init();
--    rm_init();
--    asf_init();
--#ifdef CONFIG_ENCODERS
--    avienc_init();
--#endif //CONFIG_ENCODERS
--    avidec_init();
--    ff_wav_init();
--    ff_mmf_init();
--    swf_init();
--    au_init();
--#ifdef CONFIG_ENCODERS
--    gif_init();
--#endif //CONFIG_ENCODERS
--    mov_init();
--#ifdef CONFIG_ENCODERS
--    movenc_init();
--    jpeg_init();
--#endif //CONFIG_ENCODERS
--    ff_dv_init();
--    fourxm_init();
--#ifdef CONFIG_ENCODERS
--    flvenc_init();
--#endif //CONFIG_ENCODERS
--    flvdec_init();
--    str_init();
--    roq_init();
--    ipmovie_init();
--    wc3_init();
--    westwood_init();
--    film_init();
--    idcin_init();
--    flic_init();
--    vmd_init();
--
--#if defined(AMR_NB) || defined(AMR_NB_FIXED) || defined(AMR_WB)
--    amr_init();
--#endif
--    yuv4mpeg_init();
--
--    ogg_init();
--#ifdef CONFIG_LIBOGG
--    libogg_init();
--#endif
--
--    ffm_init();
--#if defined(CONFIG_VIDEO4LINUX) || defined(CONFIG_BKTR)
--    video_grab_init();
--#endif
--#if defined(CONFIG_AUDIO_OSS) || defined(CONFIG_AUDIO_BEOS)
--    audio_init();
--#endif
--
--#ifdef CONFIG_DV1394
--    dv1394_init();
--#endif
--
--#ifdef CONFIG_DC1394
--    dc1394_init();
--#endif
--
--    nut_init();
--    matroska_init();
--    sol_init();
--    ea_init();
--    nsvdec_init();
--    daud_init();
--
--#ifdef CONFIG_ENCODERS
--    /* image formats */
--#if 0
--    av_register_image_format(&pnm_image_format);
--    av_register_image_format(&pbm_image_format);
--    av_register_image_format(&pgm_image_format);
--    av_register_image_format(&ppm_image_format);
--    av_register_image_format(&pam_image_format);
--    av_register_image_format(&pgmyuv_image_format);
--    av_register_image_format(&yuv_image_format);
--#ifdef CONFIG_ZLIB
--    av_register_image_format(&png_image_format);
--#endif
--    av_register_image_format(&jpeg_image_format);
--#endif
--    av_register_image_format(&gif_image_format);  
--//    av_register_image_format(&sgi_image_format); heap corruption, dont enable
--#endif //CONFIG_ENCODERS
--
-+    
-     /* file protocols */
-     register_protocol(&file_protocol);
-     register_protocol(&pipe_protocol);
--#ifdef CONFIG_NETWORK
--    rtsp_init();
--    rtp_init();
--    register_protocol(&udp_protocol);
--    register_protocol(&rtp_protocol);
--    register_protocol(&tcp_protocol);
--    register_protocol(&http_protocol);
--#endif
- }
-diff -urN ffmpeg.orig/libavformat/avformat.h ffmpeg.src/libavformat/avformat.h
---- ffmpeg.orig/libavformat/avformat.h	2005-09-13 19:32:04.000000000 +0200
-+++ ffmpeg.src/libavformat/avformat.h	2005-11-27 16:34:24.181552152 +0100
-@@ -549,9 +549,9 @@
- /* daud.c */
- int daud_init(void);
- 
--#include "rtp.h"
-+// #include "rtp.h"
- 
--#include "rtsp.h"
-+// #include "rtsp.h"
- 
- /* yuv4mpeg.c */
- extern AVOutputFormat yuv4mpegpipe_oformat;
-diff -urN ffmpeg.orig/libavformat/utils.c ffmpeg.src/libavformat/utils.c
---- ffmpeg.orig/libavformat/utils.c	2005-09-13 19:32:05.000000000 +0200
-+++ ffmpeg.src/libavformat/utils.c	2005-11-27 16:34:24.183551848 +0100
-@@ -85,16 +85,16 @@
-     int score_max, score;
- 
-     /* specific test for image sequences */
--    if (!short_name && filename && 
--        filename_number_test(filename) >= 0 &&
--        av_guess_image2_codec(filename) != CODEC_ID_NONE) {
--        return guess_format("image2", NULL, NULL);
--    }
--    if (!short_name && filename && 
--        filename_number_test(filename) >= 0 &&
--        guess_image_format(filename)) {
--        return guess_format("image", NULL, NULL);
--    }
-+//     if (!short_name && filename && 
-+//         filename_number_test(filename) >= 0 &&
-+//         av_guess_image2_codec(filename) != CODEC_ID_NONE) {
-+//         return guess_format("image2", NULL, NULL);
-+//     }
-+//     if (!short_name && filename && 
-+//         filename_number_test(filename) >= 0 &&
-+//         guess_image_format(filename)) {
-+//         return guess_format("image", NULL, NULL);
-+//     }
- 
-     /* find the proper file type */
-     fmt_found = NULL;
-@@ -146,9 +146,9 @@
-     if(type == CODEC_TYPE_VIDEO){
-         enum CodecID codec_id= CODEC_ID_NONE;
- 
--        if(!strcmp(fmt->name, "image2") || !strcmp(fmt->name, "image2pipe")){
--            codec_id= av_guess_image2_codec(filename);
--        }
-+//         if(!strcmp(fmt->name, "image2") || !strcmp(fmt->name, "image2pipe")){
-+//             codec_id= av_guess_image2_codec(filename);
-+//         }
-         if(codec_id == CODEC_ID_NONE)
-             codec_id= fmt->video_codec;
-         return codec_id;
diff --git a/ffmpeg.src/COPYING b/ffmpeg.src/COPYING
deleted file mode 100644
index 223ede7..0000000
--- a/ffmpeg.src/COPYING
+++ /dev/null
@@ -1,504 +0,0 @@
-		  GNU LESSER GENERAL PUBLIC LICENSE
-		       Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL.  It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-			    Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard.  To achieve this, non-free programs must be
-allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software.  For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
-		  GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-  
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at
-    least three years, to give the same user the materials
-    specified in Subsection 6a, above, for a charge no more
-    than the cost of performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded.  In such case, this License incorporates the limitation as if
-written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-			    NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.  It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library 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 of the License, or (at your option) any later version.
-
-    This library 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 this library; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
-
-
diff --git a/ffmpeg.src/CREDITS b/ffmpeg.src/CREDITS
deleted file mode 100644
index de37419..0000000
--- a/ffmpeg.src/CREDITS
+++ /dev/null
@@ -1,39 +0,0 @@
-This file contains the name of the people who have contributed to
-FFmpeg. The names are sorted alphabetically by last name.
-
-Michel Bardiaux
-Fabrice Bellard
-Patrice Bensoussan
-Alex Beregszaszi
-BERO
-Mario Brito
-Ronald Bultje
-Maarten Daniels
-Tim Ferguson
-Brian Foley
-Arpad Gereoffy
-Philip Gladstone
-Vladimir Gneushev
-Roine Gustafsson
-David Hammerton
-Wolfgang Hesseler
-Falk Hueffner
-Zdenek Kabelac
-Robin Kay
-Todd Kirby
-Nick Kurshev
-Loïc Le Loarer
-Mike Melanson
-Loren Merritt
-Jeff Muizelaar
-Michael Niedermayer
-François Revol
-Måns Rullgård
-Roman Shaposhnik
-Dieter Shirley
-Konstantin Shishkov
-Juan J. Sierralta
-Ewald Snel
-Leon van Stuivenberg
-Roberto Togni
-Lionel Ulmer
diff --git a/ffmpeg.src/Changelog b/ffmpeg.src/Changelog
deleted file mode 100644
index f3e9a63..0000000
--- a/ffmpeg.src/Changelog
+++ /dev/null
@@ -1,344 +0,0 @@
-version <next>
-- TechSmith Camtasia (TSCC) video decoder
-- IBM Ultimotion (ULTI) video decoder
-- Sierra Online audio file demuxer and decoder
-- Apple QuickDraw (qdrw) video decoder
-- Creative ADPCM audio decoder
-- Electronic Arts Multimedia (WVE/UV2/etc.) file demuxer
-- Miro VideoXL (VIXL) video decoder
-- H.261 video encoder
-- QPEG video decoder
-- Nullsoft Video (NSV) file demuxer
-- Shorten audio decoder
-- LOCO video decoder
-- Apple Lossless Audio Codec (ALAC) decoder 
-- Winnov WNV1 video decoder
-- Autodesk Animator Studio Codec (AASC) decoder
-- Indeo 2 video decoder
-- Fraps FPS1 video decoder
-- SNOW video encoder/decoder
-- Sonic audio encoder/decoder
-- Vorbis decoder
-- Macromedia ADPCM decoder
-
-version 0.4.9-pre1:
-
-- DV encoder, DV muxer
-- Microsoft RLE video decoder
-- Microsoft Video-1 decoder
-- Apple Animation (RLE) decoder
-- Apple Graphics (SMC) decoder
-- Apple Video (RPZA) decoder
-- Cinepak decoder
-- Sega FILM (CPK) file demuxer
-- Westwood multimedia support (VQA & AUD files)
-- Id Quake II CIN playback support
-- 8BPS video decoder
-- FLIC playback support
-- RealVideo 2.0 (RV20) decoder
-- Duck TrueMotion v1 (DUCK) video decoder
-- Sierra VMD demuxer and video decoder
-- MSZH and ZLIB decoder support
-- SVQ1 video encoder
-- AMR-WB support
-- PPC optimisations
-- rate distortion optimal cbp support
-- rate distorted optimal ac prediction for mpeg4
-- rate distorted optimal lambda->qp support
-- AAC encoding with libfaac
-- Sunplus JPEG codec (SP5X) support
-- use lagrange multipler instead of qp for ratecontrol
-- theora/VP3 decoding support
-- XA and ADX ADPCM codecs
-- export mpeg2 active display area / pan scan
-- Add support for configuring with IBM XLC
-- floating point AAN DCT
-- initial support for zygovideo (not complete)
-- rgb ffv1 support
-- new audio/video parser API
-- av_log() system
-- av_read_frame() and av_seek_frame() support
-- missing last frame fixes
-- seek by mouse in ffplay
-- noise reduction of dct coefficients
-- h263 OBMC & 4MV support
-- h263 alternative inter vlc support
-- h263 loop filter
-- h263 slice structured mode
-- interlaced DCT support for MPEG2 encoding
-- stuffing to stay above min_bitrate
-- mb type & qp vissualization
-- frame stepping for ffplay
-- interlaced motion estimation
-- alternate scantable support
-- SVCD scan offset support
-- closed gop support
-- SSE2 fdct
-- quantizer noise shaping
-- G.726 ADPCM audio codec
-- MS ADPCM encoding
-- multithreaded/SMP motion estimation
-- multithreaded/SMP encoding for MPEG1/MPEG2/MPEG4/H263
-- multithreaded/SMP decoding for MPEG2
-- FLAC decoder
-- Metrowerks CodeWarrior suppport
-- h263+ custom pcf support
-- nicer output for 'ffmpeg -formats'
-- matroska demuxer
-- SGI image format, encoding and decoding
-- h264 loop filter support
-- h264 CABAC support
-- nicer looking arrows for the motion vector vissualization
-- improved VCD support
-- audio timestamp drift compensation
-- mpeg2 YUV 422/444 support
-- polyphase kaiser windowed sinc and blackman nuttall windowed sinc audio resample
-- better image scaling
-- h261 support
-- correctly interleave packets during encoding
-- VIS optimized motion compensation
-- intra_dc_precission>0 encoding support
-- support reuse of motion vectors/mb types/field select values of the source video
-- more accurate deblock filter
-- padding support
-- many optimizations and bugfixes
-
-version 0.4.8:
-
-- MPEG2 video encoding (Michael)
-- Id RoQ playback subsystem (Mike Melanson and Tim Ferguson)
-- Wing Commander III Movie (.mve) file playback subsystem (Mike Melanson
-  and Mario Brito)
-- Xan DPCM audio decoder (Mario Brito)
-- Interplay MVE playback subsystem (Mike Melanson)
-- Duck DK3 and DK4 ADPCM audio decoders (Mike Melanson)
-
-version 0.4.7:
-
-- RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from a mplayerhq
-  (originally from public domain player for Amiga at http://www.honeypot.net/audio)
-- Current version now also compiles with older GCC (Fabrice)
-- 4X multimedia playback system including 4xm file demuxer (Mike
-  Melanson), and 4X video and audio codecs (Michael)
-- Creative YUV (CYUV) decoder (Mike Melanson)
-- FFV1 codec (our very simple lossless intra only codec, compresses much better
-  then huffyuv) (Michael)
-- ASV1 (Asus), H.264, Intel indeo3 codecs has been added (Various)
-- Tiny PNG encoder and decoder, tiny GIF decoder, PAM decoder (PPM with
-  alpha support), JPEG YUV colorspace support. (Fabrice Bellard)
-- ffplay has been replaced with a newer version which uses SDL (optionally)
-  for multi platform support (fabrice)
-- Sorenson Version 3 codec (SVQ3) support has been added (decoding only) - donated
-  by anonymous
-- AMR format has been added (Johannes Carlsson)
-- 3gp support has been added (Johannes Carlsson)
-- VP3 codec has been added (Mike Melanson)
-- more MPEG-1/2 fixes
-- Better Multi platform support, MS Visual Studio fixes (various)
-- Altivec optimizations (Magnus Damn and others)
-- SH4 processor support has been added (BERO)
-- New public interfaces (avcodec_get_pix_fmt) (Roman Shaposhnick)
-- VOB Streaming support (Brian Foley)
-- Better MP3 Autodetection (Andriy Rysin)
-- qpel encoding (Michael)
-- 4mv+b frames encoding finally fixed (Michael)
-- chroma ME (Michael)
-- 5 comparission functions for ME (Michael)
-- b frame encoding speedup (Michael)
-- wmv2 codec (unfinished - Michael)
-- user specified diamond size for EPZS (Michael)
-- Playstation STR playback subsystem, still experimental (Mike and Michael)
-- ASV2 codec (Michael)
-- CLJR decoder (Alex)
-
-.. And lots more new enhances and fixes.
-
-version 0.4.6:
-
-- completely new integer only mpeg audio layer 1/2/3 decoder rewritten
-  from scratch.
-- recoded dct and motion vector search with gcc (no longer depends on
-  nasm).
-- fix quantization bug in AC3 encoder.
-- added PCM codecs and format. Corrected wav/avi/asf pcm issues.
-- added prototype ffplay program.
-- added GOB header parsing on H.263/H.263+ decoder. (Juanjo)
-- bug fix on MCBPC tables of H.263. (Juanjo)
-- bug fix on DC coefficients of H.263. (Juanjo)
-- added Advanced Prediction Mode on H.263/H.263+ decoder. (Juanjo)
-- now we can decode H.263 streams found on QuickTime files. (Juanjo)
-- now we can decode H.263 streams found on VIVO v1 files.(Juanjo)
-- preliminary RTP "friendly" mode for H.263/H.263+ coding. (Juanjo)
-- added GOB header for H.263/H.263+ coding on RTP mode. (Juanjo)
-- now H.263 picture size is returned on the first decoded frame. (Juanjo)
-- added first regression tests
-- added MPEG2 TS demux
-- new demux API for libav
-- more accurate and faster IDCT (Michael)
-- faster and entropy controlled motion search (Michael)
-- two pass video encoding (Michael)
-- new video rate control (Michael)
-- added MSMPEG4V1, MSMPEGV2 and WMV1 support (Michael)
-- great performance improvement of video encoders and decoders (Michael)
-- new and faster bit readers and vlc parsers (Michael)
-- high quality encoding mode : tries all macroblock/VLC types (Michael)
-- added DV video decoder
-- preliminary RTP/RTSP support in ffserver and libavformat
-- H.263+ AIC decoding/encoding support. (Juanjo)
-- VCD MPEG-PS mode. (Juanjo)
-- PSNR stuff. (Juanjo)
-- Simple stats output. (Juanjo)
-- 16-bit and 15-bit rgb/bgr/gbr support (Bisqwit)
-
-version 0.4.5:
-
-- some header fixes (Zdenek Kabelac <kabi at informatics.muni.cz>).
-- many MMX optimizations (Nick Kurshev <nickols_k at mail.ru>).
-- added configure system (actually a small shell script).
-- added mpeg audio layer 1/2/3 decoding using LGPL'ed mpglib by
-  Michael Hipp (temporary solution - waiting for integer only
-  decoder).
-- fixed VIDIOCSYNC interrupt.
-- added Intel H263 decoding support ('I263' avi fourCC)
-- added Real Video 1.0 decoding (needs further testing).
-- simplified image formats again. Added PGM format (=grey
-  pgm). Renamed old PGM to PGMYUV.
-- fixed msmpeg4 slice issues (tell me if you still find problems).
-- fixed opendivx bugs with newer versions (added VOL header decoding).
-- added support for mplayer interface.
-- added macroblock skip optimization.
-- added MJPEG decoder.
-- added mmx/mmxext idct from libmpeg2.
-- added pgmyuvpipe, ppm, and ppm_pipe formats (original patch by Celer
-  <celer at shell.scrypt.net>).
-- added pixel format convertion layer (e.g. for MJPEG or PPM).
-- added deinterlacing option.
-- mpeg1/2 fixes.
-- mpeg4 vol header fixes (Jonathan Marsden <snmjbm at pacbell.net>).
-- ARM optimizations (Lionel Ulmer <lionel.ulmer at free.fr>).
-- Windows porting of file converter.
-- added MJPEG raw format (input/ouput).
-- added JPEG image format support (input/output).
-
-version 0.4.4:
-
-- fixed some std header definitions (Bjorn Lindgren
-  <bjorn.e.lindgren at telia.com>).
-- added mpeg demux (mpeg 1 and 2 compatible).
-- added ASF demux.
-- added prototype RM demux.
-- added AC3 decoding (done with libac3 by Aaron Holtzman).
-- added decoding codec parameter guessing (.e.g. for mpeg, because the
-  header does not include them).
-- fixed header generation in mpeg1, AVI and ASF mux : wmplayer can now
-  play them (only tested video).
-- fixed h263 white bug.
-- fixed phase rounding in img resample filter.
-- add mmx code for polyphase img resample filter.
-- added CPU autodetect.
-- added generic title/author/copyright/comment string handling (ASF and RM use them).
-- added SWF demux to extract MP3 track (not usable yet because no MP3
-  decoder).
-- added fractional frame rate support.
-- codecs are no longer searched by read_header() (should fix ffserver
-  segfault).
-
-version 0.4.3:
-
-- BGR24 patch (initial patch by Jeroen Vreeken <pe1rxq at amsat.org>).
-- fixed raw yuv output.
-- added motion rounding support in MPEG4.
-- fixed motion bug rounding in MSMPEG4.
-- added B frame handling in video core.
-- added full MPEG1 decoding support.
-- added partial (frame only) MPEG2 support.
-- changed the FOURCC code for H.263 to "U263" to be able to see the
-+AVI/H.263 file with the UB Video H.263+ decoder. MPlayer works with
-this +codec ;) (JuanJo).
-- Halfpel motion estimation after mb type selection (JuanJo).
-- added pgm and .Y.U.V output format.
-- suppressed 'img:' protocol. Simply use: /tmp/test%d.[pgm|Y] as input or
-  output.
-- added pgmpipe I/O format (original patch from Martin Aumueller
-  <lists at reserv.at>, but changed completely since we use a format
-  instead of a protocol).
-
-version 0.4.2:
-
-- added H263/MPEG4/MSMPEG4 decoding support. MPEG4 decoding support
-  (for openDIVX) is almost complete: 8x8 MVs and rounding are
-  missing. MSMPEG4 support is complete.
-- added prototype MPEG1 decoder. Only I and P frames handled yet (it
-  can decode ffmpeg mpegs :-)).
-- added libavcodec API documentation (see apiexample.c).
-- fixed image polyphase bug (the bottom of some images could be
-  greenish).
-- added support for non clipped motion vectors (decoding only)
-  and image sizes non multiple of 16.
-- added support for AC prediction (decoding only).
-- added file overwrite confirmation (can be disabled with -y).
-- Added custom size picture to H.263 using H.263+ (Juanjo).
-
-version 0.4.1:
-
-- added MSMPEG4 (aka DIVX) compatible encoder. Changed default codec
-  of avi and asf to DIV3.
-- added -me option to set motion estimation method
-  (default=log). suppressed redundant -hq option.
-- added options -acodec and -vcodec to force a given codec (useful for
-  AVI for example).
-- fixed -an option.
-- improved dct_quantize speed.
-- factorized some motion estimation code.
-
-version 0.4.0:
-
-- removing grab code from ffserver and moved it to ffmpeg. Added multi
-  stream support to ffmpeg.
-- added timeshifting support for live feeds (option ?date=xxx in the
-  URL).
-- added high quality image resize code with polyphase filter (need
-  mmx/see optimisation). Enable multiple image size support in ffserver.
-- added multi live feed support in ffserver.
-- suppressed master feature from ffserver (it should be done with an
-  external program which opens the .ffm url and writes it to another
-  ffserver).
-- added preliminary support for video stream parsing (wav and avi half
-  done). Added proper support for audio/video file convertion in
-  ffmpeg.
-- added preliminary support for video file sending from ffserver.
-- redesigning I/O subsystem : now using URL based input and output
-  (see avio.h).
-- added wav format support.
-- added "tty user interface" to ffmpeg to stop grabbing gracefully.
-- added MMX/SSE optimizations to SAD (Sums of Absolutes Diferences)
-  (Juan J. Sierralta P. a.k.a. "Juanjo" <juanjo at atmlab.utfsm.cl>).
-- added MMX DCT from mpeg2_movie 1.5 (Juanjo).
-- added new motion estimation algorithms, log and phods (Juanjo).
-- changed directories : libav for format handling, libavcodec for
-  codecs.
-
-version 0.3.4:
-
-- added stereo in mpeg audio encoder.
-
-version 0.3.3:
-
-- added 'high quality' mode which use motion vectors. It can be used in
-  real time at low resolution.
-- fixed rounding problems which caused quality problems at high
-  bitrates and large gop size.
-
-version 0.3.2: small fixes
-
-- asf fixes
-- put_seek bug fix
-
-version 0.3.1: added avi/divx support
-
-- added avi support
-- added mpeg4 codec compatible with open divx. It is based on the h263
-  codec.
-- added sound for flash format (not tested)
-
-version 0.3: initial public release
diff --git a/ffmpeg.src/Makefile b/ffmpeg.src/Makefile
deleted file mode 100644
index f180dd4..0000000
--- a/ffmpeg.src/Makefile
+++ /dev/null
@@ -1,231 +0,0 @@
-#
-# Main ffmpeg Makefile
-# (c) 2000-2004 Fabrice Bellard
-#
-include config.mak
-
-VPATH=$(SRC_PATH)
-
-CFLAGS=$(OPTFLAGS) -I. -I$(SRC_PATH) -I$(SRC_PATH)/libavutil -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavformat -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE
-
-ifeq ($(DVBCUT_NO_DEBUG),)
-LDFLAGS+= -g
-endif
-
-ifeq ($(TARGET_GPROF),yes)
-CFLAGS+=-p
-LDFLAGS+=-p
-endif
-
-MANPAGE=doc/ffmpeg.1
-PROG=ffmpeg$(EXESUF)
-PROGTEST=output_example$(EXESUF)
-QTFASTSTART=qt-faststart$(EXESUF)
-
-ifeq ($(CONFIG_FFSERVER),yes)
-MANPAGE+=doc/ffserver.1
-PROG+=ffserver$(EXESUF)
-endif
-
-ifeq ($(CONFIG_FFPLAY),yes)
-MANPAGE+=doc/ffplay.1
-PROG+=ffplay$(EXESUF)
-FFPLAY_O=ffplay.o
-endif
-
-ifeq ($(CONFIG_AUDIO_BEOS),yes)
-EXTRALIBS+=-lmedia -lbe
-endif
-
-ifeq ($(BUILD_SHARED),yes)
-DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF)
-else
-DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF)
-ifeq ($(CONFIG_MP3LAME),yes)
-EXTRALIBS+=-lmp3lame
-endif
-endif
-
-ifeq ($(CONFIG_LIBOGG),yes)
-ifeq ($(CONFIG_LIBVORBIS),yes)
-EXTRALIBS+= -lvorbisenc -lvorbis
-endif
-ifeq ($(CONFIG_LIBTHEORA),yes)
-EXTRALIBS+= -ltheora
-endif
-EXTRALIBS+= -logg
-endif
-
-ifeq ($(CONFIG_FAAD),yes)
-ifeq ($(CONFIG_FAADBIN),yes)
-# no libs needed
-else
-EXTRALIBS += -lfaad
-endif
-endif
-
-ifeq ($(CONFIG_FAAC),yes)
-EXTRALIBS+=-lfaac
-endif
-
-ifeq ($(CONFIG_XVID),yes)
-EXTRALIBS+=-lxvidcore
-endif
-
-ifeq ($(CONFIG_LIBGSM),yes)
-EXTRALIBS+=-lgsm
-endif
-
-ifeq ($(CONFIG_DC1394),yes)
-EXTRALIBS+=-ldc1394_control -lraw1394
-endif
-
-ifeq ($(BUILD_VHOOK),yes)
-VHOOK=videohook
-INSTALLVHOOK=install-vhook
-CLEANVHOOK=clean-vhook
-endif
-
-ifeq ($(TARGET_OS), SunOS)
-TEST=/usr/bin/test
-else
-TEST=test
-endif
-
-ifeq ($(BUILD_DOC),yes)
-DOC=documentation
-endif
-
-OBJS = ffmpeg.o ffserver.o cmdutils.o $(FFPLAY_O)
-SRCS = $(OBJS:.o=.c) $(ASM_OBJS:.o=.s)
-FFLIBS = -L./libavformat -lavformat$(BUILDSUF) -L./libavcodec -lavcodec$(BUILDSUF) -L./libavutil -lavutil$(BUILDSUF)
-
-all: lib $(PROG) $(PROGTEST) $(VHOOK) $(QTFASTSTART) $(DOC)
-
-lib:
-	$(MAKE) -C libavutil all
-	$(MAKE) -C libavcodec all
-	$(MAKE) -C libavformat all
-
-ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
-	$(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(FFLIBS) $(EXTRALIBS)
-
-ffmpeg$(EXESUF): ffmpeg_g$(EXESUF)
-	cp -p $< $@
-	$(STRIP) $@
-
-ffserver$(EXESUF): ffserver.o .libs
-	$(CC) $(LDFLAGS) $(FFSLDFLAGS) -o $@ ffserver.o $(FFLIBS) $(EXTRALIBS) 
-
-ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
-	$(CC) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(FFLIBS) $(EXTRALIBS) $(SDL_LIBS)
-
-ffplay$(EXESUF): ffplay_g$(EXESUF)
-	cp -p $< $@
-	$(STRIP) $@
-
-output_example$(EXESUF): output_example.o .libs
-	$(CC) $(LDFLAGS) -o $@ output_example.o $(FFLIBS) $(EXTRALIBS)
-
-qt-faststart$(EXESUF): qt-faststart.c
-	$(CC) $(SRC_PATH)/qt-faststart.c -o qt-faststart$(EXESUF)
-
-cws2fws$(EXESUF): cws2fws.c
-	$(CC) $(SRC_PATH)/cws2fws.c -o cws2fws$(EXESUF) -lz
-
-ffplay.o: ffplay.c
-	$(CC) $(CFLAGS) $(SDL_CFLAGS) -c -o $@ $< 
-
-%.o: %.c
-	$(CC) $(CFLAGS) -c -o $@ $< 
-
-videohook: .libs
-	$(MAKE) -C vhook all
-
-documentation:
-	$(MAKE) -C doc all
-
-.PHONY: install
-
-install: all install-man $(INSTALLVHOOK)
-	$(MAKE) -C libavutil install
-	$(MAKE) -C libavcodec install
-	$(MAKE) -C libavformat install
-	install -d "$(bindir)"
-	install -c $(INSTALLSTRIP) -m 755 $(PROG) "$(bindir)"
-
-# create the window installer
-wininstaller: all install
-	makensis ffinstall.nsi
-
-# install man from source dir if available
-install-man:
-ifneq ($(CONFIG_WIN32),yes)
-	if [ -f doc/ffmpeg.1 ] ; then \
-	    install -d "$(mandir)/man1" ; \
-	    install -m 644 $(MANPAGE) "$(mandir)/man1" ; \
-	fi
-endif
-
-install-vhook:
-	$(MAKE) -C vhook install
-
-installlib:
-	$(MAKE) -C libavutil installlib
-	$(MAKE) -C libavcodec installlib
-	$(MAKE) -C libavformat installlib
-
-dep:	depend
-
-depend: .depend
-	$(MAKE) -C libavcodec depend
-	$(MAKE) -C libavformat depend
-ifeq ($(BUILD_VHOOK),yes)
-	$(MAKE) -C vhook depend
-endif
-
-.depend: $(SRCS)
-	$(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $^ 1>.depend
-
-.libs: lib
-	@test -f .libs || touch .libs
-	@for i in $(DEP_LIBS) ; do if $(TEST) $$i -nt .libs ; then touch .libs; fi ; done
-
-clean:
-	$(MAKE) -C libavutil clean
-	$(MAKE) -C libavcodec clean
-	$(MAKE) -C libavformat clean
-	rm -f *.o *.d *~ .libs .depend gmon.out TAGS ffmpeg_g$(EXESUF) \
-	   ffplay_g$(EXESUF) $(PROG) $(PROGTEST) $(QTFASTSTART)
-
-clean-vhook:
-	$(MAKE) -C vhook clean
-
-# Note well: config.log is NOT removed.
-distclean: clean
-	$(MAKE) -C libavcodec distclean
-	rm -f config.mak config.h
-
-TAGS:
-	etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
-
-# regression tests
-
-libavtest test mpeg4 mpeg test-server fulltest: ffmpeg$(EXESUF)
-	$(MAKE) -C tests $@
-
-# tar release (use 'make -k tar' on a checkouted tree)
-FILE=ffmpeg-$(shell grep "\#define FFMPEG_VERSION " libavcodec/avcodec.h | \
-                    cut -d "\"" -f 2 )
-
-tar:
-	rm -rf /tmp/$(FILE)
-	cp -r . /tmp/$(FILE)
-	( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS )
-	rm -rf /tmp/$(FILE)
-
-.PHONY: lib
-
-ifneq ($(wildcard .depend),)
-include .depend
-endif
diff --git a/ffmpeg.src/README b/ffmpeg.src/README
deleted file mode 100644
index 9bc0f6e..0000000
--- a/ffmpeg.src/README
+++ /dev/null
@@ -1,19 +0,0 @@
-FFmpeg README
--------------
-
-1) Documentation
-----------------
-
-* Read the documentation in the doc/ directory.
-
-2) Licensing
-------------
-
-* Read the file COPYING. ffmpeg and the associated libraries EXCEPT
-  liba52 and libpostproc are licensed under the Lesser GNU General
-  Public License. 
-
-* liba52 and libpostproc are distributed under the GNU General Public
-  License and their compilation and use is optional in ffmpeg.
-
-Fabrice Bellard.
\ No newline at end of file
diff --git a/ffmpeg.src/berrno.h b/ffmpeg.src/berrno.h
deleted file mode 100644
index bfb91a0..0000000
--- a/ffmpeg.src/berrno.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef BERRNO_H
-#define BERRNO_H
-
-#include <Errors.h>
-
-// mmu_man: this is needed for http.c (defined errno)
-#include <errno.h>
-
-#ifdef ENOENT
-#undef ENOENT
-#endif 
-#define ENOENT 2
-
-#ifdef EINTR
-#undef EINTR
-#endif 
-#define EINTR  4
-
-#ifdef EIO
-#undef EIO
-#endif 
-#define EIO    5
-
-#ifdef EAGAIN
-#undef EAGAIN
-#endif 
-#define EAGAIN 11
-
-#ifdef ENOMEM
-#undef ENOMEM
-#endif 
-#define ENOMEM 12
-
-#ifdef EINVAL
-#undef EINVAL
-#endif 
-#define EINVAL 22
-
-#ifdef EPIPE
-#undef EPIPE
-#endif 
-#define EPIPE  32
-
-#endif /* BERRNO_H */
diff --git a/ffmpeg.src/configure b/ffmpeg.src/configure
deleted file mode 100755
index 76b642a..0000000
--- a/ffmpeg.src/configure
+++ /dev/null
@@ -1,1847 +0,0 @@
-#!/bin/sh
-#
-# ffmpeg configure script (c) 2000, 2001, 2002 Fabrice Bellard
-#
-
-if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
-cat << EOF
-
-Usage: configure [options]
-Options: [defaults in brackets after descriptions]
-
-EOF
-echo "Standard options:"
-echo "  --help                   print this message"
-echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
-echo "  --libdir=DIR             install libs in DIR [PREFIX/lib]"
-echo "  --mandir=DIR             man documentation in DIR [PREFIX/man]"
-echo "  --enable-mp3lame         enable mp3 encoding via libmp3lame [default=no]"
-echo "  --enable-libogg          enable ogg support via libogg [default=no]"
-echo "  --enable-vorbis          enable vorbis support via libvorbis [default=no]"
-echo "  --enable-theora          enable theora support via libtheora [default=no]"
-echo "  --enable-faad            enable faad support via libfaad [default=no]"
-echo "  --enable-faadbin         build faad support with runtime linking [default=no]"
-echo "  --enable-faac            enable faac support via libfaac [default=no]"
-echo "  --enable-libgsm          enable gsm support via libgsm [default=no]"
-echo "  --enable-xvid            enable xvid support via xvidcore [default=no]"
-echo "  --enable-x264            enable H.264 encoding via x264 [default=no]"
-echo "  --enable-mingw32         enable mingw32 native/cross windows compile"
-echo "  --enable-a52             enable GPL'ed A52 support [default=no]"
-echo "  --enable-a52bin          open liba52.so.0 at runtime [default=no]"
-echo "  --enable-dts             enable GPL'ed DTS support [default=no]"
-echo "  --enable-pp              enable GPL'ed post processing support [default=no]"
-echo "  --enable-shared-pp       use libpostproc.so [default=no]"
-echo "  --enable-shared          build shared libraries [default=no]"
-echo "  --enable-amr_nb          enable amr_nb float audio codec"
-echo "  --enable-amr_nb-fixed    use fixed point for amr-nb codec"
-echo "  --enable-amr_wb          enable amr_wb float audio codec"
-echo "  --enable-sunmlib         use Sun medialib [default=no]"
-echo "  --enable-pthreads        use pthreads [default=no]"
-echo "  --enable-dc1394          enable IIDC-1394 grabbing using libdc1394 and libraw1394 [default=no]"
-echo "  --enable-gpl             allow use of gpl code, the resulting libav* and ffmpeg will be under gpl [default=no]"
-echo ""
-echo "Advanced options (experts only):"
-echo "  --source-path=PATH       path of source code [$source_path]"
-echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
-echo "  --cc=CC                  use C compiler CC [$cc]"
-echo "  --make=MAKE              use specified make [$make]"
-echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
-echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
-echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
-echo "  --build-suffix=SUFFIX    suffix for application specific build []"
-echo "  --cpu=CPU                force cpu to CPU  [$cpu]"
-echo "  --tune=PROCESSOR         tune code for a particular CPU (may fails or misperforms on other CPUs)"
-echo "  --powerpc-perf-enable    enable performance report on PPC (requires enabling PMC)"
-echo "  --disable-mmx            disable mmx usage"
-echo "  --disable-iwmmxt         disable iwmmxt usage"
-echo "  --disable-altivec        disable AltiVec usage"
-echo "  --disable-audio-oss      disable OSS audio support [default=no]"
-echo "  --disable-audio-beos     disable BeOS audio support [default=no]"
-echo "  --disable-v4l            disable video4linux grabbing [default=no]"
-echo "  --disable-bktr           disable bktr video grabbing [default=no]"
-echo "  --disable-dv1394         disable DV1394 grabbing [default=no]"
-echo "  --disable-network        disable network support [default=no]"
-echo "  --disable-zlib           disable zlib [default=no]"
-echo "  --disable-simple_idct    disable simple IDCT routines [default=no]"
-echo "  --disable-vhook          disable video hooking support"
-echo "  --enable-gprof           enable profiling with gprof [$gprof]"
-echo "  --disable-debug          disable debugging symbols"
-echo "  --disable-opts           disable compiler optimizations"
-echo "  --disable-mpegaudio-hp   faster (but less accurate)"
-echo "                           mpegaudio decoding [default=no]"
-echo "  --disable-ffserver       disable ffserver build"
-echo "  --disable-ffplay         disable ffplay build"
-echo "  --enable-small           optimize for size instead of speed"
-echo "  --enable-memalign-hack   emulate memalign, interferes with memory debuggers"
-echo "  --disable-strip          disable stripping of executables and shared libraries"
-echo "  --enable-codec=codec     enables codec"
-echo "  --disable-codec=codec    disables codec"
-echo "  --disable-encoders       disables all encoders"
-echo "  --disable-decoders       disables all decoders"
-echo ""
-echo "NOTE: The object files are build at the place where configure is launched"
-exit 1
-fi
-
-# set temporary file name
-if test ! -z "$TMPDIR" ; then
-    TMPDIR1="${TMPDIR}"
-elif test ! -z "$TEMPDIR" ; then
-    TMPDIR1="${TEMPDIR}"
-else
-    TMPDIR1="/tmp"
-fi
-
-TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
-TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
-TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
-TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
-TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
-
-# default parameters
-prefix="/usr/local"
-libdir=""
-mandir=""
-bindir=""
-cross_prefix=""
-cc="gcc"
-ar="ar"
-ranlib="ranlib"
-make="make"
-strip="strip"
-cpu=`uname -m`
-tune="generic"
-powerpc_perf="no"
-mmx="default"
-iwmmxt="default"
-altivec="default"
-mmi="default"
-case "$cpu" in
-  i386|i486|i586|i686|i86pc|BePC)
-    cpu="x86"
-  ;;
-  x86_64|amd64)
-    cpu="x86"
-    canon_arch="`cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
-    if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
-      if [ -z "`echo $CFLAGS | grep -- -m32`"  ]; then
-        cpu="x86_64"
-      fi
-    fi
-  ;;
-  # armv4l is a subset of armv5tel
-  armv4l|armv5tel)
-    cpu="armv4l"
-  ;;
-  alpha)
-    cpu="alpha"
-  ;;
-  "Power Macintosh"|ppc)
-    cpu="powerpc"
-  ;;
-  mips)
-    cpu="mips"
-  ;;
-  sun4u|sparc64)
-    cpu="sparc64"
-  ;;
-  sparc)
-    cpu="sparc"
-  ;;
-  sh4)
-    cpu="sh4"
-  ;;
-  *)
-    cpu="unknown"
-  ;;
-esac
-gprof="no"
-v4l="yes"
-bktr="no"
-audio_oss="yes"
-audio_beos="no"
-dv1394="yes"
-dc1394="no"
-network="yes"
-zlib="yes"
-libgsm="no"
-mp3lame="no"
-libogg="no"
-vorbis="no"
-theora="no"
-faad="no"
-faadbin="no"
-faac="no"
-xvid="no"
-x264="no"
-a52="no"
-a52bin="no"
-dts="no"
-pp="no"
-shared_pp="no"
-mingw32="no"
-cygwin="no"
-os2="no"
-lshared="no"
-optimize="yes"
-debug="yes"
-dostrip="yes"
-extralibs="-lm"
-simpleidct="yes"
-bigendian="no"
-inttypes="yes"
-emu_fast_int="no"
-vhook="default"
-dlfcn="no"
-dlopen="no"
-mpegaudio_hp="yes"
-SHFLAGS=-shared
-netserver="no"
-need_inet_aton="no"
-ffserver="yes"
-ffplay="yes"
-LIBOBJFLAGS=""
-LDFLAGS=-Wl,--warn-common
-FFSLDFLAGS=-Wl,-E
-LDCONFIG="ldconfig"
-LIBPREF="lib"
-LIBSUF=".a"
-SLIBPREF="lib"
-SLIBSUF=".so"
-EXESUF=""
-BUILDSUF=""
-amr_nb="no"
-amr_wb="no"
-amr_nb_fixed="no"
-amr_if2="no"
-sunmlib="no"
-pthreads="no"
-gpl="no"
-memalignhack="no"
-
-# OS specific
-targetos=`uname -s`
-case $targetos in
-BeOS)
-prefix="/boot/home/config"
-# helps building libavcodec
-CFLAGS="-DPIC -fomit-frame-pointer"
-# 3 gcc releases known for BeOS, each with ugly bugs
-gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
-case "$gcc_version" in
-2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
-mmx="no"
-;;
-*20010315*) echo "BeBits gcc"
-CFLAGS="$CFLAGS -fno-expensive-optimizations"
-;;
-esac
-SHFLAGS=-nostart
-# disable linux things
-audio_oss="no"
-v4l="no"
-dv1394="no"
-# enable beos things
-audio_beos="yes"
-# no need for libm, but the inet stuff
-# Check for BONE
-if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
-extralibs="-lbind -lsocket"
-else
-netserver="yes"
-need_inet_aton="yes"
-extralibs="-lnet"
-fi ;;
-SunOS)
-v4l="no"
-audio_oss="no"
-dv1394="no"
-make="gmake"
-LDFLAGS=""
-FFSLDFLAGS=""
-need_inet_aton="yes"
-extralibs="$extralibs -lsocket -lnsl"
-;;
-NetBSD)
-v4l="no"
-bktr="yes"
-audio_oss="yes"
-dv1394="no"
-make="gmake"
-LDFLAGS="$LDFLAGS -export-dynamic"
-case `uname -r` in
-2.*) extralibs="-lossaudio"
-;;
-esac
-;;
-OpenBSD)
-v4l="no"
-bktr="yes"
-audio_oss="yes"
-dv1394="no"
-make="gmake"
-LIBOBJFLAGS="\$(PIC)"
-LDFLAGS="$LDFLAGS -export-dynamic -pthread"
-LDCONFIG="ldconfig -m \$(libdir)"
-extralibs="$extralibs -lossaudio"
-;;
-FreeBSD)
-v4l="no"
-bktr="yes"
-audio_oss="yes"
-dv1394="no"
-make="gmake"
-CFLAGS="-pthread"
-LDFLAGS="$LDFLAGS -export-dynamic -pthread"
-;;
-BSD/OS)
-v4l="no"
-bktr="yes"
-audio_oss="yes"
-dv1394="no"
-extralibs="-lpoll -lgnugetopt -lm"
-make="gmake"
-;;
-Darwin)
-cc="cc"
-v4l="no"
-audio_oss="no"
-dv1394="no"
-ffserver="no"
-SHFLAGS="-dynamiclib"
-extralibs=""
-darwin="yes"
-strip="strip -x"
-LDFLAGS="-Wl,-search_paths_first"
-FFSLDFLAGS=-Wl,-bind_at_load
-;;
-MINGW32*)
-# Note: the rest of the mingw32 config is done afterwards as mingw32
-# can be forced on command line for linux cross compilation
-mingw32="yes"
-;;
-CYGWIN*)
-v4l="no"
-audio_oss="yes"
-dv1394="no"
-ffserver="no"
-extralibs=""
-cygwin="yes"
-EXESUF=".exe"
-;;
-Linux)
-LDFLAGS="$LDFLAGS -rdynamic"
-;;
-IRIX*)
-ranlib="echo ignoring ranlib"
-v4l="no"
-audio_oss="no"
-make="gmake"
-;;
-OS/2)
-TMPE=$TMPE".exe"
-ar="emxomfar -p128"
-ranlib="echo ignoring ranlib"
-strip="echo ignoring strip"
-CFLAGS="-Zomf"
-LDFLAGS="-Zomf -Zstack 16384 -s"
-SHFLAGS="-Zdll -Zomf"
-FFSLDFLAGS=""
-LIBPREF=""
-LIBSUF=".lib"
-SLIBPREF=""
-SLIBSUF=".dll"
-EXESUF=".exe"
-extralibs=""
-v4l="no"
-audio_oss="no"
-dv1394="no"
-network="no"
-ffserver="no"
-vhook="no"
-os2="yes"
-
-;;
-*) ;;
-esac
-
-# From mplayer configure. We need TARGET_OS available
-# to the Makefile, so it can distinguish between flavors
-# of AltiVec on PowerPC
-TARGET_OS=`( uname -s ) 2>&1`
-  case "$TARGET_OS" in
-  Linux|FreeBSD|NetBSD|BSD/OS|OpenBSD|SunOS|QNX|Darwin|GNU|BeOS)
-    ;;
-  IRIX*)
-    TARGET_OS=IRIX
-    ;;
-  HP-UX*)
-    TARGET_OS=HP-UX
-    ;;
-  [cC][yY][gG][wW][iI][nN]*)
-    TARGET_OS=CYGWIN
-    ;;
-  *)
-    TARGET_OS="$TARGET_OS-UNKNOWN"
-    ;;
-  esac
-
-# find source path
-source_path="`echo $0 | sed -e 's#/configure##'`"
-source_path_used="yes"
-if test -z "$source_path" -o "$source_path" = "." ; then
-    source_path=`pwd`
-    source_path_used="no"
-else
-    source_path="`cd \"$source_path\"; pwd`"
-fi
-
-FFMPEG_CONFIGURATION=" "
-for opt do
-  FFMPEG_CONFIGURATION="$FFMPEG_CONFIGURATION""$opt "
-done
-
-CODEC_LIST=`grep 'register_avcodec(&[a-z]' $source_path/libavcodec/allcodecs.c  | sed 's/.*&\(.*\)).*/\1/'`
-
-for opt do
-  case "$opt" in
-  --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`; force_prefix=yes
-  ;;
-  --libdir=*) libdir=`echo $opt | cut -d '=' -f 2`; force_libdir=yes
-  ;;
-  --mandir=*) mandir=`echo $opt | cut -d '=' -f 2`
-  ;;
-  --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
-  ;;
-  --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
-  ;;
-  --cc=*) cc=`echo $opt | cut -d '=' -f 2-`
-  ;;
-  --make=*) make=`echo $opt | cut -d '=' -f 2`
-  ;;
-  --extra-cflags=*) CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
-  ;;
-  --extra-ldflags=*) LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
-  ;;
-  --extra-libs=*) extralibs=${opt#--extra-libs=}
-  ;;
-  --build-suffix=*) BUILDSUF=${opt#--build-suffix=}
-  ;;
-  --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
-  ;;
-  --tune=*) tune=`echo $opt | cut -d '=' -f 2`
-  ;;
-  --powerpc-perf-enable) powerpc_perf="yes"
-  ;;
-  --disable-mmx) mmx="no"
-  ;;
-  --disable-iwmmxt) iwmmxt="no"
-  ;;
-  --disable-altivec) altivec="no"
-  ;;
-  --enable-gprof) gprof="yes"
-  ;;
-  --disable-v4l) v4l="no"
-  ;;
-  --disable-bktr) bktr="no"
-  ;;
-  --disable-audio-oss) audio_oss="no"
-  ;;
-  --disable-audio-beos) audio_beos="no"
-  ;;
-  --disable-dv1394) dv1394="no"
-  ;;
-  --disable-network) network="no"; ffserver="no"
-  ;;
-  --disable-zlib) zlib="no"
-  ;;
-  --enable-a52) a52="yes"
-  ;;
-  --enable-a52bin) a52bin="yes"
-  ;;
-  --enable-dts) dts="yes" ; extralibs="$extralibs -ldts"
-  ;;
-  --enable-pp) pp="yes"
-  ;;
-  --enable-shared-pp) shared_pp="yes"
-  ;;
-  --enable-libgsm) libgsm="yes"
-  ;;
-  --enable-mp3lame) mp3lame="yes"
-  ;;
-  --enable-libogg) libogg="yes"
-  ;;
-  --enable-vorbis) vorbis="yes"
-  ;;
-  --enable-theora) theora="yes"
-  ;;
-  --enable-faad) faad="yes"
-  ;;
-  --enable-faadbin) faadbin="yes"
-  ;;
-  --enable-faac) faac="yes"
-  ;;
-  --enable-xvid) xvid="yes"
-  ;;
-  --enable-x264) x264="yes"; extralibs="$extralibs -lx264"
-  ;;
-  --enable-dc1394) dc1394="yes"
-  ;;
-  --disable-vhook) vhook="no"
-  ;;
-  --disable-simple_idct) simpleidct="no"
-  ;;
-  --enable-mingw32) mingw32="yes"
-  ;;
-  --enable-shared) lshared="yes"
-  ;;
-  --disable-debug) debug="no"
-  ;;
-  --disable-opts) optimize="no"
-  ;;
-  --disable-mpegaudio-hp) mpegaudio_hp="no"
-  ;;
-  --disable-ffserver) ffserver="no"
-  ;;
-  --disable-ffplay) ffplay="no"
-  ;;
-  --enable-small) optimize="small"
-  ;;
-  --enable-amr_nb) amr_nb="yes"
-  ;;
-  --enable-amr_nb-fixed) amr_nb_fixed="yes"
-  ;;
-  --enable-amr_wb) amr_wb="yes"
-  ;; 
-  --enable-amr_if2) amr_if2="yes"
-  ;;
-  --enable-sunmlib) sunmlib="yes"
-  ;;
-  --enable-pthreads) pthreads="yes"
-  ;;
-  --enable-gpl) gpl="yes"
-  ;;
-  --enable-memalign-hack) memalignhack="yes"
-  ;;
-  --disable-strip) dostrip="no"
-  ;;
-  --enable-codec=*) CODEC_LIST="$CODEC_LIST ${opt#--enable-codec=}"
-  ;;
-  --disable-codec=*) CODEC_LIST="`echo $CODEC_LIST | sed -e \"s#${opt#--disable-codec=}##\"`"
-  ;;
-  --disable-encoders) CODEC_LIST="`echo $CODEC_LIST | sed 's/[-_a-zA-Z0-9]*encoder//g'`"
-  ;;
-  --disable-decoders) CODEC_LIST="`echo $CODEC_LIST | sed 's/[-_a-zA-Z0-9]*decoder//g'`"
-  ;;
-  esac
-done
-
-if test "$theora" = "yes" ; then
-    if test "$libogg" = "no"; then
-        echo "libogg must be enabled to enable Theora"     
-        fail="yes"
-        theora="no"
-    fi
-fi
-
-if test "$vorbis" = "yes" ; then
-    if test "$libogg" = "no"; then
-        echo "libogg must be enabled to enable Vorbis"
-        fail="yes"
-        vorbis="no"
-    fi
-fi
-
-if test "$gpl" != "yes"; then
-    if test "$pp" != "no" -o "$shared_pp" != "no"; then
-        echo "The Postprocessing code is under GPL and --enable-gpl is not specified"
-        fail="yes"
-    fi
-
-    if test "$a52" != "no" -o "$a52bin" != "no"; then
-        echo "liba52 is under GPL and --enable-gpl is not specified"
-        fail="yes"
-    fi
-
-    if test "$xvid" != "no"; then
-        echo "libxvidcore is under GPL and --enable-gpl is not specified"
-        fail="yes"
-    fi
-
-    if test "$x264" != "no"; then
-        echo "x264 is under GPL and --enable-gpl is not specified"
-        fail="yes"
-    fi
-
-    if test "$dts" != "no"; then
-        echo "libdts is under GPL and --enable-gpl is not specified"
-        fail="yes"
-    fi
-    
-    if test "$faad" != "no" -o "$faadbin" != "no"; then
-        cat > $TMPC << EOF
-            #include <faad.h>
-            int main( void ) { return 0; }
-EOF
-    
-        if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
-            cat > $TMPC << EOF
-                #include <faad.h>
-                #ifndef FAAD2_VERSION
-                ok faad1
-                #endif
-                int main( void ) { return 0; }
-EOF
-            if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
-                echo "faad2 is under GPL and --enable-gpl is not specified"
-                fail="yes"
-            fi
-        else
-            faad="no"
-            faadbin="no"
-            echo "faad test failed"
-        fi
-    fi
-   
-
-    if test "$fail" = "yes"; then
-        exit 1
-    fi
-fi
-
-# compute mmx state
-if test $mmx = "default"; then
-    if test $cpu = "x86" -o $cpu = "x86_64"; then
-        mmx="yes"
-    else
-        mmx="no"
-    fi
-fi
-
-# check iwmmxt support
-if test $iwmmxt = "default" -a $cpu = "armv4l"; then
-    cat > $TMPC << EOF
-        int main(void) { 
-        __asm__ __volatile__ ("wunpckelub wr6, wr4");
-        }
-EOF
-
-    iwmmxt=no
-    if ${cross_prefix}${cc} -o $TMPO $TMPC 2> /dev/null ; then
-        iwmmxt=yes
-    fi
-fi
-
-#Darwin CC versions
-needmdynamicnopic="no"
-if test $targetos = Darwin; then
-    if test -n "`$cc -v 2>&1 | grep xlc`"; then
-	CFLAGS="$CFLAGS -qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
-    else
-	gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
-	case "$gcc_version" in
-	    *2.95*) 
-		CFLAGS="$CFLAGS -no-cpp-precomp -pipe -fomit-frame-pointer"
-		;;
-	    *[34].*)
-		CFLAGS="$CFLAGS -no-cpp-precomp -pipe -fomit-frame-pointer -force_cpusubtype_ALL -Wno-sign-compare"
-		if test "$lshared" = no; then
-		   needmdynamicnopic="yes"
-		fi
-		;;
-	    *)
-		CFLAGS="$CFLAGS -no-cpp-precomp -pipe -fomit-frame-pointer"
-		if test "$lshared" = no; then
-		   needmdynamicnopic="yes"
-		fi
-		;;
-	esac
-    fi
-fi
-
-# Can only do AltiVec on PowerPC
-if test $altivec = "default"; then
-    if test $cpu = "powerpc"; then
-        altivec="yes"
-    else
-        altivec="no"
-    fi
-fi
-
-# Add processor-specific flags
-TUNECPU="generic"
-POWERPCMODE="32bits"
-if test $tune != "generic"; then
-    case $tune in
-	601|ppc601|PowerPC601)
-	    CFLAGS="$CFLAGS -mcpu=601"
-	    if test $altivec = "yes"; then
-		echo "WARNING: tuning for PPC601 but altivec enabled !";
-	    fi
-	    TUNECPU=ppc601
-	;;
-	603*|ppc603*|PowerPC603*)
-	    CFLAGS="$CFLAGS -mcpu=603"
-	    if test $altivec = "yes"; then
-		echo "WARNING: tuning for PPC603 but altivec enabled !";
-	    fi
-	    TUNECPU=ppc603
-	;;
-	604*|ppc604*|PowerPC604*)
-	    CFLAGS="$CFLAGS -mcpu=604"
-	    if test $altivec = "yes"; then
-		echo "WARNING: tuning for PPC604 but altivec enabled !";
-	    fi
-	    TUNECPU=ppc604
-	;;
-	G3|g3|75*|ppc75*|PowerPC75*)
-	    CFLAGS="$CFLAGS -mcpu=750 -mtune=750 -mpowerpc-gfxopt"
-	    if test $altivec = "yes"; then
-		echo "WARNING: tuning for PPC75x but altivec enabled !";
-	    fi
-	    TUNECPU=ppc750
-	;;
-	G4|g4|745*|ppc745*|PowerPC745*)
-	    CFLAGS="$CFLAGS -mcpu=7450 -mtune=7450 -mpowerpc-gfxopt"
-	    if test $altivec = "no"; then
-		echo "WARNING: tuning for PPC745x but altivec disabled !";
-	    fi
-	    TUNECPU=ppc7450
-	;;
-	74*|ppc74*|PowerPC74*)
-	    CFLAGS="$CFLAGS -mcpu=7400 -mtune=7400 -mpowerpc-gfxopt"
-	    if test $altivec = "no"; then
-		echo "WARNING: tuning for PPC74xx but altivec disabled !";
-	    fi
-	    TUNECPU=ppc7400
-	;;
-	G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
-	    CFLAGS="$CFLAGS -mcpu=970 -mtune=970 -mpowerpc-gfxopt -mpowerpc64"
-	    if test $altivec = "no"; then
-		echo "WARNING: tuning for PPC970 but altivec disabled !";
-	    fi
-	    TUNECPU=ppc970
-            POWERPCMODE="64bits"
-	;;
-	i[3456]86|pentium|pentiumpro|pentium-mmx|pentium[234]|prescott|k6|k6-[23]|athlon|athlon-tbird|athlon-4|athlon-[mx]p|winchip-c6|winchip2|c3|nocona)
-	    CFLAGS="$CFLAGS -march=$tune"
-	;;
-	*)
-	echo "WARNING: unknown CPU \"$tune\", ignored"
-	;;
-    esac
-fi
-
-# AltiVec flags: The FSF version of GCC differs from the Apple version 
-if test $cpu = "powerpc"; then
-    if test $altivec = "yes"; then
-        if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
-            CFLAGS="$CFLAGS -faltivec"
-        else
-            CFLAGS="$CFLAGS -maltivec -mabi=altivec"
-        fi
-    fi
-fi
-
-# See if we have <altivec.h>
-cat > $TMPC << EOF
-#include <altivec.h>
-int main( void ) { return 0; }
-EOF
-
-_altivec_h="no"
-if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
-_altivec_h="yes"
-fi
-
-# See does our compiler support Motorola AltiVec C API
-if test $altivec = "yes"; then
-if test $_altivec_h = "yes"; then
-cat > $TMPC << EOF
-#include <altivec.h>
-int main(void) {
-    vector signed int v1, v2, v3;
-    v1 = vec_add(v2,v3);
-    return 0;
-}
-EOF
-else
-cat > $TMPC << EOF
-int main(void) {
-    vector signed int v1, v2, v3;
-    v1 = vec_add(v2,v3);
-    return 0;
-}
-EOF
-fi
-$cc $CFLAGS -o $TMPE $TMPC 2> /dev/null || altivec="no"
-fi
-
-# Can only do mmi on mips
-if test $mmi = "default"; then
-    if test $cpu = "mips"; then
-        mmi="yes"
-    else
-        mmi="no"
-    fi
-fi
-
-# See does our compiler support mmi
-if test $mmi = "yes"; then
-cat > $TMPC << EOF
-int main(void) {
-    __asm__ ("lq \$2, 0(\$2)");
-    return 0;
-}
-EOF
-$cc -o $TMPE $TMPC 2> /dev/null || mmi="no"
-fi
-
-if test "$mingw32" = "yes" ; then
-    v4l="no"
-    bktr="no"
-    audio_oss="no"
-    dv1394="no"
-    dc1394="no"
-    ffserver="no"
-    network="no"
-    SLIBPREF=""
-    SLIBSUF=".dll"
-    EXESUF=".exe"
-    if test "$force_prefix" != yes; then prefix="/c/Program Files/FFmpeg"; fi
-    if test "$force_libdir" != yes; then bindir="$prefix"; fi
-fi
-
-cc="${cross_prefix}${cc}"
-ar="${cross_prefix}${ar}"
-ranlib="${cross_prefix}${ranlib}"
-strip="${cross_prefix}${strip}"
-
-if test -z "$cross_prefix" ; then
-
-# ---
-# big/little endian test
-cat > $TMPC << EOF
-#include <inttypes.h>
-int main(int argc, char ** argv){
-	volatile uint32_t i=0x01234567;
-	return (*((uint8_t*)(&i))) == 0x67;
-}
-EOF
-
-if $cc -o $TMPE $TMPC 2>/dev/null ; then
-$TMPE && bigendian="yes"
-else
-echo big/little test failed
-fi
-
-else
-
-# if cross compiling, cannot launch a program, so make a static guess
-if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
-    bigendian="yes"
-fi
-
-fi
-
-# ---
-# *inttypes.h* test
-cat > $TMPC << EOF
-#include <inttypes.h>
-int main(int argc, char ** argv){
-    return 0;
-}
-EOF
-
-$cc -o $TMPE $TMPC 2>/dev/null || inttypes="no"
-
-# ---
-# *int_fast* test
-cat > $TMPC << EOF
-#include <inttypes.h>
-int main(int argc, char ** argv){
-	volatile uint_fast64_t i=0x01234567;
-	return 0;
-}
-EOF
-
-$cc -o $TMPE $TMPC 2>/dev/null || emu_fast_int="yes"
-
-# ---
-# check availability of some header files
-
-cat > $TMPC << EOF
-#include <malloc.h>
-int main( void ) { return 0; }
-EOF
-
-_memalign=no
-_malloc_h=no
-if $cc -o $TMPE $TMPC 2> /dev/null ; then
-_malloc_h=yes
-_memalign=yes
-# check for memalign - atmos
-cat > $TMPC << EOF
-#include <stdio.h>
-#include <malloc.h>
-int main ( void ) {
-char *string = NULL;
-string = memalign(64, sizeof(char));
-return 0;
-}
-EOF
-$cc -o $TMPE $TMPC 2> /dev/null || _memalign=no
-fi
-
-if test "$_memalign" = "no" -a "$mmx" = "yes" -a "$memalignhack" != "yes"; then
-    echo "error, no memalign() but sse enabled, either disable it or use --enable-memalign-hack"
-    exit 1
-fi
-
-cat > $TMPC << EOF
-#include <time.h>
-int main( void ) { localtime_r(NULL, NULL); }
-EOF
-
-localtime_r=no
-if $cc -o $TMPE $TMPC 2> /dev/null ; then
-  localtime_r=yes
-fi
-
-if test "$zlib" = "yes"; then
-# check for zlib - mmu_man
-cat > $TMPC << EOF
-#include <zlib.h>
-int main ( void ) {
-if (zlibVersion() != ZLIB_VERSION)
-   puts("zlib version differs !!!");
-   return 1;
-return 0;
-}
-EOF
-$cc $CFLAGS $LDFLAGS -o $TMPE $TMPC -lz 2> /dev/null || zlib="no"
-# $TMPE 2> /dev/null > /dev/null || zlib="no"
-# XXX: more tests needed - runtime test
-fi
-if test "$zlib" = "yes"; then
-extralibs="$extralibs -lz"
-fi
-
-# test for lrintf in math.h
-cat > $TMPC << EOF
-#define _ISOC9X_SOURCE  1
-#include <math.h>
-int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
-EOF
-
-have_lrintf="no"
-if $cc $extralibs -o $TMPE $TMPC 2> /dev/null ; then
-  have_lrintf="yes"
-  # allanc at chickenandporn.com: cannot execute cross-compiled
-  # code on the host.  Only execute if not cross-compiling.
-  if test -z "$cross_prefix" ; then
-    $TMPE 2> /dev/null > /dev/null || have_lrintf="no"
-  fi
-fi
-
-_restrict=
-for restrict_keyword in restrict __restrict__ __restrict; do
-  echo "void foo(char * $restrict_keyword p);" > $TMPC
-  if $cc -c -o $TMPO $TMPC 2> /dev/null; then
-    _restrict=$restrict_keyword
-    break;
-  fi
-done
-
-# test gcc version to see if vector builtins can be used
-# currently only used on i386 for MMX builtins
-cat > $TMPC << EOF
-#include <xmmintrin.h>
-int main(void) { 
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)
-return 0;
-#else
-#error no vector builtins
-#endif
-}
-EOF
-
-builtin_vector=no
-if $cc -msse -o $TMPO $TMPC 2> /dev/null ; then
-  builtin_vector=yes
-fi
-
-# dlopen/dlfcn.h probing
-
-cat > $TMPC << EOF
-#include <dlfcn.h>
-int main( void ) { return (int) dlopen("foo", 0); }
-EOF
-
-ldl=-ldl
-
-if $cc -o $TMPE $TMPC -ldl > /dev/null 2>&1 ; then
-dlfcn=yes
-dlopen=yes
-fi
-
-if $cc -o $TMPE $TMPC > /dev/null 2>&1 ; then
-dlfcn=yes
-dlopen=yes
-ldl=""
-fi
-
-cat > $TMPC << EOF
-int main( void ) { return (int) dlopen("foo", 0); }
-EOF
-
-if $cc -o $TMPE $TMPC -ldl > /dev/null 2>&1  ; then
-dlopen=yes
-fi
-
-if $cc -o $TMPE $TMPC > /dev/null 2>&1  ; then
-dlopen=yes
-ldl=""
-fi
-
-if test "$vhook" = "default" ; then
-  vhook="$dlopen"
-fi
-
-if test "$vhook" = "yes" -o "$a52bin" = "yes" -o "$faadbin" = "yes"; then
-  extralibs="$extralibs $ldl"
-fi
-
-
-##########################################
-# imlib probe
-
-cat > $TMPC << EOF
-#include <X11/Xlib.h>
-#include <Imlib2.h>
-int main( void ) { return (int) imlib_load_font("foo"); }
-EOF
-
-imlib2=no
-if $cc $CFLAGS $LDFLAGS -o $TMPE $TMPC -lImlib2 -lm > /dev/null 2>&1  ; then
-imlib2=yes
-fi
-
-##########################################
-# freetype probe
-
-cat > $TMPC << EOF
-#include <ft2build.h>
-int main( void ) { return (int) FT_Init_FreeType(0); }
-EOF
-
-freetype2=no
-if test "x$targetos" != "xBeOS" && test "$os2" != "yes"; then
-  if (freetype-config --version) >/dev/null 2>&1 ; then
-    if $cc -o $TMPE $TMPC `freetype-config --cflags` `freetype-config --libs`  > /dev/null 2>&1 ; then
-      freetype2=yes
-    fi
-  fi
-fi
-
-##########################################
-# SDL probe
-
-cat > $TMPC << EOF
-#include <SDL.h>
-#undef main /* We don't want SDL to override our main() */
-int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
-EOF
-
-sdl_too_old=no
-sdl=no
-if (sdl-config --version) >/dev/null 2>&1 ; then
-if $cc -o $TMPE `sdl-config --cflags` $TMPC `sdl-config --libs`  > /dev/null 2>&1  ; then
-_sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
-if test "$_sdlversion" -lt 121 ; then
-sdl_too_old=yes
-else
-sdl=yes
-fi
-fi
-fi
-
-##########################################
-# texi2html probe
-
-texi2html=no
-if (texi2html -version) >/dev/null 2>&1; then
-texi2html=yes
-fi
-
-if test "$network" = "yes" ; then
-##########################################
-# IPv6 probe
-
-cat > $TMPC << EOF
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-int main( void ) {
-  struct sockaddr_storage saddr;
-  struct ipv6_mreq mreq6;
-  getaddrinfo(0,0,0,0);
-  getnameinfo(0,0,0,0,0,0,0);
-  IN6_IS_ADDR_MULTICAST(0);
-}
-EOF
-
-ipv6=no
-if $cc -o $TMPE $TMPC > /dev/null 2>&1  ; then
-ipv6=yes
-fi
-fi
-
-case "`$cc -v 2>&1 | grep version`" in
-    *gcc*)
-	CFLAGS="-Wall -Wno-switch $CFLAGS"
-	;;
-    *)
-	;;
-esac
-
-if test "$sdl" = "no" ; then
-   ffplay=no
-fi
-
-if test "$debug" = "yes"; then
-	CFLAGS="-g $CFLAGS"
-fi
-
-if test "$optimize" = "small"; then
-#  CFLAGS=${CFLAGS//-O3/-Os}
-  CFLAGS="$CFLAGS -Os"
-fi
-
-if test "$optimize" = "yes"; then
-    if test -n "`$cc -v 2>&1 | grep xlc`"; then
-	CFLAGS="$CFLAGS -O5"
-	LDFLAGS="$LDFLAGS -O5"
-    else
-	CFLAGS="-O3 $CFLAGS"
-    fi
-fi
-
-# PIC flags for shared library objects where they are needed
-if test "$lshared" = "yes" ; then
-  # LIBOBJFLAGS may have already been set in the OS configuration
-  if test -z "$LIBOBJFLAGS" ; then
-    if test "$cpu" = "x86_64" -o "$cpu" = "ia64" ; then
-      LIBOBJFLAGS="\$(PIC)"
-    fi
-  fi
-fi
-
-if test x"$bindir" = x""; then
-bindir="${prefix}/bin"
-fi
-
-if test x"$libdir" = x""; then
-libdir="${prefix}/lib"
-fi
-
-if test x"$mandir" = x""; then
-mandir="${prefix}/man"
-fi
-
-echo "Install prefix   $prefix"
-echo "Source path      $source_path"
-echo "C compiler       $cc"
-echo "make             $make"
-echo "CPU              $cpu ($tune)"
-if test "$BUILDSUF" != ""; then
-echo "Build suffix     $BUILDSUF"
-fi
-echo "Big Endian       $bigendian"
-echo "inttypes.h       $inttypes"
-echo "broken inttypes.h $emu_fast_int"
-if test $cpu = "x86" -o $cpu = "x86_64"; then
-echo "MMX enabled      $mmx"
-echo "Vector Builtins  $builtin_vector"
-fi
-if test $cpu = "armv4l"; then
-echo "IWMMXT enabled   $iwmmxt"
-fi
-if test $cpu = "mips"; then
-echo "MMI enabled      $mmi"
-fi
-if test $cpu = "powerpc"; then
-echo "AltiVec enabled  $altivec"
-fi
-echo "gprof enabled    $gprof"
-echo "zlib enabled     $zlib"
-echo "libgsm enabled   $libgsm"
-echo "mp3lame enabled  $mp3lame"
-echo "libogg enabled   $libogg"
-echo "vorbis enabled   $vorbis"
-echo "theora enabled   $theora"
-echo "faad enabled     $faad"
-echo "faadbin enabled  $faadbin"
-echo "faac enabled     $faac"
-echo "xvid enabled     $xvid"
-echo "x264 enabled     $x264"
-echo "a52 support      $a52"
-echo "a52 dlopened     $a52bin"
-echo "dts support      $dts"
-echo "pp support       $pp"
-echo "debug symbols    $debug"
-echo "strip symbols    $dostrip"
-echo "optimize         $optimize"
-echo "shared pp        $shared_pp"
-echo "Video hooking    $vhook"
-echo "SDL support      $sdl"
-if test $sdl_too_old = "yes"; then
-echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support"
-fi
-
-if test "$vhook" = "yes" ; then
-echo "Imlib2 support   $imlib2"
-echo "freetype support $freetype2"
-fi
-echo "Sun medialib support"  $sunmlib
-echo "pthreads support"      $pthreads
-echo "AMR-NB float support"  $amr_nb
-echo "AMR-NB fixed support"  $amr_nb_fixed
-echo "AMR-WB float support"  $amr_wb
-echo "AMR-WB IF2 support"    $amr_if2
-echo "network support      $network"
-if test "$network" = "yes" ; then
-echo "IPv6 support         $ipv6"
-fi
-if test "$gpl" = "no" ; then
-echo "License: LGPL"
-else
-echo "License: GPL"
-fi
-
-echo "Creating config.mak and config.h"
-
-date >> config.log
-echo "   $0 $FFMPEG_CONFIGURATION" >> config.log
-echo "# Automatically generated by configure - do not modify" > config.mak
-echo "/* Automatically generated by configure - do not modify */" > $TMPH
-echo "#define FFMPEG_CONFIGURATION "'"'"$FFMPEG_CONFIGURATION"'"' >> $TMPH
-
-echo "prefix=$prefix" >> config.mak
-echo "libdir=$libdir" >> config.mak
-echo "bindir=$bindir" >> config.mak
-echo "mandir=$mandir" >> config.mak
-echo "MAKE=$make" >> config.mak
-echo "CC=$cc" >> config.mak
-echo "AR=$ar" >> config.mak
-echo "RANLIB=$ranlib" >> config.mak
-if test "$dostrip" = "yes" ; then
-echo "STRIP=$strip" >> config.mak
-echo "INSTALLSTRIP=-s" >> config.mak
-else
-echo "STRIP=echo ignoring strip" >> config.mak
-echo "INSTALLSTRIP=" >> config.mak
-fi
-
-# SHCFLAGS is a copy of CFLAGS without -mdynamic-no-pic.  Used when building 
-# shared modules on OS/X (vhook/Makefile).
-SHCFLAGS=$CFLAGS
-if test "$needmdynamicnopic" = yes; then
-   CFLAGS="$CFLAGS -mdynamic-no-pic"
-fi
-
-echo "OPTFLAGS=$CFLAGS" >> config.mak
-echo "SHCFLAGS=$SHCFLAGS">>config.mak
-echo "LDFLAGS=$LDFLAGS" >> config.mak
-echo "LDCONFIG=$LDCONFIG" >> config.mak
-echo "FFSLDFLAGS=$FFSLDFLAGS" >> config.mak
-echo "SHFLAGS=$SHFLAGS" >> config.mak
-echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
-echo "BUILDSUF=$BUILDSUF" >> config.mak
-echo "LIBPREF=$LIBPREF" >> config.mak
-echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
-echo "SLIBPREF=$SLIBPREF" >> config.mak
-echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
-echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
-echo "TARGET_OS=$TARGET_OS" >> config.mak
-if test "$cpu" = "x86" ; then
-  echo "TARGET_ARCH_X86=yes" >> config.mak
-  echo "#define ARCH_X86 1" >> $TMPH
-elif test "$cpu" = "x86_64" ; then
-  echo "TARGET_ARCH_X86_64=yes" >> config.mak
-  echo "#define ARCH_X86_64 1" >> $TMPH
-elif test "$cpu" = "armv4l" ; then
-  echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
-  echo "#define ARCH_ARMV4L 1" >> $TMPH
-elif test "$cpu" = "alpha" ; then
-  echo "TARGET_ARCH_ALPHA=yes" >> config.mak
-  echo "#define ARCH_ALPHA 1" >> $TMPH
-elif test "$cpu" = "sparc64" ; then
-  echo "TARGET_ARCH_SPARC64=yes" >> config.mak
-  echo "#define ARCH_SPARC64 1" >> $TMPH
-  echo "TARGET_ARCH_SPARC=yes" >> config.mak
-  echo "#define ARCH_SPARC 1" >> $TMPH
-elif test "$cpu" = "sparc" ; then
-  echo "TARGET_ARCH_SPARC=yes" >> config.mak
-  echo "#define ARCH_SPARC 1" >> $TMPH
-elif test "$cpu" = "powerpc" ; then
-  echo "TARGET_ARCH_POWERPC=yes" >> config.mak
-  echo "#define ARCH_POWERPC 1" >> $TMPH
-  if test $POWERPCMODE = "32bits"; then
-    echo "#define POWERPC_MODE_32BITS 1" >> $TMPH
-  else
-    echo "#define POWERPC_MODE_64BITS 1" >> $TMPH
-  fi
-  if test "$powerpc_perf" = "yes"; then
-    echo "#define POWERPC_PERFORMANCE_REPORT 1" >> $TMPH
-  fi
-elif test "$cpu" = "mips" ; then
-  echo "TARGET_ARCH_MIPS=yes" >> config.mak
-  echo "#define ARCH_MIPS 1" >> $TMPH
-elif test "$cpu" = "sh4" ; then
-  echo "TARGET_ARCH_SH4=yes" >> config.mak
-  echo "#define ARCH_SH4 1" >> $TMPH
-fi
-echo "#define TUNECPU $TUNECPU" >> $TMPH
-if test "$bigendian" = "yes" ; then
-  echo "WORDS_BIGENDIAN=yes" >> config.mak
-  echo "#define WORDS_BIGENDIAN 1" >> $TMPH
-fi
-if test "$inttypes" != "yes" ; then
-  echo "#define EMULATE_INTTYPES 1" >> $TMPH
-fi
-if test "$emu_fast_int" = "yes" ; then
-  echo "#define EMULATE_FAST_INT 1" >> $TMPH
-fi
-if test "$mmx" = "yes" ; then
-  echo "TARGET_MMX=yes" >> config.mak
-  echo "#define HAVE_MMX 1" >> $TMPH
-  echo "#define __CPU__ 586" >> $TMPH
-fi
-if test "$builtin_vector" = "yes" ; then
-  echo "TARGET_BUILTIN_VECTOR=yes" >> config.mak
-  echo "#define HAVE_BUILTIN_VECTOR 1" >> $TMPH
-fi
-if test "$iwmmxt" = "yes" ; then
-  echo "TARGET_IWMMXT=yes" >> config.mak
-  echo "#define HAVE_IWMMXT 1" >> $TMPH
-fi
-if test "$mmi" = "yes" ; then
-  echo "TARGET_MMI=yes" >> config.mak
-  echo "#define HAVE_MMI 1" >> $TMPH
-fi
-if test "$altivec" = "yes" ; then
-  echo "TARGET_ALTIVEC=yes" >> config.mak
-  echo "#define HAVE_ALTIVEC 1" >> $TMPH
-  echo "// Enable the next line to use the reference C code instead of AltiVec" >> $TMPH
-  echo "// #define ALTIVEC_USE_REFERENCE_C_CODE 1" >> $TMPH
-  if test "$_altivec_h" = "yes" ; then
-    echo "#define HAVE_ALTIVEC_H 1" >> $TMPH
-  else
-    echo "#undef HAVE_ALTIVEC_H" >> $TMPH
-  fi
-fi
-if test "$gprof" = "yes" ; then
-  echo "TARGET_GPROF=yes" >> config.mak
-  echo "#define HAVE_GPROF 1" >> $TMPH
-fi
-if test "$localtime_r" = "yes" ; then
-  echo "#define HAVE_LOCALTIME_R 1" >> $TMPH
-fi
-if test "$imlib2" = "yes" ; then
-  echo "HAVE_IMLIB2=yes" >> config.mak
-fi
-if test "$freetype2" = "yes" ; then
-  echo "HAVE_FREETYPE2=yes" >> config.mak
-fi
-if test "$sunmlib" = "yes" ; then
-  echo "HAVE_MLIB=yes" >> config.mak
-  echo "#define HAVE_MLIB 1" >> $TMPH
-  extralibs="$extralibs -lmlib"
-fi
-if test "$pthreads" = "yes" ; then
-  echo "HAVE_PTHREADS=yes" >> config.mak
-  echo "#define HAVE_PTHREADS 1" >> $TMPH
-  echo "#define HAVE_THREADS 1" >> $TMPH
-  if test $targetos != FreeBSD -a $targetos != OpenBSD ; then
-     extralibs="$extralibs -lpthread"
-  fi
-fi
-if test "$sdl" = "yes" ; then
-  echo "CONFIG_SDL=yes" >> config.mak
-  echo "SDL_LIBS=`sdl-config --libs`" >> config.mak
-  echo "SDL_CFLAGS=`sdl-config --cflags`" >> config.mak
-fi
-if test "$texi2html" = "yes"; then
-  echo "BUILD_DOC=yes" >> config.mak
-fi
-if test "$have_lrintf" = "yes" ; then
-  echo "#define HAVE_LRINTF 1" >> $TMPH
-fi
-if test "$vhook" = "yes" ; then
-  echo "BUILD_VHOOK=yes" >> config.mak
-  echo "#define HAVE_VHOOK 1" >> $TMPH
-fi
-if test "$lshared" = "yes" ; then
-  echo "BUILD_SHARED=yes" >> config.mak
-  echo "PIC=-fPIC -DPIC" >> config.mak
-fi
-echo "EXTRALIBS=$extralibs" >> config.mak
-version=`grep '#define FFMPEG_VERSION ' "$source_path/libavcodec/avcodec.h" |
- cut -d '"' -f 2`
-echo "VERSION=$version" >>config.mak
-# if you do not want to use encoders, disable that.
-echo "#define CONFIG_ENCODERS 1" >> $TMPH
-echo "CONFIG_ENCODERS=yes" >> config.mak
-
-# if you do not want to use decoders, disable that.
-echo "#define CONFIG_DECODERS 1" >> $TMPH
-echo "CONFIG_DECODERS=yes" >> config.mak
-
-# AC3
-if test "$a52" = "yes" ; then
-  echo "#define CONFIG_AC3 1" >> $TMPH
-  echo "CONFIG_AC3=yes" >> config.mak
-
-  if test "$a52bin" = "yes" ; then
-    echo "#define CONFIG_A52BIN 1" >> $TMPH
-    echo "CONFIG_A52BIN=yes" >> config.mak
-  fi
-fi
-
-# DTS
-if test "$dts" = "yes" ; then
-  echo "#define CONFIG_DTS 1" >> $TMPH
-  echo "CONFIG_DTS=yes" >> config.mak
-fi
-
-# PP
-if test "$pp" = "yes" ; then
-  echo "#define CONFIG_PP 1" >> $TMPH
-  echo "CONFIG_PP=yes" >> config.mak
-
-  if test "$shared_pp" = "yes" ; then
-    echo "#define SHARED_PP 1" >> $TMPH
-    echo "SHARED_PP=yes" >> config.mak
-  fi
-fi
-
-# mpeg audio high precision mode
-if test "$mpegaudio_hp" = "yes" ; then
-  echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
-fi
-
-if test "$v4l" = "yes" ; then
-  echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
-  echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
-fi
-
-if test "$bktr" = "yes" ; then
-  echo "#define CONFIG_BKTR 1" >> $TMPH
-  echo "CONFIG_BKTR=yes" >> config.mak
-fi
-
-if test "$dv1394" = "yes" ; then
-  echo "#define CONFIG_DV1394 1" >> $TMPH
-  echo "CONFIG_DV1394=yes" >> config.mak
-fi
-
-if test "$dc1394" = "yes" ; then
-  echo "#define CONFIG_DC1394 1" >> $TMPH
-  echo "CONFIG_DC1394=yes" >> config.mak
-fi
-
-if test "$dlopen" = "yes" ; then
-  echo "#define CONFIG_HAVE_DLOPEN 1" >> $TMPH
-fi
-
-if test "$dlfcn" = "yes" ; then
-  echo "#define CONFIG_HAVE_DLFCN 1" >> $TMPH
-fi
-
-if test "$audio_oss" = "yes" ; then
-  echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
-  echo "CONFIG_AUDIO_OSS=yes" >> config.mak
-fi
-
-if test "$audio_beos" = "yes" ; then
-  echo "#define CONFIG_AUDIO_BEOS 1" >> $TMPH
-  echo "CONFIG_AUDIO_BEOS=yes" >> config.mak
-fi
-
-if test "$network" = "yes" ; then
-  echo "#define CONFIG_NETWORK 1" >> $TMPH
-  echo "CONFIG_NETWORK=yes" >> config.mak
-fi
-
-if test "$ipv6" = "yes" ; then
-  echo "#define CONFIG_IPV6 1" >> $TMPH
-fi
-
-if test "$zlib" = "yes" ; then
-  echo "#define CONFIG_ZLIB 1" >> $TMPH
-  echo "CONFIG_ZLIB=yes" >> config.mak
-fi
-
-if test "$libgsm" = "yes" ; then
-  echo "#define CONFIG_LIBGSM 1" >> $TMPH
-  echo "CONFIG_LIBGSM=yes" >> config.mak
-fi
-
-if test "$mp3lame" = "yes" ; then
-  echo "#define CONFIG_MP3LAME 1" >> $TMPH
-  echo "CONFIG_MP3LAME=yes" >> config.mak
-fi
-
-if test "$libogg" = "yes" ; then
-  echo "#define CONFIG_LIBOGG 1" >> $TMPH
-  echo "CONFIG_LIBOGG=yes" >> config.mak
-fi
-
-if test "$vorbis" = "yes" ; then
-  echo "#define CONFIG_LIBVORBIS 1" >> $TMPH
-  echo "CONFIG_LIBVORBIS=yes" >> config.mak
-fi
-
-if test "$theora" = "yes" ; then
-  echo "#define CONFIG_LIBTHEORA 1" >> $TMPH
-  echo "CONFIG_LIBTHEORA=yes" >> config.mak
-fi
-
-if test "$faad" = "yes" ; then
-  echo "#define CONFIG_FAAD 1" >> $TMPH
-  echo "CONFIG_FAAD=yes" >> config.mak
-fi
-
-if test "$faadbin" = "yes" ; then
-  echo "#define CONFIG_FAADBIN 1" >> $TMPH
-  echo "CONFIG_FAADBIN=yes" >> config.mak
-fi
-
-if test "$faac" = "yes" ; then
-  echo "#define CONFIG_FAAC 1" >> $TMPH
-  echo "CONFIG_FAAC=yes" >> config.mak
-fi
-
-if test "$xvid" = "yes" ; then
-  echo "#define CONFIG_XVID 1" >> $TMPH
-  echo "CONFIG_XVID=yes" >> config.mak
-fi
-
-if test "$x264" = "yes" ; then
-  echo "#define CONFIG_X264 1" >> $TMPH
-  echo "CONFIG_X264=yes" >> config.mak
-fi
-
-if test "$mingw32" = "yes" ; then
-  echo "#define CONFIG_WIN32 1" >> $TMPH
-  echo "CONFIG_WIN32=yes" >> config.mak
-  echo "HAVE_W32THREADS=yes" >> config.mak
-  echo "#define HAVE_W32THREADS 1" >> $TMPH
-  echo "#define HAVE_THREADS 1" >> $TMPH
-  echo "#ifndef __MINGW32__" >> $TMPH
-  echo "#define __MINGW32__ 1" >> $TMPH
-  echo "#endif" >> $TMPH
-fi
-
-if test "$os2" = "yes" ; then
-  echo "#define CONFIG_OS2 1" >> $TMPH
-  echo "CONFIG_OS2=yes" >> config.mak
-fi
-
-if test "$TARGET_OS" = "SunOS" ; then
-  echo "#define CONFIG_SUNOS 1" >> $TMPH
-fi
-
-if test "$TARGET_OS" = "BeOS" ; then
-  echo "HAVE_BEOSTHREADS=yes" >> config.mak
-  echo "#define HAVE_BEOSTHREADS 1" >> $TMPH
-  echo "#define HAVE_THREADS 1" >> $TMPH
-fi
-
-if test "$darwin" = "yes"; then
-  echo "#define CONFIG_DARWIN 1"  >> $TMPH
-  echo "CONFIG_DARWIN=yes" >> config.mak
-fi
-
-if test "$_malloc_h" = "yes" ; then
-  echo "#define HAVE_MALLOC_H 1" >> $TMPH
-else
-  echo "#undef  HAVE_MALLOC_H" >> $TMPH
-fi
-
-if test "$_memalign" = "yes" ; then
-  echo "#define HAVE_MEMALIGN 1" >> $TMPH
-else
-  echo "#undef  HAVE_MEMALIGN" >> $TMPH
-fi
-
-if test "$memalignhack" = "yes" ; then
-  echo "#define MEMALIGN_HACK 1" >> $TMPH
-fi
-
-
-if test "$netserver" = "yes" ; then
-  echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
-  echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
-fi
-
-if test "$need_inet_aton" = "yes" ; then
-  echo "NEED_INET_ATON=yes" >> config.mak
-fi
-
-if test "$simpleidct" = "yes" ; then
-  echo "#define SIMPLE_IDCT 1" >> $TMPH
-fi
-
-if test "$ffserver" = "yes" ; then
-  echo "#define CONFIG_FFSERVER 1" >> $TMPH
-  echo "CONFIG_FFSERVER=yes" >> config.mak
-fi
-
-if test "$ffplay" = "yes" ; then
-  echo "CONFIG_FFPLAY=yes" >> config.mak
-fi
-
-if test "$gpl" = "yes" ; then
-  echo "#define CONFIG_GPL 1" >> $TMPH
-  echo "CONFIG_GPL=yes" >> config.mak
-fi
-
-echo "#define restrict $_restrict" >> $TMPH
-
-if test "$optimize" = "small"; then
-  echo "#define always_inline"  >> $TMPH
-fi
-
-# build tree in object directory if source path is different from current one
-if test "$source_path_used" = "yes" ; then
-    DIRS="\
-         doc \
-         libavformat \
-         libavcodec \
-         libavcodec/alpha \
-         libavcodec/armv4l \
-         libavcodec/i386 \
-         libavcodec/sparc \
-         libavcodec/mlib \
-         libavcodec/ppc \
-         libavcodec/liba52 \
-         libavcodec/libpostproc \
-         libavutil \
-         tests \
-         vhook \
-         "
-    FILES="\
-          Makefile \
-          libavformat/Makefile \
-          libavcodec/Makefile \
-          libavcodec/libpostproc/Makefile \
-          libavutil/Makefile \
-          tests/Makefile \
-          vhook/Makefile \
-          doc/Makefile \
-          doc/texi2pod.pl \
-          "
-    for dir in $DIRS ; do
-            mkdir -p $dir
-    done
-    for f in $FILES ; do
-        ln -sf "$source_path/$f" $f
-    done
-    echo "SRC_PATH=$source_path" >> config.mak
-else
-    echo "SRC_PATH='$source_path'" >> config.mak
-fi
-
-if test "$amr_wb" = "yes" ; then
-  echo "#define AMR_WB 1" >> $TMPH
-  echo "AMR_WB=yes" >> config.mak
-  echo
-  echo "AMR WB FLOAT NOTICE ! Make sure you have downloaded TS26.204"
-  echo "V5.1.0 from "
-  echo "http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-510.zip"
-  echo "and extracted the source to libavcodec/amrwb_float"
-  echo
-fi
-
-if test "$amr_nb" = "yes" ; then
-  echo "#define AMR_NB 1" >> $TMPH
-  echo "AMR_NB=yes" >> config.mak
-  echo
-if test "$amr_nb_fixed" = "yes" ; then
-  echo "AMR_NB_FIXED=yes" >> config.mak
-  echo "#define AMR_NB_FIXED 1" >> $TMPH
-  echo "AMR NB FIXED POINT NOTICE! Make sure you have downloaded TS26.073 "
-  echo "REL-5 version 5.1.0 from "
-  echo "http://www.3gpp.org/ftp/Specs/latest/Rel-5/26_series/26073-5??.zip"
-  echo "and extracted src to libavcodec/amr"
-  echo "You must also add -DMMS_IO and remove -pedantic-errors to/from CFLAGS in libavcodec/amr/makefile."
-  echo "i.e. CFLAGS = -Wall -I. \$(CFLAGS_\$(MODE)) -D\$(VAD) -DMMS_IO"
-  echo
-else
-  echo "AMR NB FLOAT NOTICE ! Make sure you have downloaded TS26.104"
-  echo "REL-5 V5.1.0 from "
-  echo "http://www.3gpp.org/ftp/Specs/latest/Rel-5/26_series/26104-5??.zip"
-  echo "and extracted the source to libavcodec/amr_float"
-  echo "and if u try this on an alpha, u may need to change Word32 to int in amr/typedef.h"
-  echo
-fi
-
-if test "$amr_if2" = "yes" ; then
-  echo "AMR_CFLAGS=-DIF2=1" >> config.mak
-fi
-
-fi
-
-for codec in $CODEC_LIST ; do
-    echo "#define CONFIG_`echo $codec | tr a-z A-Z` 1" >> $TMPH
-    echo "CONFIG_`echo $codec | tr a-z A-Z`=yes" >> config.mak
-done
-
-diff $TMPH config.h >/dev/null 2>&1
-if test $? -ne 0 ; then
-	mv -f $TMPH config.h
-else
-	echo "config.h is unchanged"
-fi
-
-rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
-
-
-# build pkg-config files libavcodec.pc, libavformat.pc and libpostproc.pc 
-lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
-lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
-lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
-
-requires=
-test "$libogg" = "yes" && requires="$requires ogg >= 1.1"
-test "$vorbis" = "yes" && requires="$requires vorbis"
-test "$theora" = "yes" && requires="$requires theora"
-test "$faad" = "yes" && test "$faadbin" = "no" && extralibs="$extralibs -lfaad"
-
-# libavutil.pc
-cat <<EOF >libavutil.pc
-prefix=$prefix
-exec_prefix=\${prefix}
-libdir=\${exec_prefix}/lib
-includedir=\${prefix}/include
-
-Name: libavutil
-Description: FFmpeg utility library
-Version: $lavu_version
-Requires: 
-Conflicts:
-Libs: -L\${libdir} -lavutil
-Cflags: -I\${includedir} -I\${includedir}/ffmpeg
-EOF
-
-cat <<EOF >libavutil-uninstalled.pc
-prefix=
-exec_prefix=
-libdir=\${pcfiledir}/libavutil
-includedir=\${pcfiledir}/libavutil
-
-Name: libavutil
-Description: FFmpeg utility library
-Version: $lavu_version
-Requires: 
-Conflicts:
-Libs: \${libdir}/${LIBPREF}avutil${LIBSUF}
-Cflags: -I\${includedir}
-EOF
-
-# libavcodec.pc
-cat <<EOF >libavcodec.pc
-prefix=$prefix
-exec_prefix=\${prefix}
-libdir=\${exec_prefix}/lib
-includedir=\${prefix}/include
-
-Name: libavcodec
-Description: FFmpeg codec library
-Version: $lavc_version
-Requires: $requires libavutil = $lavu_version
-Conflicts:
-Libs: -L\${libdir} -lavcodec $extralibs
-Cflags: -I\${includedir} -I\${includedir}/ffmpeg
-EOF
-
-cat <<EOF >libavcodec-uninstalled.pc
-prefix=
-exec_prefix=
-libdir=\${pcfiledir}/libavcodec
-includedir=\${pcfiledir}/libavcodec
-
-Name: libavcodec
-Description: FFmpeg codec library
-Version: $lavc_version
-Requires: $requires libavutil = $lavu_version
-Conflicts:
-Libs: \${libdir}/${LIBPREF}avcodec${LIBSUF} $extralibs
-Cflags: -I\${includedir}
-EOF
-
-# libavformat.pc
-cat <<EOF >libavformat.pc
-prefix=$prefix
-exec_prefix=\${prefix}
-libdir=\${exec_prefix}/lib
-includedir=\${prefix}/include
-
-Name: libavformat
-Description: FFmpeg container format library
-Version: $lavf_version
-Requires: $requires libavcodec = $lavc_version
-Conflicts:
-Libs: -L\${libdir} -lavformat $extralibs
-Cflags: -I\${includedir} -I\${includedir}/ffmpeg
-EOF
-
-cat <<EOF >libavformat-uninstalled.pc
-prefix=
-exec_prefix=
-libdir=\${pcfiledir}/libavformat
-includedir=\${pcfiledir}/libavformat
-
-Name: libavformat
-Description: FFmpeg container format library
-Version: $lavf_version
-Requires: $requires libavcodec = $lavc_version
-Conflicts:
-Libs: \${libdir}/${LIBPREF}avformat${LIBSUF} $extralibs
-Cflags: -I\${includedir}
-EOF
-
-
-# libpostproc.pc
-cat <<EOF >libpostproc.pc
-prefix=$prefix
-exec_prefix=\${prefix}
-libdir=\${exec_prefix}/lib
-includedir=\${prefix}/include
-
-Name: libpostproc
-Description: FFmpeg post processing library
-Version: $lavc_version
-Requires: 
-Conflicts:
-Libs: -L\${libdir} -lpostproc
-Cflags: -I\${includedir} -I\${includedir}/postproc
-EOF
-
-cat <<EOF >libpostproc-uninstalled.pc
-prefix=
-exec_prefix=
-libdir=\${pcfiledir}/libavcodec/libpostproc
-includedir=\${pcfiledir}/libavcodec/libpostproc
-
-Name: libpostproc
-Description: FFmpeg post processing library
-Version: $lavc_version
-Requires: 
-Conflicts:
-Libs: \${libdir}/${LIBPREF}postproc${LIBSUF}
-Cflags: -I\${includedir}
-EOF
diff --git a/ffmpeg.src/libavcodec/Makefile b/ffmpeg.src/libavcodec/Makefile
deleted file mode 100644
index 830d095..0000000
--- a/ffmpeg.src/libavcodec/Makefile
+++ /dev/null
@@ -1,239 +0,0 @@
-#
-# libavcodec Makefile
-# (c) 2000-2005 Fabrice Bellard
-#
-include ../config.mak
-
-VPATH=$(SRC_PATH)/libavcodec
-
-# NOTE: -I.. is needed to include config.h
-CFLAGS=$(OPTFLAGS) -DHAVE_AV_CONFIG_H -I.. -I$(SRC_PATH)/libavutil -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE $(AMR_CFLAGS)
-
-OBJS= bitstream.o utils.o mem.o allcodecs.o \
-      mpegvideo.o jrevdct.o jfdctfst.o jfdctint.o\
-      mpegaudio.o ac3enc.o mjpeg.o resample.o resample2.o dsputil.o \
-      motion_est.o imgconvert.o imgresample.o \
-      mpeg12.o mpegaudiodec.o pcm.o simple_idct.o \
-      ratecontrol.o adpcm.o eval.o error_resilience.o \
-      fft.o mdct.o raw.o golomb.o cabac.o\
-      dpcm.o adx.o faandct.o parser.o g726.o \
-      vp3dsp.o h264idct.o rangecoder.o pnm.o h263.o msmpeg4.o h263dec.o \
-      opt.o
-
-# currently using liba52 for ac3 decoding
-ifeq ($(CONFIG_AC3),yes)
-OBJS+= a52dec.o
-
-# using builtin liba52 or runtime linked liba52.so.0
-ifneq ($(CONFIG_A52BIN),yes)
-OBJS+= liba52/bit_allocate.o liba52/bitstream.o liba52/downmix.o \
-	liba52/imdct.o  liba52/parse.o liba52/crc.o liba52/resample.o
-endif
-endif
-
-EXTRALIBS += -L../libavutil -lavutil$(BUILDSUF)
-
-# currently using libdts for dts decoding
-ifeq ($(CONFIG_DTS),yes)
-OBJS+= dtsdec.o
-CFLAGS += $(DTS_INC)
-EXTRALIBS += -ldts
-endif
-
-ifeq ($(TARGET_GPROF),yes)
-CFLAGS+=-p
-LDFLAGS+=-p
-endif
-
-# i386 mmx specific stuff
-ifeq ($(TARGET_MMX),yes)
-OBJS += i386/fdct_mmx.o i386/cputest.o \
-	i386/dsputil_mmx.o i386/mpegvideo_mmx.o \
-	i386/idct_mmx.o i386/motion_est_mmx.o \
-	i386/simple_idct_mmx.o i386/fft_sse.o i386/vp3dsp_mmx.o \
-	i386/vp3dsp_sse2.o
-ifeq ($(CONFIG_GPL),yes)
-OBJS += i386/idct_mmx_xvid.o
-endif
-ifdef TARGET_BUILTIN_VECTOR
-i386/fft_sse.o: CFLAGS+= -msse
-depend: CFLAGS+= -msse
-endif
-endif
-
-# armv4l specific stuff
-ifeq ($(TARGET_ARCH_ARMV4L),yes)
-ASM_OBJS += armv4l/jrevdct_arm.o armv4l/simple_idct_arm.o armv4l/dsputil_arm_s.o
-OBJS += armv4l/dsputil_arm.o armv4l/mpegvideo_arm.o
-ifeq ($(TARGET_IWMMXT),yes)
-OBJS += armv4l/dsputil_iwmmxt.o armv4l/mpegvideo_iwmmxt.o
-endif
-endif
-
-# sun mediaLib specific stuff
-# currently only works when libavcodec is used in mplayer
-ifeq ($(HAVE_MLIB),yes)
-OBJS += mlib/dsputil_mlib.o
-CFLAGS += $(MLIB_INC)
-endif
-
-# Intel IPP specific stuff
-# currently only works when libavcodec is used in mplayer
-ifeq ($(HAVE_IPP),yes)
-CFLAGS += $(IPP_INC)
-endif
-
-# alpha specific stuff
-ifeq ($(TARGET_ARCH_ALPHA),yes)
-OBJS += alpha/dsputil_alpha.o alpha/mpegvideo_alpha.o \
-	alpha/simple_idct_alpha.o alpha/motion_est_alpha.o
-ASM_OBJS += alpha/dsputil_alpha_asm.o alpha/motion_est_mvi_asm.o
-CFLAGS += -fforce-addr
-endif
-
-ifeq ($(TARGET_ARCH_POWERPC),yes)
-OBJS += ppc/dsputil_ppc.o ppc/mpegvideo_ppc.o
-endif
-
-ifeq ($(TARGET_MMI),yes)
-OBJS += ps2/dsputil_mmi.o ps2/idct_mmi.o ps2/mpegvideo_mmi.o
-endif
-
-ifeq ($(TARGET_ALTIVEC),yes)
-OBJS += ppc/dsputil_altivec.o ppc/mpegvideo_altivec.o ppc/idct_altivec.o \
-        ppc/fft_altivec.o ppc/gmc_altivec.o ppc/fdct_altivec.o \
-        ppc/dsputil_h264_altivec.o
-endif
-
-ifeq ($(TARGET_ARCH_SH4),yes)
-OBJS+= sh4/idct_sh4.o sh4/dsputil_sh4.o sh4/dsputil_align.o
-endif
-
-ifeq ($(TARGET_ARCH_SPARC),yes)
-OBJS+=sparc/dsputil_vis.o
-sparc/%.o: sparc/%.c
-	$(CC) -mcpu=ultrasparc -mtune=ultrasparc $(CFLAGS) -c -o $@ $< 
-endif
-ifeq ($(TARGET_ARCH_SPARC64),yes)
-CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc
-endif
-
-SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S)
-OBJS := $(OBJS) $(ASM_OBJS)
-
-LIB= $(LIBPREF)avcodec$(LIBSUF)
-LIBAVUTIL= $(SRC_PATH)/libavutil/$(LIBPREF)avutil$(LIBSUF)
-ifeq ($(BUILD_SHARED),yes)
-SLIB= $(SLIBPREF)avcodec$(SLIBSUF)
-endif
-TESTS= imgresample-test dct-test motion-test fft-test
-
-all: $(LIB) $(SLIB)
-
-amrlibs:
-	$(MAKE) -C amr spclib fipoplib
-
-tests: apiexample cpuid_test $(TESTS)
-
-$(LIB): $(OBJS) $(AMRLIBS)
-	rm -f $@
-	$(AR) rc $@ $(OBJS) $(AMREXTRALIBS)
-	$(RANLIB) $@
-
-$(SLIB): $(OBJS)
-ifeq ($(CONFIG_WIN32),yes)
-	$(CC) $(SHFLAGS) -Wl,--output-def,$(@:.dll=.def) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS)
-	-lib /machine:i386 /def:$(@:.dll=.def)
-else
-	$(CC) $(SHFLAGS) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS) $(LDFLAGS)
-endif
-
-dsputil.o: dsputil.c dsputil.h
-
-%.o: %.c
-	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $< 
-
-%.o: %.S
-	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
-
-depend: $(SRCS)
-	$(CC) -MM $(CFLAGS) $^ 1>.depend
-
-dep:	depend
-
-clean: $(CLEANAMR)
-	rm -f *.o *.d *~ .depend $(LIB) $(SLIB) *.so i386/*.o i386/*~ \
-	   armv4l/*.o armv4l/*~ \
-	   mlib/*.o mlib/*~ \
-	   alpha/*.o alpha/*~ \
-	   ppc/*.o ppc/*~ \
-	   ps2/*.o ps2/*~ \
-	   sh4/*.o sh4/*~ \
-	   sparc/*.o sparc/*~ \
-	   liba52/*.o liba52/*~ \
-	   apiexample $(TESTS)
-
-distclean: clean
-	rm -f Makefile.bak .depend
-
-cleanamr:
-	$(MAKE) -C amr clean
-
-cleanamrfloat:
-	rm -f amr_float/*.o
-
-cleanamrwbfloat:
-	$(MAKE) -C amrwb_float -f makefile.gcc clean
-
-# api example program
-apiexample: apiexample.c $(LIB)
-	$(CC) $(CFLAGS) -o $@ $< $(LIB) $(LIBAVUTIL) $(EXTRALIBS) -lm
-
-# cpuid test
-cpuid_test: i386/cputest.c
-	$(CC) $(CFLAGS) -D__TEST__ -o $@ $<
-
-# testing progs
-
-imgresample-test: imgresample.c
-	$(CC) $(CFLAGS) -DTEST -o $@ $^ -lm
-
-dct-test: dct-test.o fdctref.o $(LIB)
-	$(CC) -o $@ $^ -lm $(LIBAVUTIL)
-
-motion-test: motion_test.o $(LIB)
-	$(CC) -o $@ $^ -lm
-
-fft-test: fft-test.o $(LIB)
-	$(CC) -o $@ $^ $(LIBAVUTIL) -lm
-
-ifeq ($(BUILD_SHARED),yes)
-install: all install-headers
-ifeq ($(CONFIG_WIN32),yes)
-	install $(INSTALLSTRIP) -m 755 $(SLIB) "$(prefix)"
-else
-	install -d $(libdir)
-	install $(INSTALLSTRIP) -m 755 $(SLIB) $(libdir)/libavcodec-$(VERSION).so
-	ln -sf libavcodec-$(VERSION).so $(libdir)/libavcodec.so
-	$(LDCONFIG) || true
-endif
-else
-install:
-endif
-
-installlib: all install-headers
-	install -m 644 $(LIB) "$(libdir)"
-
-install-headers:
-	mkdir -p "$(prefix)/include/ffmpeg"
-	install -m 644 $(SRC_PATH)/libavcodec/avcodec.h \
-                "$(prefix)/include/ffmpeg"
-	install -d $(libdir)/pkgconfig
-	install -m 644 ../libavcodec.pc $(libdir)/pkgconfig
-
-#
-# include dependency files if they exist
-#
-ifneq ($(wildcard .depend),)
-include .depend
-endif
diff --git a/ffmpeg.src/libavcodec/a52dec.c b/ffmpeg.src/libavcodec/a52dec.c
deleted file mode 100644
index 7ebea40..0000000
--- a/ffmpeg.src/libavcodec/a52dec.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * A52 decoder
- * Copyright (c) 2001 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file a52dec.c
- * A52 decoder.
- */
-
-#include "avcodec.h"
-#include "liba52/a52.h"
-
-#ifdef CONFIG_A52BIN
-#include <dlfcn.h>
-static const char* liba52name = "liba52.so.0";
-#endif
-
-/**
- * liba52 - Copyright (C) Aaron Holtzman
- * released under the GPL license.
- */
-typedef struct AC3DecodeState {
-    uint8_t inbuf[4096]; /* input buffer */
-    uint8_t *inbuf_ptr;
-    int frame_size;
-    int flags;
-    int channels;
-    a52_state_t* state;
-    sample_t* samples;
-
-    /*
-     * virtual method table
-     *
-     * using this function table so the liba52 doesn't
-     * have to be really linked together with ffmpeg
-     * and might be linked in runtime - this allows binary
-     * distribution of ffmpeg library which doens't depend
-     * on liba52 library - but if user has it installed
-     * it will be used - user might install such library
-     * separately
-     */
-    void* handle;
-    a52_state_t* (*a52_init)(uint32_t mm_accel);
-    sample_t* (*a52_samples)(a52_state_t * state);
-    int (*a52_syncinfo)(uint8_t * buf, int * flags,
-			  int * sample_rate, int * bit_rate);
-    int (*a52_frame)(a52_state_t * state, uint8_t * buf, int * flags,
-		       sample_t * level, sample_t bias);
-    void (*a52_dynrng)(a52_state_t * state,
-			 sample_t (* call) (sample_t, void *), void * data);
-    int (*a52_block)(a52_state_t * state);
-    void (*a52_free)(a52_state_t * state);
-
-} AC3DecodeState;
-
-#ifdef CONFIG_A52BIN
-static void* dlsymm(void* handle, const char* symbol)
-{
-    void* f = dlsym(handle, symbol);
-    if (!f)
-        av_log( NULL, AV_LOG_ERROR, "A52 Decoder - function '%s' can't be resolved\n", symbol);
-    return f;
-}
-
-int ff_a52_syncinfo( AVCodecContext * avctx, uint8_t * buf, int * flags, int * sample_rate, int * bit_rate )
-{
-    AC3DecodeState *s = avctx->priv_data;
-
-    return s->a52_syncinfo(buf, flags, sample_rate, bit_rate);
-}
-#endif
-
-static int a52_decode_init(AVCodecContext *avctx)
-{
-    AC3DecodeState *s = avctx->priv_data;
-
-#ifdef CONFIG_A52BIN
-    s->handle = dlopen(liba52name, RTLD_LAZY);
-    if (!s->handle)
-    {
-        av_log( avctx, AV_LOG_ERROR, "A52 library %s could not be opened! \n%s\n", liba52name, dlerror());
-        return -1;
-    }
-    s->a52_init = (a52_state_t* (*)(uint32_t)) dlsymm(s->handle, "a52_init");
-    s->a52_samples = (sample_t* (*)(a52_state_t*)) dlsymm(s->handle, "a52_samples");
-    s->a52_syncinfo = (int (*)(uint8_t*, int*, int*, int*)) dlsymm(s->handle, "a52_syncinfo");
-    s->a52_frame = (int (*)(a52_state_t*, uint8_t*, int*, sample_t*, sample_t)) dlsymm(s->handle, "a52_frame");
-    s->a52_block = (int (*)(a52_state_t*)) dlsymm(s->handle, "a52_block");
-    s->a52_free = (void (*)(a52_state_t*)) dlsymm(s->handle, "a52_free");
-    if (!s->a52_init || !s->a52_samples || !s->a52_syncinfo
-        || !s->a52_frame || !s->a52_block || !s->a52_free)
-    {
-	dlclose(s->handle);
-        return -1;
-    }
-#else
-    /* static linked version */
-    s->handle = 0;
-    s->a52_init = a52_init;
-    s->a52_samples = a52_samples;
-    s->a52_syncinfo = a52_syncinfo;
-    s->a52_frame = a52_frame;
-    s->a52_block = a52_block;
-    s->a52_free = a52_free;
-#endif
-    s->state = s->a52_init(0); /* later use CPU flags */
-    s->samples = s->a52_samples(s->state);
-    s->inbuf_ptr = s->inbuf;
-    s->frame_size = 0;
-
-    return 0;
-}
-
-/**** the following two functions comes from a52dec */
-static inline int blah (int32_t i)
-{
-    if (i > 0x43c07fff)
-	return 32767;
-    else if (i < 0x43bf8000)
-	return -32768;
-    return i - 0x43c00000;
-}
-
-static inline void float_to_int (float * _f, int16_t * s16, int nchannels)
-{
-    int i, j, c;
-    int32_t * f = (int32_t *) _f;	// XXX assumes IEEE float format
-
-    j = 0;
-    nchannels *= 256;
-    for (i = 0; i < 256; i++) {
-	for (c = 0; c < nchannels; c += 256)
-	    s16[j++] = blah (f[i + c]);
-    }
-}
-
-/**** end */
-
-#define HEADER_SIZE 7
-
-static int a52_decode_frame(AVCodecContext *avctx,
-                            void *data, int *data_size,
-                            uint8_t *buf, int buf_size)
-{
-    AC3DecodeState *s = avctx->priv_data;
-    uint8_t *buf_ptr;
-    int flags, i, len;
-    int sample_rate, bit_rate;
-    short *out_samples = data;
-    float level;
-    static const int ac3_channels[8] = {
-	2, 1, 2, 3, 3, 4, 4, 5
-    };
-
-    buf_ptr = buf;
-    while (buf_size > 0) {
-        len = s->inbuf_ptr - s->inbuf;
-        if (s->frame_size == 0) {
-            /* no header seen : find one. We need at least 7 bytes to parse it */
-            len = HEADER_SIZE - len;
-            if (len > buf_size)
-                len = buf_size;
-            memcpy(s->inbuf_ptr, buf_ptr, len);
-            buf_ptr += len;
-            s->inbuf_ptr += len;
-            buf_size -= len;
-            if ((s->inbuf_ptr - s->inbuf) == HEADER_SIZE) {
-                len = s->a52_syncinfo(s->inbuf, &s->flags, &sample_rate, &bit_rate);
-                if (len == 0) {
-                    /* no sync found : move by one byte (inefficient, but simple!) */
-                    memcpy(s->inbuf, s->inbuf + 1, HEADER_SIZE - 1);
-                    s->inbuf_ptr--;
-                } else {
-		    s->frame_size = len;
-                    /* update codec info */
-                    avctx->sample_rate = sample_rate;
-                    s->channels = ac3_channels[s->flags & 7];
-                    if (s->flags & A52_LFE)
-			s->channels++;
-		    if (avctx->channels == 0)
-			/* No specific number of channel requested */
-			avctx->channels = s->channels;
-		    else if (s->channels < avctx->channels) {
-			av_log(avctx, AV_LOG_ERROR, "ac3dec: AC3 Source channels are less than specified: output to %d channels.. (frmsize: %d)\n", s->channels, len);
-			avctx->channels = s->channels;
-		    }
-		    avctx->bit_rate = bit_rate;
-                }
-            }
-        } else if (len < s->frame_size) {
-            len = s->frame_size - len;
-            if (len > buf_size)
-                len = buf_size;
-
-            memcpy(s->inbuf_ptr, buf_ptr, len);
-            buf_ptr += len;
-            s->inbuf_ptr += len;
-            buf_size -= len;
-        } else {
-            flags = s->flags;
-            if (avctx->channels == 1)
-                flags = A52_MONO;
-            else if (avctx->channels == 2)
-                flags = A52_STEREO;
-            else
-                flags |= A52_ADJUST_LEVEL;
-            level = 1;
-            if (s->a52_frame(s->state, s->inbuf, &flags, &level, 384)) {
-            fail:
-                s->inbuf_ptr = s->inbuf;
-                s->frame_size = 0;
-                continue;
-            }
-            for (i = 0; i < 6; i++) {
-                if (s->a52_block(s->state))
-                    goto fail;
-                float_to_int(s->samples, out_samples + i * 256 * avctx->channels, avctx->channels);
-            }
-            s->inbuf_ptr = s->inbuf;
-            s->frame_size = 0;
-            *data_size = 6 * avctx->channels * 256 * sizeof(int16_t);
-            break;
-        }
-    }
-    return buf_ptr - buf;
-}
-
-static int a52_decode_end(AVCodecContext *avctx)
-{
-    AC3DecodeState *s = avctx->priv_data;
-    s->a52_free(s->state);
-#ifdef CONFIG_A52BIN
-    dlclose(s->handle);
-#endif
-    return 0;
-}
-
-AVCodec ac3_decoder = {
-    "ac3",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_AC3,
-    sizeof(AC3DecodeState),
-    a52_decode_init,
-    NULL,
-    a52_decode_end,
-    a52_decode_frame,
-};
diff --git a/ffmpeg.src/libavcodec/ac3.h b/ffmpeg.src/libavcodec/ac3.h
deleted file mode 100644
index 9825195..0000000
--- a/ffmpeg.src/libavcodec/ac3.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Common code between AC3 encoder and decoder
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file ac3.h
- * Common code between AC3 encoder and decoder.
- */
-
-#define AC3_MAX_CODED_FRAME_SIZE 3840 /* in bytes */
-#define AC3_MAX_CHANNELS 6 /* including LFE channel */
-
-#define NB_BLOCKS 6 /* number of PCM blocks inside an AC3 frame */
-#define AC3_FRAME_SIZE (NB_BLOCKS * 256)
-
-/* exponent encoding strategy */
-#define EXP_REUSE 0
-#define EXP_NEW   1
-
-#define EXP_D15   1
-#define EXP_D25   2
-#define EXP_D45   3
-
-typedef struct AC3BitAllocParameters {
-    int fscod; /* frequency */
-    int halfratecod;
-    int sgain, sdecay, fdecay, dbknee, floor;
-    int cplfleak, cplsleak;
-} AC3BitAllocParameters;
-
-#if 0
-extern const uint16_t ac3_freqs[3];
-extern const uint16_t ac3_bitratetab[19];
-extern const int16_t ac3_window[256];
-extern const uint8_t sdecaytab[4];
-extern const uint8_t fdecaytab[4];
-extern const uint16_t sgaintab[4];
-extern const uint16_t dbkneetab[4];
-extern const uint16_t floortab[8];
-extern const uint16_t fgaintab[8];
-#endif
-
-void ac3_common_init(void);
-void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
-                                   int8_t *exp, int start, int end,
-                                   int snroffset, int fgain, int is_lfe,
-                                   int deltbae,int deltnseg, 
-                                   uint8_t *deltoffst, uint8_t *deltlen, uint8_t *deltba);
diff --git a/ffmpeg.src/libavcodec/ac3enc.c b/ffmpeg.src/libavcodec/ac3enc.c
deleted file mode 100644
index aae06e4..0000000
--- a/ffmpeg.src/libavcodec/ac3enc.c
+++ /dev/null
@@ -1,1572 +0,0 @@
-/*
- * The simplest AC3 encoder
- * Copyright (c) 2000 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file ac3enc.c
- * The simplest AC3 encoder.
- */
-//#define DEBUG
-//#define DEBUG_BITALLOC
-#include "avcodec.h"
-#include "bitstream.h"
-#include "ac3.h"
-
-typedef struct AC3EncodeContext {
-    PutBitContext pb;
-    int nb_channels;
-    int nb_all_channels;
-    int lfe_channel;
-    int bit_rate;
-    unsigned int sample_rate;
-    unsigned int bsid;
-    unsigned int frame_size_min; /* minimum frame size in case rounding is necessary */
-    unsigned int frame_size; /* current frame size in words */
-    int halfratecod;
-    unsigned int frmsizecod;
-    unsigned int fscod; /* frequency */
-    unsigned int acmod;
-    int lfe;
-    unsigned int bsmod;
-    short last_samples[AC3_MAX_CHANNELS][256];
-    unsigned int chbwcod[AC3_MAX_CHANNELS];
-    int nb_coefs[AC3_MAX_CHANNELS];
-    
-    /* bitrate allocation control */
-    int sgaincod, sdecaycod, fdecaycod, dbkneecod, floorcod; 
-    AC3BitAllocParameters bit_alloc;
-    int csnroffst;
-    int fgaincod[AC3_MAX_CHANNELS];
-    int fsnroffst[AC3_MAX_CHANNELS];
-    /* mantissa encoding */
-    int mant1_cnt, mant2_cnt, mant4_cnt;
-} AC3EncodeContext;
-
-#include "ac3tab.h"
-
-#define MDCT_NBITS 9
-#define N         (1 << MDCT_NBITS)
-
-/* new exponents are sent if their Norm 1 exceed this number */
-#define EXP_DIFF_THRESHOLD 1000
-
-static void fft_init(int ln);
-static void ac3_crc_init(void);
-
-static inline int16_t fix15(float a)
-{
-    int v;
-    v = (int)(a * (float)(1 << 15));
-    if (v < -32767)
-        v = -32767;
-    else if (v > 32767) 
-        v = 32767;
-    return v;
-}
-
-static inline int calc_lowcomp1(int a, int b0, int b1)
-{
-    if ((b0 + 256) == b1) {
-        a = 384 ;
-    } else if (b0 > b1) { 
-        a = a - 64;
-        if (a < 0) a=0;
-    }
-    return a;
-}
-
-static inline int calc_lowcomp(int a, int b0, int b1, int bin)
-{
-    if (bin < 7) {
-        if ((b0 + 256) == b1) {
-            a = 384 ;
-        } else if (b0 > b1) { 
-            a = a - 64;
-            if (a < 0) a=0;
-        }
-    } else if (bin < 20) {
-        if ((b0 + 256) == b1) {
-            a = 320 ;
-        } else if (b0 > b1) {
-            a= a - 64;
-            if (a < 0) a=0;
-        }
-    } else {
-        a = a - 128;
-        if (a < 0) a=0;
-    }
-    return a;
-}
-
-/* AC3 bit allocation. The algorithm is the one described in the AC3
-   spec. */
-void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
-                                   int8_t *exp, int start, int end,
-                                   int snroffset, int fgain, int is_lfe,
-                                   int deltbae,int deltnseg, 
-                                   uint8_t *deltoffst, uint8_t *deltlen, uint8_t *deltba)
-{
-    int bin,i,j,k,end1,v,v1,bndstrt,bndend,lowcomp,begin;
-    int fastleak,slowleak,address,tmp;
-    int16_t psd[256]; /* scaled exponents */
-    int16_t bndpsd[50]; /* interpolated exponents */
-    int16_t excite[50]; /* excitation */
-    int16_t mask[50];   /* masking value */
-
-    /* exponent mapping to PSD */
-    for(bin=start;bin<end;bin++) {
-        psd[bin]=(3072 - (exp[bin] << 7));
-    }
-
-    /* PSD integration */
-    j=start;
-    k=masktab[start];
-    do {
-        v=psd[j];
-        j++;
-        end1=bndtab[k+1];
-        if (end1 > end) end1=end;
-        for(i=j;i<end1;i++) {
-            int c,adr;
-            /* logadd */
-            v1=psd[j];
-            c=v-v1;
-            if (c >= 0) {
-                adr=c >> 1;
-                if (adr > 255) adr=255;
-                v=v + latab[adr];
-            } else {
-                adr=(-c) >> 1;
-                if (adr > 255) adr=255;
-                v=v1 + latab[adr];
-            }
-            j++;
-        }
-        bndpsd[k]=v;
-        k++;
-    } while (end > bndtab[k]);
-
-    /* excitation function */
-    bndstrt = masktab[start];
-    bndend = masktab[end-1] + 1;
-    
-    if (bndstrt == 0) {
-        lowcomp = 0;
-        lowcomp = calc_lowcomp1(lowcomp, bndpsd[0], bndpsd[1]) ;
-        excite[0] = bndpsd[0] - fgain - lowcomp ;
-        lowcomp = calc_lowcomp1(lowcomp, bndpsd[1], bndpsd[2]) ;
-        excite[1] = bndpsd[1] - fgain - lowcomp ;
-        begin = 7 ;
-        for (bin = 2; bin < 7; bin++) {
-            if (!(is_lfe && bin == 6))
-                lowcomp = calc_lowcomp1(lowcomp, bndpsd[bin], bndpsd[bin+1]) ;
-            fastleak = bndpsd[bin] - fgain ;
-            slowleak = bndpsd[bin] - s->sgain ;
-            excite[bin] = fastleak - lowcomp ;
-            if (!(is_lfe && bin == 6)) {
-                if (bndpsd[bin] <= bndpsd[bin+1]) {
-                    begin = bin + 1 ;
-                    break ;
-                }
-            }
-        }
-    
-        end1=bndend;
-        if (end1 > 22) end1=22;
-    
-        for (bin = begin; bin < end1; bin++) {
-            if (!(is_lfe && bin == 6))
-                lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin+1], bin) ;
-        
-            fastleak -= s->fdecay ;
-            v = bndpsd[bin] - fgain;
-            if (fastleak < v) fastleak = v;
-        
-            slowleak -= s->sdecay ;
-            v = bndpsd[bin] - s->sgain;
-            if (slowleak < v) slowleak = v;
-        
-            v=fastleak - lowcomp;
-            if (slowleak > v) v=slowleak;
-        
-            excite[bin] = v;
-        }
-        begin = 22;
-    } else {
-        /* coupling channel */
-        begin = bndstrt;
-        
-        fastleak = (s->cplfleak << 8) + 768;
-        slowleak = (s->cplsleak << 8) + 768;
-    }
-
-    for (bin = begin; bin < bndend; bin++) {
-        fastleak -= s->fdecay ;
-        v = bndpsd[bin] - fgain;
-        if (fastleak < v) fastleak = v;
-        slowleak -= s->sdecay ;
-        v = bndpsd[bin] - s->sgain;
-        if (slowleak < v) slowleak = v;
-
-        v=fastleak;
-        if (slowleak > v) v = slowleak;
-        excite[bin] = v;
-    }
-
-    /* compute masking curve */
-
-    for (bin = bndstrt; bin < bndend; bin++) {
-        v1 = excite[bin];
-        tmp = s->dbknee - bndpsd[bin];
-        if (tmp > 0) {
-            v1 += tmp >> 2;
-        }
-        v=hth[bin >> s->halfratecod][s->fscod];
-        if (v1 > v) v=v1;
-        mask[bin] = v;
-    }
-
-    /* delta bit allocation */
-
-    if (deltbae == 0 || deltbae == 1) {
-        int band, seg, delta;
-        band = 0 ;
-        for (seg = 0; seg < deltnseg; seg++) {
-            band += deltoffst[seg] ;
-            if (deltba[seg] >= 4) {
-                delta = (deltba[seg] - 3) << 7;
-            } else {
-                delta = (deltba[seg] - 4) << 7;
-            }
-            for (k = 0; k < deltlen[seg]; k++) {
-                mask[band] += delta ;
-                band++ ;
-            }
-        }
-    }
-
-    /* compute bit allocation */
-    
-    i = start ;
-    j = masktab[start] ;
-    do {
-        v=mask[j];
-        v -= snroffset ;
-        v -= s->floor ;
-        if (v < 0) v = 0;
-        v &= 0x1fe0 ;
-        v += s->floor ;
-
-        end1=bndtab[j] + bndsz[j];
-        if (end1 > end) end1=end;
-
-        for (k = i; k < end1; k++) {
-            address = (psd[i] - v) >> 5 ;
-            if (address < 0) address=0;
-            else if (address > 63) address=63;
-            bap[i] = baptab[address];
-            i++;
-        }
-    } while (end > bndtab[j++]) ;
-}
-
-typedef struct IComplex {
-    short re,im;
-} IComplex;
-
-static void fft_init(int ln)
-{
-    int i, j, m, n;
-    float alpha;
-
-    n = 1 << ln;
-
-    for(i=0;i<(n/2);i++) {
-        alpha = 2 * M_PI * (float)i / (float)n;
-        costab[i] = fix15(cos(alpha));
-        sintab[i] = fix15(sin(alpha));
-    }
-
-    for(i=0;i<n;i++) {
-        m=0;
-        for(j=0;j<ln;j++) {
-            m |= ((i >> j) & 1) << (ln-j-1);
-        }
-        fft_rev[i]=m;
-    }
-}
-
-/* butter fly op */
-#define BF(pre, pim, qre, qim, pre1, pim1, qre1, qim1) \
-{\
-  int ax, ay, bx, by;\
-  bx=pre1;\
-  by=pim1;\
-  ax=qre1;\
-  ay=qim1;\
-  pre = (bx + ax) >> 1;\
-  pim = (by + ay) >> 1;\
-  qre = (bx - ax) >> 1;\
-  qim = (by - ay) >> 1;\
-}
-
-#define MUL16(a,b) ((a) * (b))
-
-#define CMUL(pre, pim, are, aim, bre, bim) \
-{\
-   pre = (MUL16(are, bre) - MUL16(aim, bim)) >> 15;\
-   pim = (MUL16(are, bim) + MUL16(bre, aim)) >> 15;\
-}
-
-
-/* do a 2^n point complex fft on 2^ln points. */
-static void fft(IComplex *z, int ln)
-{
-    int	j, l, np, np2;
-    int	nblocks, nloops;
-    register IComplex *p,*q;
-    int tmp_re, tmp_im;
-
-    np = 1 << ln;
-
-    /* reverse */
-    for(j=0;j<np;j++) {
-        int k;
-        IComplex tmp;
-        k = fft_rev[j];
-        if (k < j) {
-            tmp = z[k];
-            z[k] = z[j];
-            z[j] = tmp;
-        }
-    }
-
-    /* pass 0 */
-
-    p=&z[0];
-    j=(np >> 1);
-    do {
-        BF(p[0].re, p[0].im, p[1].re, p[1].im, 
-           p[0].re, p[0].im, p[1].re, p[1].im);
-        p+=2;
-    } while (--j != 0);
-
-    /* pass 1 */
-
-    p=&z[0];
-    j=np >> 2;
-    do {
-        BF(p[0].re, p[0].im, p[2].re, p[2].im, 
-           p[0].re, p[0].im, p[2].re, p[2].im);
-        BF(p[1].re, p[1].im, p[3].re, p[3].im, 
-           p[1].re, p[1].im, p[3].im, -p[3].re);
-        p+=4;
-    } while (--j != 0);
-
-    /* pass 2 .. ln-1 */
-
-    nblocks = np >> 3;
-    nloops = 1 << 2;
-    np2 = np >> 1;
-    do {
-        p = z;
-        q = z + nloops;
-        for (j = 0; j < nblocks; ++j) {
-
-            BF(p->re, p->im, q->re, q->im,
-               p->re, p->im, q->re, q->im);
-            
-            p++;
-            q++;
-            for(l = nblocks; l < np2; l += nblocks) {
-                CMUL(tmp_re, tmp_im, costab[l], -sintab[l], q->re, q->im);
-                BF(p->re, p->im, q->re, q->im,
-                   p->re, p->im, tmp_re, tmp_im);
-                p++;
-                q++;
-            }
-            p += nloops;
-            q += nloops;
-        }
-        nblocks = nblocks >> 1;
-        nloops = nloops << 1;
-    } while (nblocks != 0);
-}
-
-/* do a 512 point mdct */
-static void mdct512(int32_t *out, int16_t *in)
-{
-    int i, re, im, re1, im1;
-    int16_t rot[N]; 
-    IComplex x[N/4];
-
-    /* shift to simplify computations */
-    for(i=0;i<N/4;i++)
-        rot[i] = -in[i + 3*N/4];
-    for(i=N/4;i<N;i++)
-        rot[i] = in[i - N/4];
-        
-    /* pre rotation */
-    for(i=0;i<N/4;i++) {
-        re = ((int)rot[2*i] - (int)rot[N-1-2*i]) >> 1;
-        im = -((int)rot[N/2+2*i] - (int)rot[N/2-1-2*i]) >> 1;
-        CMUL(x[i].re, x[i].im, re, im, -xcos1[i], xsin1[i]);
-    }
-
-    fft(x, MDCT_NBITS - 2);
-  
-    /* post rotation */
-    for(i=0;i<N/4;i++) {
-        re = x[i].re;
-        im = x[i].im;
-        CMUL(re1, im1, re, im, xsin1[i], xcos1[i]);
-        out[2*i] = im1;
-        out[N/2-1-2*i] = re1;
-    }
-}
-
-/* XXX: use another norm ? */
-static int calc_exp_diff(uint8_t *exp1, uint8_t *exp2, int n)
-{
-    int sum, i;
-    sum = 0;
-    for(i=0;i<n;i++) {
-        sum += abs(exp1[i] - exp2[i]);
-    }
-    return sum;
-}
-
-static void compute_exp_strategy(uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS],
-                                 uint8_t exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
-                                 int ch, int is_lfe)
-{
-    int i, j;
-    int exp_diff;
-    
-    /* estimate if the exponent variation & decide if they should be
-       reused in the next frame */
-    exp_strategy[0][ch] = EXP_NEW;
-    for(i=1;i<NB_BLOCKS;i++) {
-        exp_diff = calc_exp_diff(exp[i][ch], exp[i-1][ch], N/2);
-#ifdef DEBUG            
-        av_log(NULL, AV_LOG_DEBUG, "exp_diff=%d\n", exp_diff);
-#endif
-        if (exp_diff > EXP_DIFF_THRESHOLD)
-            exp_strategy[i][ch] = EXP_NEW;
-        else
-            exp_strategy[i][ch] = EXP_REUSE;
-    }
-    if (is_lfe)
-	return;
-
-    /* now select the encoding strategy type : if exponents are often
-       recoded, we use a coarse encoding */
-    i = 0;
-    while (i < NB_BLOCKS) {
-        j = i + 1;
-        while (j < NB_BLOCKS && exp_strategy[j][ch] == EXP_REUSE)
-            j++;
-        switch(j - i) {
-        case 1:
-            exp_strategy[i][ch] = EXP_D45;
-            break;
-        case 2:
-        case 3:
-            exp_strategy[i][ch] = EXP_D25;
-            break;
-        default:
-            exp_strategy[i][ch] = EXP_D15;
-            break;
-        }
-	i = j;
-    }
-}
-
-/* set exp[i] to min(exp[i], exp1[i]) */
-static void exponent_min(uint8_t exp[N/2], uint8_t exp1[N/2], int n)
-{
-    int i;
-
-    for(i=0;i<n;i++) {
-        if (exp1[i] < exp[i])
-            exp[i] = exp1[i];
-    }
-}
-                                 
-/* update the exponents so that they are the ones the decoder will
-   decode. Return the number of bits used to code the exponents */
-static int encode_exp(uint8_t encoded_exp[N/2], 
-                      uint8_t exp[N/2], 
-                      int nb_exps,
-                      int exp_strategy)
-{
-    int group_size, nb_groups, i, j, k, exp_min;
-    uint8_t exp1[N/2];
-
-    switch(exp_strategy) {
-    case EXP_D15:
-        group_size = 1;
-        break;
-    case EXP_D25:
-        group_size = 2;
-        break;
-    default:
-    case EXP_D45:
-        group_size = 4;
-        break;
-    }
-    nb_groups = ((nb_exps + (group_size * 3) - 4) / (3 * group_size)) * 3;
-
-    /* for each group, compute the minimum exponent */
-    exp1[0] = exp[0]; /* DC exponent is handled separately */
-    k = 1;
-    for(i=1;i<=nb_groups;i++) {
-        exp_min = exp[k];
-        assert(exp_min >= 0 && exp_min <= 24);
-        for(j=1;j<group_size;j++) {
-            if (exp[k+j] < exp_min)
-                exp_min = exp[k+j];
-        }
-        exp1[i] = exp_min;
-        k += group_size;
-    }
-
-    /* constraint for DC exponent */
-    if (exp1[0] > 15)
-        exp1[0] = 15;
-
-    /* Decrease the delta between each groups to within 2
-     * so that they can be differentially encoded */
-    for (i=1;i<=nb_groups;i++)
-	exp1[i] = FFMIN(exp1[i], exp1[i-1] + 2);
-    for (i=nb_groups-1;i>=0;i--)
-	exp1[i] = FFMIN(exp1[i], exp1[i+1] + 2);
-
-    /* now we have the exponent values the decoder will see */
-    encoded_exp[0] = exp1[0];
-    k = 1;
-    for(i=1;i<=nb_groups;i++) {
-        for(j=0;j<group_size;j++) {
-            encoded_exp[k+j] = exp1[i];
-        }
-        k += group_size;
-    }
-    
-#if defined(DEBUG)
-    av_log(NULL, AV_LOG_DEBUG, "exponents: strategy=%d\n", exp_strategy);
-    for(i=0;i<=nb_groups * group_size;i++) {
-        av_log(NULL, AV_LOG_DEBUG, "%d ", encoded_exp[i]);
-    }
-    av_log(NULL, AV_LOG_DEBUG, "\n");
-#endif
-
-    return 4 + (nb_groups / 3) * 7;
-}
-
-/* return the size in bits taken by the mantissa */
-static int compute_mantissa_size(AC3EncodeContext *s, uint8_t *m, int nb_coefs)
-{
-    int bits, mant, i;
-
-    bits = 0;
-    for(i=0;i<nb_coefs;i++) {
-        mant = m[i];
-        switch(mant) {
-        case 0:
-            /* nothing */
-            break;
-        case 1:
-            /* 3 mantissa in 5 bits */
-            if (s->mant1_cnt == 0) 
-                bits += 5;
-            if (++s->mant1_cnt == 3)
-                s->mant1_cnt = 0;
-            break;
-        case 2:
-            /* 3 mantissa in 7 bits */
-            if (s->mant2_cnt == 0) 
-                bits += 7;
-            if (++s->mant2_cnt == 3)
-                s->mant2_cnt = 0;
-            break;
-        case 3:
-            bits += 3;
-            break;
-        case 4:
-            /* 2 mantissa in 7 bits */
-            if (s->mant4_cnt == 0)
-                bits += 7;
-            if (++s->mant4_cnt == 2) 
-                s->mant4_cnt = 0;
-            break;
-        case 14:
-            bits += 14;
-            break;
-        case 15:
-            bits += 16;
-            break;
-        default:
-            bits += mant - 1;
-            break;
-        }
-    }
-    return bits;
-}
-
-
-static int bit_alloc(AC3EncodeContext *s,
-                     uint8_t bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
-                     uint8_t encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
-                     uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS],
-                     int frame_bits, int csnroffst, int fsnroffst)
-{
-    int i, ch;
-
-    /* compute size */
-    for(i=0;i<NB_BLOCKS;i++) {
-        s->mant1_cnt = 0;
-        s->mant2_cnt = 0;
-        s->mant4_cnt = 0;
-        for(ch=0;ch<s->nb_all_channels;ch++) {
-            ac3_parametric_bit_allocation(&s->bit_alloc, 
-                                          bap[i][ch], (int8_t *)encoded_exp[i][ch], 
-                                          0, s->nb_coefs[ch], 
-                                          (((csnroffst-15) << 4) + 
-                                           fsnroffst) << 2, 
-                                          fgaintab[s->fgaincod[ch]],
-                                          ch == s->lfe_channel,
-                                          2, 0, NULL, NULL, NULL);
-            frame_bits += compute_mantissa_size(s, bap[i][ch], 
-                                                 s->nb_coefs[ch]);
-        }
-    }
-#if 0
-    printf("csnr=%d fsnr=%d frame_bits=%d diff=%d\n", 
-           csnroffst, fsnroffst, frame_bits, 
-           16 * s->frame_size - ((frame_bits + 7) & ~7));
-#endif
-    return 16 * s->frame_size - frame_bits;
-}
-
-#define SNR_INC1 4
-
-static int compute_bit_allocation(AC3EncodeContext *s,
-                                  uint8_t bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
-                                  uint8_t encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2],
-                                  uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS],
-                                  int frame_bits)
-{
-    int i, ch;
-    int csnroffst, fsnroffst;
-    uint8_t bap1[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];
-    static int frame_bits_inc[8] = { 0, 0, 2, 2, 2, 4, 2, 4 };
-
-    /* init default parameters */
-    s->sdecaycod = 2;
-    s->fdecaycod = 1;
-    s->sgaincod = 1;
-    s->dbkneecod = 2;
-    s->floorcod = 4;
-    for(ch=0;ch<s->nb_all_channels;ch++) 
-        s->fgaincod[ch] = 4;
-    
-    /* compute real values */
-    s->bit_alloc.fscod = s->fscod;
-    s->bit_alloc.halfratecod = s->halfratecod;
-    s->bit_alloc.sdecay = sdecaytab[s->sdecaycod] >> s->halfratecod;
-    s->bit_alloc.fdecay = fdecaytab[s->fdecaycod] >> s->halfratecod;
-    s->bit_alloc.sgain = sgaintab[s->sgaincod];
-    s->bit_alloc.dbknee = dbkneetab[s->dbkneecod];
-    s->bit_alloc.floor = floortab[s->floorcod];
-    
-    /* header size */
-    frame_bits += 65;
-    // if (s->acmod == 2)
-    //    frame_bits += 2;
-    frame_bits += frame_bits_inc[s->acmod];
-
-    /* audio blocks */
-    for(i=0;i<NB_BLOCKS;i++) {
-        frame_bits += s->nb_channels * 2 + 2; /* blksw * c, dithflag * c, dynrnge, cplstre */
-        if (s->acmod == 2) {
-            frame_bits++; /* rematstr */
-            if(i==0) frame_bits += 4;
-        }
-        frame_bits += 2 * s->nb_channels; /* chexpstr[2] * c */
-	if (s->lfe)
-	    frame_bits++; /* lfeexpstr */
-        for(ch=0;ch<s->nb_channels;ch++) {
-            if (exp_strategy[i][ch] != EXP_REUSE)
-                frame_bits += 6 + 2; /* chbwcod[6], gainrng[2] */
-        }
-        frame_bits++; /* baie */
-        frame_bits++; /* snr */
-        frame_bits += 2; /* delta / skip */
-    }
-    frame_bits++; /* cplinu for block 0 */
-    /* bit alloc info */
-    /* sdcycod[2], fdcycod[2], sgaincod[2], dbpbcod[2], floorcod[3] */
-    /* csnroffset[6] */
-    /* (fsnoffset[4] + fgaincod[4]) * c */
-    frame_bits += 2*4 + 3 + 6 + s->nb_all_channels * (4 + 3);
-
-    /* auxdatae, crcrsv */
-    frame_bits += 2;
-
-    /* CRC */
-    frame_bits += 16;
-
-    /* now the big work begins : do the bit allocation. Modify the snr
-       offset until we can pack everything in the requested frame size */
-
-    csnroffst = s->csnroffst;
-    while (csnroffst >= 0 && 
-	   bit_alloc(s, bap, encoded_exp, exp_strategy, frame_bits, csnroffst, 0) < 0)
-	csnroffst -= SNR_INC1;
-    if (csnroffst < 0) {
-	av_log(NULL, AV_LOG_ERROR, "Yack, Error !!!\n");
-	return -1;
-    }
-    while ((csnroffst + SNR_INC1) <= 63 && 
-           bit_alloc(s, bap1, encoded_exp, exp_strategy, frame_bits, 
-                     csnroffst + SNR_INC1, 0) >= 0) {
-        csnroffst += SNR_INC1;
-        memcpy(bap, bap1, sizeof(bap1));
-    }
-    while ((csnroffst + 1) <= 63 && 
-           bit_alloc(s, bap1, encoded_exp, exp_strategy, frame_bits, csnroffst + 1, 0) >= 0) {
-        csnroffst++;
-        memcpy(bap, bap1, sizeof(bap1));
-    }
-
-    fsnroffst = 0;
-    while ((fsnroffst + SNR_INC1) <= 15 && 
-           bit_alloc(s, bap1, encoded_exp, exp_strategy, frame_bits, 
-                     csnroffst, fsnroffst + SNR_INC1) >= 0) {
-        fsnroffst += SNR_INC1;
-        memcpy(bap, bap1, sizeof(bap1));
-    }
-    while ((fsnroffst + 1) <= 15 && 
-           bit_alloc(s, bap1, encoded_exp, exp_strategy, frame_bits, 
-                     csnroffst, fsnroffst + 1) >= 0) {
-        fsnroffst++;
-        memcpy(bap, bap1, sizeof(bap1));
-    }
-    
-    s->csnroffst = csnroffst;
-    for(ch=0;ch<s->nb_all_channels;ch++)
-        s->fsnroffst[ch] = fsnroffst;
-#if defined(DEBUG_BITALLOC)
-    {
-        int j;
-
-        for(i=0;i<6;i++) {
-            for(ch=0;ch<s->nb_all_channels;ch++) {
-                printf("Block #%d Ch%d:\n", i, ch);
-                printf("bap=");
-                for(j=0;j<s->nb_coefs[ch];j++) {
-                    printf("%d ",bap[i][ch][j]);
-                }
-                printf("\n");
-            }
-        }
-    }
-#endif
-    return 0;
-}
-
-void ac3_common_init(void)
-{
-    int i, j, k, l, v;
-    /* compute bndtab and masktab from bandsz */
-    k = 0;
-    l = 0;
-    for(i=0;i<50;i++) {
-        bndtab[i] = l;
-        v = bndsz[i];
-        for(j=0;j<v;j++) masktab[k++]=i;
-        l += v;
-    }
-    bndtab[50] = 0;
-}
-
-
-static int AC3_encode_init(AVCodecContext *avctx)
-{
-    int freq = avctx->sample_rate;
-    int bitrate = avctx->bit_rate;
-    int channels = avctx->channels;
-    AC3EncodeContext *s = avctx->priv_data;
-    int i, j, ch;
-    float alpha;
-    static const uint8_t acmod_defs[6] = {
-	0x01, /* C */
-	0x02, /* L R */
-	0x03, /* L C R */
-	0x06, /* L R SL SR */
-	0x07, /* L C R SL SR */
-	0x07, /* L C R SL SR (+LFE) */
-    };
-
-    avctx->frame_size = AC3_FRAME_SIZE;
-    
-    /* number of channels */
-    if (channels < 1 || channels > 6)
-	return -1;
-    s->acmod = acmod_defs[channels - 1];
-    s->lfe = (channels == 6) ? 1 : 0;
-    s->nb_all_channels = channels;
-    s->nb_channels = channels > 5 ? 5 : channels;
-    s->lfe_channel = s->lfe ? 5 : -1;
-
-    /* frequency */
-    for(i=0;i<3;i++) {
-        for(j=0;j<3;j++) 
-            if ((ac3_freqs[j] >> i) == freq)
-                goto found;
-    }
-    return -1;
- found:    
-    s->sample_rate = freq;
-    s->halfratecod = i;
-    s->fscod = j;
-    s->bsid = 8 + s->halfratecod;
-    s->bsmod = 0; /* complete main audio service */
-
-    /* bitrate & frame size */
-    bitrate /= 1000;
-    for(i=0;i<19;i++) {
-        if ((ac3_bitratetab[i] >> s->halfratecod) == bitrate)
-            break;
-    }
-    if (i == 19)
-        return -1;
-    s->bit_rate = bitrate;
-    s->frmsizecod = i << 1;
-    s->frame_size_min = (bitrate * 1000 * AC3_FRAME_SIZE) / (freq * 16);
-    /* for now we do not handle fractional sizes */
-    s->frame_size = s->frame_size_min;
-    
-    /* bit allocation init */
-    for(ch=0;ch<s->nb_channels;ch++) {
-        /* bandwidth for each channel */
-        /* XXX: should compute the bandwidth according to the frame
-           size, so that we avoid anoying high freq artefacts */
-        s->chbwcod[ch] = 50; /* sample bandwidth as mpeg audio layer 2 table 0 */
-        s->nb_coefs[ch] = ((s->chbwcod[ch] + 12) * 3) + 37;
-    }
-    if (s->lfe) {
-	s->nb_coefs[s->lfe_channel] = 7; /* fixed */
-    }
-    /* initial snr offset */
-    s->csnroffst = 40;
-
-    ac3_common_init();
-
-    /* mdct init */
-    fft_init(MDCT_NBITS - 2);
-    for(i=0;i<N/4;i++) {
-        alpha = 2 * M_PI * (i + 1.0 / 8.0) / (float)N;
-        xcos1[i] = fix15(-cos(alpha));
-        xsin1[i] = fix15(-sin(alpha));
-    }
-
-    ac3_crc_init();
-    
-    avctx->coded_frame= avcodec_alloc_frame();
-    avctx->coded_frame->key_frame= 1;
-
-    return 0;
-}
-
-/* output the AC3 frame header */
-static void output_frame_header(AC3EncodeContext *s, unsigned char *frame)
-{
-    init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE);
-
-    put_bits(&s->pb, 16, 0x0b77); /* frame header */
-    put_bits(&s->pb, 16, 0); /* crc1: will be filled later */
-    put_bits(&s->pb, 2, s->fscod);
-    put_bits(&s->pb, 6, s->frmsizecod + (s->frame_size - s->frame_size_min));
-    put_bits(&s->pb, 5, s->bsid);
-    put_bits(&s->pb, 3, s->bsmod);
-    put_bits(&s->pb, 3, s->acmod);
-    if ((s->acmod & 0x01) && s->acmod != 0x01)
-	put_bits(&s->pb, 2, 1); /* XXX -4.5 dB */
-    if (s->acmod & 0x04)
-	put_bits(&s->pb, 2, 1); /* XXX -6 dB */
-    if (s->acmod == 0x02)
-        put_bits(&s->pb, 2, 0); /* surround not indicated */
-    put_bits(&s->pb, 1, s->lfe); /* LFE */
-    put_bits(&s->pb, 5, 31); /* dialog norm: -31 db */
-    put_bits(&s->pb, 1, 0); /* no compression control word */
-    put_bits(&s->pb, 1, 0); /* no lang code */
-    put_bits(&s->pb, 1, 0); /* no audio production info */
-    put_bits(&s->pb, 1, 0); /* no copyright */
-    put_bits(&s->pb, 1, 1); /* original bitstream */
-    put_bits(&s->pb, 1, 0); /* no time code 1 */
-    put_bits(&s->pb, 1, 0); /* no time code 2 */
-    put_bits(&s->pb, 1, 0); /* no addtional bit stream info */
-}
-
-/* symetric quantization on 'levels' levels */
-static inline int sym_quant(int c, int e, int levels)
-{
-    int v;
-
-    if (c >= 0) {
-        v = (levels * (c << e)) >> 24;
-        v = (v + 1) >> 1;
-        v = (levels >> 1) + v;
-    } else {
-        v = (levels * ((-c) << e)) >> 24;
-        v = (v + 1) >> 1;
-        v = (levels >> 1) - v;
-    }
-    assert (v >= 0 && v < levels);
-    return v;
-}
-
-/* asymetric quantization on 2^qbits levels */
-static inline int asym_quant(int c, int e, int qbits)
-{
-    int lshift, m, v;
-
-    lshift = e + qbits - 24;
-    if (lshift >= 0)
-        v = c << lshift;
-    else
-        v = c >> (-lshift);
-    /* rounding */
-    v = (v + 1) >> 1;
-    m = (1 << (qbits-1));
-    if (v >= m)
-        v = m - 1;
-    assert(v >= -m);
-    return v & ((1 << qbits)-1);
-}
-
-/* Output one audio block. There are NB_BLOCKS audio blocks in one AC3
-   frame */
-static void output_audio_block(AC3EncodeContext *s,
-                               uint8_t exp_strategy[AC3_MAX_CHANNELS],
-                               uint8_t encoded_exp[AC3_MAX_CHANNELS][N/2],
-                               uint8_t bap[AC3_MAX_CHANNELS][N/2],
-                               int32_t mdct_coefs[AC3_MAX_CHANNELS][N/2],
-                               int8_t global_exp[AC3_MAX_CHANNELS],
-                               int block_num)
-{
-    int ch, nb_groups, group_size, i, baie, rbnd;
-    uint8_t *p;
-    uint16_t qmant[AC3_MAX_CHANNELS][N/2];
-    int exp0, exp1;
-    int mant1_cnt, mant2_cnt, mant4_cnt;
-    uint16_t *qmant1_ptr, *qmant2_ptr, *qmant4_ptr;
-    int delta0, delta1, delta2;
-
-    for(ch=0;ch<s->nb_channels;ch++) 
-        put_bits(&s->pb, 1, 0); /* 512 point MDCT */
-    for(ch=0;ch<s->nb_channels;ch++) 
-        put_bits(&s->pb, 1, 1); /* no dither */
-    put_bits(&s->pb, 1, 0); /* no dynamic range */
-    if (block_num == 0) {
-        /* for block 0, even if no coupling, we must say it. This is a
-           waste of bit :-) */
-        put_bits(&s->pb, 1, 1); /* coupling strategy present */
-        put_bits(&s->pb, 1, 0); /* no coupling strategy */
-    } else {
-        put_bits(&s->pb, 1, 0); /* no new coupling strategy */
-    }
-
-    if (s->acmod == 2)
-      {
-	if(block_num==0)
-	  {
-	    /* first block must define rematrixing (rematstr)  */
-	    put_bits(&s->pb, 1, 1); 
-	    
-	    /* dummy rematrixing rematflg(1:4)=0 */
-	    for (rbnd=0;rbnd<4;rbnd++)
-	      put_bits(&s->pb, 1, 0); 
-	  }
-	else 
-	  {
-	    /* no matrixing (but should be used in the future) */
-	    put_bits(&s->pb, 1, 0);
-	  } 
-      }
-
-#if defined(DEBUG) 
-    {
-      static int count = 0;
-      av_log(NULL, AV_LOG_DEBUG, "Block #%d (%d)\n", block_num, count++);
-    }
-#endif
-    /* exponent strategy */
-    for(ch=0;ch<s->nb_channels;ch++) {
-        put_bits(&s->pb, 2, exp_strategy[ch]);
-    }
-    
-    if (s->lfe) {
-	put_bits(&s->pb, 1, exp_strategy[s->lfe_channel]);
-    }
-
-    for(ch=0;ch<s->nb_channels;ch++) {
-        if (exp_strategy[ch] != EXP_REUSE)
-            put_bits(&s->pb, 6, s->chbwcod[ch]);
-    }
-    
-    /* exponents */
-    for (ch = 0; ch < s->nb_all_channels; ch++) {
-        switch(exp_strategy[ch]) {
-        case EXP_REUSE:
-            continue;
-        case EXP_D15:
-            group_size = 1;
-            break;
-        case EXP_D25:
-            group_size = 2;
-            break;
-        default:
-        case EXP_D45:
-            group_size = 4;
-            break;
-        }
-	nb_groups = (s->nb_coefs[ch] + (group_size * 3) - 4) / (3 * group_size);
-        p = encoded_exp[ch];
-
-        /* first exponent */
-        exp1 = *p++;
-        put_bits(&s->pb, 4, exp1);
-
-        /* next ones are delta encoded */
-        for(i=0;i<nb_groups;i++) {
-            /* merge three delta in one code */
-            exp0 = exp1;
-            exp1 = p[0];
-            p += group_size;
-            delta0 = exp1 - exp0 + 2;
-
-            exp0 = exp1;
-            exp1 = p[0];
-            p += group_size;
-            delta1 = exp1 - exp0 + 2;
-
-            exp0 = exp1;
-            exp1 = p[0];
-            p += group_size;
-            delta2 = exp1 - exp0 + 2;
-
-            put_bits(&s->pb, 7, ((delta0 * 5 + delta1) * 5) + delta2);
-        }
-
-	if (ch != s->lfe_channel)
-	    put_bits(&s->pb, 2, 0); /* no gain range info */
-    }
-
-    /* bit allocation info */
-    baie = (block_num == 0);
-    put_bits(&s->pb, 1, baie);
-    if (baie) {
-        put_bits(&s->pb, 2, s->sdecaycod);
-        put_bits(&s->pb, 2, s->fdecaycod);
-        put_bits(&s->pb, 2, s->sgaincod);
-        put_bits(&s->pb, 2, s->dbkneecod);
-        put_bits(&s->pb, 3, s->floorcod);
-    }
-
-    /* snr offset */
-    put_bits(&s->pb, 1, baie); /* always present with bai */
-    if (baie) {
-        put_bits(&s->pb, 6, s->csnroffst);
-        for(ch=0;ch<s->nb_all_channels;ch++) {
-            put_bits(&s->pb, 4, s->fsnroffst[ch]);
-            put_bits(&s->pb, 3, s->fgaincod[ch]);
-        }
-    }
-    
-    put_bits(&s->pb, 1, 0); /* no delta bit allocation */
-    put_bits(&s->pb, 1, 0); /* no data to skip */
-
-    /* mantissa encoding : we use two passes to handle the grouping. A
-       one pass method may be faster, but it would necessitate to
-       modify the output stream. */
-
-    /* first pass: quantize */
-    mant1_cnt = mant2_cnt = mant4_cnt = 0;
-    qmant1_ptr = qmant2_ptr = qmant4_ptr = NULL;
-
-    for (ch = 0; ch < s->nb_all_channels; ch++) {
-        int b, c, e, v;
-
-        for(i=0;i<s->nb_coefs[ch];i++) {
-            c = mdct_coefs[ch][i];
-            e = encoded_exp[ch][i] - global_exp[ch];
-            b = bap[ch][i];
-            switch(b) {
-            case 0:
-                v = 0;
-                break;
-            case 1:
-                v = sym_quant(c, e, 3);
-                switch(mant1_cnt) {
-                case 0:
-                    qmant1_ptr = &qmant[ch][i];
-                    v = 9 * v;
-                    mant1_cnt = 1;
-                    break;
-                case 1:
-                    *qmant1_ptr += 3 * v;
-                    mant1_cnt = 2;
-                    v = 128;
-                    break;
-                default:
-                    *qmant1_ptr += v;
-                    mant1_cnt = 0;
-                    v = 128;
-                    break;
-                }
-                break;
-            case 2:
-                v = sym_quant(c, e, 5);
-                switch(mant2_cnt) {
-                case 0:
-                    qmant2_ptr = &qmant[ch][i];
-                    v = 25 * v;
-                    mant2_cnt = 1;
-                    break;
-                case 1:
-                    *qmant2_ptr += 5 * v;
-                    mant2_cnt = 2;
-                    v = 128;
-                    break;
-                default:
-                    *qmant2_ptr += v;
-                    mant2_cnt = 0;
-                    v = 128;
-                    break;
-                }
-                break;
-            case 3:
-                v = sym_quant(c, e, 7);
-                break;
-            case 4:
-                v = sym_quant(c, e, 11);
-                switch(mant4_cnt) {
-                case 0:
-                    qmant4_ptr = &qmant[ch][i];
-                    v = 11 * v;
-                    mant4_cnt = 1;
-                    break;
-                default:
-                    *qmant4_ptr += v;
-                    mant4_cnt = 0;
-                    v = 128;
-                    break;
-                }
-                break;
-            case 5:
-                v = sym_quant(c, e, 15);
-                break;
-            case 14:
-                v = asym_quant(c, e, 14);
-                break;
-            case 15:
-                v = asym_quant(c, e, 16);
-                break;
-            default:
-                v = asym_quant(c, e, b - 1);
-                break;
-            }
-            qmant[ch][i] = v;
-        }
-    }
-
-    /* second pass : output the values */
-    for (ch = 0; ch < s->nb_all_channels; ch++) {
-        int b, q;
-        
-        for(i=0;i<s->nb_coefs[ch];i++) {
-            q = qmant[ch][i];
-            b = bap[ch][i];
-            switch(b) {
-            case 0:
-                break;
-            case 1:
-                if (q != 128) 
-                    put_bits(&s->pb, 5, q);
-                break;
-            case 2:
-                if (q != 128) 
-                    put_bits(&s->pb, 7, q);
-                break;
-            case 3:
-                put_bits(&s->pb, 3, q);
-                break;
-            case 4:
-                if (q != 128)
-                    put_bits(&s->pb, 7, q);
-                break;
-            case 14:
-                put_bits(&s->pb, 14, q);
-                break;
-            case 15:
-                put_bits(&s->pb, 16, q);
-                break;
-            default:
-                put_bits(&s->pb, b - 1, q);
-                break;
-            }
-        }
-    }
-}
-
-/* compute the ac3 crc */
-
-#define CRC16_POLY ((1 << 0) | (1 << 2) | (1 << 15) | (1 << 16))
-
-static void ac3_crc_init(void)
-{
-    unsigned int c, n, k;
-
-    for(n=0;n<256;n++) {
-        c = n << 8;
-        for (k = 0; k < 8; k++) {
-            if (c & (1 << 15)) 
-                c = ((c << 1) & 0xffff) ^ (CRC16_POLY & 0xffff);
-            else
-                c = c << 1;
-        }
-        crc_table[n] = c;
-    }
-}
-
-static unsigned int ac3_crc(uint8_t *data, int n, unsigned int crc)
-{
-    int i;
-    for(i=0;i<n;i++) {
-        crc = (crc_table[data[i] ^ (crc >> 8)] ^ (crc << 8)) & 0xffff;
-    }
-    return crc;
-}
-
-static unsigned int mul_poly(unsigned int a, unsigned int b, unsigned int poly)
-{
-    unsigned int c;
-
-    c = 0;
-    while (a) {
-        if (a & 1)
-            c ^= b;
-        a = a >> 1;
-        b = b << 1;
-        if (b & (1 << 16))
-            b ^= poly;
-    }
-    return c;
-}
-
-static unsigned int pow_poly(unsigned int a, unsigned int n, unsigned int poly)
-{
-    unsigned int r;
-    r = 1;
-    while (n) {
-        if (n & 1)
-            r = mul_poly(r, a, poly);
-        a = mul_poly(a, a, poly);
-        n >>= 1;
-    }
-    return r;
-}
-
-
-/* compute log2(max(abs(tab[]))) */
-static int log2_tab(int16_t *tab, int n)
-{
-    int i, v;
-
-    v = 0;
-    for(i=0;i<n;i++) {
-        v |= abs(tab[i]);
-    }
-    return av_log2(v);
-}
-
-static void lshift_tab(int16_t *tab, int n, int lshift)
-{
-    int i;
-
-    if (lshift > 0) {
-        for(i=0;i<n;i++) {
-            tab[i] <<= lshift;
-        }
-    } else if (lshift < 0) {
-        lshift = -lshift;
-        for(i=0;i<n;i++) {
-            tab[i] >>= lshift;
-        }
-    }
-}
-
-/* fill the end of the frame and compute the two crcs */
-static int output_frame_end(AC3EncodeContext *s)
-{
-    int frame_size, frame_size_58, n, crc1, crc2, crc_inv;
-    uint8_t *frame;
-
-    frame_size = s->frame_size; /* frame size in words */
-    /* align to 8 bits */
-    flush_put_bits(&s->pb);
-    /* add zero bytes to reach the frame size */
-    frame = s->pb.buf;
-    n = 2 * s->frame_size - (pbBufPtr(&s->pb) - frame) - 2;
-    assert(n >= 0);
-    if(n>0)
-      memset(pbBufPtr(&s->pb), 0, n);
-    
-    /* Now we must compute both crcs : this is not so easy for crc1
-       because it is at the beginning of the data... */
-    frame_size_58 = (frame_size >> 1) + (frame_size >> 3);
-    crc1 = ac3_crc(frame + 4, (2 * frame_size_58) - 4, 0);
-    /* XXX: could precompute crc_inv */
-    crc_inv = pow_poly((CRC16_POLY >> 1), (16 * frame_size_58) - 16, CRC16_POLY);
-    crc1 = mul_poly(crc_inv, crc1, CRC16_POLY);
-    frame[2] = crc1 >> 8;
-    frame[3] = crc1;
-    
-    crc2 = ac3_crc(frame + 2 * frame_size_58, (frame_size - frame_size_58) * 2 - 2, 0);
-    frame[2*frame_size - 2] = crc2 >> 8;
-    frame[2*frame_size - 1] = crc2;
-
-    //    printf("n=%d frame_size=%d\n", n, frame_size);
-    return frame_size * 2;
-}
-
-static int AC3_encode_frame(AVCodecContext *avctx,
-                            unsigned char *frame, int buf_size, void *data)
-{
-    AC3EncodeContext *s = avctx->priv_data;
-    int16_t *samples = data;
-    int i, j, k, v, ch;
-    int16_t input_samples[N];
-    int32_t mdct_coef[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];
-    uint8_t exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];
-    uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS];
-    uint8_t encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];
-    uint8_t bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2];
-    int8_t exp_samples[NB_BLOCKS][AC3_MAX_CHANNELS];
-    int frame_bits;
-
-    frame_bits = 0;
-    for(ch=0;ch<s->nb_all_channels;ch++) {
-        /* fixed mdct to the six sub blocks & exponent computation */
-        for(i=0;i<NB_BLOCKS;i++) {
-            int16_t *sptr;
-            int sinc;
-
-            /* compute input samples */
-            memcpy(input_samples, s->last_samples[ch], N/2 * sizeof(int16_t));
-            sinc = s->nb_all_channels;
-            sptr = samples + (sinc * (N/2) * i) + ch;
-            for(j=0;j<N/2;j++) {
-                v = *sptr;
-                input_samples[j + N/2] = v;
-                s->last_samples[ch][j] = v; 
-                sptr += sinc;
-            }
-
-            /* apply the MDCT window */
-            for(j=0;j<N/2;j++) {
-                input_samples[j] = MUL16(input_samples[j], 
-                                         ac3_window[j]) >> 15;
-                input_samples[N-j-1] = MUL16(input_samples[N-j-1], 
-                                             ac3_window[j]) >> 15;
-            }
-        
-            /* Normalize the samples to use the maximum available
-               precision */
-            v = 14 - log2_tab(input_samples, N);
-            if (v < 0)
-                v = 0;
-            exp_samples[i][ch] = v - 8;
-            lshift_tab(input_samples, N, v);
-
-            /* do the MDCT */
-            mdct512(mdct_coef[i][ch], input_samples);
-            
-            /* compute "exponents". We take into account the
-               normalization there */
-            for(j=0;j<N/2;j++) {
-                int e;
-                v = abs(mdct_coef[i][ch][j]);
-                if (v == 0)
-                    e = 24;
-                else {
-                    e = 23 - av_log2(v) + exp_samples[i][ch];
-                    if (e >= 24) {
-                        e = 24;
-                        mdct_coef[i][ch][j] = 0;
-                    }
-                }
-                exp[i][ch][j] = e;
-            }
-        }
-        
-        compute_exp_strategy(exp_strategy, exp, ch, ch == s->lfe_channel);
-
-        /* compute the exponents as the decoder will see them. The
-           EXP_REUSE case must be handled carefully : we select the
-           min of the exponents */
-        i = 0;
-        while (i < NB_BLOCKS) {
-            j = i + 1;
-            while (j < NB_BLOCKS && exp_strategy[j][ch] == EXP_REUSE) {
-                exponent_min(exp[i][ch], exp[j][ch], s->nb_coefs[ch]);
-                j++;
-            }
-            frame_bits += encode_exp(encoded_exp[i][ch],
-                                     exp[i][ch], s->nb_coefs[ch], 
-                                     exp_strategy[i][ch]);
-            /* copy encoded exponents for reuse case */
-            for(k=i+1;k<j;k++) {
-                memcpy(encoded_exp[k][ch], encoded_exp[i][ch], 
-                       s->nb_coefs[ch] * sizeof(uint8_t));
-            }
-            i = j;
-        }
-    }
-
-    compute_bit_allocation(s, bap, encoded_exp, exp_strategy, frame_bits);
-    /* everything is known... let's output the frame */
-    output_frame_header(s, frame);
-        
-    for(i=0;i<NB_BLOCKS;i++) {
-        output_audio_block(s, exp_strategy[i], encoded_exp[i], 
-                           bap[i], mdct_coef[i], exp_samples[i], i);
-    }
-    return output_frame_end(s);
-}
-
-static int AC3_encode_close(AVCodecContext *avctx)
-{
-    av_freep(&avctx->coded_frame);
-    return 0;
-}
-
-#if 0
-/*************************************************************************/
-/* TEST */
-
-#define FN (N/4)
-
-void fft_test(void)
-{
-    IComplex in[FN], in1[FN];
-    int k, n, i;
-    float sum_re, sum_im, a;
-
-    /* FFT test */
-
-    for(i=0;i<FN;i++) {
-        in[i].re = random() % 65535 - 32767;
-        in[i].im = random() % 65535 - 32767;
-        in1[i] = in[i];
-    }
-    fft(in, 7);
-
-    /* do it by hand */
-    for(k=0;k<FN;k++) {
-        sum_re = 0;
-        sum_im = 0;
-        for(n=0;n<FN;n++) {
-            a = -2 * M_PI * (n * k) / FN;
-            sum_re += in1[n].re * cos(a) - in1[n].im * sin(a);
-            sum_im += in1[n].re * sin(a) + in1[n].im * cos(a);
-        }
-        printf("%3d: %6d,%6d %6.0f,%6.0f\n", 
-               k, in[k].re, in[k].im, sum_re / FN, sum_im / FN); 
-    }
-}
-
-void mdct_test(void)
-{
-    int16_t input[N];
-    int32_t output[N/2];
-    float input1[N];
-    float output1[N/2];
-    float s, a, err, e, emax;
-    int i, k, n;
-
-    for(i=0;i<N;i++) {
-        input[i] = (random() % 65535 - 32767) * 9 / 10;
-        input1[i] = input[i];
-    }
-
-    mdct512(output, input);
-    
-    /* do it by hand */
-    for(k=0;k<N/2;k++) {
-        s = 0;
-        for(n=0;n<N;n++) {
-            a = (2*M_PI*(2*n+1+N/2)*(2*k+1) / (4 * N));
-            s += input1[n] * cos(a);
-        }
-        output1[k] = -2 * s / N;
-    }
-    
-    err = 0;
-    emax = 0;
-    for(i=0;i<N/2;i++) {
-        printf("%3d: %7d %7.0f\n", i, output[i], output1[i]);
-        e = output[i] - output1[i];
-        if (e > emax)
-            emax = e;
-        err += e * e;
-    }
-    printf("err2=%f emax=%f\n", err / (N/2), emax);
-}
-
-void test_ac3(void)
-{
-    AC3EncodeContext ctx;
-    unsigned char frame[AC3_MAX_CODED_FRAME_SIZE];
-    short samples[AC3_FRAME_SIZE];
-    int ret, i;
-    
-    AC3_encode_init(&ctx, 44100, 64000, 1);
-
-    fft_test();
-    mdct_test();
-
-    for(i=0;i<AC3_FRAME_SIZE;i++)
-        samples[i] = (int)(sin(2*M_PI*i*1000.0/44100) * 10000);
-    ret = AC3_encode_frame(&ctx, frame, samples);
-    printf("ret=%d\n", ret);
-}
-#endif
-
-AVCodec ac3_encoder = {
-    "ac3",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_AC3,
-    sizeof(AC3EncodeContext),
-    AC3_encode_init,
-    AC3_encode_frame,
-    AC3_encode_close,
-    NULL,
-};
diff --git a/ffmpeg.src/libavcodec/ac3tab.h b/ffmpeg.src/libavcodec/ac3tab.h
deleted file mode 100644
index 8e667b7..0000000
--- a/ffmpeg.src/libavcodec/ac3tab.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/**
- * @file ac3tab.h
- * tables taken directly from AC3 spec.
- */
-
-/* possible frequencies */
-static const uint16_t ac3_freqs[3] = { 48000, 44100, 32000 };
-
-/* possible bitrates */
-static const uint16_t ac3_bitratetab[19] = {
-    32, 40, 48, 56, 64, 80, 96, 112, 128, 
-    160, 192, 224, 256, 320, 384, 448, 512, 576, 640 
-};
-
-/* AC3 MDCT window */
-
-/* MDCT window */
-static const int16_t ac3_window[256] = {
-    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,  
-};
-
-static uint8_t masktab[253];
-
-static const uint8_t latab[260]= {
-0x0040,0x003f,0x003e,0x003d,0x003c,0x003b,0x003a,0x0039,0x0038,0x0037,
-0x0036,0x0035,0x0034,0x0034,0x0033,0x0032,0x0031,0x0030,0x002f,0x002f,
-0x002e,0x002d,0x002c,0x002c,0x002b,0x002a,0x0029,0x0029,0x0028,0x0027,
-0x0026,0x0026,0x0025,0x0024,0x0024,0x0023,0x0023,0x0022,0x0021,0x0021,
-0x0020,0x0020,0x001f,0x001e,0x001e,0x001d,0x001d,0x001c,0x001c,0x001b,
-0x001b,0x001a,0x001a,0x0019,0x0019,0x0018,0x0018,0x0017,0x0017,0x0016,
-0x0016,0x0015,0x0015,0x0015,0x0014,0x0014,0x0013,0x0013,0x0013,0x0012,
-0x0012,0x0012,0x0011,0x0011,0x0011,0x0010,0x0010,0x0010,0x000f,0x000f,
-0x000f,0x000e,0x000e,0x000e,0x000d,0x000d,0x000d,0x000d,0x000c,0x000c,
-0x000c,0x000c,0x000b,0x000b,0x000b,0x000b,0x000a,0x000a,0x000a,0x000a,
-0x000a,0x0009,0x0009,0x0009,0x0009,0x0009,0x0008,0x0008,0x0008,0x0008,
-0x0008,0x0008,0x0007,0x0007,0x0007,0x0007,0x0007,0x0007,0x0006,0x0006,
-0x0006,0x0006,0x0006,0x0006,0x0006,0x0006,0x0005,0x0005,0x0005,0x0005,
-0x0005,0x0005,0x0005,0x0005,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,
-0x0004,0x0004,0x0004,0x0004,0x0004,0x0003,0x0003,0x0003,0x0003,0x0003,
-0x0003,0x0003,0x0003,0x0003,0x0003,0x0003,0x0003,0x0003,0x0003,0x0002,
-0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,
-0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0001,0x0001,
-0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
-0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
-0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,
-0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
-0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
-0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
-0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
-0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
-};
-
-static const uint16_t hth[50][3]= {
-{ 0x04d0,0x04f0,0x0580 },
-{ 0x04d0,0x04f0,0x0580 },
-{ 0x0440,0x0460,0x04b0 },
-{ 0x0400,0x0410,0x0450 },
-{ 0x03e0,0x03e0,0x0420 },
-{ 0x03c0,0x03d0,0x03f0 },
-{ 0x03b0,0x03c0,0x03e0 },
-{ 0x03b0,0x03b0,0x03d0 },
-{ 0x03a0,0x03b0,0x03c0 },
-{ 0x03a0,0x03a0,0x03b0 },
-{ 0x03a0,0x03a0,0x03b0 },
-{ 0x03a0,0x03a0,0x03b0 },
-{ 0x03a0,0x03a0,0x03a0 },
-{ 0x0390,0x03a0,0x03a0 },
-{ 0x0390,0x0390,0x03a0 },
-{ 0x0390,0x0390,0x03a0 },
-{ 0x0380,0x0390,0x03a0 },
-{ 0x0380,0x0380,0x03a0 },
-{ 0x0370,0x0380,0x03a0 },
-{ 0x0370,0x0380,0x03a0 },
-{ 0x0360,0x0370,0x0390 },
-{ 0x0360,0x0370,0x0390 },
-{ 0x0350,0x0360,0x0390 },
-{ 0x0350,0x0360,0x0390 },
-{ 0x0340,0x0350,0x0380 },
-{ 0x0340,0x0350,0x0380 },
-{ 0x0330,0x0340,0x0380 },
-{ 0x0320,0x0340,0x0370 },
-{ 0x0310,0x0320,0x0360 },
-{ 0x0300,0x0310,0x0350 },
-{ 0x02f0,0x0300,0x0340 },
-{ 0x02f0,0x02f0,0x0330 },
-{ 0x02f0,0x02f0,0x0320 },
-{ 0x02f0,0x02f0,0x0310 },
-{ 0x0300,0x02f0,0x0300 },
-{ 0x0310,0x0300,0x02f0 },
-{ 0x0340,0x0320,0x02f0 },
-{ 0x0390,0x0350,0x02f0 },
-{ 0x03e0,0x0390,0x0300 },
-{ 0x0420,0x03e0,0x0310 },
-{ 0x0460,0x0420,0x0330 },
-{ 0x0490,0x0450,0x0350 },
-{ 0x04a0,0x04a0,0x03c0 },
-{ 0x0460,0x0490,0x0410 },
-{ 0x0440,0x0460,0x0470 },
-{ 0x0440,0x0440,0x04a0 },
-{ 0x0520,0x0480,0x0460 },
-{ 0x0800,0x0630,0x0440 },
-{ 0x0840,0x0840,0x0450 },
-{ 0x0840,0x0840,0x04e0 },
-};
-
-static const uint8_t baptab[64]= {
-    0, 1, 1, 1, 1, 1, 2, 2, 3, 3, 
-    3, 4, 4, 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, 14, 14, 14, 14, 15, 15, 15, 15, 15, 
-    15, 15, 15, 15,
-};
-
-static const uint8_t sdecaytab[4]={ 
-    0x0f, 0x11, 0x13, 0x15,
-};
-
-static const uint8_t fdecaytab[4]={ 
-    0x3f, 0x53, 0x67, 0x7b, 
-};
-
-static const uint16_t sgaintab[4]= { 
-    0x540, 0x4d8, 0x478, 0x410,
-};
-
-static const uint16_t dbkneetab[4]= { 
-    0x000, 0x700, 0x900, 0xb00,
-};
-
-static const uint16_t floortab[8]= { 
-    0x2f0, 0x2b0, 0x270, 0x230, 0x1f0, 0x170, 0x0f0, 0xf800,
-};
-
-static const uint16_t fgaintab[8]= {
-    0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400,
-};
-
-static const uint8_t bndsz[50]={
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 
-    3, 6, 6, 6, 6, 6, 6, 12, 12, 12, 12, 24, 24, 24, 24, 24 
-};
-
-static uint8_t bndtab[51]; 
-
-/* fft & mdct sin cos tables */
-static int16_t costab[64];
-static int16_t sintab[64];
-static int16_t fft_rev[512];
-static int16_t xcos1[128];
-static int16_t xsin1[128];
-
-static uint16_t crc_table[256];
diff --git a/ffmpeg.src/libavcodec/adpcm.c b/ffmpeg.src/libavcodec/adpcm.c
deleted file mode 100644
index 3c67242..0000000
--- a/ffmpeg.src/libavcodec/adpcm.c
+++ /dev/null
@@ -1,1121 +0,0 @@
-/*
- * ADPCM codecs
- * Copyright (c) 2001-2003 The ffmpeg Project
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avcodec.h"
-#include "bitstream.h"
-
-/**
- * @file adpcm.c
- * ADPCM codecs.
- * First version by Francois Revol (revol at free.fr)
- * Fringe ADPCM codecs (e.g., DK3, DK4, Westwood)
- *   by Mike Melanson (melanson at pcisys.net)
- * CD-ROM XA ADPCM codec by BERO
- * EA ADPCM decoder by Robin Kay (komadori at myrealbox.com)
- *
- * Features and limitations:
- *
- * Reference documents:
- * http://www.pcisys.net/~melanson/codecs/simpleaudio.html
- * http://www.geocities.com/SiliconValley/8682/aud3.txt
- * http://openquicktime.sourceforge.net/plugins.htm
- * XAnim sources (xa_codec.c) http://www.rasnaimaging.com/people/lapus/download.html
- * http://www.cs.ucla.edu/~leec/mediabench/applications.html
- * SoX source code http://home.sprynet.com/~cbagwell/sox.html
- *
- * CD-ROM XA:
- * http://ku-www.ss.titech.ac.jp/~yatsushi/xaadpcm.html
- * vagpack & depack http://homepages.compuserve.de/bITmASTER32/psx-index.html
- * readstr http://www.geocities.co.jp/Playtown/2004/
- */
-
-#define BLKSIZE 1024
-
-#define CLAMP_TO_SHORT(value) \
-if (value > 32767) \
-    value = 32767; \
-else if (value < -32768) \
-    value = -32768; \
-
-/* step_table[] and index_table[] are from the ADPCM reference source */
-/* This is the index table: */
-static const int index_table[16] = {
-    -1, -1, -1, -1, 2, 4, 6, 8,
-    -1, -1, -1, -1, 2, 4, 6, 8,
-};
-
-/** 
- * This is the step table. Note that many programs use slight deviations from
- * this table, but such deviations are negligible:
- */
-static const int step_table[89] = {
-    7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
-    19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
-    50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
-    130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
-    337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
-    876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
-    2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
-    5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
-    15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
-};
-
-/* These are for MS-ADPCM */
-/* AdaptationTable[], AdaptCoeff1[], and AdaptCoeff2[] are from libsndfile */
-static const int AdaptationTable[] = {
-        230, 230, 230, 230, 307, 409, 512, 614,
-        768, 614, 512, 409, 307, 230, 230, 230
-};
-
-static const int AdaptCoeff1[] = {
-        256, 512, 0, 192, 240, 460, 392
-};
-
-static const int AdaptCoeff2[] = {
-        0, -256, 0, 64, 0, -208, -232
-};
-
-/* These are for CD-ROM XA ADPCM */
-static const int xa_adpcm_table[5][2] = {
-   {   0,   0 },
-   {  60,   0 },
-   { 115, -52 },
-   {  98, -55 },
-   { 122, -60 }
-};
-
-static const int ea_adpcm_table[] = {
-    0, 240, 460, 392, 0, 0, -208, -220, 0, 1,
-    3, 4, 7, 8, 10, 11, 0, -1, -3, -4
-};
-
-static const int ct_adpcm_table[8] = {
-    0x00E6, 0x00E6, 0x00E6, 0x00E6,
-    0x0133, 0x0199, 0x0200, 0x0266
-};
-
-// padded to zero where table size is less then 16
-static const int swf_index_tables[4][16] = {
-    /*2*/ { -1, 2 },
-    /*3*/ { -1, -1, 2, 4 },
-    /*4*/ { -1, -1, -1, -1, 2, 4, 6, 8 },
-    /*5*/ { -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16 }
-};
-
-static const int yamaha_indexscale[] = {
-    230, 230, 230, 230, 307, 409, 512, 614,
-    230, 230, 230, 230, 307, 409, 512, 614
-};
-
-static const int yamaha_difflookup[] = {
-    1, 3, 5, 7, 9, 11, 13, 15,
-    -1, -3, -5, -7, -9, -11, -13, -15
-};
-
-/* end of tables */
-
-typedef struct ADPCMChannelStatus {
-    int predictor;
-    short int step_index;
-    int step;
-    /* for encoding */
-    int prev_sample;
-
-    /* MS version */
-    short sample1;
-    short sample2;
-    int coeff1;
-    int coeff2;
-    int idelta;
-} ADPCMChannelStatus;
-
-typedef struct ADPCMContext {
-    int channel; /* for stereo MOVs, decode left, then decode right, then tell it's decoded */
-    ADPCMChannelStatus status[2];
-    short sample_buffer[32]; /* hold left samples while waiting for right samples */
-
-    /* SWF only */
-    int nb_bits;
-    int nb_samples;
-} ADPCMContext;
-
-/* XXX: implement encoding */
-
-#ifdef CONFIG_ENCODERS
-static int adpcm_encode_init(AVCodecContext *avctx)
-{
-    if (avctx->channels > 2)
-        return -1; /* only stereo or mono =) */
-    switch(avctx->codec->id) {
-    case CODEC_ID_ADPCM_IMA_QT:
-        av_log(avctx, AV_LOG_ERROR, "ADPCM: codec adpcm_ima_qt unsupported for encoding !\n");
-        avctx->frame_size = 64; /* XXX: can multiple of avctx->channels * 64 (left and right blocks are interleaved) */
-        return -1;
-        break;
-    case CODEC_ID_ADPCM_IMA_WAV:
-        avctx->frame_size = (BLKSIZE - 4 * avctx->channels) * 8 / (4 * avctx->channels) + 1; /* each 16 bits sample gives one nibble */
-                                                             /* and we have 4 bytes per channel overhead */
-        avctx->block_align = BLKSIZE;
-        /* seems frame_size isn't taken into account... have to buffer the samples :-( */
-        break;
-    case CODEC_ID_ADPCM_MS:
-        avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 / avctx->channels + 2; /* each 16 bits sample gives one nibble */
-                                                             /* and we have 7 bytes per channel overhead */
-        avctx->block_align = BLKSIZE;
-        break;
-    case CODEC_ID_ADPCM_YAMAHA:
-        avctx->frame_size = BLKSIZE * avctx->channels;
-        avctx->block_align = BLKSIZE;
-        break;
-    default:
-        return -1;
-        break;
-    }
-
-    avctx->coded_frame= avcodec_alloc_frame();
-    avctx->coded_frame->key_frame= 1;
-
-    return 0;
-}
-
-static int adpcm_encode_close(AVCodecContext *avctx)
-{
-    av_freep(&avctx->coded_frame);
-
-    return 0;
-}
-
-
-static inline unsigned char adpcm_ima_compress_sample(ADPCMChannelStatus *c, short sample)
-{
-    int step_index;
-    unsigned char nibble;
-    
-    int sign = 0; /* sign bit of the nibble (MSB) */
-    int delta, predicted_delta;
-
-    delta = sample - c->prev_sample;
-
-    if (delta < 0) {
-        sign = 1;
-        delta = -delta;
-    }
-
-    step_index = c->step_index;
-
-    /* nibble = 4 * delta / step_table[step_index]; */
-    nibble = (delta << 2) / step_table[step_index];
-
-    if (nibble > 7)
-        nibble = 7;
-
-    step_index += index_table[nibble];
-    if (step_index < 0)
-        step_index = 0;
-    if (step_index > 88)
-        step_index = 88;
-
-    /* what the decoder will find */
-    predicted_delta = ((step_table[step_index] * nibble) / 4) + (step_table[step_index] / 8);
-
-    if (sign)
-        c->prev_sample -= predicted_delta;
-    else
-        c->prev_sample += predicted_delta;
-
-    CLAMP_TO_SHORT(c->prev_sample);
-
-
-    nibble += sign << 3; /* sign * 8 */   
-
-    /* save back */
-    c->step_index = step_index;
-
-    return nibble;
-}
-
-static inline unsigned char adpcm_ms_compress_sample(ADPCMChannelStatus *c, short sample)
-{
-    int predictor, nibble, bias;
-
-    predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 256;
-    
-    nibble= sample - predictor;
-    if(nibble>=0) bias= c->idelta/2;
-    else          bias=-c->idelta/2;
-        
-    nibble= (nibble + bias) / c->idelta;
-    nibble= clip(nibble, -8, 7)&0x0F;
-    
-    predictor += (signed)((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta;
-    CLAMP_TO_SHORT(predictor);
-
-    c->sample2 = c->sample1;
-    c->sample1 = predictor;
-
-    c->idelta = (AdaptationTable[(int)nibble] * c->idelta) >> 8;
-    if (c->idelta < 16) c->idelta = 16;
-
-    return nibble;
-}
-
-static inline unsigned char adpcm_yamaha_compress_sample(ADPCMChannelStatus *c, short sample)
-{
-    int i1 = 0, j1;
-
-    if(!c->step) {
-        c->predictor = 0;
-        c->step = 127;
-    }
-    j1 = sample - c->predictor;
-
-    j1 = (j1 * 8) / c->step;
-    i1 = abs(j1) / 2;
-    if (i1 > 7)
-        i1 = 7;
-    if (j1 < 0)
-        i1 += 8;
-
-    c->predictor = c->predictor + ((c->step * yamaha_difflookup[i1]) / 8);
-    CLAMP_TO_SHORT(c->predictor);
-    c->step = (c->step * yamaha_indexscale[i1]) >> 8;
-    c->step = clip(c->step, 127, 24567);
-
-    return i1;
-}
-
-static int adpcm_encode_frame(AVCodecContext *avctx,
-			    unsigned char *frame, int buf_size, void *data)
-{
-    int n, i, st;
-    short *samples;
-    unsigned char *dst;
-    ADPCMContext *c = avctx->priv_data;
-
-    dst = frame;
-    samples = (short *)data;
-    st= avctx->channels == 2;
-/*    n = (BLKSIZE - 4 * avctx->channels) / (2 * 8 * avctx->channels); */
-
-    switch(avctx->codec->id) {
-    case CODEC_ID_ADPCM_IMA_QT: /* XXX: can't test until we get .mov writer */
-        break;
-    case CODEC_ID_ADPCM_IMA_WAV:
-        n = avctx->frame_size / 8;
-            c->status[0].prev_sample = (signed short)samples[0]; /* XXX */
-/*            c->status[0].step_index = 0; *//* XXX: not sure how to init the state machine */
-            *dst++ = (c->status[0].prev_sample) & 0xFF; /* little endian */
-            *dst++ = (c->status[0].prev_sample >> 8) & 0xFF;
-            *dst++ = (unsigned char)c->status[0].step_index;
-            *dst++ = 0; /* unknown */
-            samples++;
-            if (avctx->channels == 2) {
-                c->status[1].prev_sample = (signed short)samples[1];
-/*                c->status[1].step_index = 0; */
-                *dst++ = (c->status[1].prev_sample) & 0xFF;
-                *dst++ = (c->status[1].prev_sample >> 8) & 0xFF;
-                *dst++ = (unsigned char)c->status[1].step_index;
-                *dst++ = 0;
-                samples++;
-            }
-        
-            /* stereo: 4 bytes (8 samples) for left, 4 bytes for right, 4 bytes left, ... */
-            for (; n>0; n--) {
-                *dst = adpcm_ima_compress_sample(&c->status[0], samples[0]) & 0x0F;
-                *dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels]) << 4) & 0xF0;
-                dst++;
-                *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 2]) & 0x0F;
-                *dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 3]) << 4) & 0xF0;
-                dst++;
-                *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 4]) & 0x0F;
-                *dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 5]) << 4) & 0xF0;
-                dst++;
-                *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 6]) & 0x0F;
-                *dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 7]) << 4) & 0xF0;
-                dst++;
-                /* right channel */
-                if (avctx->channels == 2) {
-                    *dst = adpcm_ima_compress_sample(&c->status[1], samples[1]);
-                    *dst |= adpcm_ima_compress_sample(&c->status[1], samples[3]) << 4;
-                    dst++;
-                    *dst = adpcm_ima_compress_sample(&c->status[1], samples[5]);
-                    *dst |= adpcm_ima_compress_sample(&c->status[1], samples[7]) << 4;
-                    dst++;
-                    *dst = adpcm_ima_compress_sample(&c->status[1], samples[9]);
-                    *dst |= adpcm_ima_compress_sample(&c->status[1], samples[11]) << 4;
-                    dst++;
-                    *dst = adpcm_ima_compress_sample(&c->status[1], samples[13]);
-                    *dst |= adpcm_ima_compress_sample(&c->status[1], samples[15]) << 4;
-                    dst++;
-                }
-                samples += 8 * avctx->channels;
-            }
-        break;
-    case CODEC_ID_ADPCM_MS:
-        for(i=0; i<avctx->channels; i++){
-            int predictor=0;
-
-            *dst++ = predictor;
-            c->status[i].coeff1 = AdaptCoeff1[predictor];
-            c->status[i].coeff2 = AdaptCoeff2[predictor];
-        }
-        for(i=0; i<avctx->channels; i++){
-            if (c->status[i].idelta < 16) 
-                c->status[i].idelta = 16;
-            
-            *dst++ = c->status[i].idelta & 0xFF;
-            *dst++ = c->status[i].idelta >> 8;
-        }
-        for(i=0; i<avctx->channels; i++){
-            c->status[i].sample1= *samples++;
-
-            *dst++ = c->status[i].sample1 & 0xFF;
-            *dst++ = c->status[i].sample1 >> 8;
-        }
-        for(i=0; i<avctx->channels; i++){
-            c->status[i].sample2= *samples++;
-
-            *dst++ = c->status[i].sample2 & 0xFF;
-            *dst++ = c->status[i].sample2 >> 8;
-        }
-
-        for(i=7*avctx->channels; i<avctx->block_align; i++) {
-            int nibble;
-            nibble = adpcm_ms_compress_sample(&c->status[ 0], *samples++)<<4;
-            nibble|= adpcm_ms_compress_sample(&c->status[st], *samples++);
-            *dst++ = nibble;
-        }
-        break;
-    case CODEC_ID_ADPCM_YAMAHA:
-        n = avctx->frame_size / 2;
-        for (; n>0; n--) {
-            for(i = 0; i < avctx->channels; i++) {
-                int nibble;
-                nibble  = adpcm_yamaha_compress_sample(&c->status[i], samples[i]);
-                nibble |= adpcm_yamaha_compress_sample(&c->status[i], samples[i+avctx->channels]) << 4;
-                *dst++ = nibble;
-            }
-            samples += 2 * avctx->channels;
-        }
-        break;
-    default:
-        return -1;
-    }
-    return dst - frame;
-}
-#endif //CONFIG_ENCODERS
-
-static int adpcm_decode_init(AVCodecContext * avctx)
-{
-    ADPCMContext *c = avctx->priv_data;
-
-    c->channel = 0;
-    c->status[0].predictor = c->status[1].predictor = 0;
-    c->status[0].step_index = c->status[1].step_index = 0;
-    c->status[0].step = c->status[1].step = 0;
-
-    switch(avctx->codec->id) {
-    case CODEC_ID_ADPCM_CT:
-	c->status[0].step = c->status[1].step = 511;
-	break;
-    default:
-        break;
-    }
-    return 0;
-}
-
-static inline short adpcm_ima_expand_nibble(ADPCMChannelStatus *c, char nibble, int shift)
-{
-    int step_index;
-    int predictor;
-    int sign, delta, diff, step;
-
-    step = step_table[c->step_index];
-    step_index = c->step_index + index_table[(unsigned)nibble];
-    if (step_index < 0) step_index = 0;
-    else if (step_index > 88) step_index = 88;
-
-    sign = nibble & 8;
-    delta = nibble & 7;
-    /* perform direct multiplication instead of series of jumps proposed by
-     * the reference ADPCM implementation since modern CPUs can do the mults
-     * quickly enough */
-    diff = ((2 * delta + 1) * step) >> shift;
-    predictor = c->predictor;
-    if (sign) predictor -= diff;
-    else predictor += diff;
-
-    CLAMP_TO_SHORT(predictor);
-    c->predictor = predictor;
-    c->step_index = step_index;
-
-    return (short)predictor;
-}
-
-static inline short adpcm_ms_expand_nibble(ADPCMChannelStatus *c, char nibble)
-{
-    int predictor;
-
-    predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 256;
-    predictor += (signed)((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta;
-    CLAMP_TO_SHORT(predictor);
-
-    c->sample2 = c->sample1;
-    c->sample1 = predictor;
-    c->idelta = (AdaptationTable[(int)nibble] * c->idelta) >> 8;
-    if (c->idelta < 16) c->idelta = 16;
-
-    return (short)predictor;
-}
-
-static inline short adpcm_ct_expand_nibble(ADPCMChannelStatus *c, char nibble)
-{
-    int predictor;
-    int sign, delta, diff;
-    int new_step;
-
-    sign = nibble & 8;
-    delta = nibble & 7;
-    /* perform direct multiplication instead of series of jumps proposed by
-     * the reference ADPCM implementation since modern CPUs can do the mults
-     * quickly enough */
-    diff = ((2 * delta + 1) * c->step) >> 3;
-    predictor = c->predictor;
-    /* predictor update is not so trivial: predictor is multiplied on 254/256 before updating */
-    if(sign)
-	predictor = ((predictor * 254) >> 8) - diff;
-    else
-    	predictor = ((predictor * 254) >> 8) + diff;
-    /* calculate new step and clamp it to range 511..32767 */
-    new_step = (ct_adpcm_table[nibble & 7] * c->step) >> 8;
-    c->step = new_step;
-    if(c->step < 511)
-	c->step = 511;
-    if(c->step > 32767)
-	c->step = 32767;
-
-    CLAMP_TO_SHORT(predictor);
-    c->predictor = predictor;
-    return (short)predictor;
-}
-
-static inline short adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, unsigned char nibble)
-{
-    if(!c->step) {
-        c->predictor = 0;
-        c->step = 127;
-    }
-
-    c->predictor += (c->step * yamaha_difflookup[nibble]) / 8;
-    CLAMP_TO_SHORT(c->predictor);
-    c->step = (c->step * yamaha_indexscale[nibble]) >> 8;
-    c->step = clip(c->step, 127, 24567);
-    return c->predictor;
-}
-
-static void xa_decode(short *out, const unsigned char *in, 
-    ADPCMChannelStatus *left, ADPCMChannelStatus *right, int inc)
-{
-    int i, j;
-    int shift,filter,f0,f1;
-    int s_1,s_2;
-    int d,s,t;
-
-    for(i=0;i<4;i++) {
-
-        shift  = 12 - (in[4+i*2] & 15);
-        filter = in[4+i*2] >> 4;
-        f0 = xa_adpcm_table[filter][0];
-        f1 = xa_adpcm_table[filter][1];
-
-        s_1 = left->sample1;
-        s_2 = left->sample2;
-
-        for(j=0;j<28;j++) {
-            d = in[16+i+j*4];
-
-            t = (signed char)(d<<4)>>4;
-            s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
-            CLAMP_TO_SHORT(s);
-            *out = s;
-            out += inc;
-            s_2 = s_1;
-            s_1 = s;
-        }
-
-        if (inc==2) { /* stereo */
-            left->sample1 = s_1;
-            left->sample2 = s_2;
-            s_1 = right->sample1;
-            s_2 = right->sample2;
-            out = out + 1 - 28*2;
-        }
-
-        shift  = 12 - (in[5+i*2] & 15);
-        filter = in[5+i*2] >> 4;
-
-        f0 = xa_adpcm_table[filter][0];
-        f1 = xa_adpcm_table[filter][1];
-
-        for(j=0;j<28;j++) {
-            d = in[16+i+j*4];
-
-            t = (signed char)d >> 4;
-            s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
-            CLAMP_TO_SHORT(s);
-            *out = s;
-            out += inc;
-            s_2 = s_1;
-            s_1 = s;
-        }
-
-        if (inc==2) { /* stereo */
-            right->sample1 = s_1;
-            right->sample2 = s_2;
-            out -= 1;
-        } else {
-            left->sample1 = s_1;
-            left->sample2 = s_2;
-        }
-    }
-}
-
-
-/* DK3 ADPCM support macro */
-#define DK3_GET_NEXT_NIBBLE() \
-    if (decode_top_nibble_next) \
-    { \
-        nibble = (last_byte >> 4) & 0x0F; \
-        decode_top_nibble_next = 0; \
-    } \
-    else \
-    { \
-        last_byte = *src++; \
-        if (src >= buf + buf_size) break; \
-        nibble = last_byte & 0x0F; \
-        decode_top_nibble_next = 1; \
-    }
-
-static int adpcm_decode_frame(AVCodecContext *avctx,
-			    void *data, int *data_size,
-			    uint8_t *buf, int buf_size)
-{
-    ADPCMContext *c = avctx->priv_data;
-    ADPCMChannelStatus *cs;
-    int n, m, channel, i;
-    int block_predictor[2];
-    short *samples;
-    uint8_t *src;
-    int st; /* stereo */
-
-    /* DK3 ADPCM accounting variables */
-    unsigned char last_byte = 0;
-    unsigned char nibble;
-    int decode_top_nibble_next = 0;
-    int diff_channel;
-
-    /* EA ADPCM state variables */
-    uint32_t samples_in_chunk;
-    int32_t previous_left_sample, previous_right_sample;
-    int32_t current_left_sample, current_right_sample;
-    int32_t next_left_sample, next_right_sample;
-    int32_t coeff1l, coeff2l, coeff1r, coeff2r;
-    uint8_t shift_left, shift_right;
-    int count1, count2;
-
-    if (!buf_size)
-        return 0;
-
-    samples = data;
-    src = buf;
-
-    st = avctx->channels == 2;
-
-    switch(avctx->codec->id) {
-    case CODEC_ID_ADPCM_IMA_QT:
-        n = (buf_size - 2);/* >> 2*avctx->channels;*/
-        channel = c->channel;
-        cs = &(c->status[channel]);
-        /* (pppppp) (piiiiiii) */
-
-        /* Bits 15-7 are the _top_ 9 bits of the 16-bit initial predictor value */
-        cs->predictor = (*src++) << 8;
-        cs->predictor |= (*src & 0x80);
-        cs->predictor &= 0xFF80;
-
-        /* sign extension */
-        if(cs->predictor & 0x8000)
-            cs->predictor -= 0x10000;
-
-        CLAMP_TO_SHORT(cs->predictor);
-
-        cs->step_index = (*src++) & 0x7F;
-
-        if (cs->step_index > 88) av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index);
-        if (cs->step_index > 88) cs->step_index = 88;
-
-        cs->step = step_table[cs->step_index];
-
-        if (st && channel)
-            samples++;
-
-        for(m=32; n>0 && m>0; n--, m--) { /* in QuickTime, IMA is encoded by chuncks of 34 bytes (=64 samples) */
-            *samples = adpcm_ima_expand_nibble(cs, src[0] & 0x0F, 3);
-            samples += avctx->channels;
-            *samples = adpcm_ima_expand_nibble(cs, (src[0] >> 4) & 0x0F, 3);
-            samples += avctx->channels;
-            src ++;
-        }
-
-        if(st) { /* handle stereo interlacing */
-            c->channel = (channel + 1) % 2; /* we get one packet for left, then one for right data */
-            if(channel == 1) { /* wait for the other packet before outputing anything */
-                return src - buf;
-            }
-        }
-        break;
-    case CODEC_ID_ADPCM_IMA_WAV:
-        if (avctx->block_align != 0 && buf_size > avctx->block_align)
-            buf_size = avctx->block_align;
-
-        for(i=0; i<avctx->channels; i++){
-            cs = &(c->status[i]);
-            cs->predictor = *src++;
-            cs->predictor |= (*src++) << 8;
-            if(cs->predictor & 0x8000)
-                cs->predictor -= 0x10000;
-            CLAMP_TO_SHORT(cs->predictor);
-
-	// XXX: is this correct ??: *samples++ = cs->predictor;
-
-            cs->step_index = *src++;
-            if (cs->step_index < 0) cs->step_index = 0;
-            if (cs->step_index > 88) cs->step_index = 88;
-            if (*src++) av_log(avctx, AV_LOG_ERROR, "unused byte should be null !!\n"); /* unused */
-        }
-
-        for(m=4; src < (buf + buf_size);) {
-	    *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] & 0x0F, 3);
-            if (st)
-                *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[4] & 0x0F, 3);
-            *samples++ = adpcm_ima_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F, 3);
-	    if (st) {
-                *samples++ = adpcm_ima_expand_nibble(&c->status[1], (src[4] >> 4) & 0x0F, 3);
-		if (!--m) {
-		    m=4;
-		    src+=4;
-		}
-	    }
-	    src++;
-	}
-        break;
-    case CODEC_ID_ADPCM_4XM:
-        cs = &(c->status[0]);
-        c->status[0].predictor= (int16_t)(src[0] + (src[1]<<8)); src+=2;
-        if(st){
-            c->status[1].predictor= (int16_t)(src[0] + (src[1]<<8)); src+=2;
-        }
-        c->status[0].step_index= (int16_t)(src[0] + (src[1]<<8)); src+=2;
-        if(st){
-            c->status[1].step_index= (int16_t)(src[0] + (src[1]<<8)); src+=2;
-        }
-        if (cs->step_index < 0) cs->step_index = 0;
-        if (cs->step_index > 88) cs->step_index = 88;
-
-        m= (buf_size - (src - buf))>>st;
-        for(i=0; i<m; i++) {
-	    *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] & 0x0F, 4);
-            if (st)
-                *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[i+m] & 0x0F, 4);
-            *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] >> 4, 4);
-	    if (st)
-                *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[i+m] >> 4, 4);
-	}
-
-        src += m<<st;
-
-        break;
-    case CODEC_ID_ADPCM_MS:
-        if (avctx->block_align != 0 && buf_size > avctx->block_align)
-            buf_size = avctx->block_align;
-        n = buf_size - 7 * avctx->channels;
-        if (n < 0)
-            return -1;
-        block_predictor[0] = clip(*src++, 0, 7);
-        block_predictor[1] = 0;
-        if (st)
-            block_predictor[1] = clip(*src++, 0, 7);
-        c->status[0].idelta = (int16_t)((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
-        src+=2;
-        if (st){
-            c->status[1].idelta = (int16_t)((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
-            src+=2;
-        }
-        c->status[0].coeff1 = AdaptCoeff1[block_predictor[0]];
-        c->status[0].coeff2 = AdaptCoeff2[block_predictor[0]];
-        c->status[1].coeff1 = AdaptCoeff1[block_predictor[1]];
-        c->status[1].coeff2 = AdaptCoeff2[block_predictor[1]];
-        
-        c->status[0].sample1 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
-        src+=2;
-        if (st) c->status[1].sample1 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
-        if (st) src+=2;
-        c->status[0].sample2 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
-        src+=2;
-        if (st) c->status[1].sample2 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));
-        if (st) src+=2;
-
-        *samples++ = c->status[0].sample1;
-        if (st) *samples++ = c->status[1].sample1;
-        *samples++ = c->status[0].sample2;
-        if (st) *samples++ = c->status[1].sample2;
-        for(;n>0;n--) {
-            *samples++ = adpcm_ms_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F);
-            *samples++ = adpcm_ms_expand_nibble(&c->status[st], src[0] & 0x0F);
-            src ++;
-        }
-        break;
-    case CODEC_ID_ADPCM_IMA_DK4:
-        if (avctx->block_align != 0 && buf_size > avctx->block_align)
-            buf_size = avctx->block_align;
-
-        c->status[0].predictor = (int16_t)(src[0] | (src[1] << 8));
-        c->status[0].step_index = src[2];
-        src += 4;
-        *samples++ = c->status[0].predictor;
-        if (st) {
-            c->status[1].predictor = (int16_t)(src[0] | (src[1] << 8));
-            c->status[1].step_index = src[2];
-            src += 4;
-            *samples++ = c->status[1].predictor;
-        }
-        while (src < buf + buf_size) {
-
-            /* take care of the top nibble (always left or mono channel) */
-            *samples++ = adpcm_ima_expand_nibble(&c->status[0], 
-                (src[0] >> 4) & 0x0F, 3);
-
-            /* take care of the bottom nibble, which is right sample for
-             * stereo, or another mono sample */
-            if (st)
-                *samples++ = adpcm_ima_expand_nibble(&c->status[1], 
-                    src[0] & 0x0F, 3);
-            else
-                *samples++ = adpcm_ima_expand_nibble(&c->status[0], 
-                    src[0] & 0x0F, 3);
-
-            src++;
-        }
-        break;
-    case CODEC_ID_ADPCM_IMA_DK3:
-        if (avctx->block_align != 0 && buf_size > avctx->block_align)
-            buf_size = avctx->block_align;
-
-        c->status[0].predictor = (int16_t)(src[10] | (src[11] << 8));
-        c->status[1].predictor = (int16_t)(src[12] | (src[13] << 8));
-        c->status[0].step_index = src[14];
-        c->status[1].step_index = src[15];
-        /* sign extend the predictors */
-        src += 16;
-        diff_channel = c->status[1].predictor;
-
-        /* the DK3_GET_NEXT_NIBBLE macro issues the break statement when
-         * the buffer is consumed */
-        while (1) {
-
-            /* for this algorithm, c->status[0] is the sum channel and
-             * c->status[1] is the diff channel */
-
-            /* process the first predictor of the sum channel */
-            DK3_GET_NEXT_NIBBLE();
-            adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
-
-            /* process the diff channel predictor */
-            DK3_GET_NEXT_NIBBLE();
-            adpcm_ima_expand_nibble(&c->status[1], nibble, 3);
-
-            /* process the first pair of stereo PCM samples */
-            diff_channel = (diff_channel + c->status[1].predictor) / 2;
-            *samples++ = c->status[0].predictor + c->status[1].predictor;
-            *samples++ = c->status[0].predictor - c->status[1].predictor;
-
-            /* process the second predictor of the sum channel */
-            DK3_GET_NEXT_NIBBLE();
-            adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
-
-            /* process the second pair of stereo PCM samples */
-            diff_channel = (diff_channel + c->status[1].predictor) / 2;
-            *samples++ = c->status[0].predictor + c->status[1].predictor;
-            *samples++ = c->status[0].predictor - c->status[1].predictor;
-        }
-        break;
-    case CODEC_ID_ADPCM_IMA_WS:
-        /* no per-block initialization; just start decoding the data */
-        while (src < buf + buf_size) {
-
-            if (st) {
-                *samples++ = adpcm_ima_expand_nibble(&c->status[0], 
-                    (src[0] >> 4) & 0x0F, 3);
-                *samples++ = adpcm_ima_expand_nibble(&c->status[1], 
-                    src[0] & 0x0F, 3);
-            } else {
-                *samples++ = adpcm_ima_expand_nibble(&c->status[0], 
-                    (src[0] >> 4) & 0x0F, 3);
-                *samples++ = adpcm_ima_expand_nibble(&c->status[0], 
-                    src[0] & 0x0F, 3);
-            }
-
-            src++;
-        }
-        break;
-    case CODEC_ID_ADPCM_XA:
-        c->status[0].sample1 = c->status[0].sample2 = 
-        c->status[1].sample1 = c->status[1].sample2 = 0;
-        while (buf_size >= 128) {
-            xa_decode(samples, src, &c->status[0], &c->status[1], 
-                avctx->channels);
-            src += 128;
-            samples += 28 * 8;
-            buf_size -= 128;
-        }
-        break;
-    case CODEC_ID_ADPCM_EA:
-        samples_in_chunk = LE_32(src);
-        if (samples_in_chunk >= ((buf_size - 12) * 2)) {
-            src += buf_size;
-            break;
-        }
-        src += 4;
-        current_left_sample = (int16_t)LE_16(src);
-        src += 2;
-        previous_left_sample = (int16_t)LE_16(src);
-        src += 2;
-        current_right_sample = (int16_t)LE_16(src);
-        src += 2;
-        previous_right_sample = (int16_t)LE_16(src);
-        src += 2;
-
-        for (count1 = 0; count1 < samples_in_chunk/28;count1++) {
-            coeff1l = ea_adpcm_table[(*src >> 4) & 0x0F];
-            coeff2l = ea_adpcm_table[((*src >> 4) & 0x0F) + 4];
-            coeff1r = ea_adpcm_table[*src & 0x0F];
-            coeff2r = ea_adpcm_table[(*src & 0x0F) + 4];
-            src++;
-
-            shift_left = ((*src >> 4) & 0x0F) + 8;
-            shift_right = (*src & 0x0F) + 8;
-            src++;
-
-            for (count2 = 0; count2 < 28; count2++) {
-                next_left_sample = (((*src & 0xF0) << 24) >> shift_left);
-                next_right_sample = (((*src & 0x0F) << 28) >> shift_right);
-                src++;
-
-                next_left_sample = (next_left_sample + 
-                    (current_left_sample * coeff1l) + 
-                    (previous_left_sample * coeff2l) + 0x80) >> 8;
-                next_right_sample = (next_right_sample + 
-                    (current_right_sample * coeff1r) + 
-                    (previous_right_sample * coeff2r) + 0x80) >> 8;
-                CLAMP_TO_SHORT(next_left_sample);
-                CLAMP_TO_SHORT(next_right_sample);
-
-                previous_left_sample = current_left_sample;
-                current_left_sample = next_left_sample;
-                previous_right_sample = current_right_sample;
-                current_right_sample = next_right_sample;
-                *samples++ = (unsigned short)current_left_sample;
-                *samples++ = (unsigned short)current_right_sample;
-            }
-        }
-        break;
-    case CODEC_ID_ADPCM_IMA_SMJPEG:
-        c->status[0].predictor = *src;
-        src += 2;
-        c->status[0].step_index = *src++;
-        src++;  /* skip another byte before getting to the meat */
-        while (src < buf + buf_size) {
-            *samples++ = adpcm_ima_expand_nibble(&c->status[0],
-                *src & 0x0F, 3);
-            *samples++ = adpcm_ima_expand_nibble(&c->status[0],
-                (*src >> 4) & 0x0F, 3);
-            src++;
-        }
-        break;
-    case CODEC_ID_ADPCM_CT:
-	while (src < buf + buf_size) {
-            if (st) {
-                *samples++ = adpcm_ct_expand_nibble(&c->status[0], 
-                    (src[0] >> 4) & 0x0F);
-                *samples++ = adpcm_ct_expand_nibble(&c->status[1], 
-                    src[0] & 0x0F);
-            } else {
-                *samples++ = adpcm_ct_expand_nibble(&c->status[0], 
-                    (src[0] >> 4) & 0x0F);
-                *samples++ = adpcm_ct_expand_nibble(&c->status[0], 
-                    src[0] & 0x0F);
-            }
-	    src++;
-        }
-        break;
-    case CODEC_ID_ADPCM_SWF:
-    {
-	GetBitContext gb;
-	const int *table;
-	int k0, signmask;
-	int size = buf_size*8;
-	
-	init_get_bits(&gb, buf, size);
-
-	// first frame, read bits & inital values
-	if (!c->nb_bits)
-	{
-	    c->nb_bits = get_bits(&gb, 2)+2;
-//	    av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", c->nb_bits);
-	}
-	
-	table = swf_index_tables[c->nb_bits-2];
-	k0 = 1 << (c->nb_bits-2);
-	signmask = 1 << (c->nb_bits-1);
-	
-	while (get_bits_count(&gb) <= size)
-	{
-	    int i;
-
-	    c->nb_samples++;
-	    // wrap around at every 4096 samples...
-	    if ((c->nb_samples & 0xfff) == 1)
-	    {
-		for (i = 0; i <= st; i++)
-		{
-		    *samples++ = c->status[i].predictor = get_sbits(&gb, 16);
-		    c->status[i].step_index = get_bits(&gb, 6);
-		}
-	    }
-
-	    // similar to IMA adpcm
-	    for (i = 0; i <= st; i++)
-	    {
-		int delta = get_bits(&gb, c->nb_bits);
-		int step = step_table[c->status[i].step_index];
-		long vpdiff = 0; // vpdiff = (delta+0.5)*step/4
-		int k = k0;
-		
-		do {
-		    if (delta & k)
-			vpdiff += step;
-		    step >>= 1;
-		    k >>= 1;
-		} while(k);
-		vpdiff += step;
-		
-		if (delta & signmask)
-		    c->status[i].predictor -= vpdiff;
-		else
-		    c->status[i].predictor += vpdiff;
-		
-		c->status[i].step_index += table[delta & (~signmask)];
-		
-		c->status[i].step_index = clip(c->status[i].step_index, 0, 88);
-		c->status[i].predictor = clip(c->status[i].predictor, -32768, 32767);
-		
-		*samples++ = c->status[i].predictor;
-	    }
-	}
-	
-//	src += get_bits_count(&gb)*8;
-	src += size;
-	
-	break;
-    }
-    case CODEC_ID_ADPCM_YAMAHA:
-        while (src < buf + buf_size) {
-            if (st) {
-                *samples++ = adpcm_yamaha_expand_nibble(&c->status[0],
-                        src[0] & 0x0F);
-                *samples++ = adpcm_yamaha_expand_nibble(&c->status[1],
-                        (src[0] >> 4) & 0x0F);
-            } else {
-                *samples++ = adpcm_yamaha_expand_nibble(&c->status[0],
-                        src[0] & 0x0F);
-                *samples++ = adpcm_yamaha_expand_nibble(&c->status[0],
-                        (src[0] >> 4) & 0x0F);
-            }
-            src++;
-        }
-        break;
-    default:
-        return -1;
-    }
-    *data_size = (uint8_t *)samples - (uint8_t *)data;
-    return src - buf;
-}
-
-
-
-#ifdef CONFIG_ENCODERS
-#define ADPCM_ENCODER(id,name)                  \
-AVCodec name ## _encoder = {                    \
-    #name,                                      \
-    CODEC_TYPE_AUDIO,                           \
-    id,                                         \
-    sizeof(ADPCMContext),                       \
-    adpcm_encode_init,                          \
-    adpcm_encode_frame,                         \
-    adpcm_encode_close,                         \
-    NULL,                                       \
-};
-#else
-#define ADPCM_ENCODER(id,name)
-#endif
-
-#ifdef CONFIG_DECODERS
-#define ADPCM_DECODER(id,name)                  \
-AVCodec name ## _decoder = {                    \
-    #name,                                      \
-    CODEC_TYPE_AUDIO,                           \
-    id,                                         \
-    sizeof(ADPCMContext),                       \
-    adpcm_decode_init,                          \
-    NULL,                                       \
-    NULL,                                       \
-    adpcm_decode_frame,                         \
-};
-#else
-#define ADPCM_DECODER(id,name)
-#endif
-
-#define ADPCM_CODEC(id, name)                   \
-ADPCM_ENCODER(id,name) ADPCM_DECODER(id,name)
-
-ADPCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
-ADPCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
-ADPCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
-ADPCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
-ADPCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
-ADPCM_CODEC(CODEC_ID_ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg);
-ADPCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
-ADPCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
-ADPCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
-ADPCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
-ADPCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
-ADPCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
-ADPCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
-ADPCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);
-
-#undef ADPCM_CODEC
diff --git a/ffmpeg.src/libavcodec/adx.c b/ffmpeg.src/libavcodec/adx.c
deleted file mode 100644
index a52575c..0000000
--- a/ffmpeg.src/libavcodec/adx.c
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * ADX ADPCM codecs
- * Copyright (c) 2001,2003 BERO
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avcodec.h"
-
-/**
- * @file adx.c
- * SEGA CRI adx codecs.
- *
- * Reference documents:
- * http://ku-www.ss.titech.ac.jp/~yatsushi/adx.html
- * adx2wav & wav2adx http://www.geocities.co.jp/Playtown/2004/
- */
-
-typedef struct {
-    int s1,s2;
-} PREV;
-
-typedef struct {
-    PREV prev[2];
-    int header_parsed;
-    unsigned char dec_temp[18*2];
-    unsigned short enc_temp[32*2];
-    int in_temp;
-} ADXContext;
-
-//#define    BASEVOL    0x11e0
-#define    BASEVOL   0x4000
-#define    SCALE1    0x7298
-#define    SCALE2    0x3350
-
-#define    CLIP(s)    if (s>32767) s=32767; else if (s<-32768) s=-32768
-
-/* 18 bytes <-> 32 samples */
-
-#ifdef CONFIG_ENCODERS
-static void adx_encode(unsigned char *adx,const short *wav,PREV *prev)
-{
-    int scale;
-    int i;
-    int s0,s1,s2,d;
-    int max=0;
-    int min=0;
-    int data[32];
-
-    s1 = prev->s1;
-    s2 = prev->s2;
-    for(i=0;i<32;i++) {
-        s0 = wav[i];
-        d = ((s0<<14) - SCALE1*s1 + SCALE2*s2)/BASEVOL;
-        data[i]=d;
-        if (max<d) max=d;
-        if (min>d) min=d;
-        s2 = s1;
-        s1 = s0;
-    }
-    prev->s1 = s1;
-    prev->s2 = s2;
-
-    /* -8..+7 */
-
-    if (max==0 && min==0) {
-        memset(adx,0,18);
-        return;
-    }
-
-    if (max/7>-min/8) scale = max/7;
-    else scale = -min/8;
-
-    if (scale==0) scale=1;
-
-    adx[0] = scale>>8;
-    adx[1] = scale;
-
-    for(i=0;i<16;i++) {
-        adx[i+2] = ((data[i*2]/scale)<<4) | ((data[i*2+1]/scale)&0xf);
-    }
-}
-#endif //CONFIG_ENCODERS
-
-static void adx_decode(short *out,const unsigned char *in,PREV *prev)
-{
-    int scale = ((in[0]<<8)|(in[1]));
-    int i;
-    int s0,s1,s2,d;
-
-//    printf("%x ",scale);
-
-    in+=2;
-    s1 = prev->s1;
-    s2 = prev->s2;
-    for(i=0;i<16;i++) {
-        d = in[i];
-        // d>>=4; if (d&8) d-=16;
-        d = ((signed char)d >> 4);
-        s0 = (BASEVOL*d*scale + SCALE1*s1 - SCALE2*s2)>>14;
-        CLIP(s0);
-        *out++=s0;
-        s2 = s1;
-        s1 = s0;
-
-        d = in[i];
-        //d&=15; if (d&8) d-=16;
-        d = ((signed char)(d<<4) >> 4);
-        s0 = (BASEVOL*d*scale + SCALE1*s1 - SCALE2*s2)>>14;
-        CLIP(s0);
-        *out++=s0;
-        s2 = s1;
-        s1 = s0;
-    }
-    prev->s1 = s1;
-    prev->s2 = s2;
-
-}
-
-static void adx_decode_stereo(short *out,const unsigned char *in,PREV *prev)
-{
-    short tmp[32*2];
-    int i;
-
-    adx_decode(tmp   ,in   ,prev);
-    adx_decode(tmp+32,in+18,prev+1);
-    for(i=0;i<32;i++) {
-        out[i*2]   = tmp[i];
-        out[i*2+1] = tmp[i+32];
-    }
-}
-
-#ifdef CONFIG_ENCODERS
-
-static void write_long(unsigned char *p,uint32_t v)
-{
-    p[0] = v>>24;
-    p[1] = v>>16;
-    p[2] = v>>8;
-    p[3] = v;
-}
-
-static int adx_encode_header(AVCodecContext *avctx,unsigned char *buf,size_t bufsize)
-{
-#if 0
-    struct {
-        uint32_t offset; /* 0x80000000 + sample start - 4 */
-        unsigned char unknown1[3]; /* 03 12 04 */
-        unsigned char channel; /* 1 or 2 */
-        uint32_t freq;
-        uint32_t size;
-        uint32_t unknown2; /* 01 f4 03 00 */
-        uint32_t unknown3; /* 00 00 00 00 */
-        uint32_t unknown4; /* 00 00 00 00 */
-
-    /* if loop
-        unknown3 00 15 00 01
-        unknown4 00 00 00 01
-        long loop_start_sample;
-        long loop_start_byte;
-        long loop_end_sample;
-        long loop_end_byte;
-        long 
-    */
-    } adxhdr; /* big endian */
-    /* offset-6 "(c)CRI" */
-#endif
-    write_long(buf+0x00,0x80000000|0x20);
-    write_long(buf+0x04,0x03120400|avctx->channels);
-    write_long(buf+0x08,avctx->sample_rate);
-    write_long(buf+0x0c,0); /* FIXME: set after */
-    write_long(buf+0x10,0x01040300);
-    write_long(buf+0x14,0x00000000);
-    write_long(buf+0x18,0x00000000);
-    memcpy(buf+0x1c,"\0\0(c)CRI",8);
-    return 0x20+4;
-}
-
-static int adx_decode_init(AVCodecContext *avctx);
-static int adx_encode_init(AVCodecContext *avctx)
-{
-    if (avctx->channels > 2)
-        return -1; /* only stereo or mono =) */
-    avctx->frame_size = 32;
-
-    avctx->coded_frame= avcodec_alloc_frame();
-    avctx->coded_frame->key_frame= 1;
-
-//    avctx->bit_rate = avctx->sample_rate*avctx->channels*18*8/32;
-
-    av_log(avctx, AV_LOG_DEBUG, "adx encode init\n");
-    adx_decode_init(avctx);
-
-    return 0;
-}
-
-static int adx_encode_close(AVCodecContext *avctx)
-{
-    av_freep(&avctx->coded_frame);
-
-    return 0;
-}
-
-static int adx_encode_frame(AVCodecContext *avctx,
-                uint8_t *frame, int buf_size, void *data)
-{
-    ADXContext *c = avctx->priv_data;
-    const short *samples = data;
-    unsigned char *dst = frame;
-    int rest = avctx->frame_size;
-
-/*
-    input data size =
-    ffmpeg.c: do_audio_out()
-    frame_bytes = enc->frame_size * 2 * enc->channels;
-*/
-
-//    printf("sz=%d ",buf_size); fflush(stdout);
-    if (!c->header_parsed) {
-        int hdrsize = adx_encode_header(avctx,dst,buf_size);
-        dst+=hdrsize;
-        c->header_parsed = 1;
-    }
-
-    if (avctx->channels==1) {
-        while(rest>=32) {
-            adx_encode(dst,samples,c->prev);
-            dst+=18;
-            samples+=32;
-            rest-=32;
-        }
-    } else {
-        while(rest>=32*2) {
-            short tmpbuf[32*2];
-            int i;
-
-            for(i=0;i<32;i++) {
-                tmpbuf[i] = samples[i*2];
-                tmpbuf[i+32] = samples[i*2+1];
-            }
-
-            adx_encode(dst,tmpbuf,c->prev);
-            adx_encode(dst+18,tmpbuf+32,c->prev+1);
-            dst+=18*2;
-            samples+=32*2;
-            rest-=32*2;
-        }
-    }
-    return dst-frame;
-}
-
-#endif //CONFIG_ENCODERS
-
-static uint32_t read_long(const unsigned char *p)
-{
-    return (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
-}
-
-int is_adx(const unsigned char *buf,size_t bufsize)
-{
-    int    offset;
-
-    if (buf[0]!=0x80) return 0;
-    offset = (read_long(buf)^0x80000000)+4;
-    if (bufsize<offset || memcmp(buf+offset-6,"(c)CRI",6)) return 0;
-    return offset;
-}
-
-/* return data offset or 6 */
-static int adx_decode_header(AVCodecContext *avctx,const unsigned char *buf,size_t bufsize)
-{
-    int offset;
-    int channels,freq,size;
-
-    offset = is_adx(buf,bufsize);
-    if (offset==0) return 0;
-
-    channels = buf[7];
-    freq = read_long(buf+8);
-    size = read_long(buf+12);
-
-//    printf("freq=%d ch=%d\n",freq,channels);
-
-    avctx->sample_rate = freq;
-    avctx->channels = channels;
-    avctx->bit_rate = freq*channels*18*8/32;
-//    avctx->frame_size = 18*channels;
-
-    return offset;
-}
-
-static int adx_decode_init(AVCodecContext * avctx)
-{
-    ADXContext *c = avctx->priv_data;
-
-//    printf("adx_decode_init\n"); fflush(stdout);
-    c->prev[0].s1 = 0;
-    c->prev[0].s2 = 0;
-    c->prev[1].s1 = 0;
-    c->prev[1].s2 = 0;
-    c->header_parsed = 0;
-    c->in_temp = 0;
-    return 0;
-}
-
-#if 0
-static void dump(unsigned char *buf,size_t len)
-{
-    int i;
-    for(i=0;i<len;i++) {
-        if ((i&15)==0) av_log(NULL, AV_LOG_DEBUG, "%04x  ",i);
-        av_log(NULL, AV_LOG_DEBUG, "%02x ",buf[i]);
-        if ((i&15)==15) av_log(NULL, AV_LOG_DEBUG, "\n");
-    }
-    av_log(NULL, AV_LOG_ERROR, "\n");
-}
-#endif
-
-static int adx_decode_frame(AVCodecContext *avctx,
-                void *data, int *data_size,
-                uint8_t *buf0, int buf_size)
-{
-    ADXContext *c = avctx->priv_data;
-    short *samples = data;
-    const uint8_t *buf = buf0;
-    int rest = buf_size;
-
-    if (!c->header_parsed) {
-        int hdrsize = adx_decode_header(avctx,buf,rest);
-        if (hdrsize==0) return -1;
-        c->header_parsed = 1;
-        buf  += hdrsize;
-        rest -= hdrsize;
-    }
-
-    if (c->in_temp) {
-        int copysize = 18*avctx->channels - c->in_temp;
-        memcpy(c->dec_temp+c->in_temp,buf,copysize);
-        rest -= copysize;
-        buf  += copysize;
-        if (avctx->channels==1) {
-            adx_decode(samples,c->dec_temp,c->prev);
-            samples += 32;
-        } else {
-            adx_decode_stereo(samples,c->dec_temp,c->prev);
-            samples += 32*2;
-        }
-    }
-    //
-    if (avctx->channels==1) {
-        while(rest>=18) {
-            adx_decode(samples,buf,c->prev);
-            rest-=18;
-            buf+=18;
-            samples+=32;
-        }
-    } else {
-        while(rest>=18*2) {
-            adx_decode_stereo(samples,buf,c->prev);
-            rest-=18*2;
-            buf+=18*2;
-            samples+=32*2;
-        }
-    }
-    //
-    c->in_temp = rest;
-    if (rest) {
-        memcpy(c->dec_temp,buf,rest);
-        buf+=rest;
-    }
-    *data_size = (uint8_t*)samples - (uint8_t*)data;
-//    printf("%d:%d ",buf-buf0,*data_size); fflush(stdout);
-    return buf-buf0;
-}
-
-#ifdef CONFIG_ENCODERS
-AVCodec adx_adpcm_encoder = {
-    "adx_adpcm",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_ADPCM_ADX,
-    sizeof(ADXContext),
-    adx_encode_init,
-    adx_encode_frame,
-    adx_encode_close,
-    NULL,
-};
-#endif //CONFIG_ENCODERS
-
-AVCodec adx_adpcm_decoder = {
-    "adx_adpcm",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_ADPCM_ADX,
-    sizeof(ADXContext),
-    adx_decode_init,
-    NULL,
-    NULL,
-    adx_decode_frame,
-};
-
diff --git a/ffmpeg.src/libavcodec/allcodecs.c b/ffmpeg.src/libavcodec/allcodecs.c
deleted file mode 100644
index 2b7c192..0000000
--- a/ffmpeg.src/libavcodec/allcodecs.c
+++ /dev/null
@@ -1,60 +0,0 @@
-
-/*
- * Utils for libavcodec
- * Copyright (c) 2002 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file allcodecs.c
- * Utils for libavcodec.
- */
-
-#include "avcodec.h"
-
-/* If you do not call this function, then you can select exactly which
-   formats you want to support */
-
-/**
- * simple call to register all the codecs. 
- */
-void avcodec_register_all(void)
-{
-    static int inited = 0;
-    
-    if (inited != 0)
-	return;
-    inited = 1;
-
-    register_avcodec(&mpeg2video_encoder);
-    register_avcodec(&mpeg2video_decoder);
-    register_avcodec(&mp2_encoder);
-    register_avcodec(&mp2_decoder);
-    register_avcodec(&mp3_decoder);
-
-#ifdef CONFIG_AC3
-    register_avcodec(&ac3_encoder);
-    register_avcodec(&ac3_decoder);
-#endif
-
-#ifdef CONFIG_DTS
-    register_avcodec(&dts_decoder);
-#endif
-    
-    av_register_codec_parser(&mpegaudio_parser);
-//     av_register_codec_parser(&ac3_parser);
-}
-
diff --git a/ffmpeg.src/libavcodec/alpha/asm.h b/ffmpeg.src/libavcodec/alpha/asm.h
deleted file mode 100644
index 6dc997b..0000000
--- a/ffmpeg.src/libavcodec/alpha/asm.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Alpha optimized DSP utils
- * Copyright (c) 2002 Falk Hueffner <falk at debian.org>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef LIBAVCODEC_ALPHA_ASM_H
-#define LIBAVCODEC_ALPHA_ASM_H
-
-#include <inttypes.h>
-
-#if defined __GNUC__
-# define GNUC_PREREQ(maj, min) \
-        ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-#else
-# define GNUC_PREREQ(maj, min) 0
-#endif
-
-#if GNUC_PREREQ(2,96)
-# define likely(x)      __builtin_expect((x) != 0, 1)
-# define unlikely(x)    __builtin_expect((x) != 0, 0)
-#else
-# define likely(x)      (x)
-# define unlikely(x)    (x)
-#endif
-
-#define AMASK_BWX (1 << 0)
-#define AMASK_FIX (1 << 1)
-#define AMASK_CIX (1 << 2)
-#define AMASK_MVI (1 << 8)
-
-static inline uint64_t BYTE_VEC(uint64_t x)
-{
-    x |= x <<  8;
-    x |= x << 16;
-    x |= x << 32;
-    return x;
-}
-static inline uint64_t WORD_VEC(uint64_t x)
-{
-    x |= x << 16;
-    x |= x << 32;
-    return x;
-}
-
-#define sextw(x) ((int16_t) (x))
-
-#ifdef __GNUC__
-#define ldq(p)                                                  \
-    (((union {                                                  \
-        uint64_t __l;                                           \
-        __typeof__(*(p)) __s[sizeof (uint64_t) / sizeof *(p)];  \
-    } *) (p))->__l)
-#define ldl(p)                                                  \
-    (((union {                                                  \
-        int32_t __l;                                            \
-        __typeof__(*(p)) __s[sizeof (int32_t) / sizeof *(p)];   \
-    } *) (p))->__l)
-#define stq(l, p)                                                       \
-    do {                                                                \
-        (((union {                                                      \
-            uint64_t __l;                                               \
-            __typeof__(*(p)) __s[sizeof (uint64_t) / sizeof *(p)];      \
-        } *) (p))->__l) = l;                                            \
-    } while (0)
-#define stl(l, p)                                                       \
-    do {                                                                \
-        (((union {                                                      \
-            int32_t __l;                                                \
-            __typeof__(*(p)) __s[sizeof (int32_t) / sizeof *(p)];       \
-        } *) (p))->__l) = l;                                            \
-    } while (0)
-struct unaligned_long { uint64_t l; } __attribute__((packed));
-#define ldq_u(p)     (*(const uint64_t *) (((uint64_t) (p)) & ~7ul))
-#define uldq(a)	     (((const struct unaligned_long *) (a))->l)
-
-#if GNUC_PREREQ(3,3)
-#define prefetch(p)     __builtin_prefetch((p), 0, 1)
-#define prefetch_en(p)  __builtin_prefetch((p), 0, 0)
-#define prefetch_m(p)   __builtin_prefetch((p), 1, 1)
-#define prefetch_men(p) __builtin_prefetch((p), 1, 0)
-#define cmpbge	__builtin_alpha_cmpbge
-/* Avoid warnings.  */
-#define extql(a, b)	__builtin_alpha_extql(a, (uint64_t) (b))
-#define extwl(a, b)	__builtin_alpha_extwl(a, (uint64_t) (b))
-#define extqh(a, b)	__builtin_alpha_extqh(a, (uint64_t) (b))
-#define zap	__builtin_alpha_zap
-#define zapnot	__builtin_alpha_zapnot
-#define amask	__builtin_alpha_amask
-#define implver	__builtin_alpha_implver
-#define rpcc	__builtin_alpha_rpcc
-#else
-#define prefetch(p)     asm volatile("ldl $31,%0"  : : "m"(*(const char *) (p)) : "memory")
-#define prefetch_en(p)  asm volatile("ldq $31,%0"  : : "m"(*(const char *) (p)) : "memory")
-#define prefetch_m(p)   asm volatile("lds $f31,%0" : : "m"(*(const char *) (p)) : "memory")
-#define prefetch_men(p) asm volatile("ldt $f31,%0" : : "m"(*(const char *) (p)) : "memory")
-#define cmpbge(a, b) ({ uint64_t __r; asm ("cmpbge  %r1,%2,%0"  : "=r" (__r) : "rJ"  (a), "rI" (b)); __r; })
-#define extql(a, b)  ({ uint64_t __r; asm ("extql   %r1,%2,%0"  : "=r" (__r) : "rJ"  (a), "rI" (b)); __r; })
-#define extwl(a, b)  ({ uint64_t __r; asm ("extwl   %r1,%2,%0"  : "=r" (__r) : "rJ"  (a), "rI" (b)); __r; })
-#define extqh(a, b)  ({ uint64_t __r; asm ("extqh   %r1,%2,%0"  : "=r" (__r) : "rJ"  (a), "rI" (b)); __r; })
-#define zap(a, b)    ({ uint64_t __r; asm ("zap     %r1,%2,%0"  : "=r" (__r) : "rJ"  (a), "rI" (b)); __r; })
-#define zapnot(a, b) ({ uint64_t __r; asm ("zapnot  %r1,%2,%0"  : "=r" (__r) : "rJ"  (a), "rI" (b)); __r; })
-#define amask(a)     ({ uint64_t __r; asm ("amask   %1,%0"      : "=r" (__r) : "rI"  (a));	     __r; })
-#define implver()    ({ uint64_t __r; asm ("implver %0"         : "=r" (__r));			     __r; })
-#define rpcc()	     ({ uint64_t __r; asm volatile ("rpcc %0"   : "=r" (__r));			     __r; })
-#endif
-#define wh64(p) asm volatile("wh64 (%0)" : : "r"(p) : "memory")
-
-#if GNUC_PREREQ(3,3) && defined(__alpha_max__)
-#define minub8	__builtin_alpha_minub8
-#define minsb8	__builtin_alpha_minsb8
-#define minuw4	__builtin_alpha_minuw4
-#define minsw4	__builtin_alpha_minsw4
-#define maxub8	__builtin_alpha_maxub8
-#define maxsb8	__builtin_alpha_maxsb8
-#define maxuw4	__builtin_alpha_maxuw4	
-#define maxsw4	__builtin_alpha_maxsw4
-#define perr	__builtin_alpha_perr
-#define pklb	__builtin_alpha_pklb
-#define pkwb	__builtin_alpha_pkwb
-#define unpkbl	__builtin_alpha_unpkbl
-#define unpkbw	__builtin_alpha_unpkbw
-#else
-#define minub8(a, b) ({ uint64_t __r; asm (".arch ev6; minub8  %r1,%2,%0"  : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define minsb8(a, b) ({ uint64_t __r; asm (".arch ev6; minsb8  %r1,%2,%0"  : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define minuw4(a, b) ({ uint64_t __r; asm (".arch ev6; minuw4  %r1,%2,%0"  : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define minsw4(a, b) ({ uint64_t __r; asm (".arch ev6; minsw4  %r1,%2,%0"  : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define maxub8(a, b) ({ uint64_t __r; asm (".arch ev6; maxub8  %r1,%2,%0"  : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define maxsb8(a, b) ({ uint64_t __r; asm (".arch ev6; maxsb8  %r1,%2,%0"  : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define maxuw4(a, b) ({ uint64_t __r; asm (".arch ev6; maxuw4  %r1,%2,%0"  : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define maxsw4(a, b) ({ uint64_t __r; asm (".arch ev6; maxsw4  %r1,%2,%0"  : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
-#define perr(a, b)   ({ uint64_t __r; asm (".arch ev6; perr    %r1,%r2,%0" : "=r" (__r) : "%rJ" (a), "rJ" (b)); __r; })
-#define pklb(a)      ({ uint64_t __r; asm (".arch ev6; pklb    %r1,%0"     : "=r" (__r) : "rJ"  (a));	     __r; })
-#define pkwb(a)      ({ uint64_t __r; asm (".arch ev6; pkwb    %r1,%0"     : "=r" (__r) : "rJ"  (a));	     __r; })
-#define unpkbl(a)    ({ uint64_t __r; asm (".arch ev6; unpkbl  %r1,%0"     : "=r" (__r) : "rJ"  (a));	     __r; })
-#define unpkbw(a)    ({ uint64_t __r; asm (".arch ev6; unpkbw  %r1,%0"     : "=r" (__r) : "rJ"  (a));	     __r; })
-#endif
-
-#elif defined(__DECC)		/* Digital/Compaq/hp "ccc" compiler */
-
-#include <c_asm.h>
-#define ldq(p) (*(const uint64_t *) (p))
-#define ldl(p) (*(const int32_t *)  (p))
-#define stq(l, p) do { *(uint64_t *) (p) = (l); } while (0)
-#define stl(l, p) do { *(int32_t *)  (p) = (l); } while (0)
-#define ldq_u(a)     asm ("ldq_u   %v0,0(%a0)", a)
-#define uldq(a)	     (*(const __unaligned uint64_t *) (a))
-#define cmpbge(a, b) asm ("cmpbge  %a0,%a1,%v0", a, b)
-#define extql(a, b)  asm ("extql   %a0,%a1,%v0", a, b)
-#define extwl(a, b)  asm ("extwl   %a0,%a1,%v0", a, b)
-#define extqh(a, b)  asm ("extqh   %a0,%a1,%v0", a, b)
-#define zap(a, b)    asm ("zap     %a0,%a1,%v0", a, b)
-#define zapnot(a, b) asm ("zapnot  %a0,%a1,%v0", a, b)
-#define amask(a)     asm ("amask   %a0,%v0", a)
-#define implver()    asm ("implver %v0")
-#define rpcc()	     asm ("rpcc	   %v0")
-#define minub8(a, b) asm ("minub8  %a0,%a1,%v0", a, b)
-#define minsb8(a, b) asm ("minsb8  %a0,%a1,%v0", a, b)
-#define minuw4(a, b) asm ("minuw4  %a0,%a1,%v0", a, b)
-#define minsw4(a, b) asm ("minsw4  %a0,%a1,%v0", a, b)
-#define maxub8(a, b) asm ("maxub8  %a0,%a1,%v0", a, b)
-#define maxsb8(a, b) asm ("maxsb8  %a0,%a1,%v0", a, b)
-#define maxuw4(a, b) asm ("maxuw4  %a0,%a1,%v0", a, b)
-#define maxsw4(a, b) asm ("maxsw4  %a0,%a1,%v0", a, b)
-#define perr(a, b)   asm ("perr    %a0,%a1,%v0", a, b)
-#define pklb(a)      asm ("pklb    %a0,%v0", a)
-#define pkwb(a)      asm ("pkwb    %a0,%v0", a)
-#define unpkbl(a)    asm ("unpkbl  %a0,%v0", a)
-#define unpkbw(a)    asm ("unpkbw  %a0,%v0", a)
-#define wh64(a)      asm ("wh64    %a0", a)
-
-#else
-#error "Unknown compiler!"
-#endif
-
-#endif /* LIBAVCODEC_ALPHA_ASM_H */
diff --git a/ffmpeg.src/libavcodec/alpha/dsputil_alpha.c b/ffmpeg.src/libavcodec/alpha/dsputil_alpha.c
deleted file mode 100644
index 496f461..0000000
--- a/ffmpeg.src/libavcodec/alpha/dsputil_alpha.c
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * Alpha optimized DSP utils
- * Copyright (c) 2002 Falk Hueffner <falk at debian.org>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "asm.h"
-#include "../dsputil.h"
-
-extern void simple_idct_axp(DCTELEM *block);
-extern void simple_idct_put_axp(uint8_t *dest, int line_size, DCTELEM *block);
-extern void simple_idct_add_axp(uint8_t *dest, int line_size, DCTELEM *block);
-
-void put_pixels_axp_asm(uint8_t *block, const uint8_t *pixels,
-                        int line_size, int h);
-void put_pixels_clamped_mvi_asm(const DCTELEM *block, uint8_t *pixels,
-                                int line_size);
-void add_pixels_clamped_mvi_asm(const DCTELEM *block, uint8_t *pixels, 
-                                int line_size);
-void (*put_pixels_clamped_axp_p)(const DCTELEM *block, uint8_t *pixels,
-                                 int line_size);
-void (*add_pixels_clamped_axp_p)(const DCTELEM *block, uint8_t *pixels, 
-                                 int line_size);
-
-void get_pixels_mvi(DCTELEM *restrict block,
-                    const uint8_t *restrict pixels, int line_size);
-void diff_pixels_mvi(DCTELEM *block, const uint8_t *s1, const uint8_t *s2,
-                     int stride);
-int pix_abs8x8_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
-int pix_abs16x16_mvi_asm(uint8_t *pix1, uint8_t *pix2, int line_size);
-int pix_abs16x16_x2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
-int pix_abs16x16_y2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
-int pix_abs16x16_xy2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
-
-#if 0
-/* These functions were the base for the optimized assembler routines,
-   and remain here for documentation purposes.  */
-static void put_pixels_clamped_mvi(const DCTELEM *block, uint8_t *pixels, 
-                                   int line_size)
-{
-    int i = 8;
-    uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */
-
-    do {
-        uint64_t shorts0, shorts1;
-
-        shorts0 = ldq(block);
-        shorts0 = maxsw4(shorts0, 0);
-        shorts0 = minsw4(shorts0, clampmask);
-        stl(pkwb(shorts0), pixels);
-
-        shorts1 = ldq(block + 4);
-        shorts1 = maxsw4(shorts1, 0);
-        shorts1 = minsw4(shorts1, clampmask);
-        stl(pkwb(shorts1), pixels + 4);
-
-        pixels += line_size;
-        block += 8;
-    } while (--i);
-}
-
-void add_pixels_clamped_mvi(const DCTELEM *block, uint8_t *pixels, 
-                            int line_size)
-{
-    int h = 8;
-    /* Keep this function a leaf function by generating the constants
-       manually (mainly for the hack value ;-).  */
-    uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */
-    uint64_t signmask  = zap(-1, 0x33);
-    signmask ^= signmask >> 1;  /* 0x8000800080008000 */
-
-    do {
-        uint64_t shorts0, pix0, signs0;
-        uint64_t shorts1, pix1, signs1;
-
-        shorts0 = ldq(block);
-        shorts1 = ldq(block + 4);
-
-        pix0    = unpkbw(ldl(pixels));
-        /* Signed subword add (MMX paddw).  */
-        signs0  = shorts0 & signmask;
-        shorts0 &= ~signmask;
-        shorts0 += pix0;
-        shorts0 ^= signs0;
-        /* Clamp. */
-        shorts0 = maxsw4(shorts0, 0);
-        shorts0 = minsw4(shorts0, clampmask);   
-
-        /* Next 4.  */
-        pix1    = unpkbw(ldl(pixels + 4));
-        signs1  = shorts1 & signmask;
-        shorts1 &= ~signmask;
-        shorts1 += pix1;
-        shorts1 ^= signs1;
-        shorts1 = maxsw4(shorts1, 0);
-        shorts1 = minsw4(shorts1, clampmask);
-
-        stl(pkwb(shorts0), pixels);
-        stl(pkwb(shorts1), pixels + 4);
-
-        pixels += line_size;
-        block += 8;
-    } while (--h);
-}
-#endif
-
-static void clear_blocks_axp(DCTELEM *blocks) {
-    uint64_t *p = (uint64_t *) blocks;
-    int n = sizeof(DCTELEM) * 6 * 64;
-
-    do {
-        p[0] = 0;
-        p[1] = 0;
-        p[2] = 0;
-        p[3] = 0;
-        p[4] = 0;
-        p[5] = 0;
-        p[6] = 0;
-        p[7] = 0;
-        p += 8;
-        n -= 8 * 8;
-    } while (n);
-}
-
-static inline uint64_t avg2_no_rnd(uint64_t a, uint64_t b)
-{
-    return (a & b) + (((a ^ b) & BYTE_VEC(0xfe)) >> 1);
-}
-
-static inline uint64_t avg2(uint64_t a, uint64_t b)
-{
-    return (a | b) - (((a ^ b) & BYTE_VEC(0xfe)) >> 1);    
-}
-
-#if 0
-/* The XY2 routines basically utilize this scheme, but reuse parts in
-   each iteration.  */
-static inline uint64_t avg4(uint64_t l1, uint64_t l2, uint64_t l3, uint64_t l4)
-{
-    uint64_t r1 = ((l1 & ~BYTE_VEC(0x03)) >> 2)
-                + ((l2 & ~BYTE_VEC(0x03)) >> 2)
-                + ((l3 & ~BYTE_VEC(0x03)) >> 2)
-                + ((l4 & ~BYTE_VEC(0x03)) >> 2);
-    uint64_t r2 = ((  (l1 & BYTE_VEC(0x03))
-                    + (l2 & BYTE_VEC(0x03))
-                    + (l3 & BYTE_VEC(0x03))
-                    + (l4 & BYTE_VEC(0x03))
-                    + BYTE_VEC(0x02)) >> 2) & BYTE_VEC(0x03);
-    return r1 + r2;
-}
-#endif
-
-#define OP(LOAD, STORE)                         \
-    do {                                        \
-        STORE(LOAD(pixels), block);             \
-        pixels += line_size;                    \
-        block += line_size;                     \
-    } while (--h)
-
-#define OP_X2(LOAD, STORE)                                      \
-    do {                                                        \
-        uint64_t pix1, pix2;                                    \
-                                                                \
-        pix1 = LOAD(pixels);                                    \
-        pix2 = pix1 >> 8 | ((uint64_t) pixels[8] << 56);        \
-        STORE(AVG2(pix1, pix2), block);                         \
-        pixels += line_size;                                    \
-        block += line_size;                                     \
-    } while (--h)
-
-#define OP_Y2(LOAD, STORE)                      \
-    do {                                        \
-        uint64_t pix = LOAD(pixels);            \
-        do {                                    \
-            uint64_t next_pix;                  \
-                                                \
-            pixels += line_size;                \
-            next_pix = LOAD(pixels);            \
-            STORE(AVG2(pix, next_pix), block);  \
-            block += line_size;                 \
-            pix = next_pix;                     \
-        } while (--h);                          \
-    } while (0)
-
-#define OP_XY2(LOAD, STORE)                                                 \
-    do {                                                                    \
-        uint64_t pix1 = LOAD(pixels);                                       \
-        uint64_t pix2 = pix1 >> 8 | ((uint64_t) pixels[8] << 56);           \
-        uint64_t pix_l = (pix1 & BYTE_VEC(0x03))                            \
-                       + (pix2 & BYTE_VEC(0x03));                           \
-        uint64_t pix_h = ((pix1 & ~BYTE_VEC(0x03)) >> 2)                    \
-                       + ((pix2 & ~BYTE_VEC(0x03)) >> 2);                   \
-                                                                            \
-        do {                                                                \
-            uint64_t npix1, npix2;                                          \
-            uint64_t npix_l, npix_h;                                        \
-            uint64_t avg;                                                   \
-                                                                            \
-            pixels += line_size;                                            \
-            npix1 = LOAD(pixels);                                           \
-            npix2 = npix1 >> 8 | ((uint64_t) pixels[8] << 56);              \
-            npix_l = (npix1 & BYTE_VEC(0x03))                               \
-                   + (npix2 & BYTE_VEC(0x03));                              \
-            npix_h = ((npix1 & ~BYTE_VEC(0x03)) >> 2)                       \
-                   + ((npix2 & ~BYTE_VEC(0x03)) >> 2);                      \
-            avg = (((pix_l + npix_l + AVG4_ROUNDER) >> 2) & BYTE_VEC(0x03)) \
-                + pix_h + npix_h;                                           \
-            STORE(avg, block);                                              \
-                                                                            \
-            block += line_size;                                             \
-            pix_l = npix_l;                                                 \
-            pix_h = npix_h;                                                 \
-        } while (--h);                                                      \
-    } while (0)
-
-#define MAKE_OP(OPNAME, SUFF, OPKIND, STORE)                                \
-static void OPNAME ## _pixels ## SUFF ## _axp                               \
-        (uint8_t *restrict block, const uint8_t *restrict pixels,           \
-         int line_size, int h)                                              \
-{                                                                           \
-    if ((size_t) pixels & 0x7) {                                            \
-        OPKIND(uldq, STORE);                                                \
-    } else {                                                                \
-        OPKIND(ldq, STORE);                                                 \
-    }                                                                       \
-}                                                                           \
-                                                                            \
-static void OPNAME ## _pixels16 ## SUFF ## _axp                             \
-        (uint8_t *restrict block, const uint8_t *restrict pixels,           \
-         int line_size, int h)                                              \
-{                                                                           \
-    OPNAME ## _pixels ## SUFF ## _axp(block,     pixels,     line_size, h); \
-    OPNAME ## _pixels ## SUFF ## _axp(block + 8, pixels + 8, line_size, h); \
-}
-
-#define PIXOP(OPNAME, STORE)                    \
-    MAKE_OP(OPNAME, ,     OP,     STORE)        \
-    MAKE_OP(OPNAME, _x2,  OP_X2,  STORE)        \
-    MAKE_OP(OPNAME, _y2,  OP_Y2,  STORE)        \
-    MAKE_OP(OPNAME, _xy2, OP_XY2, STORE)
-
-/* Rounding primitives.  */
-#define AVG2 avg2
-#define AVG4 avg4
-#define AVG4_ROUNDER BYTE_VEC(0x02)
-#define STORE(l, b) stq(l, b)
-PIXOP(put, STORE);
-
-#undef STORE
-#define STORE(l, b) stq(AVG2(l, ldq(b)), b);
-PIXOP(avg, STORE);
-
-/* Not rounding primitives.  */
-#undef AVG2
-#undef AVG4
-#undef AVG4_ROUNDER
-#undef STORE
-#define AVG2 avg2_no_rnd
-#define AVG4 avg4_no_rnd
-#define AVG4_ROUNDER BYTE_VEC(0x01)
-#define STORE(l, b) stq(l, b)
-PIXOP(put_no_rnd, STORE);
-
-#undef STORE
-#define STORE(l, b) stq(AVG2(l, ldq(b)), b);
-PIXOP(avg_no_rnd, STORE);
-
-void put_pixels16_axp_asm(uint8_t *block, const uint8_t *pixels,
-                          int line_size, int h)
-{
-    put_pixels_axp_asm(block,     pixels,     line_size, h);
-    put_pixels_axp_asm(block + 8, pixels + 8, line_size, h);
-}
-
-static int sad16x16_mvi(void *s, uint8_t *a, uint8_t *b, int stride)
-{
-    return pix_abs16x16_mvi_asm(a, b, stride);
-}
-
-void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx)
-{
-    c->put_pixels_tab[0][0] = put_pixels16_axp_asm;
-    c->put_pixels_tab[0][1] = put_pixels16_x2_axp;
-    c->put_pixels_tab[0][2] = put_pixels16_y2_axp;
-    c->put_pixels_tab[0][3] = put_pixels16_xy2_axp;
-
-    c->put_no_rnd_pixels_tab[0][0] = put_pixels16_axp_asm;
-    c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_axp;
-    c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_axp;
-    c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_axp;
-
-    c->avg_pixels_tab[0][0] = avg_pixels16_axp;
-    c->avg_pixels_tab[0][1] = avg_pixels16_x2_axp;
-    c->avg_pixels_tab[0][2] = avg_pixels16_y2_axp;
-    c->avg_pixels_tab[0][3] = avg_pixels16_xy2_axp;
-
-    c->avg_no_rnd_pixels_tab[0][0] = avg_no_rnd_pixels16_axp;
-    c->avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_axp;
-    c->avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_axp;
-    c->avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_axp;
-
-    c->put_pixels_tab[1][0] = put_pixels_axp_asm;
-    c->put_pixels_tab[1][1] = put_pixels_x2_axp;
-    c->put_pixels_tab[1][2] = put_pixels_y2_axp;
-    c->put_pixels_tab[1][3] = put_pixels_xy2_axp;
-
-    c->put_no_rnd_pixels_tab[1][0] = put_pixels_axp_asm;
-    c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels_x2_axp;
-    c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels_y2_axp;
-    c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels_xy2_axp;
-
-    c->avg_pixels_tab[1][0] = avg_pixels_axp;
-    c->avg_pixels_tab[1][1] = avg_pixels_x2_axp;
-    c->avg_pixels_tab[1][2] = avg_pixels_y2_axp;
-    c->avg_pixels_tab[1][3] = avg_pixels_xy2_axp;
-
-    c->avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels_axp;
-    c->avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels_x2_axp;
-    c->avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels_y2_axp;
-    c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels_xy2_axp;
-
-    c->clear_blocks = clear_blocks_axp;
-
-    /* amask clears all bits that correspond to present features.  */
-    if (amask(AMASK_MVI) == 0) {
-        c->put_pixels_clamped = put_pixels_clamped_mvi_asm;
-        c->add_pixels_clamped = add_pixels_clamped_mvi_asm;
-
-        c->get_pixels       = get_pixels_mvi;
-        c->diff_pixels      = diff_pixels_mvi;
-        c->sad[0]           = sad16x16_mvi;
-        c->sad[1]           = pix_abs8x8_mvi;
-//        c->pix_abs[0][0]    = pix_abs16x16_mvi_asm; //FIXME function arguments for the asm must be fixed
-        c->pix_abs[0][0]    = sad16x16_mvi;
-        c->pix_abs[1][0]    = pix_abs8x8_mvi;
-        c->pix_abs[0][1]    = pix_abs16x16_x2_mvi;
-        c->pix_abs[0][2]    = pix_abs16x16_y2_mvi;
-        c->pix_abs[0][3]    = pix_abs16x16_xy2_mvi;
-    }
-
-    put_pixels_clamped_axp_p = c->put_pixels_clamped;
-    add_pixels_clamped_axp_p = c->add_pixels_clamped;
-    
-    c->idct_put = simple_idct_put_axp;
-    c->idct_add = simple_idct_add_axp;
-    c->idct = simple_idct_axp;
-}
diff --git a/ffmpeg.src/libavcodec/alpha/dsputil_alpha_asm.S b/ffmpeg.src/libavcodec/alpha/dsputil_alpha_asm.S
deleted file mode 100644
index 6519a95..0000000
--- a/ffmpeg.src/libavcodec/alpha/dsputil_alpha_asm.S
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Alpha optimized DSP utils
- * Copyright (c) 2002 Falk Hueffner <falk at debian.org>
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
- * These functions are scheduled for pca56. They should work
- * reasonably on ev6, though.
- */
-
-#include "regdef.h"
-
-/* Some nicer register names.  */
-#define ta t10
-#define tb t11
-#define tc t12
-#define td AT
-/* Danger: these overlap with the argument list and the return value */
-#define te a5
-#define tf a4
-#define tg a3
-#define th v0
-                
-        .set noat
-        .set noreorder
-        .arch pca56
-        .text
-
-/************************************************************************
- * void put_pixels_axp_asm(uint8_t *block, const uint8_t *pixels,
- *                         int line_size, int h)
- */
-        .align 6
-        .globl put_pixels_axp_asm
-        .ent put_pixels_axp_asm
-put_pixels_axp_asm:
-        .frame sp, 0, ra
-        .prologue 0
-
-#ifdef HAVE_GPROF
-        lda     AT, _mcount
-        jsr     AT, (AT), _mcount
-#endif
-
-        and     a1, 7, t0
-        beq     t0, $aligned
-
-        .align 4
-$unaligned:
-        ldq_u   t0, 0(a1)
-        ldq_u   t1, 8(a1)
-        addq    a1, a2, a1
-        nop
-
-        ldq_u   t2, 0(a1)
-        ldq_u   t3, 8(a1)
-        addq    a1, a2, a1
-        nop
-
-	ldq_u   t4, 0(a1)
-        ldq_u   t5, 8(a1)
-        addq    a1, a2, a1
-        nop
-
-        ldq_u   t6, 0(a1)
-        ldq_u   t7, 8(a1)
-        extql   t0, a1, t0
-        addq    a1, a2, a1
-
-        extqh   t1, a1, t1
-        addq    a0, a2, t8
-        extql   t2, a1, t2
-        addq    t8, a2, t9
-
-        extqh   t3, a1, t3
-        addq    t9, a2, ta
-        extql   t4, a1, t4
-        or      t0, t1, t0
-
-        extqh   t5, a1, t5
-        or      t2, t3, t2
-        extql   t6, a1, t6
-        or      t4, t5, t4
-
-        extqh   t7, a1, t7
-        or      t6, t7, t6
-        stq     t0, 0(a0)
-        stq     t2, 0(t8)
-
-        stq     t4, 0(t9)
-        subq    a3, 4, a3
-        stq     t6, 0(ta)
-        addq    ta, a2, a0
-
-        bne     a3, $unaligned
-        ret
-
-        .align 4
-$aligned:
-        ldq     t0, 0(a1)
-        addq    a1, a2, a1
-        ldq     t1, 0(a1)
-        addq    a1, a2, a1
-
-        ldq     t2, 0(a1)
-        addq    a1, a2, a1
-        ldq     t3, 0(a1)
-
-	addq	a0, a2, t4
-	addq    a1, a2, a1
-	addq	t4, a2, t5
-	subq    a3, 4, a3
-
-	stq	t0, 0(a0)
-	addq	t5, a2, t6
-	stq	t1, 0(t4)
-	addq	t6, a2, a0
-
-	stq	t2, 0(t5)
-	stq	t3, 0(t6)
-	
-	bne     a3, $aligned
-        ret
-        .end put_pixels_axp_asm
-
-/************************************************************************
- * void put_pixels_clamped_mvi_asm(const DCTELEM *block, uint8_t *pixels, 
- *                                 int line_size)
- */
-        .align 6
-        .globl put_pixels_clamped_mvi_asm
-        .ent put_pixels_clamped_mvi_asm
-put_pixels_clamped_mvi_asm:
-        .frame sp, 0, ra
-        .prologue 0
-
-#ifdef HAVE_GPROF
-        lda     AT, _mcount
-        jsr     AT, (AT), _mcount
-#endif
-
-        lda     t8, -1
-        lda     t9, 8           # loop counter
-        zap     t8, 0xaa, t8    # 00ff00ff00ff00ff
-
-        .align 4
-1:      ldq     t0,  0(a0)
-        ldq     t1,  8(a0)
-        ldq     t2, 16(a0)
-        ldq     t3, 24(a0)
-
-        maxsw4  t0, zero, t0
-        subq    t9, 2, t9
-        maxsw4  t1, zero, t1
-        lda     a0, 32(a0)
-
-        maxsw4  t2, zero, t2
-        addq    a1, a2, ta
-        maxsw4  t3, zero, t3
-        minsw4  t0, t8, t0
-        
-        minsw4  t1, t8, t1
-        minsw4  t2, t8, t2
-        minsw4  t3, t8, t3
-        pkwb    t0, t0
-        
-        pkwb    t1, t1
-        pkwb    t2, t2
-        pkwb    t3, t3
-        stl     t0, 0(a1)
-        
-        stl     t1, 4(a1)
-        addq    ta, a2, a1
-        stl     t2, 0(ta)
-        stl     t3, 4(ta)
-
-        bne     t9, 1b
-        ret
-        .end put_pixels_clamped_mvi_asm
-
-/************************************************************************
- * void add_pixels_clamped_mvi_asm(const DCTELEM *block, uint8_t *pixels, 
- *                                 int line_size)
- */
-        .align 6
-        .globl add_pixels_clamped_mvi_asm
-        .ent add_pixels_clamped_mvi_asm
-add_pixels_clamped_mvi_asm:
-        .frame sp, 0, ra
-        .prologue 0
-
-#ifdef HAVE_GPROF
-        lda     AT, _mcount
-        jsr     AT, (AT), _mcount
-#endif
-
-        lda     t1, -1
-        lda     th, 8
-        zap     t1, 0x33, tg
-        nop
-
-        srl     tg, 1, t0
-        xor     tg, t0, tg      # 0x8000800080008000
-        zap     t1, 0xaa, tf    # 0x00ff00ff00ff00ff
-
-        .align 4
-1:      ldl     t1, 0(a1)       # pix0 (try to hit cache line soon)
-        ldl     t4, 4(a1)       # pix1
-        addq    a1, a2, te      # pixels += line_size
-        ldq     t0, 0(a0)       # shorts0
-
-        ldl     t7, 0(te)       # pix2 (try to hit cache line soon)
-        ldl     ta, 4(te)       # pix3
-        ldq     t3, 8(a0)       # shorts1
-        ldq     t6, 16(a0)      # shorts2
-
-        ldq     t9, 24(a0)      # shorts3
-        unpkbw  t1, t1          # 0 0 (quarter/op no.)
-        and     t0, tg, t2      # 0 1
-        unpkbw  t4, t4          # 1 0
-
-        bic     t0, tg, t0      # 0 2
-        unpkbw  t7, t7          # 2 0
-        and     t3, tg, t5      # 1 1
-        addq    t0, t1, t0      # 0 3 
-
-        xor     t0, t2, t0      # 0 4
-        unpkbw  ta, ta          # 3 0
-        and     t6, tg, t8      # 2 1
-        maxsw4  t0, zero, t0    # 0 5
-        
-        bic     t3, tg, t3      # 1 2
-        bic     t6, tg, t6      # 2 2
-        minsw4  t0, tf, t0      # 0 6
-        addq    t3, t4, t3      # 1 3
-        
-        pkwb    t0, t0          # 0 7
-        xor     t3, t5, t3      # 1 4
-        maxsw4  t3, zero, t3    # 1 5
-        addq    t6, t7, t6      # 2 3
-
-        xor     t6, t8, t6      # 2 4
-        and     t9, tg, tb      # 3 1
-        minsw4  t3, tf, t3      # 1 6
-        bic     t9, tg, t9      # 3 2
-
-        maxsw4  t6, zero, t6    # 2 5
-        addq    t9, ta, t9      # 3 3
-        stl     t0, 0(a1)       # 0 8   
-        minsw4  t6, tf, t6      # 2 6
-
-        xor     t9, tb, t9      # 3 4
-        maxsw4  t9, zero, t9    # 3 5
-        lda     a0, 32(a0)      # block += 16;
-        pkwb    t3, t3          # 1 7
-        
-        minsw4  t9, tf, t9      # 3 6
-        subq    th, 2, th
-        pkwb    t6, t6          # 2 7
-        pkwb    t9, t9          # 3 7
-
-        stl     t3, 4(a1)       # 1 8
-        addq    te, a2, a1      # pixels += line_size
-        stl     t6, 0(te)       # 2 8
-        stl     t9, 4(te)       # 3 8
-
-        bne     th, 1b
-        ret     
-        .end add_pixels_clamped_mvi_asm
diff --git a/ffmpeg.src/libavcodec/alpha/motion_est_alpha.c b/ffmpeg.src/libavcodec/alpha/motion_est_alpha.c
deleted file mode 100644
index 8b8a0a2..0000000
--- a/ffmpeg.src/libavcodec/alpha/motion_est_alpha.c
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Alpha optimized DSP utils
- * Copyright (c) 2002 Falk Hueffner <falk at debian.org>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "asm.h"
-#include "../dsputil.h"
-
-void get_pixels_mvi(DCTELEM *restrict block,
-                    const uint8_t *restrict pixels, int line_size)
-{
-    int h = 8;
-
-    do {
-        uint64_t p;
-
-        p = ldq(pixels);
-        stq(unpkbw(p),       block);
-        stq(unpkbw(p >> 32), block + 4); 
-
-        pixels += line_size;
-        block += 8;
-    } while (--h);
-}
-
-void diff_pixels_mvi(DCTELEM *block, const uint8_t *s1, const uint8_t *s2,
-                     int stride) {
-    int h = 8;
-    uint64_t mask = 0x4040;
-
-    mask |= mask << 16;
-    mask |= mask << 32;
-    do {
-        uint64_t x, y, c, d, a;
-        uint64_t signs;
-
-        x = ldq(s1);
-        y = ldq(s2);
-        c = cmpbge(x, y);
-        d = x - y;
-        a = zap(mask, c);       /* We use 0x4040404040404040 here...  */
-        d += 4 * a;             /* ...so we can use s4addq here.      */
-        signs = zap(-1, c);
-
-        stq(unpkbw(d)       | (unpkbw(signs)       << 8), block);
-        stq(unpkbw(d >> 32) | (unpkbw(signs >> 32) << 8), block + 4);
-
-        s1 += stride;
-        s2 += stride;
-        block += 8;
-    } while (--h);
-}
-
-static inline uint64_t avg2(uint64_t a, uint64_t b)
-{
-    return (a | b) - (((a ^ b) & BYTE_VEC(0xfe)) >> 1);
-}
-
-static inline uint64_t avg4(uint64_t l1, uint64_t l2, uint64_t l3, uint64_t l4)
-{
-    uint64_t r1 = ((l1 & ~BYTE_VEC(0x03)) >> 2)
-                + ((l2 & ~BYTE_VEC(0x03)) >> 2)
-                + ((l3 & ~BYTE_VEC(0x03)) >> 2)
-                + ((l4 & ~BYTE_VEC(0x03)) >> 2);
-    uint64_t r2 = ((  (l1 & BYTE_VEC(0x03))
-                    + (l2 & BYTE_VEC(0x03))
-                    + (l3 & BYTE_VEC(0x03))
-                    + (l4 & BYTE_VEC(0x03))
-                    + BYTE_VEC(0x02)) >> 2) & BYTE_VEC(0x03);
-    return r1 + r2;
-}
-
-int pix_abs8x8_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int result = 0;
-
-    if ((size_t) pix2 & 0x7) {
-        /* works only when pix2 is actually unaligned */
-        do {                    /* do 8 pixel a time */
-            uint64_t p1, p2;
-
-            p1  = ldq(pix1);
-            p2  = uldq(pix2);
-            result += perr(p1, p2);
-
-            pix1 += line_size;
-            pix2 += line_size;
-        } while (--h);
-    } else {
-        do {
-            uint64_t p1, p2;
-
-            p1 = ldq(pix1);
-            p2 = ldq(pix2);
-            result += perr(p1, p2);
-
-            pix1 += line_size;
-            pix2 += line_size;
-        } while (--h);
-    }
-
-    return result;
-}
-
-#if 0				/* now done in assembly */
-int pix_abs16x16_mvi(uint8_t *pix1, uint8_t *pix2, int line_size)
-{
-    int result = 0;
-    int h = 16;
-
-    if ((size_t) pix2 & 0x7) {
-        /* works only when pix2 is actually unaligned */
-        do {                    /* do 16 pixel a time */
-            uint64_t p1_l, p1_r, p2_l, p2_r;
-            uint64_t t;
-
-            p1_l  = ldq(pix1);
-            p1_r  = ldq(pix1 + 8);
-            t     = ldq_u(pix2 + 8);
-            p2_l  = extql(ldq_u(pix2), pix2) | extqh(t, pix2);
-            p2_r  = extql(t, pix2) | extqh(ldq_u(pix2 + 16), pix2);
-            pix1 += line_size;
-            pix2 += line_size;
-
-            result += perr(p1_l, p2_l)
-                    + perr(p1_r, p2_r);
-        } while (--h);
-    } else {
-        do {
-            uint64_t p1_l, p1_r, p2_l, p2_r;
-
-            p1_l = ldq(pix1);
-            p1_r = ldq(pix1 + 8);
-            p2_l = ldq(pix2);
-            p2_r = ldq(pix2 + 8);
-            pix1 += line_size;
-            pix2 += line_size;
-
-            result += perr(p1_l, p2_l)
-                    + perr(p1_r, p2_r);
-        } while (--h);
-    }
-
-    return result;
-}
-#endif
-
-int pix_abs16x16_x2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int result = 0;
-    uint64_t disalign = (size_t) pix2 & 0x7;
-
-    switch (disalign) {
-    case 0:
-        do {
-            uint64_t p1_l, p1_r, p2_l, p2_r;
-            uint64_t l, r;
-
-            p1_l = ldq(pix1);
-            p1_r = ldq(pix1 + 8);
-            l    = ldq(pix2);
-            r    = ldq(pix2 + 8);
-            p2_l = avg2(l, (l >> 8) | ((uint64_t) r << 56));
-            p2_r = avg2(r, (r >> 8) | ((uint64_t) pix2[16] << 56));
-            pix1 += line_size;
-            pix2 += line_size;
-
-            result += perr(p1_l, p2_l)
-                    + perr(p1_r, p2_r);
-        } while (--h);
-        break;
-    case 7:
-        /* |.......l|lllllllr|rrrrrrr*|
-           This case is special because disalign1 would be 8, which
-           gets treated as 0 by extqh.  At least it is a bit faster
-           that way :)  */   
-        do {
-            uint64_t p1_l, p1_r, p2_l, p2_r;
-            uint64_t l, m, r;
-
-            p1_l = ldq(pix1);
-            p1_r = ldq(pix1 + 8);
-            l     = ldq_u(pix2);
-            m     = ldq_u(pix2 + 8);
-            r     = ldq_u(pix2 + 16);
-            p2_l  = avg2(extql(l, disalign) | extqh(m, disalign), m);
-            p2_r  = avg2(extql(m, disalign) | extqh(r, disalign), r);
-            pix1 += line_size;
-            pix2 += line_size;
-            
-            result += perr(p1_l, p2_l)
-                    + perr(p1_r, p2_r);
-        } while (--h);
-        break;
-    default:
-        do {
-            uint64_t disalign1 = disalign + 1;
-            uint64_t p1_l, p1_r, p2_l, p2_r;
-            uint64_t l, m, r;
-
-            p1_l  = ldq(pix1);
-            p1_r  = ldq(pix1 + 8);
-            l     = ldq_u(pix2);
-            m     = ldq_u(pix2 + 8);
-            r     = ldq_u(pix2 + 16);
-            p2_l  = avg2(extql(l, disalign) | extqh(m, disalign),
-                         extql(l, disalign1) | extqh(m, disalign1));
-            p2_r  = avg2(extql(m, disalign) | extqh(r, disalign),
-                         extql(m, disalign1) | extqh(r, disalign1));
-            pix1 += line_size;
-            pix2 += line_size;
-
-            result += perr(p1_l, p2_l)
-                    + perr(p1_r, p2_r);
-        } while (--h);
-        break;
-    }
-    return result;
-}
-
-int pix_abs16x16_y2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int result = 0;
-
-    if ((size_t) pix2 & 0x7) {
-        uint64_t t, p2_l, p2_r;
-        t     = ldq_u(pix2 + 8);
-        p2_l  = extql(ldq_u(pix2), pix2) | extqh(t, pix2);
-        p2_r  = extql(t, pix2) | extqh(ldq_u(pix2 + 16), pix2);
-
-        do {
-            uint64_t p1_l, p1_r, np2_l, np2_r;
-            uint64_t t;
-
-            p1_l  = ldq(pix1);
-            p1_r  = ldq(pix1 + 8);
-            pix2 += line_size;
-            t     = ldq_u(pix2 + 8);
-            np2_l = extql(ldq_u(pix2), pix2) | extqh(t, pix2);
-            np2_r = extql(t, pix2) | extqh(ldq_u(pix2 + 16), pix2);
-
-            result += perr(p1_l, avg2(p2_l, np2_l))
-                    + perr(p1_r, avg2(p2_r, np2_r));
-
-            pix1 += line_size;
-            p2_l  = np2_l;
-            p2_r  = np2_r;
-
-        } while (--h);
-    } else {
-        uint64_t p2_l, p2_r;
-        p2_l = ldq(pix2);
-        p2_r = ldq(pix2 + 8);
-        do {
-            uint64_t p1_l, p1_r, np2_l, np2_r;
-
-            p1_l = ldq(pix1);
-            p1_r = ldq(pix1 + 8);
-            pix2 += line_size;
-            np2_l = ldq(pix2);
-            np2_r = ldq(pix2 + 8);
-
-            result += perr(p1_l, avg2(p2_l, np2_l))
-                    + perr(p1_r, avg2(p2_r, np2_r));
-
-            pix1 += line_size;
-            p2_l  = np2_l;
-            p2_r  = np2_r;
-        } while (--h);
-    }
-    return result;
-}
-
-int pix_abs16x16_xy2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int result = 0;
-    
-    uint64_t p1_l, p1_r;
-    uint64_t p2_l, p2_r, p2_x;
-
-    p1_l = ldq(pix1);
-    p1_r = ldq(pix1 + 8);
-
-    if ((size_t) pix2 & 0x7) { /* could be optimized a lot */
-        p2_l = uldq(pix2);
-        p2_r = uldq(pix2 + 8);
-        p2_x = (uint64_t) pix2[16] << 56;
-    } else {
-        p2_l = ldq(pix2);
-        p2_r = ldq(pix2 + 8);
-        p2_x = ldq(pix2 + 16) << 56;
-    }
-
-    do {
-        uint64_t np1_l, np1_r;
-        uint64_t np2_l, np2_r, np2_x;
-
-        pix1 += line_size;
-        pix2 += line_size;
-
-        np1_l = ldq(pix1);
-        np1_r = ldq(pix1 + 8);
-
-        if ((size_t) pix2 & 0x7) { /* could be optimized a lot */
-            np2_l = uldq(pix2);
-            np2_r = uldq(pix2 + 8);
-            np2_x = (uint64_t) pix2[16] << 56;
-        } else {
-            np2_l = ldq(pix2);
-            np2_r = ldq(pix2 + 8);
-            np2_x = ldq(pix2 + 16) << 56;
-        }
-
-        result += perr(p1_l,
-                       avg4( p2_l, ( p2_l >> 8) | ((uint64_t)  p2_r << 56),
-                            np2_l, (np2_l >> 8) | ((uint64_t) np2_r << 56)))
-                + perr(p1_r,
-                       avg4( p2_r, ( p2_r >> 8) | ((uint64_t)  p2_x),
-                            np2_r, (np2_r >> 8) | ((uint64_t) np2_x)));
-
-        p1_l = np1_l;
-        p1_r = np1_r;
-        p2_l = np2_l;
-        p2_r = np2_r;
-        p2_x = np2_x;
-    } while (--h);
-
-    return result;
-}
diff --git a/ffmpeg.src/libavcodec/alpha/motion_est_mvi_asm.S b/ffmpeg.src/libavcodec/alpha/motion_est_mvi_asm.S
deleted file mode 100644
index 9e6b75f..0000000
--- a/ffmpeg.src/libavcodec/alpha/motion_est_mvi_asm.S
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Alpha optimized DSP utils
- * Copyright (c) 2002 Falk Hueffner <falk at debian.org>
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "regdef.h"
-
-/* Some nicer register names.  */
-#define ta t10
-#define tb t11
-#define tc t12
-#define td AT
-/* Danger: these overlap with the argument list and the return value */
-#define te a5
-#define tf a4
-#define tg a3
-#define th v0
-        
-        .set noat
-        .set noreorder
-        .arch pca56
-        .text
-
-/*****************************************************************************
- * int pix_abs16x16_mvi_asm(uint8_t *pix1, uint8_t *pix2, int line_size)
- *
- * This code is written with a pca56 in mind. For ev6, one should
- * really take the increased latency of 3 cycles for MVI instructions
- * into account.
- *
- * It is important to keep the loading and first use of a register as
- * far apart as possible, because if a register is accessed before it
- * has been fetched from memory, the CPU will stall.
- */
-        .align 4
-        .globl pix_abs16x16_mvi_asm
-        .ent pix_abs16x16_mvi_asm
-pix_abs16x16_mvi_asm:
-        .frame sp, 0, ra, 0
-        .prologue 0
-
-#ifdef HAVE_GPROF
-        lda     AT, _mcount
-        jsr     AT, (AT), _mcount
-#endif
-
-        and     a1, 7, t0
-        clr     v0
-        lda     a3, 16
-        beq     t0, $aligned
-        .align 4
-$unaligned:
-        /* Registers:
-           line 0:
-           t0:  left_u -> left lo -> left
-           t1:  mid
-           t2:  right_u -> right hi -> right
-           t3:  ref left
-           t4:  ref right
-           line 1:
-           t5:  left_u -> left lo -> left
-           t6:  mid
-           t7:  right_u -> right hi -> right
-           t8:  ref left
-           t9:  ref right
-           temp:
-           ta:  left hi
-           tb:  right lo
-           tc:  error left
-           td:  error right  */
-
-        /* load line 0 */
-        ldq_u   t0, 0(a1)       # left_u
-        ldq_u   t1, 8(a1)       # mid
-        ldq_u   t2, 16(a1)      # right_u
-        ldq     t3, 0(a0)       # ref left
-        ldq     t4, 8(a0)       # ref right
-        addq    a0, a2, a0      # pix1
-        addq    a1, a2, a1      # pix2
-        /* load line 1 */        
-        ldq_u   t5, 0(a1)       # left_u
-        ldq_u   t6, 8(a1)       # mid
-        ldq_u   t7, 16(a1)      # right_u
-        ldq     t8, 0(a0)       # ref left
-        ldq     t9, 8(a0)       # ref right
-        addq    a0, a2, a0      # pix1
-        addq    a1, a2, a1      # pix2
-        /* calc line 0 */
-        extql   t0, a1, t0      # left lo
-        extqh   t1, a1, ta      # left hi
-        extql   t1, a1, tb      # right lo
-        or      t0, ta, t0      # left
-        extqh   t2, a1, t2      # right hi
-        perr    t3, t0, tc      # error left
-        or      t2, tb, t2      # right
-        perr    t4, t2, td      # error right
-        addq    v0, tc, v0      # add error left
-        addq    v0, td, v0      # add error left
-        /* calc line 1 */
-        extql   t5, a1, t5      # left lo
-        extqh   t6, a1, ta      # left hi
-        extql   t6, a1, tb      # right lo
-        or      t5, ta, t5      # left
-        extqh   t7, a1, t7      # right hi
-        perr    t8, t5, tc      # error left
-        or      t7, tb, t7      # right
-        perr    t9, t7, td      # error right
-        addq    v0, tc, v0      # add error left
-        addq    v0, td, v0      # add error left
-        /* loop */
-        subq    a3,  2, a3      # h -= 2
-        bne     a3, $unaligned
-        ret
-
-        .align 4
-$aligned:
-        /* load line 0 */
-        ldq     t0, 0(a1)       # left
-        ldq     t1, 8(a1)       # right
-        addq    a1, a2, a1      # pix2
-        ldq     t2, 0(a0)       # ref left
-        ldq     t3, 8(a0)       # ref right
-        addq    a0, a2, a0      # pix1
-        /* load line 1 */
-        ldq     t4, 0(a1)       # left
-        ldq     t5, 8(a1)       # right
-        addq    a1, a2, a1      # pix2
-        ldq     t6, 0(a0)       # ref left
-        ldq     t7, 8(a0)       # ref right
-        addq    a0, a2, a0      # pix1
-        /* load line 2 */
-        ldq     t8, 0(a1)       # left
-        ldq     t9, 8(a1)       # right
-        addq    a1, a2, a1      # pix2
-        ldq     ta, 0(a0)       # ref left
-        ldq     tb, 8(a0)       # ref right
-        addq    a0, a2, a0      # pix1
-        /* load line 3 */
-        ldq     tc, 0(a1)       # left
-        ldq     td, 8(a1)       # right
-        addq    a1, a2, a1      # pix2
-        ldq     te, 0(a0)       # ref left
-        ldq     tf, 8(a0)       # ref right
-        /* calc line 0 */
-        perr    t0, t2, t0      # error left
-        addq    a0, a2, a0      # pix1
-        perr    t1, t3, t1      # error right
-        addq    v0, t0, v0      # add error left
-        /* calc line 1 */
-        perr    t4, t6, t0      # error left
-        addq    v0, t1, v0      # add error right
-        perr    t5, t7, t1      # error right
-        addq    v0, t0, v0      # add error left
-        /* calc line 2 */
-        perr    t8, ta, t0      # error left
-        addq    v0, t1, v0      # add error right
-        perr    t9, tb, t1      # error right
-        addq    v0, t0, v0      # add error left
-        /* calc line 3 */
-        perr    tc, te, t0      # error left
-        addq    v0, t1, v0      # add error right
-        perr    td, tf, t1      # error right
-        addq    v0, t0, v0      # add error left
-        addq    v0, t1, v0      # add error right
-        /* loop */
-        subq    a3,  4, a3      # h -= 4
-        bne     a3, $aligned
-        ret
-        .end pix_abs16x16_mvi_asm
diff --git a/ffmpeg.src/libavcodec/alpha/mpegvideo_alpha.c b/ffmpeg.src/libavcodec/alpha/mpegvideo_alpha.c
deleted file mode 100644
index f64fb74..0000000
--- a/ffmpeg.src/libavcodec/alpha/mpegvideo_alpha.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Alpha optimized DSP utils
- * Copyright (c) 2002 Falk Hueffner <falk at debian.org>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "asm.h"
-#include "../dsputil.h"
-#include "../mpegvideo.h"
-
-static void dct_unquantize_h263_intra_axp(MpegEncContext *s, DCTELEM *block,
-                                    int n, int qscale)
-{
-    int i, n_coeffs;
-    uint64_t qmul, qadd;
-    uint64_t correction;
-    DCTELEM *orig_block = block;
-    DCTELEM block0;
-
-    qadd = WORD_VEC((qscale - 1) | 1);
-    qmul = qscale << 1;
-    /* This mask kills spill from negative subwords to the next subword.  */ 
-    correction = WORD_VEC((qmul - 1) + 1); /* multiplication / addition */
-
-    if (!s->h263_aic) {
-        if (n < 4) 
-            block0 = block[0] * s->y_dc_scale;
-        else
-            block0 = block[0] * s->c_dc_scale;
-    } else {
-        qadd = 0;
-    }
-    n_coeffs = 63; // does not always use zigzag table 
-
-    for(i = 0; i <= n_coeffs; block += 4, i += 4) {
-        uint64_t levels, negmask, zeros, add;
-
-        levels = ldq(block);
-        if (levels == 0)
-            continue;
-
-#ifdef __alpha_max__
-        /* I don't think the speed difference justifies runtime
-           detection.  */
-        negmask = maxsw4(levels, -1); /* negative -> ffff (-1) */
-        negmask = minsw4(negmask, 0); /* positive -> 0000 (0) */
-#else
-        negmask = cmpbge(WORD_VEC(0x7fff), levels);
-        negmask &= (negmask >> 1) | (1 << 7);
-        negmask = zap(-1, negmask);
-#endif
-
-        zeros = cmpbge(0, levels);
-        zeros &= zeros >> 1;
-        /* zeros |= zeros << 1 is not needed since qadd <= 255, so
-           zapping the lower byte suffices.  */
-
-        levels *= qmul;
-        levels -= correction & (negmask << 16);
-
-        /* Negate qadd for negative levels.  */
-        add = qadd ^ negmask;
-        add += WORD_VEC(0x0001) & negmask;
-        /* Set qadd to 0 for levels == 0.  */
-        add = zap(add, zeros);
-
-        levels += add;
-
-        stq(levels, block);
-    }
-
-    if (s->mb_intra && !s->h263_aic)
-        orig_block[0] = block0;
-}
-
-static void dct_unquantize_h263_inter_axp(MpegEncContext *s, DCTELEM *block,
-                                    int n, int qscale)
-{
-    int i, n_coeffs;
-    uint64_t qmul, qadd;
-    uint64_t correction;
-    DCTELEM *orig_block = block;
-    DCTELEM block0;
-
-    qadd = WORD_VEC((qscale - 1) | 1);
-    qmul = qscale << 1;
-    /* This mask kills spill from negative subwords to the next subword.  */ 
-    correction = WORD_VEC((qmul - 1) + 1); /* multiplication / addition */
-
-    n_coeffs = s->intra_scantable.raster_end[s->block_last_index[n]];
-
-    for(i = 0; i <= n_coeffs; block += 4, i += 4) {
-        uint64_t levels, negmask, zeros, add;
-
-        levels = ldq(block);
-        if (levels == 0)
-            continue;
-
-#ifdef __alpha_max__
-        /* I don't think the speed difference justifies runtime
-           detection.  */
-        negmask = maxsw4(levels, -1); /* negative -> ffff (-1) */
-        negmask = minsw4(negmask, 0); /* positive -> 0000 (0) */
-#else
-        negmask = cmpbge(WORD_VEC(0x7fff), levels);
-        negmask &= (negmask >> 1) | (1 << 7);
-        negmask = zap(-1, negmask);
-#endif
-
-        zeros = cmpbge(0, levels);
-        zeros &= zeros >> 1;
-        /* zeros |= zeros << 1 is not needed since qadd <= 255, so
-           zapping the lower byte suffices.  */
-
-        levels *= qmul;
-        levels -= correction & (negmask << 16);
-
-        /* Negate qadd for negative levels.  */
-        add = qadd ^ negmask;
-        add += WORD_VEC(0x0001) & negmask;
-        /* Set qadd to 0 for levels == 0.  */
-        add = zap(add, zeros);
-
-        levels += add;
-
-        stq(levels, block);
-    }
-}
-
-void MPV_common_init_axp(MpegEncContext *s)
-{
-    s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_axp;
-    s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_axp;
-}
diff --git a/ffmpeg.src/libavcodec/alpha/regdef.h b/ffmpeg.src/libavcodec/alpha/regdef.h
deleted file mode 100644
index 7e7fc06..0000000
--- a/ffmpeg.src/libavcodec/alpha/regdef.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Some BSDs don't seem to have regdef.h... sigh  */
-#ifndef alpha_regdef_h
-#define alpha_regdef_h
-
-#define v0      $0      /* function return value */
-
-#define t0      $1      /* temporary registers (caller-saved) */
-#define t1      $2
-#define t2      $3
-#define t3      $4
-#define t4      $5
-#define t5      $6
-#define t6      $7
-#define t7      $8
-
-#define s0      $9      /* saved-registers (callee-saved registers) */
-#define s1      $10
-#define s2      $11
-#define s3      $12
-#define s4      $13
-#define s5      $14
-#define s6      $15
-#define fp      s6      /* frame-pointer (s6 in frame-less procedures) */
-
-#define a0      $16     /* argument registers (caller-saved) */
-#define a1      $17
-#define a2      $18
-#define a3      $19
-#define a4      $20
-#define a5      $21
-
-#define t8      $22     /* more temps (caller-saved) */
-#define t9      $23
-#define t10     $24
-#define t11     $25
-#define ra      $26     /* return address register */
-#define t12     $27
-
-#define pv      t12     /* procedure-variable register */
-#define AT      $at     /* assembler temporary */
-#define gp      $29     /* global pointer */
-#define sp      $30     /* stack pointer */
-#define zero    $31     /* reads as zero, writes are noops */
-
-#endif /* alpha_regdef_h */
diff --git a/ffmpeg.src/libavcodec/alpha/simple_idct_alpha.c b/ffmpeg.src/libavcodec/alpha/simple_idct_alpha.c
deleted file mode 100644
index 293a2f9..0000000
--- a/ffmpeg.src/libavcodec/alpha/simple_idct_alpha.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Simple IDCT (Alpha optimized)
- *
- * Copyright (c) 2001 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * based upon some outcommented c code from mpeg2dec (idct_mmx.c
- * written by Aaron Holtzman <aholtzma at ess.engr.uvic.ca>)
- *
- * Alpha optimiziations by Måns Rullgård <mru at users.sourceforge.net>
- *                     and Falk Hueffner <falk at debian.org>
- */
-
-#include "asm.h"
-#include "../dsputil.h"
-
-extern void (*put_pixels_clamped_axp_p)(const DCTELEM *block, uint8_t *pixels,
-                                        int line_size);
-extern void (*add_pixels_clamped_axp_p)(const DCTELEM *block, uint8_t *pixels, 
-                                        int line_size);
-
-// cos(i * M_PI / 16) * sqrt(2) * (1 << 14)
-// W4 is actually exactly 16384, but using 16383 works around
-// accumulating rounding errors for some encoders
-#define W1 ((int_fast32_t) 22725)
-#define W2 ((int_fast32_t) 21407)
-#define W3 ((int_fast32_t) 19266)
-#define W4 ((int_fast32_t) 16383)
-#define W5 ((int_fast32_t) 12873)
-#define W6 ((int_fast32_t)  8867)
-#define W7 ((int_fast32_t)  4520)
-#define ROW_SHIFT 11
-#define COL_SHIFT 20
-
-/* 0: all entries 0, 1: only first entry nonzero, 2: otherwise  */
-static inline int idct_row(DCTELEM *row)
-{
-    int_fast32_t a0, a1, a2, a3, b0, b1, b2, b3, t;
-    uint64_t l, r, t2;
-    l = ldq(row);
-    r = ldq(row + 4);
-
-    if (l == 0 && r == 0)
-        return 0;
-    
-    a0 = W4 * sextw(l) + (1 << (ROW_SHIFT - 1));
-
-    if (((l & ~0xffffUL) | r) == 0) {
-        a0 >>= ROW_SHIFT;
-        t2 = (uint16_t) a0;
-        t2 |= t2 << 16;
-        t2 |= t2 << 32;
-        
-        stq(t2, row);
-        stq(t2, row + 4);
-        return 1;
-    }
-
-    a1 = a0;
-    a2 = a0;
-    a3 = a0;
-
-    t = extwl(l, 4);            /* row[2] */
-    if (t != 0) {
-        t = sextw(t);
-        a0 += W2 * t;
-        a1 += W6 * t;
-        a2 -= W6 * t;
-        a3 -= W2 * t;
-    }
-
-    t = extwl(r, 0);            /* row[4] */
-    if (t != 0) {
-        t = sextw(t);
-        a0 += W4 * t;
-        a1 -= W4 * t;
-        a2 -= W4 * t;
-        a3 += W4 * t;
-    }
-
-    t = extwl(r, 4);            /* row[6] */
-    if (t != 0) {
-        t = sextw(t);
-        a0 += W6 * t;
-        a1 -= W2 * t;
-        a2 += W2 * t;
-        a3 -= W6 * t;
-    }
-
-    t = extwl(l, 2);            /* row[1] */
-    if (t != 0) {
-        t = sextw(t);
-        b0 = W1 * t;
-        b1 = W3 * t;
-        b2 = W5 * t;
-        b3 = W7 * t;
-    } else {
-        b0 = 0;
-        b1 = 0;
-        b2 = 0;
-        b3 = 0;
-    }
-
-    t = extwl(l, 6);            /* row[3] */
-    if (t) {
-        t = sextw(t);
-        b0 += W3 * t;
-        b1 -= W7 * t;
-        b2 -= W1 * t;
-        b3 -= W5 * t;
-    }
-
-    
-    t = extwl(r, 2);            /* row[5] */
-    if (t) {
-        t = sextw(t);
-        b0 += W5 * t;
-        b1 -= W1 * t;
-        b2 += W7 * t;
-        b3 += W3 * t;
-    }
-
-    t = extwl(r, 6);            /* row[7] */
-    if (t) {
-        t = sextw(t);
-        b0 += W7 * t;
-        b1 -= W5 * t;
-        b2 += W3 * t;
-        b3 -= W1 * t;
-    }
-
-    row[0] = (a0 + b0) >> ROW_SHIFT;
-    row[1] = (a1 + b1) >> ROW_SHIFT;
-    row[2] = (a2 + b2) >> ROW_SHIFT;
-    row[3] = (a3 + b3) >> ROW_SHIFT;
-    row[4] = (a3 - b3) >> ROW_SHIFT;
-    row[5] = (a2 - b2) >> ROW_SHIFT;
-    row[6] = (a1 - b1) >> ROW_SHIFT;
-    row[7] = (a0 - b0) >> ROW_SHIFT;
-
-    return 2;
-}
-
-static inline void idct_col(DCTELEM *col)
-{
-    int_fast32_t a0, a1, a2, a3, b0, b1, b2, b3;
-
-    col[0] += (1 << (COL_SHIFT - 1)) / W4;
-
-    a0 = W4 * col[8 * 0];
-    a1 = W4 * col[8 * 0];
-    a2 = W4 * col[8 * 0];
-    a3 = W4 * col[8 * 0];
-
-    if (col[8 * 2]) {
-        a0 += W2 * col[8 * 2];
-        a1 += W6 * col[8 * 2];
-        a2 -= W6 * col[8 * 2];
-        a3 -= W2 * col[8 * 2];
-    }
-
-    if (col[8 * 4]) {
-        a0 += W4 * col[8 * 4];
-        a1 -= W4 * col[8 * 4];
-        a2 -= W4 * col[8 * 4];
-        a3 += W4 * col[8 * 4];
-    }
-
-    if (col[8 * 6]) {
-        a0 += W6 * col[8 * 6];
-        a1 -= W2 * col[8 * 6];
-        a2 += W2 * col[8 * 6];
-        a3 -= W6 * col[8 * 6];
-    }
-
-    if (col[8 * 1]) {
-        b0 = W1 * col[8 * 1];
-        b1 = W3 * col[8 * 1];
-        b2 = W5 * col[8 * 1];
-        b3 = W7 * col[8 * 1];
-    } else {
-        b0 = 0;
-        b1 = 0;
-        b2 = 0;
-        b3 = 0;
-    }
-
-    if (col[8 * 3]) {
-        b0 += W3 * col[8 * 3];
-        b1 -= W7 * col[8 * 3];
-        b2 -= W1 * col[8 * 3];
-        b3 -= W5 * col[8 * 3];
-    }
-
-    if (col[8 * 5]) {
-        b0 += W5 * col[8 * 5];
-        b1 -= W1 * col[8 * 5];
-        b2 += W7 * col[8 * 5];
-        b3 += W3 * col[8 * 5];
-    }
-
-    if (col[8 * 7]) {
-        b0 += W7 * col[8 * 7];
-        b1 -= W5 * col[8 * 7];
-        b2 += W3 * col[8 * 7];
-        b3 -= W1 * col[8 * 7];
-    }
-
-    col[8 * 0] = (a0 + b0) >> COL_SHIFT;
-    col[8 * 7] = (a0 - b0) >> COL_SHIFT;
-    col[8 * 1] = (a1 + b1) >> COL_SHIFT;
-    col[8 * 6] = (a1 - b1) >> COL_SHIFT;
-    col[8 * 2] = (a2 + b2) >> COL_SHIFT;
-    col[8 * 5] = (a2 - b2) >> COL_SHIFT;
-    col[8 * 3] = (a3 + b3) >> COL_SHIFT;
-    col[8 * 4] = (a3 - b3) >> COL_SHIFT;
-}
-
-/* If all rows but the first one are zero after row transformation,
-   all rows will be identical after column transformation.  */
-static inline void idct_col2(DCTELEM *col)
-{
-    int i;
-    uint64_t l, r;
-
-    for (i = 0; i < 8; ++i) {
-        int_fast32_t a0 = col[i] + (1 << (COL_SHIFT - 1)) / W4;
-
-        a0 *= W4;
-        col[i] = a0 >> COL_SHIFT;
-    }
-
-    l = ldq(col + 0 * 4); r = ldq(col + 1 * 4);
-    stq(l, col +  2 * 4); stq(r, col +  3 * 4);
-    stq(l, col +  4 * 4); stq(r, col +  5 * 4);
-    stq(l, col +  6 * 4); stq(r, col +  7 * 4);
-    stq(l, col +  8 * 4); stq(r, col +  9 * 4);
-    stq(l, col + 10 * 4); stq(r, col + 11 * 4);
-    stq(l, col + 12 * 4); stq(r, col + 13 * 4);
-    stq(l, col + 14 * 4); stq(r, col + 15 * 4);
-}
-
-void simple_idct_axp(DCTELEM *block)
-{
-
-    int i;
-    int rowsZero = 1;           /* all rows except row 0 zero */
-    int rowsConstant = 1;       /* all rows consist of a constant value */
-
-    for (i = 0; i < 8; i++) {
-        int sparseness = idct_row(block + 8 * i);
-
-        if (i > 0 && sparseness > 0)
-            rowsZero = 0;
-        if (sparseness == 2)
-            rowsConstant = 0;
-    }
-
-    if (rowsZero) {
-        idct_col2(block);
-    } else if (rowsConstant) {
-        idct_col(block);
-        for (i = 0; i < 8; i += 2) {
-            uint64_t v = (uint16_t) block[0];
-            uint64_t w = (uint16_t) block[8];
-
-            v |= v << 16;
-            w |= w << 16;
-            v |= v << 32;
-            w |= w << 32;
-            stq(v, block + 0 * 4);
-            stq(v, block + 1 * 4);
-            stq(w, block + 2 * 4);
-            stq(w, block + 3 * 4);
-	    block += 4 * 4;
-        }
-    } else {
-        for (i = 0; i < 8; i++)
-            idct_col(block + i);
-    }
-}
-
-void simple_idct_put_axp(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    simple_idct_axp(block);
-    put_pixels_clamped_axp_p(block, dest, line_size);
-}
-
-void simple_idct_add_axp(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    simple_idct_axp(block);
-    add_pixels_clamped_axp_p(block, dest, line_size);
-}
diff --git a/ffmpeg.src/libavcodec/armv4l/dsputil_arm.c b/ffmpeg.src/libavcodec/armv4l/dsputil_arm.c
deleted file mode 100644
index 0195c3c..0000000
--- a/ffmpeg.src/libavcodec/armv4l/dsputil_arm.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * ARMv4L optimized DSP utils
- * Copyright (c) 2001 Lionel Ulmer.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "../dsputil.h"
-#ifdef HAVE_IPP
-#include "ipp.h"
-#endif
-
-extern void dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx);
-
-extern void j_rev_dct_ARM(DCTELEM *data);
-extern void simple_idct_ARM(DCTELEM *data);
-
-/* XXX: local hack */
-static void (*ff_put_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
-static void (*ff_add_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
-
-void put_pixels8_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-void put_pixels8_x2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-void put_pixels8_y2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-void put_pixels8_xy2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-
-void put_no_rnd_pixels8_x2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-void put_no_rnd_pixels8_y2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-void put_no_rnd_pixels8_xy2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-
-void put_pixels16_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-
-CALL_2X_PIXELS(put_pixels16_x2_arm , put_pixels8_x2_arm , 8)
-CALL_2X_PIXELS(put_pixels16_y2_arm , put_pixels8_y2_arm , 8)
-CALL_2X_PIXELS(put_pixels16_xy2_arm, put_pixels8_xy2_arm, 8)
-CALL_2X_PIXELS(put_no_rnd_pixels16_x2_arm , put_no_rnd_pixels8_x2_arm , 8)
-CALL_2X_PIXELS(put_no_rnd_pixels16_y2_arm , put_no_rnd_pixels8_y2_arm , 8)
-CALL_2X_PIXELS(put_no_rnd_pixels16_xy2_arm, put_no_rnd_pixels8_xy2_arm, 8)
-
-static void add_pixels_clamped_ARM(short *block, unsigned char *dest, int line_size)
-{
-    asm volatile (
-                  "mov r10, #8 \n\t"
-
-                  "1: \n\t"
-
-                  /* load dest */
-                  "ldr r4, [%1] \n\t"
-                  /* block[0] and block[1]*/
-                  "ldrsh r5, [%0] \n\t"
-                  "ldrsh r7, [%0, #2] \n\t"
-                  "and r6, r4, #0xFF \n\t"
-                  "and r8, r4, #0xFF00 \n\t"
-                  "add r6, r5, r6 \n\t"
-                  "add r8, r7, r8, lsr #8 \n\t"
-                  "mvn r5, r5 \n\t"
-                  "mvn r7, r7 \n\t"
-                  "tst r6, #0x100 \n\t"
-                  "movne r6, r5, lsr #24 \n\t"
-                  "tst r8, #0x100 \n\t"
-                  "movne r8, r7, lsr #24 \n\t"
-                  "mov r9, r6 \n\t"
-                  "ldrsh r5, [%0, #4] \n\t" /* moved form [A] */
-                  "orr r9, r9, r8, lsl #8 \n\t"
-                  /* block[2] and block[3] */
-                  /* [A] */
-                  "ldrsh r7, [%0, #6] \n\t"
-                  "and r6, r4, #0xFF0000 \n\t"
-                  "and r8, r4, #0xFF000000 \n\t"
-                  "add r6, r5, r6, lsr #16 \n\t"
-                  "add r8, r7, r8, lsr #24 \n\t"
-                  "mvn r5, r5 \n\t"
-                  "mvn r7, r7 \n\t"
-                  "tst r6, #0x100 \n\t"
-                  "movne r6, r5, lsr #24 \n\t"
-                  "tst r8, #0x100 \n\t"
-                  "movne r8, r7, lsr #24 \n\t"
-                  "orr r9, r9, r6, lsl #16 \n\t"
-                  "ldr r4, [%1, #4] \n\t"       /* moved form [B] */
-                  "orr r9, r9, r8, lsl #24 \n\t"
-                  /* store dest */
-                  "ldrsh r5, [%0, #8] \n\t" /* moved form [C] */
-                  "str r9, [%1] \n\t"
-
-                  /* load dest */
-                  /* [B] */
-                  /* block[4] and block[5] */
-                  /* [C] */
-                  "ldrsh r7, [%0, #10] \n\t"
-                  "and r6, r4, #0xFF \n\t"
-                  "and r8, r4, #0xFF00 \n\t"
-                  "add r6, r5, r6 \n\t"
-                  "add r8, r7, r8, lsr #8 \n\t"
-                  "mvn r5, r5 \n\t"
-                  "mvn r7, r7 \n\t"
-                  "tst r6, #0x100 \n\t"
-                  "movne r6, r5, lsr #24 \n\t"
-                  "tst r8, #0x100 \n\t"
-                  "movne r8, r7, lsr #24 \n\t"
-                  "mov r9, r6 \n\t"
-                  "ldrsh r5, [%0, #12] \n\t" /* moved from [D] */
-                  "orr r9, r9, r8, lsl #8 \n\t"
-                  /* block[6] and block[7] */
-                  /* [D] */
-                  "ldrsh r7, [%0, #14] \n\t"
-                  "and r6, r4, #0xFF0000 \n\t"
-                  "and r8, r4, #0xFF000000 \n\t"
-                  "add r6, r5, r6, lsr #16 \n\t"
-                  "add r8, r7, r8, lsr #24 \n\t"
-                  "mvn r5, r5 \n\t"
-                  "mvn r7, r7 \n\t"
-                  "tst r6, #0x100 \n\t"
-                  "movne r6, r5, lsr #24 \n\t"
-                  "tst r8, #0x100 \n\t"
-                  "movne r8, r7, lsr #24 \n\t"
-                  "orr r9, r9, r6, lsl #16 \n\t"
-                  "add %0, %0, #16 \n\t" /* moved from [E] */
-                  "orr r9, r9, r8, lsl #24 \n\t"
-                  "subs r10, r10, #1 \n\t" /* moved from [F] */
-                  /* store dest */
-                  "str r9, [%1, #4] \n\t"
-
-                  /* [E] */
-                  /* [F] */
-                  "add %1, %1, %2 \n\t"
-                  "bne 1b \n\t"
-                  : "+r"(block),
-                    "+r"(dest)
-                  : "r"(line_size)
-                  : "r4", "r5", "r6", "r7", "r8", "r9", "r10", "cc", "memory" );
-}
-
-/* XXX: those functions should be suppressed ASAP when all IDCTs are
-   converted */
-static void j_rev_dct_ARM_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    j_rev_dct_ARM (block);
-    ff_put_pixels_clamped(block, dest, line_size);
-}
-static void j_rev_dct_ARM_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    j_rev_dct_ARM (block);
-    ff_add_pixels_clamped(block, dest, line_size);
-}
-static void simple_idct_ARM_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    simple_idct_ARM (block);
-    ff_put_pixels_clamped(block, dest, line_size);
-}
-static void simple_idct_ARM_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    simple_idct_ARM (block);
-    ff_add_pixels_clamped(block, dest, line_size);
-}
-static void simple_idct_ipp(DCTELEM *block)
-{
-#ifdef HAVE_IPP
-    ippiDCT8x8Inv_Video_16s_C1I(block);
-#endif
-}
-static void simple_idct_ipp_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-#ifdef HAVE_IPP
-    ippiDCT8x8Inv_Video_16s8u_C1R(block, dest, line_size);
-#endif
-}
-
-void add_pixels_clamped_iwmmxt(const DCTELEM *block, uint8_t *pixels, int line_size);
-
-static void simple_idct_ipp_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-#ifdef HAVE_IPP
-    ippiDCT8x8Inv_Video_16s_C1I(block);
-#ifdef HAVE_IWMMXT
-    add_pixels_clamped_iwmmxt(block, dest, line_size);
-#else
-    add_pixels_clamped_ARM(block, dest, line_size);
-#endif
-#endif
-}
-
-void dsputil_init_armv4l(DSPContext* c, AVCodecContext *avctx)
-{
-    const int idct_algo= avctx->idct_algo;
-
-    ff_put_pixels_clamped = c->put_pixels_clamped;
-    ff_add_pixels_clamped = c->add_pixels_clamped;
-
-#ifdef HAVE_IPP
-    if(idct_algo==FF_IDCT_ARM){
-#else
-    if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_ARM){
-#endif
-        c->idct_put= j_rev_dct_ARM_put;
-        c->idct_add= j_rev_dct_ARM_add;
-	c->idct    = j_rev_dct_ARM;
-        c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;/* FF_NO_IDCT_PERM */
-    } else if (idct_algo==FF_IDCT_SIMPLEARM){
-	c->idct_put= simple_idct_ARM_put;
-	c->idct_add= simple_idct_ARM_add;
-	c->idct    = simple_idct_ARM;
-	c->idct_permutation_type= FF_NO_IDCT_PERM;
-#ifdef HAVE_IPP
-    } else if (idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_IPP){
-#else
-    } else if (idct_algo==FF_IDCT_IPP){
-#endif
-        c->idct_put= simple_idct_ipp_put;
-        c->idct_add= simple_idct_ipp_add;
-        c->idct    = simple_idct_ipp;
-        c->idct_permutation_type= FF_NO_IDCT_PERM;
-    }
-
-/*     c->put_pixels_tab[0][0] = put_pixels16_arm; */ // NG!
-    c->put_pixels_tab[0][1] = put_pixels16_x2_arm; //OK!
-    c->put_pixels_tab[0][2] = put_pixels16_y2_arm; //OK!
-/*     c->put_pixels_tab[0][3] = put_pixels16_xy2_arm; /\* NG *\/ */
-/*     c->put_no_rnd_pixels_tab[0][0] = put_pixels16_arm; // ?(»È¤ï¤ì¤Ê¤¤) */
-    c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_arm; // OK
-    c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_arm; //OK
-/*     c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_arm; //NG */
-    c->put_pixels_tab[1][0] = put_pixels8_arm; //OK
-    c->put_pixels_tab[1][1] = put_pixels8_x2_arm; //OK
-/*     c->put_pixels_tab[1][2] = put_pixels8_y2_arm; //NG */
-/*     c->put_pixels_tab[1][3] = put_pixels8_xy2_arm; //NG */
-    c->put_no_rnd_pixels_tab[1][0] = put_pixels8_arm;//OK
-    c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_arm; //OK
-    c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_arm; //OK
-/*     c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels8_xy2_arm;//NG */
-
-#ifdef HAVE_IWMMXT
-    dsputil_init_iwmmxt(c, avctx);
-#endif
-}
diff --git a/ffmpeg.src/libavcodec/armv4l/dsputil_arm_s.S b/ffmpeg.src/libavcodec/armv4l/dsputil_arm_s.S
deleted file mode 100644
index 827110b..0000000
--- a/ffmpeg.src/libavcodec/armv4l/dsputil_arm_s.S
+++ /dev/null
@@ -1,694 +0,0 @@
-@
-@ ARMv4L optimized DSP utils
-@ Copyright (c) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
-@
-@ This library 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 of the License, or (at your option) any later version.
-@
-@ This library 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 this library; if not, write to the Free Software
-@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-@
-
-.macro  ADJ_ALIGN_QUADWORD_D shift, Rd0, Rd1, Rd2, Rd3, Rn0, Rn1, Rn2, Rn3, Rn4
-        mov \Rd0, \Rn0, lsr #(\shift * 8)
-        mov \Rd1, \Rn1, lsr #(\shift * 8)
-        mov \Rd2, \Rn2, lsr #(\shift * 8)
-        mov \Rd3, \Rn3, lsr #(\shift * 8)
-        orr \Rd0, \Rd0, \Rn1, lsl #(32 - \shift * 8)
-        orr \Rd1, \Rd1, \Rn2, lsl #(32 - \shift * 8)
-        orr \Rd2, \Rd2, \Rn3, lsl #(32 - \shift * 8)
-        orr \Rd3, \Rd3, \Rn4, lsl #(32 - \shift * 8)
-.endm
-.macro  ADJ_ALIGN_DOUBLEWORD shift, R0, R1, R2
-        mov \R0, \R0, lsr #(\shift * 8)
-        orr \R0, \R0, \R1, lsl #(32 - \shift * 8)
-        mov \R1, \R1, lsr #(\shift * 8)
-        orr \R1, \R1, \R2, lsl #(32 - \shift * 8)
-.endm
-.macro  ADJ_ALIGN_DOUBLEWORD_D shift, Rdst0, Rdst1, Rsrc0, Rsrc1, Rsrc2
-        mov \Rdst0, \Rsrc0, lsr #(\shift * 8)
-        mov \Rdst1, \Rsrc1, lsr #(\shift * 8)
-        orr \Rdst0, \Rdst0, \Rsrc1, lsl #(32 - (\shift * 8))
-        orr \Rdst1, \Rdst1, \Rsrc2, lsl #(32 - (\shift * 8))
-.endm
-
-.macro  RND_AVG32 Rd0, Rd1, Rn0, Rn1, Rm0, Rm1, Rmask
-        @ Rd = (Rn | Rm) - (((Rn ^ Rm) & ~0x01010101) >> 1)
-        @ Rmask = 0xFEFEFEFE
-        @ Rn = destroy
-        eor \Rd0, \Rn0, \Rm0
-        eor \Rd1, \Rn1, \Rm1
-        orr \Rn0, \Rn0, \Rm0
-        orr \Rn1, \Rn1, \Rm1
-        and \Rd0, \Rd0, \Rmask
-        and \Rd1, \Rd1, \Rmask
-        sub \Rd0, \Rn0, \Rd0, lsr #1
-        sub \Rd1, \Rn1, \Rd1, lsr #1
-.endm
-
-.macro  NO_RND_AVG32 Rd0, Rd1, Rn0, Rn1, Rm0, Rm1, Rmask
-        @ Rd = (Rn & Rm) - (((Rn ^ Rm) & ~0x01010101) >> 1)
-        @ Rmask = 0xFEFEFEFE
-        @ Rn = destroy
-        eor \Rd0, \Rn0, \Rm0
-        eor \Rd1, \Rn1, \Rm1
-        and \Rn0, \Rn0, \Rm0
-        and \Rn1, \Rn1, \Rm1
-        and \Rd0, \Rd0, \Rmask
-        and \Rd1, \Rd1, \Rmask
-        add \Rd0, \Rn0, \Rd0, lsr #1
-        add \Rd1, \Rn1, \Rd1, lsr #1
-.endm
-
-@ ----------------------------------------------------------------
-        .align 8
-        .global put_pixels16_arm
-put_pixels16_arm:
-        @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-        @ block = word aligned, pixles = unaligned
-        pld [r1]
-        stmfd sp!, {r4-r11, lr} @ R14 is also called LR
-        adr r5, 5f
-        ands r4, r1, #3
-        bic r1, r1, #3
-        add r5, r5, r4, lsl #2
-        ldrne pc, [r5]
-1:
-        ldmia r1, {r4-r7}
-        add r1, r1, r2
-        stmia r0, {r4-r7}
-        pld [r1]
-        subs r3, r3, #1
-        add r0, r0, r2
-        bne 1b
-        ldmfd sp!, {r4-r11, pc}
-        .align 8
-2:
-        ldmia r1, {r4-r8}
-        add r1, r1, r2
-        ADJ_ALIGN_QUADWORD_D 1, r9, r10, r11, r12, r4, r5, r6, r7, r8
-        pld [r1]
-        subs r3, r3, #1
-        stmia r0, {r9-r12}
-        add r0, r0, r2
-        bne 2b
-        ldmfd sp!, {r4-r11, pc}
-        .align 8
-3:
-        ldmia r1, {r4-r8}
-        add r1, r1, r2
-        ADJ_ALIGN_QUADWORD_D 2, r9, r10, r11, r12, r4, r5, r6, r7, r8
-        pld [r1]
-        subs r3, r3, #1
-        stmia r0, {r9-r12}
-        add r0, r0, r2
-        bne 3b
-        ldmfd sp!, {r4-r11, pc}
-        .align 8
-4:
-        ldmia r1, {r4-r8}
-        add r1, r1, r2
-        ADJ_ALIGN_QUADWORD_D 3, r9, r10, r11, r12, r4, r5, r6, r7, r8
-        pld [r1]
-        subs r3, r3, #1
-        stmia r0, {r9-r12}
-        add r0, r0, r2
-        bne 4b
-        ldmfd sp!, {r4-r11,pc}
-        .align 8
-5:
-        .word 1b
-        .word 2b
-        .word 3b
-        .word 4b
-
-@ ----------------------------------------------------------------
-        .align 8
-        .global put_pixels8_arm
-put_pixels8_arm:
-        @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-        @ block = word aligned, pixles = unaligned
-        pld [r1]
-        stmfd sp!, {r4-r5,lr} @ R14 is also called LR
-        adr r5, 5f
-        ands r4, r1, #3
-        bic r1, r1, #3
-        add r5, r5, r4, lsl #2
-        ldrne pc, [r5]
-1:
-        ldmia r1, {r4-r5}
-        add r1, r1, r2
-        subs r3, r3, #1
-        pld [r1]
-        stmia r0, {r4-r5}
-        add r0, r0, r2
-        bne 1b
-        ldmfd sp!, {r4-r5,pc}
-        .align 8
-2:
-        ldmia r1, {r4-r5, r12}
-        add r1, r1, r2
-        ADJ_ALIGN_DOUBLEWORD 1, r4, r5, r12
-        pld [r1]
-        subs r3, r3, #1
-        stmia r0, {r4-r5}
-        add r0, r0, r2
-        bne 2b
-        ldmfd sp!, {r4-r5,pc}
-        .align 8
-3:
-        ldmia r1, {r4-r5, r12}
-        add r1, r1, r2
-        ADJ_ALIGN_DOUBLEWORD 2, r4, r5, r12
-        pld [r1]
-        subs r3, r3, #1
-        stmia r0, {r4-r5}
-        add r0, r0, r2
-        bne 3b
-        ldmfd sp!, {r4-r5,pc}
-        .align 8
-4:
-        ldmia r1, {r4-r5, r12}
-        add r1, r1, r2
-        ADJ_ALIGN_DOUBLEWORD 3, r4, r5, r12
-        pld [r1]
-        subs r3, r3, #1
-        stmia r0, {r4-r5}
-        add r0, r0, r2
-        bne 4b
-        ldmfd sp!, {r4-r5,pc}
-        .align 8
-5:
-        .word 1b
-        .word 2b
-        .word 3b
-        .word 4b
-
-@ ----------------------------------------------------------------
-        .align 8
-        .global put_pixels8_x2_arm
-put_pixels8_x2_arm:
-        @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-        @ block = word aligned, pixles = unaligned
-        pld [r1]
-        stmfd sp!, {r4-r10,lr} @ R14 is also called LR
-        adr r5, 5f
-        ands r4, r1, #3
-        ldr r12, [r5]
-        add r5, r5, r4, lsl #2
-        bic r1, r1, #3
-        ldrne pc, [r5]
-1:
-        ldmia r1, {r4-r5, r10}
-        add r1, r1, r2
-        ADJ_ALIGN_DOUBLEWORD_D 1, r6, r7, r4, r5, r10
-        pld [r1]
-        RND_AVG32 r8, r9, r4, r5, r6, r7, r12
-        subs r3, r3, #1
-        stmia r0, {r8-r9}
-        add r0, r0, r2
-        bne 1b
-        ldmfd sp!, {r4-r10,pc}
-        .align 8
-2:
-        ldmia r1, {r4-r5, r10}
-        add r1, r1, r2
-        ADJ_ALIGN_DOUBLEWORD_D 1, r6, r7, r4, r5, r10
-        ADJ_ALIGN_DOUBLEWORD_D 2, r8, r9, r4, r5, r10
-        pld [r1]
-        RND_AVG32 r4, r5, r6, r7, r8, r9, r12
-        subs r3, r3, #1
-        stmia r0, {r4-r5}
-        add r0, r0, r2
-        bne 2b
-        ldmfd sp!, {r4-r10,pc}
-        .align 8
-3:
-        ldmia r1, {r4-r5, r10}
-        add r1, r1, r2
-        ADJ_ALIGN_DOUBLEWORD_D 2, r6, r7, r4, r5, r10
-        ADJ_ALIGN_DOUBLEWORD_D 3, r8, r9, r4, r5, r10
-        pld [r1]
-        RND_AVG32 r4, r5, r6, r7, r8, r9, r12
-        subs r3, r3, #1
-        stmia r0, {r4-r5}
-        add r0, r0, r2
-        bne 3b
-        ldmfd sp!, {r4-r10,pc}
-        .align 8
-4:
-        ldmia r1, {r4-r5, r10}
-        add r1, r1, r2
-        ADJ_ALIGN_DOUBLEWORD_D 3, r6, r7, r4, r5, r10
-        pld [r1]
-        RND_AVG32 r8, r9, r6, r7, r5, r10, r12
-        subs r3, r3, #1
-        stmia r0, {r8-r9}
-        add r0, r0, r2
-        bne 4b
-        ldmfd sp!, {r4-r10,pc} @@ update PC with LR content.
-        .align 8
-5:
-        .word 0xFEFEFEFE
-        .word 2b
-        .word 3b
-        .word 4b
-
-        .align 8
-        .global put_no_rnd_pixels8_x2_arm
-put_no_rnd_pixels8_x2_arm:
-        @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-        @ block = word aligned, pixles = unaligned
-        pld [r1]
-        stmfd sp!, {r4-r10,lr} @ R14 is also called LR
-        adr r5, 5f
-        ands r4, r1, #3
-        ldr r12, [r5]
-        add r5, r5, r4, lsl #2
-        bic r1, r1, #3
-        ldrne pc, [r5]
-1:
-        ldmia r1, {r4-r5, r10}
-        add r1, r1, r2
-        ADJ_ALIGN_DOUBLEWORD_D 1, r6, r7, r4, r5, r10
-        pld [r1]
-        NO_RND_AVG32 r8, r9, r4, r5, r6, r7, r12
-        subs r3, r3, #1
-        stmia r0, {r8-r9}
-        add r0, r0, r2
-        bne 1b
-        ldmfd sp!, {r4-r10,pc}
-        .align 8
-2:
-        ldmia r1, {r4-r5, r10}
-        add r1, r1, r2
-        ADJ_ALIGN_DOUBLEWORD_D 1, r6, r7, r4, r5, r10
-        ADJ_ALIGN_DOUBLEWORD_D 2, r8, r9, r4, r5, r10
-        pld [r1]
-        NO_RND_AVG32 r4, r5, r6, r7, r8, r9, r12
-        subs r3, r3, #1
-        stmia r0, {r4-r5}
-        add r0, r0, r2
-        bne 2b
-        ldmfd sp!, {r4-r10,pc}
-        .align 8
-3:
-        ldmia r1, {r4-r5, r10}
-        add r1, r1, r2
-        ADJ_ALIGN_DOUBLEWORD_D 2, r6, r7, r4, r5, r10
-        ADJ_ALIGN_DOUBLEWORD_D 3, r8, r9, r4, r5, r10
-        pld [r1]
-        NO_RND_AVG32 r4, r5, r6, r7, r8, r9, r12
-        subs r3, r3, #1
-        stmia r0, {r4-r5}
-        add r0, r0, r2
-        bne 3b
-        ldmfd sp!, {r4-r10,pc}
-        .align 8
-4:
-        ldmia r1, {r4-r5, r10}
-        add r1, r1, r2
-        ADJ_ALIGN_DOUBLEWORD_D 3, r6, r7, r4, r5, r10
-        pld [r1]
-        NO_RND_AVG32 r8, r9, r6, r7, r5, r10, r12
-        subs r3, r3, #1
-        stmia r0, {r8-r9}
-        add r0, r0, r2
-        bne 4b
-        ldmfd sp!, {r4-r10,pc} @@ update PC with LR content.
-        .align 8
-5:
-        .word 0xFEFEFEFE
-        .word 2b
-        .word 3b
-        .word 4b
-
-
-@ ----------------------------------------------------------------
-        .align 8
-        .global put_pixels8_y2_arm
-put_pixels8_y2_arm:
-        @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-        @ block = word aligned, pixles = unaligned
-        pld [r1]
-        stmfd sp!, {r4-r11,lr} @ R14 is also called LR
-        adr r5, 5f
-        ands r4, r1, #3
-        mov r3, r3, lsr #1
-        ldr r12, [r5]
-        add r5, r5, r4, lsl #2
-        bic r1, r1, #3
-        ldrne pc, [r5]
-1:
-        ldmia r1, {r4-r5}
-        add r1, r1, r2
-6:      ldmia r1, {r6-r7}
-        add r1, r1, r2
-        pld [r1]
-        RND_AVG32 r8, r9, r4, r5, r6, r7, r12
-        ldmia r1, {r4-r5}
-        add r1, r1, r2
-        stmia r0, {r8-r9}
-        add r0, r0, r2
-        pld [r1]
-        RND_AVG32 r8, r9, r6, r7, r4, r5, r12
-        subs r3, r3, #1
-        stmia r0, {r8-r9}
-        add r0, r0, r2
-        bne 6b
-        ldmfd sp!, {r4-r11,pc}
-        .align 8
-2:
-        ldmia r1, {r4-r6}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 1, r4, r5, r6
-6:      ldmia r1, {r7-r9}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 1, r7, r8, r9
-        RND_AVG32 r10, r11, r4, r5, r7, r8, r12
-        stmia r0, {r10-r11}
-        add r0, r0, r2
-        ldmia r1, {r4-r6}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 1, r4, r5, r6
-        subs r3, r3, #1
-        RND_AVG32 r10, r11, r7, r8, r4, r5, r12
-        stmia r0, {r10-r11}
-        add r0, r0, r2
-        bne 6b
-        ldmfd sp!, {r4-r11,pc}
-        .align 8
-3:
-        ldmia r1, {r4-r6}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 2, r4, r5, r6
-6:      ldmia r1, {r7-r9}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 2, r7, r8, r9
-        RND_AVG32 r10, r11, r4, r5, r7, r8, r12
-        stmia r0, {r10-r11}
-        add r0, r0, r2
-        ldmia r1, {r4-r6}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 2, r4, r5, r6
-        subs r3, r3, #1
-        RND_AVG32 r10, r11, r7, r8, r4, r5, r12
-        stmia r0, {r10-r11}
-        add r0, r0, r2
-        bne 6b
-        ldmfd sp!, {r4-r11,pc}
-        .align 8
-4:
-        ldmia r1, {r4-r6}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 3, r4, r5, r6
-6:      ldmia r1, {r7-r9}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 3, r7, r8, r9
-        RND_AVG32 r10, r11, r4, r5, r7, r8, r12
-        stmia r0, {r10-r11}
-        add r0, r0, r2
-        ldmia r1, {r4-r6}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 3, r4, r5, r6
-        subs r3, r3, #1
-        RND_AVG32 r10, r11, r7, r8, r4, r5, r12
-        stmia r0, {r10-r11}
-        add r0, r0, r2
-        bne 6b
-        ldmfd sp!, {r4-r11,pc}
-
-        .align 8
-5:
-        .word 0xFEFEFEFE
-        .word 2b
-        .word 3b
-        .word 4b
-
-        .align 8
-        .global put_no_rnd_pixels8_y2_arm
-put_no_rnd_pixels8_y2_arm:
-        @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-        @ block = word aligned, pixles = unaligned
-        pld [r1]
-        stmfd sp!, {r4-r11,lr} @ R14 is also called LR
-        adr r5, 5f
-        ands r4, r1, #3
-        mov r3, r3, lsr #1
-        ldr r12, [r5]
-        add r5, r5, r4, lsl #2
-        bic r1, r1, #3
-        ldrne pc, [r5]
-1:
-        ldmia r1, {r4-r5}
-        add r1, r1, r2
-6:      ldmia r1, {r6-r7}
-        add r1, r1, r2
-        pld [r1]
-        NO_RND_AVG32 r8, r9, r4, r5, r6, r7, r12
-        ldmia r1, {r4-r5}
-        add r1, r1, r2
-        stmia r0, {r8-r9}
-        add r0, r0, r2
-        pld [r1]
-        NO_RND_AVG32 r8, r9, r6, r7, r4, r5, r12
-        subs r3, r3, #1
-        stmia r0, {r8-r9}
-        add r0, r0, r2
-        bne 6b
-        ldmfd sp!, {r4-r11,pc}
-        .align 8
-2:
-        ldmia r1, {r4-r6}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 1, r4, r5, r6
-6:      ldmia r1, {r7-r9}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 1, r7, r8, r9
-        NO_RND_AVG32 r10, r11, r4, r5, r7, r8, r12
-        stmia r0, {r10-r11}
-        add r0, r0, r2
-        ldmia r1, {r4-r6}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 1, r4, r5, r6
-        subs r3, r3, #1
-        NO_RND_AVG32 r10, r11, r7, r8, r4, r5, r12
-        stmia r0, {r10-r11}
-        add r0, r0, r2
-        bne 6b
-        ldmfd sp!, {r4-r11,pc}
-        .align 8
-3:
-        ldmia r1, {r4-r6}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 2, r4, r5, r6
-6:      ldmia r1, {r7-r9}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 2, r7, r8, r9
-        NO_RND_AVG32 r10, r11, r4, r5, r7, r8, r12
-        stmia r0, {r10-r11}
-        add r0, r0, r2
-        ldmia r1, {r4-r6}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 2, r4, r5, r6
-        subs r3, r3, #1
-        NO_RND_AVG32 r10, r11, r7, r8, r4, r5, r12
-        stmia r0, {r10-r11}
-        add r0, r0, r2
-        bne 6b
-        ldmfd sp!, {r4-r11,pc}
-        .align 8
-4:
-        ldmia r1, {r4-r6}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 3, r4, r5, r6
-6:      ldmia r1, {r7-r9}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 3, r7, r8, r9
-        NO_RND_AVG32 r10, r11, r4, r5, r7, r8, r12
-        stmia r0, {r10-r11}
-        add r0, r0, r2
-        ldmia r1, {r4-r6}
-        add r1, r1, r2
-        pld [r1]
-        ADJ_ALIGN_DOUBLEWORD 3, r4, r5, r6
-        subs r3, r3, #1
-        NO_RND_AVG32 r10, r11, r7, r8, r4, r5, r12
-        stmia r0, {r10-r11}
-        add r0, r0, r2
-        bne 6b
-        ldmfd sp!, {r4-r11,pc}
-        .align 8
-5:
-        .word 0xFEFEFEFE
-        .word 2b
-        .word 3b
-        .word 4b
-
-@ ----------------------------------------------------------------
-.macro  RND_XY2_IT align, rnd
-        @ l1=  (a & 0x03030303) + (b & 0x03030303) ?(+ 0x02020202)
-        @ h1= ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2)
-.if \align == 0
-        ldmia r1, {r6-r8}
-.elseif \align == 3
-        ldmia r1, {r5-r7}
-.else
-        ldmia r1, {r8-r10}
-.endif
-        add r1, r1, r2
-        pld [r1]
-.if \align == 0
-        ADJ_ALIGN_DOUBLEWORD_D 1, r4, r5, r6, r7, r8
-.elseif \align == 1
-        ADJ_ALIGN_DOUBLEWORD_D 1, r4, r5, r8, r9, r10
-        ADJ_ALIGN_DOUBLEWORD_D 2, r6, r7, r8, r9, r10
-.elseif \align == 2
-        ADJ_ALIGN_DOUBLEWORD_D 2, r4, r5, r8, r9, r10
-        ADJ_ALIGN_DOUBLEWORD_D 3, r6, r7, r8, r9, r10
-.elseif \align == 3
-        ADJ_ALIGN_DOUBLEWORD_D 3, r4, r5, r5, r6, r7
-.endif
-        ldr r14, [r12, #0]      @ 0x03030303
-        tst r3, #1
-        and r8, r4, r14
-        and r9, r5, r14
-        and r10, r6, r14
-        and r11, r7, r14
-.if \rnd == 1
-        ldreq r14, [r12, #16]   @ 0x02020202
-.else
-        ldreq r14, [r12, #28]   @ 0x01010101
-.endif
-        add r8, r8, r10
-        add r9, r9, r11
-        addeq r8, r8, r14
-        addeq r9, r9, r14
-        ldr r14, [r12, #20]     @ 0xFCFCFCFC >> 2
-        and r4, r14, r4, lsr #2
-        and r5, r14, r5, lsr #2
-        and r6, r14, r6, lsr #2
-        and r7, r14, r7, lsr #2
-        add r10, r4, r6
-        add r11, r5, r7
-.endm
-
-.macro RND_XY2_EXPAND align, rnd
-        RND_XY2_IT \align, \rnd
-6:      stmfd sp!, {r8-r11}
-        RND_XY2_IT \align, \rnd
-        ldmfd sp!, {r4-r7}
-        add r4, r4, r8
-        add r5, r5, r9
-        add r6, r6, r10
-        add r7, r7, r11
-        ldr r14, [r12, #24]     @ 0x0F0F0F0F
-        and r4, r14, r4, lsr #2
-        and r5, r14, r5, lsr #2
-        add r4, r4, r6
-        add r5, r5, r7
-        subs r3, r3, #1
-        stmia r0, {r4-r5}
-        add r0, r0, r2
-        bne 6b
-        ldmfd sp!, {r4-r11,pc}
-.endm
-
-        .align 8
-        .global put_pixels8_xy2_arm
-put_pixels8_xy2_arm:
-        @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-        @ block = word aligned, pixles = unaligned
-        pld [r1]
-        stmfd sp!, {r4-r11,lr} @ R14 is also called LR
-        adrl r12, 5f
-        ands r4, r1, #3
-        add r5, r12, r4, lsl #2
-        bic r1, r1, #3
-        ldrne pc, [r5]
-1:
-        RND_XY2_EXPAND 0, 1
-
-        .align 8
-2:
-        RND_XY2_EXPAND 1, 1
-        
-        .align 8
-3:
-        RND_XY2_EXPAND 2, 1
-        
-        .align 8
-4:
-        RND_XY2_EXPAND 3, 1
-        
-5:
-        .word 0x03030303
-        .word 2b
-        .word 3b
-        .word 4b
-        .word 0x02020202
-        .word 0xFCFCFCFC >> 2
-        .word 0x0F0F0F0F
-        .word 0x01010101
-
-        .align 8
-        .global put_no_rnd_pixels8_xy2_arm
-put_no_rnd_pixels8_xy2_arm:
-        @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-        @ block = word aligned, pixles = unaligned
-        pld [r1]
-        stmfd sp!, {r4-r11,lr} @ R14 is also called LR
-        adrl r12, 5f
-        ands r4, r1, #3
-        add r5, r12, r4, lsl #2
-        bic r1, r1, #3
-        ldrne pc, [r5]
-1:
-        RND_XY2_EXPAND 0, 0
-
-        .align 8
-2:
-        RND_XY2_EXPAND 1, 0
-        
-        .align 8
-3:
-        RND_XY2_EXPAND 2, 0
-        
-        .align 8
-4:
-        RND_XY2_EXPAND 3, 0
-        
-5:
-        .word 0x03030303
-        .word 2b
-        .word 3b
-        .word 4b
-        .word 0x02020202
-        .word 0xFCFCFCFC >> 2
-        .word 0x0F0F0F0F
-        .word 0x01010101
diff --git a/ffmpeg.src/libavcodec/armv4l/dsputil_iwmmxt.c b/ffmpeg.src/libavcodec/armv4l/dsputil_iwmmxt.c
deleted file mode 100644
index 99a55e7..0000000
--- a/ffmpeg.src/libavcodec/armv4l/dsputil_iwmmxt.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * iWMMXt optimized DSP utils
- * Copyright (c) 2004 AGAWA Koji
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "../dsputil.h"
-
-#define DEF(x, y) x ## _no_rnd_ ## y ##_iwmmxt
-#define SET_RND(regd)  __asm__ __volatile__ ("mov r12, #1 \n\t tbcsth " #regd ", r12":::"r12");
-#define WAVG2B "wavg2b"
-#include "dsputil_iwmmxt_rnd.h"
-#undef DEF
-#undef SET_RND
-#undef WAVG2B
-
-#define DEF(x, y) x ## _ ## y ##_iwmmxt
-#define SET_RND(regd)  __asm__ __volatile__ ("mov r12, #2 \n\t tbcsth " #regd ", r12":::"r12");
-#define WAVG2B "wavg2br"
-#include "dsputil_iwmmxt_rnd.h"
-#undef DEF
-#undef SET_RND
-#undef WAVG2BR
-
-// need scheduling
-#define OP(AVG)                                         \
-    asm volatile (                                      \
-        /* alignment */                                 \
-        "and r12, %[pixels], #7 \n\t"                   \
-        "bic %[pixels], %[pixels], #7 \n\t"             \
-        "tmcr wcgr1, r12 \n\t"                          \
-                                                        \
-        "wldrd wr0, [%[pixels]] \n\t"                   \
-        "wldrd wr1, [%[pixels], #8] \n\t"               \
-        "add %[pixels], %[pixels], %[line_size] \n\t"   \
-        "walignr1 wr4, wr0, wr1 \n\t"                   \
-                                                        \
-        "1: \n\t"                                       \
-                                                        \
-        "wldrd wr2, [%[pixels]] \n\t"                   \
-        "wldrd wr3, [%[pixels], #8] \n\t"               \
-        "add %[pixels], %[pixels], %[line_size] \n\t"   \
-        "pld [%[pixels]] \n\t"                          \
-        "walignr1 wr5, wr2, wr3 \n\t"                   \
-        AVG " wr6, wr4, wr5 \n\t"                       \
-        "wstrd wr6, [%[block]] \n\t"                    \
-        "add %[block], %[block], %[line_size] \n\t"     \
-                                                        \
-        "wldrd wr0, [%[pixels]] \n\t"                   \
-        "wldrd wr1, [%[pixels], #8] \n\t"               \
-        "add %[pixels], %[pixels], %[line_size] \n\t"   \
-        "walignr1 wr4, wr0, wr1 \n\t"                   \
-        "pld [%[pixels]] \n\t"                          \
-        AVG " wr6, wr4, wr5 \n\t"                       \
-        "wstrd wr6, [%[block]] \n\t"                    \
-        "add %[block], %[block], %[line_size] \n\t"     \
-                                                        \
-        "subs %[h], %[h], #2 \n\t"                      \
-        "bne 1b \n\t"                                   \
-        : [block]"+r"(block), [pixels]"+r"(pixels), [h]"+r"(h)  \
-        : [line_size]"r"(line_size) \
-        : "memory", "r12");
-void put_pixels8_y2_iwmmxt(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    OP("wavg2br");
-}
-void put_no_rnd_pixels8_y2_iwmmxt(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    OP("wavg2b");
-}
-#undef OP
-
-void add_pixels_clamped_iwmmxt(const DCTELEM *block, uint8_t *pixels, int line_size)
-{
-    uint8_t *pixels2 = pixels + line_size;
-
-    __asm__ __volatile__ (
-        "mov            r12, #4                 \n\t"
-        "1:                                     \n\t"
-        "pld            [%[pixels], %[line_size2]]              \n\t"
-        "pld            [%[pixels2], %[line_size2]]             \n\t"
-        "wldrd          wr4, [%[pixels]]        \n\t"
-        "wldrd          wr5, [%[pixels2]]       \n\t"
-        "pld            [%[block], #32]         \n\t"
-        "wunpckelub     wr6, wr4                \n\t"
-        "wldrd          wr0, [%[block]]         \n\t"
-        "wunpckehub     wr7, wr4                \n\t"
-        "wldrd          wr1, [%[block], #8]     \n\t"
-        "wunpckelub     wr8, wr5                \n\t"
-        "wldrd          wr2, [%[block], #16]    \n\t"
-        "wunpckehub     wr9, wr5                \n\t"
-        "wldrd          wr3, [%[block], #24]    \n\t"
-        "add            %[block], %[block], #32 \n\t"
-        "waddhss        wr10, wr0, wr6          \n\t"
-        "waddhss        wr11, wr1, wr7          \n\t"
-        "waddhss        wr12, wr2, wr8          \n\t"
-        "waddhss        wr13, wr3, wr9          \n\t"
-        "wpackhus       wr14, wr10, wr11        \n\t"
-        "wpackhus       wr15, wr12, wr13        \n\t"
-        "wstrd          wr14, [%[pixels]]       \n\t"
-        "add            %[pixels], %[pixels], %[line_size2]     \n\t"
-        "subs           r12, r12, #1            \n\t"
-        "wstrd          wr15, [%[pixels2]]      \n\t"
-        "add            %[pixels2], %[pixels2], %[line_size2]   \n\t"
-        "bne            1b                      \n\t"
-        : [block]"+r"(block), [pixels]"+r"(pixels), [pixels2]"+r"(pixels2)
-        : [line_size2]"r"(line_size << 1)
-        : "cc", "memory", "r12");
-}
-
-static void nop(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    return;
-}
-
-int mm_flags; /* multimedia extension flags */
-
-int mm_support(void)
-{
-    return 0; /* TODO, implement proper detection */
-}
-
-void dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx)
-{
-    mm_flags = mm_support();
-
-    if (avctx->dsp_mask) {
-	if (avctx->dsp_mask & FF_MM_FORCE)
-	    mm_flags |= (avctx->dsp_mask & 0xffff);
-	else
-	    mm_flags &= ~(avctx->dsp_mask & 0xffff);
-    }
-
-    if (!(mm_flags & MM_IWMMXT)) return;
-
-    c->add_pixels_clamped = add_pixels_clamped_iwmmxt;
-
-    c->put_pixels_tab[0][0] = put_pixels16_iwmmxt;
-    c->put_pixels_tab[0][1] = put_pixels16_x2_iwmmxt;
-    c->put_pixels_tab[0][2] = put_pixels16_y2_iwmmxt;
-    c->put_pixels_tab[0][3] = put_pixels16_xy2_iwmmxt;
-    c->put_no_rnd_pixels_tab[0][0] = put_pixels16_iwmmxt;
-    c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_iwmmxt;
-    c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_iwmmxt;
-    c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_iwmmxt;
-
-    c->put_pixels_tab[1][0] = put_pixels8_iwmmxt;
-    c->put_pixels_tab[1][1] = put_pixels8_x2_iwmmxt;
-    c->put_pixels_tab[1][2] = put_pixels8_y2_iwmmxt;
-    c->put_pixels_tab[1][3] = put_pixels8_xy2_iwmmxt;
-    c->put_no_rnd_pixels_tab[1][0] = put_pixels8_iwmmxt;
-    c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_iwmmxt;
-    c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_iwmmxt;
-    c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels8_xy2_iwmmxt;
-
-    c->avg_pixels_tab[0][0] = avg_pixels16_iwmmxt;
-    c->avg_pixels_tab[0][1] = avg_pixels16_x2_iwmmxt;
-    c->avg_pixels_tab[0][2] = avg_pixels16_y2_iwmmxt;
-    c->avg_pixels_tab[0][3] = avg_pixels16_xy2_iwmmxt;
-    c->avg_no_rnd_pixels_tab[0][0] = avg_pixels16_iwmmxt;
-    c->avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_iwmmxt;
-    c->avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_iwmmxt;
-    c->avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_iwmmxt;
-
-    c->avg_pixels_tab[1][0] = avg_pixels8_iwmmxt;
-    c->avg_pixels_tab[1][1] = avg_pixels8_x2_iwmmxt;
-    c->avg_pixels_tab[1][2] = avg_pixels8_y2_iwmmxt;
-    c->avg_pixels_tab[1][3] = avg_pixels8_xy2_iwmmxt;
-    c->avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels8_iwmmxt;
-    c->avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels8_x2_iwmmxt;
-    c->avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels8_y2_iwmmxt;
-    c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels8_xy2_iwmmxt;
-}
diff --git a/ffmpeg.src/libavcodec/armv4l/dsputil_iwmmxt_rnd.h b/ffmpeg.src/libavcodec/armv4l/dsputil_iwmmxt_rnd.h
deleted file mode 100644
index ca49a76..0000000
--- a/ffmpeg.src/libavcodec/armv4l/dsputil_iwmmxt_rnd.h
+++ /dev/null
@@ -1,1093 +0,0 @@
-void DEF(put, pixels8)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    int stride = line_size;
-    __asm__ __volatile__ (
-        "and r12, %[pixels], #7 \n\t"
-        "bic %[pixels], %[pixels], #7 \n\t"
-        "tmcr wcgr1, r12 \n\t"
-        "add r4, %[pixels], %[line_size] \n\t"
-        "add r5, %[block], %[line_size] \n\t"
-        "mov %[line_size], %[line_size], lsl #1 \n\t"
-        "1: \n\t"
-        "wldrd wr0, [%[pixels]] \n\t"
-        "subs %[h], %[h], #2 \n\t"
-        "wldrd wr1, [%[pixels], #8] \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "wldrd wr3, [r4] \n\t"
-        "pld [%[pixels]] \n\t"
-        "pld [%[pixels], #32] \n\t"
-        "wldrd wr4, [r4, #8] \n\t"
-        "add r4, r4, %[line_size] \n\t"
-        "walignr1 wr8, wr0, wr1 \n\t"
-        "pld [r4] \n\t"
-        "pld [r4, #32] \n\t"
-        "walignr1 wr10, wr3, wr4 \n\t"
-        "wstrd wr8, [%[block]] \n\t"
-        "add %[block], %[block], %[line_size] \n\t"
-        "wstrd wr10, [r5] \n\t"
-        "add r5, r5, %[line_size] \n\t"
-        "bne 1b \n\t"
-        : [block]"+r"(block), [pixels]"+r"(pixels), [line_size]"+r"(stride), [h]"+r"(h)
-        :
-        : "memory", "r4", "r5", "r12");
-}
-
-void DEF(avg, pixels8)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    int stride = line_size;
-    __asm__ __volatile__ (
-        "and r12, %[pixels], #7 \n\t"
-        "bic %[pixels], %[pixels], #7 \n\t"
-        "tmcr wcgr1, r12 \n\t"
-        "add r4, %[pixels], %[line_size] \n\t"
-        "add r5, %[block], %[line_size] \n\t"
-        "mov %[line_size], %[line_size], lsl #1 \n\t"
-        "1: \n\t"
-        "wldrd wr0, [%[pixels]] \n\t"
-        "subs %[h], %[h], #2 \n\t"
-        "wldrd wr1, [%[pixels], #8] \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "wldrd wr3, [r4] \n\t"
-        "pld [%[pixels]] \n\t"
-        "pld [%[pixels], #32] \n\t"
-        "wldrd wr4, [r4, #8] \n\t"
-        "add r4, r4, %[line_size] \n\t"
-        "walignr1 wr8, wr0, wr1 \n\t"
-        "wldrd wr0, [%[block]] \n\t"
-        "wldrd wr2, [r5] \n\t"
-        "pld [r4] \n\t"
-        "pld [r4, #32] \n\t"
-        "walignr1 wr10, wr3, wr4 \n\t"
-        WAVG2B" wr8, wr8, wr0 \n\t"
-        WAVG2B" wr10, wr10, wr2 \n\t"
-        "wstrd wr8, [%[block]] \n\t"
-        "add %[block], %[block], %[line_size] \n\t"
-        "wstrd wr10, [r5] \n\t"
-        "pld [%[block]] \n\t"
-        "pld [%[block], #32] \n\t"
-        "add r5, r5, %[line_size] \n\t"
-        "pld [r5] \n\t"
-        "pld [r5, #32] \n\t"
-        "bne 1b \n\t"
-        : [block]"+r"(block), [pixels]"+r"(pixels), [line_size]"+r"(stride), [h]"+r"(h)
-        :
-        : "memory", "r4", "r5", "r12");
-}
-
-void DEF(put, pixels16)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    int stride = line_size;
-    __asm__ __volatile__ (
-        "and r12, %[pixels], #7 \n\t"
-        "bic %[pixels], %[pixels], #7 \n\t"
-        "tmcr wcgr1, r12 \n\t"
-        "add r4, %[pixels], %[line_size] \n\t"
-        "add r5, %[block], %[line_size] \n\t"
-        "mov %[line_size], %[line_size], lsl #1 \n\t"
-        "1: \n\t"
-        "wldrd wr0, [%[pixels]] \n\t"
-        "wldrd wr1, [%[pixels], #8] \n\t"
-        "subs %[h], %[h], #2 \n\t"
-        "wldrd wr2, [%[pixels], #16] \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "wldrd wr3, [r4] \n\t"
-        "pld [%[pixels]] \n\t"
-        "pld [%[pixels], #32] \n\t"
-        "walignr1 wr8, wr0, wr1 \n\t"
-        "wldrd wr4, [r4, #8] \n\t"
-        "walignr1 wr9, wr1, wr2 \n\t"
-        "wldrd wr5, [r4, #16] \n\t"
-        "add r4, r4, %[line_size] \n\t"
-        "pld [r4] \n\t"
-        "pld [r4, #32] \n\t"
-        "walignr1 wr10, wr3, wr4 \n\t"
-        "wstrd wr8, [%[block]] \n\t"
-        "walignr1 wr11, wr4, wr5 \n\t"
-        "wstrd wr9, [%[block], #8] \n\t"
-        "add %[block], %[block], %[line_size] \n\t"
-        "wstrd wr10, [r5] \n\t"
-        "wstrd wr11, [r5, #8] \n\t"
-        "add r5, r5, %[line_size] \n\t"
-        "bne 1b \n\t"
-        : [block]"+r"(block), [pixels]"+r"(pixels), [line_size]"+r"(stride), [h]"+r"(h)
-        :
-        : "memory", "r4", "r5", "r12");
-}
-
-void DEF(avg, pixels16)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    int stride = line_size;
-    __asm__ __volatile__ (
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "pld [%[block]]                 \n\t"
-        "pld [%[block], #32]            \n\t"
-        "and r12, %[pixels], #7         \n\t"
-        "bic %[pixels], %[pixels], #7   \n\t"
-        "tmcr wcgr1, r12                \n\t"
-        "add r4, %[pixels], %[line_size]\n\t"
-        "add r5, %[block], %[line_size] \n\t"
-        "mov %[line_size], %[line_size], lsl #1 \n\t"
-        "1:                             \n\t"
-        "wldrd wr0, [%[pixels]]         \n\t"
-        "wldrd wr1, [%[pixels], #8]     \n\t"
-        "subs %[h], %[h], #2            \n\t"
-        "wldrd wr2, [%[pixels], #16]    \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "wldrd wr3, [r4]                \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr8, wr0, wr1         \n\t"
-        "wldrd wr4, [r4, #8]            \n\t"
-        "walignr1 wr9, wr1, wr2         \n\t"
-        "wldrd wr5, [r4, #16]           \n\t"
-        "add r4, r4, %[line_size]       \n\t"
-        "wldrd wr0, [%[block]]          \n\t"
-        "pld [r4]                       \n\t"
-        "wldrd wr1, [%[block], #8]      \n\t"
-        "pld [r4, #32]                  \n\t"
-        "wldrd wr2, [r5]                \n\t"
-        "walignr1 wr10, wr3, wr4        \n\t"
-        "wldrd wr3, [r5, #8]            \n\t"
-        WAVG2B" wr8, wr8, wr0           \n\t"
-        WAVG2B" wr9, wr9, wr1           \n\t"
-        WAVG2B" wr10, wr10, wr2         \n\t"
-        "wstrd wr8, [%[block]]          \n\t"
-        "walignr1 wr11, wr4, wr5        \n\t"
-        WAVG2B" wr11, wr11, wr3         \n\t"
-        "wstrd wr9, [%[block], #8]      \n\t"
-        "add %[block], %[block], %[line_size] \n\t"
-        "wstrd wr10, [r5]               \n\t"
-        "pld [%[block]]                 \n\t"
-        "pld [%[block], #32]            \n\t"
-        "wstrd wr11, [r5, #8]           \n\t"
-        "add r5, r5, %[line_size]       \n\t"
-        "pld [r5]                       \n\t"
-        "pld [r5, #32]                  \n\t"
-        "bne 1b \n\t"
-        : [block]"+r"(block), [pixels]"+r"(pixels), [line_size]"+r"(stride), [h]"+r"(h)
-        :
-        : "memory", "r4", "r5", "r12");
-}
-
-void DEF(put, pixels8_x2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    int stride = line_size;
-    // [wr0 wr1 wr2 wr3] for previous line
-    // [wr4 wr5 wr6 wr7] for current line
-    SET_RND(wr15); // =2 for rnd  and  =1 for no_rnd version
-    __asm__ __volatile__(
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "and r12, %[pixels], #7         \n\t"
-        "bic %[pixels], %[pixels], #7   \n\t"
-        "tmcr wcgr1, r12                \n\t"
-        "add r12, r12, #1               \n\t"
-        "add r4, %[pixels], %[line_size]\n\t"
-        "tmcr wcgr2, r12                \n\t"
-        "add r5, %[block], %[line_size] \n\t"
-        "mov %[line_size], %[line_size], lsl #1 \n\t"
-
-        "1:                             \n\t"
-        "wldrd wr10, [%[pixels]]        \n\t"
-        "cmp r12, #8                    \n\t"
-        "wldrd wr11, [%[pixels], #8]    \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "wldrd wr13, [r4]               \n\t"
-        "pld [%[pixels]]                \n\t"
-        "wldrd wr14, [r4, #8]           \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "add r4, r4, %[line_size]       \n\t"
-        "walignr1 wr0, wr10, wr11       \n\t"
-        "pld [r4]                       \n\t"
-        "pld [r4, #32]                  \n\t"
-        "walignr1 wr2, wr13, wr14       \n\t"
-        "wmoveq wr4, wr11               \n\t"
-        "wmoveq wr6, wr14               \n\t"
-        "walignr2ne wr4, wr10, wr11     \n\t"
-        "walignr2ne wr6, wr13, wr14     \n\t"
-        WAVG2B" wr0, wr0, wr4           \n\t"
-        WAVG2B" wr2, wr2, wr6           \n\t"
-        "wstrd wr0, [%[block]]          \n\t"
-        "subs %[h], %[h], #2            \n\t"
-        "wstrd wr2, [r5]                \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-        "add r5, r5, %[line_size]       \n\t"
-        "bne 1b                         \n\t"
-        : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride)
-        :
-        : "r4", "r5", "r12", "memory");
-}
-
-void DEF(put, pixels16_x2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    int stride = line_size;
-    // [wr0 wr1 wr2 wr3] for previous line
-    // [wr4 wr5 wr6 wr7] for current line
-    SET_RND(wr15); // =2 for rnd  and  =1 for no_rnd version
-    __asm__ __volatile__(
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "and r12, %[pixels], #7         \n\t"
-        "bic %[pixels], %[pixels], #7   \n\t"
-        "tmcr wcgr1, r12                \n\t"
-        "add r12, r12, #1               \n\t"
-        "add r4, %[pixels], %[line_size]\n\t"
-        "tmcr wcgr2, r12                \n\t"
-        "add r5, %[block], %[line_size] \n\t"
-        "mov %[line_size], %[line_size], lsl #1 \n\t"
-
-        "1:                             \n\t"
-        "wldrd wr10, [%[pixels]]        \n\t"
-        "cmp r12, #8                    \n\t"
-        "wldrd wr11, [%[pixels], #8]    \n\t"
-        "wldrd wr12, [%[pixels], #16]   \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "wldrd wr13, [r4]               \n\t"
-        "pld [%[pixels]]                \n\t"
-        "wldrd wr14, [r4, #8]           \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "wldrd wr15, [r4, #16]          \n\t"
-        "add r4, r4, %[line_size]       \n\t"
-        "walignr1 wr0, wr10, wr11       \n\t"
-        "pld [r4]                       \n\t"
-        "pld [r4, #32]                  \n\t"
-        "walignr1 wr1, wr11, wr12       \n\t"
-        "walignr1 wr2, wr13, wr14       \n\t"
-        "walignr1 wr3, wr14, wr15       \n\t"
-        "wmoveq wr4, wr11               \n\t"
-        "wmoveq wr5, wr12               \n\t"
-        "wmoveq wr6, wr14               \n\t"
-        "wmoveq wr7, wr15               \n\t"
-        "walignr2ne wr4, wr10, wr11     \n\t"
-        "walignr2ne wr5, wr11, wr12     \n\t"
-        "walignr2ne wr6, wr13, wr14     \n\t"
-        "walignr2ne wr7, wr14, wr15     \n\t"
-        WAVG2B" wr0, wr0, wr4           \n\t"
-        WAVG2B" wr1, wr1, wr5           \n\t"
-        "wstrd wr0, [%[block]]          \n\t"
-        WAVG2B" wr2, wr2, wr6           \n\t"
-        "wstrd wr1, [%[block], #8]      \n\t"
-        WAVG2B" wr3, wr3, wr7           \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-        "wstrd wr2, [r5]                \n\t"
-        "subs %[h], %[h], #2            \n\t"
-        "wstrd wr3, [r5, #8]            \n\t"
-        "add r5, r5, %[line_size]       \n\t"
-        "bne 1b                         \n\t"
-        : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride)
-        :
-        : "r4", "r5", "r12", "memory");
-}
-
-void DEF(avg, pixels8_x2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    int stride = line_size;
-    // [wr0 wr1 wr2 wr3] for previous line
-    // [wr4 wr5 wr6 wr7] for current line
-    SET_RND(wr15); // =2 for rnd  and  =1 for no_rnd version
-    __asm__ __volatile__(
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "pld [%[block]]                 \n\t"
-        "pld [%[block], #32]            \n\t"
-        "and r12, %[pixels], #7         \n\t"
-        "bic %[pixels], %[pixels], #7   \n\t"
-        "tmcr wcgr1, r12                \n\t"
-        "add r12, r12, #1               \n\t"
-        "add r4, %[pixels], %[line_size]\n\t"
-        "tmcr wcgr2, r12                \n\t"
-        "add r5, %[block], %[line_size] \n\t"
-        "mov %[line_size], %[line_size], lsl #1 \n\t"
-        "pld [r5]                       \n\t"
-        "pld [r5, #32]                  \n\t"
-
-        "1:                             \n\t"
-        "wldrd wr10, [%[pixels]]        \n\t"
-        "cmp r12, #8                    \n\t"
-        "wldrd wr11, [%[pixels], #8]    \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "wldrd wr13, [r4]               \n\t"
-        "pld [%[pixels]]                \n\t"
-        "wldrd wr14, [r4, #8]           \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "add r4, r4, %[line_size]       \n\t"
-        "walignr1 wr0, wr10, wr11       \n\t"
-        "pld [r4]                       \n\t"
-        "pld [r4, #32]                  \n\t"
-        "walignr1 wr2, wr13, wr14       \n\t"
-        "wmoveq wr4, wr11               \n\t"
-        "wmoveq wr6, wr14               \n\t"
-        "walignr2ne wr4, wr10, wr11     \n\t"
-        "wldrd wr10, [%[block]]         \n\t"
-        "walignr2ne wr6, wr13, wr14     \n\t"
-        "wldrd wr12, [r5]               \n\t"
-        WAVG2B" wr0, wr0, wr4           \n\t"
-        WAVG2B" wr2, wr2, wr6           \n\t"
-        WAVG2B" wr0, wr0, wr10          \n\t"
-        WAVG2B" wr2, wr2, wr12          \n\t"
-        "wstrd wr0, [%[block]]          \n\t"
-        "subs %[h], %[h], #2            \n\t"
-        "wstrd wr2, [r5]                \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-        "add r5, r5, %[line_size]       \n\t"
-        "pld [%[block]]                 \n\t"
-        "pld [%[block], #32]            \n\t"
-        "pld [r5]                       \n\t"
-        "pld [r5, #32]                  \n\t"
-        "bne 1b                         \n\t"
-        : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride)
-        :
-        : "r4", "r5", "r12", "memory");
-}
-
-void DEF(avg, pixels16_x2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    int stride = line_size;
-    // [wr0 wr1 wr2 wr3] for previous line
-    // [wr4 wr5 wr6 wr7] for current line
-    SET_RND(wr15); // =2 for rnd  and  =1 for no_rnd version
-    __asm__ __volatile__(
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "pld [%[block]]                 \n\t"
-        "pld [%[block], #32]            \n\t"
-        "and r12, %[pixels], #7         \n\t"
-        "bic %[pixels], %[pixels], #7   \n\t"
-        "tmcr wcgr1, r12                \n\t"
-        "add r12, r12, #1               \n\t"
-        "add r4, %[pixels], %[line_size]\n\t"
-        "tmcr wcgr2, r12                \n\t"
-        "add r5, %[block], %[line_size] \n\t"
-        "mov %[line_size], %[line_size], lsl #1 \n\t"
-        "pld [r5]                       \n\t"
-        "pld [r5, #32]                  \n\t"
-
-        "1:                             \n\t"
-        "wldrd wr10, [%[pixels]]        \n\t"
-        "cmp r12, #8                    \n\t"
-        "wldrd wr11, [%[pixels], #8]    \n\t"
-        "wldrd wr12, [%[pixels], #16]   \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "wldrd wr13, [r4]               \n\t"
-        "pld [%[pixels]]                \n\t"
-        "wldrd wr14, [r4, #8]           \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "wldrd wr15, [r4, #16]          \n\t"
-        "add r4, r4, %[line_size]       \n\t"
-        "walignr1 wr0, wr10, wr11       \n\t"
-        "pld [r4]                       \n\t"
-        "pld [r4, #32]                  \n\t"
-        "walignr1 wr1, wr11, wr12       \n\t"
-        "walignr1 wr2, wr13, wr14       \n\t"
-        "walignr1 wr3, wr14, wr15       \n\t"
-        "wmoveq wr4, wr11               \n\t"
-        "wmoveq wr5, wr12               \n\t"
-        "wmoveq wr6, wr14               \n\t"
-        "wmoveq wr7, wr15               \n\t"
-        "walignr2ne wr4, wr10, wr11     \n\t"
-        "walignr2ne wr5, wr11, wr12     \n\t"
-        "walignr2ne wr6, wr13, wr14     \n\t"
-        "walignr2ne wr7, wr14, wr15     \n\t"
-        "wldrd wr10, [%[block]]         \n\t"
-        WAVG2B" wr0, wr0, wr4           \n\t"
-        "wldrd wr11, [%[block], #8]     \n\t"
-        WAVG2B" wr1, wr1, wr5           \n\t"
-        "wldrd wr12, [r5]               \n\t"
-        WAVG2B" wr2, wr2, wr6           \n\t"
-        "wldrd wr13, [r5, #8]           \n\t"
-        WAVG2B" wr3, wr3, wr7           \n\t"
-        WAVG2B" wr0, wr0, wr10          \n\t"
-        WAVG2B" wr1, wr1, wr11          \n\t"
-        WAVG2B" wr2, wr2, wr12          \n\t"
-        WAVG2B" wr3, wr3, wr13          \n\t"
-        "wstrd wr0, [%[block]]          \n\t"
-        "subs %[h], %[h], #2            \n\t"
-        "wstrd wr1, [%[block], #8]      \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-        "wstrd wr2, [r5]                \n\t"
-        "pld [%[block]]                 \n\t"
-        "wstrd wr3, [r5, #8]            \n\t"
-        "add r5, r5, %[line_size]       \n\t"
-        "pld [%[block], #32]            \n\t"
-        "pld [r5]                       \n\t"
-        "pld [r5, #32]                  \n\t"
-        "bne 1b                         \n\t"
-        : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride)
-        :
-        :"r4", "r5", "r12", "memory");
-}
-
-void DEF(avg, pixels8_y2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    int stride = line_size;
-    // [wr0 wr1 wr2 wr3] for previous line
-    // [wr4 wr5 wr6 wr7] for current line
-    __asm__ __volatile__(
-        "pld            [%[pixels]]                             \n\t"
-        "pld            [%[pixels], #32]                        \n\t"
-        "and            r12, %[pixels], #7                      \n\t"
-        "tmcr           wcgr1, r12                              \n\t"
-        "bic            %[pixels], %[pixels], #7                \n\t"
-
-        "wldrd          wr10, [%[pixels]]                       \n\t"
-        "wldrd          wr11, [%[pixels], #8]                   \n\t"
-        "pld            [%[block]]                              \n\t"
-        "add            %[pixels], %[pixels], %[line_size]      \n\t"
-        "walignr1       wr0, wr10, wr11                         \n\t"
-        "pld            [%[pixels]]                             \n\t"
-        "pld            [%[pixels], #32]                        \n\t"
-
-      "1:                                                       \n\t"
-        "wldrd          wr10, [%[pixels]]                       \n\t"
-        "wldrd          wr11, [%[pixels], #8]                   \n\t"
-        "add            %[pixels], %[pixels], %[line_size]      \n\t"
-        "pld            [%[pixels]]                             \n\t"
-        "pld            [%[pixels], #32]                        \n\t"
-        "walignr1       wr4, wr10, wr11                         \n\t"
-        "wldrd          wr10, [%[block]]                        \n\t"
-         WAVG2B"        wr8, wr0, wr4                           \n\t"
-         WAVG2B"        wr8, wr8, wr10                          \n\t"
-        "wstrd          wr8, [%[block]]                         \n\t"
-        "add            %[block], %[block], %[line_size]        \n\t"
-
-        "wldrd          wr10, [%[pixels]]                       \n\t"
-        "wldrd          wr11, [%[pixels], #8]                   \n\t"
-        "pld            [%[block]]                              \n\t"
-        "add            %[pixels], %[pixels], %[line_size]      \n\t"
-        "pld            [%[pixels]]                             \n\t"
-        "pld            [%[pixels], #32]                        \n\t"
-        "walignr1       wr0, wr10, wr11                         \n\t"
-        "wldrd          wr10, [%[block]]                        \n\t"
-         WAVG2B"        wr8, wr0, wr4                           \n\t"
-         WAVG2B"        wr8, wr8, wr10                          \n\t"
-        "wstrd          wr8, [%[block]]                         \n\t"
-        "add            %[block], %[block], %[line_size]        \n\t"
-
-        "subs           %[h], %[h], #2                          \n\t"
-        "pld            [%[block]]                              \n\t"
-        "bne            1b                                      \n\t"
-        : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride)
-        :
-        : "cc", "memory", "r12");
-}
-
-void DEF(put, pixels16_y2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    int stride = line_size;
-    // [wr0 wr1 wr2 wr3] for previous line
-    // [wr4 wr5 wr6 wr7] for current line
-    __asm__ __volatile__(
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "and r12, %[pixels], #7         \n\t"
-        "tmcr wcgr1, r12                \n\t"
-        "bic %[pixels], %[pixels], #7   \n\t"
-
-        "wldrd wr10, [%[pixels]]        \n\t"
-        "wldrd wr11, [%[pixels], #8]    \n\t"
-        "wldrd wr12, [%[pixels], #16]   \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr0, wr10, wr11       \n\t"
-        "walignr1 wr1, wr11, wr12       \n\t"
-
-        "1:                             \n\t"
-        "wldrd wr10, [%[pixels]]        \n\t"
-        "wldrd wr11, [%[pixels], #8]    \n\t"
-        "wldrd wr12, [%[pixels], #16]   \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr4, wr10, wr11       \n\t"
-        "walignr1 wr5, wr11, wr12       \n\t"
-        WAVG2B" wr8, wr0, wr4           \n\t"
-        WAVG2B" wr9, wr1, wr5           \n\t"
-        "wstrd wr8, [%[block]]          \n\t"
-        "wstrd wr9, [%[block], #8]      \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-
-        "wldrd wr10, [%[pixels]]        \n\t"
-        "wldrd wr11, [%[pixels], #8]    \n\t"
-        "wldrd wr12, [%[pixels], #16]   \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr0, wr10, wr11       \n\t"
-        "walignr1 wr1, wr11, wr12       \n\t"
-        WAVG2B" wr8, wr0, wr4           \n\t"
-        WAVG2B" wr9, wr1, wr5           \n\t"
-        "wstrd wr8, [%[block]]          \n\t"
-        "wstrd wr9, [%[block], #8]      \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-
-        "subs %[h], %[h], #2            \n\t"
-        "bne 1b                         \n\t"
-        : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride)
-        :
-        : "r4", "r5", "r12", "memory");
-}
-
-void DEF(avg, pixels16_y2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    int stride = line_size;
-    // [wr0 wr1 wr2 wr3] for previous line
-    // [wr4 wr5 wr6 wr7] for current line
-    __asm__ __volatile__(
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "and r12, %[pixels], #7         \n\t"
-        "tmcr wcgr1, r12                \n\t"
-        "bic %[pixels], %[pixels], #7   \n\t"
-
-        "wldrd wr10, [%[pixels]]        \n\t"
-        "wldrd wr11, [%[pixels], #8]    \n\t"
-        "pld [%[block]]                 \n\t"
-        "wldrd wr12, [%[pixels], #16]   \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr0, wr10, wr11       \n\t"
-        "walignr1 wr1, wr11, wr12       \n\t"
-
-        "1:                             \n\t"
-        "wldrd wr10, [%[pixels]]        \n\t"
-        "wldrd wr11, [%[pixels], #8]    \n\t"
-        "wldrd wr12, [%[pixels], #16]   \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr4, wr10, wr11       \n\t"
-        "walignr1 wr5, wr11, wr12       \n\t"
-        "wldrd wr10, [%[block]]         \n\t"
-        "wldrd wr11, [%[block], #8]     \n\t"
-        WAVG2B" wr8, wr0, wr4           \n\t"
-        WAVG2B" wr9, wr1, wr5           \n\t"
-        WAVG2B" wr8, wr8, wr10          \n\t"
-        WAVG2B" wr9, wr9, wr11          \n\t"
-        "wstrd wr8, [%[block]]          \n\t"
-        "wstrd wr9, [%[block], #8]      \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-
-        "wldrd wr10, [%[pixels]]        \n\t"
-        "wldrd wr11, [%[pixels], #8]    \n\t"
-        "pld [%[block]]                 \n\t"
-        "wldrd wr12, [%[pixels], #16]   \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr0, wr10, wr11       \n\t"
-        "walignr1 wr1, wr11, wr12       \n\t"
-        "wldrd wr10, [%[block]]         \n\t"
-        "wldrd wr11, [%[block], #8]     \n\t"
-        WAVG2B" wr8, wr0, wr4           \n\t"
-        WAVG2B" wr9, wr1, wr5           \n\t"
-        WAVG2B" wr8, wr8, wr10          \n\t"
-        WAVG2B" wr9, wr9, wr11          \n\t"
-        "wstrd wr8, [%[block]]          \n\t"
-        "wstrd wr9, [%[block], #8]      \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-
-        "subs %[h], %[h], #2            \n\t"
-        "pld [%[block]]                 \n\t"
-        "bne 1b                         \n\t"
-        : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block), [line_size]"+r"(stride)
-        :
-        : "r4", "r5", "r12", "memory");
-}
-
-void DEF(put, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    // [wr0 wr1 wr2 wr3] for previous line
-    // [wr4 wr5 wr6 wr7] for current line
-    SET_RND(wr15); // =2 for rnd  and  =1 for no_rnd version
-    __asm__ __volatile__(
-        "pld [%[pixels]]                \n\t"
-        "mov r12, #2                    \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "tmcr wcgr0, r12                \n\t" /* for shift value */
-        "and r12, %[pixels], #7         \n\t"
-        "bic %[pixels], %[pixels], #7   \n\t"
-        "tmcr wcgr1, r12                \n\t"
-
-        // [wr0 wr1 wr2 wr3] <= *
-        // [wr4 wr5 wr6 wr7]
-        "wldrd wr12, [%[pixels]]        \n\t"
-        "add r12, r12, #1               \n\t"
-        "wldrd wr13, [%[pixels], #8]    \n\t"
-        "tmcr wcgr2, r12                \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "cmp r12, #8                    \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr2, wr12, wr13       \n\t"
-        "wmoveq wr10, wr13              \n\t"
-        "walignr2ne wr10, wr12, wr13    \n\t"
-        "wunpckelub wr0, wr2            \n\t"
-        "wunpckehub wr1, wr2            \n\t"
-        "wunpckelub wr8, wr10           \n\t"
-        "wunpckehub wr9, wr10           \n\t"
-        "waddhus wr0, wr0, wr8          \n\t"
-        "waddhus wr1, wr1, wr9          \n\t"
-
-        "1:                             \n\t"
-        // [wr0 wr1 wr2 wr3]
-        // [wr4 wr5 wr6 wr7] <= *
-        "wldrd wr12, [%[pixels]]        \n\t"
-        "cmp r12, #8                    \n\t"
-        "wldrd wr13, [%[pixels], #8]    \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "walignr1 wr6, wr12, wr13       \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "wmoveq wr10, wr13              \n\t"
-        "walignr2ne wr10, wr12, wr13    \n\t"
-        "wunpckelub wr4, wr6            \n\t"
-        "wunpckehub wr5, wr6            \n\t"
-        "wunpckelub wr8, wr10           \n\t"
-        "wunpckehub wr9, wr10           \n\t"
-        "waddhus wr4, wr4, wr8          \n\t"
-        "waddhus wr5, wr5, wr9          \n\t"
-        "waddhus wr8, wr0, wr4          \n\t"
-        "waddhus wr9, wr1, wr5          \n\t"
-        "waddhus wr8, wr8, wr15         \n\t"
-        "waddhus wr9, wr9, wr15         \n\t"
-        "wsrlhg wr8, wr8, wcgr0         \n\t"
-        "wsrlhg wr9, wr9, wcgr0         \n\t"
-        "wpackhus wr8, wr8, wr9         \n\t"
-        "wstrd wr8, [%[block]]          \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-
-        // [wr0 wr1 wr2 wr3] <= *
-        // [wr4 wr5 wr6 wr7]
-        "wldrd wr12, [%[pixels]]        \n\t"
-        "wldrd wr13, [%[pixels], #8]    \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "walignr1 wr2, wr12, wr13       \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "wmoveq wr10, wr13              \n\t"
-        "walignr2ne wr10, wr12, wr13    \n\t"
-        "wunpckelub wr0, wr2            \n\t"
-        "wunpckehub wr1, wr2            \n\t"
-        "wunpckelub wr8, wr10           \n\t"
-        "wunpckehub wr9, wr10           \n\t"
-        "waddhus wr0, wr0, wr8          \n\t"
-        "waddhus wr1, wr1, wr9          \n\t"
-        "waddhus wr8, wr0, wr4          \n\t"
-        "waddhus wr9, wr1, wr5          \n\t"
-        "waddhus wr8, wr8, wr15         \n\t"
-        "waddhus wr9, wr9, wr15         \n\t"
-        "wsrlhg wr8, wr8, wcgr0         \n\t"
-        "wsrlhg wr9, wr9, wcgr0         \n\t"
-        "wpackhus wr8, wr8, wr9         \n\t"
-        "subs %[h], %[h], #2            \n\t"
-        "wstrd wr8, [%[block]]          \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-        "bne 1b                         \n\t"
-        : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block)
-        : [line_size]"r"(line_size)
-        : "r12", "memory");
-}
-
-void DEF(put, pixels16_xy2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    // [wr0 wr1 wr2 wr3] for previous line
-    // [wr4 wr5 wr6 wr7] for current line
-    SET_RND(wr15); // =2 for rnd  and  =1 for no_rnd version
-    __asm__ __volatile__(
-        "pld [%[pixels]]                \n\t"
-        "mov r12, #2                    \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "tmcr wcgr0, r12                \n\t" /* for shift value */
-        /* alignment */
-        "and r12, %[pixels], #7         \n\t"
-        "bic %[pixels], %[pixels], #7   \n\t"
-        "tmcr wcgr1, r12                \n\t"
-        "add r12, r12, #1               \n\t"
-        "tmcr wcgr2, r12                \n\t"
-
-        // [wr0 wr1 wr2 wr3] <= *
-        // [wr4 wr5 wr6 wr7]
-        "wldrd wr12, [%[pixels]]        \n\t"
-        "cmp r12, #8                    \n\t"
-        "wldrd wr13, [%[pixels], #8]    \n\t"
-        "wldrd wr14, [%[pixels], #16]   \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "pld [%[pixels]]                \n\t"
-        "walignr1 wr2, wr12, wr13       \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr3, wr13, wr14       \n\t"
-        "wmoveq wr10, wr13              \n\t"
-        "wmoveq wr11, wr14              \n\t"
-        "walignr2ne wr10, wr12, wr13    \n\t"
-        "walignr2ne wr11, wr13, wr14    \n\t"
-        "wunpckelub wr0, wr2            \n\t"
-        "wunpckehub wr1, wr2            \n\t"
-        "wunpckelub wr2, wr3            \n\t"
-        "wunpckehub wr3, wr3            \n\t"
-        "wunpckelub wr8, wr10           \n\t"
-        "wunpckehub wr9, wr10           \n\t"
-        "wunpckelub wr10, wr11          \n\t"
-        "wunpckehub wr11, wr11          \n\t"
-        "waddhus wr0, wr0, wr8          \n\t"
-        "waddhus wr1, wr1, wr9          \n\t"
-        "waddhus wr2, wr2, wr10         \n\t"
-        "waddhus wr3, wr3, wr11         \n\t"
-
-        "1:                             \n\t"
-        // [wr0 wr1 wr2 wr3]
-        // [wr4 wr5 wr6 wr7] <= *
-        "wldrd wr12, [%[pixels]]        \n\t"
-        "cmp r12, #8                    \n\t"
-        "wldrd wr13, [%[pixels], #8]    \n\t"
-        "wldrd wr14, [%[pixels], #16]   \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "walignr1 wr6, wr12, wr13       \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr7, wr13, wr14       \n\t"
-        "wmoveq wr10, wr13              \n\t"
-        "wmoveq wr11, wr14              \n\t"
-        "walignr2ne wr10, wr12, wr13    \n\t"
-        "walignr2ne wr11, wr13, wr14    \n\t"
-        "wunpckelub wr4, wr6            \n\t"
-        "wunpckehub wr5, wr6            \n\t"
-        "wunpckelub wr6, wr7            \n\t"
-        "wunpckehub wr7, wr7            \n\t"
-        "wunpckelub wr8, wr10           \n\t"
-        "wunpckehub wr9, wr10           \n\t"
-        "wunpckelub wr10, wr11          \n\t"
-        "wunpckehub wr11, wr11          \n\t"
-        "waddhus wr4, wr4, wr8          \n\t"
-        "waddhus wr5, wr5, wr9          \n\t"
-        "waddhus wr6, wr6, wr10         \n\t"
-        "waddhus wr7, wr7, wr11         \n\t"
-        "waddhus wr8, wr0, wr4          \n\t"
-        "waddhus wr9, wr1, wr5          \n\t"
-        "waddhus wr10, wr2, wr6         \n\t"
-        "waddhus wr11, wr3, wr7         \n\t"
-        "waddhus wr8, wr8, wr15         \n\t"
-        "waddhus wr9, wr9, wr15         \n\t"
-        "waddhus wr10, wr10, wr15       \n\t"
-        "waddhus wr11, wr11, wr15       \n\t"
-        "wsrlhg wr8, wr8, wcgr0         \n\t"
-        "wsrlhg wr9, wr9, wcgr0         \n\t"
-        "wsrlhg wr10, wr10, wcgr0       \n\t"
-        "wsrlhg wr11, wr11, wcgr0       \n\t"
-        "wpackhus wr8, wr8, wr9         \n\t"
-        "wpackhus wr9, wr10, wr11       \n\t"
-        "wstrd wr8, [%[block]]          \n\t"
-        "wstrd wr9, [%[block], #8]      \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-
-        // [wr0 wr1 wr2 wr3] <= *
-        // [wr4 wr5 wr6 wr7]
-        "wldrd wr12, [%[pixels]]        \n\t"
-        "wldrd wr13, [%[pixels], #8]    \n\t"
-        "wldrd wr14, [%[pixels], #16]   \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "walignr1 wr2, wr12, wr13       \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr3, wr13, wr14       \n\t"
-        "wmoveq wr10, wr13              \n\t"
-        "wmoveq wr11, wr14              \n\t"
-        "walignr2ne wr10, wr12, wr13    \n\t"
-        "walignr2ne wr11, wr13, wr14    \n\t"
-        "wunpckelub wr0, wr2            \n\t"
-        "wunpckehub wr1, wr2            \n\t"
-        "wunpckelub wr2, wr3            \n\t"
-        "wunpckehub wr3, wr3            \n\t"
-        "wunpckelub wr8, wr10           \n\t"
-        "wunpckehub wr9, wr10           \n\t"
-        "wunpckelub wr10, wr11          \n\t"
-        "wunpckehub wr11, wr11          \n\t"
-        "waddhus wr0, wr0, wr8          \n\t"
-        "waddhus wr1, wr1, wr9          \n\t"
-        "waddhus wr2, wr2, wr10         \n\t"
-        "waddhus wr3, wr3, wr11         \n\t"
-        "waddhus wr8, wr0, wr4          \n\t"
-        "waddhus wr9, wr1, wr5          \n\t"
-        "waddhus wr10, wr2, wr6         \n\t"
-        "waddhus wr11, wr3, wr7         \n\t"
-        "waddhus wr8, wr8, wr15         \n\t"
-        "waddhus wr9, wr9, wr15         \n\t"
-        "waddhus wr10, wr10, wr15       \n\t"
-        "waddhus wr11, wr11, wr15       \n\t"
-        "wsrlhg wr8, wr8, wcgr0         \n\t"
-        "wsrlhg wr9, wr9, wcgr0         \n\t"
-        "wsrlhg wr10, wr10, wcgr0       \n\t"
-        "wsrlhg wr11, wr11, wcgr0       \n\t"
-        "wpackhus wr8, wr8, wr9         \n\t"
-        "wpackhus wr9, wr10, wr11       \n\t"
-        "wstrd wr8, [%[block]]          \n\t"
-        "wstrd wr9, [%[block], #8]      \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-
-        "subs %[h], %[h], #2            \n\t"
-        "bne 1b                         \n\t"
-        : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block)
-        : [line_size]"r"(line_size)
-        : "r12", "memory");
-}
-
-void DEF(avg, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    // [wr0 wr1 wr2 wr3] for previous line
-    // [wr4 wr5 wr6 wr7] for current line
-    SET_RND(wr15); // =2 for rnd  and  =1 for no_rnd version
-    __asm__ __volatile__(
-        "pld [%[block]]                 \n\t"
-        "pld [%[block], #32]            \n\t"
-        "pld [%[pixels]]                \n\t"
-        "mov r12, #2                    \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "tmcr wcgr0, r12                \n\t" /* for shift value */
-        "and r12, %[pixels], #7         \n\t"
-        "bic %[pixels], %[pixels], #7   \n\t"
-        "tmcr wcgr1, r12                \n\t"
-
-        // [wr0 wr1 wr2 wr3] <= *
-        // [wr4 wr5 wr6 wr7]
-        "wldrd wr12, [%[pixels]]        \n\t"
-        "add r12, r12, #1               \n\t"
-        "wldrd wr13, [%[pixels], #8]    \n\t"
-        "tmcr wcgr2, r12                \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "cmp r12, #8                    \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr2, wr12, wr13       \n\t"
-        "wmoveq wr10, wr13              \n\t"
-        "walignr2ne wr10, wr12, wr13    \n\t"
-        "wunpckelub wr0, wr2            \n\t"
-        "wunpckehub wr1, wr2            \n\t"
-        "wunpckelub wr8, wr10           \n\t"
-        "wunpckehub wr9, wr10           \n\t"
-        "waddhus wr0, wr0, wr8          \n\t"
-        "waddhus wr1, wr1, wr9          \n\t"
-
-        "1:                             \n\t"
-        // [wr0 wr1 wr2 wr3]
-        // [wr4 wr5 wr6 wr7] <= *
-        "wldrd wr12, [%[pixels]]        \n\t"
-        "cmp r12, #8                    \n\t"
-        "wldrd wr13, [%[pixels], #8]    \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "walignr1 wr6, wr12, wr13       \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "wmoveq wr10, wr13              \n\t"
-        "walignr2ne wr10, wr12, wr13    \n\t"
-        "wunpckelub wr4, wr6            \n\t"
-        "wunpckehub wr5, wr6            \n\t"
-        "wunpckelub wr8, wr10           \n\t"
-        "wunpckehub wr9, wr10           \n\t"
-        "waddhus wr4, wr4, wr8          \n\t"
-        "waddhus wr5, wr5, wr9          \n\t"
-        "waddhus wr8, wr0, wr4          \n\t"
-        "waddhus wr9, wr1, wr5          \n\t"
-        "waddhus wr8, wr8, wr15         \n\t"
-        "waddhus wr9, wr9, wr15         \n\t"
-        "wldrd wr12, [%[block]]         \n\t"
-        "wsrlhg wr8, wr8, wcgr0         \n\t"
-        "wsrlhg wr9, wr9, wcgr0         \n\t"
-        "wpackhus wr8, wr8, wr9         \n\t"
-        WAVG2B" wr8, wr8, wr12          \n\t"
-        "wstrd wr8, [%[block]]          \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-        "wldrd wr12, [%[pixels]]        \n\t"
-        "pld [%[block]]                 \n\t"
-        "pld [%[block], #32]            \n\t"
-
-        // [wr0 wr1 wr2 wr3] <= *
-        // [wr4 wr5 wr6 wr7]
-        "wldrd wr13, [%[pixels], #8]    \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "walignr1 wr2, wr12, wr13       \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "wmoveq wr10, wr13              \n\t"
-        "walignr2ne wr10, wr12, wr13    \n\t"
-        "wunpckelub wr0, wr2            \n\t"
-        "wunpckehub wr1, wr2            \n\t"
-        "wunpckelub wr8, wr10           \n\t"
-        "wunpckehub wr9, wr10           \n\t"
-        "waddhus wr0, wr0, wr8          \n\t"
-        "waddhus wr1, wr1, wr9          \n\t"
-        "waddhus wr8, wr0, wr4          \n\t"
-        "waddhus wr9, wr1, wr5          \n\t"
-        "waddhus wr8, wr8, wr15         \n\t"
-        "waddhus wr9, wr9, wr15         \n\t"
-        "wldrd wr12, [%[block]]         \n\t"
-        "wsrlhg wr8, wr8, wcgr0         \n\t"
-        "wsrlhg wr9, wr9, wcgr0         \n\t"
-        "wpackhus wr8, wr8, wr9         \n\t"
-        "subs %[h], %[h], #2            \n\t"
-        WAVG2B" wr8, wr8, wr12          \n\t"
-        "wstrd wr8, [%[block]]          \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-        "pld [%[block]]                 \n\t"
-        "pld [%[block], #32]            \n\t"
-        "bne 1b                         \n\t"
-        : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block)
-        : [line_size]"r"(line_size)
-        : "r12", "memory");
-}
-
-void DEF(avg, pixels16_xy2)(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
-{
-    // [wr0 wr1 wr2 wr3] for previous line
-    // [wr4 wr5 wr6 wr7] for current line
-    SET_RND(wr15); // =2 for rnd  and  =1 for no_rnd version
-    __asm__ __volatile__(
-        "pld [%[block]]                 \n\t"
-        "pld [%[block], #32]            \n\t"
-        "pld [%[pixels]]                \n\t"
-        "mov r12, #2                    \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "tmcr wcgr0, r12                \n\t" /* for shift value */
-        /* alignment */
-        "and r12, %[pixels], #7         \n\t"
-        "bic %[pixels], %[pixels], #7           \n\t"
-        "tmcr wcgr1, r12                \n\t"
-        "add r12, r12, #1               \n\t"
-        "tmcr wcgr2, r12                \n\t"
-
-        // [wr0 wr1 wr2 wr3] <= *
-        // [wr4 wr5 wr6 wr7]
-        "wldrd wr12, [%[pixels]]        \n\t"
-        "cmp r12, #8                    \n\t"
-        "wldrd wr13, [%[pixels], #8]    \n\t"
-        "wldrd wr14, [%[pixels], #16]   \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "pld [%[pixels]]                \n\t"
-        "walignr1 wr2, wr12, wr13       \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr3, wr13, wr14       \n\t"
-        "wmoveq wr10, wr13              \n\t"
-        "wmoveq wr11, wr14              \n\t"
-        "walignr2ne wr10, wr12, wr13    \n\t"
-        "walignr2ne wr11, wr13, wr14    \n\t"
-        "wunpckelub wr0, wr2            \n\t"
-        "wunpckehub wr1, wr2            \n\t"
-        "wunpckelub wr2, wr3            \n\t"
-        "wunpckehub wr3, wr3            \n\t"
-        "wunpckelub wr8, wr10           \n\t"
-        "wunpckehub wr9, wr10           \n\t"
-        "wunpckelub wr10, wr11          \n\t"
-        "wunpckehub wr11, wr11          \n\t"
-        "waddhus wr0, wr0, wr8          \n\t"
-        "waddhus wr1, wr1, wr9          \n\t"
-        "waddhus wr2, wr2, wr10         \n\t"
-        "waddhus wr3, wr3, wr11         \n\t"
-
-        "1:                             \n\t"
-        // [wr0 wr1 wr2 wr3]
-        // [wr4 wr5 wr6 wr7] <= *
-        "wldrd wr12, [%[pixels]]        \n\t"
-        "cmp r12, #8                    \n\t"
-        "wldrd wr13, [%[pixels], #8]    \n\t"
-        "wldrd wr14, [%[pixels], #16]   \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "walignr1 wr6, wr12, wr13       \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr7, wr13, wr14       \n\t"
-        "wmoveq wr10, wr13              \n\t"
-        "wmoveq wr11, wr14              \n\t"
-        "walignr2ne wr10, wr12, wr13    \n\t"
-        "walignr2ne wr11, wr13, wr14    \n\t"
-        "wunpckelub wr4, wr6            \n\t"
-        "wunpckehub wr5, wr6            \n\t"
-        "wunpckelub wr6, wr7            \n\t"
-        "wunpckehub wr7, wr7            \n\t"
-        "wunpckelub wr8, wr10           \n\t"
-        "wunpckehub wr9, wr10           \n\t"
-        "wunpckelub wr10, wr11          \n\t"
-        "wunpckehub wr11, wr11          \n\t"
-        "waddhus wr4, wr4, wr8          \n\t"
-        "waddhus wr5, wr5, wr9          \n\t"
-        "waddhus wr6, wr6, wr10         \n\t"
-        "waddhus wr7, wr7, wr11         \n\t"
-        "waddhus wr8, wr0, wr4          \n\t"
-        "waddhus wr9, wr1, wr5          \n\t"
-        "waddhus wr10, wr2, wr6         \n\t"
-        "waddhus wr11, wr3, wr7         \n\t"
-        "waddhus wr8, wr8, wr15         \n\t"
-        "waddhus wr9, wr9, wr15         \n\t"
-        "waddhus wr10, wr10, wr15       \n\t"
-        "waddhus wr11, wr11, wr15       \n\t"
-        "wsrlhg wr8, wr8, wcgr0         \n\t"
-        "wsrlhg wr9, wr9, wcgr0         \n\t"
-        "wldrd wr12, [%[block]]         \n\t"
-        "wldrd wr13, [%[block], #8]     \n\t"
-        "wsrlhg wr10, wr10, wcgr0       \n\t"
-        "wsrlhg wr11, wr11, wcgr0       \n\t"
-        "wpackhus wr8, wr8, wr9         \n\t"
-        "wpackhus wr9, wr10, wr11       \n\t"
-        WAVG2B" wr8, wr8, wr12          \n\t"
-        WAVG2B" wr9, wr9, wr13          \n\t"
-        "wstrd wr8, [%[block]]          \n\t"
-        "wstrd wr9, [%[block], #8]      \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-
-        // [wr0 wr1 wr2 wr3] <= *
-        // [wr4 wr5 wr6 wr7]
-        "wldrd wr12, [%[pixels]]        \n\t"
-        "pld [%[block]]                 \n\t"
-        "wldrd wr13, [%[pixels], #8]    \n\t"
-        "pld [%[block], #32]            \n\t"
-        "wldrd wr14, [%[pixels], #16]   \n\t"
-        "add %[pixels], %[pixels], %[line_size] \n\t"
-        "walignr1 wr2, wr12, wr13       \n\t"
-        "pld [%[pixels]]                \n\t"
-        "pld [%[pixels], #32]           \n\t"
-        "walignr1 wr3, wr13, wr14       \n\t"
-        "wmoveq wr10, wr13              \n\t"
-        "wmoveq wr11, wr14              \n\t"
-        "walignr2ne wr10, wr12, wr13    \n\t"
-        "walignr2ne wr11, wr13, wr14    \n\t"
-        "wunpckelub wr0, wr2            \n\t"
-        "wunpckehub wr1, wr2            \n\t"
-        "wunpckelub wr2, wr3            \n\t"
-        "wunpckehub wr3, wr3            \n\t"
-        "wunpckelub wr8, wr10           \n\t"
-        "wunpckehub wr9, wr10           \n\t"
-        "wunpckelub wr10, wr11          \n\t"
-        "wunpckehub wr11, wr11          \n\t"
-        "waddhus wr0, wr0, wr8          \n\t"
-        "waddhus wr1, wr1, wr9          \n\t"
-        "waddhus wr2, wr2, wr10         \n\t"
-        "waddhus wr3, wr3, wr11         \n\t"
-        "waddhus wr8, wr0, wr4          \n\t"
-        "waddhus wr9, wr1, wr5          \n\t"
-        "waddhus wr10, wr2, wr6         \n\t"
-        "waddhus wr11, wr3, wr7         \n\t"
-        "waddhus wr8, wr8, wr15         \n\t"
-        "waddhus wr9, wr9, wr15         \n\t"
-        "waddhus wr10, wr10, wr15       \n\t"
-        "waddhus wr11, wr11, wr15       \n\t"
-        "wsrlhg wr8, wr8, wcgr0         \n\t"
-        "wsrlhg wr9, wr9, wcgr0         \n\t"
-        "wldrd wr12, [%[block]]         \n\t"
-        "wldrd wr13, [%[block], #8]     \n\t"
-        "wsrlhg wr10, wr10, wcgr0       \n\t"
-        "wsrlhg wr11, wr11, wcgr0       \n\t"
-        "wpackhus wr8, wr8, wr9         \n\t"
-        "wpackhus wr9, wr10, wr11       \n\t"
-        WAVG2B" wr8, wr8, wr12          \n\t"
-        WAVG2B" wr9, wr9, wr13          \n\t"
-        "wstrd wr8, [%[block]]          \n\t"
-        "wstrd wr9, [%[block], #8]      \n\t"
-        "add %[block], %[block], %[line_size]   \n\t"
-        "subs %[h], %[h], #2            \n\t"
-        "pld [%[block]]                 \n\t"
-        "pld [%[block], #32]            \n\t"
-        "bne 1b                         \n\t"
-        : [h]"+r"(h), [pixels]"+r"(pixels), [block]"+r"(block)
-        : [line_size]"r"(line_size)
-        : "r12", "memory");
-}
diff --git a/ffmpeg.src/libavcodec/armv4l/jrevdct_arm.S b/ffmpeg.src/libavcodec/armv4l/jrevdct_arm.S
deleted file mode 100644
index 76eda57..0000000
--- a/ffmpeg.src/libavcodec/armv4l/jrevdct_arm.S
+++ /dev/null
@@ -1,386 +0,0 @@
-/* 
-   C-like prototype :
-	void j_rev_dct_ARM(DCTBLOCK data)
-
-   With DCTBLOCK being a pointer to an array of 64 'signed shorts'
-
-   Copyright (c) 2001 Lionel Ulmer (lionel.ulmer at free.fr / bbrox at bbrox.org)
-
-   Permission is hereby granted, free of charge, to any person obtaining a copy
-   of this software and associated documentation files (the "Software"), to deal
-   in the Software without restriction, including without limitation the rights
-   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-   copies of the Software, and to permit persons to whom the Software is
-   furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included in
-   all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-   COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-   IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-	
-*/
-#define FIX_0_298631336 2446
-#define FIX_0_541196100 4433
-#define FIX_0_765366865 6270
-#define FIX_1_175875602 9633
-#define FIX_1_501321110 12299
-#define FIX_2_053119869 16819
-#define FIX_3_072711026 25172
-#define FIX_M_0_390180644 -3196
-#define FIX_M_0_899976223 -7373
-#define FIX_M_1_847759065 -15137
-#define FIX_M_1_961570560 -16069
-#define FIX_M_2_562915447 -20995
-#define FIX_0xFFFF 0xFFFF	
-		
-#define FIX_0_298631336_ID      0
-#define FIX_0_541196100_ID      4
-#define FIX_0_765366865_ID      8
-#define FIX_1_175875602_ID     12
-#define FIX_1_501321110_ID     16
-#define FIX_2_053119869_ID     20
-#define FIX_3_072711026_ID     24
-#define FIX_M_0_390180644_ID   28
-#define FIX_M_0_899976223_ID   32
-#define FIX_M_1_847759065_ID   36
-#define FIX_M_1_961570560_ID   40
-#define FIX_M_2_562915447_ID   44
-#define FIX_0xFFFF_ID          48
-	.text
-	.align
-	
-	.global j_rev_dct_ARM
-j_rev_dct_ARM:
-	stmdb   sp!, { r4 - r12, lr }   @ all callee saved regs
-
-	sub sp, sp, #4                  @ reserve some space on the stack
-	str r0, [ sp ]                  @ save the DCT pointer to the stack
-
-	mov lr, r0                      @ lr = pointer to the current row
-	mov r12, #8                     @ r12 = row-counter
-	add r11, pc, #(const_array-.-8) @ r11 = base pointer to the constants array	
-row_loop:
-	ldrsh r0, [lr, # 0]             @ r0 = 'd0'
-	ldrsh r1, [lr, # 8]             @ r1 = 'd1'
-
-	@ Optimization for row that have all items except the first set to 0
-	@ (this works as the DCTELEMS are always 4-byte aligned)
-	ldr r5, [lr, # 0]
-	ldr r2, [lr, # 4]
-	ldr r3, [lr, # 8]
-	ldr r4, [lr, #12]
-	orr r3, r3, r4
-	orr r3, r3, r2
-	orrs r5, r3, r5
-	beq end_of_row_loop             @ nothing to be done as ALL of them are '0'
-	orrs r2, r3, r1
-	beq empty_row
-	
-	ldrsh r2, [lr, # 2]             @ r2 = 'd2'
-	ldrsh r4, [lr, # 4]             @ r4 = 'd4'
-	ldrsh r6, [lr, # 6]             @ r6 = 'd6'
-	
-	ldr r3, [r11, #FIX_0_541196100_ID]
-	add r7, r2, r6
-	ldr r5, [r11, #FIX_M_1_847759065_ID]
-	mul r7, r3, r7                      @ r7 = z1
-	ldr r3, [r11, #FIX_0_765366865_ID]
-	mla r6, r5, r6, r7                  @ r6 = tmp2
-	add r5, r0, r4                      @ r5 = tmp0
-	mla r2, r3, r2, r7                  @ r2 = tmp3
-	sub r3, r0, r4                      @ r3 = tmp1
-
-	add r0, r2, r5, lsl #13             @ r0 = tmp10
-	rsb r2, r2, r5, lsl #13             @ r2 = tmp13
-	add r4, r6, r3, lsl #13             @ r4 = tmp11
-	rsb r3, r6, r3, lsl #13             @ r3 = tmp12
-
-	stmdb   sp!, { r0, r2, r3, r4 } @ save on the stack tmp10, tmp13, tmp12, tmp11
-	
-	ldrsh r3, [lr, #10]             @ r3 = 'd3'
-	ldrsh r5, [lr, #12]             @ r5 = 'd5'
-	ldrsh r7, [lr, #14]             @ r7 = 'd7'
-
-	add r0, r3, r5	                @ r0 = 'z2'
-	add r2, r1, r7                  @ r2 = 'z1'
-	add r4, r3, r7                  @ r4 = 'z3'
-	add r6, r1, r5                  @ r6 = 'z4'
-	ldr r9, [r11, #FIX_1_175875602_ID]
-	add r8, r4, r6                  @ r8 = z3 + z4
-	ldr r10, [r11, #FIX_M_0_899976223_ID]
-	mul r8, r9, r8                  @ r8 = 'z5'
-	ldr r9, [r11, #FIX_M_2_562915447_ID]
-	mul r2, r10, r2                 @ r2 = 'z1'
-	ldr r10, [r11, #FIX_M_1_961570560_ID]
-	mul r0, r9, r0                  @ r0 = 'z2'
-	ldr r9, [r11, #FIX_M_0_390180644_ID]
-	mla r4, r10, r4, r8             @ r4 = 'z3'
-	ldr r10, [r11, #FIX_0_298631336_ID]
-	mla r6, r9, r6, r8              @ r6 = 'z4'
-	ldr r9, [r11, #FIX_2_053119869_ID]
-	mla r7, r10, r7, r2             @ r7 = tmp0 + z1
-	ldr r10, [r11, #FIX_3_072711026_ID]
-	mla r5, r9, r5, r0              @ r5 = tmp1 + z2
-	ldr r9, [r11, #FIX_1_501321110_ID]
-	mla r3, r10, r3, r0             @ r3 = tmp2 + z2
-	add r7, r7, r4                  @ r7 = tmp0
-	mla r1, r9, r1, r2              @ r1 = tmp3 + z1
-	add r5,	r5, r6                  @ r5 = tmp1
-	add r3, r3, r4                  @ r3 = tmp2
-	add r1, r1, r6                  @ r1 = tmp3
-
-	ldmia sp!, { r0, r2, r4, r6 } @ r0 = tmp10 / r2 = tmp13 / r4 = tmp12 / r6 = tmp11
-	                              @ r1 = tmp3  / r3 = tmp2  / r5 = tmp1  / r7 = tmp0
-	
-	@ Compute DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS)
-	add r8, r0, r1
-	add r8, r8, #(1<<10)
-	mov r8, r8, asr #11
-	strh r8, [lr, # 0]
-	
-	@ Compute DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS)
-	sub r8, r0, r1
-	add r8, r8, #(1<<10)
-	mov r8, r8, asr #11
-	strh r8, [lr, #14]
-	
-	@ Compute DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS)
-	add r8, r6, r3
-	add r8, r8, #(1<<10)
-	mov r8, r8, asr #11
-	strh r8, [lr, # 2]
-	
-	@ Compute DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS)
-	sub r8, r6, r3
-	add r8, r8, #(1<<10)
-	mov r8, r8, asr #11
-	strh r8, [lr, #12]
-	
-	@ Compute DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS)
-	add r8, r4, r5
-	add r8, r8, #(1<<10)
-	mov r8, r8, asr #11
-	strh r8, [lr, # 4]
-	
-	@ Compute DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS)
-	sub r8, r4, r5
-	add r8, r8, #(1<<10)
-	mov r8, r8, asr #11
-	strh r8, [lr, #10]
-	
-	@ Compute DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS)
-	add r8, r2, r7
-	add r8, r8, #(1<<10)
-	mov r8, r8, asr #11
-	strh r8, [lr, # 6]
-	
-	@ Compute DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS)
-	sub r8, r2, r7
-	add r8, r8, #(1<<10)
-	mov r8, r8, asr #11
-	strh r8, [lr, # 8]
-
-	@ End of row loop
-	add lr, lr, #16
-	subs r12, r12, #1
-	bne row_loop
-	beq start_column_loop
-	
-empty_row:
-	ldr r1, [r11, #FIX_0xFFFF_ID]
-	mov r0, r0, lsl #2
-	and r0, r0, r1
-	add r0, r0, r0, lsl #16
-	str r0, [lr, # 0]
-	str r0, [lr, # 4]
-	str r0, [lr, # 8]
-	str r0, [lr, #12]
-
-end_of_row_loop:
-	@ End of loop
-	add lr, lr, #16
-	subs r12, r12, #1
-	bne row_loop
-
-start_column_loop:
-	@ Start of column loop
-	ldr lr, [ sp ]
-	mov r12, #8
-column_loop:
-	ldrsh r0, [lr, #( 0*8)]             @ r0 = 'd0'
-	ldrsh r2, [lr, #( 4*8)]             @ r2 = 'd2'
-	ldrsh r4, [lr, #( 8*8)]             @ r4 = 'd4'
-	ldrsh r6, [lr, #(12*8)]             @ r6 = 'd6'
-
-	ldr r3, [r11, #FIX_0_541196100_ID]
-	add r1, r2, r6
-	ldr r5, [r11, #FIX_M_1_847759065_ID]
-	mul r1, r3, r1                      @ r1 = z1
-	ldr r3, [r11, #FIX_0_765366865_ID]
-	mla r6, r5, r6, r1                  @ r6 = tmp2
-	add r5, r0, r4                      @ r5 = tmp0
-	mla r2, r3, r2, r1                  @ r2 = tmp3
-	sub r3, r0, r4                      @ r3 = tmp1
-
-	add r0, r2, r5, lsl #13             @ r0 = tmp10
-	rsb r2, r2, r5, lsl #13             @ r2 = tmp13
-	add r4, r6, r3, lsl #13             @ r4 = tmp11
-	rsb r6, r6, r3, lsl #13             @ r6 = tmp12
-
-	ldrsh r1, [lr, #( 2*8)]             @ r1 = 'd1'
-	ldrsh r3, [lr, #( 6*8)]             @ r3 = 'd3'
-	ldrsh r5, [lr, #(10*8)]             @ r5 = 'd5'
-	ldrsh r7, [lr, #(14*8)]             @ r7 = 'd7'
-
-	@ Check for empty odd column (happens about 20 to 25 % of the time according to my stats)
-	orr r9, r1, r3
-	orr r10, r5, r7
-	orrs r10, r9, r10
-	beq empty_odd_column
-
-	stmdb   sp!, { r0, r2, r4, r6 } @ save on the stack tmp10, tmp13, tmp12, tmp11
-		
-	add r0, r3, r5	                @ r0 = 'z2'
-	add r2, r1, r7                  @ r2 = 'z1'
-	add r4, r3, r7                  @ r4 = 'z3'
-	add r6, r1, r5                  @ r6 = 'z4'
-	ldr r9, [r11, #FIX_1_175875602_ID]
-	add r8, r4, r6
-	ldr r10, [r11, #FIX_M_0_899976223_ID]
-	mul r8, r9, r8                  @ r8 = 'z5'
-	ldr r9, [r11, #FIX_M_2_562915447_ID]
-	mul r2, r10, r2                 @ r2 = 'z1'
-	ldr r10, [r11, #FIX_M_1_961570560_ID]
-	mul r0, r9, r0                  @ r0 = 'z2'
-	ldr r9, [r11, #FIX_M_0_390180644_ID]
-	mla r4, r10, r4, r8             @ r4 = 'z3'
-	ldr r10, [r11, #FIX_0_298631336_ID]
-	mla r6, r9, r6, r8              @ r6 = 'z4'
-	ldr r9, [r11, #FIX_2_053119869_ID]
-	mla r7, r10, r7, r2             @ r7 = tmp0 + z1
-	ldr r10, [r11, #FIX_3_072711026_ID]
-	mla r5, r9, r5, r0              @ r5 = tmp1 + z2
-	ldr r9, [r11, #FIX_1_501321110_ID]
-	mla r3, r10, r3, r0             @ r3 = tmp2 + z2
-	add r7, r7, r4                  @ r7 = tmp0
-	mla r1, r9, r1, r2              @ r1 = tmp3 + z1
-	add r5,	r5, r6                  @ r5 = tmp1
-	add r3, r3, r4                  @ r3 = tmp2
-	add r1, r1, r6                  @ r1 = tmp3	
-	
-	ldmia sp!, { r0, r2, r4, r6 } @ r0 = tmp10 / r2 = tmp13 / r4 = tmp11 / r6 = tmp12
-	                              @ r1 = tmp3  / r3 = tmp2  / r5 = tmp1  / r7 = tmp0	
-
-	@ Compute DESCALE(tmp10 + tmp3, CONST_BITS+PASS1_BITS+3)
-	add r8, r0, r1
-	add r8, r8, #(1<<17)
-	mov r8, r8, asr #18
-	strh r8, [lr, #( 0*8)]
-	
-	@ Compute DESCALE(tmp10 - tmp3, CONST_BITS+PASS1_BITS+3)
-	sub r8, r0, r1
-	add r8, r8, #(1<<17)
-	mov r8, r8, asr #18
-	strh r8, [lr, #(14*8)]
-	
-	@ Compute DESCALE(tmp11 + tmp2, CONST_BITS+PASS1_BITS+3)
-	add r8, r4, r3
-	add r8, r8, #(1<<17)
-	mov r8, r8, asr #18
-	strh r8, [lr, #( 2*8)]
-	
-	@ Compute DESCALE(tmp11 - tmp2, CONST_BITS+PASS1_BITS+3)
-	sub r8, r4, r3
-	add r8, r8, #(1<<17)
-	mov r8, r8, asr #18
-	strh r8, [lr, #(12*8)]
-	
-	@ Compute DESCALE(tmp12 + tmp1, CONST_BITS+PASS1_BITS+3)
-	add r8, r6, r5
-	add r8, r8, #(1<<17)
-	mov r8, r8, asr #18
-	strh r8, [lr, #( 4*8)]
-	
-	@ Compute DESCALE(tmp12 - tmp1, CONST_BITS+PASS1_BITS+3)
-	sub r8, r6, r5
-	add r8, r8, #(1<<17)
-	mov r8, r8, asr #18
-	strh r8, [lr, #(10*8)]
-	
-	@ Compute DESCALE(tmp13 + tmp0, CONST_BITS+PASS1_BITS+3)
-	add r8, r2, r7
-	add r8, r8, #(1<<17)
-	mov r8, r8, asr #18
-	strh r8, [lr, #( 6*8)]
-	
-	@ Compute DESCALE(tmp13 - tmp0, CONST_BITS+PASS1_BITS+3)
-	sub r8, r2, r7
-	add r8, r8, #(1<<17)
-	mov r8, r8, asr #18
-	strh r8, [lr, #( 8*8)]
-
-	@ End of row loop
-	add lr, lr, #2
-	subs r12, r12, #1
-	bne column_loop
-	beq the_end
-	
-empty_odd_column:
-	@ Compute DESCALE(tmp10 + tmp3, CONST_BITS+PASS1_BITS+3)
-	@ Compute DESCALE(tmp10 - tmp3, CONST_BITS+PASS1_BITS+3)
-	add r0, r0, #(1<<17)
-	mov r0, r0, asr #18
-	strh r0, [lr, #( 0*8)]
-	strh r0, [lr, #(14*8)]
-	
-	@ Compute DESCALE(tmp11 + tmp2, CONST_BITS+PASS1_BITS+3)
-	@ Compute DESCALE(tmp11 - tmp2, CONST_BITS+PASS1_BITS+3)
-	add r4, r4, #(1<<17)
-	mov r4, r4, asr #18
-	strh r4, [lr, #( 2*8)]
-	strh r4, [lr, #(12*8)]
-	
-	@ Compute DESCALE(tmp12 + tmp1, CONST_BITS+PASS1_BITS+3)
-	@ Compute DESCALE(tmp12 - tmp1, CONST_BITS+PASS1_BITS+3)
-	add r6, r6, #(1<<17)
-	mov r6, r6, asr #18
-	strh r6, [lr, #( 4*8)]
-	strh r6, [lr, #(10*8)]
-	
-	@ Compute DESCALE(tmp13 + tmp0, CONST_BITS+PASS1_BITS+3)
-	@ Compute DESCALE(tmp13 - tmp0, CONST_BITS+PASS1_BITS+3)
-	add r2, r2, #(1<<17)
-	mov r2, r2, asr #18
-	strh r2, [lr, #( 6*8)]
-	strh r2, [lr, #( 8*8)]
-
-	@ End of row loop
-	add lr, lr, #2
-	subs r12, r12, #1
-	bne column_loop
-		
-the_end:	
-	@ The end....
-	add sp, sp, #4
-	ldmia   sp!, { r4 - r12, pc }   @ restore callee saved regs and return
-
-const_array:
-	.align
-	.word FIX_0_298631336
-	.word FIX_0_541196100
-	.word FIX_0_765366865
-	.word FIX_1_175875602
-	.word FIX_1_501321110
-	.word FIX_2_053119869
-	.word FIX_3_072711026
-	.word FIX_M_0_390180644
-	.word FIX_M_0_899976223
-	.word FIX_M_1_847759065
-	.word FIX_M_1_961570560
-	.word FIX_M_2_562915447
-	.word FIX_0xFFFF
diff --git a/ffmpeg.src/libavcodec/armv4l/mpegvideo_arm.c b/ffmpeg.src/libavcodec/armv4l/mpegvideo_arm.c
deleted file mode 100644
index 6e4c9fb..0000000
--- a/ffmpeg.src/libavcodec/armv4l/mpegvideo_arm.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2002 Michael Niedermayer
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include "../dsputil.h"
-#include "../mpegvideo.h"
-#include "../avcodec.h"
-
-extern void MPV_common_init_iwmmxt(MpegEncContext *s);
-
-void MPV_common_init_armv4l(MpegEncContext *s)
-{
-#ifdef HAVE_IWMMXT
-    MPV_common_init_iwmmxt(s);
-#endif
-}
diff --git a/ffmpeg.src/libavcodec/armv4l/mpegvideo_iwmmxt.c b/ffmpeg.src/libavcodec/armv4l/mpegvideo_iwmmxt.c
deleted file mode 100644
index 9724de8..0000000
--- a/ffmpeg.src/libavcodec/armv4l/mpegvideo_iwmmxt.c
+++ /dev/null
@@ -1,99 +0,0 @@
-#include "../dsputil.h"
-#include "../mpegvideo.h"
-#include "../avcodec.h"
-
-static void dct_unquantize_h263_intra_iwmmxt(MpegEncContext *s,
-                                             DCTELEM *block, int n, int qscale)
-{
-    int level, qmul, qadd;
-    int nCoeffs;
-    DCTELEM *block_orig = block;
-
-    assert(s->block_last_index[n]>=0);
-
-    qmul = qscale << 1;
-
-    if (!s->h263_aic) {
-        if (n < 4)
-            level = block[0] * s->y_dc_scale;
-        else
-            level = block[0] * s->c_dc_scale;
-        qadd = (qscale - 1) | 1;
-    }else{
-        qadd = 0;
-        level = block[0];
-    }
-    if(s->ac_pred)
-        nCoeffs=63;
-    else
-        nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
-
-    __asm__ __volatile__ (
-/*      "movd %1, %%mm6                 \n\t" //qmul */
-/*      "packssdw %%mm6, %%mm6          \n\t" */
-/*      "packssdw %%mm6, %%mm6          \n\t" */
-        "tbcsth wr6, %[qmul]            \n\t"
-/*      "movd %2, %%mm5                 \n\t" //qadd */
-/*      "packssdw %%mm5, %%mm5          \n\t" */
-/*      "packssdw %%mm5, %%mm5          \n\t" */
-        "tbcsth wr5, %[qadd]            \n\t"
-        "wzero wr7                      \n\t" /* "pxor %%mm7, %%mm7             \n\t" */
-        "wzero wr4                      \n\t" /* "pxor %%mm4, %%mm4             \n\t" */
-        "wsubh wr7, wr5, wr7            \n\t" /* "psubw %%mm5, %%mm7            \n\t" */
-        "1:                             \n\t"
-        "wldrd wr2, [%[block]]          \n\t" /* "movq (%0, %3), %%mm0          \n\t" */
-        "wldrd wr3, [%[block], #8]      \n\t" /* "movq 8(%0, %3), %%mm1         \n\t" */
-        "wmulsl wr0, wr6, wr2           \n\t" /* "pmullw %%mm6, %%mm0           \n\t" */
-        "wmulsl wr1, wr6, wr3           \n\t" /* "pmullw %%mm6, %%mm1           \n\t" */
-/*      "movq (%0, %3), %%mm2           \n\t" */
-/*      "movq 8(%0, %3), %%mm3          \n\t" */
-        "wcmpgtsh wr2, wr4, wr2         \n\t" /* "pcmpgtw %%mm4, %%mm2          \n\t" // block[i] < 0 ? -1 : 0 */
-        "wcmpgtsh wr3, wr4, wr2         \n\t" /* "pcmpgtw %%mm4, %%mm3          \n\t" // block[i] < 0 ? -1 : 0 */
-        "wxor wr0, wr2, wr0             \n\t" /* "pxor %%mm2, %%mm0             \n\t" */
-        "wxor wr1, wr3, wr1             \n\t" /* "pxor %%mm3, %%mm1             \n\t" */
-        "waddh wr0, wr7, wr0            \n\t" /* "paddw %%mm7, %%mm0            \n\t" */
-        "waddh wr1, wr7, wr1            \n\t" /* "paddw %%mm7, %%mm1            \n\t" */
-        "wxor wr2, wr0, wr2             \n\t" /* "pxor %%mm0, %%mm2             \n\t" */
-        "wxor wr3, wr1, wr3             \n\t" /* "pxor %%mm1, %%mm3             \n\t" */
-        "wcmpeqh wr0, wr7, wr0          \n\t" /* "pcmpeqw %%mm7, %%mm0          \n\t" // block[i] == 0 ? -1 : 0 */
-        "wcmpeqh wr1, wr7, wr1          \n\t" /* "pcmpeqw %%mm7, %%mm1          \n\t" // block[i] == 0 ? -1 : 0 */
-        "wandn wr0, wr2, wr0            \n\t" /* "pandn %%mm2, %%mm0            \n\t" */
-        "wandn wr1, wr3, wr1            \n\t" /* "pandn %%mm3, %%mm1            \n\t" */
-        "wstrd wr0, [%[block]]          \n\t" /* "movq %%mm0, (%0, %3)          \n\t" */
-        "wstrd wr1, [%[block], #8]      \n\t" /* "movq %%mm1, 8(%0, %3)         \n\t" */
-        "add %[block], %[block], #16    \n\t" /* "addl $16, %3                  \n\t" */
-        "subs %[i], %[i], #1            \n\t"
-        "bne 1b                         \n\t" /* "jng 1b                                \n\t" */
-        :[block]"+r"(block)
-        :[i]"r"((nCoeffs + 8) / 8), [qmul]"r"(qmul), [qadd]"r"(qadd)
-        :"memory");
-
-    block_orig[0] = level;
-}
-
-#if 0
-static void dct_unquantize_h263_inter_iwmmxt(MpegEncContext *s,
-                                             DCTELEM *block, int n, int qscale)
-{
-    int nCoeffs;
-
-    assert(s->block_last_index[n]>=0);
-
-    if(s->ac_pred)
-        nCoeffs=63;
-    else
-        nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
-
-    ippiQuantInvInter_Compact_H263_16s_I(block, nCoeffs+1, qscale);
-}
-#endif
-
-void MPV_common_init_iwmmxt(MpegEncContext *s)
-{
-    if (!(mm_flags & MM_IWMMXT)) return;
-
-    s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_iwmmxt;
-#if 0
-    s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_iwmmxt;
-#endif
-}
diff --git a/ffmpeg.src/libavcodec/armv4l/simple_idct_arm.S b/ffmpeg.src/libavcodec/armv4l/simple_idct_arm.S
deleted file mode 100644
index 95ac0de..0000000
--- a/ffmpeg.src/libavcodec/armv4l/simple_idct_arm.S
+++ /dev/null
@@ -1,485 +0,0 @@
-/* 
- * simple_idct_arm.S
- * Copyright (C) 2002 Frederic 'dilb' Boulay.
- * All Rights Reserved.
- *
- * Author: Frederic Boulay <dilb at handhelds.org>
- *
- * You can redistribute this file and/or modify
- * it under the terms of the GNU General Public License (version 2)
- * as published by the Free Software Foundation.
- *
- * This file 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- *
- * The function defined in this file, is derived from the simple_idct function
- * from the libavcodec library part of the ffmpeg project. 
- */
-
-/* useful constants for the algorithm, they are save in __constant_ptr__ at */
-/* the end of the source code.*/
-#define W1  22725
-#define W2  21407
-#define W3  19266
-#define W4  16383
-#define W5  12873
-#define W6  8867
-#define W7  4520
-#define MASK_MSHW 0xFFFF0000
-
-/* offsets of the constants in the vector */
-#define offW1  0
-#define offW2  4
-#define offW3  8
-#define offW4  12
-#define offW5  16
-#define offW6  20
-#define offW7  24
-#define offMASK_MSHW 28
-
-#define ROW_SHIFT 11
-#define ROW_SHIFT2MSHW (16-11)
-#define COL_SHIFT 20
-#define ROW_SHIFTED_1 1024 /* 1<< (ROW_SHIFT-1) */
-#define COL_SHIFTED_1 524288 /* 1<< (COL_SHIFT-1) */
-
-
-	.text
-	.align
-	.global simple_idct_ARM
-
-simple_idct_ARM:
-        @@ void simple_idct_ARM(int16_t *block)
-        @@ save stack for reg needed (take all of them),
-        @@ R0-R3 are scratch regs, so no need to save them, but R0 contains the pointer to block
-        @@ so it must not be overwritten, if it is not saved!!
-        @@ R12 is another scratch register, so it should not be saved too
-        @@ save all registers
-        stmfd sp!, {r4-r11, r14} @ R14 is also called LR
-        @@ at this point, R0=block, other registers are free.
-        add r14, r0, #112        @ R14=&block[8*7], better start from the last row, and decrease the value until row=0, i.e. R12=block.
-        add r12, pc, #(__constant_ptr__-.-8) @ R12=__constant_ptr__, the vector containing the constants, probably not necessary to reserve a register for it
-        @@ add 2 temporary variables in the stack: R0 and R14
-        sub sp, sp, #8          @ allow 2 local variables
-        str r0, [sp, #0]        @ save block in sp[0]
-        @@ stack status
-        @@ sp+4   free
-        @@ sp+0   R0  (block)
-
-
-        @@ at this point, R0=block, R14=&block[56], R12=__const_ptr_, R1-R11 free
-
-
-__row_loop:
-        @@ read the row and check if it is null, almost null, or not, according to strongarm specs, it is not necessary to optimise ldr accesses (i.e. split 32bits in 2 16bits words), at least it gives more usable registers :)
-        ldr r1, [r14, #0]        @ R1=(int32)(R12)[0]=ROWr32[0] (relative row cast to a 32b pointer)
-        ldr r2, [r14, #4]        @ R2=(int32)(R12)[1]=ROWr32[1]
-        ldr r3, [r14, #8]        @ R3=ROWr32[2]
-        ldr r4, [r14, #12]       @ R4=ROWr32[3]
-        @@ check if the words are null, if all of them are null, then proceed with next row (branch __end_row_loop),
-        @@ if ROWr16[0] is the only one not null, then proceed with this special case (branch __almost_empty_row)
-        @@ else follow the complete algorithm.
-        @@ at this point, R0=block, R14=&block[n], R12=__const_ptr_, R1=ROWr32[0], R2=ROWr32[1],
-        @@                R3=ROWr32[2], R4=ROWr32[3], R5-R11 free
-        orr r5, r4, r3           @ R5=R4 | R3
-        orr r5, r5, r2           @ R5=R4 | R3 | R2
-        orrs r6, r5, r1          @ Test R5 | R1 (the aim is to check if everything is null)
-        beq __end_row_loop
-        mov r7, r1, asr #16      @ R7=R1>>16=ROWr16[1] (evaluate it now, as it could be useful later)
-        ldrsh r6, [r14, #0]      @ R6=ROWr16[0]
-        orrs r5, r5, r7          @ R5=R4 | R3 | R2 | R7
-        beq __almost_empty_row
-
-__b_evaluation:
-        @@ at this point, R0=block (temp),  R1(free), R2=ROWr32[1], R3=ROWr32[2], R4=ROWr32[3],
-        @@     R5=(temp), R6=ROWr16[0], R7=ROWr16[1], R8-R11 free,
-        @@     R12=__const_ptr_, R14=&block[n]
-        @@ to save some registers/calls, proceed with b0-b3 first, followed by a0-a3
-
-        @@ MUL16(b0, W1, row[1]);
-        @@ MUL16(b1, W3, row[1]);
-        @@ MUL16(b2, W5, row[1]);
-        @@ MUL16(b3, W7, row[1]);
-        @@ MAC16(b0, W3, row[3]);
-        @@ MAC16(b1, -W7, row[3]);
-        @@ MAC16(b2, -W1, row[3]);
-        @@ MAC16(b3, -W5, row[3]);
-        ldr r8, [r12, #offW1]    @ R8=W1
-        mov r2, r2, asr #16      @ R2=ROWr16[3]
-        mul r0, r8, r7           @ R0=W1*ROWr16[1]=b0 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
-        ldr r9, [r12, #offW3]    @ R9=W3
-        ldr r10, [r12, #offW5]   @ R10=W5
-        mul r1, r9, r7           @ R1=W3*ROWr16[1]=b1 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
-        ldr r11, [r12, #offW7]   @ R11=W7
-        mul r5, r10, r7          @ R5=W5*ROWr16[1]=b2 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
-        mul r7, r11, r7          @ R7=W7*ROWr16[1]=b3 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
-		teq r2, #0               @ if null avoid muls
-		mlane r0, r9, r2, r0     @ R0+=W3*ROWr16[3]=b0 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
-        rsbne r2, r2, #0         @ R2=-ROWr16[3]
-        mlane r1, r11, r2, r1    @ R1-=W7*ROWr16[3]=b1 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
-        mlane r5, r8, r2, r5     @ R5-=W1*ROWr16[3]=b2 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
-        mlane r7, r10, r2, r7    @ R7-=W5*ROWr16[3]=b3 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
-
-        @@ at this point, R0=b0,  R1=b1, R2 (free), R3=ROWr32[2], R4=ROWr32[3],
-        @@     R5=b2, R6=ROWr16[0], R7=b3, R8=W1, R9=W3, R10=W5, R11=W7,
-        @@     R12=__const_ptr_, R14=&block[n]
-        @@ temp = ((uint32_t*)row)[2] | ((uint32_t*)row)[3];
-        @@ if (temp != 0) {}
-        orrs r2, r3, r4          @ R2=ROWr32[2] | ROWr32[3]
-        beq __end_b_evaluation
-
-        @@ at this point, R0=b0,  R1=b1, R2 (free), R3=ROWr32[2], R4=ROWr32[3],
-        @@     R5=b2, R6=ROWr16[0], R7=b3, R8=W1, R9=W3, R10=W5, R11=W7,
-        @@     R12=__const_ptr_, R14=&block[n]
-        @@ MAC16(b0, W5, row[5]);
-        @@ MAC16(b2, W7, row[5]);
-        @@ MAC16(b3, W3, row[5]);
-        @@ MAC16(b1, -W1, row[5]);
-        @@ MAC16(b0, W7, row[7]);
-        @@ MAC16(b2, W3, row[7]);
-        @@ MAC16(b3, -W1, row[7]);
-        @@ MAC16(b1, -W5, row[7]);
-        mov r3, r3, asr #16      @ R3=ROWr16[5]
-		teq r3, #0               @ if null avoid muls
-        mlane r0, r10, r3, r0    @ R0+=W5*ROWr16[5]=b0
-        mov r4, r4, asr #16      @ R4=ROWr16[7]
-        mlane r5, r11, r3, r5    @ R5+=W7*ROWr16[5]=b2
-        mlane r7, r9, r3, r7     @ R7+=W3*ROWr16[5]=b3
-        rsbne r3, r3, #0         @ R3=-ROWr16[5]
-        mlane r1, r8, r3, r1     @ R7-=W1*ROWr16[5]=b1
-        @@ R3 is free now
-		teq r4, #0               @ if null avoid muls
-        mlane r0, r11, r4, r0    @ R0+=W7*ROWr16[7]=b0
-        mlane r5, r9, r4, r5     @ R5+=W3*ROWr16[7]=b2
-        rsbne r4, r4, #0         @ R4=-ROWr16[7]
-        mlane r7, r8, r4, r7     @ R7-=W1*ROWr16[7]=b3
-        mlane r1, r10, r4, r1    @ R1-=W5*ROWr16[7]=b1
-        @@ R4 is free now
-__end_b_evaluation:
-        @@ at this point, R0=b0,  R1=b1, R2=ROWr32[2] | ROWr32[3] (tmp), R3 (free), R4 (free),
-        @@     R5=b2, R6=ROWr16[0], R7=b3, R8 (free), R9 (free), R10 (free), R11 (free),
-        @@     R12=__const_ptr_, R14=&block[n]
-
-__a_evaluation:
-        @@ a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1));
-        @@ a1 = a0 + W6 * row[2];
-        @@ a2 = a0 - W6 * row[2];
-        @@ a3 = a0 - W2 * row[2];
-        @@ a0 = a0 + W2 * row[2];
-        ldr r9, [r12, #offW4]    @ R9=W4
-        mul r6, r9, r6           @ R6=W4*ROWr16[0]
-        ldr r10, [r12, #offW6]   @ R10=W6
-        ldrsh r4, [r14, #4]      @ R4=ROWr16[2] (a3 not defined yet)
-        add r6, r6, #ROW_SHIFTED_1 @ R6=W4*ROWr16[0] + 1<<(ROW_SHIFT-1) (a0)
-
-        mul r11, r10, r4         @ R11=W6*ROWr16[2]
-        ldr r8, [r12, #offW2]    @ R8=W2
-        sub r3, r6, r11          @ R3=a0-W6*ROWr16[2] (a2)
-        @@ temp = ((uint32_t*)row)[2] | ((uint32_t*)row)[3];
-        @@ if (temp != 0) {}
-        teq r2, #0
-        beq __end_bef_a_evaluation
-
-	add r2, r6, r11          @ R2=a0+W6*ROWr16[2] (a1)
-        mul r11, r8, r4          @ R11=W2*ROWr16[2]
-        sub r4, r6, r11          @ R4=a0-W2*ROWr16[2] (a3)
-        add r6, r6, r11          @ R6=a0+W2*ROWr16[2] (a0)
-
-
-        @@ at this point, R0=b0,  R1=b1, R2=a1, R3=a2, R4=a3,
-        @@     R5=b2, R6=a0, R7=b3, R8=W2, R9=W4, R10=W6, R11 (free),
-        @@     R12=__const_ptr_, R14=&block[n]
-
-
-        @@ a0 += W4*row[4]
-        @@ a1 -= W4*row[4]
-        @@ a2 -= W4*row[4]
-        @@ a3 += W4*row[4]
-        ldrsh r11, [r14, #8]     @ R11=ROWr16[4]
-		teq r11, #0              @ if null avoid muls
-        mulne r11, r9, r11       @ R11=W4*ROWr16[4]
-        @@ R9 is free now
-        ldrsh r9, [r14, #12]     @ R9=ROWr16[6]
-        addne r6, r6, r11        @ R6+=W4*ROWr16[4] (a0)
-        subne r2, r2, r11        @ R2-=W4*ROWr16[4] (a1)
-        subne r3, r3, r11        @ R3-=W4*ROWr16[4] (a2)
-        addne r4, r4, r11        @ R4+=W4*ROWr16[4] (a3)
-        @@ W6 alone is no more useful, save W2*ROWr16[6] in it instead
-		teq r9, #0               @ if null avoid muls
-        mulne r11, r10, r9       @ R11=W6*ROWr16[6]
-        addne r6, r6, r11        @ R6+=W6*ROWr16[6] (a0)
-        mulne r10, r8, r9        @ R10=W2*ROWr16[6]
-        @@ a0 += W6*row[6];
-        @@ a3 -= W6*row[6];
-        @@ a1 -= W2*row[6];
-        @@ a2 += W2*row[6];
-        subne r4, r4, r11        @ R4-=W6*ROWr16[6] (a3)
-        subne r2, r2, r10        @ R2-=W2*ROWr16[6] (a1)
-        addne r3, r3, r10        @ R3+=W2*ROWr16[6] (a2)
-
-__end_a_evaluation:
-        @@ at this point, R0=b0,  R1=b1, R2=a1, R3=a2, R4=a3,
-        @@     R5=b2, R6=a0, R7=b3, R8 (free), R9 (free), R10 (free), R11 (free),
-        @@     R12=__const_ptr_, R14=&block[n]
-        @@ row[0] = (a0 + b0) >> ROW_SHIFT;
-        @@ row[1] = (a1 + b1) >> ROW_SHIFT;
-        @@ row[2] = (a2 + b2) >> ROW_SHIFT;
-        @@ row[3] = (a3 + b3) >> ROW_SHIFT;
-        @@ row[4] = (a3 - b3) >> ROW_SHIFT;
-        @@ row[5] = (a2 - b2) >> ROW_SHIFT;
-        @@ row[6] = (a1 - b1) >> ROW_SHIFT;
-        @@ row[7] = (a0 - b0) >> ROW_SHIFT;
-        add r8, r6, r0           @ R8=a0+b0
-        add r9, r2, r1           @ R9=a1+b1
-        @@ put 2 16 bits half-words in a 32bits word
-        @@ ROWr32[0]=ROWr16[0] | (ROWr16[1]<<16) (only Little Endian compliant then!!!)
-        ldr r10, [r12, #offMASK_MSHW] @ R10=0xFFFF0000
-        and r9, r10, r9, lsl #ROW_SHIFT2MSHW @ R9=0xFFFF0000 & ((a1+b1)<<5)
-        mvn r11, r10             @ R11= NOT R10= 0x0000FFFF
-        and r8, r11, r8, asr #ROW_SHIFT @ R8=0x0000FFFF & ((a0+b0)>>11)
-        orr r8, r8, r9
-        str r8, [r14, #0]
-
-        add r8, r3, r5           @ R8=a2+b2
-        add r9, r4, r7           @ R9=a3+b3
-        and r9, r10, r9, lsl #ROW_SHIFT2MSHW @ R9=0xFFFF0000 & ((a3+b3)<<5)
-        and r8, r11, r8, asr #ROW_SHIFT @ R8=0x0000FFFF & ((a2+b2)>>11)
-        orr r8, r8, r9
-        str r8, [r14, #4]
-
-        sub r8, r4, r7           @ R8=a3-b3
-        sub r9, r3, r5           @ R9=a2-b2
-        and r9, r10, r9, lsl #ROW_SHIFT2MSHW @ R9=0xFFFF0000 & ((a2-b2)<<5)
-        and r8, r11, r8, asr #ROW_SHIFT @ R8=0x0000FFFF & ((a3-b3)>>11)
-        orr r8, r8, r9
-        str r8, [r14, #8]
-
-        sub r8, r2, r1           @ R8=a1-b1
-        sub r9, r6, r0           @ R9=a0-b0
-        and r9, r10, r9, lsl #ROW_SHIFT2MSHW @ R9=0xFFFF0000 & ((a0-b0)<<5)
-        and r8, r11, r8, asr #ROW_SHIFT @ R8=0x0000FFFF & ((a1-b1)>>11)
-        orr r8, r8, r9
-        str r8, [r14, #12]
-
-        bal __end_row_loop
-
-__almost_empty_row:
-        @@ the row was empty, except ROWr16[0], now, management of this special case
-        @@ at this point, R0=block, R14=&block[n], R12=__const_ptr_, R1=ROWr32[0], R2=ROWr32[1],
-        @@                R3=ROWr32[2], R4=ROWr32[3], R5=(temp), R6=ROWr16[0], R7=ROWr16[1],
-        @@                R8=0xFFFF (temp), R9-R11 free
-        mov r8, #0x10000         @ R8=0xFFFF (2 steps needed!) it saves a ldr call (because of delay run).
-        sub r8, r8, #1           @ R8 is now ready.
-        and r5, r8, r6, lsl #3   @ R5=R8 & (R6<<3)= (ROWr16[0]<<3) & 0xFFFF
-        orr r5, r5, r5, lsl #16  @ R5=R5 | (R5<<16)
-        str r5, [r14, #0]        @ R14[0]=ROWr32[0]=R5
-        str r5, [r14, #4]        @ R14[4]=ROWr32[1]=R5
-        str r5, [r14, #8]        @ R14[8]=ROWr32[2]=R5
-        str r5, [r14, #12]       @ R14[12]=ROWr32[3]=R5
-
-__end_row_loop:
-        @@ at this point, R0-R11 (free)
-        @@     R12=__const_ptr_, R14=&block[n]
-        ldr r0, [sp, #0]         @ R0=block
-        teq r0, r14              @ compare current &block[8*n] to block, when block is reached, the loop is finished.
-        sub r14, r14, #16
-        bne __row_loop
-
-
-
-	@@ at this point, R0=block, R1-R11 (free)
-	@@     R12=__const_ptr_, R14=&block[n]
-	add r14, r0, #14        @ R14=&block[7], better start from the last col, and decrease the value until col=0, i.e. R14=block.
-__col_loop:
-
-__b_evaluation2:
-	@@ at this point, R0=block (temp),  R1-R11 (free)
-	@@     R12=__const_ptr_, R14=&block[n]
-	@@ proceed with b0-b3 first, followed by a0-a3
-	@@ MUL16(b0, W1, col[8x1]);
-	@@ MUL16(b1, W3, col[8x1]);
-	@@ MUL16(b2, W5, col[8x1]);
-	@@ MUL16(b3, W7, col[8x1]);
-	@@ MAC16(b0, W3, col[8x3]);
-	@@ MAC16(b1, -W7, col[8x3]);
-	@@ MAC16(b2, -W1, col[8x3]);
-	@@ MAC16(b3, -W5, col[8x3]);
-	ldr r8, [r12, #offW1]    @ R8=W1
-	ldrsh r7, [r14, #16]
-	mul r0, r8, r7           @ R0=W1*ROWr16[1]=b0 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
-	ldr r9, [r12, #offW3]    @ R9=W3
-	ldr r10, [r12, #offW5]   @ R10=W5
-	mul r1, r9, r7           @ R1=W3*ROWr16[1]=b1 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
-	ldr r11, [r12, #offW7]   @ R11=W7
-	mul r5, r10, r7          @ R5=W5*ROWr16[1]=b2 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
-	ldrsh r2, [r14, #48]
-	mul r7, r11, r7          @ R7=W7*ROWr16[1]=b3 (ROWr16[1] must be the second arg, to have the possibility to save 1 cycle)
-	teq r2, #0               @ if 0, then avoid muls
-	mlane r0, r9, r2, r0     @ R0+=W3*ROWr16[3]=b0 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
-	rsbne r2, r2, #0         @ R2=-ROWr16[3]
-	mlane r1, r11, r2, r1    @ R1-=W7*ROWr16[3]=b1 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
-	mlane r5, r8, r2, r5     @ R5-=W1*ROWr16[3]=b2 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
-	mlane r7, r10, r2, r7    @ R7-=W5*ROWr16[3]=b3 (ROWr16[3] must be the second arg, to have the possibility to save 1 cycle)
-
-	@@ at this point, R0=b0,  R1=b1, R2 (free), R3 (free), R4 (free),
-	@@     R5=b2, R6 (free), R7=b3, R8=W1, R9=W3, R10=W5, R11=W7,
-	@@     R12=__const_ptr_, R14=&block[n]
-	@@ MAC16(b0, W5, col[5x8]);
-	@@ MAC16(b2, W7, col[5x8]);
-	@@ MAC16(b3, W3, col[5x8]);
-	@@ MAC16(b1, -W1, col[5x8]);
-	@@ MAC16(b0, W7, col[7x8]);
-	@@ MAC16(b2, W3, col[7x8]);
-	@@ MAC16(b3, -W1, col[7x8]);
-	@@ MAC16(b1, -W5, col[7x8]);
-	ldrsh r3, [r14, #80]     @ R3=COLr16[5x8]
-	teq r3, #0               @ if 0 then avoid muls
-	mlane r0, r10, r3, r0    @ R0+=W5*ROWr16[5x8]=b0
-	mlane r5, r11, r3, r5    @ R5+=W7*ROWr16[5x8]=b2
-	mlane r7, r9, r3, r7     @ R7+=W3*ROWr16[5x8]=b3
-	rsbne r3, r3, #0         @ R3=-ROWr16[5x8]
-	ldrsh r4, [r14, #112]    @ R4=COLr16[7x8]
-	mlane r1, r8, r3, r1     @ R7-=W1*ROWr16[5x8]=b1
-	@@ R3 is free now
-	teq r4, #0               @ if 0 then avoid muls
-	mlane r0, r11, r4, r0    @ R0+=W7*ROWr16[7x8]=b0
-	mlane r5, r9, r4, r5     @ R5+=W3*ROWr16[7x8]=b2
-	rsbne r4, r4, #0         @ R4=-ROWr16[7x8]
-	mlane r7, r8, r4, r7     @ R7-=W1*ROWr16[7x8]=b3
-	mlane r1, r10, r4, r1    @ R1-=W5*ROWr16[7x8]=b1
-	@@ R4 is free now
-__end_b_evaluation2:
-	@@ at this point, R0=b0,  R1=b1, R2 (free), R3 (free), R4 (free),
-	@@     R5=b2, R6 (free), R7=b3, R8 (free), R9 (free), R10 (free), R11 (free),
-	@@     R12=__const_ptr_, R14=&block[n]
-
-__a_evaluation2:
-	@@ a0 = (W4 * col[8x0]) + (1 << (COL_SHIFT - 1));
-	@@ a1 = a0 + W6 * row[2];
-	@@ a2 = a0 - W6 * row[2];
-	@@ a3 = a0 - W2 * row[2];
-	@@ a0 = a0 + W2 * row[2];
-	ldrsh r6, [r14, #0]
-	ldr r9, [r12, #offW4]    @ R9=W4
-	mul r6, r9, r6           @ R6=W4*ROWr16[0]
-	ldr r10, [r12, #offW6]   @ R10=W6
-	ldrsh r4, [r14, #32]      @ R4=ROWr16[2] (a3 not defined yet)
-	add r6, r6, #COL_SHIFTED_1 @ R6=W4*ROWr16[0] + 1<<(COL_SHIFT-1) (a0)
-	mul r11, r10, r4         @ R11=W6*ROWr16[2]
-	ldr r8, [r12, #offW2]    @ R8=W2
-	add r2, r6, r11          @ R2=a0+W6*ROWr16[2] (a1)
-	sub r3, r6, r11          @ R3=a0-W6*ROWr16[2] (a2)
-	mul r11, r8, r4          @ R11=W2*ROWr16[2]
-	sub r4, r6, r11          @ R4=a0-W2*ROWr16[2] (a3)
-	add r6, r6, r11          @ R6=a0+W2*ROWr16[2] (a0)
-
-	@@ at this point, R0=b0,  R1=b1, R2=a1, R3=a2, R4=a3,
-	@@     R5=b2, R6=a0, R7=b3, R8=W2, R9=W4, R10=W6, R11 (free),
-	@@     R12=__const_ptr_, R14=&block[n]
-	@@ a0 += W4*row[4]
-	@@ a1 -= W4*row[4]
-	@@ a2 -= W4*row[4]
-	@@ a3 += W4*row[4]
-	ldrsh r11, [r14, #64]     @ R11=ROWr16[4]
-	teq r11, #0              @ if null avoid muls
-	mulne r11, r9, r11       @ R11=W4*ROWr16[4]
-	@@ R9 is free now
-	addne r6, r6, r11        @ R6+=W4*ROWr16[4] (a0)
-	subne r2, r2, r11        @ R2-=W4*ROWr16[4] (a1)
-	subne r3, r3, r11        @ R3-=W4*ROWr16[4] (a2)
-	ldrsh r9, [r14, #96]     @ R9=ROWr16[6]
-	addne r4, r4, r11        @ R4+=W4*ROWr16[4] (a3)
-	@@ W6 alone is no more useful, save W2*ROWr16[6] in it instead
-	teq r9, #0               @ if null avoid muls
-	mulne r11, r10, r9       @ R11=W6*ROWr16[6]
-	addne r6, r6, r11        @ R6+=W6*ROWr16[6] (a0)
-	mulne r10, r8, r9        @ R10=W2*ROWr16[6]
-	@@ a0 += W6*row[6];
-	@@ a3 -= W6*row[6];
-	@@ a1 -= W2*row[6];
-	@@ a2 += W2*row[6];
-	subne r4, r4, r11        @ R4-=W6*ROWr16[6] (a3)
-	subne r2, r2, r10        @ R2-=W2*ROWr16[6] (a1)
-	addne r3, r3, r10        @ R3+=W2*ROWr16[6] (a2)
-__end_a_evaluation2:
-	@@ at this point, R0=b0,  R1=b1, R2=a1, R3=a2, R4=a3,
-	@@     R5=b2, R6=a0, R7=b3, R8 (free), R9 (free), R10 (free), R11 (free),
-	@@     R12=__const_ptr_, R14=&block[n]
-	@@ col[0 ] = ((a0 + b0) >> COL_SHIFT);
-	@@ col[8 ] = ((a1 + b1) >> COL_SHIFT);
-	@@ col[16] = ((a2 + b2) >> COL_SHIFT);
-	@@ col[24] = ((a3 + b3) >> COL_SHIFT);
-	@@ col[32] = ((a3 - b3) >> COL_SHIFT);
-	@@ col[40] = ((a2 - b2) >> COL_SHIFT);
-	@@ col[48] = ((a1 - b1) >> COL_SHIFT);
-	@@ col[56] = ((a0 - b0) >> COL_SHIFT);
-	@@@@@ no optimisation here @@@@@
-	add r8, r6, r0           @ R8=a0+b0
-	add r9, r2, r1           @ R9=a1+b1
-	mov r8, r8, asr #COL_SHIFT
-	mov r9, r9, asr #COL_SHIFT
-	strh r8, [r14, #0]
-	strh r9, [r14, #16]
-	add r8, r3, r5           @ R8=a2+b2
-	add r9, r4, r7           @ R9=a3+b3
-	mov r8, r8, asr #COL_SHIFT
-	mov r9, r9, asr #COL_SHIFT
-	strh r8, [r14, #32]
-	strh r9, [r14, #48]
-	sub r8, r4, r7           @ R8=a3-b3
-	sub r9, r3, r5           @ R9=a2-b2
-	mov r8, r8, asr #COL_SHIFT
-	mov r9, r9, asr #COL_SHIFT
-	strh r8, [r14, #64]
-	strh r9, [r14, #80]
-	sub r8, r2, r1           @ R8=a1-b1
-	sub r9, r6, r0           @ R9=a0-b0
-	mov r8, r8, asr #COL_SHIFT
-	mov r9, r9, asr #COL_SHIFT
-	strh r8, [r14, #96]
-	strh r9, [r14, #112]
-
-__end_col_loop:
-	@@ at this point, R0-R11 (free)
-	@@     R12=__const_ptr_, R14=&block[n]
-	ldr r0, [sp, #0]         @ R0=block
-	teq r0, r14              @ compare current &block[n] to block, when block is reached, the loop is finished.
-	sub r14, r14, #2
-	bne __col_loop
-
-
-
-
-__end_simple_idct_ARM:
-        @@ restore registers to previous status!
-        add sp, sp, #8 @@ the local variables!
-        ldmfd sp!, {r4-r11, r15} @@ update PC with LR content.
-
-
-
-@@ kind of sub-function, here not to overload the common case.
-__end_bef_a_evaluation:
-	add r2, r6, r11          @ R2=a0+W6*ROWr16[2] (a1)
-        mul r11, r8, r4          @ R11=W2*ROWr16[2]
-        sub r4, r6, r11          @ R4=a0-W2*ROWr16[2] (a3)
-        add r6, r6, r11          @ R6=a0+W2*ROWr16[2] (a0)
-	bal __end_a_evaluation
-
-
-__constant_ptr__:  @@ see #defines at the beginning of the source code for values.
-	.align
-        .word   W1
-        .word   W2
-        .word   W3
-        .word   W4
-        .word   W5
-        .word   W6
-        .word   W7
-        .word   MASK_MSHW
diff --git a/ffmpeg.src/libavcodec/avcodec.h b/ffmpeg.src/libavcodec/avcodec.h
deleted file mode 100644
index 82a1984..0000000
--- a/ffmpeg.src/libavcodec/avcodec.h
+++ /dev/null
@@ -1,2421 +0,0 @@
-#ifndef AVCODEC_H
-#define AVCODEC_H
-
-/**
- * @file avcodec.h
- * external api header.
- */
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "avutil.h"
-#include <sys/types.h> /* size_t */
-
-//FIXME the following 2 really dont belong in here
-#define FFMPEG_VERSION_INT     0x000409
-#define FFMPEG_VERSION         "CVS"
-
-#define AV_STRINGIFY(s)	AV_TOSTRING(s)
-#define AV_TOSTRING(s) #s
-
-#define LIBAVCODEC_VERSION_INT ((50<<16)+(0<<8)+0)
-#define LIBAVCODEC_VERSION     50.0.0
-#define LIBAVCODEC_BUILD       LIBAVCODEC_VERSION_INT
-
-#define LIBAVCODEC_IDENT       "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
-
-#define AV_NOPTS_VALUE int64_t_C(0x8000000000000000)
-#define AV_TIME_BASE 1000000
-#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
-
-enum CodecID {
-    CODEC_ID_NONE, 
-    CODEC_ID_MPEG1VIDEO,
-    CODEC_ID_MPEG2VIDEO, /* prefered ID for MPEG Video 1 or 2 decoding */
-    CODEC_ID_MPEG2VIDEO_XVMC,
-    CODEC_ID_H261,
-    CODEC_ID_H263,
-    CODEC_ID_RV10,
-    CODEC_ID_RV20,
-    CODEC_ID_MJPEG,
-    CODEC_ID_MJPEGB,
-    CODEC_ID_LJPEG,
-    CODEC_ID_SP5X,
-    CODEC_ID_MPEG4,
-    CODEC_ID_RAWVIDEO,
-    CODEC_ID_MSMPEG4V1,
-    CODEC_ID_MSMPEG4V2,
-    CODEC_ID_MSMPEG4V3,
-    CODEC_ID_WMV1,
-    CODEC_ID_WMV2,
-    CODEC_ID_H263P,
-    CODEC_ID_H263I,
-    CODEC_ID_FLV1,
-    CODEC_ID_SVQ1,
-    CODEC_ID_SVQ3,
-    CODEC_ID_DVVIDEO,
-    CODEC_ID_HUFFYUV,
-    CODEC_ID_CYUV,
-    CODEC_ID_H264,
-    CODEC_ID_INDEO3,
-    CODEC_ID_VP3,
-    CODEC_ID_THEORA,
-    CODEC_ID_ASV1,
-    CODEC_ID_ASV2,
-    CODEC_ID_FFV1,
-    CODEC_ID_4XM,
-    CODEC_ID_VCR1,
-    CODEC_ID_CLJR,
-    CODEC_ID_MDEC,
-    CODEC_ID_ROQ,
-    CODEC_ID_INTERPLAY_VIDEO,
-    CODEC_ID_XAN_WC3,
-    CODEC_ID_XAN_WC4,
-    CODEC_ID_RPZA,
-    CODEC_ID_CINEPAK,
-    CODEC_ID_WS_VQA,
-    CODEC_ID_MSRLE,
-    CODEC_ID_MSVIDEO1,
-    CODEC_ID_IDCIN,
-    CODEC_ID_8BPS,
-    CODEC_ID_SMC,
-    CODEC_ID_FLIC,
-    CODEC_ID_TRUEMOTION1,
-    CODEC_ID_VMDVIDEO,
-    CODEC_ID_MSZH,
-    CODEC_ID_ZLIB,
-    CODEC_ID_QTRLE,
-    CODEC_ID_SNOW,
-    CODEC_ID_TSCC,
-    CODEC_ID_ULTI,
-    CODEC_ID_QDRAW,
-    CODEC_ID_VIXL,
-    CODEC_ID_QPEG,
-    CODEC_ID_XVID,
-    CODEC_ID_PNG,
-    CODEC_ID_PPM,
-    CODEC_ID_PBM,
-    CODEC_ID_PGM,
-    CODEC_ID_PGMYUV,
-    CODEC_ID_PAM,
-    CODEC_ID_FFVHUFF,
-    CODEC_ID_RV30,
-    CODEC_ID_RV40,
-    CODEC_ID_VC9,
-    CODEC_ID_WMV3,
-    CODEC_ID_LOCO,
-    CODEC_ID_WNV1,
-    CODEC_ID_AASC,
-    CODEC_ID_INDEO2,
-    CODEC_ID_FRAPS,
-
-    /* various pcm "codecs" */
-    CODEC_ID_PCM_S16LE= 0x10000,
-    CODEC_ID_PCM_S16BE,
-    CODEC_ID_PCM_U16LE,
-    CODEC_ID_PCM_U16BE,
-    CODEC_ID_PCM_S8,
-    CODEC_ID_PCM_U8,
-    CODEC_ID_PCM_MULAW,
-    CODEC_ID_PCM_ALAW,
-    CODEC_ID_PCM_S32LE,
-    CODEC_ID_PCM_S32BE,
-    CODEC_ID_PCM_U32LE,
-    CODEC_ID_PCM_U32BE,
-    CODEC_ID_PCM_S24LE,
-    CODEC_ID_PCM_S24BE,
-    CODEC_ID_PCM_U24LE,
-    CODEC_ID_PCM_U24BE,
-    CODEC_ID_PCM_S24DAUD,
-
-    /* various adpcm codecs */
-    CODEC_ID_ADPCM_IMA_QT= 0x11000,
-    CODEC_ID_ADPCM_IMA_WAV,
-    CODEC_ID_ADPCM_IMA_DK3,
-    CODEC_ID_ADPCM_IMA_DK4,
-    CODEC_ID_ADPCM_IMA_WS,
-    CODEC_ID_ADPCM_IMA_SMJPEG,
-    CODEC_ID_ADPCM_MS,
-    CODEC_ID_ADPCM_4XM,
-    CODEC_ID_ADPCM_XA,
-    CODEC_ID_ADPCM_ADX,
-    CODEC_ID_ADPCM_EA,
-    CODEC_ID_ADPCM_G726,
-    CODEC_ID_ADPCM_CT,
-    CODEC_ID_ADPCM_SWF,
-    CODEC_ID_ADPCM_YAMAHA,
-
-    /* AMR */
-    CODEC_ID_AMR_NB= 0x12000,
-    CODEC_ID_AMR_WB,
-
-    /* RealAudio codecs*/
-    CODEC_ID_RA_144= 0x13000,
-    CODEC_ID_RA_288,
-
-    /* various DPCM codecs */
-    CODEC_ID_ROQ_DPCM= 0x14000,
-    CODEC_ID_INTERPLAY_DPCM,
-    CODEC_ID_XAN_DPCM,
-    CODEC_ID_SOL_DPCM,
-    
-    CODEC_ID_MP2= 0x15000,
-    CODEC_ID_MP3, /* prefered ID for MPEG Audio layer 1, 2 or3 decoding */
-    CODEC_ID_AAC,
-    CODEC_ID_MPEG4AAC,
-    CODEC_ID_AC3,
-    CODEC_ID_DTS,
-    CODEC_ID_VORBIS,
-    CODEC_ID_DVAUDIO,
-    CODEC_ID_WMAV1,
-    CODEC_ID_WMAV2,
-    CODEC_ID_MACE3,
-    CODEC_ID_MACE6,
-    CODEC_ID_VMDAUDIO,
-    CODEC_ID_SONIC,
-    CODEC_ID_SONIC_LS,
-    CODEC_ID_FLAC,
-    CODEC_ID_MP3ADU,
-    CODEC_ID_MP3ON4,
-    CODEC_ID_SHORTEN,
-    CODEC_ID_ALAC,
-    CODEC_ID_WESTWOOD_SND1,
-    CODEC_ID_GSM,    
-    
-    CODEC_ID_OGGTHEORA= 0x16000, 
-
-    /* subtitle codecs */
-    CODEC_ID_DVD_SUBTITLE= 0x17000, 
-    CODEC_ID_DVB_SUBTITLE, 
-    
-    CODEC_ID_MPEG2TS= 0x20000, /* _FAKE_ codec to indicate a raw MPEG2 transport
-                         stream (only used by libavformat) */
-};
-
-/* CODEC_ID_MP3LAME is absolete */
-#define CODEC_ID_MP3LAME CODEC_ID_MP3
-
-enum CodecType {
-    CODEC_TYPE_UNKNOWN = -1,
-    CODEC_TYPE_VIDEO,
-    CODEC_TYPE_AUDIO,
-    CODEC_TYPE_DATA,
-    CODEC_TYPE_SUBTITLE,
-};
-
-/**
- * Pixel format. Notes: 
- *
- * PIX_FMT_RGBA32 is handled in an endian-specific manner. A RGBA
- * color is put together as:
- *  (A << 24) | (R << 16) | (G << 8) | B
- * This is stored as BGRA on little endian CPU architectures and ARGB on
- * big endian CPUs.
- *
- * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized
- * image data is stored in AVFrame.data[0]. The palette is transported in
- * AVFrame.data[1] and, is 1024 bytes long (256 4-byte entries) and is
- * formatted the same as in PIX_FMT_RGBA32 described above (i.e., it is
- * also endian-specific). Note also that the individual RGB palette
- * components stored in AVFrame.data[1] should be in the range 0..255.
- * This is important as many custom PAL8 video codecs that were designed
- * to run on the IBM VGA graphics adapter use 6-bit palette components.
- */
-enum PixelFormat {
-    PIX_FMT_NONE= -1,
-    PIX_FMT_YUV420P,   ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
-    PIX_FMT_YUV422,    ///< Packed pixel, Y0 Cb Y1 Cr 
-    PIX_FMT_RGB24,     ///< Packed pixel, 3 bytes per pixel, RGBRGB...
-    PIX_FMT_BGR24,     ///< Packed pixel, 3 bytes per pixel, BGRBGR...
-    PIX_FMT_YUV422P,   ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
-    PIX_FMT_YUV444P,   ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
-    PIX_FMT_RGBA32,    ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
-    PIX_FMT_YUV410P,   ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
-    PIX_FMT_YUV411P,   ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
-    PIX_FMT_RGB565,    ///< always stored in cpu endianness 
-    PIX_FMT_RGB555,    ///< always stored in cpu endianness, most significant bit to 1 
-    PIX_FMT_GRAY8,
-    PIX_FMT_MONOWHITE, ///< 0 is white 
-    PIX_FMT_MONOBLACK, ///< 0 is black 
-    PIX_FMT_PAL8,      ///< 8 bit with RGBA palette 
-    PIX_FMT_YUVJ420P,  ///< Planar YUV 4:2:0 full scale (jpeg)
-    PIX_FMT_YUVJ422P,  ///< Planar YUV 4:2:2 full scale (jpeg)
-    PIX_FMT_YUVJ444P,  ///< Planar YUV 4:4:4 full scale (jpeg)
-    PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h)
-    PIX_FMT_XVMC_MPEG2_IDCT,
-    PIX_FMT_UYVY422,   ///< Packed pixel, Cb Y0 Cr Y1 
-    PIX_FMT_UYVY411,   ///< Packed pixel, Cb Y0 Y1 Cr Y2 Y3
-    PIX_FMT_NB,
-};
-
-/* currently unused, may be used if 24/32 bits samples ever supported */
-enum SampleFormat {
-    SAMPLE_FMT_S16 = 0,         ///< signed 16 bits 
-    SAMPLE_FMT_S32,             ///< signed 32 bits 
-    SAMPLE_FMT_FLT,             ///< float
-    SAMPLE_FMT_DBL,             ///< double
-};
-
-/* in bytes */
-#define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
-
-/**
- * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
- * this is mainly needed because some optimized bitstream readers read 
- * 32 or 64 bit at once and could read over the end<br>
- * Note, if the first 23 bits of the additional bytes are not 0 then damaged
- * MPEG bitstreams could cause overread and segfault
- */
-#define FF_INPUT_BUFFER_PADDING_SIZE 8
-
-/**
- * minimum encoding buffer size.
- * used to avoid some checks during header writing
- */
-#define FF_MIN_BUFFER_SIZE 16384
-
-/* motion estimation type, EPZS by default */
-enum Motion_Est_ID {
-    ME_ZERO = 1,
-    ME_FULL,
-    ME_LOG,
-    ME_PHODS,
-    ME_EPZS,
-    ME_X1
-};
-
-enum AVDiscard{
-//we leave some space between them for extensions (drop some keyframes for intra only or drop just some bidir frames)
-    AVDISCARD_NONE   =-16, ///< discard nothing
-    AVDISCARD_DEFAULT=  0, ///< discard useless packets like 0 size packets in avi
-    AVDISCARD_NONREF =  8, ///< discard all non reference
-    AVDISCARD_BIDIR  = 16, ///< discard all bidirectional frames
-    AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
-    AVDISCARD_ALL    = 48, ///< discard all
-};
-
-typedef struct RcOverride{
-    int start_frame;
-    int end_frame;
-    int qscale; // if this is 0 then quality_factor will be used instead
-    float quality_factor;
-} RcOverride;
-
-/* only for ME compatiblity with old apps */
-extern int motion_estimation_method;
-
-#define FF_MAX_B_FRAMES 8
-
-/* encoding support
-   these flags can be passed in AVCodecContext.flags before initing 
-   Note: not everything is supported yet.
-*/
-
-#define CODEC_FLAG_QSCALE 0x0002  ///< use fixed qscale 
-#define CODEC_FLAG_4MV    0x0004  ///< 4 MV per MB allowed / Advanced prediction for H263
-#define CODEC_FLAG_QPEL   0x0010  ///< use qpel MC 
-#define CODEC_FLAG_GMC    0x0020  ///< use GMC 
-#define CODEC_FLAG_MV0    0x0040  ///< always try a MB with MV=<0,0> 
-#define CODEC_FLAG_PART   0x0080  ///< use data partitioning 
-/* parent program gurantees that the input for b-frame containing streams is not written to 
-   for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
-#define CODEC_FLAG_INPUT_PRESERVED 0x0100
-#define CODEC_FLAG_PASS1 0x0200   ///< use internal 2pass ratecontrol in first  pass mode 
-#define CODEC_FLAG_PASS2 0x0400   ///< use internal 2pass ratecontrol in second pass mode 
-#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg) 
-#define CODEC_FLAG_GRAY  0x2000   ///< only decode/encode grayscale 
-#define CODEC_FLAG_EMU_EDGE 0x4000///< don't draw edges
-#define CODEC_FLAG_PSNR           0x8000 ///< error[?] variables will be set during encoding 
-#define CODEC_FLAG_TRUNCATED  0x00010000 /** input bitstream might be truncated at a random location instead 
-                                            of only at frame boundaries */
-#define CODEC_FLAG_NORMALIZE_AQP  0x00020000 ///< normalize adaptive quantization 
-#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct 
-#define CODEC_FLAG_LOW_DELAY      0x00080000 ///< force low delay
-#define CODEC_FLAG_ALT_SCAN       0x00100000 ///< use alternate scan 
-#define CODEC_FLAG_TRELLIS_QUANT  0x00200000 ///< use trellis quantization 
-#define CODEC_FLAG_GLOBAL_HEADER  0x00400000 ///< place global headers in extradata instead of every keyframe 
-#define CODEC_FLAG_BITEXACT       0x00800000 ///< use only bitexact stuff (except (i)dct) 
-/* Fx : Flag for h263+ extra options */
-#define CODEC_FLAG_H263P_AIC      0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction (remove this)
-#define CODEC_FLAG_AC_PRED        0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction
-#define CODEC_FLAG_H263P_UMV      0x02000000 ///< Unlimited motion vector  
-#define CODEC_FLAG_CBP_RD         0x04000000 ///< use rate distortion optimization for cbp
-#define CODEC_FLAG_QP_RD          0x08000000 ///< use rate distortion optimization for qp selectioon
-#define CODEC_FLAG_H263P_AIV      0x00000008 ///< H263 Alternative inter vlc
-#define CODEC_FLAG_OBMC           0x00000001 ///< OBMC
-#define CODEC_FLAG_LOOP_FILTER    0x00000800 ///< loop filter
-#define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
-#define CODEC_FLAG_INTERLACED_ME  0x20000000 ///< interlaced motion estimation
-#define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< will reserve space for SVCD scan offset user data
-#define CODEC_FLAG_CLOSED_GOP     0x80000000
-#define CODEC_FLAG2_FAST          0x00000001 ///< allow non spec compliant speedup tricks
-#define CODEC_FLAG2_STRICT_GOP    0x00000002 ///< strictly enforce GOP size
-#define CODEC_FLAG2_NO_OUTPUT     0x00000004 ///< skip bitstream encoding
-#define CODEC_FLAG2_LOCAL_HEADER  0x00000008 ///< place global headers at every keyframe instead of in extradata
-
-/* Unsupported options :
- * 		Syntax Arithmetic coding (SAC)
- * 		Reference Picture Selection
- * 		Independant Segment Decoding */
-/* /Fx */
-/* codec capabilities */
-
-#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback 
-/**
- * Codec uses get_buffer() for allocating buffers.
- * direct rendering method 1
- */
-#define CODEC_CAP_DR1             0x0002
-/* if 'parse_only' field is true, then avcodec_parse_frame() can be
-   used */
-#define CODEC_CAP_PARSE_ONLY      0x0004
-#define CODEC_CAP_TRUNCATED       0x0008
-/* codec can export data for HW decoding (XvMC) */
-#define CODEC_CAP_HWACCEL         0x0010
-/** 
- * codec has a non zero delay and needs to be feeded with NULL at the end to get the delayed data.
- * if this is not set, the codec is guranteed to never be feeded with NULL data
- */
-#define CODEC_CAP_DELAY           0x0020
-
-//the following defines may change, don't expect compatibility if you use them
-#define MB_TYPE_INTRA4x4   0x0001
-#define MB_TYPE_INTRA16x16 0x0002 //FIXME h264 specific
-#define MB_TYPE_INTRA_PCM  0x0004 //FIXME h264 specific
-#define MB_TYPE_16x16      0x0008
-#define MB_TYPE_16x8       0x0010
-#define MB_TYPE_8x16       0x0020
-#define MB_TYPE_8x8        0x0040
-#define MB_TYPE_INTERLACED 0x0080
-#define MB_TYPE_DIRECT2     0x0100 //FIXME
-#define MB_TYPE_ACPRED     0x0200
-#define MB_TYPE_GMC        0x0400
-#define MB_TYPE_SKIP       0x0800
-#define MB_TYPE_P0L0       0x1000
-#define MB_TYPE_P1L0       0x2000
-#define MB_TYPE_P0L1       0x4000
-#define MB_TYPE_P1L1       0x8000
-#define MB_TYPE_L0         (MB_TYPE_P0L0 | MB_TYPE_P1L0)
-#define MB_TYPE_L1         (MB_TYPE_P0L1 | MB_TYPE_P1L1)
-#define MB_TYPE_L0L1       (MB_TYPE_L0   | MB_TYPE_L1)
-#define MB_TYPE_QUANT      0x00010000
-#define MB_TYPE_CBP        0x00020000
-//Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
-
-/**
- * Pan Scan area.
- * this specifies the area which should be displayed. Note there may be multiple such areas for one frame
- */
-typedef struct AVPanScan{
-    /**
-     * id.
-     * - encoding: set by user.
-     * - decoding: set by lavc
-     */
-    int id;
-
-    /**
-     * width and height in 1/16 pel
-     * - encoding: set by user.
-     * - decoding: set by lavc
-     */
-    int width;
-    int height;
-
-    /**
-     * position of the top left corner in 1/16 pel for up to 3 fields/frames.
-     * - encoding: set by user.
-     * - decoding: set by lavc
-     */
-    int16_t position[3][2];
-}AVPanScan;
-
-#define FF_COMMON_FRAME \
-    /**\
-     * pointer to the picture planes.\
-     * this might be different from the first allocated byte\
-     * - encoding: \
-     * - decoding: \
-     */\
-    uint8_t *data[4];\
-    int linesize[4];\
-    /**\
-     * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
-     * this isn't used by lavc unless the default get/release_buffer() is used\
-     * - encoding: \
-     * - decoding: \
-     */\
-    uint8_t *base[4];\
-    /**\
-     * 1 -> keyframe, 0-> not\
-     * - encoding: set by lavc\
-     * - decoding: set by lavc\
-     */\
-    int key_frame;\
-\
-    /**\
-     * picture type of the frame, see ?_TYPE below.\
-     * - encoding: set by lavc for coded_picture (and set by user for input)\
-     * - decoding: set by lavc\
-     */\
-    int pict_type;\
-\
-    /**\
-     * presentation timestamp in time_base units (time when frame should be shown to user)\
-     * if AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed\
-     * - encoding: MUST be set by user\
-     * - decoding: set by lavc\
-     */\
-    int64_t pts;\
-\
-    /**\
-     * picture number in bitstream order.\
-     * - encoding: set by\
-     * - decoding: set by lavc\
-     */\
-    int coded_picture_number;\
-    /**\
-     * picture number in display order.\
-     * - encoding: set by\
-     * - decoding: set by lavc\
-     */\
-    int display_picture_number;\
-\
-    /**\
-     * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \
-     * - encoding: set by lavc for coded_picture (and set by user for input)\
-     * - decoding: set by lavc\
-     */\
-    int quality; \
-\
-    /**\
-     * buffer age (1->was last buffer and dint change, 2->..., ...).\
-     * set to INT_MAX if the buffer has not been used yet \
-     * - encoding: unused\
-     * - decoding: MUST be set by get_buffer()\
-     */\
-    int age;\
-\
-    /**\
-     * is this picture used as reference\
-     * - encoding: unused\
-     * - decoding: set by lavc (before get_buffer() call))\
-     */\
-    int reference;\
-\
-    /**\
-     * QP table\
-     * - encoding: unused\
-     * - decoding: set by lavc\
-     */\
-    int8_t *qscale_table;\
-    /**\
-     * QP store stride\
-     * - encoding: unused\
-     * - decoding: set by lavc\
-     */\
-    int qstride;\
-\
-    /**\
-     * mbskip_table[mb]>=1 if MB didnt change\
-     * stride= mb_width = (width+15)>>4\
-     * - encoding: unused\
-     * - decoding: set by lavc\
-     */\
-    uint8_t *mbskip_table;\
-\
-    /**\
-     * Motion vector table.\
-     * @code\
-     * example:\
-     * int mv_sample_log2= 4 - motion_subsample_log2;\
-     * int mb_width= (width+15)>>4;\
-     * int mv_stride= (mb_width << mv_sample_log2) + 1;\
-     * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\
-     * @endcode\
-     * - encoding: set by user\
-     * - decoding: set by lavc\
-     */\
-    int16_t (*motion_val[2])[2];\
-\
-    /**\
-     * Macroblock type table\
-     * mb_type_base + mb_width + 2\
-     * - encoding: set by user\
-     * - decoding: set by lavc\
-     */\
-    uint32_t *mb_type;\
-\
-    /**\
-     * log2 of the size of the block which a single vector in motion_val represents: \
-     * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\
-     * - encoding: unused\
-     * - decoding: set by lavc\
-     */\
-    uint8_t motion_subsample_log2;\
-\
-    /**\
-     * for some private data of the user\
-     * - encoding: unused\
-     * - decoding: set by user\
-     */\
-    void *opaque;\
-\
-    /**\
-     * error\
-     * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
-     * - decoding: unused\
-     */\
-    uint64_t error[4];\
-\
-    /**\
-     * type of the buffer (to keep track of who has to dealloc data[*])\
-     * - encoding: set by the one who allocs it\
-     * - decoding: set by the one who allocs it\
-     * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
-     */\
-    int type;\
-    \
-    /**\
-     * when decoding, this signal how much the picture must be delayed.\
-     * extra_delay = repeat_pict / (2*fps)\
-     * - encoding: unused\
-     * - decoding: set by lavc\
-     */\
-    int repeat_pict;\
-    \
-    /**\
-     * \
-     */\
-    int qscale_type;\
-    \
-    /**\
-     * The content of the picture is interlaced.\
-     * - encoding: set by user\
-     * - decoding: set by lavc (default 0)\
-     */\
-    int interlaced_frame;\
-    \
-    /**\
-     * if the content is interlaced, is top field displayed first.\
-     * - encoding: set by user\
-     * - decoding: set by lavc\
-     */\
-    int top_field_first;\
-    \
-    /**\
-     * Pan scan.\
-     * - encoding: set by user\
-     * - decoding: set by lavc\
-     */\
-    AVPanScan *pan_scan;\
-    \
-    /**\
-     * tell user application that palette has changed from previous frame.\
-     * - encoding: ??? (no palette-enabled encoder yet)\
-     * - decoding: set by lavc (default 0)\
-     */\
-    int palette_has_changed;\
-    \
-    /**\
-     * Codec suggestion on buffer type if != 0\
-     * - encoding: unused\
-     * - decoding: set by lavc (before get_buffer() call))\
-     */\
-    int buffer_hints;\
-\
-    /**\
-     * DCT coeffitients\
-     * - encoding: unused\
-     * - decoding: set by lavc\
-     */\
-    short *dct_coeff;\
-\
-    /**\
-     * Motion referece frame index\
-     * - encoding: set by user\
-     * - decoding: set by lavc\
-     */\
-    int8_t *ref_index[2];
-
-#define FF_QSCALE_TYPE_MPEG1	0
-#define FF_QSCALE_TYPE_MPEG2	1
-
-#define FF_BUFFER_TYPE_INTERNAL 1
-#define FF_BUFFER_TYPE_USER     2 ///< Direct rendering buffers (image is (de)allocated by user)
-#define FF_BUFFER_TYPE_SHARED   4 ///< buffer from somewhere else, don't dealloc image (data/base), all other tables are not shared
-#define FF_BUFFER_TYPE_COPY     8 ///< just a (modified) copy of some other buffer, don't dealloc anything
-
-
-#define FF_I_TYPE 1 // Intra
-#define FF_P_TYPE 2 // Predicted
-#define FF_B_TYPE 3 // Bi-dir predicted
-#define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
-#define FF_SI_TYPE 5
-#define FF_SP_TYPE 6
-
-#define FF_BUFFER_HINTS_VALID    0x01 // Buffer hints value is meaningful (if 0 ignore)
-#define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer
-#define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content
-#define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update)
-
-/**
- * Audio Video Frame.
- */
-typedef struct AVFrame {
-    FF_COMMON_FRAME
-} AVFrame;
-
-#define DEFAULT_FRAME_RATE_BASE 1001000
-
-/**
- * Used by av_log
- */
-typedef struct AVCLASS AVClass;
-struct AVCLASS {
-    const char* class_name;
-    const char* (*item_name)(void*); /* actually passing a pointer to an AVCodecContext
-					or AVFormatContext, which begin with an AVClass.
-					Needed because av_log is in libavcodec and has no visibility
-					of AVIn/OutputFormat */
-    struct AVOption *option;
-};
-
-/**
- * main external api structure.
- */
-typedef struct AVCodecContext {
-    /**
-     * Info on struct for av_log
-     * - set by avcodec_alloc_context
-     */
-    AVClass *av_class;
-    /**
-     * the average bitrate.
-     * - encoding: set by user. unused for constant quantizer encoding
-     * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream 
-     */
-    int bit_rate;
-
-    /**
-     * number of bits the bitstream is allowed to diverge from the reference.
-     *           the reference can be CBR (for CBR pass1) or VBR (for pass2)
-     * - encoding: set by user. unused for constant quantizer encoding
-     * - decoding: unused
-     */
-    int bit_rate_tolerance; 
-
-    /**
-     * CODEC_FLAG_*.
-     * - encoding: set by user.
-     * - decoding: set by user.
-     */
-    int flags;
-
-    /**
-     * some codecs needs additionnal format info. It is stored here
-     * - encoding: set by user. 
-     * - decoding: set by lavc. (FIXME is this ok?)
-     */
-    int sub_id;
-
-    /**
-     * motion estimation algorithm used for video coding.
-     * - encoding: MUST be set by user.
-     * - decoding: unused
-     */
-    int me_method;
-
-    /**
-     * some codecs need / can use extra-data like huffman tables.
-     * mjpeg: huffman tables
-     * rv10: additional flags
-     * mpeg4: global headers (they can be in the bitstream or here)
-     * the allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
-     * then extradata_size to avoid prolems if its read with the bitstream reader
-     * - encoding: set/allocated/freed by lavc.
-     * - decoding: set/allocated/freed by user.
-     */
-    void *extradata;
-    int extradata_size;
-    
-    /**
-     * this is the fundamental unit of time (in seconds) in terms
-     * of which frame timestamps are represented. for fixed-fps content,
-     * timebase should be 1/framerate and timestamp increments should be
-     * identically 1.
-     * - encoding: MUST be set by user
-     * - decoding: set by lavc.
-     */
-    AVRational time_base;
-    
-    /* video only */
-    /**
-     * picture width / height.
-     * - encoding: MUST be set by user. 
-     * - decoding: set by lavc.
-     * Note, for compatibility its possible to set this instead of 
-     * coded_width/height before decoding
-     */
-    int width, height;
-    
-#define FF_ASPECT_EXTENDED 15
-
-    /**
-     * the number of pictures in a group of pitures, or 0 for intra_only.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int gop_size;
-
-    /**
-     * pixel format, see PIX_FMT_xxx.
-     * - encoding: set by user.
-     * - decoding: set by lavc.
-     */
-    enum PixelFormat pix_fmt;
- 
-    /**
-     * Frame rate emulation. If not zero lower layer (i.e. format handler) 
-     * has to read frames at native frame rate.
-     * - encoding: set by user.
-     * - decoding: unused.
-     */
-    int rate_emu;
-       
-    /**
-     * if non NULL, 'draw_horiz_band' is called by the libavcodec
-     * decoder to draw an horizontal band. It improve cache usage. Not
-     * all codecs can do that. You must check the codec capabilities
-     * before
-     * - encoding: unused
-     * - decoding: set by user.
-     * @param height the height of the slice
-     * @param y the y position of the slice
-     * @param type 1->top field, 2->bottom field, 3->frame
-     * @param offset offset into the AVFrame.data from which the slice should be read
-     */
-    void (*draw_horiz_band)(struct AVCodecContext *s,
-                            const AVFrame *src, int offset[4],
-                            int y, int type, int height);
-
-    /* audio only */
-    int sample_rate; ///< samples per sec 
-    int channels;
-
-    /**
-     * audio sample format.
-     * - encoding: set by user.
-     * - decoding: set by lavc.
-     */
-    enum SampleFormat sample_fmt;  ///< sample format, currenly unused 
-
-    /* the following data should not be initialized */
-    /**
-     * samples per packet. initialized when calling 'init' 
-     */
-    int frame_size;
-    int frame_number;   ///< audio or video frame number 
-    int real_pict_num;  ///< returns the real picture number of previous encoded frame 
-    
-    /**
-     * number of frames the decoded output will be delayed relative to 
-     * the encoded input.
-     * - encoding: set by lavc.
-     * - decoding: unused
-     */
-    int delay;
-    
-    /* - encoding parameters */
-    float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0)
-    float qblur;      ///< amount of qscale smoothing over time (0.0-1.0) 
-    
-    /**
-     * minimum quantizer.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int qmin;
-
-    /**
-     * maximum quantizer.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int qmax;
-
-    /**
-     * maximum quantizer difference etween frames.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int max_qdiff;
-
-    /**
-     * maximum number of b frames between non b frames.
-     * note: the output will be delayed by max_b_frames+1 relative to the input
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int max_b_frames;
-
-    /**
-     * qscale factor between ip and b frames.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    float b_quant_factor;
-    
-    /** obsolete FIXME remove */
-    int rc_strategy;
-    int b_frame_strategy;
-
-    /**
-     * hurry up amount.
-     * deprecated in favor of skip_idct and skip_frame
-     * - encoding: unused
-     * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
-     */
-    int hurry_up;
-    
-    struct AVCodec *codec;
-    
-    void *priv_data;
-
-    /* unused, FIXME remove*/
-    int rtp_mode;
-    
-    int rtp_payload_size;   /* The size of the RTP payload: the coder will  */
-                            /* do it's best to deliver a chunk with size    */
-                            /* below rtp_payload_size, the chunk will start */
-                            /* with a start code on some codecs like H.263  */
-                            /* This doesn't take account of any particular  */
-                            /* headers inside the transmited RTP payload    */
-
-    
-    /* The RTP callback: This function is called   */
-    /* every time the encoder has a packet to send */
-    /* Depends on the encoder if the data starts   */
-    /* with a Start Code (it should) H.263 does.   */
-    /* mb_nb contains the number of macroblocks    */
-    /* encoded in the RTP payload                  */
-    void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb); 
-
-    /* statistics, used for 2-pass encoding */
-    int mv_bits;
-    int header_bits;
-    int i_tex_bits;
-    int p_tex_bits;
-    int i_count;
-    int p_count;
-    int skip_count;
-    int misc_bits;
-    
-    /**
-     * number of bits used for the previously encoded frame.
-     * - encoding: set by lavc
-     * - decoding: unused
-     */
-    int frame_bits;
-
-    /**
-     * private data of the user, can be used to carry app specific stuff.
-     * - encoding: set by user
-     * - decoding: set by user
-     */
-    void *opaque;
-
-    char codec_name[32];
-    enum CodecType codec_type; /* see CODEC_TYPE_xxx */
-    enum CodecID codec_id; /* see CODEC_ID_xxx */
-    
-    /**
-     * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
-     * this is used to workaround some encoder bugs
-     * - encoding: set by user, if not then the default based on codec_id will be used
-     * - decoding: set by user, will be converted to upper case by lavc during init
-     */
-    unsigned int codec_tag;
-    
-    /**
-     * workaround bugs in encoders which sometimes cannot be detected automatically.
-     * - encoding: set by user
-     * - decoding: set by user
-     */
-    int workaround_bugs;
-#define FF_BUG_AUTODETECT       1  ///< autodetection
-#define FF_BUG_OLD_MSMPEG4      2
-#define FF_BUG_XVID_ILACE       4
-#define FF_BUG_UMP4             8
-#define FF_BUG_NO_PADDING       16
-#define FF_BUG_AMV              32
-#define FF_BUG_AC_VLC           0  ///< will be removed, libavcodec can now handle these non compliant files by default
-#define FF_BUG_QPEL_CHROMA      64
-#define FF_BUG_STD_QPEL         128
-#define FF_BUG_QPEL_CHROMA2     256
-#define FF_BUG_DIRECT_BLOCKSIZE 512
-#define FF_BUG_EDGE             1024
-#define FF_BUG_HPEL_CHROMA      2048
-#define FF_BUG_DC_CLIP          4096
-#define FF_BUG_MS               8192 ///< workaround various bugs in microsofts broken decoders
-//#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
-        
-    /**
-     * luma single coeff elimination threshold.
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    int luma_elim_threshold;
-    
-    /**
-     * chroma single coeff elimination threshold.
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    int chroma_elim_threshold;
-    
-    /**
-     * strictly follow the std (MPEG4, ...).
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    int strict_std_compliance;
-#define FF_COMPLIANCE_VERY_STRICT   2 ///< strictly conform to a older more strict version of the spec or reference software
-#define FF_COMPLIANCE_STRICT        1 ///< strictly conform to all the things in the spec no matter what consequences
-#define FF_COMPLIANCE_NORMAL        0
-#define FF_COMPLIANCE_INOFFICIAL   -1 ///< allow inofficial extensions
-#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< allow non standarized experimental things
-
-    /**
-     * qscale offset between ip and b frames.
-     * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
-     * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    float b_quant_offset;
-    
-    /**
-     * error resilience higher values will detect more errors but may missdetect
-     * some more or less valid parts as errors.
-     * - encoding: unused
-     * - decoding: set by user
-     */
-    int error_resilience;
-#define FF_ER_CAREFUL         1
-#define FF_ER_COMPLIANT       2
-#define FF_ER_AGGRESSIVE      3
-#define FF_ER_VERY_AGGRESSIVE 4
-    
-    /**
-     * called at the beginning of each frame to get a buffer for it.
-     * if pic.reference is set then the frame will be read later by lavc
-     * avcodec_align_dimensions() should be used to find the required width and
-     * height, as they normally need to be rounded up to the next multiple of 16
-     * - encoding: unused
-     * - decoding: set by lavc, user can override
-     */
-    int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
-    
-    /**
-     * called to release buffers which where allocated with get_buffer.
-     * a released buffer can be reused in get_buffer()
-     * pic.data[*] must be set to NULL
-     * - encoding: unused
-     * - decoding: set by lavc, user can override
-     */
-    void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
-
-    /**
-     * if 1 the stream has a 1 frame delay during decoding.
-     * - encoding: set by lavc
-     * - decoding: set by lavc
-     */
-    int has_b_frames;
-
-    /**
-     * number of bytes per packet if constant and known or 0
-     * used by some WAV based audio codecs
-     */
-    int block_align;
-    
-    int parse_only; /* - decoding only: if true, only parsing is done
-                       (function avcodec_parse_frame()). The frame
-                       data is returned. Only MPEG codecs support this now. */
-    
-    /**
-     * 0-> h263 quant 1-> mpeg quant.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int mpeg_quant;
-    
-    /**
-     * pass1 encoding statistics output buffer.
-     * - encoding: set by lavc
-     * - decoding: unused
-     */
-    char *stats_out;
-    
-    /**
-     * pass2 encoding statistics input buffer.
-     * concatenated stuff from stats_out of pass1 should be placed here
-     * - encoding: allocated/set/freed by user
-     * - decoding: unused
-     */
-    char *stats_in;
-    
-    /**
-     * ratecontrol qmin qmax limiting method.
-     * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    float rc_qsquish;
-
-    float rc_qmod_amp;
-    int rc_qmod_freq;
-    
-    /**
-     * ratecontrol override, see RcOverride.
-     * - encoding: allocated/set/freed by user.
-     * - decoding: unused
-     */
-    RcOverride *rc_override;
-    int rc_override_count;
-    
-    /**
-     * rate control equation.
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    char *rc_eq;
-    
-    /**
-     * maximum bitrate.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int rc_max_rate;
-    
-    /**
-     * minimum bitrate.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int rc_min_rate;
-    
-    /**
-     * decoder bitstream buffer size.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int rc_buffer_size;
-    float rc_buffer_aggressivity;
-
-    /**
-     * qscale factor between p and i frames.
-     * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
-     * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    float i_quant_factor;
-    
-    /**
-     * qscale offset between p and i frames.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    float i_quant_offset;
-    
-    /**
-     * initial complexity for pass1 ratecontrol.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    float rc_initial_cplx;
-
-    /**
-     * dct algorithm, see FF_DCT_* below.
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    int dct_algo;
-#define FF_DCT_AUTO    0
-#define FF_DCT_FASTINT 1
-#define FF_DCT_INT     2
-#define FF_DCT_MMX     3
-#define FF_DCT_MLIB    4
-#define FF_DCT_ALTIVEC 5
-#define FF_DCT_FAAN    6
-    
-    /**
-     * luminance masking (0-> disabled).
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    float lumi_masking;
-    
-    /**
-     * temporary complexity masking (0-> disabled).
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    float temporal_cplx_masking;
-    
-    /**
-     * spatial complexity masking (0-> disabled).
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    float spatial_cplx_masking;
-    
-    /**
-     * p block masking (0-> disabled).
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    float p_masking;
-
-    /**
-     * darkness masking (0-> disabled).
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    float dark_masking;
-    
-    
-    /* for binary compatibility */
-    int unused;
-    
-    /**
-     * idct algorithm, see FF_IDCT_* below.
-     * - encoding: set by user
-     * - decoding: set by user
-     */
-    int idct_algo;
-#define FF_IDCT_AUTO         0
-#define FF_IDCT_INT          1
-#define FF_IDCT_SIMPLE       2
-#define FF_IDCT_SIMPLEMMX    3
-#define FF_IDCT_LIBMPEG2MMX  4
-#define FF_IDCT_PS2          5
-#define FF_IDCT_MLIB         6
-#define FF_IDCT_ARM          7
-#define FF_IDCT_ALTIVEC      8
-#define FF_IDCT_SH4          9
-#define FF_IDCT_SIMPLEARM    10
-#define FF_IDCT_H264         11
-#define FF_IDCT_VP3          12
-#define FF_IDCT_IPP          13
-#define FF_IDCT_XVIDMMX      14
-
-    /**
-     * slice count.
-     * - encoding: set by lavc
-     * - decoding: set by user (or 0)
-     */
-    int slice_count;
-    /**
-     * slice offsets in the frame in bytes.
-     * - encoding: set/allocated by lavc
-     * - decoding: set/allocated by user (or NULL)
-     */
-    int *slice_offset;
-
-    /**
-     * error concealment flags.
-     * - encoding: unused
-     * - decoding: set by user
-     */
-    int error_concealment;
-#define FF_EC_GUESS_MVS   1
-#define FF_EC_DEBLOCK     2
-
-    /**
-     * dsp_mask could be add used to disable unwanted CPU features
-     * CPU features (i.e. MMX, SSE. ...)
-     *
-     * with FORCE flag you may instead enable given CPU features
-     * (Dangerous: usable in case of misdetection, improper usage however will
-     * result into program crash)
-     */
-    unsigned dsp_mask;
-#define FF_MM_FORCE	0x80000000 /* force usage of selected flags (OR) */
-    /* lower 16 bits - CPU features */
-#ifdef HAVE_MMX
-#define FF_MM_MMX	0x0001 /* standard MMX */
-#define FF_MM_3DNOW	0x0004 /* AMD 3DNOW */
-#define FF_MM_MMXEXT	0x0002 /* SSE integer functions or AMD MMX ext */
-#define FF_MM_SSE	0x0008 /* SSE functions */
-#define FF_MM_SSE2	0x0010 /* PIV SSE2 functions */
-#define FF_MM_3DNOWEXT	0x0020 /* AMD 3DNowExt */
-#endif /* HAVE_MMX */
-#ifdef HAVE_IWMMXT
-#define FF_MM_IWMMXT	0x0100 /* XScale IWMMXT */
-#endif /* HAVE_IWMMXT */
-
-    /**
-     * bits per sample/pixel from the demuxer (needed for huffyuv).
-     * - encoding: set by lavc
-     * - decoding: set by user
-     */
-     int bits_per_sample;
-    
-    /**
-     * prediction method (needed for huffyuv).
-     * - encoding: set by user
-     * - decoding: unused
-     */
-     int prediction_method;
-#define FF_PRED_LEFT   0
-#define FF_PRED_PLANE  1
-#define FF_PRED_MEDIAN 2
-    
-    /**
-     * sample aspect ratio (0 if unknown).
-     * numerator and denominator must be relative prime and smaller then 256 for some video standards
-     * - encoding: set by user.
-     * - decoding: set by lavc.
-     */
-    AVRational sample_aspect_ratio;
-
-    /**
-     * the picture in the bitstream.
-     * - encoding: set by lavc
-     * - decoding: set by lavc
-     */
-    AVFrame *coded_frame;
-
-    /**
-     * debug.
-     * - encoding: set by user.
-     * - decoding: set by user.
-     */
-    int debug;
-#define FF_DEBUG_PICT_INFO 1
-#define FF_DEBUG_RC        2
-#define FF_DEBUG_BITSTREAM 4
-#define FF_DEBUG_MB_TYPE   8
-#define FF_DEBUG_QP        16
-#define FF_DEBUG_MV        32
-#define FF_DEBUG_DCT_COEFF 0x00000040
-#define FF_DEBUG_SKIP      0x00000080
-#define FF_DEBUG_STARTCODE 0x00000100
-#define FF_DEBUG_PTS       0x00000200
-#define FF_DEBUG_ER        0x00000400
-#define FF_DEBUG_MMCO      0x00000800
-#define FF_DEBUG_BUGS      0x00001000
-#define FF_DEBUG_VIS_QP    0x00002000
-#define FF_DEBUG_VIS_MB_TYPE 0x00004000
-    
-    /**
-     * 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
-
-    /**
-     * error.
-     * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
-     * - decoding: unused
-     */
-    uint64_t error[4];
-    
-    /**
-     * minimum MB quantizer.
-     * - encoding: unused
-     * - decoding: unused
-     */
-    int mb_qmin;
-
-    /**
-     * maximum MB quantizer.
-     * - encoding: unused
-     * - decoding: unused
-     */
-    int mb_qmax;
-    
-    /**
-     * motion estimation compare function.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int me_cmp;
-    /**
-     * subpixel motion estimation compare function.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int me_sub_cmp;
-    /**
-     * macroblock compare function (not supported yet).
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int mb_cmp;
-    /**
-     * interlaced dct compare function
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int ildct_cmp;
-#define FF_CMP_SAD  0
-#define FF_CMP_SSE  1
-#define FF_CMP_SATD 2
-#define FF_CMP_DCT  3
-#define FF_CMP_PSNR 4
-#define FF_CMP_BIT  5
-#define FF_CMP_RD   6
-#define FF_CMP_ZERO 7
-#define FF_CMP_VSAD 8
-#define FF_CMP_VSSE 9
-#define FF_CMP_NSSE 10
-#define FF_CMP_W53  11
-#define FF_CMP_W97  12
-#define FF_CMP_DCTMAX 13
-#define FF_CMP_CHROMA 256
-    
-    /**
-     * ME diamond size & shape.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int dia_size;
-
-    /**
-     * amount of previous MV predictors (2a+1 x 2a+1 square).
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int last_predictor_count;
-
-    /**
-     * pre pass for motion estimation.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int pre_me;
-
-    /**
-     * motion estimation pre pass compare function.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int me_pre_cmp;
-
-    /**
-     * ME pre pass diamond size & shape.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int pre_dia_size;
-
-    /**
-     * subpel ME quality.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int me_subpel_quality;
-
-    /**
-     * callback to negotiate the pixelFormat.
-     * @param fmt is the list of formats which are supported by the codec,
-     * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
-     * the first is allways the native one
-     * @return the choosen format
-     * - encoding: unused
-     * - decoding: set by user, if not set then the native format will always be choosen
-     */
-    enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
-
-    /**
-     * DTG active format information (additionnal aspect ratio
-     * information only used in DVB MPEG2 transport streams). 0 if
-     * not set.
-     * 
-     * - encoding: unused.
-     * - decoding: set by decoder 
-     */
-    int dtg_active_format;
-#define FF_DTG_AFD_SAME         8
-#define FF_DTG_AFD_4_3          9
-#define FF_DTG_AFD_16_9         10
-#define FF_DTG_AFD_14_9         11
-#define FF_DTG_AFD_4_3_SP_14_9  13
-#define FF_DTG_AFD_16_9_SP_14_9 14
-#define FF_DTG_AFD_SP_4_3       15
-
-    /**
-     * Maximum motion estimation search range in subpel units.
-     * if 0 then no limit
-     * 
-     * - encoding: set by user.
-     * - decoding: unused.
-     */
-    int me_range;
-
-    /**
-     * intra quantizer bias.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int intra_quant_bias;
-#define FF_DEFAULT_QUANT_BIAS 999999
-    
-    /**
-     * inter quantizer bias.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int inter_quant_bias;
-
-    /**
-     * color table ID.
-     * - encoding: unused.
-     * - decoding: which clrtable should be used for 8bit RGB images
-     *             table have to be stored somewhere FIXME
-     */
-    int color_table_id;
-    
-    /**
-     * internal_buffer count. 
-     * Don't touch, used by lavc default_get_buffer()
-     */
-    int internal_buffer_count;
-    
-    /**
-     * internal_buffers. 
-     * Don't touch, used by lavc default_get_buffer()
-     */
-    void *internal_buffer;
-
-#define FF_LAMBDA_SHIFT 7
-#define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
-#define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
-#define FF_LAMBDA_MAX (256*128-1)
-
-#define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
-    /**
-     * global quality for codecs which cannot change it per frame.
-     * this should be proportional to MPEG1/2/4 qscale.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int global_quality;
-    
-#define FF_CODER_TYPE_VLC   0
-#define FF_CODER_TYPE_AC    1
-    /**
-     * coder type
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int coder_type;
-
-    /**
-     * context model
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int context_model;
-    
-    /**
-     * slice flags
-     * - encoding: unused
-     * - decoding: set by user.
-     */
-    int slice_flags;
-#define SLICE_FLAG_CODED_ORDER    0x0001 ///< draw_horiz_band() is called in coded order instead of display
-#define SLICE_FLAG_ALLOW_FIELD    0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
-#define SLICE_FLAG_ALLOW_PLANE    0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
-
-    /**
-     * XVideo Motion Acceleration
-     * - encoding: forbidden
-     * - decoding: set by decoder
-     */
-    int xvmc_acceleration;
-    
-    /**
-     * macroblock decision mode
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int mb_decision;
-#define FF_MB_DECISION_SIMPLE 0        ///< uses mb_cmp
-#define FF_MB_DECISION_BITS   1        ///< chooses the one which needs the fewest bits
-#define FF_MB_DECISION_RD     2        ///< rate distoration
-
-    /**
-     * custom intra quantization matrix
-     * - encoding: set by user, can be NULL
-     * - decoding: set by lavc
-     */
-    uint16_t *intra_matrix;
-
-    /**
-     * custom inter quantization matrix
-     * - encoding: set by user, can be NULL
-     * - decoding: set by lavc
-     */
-    uint16_t *inter_matrix;
-    
-    /**
-     * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
-     * this is used to workaround some encoder bugs
-     * - encoding: unused
-     * - decoding: set by user, will be converted to upper case by lavc during init
-     */
-    unsigned int stream_codec_tag;
-
-    /**
-     * scene change detection threshold.
-     * 0 is default, larger means fewer detected scene changes
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int scenechange_threshold;
-
-    /**
-     * minimum lagrange multipler
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int lmin;
-
-    /**
-     * maximum lagrange multipler
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int lmax;
-
-    /**
-     * Palette control structure
-     * - encoding: ??? (no palette-enabled encoder yet)
-     * - decoding: set by user.
-     */
-    struct AVPaletteControl *palctrl;
-
-    /**
-     * noise reduction strength
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int noise_reduction;
-    
-    /**
-     * called at the beginning of a frame to get cr buffer for it.
-     * buffer type (size, hints) must be the same. lavc won't check it.
-     * lavc will pass previous buffer in pic, function should return
-     * same buffer or new buffer with old frame "painted" into it.
-     * if pic.data[0] == NULL must behave like get_buffer().
-     * - encoding: unused
-     * - decoding: set by lavc, user can override
-     */
-    int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
-
-    /**
-     * number of bits which should be loaded into the rc buffer before decoding starts
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int rc_initial_buffer_occupancy;
-
-    /**
-     *
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int inter_threshold;
-
-    /**
-     * CODEC_FLAG2_*.
-     * - encoding: set by user.
-     * - decoding: set by user.
-     */
-    int flags2;
-
-    /**
-     * simulates errors in the bitstream to test error concealment.
-     * - encoding: set by user.
-     * - decoding: unused.
-     */
-    int error_rate;
-    
-    /**
-     * MP3 antialias algorithm, see FF_AA_* below.
-     * - encoding: unused
-     * - decoding: set by user
-     */
-    int antialias_algo;
-#define FF_AA_AUTO    0
-#define FF_AA_FASTINT 1 //not implemented yet
-#define FF_AA_INT     2
-#define FF_AA_FLOAT   3
-    /**
-     * Quantizer noise shaping.
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    int quantizer_noise_shaping;
-
-    /**
-     * Thread count.
-     * is used to decide how many independant tasks should be passed to execute()
-     * - encoding: set by user
-     * - decoding: set by user
-     */
-    int thread_count;
-    
-    /**
-     * the codec may call this to execute several independant things. it will return only after
-     * finishing all tasks, the user may replace this with some multithreaded implementation, the
-     * default implementation will execute the parts serially
-     * @param count the number of things to execute
-     * - encoding: set by lavc, user can override
-     * - decoding: set by lavc, user can override
-     */
-    int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void **arg2, int *ret, int count);
-    
-    /**
-     * Thread opaque.
-     * can be used by execute() to store some per AVCodecContext stuff.
-     * - encoding: set by execute()
-     * - decoding: set by execute()
-     */
-    void *thread_opaque;
-
-    /**
-     * Motion estimation threshold. under which no motion estimation is 
-     * performed, but instead the user specified motion vectors are used
-     * 
-     * - encoding: set by user
-     * - decoding: unused
-     */
-     int me_threshold;
-
-    /**
-     * Macroblock threshold. under which the user specified macroblock types will be used
-     * - encoding: set by user
-     * - decoding: unused
-     */
-     int mb_threshold;
-
-    /**
-     * precision of the intra dc coefficient - 8.
-     * - encoding: set by user
-     * - decoding: unused
-     */
-     int intra_dc_precision;
-
-    /**
-     * noise vs. sse weight for the nsse comparsion function.
-     * - encoding: set by user
-     * - decoding: unused
-     */
-     int nsse_weight;
-
-    /**
-     * number of macroblock rows at the top which are skipped.
-     * - encoding: unused
-     * - decoding: set by user
-     */
-     int skip_top;
-
-    /**
-     * number of macroblock rows at the bottom which are skipped.
-     * - encoding: unused
-     * - decoding: set by user
-     */
-     int skip_bottom;
-
-    /**
-     * profile
-     * - encoding: set by user
-     * - decoding: set by lavc
-     */
-     int profile;
-#define FF_PROFILE_UNKNOWN -99
-
-    /**
-     * level
-     * - encoding: set by user
-     * - decoding: set by lavc
-     */
-     int level;
-#define FF_LEVEL_UNKNOWN -99
-
-    /**
-     * low resolution decoding. 1-> 1/2 size, 2->1/4 size
-     * - encoding: unused
-     * - decoding: set by user
-     */
-     int lowres;
-
-    /**
-     * bitsream width / height. may be different from width/height if lowres
-     * or other things are used
-     * - encoding: unused
-     * - decoding: set by user before init if known, codec should override / dynamically change if needed
-     */
-    int coded_width, coded_height;
-
-    /**
-     * frame skip threshold
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    int frame_skip_threshold;
-
-    /**
-     * frame skip factor
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    int frame_skip_factor;
-
-    /**
-     * frame skip exponent
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    int frame_skip_exp;
-
-    /**
-     * frame skip comparission function
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int frame_skip_cmp;
-
-    /**
-     * border processing masking. raises the quantizer for mbs on the borders
-     * of the picture.
-     * - encoding: set by user
-     * - decoding: unused
-     */
-    float border_masking;
-
-    /**
-     * minimum MB lagrange multipler.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int mb_lmin;
-
-    /**
-     * maximum MB lagrange multipler.
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int mb_lmax;
-
-    /**
-     * 
-     * - encoding: set by user.
-     * - decoding: unused
-     */
-    int me_penalty_compensation;
-
-    /**
-     * 
-     * - encoding: unused
-     * - decoding: set by user.
-     */
-    enum AVDiscard skip_loop_filter;
-
-    /**
-     * 
-     * - encoding: unused
-     * - decoding: set by user.
-     */
-    enum AVDiscard skip_idct;
-
-    /**
-     * 
-     * - encoding: unused
-     * - decoding: set by user.
-     */
-    enum AVDiscard skip_frame;
-} AVCodecContext;
-
-/**
- * AVCodec.
- */
-typedef struct AVCodec {
-    const char *name;
-    enum CodecType type;
-    enum CodecID id;
-    int priv_data_size;
-    int (*init)(AVCodecContext *);
-    int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
-    int (*close)(AVCodecContext *);
-    int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
-                  uint8_t *buf, int buf_size);
-    int capabilities;
-#if LIBAVCODEC_VERSION_INT < ((50<<16)+(0<<8)+0)
-    void *dummy; // FIXME remove next time we break binary compatibility
-#endif
-    struct AVCodec *next;
-    void (*flush)(AVCodecContext *);
-    const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0}
-    const enum PixelFormat *pix_fmts;       ///array of supported pixel formats, or NULL if unknown, array is terminanted by -1
-} AVCodec;
-
-/**
- * four components are given, that's all.
- * the last component is alpha
- */
-typedef struct AVPicture {
-    uint8_t *data[4];
-    int linesize[4];       ///< number of bytes per line
-} AVPicture;
-
-/**
- * AVPaletteControl
- * This structure defines a method for communicating palette changes
- * between and demuxer and a decoder.
- */
-#define AVPALETTE_SIZE 1024
-#define AVPALETTE_COUNT 256
-typedef struct AVPaletteControl {
-
-    /* demuxer sets this to 1 to indicate the palette has changed;
-     * decoder resets to 0 */
-    int palette_changed;
-
-    /* 4-byte ARGB palette entries, stored in native byte order; note that
-     * the individual palette components should be on a 8-bit scale; if
-     * the palette data comes from a IBM VGA native format, the component
-     * data is probably 6 bits in size and needs to be scaled */
-    unsigned int palette[AVPALETTE_COUNT];
-
-} AVPaletteControl;
-
-typedef struct AVSubtitleRect {
-    uint16_t x;
-    uint16_t y;
-    uint16_t w;
-    uint16_t h;
-    uint16_t nb_colors;
-    int linesize;
-    uint32_t *rgba_palette;
-    uint8_t *bitmap;
-} AVSubtitleRect;
-
-typedef struct AVSubtitle {
-    uint16_t format; /* 0 = graphics */
-    uint32_t start_display_time; /* relative to packet pts, in ms */
-    uint32_t end_display_time; /* relative to packet pts, in ms */
-    uint32_t num_rects;
-    AVSubtitleRect *rects;
-} AVSubtitle;
-
-extern AVCodec ac3_encoder;
-extern AVCodec mp2_encoder;
-extern AVCodec mp3lame_encoder;
-extern AVCodec oggvorbis_encoder;
-extern AVCodec oggtheora_encoder;
-extern AVCodec faac_encoder;
-extern AVCodec xvid_encoder;
-extern AVCodec mpeg1video_encoder;
-extern AVCodec mpeg2video_encoder;
-extern AVCodec h261_encoder;
-extern AVCodec h263_encoder;
-extern AVCodec h263p_encoder;
-extern AVCodec flv_encoder;
-extern AVCodec rv10_encoder;
-extern AVCodec rv20_encoder;
-extern AVCodec dvvideo_encoder;
-extern AVCodec mjpeg_encoder;
-extern AVCodec ljpeg_encoder;
-extern AVCodec png_encoder;
-extern AVCodec ppm_encoder;
-extern AVCodec pgm_encoder;
-extern AVCodec pgmyuv_encoder;
-extern AVCodec pbm_encoder;
-extern AVCodec pam_encoder;
-extern AVCodec mpeg4_encoder;
-extern AVCodec msmpeg4v1_encoder;
-extern AVCodec msmpeg4v2_encoder;
-extern AVCodec msmpeg4v3_encoder;
-extern AVCodec wmv1_encoder;
-extern AVCodec wmv2_encoder;
-extern AVCodec huffyuv_encoder;
-extern AVCodec ffvhuff_encoder;
-extern AVCodec h264_encoder;
-extern AVCodec asv1_encoder;
-extern AVCodec asv2_encoder;
-extern AVCodec vcr1_encoder;
-extern AVCodec ffv1_encoder;
-extern AVCodec snow_encoder;
-extern AVCodec mdec_encoder;
-extern AVCodec zlib_encoder;
-extern AVCodec sonic_encoder;
-extern AVCodec sonic_ls_encoder;
-extern AVCodec svq1_encoder;
-extern AVCodec x264_encoder;
-
-extern AVCodec h263_decoder;
-extern AVCodec h261_decoder;
-extern AVCodec mpeg4_decoder;
-extern AVCodec msmpeg4v1_decoder;
-extern AVCodec msmpeg4v2_decoder;
-extern AVCodec msmpeg4v3_decoder;
-extern AVCodec wmv1_decoder;
-extern AVCodec wmv2_decoder;
-extern AVCodec vc9_decoder;
-extern AVCodec wmv3_decoder;
-extern AVCodec mpeg1video_decoder;
-extern AVCodec mpeg2video_decoder;
-extern AVCodec mpegvideo_decoder;
-extern AVCodec mpeg_xvmc_decoder;
-extern AVCodec h263i_decoder;
-extern AVCodec flv_decoder;
-extern AVCodec rv10_decoder;
-extern AVCodec rv20_decoder;
-extern AVCodec rv30_decoder;
-extern AVCodec rv40_decoder;
-extern AVCodec svq1_decoder;
-extern AVCodec svq3_decoder;
-extern AVCodec dvvideo_decoder;
-extern AVCodec wmav1_decoder;
-extern AVCodec wmav2_decoder;
-extern AVCodec mjpeg_decoder;
-extern AVCodec mjpegb_decoder;
-extern AVCodec sp5x_decoder;
-extern AVCodec png_decoder;
-extern AVCodec mp2_decoder;
-extern AVCodec mp3_decoder;
-extern AVCodec mp3adu_decoder;
-extern AVCodec mp3on4_decoder;
-extern AVCodec mace3_decoder;
-extern AVCodec mace6_decoder;
-extern AVCodec huffyuv_decoder;
-extern AVCodec ffvhuff_decoder;
-extern AVCodec oggvorbis_decoder;
-extern AVCodec oggtheora_decoder;
-extern AVCodec cyuv_decoder;
-extern AVCodec h264_decoder;
-extern AVCodec indeo3_decoder;
-extern AVCodec vp3_decoder;
-extern AVCodec theora_decoder;
-extern AVCodec amr_nb_decoder;
-extern AVCodec amr_nb_encoder;
-extern AVCodec amr_wb_encoder;
-extern AVCodec amr_wb_decoder;
-extern AVCodec aac_decoder;
-extern AVCodec mpeg4aac_decoder;
-extern AVCodec asv1_decoder;
-extern AVCodec asv2_decoder;
-extern AVCodec vcr1_decoder;
-extern AVCodec cljr_decoder;
-extern AVCodec ffv1_decoder;
-extern AVCodec snow_decoder;
-extern AVCodec fourxm_decoder;
-extern AVCodec mdec_decoder;
-extern AVCodec roq_decoder;
-extern AVCodec interplay_video_decoder;
-extern AVCodec xan_wc3_decoder;
-extern AVCodec rpza_decoder;
-extern AVCodec cinepak_decoder;
-extern AVCodec msrle_decoder;
-extern AVCodec msvideo1_decoder;
-extern AVCodec vqa_decoder;
-extern AVCodec idcin_decoder;
-extern AVCodec eightbps_decoder;
-extern AVCodec smc_decoder;
-extern AVCodec flic_decoder;
-extern AVCodec vmdvideo_decoder;
-extern AVCodec vmdaudio_decoder;
-extern AVCodec truemotion1_decoder;
-extern AVCodec mszh_decoder;
-extern AVCodec zlib_decoder;
-extern AVCodec ra_144_decoder;
-extern AVCodec ra_288_decoder;
-extern AVCodec roq_dpcm_decoder;
-extern AVCodec interplay_dpcm_decoder;
-extern AVCodec xan_dpcm_decoder;
-extern AVCodec sol_dpcm_decoder;
-extern AVCodec sonic_decoder;
-extern AVCodec qtrle_decoder;
-extern AVCodec flac_decoder;
-extern AVCodec tscc_decoder;
-extern AVCodec ulti_decoder;
-extern AVCodec qdraw_decoder;
-extern AVCodec xl_decoder;
-extern AVCodec qpeg_decoder;
-extern AVCodec shorten_decoder;
-extern AVCodec loco_decoder;
-extern AVCodec wnv1_decoder;
-extern AVCodec aasc_decoder;
-extern AVCodec alac_decoder;
-extern AVCodec ws_snd1_decoder;
-extern AVCodec indeo2_decoder;
-extern AVCodec vorbis_decoder;
-extern AVCodec fraps_decoder;
-extern AVCodec libgsm_encoder;
-extern AVCodec libgsm_decoder;
-
-/* pcm codecs */
-#define PCM_CODEC(id, name) \
-extern AVCodec name ## _decoder; \
-extern AVCodec name ## _encoder
-
-PCM_CODEC(CODEC_ID_PCM_S32LE, pcm_s32le);
-PCM_CODEC(CODEC_ID_PCM_S32BE, pcm_s32be);
-PCM_CODEC(CODEC_ID_PCM_U32LE, pcm_u32le);
-PCM_CODEC(CODEC_ID_PCM_U32BE, pcm_u32be);
-PCM_CODEC(CODEC_ID_PCM_S24LE, pcm_s24le);
-PCM_CODEC(CODEC_ID_PCM_S24BE, pcm_s24be);
-PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le);
-PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be);
-PCM_CODEC(CODEC_ID_PCM_S24DAUD, pcm_s24daud);
-PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
-PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
-PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
-PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
-PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
-PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
-PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
-PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
-
-/* adpcm codecs */
-
-PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
-PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
-PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
-PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
-PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
-PCM_CODEC(CODEC_ID_ADPCM_SMJPEG, adpcm_ima_smjpeg);
-PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
-PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
-PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
-PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
-PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
-PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
-PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
-PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
-PCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);
-
-#undef PCM_CODEC
-
-/* dummy raw video codec */
-extern AVCodec rawvideo_encoder;
-extern AVCodec rawvideo_decoder;
-
-/* the following codecs use external GPL libs */
-extern AVCodec ac3_decoder;
-extern AVCodec dts_decoder;
-
-/* subtitles */
-extern AVCodec dvdsub_decoder;
-extern AVCodec dvbsub_encoder;
-extern AVCodec dvbsub_decoder;
-
-/* resample.c */
-
-struct ReSampleContext;
-struct AVResampleContext;
-
-typedef struct ReSampleContext ReSampleContext;
-
-ReSampleContext *audio_resample_init(int output_channels, int input_channels, 
-                                     int output_rate, int input_rate);
-int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
-void audio_resample_close(ReSampleContext *s);
-
-struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
-int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
-void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
-void av_resample_close(struct AVResampleContext *c);
-
-/* YUV420 format is assumed ! */
-
-struct ImgReSampleContext;
-
-typedef struct ImgReSampleContext ImgReSampleContext;
-
-ImgReSampleContext *img_resample_init(int output_width, int output_height,
-                                      int input_width, int input_height);
-
-ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
-                                      int iwidth, int iheight,
-                                      int topBand, int bottomBand,
-                                      int leftBand, int rightBand,
-                                      int padtop, int padbottom,
-                                      int padleft, int padright);
-
-
-void img_resample(ImgReSampleContext *s, 
-                  AVPicture *output, const AVPicture *input);
-
-void img_resample_close(ImgReSampleContext *s);
-
-/**
- * Allocate memory for a picture.  Call avpicture_free to free it.
- *
- * @param picture the picture to be filled in.
- * @param pix_fmt the format of the picture.
- * @param width the width of the picture.
- * @param height the height of the picture.
- * @return 0 if successful, -1 if not.
- */
-int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height);
-
-/* Free a picture previously allocated by avpicture_alloc. */
-void avpicture_free(AVPicture *picture);
-
-int avpicture_fill(AVPicture *picture, uint8_t *ptr,
-                   int pix_fmt, int width, int height);
-int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
-                     unsigned char *dest, int dest_size);
-int avpicture_get_size(int pix_fmt, int width, int height);
-void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
-const char *avcodec_get_pix_fmt_name(int pix_fmt);
-void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
-enum PixelFormat avcodec_get_pix_fmt(const char* name);
-unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p);
-
-#define FF_LOSS_RESOLUTION  0x0001 /* loss due to resolution change */
-#define FF_LOSS_DEPTH       0x0002 /* loss due to color depth change */
-#define FF_LOSS_COLORSPACE  0x0004 /* loss due to color space conversion */
-#define FF_LOSS_ALPHA       0x0008 /* loss of alpha bits */
-#define FF_LOSS_COLORQUANT  0x0010 /* loss due to color quantization */
-#define FF_LOSS_CHROMA      0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
-
-int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
-                             int has_alpha);
-int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
-                              int has_alpha, int *loss_ptr);
-
-#define FF_ALPHA_TRANSP       0x0001 /* image has some totally transparent pixels */
-#define FF_ALPHA_SEMI_TRANSP  0x0002 /* image has some transparent pixels */
-int img_get_alpha_info(const AVPicture *src,
-		       int pix_fmt, int width, int height);
-
-/* convert among pixel formats */
-int img_convert(AVPicture *dst, int dst_pix_fmt,
-                const AVPicture *src, int pix_fmt, 
-                int width, int height);
-
-/* deinterlace a picture */
-int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
-                          int pix_fmt, int width, int height);
-
-/* external high level API */
-
-extern AVCodec *first_avcodec;
-
-/* returns LIBAVCODEC_VERSION_INT constant */
-unsigned avcodec_version(void);
-/* returns LIBAVCODEC_BUILD constant */
-unsigned avcodec_build(void);
-void avcodec_init(void);
-
-void register_avcodec(AVCodec *format);
-AVCodec *avcodec_find_encoder(enum CodecID id);
-AVCodec *avcodec_find_encoder_by_name(const char *name);
-AVCodec *avcodec_find_decoder(enum CodecID id);
-AVCodec *avcodec_find_decoder_by_name(const char *name);
-void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
-
-void avcodec_get_context_defaults(AVCodecContext *s);
-AVCodecContext *avcodec_alloc_context(void);
-void avcodec_get_frame_defaults(AVFrame *pic);
-AVFrame *avcodec_alloc_frame(void);
-
-int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
-void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
-int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
-void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
-int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
-enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
-
-int avcodec_thread_init(AVCodecContext *s, int thread_count);
-void avcodec_thread_free(AVCodecContext *s);
-int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
-int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
-//FIXME func typedef
-
-/**
- * opens / inits the AVCodecContext.
- * not thread save!
- */
-int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
-
-int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, 
-                         int *frame_size_ptr,
-                         uint8_t *buf, int buf_size);
-int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, 
-                         int *got_picture_ptr,
-                         uint8_t *buf, int buf_size);
-int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
-                            int *got_sub_ptr,
-                            const uint8_t *buf, int buf_size);
-int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, 
-                        int *data_size_ptr,
-                        uint8_t *buf, int buf_size);
-int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
-                         const short *samples);
-int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
-                         const AVFrame *pict);
-int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
-                            const AVSubtitle *sub);
-
-int avcodec_close(AVCodecContext *avctx);
-
-void avcodec_register_all(void);
-
-void avcodec_flush_buffers(AVCodecContext *avctx);
-
-void avcodec_default_free_buffers(AVCodecContext *s);
-
-/* misc usefull functions */
-
-/**
- * returns a single letter to describe the picture type
- */
-char av_get_pict_type_char(int pict_type);
-
-
-/* frame parsing */
-typedef struct AVCodecParserContext {
-    void *priv_data;
-    struct AVCodecParser *parser;
-    int64_t frame_offset; /* offset of the current frame */
-    int64_t cur_offset; /* current offset 
-                           (incremented by each av_parser_parse()) */
-    int64_t last_frame_offset; /* offset of the last frame */
-    /* video info */
-    int pict_type; /* XXX: put it back in AVCodecContext */
-    int repeat_pict; /* XXX: put it back in AVCodecContext */
-    int64_t pts;     /* pts of the current frame */
-    int64_t dts;     /* dts of the current frame */
-
-    /* private data */
-    int64_t last_pts;
-    int64_t last_dts;
-    int fetch_timestamp;
-
-#define AV_PARSER_PTS_NB 4
-    int cur_frame_start_index;
-    int64_t cur_frame_offset[AV_PARSER_PTS_NB];
-    int64_t cur_frame_pts[AV_PARSER_PTS_NB];
-    int64_t cur_frame_dts[AV_PARSER_PTS_NB];
-    
-    int flags;
-#define PARSER_FLAG_COMPLETE_FRAMES           0x0001
-} AVCodecParserContext;
-
-typedef struct AVCodecParser {
-    int codec_ids[5]; /* several codec IDs are permitted */
-    int priv_data_size;
-    int (*parser_init)(AVCodecParserContext *s);
-    int (*parser_parse)(AVCodecParserContext *s, 
-                        AVCodecContext *avctx,
-                        uint8_t **poutbuf, int *poutbuf_size, 
-                        const uint8_t *buf, int buf_size);
-    void (*parser_close)(AVCodecParserContext *s);
-    int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
-    struct AVCodecParser *next;
-} AVCodecParser;
-
-extern AVCodecParser *av_first_parser;
-
-void av_register_codec_parser(AVCodecParser *parser);
-AVCodecParserContext *av_parser_init(int codec_id);
-int av_parser_parse(AVCodecParserContext *s, 
-                    AVCodecContext *avctx,
-                    uint8_t **poutbuf, int *poutbuf_size, 
-                    const uint8_t *buf, int buf_size,
-                    int64_t pts, int64_t dts);
-int av_parser_change(AVCodecParserContext *s,
-                     AVCodecContext *avctx,
-                     uint8_t **poutbuf, int *poutbuf_size, 
-                     const uint8_t *buf, int buf_size, int keyframe);
-void av_parser_close(AVCodecParserContext *s);
-
-extern AVCodecParser mpegvideo_parser;
-extern AVCodecParser mpeg4video_parser;
-extern AVCodecParser h261_parser;
-extern AVCodecParser h263_parser;
-extern AVCodecParser h264_parser;
-extern AVCodecParser mjpeg_parser;
-extern AVCodecParser pnm_parser;
-extern AVCodecParser mpegaudio_parser;
-extern AVCodecParser ac3_parser;
-extern AVCodecParser dvdsub_parser;
-extern AVCodecParser dvbsub_parser;
-
-/* memory */
-void *av_malloc(unsigned int size);
-void *av_mallocz(unsigned int size);
-void *av_realloc(void *ptr, unsigned int size);
-void av_free(void *ptr);
-char *av_strdup(const char *s);
-void av_freep(void *ptr);
-void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
-/* for static data only */
-/* call av_free_static to release all staticaly allocated tables */
-void av_free_static(void);
-void *av_mallocz_static(unsigned int size);
-void *av_realloc_static(void *ptr, unsigned int size);
-
-/* add by bero : in adx.c */
-int is_adx(const unsigned char *buf,size_t bufsize);
-
-void img_copy(AVPicture *dst, const AVPicture *src,
-              int pix_fmt, int width, int height);
-
-/* av_log API */
-
-#include <stdarg.h>
-
-#define AV_LOG_QUIET -1
-#define AV_LOG_ERROR 0
-#define AV_LOG_INFO 1
-#define AV_LOG_DEBUG 2
-
-#ifdef __GNUC__
-extern void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
-#else
-extern void av_log(void*, int level, const char *fmt, ...);
-#endif
-
-extern void av_vlog(void*, int level, const char *fmt, va_list);
-extern int av_log_get_level(void);
-extern void av_log_set_level(int);
-extern void av_log_set_callback(void (*)(void*, int, const char*, va_list));
-
-/* endian macros */
-#if !defined(BE_16) || !defined(BE_32) || !defined(LE_16) || !defined(LE_32)
-#define BE_16(x)  ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
-#define BE_32(x)  ((((uint8_t*)(x))[0] << 24) | \
-                   (((uint8_t*)(x))[1] << 16) | \
-                   (((uint8_t*)(x))[2] << 8) | \
-                    ((uint8_t*)(x))[3])
-#define LE_16(x)  ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
-#define LE_32(x)  ((((uint8_t*)(x))[3] << 24) | \
-                   (((uint8_t*)(x))[2] << 16) | \
-                   (((uint8_t*)(x))[1] << 8) | \
-                    ((uint8_t*)(x))[0])
-#endif
-
-extern unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* AVCODEC_H */
diff --git a/ffmpeg.src/libavcodec/bitstream.c b/ffmpeg.src/libavcodec/bitstream.c
deleted file mode 100644
index fcd4fd9..0000000
--- a/ffmpeg.src/libavcodec/bitstream.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Common bit i/o utils
- * Copyright (c) 2000, 2001 Fabrice Bellard.
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * alternative bitstream reader & writer by Michael Niedermayer <michaelni at gmx.at>
- */
-
-/**
- * @file bitstream.c
- * bitstream api.
- */
- 
-#include "avcodec.h"
-#include "bitstream.h"
-
-void align_put_bits(PutBitContext *s)
-{
-#ifdef ALT_BITSTREAM_WRITER
-    put_bits(s,(  - s->index) & 7,0);
-#else
-    put_bits(s,s->bit_left & 7,0);
-#endif
-}
-
-void put_string(PutBitContext * pbc, char *s, int put_zero)
-{
-    while(*s){
-        put_bits(pbc, 8, *s);
-        s++;
-    }
-    if(put_zero)
-        put_bits(pbc, 8, 0);
-}
-
-/* bit input functions */
-
-/** 
- * reads 0-32 bits.
- */
-unsigned int get_bits_long(GetBitContext *s, int n){
-    if(n<=17) return get_bits(s, n);
-    else{
-        int ret= get_bits(s, 16) << (n-16);
-        return ret | get_bits(s, n-16);
-    }
-}
-
-/** 
- * shows 0-32 bits.
- */
-unsigned int show_bits_long(GetBitContext *s, int n){
-    if(n<=17) return show_bits(s, n);
-    else{
-        GetBitContext gb= *s;
-        int ret= get_bits_long(s, n);
-        *s= gb;
-        return ret;
-    }
-}
-
-void align_get_bits(GetBitContext *s)
-{
-    int n= (-get_bits_count(s)) & 7;
-    if(n) skip_bits(s, n);
-}
-
-int check_marker(GetBitContext *s, const char *msg)
-{
-    int bit= get_bits1(s);
-    if(!bit)
-	    av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg);
-
-    return bit;
-}
-
-/* VLC decoding */
-
-//#define DEBUG_VLC
-
-#define GET_DATA(v, table, i, wrap, size) \
-{\
-    const uint8_t *ptr = (const uint8_t *)table + i * wrap;\
-    switch(size) {\
-    case 1:\
-        v = *(const uint8_t *)ptr;\
-        break;\
-    case 2:\
-        v = *(const uint16_t *)ptr;\
-        break;\
-    default:\
-        v = *(const uint32_t *)ptr;\
-        break;\
-    }\
-}
-
-
-static int alloc_table(VLC *vlc, int size, int use_static)
-{
-    int index;
-    index = vlc->table_size;
-    vlc->table_size += size;
-    if (vlc->table_size > vlc->table_allocated) {
-        vlc->table_allocated += (1 << vlc->bits);
-        if(use_static)
-            vlc->table = av_realloc_static(vlc->table,
-                                           sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
-        else
-            vlc->table = av_realloc(vlc->table,
-                                    sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
-        if (!vlc->table)
-            return -1;
-    }
-    return index;
-}
-
-static int build_table(VLC *vlc, int table_nb_bits,
-                       int nb_codes,
-                       const void *bits, int bits_wrap, int bits_size,
-                       const void *codes, int codes_wrap, int codes_size,
-                       uint32_t code_prefix, int n_prefix, int flags)
-{
-    int i, j, k, n, table_size, table_index, nb, n1, index, code_prefix2;
-    uint32_t code;
-    VLC_TYPE (*table)[2];
-
-    table_size = 1 << table_nb_bits;
-    table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_STATIC);
-#ifdef DEBUG_VLC
-    printf("new table index=%d size=%d code_prefix=%x n=%d\n",
-           table_index, table_size, code_prefix, n_prefix);
-#endif
-    if (table_index < 0)
-        return -1;
-    table = &vlc->table[table_index];
-
-    for(i=0;i<table_size;i++) {
-        table[i][1] = 0; //bits
-        table[i][0] = -1; //codes
-    }
-
-    /* first pass: map codes and compute auxillary table sizes */
-    for(i=0;i<nb_codes;i++) {
-        GET_DATA(n, bits, i, bits_wrap, bits_size);
-        GET_DATA(code, codes, i, codes_wrap, codes_size);
-        /* we accept tables with holes */
-        if (n <= 0)
-            continue;
-#if defined(DEBUG_VLC) && 0
-        printf("i=%d n=%d code=0x%x\n", i, n, code);
-#endif
-        /* if code matches the prefix, it is in the table */
-        n -= n_prefix;
-        if(flags & INIT_VLC_LE)
-            code_prefix2= code & (n_prefix>=32 ? 0xffffffff : (1 << n_prefix)-1);
-        else
-            code_prefix2= code >> n;
-        if (n > 0 && code_prefix2 == code_prefix) {
-            if (n <= table_nb_bits) {
-                /* no need to add another table */
-                j = (code << (table_nb_bits - n)) & (table_size - 1);
-                nb = 1 << (table_nb_bits - n);
-                for(k=0;k<nb;k++) {
-                    if(flags & INIT_VLC_LE)
-                        j = (code >> n_prefix) + (k<<n);
-#ifdef DEBUG_VLC
-                    av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n",
-                           j, i, n);
-#endif
-                    if (table[j][1] /*bits*/ != 0) {
-                        av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
-                        return -1;
-                    }
-                    table[j][1] = n; //bits
-                    table[j][0] = i; //code
-                    j++;
-                }
-            } else {
-                n -= table_nb_bits;
-                j = (code >> ((flags & INIT_VLC_LE) ? n_prefix : n)) & ((1 << table_nb_bits) - 1);
-#ifdef DEBUG_VLC
-                printf("%4x: n=%d (subtable)\n",
-                       j, n);
-#endif
-                /* compute table size */
-                n1 = -table[j][1]; //bits
-                if (n > n1)
-                    n1 = n;
-                table[j][1] = -n1; //bits
-            }
-        }
-    }
-
-    /* second pass : fill auxillary tables recursively */
-    for(i=0;i<table_size;i++) {
-        n = table[i][1]; //bits
-        if (n < 0) {
-            n = -n;
-            if (n > table_nb_bits) {
-                n = table_nb_bits;
-                table[i][1] = -n; //bits
-            }
-            index = build_table(vlc, n, nb_codes,
-                                bits, bits_wrap, bits_size,
-                                codes, codes_wrap, codes_size,
-                                (flags & INIT_VLC_LE) ? (code_prefix | (i << n_prefix)) : ((code_prefix << table_nb_bits) | i),
-                                n_prefix + table_nb_bits, flags);
-            if (index < 0)
-                return -1;
-            /* note: realloc has been done, so reload tables */
-            table = &vlc->table[table_index];
-            table[i][0] = index; //code
-        }
-    }
-    return table_index;
-}
-
-
-/* Build VLC decoding tables suitable for use with get_vlc().
-
-   'nb_bits' set thee decoding table size (2^nb_bits) entries. The
-   bigger it is, the faster is the decoding. But it should not be too
-   big to save memory and L1 cache. '9' is a good compromise.
-   
-   'nb_codes' : number of vlcs codes
-
-   'bits' : table which gives the size (in bits) of each vlc code.
-
-   'codes' : table which gives the bit pattern of of each vlc code.
-
-   'xxx_wrap' : give the number of bytes between each entry of the
-   'bits' or 'codes' tables.
-
-   'xxx_size' : gives the number of bytes of each entry of the 'bits'
-   or 'codes' tables.
-
-   'wrap' and 'size' allows to use any memory configuration and types
-   (byte/word/long) to store the 'bits' and 'codes' tables.  
-
-   'use_static' should be set to 1 for tables, which should be freed
-   with av_free_static(), 0 if free_vlc() will be used.
-*/
-int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
-             const void *bits, int bits_wrap, int bits_size,
-             const void *codes, int codes_wrap, int codes_size,
-             int use_static)
-{
-    vlc->bits = nb_bits;
-    if(!use_static) {
-        vlc->table = NULL;
-        vlc->table_allocated = 0;
-        vlc->table_size = 0;
-    } else {
-        /* Static tables are initially always NULL, return
-           if vlc->table != NULL to avoid double allocation */
-        if(vlc->table)
-            return 0;
-    }
-
-#ifdef DEBUG_VLC
-    printf("build table nb_codes=%d\n", nb_codes);
-#endif
-
-    if (build_table(vlc, nb_bits, nb_codes,
-                    bits, bits_wrap, bits_size,
-                    codes, codes_wrap, codes_size,
-                    0, 0, use_static) < 0) {
-        av_free(vlc->table);
-        return -1;
-    }
-    return 0;
-}
-
-
-void free_vlc(VLC *vlc)
-{
-    av_free(vlc->table);
-}
-
diff --git a/ffmpeg.src/libavcodec/bitstream.h b/ffmpeg.src/libavcodec/bitstream.h
deleted file mode 100644
index 0e60ea1..0000000
--- a/ffmpeg.src/libavcodec/bitstream.h
+++ /dev/null
@@ -1,884 +0,0 @@
-/**
- * @file bitstream.h
- * bitstream api header.
- */
-
-#ifndef BITSTREAM_H
-#define BITSTREAM_H
-
-//#define ALT_BITSTREAM_WRITER
-//#define ALIGNED_BITSTREAM_WRITER
-
-#define ALT_BITSTREAM_READER
-//#define LIBMPEG2_BITSTREAM_READER
-//#define A32_BITSTREAM_READER
-#define LIBMPEG2_BITSTREAM_READER_HACK //add BERO
- 
-extern const uint8_t ff_reverse[256];
-
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
-// avoid +32 for shift optimization (gcc should do that ...)
-static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-    asm ("sarl %1, %0\n\t"
-         : "+r" (a)
-         : "ic" ((uint8_t)(-s))
-    );
-    return a;
-}
-static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-    asm ("shrl %1, %0\n\t"
-         : "+r" (a)
-         : "ic" ((uint8_t)(-s))
-    );
-    return a;
-}
-#else
-#    define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s)))
-#    define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
-#endif
-
-/* bit output */
-
-/* buf and buf_end must be present and used by every alternative writer. */
-typedef struct PutBitContext {
-#ifdef ALT_BITSTREAM_WRITER
-    uint8_t *buf, *buf_end;
-    int index;
-#else
-    uint32_t bit_buf;
-    int bit_left;
-    uint8_t *buf, *buf_ptr, *buf_end;
-#endif
-} PutBitContext;
-
-static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
-{
-    s->buf = buffer;
-    s->buf_end = s->buf + buffer_size;
-#ifdef ALT_BITSTREAM_WRITER
-    s->index=0;
-    ((uint32_t*)(s->buf))[0]=0;
-//    memset(buffer, 0, buffer_size);
-#else
-    s->buf_ptr = s->buf;
-    s->bit_left=32;
-    s->bit_buf=0;
-#endif
-}
-
-/* return the number of bits output */
-static inline int put_bits_count(PutBitContext *s)
-{
-#ifdef ALT_BITSTREAM_WRITER
-    return s->index;
-#else
-    return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left;
-#endif
-}
-
-/* pad the end of the output stream with zeros */
-static inline void flush_put_bits(PutBitContext *s)
-{
-#ifdef ALT_BITSTREAM_WRITER
-    align_put_bits(s);
-#else
-    s->bit_buf<<= s->bit_left;
-    while (s->bit_left < 32) {
-        /* XXX: should test end of buffer */
-        *s->buf_ptr++=s->bit_buf >> 24;
-        s->bit_buf<<=8;
-        s->bit_left+=8;
-    }
-    s->bit_left=32;
-    s->bit_buf=0;
-#endif
-}
-
-void align_put_bits(PutBitContext *s);
-void put_string(PutBitContext * pbc, char *s, int put_zero);
-
-/* bit input */
-/* buffer, buffer_end and size_in_bits must be present and used by every reader */
-typedef struct GetBitContext {
-    const uint8_t *buffer, *buffer_end;
-#ifdef ALT_BITSTREAM_READER
-    int index;
-#elif defined LIBMPEG2_BITSTREAM_READER
-    uint8_t *buffer_ptr;
-    uint32_t cache;
-    int bit_count;
-#elif defined A32_BITSTREAM_READER
-    uint32_t *buffer_ptr;
-    uint32_t cache0;
-    uint32_t cache1;
-    int bit_count;
-#endif
-    int size_in_bits;
-} GetBitContext;
-
-#define VLC_TYPE int16_t
-
-typedef struct VLC {
-    int bits;
-    VLC_TYPE (*table)[2]; ///< code, bits
-    int table_size, table_allocated;
-} VLC;
-
-typedef struct RL_VLC_ELEM {
-    int16_t level;
-    int8_t len;
-    uint8_t run;
-} RL_VLC_ELEM;
-
-#if defined(ARCH_SPARC) || defined(ARCH_ARMV4L)
-#define UNALIGNED_STORES_ARE_BAD
-#endif
-
-/* used to avoid missaligned exceptions on some archs (alpha, ...) */
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
-#    define unaligned32(a) (*(const uint32_t*)(a))
-#else
-#    ifdef __GNUC__
-static inline uint32_t unaligned32(const void *v) {
-    struct Unaligned {
-	uint32_t i;
-    } __attribute__((packed));
-
-    return ((const struct Unaligned *) v)->i;
-}
-#    elif defined(__DECC)
-static inline uint32_t unaligned32(const void *v) {
-    return *(const __unaligned uint32_t *) v;
-}
-#    else
-static inline uint32_t unaligned32(const void *v) {
-    return *(const uint32_t *) v;
-}
-#    endif
-#endif //!ARCH_X86
-
-#ifndef ALT_BITSTREAM_WRITER
-static inline void put_bits(PutBitContext *s, int n, unsigned int value)
-{
-    unsigned int bit_buf;
-    int bit_left;
-
-#ifdef STATS
-    st_out_bit_counts[st_current_index] += n;
-#endif
-    //    printf("put_bits=%d %x\n", n, value);
-    assert(n == 32 || value < (1U << n));
-    
-    bit_buf = s->bit_buf;
-    bit_left = s->bit_left;
-
-    //    printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt, bit_buf);
-    /* XXX: optimize */
-    if (n < bit_left) {
-        bit_buf = (bit_buf<<n) | value;
-        bit_left-=n;
-    } else {
-	bit_buf<<=bit_left;
-        bit_buf |= value >> (n - bit_left);
-#ifdef UNALIGNED_STORES_ARE_BAD
-        if (3 & (intptr_t) s->buf_ptr) {
-            s->buf_ptr[0] = bit_buf >> 24;
-            s->buf_ptr[1] = bit_buf >> 16;
-            s->buf_ptr[2] = bit_buf >>  8;
-            s->buf_ptr[3] = bit_buf      ;
-        } else
-#endif
-        *(uint32_t *)s->buf_ptr = be2me_32(bit_buf);
-        //printf("bitbuf = %08x\n", bit_buf);
-        s->buf_ptr+=4;
-	bit_left+=32 - n;
-        bit_buf = value;
-    }
-
-    s->bit_buf = bit_buf;
-    s->bit_left = bit_left;
-}
-#endif
-
-
-#ifdef ALT_BITSTREAM_WRITER
-static inline void put_bits(PutBitContext *s, int n, unsigned int value)
-{
-#    ifdef ALIGNED_BITSTREAM_WRITER
-#        if defined(ARCH_X86) || defined(ARCH_X86_64)
-    asm volatile(
-	"movl %0, %%ecx			\n\t"
-	"xorl %%eax, %%eax		\n\t"
-	"shrdl %%cl, %1, %%eax		\n\t"
-	"shrl %%cl, %1			\n\t"
-	"movl %0, %%ecx			\n\t"
-	"shrl $3, %%ecx			\n\t"
-	"andl $0xFFFFFFFC, %%ecx	\n\t"
-	"bswapl %1			\n\t"
-	"orl %1, (%2, %%ecx)		\n\t"
-	"bswapl %%eax			\n\t"
-	"addl %3, %0			\n\t"
-	"movl %%eax, 4(%2, %%ecx)	\n\t"
-	: "=&r" (s->index), "=&r" (value)
-	: "r" (s->buf), "r" (n), "0" (s->index), "1" (value<<(-n))
-	: "%eax", "%ecx"
-    );
-#        else
-    int index= s->index;
-    uint32_t *ptr= ((uint32_t *)s->buf)+(index>>5);
-    
-    value<<= 32-n; 
-    
-    ptr[0] |= be2me_32(value>>(index&31));
-    ptr[1]  = be2me_32(value<<(32-(index&31)));
-//if(n>24) printf("%d %d\n", n, value);
-    index+= n;
-    s->index= index;
-#        endif
-#    else //ALIGNED_BITSTREAM_WRITER
-#        if defined(ARCH_X86) || defined(ARCH_X86_64)
-    asm volatile(
-	"movl $7, %%ecx			\n\t"
-	"andl %0, %%ecx			\n\t"
-	"addl %3, %%ecx			\n\t"
-	"negl %%ecx			\n\t"
-	"shll %%cl, %1			\n\t"
-	"bswapl %1			\n\t"
-	"movl %0, %%ecx			\n\t"
-	"shrl $3, %%ecx			\n\t"
-	"orl %1, (%%ecx, %2)		\n\t"
-	"addl %3, %0			\n\t"
-	"movl $0, 4(%%ecx, %2)		\n\t"
-	: "=&r" (s->index), "=&r" (value)
-	: "r" (s->buf), "r" (n), "0" (s->index), "1" (value)
-	: "%ecx"
-    );
-#        else
-    int index= s->index;
-    uint32_t *ptr= (uint32_t*)(((uint8_t *)s->buf)+(index>>3));
-    
-    ptr[0] |= be2me_32(value<<(32-n-(index&7) ));
-    ptr[1] = 0;
-//if(n>24) printf("%d %d\n", n, value);
-    index+= n;
-    s->index= index;
-#        endif
-#    endif //!ALIGNED_BITSTREAM_WRITER
-}
-#endif
-
-
-static inline uint8_t* pbBufPtr(PutBitContext *s)
-{
-#ifdef ALT_BITSTREAM_WRITER
-	return s->buf + (s->index>>3);
-#else
-	return s->buf_ptr;
-#endif
-}
-
-/**
- *
- * PutBitContext must be flushed & aligned to a byte boundary before calling this.
- */
-static inline void skip_put_bytes(PutBitContext *s, int n){
-        assert((put_bits_count(s)&7)==0);
-#ifdef ALT_BITSTREAM_WRITER
-        FIXME may need some cleaning of the buffer
-	s->index += n<<3;
-#else
-        assert(s->bit_left==32);
-	s->buf_ptr += n;
-#endif    
-}
-
-/**
- * skips the given number of bits.
- * must only be used if the actual values in the bitstream dont matter
- */
-static inline void skip_put_bits(PutBitContext *s, int n){
-#ifdef ALT_BITSTREAM_WRITER
-    s->index += n;
-#else
-    s->bit_left -= n;
-    s->buf_ptr-= s->bit_left>>5;
-    s->bit_left &= 31;
-#endif        
-}
-
-/**
- * Changes the end of the buffer.
- */
-static inline void set_put_bits_buffer_size(PutBitContext *s, int size){
-    s->buf_end= s->buf + size;
-}
-
-/* Bitstream reader API docs:
-name
-    abritary name which is used as prefix for the internal variables
-
-gb
-    getbitcontext
-
-OPEN_READER(name, gb)
-    loads gb into local variables
-
-CLOSE_READER(name, gb)
-    stores local vars in gb
-
-UPDATE_CACHE(name, gb)
-    refills the internal cache from the bitstream
-    after this call at least MIN_CACHE_BITS will be available,
-
-GET_CACHE(name, gb)
-    will output the contents of the internal cache, next bit is MSB of 32 or 64 bit (FIXME 64bit)
-
-SHOW_UBITS(name, gb, num)
-    will return the next num bits
-
-SHOW_SBITS(name, gb, num)
-    will return the next num bits and do sign extension
-
-SKIP_BITS(name, gb, num)
-    will skip over the next num bits
-    note, this is equivalent to SKIP_CACHE; SKIP_COUNTER
-
-SKIP_CACHE(name, gb, num)
-    will remove the next num bits from the cache (note SKIP_COUNTER MUST be called before UPDATE_CACHE / CLOSE_READER)
-
-SKIP_COUNTER(name, gb, num)
-    will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS)
-
-LAST_SKIP_CACHE(name, gb, num)
-    will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing
-
-LAST_SKIP_BITS(name, gb, num)
-    is equivalent to SKIP_LAST_CACHE; SKIP_COUNTER
-
-for examples see get_bits, show_bits, skip_bits, get_vlc
-*/
-
-static inline int unaligned32_be(const void *v)
-{
-#ifdef CONFIG_ALIGN
-	const uint8_t *p=v;
-	return (((p[0]<<8) | p[1])<<16) | (p[2]<<8) | (p[3]);
-#else
-	return be2me_32( unaligned32(v)); //original
-#endif
-}
-
-static inline int unaligned32_le(const void *v)
-{
-#ifdef CONFIG_ALIGN
-       const uint8_t *p=v;
-       return (((p[3]<<8) | p[2])<<16) | (p[1]<<8) | (p[0]);
-#else
-       return le2me_32( unaligned32(v)); //original
-#endif
-}
-
-#ifdef ALT_BITSTREAM_READER
-#   define MIN_CACHE_BITS 25
-
-#   define OPEN_READER(name, gb)\
-        int name##_index= (gb)->index;\
-        int name##_cache= 0;\
-
-#   define CLOSE_READER(name, gb)\
-        (gb)->index= name##_index;\
-
-# ifdef ALT_BITSTREAM_READER_LE
-#   define UPDATE_CACHE(name, gb)\
-        name##_cache= unaligned32_le( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\
-
-#   define SKIP_CACHE(name, gb, num)\
-        name##_cache >>= (num);
-# else
-#   define UPDATE_CACHE(name, gb)\
-        name##_cache= unaligned32_be( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\
-
-#   define SKIP_CACHE(name, gb, num)\
-        name##_cache <<= (num);
-# endif
-
-// FIXME name?
-#   define SKIP_COUNTER(name, gb, num)\
-        name##_index += (num);\
-
-#   define SKIP_BITS(name, gb, num)\
-        {\
-            SKIP_CACHE(name, gb, num)\
-            SKIP_COUNTER(name, gb, num)\
-        }\
-
-#   define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
-#   define LAST_SKIP_CACHE(name, gb, num) ;
-
-# ifdef ALT_BITSTREAM_READER_LE
-#   define SHOW_UBITS(name, gb, num)\
-        ((name##_cache) & (NEG_USR32(0xffffffff,num)))
-# else
-#   define SHOW_UBITS(name, gb, num)\
-        NEG_USR32(name##_cache, num)
-# endif
-
-#   define SHOW_SBITS(name, gb, num)\
-        NEG_SSR32(name##_cache, num)
-
-#   define GET_CACHE(name, gb)\
-        ((uint32_t)name##_cache)
-
-static inline int get_bits_count(GetBitContext *s){
-    return s->index;
-}
-#elif defined LIBMPEG2_BITSTREAM_READER
-//libmpeg2 like reader
-
-#   define MIN_CACHE_BITS 17
-
-#   define OPEN_READER(name, gb)\
-        int name##_bit_count=(gb)->bit_count;\
-        int name##_cache= (gb)->cache;\
-        uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\
-
-#   define CLOSE_READER(name, gb)\
-        (gb)->bit_count= name##_bit_count;\
-        (gb)->cache= name##_cache;\
-        (gb)->buffer_ptr= name##_buffer_ptr;\
-
-#ifdef LIBMPEG2_BITSTREAM_READER_HACK
-
-#   define UPDATE_CACHE(name, gb)\
-    if(name##_bit_count >= 0){\
-        name##_cache+= (int)be2me_16(*(uint16_t*)name##_buffer_ptr) << name##_bit_count;\
-        name##_buffer_ptr += 2;\
-        name##_bit_count-= 16;\
-    }\
-
-#else
-
-#   define UPDATE_CACHE(name, gb)\
-    if(name##_bit_count >= 0){\
-        name##_cache+= ((name##_buffer_ptr[0]<<8) + name##_buffer_ptr[1]) << name##_bit_count;\
-        name##_buffer_ptr+=2;\
-        name##_bit_count-= 16;\
-    }\
-
-#endif
-
-#   define SKIP_CACHE(name, gb, num)\
-        name##_cache <<= (num);\
-
-#   define SKIP_COUNTER(name, gb, num)\
-        name##_bit_count += (num);\
-
-#   define SKIP_BITS(name, gb, num)\
-        {\
-            SKIP_CACHE(name, gb, num)\
-            SKIP_COUNTER(name, gb, num)\
-        }\
-
-#   define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
-#   define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
-
-#   define SHOW_UBITS(name, gb, num)\
-        NEG_USR32(name##_cache, num)
-
-#   define SHOW_SBITS(name, gb, num)\
-        NEG_SSR32(name##_cache, num)
-
-#   define GET_CACHE(name, gb)\
-        ((uint32_t)name##_cache)
-
-static inline int get_bits_count(GetBitContext *s){
-    return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count;
-}
-
-#elif defined A32_BITSTREAM_READER
-
-#   define MIN_CACHE_BITS 32
-
-#   define OPEN_READER(name, gb)\
-        int name##_bit_count=(gb)->bit_count;\
-        uint32_t name##_cache0= (gb)->cache0;\
-        uint32_t name##_cache1= (gb)->cache1;\
-        uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\
-
-#   define CLOSE_READER(name, gb)\
-        (gb)->bit_count= name##_bit_count;\
-        (gb)->cache0= name##_cache0;\
-        (gb)->cache1= name##_cache1;\
-        (gb)->buffer_ptr= name##_buffer_ptr;\
-
-#   define UPDATE_CACHE(name, gb)\
-    if(name##_bit_count > 0){\
-        const uint32_t next= be2me_32( *name##_buffer_ptr );\
-        name##_cache0 |= NEG_USR32(next,name##_bit_count);\
-        name##_cache1 |= next<<name##_bit_count;\
-        name##_buffer_ptr++;\
-        name##_bit_count-= 32;\
-    }\
-
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
-#   define SKIP_CACHE(name, gb, num)\
-        asm(\
-            "shldl %2, %1, %0		\n\t"\
-            "shll %2, %1		\n\t"\
-            : "+r" (name##_cache0), "+r" (name##_cache1)\
-            : "Ic" ((uint8_t)num)\
-           );
-#else
-#   define SKIP_CACHE(name, gb, num)\
-        name##_cache0 <<= (num);\
-        name##_cache0 |= NEG_USR32(name##_cache1,num);\
-        name##_cache1 <<= (num);
-#endif
-
-#   define SKIP_COUNTER(name, gb, num)\
-        name##_bit_count += (num);\
-
-#   define SKIP_BITS(name, gb, num)\
-        {\
-            SKIP_CACHE(name, gb, num)\
-            SKIP_COUNTER(name, gb, num)\
-        }\
-
-#   define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num)
-#   define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
-
-#   define SHOW_UBITS(name, gb, num)\
-        NEG_USR32(name##_cache0, num)
-
-#   define SHOW_SBITS(name, gb, num)\
-        NEG_SSR32(name##_cache0, num)
-
-#   define GET_CACHE(name, gb)\
-        (name##_cache0)
-
-static inline int get_bits_count(GetBitContext *s){
-    return ((uint8_t*)s->buffer_ptr - s->buffer)*8 - 32 + s->bit_count;
-}
-
-#endif
-
-/**
- * read mpeg1 dc style vlc (sign bit + mantisse with no MSB).
- * if MSB not set it is negative 
- * @param n length in bits
- * @author BERO  
- */
-static inline int get_xbits(GetBitContext *s, int n){
-    register int tmp;
-    register int32_t cache;
-    OPEN_READER(re, s)
-    UPDATE_CACHE(re, s)
-    cache = GET_CACHE(re,s);
-    if ((int32_t)cache<0) { //MSB=1
-        tmp = NEG_USR32(cache,n);
-    } else {
-    //   tmp = (-1<<n) | NEG_USR32(cache,n) + 1; mpeg12.c algo
-    //   tmp = - (NEG_USR32(cache,n) ^ ((1 << n) - 1)); h263.c algo
-        tmp = - NEG_USR32(~cache,n);
-    }
-    LAST_SKIP_BITS(re, s, n)
-    CLOSE_READER(re, s)
-    return tmp;
-}
-
-static inline int get_sbits(GetBitContext *s, int n){
-    register int tmp;
-    OPEN_READER(re, s)
-    UPDATE_CACHE(re, s)
-    tmp= SHOW_SBITS(re, s, n);
-    LAST_SKIP_BITS(re, s, n)
-    CLOSE_READER(re, s)
-    return tmp;
-}
-
-/**
- * reads 0-17 bits.
- * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
- */
-static inline unsigned int get_bits(GetBitContext *s, int n){
-    register int tmp;
-    OPEN_READER(re, s)
-    UPDATE_CACHE(re, s)
-    tmp= SHOW_UBITS(re, s, n);
-    LAST_SKIP_BITS(re, s, n)
-    CLOSE_READER(re, s)
-    return tmp;
-}
-
-unsigned int get_bits_long(GetBitContext *s, int n);
-
-/**
- * shows 0-17 bits.
- * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't
- */
-static inline unsigned int show_bits(GetBitContext *s, int n){
-    register int tmp;
-    OPEN_READER(re, s)
-    UPDATE_CACHE(re, s)
-    tmp= SHOW_UBITS(re, s, n);
-//    CLOSE_READER(re, s)
-    return tmp;
-}
-
-unsigned int show_bits_long(GetBitContext *s, int n);
-
-static inline void skip_bits(GetBitContext *s, int n){
- //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
-    OPEN_READER(re, s)
-    UPDATE_CACHE(re, s)
-    LAST_SKIP_BITS(re, s, n)
-    CLOSE_READER(re, s)
-}
-
-static inline unsigned int get_bits1(GetBitContext *s){
-#ifdef ALT_BITSTREAM_READER
-    int index= s->index;
-    uint8_t result= s->buffer[ index>>3 ];
-#ifdef ALT_BITSTREAM_READER_LE
-    result>>= (index&0x07);
-    result&= 1;
-#else
-    result<<= (index&0x07);
-    result>>= 8 - 1;
-#endif
-    index++;
-    s->index= index;
-
-    return result;
-#else
-    return get_bits(s, 1);
-#endif
-}
-
-static inline unsigned int show_bits1(GetBitContext *s){
-    return show_bits(s, 1);
-}
-
-static inline void skip_bits1(GetBitContext *s){
-    skip_bits(s, 1);
-}
-
-/**
- * init GetBitContext.
- * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits
- * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
- * @param bit_size the size of the buffer in bits
- */
-static inline void init_get_bits(GetBitContext *s,
-                   const uint8_t *buffer, int bit_size)
-{
-    const int buffer_size= (bit_size+7)>>3;
-
-    s->buffer= buffer;
-    s->size_in_bits= bit_size;
-    s->buffer_end= buffer + buffer_size;
-#ifdef ALT_BITSTREAM_READER
-    s->index=0;
-#elif defined LIBMPEG2_BITSTREAM_READER
-#ifdef LIBMPEG2_BITSTREAM_READER_HACK
-  if ((int)buffer&1) {
-     /* word alignment */
-    s->cache = (*buffer++)<<24;
-    s->buffer_ptr = buffer;
-    s->bit_count = 16-8;
-  } else
-#endif
-  {
-    s->buffer_ptr = buffer;
-    s->bit_count = 16;
-    s->cache = 0;
-  }
-#elif defined A32_BITSTREAM_READER
-    s->buffer_ptr = (uint32_t*)buffer;
-    s->bit_count = 32;
-    s->cache0 = 0;
-    s->cache1 = 0;
-#endif
-    {
-        OPEN_READER(re, s)
-        UPDATE_CACHE(re, s)
-        UPDATE_CACHE(re, s)
-        CLOSE_READER(re, s)
-    }
-#ifdef A32_BITSTREAM_READER
-    s->cache1 = 0;
-#endif
-}
-
-int check_marker(GetBitContext *s, const char *msg);
-void align_get_bits(GetBitContext *s);
-int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
-             const void *bits, int bits_wrap, int bits_size,
-             const void *codes, int codes_wrap, int codes_size,
-             int flags);
-#define INIT_VLC_USE_STATIC 1
-#define INIT_VLC_LE         2
-void free_vlc(VLC *vlc);
-
-/**
- *
- * if the vlc code is invalid and max_depth=1 than no bits will be removed
- * if the vlc code is invalid and max_depth>1 than the number of bits removed
- * is undefined
- */
-#define GET_VLC(code, name, gb, table, bits, max_depth)\
-{\
-    int n, index, nb_bits;\
-\
-    index= SHOW_UBITS(name, gb, bits);\
-    code = table[index][0];\
-    n    = table[index][1];\
-\
-    if(max_depth > 1 && n < 0){\
-        LAST_SKIP_BITS(name, gb, bits)\
-        UPDATE_CACHE(name, gb)\
-\
-        nb_bits = -n;\
-\
-        index= SHOW_UBITS(name, gb, nb_bits) + code;\
-        code = table[index][0];\
-        n    = table[index][1];\
-        if(max_depth > 2 && n < 0){\
-            LAST_SKIP_BITS(name, gb, nb_bits)\
-            UPDATE_CACHE(name, gb)\
-\
-            nb_bits = -n;\
-\
-            index= SHOW_UBITS(name, gb, nb_bits) + code;\
-            code = table[index][0];\
-            n    = table[index][1];\
-        }\
-    }\
-    SKIP_BITS(name, gb, n)\
-}
-
-#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\
-{\
-    int n, index, nb_bits;\
-\
-    index= SHOW_UBITS(name, gb, bits);\
-    level = table[index].level;\
-    n     = table[index].len;\
-\
-    if(max_depth > 1 && n < 0){\
-        SKIP_BITS(name, gb, bits)\
-        if(need_update){\
-            UPDATE_CACHE(name, gb)\
-        }\
-\
-        nb_bits = -n;\
-\
-        index= SHOW_UBITS(name, gb, nb_bits) + level;\
-        level = table[index].level;\
-        n     = table[index].len;\
-    }\
-    run= table[index].run;\
-    SKIP_BITS(name, gb, n)\
-}
-
-// deprecated, dont use get_vlc for new code, use get_vlc2 instead or use GET_VLC directly
-static inline int get_vlc(GetBitContext *s, VLC *vlc)
-{
-    int code;
-    VLC_TYPE (*table)[2]= vlc->table;
-    
-    OPEN_READER(re, s)
-    UPDATE_CACHE(re, s)
-
-    GET_VLC(code, re, s, table, vlc->bits, 3)    
-
-    CLOSE_READER(re, s)
-    return code;
-}
-
-/**
- * parses a vlc code, faster then get_vlc()
- * @param bits is the number of bits which will be read at once, must be 
- *             identical to nb_bits in init_vlc()
- * @param max_depth is the number of times bits bits must be readed to completly
- *                  read the longest vlc code 
- *                  = (max_vlc_length + bits - 1) / bits
- */
-static always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
-                                  int bits, int max_depth)
-{
-    int code;
-    
-    OPEN_READER(re, s)
-    UPDATE_CACHE(re, s)
-
-    GET_VLC(code, re, s, table, bits, max_depth)
-
-    CLOSE_READER(re, s)
-    return code;
-}
-
-//#define TRACE
-
-#ifdef TRACE
-#include "avcodec.h"
-static inline void print_bin(int bits, int n){
-    int i;
-    
-    for(i=n-1; i>=0; i--){
-        av_log(NULL, AV_LOG_DEBUG, "%d", (bits>>i)&1);
-    }
-    for(i=n; i<24; i++)
-        av_log(NULL, AV_LOG_DEBUG, " ");
-}
-
-static inline int get_bits_trace(GetBitContext *s, int n, char *file, const char *func, int line){
-    int r= get_bits(s, n);
-    
-    print_bin(r, n);
-    av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line);
-    return r;
-}
-static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, const char *func, int line){
-    int show= show_bits(s, 24);
-    int pos= get_bits_count(s);
-    int r= get_vlc2(s, table, bits, max_depth);
-    int len= get_bits_count(s) - pos;
-    int bits2= show>>(24-len);
-    
-    print_bin(bits2, len);
-    
-    av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line);
-    return r;
-}
-static inline int get_xbits_trace(GetBitContext *s, int n, char *file, const char *func, int line){
-    int show= show_bits(s, n);
-    int r= get_xbits(s, n);
-    
-    print_bin(show, n);
-    av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line);
-    return r;
-}
-
-#define get_bits(s, n)  get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#define get_bits1(s)    get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#define get_vlc(s, vlc)            get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-
-#define tprintf(...) av_log(NULL, AV_LOG_DEBUG, __VA_ARGS__)
-
-#else //TRACE
-#define tprintf(...) {}
-#endif
-
-static inline int decode012(GetBitContext *gb){
-    int n;
-    n = get_bits1(gb);
-    if (n == 0)
-        return 0;
-    else
-        return get_bits1(gb) + 1;
-}
-
-#endif /* BITSTREAM_H */
diff --git a/ffmpeg.src/libavcodec/cabac.c b/ffmpeg.src/libavcodec/cabac.c
deleted file mode 100644
index 9a598fa..0000000
--- a/ffmpeg.src/libavcodec/cabac.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
- * Copyright (c) 2003 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-/**
- * @file cabac.c
- * Context Adaptive Binary Arithmetic Coder.
- */
-
-#include <string.h>
-
-#include "common.h"
-#include "bitstream.h"
-#include "cabac.h"
-
-const uint8_t ff_h264_lps_range[64][4]= {
-{128,176,208,240}, {128,167,197,227}, {128,158,187,216}, {123,150,178,205},
-{116,142,169,195}, {111,135,160,185}, {105,128,152,175}, {100,122,144,166},
-{ 95,116,137,158}, { 90,110,130,150}, { 85,104,123,142}, { 81, 99,117,135},
-{ 77, 94,111,128}, { 73, 89,105,122}, { 69, 85,100,116}, { 66, 80, 95,110},
-{ 62, 76, 90,104}, { 59, 72, 86, 99}, { 56, 69, 81, 94}, { 53, 65, 77, 89},
-{ 51, 62, 73, 85}, { 48, 59, 69, 80}, { 46, 56, 66, 76}, { 43, 53, 63, 72},
-{ 41, 50, 59, 69}, { 39, 48, 56, 65}, { 37, 45, 54, 62}, { 35, 43, 51, 59},
-{ 33, 41, 48, 56}, { 32, 39, 46, 53}, { 30, 37, 43, 50}, { 29, 35, 41, 48},
-{ 27, 33, 39, 45}, { 26, 31, 37, 43}, { 24, 30, 35, 41}, { 23, 28, 33, 39},
-{ 22, 27, 32, 37}, { 21, 26, 30, 35}, { 20, 24, 29, 33}, { 19, 23, 27, 31},
-{ 18, 22, 26, 30}, { 17, 21, 25, 28}, { 16, 20, 23, 27}, { 15, 19, 22, 25},
-{ 14, 18, 21, 24}, { 14, 17, 20, 23}, { 13, 16, 19, 22}, { 12, 15, 18, 21},
-{ 12, 14, 17, 20}, { 11, 14, 16, 19}, { 11, 13, 15, 18}, { 10, 12, 15, 17},
-{ 10, 12, 14, 16}, {  9, 11, 13, 15}, {  9, 11, 12, 14}, {  8, 10, 12, 14},
-{  8,  9, 11, 13}, {  7,  9, 11, 12}, {  7,  9, 10, 12}, {  7,  8, 10, 11},
-{  6,  8,  9, 11}, {  6,  7,  9, 10}, {  6,  7,  8,  9}, {  2,  2,  2,  2},
-};
-
-const uint8_t ff_h264_mps_state[64]= {
-  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,32,
- 33,34,35,36,37,38,39,40,
- 41,42,43,44,45,46,47,48,
- 49,50,51,52,53,54,55,56,
- 57,58,59,60,61,62,62,63,
-};
-
-const uint8_t ff_h264_lps_state[64]= {
-  0, 0, 1, 2, 2, 4, 4, 5,
-  6, 7, 8, 9, 9,11,11,12,
- 13,13,15,15,16,16,18,18,
- 19,19,21,21,22,22,23,24,
- 24,25,26,26,27,27,28,29,
- 29,30,30,30,31,32,32,33,
- 33,33,34,34,35,35,35,36,
- 36,36,37,37,37,38,38,63,
-};
-
-const uint8_t ff_h264_norm_shift[256]= {
- 8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,
- 3,3,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,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,
- 1,1,1,1,1,1,1,1,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,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,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,0,0,0,0,0,0,0,0, 
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 
-};
-
-/**
- *
- * @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;
-#ifdef STRICT_LIMITS
-    c->sym_count =0;
-#endif
-    
-    c->pb.bit_left++; //avoids firstBitFlag
-}
-
-/**
- *
- * @param buf_size size of buf in bits
- */
-void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size){
-    c->bytestream_start= 
-    c->bytestream= buf;
-    c->bytestream_end= buf + buf_size;
-
-#if CABAC_BITS == 16
-    c->low =  (*c->bytestream++)<<18;
-    c->low+=  (*c->bytestream++)<<10;
-#else
-    c->low =  (*c->bytestream++)<<10;
-#endif
-    c->low+= ((*c->bytestream++)<<2) + 2;
-    c->range= 0x1FE<<(CABAC_BITS + 1);
-}
-
-void ff_init_cabac_states(CABACContext *c, uint8_t const (*lps_range)[4], 
-                          uint8_t const *mps_state, uint8_t const *lps_state, int state_count){
-    int i, j;
-    
-    for(i=0; i<state_count; i++){
-        for(j=0; j<4; j++){ //FIXME check if this is worth the 1 shift we save
-            c->lps_range[2*i+0][j+4]=
-            c->lps_range[2*i+1][j+4]= lps_range[i][j];
-        }
-
-        c->mps_state[2*i+0]= 2*mps_state[i];
-        c->mps_state[2*i+1]= 2*mps_state[i]+1;
-
-        if( i ){
-            c->lps_state[2*i+0]= 2*lps_state[i];
-            c->lps_state[2*i+1]= 2*lps_state[i]+1;
-        }else{
-            c->lps_state[2*i+0]= 1;
-            c->lps_state[2*i+1]= 0;
-        }
-    }
-}
-
-#if 0 //selftest
-#define SIZE 10240
-
-#include "avcodec.h"
-
-int main(){
-    CABACContext c;
-    uint8_t b[9*SIZE];
-    uint8_t r[9*SIZE];
-    int i;
-    uint8_t state[10]= {0};
-    
-    ff_init_cabac_encoder(&c, b, SIZE);
-    ff_init_cabac_states(&c, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64);
-    
-    for(i=0; i<SIZE; i++){
-        r[i]= random()%7;
-    }
-    
-    for(i=0; i<SIZE; i++){
-START_TIMER
-        put_cabac_bypass(&c, r[i]&1);
-STOP_TIMER("put_cabac_bypass")
-    }
-    
-    for(i=0; i<SIZE; i++){
-START_TIMER
-        put_cabac(&c, state, r[i]&1);
-STOP_TIMER("put_cabac")
-    }
-
-    for(i=0; i<SIZE; i++){
-START_TIMER
-        put_cabac_u(&c, state, r[i], 6, 3, i&1);
-STOP_TIMER("put_cabac_u")
-    }    
-
-    for(i=0; i<SIZE; i++){
-START_TIMER
-        put_cabac_ueg(&c, state, r[i], 3, 0, 1, 2);
-STOP_TIMER("put_cabac_ueg")
-    }    
-   
-    put_cabac_terminate(&c, 1);
-    
-    ff_init_cabac_decoder(&c, b, SIZE);
-    
-    memset(state, 0, sizeof(state));
-    
-    for(i=0; i<SIZE; i++){
-START_TIMER
-        if( (r[i]&1) != get_cabac_bypass(&c) )
-            av_log(NULL, AV_LOG_ERROR, "CABAC bypass failure at %d\n", i);
-STOP_TIMER("get_cabac_bypass")
-    }
-    
-    for(i=0; i<SIZE; i++){
-START_TIMER
-        if( (r[i]&1) != get_cabac(&c, state) )
-            av_log(NULL, AV_LOG_ERROR, "CABAC failure at %d\n", i);
-STOP_TIMER("get_cabac")
-    }
-#if 0
-    for(i=0; i<SIZE; i++){
-START_TIMER
-        if( r[i] != get_cabac_u(&c, state, (i&1) ? 6 : 7, 3, i&1) )
-            av_log(NULL, AV_LOG_ERROR, "CABAC unary (truncated) binarization failure at %d\n", i);
-STOP_TIMER("get_cabac_u")
-    }
-
-    for(i=0; i<SIZE; i++){
-START_TIMER
-        if( r[i] != get_cabac_ueg(&c, state, 3, 0, 1, 2))
-            av_log(NULL, AV_LOG_ERROR, "CABAC unary (truncated) binarization failure at %d\n", i);
-STOP_TIMER("get_cabac_ueg")
-    }
-#endif
-    if(!get_cabac_terminate(&c))
-        av_log(NULL, AV_LOG_ERROR, "where's the Terminator?\n");
-    
-    return 0;
-}
-
-#endif
diff --git a/ffmpeg.src/libavcodec/cabac.h b/ffmpeg.src/libavcodec/cabac.h
deleted file mode 100644
index 15ec88d..0000000
--- a/ffmpeg.src/libavcodec/cabac.h
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
- * Copyright (c) 2003 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
- 
-/**
- * @file cabac.h
- * Context Adaptive Binary Arithmetic Coder.
- */
-
-
-#undef NDEBUG
-#include <assert.h>
-
-#define CABAC_BITS 8
-#define CABAC_MASK ((1<<CABAC_BITS)-1)
-
-typedef struct CABACContext{
-    int low;
-    int range;
-    int outstanding_count;
-#ifdef STRICT_LIMITS
-    int symCount;
-#endif
-    uint8_t lps_range[2*65][4];   ///< rangeTabLPS
-    uint8_t lps_state[2*64];      ///< transIdxLPS
-    uint8_t mps_state[2*64];      ///< transIdxMPS
-    const uint8_t *bytestream_start;
-    const uint8_t *bytestream;
-    const uint8_t *bytestream_end;
-    PutBitContext pb;
-}CABACContext;
-
-extern const uint8_t ff_h264_lps_range[64][4];
-extern const uint8_t ff_h264_mps_state[64];
-extern const uint8_t ff_h264_lps_state[64];
-extern const uint8_t ff_h264_norm_shift[256];
-
-
-void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size);
-void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size);
-void ff_init_cabac_states(CABACContext *c, uint8_t const (*lps_range)[4], 
-                          uint8_t const *mps_state, uint8_t const *lps_state, int state_count);
-
-
-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(CABACContext *c){
-    while(c->range < 0x100){
-        //FIXME optimize
-        if(c->low<0x100){
-            put_cabac_bit(c, 0);
-        }else if(c->low<0x200){
-            c->outstanding_count++;
-            c->low -= 0x100;
-        }else{
-            put_cabac_bit(c, 1);
-            c->low -= 0x200;
-        }
-        
-        c->range+= c->range;
-        c->low += c->low;
-    }
-}
-
-static inline void put_cabac(CABACContext *c, uint8_t * const state, int bit){
-    int RangeLPS= c->lps_range[*state][c->range>>6];
-    
-    if(bit == ((*state)&1)){
-        c->range -= RangeLPS;
-        *state= c->mps_state[*state];
-    }else{
-        c->low += c->range - RangeLPS;
-        c->range = RangeLPS;
-        *state= c->lps_state[*state];
-    }
-    
-    renorm_cabac_encoder(c);
-
-#ifdef STRICT_LIMITS
-    c->symCount++;
-#endif
-}
-
-static inline void put_cabac_static(CABACContext *c, int RangeLPS, int bit){
-    assert(c->range > RangeLPS);
-
-    if(!bit){
-        c->range -= RangeLPS;
-    }else{
-        c->low += c->range - RangeLPS;
-        c->range = RangeLPS;
-    }
-
-    renorm_cabac_encoder(c);
-
-#ifdef STRICT_LIMITS
-    c->symCount++;
-#endif
-}
-
-/**
- * @param bit 0 -> write zero bit, !=0 write one bit
- */
-static inline void put_cabac_bypass(CABACContext *c, int bit){
-    c->low += c->low;
-
-    if(bit){
-        c->low += c->range;
-    }
-//FIXME optimize
-    if(c->low<0x200){
-        put_cabac_bit(c, 0);
-    }else if(c->low<0x400){
-        c->outstanding_count++;
-        c->low -= 0x200;
-    }else{
-        put_cabac_bit(c, 1);
-        c->low -= 0x400;
-    }
-        
-#ifdef STRICT_LIMITS
-    c->symCount++;
-#endif
-}
-
-/**
- *
- * @return the number of bytes written
- */
-static inline int put_cabac_terminate(CABACContext *c, int bit){
-    c->range -= 2;
-
-    if(!bit){
-        renorm_cabac_encoder(c);
-    }else{
-        c->low += c->range;
-        c->range= 2;
-        
-        renorm_cabac_encoder(c);
-
-        assert(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
-    }
-        
-#ifdef STRICT_LIMITS
-    c->symCount++;
-#endif
-
-    return (put_bits_count(&c->pb)+7)>>3;
-}
-
-/**
- * put (truncated) unary binarization.
- */
-static inline void put_cabac_u(CABACContext *c, uint8_t * state, int v, int max, int max_index, int truncated){
-    int i;
-    
-    assert(v <= max);
-    
-#if 1
-    for(i=0; i<v; i++){
-        put_cabac(c, state, 1);
-        if(i < max_index) state++;
-    }
-    if(truncated==0 || v<max)
-        put_cabac(c, state, 0);
-#else
-    if(v <= max_index){
-        for(i=0; i<v; i++){
-            put_cabac(c, state+i, 1);
-        }
-        if(truncated==0 || v<max)
-            put_cabac(c, state+i, 0);
-    }else{
-        for(i=0; i<=max_index; i++){
-            put_cabac(c, state+i, 1);
-        }
-        for(; i<v; i++){
-            put_cabac(c, state+max_index, 1);
-        }
-        if(truncated==0 || v<max)
-            put_cabac(c, state+max_index, 0);
-    }
-#endif
-}
-
-/**
- * put unary exp golomb k-th order binarization.
- */
-static inline void put_cabac_ueg(CABACContext *c, uint8_t * state, int v, int max, int is_signed, int k, int max_index){
-    int i;
-    
-    if(v==0)
-        put_cabac(c, state, 0);
-    else{
-        const int sign= v < 0;
-        
-        if(is_signed) v= ABS(v);
-        
-        if(v<max){
-            for(i=0; i<v; i++){
-                put_cabac(c, state, 1);
-                if(i < max_index) state++;
-            }
-
-            put_cabac(c, state, 0);
-        }else{
-            int m= 1<<k;
-
-            for(i=0; i<max; i++){
-                put_cabac(c, state, 1);
-                if(i < max_index) state++;
-            }
-
-            v -= max;
-            while(v >= m){ //FIXME optimize
-                put_cabac_bypass(c, 1);
-                v-= m;
-                m+= m;
-            }
-            put_cabac_bypass(c, 0);
-            while(m>>=1){
-                put_cabac_bypass(c, v&m);
-            }
-        }
-
-        if(is_signed)
-            put_cabac_bypass(c, sign);
-    }
-}
-
-static void refill(CABACContext *c){
-    if(c->bytestream <= c->bytestream_end)
-#if CABAC_BITS == 16
-        c->low+= ((c->bytestream[0]<<9) + (c->bytestream[1])<<1);
-#else
-        c->low+= c->bytestream[0]<<1;
-#endif
-    c->low -= CABAC_MASK;
-    c->bytestream+= CABAC_BITS/8;
-}
-
-#if 0 /* all use commented */
-static void refill2(CABACContext *c){
-    int i, x;
-
-    x= c->low ^ (c->low-1);
-    i= 8 - ff_h264_norm_shift[x>>(CABAC_BITS+1)];
-
-    x= -CABAC_MASK;
-    
-    if(c->bytestream < c->bytestream_end)
-#if CABAC_BITS == 16
-        x+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1);
-#else
-        x+= c->bytestream[0]<<1;
-#endif
-    
-    c->low += x<<i;
-    c->bytestream+= CABAC_BITS/8;
-}
-#endif
-
-static inline void renorm_cabac_decoder(CABACContext *c){
-    while(c->range < (0x200 << CABAC_BITS)){
-        c->range+= c->range;
-        c->low+= c->low;
-        if(!(c->low & CABAC_MASK))
-            refill(c);
-    }
-}
-
-static inline void renorm_cabac_decoder_once(CABACContext *c){
-    int mask= (c->range - (0x200 << CABAC_BITS))>>31;
-    c->range+= c->range&mask;
-    c->low  += c->low  &mask;
-    if(!(c->low & CABAC_MASK))
-        refill(c);
-}
-
-static inline int get_cabac(CABACContext *c, uint8_t * const state){
-    int RangeLPS= c->lps_range[*state][c->range>>(CABAC_BITS+7)]<<(CABAC_BITS+1);
-    int bit, lps_mask attribute_unused;
-    
-    c->range -= RangeLPS;
-#if 1
-    if(c->low < c->range){
-        bit= (*state)&1;
-        *state= c->mps_state[*state];
-        renorm_cabac_decoder_once(c);
-    }else{
-//        int shift= ff_h264_norm_shift[RangeLPS>>17];
-        bit= ((*state)&1)^1;
-        c->low -= c->range;
-        *state= c->lps_state[*state];
-        c->range = RangeLPS;
-        renorm_cabac_decoder(c);
-/*        c->range = RangeLPS<<shift;
-        c->low <<= shift;
-        if(!(c->low & 0xFFFF)){
-            refill2(c);
-        }*/
-    }
-#else
-    lps_mask= (c->range - c->low)>>31;
-    
-    c->low -= c->range & lps_mask;
-    c->range += (RangeLPS - c->range) & lps_mask;
-    
-    bit= ((*state)^lps_mask)&1;
-    *state= c->mps_state[(*state) - (128&lps_mask)];
-    
-    lps_mask= ff_h264_norm_shift[c->range>>(CABAC_BITS+2)];
-    c->range<<= lps_mask;
-    c->low  <<= lps_mask;
-    if(!(c->low & CABAC_MASK))
-        refill2(c);
-#endif
-
-    return bit;    
-}
-
-static inline int get_cabac_bypass(CABACContext *c){
-    c->low += c->low;
-
-    if(!(c->low & CABAC_MASK))
-        refill(c);
-    
-    if(c->low < c->range){
-        return 0;
-    }else{
-        c->low -= c->range;
-        return 1;
-    }
-}
-
-/**
- *
- * @return the number of bytes read or 0 if no end
- */
-static inline int get_cabac_terminate(CABACContext *c){
-    c->range -= 4<<CABAC_BITS;
-    if(c->low < c->range){
-        renorm_cabac_decoder_once(c);
-        return 0;
-    }else{
-        return c->bytestream - c->bytestream_start;
-    }    
-}
-
-/**
- * get (truncated) unnary binarization.
- */
-static inline int get_cabac_u(CABACContext *c, uint8_t * state, int max, int max_index, int truncated){
-    int i;
-    
-    for(i=0; i<max; i++){ 
-        if(get_cabac(c, state)==0)
-            return i;
-            
-        if(i< max_index) state++;
-    }
-
-    return truncated ? max : -1;
-}
-
-/**
- * get unary exp golomb k-th order binarization.
- */
-static inline int get_cabac_ueg(CABACContext *c, uint8_t * state, int max, int is_signed, int k, int max_index){
-    int i, v;
-    int m= 1<<k;
-    
-    if(get_cabac(c, state)==0) 
-        return 0;
-        
-    if(0 < max_index) state++;
-    
-    for(i=1; i<max; i++){ 
-        if(get_cabac(c, state)==0){
-            if(is_signed && get_cabac_bypass(c)){
-                return -i;
-            }else
-                return i;
-        }
-
-        if(i < max_index) state++;
-    }
-    
-    while(get_cabac_bypass(c)){
-        i+= m;
-        m+= m;
-    }
-    
-    v=0;
-    while(m>>=1){
-        v+= v + get_cabac_bypass(c);
-    }
-    i += v;
-
-    if(is_signed && get_cabac_bypass(c)){
-        return -i;
-    }else
-        return i;
-}
diff --git a/ffmpeg.src/libavcodec/dpcm.c b/ffmpeg.src/libavcodec/dpcm.c
deleted file mode 100644
index 78ab8cb..0000000
--- a/ffmpeg.src/libavcodec/dpcm.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * Assorted DPCM codecs
- * Copyright (c) 2003 The ffmpeg Project.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file: dpcm.c
- * Assorted DPCM (differential pulse code modulation) audio codecs
- * by Mike Melanson (melanson at pcisys.net)
- * Xan DPCM decoder by Mario Brito (mbrito at student.dei.uc.pt)
- * for more information on the specific data formats, visit:
- *   http://www.pcisys.net/~melanson/codecs/simpleaudio.html
- * SOL DPCMs implemented by Konstantin Shishkov
- *
- * Note about using the Xan DPCM decoder: Xan DPCM is used in AVI files
- * found in the Wing Commander IV computer game. These AVI files contain
- * WAVEFORMAT headers which report the audio format as 0x01: raw PCM.
- * Clearly incorrect. To detect Xan DPCM, you will probably have to
- * special-case your AVI demuxer to use Xan DPCM if the file uses 'Xxan'
- * (Xan video) for its video codec. Alternately, such AVI files also contain
- * the fourcc 'Axan' in the 'auds' chunk of the AVI header.
- */
-
-#include "avcodec.h"
-
-typedef struct DPCMContext {
-    int channels;
-    short roq_square_array[256];
-    long sample[2];//for SOL_DPCM
-    int *sol_table;//for SOL_DPCM
-} DPCMContext;
-
-#define SATURATE_S16(x)  if (x < -32768) x = -32768; \
-  else if (x > 32767) x = 32767;
-#define SE_16BIT(x)  if (x & 0x8000) x -= 0x10000;
-
-static int interplay_delta_table[] = {
-         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,
-        32,     33,     34,     35,     36,     37,     38,     39,
-        40,     41,     42,     43,     47,     51,     56,     61,
-        66,     72,     79,     86,     94,    102,    112,    122,
-       133,    145,    158,    173,    189,    206,    225,    245,
-       267,    292,    318,    348,    379,    414,    452,    493,
-       538,    587,    640,    699,    763,    832,    908,    991,
-      1081,   1180,   1288,   1405,   1534,   1673,   1826,   1993,
-      2175,   2373,   2590,   2826,   3084,   3365,   3672,   4008,
-      4373,   4772,   5208,   5683,   6202,   6767,   7385,   8059,
-      8794,   9597,  10472,  11428,  12471,  13609,  14851,  16206,
-     17685,  19298,  21060,  22981,  25078,  27367,  29864,  32589,
-    -29973, -26728, -23186, -19322, -15105, -10503,  -5481,     -1,
-         1,      1,   5481,  10503,  15105,  19322,  23186,  26728,
-     29973, -32589, -29864, -27367, -25078, -22981, -21060, -19298,
-    -17685, -16206, -14851, -13609, -12471, -11428, -10472,  -9597,
-     -8794,  -8059,  -7385,  -6767,  -6202,  -5683,  -5208,  -4772,
-     -4373,  -4008,  -3672,  -3365,  -3084,  -2826,  -2590,  -2373,
-     -2175,  -1993,  -1826,  -1673,  -1534,  -1405,  -1288,  -1180,
-     -1081,   -991,   -908,   -832,   -763,   -699,   -640,   -587,
-      -538,   -493,   -452,   -414,   -379,   -348,   -318,   -292,
-      -267,   -245,   -225,   -206,   -189,   -173,   -158,   -145,
-      -133,   -122,   -112,   -102,    -94,    -86,    -79,    -72,
-       -66,    -61,    -56,    -51,    -47,    -43,    -42,    -41,
-       -40,    -39,    -38,    -37,    -36,    -35,    -34,    -33,
-       -32,    -31,    -30,    -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
-
-};
-
-static int sol_table_old[16] =
-    { 0x0,  0x1,  0x2 , 0x3,  0x6,  0xA,  0xF, 0x15,
-    -0x15, -0xF, -0xA, -0x6, -0x3, -0x2, -0x1, 0x0};
-
-static int sol_table_new[16] =
-    { 0x0,  0x1,  0x2,  0x3,  0x6,  0xA,  0xF,  0x15,
-      0x0, -0x1, -0x2, -0x3, -0x6, -0xA, -0xF, -0x15};
-    
-static int sol_table_16[128] = {
-    0x000, 0x008, 0x010, 0x020, 0x030, 0x040, 0x050, 0x060, 0x070, 0x080,
-    0x090, 0x0A0, 0x0B0, 0x0C0, 0x0D0, 0x0E0, 0x0F0, 0x100, 0x110, 0x120,
-    0x130, 0x140, 0x150, 0x160, 0x170, 0x180, 0x190, 0x1A0, 0x1B0, 0x1C0,
-    0x1D0, 0x1E0, 0x1F0, 0x200, 0x208, 0x210, 0x218, 0x220, 0x228, 0x230,
-    0x238, 0x240, 0x248, 0x250, 0x258, 0x260, 0x268, 0x270, 0x278, 0x280,
-    0x288, 0x290, 0x298, 0x2A0, 0x2A8, 0x2B0, 0x2B8, 0x2C0, 0x2C8, 0x2D0,
-    0x2D8, 0x2E0, 0x2E8, 0x2F0, 0x2F8, 0x300, 0x308, 0x310, 0x318, 0x320,
-    0x328, 0x330, 0x338, 0x340, 0x348, 0x350, 0x358, 0x360, 0x368, 0x370,
-    0x378, 0x380, 0x388, 0x390, 0x398, 0x3A0, 0x3A8, 0x3B0, 0x3B8, 0x3C0,
-    0x3C8, 0x3D0, 0x3D8, 0x3E0, 0x3E8, 0x3F0, 0x3F8, 0x400, 0x440, 0x480,
-    0x4C0, 0x500, 0x540, 0x580, 0x5C0, 0x600, 0x640, 0x680, 0x6C0, 0x700,
-    0x740, 0x780, 0x7C0, 0x800, 0x900, 0xA00, 0xB00, 0xC00, 0xD00, 0xE00,
-    0xF00, 0x1000, 0x1400, 0x1800, 0x1C00, 0x2000, 0x3000, 0x4000
-};
-
-
-
-static int dpcm_decode_init(AVCodecContext *avctx)
-{
-    DPCMContext *s = avctx->priv_data;
-    int i;
-    short square;
-
-    s->channels = avctx->channels;
-    s->sample[0] = s->sample[1] = 0;
-
-    switch(avctx->codec->id) {
-
-    case CODEC_ID_ROQ_DPCM:
-        /* initialize square table */
-        for (i = 0; i < 128; i++) {
-            square = i * i;
-            s->roq_square_array[i] = square;
-            s->roq_square_array[i + 128] = -square;
-        }
-        break;
-
-        
-    case CODEC_ID_SOL_DPCM:
-        switch(avctx->codec_tag){
-        case 1:
-            s->sol_table=sol_table_old;
-            s->sample[0] = s->sample[1] = 0x80;
-            break;
-        case 2:
-            s->sol_table=sol_table_new;
-            s->sample[0] = s->sample[1] = 0x80;
-            break;
-        case 3:
-            s->sol_table=sol_table_16;
-            break;
-        default:
-            av_log(avctx, AV_LOG_ERROR, "Unknown SOL subcodec\n");
-            return -1;
-        }
-        break;
-     
-    default:
-        break;
-    }
-
-    return 0;
-}
-
-static int dpcm_decode_frame(AVCodecContext *avctx,
-                             void *data, int *data_size,
-                             uint8_t *buf, int buf_size)
-{
-    DPCMContext *s = avctx->priv_data;
-    int in, out = 0;
-    int predictor[2];
-    int channel_number = 0;
-    short *output_samples = data;
-    int shift[2];
-    unsigned char byte;
-    short diff;
-
-    if (!buf_size)
-        return 0;
-
-    switch(avctx->codec->id) {
-
-    case CODEC_ID_ROQ_DPCM:
-        if (s->channels == 1)
-            predictor[0] = LE_16(&buf[6]);
-        else {
-            predictor[0] = buf[7] << 8;
-            predictor[1] = buf[6] << 8;
-        }
-        SE_16BIT(predictor[0]);
-        SE_16BIT(predictor[1]);
-
-        /* decode the samples */
-        for (in = 8, out = 0; in < buf_size; in++, out++) {
-            predictor[channel_number] += s->roq_square_array[buf[in]];
-            SATURATE_S16(predictor[channel_number]);
-            output_samples[out] = predictor[channel_number];
-
-            /* toggle channel */
-            channel_number ^= s->channels - 1;
-        }
-        break;
-
-    case CODEC_ID_INTERPLAY_DPCM:
-        in = 6;  /* skip over the stream mask and stream length */
-        predictor[0] = LE_16(&buf[in]);
-        in += 2;
-        SE_16BIT(predictor[0])
-        output_samples[out++] = predictor[0];
-        if (s->channels == 2) {
-            predictor[1] = LE_16(&buf[in]);
-            in += 2;
-            SE_16BIT(predictor[1])
-            output_samples[out++] = predictor[1];
-        }
-
-        while (in < buf_size) {
-            predictor[channel_number] += interplay_delta_table[buf[in++]];
-            SATURATE_S16(predictor[channel_number]);
-            output_samples[out++] = predictor[channel_number];
-
-            /* toggle channel */
-            channel_number ^= s->channels - 1;
-        }
-
-        break;
-
-    case CODEC_ID_XAN_DPCM:
-        in = 0;
-        shift[0] = shift[1] = 4;
-        predictor[0] = LE_16(&buf[in]);
-        in += 2;
-        SE_16BIT(predictor[0]);
-        if (s->channels == 2) {
-            predictor[1] = LE_16(&buf[in]);
-            in += 2;
-            SE_16BIT(predictor[1]);
-        }
-
-        while (in < buf_size) {
-            byte = buf[in++];
-            diff = (byte & 0xFC) << 8;
-            if ((byte & 0x03) == 3)
-                shift[channel_number]++;
-            else
-                shift[channel_number] -= (2 * (byte & 3));
-            /* saturate the shifter to a lower limit of 0 */
-            if (shift[channel_number] < 0)
-                shift[channel_number] = 0;
-
-            diff >>= shift[channel_number];
-            predictor[channel_number] += diff;
-
-            SATURATE_S16(predictor[channel_number]);
-            output_samples[out++] = predictor[channel_number];
-
-            /* toggle channel */
-            channel_number ^= s->channels - 1;
-        }
-        break;
-    case CODEC_ID_SOL_DPCM:
-        in = 0;
-        if (avctx->codec_tag != 3) {
-            while (in < buf_size) {
-                int n1, n2;
-                n1 = (buf[in] >> 4) & 0xF;
-                n2 = buf[in++] & 0xF;
-                s->sample[0] += s->sol_table[n1];
-                 if (s->sample[0] < 0) s->sample[0] = 0;
-                if (s->sample[0] > 255) s->sample[0] = 255;
-                output_samples[out++] = (s->sample[0] - 128) << 8;
-                s->sample[s->channels - 1] += s->sol_table[n2];
-                if (s->sample[s->channels - 1] < 0) s->sample[s->channels - 1] = 0;
-                if (s->sample[s->channels - 1] > 255) s->sample[s->channels - 1] = 255;
-                output_samples[out++] = (s->sample[s->channels - 1] - 128) << 8;
-            }
-        } else {
-            while (in < buf_size) {
-                int n;
-                n = buf[in++];
-                if (n & 0x80) s->sample[channel_number] -= s->sol_table[n & 0x7F];
-                else s->sample[channel_number] += s->sol_table[n & 0x7F];
-                SATURATE_S16(s->sample[channel_number]);
-                output_samples[out++] = s->sample[channel_number];
-                /* toggle channel */
-                channel_number ^= s->channels - 1;
-            }
-        }
-        break;
-    }
-
-    *data_size = out * sizeof(short);
-    return buf_size;
-}
-
-AVCodec roq_dpcm_decoder = {
-    "roq_dpcm",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_ROQ_DPCM,
-    sizeof(DPCMContext),
-    dpcm_decode_init,
-    NULL,
-    NULL,
-    dpcm_decode_frame,
-};
-
-AVCodec interplay_dpcm_decoder = {
-    "interplay_dpcm",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_INTERPLAY_DPCM,
-    sizeof(DPCMContext),
-    dpcm_decode_init,
-    NULL,
-    NULL,
-    dpcm_decode_frame,
-};
-
-AVCodec xan_dpcm_decoder = {
-    "xan_dpcm",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_XAN_DPCM,
-    sizeof(DPCMContext),
-    dpcm_decode_init,
-    NULL,
-    NULL,
-    dpcm_decode_frame,
-};
-
-AVCodec sol_dpcm_decoder = {
-    "sol_dpcm",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_SOL_DPCM,
-    sizeof(DPCMContext),
-    dpcm_decode_init,
-    NULL,
-    NULL,
-    dpcm_decode_frame,
-};
diff --git a/ffmpeg.src/libavcodec/dsputil.c b/ffmpeg.src/libavcodec/dsputil.c
deleted file mode 100644
index bfab8e2..0000000
--- a/ffmpeg.src/libavcodec/dsputil.c
+++ /dev/null
@@ -1,3962 +0,0 @@
-/*
- * DSP utils
- * Copyright (c) 2000, 2001 Fabrice Bellard.
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni at gmx.at>
- */
- 
-/**
- * @file dsputil.c
- * DSP utils
- */
- 
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-#include "simple_idct.h"
-#include "faandct.h"
-
-/* snow.c */
-void ff_spatial_dwt(int *buffer, int width, int height, int stride, int type, int decomposition_count);
-
-uint8_t cropTbl[256 + 2 * MAX_NEG_CROP] = {0, };
-uint32_t squareTbl[512] = {0, };
-
-const uint8_t ff_zigzag_direct[64] = {
-    0,   1,  8, 16,  9,  2,  3, 10,
-    17, 24, 32, 25, 18, 11,  4,  5,
-    12, 19, 26, 33, 40, 48, 41, 34,
-    27, 20, 13,  6,  7, 14, 21, 28,
-    35, 42, 49, 56, 57, 50, 43, 36,
-    29, 22, 15, 23, 30, 37, 44, 51,
-    58, 59, 52, 45, 38, 31, 39, 46,
-    53, 60, 61, 54, 47, 55, 62, 63
-};
-
-/* Specific zigzag scan for 248 idct. NOTE that unlike the
-   specification, we interleave the fields */
-const uint8_t ff_zigzag248_direct[64] = {
-     0,  8,  1,  9, 16, 24,  2, 10,
-    17, 25, 32, 40, 48, 56, 33, 41,
-    18, 26,  3, 11,  4, 12, 19, 27,
-    34, 42, 49, 57, 50, 58, 35, 43,
-    20, 28,  5, 13,  6, 14, 21, 29,
-    36, 44, 51, 59, 52, 60, 37, 45,
-    22, 30,  7, 15, 23, 31, 38, 46,
-    53, 61, 54, 62, 39, 47, 55, 63,
-};
-
-/* not permutated inverse zigzag_direct + 1 for MMX quantizer */
-uint16_t __align8 inv_zigzag_direct16[64] = {0, };
-
-const uint8_t ff_alternate_horizontal_scan[64] = {
-    0,  1,   2,  3,  8,  9, 16, 17, 
-    10, 11,  4,  5,  6,  7, 15, 14,
-    13, 12, 19, 18, 24, 25, 32, 33, 
-    26, 27, 20, 21, 22, 23, 28, 29,
-    30, 31, 34, 35, 40, 41, 48, 49, 
-    42, 43, 36, 37, 38, 39, 44, 45,
-    46, 47, 50, 51, 56, 57, 58, 59, 
-    52, 53, 54, 55, 60, 61, 62, 63,
-};
-
-const uint8_t ff_alternate_vertical_scan[64] = {
-    0,  8,  16, 24,  1,  9,  2, 10, 
-    17, 25, 32, 40, 48, 56, 57, 49,
-    41, 33, 26, 18,  3, 11,  4, 12, 
-    19, 27, 34, 42, 50, 58, 35, 43,
-    51, 59, 20, 28,  5, 13,  6, 14, 
-    21, 29, 36, 44, 52, 60, 37, 45,
-    53, 61, 22, 30,  7, 15, 23, 31, 
-    38, 46, 54, 62, 39, 47, 55, 63,
-};
-
-/* a*inverse[b]>>32 == a/b for all 0<=a<=65536 && 2<=b<=255 */
-const uint32_t inverse[256]={
-         0, 4294967295U,2147483648U,1431655766, 1073741824,  858993460,  715827883,  613566757, 
- 536870912,  477218589,  429496730,  390451573,  357913942,  330382100,  306783379,  286331154, 
- 268435456,  252645136,  238609295,  226050911,  214748365,  204522253,  195225787,  186737709, 
- 178956971,  171798692,  165191050,  159072863,  153391690,  148102321,  143165577,  138547333, 
- 134217728,  130150525,  126322568,  122713352,  119304648,  116080198,  113025456,  110127367, 
- 107374183,  104755300,  102261127,   99882961,   97612894,   95443718,   93368855,   91382283, 
-  89478486,   87652394,   85899346,   84215046,   82595525,   81037119,   79536432,   78090315, 
-  76695845,   75350304,   74051161,   72796056,   71582789,   70409300,   69273667,   68174085, 
-  67108864,   66076420,   65075263,   64103990,   63161284,   62245903,   61356676,   60492498, 
-  59652324,   58835169,   58040099,   57266231,   56512728,   55778797,   55063684,   54366675, 
-  53687092,   53024288,   52377650,   51746594,   51130564,   50529028,   49941481,   49367441, 
-  48806447,   48258060,   47721859,   47197443,   46684428,   46182445,   45691142,   45210183, 
-  44739243,   44278014,   43826197,   43383509,   42949673,   42524429,   42107523,   41698712, 
-  41297763,   40904451,   40518560,   40139882,   39768216,   39403370,   39045158,   38693400, 
-  38347923,   38008561,   37675152,   37347542,   37025581,   36709123,   36398028,   36092163, 
-  35791395,   35495598,   35204650,   34918434,   34636834,   34359739,   34087043,   33818641, 
-  33554432,   33294321,   33038210,   32786010,   32537632,   32292988,   32051995,   31814573, 
-  31580642,   31350127,   31122952,   30899046,   30678338,   30460761,   30246249,   30034737, 
-  29826162,   29620465,   29417585,   29217465,   29020050,   28825284,   28633116,   28443493, 
-  28256364,   28071682,   27889399,   27709467,   27531842,   27356480,   27183338,   27012373, 
-  26843546,   26676816,   26512144,   26349493,   26188825,   26030105,   25873297,   25718368, 
-  25565282,   25414008,   25264514,   25116768,   24970741,   24826401,   24683721,   24542671, 
-  24403224,   24265352,   24129030,   23994231,   23860930,   23729102,   23598722,   23469767, 
-  23342214,   23216040,   23091223,   22967740,   22845571,   22724695,   22605092,   22486740, 
-  22369622,   22253717,   22139007,   22025474,   21913099,   21801865,   21691755,   21582751, 
-  21474837,   21367997,   21262215,   21157475,   21053762,   20951060,   20849356,   20748635, 
-  20648882,   20550083,   20452226,   20355296,   20259280,   20164166,   20069941,   19976593, 
-  19884108,   19792477,   19701685,   19611723,   19522579,   19434242,   19346700,   19259944, 
-  19173962,   19088744,   19004281,   18920561,   18837576,   18755316,   18673771,   18592933, 
-  18512791,   18433337,   18354562,   18276457,   18199014,   18122225,   18046082,   17970575, 
-  17895698,   17821442,   17747799,   17674763,   17602325,   17530479,   17459217,   17388532, 
-  17318417,   17248865,   17179870,   17111424,   17043522,   16976156,   16909321,   16843010,
-};
-
-/* Input permutation for the simple_idct_mmx */
-static const uint8_t simple_mmx_permutation[64]={
-	0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D, 
-	0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D, 
-	0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D, 
-	0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F, 
-	0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F, 
-	0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D, 
-	0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F, 
-	0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
-};
-
-static int pix_sum_c(uint8_t * pix, int line_size)
-{
-    int s, i, j;
-
-    s = 0;
-    for (i = 0; i < 16; i++) {
-	for (j = 0; j < 16; j += 8) {
-	    s += pix[0];
-	    s += pix[1];
-	    s += pix[2];
-	    s += pix[3];
-	    s += pix[4];
-	    s += pix[5];
-	    s += pix[6];
-	    s += pix[7];
-	    pix += 8;
-	}
-	pix += line_size - 16;
-    }
-    return s;
-}
-
-static int pix_norm1_c(uint8_t * pix, int line_size)
-{
-    int s, i, j;
-    uint32_t *sq = squareTbl + 256;
-
-    s = 0;
-    for (i = 0; i < 16; i++) {
-	for (j = 0; j < 16; j += 8) {
-#if 0
-	    s += sq[pix[0]];
-	    s += sq[pix[1]];
-	    s += sq[pix[2]];
-	    s += sq[pix[3]];
-	    s += sq[pix[4]];
-	    s += sq[pix[5]];
-	    s += sq[pix[6]];
-	    s += sq[pix[7]];
-#else
-#if LONG_MAX > 2147483647
-	    register uint64_t x=*(uint64_t*)pix;
-	    s += sq[x&0xff];
-	    s += sq[(x>>8)&0xff];
-	    s += sq[(x>>16)&0xff];
-	    s += sq[(x>>24)&0xff];
-            s += sq[(x>>32)&0xff];
-            s += sq[(x>>40)&0xff];
-            s += sq[(x>>48)&0xff];
-            s += sq[(x>>56)&0xff];
-#else
-	    register uint32_t x=*(uint32_t*)pix;
-	    s += sq[x&0xff];
-	    s += sq[(x>>8)&0xff];
-	    s += sq[(x>>16)&0xff];
-	    s += sq[(x>>24)&0xff];
-            x=*(uint32_t*)(pix+4);
-            s += sq[x&0xff];
-            s += sq[(x>>8)&0xff];
-            s += sq[(x>>16)&0xff];
-            s += sq[(x>>24)&0xff];
-#endif
-#endif
-	    pix += 8;
-	}
-	pix += line_size - 16;
-    }
-    return s;
-}
-
-static void bswap_buf(uint32_t *dst, uint32_t *src, int w){
-    int i;
-    
-    for(i=0; i+8<=w; i+=8){
-        dst[i+0]= bswap_32(src[i+0]);
-        dst[i+1]= bswap_32(src[i+1]);
-        dst[i+2]= bswap_32(src[i+2]);
-        dst[i+3]= bswap_32(src[i+3]);
-        dst[i+4]= bswap_32(src[i+4]);
-        dst[i+5]= bswap_32(src[i+5]);
-        dst[i+6]= bswap_32(src[i+6]);
-        dst[i+7]= bswap_32(src[i+7]);
-    }
-    for(;i<w; i++){
-        dst[i+0]= bswap_32(src[i+0]);
-    }
-}
-
-static int sse4_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
-{
-    int s, i;
-    uint32_t *sq = squareTbl + 256;
-
-    s = 0;
-    for (i = 0; i < h; i++) {
-        s += sq[pix1[0] - pix2[0]];
-        s += sq[pix1[1] - pix2[1]];
-        s += sq[pix1[2] - pix2[2]];
-        s += sq[pix1[3] - pix2[3]];
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    return s;
-}
-
-static int sse8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
-{
-    int s, i;
-    uint32_t *sq = squareTbl + 256;
-
-    s = 0;
-    for (i = 0; i < h; i++) {
-        s += sq[pix1[0] - pix2[0]];
-        s += sq[pix1[1] - pix2[1]];
-        s += sq[pix1[2] - pix2[2]];
-        s += sq[pix1[3] - pix2[3]];
-        s += sq[pix1[4] - pix2[4]];
-        s += sq[pix1[5] - pix2[5]];
-        s += sq[pix1[6] - pix2[6]];
-        s += sq[pix1[7] - pix2[7]];
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    return s;
-}
-
-static int sse16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int s, i;
-    uint32_t *sq = squareTbl + 256;
-
-    s = 0;
-    for (i = 0; i < h; i++) {
-        s += sq[pix1[ 0] - pix2[ 0]];
-        s += sq[pix1[ 1] - pix2[ 1]];
-        s += sq[pix1[ 2] - pix2[ 2]];
-        s += sq[pix1[ 3] - pix2[ 3]];
-        s += sq[pix1[ 4] - pix2[ 4]];
-        s += sq[pix1[ 5] - pix2[ 5]];
-        s += sq[pix1[ 6] - pix2[ 6]];
-        s += sq[pix1[ 7] - pix2[ 7]];
-        s += sq[pix1[ 8] - pix2[ 8]];
-        s += sq[pix1[ 9] - pix2[ 9]];
-        s += sq[pix1[10] - pix2[10]];
-        s += sq[pix1[11] - pix2[11]];
-        s += sq[pix1[12] - pix2[12]];
-        s += sq[pix1[13] - pix2[13]];
-        s += sq[pix1[14] - pix2[14]];
-        s += sq[pix1[15] - pix2[15]];
-
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    return s;
-}
-
-
-static inline int w_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int w, int h, int type){
-#ifdef CONFIG_SNOW_ENCODER //idwt is in snow.c
-    int s, i, j;
-    const int dec_count= w==8 ? 3 : 4;
-    int tmp[16*16];
-#if 0
-    int level, ori;
-    static const int scale[2][2][4][4]={ 
-      {
-        {
-            //8x8 dec=3
-            {268, 239, 239, 213},
-            {  0, 224, 224, 152},
-            {  0, 135, 135, 110},
-        },{
-            //16x16 dec=4
-            {344, 310, 310, 280},
-            {  0, 320, 320, 228},
-            {  0, 175, 175, 136},
-            {  0, 129, 129, 102},
-        }
-      },{
-        {//FIXME 5/3
-            //8x8 dec=3
-            {275, 245, 245, 218},
-            {  0, 230, 230, 156},
-            {  0, 138, 138, 113},
-        },{
-            //16x16 dec=4
-            {352, 317, 317, 286},
-            {  0, 328, 328, 233},
-            {  0, 180, 180, 140},
-            {  0, 132, 132, 105},
-        }
-      }
-    };
-#endif
-
-    for (i = 0; i < h; i++) {
-        for (j = 0; j < w; j+=4) {
-            tmp[16*i+j+0] = (pix1[j+0] - pix2[j+0])<<4;
-            tmp[16*i+j+1] = (pix1[j+1] - pix2[j+1])<<4;
-            tmp[16*i+j+2] = (pix1[j+2] - pix2[j+2])<<4;
-            tmp[16*i+j+3] = (pix1[j+3] - pix2[j+3])<<4;
-        }
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-
-    ff_spatial_dwt(tmp, w, h, 16, type, dec_count);
-
-    s=0;
-#if 0
-    for(level=0; level<dec_count; level++){
-        for(ori= level ? 1 : 0; ori<4; ori++){
-            int sx= (ori&1) ? 1<<level: 0;
-            int stride= 16<<(dec_count-level);
-            int sy= (ori&2) ? stride>>1 : 0;
-            int size= 1<<level;
-            
-            for(i=0; i<size; i++){
-                for(j=0; j<size; j++){
-                    int v= tmp[sx + sy + i*stride + j] * scale[type][dec_count-3][level][ori];
-                    s += ABS(v);
-                }
-            }
-        }
-    }
-#endif
-    for (i = 0; i < h; i++) {
-        for (j = 0; j < w; j+=4) {
-            s+= ABS(tmp[16*i+j+0]);
-            s+= ABS(tmp[16*i+j+1]);
-            s+= ABS(tmp[16*i+j+2]);
-            s+= ABS(tmp[16*i+j+3]);
-        }
-    }
-    assert(s>=0); 
-    
-    return s>>2;
-#endif
-}
-
-static int w53_8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){
-    return w_c(v, pix1, pix2, line_size,  8, h, 1);
-}
-
-static int w97_8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){
-    return w_c(v, pix1, pix2, line_size,  8, h, 0);
-}
-
-static int w53_16_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){
-    return w_c(v, pix1, pix2, line_size, 16, h, 1);
-}
-
-static int w97_16_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){
-    return w_c(v, pix1, pix2, line_size, 16, h, 0);
-}
-
-static void get_pixels_c(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
-{
-    int i;
-
-    /* read the pixels */
-    for(i=0;i<8;i++) {
-        block[0] = pixels[0];
-        block[1] = pixels[1];
-        block[2] = pixels[2];
-        block[3] = pixels[3];
-        block[4] = pixels[4];
-        block[5] = pixels[5];
-        block[6] = pixels[6];
-        block[7] = pixels[7];
-        pixels += line_size;
-        block += 8;
-    }
-}
-
-static void diff_pixels_c(DCTELEM *restrict block, const uint8_t *s1,
-			  const uint8_t *s2, int stride){
-    int i;
-
-    /* read the pixels */
-    for(i=0;i<8;i++) {
-        block[0] = s1[0] - s2[0];
-        block[1] = s1[1] - s2[1];
-        block[2] = s1[2] - s2[2];
-        block[3] = s1[3] - s2[3];
-        block[4] = s1[4] - s2[4];
-        block[5] = s1[5] - s2[5];
-        block[6] = s1[6] - s2[6];
-        block[7] = s1[7] - s2[7];
-        s1 += stride;
-        s2 += stride;
-        block += 8;
-    }
-}
-
-
-static void put_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
-				 int line_size)
-{
-    int i;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-    
-    /* read the pixels */
-    for(i=0;i<8;i++) {
-        pixels[0] = cm[block[0]];
-        pixels[1] = cm[block[1]];
-        pixels[2] = cm[block[2]];
-        pixels[3] = cm[block[3]];
-        pixels[4] = cm[block[4]];
-        pixels[5] = cm[block[5]];
-        pixels[6] = cm[block[6]];
-        pixels[7] = cm[block[7]];
-
-        pixels += line_size;
-        block += 8;
-    }
-}
-
-static void put_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels,
-				 int line_size)
-{
-    int i;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-    
-    /* read the pixels */
-    for(i=0;i<4;i++) {
-        pixels[0] = cm[block[0]];
-        pixels[1] = cm[block[1]];
-        pixels[2] = cm[block[2]];
-        pixels[3] = cm[block[3]];
-
-        pixels += line_size;
-        block += 8;
-    }
-}
-
-static void put_pixels_clamped2_c(const DCTELEM *block, uint8_t *restrict pixels,
-				 int line_size)
-{
-    int i;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-    
-    /* read the pixels */
-    for(i=0;i<2;i++) {
-        pixels[0] = cm[block[0]];
-        pixels[1] = cm[block[1]];
-
-        pixels += line_size;
-        block += 8;
-    }
-}
-
-static void put_signed_pixels_clamped_c(const DCTELEM *block, 
-                                        uint8_t *restrict pixels,
-                                        int line_size)
-{
-    int i, j;
-
-    for (i = 0; i < 8; i++) {
-        for (j = 0; j < 8; j++) {
-            if (*block < -128)
-                *pixels = 0;
-            else if (*block > 127)
-                *pixels = 255;
-            else
-                *pixels = (uint8_t)(*block + 128);
-            block++;
-            pixels++;
-        }
-        pixels += (line_size - 8);
-    }
-}
-
-static void add_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
-                          int line_size)
-{
-    int i;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-    
-    /* read the pixels */
-    for(i=0;i<8;i++) {
-        pixels[0] = cm[pixels[0] + block[0]];
-        pixels[1] = cm[pixels[1] + block[1]];
-        pixels[2] = cm[pixels[2] + block[2]];
-        pixels[3] = cm[pixels[3] + block[3]];
-        pixels[4] = cm[pixels[4] + block[4]];
-        pixels[5] = cm[pixels[5] + block[5]];
-        pixels[6] = cm[pixels[6] + block[6]];
-        pixels[7] = cm[pixels[7] + block[7]];
-        pixels += line_size;
-        block += 8;
-    }
-}
-
-static void add_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels,
-                          int line_size)
-{
-    int i;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-    
-    /* read the pixels */
-    for(i=0;i<4;i++) {
-        pixels[0] = cm[pixels[0] + block[0]];
-        pixels[1] = cm[pixels[1] + block[1]];
-        pixels[2] = cm[pixels[2] + block[2]];
-        pixels[3] = cm[pixels[3] + block[3]];
-        pixels += line_size;
-        block += 8;
-    }
-}
-
-static void add_pixels_clamped2_c(const DCTELEM *block, uint8_t *restrict pixels,
-                          int line_size)
-{
-    int i;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-    
-    /* read the pixels */
-    for(i=0;i<2;i++) {
-        pixels[0] = cm[pixels[0] + block[0]];
-        pixels[1] = cm[pixels[1] + block[1]];
-        pixels += line_size;
-        block += 8;
-    }
-}
-
-static void add_pixels8_c(uint8_t *restrict pixels, DCTELEM *block, int line_size)
-{
-    int i;
-    for(i=0;i<8;i++) {
-        pixels[0] += block[0];
-        pixels[1] += block[1];
-        pixels[2] += block[2];
-        pixels[3] += block[3];
-        pixels[4] += block[4];
-        pixels[5] += block[5];
-        pixels[6] += block[6];
-        pixels[7] += block[7];
-        pixels += line_size;
-        block += 8;
-    }
-}
-
-static void add_pixels4_c(uint8_t *restrict pixels, DCTELEM *block, int line_size)
-{
-    int i;
-    for(i=0;i<4;i++) {
-        pixels[0] += block[0];
-        pixels[1] += block[1];
-        pixels[2] += block[2];
-        pixels[3] += block[3];
-        pixels += line_size;
-        block += 4;
-    }
-}
-
-#if 0
-
-#define PIXOP2(OPNAME, OP) \
-static void OPNAME ## _pixels(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
-{\
-    int i;\
-    for(i=0; i<h; i++){\
-        OP(*((uint64_t*)block), LD64(pixels));\
-        pixels+=line_size;\
-        block +=line_size;\
-    }\
-}\
-\
-static void OPNAME ## _no_rnd_pixels_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
-{\
-    int i;\
-    for(i=0; i<h; i++){\
-        const uint64_t a= LD64(pixels  );\
-        const uint64_t b= LD64(pixels+1);\
-        OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
-        pixels+=line_size;\
-        block +=line_size;\
-    }\
-}\
-\
-static void OPNAME ## _pixels_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
-{\
-    int i;\
-    for(i=0; i<h; i++){\
-        const uint64_t a= LD64(pixels  );\
-        const uint64_t b= LD64(pixels+1);\
-        OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
-        pixels+=line_size;\
-        block +=line_size;\
-    }\
-}\
-\
-static void OPNAME ## _no_rnd_pixels_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
-{\
-    int i;\
-    for(i=0; i<h; i++){\
-        const uint64_t a= LD64(pixels          );\
-        const uint64_t b= LD64(pixels+line_size);\
-        OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
-        pixels+=line_size;\
-        block +=line_size;\
-    }\
-}\
-\
-static void OPNAME ## _pixels_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
-{\
-    int i;\
-    for(i=0; i<h; i++){\
-        const uint64_t a= LD64(pixels          );\
-        const uint64_t b= LD64(pixels+line_size);\
-        OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
-        pixels+=line_size;\
-        block +=line_size;\
-    }\
-}\
-\
-static void OPNAME ## _pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
-{\
-        int i;\
-        const uint64_t a= LD64(pixels  );\
-        const uint64_t b= LD64(pixels+1);\
-        uint64_t l0=  (a&0x0303030303030303ULL)\
-                    + (b&0x0303030303030303ULL)\
-                    + 0x0202020202020202ULL;\
-        uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
-                   + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
-        uint64_t l1,h1;\
-\
-        pixels+=line_size;\
-        for(i=0; i<h; i+=2){\
-            uint64_t a= LD64(pixels  );\
-            uint64_t b= LD64(pixels+1);\
-            l1=  (a&0x0303030303030303ULL)\
-               + (b&0x0303030303030303ULL);\
-            h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
-              + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
-            OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
-            pixels+=line_size;\
-            block +=line_size;\
-            a= LD64(pixels  );\
-            b= LD64(pixels+1);\
-            l0=  (a&0x0303030303030303ULL)\
-               + (b&0x0303030303030303ULL)\
-               + 0x0202020202020202ULL;\
-            h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
-              + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
-            OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
-            pixels+=line_size;\
-            block +=line_size;\
-        }\
-}\
-\
-static void OPNAME ## _no_rnd_pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
-{\
-        int i;\
-        const uint64_t a= LD64(pixels  );\
-        const uint64_t b= LD64(pixels+1);\
-        uint64_t l0=  (a&0x0303030303030303ULL)\
-                    + (b&0x0303030303030303ULL)\
-                    + 0x0101010101010101ULL;\
-        uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
-                   + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
-        uint64_t l1,h1;\
-\
-        pixels+=line_size;\
-        for(i=0; i<h; i+=2){\
-            uint64_t a= LD64(pixels  );\
-            uint64_t b= LD64(pixels+1);\
-            l1=  (a&0x0303030303030303ULL)\
-               + (b&0x0303030303030303ULL);\
-            h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
-              + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
-            OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
-            pixels+=line_size;\
-            block +=line_size;\
-            a= LD64(pixels  );\
-            b= LD64(pixels+1);\
-            l0=  (a&0x0303030303030303ULL)\
-               + (b&0x0303030303030303ULL)\
-               + 0x0101010101010101ULL;\
-            h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
-              + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
-            OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
-            pixels+=line_size;\
-            block +=line_size;\
-        }\
-}\
-\
-CALL_2X_PIXELS(OPNAME ## _pixels16_c    , OPNAME ## _pixels_c    , 8)\
-CALL_2X_PIXELS(OPNAME ## _pixels16_x2_c , OPNAME ## _pixels_x2_c , 8)\
-CALL_2X_PIXELS(OPNAME ## _pixels16_y2_c , OPNAME ## _pixels_y2_c , 8)\
-CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_c, OPNAME ## _pixels_xy2_c, 8)\
-CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_c , OPNAME ## _no_rnd_pixels_x2_c , 8)\
-CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_c , OPNAME ## _no_rnd_pixels_y2_c , 8)\
-CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_c, OPNAME ## _no_rnd_pixels_xy2_c, 8)
-
-#define op_avg(a, b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEFEFEFEFEULL)>>1) )
-#else // 64 bit variant
-
-#define PIXOP2(OPNAME, OP) \
-static void OPNAME ## _pixels2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
-    int i;\
-    for(i=0; i<h; i++){\
-        OP(*((uint16_t*)(block  )), LD16(pixels  ));\
-        pixels+=line_size;\
-        block +=line_size;\
-    }\
-}\
-static void OPNAME ## _pixels4_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
-    int i;\
-    for(i=0; i<h; i++){\
-        OP(*((uint32_t*)(block  )), LD32(pixels  ));\
-        pixels+=line_size;\
-        block +=line_size;\
-    }\
-}\
-static void OPNAME ## _pixels8_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
-    int i;\
-    for(i=0; i<h; i++){\
-        OP(*((uint32_t*)(block  )), LD32(pixels  ));\
-        OP(*((uint32_t*)(block+4)), LD32(pixels+4));\
-        pixels+=line_size;\
-        block +=line_size;\
-    }\
-}\
-static inline void OPNAME ## _no_rnd_pixels8_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
-    OPNAME ## _pixels8_c(block, pixels, line_size, h);\
-}\
-\
-static inline void OPNAME ## _no_rnd_pixels8_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
-                                                int src_stride1, int src_stride2, int h){\
-    int i;\
-    for(i=0; i<h; i++){\
-        uint32_t a,b;\
-        a= LD32(&src1[i*src_stride1  ]);\
-        b= LD32(&src2[i*src_stride2  ]);\
-        OP(*((uint32_t*)&dst[i*dst_stride  ]), no_rnd_avg32(a, b));\
-        a= LD32(&src1[i*src_stride1+4]);\
-        b= LD32(&src2[i*src_stride2+4]);\
-        OP(*((uint32_t*)&dst[i*dst_stride+4]), no_rnd_avg32(a, b));\
-    }\
-}\
-\
-static inline void OPNAME ## _pixels8_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
-                                                int src_stride1, int src_stride2, int h){\
-    int i;\
-    for(i=0; i<h; i++){\
-        uint32_t a,b;\
-        a= LD32(&src1[i*src_stride1  ]);\
-        b= LD32(&src2[i*src_stride2  ]);\
-        OP(*((uint32_t*)&dst[i*dst_stride  ]), rnd_avg32(a, b));\
-        a= LD32(&src1[i*src_stride1+4]);\
-        b= LD32(&src2[i*src_stride2+4]);\
-        OP(*((uint32_t*)&dst[i*dst_stride+4]), rnd_avg32(a, b));\
-    }\
-}\
-\
-static inline void OPNAME ## _pixels4_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
-                                                int src_stride1, int src_stride2, int h){\
-    int i;\
-    for(i=0; i<h; i++){\
-        uint32_t a,b;\
-        a= LD32(&src1[i*src_stride1  ]);\
-        b= LD32(&src2[i*src_stride2  ]);\
-        OP(*((uint32_t*)&dst[i*dst_stride  ]), rnd_avg32(a, b));\
-    }\
-}\
-\
-static inline void OPNAME ## _pixels2_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
-                                                int src_stride1, int src_stride2, int h){\
-    int i;\
-    for(i=0; i<h; i++){\
-        uint32_t a,b;\
-        a= LD16(&src1[i*src_stride1  ]);\
-        b= LD16(&src2[i*src_stride2  ]);\
-        OP(*((uint16_t*)&dst[i*dst_stride  ]), rnd_avg32(a, b));\
-    }\
-}\
-\
-static inline void OPNAME ## _pixels16_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
-                                                int src_stride1, int src_stride2, int h){\
-    OPNAME ## _pixels8_l2(dst  , src1  , src2  , dst_stride, src_stride1, src_stride2, h);\
-    OPNAME ## _pixels8_l2(dst+8, src1+8, src2+8, dst_stride, src_stride1, src_stride2, h);\
-}\
-\
-static inline void OPNAME ## _no_rnd_pixels16_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
-                                                int src_stride1, int src_stride2, int h){\
-    OPNAME ## _no_rnd_pixels8_l2(dst  , src1  , src2  , dst_stride, src_stride1, src_stride2, h);\
-    OPNAME ## _no_rnd_pixels8_l2(dst+8, src1+8, src2+8, dst_stride, src_stride1, src_stride2, h);\
-}\
-\
-static inline void OPNAME ## _no_rnd_pixels8_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
-    OPNAME ## _no_rnd_pixels8_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\
-}\
-\
-static inline void OPNAME ## _pixels8_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
-    OPNAME ## _pixels8_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\
-}\
-\
-static inline void OPNAME ## _no_rnd_pixels8_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
-    OPNAME ## _no_rnd_pixels8_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
-}\
-\
-static inline void OPNAME ## _pixels8_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
-    OPNAME ## _pixels8_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
-}\
-\
-static inline void OPNAME ## _pixels8_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\
-                 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-    int i;\
-    for(i=0; i<h; i++){\
-        uint32_t a, b, c, d, l0, l1, h0, h1;\
-        a= LD32(&src1[i*src_stride1]);\
-        b= LD32(&src2[i*src_stride2]);\
-        c= LD32(&src3[i*src_stride3]);\
-        d= LD32(&src4[i*src_stride4]);\
-        l0=  (a&0x03030303UL)\
-           + (b&0x03030303UL)\
-           + 0x02020202UL;\
-        h0= ((a&0xFCFCFCFCUL)>>2)\
-          + ((b&0xFCFCFCFCUL)>>2);\
-        l1=  (c&0x03030303UL)\
-           + (d&0x03030303UL);\
-        h1= ((c&0xFCFCFCFCUL)>>2)\
-          + ((d&0xFCFCFCFCUL)>>2);\
-        OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-        a= LD32(&src1[i*src_stride1+4]);\
-        b= LD32(&src2[i*src_stride2+4]);\
-        c= LD32(&src3[i*src_stride3+4]);\
-        d= LD32(&src4[i*src_stride4+4]);\
-        l0=  (a&0x03030303UL)\
-           + (b&0x03030303UL)\
-           + 0x02020202UL;\
-        h0= ((a&0xFCFCFCFCUL)>>2)\
-          + ((b&0xFCFCFCFCUL)>>2);\
-        l1=  (c&0x03030303UL)\
-           + (d&0x03030303UL);\
-        h1= ((c&0xFCFCFCFCUL)>>2)\
-          + ((d&0xFCFCFCFCUL)>>2);\
-        OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-    }\
-}\
-\
-static inline void OPNAME ## _pixels4_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
-    OPNAME ## _pixels4_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\
-}\
-\
-static inline void OPNAME ## _pixels4_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
-    OPNAME ## _pixels4_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
-}\
-\
-static inline void OPNAME ## _pixels2_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
-    OPNAME ## _pixels2_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\
-}\
-\
-static inline void OPNAME ## _pixels2_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
-    OPNAME ## _pixels2_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
-}\
-\
-static inline void OPNAME ## _no_rnd_pixels8_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\
-                 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-    int i;\
-    for(i=0; i<h; i++){\
-        uint32_t a, b, c, d, l0, l1, h0, h1;\
-        a= LD32(&src1[i*src_stride1]);\
-        b= LD32(&src2[i*src_stride2]);\
-        c= LD32(&src3[i*src_stride3]);\
-        d= LD32(&src4[i*src_stride4]);\
-        l0=  (a&0x03030303UL)\
-           + (b&0x03030303UL)\
-           + 0x01010101UL;\
-        h0= ((a&0xFCFCFCFCUL)>>2)\
-          + ((b&0xFCFCFCFCUL)>>2);\
-        l1=  (c&0x03030303UL)\
-           + (d&0x03030303UL);\
-        h1= ((c&0xFCFCFCFCUL)>>2)\
-          + ((d&0xFCFCFCFCUL)>>2);\
-        OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-        a= LD32(&src1[i*src_stride1+4]);\
-        b= LD32(&src2[i*src_stride2+4]);\
-        c= LD32(&src3[i*src_stride3+4]);\
-        d= LD32(&src4[i*src_stride4+4]);\
-        l0=  (a&0x03030303UL)\
-           + (b&0x03030303UL)\
-           + 0x01010101UL;\
-        h0= ((a&0xFCFCFCFCUL)>>2)\
-          + ((b&0xFCFCFCFCUL)>>2);\
-        l1=  (c&0x03030303UL)\
-           + (d&0x03030303UL);\
-        h1= ((c&0xFCFCFCFCUL)>>2)\
-          + ((d&0xFCFCFCFCUL)>>2);\
-        OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-    }\
-}\
-static inline void OPNAME ## _pixels16_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\
-                 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-    OPNAME ## _pixels8_l4(dst  , src1  , src2  , src3  , src4  , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
-    OPNAME ## _pixels8_l4(dst+8, src1+8, src2+8, src3+8, src4+8, dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
-}\
-static inline void OPNAME ## _no_rnd_pixels16_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\
-                 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-    OPNAME ## _no_rnd_pixels8_l4(dst  , src1  , src2  , src3  , src4  , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
-    OPNAME ## _no_rnd_pixels8_l4(dst+8, src1+8, src2+8, src3+8, src4+8, dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
-}\
-\
-static inline void OPNAME ## _pixels2_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
-{\
-        int i, a0, b0, a1, b1;\
-        a0= pixels[0];\
-        b0= pixels[1] + 2;\
-        a0 += b0;\
-        b0 += pixels[2];\
-\
-        pixels+=line_size;\
-        for(i=0; i<h; i+=2){\
-            a1= pixels[0];\
-            b1= pixels[1];\
-            a1 += b1;\
-            b1 += pixels[2];\
-\
-            block[0]= (a1+a0)>>2; /* FIXME non put */\
-            block[1]= (b1+b0)>>2;\
-\
-            pixels+=line_size;\
-            block +=line_size;\
-\
-            a0= pixels[0];\
-            b0= pixels[1] + 2;\
-            a0 += b0;\
-            b0 += pixels[2];\
-\
-            block[0]= (a1+a0)>>2;\
-            block[1]= (b1+b0)>>2;\
-            pixels+=line_size;\
-            block +=line_size;\
-        }\
-}\
-\
-static inline void OPNAME ## _pixels4_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
-{\
-        int i;\
-        const uint32_t a= LD32(pixels  );\
-        const uint32_t b= LD32(pixels+1);\
-        uint32_t l0=  (a&0x03030303UL)\
-                    + (b&0x03030303UL)\
-                    + 0x02020202UL;\
-        uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
-                   + ((b&0xFCFCFCFCUL)>>2);\
-        uint32_t l1,h1;\
-\
-        pixels+=line_size;\
-        for(i=0; i<h; i+=2){\
-            uint32_t a= LD32(pixels  );\
-            uint32_t b= LD32(pixels+1);\
-            l1=  (a&0x03030303UL)\
-               + (b&0x03030303UL);\
-            h1= ((a&0xFCFCFCFCUL)>>2)\
-              + ((b&0xFCFCFCFCUL)>>2);\
-            OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-            pixels+=line_size;\
-            block +=line_size;\
-            a= LD32(pixels  );\
-            b= LD32(pixels+1);\
-            l0=  (a&0x03030303UL)\
-               + (b&0x03030303UL)\
-               + 0x02020202UL;\
-            h0= ((a&0xFCFCFCFCUL)>>2)\
-              + ((b&0xFCFCFCFCUL)>>2);\
-            OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-            pixels+=line_size;\
-            block +=line_size;\
-        }\
-}\
-\
-static inline void OPNAME ## _pixels8_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
-{\
-    int j;\
-    for(j=0; j<2; j++){\
-        int i;\
-        const uint32_t a= LD32(pixels  );\
-        const uint32_t b= LD32(pixels+1);\
-        uint32_t l0=  (a&0x03030303UL)\
-                    + (b&0x03030303UL)\
-                    + 0x02020202UL;\
-        uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
-                   + ((b&0xFCFCFCFCUL)>>2);\
-        uint32_t l1,h1;\
-\
-        pixels+=line_size;\
-        for(i=0; i<h; i+=2){\
-            uint32_t a= LD32(pixels  );\
-            uint32_t b= LD32(pixels+1);\
-            l1=  (a&0x03030303UL)\
-               + (b&0x03030303UL);\
-            h1= ((a&0xFCFCFCFCUL)>>2)\
-              + ((b&0xFCFCFCFCUL)>>2);\
-            OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-            pixels+=line_size;\
-            block +=line_size;\
-            a= LD32(pixels  );\
-            b= LD32(pixels+1);\
-            l0=  (a&0x03030303UL)\
-               + (b&0x03030303UL)\
-               + 0x02020202UL;\
-            h0= ((a&0xFCFCFCFCUL)>>2)\
-              + ((b&0xFCFCFCFCUL)>>2);\
-            OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-            pixels+=line_size;\
-            block +=line_size;\
-        }\
-        pixels+=4-line_size*(h+1);\
-        block +=4-line_size*h;\
-    }\
-}\
-\
-static inline void OPNAME ## _no_rnd_pixels8_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
-{\
-    int j;\
-    for(j=0; j<2; j++){\
-        int i;\
-        const uint32_t a= LD32(pixels  );\
-        const uint32_t b= LD32(pixels+1);\
-        uint32_t l0=  (a&0x03030303UL)\
-                    + (b&0x03030303UL)\
-                    + 0x01010101UL;\
-        uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
-                   + ((b&0xFCFCFCFCUL)>>2);\
-        uint32_t l1,h1;\
-\
-        pixels+=line_size;\
-        for(i=0; i<h; i+=2){\
-            uint32_t a= LD32(pixels  );\
-            uint32_t b= LD32(pixels+1);\
-            l1=  (a&0x03030303UL)\
-               + (b&0x03030303UL);\
-            h1= ((a&0xFCFCFCFCUL)>>2)\
-              + ((b&0xFCFCFCFCUL)>>2);\
-            OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-            pixels+=line_size;\
-            block +=line_size;\
-            a= LD32(pixels  );\
-            b= LD32(pixels+1);\
-            l0=  (a&0x03030303UL)\
-               + (b&0x03030303UL)\
-               + 0x01010101UL;\
-            h0= ((a&0xFCFCFCFCUL)>>2)\
-              + ((b&0xFCFCFCFCUL)>>2);\
-            OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-            pixels+=line_size;\
-            block +=line_size;\
-        }\
-        pixels+=4-line_size*(h+1);\
-        block +=4-line_size*h;\
-    }\
-}\
-\
-CALL_2X_PIXELS(OPNAME ## _pixels16_c  , OPNAME ## _pixels8_c  , 8)\
-CALL_2X_PIXELS(OPNAME ## _pixels16_x2_c , OPNAME ## _pixels8_x2_c , 8)\
-CALL_2X_PIXELS(OPNAME ## _pixels16_y2_c , OPNAME ## _pixels8_y2_c , 8)\
-CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_c, OPNAME ## _pixels8_xy2_c, 8)\
-CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_c  , OPNAME ## _pixels8_c         , 8)\
-CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_c , OPNAME ## _no_rnd_pixels8_x2_c , 8)\
-CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_c , OPNAME ## _no_rnd_pixels8_y2_c , 8)\
-CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_c, OPNAME ## _no_rnd_pixels8_xy2_c, 8)\
-
-#define op_avg(a, b) a = rnd_avg32(a, b)
-#endif
-#define op_put(a, b) a = b
-
-PIXOP2(avg, op_avg)
-PIXOP2(put, op_put)
-#undef op_avg
-#undef op_put
-
-#define avg2(a,b) ((a+b+1)>>1)
-#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
-
-static void put_no_rnd_pixels16_l2_c(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h){
-    put_no_rnd_pixels16_l2(dst, a, b, stride, stride, stride, h);
-}
-
-static void put_no_rnd_pixels8_l2_c(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h){
-    put_no_rnd_pixels8_l2(dst, a, b, stride, stride, stride, h);
-}
-
-static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h, int x16, int y16, int rounder)
-{
-    const int A=(16-x16)*(16-y16);
-    const int B=(   x16)*(16-y16);
-    const int C=(16-x16)*(   y16);
-    const int D=(   x16)*(   y16);
-    int i;
-
-    for(i=0; i<h; i++)
-    {
-        dst[0]= (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + rounder)>>8;
-        dst[1]= (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + rounder)>>8;
-        dst[2]= (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + rounder)>>8;
-        dst[3]= (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + rounder)>>8;
-        dst[4]= (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + rounder)>>8;
-        dst[5]= (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + rounder)>>8;
-        dst[6]= (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + rounder)>>8;
-        dst[7]= (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + rounder)>>8;
-        dst+= stride;
-        src+= stride;
-    }
-}
-
-static void gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy, 
-                  int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
-{
-    int y, vx, vy;
-    const int s= 1<<shift;
-    
-    width--;
-    height--;
-
-    for(y=0; y<h; y++){
-        int x;
-
-        vx= ox;
-        vy= oy;
-        for(x=0; x<8; x++){ //XXX FIXME optimize
-            int src_x, src_y, frac_x, frac_y, index;
-
-            src_x= vx>>16;
-            src_y= vy>>16;
-            frac_x= src_x&(s-1);
-            frac_y= src_y&(s-1);
-            src_x>>=shift;
-            src_y>>=shift;
-  
-            if((unsigned)src_x < width){
-                if((unsigned)src_y < height){
-                    index= src_x + src_y*stride;
-                    dst[y*stride + x]= (  (  src[index         ]*(s-frac_x)
-                                           + src[index       +1]*   frac_x )*(s-frac_y)
-                                        + (  src[index+stride  ]*(s-frac_x)
-                                           + src[index+stride+1]*   frac_x )*   frac_y
-                                        + r)>>(shift*2);
-                }else{
-                    index= src_x + clip(src_y, 0, height)*stride;                    
-                    dst[y*stride + x]= ( (  src[index         ]*(s-frac_x) 
-                                          + src[index       +1]*   frac_x )*s
-                                        + r)>>(shift*2);
-                }
-            }else{
-                if((unsigned)src_y < height){
-                    index= clip(src_x, 0, width) + src_y*stride;                    
-                    dst[y*stride + x]= (  (  src[index         ]*(s-frac_y) 
-                                           + src[index+stride  ]*   frac_y )*s
-                                        + r)>>(shift*2);
-                }else{
-                    index= clip(src_x, 0, width) + clip(src_y, 0, height)*stride;                    
-                    dst[y*stride + x]=    src[index         ];
-                }
-            }
-            
-            vx+= dxx;
-            vy+= dyx;
-        }
-        ox += dxy;
-        oy += dyy;
-    }
-}
-
-static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    switch(width){
-    case 2: put_pixels2_c (dst, src, stride, height); break;
-    case 4: put_pixels4_c (dst, src, stride, height); break;
-    case 8: put_pixels8_c (dst, src, stride, height); break;
-    case 16:put_pixels16_c(dst, src, stride, height); break;
-    }
-}
-
-static inline void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (683*(2*src[j] + src[j+1] + 1)) >> 11;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (683*(src[j] + 2*src[j+1] + 1)) >> 11;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-    
-static inline void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (683*(2*src[j] + src[j+stride] + 1)) >> 11;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-    
-static inline void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (683*(src[j] + 2*src[j+stride] + 1)) >> 11;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    switch(width){
-    case 2: avg_pixels2_c (dst, src, stride, height); break;
-    case 4: avg_pixels4_c (dst, src, stride, height); break;
-    case 8: avg_pixels8_c (dst, src, stride, height); break;
-    case 16:avg_pixels16_c(dst, src, stride, height); break;
-    }
-}
-
-static inline void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (dst[j] + ((683*(2*src[j] + src[j+1] + 1)) >> 11) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+1] + 1)) >> 11) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-    
-static inline void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (dst[j] + ((683*(2*src[j] + src[j+stride] + 1)) >> 11) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-    
-static inline void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (dst[j] + ((2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (dst[j] + ((2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+stride] + 1)) >> 11) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (dst[j] + ((2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-	dst[j] = (dst[j] + ((2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-#if 0
-#define TPEL_WIDTH(width)\
-static void put_tpel_pixels ## width ## _mc00_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
-    void put_tpel_pixels_mc00_c(dst, src, stride, width, height);}\
-static void put_tpel_pixels ## width ## _mc10_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
-    void put_tpel_pixels_mc10_c(dst, src, stride, width, height);}\
-static void put_tpel_pixels ## width ## _mc20_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
-    void put_tpel_pixels_mc20_c(dst, src, stride, width, height);}\
-static void put_tpel_pixels ## width ## _mc01_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
-    void put_tpel_pixels_mc01_c(dst, src, stride, width, height);}\
-static void put_tpel_pixels ## width ## _mc11_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
-    void put_tpel_pixels_mc11_c(dst, src, stride, width, height);}\
-static void put_tpel_pixels ## width ## _mc21_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
-    void put_tpel_pixels_mc21_c(dst, src, stride, width, height);}\
-static void put_tpel_pixels ## width ## _mc02_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
-    void put_tpel_pixels_mc02_c(dst, src, stride, width, height);}\
-static void put_tpel_pixels ## width ## _mc12_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
-    void put_tpel_pixels_mc12_c(dst, src, stride, width, height);}\
-static void put_tpel_pixels ## width ## _mc22_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
-    void put_tpel_pixels_mc22_c(dst, src, stride, width, height);}
-#endif
-
-#define H264_CHROMA_MC(OPNAME, OP)\
-static void OPNAME ## h264_chroma_mc2_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
-    const int A=(8-x)*(8-y);\
-    const int B=(  x)*(8-y);\
-    const int C=(8-x)*(  y);\
-    const int D=(  x)*(  y);\
-    int i;\
-    \
-    assert(x<8 && y<8 && x>=0 && y>=0);\
-\
-    for(i=0; i<h; i++)\
-    {\
-        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
-        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
-        dst+= stride;\
-        src+= stride;\
-    }\
-}\
-\
-static void OPNAME ## h264_chroma_mc4_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
-    const int A=(8-x)*(8-y);\
-    const int B=(  x)*(8-y);\
-    const int C=(8-x)*(  y);\
-    const int D=(  x)*(  y);\
-    int i;\
-    \
-    assert(x<8 && y<8 && x>=0 && y>=0);\
-\
-    for(i=0; i<h; i++)\
-    {\
-        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
-        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
-        OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
-        OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
-        dst+= stride;\
-        src+= stride;\
-    }\
-}\
-\
-static void OPNAME ## h264_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
-    const int A=(8-x)*(8-y);\
-    const int B=(  x)*(8-y);\
-    const int C=(8-x)*(  y);\
-    const int D=(  x)*(  y);\
-    int i;\
-    \
-    assert(x<8 && y<8 && x>=0 && y>=0);\
-\
-    for(i=0; i<h; i++)\
-    {\
-        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
-        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
-        OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
-        OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
-        OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\
-        OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\
-        OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\
-        OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\
-        dst+= stride;\
-        src+= stride;\
-    }\
-}
-
-#define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
-#define op_put(a, b) a = (((b) + 32)>>6)
-
-H264_CHROMA_MC(put_       , op_put)
-H264_CHROMA_MC(avg_       , op_avg)
-#undef op_avg
-#undef op_put
-
-static inline void copy_block4(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
-{
-    int i;
-    for(i=0; i<h; i++)
-    {
-        ST32(dst   , LD32(src   ));
-        dst+=dstStride;
-        src+=srcStride;
-    }
-}
-
-static inline void copy_block8(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
-{
-    int i;
-    for(i=0; i<h; i++)
-    {
-        ST32(dst   , LD32(src   ));
-        ST32(dst+4 , LD32(src+4 ));
-        dst+=dstStride;
-        src+=srcStride;
-    }
-}
-
-static inline void copy_block16(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
-{
-    int i;
-    for(i=0; i<h; i++)
-    {
-        ST32(dst   , LD32(src   ));
-        ST32(dst+4 , LD32(src+4 ));
-        ST32(dst+8 , LD32(src+8 ));
-        ST32(dst+12, LD32(src+12));
-        dst+=dstStride;
-        src+=srcStride;
-    }
-}
-
-static inline void copy_block17(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
-{
-    int i;
-    for(i=0; i<h; i++)
-    {
-        ST32(dst   , LD32(src   ));
-        ST32(dst+4 , LD32(src+4 ));
-        ST32(dst+8 , LD32(src+8 ));
-        ST32(dst+12, LD32(src+12));
-        dst[16]= src[16];
-        dst+=dstStride;
-        src+=srcStride;
-    }
-}
-
-static inline void copy_block9(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
-{
-    int i;
-    for(i=0; i<h; i++)
-    {
-        ST32(dst   , LD32(src   ));
-        ST32(dst+4 , LD32(src+4 ));
-        dst[8]= src[8];
-        dst+=dstStride;
-        src+=srcStride;
-    }
-}
-
-
-#define QPEL_MC(r, OPNAME, RND, OP) \
-static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    int i;\
-    for(i=0; i<h; i++)\
-    {\
-        OP(dst[0], (src[0]+src[1])*20 - (src[0]+src[2])*6 + (src[1]+src[3])*3 - (src[2]+src[4]));\
-        OP(dst[1], (src[1]+src[2])*20 - (src[0]+src[3])*6 + (src[0]+src[4])*3 - (src[1]+src[5]));\
-        OP(dst[2], (src[2]+src[3])*20 - (src[1]+src[4])*6 + (src[0]+src[5])*3 - (src[0]+src[6]));\
-        OP(dst[3], (src[3]+src[4])*20 - (src[2]+src[5])*6 + (src[1]+src[6])*3 - (src[0]+src[7]));\
-        OP(dst[4], (src[4]+src[5])*20 - (src[3]+src[6])*6 + (src[2]+src[7])*3 - (src[1]+src[8]));\
-        OP(dst[5], (src[5]+src[6])*20 - (src[4]+src[7])*6 + (src[3]+src[8])*3 - (src[2]+src[8]));\
-        OP(dst[6], (src[6]+src[7])*20 - (src[5]+src[8])*6 + (src[4]+src[8])*3 - (src[3]+src[7]));\
-        OP(dst[7], (src[7]+src[8])*20 - (src[6]+src[8])*6 + (src[5]+src[7])*3 - (src[4]+src[6]));\
-        dst+=dstStride;\
-        src+=srcStride;\
-    }\
-}\
-\
-static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    const int w=8;\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    int i;\
-    for(i=0; i<w; i++)\
-    {\
-        const int src0= src[0*srcStride];\
-        const int src1= src[1*srcStride];\
-        const int src2= src[2*srcStride];\
-        const int src3= src[3*srcStride];\
-        const int src4= src[4*srcStride];\
-        const int src5= src[5*srcStride];\
-        const int src6= src[6*srcStride];\
-        const int src7= src[7*srcStride];\
-        const int src8= src[8*srcStride];\
-        OP(dst[0*dstStride], (src0+src1)*20 - (src0+src2)*6 + (src1+src3)*3 - (src2+src4));\
-        OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*6 + (src0+src4)*3 - (src1+src5));\
-        OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*6 + (src0+src5)*3 - (src0+src6));\
-        OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*6 + (src1+src6)*3 - (src0+src7));\
-        OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*6 + (src2+src7)*3 - (src1+src8));\
-        OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*6 + (src3+src8)*3 - (src2+src8));\
-        OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*6 + (src4+src8)*3 - (src3+src7));\
-        OP(dst[7*dstStride], (src7+src8)*20 - (src6+src8)*6 + (src5+src7)*3 - (src4+src6));\
-        dst++;\
-        src++;\
-    }\
-}\
-\
-static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    int i;\
-    \
-    for(i=0; i<h; i++)\
-    {\
-        OP(dst[ 0], (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]));\
-        OP(dst[ 1], (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]));\
-        OP(dst[ 2], (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]));\
-        OP(dst[ 3], (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]));\
-        OP(dst[ 4], (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]));\
-        OP(dst[ 5], (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 9]));\
-        OP(dst[ 6], (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 9])*3 - (src[ 3]+src[10]));\
-        OP(dst[ 7], (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 9])*6 + (src[ 5]+src[10])*3 - (src[ 4]+src[11]));\
-        OP(dst[ 8], (src[ 8]+src[ 9])*20 - (src[ 7]+src[10])*6 + (src[ 6]+src[11])*3 - (src[ 5]+src[12]));\
-        OP(dst[ 9], (src[ 9]+src[10])*20 - (src[ 8]+src[11])*6 + (src[ 7]+src[12])*3 - (src[ 6]+src[13]));\
-        OP(dst[10], (src[10]+src[11])*20 - (src[ 9]+src[12])*6 + (src[ 8]+src[13])*3 - (src[ 7]+src[14]));\
-        OP(dst[11], (src[11]+src[12])*20 - (src[10]+src[13])*6 + (src[ 9]+src[14])*3 - (src[ 8]+src[15]));\
-        OP(dst[12], (src[12]+src[13])*20 - (src[11]+src[14])*6 + (src[10]+src[15])*3 - (src[ 9]+src[16]));\
-        OP(dst[13], (src[13]+src[14])*20 - (src[12]+src[15])*6 + (src[11]+src[16])*3 - (src[10]+src[16]));\
-        OP(dst[14], (src[14]+src[15])*20 - (src[13]+src[16])*6 + (src[12]+src[16])*3 - (src[11]+src[15]));\
-        OP(dst[15], (src[15]+src[16])*20 - (src[14]+src[16])*6 + (src[13]+src[15])*3 - (src[12]+src[14]));\
-        dst+=dstStride;\
-        src+=srcStride;\
-    }\
-}\
-\
-static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    int i;\
-    const int w=16;\
-    for(i=0; i<w; i++)\
-    {\
-        const int src0= src[0*srcStride];\
-        const int src1= src[1*srcStride];\
-        const int src2= src[2*srcStride];\
-        const int src3= src[3*srcStride];\
-        const int src4= src[4*srcStride];\
-        const int src5= src[5*srcStride];\
-        const int src6= src[6*srcStride];\
-        const int src7= src[7*srcStride];\
-        const int src8= src[8*srcStride];\
-        const int src9= src[9*srcStride];\
-        const int src10= src[10*srcStride];\
-        const int src11= src[11*srcStride];\
-        const int src12= src[12*srcStride];\
-        const int src13= src[13*srcStride];\
-        const int src14= src[14*srcStride];\
-        const int src15= src[15*srcStride];\
-        const int src16= src[16*srcStride];\
-        OP(dst[ 0*dstStride], (src0 +src1 )*20 - (src0 +src2 )*6 + (src1 +src3 )*3 - (src2 +src4 ));\
-        OP(dst[ 1*dstStride], (src1 +src2 )*20 - (src0 +src3 )*6 + (src0 +src4 )*3 - (src1 +src5 ));\
-        OP(dst[ 2*dstStride], (src2 +src3 )*20 - (src1 +src4 )*6 + (src0 +src5 )*3 - (src0 +src6 ));\
-        OP(dst[ 3*dstStride], (src3 +src4 )*20 - (src2 +src5 )*6 + (src1 +src6 )*3 - (src0 +src7 ));\
-        OP(dst[ 4*dstStride], (src4 +src5 )*20 - (src3 +src6 )*6 + (src2 +src7 )*3 - (src1 +src8 ));\
-        OP(dst[ 5*dstStride], (src5 +src6 )*20 - (src4 +src7 )*6 + (src3 +src8 )*3 - (src2 +src9 ));\
-        OP(dst[ 6*dstStride], (src6 +src7 )*20 - (src5 +src8 )*6 + (src4 +src9 )*3 - (src3 +src10));\
-        OP(dst[ 7*dstStride], (src7 +src8 )*20 - (src6 +src9 )*6 + (src5 +src10)*3 - (src4 +src11));\
-        OP(dst[ 8*dstStride], (src8 +src9 )*20 - (src7 +src10)*6 + (src6 +src11)*3 - (src5 +src12));\
-        OP(dst[ 9*dstStride], (src9 +src10)*20 - (src8 +src11)*6 + (src7 +src12)*3 - (src6 +src13));\
-        OP(dst[10*dstStride], (src10+src11)*20 - (src9 +src12)*6 + (src8 +src13)*3 - (src7 +src14));\
-        OP(dst[11*dstStride], (src11+src12)*20 - (src10+src13)*6 + (src9 +src14)*3 - (src8 +src15));\
-        OP(dst[12*dstStride], (src12+src13)*20 - (src11+src14)*6 + (src10+src15)*3 - (src9 +src16));\
-        OP(dst[13*dstStride], (src13+src14)*20 - (src12+src15)*6 + (src11+src16)*3 - (src10+src16));\
-        OP(dst[14*dstStride], (src14+src15)*20 - (src13+src16)*6 + (src12+src16)*3 - (src11+src15));\
-        OP(dst[15*dstStride], (src15+src16)*20 - (src14+src16)*6 + (src13+src15)*3 - (src12+src14));\
-        dst++;\
-        src++;\
-    }\
-}\
-\
-static void OPNAME ## qpel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## pixels8_c(dst, src, stride, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t half[64];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
-    OPNAME ## pixels8_l2(dst, src, half, stride, stride, 8, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t half[64];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
-    OPNAME ## pixels8_l2(dst, src+1, half, stride, stride, 8, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t half[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
-    OPNAME ## pixels8_l2(dst, full, half, stride, 16, 8, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    copy_block9(full, src, 16, stride, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16);\
-}\
-\
-static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t half[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
-    OPNAME ## pixels8_l2(dst, full+16, half, stride, 16, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l4(dst, full, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l4(dst, full+1, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l4(dst, full+16, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full  , 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l4(dst, full+17, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
-}\
-static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t halfH[72];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
-}\
-static void OPNAME ## qpel16_mc00_c (uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## pixels16_c(dst, src, stride, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t half[256];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
-    OPNAME ## pixels16_l2(dst, src, half, stride, stride, 16, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t half[256];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
-    OPNAME ## pixels16_l2(dst, src+1, half, stride, stride, 16, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t half[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
-    OPNAME ## pixels16_l2(dst, full, half, stride, 24, 16, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    copy_block17(full, src, 24, stride, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24);\
-}\
-\
-static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t half[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
-    OPNAME ## pixels16_l2(dst, full+24, half, stride, 24, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l4(dst, full, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l4(dst, full+1, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l4(dst, full+24, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full  , 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l4(dst, full+25, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
-}\
-static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t halfH[272];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
-}
-
-#define op_avg(a, b) a = (((a)+cm[((b) + 16)>>5]+1)>>1)
-#define op_avg_no_rnd(a, b) a = (((a)+cm[((b) + 15)>>5])>>1)
-#define op_put(a, b) a = cm[((b) + 16)>>5]
-#define op_put_no_rnd(a, b) a = cm[((b) + 15)>>5]
-
-QPEL_MC(0, put_       , _       , op_put)
-QPEL_MC(1, put_no_rnd_, _no_rnd_, op_put_no_rnd)
-QPEL_MC(0, avg_       , _       , op_avg)
-//QPEL_MC(1, avg_no_rnd , _       , op_avg)
-#undef op_avg
-#undef op_avg_no_rnd
-#undef op_put
-#undef op_put_no_rnd
-
-#if 1
-#define H264_LOWPASS(OPNAME, OP, OP2) \
-static void OPNAME ## h264_qpel4_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    const int h=4;\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    int i;\
-    for(i=0; i<h; i++)\
-    {\
-        OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
-        OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
-        OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]));\
-        OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]));\
-        dst+=dstStride;\
-        src+=srcStride;\
-    }\
-}\
-\
-static void OPNAME ## h264_qpel4_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    const int w=4;\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    int i;\
-    for(i=0; i<w; i++)\
-    {\
-        const int srcB= src[-2*srcStride];\
-        const int srcA= src[-1*srcStride];\
-        const int src0= src[0 *srcStride];\
-        const int src1= src[1 *srcStride];\
-        const int src2= src[2 *srcStride];\
-        const int src3= src[3 *srcStride];\
-        const int src4= src[4 *srcStride];\
-        const int src5= src[5 *srcStride];\
-        const int src6= src[6 *srcStride];\
-        OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
-        OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
-        OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
-        OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
-        dst++;\
-        src++;\
-    }\
-}\
-\
-static void OPNAME ## h264_qpel4_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
-    const int h=4;\
-    const int w=4;\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    int i;\
-    src -= 2*srcStride;\
-    for(i=0; i<h+5; i++)\
-    {\
-        tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]);\
-        tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]);\
-        tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]);\
-        tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]);\
-        tmp+=tmpStride;\
-        src+=srcStride;\
-    }\
-    tmp -= tmpStride*(h+5-2);\
-    for(i=0; i<w; i++)\
-    {\
-        const int tmpB= tmp[-2*tmpStride];\
-        const int tmpA= tmp[-1*tmpStride];\
-        const int tmp0= tmp[0 *tmpStride];\
-        const int tmp1= tmp[1 *tmpStride];\
-        const int tmp2= tmp[2 *tmpStride];\
-        const int tmp3= tmp[3 *tmpStride];\
-        const int tmp4= tmp[4 *tmpStride];\
-        const int tmp5= tmp[5 *tmpStride];\
-        const int tmp6= tmp[6 *tmpStride];\
-        OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
-        OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
-        OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
-        OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
-        dst++;\
-        tmp++;\
-    }\
-}\
-\
-static void OPNAME ## h264_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    const int h=8;\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    int i;\
-    for(i=0; i<h; i++)\
-    {\
-        OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]));\
-        OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]));\
-        OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]));\
-        OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]));\
-        OP(dst[4], (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]));\
-        OP(dst[5], (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]));\
-        OP(dst[6], (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]));\
-        OP(dst[7], (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]));\
-        dst+=dstStride;\
-        src+=srcStride;\
-    }\
-}\
-\
-static void OPNAME ## h264_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    const int w=8;\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    int i;\
-    for(i=0; i<w; i++)\
-    {\
-        const int srcB= src[-2*srcStride];\
-        const int srcA= src[-1*srcStride];\
-        const int src0= src[0 *srcStride];\
-        const int src1= src[1 *srcStride];\
-        const int src2= src[2 *srcStride];\
-        const int src3= src[3 *srcStride];\
-        const int src4= src[4 *srcStride];\
-        const int src5= src[5 *srcStride];\
-        const int src6= src[6 *srcStride];\
-        const int src7= src[7 *srcStride];\
-        const int src8= src[8 *srcStride];\
-        const int src9= src[9 *srcStride];\
-        const int src10=src[10*srcStride];\
-        OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
-        OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
-        OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
-        OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
-        OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*5 + (src2+src7));\
-        OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*5 + (src3+src8));\
-        OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*5 + (src4+src9));\
-        OP(dst[7*dstStride], (src7+src8)*20 - (src6+src9)*5 + (src5+src10));\
-        dst++;\
-        src++;\
-    }\
-}\
-\
-static void OPNAME ## h264_qpel8_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
-    const int h=8;\
-    const int w=8;\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    int i;\
-    src -= 2*srcStride;\
-    for(i=0; i<h+5; i++)\
-    {\
-        tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]);\
-        tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]);\
-        tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]);\
-        tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]);\
-        tmp[4]= (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]);\
-        tmp[5]= (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]);\
-        tmp[6]= (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]);\
-        tmp[7]= (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]);\
-        tmp+=tmpStride;\
-        src+=srcStride;\
-    }\
-    tmp -= tmpStride*(h+5-2);\
-    for(i=0; i<w; i++)\
-    {\
-        const int tmpB= tmp[-2*tmpStride];\
-        const int tmpA= tmp[-1*tmpStride];\
-        const int tmp0= tmp[0 *tmpStride];\
-        const int tmp1= tmp[1 *tmpStride];\
-        const int tmp2= tmp[2 *tmpStride];\
-        const int tmp3= tmp[3 *tmpStride];\
-        const int tmp4= tmp[4 *tmpStride];\
-        const int tmp5= tmp[5 *tmpStride];\
-        const int tmp6= tmp[6 *tmpStride];\
-        const int tmp7= tmp[7 *tmpStride];\
-        const int tmp8= tmp[8 *tmpStride];\
-        const int tmp9= tmp[9 *tmpStride];\
-        const int tmp10=tmp[10*tmpStride];\
-        OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
-        OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
-        OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
-        OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
-        OP2(dst[4*dstStride], (tmp4+tmp5)*20 - (tmp3+tmp6)*5 + (tmp2+tmp7));\
-        OP2(dst[5*dstStride], (tmp5+tmp6)*20 - (tmp4+tmp7)*5 + (tmp3+tmp8));\
-        OP2(dst[6*dstStride], (tmp6+tmp7)*20 - (tmp5+tmp8)*5 + (tmp4+tmp9));\
-        OP2(dst[7*dstStride], (tmp7+tmp8)*20 - (tmp6+tmp9)*5 + (tmp5+tmp10));\
-        dst++;\
-        tmp++;\
-    }\
-}\
-\
-static void OPNAME ## h264_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    OPNAME ## h264_qpel8_v_lowpass(dst  , src  , dstStride, srcStride);\
-    OPNAME ## h264_qpel8_v_lowpass(dst+8, src+8, dstStride, srcStride);\
-    src += 8*srcStride;\
-    dst += 8*dstStride;\
-    OPNAME ## h264_qpel8_v_lowpass(dst  , src  , dstStride, srcStride);\
-    OPNAME ## h264_qpel8_v_lowpass(dst+8, src+8, dstStride, srcStride);\
-}\
-\
-static void OPNAME ## h264_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    OPNAME ## h264_qpel8_h_lowpass(dst  , src  , dstStride, srcStride);\
-    OPNAME ## h264_qpel8_h_lowpass(dst+8, src+8, dstStride, srcStride);\
-    src += 8*srcStride;\
-    dst += 8*dstStride;\
-    OPNAME ## h264_qpel8_h_lowpass(dst  , src  , dstStride, srcStride);\
-    OPNAME ## h264_qpel8_h_lowpass(dst+8, src+8, dstStride, srcStride);\
-}\
-\
-static void OPNAME ## h264_qpel16_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
-    OPNAME ## h264_qpel8_hv_lowpass(dst  , tmp  , src  , dstStride, tmpStride, srcStride);\
-    OPNAME ## h264_qpel8_hv_lowpass(dst+8, tmp+8, src+8, dstStride, tmpStride, srcStride);\
-    src += 8*srcStride;\
-    dst += 8*dstStride;\
-    OPNAME ## h264_qpel8_hv_lowpass(dst  , tmp  , src  , dstStride, tmpStride, srcStride);\
-    OPNAME ## h264_qpel8_hv_lowpass(dst+8, tmp+8, src+8, dstStride, tmpStride, srcStride);\
-}\
-
-#define H264_MC(OPNAME, SIZE) \
-static void OPNAME ## h264_qpel ## SIZE ## _mc00_c (uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## pixels ## SIZE ## _c(dst, src, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t half[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(half, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2(dst, src, half, stride, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc20_c(uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## h264_qpel ## SIZE ## _h_lowpass(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc30_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t half[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(half, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2(dst, src+1, half, stride, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    uint8_t half[SIZE*SIZE];\
-    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(half, full_mid, SIZE, SIZE);\
-    OPNAME ## pixels ## SIZE ## _l2(dst, full_mid, half, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc02_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
-    OPNAME ## h264_qpel ## SIZE ## _v_lowpass(dst, full_mid, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc03_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    uint8_t half[SIZE*SIZE];\
-    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(half, full_mid, SIZE, SIZE);\
-    OPNAME ## pixels ## SIZE ## _l2(dst, full_mid+SIZE, half, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    uint8_t halfH[SIZE*SIZE];\
-    uint8_t halfV[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\
-    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
-    OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc31_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    uint8_t halfH[SIZE*SIZE];\
-    uint8_t halfV[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\
-    copy_block ## SIZE (full, src - stride*2 + 1, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
-    OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc13_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    uint8_t halfH[SIZE*SIZE];\
-    uint8_t halfV[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\
-    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
-    OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc33_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    uint8_t halfH[SIZE*SIZE];\
-    uint8_t halfV[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\
-    copy_block ## SIZE (full, src - stride*2 + 1, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
-    OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\
-    int16_t tmp[SIZE*(SIZE+5)];\
-    OPNAME ## h264_qpel ## SIZE ## _hv_lowpass(dst, tmp, src, stride, SIZE, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\
-    int16_t tmp[SIZE*(SIZE+5)];\
-    uint8_t halfH[SIZE*SIZE];\
-    uint8_t halfHV[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfHV, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc23_c(uint8_t *dst, uint8_t *src, int stride){\
-    int16_t tmp[SIZE*(SIZE+5)];\
-    uint8_t halfH[SIZE*SIZE];\
-    uint8_t halfHV[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfHV, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    int16_t tmp[SIZE*(SIZE+5)];\
-    uint8_t halfV[SIZE*SIZE];\
-    uint8_t halfHV[SIZE*SIZE];\
-    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
-    put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2(dst, halfV, halfHV, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc32_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    int16_t tmp[SIZE*(SIZE+5)];\
-    uint8_t halfV[SIZE*SIZE];\
-    uint8_t halfHV[SIZE*SIZE];\
-    copy_block ## SIZE (full, src - stride*2 + 1, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
-    put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2(dst, halfV, halfHV, stride, SIZE, SIZE, SIZE);\
-}\
-
-#define op_avg(a, b)  a = (((a)+cm[((b) + 16)>>5]+1)>>1)
-//#define op_avg2(a, b) a = (((a)*w1+cm[((b) + 16)>>5]*w2 + o + 64)>>7)
-#define op_put(a, b)  a = cm[((b) + 16)>>5]
-#define op2_avg(a, b)  a = (((a)+cm[((b) + 512)>>10]+1)>>1)
-#define op2_put(a, b)  a = cm[((b) + 512)>>10]
-
-H264_LOWPASS(put_       , op_put, op2_put)
-H264_LOWPASS(avg_       , op_avg, op2_avg)
-H264_MC(put_, 4)
-H264_MC(put_, 8)
-H264_MC(put_, 16)
-H264_MC(avg_, 4)
-H264_MC(avg_, 8)
-H264_MC(avg_, 16)
-
-#undef op_avg
-#undef op_put
-#undef op2_avg
-#undef op2_put
-#endif
-
-#define op_scale1(x)  block[x] = clip_uint8( (block[x]*weight + offset) >> log2_denom )
-#define op_scale2(x)  dst[x] = clip_uint8( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1))
-#define H264_WEIGHT(W,H) \
-static void weight_h264_pixels ## W ## x ## H ## _c(uint8_t *block, int stride, int log2_denom, int weight, int offset){ \
-    int attribute_unused x, y; \
-    offset <<= log2_denom; \
-    if(log2_denom) offset += 1<<(log2_denom-1); \
-    for(y=0; y<H; y++, block += stride){ \
-        op_scale1(0); \
-        op_scale1(1); \
-        if(W==2) continue; \
-        op_scale1(2); \
-        op_scale1(3); \
-        if(W==4) continue; \
-        op_scale1(4); \
-        op_scale1(5); \
-        op_scale1(6); \
-        op_scale1(7); \
-        if(W==8) continue; \
-        op_scale1(8); \
-        op_scale1(9); \
-        op_scale1(10); \
-        op_scale1(11); \
-        op_scale1(12); \
-        op_scale1(13); \
-        op_scale1(14); \
-        op_scale1(15); \
-    } \
-} \
-static void biweight_h264_pixels ## W ## x ## H ## _c(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offsetd, int offsets){ \
-    int attribute_unused x, y; \
-    int offset = (offsets + offsetd + 1) >> 1; \
-    offset = ((offset << 1) + 1) << log2_denom; \
-    for(y=0; y<H; y++, dst += stride, src += stride){ \
-        op_scale2(0); \
-        op_scale2(1); \
-        if(W==2) continue; \
-        op_scale2(2); \
-        op_scale2(3); \
-        if(W==4) continue; \
-        op_scale2(4); \
-        op_scale2(5); \
-        op_scale2(6); \
-        op_scale2(7); \
-        if(W==8) continue; \
-        op_scale2(8); \
-        op_scale2(9); \
-        op_scale2(10); \
-        op_scale2(11); \
-        op_scale2(12); \
-        op_scale2(13); \
-        op_scale2(14); \
-        op_scale2(15); \
-    } \
-}
-
-H264_WEIGHT(16,16)
-H264_WEIGHT(16,8)
-H264_WEIGHT(8,16)
-H264_WEIGHT(8,8)
-H264_WEIGHT(8,4)
-H264_WEIGHT(4,8)
-H264_WEIGHT(4,4)
-H264_WEIGHT(4,2)
-H264_WEIGHT(2,4)
-H264_WEIGHT(2,2)
-
-#undef op_scale1
-#undef op_scale2
-#undef H264_WEIGHT
-
-static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-    int i;
-
-    for(i=0; i<h; i++){
-        dst[0]= cm[(9*(src[0] + src[1]) - (src[-1] + src[2]) + 8)>>4];
-        dst[1]= cm[(9*(src[1] + src[2]) - (src[ 0] + src[3]) + 8)>>4];
-        dst[2]= cm[(9*(src[2] + src[3]) - (src[ 1] + src[4]) + 8)>>4];
-        dst[3]= cm[(9*(src[3] + src[4]) - (src[ 2] + src[5]) + 8)>>4];
-        dst[4]= cm[(9*(src[4] + src[5]) - (src[ 3] + src[6]) + 8)>>4];
-        dst[5]= cm[(9*(src[5] + src[6]) - (src[ 4] + src[7]) + 8)>>4];
-        dst[6]= cm[(9*(src[6] + src[7]) - (src[ 5] + src[8]) + 8)>>4];
-        dst[7]= cm[(9*(src[7] + src[8]) - (src[ 6] + src[9]) + 8)>>4];
-        dst+=dstStride;
-        src+=srcStride;        
-    }
-}
-
-static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-    int i;
-
-    for(i=0; i<w; i++){
-        const int src_1= src[ -srcStride];
-        const int src0 = src[0          ];
-        const int src1 = src[  srcStride];
-        const int src2 = src[2*srcStride];
-        const int src3 = src[3*srcStride];
-        const int src4 = src[4*srcStride];
-        const int src5 = src[5*srcStride];
-        const int src6 = src[6*srcStride];
-        const int src7 = src[7*srcStride];
-        const int src8 = src[8*srcStride];
-        const int src9 = src[9*srcStride];
-        dst[0*dstStride]= cm[(9*(src0 + src1) - (src_1 + src2) + 8)>>4];
-        dst[1*dstStride]= cm[(9*(src1 + src2) - (src0  + src3) + 8)>>4];
-        dst[2*dstStride]= cm[(9*(src2 + src3) - (src1  + src4) + 8)>>4];
-        dst[3*dstStride]= cm[(9*(src3 + src4) - (src2  + src5) + 8)>>4];
-        dst[4*dstStride]= cm[(9*(src4 + src5) - (src3  + src6) + 8)>>4];
-        dst[5*dstStride]= cm[(9*(src5 + src6) - (src4  + src7) + 8)>>4];
-        dst[6*dstStride]= cm[(9*(src6 + src7) - (src5  + src8) + 8)>>4];
-        dst[7*dstStride]= cm[(9*(src7 + src8) - (src6  + src9) + 8)>>4];
-        src++;
-        dst++;
-    }
-}
-
-static void put_mspel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){
-    put_pixels8_c(dst, src, stride, 8);
-}
-
-static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){
-    uint8_t half[64];
-    wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
-    put_pixels8_l2(dst, src, half, stride, stride, 8, 8);
-}
-
-static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){
-    wmv2_mspel8_h_lowpass(dst, src, stride, stride, 8);
-}
-
-static void put_mspel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){
-    uint8_t half[64];
-    wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
-    put_pixels8_l2(dst, src+1, half, stride, stride, 8, 8);
-}
-
-static void put_mspel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){
-    wmv2_mspel8_v_lowpass(dst, src, stride, stride, 8);
-}
-
-static void put_mspel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){
-    uint8_t halfH[88];
-    uint8_t halfV[64];
-    uint8_t halfHV[64];
-    wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
-    wmv2_mspel8_v_lowpass(halfV, src, 8, stride, 8);
-    wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8);
-    put_pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);
-}
-static void put_mspel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){
-    uint8_t halfH[88];
-    uint8_t halfV[64];
-    uint8_t halfHV[64];
-    wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
-    wmv2_mspel8_v_lowpass(halfV, src+1, 8, stride, 8);
-    wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8);
-    put_pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);
-}
-static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){
-    uint8_t halfH[88];
-    wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
-    wmv2_mspel8_v_lowpass(dst, halfH+8, stride, 8, 8);
-}
-
-static void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale){
-    int x;
-    const int strength= ff_h263_loop_filter_strength[qscale];
-    
-    for(x=0; x<8; x++){
-        int d1, d2, ad1;
-        int p0= src[x-2*stride];
-        int p1= src[x-1*stride];
-        int p2= src[x+0*stride];
-        int p3= src[x+1*stride];
-        int d = (p0 - p3 + 4*(p2 - p1)) / 8;
-
-        if     (d<-2*strength) d1= 0;
-        else if(d<-  strength) d1=-2*strength - d;
-        else if(d<   strength) d1= d;
-        else if(d< 2*strength) d1= 2*strength - d;
-        else                   d1= 0;
-        
-        p1 += d1;
-        p2 -= d1;
-        if(p1&256) p1= ~(p1>>31);
-        if(p2&256) p2= ~(p2>>31);
-        
-        src[x-1*stride] = p1;
-        src[x+0*stride] = p2;
-
-        ad1= ABS(d1)>>1;
-        
-        d2= clip((p0-p3)/4, -ad1, ad1);
-        
-        src[x-2*stride] = p0 - d2;
-        src[x+  stride] = p3 + d2;
-    }
-}
-
-static void h263_h_loop_filter_c(uint8_t *src, int stride, int qscale){
-    int y;
-    const int strength= ff_h263_loop_filter_strength[qscale];
-    
-    for(y=0; y<8; y++){
-        int d1, d2, ad1;
-        int p0= src[y*stride-2];
-        int p1= src[y*stride-1];
-        int p2= src[y*stride+0];
-        int p3= src[y*stride+1];
-        int d = (p0 - p3 + 4*(p2 - p1)) / 8;
-
-        if     (d<-2*strength) d1= 0;
-        else if(d<-  strength) d1=-2*strength - d;
-        else if(d<   strength) d1= d;
-        else if(d< 2*strength) d1= 2*strength - d;
-        else                   d1= 0;
-        
-        p1 += d1;
-        p2 -= d1;
-        if(p1&256) p1= ~(p1>>31);
-        if(p2&256) p2= ~(p2>>31);
-        
-        src[y*stride-1] = p1;
-        src[y*stride+0] = p2;
-
-        ad1= ABS(d1)>>1;
-        
-        d2= clip((p0-p3)/4, -ad1, ad1);
-        
-        src[y*stride-2] = p0 - d2;
-        src[y*stride+1] = p3 + d2;
-    }
-}
-
-static void h261_loop_filter_c(uint8_t *src, int stride){
-    int x,y,xy,yz;
-    int temp[64];
-
-    for(x=0; x<8; x++){
-        temp[x      ] = 4*src[x           ];
-        temp[x + 7*8] = 4*src[x + 7*stride];
-    }
-    for(y=1; y<7; y++){
-        for(x=0; x<8; x++){
-            xy = y * stride + x;
-            yz = y * 8 + x;
-            temp[yz] = src[xy - stride] + 2*src[xy] + src[xy + stride];
-        }
-    }
-        
-    for(y=0; y<8; y++){
-        src[  y*stride] = (temp[  y*8] + 2)>>2;
-        src[7+y*stride] = (temp[7+y*8] + 2)>>2;
-        for(x=1; x<7; x++){
-            xy = y * stride + x;
-            yz = y * 8 + x;
-            src[xy] = (temp[yz-1] + 2*temp[yz] + temp[yz+1] + 8)>>4;
-        }
-    }
-}
-
-static inline void h264_loop_filter_luma_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta, int8_t *tc0)
-{
-    int i, d;
-    for( i = 0; i < 4; i++ ) {
-        if( tc0[i] < 0 ) {
-            pix += 4*ystride;
-            continue;
-        }
-        for( d = 0; d < 4; d++ ) {
-            const int p0 = pix[-1*xstride];
-            const int p1 = pix[-2*xstride];
-            const int p2 = pix[-3*xstride];
-            const int q0 = pix[0];
-            const int q1 = pix[1*xstride];
-            const int q2 = pix[2*xstride];
-    
-            if( ABS( p0 - q0 ) < alpha &&
-                ABS( p1 - p0 ) < beta &&
-                ABS( q1 - q0 ) < beta ) {
-    
-                int tc = tc0[i];
-                int i_delta;
-    
-                if( ABS( p2 - p0 ) < beta ) {
-                    pix[-2*xstride] = p1 + clip( (( p2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - p1, -tc0[i], tc0[i] );
-                    tc++;
-                }
-                if( ABS( q2 - q0 ) < beta ) {
-                    pix[   xstride] = q1 + clip( (( q2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - q1, -tc0[i], tc0[i] );
-                    tc++;
-                }
-    
-                i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
-                pix[-xstride] = clip_uint8( p0 + i_delta );    /* p0' */
-                pix[0]        = clip_uint8( q0 - i_delta );    /* q0' */
-            }
-            pix += ystride;
-        }
-    }
-}
-static void h264_v_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
-    h264_loop_filter_luma_c(pix, stride, 1, alpha, beta, tc0);
-}
-static void h264_h_loop_filter_luma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
-    h264_loop_filter_luma_c(pix, 1, stride, alpha, beta, tc0);
-}
-
-static inline void h264_loop_filter_chroma_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta, int8_t *tc0)
-{
-    int i, d;
-    for( i = 0; i < 4; i++ ) {
-        const int tc = tc0[i];
-        if( tc <= 0 ) {
-            pix += 2*ystride;
-            continue;
-        }
-        for( d = 0; d < 2; d++ ) {
-            const int p0 = pix[-1*xstride];
-            const int p1 = pix[-2*xstride];
-            const int q0 = pix[0];
-            const int q1 = pix[1*xstride];
-
-            if( ABS( p0 - q0 ) < alpha &&
-                ABS( p1 - p0 ) < beta &&
-                ABS( q1 - q0 ) < beta ) {
-
-                int delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
-
-                pix[-xstride] = clip_uint8( p0 + delta );    /* p0' */
-                pix[0]        = clip_uint8( q0 - delta );    /* q0' */
-            }
-            pix += ystride;
-        }
-    }
-}
-static void h264_v_loop_filter_chroma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
-    h264_loop_filter_chroma_c(pix, stride, 1, alpha, beta, tc0);
-}
-static void h264_h_loop_filter_chroma_c(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
-    h264_loop_filter_chroma_c(pix, 1, stride, alpha, beta, tc0);
-}
-
-static inline void h264_loop_filter_chroma_intra_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta)
-{
-    int d;
-    for( d = 0; d < 8; d++ ) {
-        const int p0 = pix[-1*xstride];
-        const int p1 = pix[-2*xstride];
-        const int q0 = pix[0];
-        const int q1 = pix[1*xstride];
-
-        if( ABS( p0 - q0 ) < alpha &&
-            ABS( p1 - p0 ) < beta &&
-            ABS( q1 - q0 ) < beta ) {
-
-            pix[-xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2;   /* p0' */
-            pix[0]        = ( 2*q1 + q0 + p1 + 2 ) >> 2;   /* q0' */
-        }
-        pix += ystride;
-    }
-}
-static void h264_v_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta)
-{
-    h264_loop_filter_chroma_intra_c(pix, stride, 1, alpha, beta);
-}
-static void h264_h_loop_filter_chroma_intra_c(uint8_t *pix, int stride, int alpha, int beta)
-{
-    h264_loop_filter_chroma_intra_c(pix, 1, stride, alpha, beta);
-}
-
-static inline int pix_abs16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int s, i;
-
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - pix2[0]);
-        s += abs(pix1[1] - pix2[1]);
-        s += abs(pix1[2] - pix2[2]);
-        s += abs(pix1[3] - pix2[3]);
-        s += abs(pix1[4] - pix2[4]);
-        s += abs(pix1[5] - pix2[5]);
-        s += abs(pix1[6] - pix2[6]);
-        s += abs(pix1[7] - pix2[7]);
-        s += abs(pix1[8] - pix2[8]);
-        s += abs(pix1[9] - pix2[9]);
-        s += abs(pix1[10] - pix2[10]);
-        s += abs(pix1[11] - pix2[11]);
-        s += abs(pix1[12] - pix2[12]);
-        s += abs(pix1[13] - pix2[13]);
-        s += abs(pix1[14] - pix2[14]);
-        s += abs(pix1[15] - pix2[15]);
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    return s;
-}
-
-static int pix_abs16_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int s, i;
-
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
-        s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
-        s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
-        s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
-        s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
-        s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
-        s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
-        s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
-        s += abs(pix1[8] - avg2(pix2[8], pix2[9]));
-        s += abs(pix1[9] - avg2(pix2[9], pix2[10]));
-        s += abs(pix1[10] - avg2(pix2[10], pix2[11]));
-        s += abs(pix1[11] - avg2(pix2[11], pix2[12]));
-        s += abs(pix1[12] - avg2(pix2[12], pix2[13]));
-        s += abs(pix1[13] - avg2(pix2[13], pix2[14]));
-        s += abs(pix1[14] - avg2(pix2[14], pix2[15]));
-        s += abs(pix1[15] - avg2(pix2[15], pix2[16]));
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    return s;
-}
-
-static int pix_abs16_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int s, i;
-    uint8_t *pix3 = pix2 + line_size;
-
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
-        s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
-        s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
-        s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
-        s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
-        s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
-        s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
-        s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
-        s += abs(pix1[8] - avg2(pix2[8], pix3[8]));
-        s += abs(pix1[9] - avg2(pix2[9], pix3[9]));
-        s += abs(pix1[10] - avg2(pix2[10], pix3[10]));
-        s += abs(pix1[11] - avg2(pix2[11], pix3[11]));
-        s += abs(pix1[12] - avg2(pix2[12], pix3[12]));
-        s += abs(pix1[13] - avg2(pix2[13], pix3[13]));
-        s += abs(pix1[14] - avg2(pix2[14], pix3[14]));
-        s += abs(pix1[15] - avg2(pix2[15], pix3[15]));
-        pix1 += line_size;
-        pix2 += line_size;
-        pix3 += line_size;
-    }
-    return s;
-}
-
-static int pix_abs16_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int s, i;
-    uint8_t *pix3 = pix2 + line_size;
-
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
-        s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
-        s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
-        s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
-        s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
-        s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
-        s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
-        s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
-        s += abs(pix1[8] - avg4(pix2[8], pix2[9], pix3[8], pix3[9]));
-        s += abs(pix1[9] - avg4(pix2[9], pix2[10], pix3[9], pix3[10]));
-        s += abs(pix1[10] - avg4(pix2[10], pix2[11], pix3[10], pix3[11]));
-        s += abs(pix1[11] - avg4(pix2[11], pix2[12], pix3[11], pix3[12]));
-        s += abs(pix1[12] - avg4(pix2[12], pix2[13], pix3[12], pix3[13]));
-        s += abs(pix1[13] - avg4(pix2[13], pix2[14], pix3[13], pix3[14]));
-        s += abs(pix1[14] - avg4(pix2[14], pix2[15], pix3[14], pix3[15]));
-        s += abs(pix1[15] - avg4(pix2[15], pix2[16], pix3[15], pix3[16]));
-        pix1 += line_size;
-        pix2 += line_size;
-        pix3 += line_size;
-    }
-    return s;
-}
-
-static inline int pix_abs8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int s, i;
-
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - pix2[0]);
-        s += abs(pix1[1] - pix2[1]);
-        s += abs(pix1[2] - pix2[2]);
-        s += abs(pix1[3] - pix2[3]);
-        s += abs(pix1[4] - pix2[4]);
-        s += abs(pix1[5] - pix2[5]);
-        s += abs(pix1[6] - pix2[6]);
-        s += abs(pix1[7] - pix2[7]);
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    return s;
-}
-
-static int pix_abs8_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int s, i;
-
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
-        s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
-        s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
-        s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
-        s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
-        s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
-        s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
-        s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    return s;
-}
-
-static int pix_abs8_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int s, i;
-    uint8_t *pix3 = pix2 + line_size;
-
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
-        s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
-        s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
-        s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
-        s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
-        s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
-        s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
-        s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
-        pix1 += line_size;
-        pix2 += line_size;
-        pix3 += line_size;
-    }
-    return s;
-}
-
-static int pix_abs8_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int s, i;
-    uint8_t *pix3 = pix2 + line_size;
-
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
-        s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
-        s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
-        s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
-        s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
-        s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
-        s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
-        s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
-        pix1 += line_size;
-        pix2 += line_size;
-        pix3 += line_size;
-    }
-    return s;
-}
-
-static int nsse16_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
-    MpegEncContext *c = v;
-    int score1=0;
-    int score2=0;
-    int x,y;
-
-    for(y=0; y<h; y++){
-        for(x=0; x<16; x++){
-            score1+= (s1[x  ] - s2[x ])*(s1[x  ] - s2[x ]);
-        }
-        if(y+1<h){
-            for(x=0; x<15; x++){
-                score2+= ABS(  s1[x  ] - s1[x  +stride]
-                             - s1[x+1] + s1[x+1+stride])
-                        -ABS(  s2[x  ] - s2[x  +stride]
-                             - s2[x+1] + s2[x+1+stride]);
-            }
-        }
-        s1+= stride;
-        s2+= stride;
-    }
-
-    if(c) return score1 + ABS(score2)*c->avctx->nsse_weight;
-    else  return score1 + ABS(score2)*8;
-}
-
-static int nsse8_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
-    MpegEncContext *c = v;
-    int score1=0;
-    int score2=0;
-    int x,y;
-    
-    for(y=0; y<h; y++){
-        for(x=0; x<8; x++){
-            score1+= (s1[x  ] - s2[x ])*(s1[x  ] - s2[x ]);
-        }
-        if(y+1<h){
-            for(x=0; x<7; x++){
-                score2+= ABS(  s1[x  ] - s1[x  +stride]
-                             - s1[x+1] + s1[x+1+stride])
-                        -ABS(  s2[x  ] - s2[x  +stride]
-                             - s2[x+1] + s2[x+1+stride]);
-            }
-        }
-        s1+= stride;
-        s2+= stride;
-    }
-    
-    if(c) return score1 + ABS(score2)*c->avctx->nsse_weight;
-    else  return score1 + ABS(score2)*8;
-}
-
-static int try_8x8basis_c(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale){
-    int i;
-    unsigned int sum=0;
-
-    for(i=0; i<8*8; i++){
-        int b= rem[i] + ((basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT));
-        int w= weight[i];
-        b>>= RECON_SHIFT;
-        assert(-512<b && b<512);
-
-        sum += (w*b)*(w*b)>>4;
-    }
-    return sum>>2;
-}
-
-static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale){
-    int i;
-
-    for(i=0; i<8*8; i++){
-        rem[i] += (basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT);
-    }    
-}
-
-/**
- * permutes an 8x8 block.
- * @param block the block which will be permuted according to the given permutation vector
- * @param permutation the permutation vector
- * @param last the last non zero coefficient in scantable order, used to speed the permutation up
- * @param scantable the used scantable, this is only used to speed the permutation up, the block is not 
- *                  (inverse) permutated to scantable order!
- */
-void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last)
-{
-    int i;
-    DCTELEM temp[64];
-    
-    if(last<=0) return;
-    //if(permutation[1]==1) return; //FIXME its ok but not clean and might fail for some perms
-
-    for(i=0; i<=last; i++){
-        const int j= scantable[i];
-        temp[j]= block[j];
-        block[j]=0;
-    }
-    
-    for(i=0; i<=last; i++){
-        const int j= scantable[i];
-        const int perm_j= permutation[j];
-        block[perm_j]= temp[j];
-    }
-}
-
-static int zero_cmp(void *s, uint8_t *a, uint8_t *b, int stride, int h){
-    return 0;
-}
-
-void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
-    int i;
-    
-    memset(cmp, 0, sizeof(void*)*5);
-        
-    for(i=0; i<5; i++){
-        switch(type&0xFF){
-        case FF_CMP_SAD:
-            cmp[i]= c->sad[i];
-            break;
-        case FF_CMP_SATD:
-            cmp[i]= c->hadamard8_diff[i];
-            break;
-        case FF_CMP_SSE:
-            cmp[i]= c->sse[i];
-            break;
-        case FF_CMP_DCT:
-            cmp[i]= c->dct_sad[i];
-            break;
-        case FF_CMP_DCTMAX:
-            cmp[i]= c->dct_max[i];
-            break;
-        case FF_CMP_PSNR:
-            cmp[i]= c->quant_psnr[i];
-            break;
-        case FF_CMP_BIT:
-            cmp[i]= c->bit[i];
-            break;
-        case FF_CMP_RD:
-            cmp[i]= c->rd[i];
-            break;
-        case FF_CMP_VSAD:
-            cmp[i]= c->vsad[i];
-            break;
-        case FF_CMP_VSSE:
-            cmp[i]= c->vsse[i];
-            break;
-        case FF_CMP_ZERO:
-            cmp[i]= zero_cmp;
-            break;
-        case FF_CMP_NSSE:
-            cmp[i]= c->nsse[i];
-            break;
-        case FF_CMP_W53:
-            cmp[i]= c->w53[i];
-            break;
-        case FF_CMP_W97:
-            cmp[i]= c->w97[i];
-            break;
-        default:
-            av_log(NULL, AV_LOG_ERROR,"internal error in cmp function selection\n");
-        }
-    }
-}
-
-/**
- * memset(blocks, 0, sizeof(DCTELEM)*6*64)
- */
-static void clear_blocks_c(DCTELEM *blocks)
-{
-    memset(blocks, 0, sizeof(DCTELEM)*6*64);
-}
-
-static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
-    int i;
-    for(i=0; i+7<w; i+=8){
-        dst[i+0] += src[i+0];
-        dst[i+1] += src[i+1];
-        dst[i+2] += src[i+2];
-        dst[i+3] += src[i+3];
-        dst[i+4] += src[i+4];
-        dst[i+5] += src[i+5];
-        dst[i+6] += src[i+6];
-        dst[i+7] += src[i+7];
-    }
-    for(; i<w; i++)
-        dst[i+0] += src[i+0];
-}
-
-static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
-    int i;
-    for(i=0; i+7<w; i+=8){
-        dst[i+0] = src1[i+0]-src2[i+0];
-        dst[i+1] = src1[i+1]-src2[i+1];
-        dst[i+2] = src1[i+2]-src2[i+2];
-        dst[i+3] = src1[i+3]-src2[i+3];
-        dst[i+4] = src1[i+4]-src2[i+4];
-        dst[i+5] = src1[i+5]-src2[i+5];
-        dst[i+6] = src1[i+6]-src2[i+6];
-        dst[i+7] = src1[i+7]-src2[i+7];
-    }
-    for(; i<w; i++)
-        dst[i+0] = src1[i+0]-src2[i+0];
-}
-
-static void sub_hfyu_median_prediction_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top){
-    int i;
-    uint8_t l, lt;
-
-    l= *left;
-    lt= *left_top;
-
-    for(i=0; i<w; i++){
-        const int pred= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF);
-        lt= src1[i];
-        l= src2[i];
-        dst[i]= l - pred;
-    }    
-
-    *left= l;
-    *left_top= lt;
-}
-
-#define BUTTERFLY2(o1,o2,i1,i2) \
-o1= (i1)+(i2);\
-o2= (i1)-(i2);
-
-#define BUTTERFLY1(x,y) \
-{\
-    int a,b;\
-    a= x;\
-    b= y;\
-    x= a+b;\
-    y= a-b;\
-}
-
-#define BUTTERFLYA(x,y) (ABS((x)+(y)) + ABS((x)-(y)))
-
-static int hadamard8_diff8x8_c(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){
-    int i;
-    int temp[64];
-    int sum=0;
-    
-    assert(h==8);
-
-    for(i=0; i<8; i++){
-        //FIXME try pointer walks
-        BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0]-dst[stride*i+0],src[stride*i+1]-dst[stride*i+1]);
-        BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2]-dst[stride*i+2],src[stride*i+3]-dst[stride*i+3]);
-        BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4]-dst[stride*i+4],src[stride*i+5]-dst[stride*i+5]);
-        BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6]-dst[stride*i+6],src[stride*i+7]-dst[stride*i+7]);
-        
-        BUTTERFLY1(temp[8*i+0], temp[8*i+2]);
-        BUTTERFLY1(temp[8*i+1], temp[8*i+3]);
-        BUTTERFLY1(temp[8*i+4], temp[8*i+6]);
-        BUTTERFLY1(temp[8*i+5], temp[8*i+7]);
-        
-        BUTTERFLY1(temp[8*i+0], temp[8*i+4]);
-        BUTTERFLY1(temp[8*i+1], temp[8*i+5]);
-        BUTTERFLY1(temp[8*i+2], temp[8*i+6]);
-        BUTTERFLY1(temp[8*i+3], temp[8*i+7]);
-    }
-
-    for(i=0; i<8; i++){
-        BUTTERFLY1(temp[8*0+i], temp[8*1+i]);
-        BUTTERFLY1(temp[8*2+i], temp[8*3+i]);
-        BUTTERFLY1(temp[8*4+i], temp[8*5+i]);
-        BUTTERFLY1(temp[8*6+i], temp[8*7+i]);
-        
-        BUTTERFLY1(temp[8*0+i], temp[8*2+i]);
-        BUTTERFLY1(temp[8*1+i], temp[8*3+i]);
-        BUTTERFLY1(temp[8*4+i], temp[8*6+i]);
-        BUTTERFLY1(temp[8*5+i], temp[8*7+i]);
-
-        sum += 
-             BUTTERFLYA(temp[8*0+i], temp[8*4+i])
-            +BUTTERFLYA(temp[8*1+i], temp[8*5+i])
-            +BUTTERFLYA(temp[8*2+i], temp[8*6+i])
-            +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
-    }
-#if 0
-static int maxi=0;
-if(sum>maxi){
-    maxi=sum;
-    printf("MAX:%d\n", maxi);
-}
-#endif
-    return sum;
-}
-
-static int hadamard8_intra8x8_c(/*MpegEncContext*/ void *s, uint8_t *src, uint8_t *dummy, int stride, int h){
-    int i;
-    int temp[64];
-    int sum=0;
-    
-    assert(h==8);
-    
-    for(i=0; i<8; i++){
-        //FIXME try pointer walks
-        BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0],src[stride*i+1]);
-        BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2],src[stride*i+3]);
-        BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4],src[stride*i+5]);
-        BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6],src[stride*i+7]);
-        
-        BUTTERFLY1(temp[8*i+0], temp[8*i+2]);
-        BUTTERFLY1(temp[8*i+1], temp[8*i+3]);
-        BUTTERFLY1(temp[8*i+4], temp[8*i+6]);
-        BUTTERFLY1(temp[8*i+5], temp[8*i+7]);
-        
-        BUTTERFLY1(temp[8*i+0], temp[8*i+4]);
-        BUTTERFLY1(temp[8*i+1], temp[8*i+5]);
-        BUTTERFLY1(temp[8*i+2], temp[8*i+6]);
-        BUTTERFLY1(temp[8*i+3], temp[8*i+7]);
-    }
-
-    for(i=0; i<8; i++){
-        BUTTERFLY1(temp[8*0+i], temp[8*1+i]);
-        BUTTERFLY1(temp[8*2+i], temp[8*3+i]);
-        BUTTERFLY1(temp[8*4+i], temp[8*5+i]);
-        BUTTERFLY1(temp[8*6+i], temp[8*7+i]);
-        
-        BUTTERFLY1(temp[8*0+i], temp[8*2+i]);
-        BUTTERFLY1(temp[8*1+i], temp[8*3+i]);
-        BUTTERFLY1(temp[8*4+i], temp[8*6+i]);
-        BUTTERFLY1(temp[8*5+i], temp[8*7+i]);
-    
-        sum += 
-             BUTTERFLYA(temp[8*0+i], temp[8*4+i])
-            +BUTTERFLYA(temp[8*1+i], temp[8*5+i])
-            +BUTTERFLYA(temp[8*2+i], temp[8*6+i])
-            +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
-    }
-    
-    sum -= ABS(temp[8*0] + temp[8*4]); // -mean
-    
-    return sum;
-}
-
-static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
-    MpegEncContext * const s= (MpegEncContext *)c;
-    uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8];
-    DCTELEM * const temp= (DCTELEM*)aligned_temp;
-    int sum=0, i;
-    
-    assert(h==8);
-
-    s->dsp.diff_pixels(temp, src1, src2, stride);
-    s->dsp.fdct(temp);
-
-    for(i=0; i<64; i++)
-        sum+= ABS(temp[i]);
-        
-    return sum;
-}
-
-static int dct_max8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
-    MpegEncContext * const s= (MpegEncContext *)c;
-    uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8];
-    DCTELEM * const temp= (DCTELEM*)aligned_temp;
-    int sum=0, i;
-    
-    assert(h==8);
-
-    s->dsp.diff_pixels(temp, src1, src2, stride);
-    s->dsp.fdct(temp);
-
-    for(i=0; i<64; i++)
-        sum= FFMAX(sum, ABS(temp[i]));
-        
-    return sum;
-}
-
-void simple_idct(DCTELEM *block); //FIXME
-
-static int quant_psnr8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
-    MpegEncContext * const s= (MpegEncContext *)c;
-    uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64*2/8];
-    DCTELEM * const temp= (DCTELEM*)aligned_temp;
-    DCTELEM * const bak = ((DCTELEM*)aligned_temp)+64;
-    int sum=0, i;
-
-    assert(h==8);
-    s->mb_intra=0;
-    
-    s->dsp.diff_pixels(temp, src1, src2, stride);
-    
-    memcpy(bak, temp, 64*sizeof(DCTELEM));
-    
-    s->block_last_index[0/*FIXME*/]= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
-    s->dct_unquantize_inter(s, temp, 0, s->qscale);
-    simple_idct(temp); //FIXME 
-    
-    for(i=0; i<64; i++)
-        sum+= (temp[i]-bak[i])*(temp[i]-bak[i]);
-        
-    return sum;
-}
-
-static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
-    MpegEncContext * const s= (MpegEncContext *)c;
-    const uint8_t *scantable= s->intra_scantable.permutated;
-    uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8];
-    uint64_t __align8 aligned_bak[stride];
-    DCTELEM * const temp= (DCTELEM*)aligned_temp;
-    uint8_t * const bak= (uint8_t*)aligned_bak;
-    int i, last, run, bits, level, distoration, start_i;
-    const int esc_length= s->ac_esc_length;
-    uint8_t * length;
-    uint8_t * last_length;
-    
-    assert(h==8);
-
-    for(i=0; i<8; i++){
-        ((uint32_t*)(bak + i*stride))[0]= ((uint32_t*)(src2 + i*stride))[0];
-        ((uint32_t*)(bak + i*stride))[1]= ((uint32_t*)(src2 + i*stride))[1];
-    }
-
-    s->dsp.diff_pixels(temp, src1, src2, stride);
-
-    s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
-
-    bits=0;
-    
-    if (s->mb_intra) {
-        start_i = 1; 
-        length     = s->intra_ac_vlc_length;
-        last_length= s->intra_ac_vlc_last_length;
-        bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma
-    } else {
-        start_i = 0;
-        length     = s->inter_ac_vlc_length;
-        last_length= s->inter_ac_vlc_last_length;
-    }
-    
-    if(last>=start_i){
-        run=0;
-        for(i=start_i; i<last; i++){
-            int j= scantable[i];
-            level= temp[j];
-        
-            if(level){
-                level+=64;
-                if((level&(~127)) == 0){
-                    bits+= length[UNI_AC_ENC_INDEX(run, level)];
-                }else
-                    bits+= esc_length;
-                run=0;
-            }else
-                run++;
-        }
-        i= scantable[last];
-       
-        level= temp[i] + 64;
-
-        assert(level - 64);
-        
-        if((level&(~127)) == 0){
-            bits+= last_length[UNI_AC_ENC_INDEX(run, level)];
-        }else
-            bits+= esc_length;
-    
-    }
-
-    if(last>=0){
-        if(s->mb_intra)
-            s->dct_unquantize_intra(s, temp, 0, s->qscale);
-        else
-            s->dct_unquantize_inter(s, temp, 0, s->qscale);
-    }
-    
-    s->dsp.idct_add(bak, stride, temp);
-    
-    distoration= s->dsp.sse[1](NULL, bak, src1, stride, 8);
-
-    return distoration + ((bits*s->qscale*s->qscale*109 + 64)>>7);
-}
-
-static int bit8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
-    MpegEncContext * const s= (MpegEncContext *)c;
-    const uint8_t *scantable= s->intra_scantable.permutated;
-    uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8];
-    DCTELEM * const temp= (DCTELEM*)aligned_temp;
-    int i, last, run, bits, level, start_i;
-    const int esc_length= s->ac_esc_length;
-    uint8_t * length;
-    uint8_t * last_length;
-
-    assert(h==8);
-    
-    s->dsp.diff_pixels(temp, src1, src2, stride);
-
-    s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
-
-    bits=0;
-    
-    if (s->mb_intra) {
-        start_i = 1; 
-        length     = s->intra_ac_vlc_length;
-        last_length= s->intra_ac_vlc_last_length;
-        bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma
-    } else {
-        start_i = 0;
-        length     = s->inter_ac_vlc_length;
-        last_length= s->inter_ac_vlc_last_length;
-    }
-    
-    if(last>=start_i){
-        run=0;
-        for(i=start_i; i<last; i++){
-            int j= scantable[i];
-            level= temp[j];
-        
-            if(level){
-                level+=64;
-                if((level&(~127)) == 0){
-                    bits+= length[UNI_AC_ENC_INDEX(run, level)];
-                }else
-                    bits+= esc_length;
-                run=0;
-            }else
-                run++;
-        }
-        i= scantable[last];
-                
-        level= temp[i] + 64;
-        
-        assert(level - 64);
-        
-        if((level&(~127)) == 0){
-            bits+= last_length[UNI_AC_ENC_INDEX(run, level)];
-        }else
-            bits+= esc_length;
-    }
-
-    return bits;
-}
-
-static int vsad_intra16_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){
-    int score=0;
-    int x,y;
-    
-    for(y=1; y<h; y++){
-        for(x=0; x<16; x+=4){
-            score+= ABS(s[x  ] - s[x  +stride]) + ABS(s[x+1] - s[x+1+stride]) 
-                   +ABS(s[x+2] - s[x+2+stride]) + ABS(s[x+3] - s[x+3+stride]);
-        }
-        s+= stride;
-    }
-    
-    return score;
-}
-
-static int vsad16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
-    int score=0;
-    int x,y;
-    
-    for(y=1; y<h; y++){
-        for(x=0; x<16; x++){
-            score+= ABS(s1[x  ] - s2[x ] - s1[x  +stride] + s2[x +stride]);
-        }
-        s1+= stride;
-        s2+= stride;
-    }
-    
-    return score;
-}
-
-#define SQ(a) ((a)*(a))
-static int vsse_intra16_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){
-    int score=0;
-    int x,y;
-    
-    for(y=1; y<h; y++){
-        for(x=0; x<16; x+=4){
-            score+= SQ(s[x  ] - s[x  +stride]) + SQ(s[x+1] - s[x+1+stride]) 
-                   +SQ(s[x+2] - s[x+2+stride]) + SQ(s[x+3] - s[x+3+stride]);
-        }
-        s+= stride;
-    }
-    
-    return score;
-}
-
-static int vsse16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
-    int score=0;
-    int x,y;
-    
-    for(y=1; y<h; y++){
-        for(x=0; x<16; x++){
-            score+= SQ(s1[x  ] - s2[x ] - s1[x  +stride] + s2[x +stride]);
-        }
-        s1+= stride;
-        s2+= stride;
-    }
-    
-    return score;
-}
-
-WARPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
-WARPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
-WARPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
-WARPER8_16_SQ(dct_max8x8_c, dct_max16_c)
-WARPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
-WARPER8_16_SQ(rd8x8_c, rd16_c)
-WARPER8_16_SQ(bit8x8_c, bit16_c)
-
-/* XXX: those functions should be suppressed ASAP when all IDCTs are
- converted */
-static void ff_jref_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    j_rev_dct (block);
-    put_pixels_clamped_c(block, dest, line_size);
-}
-static void ff_jref_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    j_rev_dct (block);
-    add_pixels_clamped_c(block, dest, line_size);
-}
-
-static void ff_jref_idct4_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    j_rev_dct4 (block);
-    put_pixels_clamped4_c(block, dest, line_size);
-}
-static void ff_jref_idct4_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    j_rev_dct4 (block);
-    add_pixels_clamped4_c(block, dest, line_size);
-}
-
-static void ff_jref_idct2_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    j_rev_dct2 (block);
-    put_pixels_clamped2_c(block, dest, line_size);
-}
-static void ff_jref_idct2_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    j_rev_dct2 (block);
-    add_pixels_clamped2_c(block, dest, line_size);
-}
-
-static void ff_jref_idct1_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-    dest[0] = cm[(block[0] + 4)>>3];
-}
-static void ff_jref_idct1_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-    dest[0] = cm[dest[0] + ((block[0] + 4)>>3)];
-}
-
-/* init static data */
-void dsputil_static_init(void)
-{
-    int i;
-
-    for(i=0;i<256;i++) cropTbl[i + MAX_NEG_CROP] = i;
-    for(i=0;i<MAX_NEG_CROP;i++) {
-        cropTbl[i] = 0;
-        cropTbl[i + MAX_NEG_CROP + 256] = 255;
-    }
-    
-    for(i=0;i<512;i++) {
-        squareTbl[i] = (i - 256) * (i - 256);
-    }
-    
-    for(i=0; i<64; i++) inv_zigzag_direct16[ff_zigzag_direct[i]]= i+1;
-}
-
-
-void dsputil_init(DSPContext* c, AVCodecContext *avctx)
-{
-    int i;
-
-#ifdef CONFIG_ENCODERS
-    if(avctx->dct_algo==FF_DCT_FASTINT) {
-        c->fdct = fdct_ifast;
-	c->fdct248 = fdct_ifast248;
-    } 
-    else if(avctx->dct_algo==FF_DCT_FAAN) {
-        c->fdct = ff_faandct;
-	c->fdct248 = ff_faandct248; 
-    } 
-    else {
-        c->fdct = ff_jpeg_fdct_islow; //slow/accurate/default
-	c->fdct248 = ff_fdct248_islow;
-    }
-#endif //CONFIG_ENCODERS
-
-    if(avctx->lowres==1){
-        if(avctx->idct_algo==FF_IDCT_INT || avctx->idct_algo==FF_IDCT_AUTO){
-            c->idct_put= ff_jref_idct4_put;
-            c->idct_add= ff_jref_idct4_add;
-        }else{
-            c->idct_put= ff_h264_lowres_idct_put_c;
-            c->idct_add= ff_h264_lowres_idct_add_c;
-        }
-        c->idct    = j_rev_dct4;
-        c->idct_permutation_type= FF_NO_IDCT_PERM;
-    }else if(avctx->lowres==2){
-        c->idct_put= ff_jref_idct2_put;
-        c->idct_add= ff_jref_idct2_add;
-        c->idct    = j_rev_dct2;
-        c->idct_permutation_type= FF_NO_IDCT_PERM;
-    }else if(avctx->lowres==3){
-        c->idct_put= ff_jref_idct1_put;
-        c->idct_add= ff_jref_idct1_add;
-        c->idct    = j_rev_dct1;
-        c->idct_permutation_type= FF_NO_IDCT_PERM;
-    }else{
-        if(avctx->idct_algo==FF_IDCT_INT){
-            c->idct_put= ff_jref_idct_put;
-            c->idct_add= ff_jref_idct_add;
-            c->idct    = j_rev_dct;
-            c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
-        }else if(avctx->idct_algo==FF_IDCT_VP3){
-            c->idct_put= ff_vp3_idct_put_c;
-            c->idct_add= ff_vp3_idct_add_c;
-            c->idct    = ff_vp3_idct_c;
-            c->idct_permutation_type= FF_NO_IDCT_PERM;
-        }else{ //accurate/default
-            c->idct_put= simple_idct_put;
-            c->idct_add= simple_idct_add;
-            c->idct    = simple_idct;
-            c->idct_permutation_type= FF_NO_IDCT_PERM;
-        }
-    }
-
-    c->h264_idct_add= ff_h264_idct_add_c;
-    c->h264_idct8_add= ff_h264_idct8_add_c;
-
-    c->get_pixels = get_pixels_c;
-    c->diff_pixels = diff_pixels_c;
-    c->put_pixels_clamped = put_pixels_clamped_c;
-    c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;
-    c->add_pixels_clamped = add_pixels_clamped_c;
-    c->add_pixels8 = add_pixels8_c;
-    c->add_pixels4 = add_pixels4_c;
-    c->gmc1 = gmc1_c;
-    c->gmc = gmc_c;
-    c->clear_blocks = clear_blocks_c;
-    c->pix_sum = pix_sum_c;
-    c->pix_norm1 = pix_norm1_c;
-
-    /* TODO [0] 16  [1] 8 */
-    c->pix_abs[0][0] = pix_abs16_c;
-    c->pix_abs[0][1] = pix_abs16_x2_c;
-    c->pix_abs[0][2] = pix_abs16_y2_c;
-    c->pix_abs[0][3] = pix_abs16_xy2_c;
-    c->pix_abs[1][0] = pix_abs8_c;
-    c->pix_abs[1][1] = pix_abs8_x2_c;
-    c->pix_abs[1][2] = pix_abs8_y2_c;
-    c->pix_abs[1][3] = pix_abs8_xy2_c;
-
-#define dspfunc(PFX, IDX, NUM) \
-    c->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## NUM ## _c;     \
-    c->PFX ## _pixels_tab[IDX][1] = PFX ## _pixels ## NUM ## _x2_c;  \
-    c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## NUM ## _y2_c;  \
-    c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## NUM ## _xy2_c
-
-    dspfunc(put, 0, 16);
-    dspfunc(put_no_rnd, 0, 16);
-    dspfunc(put, 1, 8);
-    dspfunc(put_no_rnd, 1, 8);
-    dspfunc(put, 2, 4);
-    dspfunc(put, 3, 2);
-
-    dspfunc(avg, 0, 16);
-    dspfunc(avg_no_rnd, 0, 16);
-    dspfunc(avg, 1, 8);
-    dspfunc(avg_no_rnd, 1, 8);
-    dspfunc(avg, 2, 4);
-    dspfunc(avg, 3, 2);
-#undef dspfunc
-
-    c->put_no_rnd_pixels_l2[0]= put_no_rnd_pixels16_l2_c;
-    c->put_no_rnd_pixels_l2[1]= put_no_rnd_pixels8_l2_c;
-
-    c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
-    c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
-    c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
-    c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
-    c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
-    c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
-    c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
-    c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
-    c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
-
-    c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
-    c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
-    c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
-    c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
-    c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
-    c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
-    c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
-    c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
-    c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;
-
-#define dspfunc(PFX, IDX, NUM) \
-    c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \
-    c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \
-    c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \
-    c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \
-    c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \
-    c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \
-    c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \
-    c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \
-    c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \
-    c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \
-    c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
-    c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
-    c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
-    c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
-    c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
-    c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
-
-    dspfunc(put_qpel, 0, 16);
-    dspfunc(put_no_rnd_qpel, 0, 16);
-
-    dspfunc(avg_qpel, 0, 16);
-    /* dspfunc(avg_no_rnd_qpel, 0, 16); */
-
-    dspfunc(put_qpel, 1, 8);
-    dspfunc(put_no_rnd_qpel, 1, 8);
-
-    dspfunc(avg_qpel, 1, 8);
-    /* dspfunc(avg_no_rnd_qpel, 1, 8); */
-
-    dspfunc(put_h264_qpel, 0, 16);
-    dspfunc(put_h264_qpel, 1, 8);
-    dspfunc(put_h264_qpel, 2, 4);
-    dspfunc(avg_h264_qpel, 0, 16);
-    dspfunc(avg_h264_qpel, 1, 8);
-    dspfunc(avg_h264_qpel, 2, 4);
-
-#undef dspfunc
-    c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_c;
-    c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_c;
-    c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_c;
-    c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_c;
-    c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_c;
-    c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_c;
-
-    c->weight_h264_pixels_tab[0]= weight_h264_pixels16x16_c;
-    c->weight_h264_pixels_tab[1]= weight_h264_pixels16x8_c;
-    c->weight_h264_pixels_tab[2]= weight_h264_pixels8x16_c;
-    c->weight_h264_pixels_tab[3]= weight_h264_pixels8x8_c;
-    c->weight_h264_pixels_tab[4]= weight_h264_pixels8x4_c;
-    c->weight_h264_pixels_tab[5]= weight_h264_pixels4x8_c;
-    c->weight_h264_pixels_tab[6]= weight_h264_pixels4x4_c;
-    c->weight_h264_pixels_tab[7]= weight_h264_pixels4x2_c;
-    c->weight_h264_pixels_tab[8]= weight_h264_pixels2x4_c;
-    c->weight_h264_pixels_tab[9]= weight_h264_pixels2x2_c;
-    c->biweight_h264_pixels_tab[0]= biweight_h264_pixels16x16_c;
-    c->biweight_h264_pixels_tab[1]= biweight_h264_pixels16x8_c;
-    c->biweight_h264_pixels_tab[2]= biweight_h264_pixels8x16_c;
-    c->biweight_h264_pixels_tab[3]= biweight_h264_pixels8x8_c;
-    c->biweight_h264_pixels_tab[4]= biweight_h264_pixels8x4_c;
-    c->biweight_h264_pixels_tab[5]= biweight_h264_pixels4x8_c;
-    c->biweight_h264_pixels_tab[6]= biweight_h264_pixels4x4_c;
-    c->biweight_h264_pixels_tab[7]= biweight_h264_pixels4x2_c;
-    c->biweight_h264_pixels_tab[8]= biweight_h264_pixels2x4_c;
-    c->biweight_h264_pixels_tab[9]= biweight_h264_pixels2x2_c;
-
-    c->put_mspel_pixels_tab[0]= put_mspel8_mc00_c;
-    c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;
-    c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c;
-    c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c;
-    c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c;
-    c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c;
-    c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;
-    c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;
-        
-#define SET_CMP_FUNC(name) \
-    c->name[0]= name ## 16_c;\
-    c->name[1]= name ## 8x8_c;
-    
-    SET_CMP_FUNC(hadamard8_diff)
-    c->hadamard8_diff[4]= hadamard8_intra16_c;
-    SET_CMP_FUNC(dct_sad)
-    SET_CMP_FUNC(dct_max)
-    c->sad[0]= pix_abs16_c;
-    c->sad[1]= pix_abs8_c;
-    c->sse[0]= sse16_c;
-    c->sse[1]= sse8_c;
-    c->sse[2]= sse4_c;
-    SET_CMP_FUNC(quant_psnr)
-    SET_CMP_FUNC(rd)
-    SET_CMP_FUNC(bit)
-    c->vsad[0]= vsad16_c;
-    c->vsad[4]= vsad_intra16_c;
-    c->vsse[0]= vsse16_c;
-    c->vsse[4]= vsse_intra16_c;
-    c->nsse[0]= nsse16_c;
-    c->nsse[1]= nsse8_c;
-    c->w53[0]= w53_16_c;
-    c->w53[1]= w53_8_c;
-    c->w97[0]= w97_16_c;
-    c->w97[1]= w97_8_c;
-
-    c->add_bytes= add_bytes_c;
-    c->diff_bytes= diff_bytes_c;
-    c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
-    c->bswap_buf= bswap_buf;
-
-    c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_c;
-    c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_c;
-    c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_c;
-    c->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_c;
-    c->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_c;
-    c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_c;
-    
-    c->h263_h_loop_filter= h263_h_loop_filter_c;
-    c->h263_v_loop_filter= h263_v_loop_filter_c;
-    
-    c->h261_loop_filter= h261_loop_filter_c;
-    
-    c->try_8x8basis= try_8x8basis_c;
-    c->add_8x8basis= add_8x8basis_c;
-
-#ifdef HAVE_MMX
-    dsputil_init_mmx(c, avctx);
-#endif
-#ifdef ARCH_ARMV4L
-    dsputil_init_armv4l(c, avctx);
-#endif
-#ifdef HAVE_MLIB
-    dsputil_init_mlib(c, avctx);
-#endif
-#ifdef ARCH_SPARC
-   dsputil_init_vis(c,avctx);
-#endif
-#ifdef ARCH_ALPHA
-    dsputil_init_alpha(c, avctx);
-#endif
-#ifdef ARCH_POWERPC
-    dsputil_init_ppc(c, avctx);
-#endif
-#ifdef HAVE_MMI
-    dsputil_init_mmi(c, avctx);
-#endif
-#ifdef ARCH_SH4
-    dsputil_init_sh4(c,avctx);
-#endif
-
-    switch(c->idct_permutation_type){
-    case FF_NO_IDCT_PERM:
-        for(i=0; i<64; i++)
-            c->idct_permutation[i]= i;
-        break;
-    case FF_LIBMPEG2_IDCT_PERM:
-        for(i=0; i<64; i++)
-            c->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
-        break;
-    case FF_SIMPLE_IDCT_PERM:
-        for(i=0; i<64; i++)
-            c->idct_permutation[i]= simple_mmx_permutation[i];
-        break;
-    case FF_TRANSPOSE_IDCT_PERM:
-        for(i=0; i<64; i++)
-            c->idct_permutation[i]= ((i&7)<<3) | (i>>3);
-        break;
-    case FF_PARTTRANS_IDCT_PERM:
-        for(i=0; i<64; i++)
-            c->idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3);
-        break;
-    default:
-        av_log(avctx, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n");
-    }
-}
-
diff --git a/ffmpeg.src/libavcodec/dsputil.h b/ffmpeg.src/libavcodec/dsputil.h
deleted file mode 100644
index cad3266..0000000
--- a/ffmpeg.src/libavcodec/dsputil.h
+++ /dev/null
@@ -1,626 +0,0 @@
-/*
- * DSP utils
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file dsputil.h
- * DSP utils.
- * note, many functions in here may use MMX which trashes the FPU state, it is
- * absolutely necessary to call emms_c() between dsp & float/double code
- */
-
-#ifndef DSPUTIL_H
-#define DSPUTIL_H
-
-#include "common.h"
-#include "avcodec.h"
-
-
-//#define DEBUG
-/* dct code */
-typedef short DCTELEM;
-
-void fdct_ifast (DCTELEM *data);
-void fdct_ifast248 (DCTELEM *data);
-void ff_jpeg_fdct_islow (DCTELEM *data);
-void ff_fdct248_islow (DCTELEM *data);
-
-void j_rev_dct (DCTELEM *data);
-void j_rev_dct4 (DCTELEM *data);
-void j_rev_dct2 (DCTELEM *data);
-void j_rev_dct1 (DCTELEM *data);
-
-void ff_fdct_mmx(DCTELEM *block);
-void ff_fdct_mmx2(DCTELEM *block);
-void ff_fdct_sse2(DCTELEM *block);
-
-void ff_h264_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride);
-void ff_h264_idct_add_c(uint8_t *dst, DCTELEM *block, int stride);
-void ff_h264_lowres_idct_add_c(uint8_t *dst, int stride, DCTELEM *block);
-void ff_h264_lowres_idct_put_c(uint8_t *dst, int stride, DCTELEM *block);
-
-/* encoding scans */
-extern const uint8_t ff_alternate_horizontal_scan[64];
-extern const uint8_t ff_alternate_vertical_scan[64];
-extern const uint8_t ff_zigzag_direct[64];
-extern const uint8_t ff_zigzag248_direct[64];
-
-/* pixel operations */
-#define MAX_NEG_CROP 1024
-
-/* temporary */
-extern uint32_t squareTbl[512];
-extern uint8_t cropTbl[256 + 2 * MAX_NEG_CROP];
-
-/* VP3 DSP functions */
-void ff_vp3_idct_c(DCTELEM *block/* align 16*/);
-void ff_vp3_idct_put_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
-void ff_vp3_idct_add_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
-
-/* minimum alignment rules ;)
-if u notice errors in the align stuff, need more alignment for some asm code for some cpu
-or need to use a function with less aligned data then send a mail to the ffmpeg-dev list, ...
-
-!warning these alignments might not match reallity, (missing attribute((align)) stuff somewhere possible)
-i (michael) didnt check them, these are just the alignents which i think could be reached easily ...
-
-!future video codecs might need functions with less strict alignment
-*/
-
-/*
-void get_pixels_c(DCTELEM *block, const uint8_t *pixels, int line_size);
-void diff_pixels_c(DCTELEM *block, const uint8_t *s1, const uint8_t *s2, int stride);
-void put_pixels_clamped_c(const DCTELEM *block, uint8_t *pixels, int line_size);
-void add_pixels_clamped_c(const DCTELEM *block, uint8_t *pixels, int line_size);
-void clear_blocks_c(DCTELEM *blocks);
-*/
-
-/* add and put pixel (decoding) */
-// blocksizes for op_pixels_func are 8x4,8x8 16x8 16x16
-//h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller then 4
-typedef void (*op_pixels_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int h);
-typedef void (*tpel_mc_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int w, int h);
-typedef void (*qpel_mc_func)(uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
-typedef void (*h264_chroma_mc_func)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x, int y);
-typedef void (*h264_weight_func)(uint8_t *block, int stride, int log2_denom, int weight, int offset);
-typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offsetd, int offsets);
-
-#define DEF_OLD_QPEL(name)\
-void ff_put_        ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
-void ff_put_no_rnd_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
-void ff_avg_        ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
-
-DEF_OLD_QPEL(qpel16_mc11_old_c)
-DEF_OLD_QPEL(qpel16_mc31_old_c)
-DEF_OLD_QPEL(qpel16_mc12_old_c)
-DEF_OLD_QPEL(qpel16_mc32_old_c)
-DEF_OLD_QPEL(qpel16_mc13_old_c)
-DEF_OLD_QPEL(qpel16_mc33_old_c)
-DEF_OLD_QPEL(qpel8_mc11_old_c)
-DEF_OLD_QPEL(qpel8_mc31_old_c)
-DEF_OLD_QPEL(qpel8_mc12_old_c)
-DEF_OLD_QPEL(qpel8_mc32_old_c)
-DEF_OLD_QPEL(qpel8_mc13_old_c)
-DEF_OLD_QPEL(qpel8_mc33_old_c)
-
-#define CALL_2X_PIXELS(a, b, n)\
-static void a(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
-    b(block  , pixels  , line_size, h);\
-    b(block+n, pixels+n, line_size, h);\
-}
-
-/* motion estimation */
-// h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller then 2
-// allthough currently h<4 is not used as functions with width <8 are not used and neither implemented
-typedef int (*me_cmp_func)(void /*MpegEncContext*/ *s, uint8_t *blk1/*align width (8 or 16)*/, uint8_t *blk2/*align 1*/, int line_size, int h)/* __attribute__ ((const))*/;
-
-
-/**
- * DSPContext.
- */
-typedef struct DSPContext {
-    /* pixel ops : interface with DCT */
-    void (*get_pixels)(DCTELEM *block/*align 16*/, const uint8_t *pixels/*align 8*/, int line_size);
-    void (*diff_pixels)(DCTELEM *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride);
-    void (*put_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
-    void (*put_signed_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
-    void (*add_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
-    void (*add_pixels8)(uint8_t *pixels, DCTELEM *block, int line_size);
-    void (*add_pixels4)(uint8_t *pixels, DCTELEM *block, int line_size);
-    /**
-     * translational global motion compensation.
-     */
-    void (*gmc1)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x16, int y16, int rounder);
-    /**
-     * global motion compensation.
-     */
-    void (*gmc )(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int ox, int oy,
-		    int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
-    void (*clear_blocks)(DCTELEM *blocks/*align 16*/);
-    int (*pix_sum)(uint8_t * pix, int line_size);
-    int (*pix_norm1)(uint8_t * pix, int line_size);
-// 16x16 8x8 4x4 2x2 16x8 8x4 4x2 8x16 4x8 2x4
-    
-    me_cmp_func sad[5]; /* identical to pix_absAxA except additional void * */
-    me_cmp_func sse[5];
-    me_cmp_func hadamard8_diff[5];
-    me_cmp_func dct_sad[5];
-    me_cmp_func quant_psnr[5];
-    me_cmp_func bit[5];
-    me_cmp_func rd[5];
-    me_cmp_func vsad[5];
-    me_cmp_func vsse[5];
-    me_cmp_func nsse[5];
-    me_cmp_func w53[5];
-    me_cmp_func w97[5];
-    me_cmp_func dct_max[5];
-
-    me_cmp_func me_pre_cmp[5];
-    me_cmp_func me_cmp[5];
-    me_cmp_func me_sub_cmp[5];
-    me_cmp_func mb_cmp[5];
-    me_cmp_func ildct_cmp[5]; //only width 16 used
-    me_cmp_func frame_skip_cmp[5]; //only width 8 used
-
-    /**
-     * Halfpel motion compensation with rounding (a+b+1)>>1.
-     * this is an array[4][4] of motion compensation funcions for 4 
-     * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
-     * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
-     * @param block destination where the result is stored
-     * @param pixels source
-     * @param line_size number of bytes in a horizontal line of block
-     * @param h height
-     */
-    op_pixels_func put_pixels_tab[4][4];
-
-    /**
-     * Halfpel motion compensation with rounding (a+b+1)>>1.
-     * This is an array[4][4] of motion compensation functions for 4 
-     * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
-     * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
-     * @param block destination into which the result is averaged (a+b+1)>>1
-     * @param pixels source
-     * @param line_size number of bytes in a horizontal line of block
-     * @param h height
-     */
-    op_pixels_func avg_pixels_tab[4][4];
-
-    /**
-     * Halfpel motion compensation with no rounding (a+b)>>1.
-     * this is an array[2][4] of motion compensation funcions for 2 
-     * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
-     * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
-     * @param block destination where the result is stored
-     * @param pixels source
-     * @param line_size number of bytes in a horizontal line of block
-     * @param h height
-     */
-    op_pixels_func put_no_rnd_pixels_tab[4][4];
-
-    /**
-     * Halfpel motion compensation with no rounding (a+b)>>1.
-     * this is an array[2][4] of motion compensation funcions for 2 
-     * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
-     * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
-     * @param block destination into which the result is averaged (a+b)>>1
-     * @param pixels source
-     * @param line_size number of bytes in a horizontal line of block
-     * @param h height
-     */
-    op_pixels_func avg_no_rnd_pixels_tab[4][4];
-    
-    void (*put_no_rnd_pixels_l2[2])(uint8_t *block/*align width (8 or 16)*/, const uint8_t *a/*align 1*/, const uint8_t *b/*align 1*/, int line_size, int h);
-    
-    /**
-     * Thirdpel motion compensation with rounding (a+b+1)>>1.
-     * this is an array[12] of motion compensation funcions for the 9 thirdpel positions<br>
-     * *pixels_tab[ xthirdpel + 4*ythirdpel ]
-     * @param block destination where the result is stored
-     * @param pixels source
-     * @param line_size number of bytes in a horizontal line of block
-     * @param h height
-     */
-    tpel_mc_func put_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
-    tpel_mc_func avg_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
-
-    qpel_mc_func put_qpel_pixels_tab[2][16];
-    qpel_mc_func avg_qpel_pixels_tab[2][16];
-    qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16];
-    qpel_mc_func avg_no_rnd_qpel_pixels_tab[2][16];
-    qpel_mc_func put_mspel_pixels_tab[8];
-    
-    /**
-     * h264 Chram MC
-     */
-    h264_chroma_mc_func put_h264_chroma_pixels_tab[3];
-    h264_chroma_mc_func avg_h264_chroma_pixels_tab[3];
-
-    qpel_mc_func put_h264_qpel_pixels_tab[3][16];
-    qpel_mc_func avg_h264_qpel_pixels_tab[3][16];
-    
-    h264_weight_func weight_h264_pixels_tab[10];
-    h264_biweight_func biweight_h264_pixels_tab[10];
-    
-    me_cmp_func pix_abs[2][4];
-    
-    /* huffyuv specific */
-    void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w);
-    void (*diff_bytes)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 1*/,int w);
-    /**
-     * subtract huffyuv's variant of median prediction
-     * note, this might read from src1[-1], src2[-1]
-     */
-    void (*sub_hfyu_median_prediction)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top);
-    void (*bswap_buf)(uint32_t *dst, uint32_t *src, int w);
-
-    void (*h264_v_loop_filter_luma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0);
-    void (*h264_h_loop_filter_luma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0);
-    void (*h264_v_loop_filter_chroma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0);
-    void (*h264_h_loop_filter_chroma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0);
-    void (*h264_v_loop_filter_chroma_intra)(uint8_t *pix, int stride, int alpha, int beta);
-    void (*h264_h_loop_filter_chroma_intra)(uint8_t *pix, int stride, int alpha, int beta);
-    
-    void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale);
-    void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale);
-
-    void (*h261_loop_filter)(uint8_t *src, int stride);
-
-    /* (I)DCT */
-    void (*fdct)(DCTELEM *block/* align 16*/);
-    void (*fdct248)(DCTELEM *block/* align 16*/);
-    
-    /* IDCT really*/
-    void (*idct)(DCTELEM *block/* align 16*/);
-    
-    /**
-     * block -> idct -> clip to unsigned 8 bit -> dest.
-     * (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...)
-     * @param line_size size in bytes of a horizotal line of dest
-     */
-    void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
-    
-    /**
-     * block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
-     * @param line_size size in bytes of a horizotal line of dest
-     */
-    void (*idct_add)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
-    
-    /**
-     * idct input permutation.
-     * several optimized IDCTs need a permutated input (relative to the normal order of the reference
-     * IDCT)
-     * this permutation must be performed before the idct_put/add, note, normally this can be merged
-     * with the zigzag/alternate scan<br>
-     * an example to avoid confusion:
-     * - (->decode coeffs -> zigzag reorder -> dequant -> reference idct ->...)
-     * - (x -> referece dct -> reference idct -> x)
-     * - (x -> referece dct -> simple_mmx_perm = idct_permutation -> simple_idct_mmx -> x)
-     * - (->decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant -> simple_idct_mmx ->...)
-     */
-    uint8_t idct_permutation[64];
-    int idct_permutation_type;
-#define FF_NO_IDCT_PERM 1
-#define FF_LIBMPEG2_IDCT_PERM 2
-#define FF_SIMPLE_IDCT_PERM 3
-#define FF_TRANSPOSE_IDCT_PERM 4
-#define FF_PARTTRANS_IDCT_PERM 5
-
-    int (*try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale);
-    void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale);
-#define BASIS_SHIFT 16
-#define RECON_SHIFT 6
- 
-    void (*h264_idct_add)(uint8_t *dst, DCTELEM *block, int stride);
-    void (*h264_idct8_add)(uint8_t *dst, DCTELEM *block, int stride);
-} DSPContext;
-
-void dsputil_static_init(void);
-void dsputil_init(DSPContext* p, AVCodecContext *avctx);
-
-/**
- * permute block according to permuatation.
- * @param last last non zero element in scantable order
- */
-void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last);
-
-void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type);
-
-#define	BYTE_VEC32(c)	((c)*0x01010101UL)
-
-static inline uint32_t rnd_avg32(uint32_t a, uint32_t b)
-{
-    return (a | b) - (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
-}
-
-static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b)
-{
-    return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
-}
-
-static inline int get_penalty_factor(int lambda, int lambda2, int type){
-    switch(type&0xFF){
-    default:
-    case FF_CMP_SAD:
-        return lambda>>FF_LAMBDA_SHIFT;
-    case FF_CMP_DCT:
-        return (3*lambda)>>(FF_LAMBDA_SHIFT+1);
-    case FF_CMP_W53:
-        return (4*lambda)>>(FF_LAMBDA_SHIFT);
-    case FF_CMP_W97:
-        return (2*lambda)>>(FF_LAMBDA_SHIFT);
-    case FF_CMP_SATD:
-        return (2*lambda)>>FF_LAMBDA_SHIFT;
-    case FF_CMP_RD:
-    case FF_CMP_PSNR:
-    case FF_CMP_SSE:
-    case FF_CMP_NSSE:
-        return lambda2>>FF_LAMBDA_SHIFT;
-    case FF_CMP_BIT:
-        return 1;
-    }
-}
-
-/**
- * Empty mmx state.
- * this must be called between any dsp function and float/double code.
- * for example sin(); dsp->idct_put(); emms_c(); cos()
- */
-#define emms_c()
-
-/* should be defined by architectures supporting
-   one or more MultiMedia extension */
-int mm_support(void);
-
-#define __align16 __attribute__ ((aligned (16)))
-
-#if defined(HAVE_MMX)
-
-#undef emms_c
-
-#define MM_MMX    0x0001 /* standard MMX */
-#define MM_3DNOW  0x0004 /* AMD 3DNOW */
-#define MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
-#define MM_SSE    0x0008 /* SSE functions */
-#define MM_SSE2   0x0010 /* PIV SSE2 functions */
-#define MM_3DNOWEXT  0x0020 /* AMD 3DNowExt */
-
-extern int mm_flags;
-
-void add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
-void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
-void put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size);
-
-static inline void emms(void)
-{
-    __asm __volatile ("emms;":::"memory");
-}
-
-
-#define emms_c() \
-{\
-    if (mm_flags & MM_MMX)\
-        emms();\
-}
-
-#define __align8 __attribute__ ((aligned (8)))
-#define STRIDE_ALIGN 8
-
-void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx);
-void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx);
-
-#elif defined(ARCH_ARMV4L)
-
-/* This is to use 4 bytes read to the IDCT pointers for some 'zero'
-   line optimizations */
-#define __align8 __attribute__ ((aligned (4)))
-#define STRIDE_ALIGN 4
-
-#define MM_IWMMXT    0x0100 /* XScale IWMMXT */
-
-extern int mm_flags;
-
-void dsputil_init_armv4l(DSPContext* c, AVCodecContext *avctx);
-
-#elif defined(HAVE_MLIB)
-
-/* SPARC/VIS IDCT needs 8-byte aligned DCT blocks */
-#define __align8 __attribute__ ((aligned (8)))
-#define STRIDE_ALIGN 8
-
-void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx);
-
-#elif defined(ARCH_SPARC)
-
-/* SPARC/VIS IDCT needs 8-byte aligned DCT blocks */
-#define __align8 __attribute__ ((aligned (8)))
-#define STRIDE_ALIGN 8
-void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx);
-
-#elif defined(ARCH_ALPHA)
-
-#define __align8 __attribute__ ((aligned (8)))
-#define STRIDE_ALIGN 8
-
-void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
-
-#elif defined(ARCH_POWERPC)
-
-#define MM_ALTIVEC    0x0001 /* standard AltiVec */
-
-extern int mm_flags;
-
-#if defined(HAVE_ALTIVEC) && !defined(CONFIG_DARWIN)
-#define pixel altivec_pixel
-#include <altivec.h>
-#undef pixel
-#endif
-
-#define __align8 __attribute__ ((aligned (16)))
-#define STRIDE_ALIGN 16
-
-void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx);
-
-#elif defined(HAVE_MMI)
-
-#define __align8 __attribute__ ((aligned (16)))
-#define STRIDE_ALIGN 16
-
-void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx);
-
-#elif defined(ARCH_SH4)
-
-#define __align8 __attribute__ ((aligned (8)))
-#define STRIDE_ALIGN 8
-
-void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx);
-
-#else
-
-#define __align8 __attribute__ ((aligned (8)))
-#define STRIDE_ALIGN 8
-
-#endif
-
-#ifdef __GNUC__
-
-struct unaligned_64 { uint64_t l; } __attribute__((packed));
-struct unaligned_32 { uint32_t l; } __attribute__((packed));
-struct unaligned_16 { uint16_t l; } __attribute__((packed));
-
-#define LD16(a) (((const struct unaligned_16 *) (a))->l)
-#define LD32(a) (((const struct unaligned_32 *) (a))->l)
-#define LD64(a) (((const struct unaligned_64 *) (a))->l)
-
-#define ST32(a, b) (((struct unaligned_32 *) (a))->l) = (b)
-
-#else /* __GNUC__ */
-
-#define LD16(a) (*((uint16_t*)(a)))
-#define LD32(a) (*((uint32_t*)(a)))
-#define LD64(a) (*((uint64_t*)(a)))
-
-#define ST32(a, b) *((uint32_t*)(a)) = (b)
-
-#endif /* !__GNUC__ */
-
-/* PSNR */
-void get_psnr(uint8_t *orig_image[3], uint8_t *coded_image[3],
-              int orig_linesize[3], int coded_linesize,
-              AVCodecContext *avctx);
-
-/* FFT computation */
-
-/* NOTE: soon integer code will be added, so you must use the
-   FFTSample type */
-typedef float FFTSample;
-
-typedef struct FFTComplex {
-    FFTSample re, im;
-} FFTComplex;
-
-typedef struct FFTContext {
-    int nbits;
-    int inverse;
-    uint16_t *revtab;
-    FFTComplex *exptab;
-    FFTComplex *exptab1; /* only used by SSE code */
-    void (*fft_calc)(struct FFTContext *s, FFTComplex *z);
-} FFTContext;
-
-int ff_fft_init(FFTContext *s, int nbits, int inverse);
-void ff_fft_permute(FFTContext *s, FFTComplex *z);
-void ff_fft_calc_c(FFTContext *s, FFTComplex *z);
-void ff_fft_calc_sse(FFTContext *s, FFTComplex *z);
-void ff_fft_calc_altivec(FFTContext *s, FFTComplex *z);
-
-static inline void ff_fft_calc(FFTContext *s, FFTComplex *z)
-{
-    s->fft_calc(s, z);
-}
-void ff_fft_end(FFTContext *s);
-
-/* MDCT computation */
-
-typedef struct MDCTContext {
-    int n;  /* size of MDCT (i.e. number of input data * 2) */
-    int nbits; /* n = 2^nbits */
-    /* pre/post rotation tables */
-    FFTSample *tcos;
-    FFTSample *tsin;
-    FFTContext fft;
-} MDCTContext;
-
-int ff_mdct_init(MDCTContext *s, int nbits, int inverse);
-void ff_imdct_calc(MDCTContext *s, FFTSample *output,
-                const FFTSample *input, FFTSample *tmp);
-void ff_mdct_calc(MDCTContext *s, FFTSample *out,
-               const FFTSample *input, FFTSample *tmp);
-void ff_mdct_end(MDCTContext *s);
-
-#define WARPER8_16(name8, name16)\
-static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\
-    return name8(s, dst           , src           , stride, h)\
-          +name8(s, dst+8         , src+8         , stride, h);\
-}
-
-#define WARPER8_16_SQ(name8, name16)\
-static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\
-    int score=0;\
-    score +=name8(s, dst           , src           , stride, 8);\
-    score +=name8(s, dst+8         , src+8         , stride, 8);\
-    if(h==16){\
-        dst += 8*stride;\
-        src += 8*stride;\
-        score +=name8(s, dst           , src           , stride, 8);\
-        score +=name8(s, dst+8         , src+8         , stride, 8);\
-    }\
-    return score;\
-}
-
-#ifndef HAVE_LRINTF
-/* XXX: add ISOC specific test to avoid specific BSD testing. */
-/* better than nothing implementation. */
-/* btw, rintf() is existing on fbsd too -- alex */
-static always_inline long int lrintf(float x)
-{
-#ifdef CONFIG_WIN32
-#  ifdef ARCH_X86
-    int32_t i;
-    asm volatile(
-        "fistpl %0\n\t"
-        : "=m" (i) : "t" (x) : "st"
-    );
-    return i;
-#  else
-    /* XXX: incorrect, but make it compile */
-    return (int)(x + (x < 0 ? -0.5 : 0.5));
-#  endif
-#else
-    return (int)(rint(x));
-#endif
-}
-#else
-#ifndef _ISOC9X_SOURCE
-#define _ISOC9X_SOURCE
-#endif
-#include <math.h>
-#endif
-
-#endif
diff --git a/ffmpeg.src/libavcodec/dtsdec.c b/ffmpeg.src/libavcodec/dtsdec.c
deleted file mode 100644
index fb1d50c..0000000
--- a/ffmpeg.src/libavcodec/dtsdec.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * dtsdec.c : free DTS Coherent Acoustics stream decoder.
- * Copyright (C) 2004 Benjamin Zores <ben at geexbox.org>
- *
- * This file is part of libavcodec.
- *
- * This library 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.
- *  
- * This library 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 this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifdef HAVE_AV_CONFIG_H
-#undef HAVE_AV_CONFIG_H
-#endif
-
-#include "avcodec.h"
-#include <dts.h>
-
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-
-#define INBUF_SIZE 4096
-#define BUFFER_SIZE 4096
-#define HEADER_SIZE 14
-
-#ifdef LIBDTS_FIXED
-#define CONVERT_LEVEL (1 << 26)
-#define CONVERT_BIAS 0
-#else
-#define CONVERT_LEVEL 1
-#define CONVERT_BIAS 384
-#endif
-
-static inline
-int16_t convert (int32_t i)
-{
-#ifdef LIBDTS_FIXED
-    i >>= 15;
-#else
-    i -= 0x43c00000;
-#endif
-    return (i > 32767) ? 32767 : ((i < -32768) ? -32768 : i);
-}
-
-void
-convert2s16_2 (sample_t * _f, int16_t * s16)
-{
-  int i;
-  int32_t * f = (int32_t *) _f;
-
-  for (i = 0; i < 256; i++)
-    {
-      s16[2*i] = convert (f[i]);
-      s16[2*i+1] = convert (f[i+256]);
-    }
-}
-
-void
-convert2s16_4 (sample_t * _f, int16_t * s16)
-{
-  int i;
-  int32_t * f = (int32_t *) _f;
-
-  for (i = 0; i < 256; i++)
-    {
-      s16[4*i] = convert (f[i]);
-      s16[4*i+1] = convert (f[i+256]);
-      s16[4*i+2] = convert (f[i+512]);
-      s16[4*i+3] = convert (f[i+768]);
-    }
-}
-
-void
-convert2s16_5 (sample_t * _f, int16_t * s16)
-{
-  int i;
-  int32_t * f = (int32_t *) _f;
-
-  for (i = 0; i < 256; i++)
-    {
-      s16[5*i] = convert (f[i]);
-      s16[5*i+1] = convert (f[i+256]);
-      s16[5*i+2] = convert (f[i+512]);
-      s16[5*i+3] = convert (f[i+768]);
-      s16[5*i+4] = convert (f[i+1024]);
-    }
-}
-
-static void
-convert2s16_multi (sample_t * _f, int16_t * s16, int flags)
-{
-  int i;
-  int32_t * f = (int32_t *) _f;
-
-  switch (flags)
-    {
-    case DTS_MONO:
-      for (i = 0; i < 256; i++)
-        {
-          s16[5*i] = s16[5*i+1] = s16[5*i+2] = s16[5*i+3] = 0;
-          s16[5*i+4] = convert (f[i]);
-        }
-      break;
-    case DTS_CHANNEL:
-    case DTS_STEREO:
-    case DTS_DOLBY:
-      convert2s16_2 (_f, s16);
-      break;
-    case DTS_3F:
-      for (i = 0; i < 256; i++)
-        {
-          s16[5*i] = convert (f[i]);
-          s16[5*i+1] = convert (f[i+512]);
-          s16[5*i+2] = s16[5*i+3] = 0;
-          s16[5*i+4] = convert (f[i+256]);
-        }
-      break;
-    case DTS_2F2R:
-      convert2s16_4 (_f, s16);
-      break;
-    case DTS_3F2R:
-      convert2s16_5 (_f, s16);
-      break;
-    case DTS_MONO | DTS_LFE:
-      for (i = 0; i < 256; i++)
-        {
-          s16[6*i] = s16[6*i+1] = s16[6*i+2] = s16[6*i+3] = 0;
-          s16[6*i+4] = convert (f[i+256]);
-          s16[6*i+5] = convert (f[i]);
-        }
-      break;
-    case DTS_CHANNEL | DTS_LFE:
-    case DTS_STEREO | DTS_LFE:
-    case DTS_DOLBY | DTS_LFE:
-      for (i = 0; i < 256; i++)
-        {
-          s16[6*i] = convert (f[i+256]);
-          s16[6*i+1] = convert (f[i+512]);
-          s16[6*i+2] = s16[6*i+3] = s16[6*i+4] = 0;
-          s16[6*i+5] = convert (f[i]);
-        }
-      break;
-    case DTS_3F | DTS_LFE:
-      for (i = 0; i < 256; i++)
-        {
-          s16[6*i] = convert (f[i+256]);
-          s16[6*i+1] = convert (f[i+768]);
-          s16[6*i+2] = s16[6*i+3] = 0;
-          s16[6*i+4] = convert (f[i+512]);
-          s16[6*i+5] = convert (f[i]);
-        }
-      break;
-    case DTS_2F2R | DTS_LFE:
-      for (i = 0; i < 256; i++)
-        {
-          s16[6*i] = convert (f[i+256]);
-          s16[6*i+1] = convert (f[i+512]);
-          s16[6*i+2] = convert (f[i+768]);
-          s16[6*i+3] = convert (f[i+1024]);
-          s16[6*i+4] = 0;
-          s16[6*i+5] = convert (f[i]);
-        }
-      break;
-    case DTS_3F2R | DTS_LFE:
-      for (i = 0; i < 256; i++)
-        {
-          s16[6*i] = convert (f[i+256]);
-          s16[6*i+1] = convert (f[i+768]);
-          s16[6*i+2] = convert (f[i+1024]);
-          s16[6*i+3] = convert (f[i+1280]);
-          s16[6*i+4] = convert (f[i+512]);
-          s16[6*i+5] = convert (f[i]);
-        }
-      break;
-    }
-}
-
-static int
-channels_multi (int flags)
-{
-  if (flags & DTS_LFE)
-    return 6;
-  else if (flags & 1)	/* center channel */
-    return 5;
-  else if ((flags & DTS_CHANNEL_MASK) == DTS_2F2R)
-    return 4;
-  else
-    return 2;
-}
-
-static int
-dts_decode_frame (AVCodecContext *avctx, void *data, int *data_size,
-                  uint8_t *buff, int buff_size)
-{
-  uint8_t * start = buff;
-  uint8_t * end = buff + buff_size;
-  static uint8_t buf[BUFFER_SIZE];
-  static uint8_t * bufptr = buf;
-  static uint8_t * bufpos = buf + HEADER_SIZE;
-
-  static int sample_rate;
-  static int frame_length;
-  static int flags;
-  int bit_rate;
-  int len;
-  dts_state_t *state = avctx->priv_data;
-
-  *data_size = 0;
-
-  while (1)
-    {
-      len = end - start;
-      if (!len)
-        break;
-      if (len > bufpos - bufptr)
-        len = bufpos - bufptr;
-      memcpy (bufptr, start, len);
-      bufptr += len;
-      start += len;
-      if (bufptr == bufpos)
-        {
-          if (bufpos == buf + HEADER_SIZE)
-            {
-              int length;
-
-              length = dts_syncinfo (state, buf, &flags, &sample_rate,
-                                     &bit_rate, &frame_length);
-              if (!length)
-                {
-                  av_log (NULL, AV_LOG_INFO, "skip\n");
-                  for (bufptr = buf; bufptr < buf + HEADER_SIZE-1; bufptr++)
-                    bufptr[0] = bufptr[1];
-                  continue;
-                }
-              bufpos = buf + length;
-            }
-          else
-            {
-              level_t level;
-              sample_t bias;
-              int i;
-
-              flags = 2; /* ???????????? */
-              level = CONVERT_LEVEL;
-              bias = CONVERT_BIAS;
-
-              flags |= DTS_ADJUST_LEVEL;
-              if (dts_frame (state, buf, &flags, &level, bias))
-                goto error;
-              avctx->sample_rate = sample_rate;
-              avctx->channels = channels_multi (flags);
-              avctx->bit_rate = bit_rate;
-              for (i = 0; i < dts_blocks_num (state); i++)
-                {
-                  if (dts_block (state))
-                    goto error;
-                  {
-                    int chans;
-                    chans = channels_multi (flags);
-                    convert2s16_multi (dts_samples (state), data,
-                                       flags & (DTS_CHANNEL_MASK | DTS_LFE));
-
-                    data += 256 * sizeof (int16_t) * chans;
-                    *data_size += 256 * sizeof (int16_t) * chans;
-                  }
-                }
-              bufptr = buf;
-              bufpos = buf + HEADER_SIZE;
-              continue;
-            error:
-              av_log (NULL, AV_LOG_ERROR, "error\n");
-              bufptr = buf;
-              bufpos = buf + HEADER_SIZE;
-            }
-        }
-    }
-
-  return buff_size;
-}
-
-static int
-dts_decode_init (AVCodecContext *avctx)
-{
-  avctx->priv_data = dts_init (0);
-  if (avctx->priv_data == NULL)
-    return 1;
-
-  return 0;
-}
-
-static int
-dts_decode_end (AVCodecContext *s)
-{
-  return 0;
-}
-
-AVCodec dts_decoder = {
-  "dts", 
-  CODEC_TYPE_AUDIO,
-  CODEC_ID_DTS,
-  sizeof (dts_state_t *),
-  dts_decode_init,
-  NULL,
-  dts_decode_end,
-  dts_decode_frame,
-};
diff --git a/ffmpeg.src/libavcodec/dvbsub.c b/ffmpeg.src/libavcodec/dvbsub.c
deleted file mode 100644
index 8efe8b2..0000000
--- a/ffmpeg.src/libavcodec/dvbsub.c
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- * DVB subtitle encoding for ffmpeg
- * Copyright (c) 2005 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avcodec.h"
-
-typedef struct DVBSubtitleContext {
-    int hide_state;
-    int object_version;
-} DVBSubtitleContext;
-
-#define PUTBITS2(val)\
-{\
-    bitbuf |= (val) << bitcnt;\
-    bitcnt -= 2;\
-    if (bitcnt < 0) {\
-        bitcnt = 6;\
-        *q++ = bitbuf;\
-        bitbuf = 0;\
-    }\
-}
-
-static void dvb_encode_rle2(uint8_t **pq,
-                            const uint8_t *bitmap, int linesize,
-                            int w, int h)
-{
-    uint8_t *q;
-    unsigned int bitbuf;
-    int bitcnt;
-    int x, y, len, x1, v, color;
-
-    q = *pq;
-    
-    for(y = 0; y < h; y++) {
-        *q++ = 0x10;
-        bitbuf = 0;
-        bitcnt = 6;
-        
-        x = 0;
-        while (x < w) {
-            x1 = x;
-            color = bitmap[x1++];
-            while (x1 < w && bitmap[x1] == color)
-                x1++;
-            len = x1 - x;
-            if (color == 0 && len == 2) {
-                PUTBITS2(0);
-                PUTBITS2(0);
-                PUTBITS2(1);
-            } else if (len >= 3 && len <= 10) {
-                v = len - 3;
-                PUTBITS2(0);
-                PUTBITS2((v >> 2) | 2);
-                PUTBITS2(v & 3);
-                PUTBITS2(color);
-            } else if (len >= 12 && len <= 27) {
-                v = len - 12;
-                PUTBITS2(0);
-                PUTBITS2(0);
-                PUTBITS2(2);
-                PUTBITS2(v >> 2);
-                PUTBITS2(v & 3);
-                PUTBITS2(color);
-            } else if (len >= 29) {
-                /* length = 29 ... 284 */
-                if (len > 284)
-                    len = 284;
-                v = len - 29;
-                PUTBITS2(0);
-                PUTBITS2(0);
-                PUTBITS2(3);
-                PUTBITS2((v >> 6));
-                PUTBITS2((v >> 4) & 3);
-                PUTBITS2((v >> 2) & 3);
-                PUTBITS2(v & 3);
-                PUTBITS2(color);
-            } else {
-                PUTBITS2(color);
-                if (color == 0) {
-                    PUTBITS2(1);
-                }
-                len = 1;
-            }
-            x += len;
-        }
-        /* end of line */
-        PUTBITS2(0);
-        PUTBITS2(0);
-        PUTBITS2(0);
-        if (bitcnt != 6) {
-            *q++ = bitbuf;
-        }
-        *q++ = 0xf0;
-        bitmap += linesize;
-    }
-    *pq = q;
-}
-
-#define PUTBITS4(val)\
-{\
-    bitbuf |= (val) << bitcnt;\
-    bitcnt -= 4;\
-    if (bitcnt < 0) {\
-        bitcnt = 4;\
-        *q++ = bitbuf;\
-        bitbuf = 0;\
-    }\
-}
-
-/* some DVB decoders only implement 4 bits/pixel */
-static void dvb_encode_rle4(uint8_t **pq,
-                            const uint8_t *bitmap, int linesize,
-                            int w, int h)
-{
-    uint8_t *q;
-    unsigned int bitbuf;
-    int bitcnt;
-    int x, y, len, x1, v, color;
-
-    q = *pq;
-    
-    for(y = 0; y < h; y++) {
-        *q++ = 0x11;
-        bitbuf = 0;
-        bitcnt = 4;
-        
-        x = 0;
-        while (x < w) {
-            x1 = x;
-            color = bitmap[x1++];
-            while (x1 < w && bitmap[x1] == color)
-                x1++;
-            len = x1 - x;
-            if (color == 0 && len == 2) {
-                PUTBITS4(0);
-                PUTBITS4(0xd);
-            } else if (color == 0 && (len >= 3 && len <= 9)) {
-                PUTBITS4(0);
-                PUTBITS4(len - 2);
-            } else if (len >= 4 && len <= 7) {
-                PUTBITS4(0);
-                PUTBITS4(8 + len - 4);
-                PUTBITS4(color);
-            } else if (len >= 9 && len <= 24) {
-                PUTBITS4(0);
-                PUTBITS4(0xe);
-                PUTBITS4(len - 9);
-                PUTBITS4(color);
-            } else if (len >= 25) {
-                if (len > 280)
-                    len = 280;
-                v = len - 25;
-                PUTBITS4(0);
-                PUTBITS4(0xf);
-                PUTBITS4(v >> 4);
-                PUTBITS4(v & 0xf);
-                PUTBITS4(color);
-            } else {
-                PUTBITS4(color);
-                if (color == 0) {
-                    PUTBITS4(0xc);
-                }
-                len = 1;
-            }
-            x += len;
-        }
-        /* end of line */
-        PUTBITS4(0);
-        PUTBITS4(0);
-        if (bitcnt != 4) {
-            *q++ = bitbuf;
-        }
-        *q++ = 0xf0;
-        bitmap += linesize;
-    }
-    *pq = q;
-}
-
-#define SCALEBITS 10
-#define ONE_HALF  (1 << (SCALEBITS - 1))
-#define FIX(x)	  ((int) ((x) * (1<<SCALEBITS) + 0.5))
-
-#define RGB_TO_Y_CCIR(r, g, b) \
-((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
-  FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
-
-#define RGB_TO_U_CCIR(r1, g1, b1, shift)\
-(((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 +         \
-     FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
-
-#define RGB_TO_V_CCIR(r1, g1, b1, shift)\
-(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 -           \
-   FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
-
-static inline void putbe16(uint8_t **pq, uint16_t v)
-{
-    uint8_t *q;
-    q = *pq;
-    *q++ = v >> 8;
-    *q++ = v;
-    *pq = q;
-}
-
-static int encode_dvb_subtitles(DVBSubtitleContext *s, 
-                                uint8_t *outbuf, AVSubtitle *h)
-{
-    uint8_t *q, *pseg_len;
-    int page_id, region_id, clut_id, object_id, i, bpp_index, page_state;
-
-
-    q = outbuf;
-
-    page_id = 1;
-
-    if (h->num_rects == 0 || h->rects == NULL)
-        return -1;
-
-    *q++ = 0x00; /* subtitle_stream_id */
-
-    /* page composition segment */
-
-    *q++ = 0x0f; /* sync_byte */
-    *q++ = 0x10; /* segment_type */
-    putbe16(&q, page_id);
-    pseg_len = q;
-    q += 2; /* segment length */
-    *q++ = 30; /* page_timeout (seconds) */
-    if (s->hide_state)
-        page_state = 0; /* normal case */
-    else
-        page_state = 2; /* mode change */
-    /* page_version = 0 + page_state */
-    *q++ = s->object_version | (page_state << 2) | 3; 
-
-    for (region_id = 0; region_id < h->num_rects; region_id++) {
-        *q++ = region_id;
-        *q++ = 0xff; /* reserved */
-        putbe16(&q, h->rects[region_id].x); /* left pos */
-        putbe16(&q, h->rects[region_id].y); /* top pos */
-    }
-
-    putbe16(&pseg_len, q - pseg_len - 2);
-
-    if (!s->hide_state) {
-        for (clut_id = 0; clut_id < h->num_rects; clut_id++) {
-
-            /* CLUT segment */
-
-            if (h->rects[clut_id].nb_colors <= 4) {
-                /* 2 bpp, some decoders do not support it correctly */
-                bpp_index = 0;
-            } else if (h->rects[clut_id].nb_colors <= 16) {
-                /* 4 bpp, standard encoding */
-                bpp_index = 1;
-            } else {
-                return -1;
-            }
-
-            *q++ = 0x0f; /* sync byte */
-            *q++ = 0x12; /* CLUT definition segment */
-            putbe16(&q, page_id);
-            pseg_len = q;
-            q += 2; /* segment length */
-            *q++ = clut_id;
-            *q++ = (0 << 4) | 0xf; /* version = 0 */
-
-            for(i = 0; i < h->rects[clut_id].nb_colors; i++) {
-                *q++ = i; /* clut_entry_id */
-                *q++ = (1 << (7 - bpp_index)) | (0xf << 1) | 1; /* 2 bits/pixel full range */
-                {
-                    int a, r, g, b;
-                    a = (h->rects[clut_id].rgba_palette[i] >> 24) & 0xff;
-                    r = (h->rects[clut_id].rgba_palette[i] >> 16) & 0xff;
-                    g = (h->rects[clut_id].rgba_palette[i] >> 8) & 0xff;
-                    b = (h->rects[clut_id].rgba_palette[i] >> 0) & 0xff;
-
-                    *q++ = RGB_TO_Y_CCIR(r, g, b);
-                    *q++ = RGB_TO_V_CCIR(r, g, b, 0);
-                    *q++ = RGB_TO_U_CCIR(r, g, b, 0);
-                    *q++ = 255 - a;
-                }
-            }
-
-            putbe16(&pseg_len, q - pseg_len - 2);
-        }
-    }
-
-    for (region_id = 0; region_id < h->num_rects; region_id++) {
-
-        /* region composition segment */
-        
-        if (h->rects[region_id].nb_colors <= 4) {
-            /* 2 bpp, some decoders do not support it correctly */
-            bpp_index = 0;
-        } else if (h->rects[region_id].nb_colors <= 16) {
-            /* 4 bpp, standard encoding */
-            bpp_index = 1;
-        } else {
-            return -1;
-        }
-
-        *q++ = 0x0f; /* sync_byte */
-        *q++ = 0x11; /* segment_type */
-        putbe16(&q, page_id);
-        pseg_len = q;
-        q += 2; /* segment length */
-        *q++ = region_id;
-        *q++ = (s->object_version << 4) | (0 << 3) | 0x07; /* version , no fill */
-        putbe16(&q, h->rects[region_id].w); /* region width */
-        putbe16(&q, h->rects[region_id].h); /* region height */
-        *q++ = ((1 + bpp_index) << 5) | ((1 + bpp_index) << 2) | 0x03;
-        *q++ = region_id; /* clut_id == region_id */
-        *q++ = 0; /* 8 bit fill colors */
-        *q++ = 0x03; /* 4 bit and 2 bit fill colors */
-
-        if (!s->hide_state) {
-            putbe16(&q, region_id); /* object_id == region_id */
-            *q++ = (0 << 6) | (0 << 4);
-            *q++ = 0;
-            *q++ = 0xf0;
-            *q++ = 0;
-        }
-
-        putbe16(&pseg_len, q - pseg_len - 2);
-    }
-
-    if (!s->hide_state) {
-        
-        for (object_id = 0; object_id < h->num_rects; object_id++) {
-            /* Object Data segment */
-
-            if (h->rects[region_id].nb_colors <= 4) {
-                /* 2 bpp, some decoders do not support it correctly */
-                bpp_index = 0;
-            } else if (h->rects[region_id].nb_colors <= 16) {
-                /* 4 bpp, standard encoding */
-                bpp_index = 1;
-            } else {
-                return -1;
-            }
-
-            *q++ = 0x0f; /* sync byte */
-            *q++ = 0x13;
-            putbe16(&q, page_id);
-            pseg_len = q;
-            q += 2; /* segment length */
-
-            putbe16(&q, object_id);
-            *q++ = (s->object_version << 4) | (0 << 2) | (0 << 1) | 1; /* version = 0,
-                                                                       onject_coding_method,
-                                                                       non_modifying_color_flag */
-            {
-                uint8_t *ptop_field_len, *pbottom_field_len, *top_ptr, *bottom_ptr;
-                void (*dvb_encode_rle)(uint8_t **pq,
-                                        const uint8_t *bitmap, int linesize,
-                                        int w, int h);
-                ptop_field_len = q;
-                q += 2;
-                pbottom_field_len = q;
-                q += 2;
-
-                if (bpp_index == 0)
-                    dvb_encode_rle = dvb_encode_rle2;
-                else
-                    dvb_encode_rle = dvb_encode_rle4;
-
-                top_ptr = q;
-                dvb_encode_rle(&q, h->rects[object_id].bitmap, h->rects[object_id].w * 2,
-                                    h->rects[object_id].w, h->rects[object_id].h >> 1);
-                bottom_ptr = q;
-                dvb_encode_rle(&q, h->rects[object_id].bitmap + h->rects[object_id].w,
-                                    h->rects[object_id].w * 2, h->rects[object_id].w,
-                                    h->rects[object_id].h >> 1);
-
-                putbe16(&ptop_field_len, bottom_ptr - top_ptr);
-                putbe16(&pbottom_field_len, q - bottom_ptr);
-            }
-
-            putbe16(&pseg_len, q - pseg_len - 2);
-        }
-    }
-
-    /* end of display set segment */
-
-    *q++ = 0x0f; /* sync_byte */
-    *q++ = 0x80; /* segment_type */
-    putbe16(&q, page_id);
-    pseg_len = q;
-    q += 2; /* segment length */
-
-    putbe16(&pseg_len, q - pseg_len - 2);
-
-    *q++ = 0xff; /* end of PES data */
-
-    s->object_version = (s->object_version + 1) & 0xf;
-    s->hide_state = !s->hide_state;
-    return q - outbuf;
-}
-
-static int dvbsub_init_decoder(AVCodecContext *avctx)
-{
-    return 0;
-}
-
-static int dvbsub_close_decoder(AVCodecContext *avctx)
-{
-    return 0;
-}
-
-static int dvbsub_encode(AVCodecContext *avctx,
-                       unsigned char *buf, int buf_size, void *data)
-{
-    DVBSubtitleContext *s = avctx->priv_data;
-    AVSubtitle *sub = data;
-    int ret;
-
-    ret = encode_dvb_subtitles(s, buf, sub);
-    return ret;
-}
-
-AVCodec dvbsub_encoder = {
-    "dvbsub",
-    CODEC_TYPE_SUBTITLE,
-    CODEC_ID_DVB_SUBTITLE,
-    sizeof(DVBSubtitleContext),
-    dvbsub_init_decoder,
-    dvbsub_encode,
-    dvbsub_close_decoder,
-};
diff --git a/ffmpeg.src/libavcodec/dvbsubdec.c b/ffmpeg.src/libavcodec/dvbsubdec.c
deleted file mode 100644
index 5504ac2..0000000
--- a/ffmpeg.src/libavcodec/dvbsubdec.c
+++ /dev/null
@@ -1,1631 +0,0 @@
-/*
- * DVB subtitle decoding for ffmpeg
- * Copyright (c) 2005 Ian Caulfield.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avcodec.h"
-#include "dsputil.h"
-#include "bitstream.h"
-
-//#define DEBUG
-//#define DEBUG_PACKET_CONTENTS
-//#define DEBUG_SAVE_IMAGES
-
-#define DVBSUB_PAGE_SEGMENT     0x10
-#define DVBSUB_REGION_SEGMENT   0x11
-#define DVBSUB_CLUT_SEGMENT     0x12
-#define DVBSUB_OBJECT_SEGMENT   0x13
-#define DVBSUB_DISPLAY_SEGMENT  0x80
-
-static unsigned char *cm;
-
-#ifdef DEBUG_SAVE_IMAGES
-#undef fprintf
-#if 0
-static void png_save(const char *filename, uint8_t *bitmap, int w, int h,
-                     uint32_t *rgba_palette)
-{
-    int x, y, v;
-    FILE *f;
-    char fname[40], fname2[40];
-    char command[1024];
-    
-    snprintf(fname, 40, "%s.ppm", filename);
-
-    f = fopen(fname, "w");
-    if (!f) {
-        perror(fname);
-        exit(1);
-    }
-    fprintf(f, "P6\n"
-            "%d %d\n"
-            "%d\n",
-            w, h, 255);
-    for(y = 0; y < h; y++) {
-        for(x = 0; x < w; x++) {
-            v = rgba_palette[bitmap[y * w + x]];
-            putc((v >> 16) & 0xff, f);
-            putc((v >> 8) & 0xff, f);
-            putc((v >> 0) & 0xff, f);
-        }
-    }
-    fclose(f);
-    
-    
-    snprintf(fname2, 40, "%s-a.pgm", filename);
-
-    f = fopen(fname2, "w");
-    if (!f) {
-        perror(fname2);
-        exit(1);
-    }
-    fprintf(f, "P5\n"
-            "%d %d\n"
-            "%d\n",
-            w, h, 255);
-    for(y = 0; y < h; y++) {
-        for(x = 0; x < w; x++) {
-            v = rgba_palette[bitmap[y * w + x]];
-            putc((v >> 24) & 0xff, f);
-        }
-    }
-    fclose(f);
-    
-    snprintf(command, 1024, "pnmtopng -alpha %s %s > %s.png 2> /dev/null", fname2, fname, filename);
-    system(command);
-    
-    snprintf(command, 1024, "rm %s %s", fname, fname2);
-    system(command);
-}
-#endif
-
-static void png_save2(const char *filename, uint32_t *bitmap, int w, int h)
-{
-    int x, y, v;
-    FILE *f;
-    char fname[40], fname2[40];
-    char command[1024];
-    
-    snprintf(fname, 40, "%s.ppm", filename);
-
-    f = fopen(fname, "w");
-    if (!f) {
-        perror(fname);
-        exit(1);
-    }
-    fprintf(f, "P6\n"
-            "%d %d\n"
-            "%d\n",
-            w, h, 255);
-    for(y = 0; y < h; y++) {
-        for(x = 0; x < w; x++) {
-            v = bitmap[y * w + x];
-            putc((v >> 16) & 0xff, f);
-            putc((v >> 8) & 0xff, f);
-            putc((v >> 0) & 0xff, f);
-        }
-    }
-    fclose(f);
-    
-    
-    snprintf(fname2, 40, "%s-a.pgm", filename);
-
-    f = fopen(fname2, "w");
-    if (!f) {
-        perror(fname2);
-        exit(1);
-    }
-    fprintf(f, "P5\n"
-            "%d %d\n"
-            "%d\n",
-            w, h, 255);
-    for(y = 0; y < h; y++) {
-        for(x = 0; x < w; x++) {
-            v = bitmap[y * w + x];
-            putc((v >> 24) & 0xff, f);
-        }
-    }
-    fclose(f);
-    
-    snprintf(command, 1024, "pnmtopng -alpha %s %s > %s.png 2> /dev/null", fname2, fname, filename);
-    system(command);
-    
-    snprintf(command, 1024, "rm %s %s", fname, fname2);
-    system(command);
-}
-#endif
-
-#define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
-
-typedef struct DVBSubCLUT {
-    int id;
-
-    uint32_t clut4[4];
-    uint32_t clut16[16];
-    uint32_t clut256[256];
-    
-    struct DVBSubCLUT *next;
-} DVBSubCLUT;
-
-static DVBSubCLUT default_clut;
-
-typedef struct DVBSubObjectDisplay {
-    int object_id;
-    int region_id;
-
-    int x_pos;
-    int y_pos;
-
-    int fgcolour;
-    int bgcolour;
-    
-    struct DVBSubObjectDisplay *region_list_next;
-    struct DVBSubObjectDisplay *object_list_next;   
-} DVBSubObjectDisplay;
-
-typedef struct DVBSubObject {
-    int id;
-
-    int type;
-    
-    DVBSubObjectDisplay *display_list;   
-    
-    struct DVBSubObject *next;
-} DVBSubObject;
-
-typedef struct DVBSubRegionDisplay {
-    int region_id;
-
-    int x_pos;
-    int y_pos;
-
-    struct DVBSubRegionDisplay *next;
-} DVBSubRegionDisplay;
-
-typedef struct DVBSubRegion {
-    int id;
-
-    int width;
-    int height;
-    int depth;
-    
-    int clut;
-    int bgcolour;
-    
-    uint8_t *pbuf;
-    int buf_size;
-
-    DVBSubObjectDisplay *display_list;
-    
-    struct DVBSubRegion *next;
-} DVBSubRegion;
-
-typedef struct DVBSubContext {
-    int composition_id;
-    int ancillary_id;
-
-    int time_out;
-    DVBSubRegion *region_list;
-    DVBSubCLUT   *clut_list;
-    DVBSubObject *object_list;
-    
-    int display_list_size;
-    DVBSubRegionDisplay *display_list;
-} DVBSubContext;
-
-
-static DVBSubObject* get_object(DVBSubContext *ctx, int object_id)
-{
-    DVBSubObject *ptr = ctx->object_list;
-
-    while (ptr != NULL && ptr->id != object_id) {
-        ptr = ptr->next;
-    }
-    
-    return ptr;
-}
-
-static DVBSubCLUT* get_clut(DVBSubContext *ctx, int clut_id)
-{
-    DVBSubCLUT *ptr = ctx->clut_list;
-
-    while (ptr != NULL && ptr->id != clut_id) {
-        ptr = ptr->next;
-    }
-    
-    return ptr;
-}
-
-static DVBSubRegion* get_region(DVBSubContext *ctx, int region_id)
-{
-    DVBSubRegion *ptr = ctx->region_list;
-
-    while (ptr != NULL && ptr->id != region_id) {
-        ptr = ptr->next;
-    }
-    
-    return ptr;
-}
-
-static void delete_region_display_list(DVBSubContext *ctx, DVBSubRegion *region)
-{
-    DVBSubObject *object, *obj2, **obj2_ptr;
-    DVBSubObjectDisplay *display, *obj_disp, **obj_disp_ptr;
-
-    while (region->display_list != NULL) {
-        display = region->display_list;
-        
-        object = get_object(ctx, display->object_id);
-        
-        if (object != NULL) {
-            obj_disp = object->display_list;
-            obj_disp_ptr = &object->display_list;
-            
-            while (obj_disp != NULL && obj_disp != display) {
-                obj_disp_ptr = &obj_disp->object_list_next;
-                obj_disp = obj_disp->object_list_next;
-            }
-                
-            if (obj_disp) {
-                *obj_disp_ptr = obj_disp->object_list_next;
-                
-                if (object->display_list == NULL) {
-                    obj2 = ctx->object_list;
-                    obj2_ptr = &ctx->object_list;
-
-                    while (obj2 != NULL && obj2 != object) {
-                        obj2_ptr = &obj2->next;
-                        obj2 = obj2->next;
-                    }
-                    
-                    *obj2_ptr = obj2->next;
-                    
-                    av_free(obj2);
-                }
-            }
-        }
-        
-        region->display_list = display->region_list_next;
-        
-        av_free(display);
-    }
-                
-}
-
-static void delete_state(DVBSubContext *ctx)
-{
-    DVBSubRegion *region;
-    DVBSubCLUT *clut;
-    
-    while (ctx->region_list != NULL)
-    {
-        region = ctx->region_list;
-
-        ctx->region_list = region->next;
-
-        delete_region_display_list(ctx, region);
-        if (region->pbuf != NULL)
-            av_free(region->pbuf);
-
-        av_free(region);
-    }
-
-    while (ctx->clut_list != NULL)
-    {
-        clut = ctx->clut_list;
-
-        ctx->clut_list = clut->next;
-
-        av_free(clut);
-    }
-
-    /* Should already be null */
-    if (ctx->object_list != NULL)
-        av_log(0, AV_LOG_ERROR, "Memory deallocation error!\n");
-}
-
-static int dvbsub_init_decoder(AVCodecContext *avctx)
-{
-    int i, r, g, b, a = 0;
-    DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
-
-    cm = cropTbl + MAX_NEG_CROP;
-
-    memset(avctx->priv_data, 0, sizeof(DVBSubContext));
-    
-    ctx->composition_id = avctx->sub_id & 0xffff;
-    ctx->ancillary_id = avctx->sub_id >> 16;
-
-    default_clut.id = -1;
-    default_clut.next = NULL;
-
-    default_clut.clut4[0] = RGBA(  0,   0,   0,   0);
-    default_clut.clut4[1] = RGBA(255, 255, 255, 255);
-    default_clut.clut4[2] = RGBA(  0,   0,   0, 255);
-    default_clut.clut4[3] = RGBA(127, 127, 127, 255);
-
-    default_clut.clut16[0] = RGBA(  0,   0,   0,   0);
-    for (i = 1; i < 16; i++) {
-        if (i < 8) {
-            r = (i & 1) ? 255 : 0;
-            g = (i & 2) ? 255 : 0;
-            b = (i & 4) ? 255 : 0;
-        } else {
-            r = (i & 1) ? 127 : 0;
-            g = (i & 2) ? 127 : 0;
-            b = (i & 4) ? 127 : 0;
-        }           
-        default_clut.clut16[i] = RGBA(r, g, b, 255);
-    }
-
-    default_clut.clut256[0] = RGBA(  0,   0,   0,   0);
-    for (i = 1; i < 256; i++) {
-        if (i < 8) {
-            r = (i & 1) ? 255 : 0;
-            g = (i & 2) ? 255 : 0;
-            b = (i & 4) ? 255 : 0;
-            a = 63;
-        } else {
-            switch (i & 0x88) {
-            case 0x00:
-                r = ((i & 1) ? 85 : 0) + ((i & 0x10) ? 170 : 0);
-                g = ((i & 2) ? 85 : 0) + ((i & 0x20) ? 170 : 0);
-                b = ((i & 4) ? 85 : 0) + ((i & 0x40) ? 170 : 0);
-                a = 255;
-                break;
-            case 0x08:
-                r = ((i & 1) ? 85 : 0) + ((i & 0x10) ? 170 : 0);
-                g = ((i & 2) ? 85 : 0) + ((i & 0x20) ? 170 : 0);
-                b = ((i & 4) ? 85 : 0) + ((i & 0x40) ? 170 : 0);
-                a = 127;
-                break;
-            case 0x80:
-                r = 127 + ((i & 1) ? 43 : 0) + ((i & 0x10) ? 85 : 0);
-                g = 127 + ((i & 2) ? 43 : 0) + ((i & 0x20) ? 85 : 0);
-                b = 127 + ((i & 4) ? 43 : 0) + ((i & 0x40) ? 85 : 0);
-                a = 255;
-                break;
-            case 0x88:
-                r = ((i & 1) ? 43 : 0) + ((i & 0x10) ? 85 : 0);
-                g = ((i & 2) ? 43 : 0) + ((i & 0x20) ? 85 : 0);
-                b = ((i & 4) ? 43 : 0) + ((i & 0x40) ? 85 : 0);
-                a = 255;
-                break;
-            }
-        }           
-        default_clut.clut256[i] = RGBA(r, g, b, a);
-    }
-
-    return 0;
-}
-
-static int dvbsub_close_decoder(AVCodecContext *avctx)
-{
-    DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
-    DVBSubRegionDisplay *display;
-
-    delete_state(ctx);
-    
-    while (ctx->display_list != NULL)
-    {
-        display = ctx->display_list;
-        ctx->display_list = display->next;
-        
-        av_free(display);
-    }
-
-    return 0;
-}
-
-static int dvbsub_read_2bit_string(uint8_t *destbuf, int dbuf_len, 
-                                   uint8_t **srcbuf, int buf_size, 
-                                   int non_mod, uint8_t *map_table)
-{
-    GetBitContext gb;
-    
-    int bits;
-    int run_length;
-    int pixels_read = 0;
-    
-    init_get_bits(&gb, *srcbuf, buf_size << 8);
-    
-    while (get_bits_count(&gb) < (buf_size << 8) && pixels_read < dbuf_len) {
-        bits = get_bits(&gb, 2);
-
-        if (bits != 0) {
-            if (non_mod != 1 || bits != 1) {
-                if (map_table != NULL)
-                    *destbuf++ = map_table[bits];
-                else
-                    *destbuf++ = bits;
-            }
-            pixels_read++;
-        } else {
-            bits = get_bits(&gb, 1);
-            if (bits == 1) {
-                run_length = get_bits(&gb, 3) + 3;
-                bits = get_bits(&gb, 2);
-                
-                if (non_mod == 1 && bits == 1)
-                    pixels_read += run_length;
-                else {
-                    if (map_table != NULL)
-                        bits = map_table[bits];
-                    while (run_length-- > 0 && pixels_read < dbuf_len) {
-                        *destbuf++ = bits;
-                        pixels_read++;
-                    }
-                }
-            } else {
-                bits = get_bits(&gb, 1);
-                if (bits == 0) {
-                    bits = get_bits(&gb, 2);
-                    if (bits == 2) {
-                        run_length = get_bits(&gb, 4) + 12;
-                        bits = get_bits(&gb, 2);
-
-                        if (non_mod == 1 && bits == 1)
-                            pixels_read += run_length;
-                        else {
-                            if (map_table != NULL)
-                                bits = map_table[bits];
-                            while (run_length-- > 0 && pixels_read < dbuf_len) {
-                                *destbuf++ = bits;
-                                pixels_read++;
-                            }
-                        }
-                    } else if (bits == 3) {
-                        run_length = get_bits(&gb, 8) + 29;
-                        bits = get_bits(&gb, 2);
-
-                        if (non_mod == 1 && bits == 1)
-                            pixels_read += run_length;
-                        else {
-                            if (map_table != NULL)
-                                bits = map_table[bits];
-                            while (run_length-- > 0 && pixels_read < dbuf_len) {
-                                *destbuf++ = bits;
-                                pixels_read++;
-                            }
-                        }
-                    } else if (bits == 1) {
-                        pixels_read += 2;
-                        if (map_table != NULL)
-                            bits = map_table[0];
-                        else
-                            bits = 0;
-                        if (pixels_read <= dbuf_len) {
-                            *destbuf++ = bits;
-                            *destbuf++ = bits;
-                        }
-                    } else {
-                        (*srcbuf) += (get_bits_count(&gb) + 7) >> 3;
-                        return pixels_read;
-                    }
-                } else {
-                    if (map_table != NULL)
-                        bits = map_table[0];
-                    else
-                        bits = 0;
-                    *destbuf++ = bits;
-                    pixels_read++;
-                }
-            }
-        }
-    }
-    
-    if (get_bits(&gb, 6) != 0)
-        av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n");
-
-    (*srcbuf) += (get_bits_count(&gb) + 7) >> 3;
-
-    return pixels_read;
-}
-    
-static int dvbsub_read_4bit_string(uint8_t *destbuf, int dbuf_len, 
-                                   uint8_t **srcbuf, int buf_size, 
-                                   int non_mod, uint8_t *map_table)
-{
-    GetBitContext gb;
-        
-    int bits;
-    int run_length;
-    int pixels_read = 0;
-    
-    init_get_bits(&gb, *srcbuf, buf_size << 8);    
-    
-    while (get_bits_count(&gb) < (buf_size << 8) && pixels_read < dbuf_len) {
-        bits = get_bits(&gb, 4);
-
-        if (bits != 0) {
-            if (non_mod != 1 || bits != 1) {
-                if (map_table != NULL)
-                    *destbuf++ = map_table[bits];
-                else
-                    *destbuf++ = bits;
-            }
-            pixels_read++;
-        } else {
-            bits = get_bits(&gb, 1);
-            if (bits == 0) {
-                run_length = get_bits(&gb, 3);
-                
-                if (run_length == 0) {
-                    (*srcbuf) += (get_bits_count(&gb) + 7) >> 3;
-                    return pixels_read;
-                }
-                    
-                run_length += 2;
-                
-                if (map_table != NULL)
-                    bits = map_table[0];
-                else
-                    bits = 0;
-                
-                while (run_length-- > 0 && pixels_read < dbuf_len) {
-                    *destbuf++ = bits;
-                    pixels_read++;
-                }
-            } else {
-                bits = get_bits(&gb, 1);
-                if (bits == 0) {
-                    run_length = get_bits(&gb, 2) + 4;
-                    bits = get_bits(&gb, 4);
-
-                    if (non_mod == 1 && bits == 1)
-                        pixels_read += run_length;
-                    else {
-                        if (map_table != NULL)
-                            bits = map_table[bits];
-                        while (run_length-- > 0 && pixels_read < dbuf_len) {
-                            *destbuf++ = bits;
-                            pixels_read++;
-                        }
-                    }
-                } else {
-                    bits = get_bits(&gb, 2);
-                    if (bits == 2) {
-                        run_length = get_bits(&gb, 4) + 9;
-                        bits = get_bits(&gb, 4);
-                        
-                        if (non_mod == 1 && bits == 1)
-                            pixels_read += run_length;
-                        else {
-                            if (map_table != NULL)
-                                bits = map_table[bits];
-                            while (run_length-- > 0 && pixels_read < dbuf_len) {
-                                *destbuf++ = bits;
-                                pixels_read++;
-                            }
-                        }
-                    } else if (bits == 3) {
-                        run_length = get_bits(&gb, 8) + 25;
-                        bits = get_bits(&gb, 4);
-
-                        if (non_mod == 1 && bits == 1)
-                            pixels_read += run_length;
-                        else {
-                            if (map_table != NULL)
-                                bits = map_table[bits];
-                            while (run_length-- > 0 && pixels_read < dbuf_len) {
-                                *destbuf++ = bits;
-                                pixels_read++;
-                            }
-                        }
-                    } else if (bits == 1) {
-                        pixels_read += 2;
-                        if (map_table != NULL)
-                            bits = map_table[0];
-                        else
-                            bits = 0;
-                        if (pixels_read <= dbuf_len) {
-                            *destbuf++ = bits;
-                            *destbuf++ = bits;
-                        }
-                    } else {
-                        if (map_table != NULL)
-                            bits = map_table[0];
-                        else
-                            bits = 0;
-                        *destbuf++ = bits;
-                        pixels_read ++;
-                    }
-                }
-            }
-        }
-    }
-    
-    if (get_bits(&gb, 8) != 0)
-        av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n");
-    
-    (*srcbuf) += (get_bits_count(&gb) + 7) >> 3;
-
-    return pixels_read;
-}
-    
-static int dvbsub_read_8bit_string(uint8_t *destbuf, int dbuf_len, 
-                                    uint8_t **srcbuf, int buf_size, 
-                                    int non_mod, uint8_t *map_table)
-{
-    uint8_t *sbuf_end = (*srcbuf) + buf_size;
-    int bits;
-    int run_length;
-    int pixels_read = 0;
-     
-    while (*srcbuf < sbuf_end && pixels_read < dbuf_len) {
-        bits = *(*srcbuf)++;
-    
-        if (bits != 0) {
-            if (non_mod != 1 || bits != 1) {
-                if (map_table != NULL)
-                    *destbuf++ = map_table[bits];
-                else
-                    *destbuf++ = bits;
-            }
-            pixels_read++;
-        } else {
-            bits = *(*srcbuf)++;
-            run_length = bits & 0x7f;
-            if ((bits & 0x80) == 0) {
-                if (run_length == 0) {
-                    return pixels_read;
-                }
-                                    
-                if (map_table != NULL)
-                    bits = map_table[0];
-                else
-                    bits = 0;
-                while (run_length-- > 0 && pixels_read < dbuf_len) {
-                    *destbuf++ = bits;
-                    pixels_read++;
-                }
-            } else {
-                bits = *(*srcbuf)++;
-
-                if (non_mod == 1 && bits == 1)
-                    pixels_read += run_length;
-                if (map_table != NULL)
-                    bits = map_table[bits];
-                else while (run_length-- > 0 && pixels_read < dbuf_len) {
-                    *destbuf++ = bits;
-                    pixels_read++;
-                }
-            }
-        }
-    }
-    
-    if (*(*srcbuf)++ != 0)
-        av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n");
-    
-    return pixels_read;
-}
-    
-
-
-static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDisplay *display,
-                                          uint8_t *buf, int buf_size, int top_bottom, int non_mod)
-{
-    DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
-
-    DVBSubRegion *region = get_region(ctx, display->region_id);
-    uint8_t *buf_end = buf + buf_size;
-    uint8_t *pbuf;
-    int x_pos, y_pos;
-    int i;
-    
-    uint8_t map2to4[] = { 0x0,  0x7,  0x8,  0xf};
-    uint8_t map2to8[] = {0x00, 0x77, 0x88, 0xff};
-    uint8_t map4to8[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 
-                         0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
-    uint8_t *map_table;
-    
-#ifdef DEBUG
-    av_log(avctx, AV_LOG_INFO, "DVB pixel block size %d, %s field:\n", buf_size,
-                top_bottom ? "bottom" : "top");
-#endif
-
-#ifdef DEBUG_PACKET_CONTENTS
-    for (i = 0; i < buf_size; i++)
-    {
-        if (i % 16 == 0)
-            av_log(avctx, AV_LOG_INFO, "0x%08p: ", buf+i);
-
-        av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]);
-        if (i % 16 == 15)
-            av_log(avctx, AV_LOG_INFO, "\n");
-    }
-    
-    if (i % 16 != 0)
-        av_log(avctx, AV_LOG_INFO, "\n");
-
-#endif
-
-    if (region == 0)
-        return;
-    
-    pbuf = region->pbuf;
-    
-    x_pos = display->x_pos;
-    y_pos = display->y_pos;
-    
-    if ((y_pos & 1) != top_bottom)
-        y_pos++;
-
-    while (buf < buf_end) {
-        if (x_pos > region->width || y_pos > region->height) {
-            av_log(avctx, AV_LOG_ERROR, "Invalid object location!\n");
-            return;
-        }
-        
-        switch (*buf++) {
-        case 0x10:
-            if (region->depth == 8)
-                map_table = map2to8;
-            else if (region->depth == 4)
-                map_table = map2to4;
-            else
-                map_table = NULL;
-                
-            x_pos += dvbsub_read_2bit_string(pbuf + (y_pos * region->width) + x_pos, 
-                                                region->width - x_pos, &buf, buf_size, 
-                                                non_mod, map_table);
-            break;
-        case 0x11:
-            if (region->depth < 4) {
-                av_log(avctx, AV_LOG_ERROR, "4-bit pixel string in %d-bit region!\n", region->depth);
-                return;
-            }
-                
-            if (region->depth == 8)
-                map_table = map4to8;
-            else
-                map_table = NULL;
-                
-            x_pos += dvbsub_read_4bit_string(pbuf + (y_pos * region->width) + x_pos, 
-                                                region->width - x_pos, &buf, buf_size, 
-                                                non_mod, map_table);
-            break;
-        case 0x12:
-            if (region->depth < 8) {
-                av_log(avctx, AV_LOG_ERROR, "8-bit pixel string in %d-bit region!\n", region->depth);
-                return;
-            }
-                
-            x_pos += dvbsub_read_8bit_string(pbuf + (y_pos * region->width) + x_pos, 
-                                                region->width - x_pos, &buf, buf_size, 
-                                                non_mod, NULL);
-            break;
-            
-        case 0x20:
-            map2to4[0] = (*buf) >> 4;
-            map2to4[1] = (*buf++) & 0xf;
-            map2to4[2] = (*buf) >> 4;
-            map2to4[3] = (*buf++) & 0xf;
-            break;
-        case 0x21:
-            for (i = 0; i < 4; i++)
-                map2to8[i] = *buf++;
-            break;
-        case 0x22:
-            for (i = 0; i < 16; i++)
-                map4to8[i] = *buf++;
-            break;
-            
-        case 0xf0:
-            x_pos = display->x_pos;
-            y_pos += 2;
-            break;
-        default:
-            av_log(avctx, AV_LOG_INFO, "Unknown/unsupported pixel block 0x%x\n", *(buf-1));
-        }
-    }
-    
-}
-
-static void dvbsub_parse_object_segment(AVCodecContext *avctx,
-                                        uint8_t *buf, int buf_size)
-{
-    DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
-    
-    uint8_t *buf_end = buf + buf_size;
-    uint8_t *block;
-    int object_id;
-    DVBSubObject *object;
-    DVBSubObjectDisplay *display;
-    int top_field_len, bottom_field_len;
-    
-    int coding_method, non_modifying_colour;
-    
-    object_id = BE_16(buf);
-    buf += 2;
-    
-    object = get_object(ctx, object_id);
-
-    if (!object) 
-        return; 
-    
-    coding_method = ((*buf) >> 2) & 3;
-    non_modifying_colour = ((*buf++) >> 1) & 1;
-    
-    if (coding_method == 0) {
-        top_field_len = BE_16(buf);
-        buf += 2;
-        bottom_field_len = BE_16(buf);
-        buf += 2;
-        
-        if (buf + top_field_len + bottom_field_len > buf_end) {
-            av_log(avctx, AV_LOG_ERROR, "Field data size too large\n");
-            return;
-        }       
-        
-        for (display = object->display_list; display != 0; display = display->object_list_next) {
-            block = buf;
-
-            dvbsub_parse_pixel_data_block(avctx, display, block, top_field_len, 0,
-                                            non_modifying_colour);
-
-            if (bottom_field_len > 0)
-                block = buf + top_field_len;
-            else
-                bottom_field_len = top_field_len;
-
-            dvbsub_parse_pixel_data_block(avctx, display, block, bottom_field_len, 1,
-                                            non_modifying_colour);
-        }
-        
-/*  } else if (coding_method == 1) {*/
-        
-    } else {
-        av_log(avctx, AV_LOG_ERROR, "Unknown object coding %d\n", coding_method);
-    }
-    
-}
-
-#define SCALEBITS 10
-#define ONE_HALF  (1 << (SCALEBITS - 1))
-#define FIX(x)    ((int) ((x) * (1<<SCALEBITS) + 0.5))
-
-#define YUV_TO_RGB1_CCIR(cb1, cr1)\
-{\
-    cb = (cb1) - 128;\
-    cr = (cr1) - 128;\
-    r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;\
-    g_add = - FIX(0.34414*255.0/224.0) * cb - FIX(0.71414*255.0/224.0) * cr + \
-            ONE_HALF;\
-    b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;\
-}
-
-#define YUV_TO_RGB2_CCIR(r, g, b, y1)\
-{\
-    y = ((y1) - 16) * FIX(255.0/219.0);\
-    r = cm[(y + r_add) >> SCALEBITS];\
-    g = cm[(y + g_add) >> SCALEBITS];\
-    b = cm[(y + b_add) >> SCALEBITS];\
-}
-
-
-static void dvbsub_parse_clut_segment(AVCodecContext *avctx,
-                                        uint8_t *buf, int buf_size)
-{
-    DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
-    
-    uint8_t *buf_end = buf + buf_size;
-    int clut_id;
-    DVBSubCLUT *clut;
-    int entry_id, depth , full_range;
-    int y, cr, cb, alpha;
-    int r, g, b, r_add, g_add, b_add;
-
-#ifdef DEBUG_PACKET_CONTENTS
-    int i;
-
-    av_log(avctx, AV_LOG_INFO, "DVB clut packet:\n");
-
-    for (i=0; i < buf_size; i++)
-    {
-        av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]);
-        if (i % 16 == 15)
-            av_log(avctx, AV_LOG_INFO, "\n");
-    }
-    
-    if (i % 16 != 0)
-        av_log(avctx, AV_LOG_INFO, "\n");
-
-#endif
-
-    clut_id = *buf++;
-    buf += 1;
-    
-    clut = get_clut(ctx, clut_id);
-    
-    if (clut == NULL) {
-        clut = av_malloc(sizeof(DVBSubCLUT));
-        
-        memcpy(clut, &default_clut, sizeof(DVBSubCLUT));
-
-        clut->id = clut_id;
-        
-        clut->next = ctx->clut_list;        
-        ctx->clut_list = clut;
-    }
-            
-    while (buf + 4 < buf_end)
-    {
-        entry_id = *buf++;
-        
-        depth = (*buf) & 0xe0;
-                    
-        if (depth == 0) {
-            av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf);
-            return;
-        }
-        
-        full_range = (*buf++) & 1;
-        
-        if (full_range) {
-            y = *buf++;
-            cr = *buf++;
-            cb = *buf++;
-            alpha = *buf++;
-        } else {
-            y = buf[0] & 0xfc;
-            cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4;
-            cb = (buf[1] << 2) & 0xf0;
-            alpha = (buf[1] << 6) & 0xc0;
-            
-            buf += 2;
-        }
-        
-        if (y == 0)
-            alpha = 0xff;
-        
-        YUV_TO_RGB1_CCIR(cb, cr);
-        YUV_TO_RGB2_CCIR(r, g, b, y);
-        
-#ifdef DEBUG
-        av_log(avctx, AV_LOG_INFO, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha);
-#endif
-        
-        if (depth & 0x80)
-            clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha);
-        if (depth & 0x40)
-            clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha);
-        if (depth & 0x20)
-            clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha);
-    }
-}
-
-
-static void dvbsub_parse_region_segment(AVCodecContext *avctx,
-                                        uint8_t *buf, int buf_size)
-{
-    DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
-    
-    uint8_t *buf_end = buf + buf_size;
-    int region_id, object_id;
-    DVBSubRegion *region;
-    DVBSubObject *object;
-    DVBSubObjectDisplay *display;
-    int fill;
-    
-    if (buf_size < 10)
-        return;
-    
-    region_id = *buf++;
-    
-    region = get_region(ctx, region_id);
-    
-    if (region == NULL)
-    {
-        region = av_mallocz(sizeof(DVBSubRegion));
-        
-        region->id = region_id;
-        
-        region->next = ctx->region_list;
-        ctx->region_list = region;
-    }
-        
-    fill = ((*buf++) >> 3) & 1;
-    
-    region->width = BE_16(buf);
-    buf += 2;
-    region->height = BE_16(buf);
-    buf += 2;
-    
-    if (region->width * region->height != region->buf_size) {
-        if (region->pbuf != 0)
-            av_free(region->pbuf);
-    
-        region->buf_size = region->width * region->height;
-        
-        region->pbuf = av_malloc(region->buf_size);
-        
-        fill = 1;
-    }
-    
-    region->depth = 1 << (((*buf++) >> 2) & 7);
-    region->clut = *buf++;
-        
-    if (region->depth == 8)
-        region->bgcolour = *buf++;
-    else {
-        buf += 1;
-        
-        if (region->depth == 4)
-            region->bgcolour = (((*buf++) >> 4) & 15);
-        else
-            region->bgcolour = (((*buf++) >> 2) & 3);
-    }
-
-#ifdef DEBUG
-    av_log(avctx, AV_LOG_INFO, "Region %d, (%dx%d)\n", region_id, region->width, region->height);
-#endif
-
-    if (fill) {
-        memset(region->pbuf, region->bgcolour, region->buf_size);
-#ifdef DEBUG
-        av_log(avctx, AV_LOG_INFO, "Fill region (%d)\n", region->bgcolour);
-#endif
-    }
-
-    delete_region_display_list(ctx, region);
-
-    while (buf + 5 < buf_end) {
-        object_id = BE_16(buf);
-        buf += 2;
-                
-        object = get_object(ctx, object_id);
-
-        if (object == NULL) {
-            object = av_mallocz(sizeof(DVBSubObject));
-            
-            object->id = object_id;
-            object->next = ctx->object_list;
-            ctx->object_list = object;
-        }
-        
-        object->type = (*buf) >> 6;
-        
-        display = av_mallocz(sizeof(DVBSubObjectDisplay));
-        
-        display->object_id = object_id;
-        display->region_id = region_id;
-        
-        display->x_pos = BE_16(buf) & 0xfff;
-        buf += 2;
-        display->y_pos = BE_16(buf) & 0xfff;
-        buf += 2;
-        
-        if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {
-            display->fgcolour = *buf++;
-            display->bgcolour = *buf++;
-        }
-        
-        display->region_list_next = region->display_list;
-        region->display_list = display;
-        
-        display->object_list_next = object->display_list;
-        object->display_list = display;
-    }
-}
-
-static void dvbsub_parse_page_segment(AVCodecContext *avctx,
-                                        uint8_t *buf, int buf_size)
-{
-    DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
-    DVBSubRegionDisplay *display;
-    DVBSubRegionDisplay *tmp_display_list, **tmp_ptr;
-    
-    uint8_t *buf_end = buf + buf_size;
-    int region_id;
-    int page_state;
-     
-    if (buf_size < 1)
-        return;
-    
-    ctx->time_out = *buf++;
-    page_state = ((*buf++) >> 2) & 3;
-    
-#ifdef DEBUG
-    av_log(avctx, AV_LOG_INFO, "Page time out %ds, state %d\n", ctx->time_out, page_state);
-#endif
-
-    if (page_state == 2)
-    {
-        delete_state(ctx);
-    }
-    
-    tmp_display_list = ctx->display_list;
-    ctx->display_list = NULL;
-    ctx->display_list_size = 0;
-    
-    while (buf + 5 < buf_end) {
-        region_id = *buf++;
-        buf += 1;
-        
-        display = tmp_display_list;
-        tmp_ptr = &tmp_display_list;
-        
-        while (display != NULL && display->region_id != region_id) {
-            tmp_ptr = &display->next;
-            display = display->next;
-        }
-            
-        if (display == NULL)
-            display = av_mallocz(sizeof(DVBSubRegionDisplay));
-        
-        display->region_id = region_id;
-        
-        display->x_pos = BE_16(buf);
-        buf += 2;
-        display->y_pos = BE_16(buf);
-        buf += 2;
-        
-        *tmp_ptr = display->next;
-        
-        display->next = ctx->display_list;
-        ctx->display_list = display;
-        ctx->display_list_size++;
-        
-#ifdef DEBUG
-        av_log(avctx, AV_LOG_INFO, "Region %d, (%d,%d)\n", region_id, display->x_pos, display->y_pos);
-#endif
-    }
-    
-    while (tmp_display_list != 0) {
-        display = tmp_display_list;
-        
-        tmp_display_list = display->next;
-        
-        av_free(display);
-    }
-    
-}
-
-
-#ifdef DEBUG_SAVE_IMAGES
-static void save_display_set(DVBSubContext *ctx)
-{
-    DVBSubRegion *region;
-    DVBSubRegionDisplay *display;
-    DVBSubCLUT *clut;
-    uint32_t *clut_table;
-    int x_pos, y_pos, width, height;
-    int x, y, y_off, x_off;
-    uint32_t *pbuf;
-    char filename[32];
-    static int fileno_index = 0;
-
-    x_pos = -1;
-    y_pos = -1;
-    width = 0;
-    height = 0;
-    
-    for (display = ctx->display_list; display != NULL; display = display->next) {
-        region = get_region(ctx, display->region_id);
-    
-        if (x_pos == -1) {
-            x_pos = display->x_pos;
-            y_pos = display->y_pos;
-            width = region->width;
-            height = region->height;
-        } else {
-            if (display->x_pos < x_pos) {
-                width += (x_pos - display->x_pos);
-                x_pos = display->x_pos;
-            }
-            
-            if (display->y_pos < y_pos) {
-                height += (y_pos - display->y_pos);
-                y_pos = display->y_pos;
-            }
-            
-            if (display->x_pos + region->width > x_pos + width) {
-                width = display->x_pos + region->width - x_pos;
-            }
-            
-            if (display->y_pos + region->height > y_pos + height) {
-                height = display->y_pos + region->height - y_pos;
-            }
-        }
-    }
-    
-    if (x_pos >= 0) {
-    
-        pbuf = av_malloc(width * height * 4);
-
-        for (display = ctx->display_list; display != NULL; display = display->next) {
-            region = get_region(ctx, display->region_id);
-
-            x_off = display->x_pos - x_pos;
-            y_off = display->y_pos - y_pos;
-
-            clut = get_clut(ctx, region->clut);
-
-            if (clut == 0)
-                clut = &default_clut;
-
-            switch (region->depth) {
-            case 2:
-                clut_table = clut->clut4;
-                break;
-            case 8:
-                clut_table = clut->clut256;
-                break;
-            case 4:
-            default:
-                clut_table = clut->clut16;
-                break;
-            }
-        
-            for (y = 0; y < region->height; y++) {
-                for (x = 0; x < region->width; x++) {
-                    pbuf[((y + y_off) * width) + x_off + x] = 
-                        clut_table[region->pbuf[y * region->width + x]];
-                }
-            }
-
-        }   
-
-        snprintf(filename, 32, "dvbs.%d", fileno_index);
-
-        png_save2(filename, pbuf, width, height);
-
-        av_free(pbuf);
-    }
-    
-    fileno_index++;
-}
-#endif
-
-static int dvbsub_display_end_segment(AVCodecContext *avctx, uint8_t *buf, 
-                                        int buf_size, AVSubtitle *sub)
-{
-    DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
-
-    DVBSubRegion *region;
-    DVBSubRegionDisplay *display;
-    AVSubtitleRect *rect;
-    DVBSubCLUT *clut;
-    uint32_t *clut_table;
-    int i;
-    
-    sub->rects = NULL;
-    sub->start_display_time = 0;
-    sub->end_display_time = ctx->time_out * 1000;
-    sub->format = 0;
-
-    sub->num_rects = ctx->display_list_size;
-    
-    if (sub->num_rects > 0)
-        sub->rects = av_mallocz(sizeof(AVSubtitleRect) * sub->num_rects);
-
-    i = 0;
-
-    for (display = ctx->display_list; display != NULL; display = display->next) {
-        region = get_region(ctx, display->region_id);
-        rect = &sub->rects[i];
-        
-        if (region == NULL)
-            continue;
-        
-        rect->x = display->x_pos;
-        rect->y = display->y_pos;
-        rect->w = region->width;
-        rect->h = region->height;
-        rect->nb_colors = 16;
-        rect->linesize = region->width;
-
-        clut = get_clut(ctx, region->clut);
-        
-        if (clut == NULL)
-            clut = &default_clut;
-            
-        switch (region->depth) {
-        case 2:
-            clut_table = clut->clut4;
-            break;
-        case 8:
-            clut_table = clut->clut256;
-            break;
-        case 4:
-        default:
-            clut_table = clut->clut16;
-            break;
-        }
-        
-        rect->rgba_palette = av_malloc((1 << region->depth) * sizeof(uint32_t));
-        memcpy(rect->rgba_palette, clut_table, (1 << region->depth) * sizeof(uint32_t));
-        
-        rect->bitmap = av_malloc(region->buf_size);
-        memcpy(rect->bitmap, region->pbuf, region->buf_size);
-        
-        i++;
-    }
-    
-    sub->num_rects = i;
-    
-#ifdef DEBUG_SAVE_IMAGES
-    save_display_set(ctx);
-#endif
-    
-    return 1;
-}
-
-static int dvbsub_decode(AVCodecContext *avctx,
-                         void *data, int *data_size,
-                         uint8_t *buf, int buf_size)
-{
-    DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data;
-    AVSubtitle *sub = (AVSubtitle*) data;
-    uint8_t *p, *p_end;
-    int segment_type;
-    int page_id;
-    int segment_length;
-  
-#ifdef DEBUG_PACKET_CONTENTS
-    int i;
-
-    av_log(avctx, AV_LOG_INFO, "DVB sub packet:\n");
-
-    for (i=0; i < buf_size; i++)
-    {
-        av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]);
-        if (i % 16 == 15)
-            av_log(avctx, AV_LOG_INFO, "\n");
-    }
-    
-    if (i % 16 != 0)
-        av_log(avctx, AV_LOG_INFO, "\n");
-
-#endif
-
-    if (buf_size <= 2)
-        return -1;
-        
-    p = buf;
-    p_end = buf + buf_size;
-        
-    while (p < p_end && *p == 0x0f)
-    {
-        p += 1;
-        segment_type = *p++;
-        page_id = BE_16(p);
-        p += 2;
-        segment_length = BE_16(p);
-        p += 2;
-        
-        if (page_id == ctx->composition_id || page_id == ctx->ancillary_id) {
-            switch (segment_type) {
-            case DVBSUB_PAGE_SEGMENT:
-                dvbsub_parse_page_segment(avctx, p, segment_length);
-                break;
-            case DVBSUB_REGION_SEGMENT:
-                dvbsub_parse_region_segment(avctx, p, segment_length);
-                break;
-            case DVBSUB_CLUT_SEGMENT:
-                dvbsub_parse_clut_segment(avctx, p, segment_length);
-                break;
-            case DVBSUB_OBJECT_SEGMENT:
-                dvbsub_parse_object_segment(avctx, p, segment_length);
-                break;
-            case DVBSUB_DISPLAY_SEGMENT:
-                *data_size = dvbsub_display_end_segment(avctx, p, segment_length, sub);
-                break;
-            default:
-#ifdef DEBUG
-                av_log(avctx, AV_LOG_INFO, "Subtitling segment type 0x%x, page id %d, length %d\n", 
-                        segment_type, page_id, segment_length);
-#endif
-                break;
-            }
-        }
-
-        p += segment_length;
-    }
-    
-    if (p != p_end)
-    {
-#ifdef DEBUG
-        av_log(avctx, AV_LOG_INFO, "Junk at end of packet\n");
-#endif
-        return -1;
-    }
-
-    return buf_size;
-}
-
-
-AVCodec dvbsub_decoder = {
-    "dvbsub",
-    CODEC_TYPE_SUBTITLE,
-    CODEC_ID_DVB_SUBTITLE,
-    sizeof(DVBSubContext),
-    dvbsub_init_decoder,
-    NULL,
-    dvbsub_close_decoder,
-    dvbsub_decode,
-};
-
-/* Parser (mostly) copied from dvdsub.c */
-
-#define PARSE_BUF_SIZE  (65536)
-
-
-/* parser definition */
-typedef struct DVBSubParseContext {
-    uint8_t *packet_buf;
-    int packet_start;
-    int packet_index;
-    int in_packet;
-} DVBSubParseContext;
-
-static int dvbsub_parse_init(AVCodecParserContext *s)
-{
-    DVBSubParseContext *pc = s->priv_data;
-    pc->packet_buf = av_malloc(PARSE_BUF_SIZE);
-
-    return 0;
-}
-
-static int dvbsub_parse(AVCodecParserContext *s,
-                        AVCodecContext *avctx,
-                        uint8_t **poutbuf, int *poutbuf_size, 
-                        const uint8_t *buf, int buf_size)
-{
-    DVBSubParseContext *pc = s->priv_data;
-    uint8_t *p, *p_end;
-    int len, buf_pos = 0;
-
-#ifdef DEBUG
-    av_log(avctx, AV_LOG_INFO, "DVB parse packet pts=%Lx, lpts=%Lx, cpts=%Lx:\n", 
-            s->pts, s->last_pts, s->cur_frame_pts[s->cur_frame_start_index]);
-#endif
-    
-#ifdef DEBUG_PACKET_CONTENTS
-    int i;
-
-    for (i=0; i < buf_size; i++)
-    {
-        av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]);
-        if (i % 16 == 15)
-            av_log(avctx, AV_LOG_INFO, "\n");
-    }
-    
-    if (i % 16 != 0)
-        av_log(avctx, AV_LOG_INFO, "\n");
-
-#endif
-
-    *poutbuf = NULL;
-    *poutbuf_size = 0;
-    
-    s->fetch_timestamp = 1;
-    
-    if (s->last_pts != s->pts && s->last_pts != AV_NOPTS_VALUE) /* Start of a new packet */
-    {
-        if (pc->packet_index != pc->packet_start)
-        {
-#ifdef DEBUG
-            av_log(avctx, AV_LOG_INFO, "Discarding %d bytes\n", 
-                pc->packet_index - pc->packet_start);
-#endif
-        }
-        
-        pc->packet_start = 0;
-        pc->packet_index = 0;            
-        
-        if (buf_size < 2 || buf[0] != 0x20 || buf[1] != 0x00) {
-#ifdef DEBUG
-            av_log(avctx, AV_LOG_INFO, "Bad packet header\n");
-#endif
-            return -1;
-        }
-        
-        buf_pos = 2;
-        
-        pc->in_packet = 1;
-    } else {
-        if (pc->packet_start != 0)
-        {
-            if (pc->packet_index != pc->packet_start)
-            {
-                memmove(pc->packet_buf, pc->packet_buf + pc->packet_start,
-                            pc->packet_index - pc->packet_start);
-
-                pc->packet_index -= pc->packet_start;
-                pc->packet_start = 0;
-            } else {
-                pc->packet_start = 0;
-                pc->packet_index = 0;
-            }
-        }
-    }
-        
-    if (buf_size - buf_pos + pc->packet_index > PARSE_BUF_SIZE)
-        return -1;
-        
-/* if not currently in a packet, discard data */
-    if (pc->in_packet == 0)
-        return buf_size;
-        
-    memcpy(pc->packet_buf + pc->packet_index, buf + buf_pos, buf_size - buf_pos);
-    pc->packet_index += buf_size - buf_pos;
-    
-    p = pc->packet_buf;
-    p_end = pc->packet_buf + pc->packet_index;
-    
-    while (p < p_end)
-    {
-        if (*p == 0x0f) 
-        {
-            if (p + 6 <= p_end)
-            {
-                len = BE_16(p + 4);
-
-                if (p + len + 6 <= p_end)
-                {
-                    *poutbuf_size += len + 6;
-
-                    p += len + 6;
-                } else
-                    break;
-            } else
-                break;
-        } else if (*p == 0xff) {
-            if (p + 1 < p_end)
-            {
-#ifdef DEBUG
-                av_log(avctx, AV_LOG_INFO, "Junk at end of packet\n");
-#endif
-            }
-            pc->packet_index = p - pc->packet_buf;
-            pc->in_packet = 0;
-            break;    
-        } else {
-            av_log(avctx, AV_LOG_ERROR, "Junk in packet\n");
-            
-            pc->packet_index = p - pc->packet_buf;
-            pc->in_packet = 0;
-            break;
-        }
-    }
-
-    if (*poutbuf_size > 0)
-    {
-        *poutbuf = pc->packet_buf;
-        pc->packet_start = *poutbuf_size;
-    }
-    
-    if (s->last_pts == AV_NOPTS_VALUE)    
-        s->last_pts = s->pts;
-        
-    return buf_size;
-}
-
-static void dvbsub_parse_close(AVCodecParserContext *s)
-{
-    DVBSubParseContext *pc = s->priv_data;
-    av_freep(&pc->packet_buf);
-}
-
-AVCodecParser dvbsub_parser = {
-    { CODEC_ID_DVB_SUBTITLE },
-    sizeof(DVBSubParseContext),
-    dvbsub_parse_init,
-    dvbsub_parse,
-    dvbsub_parse_close,
-};
diff --git a/ffmpeg.src/libavcodec/dvdata.h b/ffmpeg.src/libavcodec/dvdata.h
deleted file mode 100644
index acda751..0000000
--- a/ffmpeg.src/libavcodec/dvdata.h
+++ /dev/null
@@ -1,1366 +0,0 @@
-/*
- * Constants for DV codec
- * Copyright (c) 2002 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file dvdata.h
- * Constants for DV codec.
- */
-
-/* 
- * DVprofile is used to express the differences between various 
- * DV flavors. For now it's primarily used for differentiating
- * 525/60 and 625/50, but the plans are to use it for various
- * DV specs as well (e.g. SMPTE314M vs. IEC 61834).
- */
-typedef struct DVprofile {
-    int              dsf;                 /* value of the dsf in the DV header */
-    int              frame_size;          /* total size of one frame in bytes */
-    int              difseg_size;         /* number of DIF segments */
-    int              frame_rate;      
-    int              frame_rate_base;
-    int              ltc_divisor;         /* FPS from the LTS standpoint */
-    int              height;              /* picture height in pixels */
-    int              width;               /* picture width in pixels */
-    AVRational       sar[2];              /* sample aspect ratios for 4:3 and 16:9 */
-    const uint16_t  *video_place;         /* positions of all DV macro blocks */
-    enum PixelFormat pix_fmt;             /* picture pixel format */
-    
-    int              audio_stride;        /* size of audio_shuffle table */
-    int              audio_min_samples[3];/* min ammount of audio samples */
-                                          /* for 48Khz, 44.1Khz and 32Khz */
-    int              audio_samples_dist[5];/* how many samples are supposed to be */
-                                         /* in each frame in a 5 frames window */
-    const uint16_t (*audio_shuffle)[9];  /* PCM shuffling table */
-} DVprofile;
-
-#define NB_DV_VLC 409
-
-/* 
- * There's a catch about the following three tables: the mapping they establish
- * between (run, level) and vlc is not 1-1. So you have to watch out for that
- * when building misc. tables. E.g. (1, 0) can be either 0x7cf or 0x1f82. 
- */
-static const uint16_t dv_vlc_bits[409] = {
- 0x0000, 0x0002, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016,
- 0x0017, 0x0030, 0x0031, 0x0032, 0x0033, 0x0068, 0x0069, 0x006a,
- 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, 0x00e0, 0x00e1, 0x00e2,
- 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea,
- 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, 0x01e0, 0x01e1, 0x01e2,
- 0x01e3, 0x01e4, 0x01e5, 0x01e6, 0x01e7, 0x01e8, 0x01e9, 0x01ea,
- 0x01eb, 0x01ec, 0x01ed, 0x01ee, 0x01ef, 0x03e0, 0x03e1, 0x03e2,
- 0x03e3, 0x03e4, 0x03e5, 0x03e6, 0x07ce, 0x07cf, 0x07d0, 0x07d1,
- 0x07d2, 0x07d3, 0x07d4, 0x07d5, 0x0fac, 0x0fad, 0x0fae, 0x0faf,
- 0x0fb0, 0x0fb1, 0x0fb2, 0x0fb3, 0x0fb4, 0x0fb5, 0x0fb6, 0x0fb7,
- 0x0fb8, 0x0fb9, 0x0fba, 0x0fbb, 0x0fbc, 0x0fbd, 0x0fbe, 0x0fbf,
- 0x1f80, 0x1f81, 0x1f82, 0x1f83, 0x1f84, 0x1f85, 0x1f86, 0x1f87,
- 0x1f88, 0x1f89, 0x1f8a, 0x1f8b, 0x1f8c, 0x1f8d, 0x1f8e, 0x1f8f,
- 0x1f90, 0x1f91, 0x1f92, 0x1f93, 0x1f94, 0x1f95, 0x1f96, 0x1f97,
- 0x1f98, 0x1f99, 0x1f9a, 0x1f9b, 0x1f9c, 0x1f9d, 0x1f9e, 0x1f9f,
- 0x1fa0, 0x1fa1, 0x1fa2, 0x1fa3, 0x1fa4, 0x1fa5, 0x1fa6, 0x1fa7,
- 0x1fa8, 0x1fa9, 0x1faa, 0x1fab, 0x1fac, 0x1fad, 0x1fae, 0x1faf,
- 0x1fb0, 0x1fb1, 0x1fb2, 0x1fb3, 0x1fb4, 0x1fb5, 0x1fb6, 0x1fb7,
- 0x1fb8, 0x1fb9, 0x1fba, 0x1fbb, 0x1fbc, 0x1fbd, 0x1fbe, 0x1fbf,
- 0x7f00, 0x7f01, 0x7f02, 0x7f03, 0x7f04, 0x7f05, 0x7f06, 0x7f07,
- 0x7f08, 0x7f09, 0x7f0a, 0x7f0b, 0x7f0c, 0x7f0d, 0x7f0e, 0x7f0f,
- 0x7f10, 0x7f11, 0x7f12, 0x7f13, 0x7f14, 0x7f15, 0x7f16, 0x7f17,
- 0x7f18, 0x7f19, 0x7f1a, 0x7f1b, 0x7f1c, 0x7f1d, 0x7f1e, 0x7f1f,
- 0x7f20, 0x7f21, 0x7f22, 0x7f23, 0x7f24, 0x7f25, 0x7f26, 0x7f27,
- 0x7f28, 0x7f29, 0x7f2a, 0x7f2b, 0x7f2c, 0x7f2d, 0x7f2e, 0x7f2f,
- 0x7f30, 0x7f31, 0x7f32, 0x7f33, 0x7f34, 0x7f35, 0x7f36, 0x7f37,
- 0x7f38, 0x7f39, 0x7f3a, 0x7f3b, 0x7f3c, 0x7f3d, 0x7f3e, 0x7f3f,
- 0x7f40, 0x7f41, 0x7f42, 0x7f43, 0x7f44, 0x7f45, 0x7f46, 0x7f47,
- 0x7f48, 0x7f49, 0x7f4a, 0x7f4b, 0x7f4c, 0x7f4d, 0x7f4e, 0x7f4f,
- 0x7f50, 0x7f51, 0x7f52, 0x7f53, 0x7f54, 0x7f55, 0x7f56, 0x7f57,
- 0x7f58, 0x7f59, 0x7f5a, 0x7f5b, 0x7f5c, 0x7f5d, 0x7f5e, 0x7f5f,
- 0x7f60, 0x7f61, 0x7f62, 0x7f63, 0x7f64, 0x7f65, 0x7f66, 0x7f67,
- 0x7f68, 0x7f69, 0x7f6a, 0x7f6b, 0x7f6c, 0x7f6d, 0x7f6e, 0x7f6f,
- 0x7f70, 0x7f71, 0x7f72, 0x7f73, 0x7f74, 0x7f75, 0x7f76, 0x7f77,
- 0x7f78, 0x7f79, 0x7f7a, 0x7f7b, 0x7f7c, 0x7f7d, 0x7f7e, 0x7f7f,
- 0x7f80, 0x7f81, 0x7f82, 0x7f83, 0x7f84, 0x7f85, 0x7f86, 0x7f87,
- 0x7f88, 0x7f89, 0x7f8a, 0x7f8b, 0x7f8c, 0x7f8d, 0x7f8e, 0x7f8f,
- 0x7f90, 0x7f91, 0x7f92, 0x7f93, 0x7f94, 0x7f95, 0x7f96, 0x7f97,
- 0x7f98, 0x7f99, 0x7f9a, 0x7f9b, 0x7f9c, 0x7f9d, 0x7f9e, 0x7f9f,
- 0x7fa0, 0x7fa1, 0x7fa2, 0x7fa3, 0x7fa4, 0x7fa5, 0x7fa6, 0x7fa7,
- 0x7fa8, 0x7fa9, 0x7faa, 0x7fab, 0x7fac, 0x7fad, 0x7fae, 0x7faf,
- 0x7fb0, 0x7fb1, 0x7fb2, 0x7fb3, 0x7fb4, 0x7fb5, 0x7fb6, 0x7fb7,
- 0x7fb8, 0x7fb9, 0x7fba, 0x7fbb, 0x7fbc, 0x7fbd, 0x7fbe, 0x7fbf,
- 0x7fc0, 0x7fc1, 0x7fc2, 0x7fc3, 0x7fc4, 0x7fc5, 0x7fc6, 0x7fc7,
- 0x7fc8, 0x7fc9, 0x7fca, 0x7fcb, 0x7fcc, 0x7fcd, 0x7fce, 0x7fcf,
- 0x7fd0, 0x7fd1, 0x7fd2, 0x7fd3, 0x7fd4, 0x7fd5, 0x7fd6, 0x7fd7,
- 0x7fd8, 0x7fd9, 0x7fda, 0x7fdb, 0x7fdc, 0x7fdd, 0x7fde, 0x7fdf,
- 0x7fe0, 0x7fe1, 0x7fe2, 0x7fe3, 0x7fe4, 0x7fe5, 0x7fe6, 0x7fe7,
- 0x7fe8, 0x7fe9, 0x7fea, 0x7feb, 0x7fec, 0x7fed, 0x7fee, 0x7fef,
- 0x7ff0, 0x7ff1, 0x7ff2, 0x7ff3, 0x7ff4, 0x7ff5, 0x7ff6, 0x7ff7,
- 0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff,
- 0x0006,
-};
-
-static const uint8_t dv_vlc_len[409] = {
-  2,  3,  4,  4,  4,  5,  5,  5,
-  5,  6,  6,  6,  6,  7,  7,  7,
-  7,  7,  7,  7,  7,  8,  8,  8,
-  8,  8,  8,  8,  8,  8,  8,  8,
-  8,  8,  8,  8,  8,  9,  9,  9,
-  9,  9,  9,  9,  9,  9,  9,  9,
-  9,  9,  9,  9,  9, 10, 10, 10,
- 10, 10, 10, 10, 11, 11, 11, 11,
- 11, 11, 11, 11, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
-  4,
-};
-
-static const uint8_t dv_vlc_run[409] = {
-  0,  0,  1,  0,  0,  2,  1,  0,
-  0,  3,  4,  0,  0,  5,  6,  2,
-  1,  1,  0,  0,  0,  7,  8,  9,
- 10,  3,  4,  2,  1,  1,  1,  0,
-  0,  0,  0,  0,  0, 11, 12, 13,
- 14,  5,  6,  3,  4,  2,  2,  1,
-  0,  0,  0,  0,  0,  5,  3,  3,
-  2,  1,  1,  1,  0,  1,  6,  4,
-  3,  1,  1,  1,  2,  3,  4,  5,
-  7,  8,  9, 10,  7,  8,  4,  3,
-  2,  2,  2,  2,  2,  1,  1,  1,
-  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,
- 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63,
-  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,  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,  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,  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,  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,  0,
-127,
-};
-
-static const uint8_t dv_vlc_level[409] = {
-  1,  2,  1,  3,  4,  1,  2,  5,
-  6,  1,  1,  7,  8,  1,  1,  2,
-  3,  4,  9, 10, 11,  1,  1,  1,
-  1,  2,  2,  3,  5,  6,  7, 12,
- 13, 14, 15, 16, 17,  1,  1,  1,
-  1,  2,  2,  3,  3,  4,  5,  8,
- 18, 19, 20, 21, 22,  3,  4,  5,
-  6,  9, 10, 11,  0,  0,  3,  4,
-  6, 12, 13, 14,  0,  0,  0,  0,
-  2,  2,  2,  2,  3,  3,  5,  7,
-  7,  8,  9, 10, 11, 15, 16, 17,
-  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,  0,  0,  0,  0,  0,
-  0,  0,  0,  0,  0,  0,  0,  0,
-  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,
- 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87,
- 88, 89, 90, 91, 92, 93, 94, 95,
- 96, 97, 98, 99, 100, 101, 102, 103,
- 104, 105, 106, 107, 108, 109, 110, 111,
- 112, 113, 114, 115, 116, 117, 118, 119,
- 120, 121, 122, 123, 124, 125, 126, 127,
- 128, 129, 130, 131, 132, 133, 134, 135,
- 136, 137, 138, 139, 140, 141, 142, 143,
- 144, 145, 146, 147, 148, 149, 150, 151,
- 152, 153, 154, 155, 156, 157, 158, 159,
- 160, 161, 162, 163, 164, 165, 166, 167,
- 168, 169, 170, 171, 172, 173, 174, 175,
- 176, 177, 178, 179, 180, 181, 182, 183,
- 184, 185, 186, 187, 188, 189, 190, 191,
- 192, 193, 194, 195, 196, 197, 198, 199,
- 200, 201, 202, 203, 204, 205, 206, 207,
- 208, 209, 210, 211, 212, 213, 214, 215,
- 216, 217, 218, 219, 220, 221, 222, 223,
- 224, 225, 226, 227, 228, 229, 230, 231,
- 232, 233, 234, 235, 236, 237, 238, 239,
- 240, 241, 242, 243, 244, 245, 246, 247,
- 248, 249, 250, 251, 252, 253, 254, 255,
-  0,
-};
-
-/* unquant tables (not used directly) */
-static const uint8_t dv_88_areas[64] = {
-    0,0,0,1,1,1,2,2,
-    0,0,1,1,1,2,2,2,
-    0,1,1,1,2,2,2,3,
-    1,1,1,2,2,2,3,3,
-    1,1,2,2,2,3,3,3,
-    1,2,2,2,3,3,3,3,
-    2,2,2,3,3,3,3,3,
-    2,2,3,3,3,3,3,3,
-};
-
-static const uint8_t dv_248_areas[64] = {
-    0,0,1,1,1,2,2,3,
-    0,0,1,1,2,2,2,3,
-    0,1,1,2,2,2,3,3,
-    0,1,1,2,2,2,3,3,
-    1,1,2,2,2,3,3,3,
-    1,1,2,2,2,3,3,3,
-    1,2,2,2,3,3,3,3,
-    1,2,2,3,3,3,3,3,
-};
-
-static const uint8_t dv_quant_shifts[22][4] = {
-  { 3,3,4,4 }, 
-  { 3,3,4,4 }, 
-  { 2,3,3,4 }, 
-  { 2,3,3,4 },
-  { 2,2,3,3 }, 
-  { 2,2,3,3 }, 
-  { 1,2,2,3 }, 
-  { 1,2,2,3 }, 
-  { 1,1,2,2 }, 
-  { 1,1,2,2 }, 
-  { 0,1,1,2 }, 
-  { 0,1,1,2 }, 
-  { 0,0,1,1 }, 
-  { 0,0,1,1 },
-  { 0,0,0,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 },
-};
-
-static const uint8_t dv_quant_offset[4] = { 6, 3, 0, 1 };
-
-/* NOTE: I prefer hardcoding the positionning of dv blocks, it is
-   simpler :-) */
-
-static const uint16_t dv_place_420[1620] = {
- 0x0c24, 0x2412, 0x3036, 0x0000, 0x1848,
- 0x0e24, 0x2612, 0x3236, 0x0200, 0x1a48,
- 0x1024, 0x2812, 0x3436, 0x0400, 0x1c48,
- 0x1026, 0x2814, 0x3438, 0x0402, 0x1c4a,
- 0x0e26, 0x2614, 0x3238, 0x0202, 0x1a4a,
- 0x0c26, 0x2414, 0x3038, 0x0002, 0x184a,
- 0x0c28, 0x2416, 0x303a, 0x0004, 0x184c,
- 0x0e28, 0x2616, 0x323a, 0x0204, 0x1a4c,
- 0x1028, 0x2816, 0x343a, 0x0404, 0x1c4c,
- 0x102a, 0x2818, 0x343c, 0x0406, 0x1c4e,
- 0x0e2a, 0x2618, 0x323c, 0x0206, 0x1a4e,
- 0x0c2a, 0x2418, 0x303c, 0x0006, 0x184e,
- 0x0c2c, 0x241a, 0x303e, 0x0008, 0x1850,
- 0x0e2c, 0x261a, 0x323e, 0x0208, 0x1a50,
- 0x102c, 0x281a, 0x343e, 0x0408, 0x1c50,
- 0x102e, 0x281c, 0x3440, 0x040a, 0x1c52,
- 0x0e2e, 0x261c, 0x3240, 0x020a, 0x1a52,
- 0x0c2e, 0x241c, 0x3040, 0x000a, 0x1852,
- 0x0c30, 0x241e, 0x3042, 0x000c, 0x1854,
- 0x0e30, 0x261e, 0x3242, 0x020c, 0x1a54,
- 0x1030, 0x281e, 0x3442, 0x040c, 0x1c54,
- 0x1032, 0x2820, 0x3444, 0x040e, 0x1c56,
- 0x0e32, 0x2620, 0x3244, 0x020e, 0x1a56,
- 0x0c32, 0x2420, 0x3044, 0x000e, 0x1856,
- 0x0c34, 0x2422, 0x3046, 0x0010, 0x1858,
- 0x0e34, 0x2622, 0x3246, 0x0210, 0x1a58,
- 0x1034, 0x2822, 0x3446, 0x0410, 0x1c58,
- 0x1224, 0x2a12, 0x3636, 0x0600, 0x1e48,
- 0x1424, 0x2c12, 0x3836, 0x0800, 0x2048,
- 0x1624, 0x2e12, 0x3a36, 0x0a00, 0x2248,
- 0x1626, 0x2e14, 0x3a38, 0x0a02, 0x224a,
- 0x1426, 0x2c14, 0x3838, 0x0802, 0x204a,
- 0x1226, 0x2a14, 0x3638, 0x0602, 0x1e4a,
- 0x1228, 0x2a16, 0x363a, 0x0604, 0x1e4c,
- 0x1428, 0x2c16, 0x383a, 0x0804, 0x204c,
- 0x1628, 0x2e16, 0x3a3a, 0x0a04, 0x224c,
- 0x162a, 0x2e18, 0x3a3c, 0x0a06, 0x224e,
- 0x142a, 0x2c18, 0x383c, 0x0806, 0x204e,
- 0x122a, 0x2a18, 0x363c, 0x0606, 0x1e4e,
- 0x122c, 0x2a1a, 0x363e, 0x0608, 0x1e50,
- 0x142c, 0x2c1a, 0x383e, 0x0808, 0x2050,
- 0x162c, 0x2e1a, 0x3a3e, 0x0a08, 0x2250,
- 0x162e, 0x2e1c, 0x3a40, 0x0a0a, 0x2252,
- 0x142e, 0x2c1c, 0x3840, 0x080a, 0x2052,
- 0x122e, 0x2a1c, 0x3640, 0x060a, 0x1e52,
- 0x1230, 0x2a1e, 0x3642, 0x060c, 0x1e54,
- 0x1430, 0x2c1e, 0x3842, 0x080c, 0x2054,
- 0x1630, 0x2e1e, 0x3a42, 0x0a0c, 0x2254,
- 0x1632, 0x2e20, 0x3a44, 0x0a0e, 0x2256,
- 0x1432, 0x2c20, 0x3844, 0x080e, 0x2056,
- 0x1232, 0x2a20, 0x3644, 0x060e, 0x1e56,
- 0x1234, 0x2a22, 0x3646, 0x0610, 0x1e58,
- 0x1434, 0x2c22, 0x3846, 0x0810, 0x2058,
- 0x1634, 0x2e22, 0x3a46, 0x0a10, 0x2258,
- 0x1824, 0x3012, 0x3c36, 0x0c00, 0x2448,
- 0x1a24, 0x3212, 0x3e36, 0x0e00, 0x2648,
- 0x1c24, 0x3412, 0x4036, 0x1000, 0x2848,
- 0x1c26, 0x3414, 0x4038, 0x1002, 0x284a,
- 0x1a26, 0x3214, 0x3e38, 0x0e02, 0x264a,
- 0x1826, 0x3014, 0x3c38, 0x0c02, 0x244a,
- 0x1828, 0x3016, 0x3c3a, 0x0c04, 0x244c,
- 0x1a28, 0x3216, 0x3e3a, 0x0e04, 0x264c,
- 0x1c28, 0x3416, 0x403a, 0x1004, 0x284c,
- 0x1c2a, 0x3418, 0x403c, 0x1006, 0x284e,
- 0x1a2a, 0x3218, 0x3e3c, 0x0e06, 0x264e,
- 0x182a, 0x3018, 0x3c3c, 0x0c06, 0x244e,
- 0x182c, 0x301a, 0x3c3e, 0x0c08, 0x2450,
- 0x1a2c, 0x321a, 0x3e3e, 0x0e08, 0x2650,
- 0x1c2c, 0x341a, 0x403e, 0x1008, 0x2850,
- 0x1c2e, 0x341c, 0x4040, 0x100a, 0x2852,
- 0x1a2e, 0x321c, 0x3e40, 0x0e0a, 0x2652,
- 0x182e, 0x301c, 0x3c40, 0x0c0a, 0x2452,
- 0x1830, 0x301e, 0x3c42, 0x0c0c, 0x2454,
- 0x1a30, 0x321e, 0x3e42, 0x0e0c, 0x2654,
- 0x1c30, 0x341e, 0x4042, 0x100c, 0x2854,
- 0x1c32, 0x3420, 0x4044, 0x100e, 0x2856,
- 0x1a32, 0x3220, 0x3e44, 0x0e0e, 0x2656,
- 0x1832, 0x3020, 0x3c44, 0x0c0e, 0x2456,
- 0x1834, 0x3022, 0x3c46, 0x0c10, 0x2458,
- 0x1a34, 0x3222, 0x3e46, 0x0e10, 0x2658,
- 0x1c34, 0x3422, 0x4046, 0x1010, 0x2858,
- 0x1e24, 0x3612, 0x4236, 0x1200, 0x2a48,
- 0x2024, 0x3812, 0x4436, 0x1400, 0x2c48,
- 0x2224, 0x3a12, 0x4636, 0x1600, 0x2e48,
- 0x2226, 0x3a14, 0x4638, 0x1602, 0x2e4a,
- 0x2026, 0x3814, 0x4438, 0x1402, 0x2c4a,
- 0x1e26, 0x3614, 0x4238, 0x1202, 0x2a4a,
- 0x1e28, 0x3616, 0x423a, 0x1204, 0x2a4c,
- 0x2028, 0x3816, 0x443a, 0x1404, 0x2c4c,
- 0x2228, 0x3a16, 0x463a, 0x1604, 0x2e4c,
- 0x222a, 0x3a18, 0x463c, 0x1606, 0x2e4e,
- 0x202a, 0x3818, 0x443c, 0x1406, 0x2c4e,
- 0x1e2a, 0x3618, 0x423c, 0x1206, 0x2a4e,
- 0x1e2c, 0x361a, 0x423e, 0x1208, 0x2a50,
- 0x202c, 0x381a, 0x443e, 0x1408, 0x2c50,
- 0x222c, 0x3a1a, 0x463e, 0x1608, 0x2e50,
- 0x222e, 0x3a1c, 0x4640, 0x160a, 0x2e52,
- 0x202e, 0x381c, 0x4440, 0x140a, 0x2c52,
- 0x1e2e, 0x361c, 0x4240, 0x120a, 0x2a52,
- 0x1e30, 0x361e, 0x4242, 0x120c, 0x2a54,
- 0x2030, 0x381e, 0x4442, 0x140c, 0x2c54,
- 0x2230, 0x3a1e, 0x4642, 0x160c, 0x2e54,
- 0x2232, 0x3a20, 0x4644, 0x160e, 0x2e56,
- 0x2032, 0x3820, 0x4444, 0x140e, 0x2c56,
- 0x1e32, 0x3620, 0x4244, 0x120e, 0x2a56,
- 0x1e34, 0x3622, 0x4246, 0x1210, 0x2a58,
- 0x2034, 0x3822, 0x4446, 0x1410, 0x2c58,
- 0x2234, 0x3a22, 0x4646, 0x1610, 0x2e58,
- 0x2424, 0x3c12, 0x0036, 0x1800, 0x3048,
- 0x2624, 0x3e12, 0x0236, 0x1a00, 0x3248,
- 0x2824, 0x4012, 0x0436, 0x1c00, 0x3448,
- 0x2826, 0x4014, 0x0438, 0x1c02, 0x344a,
- 0x2626, 0x3e14, 0x0238, 0x1a02, 0x324a,
- 0x2426, 0x3c14, 0x0038, 0x1802, 0x304a,
- 0x2428, 0x3c16, 0x003a, 0x1804, 0x304c,
- 0x2628, 0x3e16, 0x023a, 0x1a04, 0x324c,
- 0x2828, 0x4016, 0x043a, 0x1c04, 0x344c,
- 0x282a, 0x4018, 0x043c, 0x1c06, 0x344e,
- 0x262a, 0x3e18, 0x023c, 0x1a06, 0x324e,
- 0x242a, 0x3c18, 0x003c, 0x1806, 0x304e,
- 0x242c, 0x3c1a, 0x003e, 0x1808, 0x3050,
- 0x262c, 0x3e1a, 0x023e, 0x1a08, 0x3250,
- 0x282c, 0x401a, 0x043e, 0x1c08, 0x3450,
- 0x282e, 0x401c, 0x0440, 0x1c0a, 0x3452,
- 0x262e, 0x3e1c, 0x0240, 0x1a0a, 0x3252,
- 0x242e, 0x3c1c, 0x0040, 0x180a, 0x3052,
- 0x2430, 0x3c1e, 0x0042, 0x180c, 0x3054,
- 0x2630, 0x3e1e, 0x0242, 0x1a0c, 0x3254,
- 0x2830, 0x401e, 0x0442, 0x1c0c, 0x3454,
- 0x2832, 0x4020, 0x0444, 0x1c0e, 0x3456,
- 0x2632, 0x3e20, 0x0244, 0x1a0e, 0x3256,
- 0x2432, 0x3c20, 0x0044, 0x180e, 0x3056,
- 0x2434, 0x3c22, 0x0046, 0x1810, 0x3058,
- 0x2634, 0x3e22, 0x0246, 0x1a10, 0x3258,
- 0x2834, 0x4022, 0x0446, 0x1c10, 0x3458,
- 0x2a24, 0x4212, 0x0636, 0x1e00, 0x3648,
- 0x2c24, 0x4412, 0x0836, 0x2000, 0x3848,
- 0x2e24, 0x4612, 0x0a36, 0x2200, 0x3a48,
- 0x2e26, 0x4614, 0x0a38, 0x2202, 0x3a4a,
- 0x2c26, 0x4414, 0x0838, 0x2002, 0x384a,
- 0x2a26, 0x4214, 0x0638, 0x1e02, 0x364a,
- 0x2a28, 0x4216, 0x063a, 0x1e04, 0x364c,
- 0x2c28, 0x4416, 0x083a, 0x2004, 0x384c,
- 0x2e28, 0x4616, 0x0a3a, 0x2204, 0x3a4c,
- 0x2e2a, 0x4618, 0x0a3c, 0x2206, 0x3a4e,
- 0x2c2a, 0x4418, 0x083c, 0x2006, 0x384e,
- 0x2a2a, 0x4218, 0x063c, 0x1e06, 0x364e,
- 0x2a2c, 0x421a, 0x063e, 0x1e08, 0x3650,
- 0x2c2c, 0x441a, 0x083e, 0x2008, 0x3850,
- 0x2e2c, 0x461a, 0x0a3e, 0x2208, 0x3a50,
- 0x2e2e, 0x461c, 0x0a40, 0x220a, 0x3a52,
- 0x2c2e, 0x441c, 0x0840, 0x200a, 0x3852,
- 0x2a2e, 0x421c, 0x0640, 0x1e0a, 0x3652,
- 0x2a30, 0x421e, 0x0642, 0x1e0c, 0x3654,
- 0x2c30, 0x441e, 0x0842, 0x200c, 0x3854,
- 0x2e30, 0x461e, 0x0a42, 0x220c, 0x3a54,
- 0x2e32, 0x4620, 0x0a44, 0x220e, 0x3a56,
- 0x2c32, 0x4420, 0x0844, 0x200e, 0x3856,
- 0x2a32, 0x4220, 0x0644, 0x1e0e, 0x3656,
- 0x2a34, 0x4222, 0x0646, 0x1e10, 0x3658,
- 0x2c34, 0x4422, 0x0846, 0x2010, 0x3858,
- 0x2e34, 0x4622, 0x0a46, 0x2210, 0x3a58,
- 0x3024, 0x0012, 0x0c36, 0x2400, 0x3c48,
- 0x3224, 0x0212, 0x0e36, 0x2600, 0x3e48,
- 0x3424, 0x0412, 0x1036, 0x2800, 0x4048,
- 0x3426, 0x0414, 0x1038, 0x2802, 0x404a,
- 0x3226, 0x0214, 0x0e38, 0x2602, 0x3e4a,
- 0x3026, 0x0014, 0x0c38, 0x2402, 0x3c4a,
- 0x3028, 0x0016, 0x0c3a, 0x2404, 0x3c4c,
- 0x3228, 0x0216, 0x0e3a, 0x2604, 0x3e4c,
- 0x3428, 0x0416, 0x103a, 0x2804, 0x404c,
- 0x342a, 0x0418, 0x103c, 0x2806, 0x404e,
- 0x322a, 0x0218, 0x0e3c, 0x2606, 0x3e4e,
- 0x302a, 0x0018, 0x0c3c, 0x2406, 0x3c4e,
- 0x302c, 0x001a, 0x0c3e, 0x2408, 0x3c50,
- 0x322c, 0x021a, 0x0e3e, 0x2608, 0x3e50,
- 0x342c, 0x041a, 0x103e, 0x2808, 0x4050,
- 0x342e, 0x041c, 0x1040, 0x280a, 0x4052,
- 0x322e, 0x021c, 0x0e40, 0x260a, 0x3e52,
- 0x302e, 0x001c, 0x0c40, 0x240a, 0x3c52,
- 0x3030, 0x001e, 0x0c42, 0x240c, 0x3c54,
- 0x3230, 0x021e, 0x0e42, 0x260c, 0x3e54,
- 0x3430, 0x041e, 0x1042, 0x280c, 0x4054,
- 0x3432, 0x0420, 0x1044, 0x280e, 0x4056,
- 0x3232, 0x0220, 0x0e44, 0x260e, 0x3e56,
- 0x3032, 0x0020, 0x0c44, 0x240e, 0x3c56,
- 0x3034, 0x0022, 0x0c46, 0x2410, 0x3c58,
- 0x3234, 0x0222, 0x0e46, 0x2610, 0x3e58,
- 0x3434, 0x0422, 0x1046, 0x2810, 0x4058,
- 0x3624, 0x0612, 0x1236, 0x2a00, 0x4248,
- 0x3824, 0x0812, 0x1436, 0x2c00, 0x4448,
- 0x3a24, 0x0a12, 0x1636, 0x2e00, 0x4648,
- 0x3a26, 0x0a14, 0x1638, 0x2e02, 0x464a,
- 0x3826, 0x0814, 0x1438, 0x2c02, 0x444a,
- 0x3626, 0x0614, 0x1238, 0x2a02, 0x424a,
- 0x3628, 0x0616, 0x123a, 0x2a04, 0x424c,
- 0x3828, 0x0816, 0x143a, 0x2c04, 0x444c,
- 0x3a28, 0x0a16, 0x163a, 0x2e04, 0x464c,
- 0x3a2a, 0x0a18, 0x163c, 0x2e06, 0x464e,
- 0x382a, 0x0818, 0x143c, 0x2c06, 0x444e,
- 0x362a, 0x0618, 0x123c, 0x2a06, 0x424e,
- 0x362c, 0x061a, 0x123e, 0x2a08, 0x4250,
- 0x382c, 0x081a, 0x143e, 0x2c08, 0x4450,
- 0x3a2c, 0x0a1a, 0x163e, 0x2e08, 0x4650,
- 0x3a2e, 0x0a1c, 0x1640, 0x2e0a, 0x4652,
- 0x382e, 0x081c, 0x1440, 0x2c0a, 0x4452,
- 0x362e, 0x061c, 0x1240, 0x2a0a, 0x4252,
- 0x3630, 0x061e, 0x1242, 0x2a0c, 0x4254,
- 0x3830, 0x081e, 0x1442, 0x2c0c, 0x4454,
- 0x3a30, 0x0a1e, 0x1642, 0x2e0c, 0x4654,
- 0x3a32, 0x0a20, 0x1644, 0x2e0e, 0x4656,
- 0x3832, 0x0820, 0x1444, 0x2c0e, 0x4456,
- 0x3632, 0x0620, 0x1244, 0x2a0e, 0x4256,
- 0x3634, 0x0622, 0x1246, 0x2a10, 0x4258,
- 0x3834, 0x0822, 0x1446, 0x2c10, 0x4458,
- 0x3a34, 0x0a22, 0x1646, 0x2e10, 0x4658,
- 0x3c24, 0x0c12, 0x1836, 0x3000, 0x0048,
- 0x3e24, 0x0e12, 0x1a36, 0x3200, 0x0248,
- 0x4024, 0x1012, 0x1c36, 0x3400, 0x0448,
- 0x4026, 0x1014, 0x1c38, 0x3402, 0x044a,
- 0x3e26, 0x0e14, 0x1a38, 0x3202, 0x024a,
- 0x3c26, 0x0c14, 0x1838, 0x3002, 0x004a,
- 0x3c28, 0x0c16, 0x183a, 0x3004, 0x004c,
- 0x3e28, 0x0e16, 0x1a3a, 0x3204, 0x024c,
- 0x4028, 0x1016, 0x1c3a, 0x3404, 0x044c,
- 0x402a, 0x1018, 0x1c3c, 0x3406, 0x044e,
- 0x3e2a, 0x0e18, 0x1a3c, 0x3206, 0x024e,
- 0x3c2a, 0x0c18, 0x183c, 0x3006, 0x004e,
- 0x3c2c, 0x0c1a, 0x183e, 0x3008, 0x0050,
- 0x3e2c, 0x0e1a, 0x1a3e, 0x3208, 0x0250,
- 0x402c, 0x101a, 0x1c3e, 0x3408, 0x0450,
- 0x402e, 0x101c, 0x1c40, 0x340a, 0x0452,
- 0x3e2e, 0x0e1c, 0x1a40, 0x320a, 0x0252,
- 0x3c2e, 0x0c1c, 0x1840, 0x300a, 0x0052,
- 0x3c30, 0x0c1e, 0x1842, 0x300c, 0x0054,
- 0x3e30, 0x0e1e, 0x1a42, 0x320c, 0x0254,
- 0x4030, 0x101e, 0x1c42, 0x340c, 0x0454,
- 0x4032, 0x1020, 0x1c44, 0x340e, 0x0456,
- 0x3e32, 0x0e20, 0x1a44, 0x320e, 0x0256,
- 0x3c32, 0x0c20, 0x1844, 0x300e, 0x0056,
- 0x3c34, 0x0c22, 0x1846, 0x3010, 0x0058,
- 0x3e34, 0x0e22, 0x1a46, 0x3210, 0x0258,
- 0x4034, 0x1022, 0x1c46, 0x3410, 0x0458,
- 0x4224, 0x1212, 0x1e36, 0x3600, 0x0648,
- 0x4424, 0x1412, 0x2036, 0x3800, 0x0848,
- 0x4624, 0x1612, 0x2236, 0x3a00, 0x0a48,
- 0x4626, 0x1614, 0x2238, 0x3a02, 0x0a4a,
- 0x4426, 0x1414, 0x2038, 0x3802, 0x084a,
- 0x4226, 0x1214, 0x1e38, 0x3602, 0x064a,
- 0x4228, 0x1216, 0x1e3a, 0x3604, 0x064c,
- 0x4428, 0x1416, 0x203a, 0x3804, 0x084c,
- 0x4628, 0x1616, 0x223a, 0x3a04, 0x0a4c,
- 0x462a, 0x1618, 0x223c, 0x3a06, 0x0a4e,
- 0x442a, 0x1418, 0x203c, 0x3806, 0x084e,
- 0x422a, 0x1218, 0x1e3c, 0x3606, 0x064e,
- 0x422c, 0x121a, 0x1e3e, 0x3608, 0x0650,
- 0x442c, 0x141a, 0x203e, 0x3808, 0x0850,
- 0x462c, 0x161a, 0x223e, 0x3a08, 0x0a50,
- 0x462e, 0x161c, 0x2240, 0x3a0a, 0x0a52,
- 0x442e, 0x141c, 0x2040, 0x380a, 0x0852,
- 0x422e, 0x121c, 0x1e40, 0x360a, 0x0652,
- 0x4230, 0x121e, 0x1e42, 0x360c, 0x0654,
- 0x4430, 0x141e, 0x2042, 0x380c, 0x0854,
- 0x4630, 0x161e, 0x2242, 0x3a0c, 0x0a54,
- 0x4632, 0x1620, 0x2244, 0x3a0e, 0x0a56,
- 0x4432, 0x1420, 0x2044, 0x380e, 0x0856,
- 0x4232, 0x1220, 0x1e44, 0x360e, 0x0656,
- 0x4234, 0x1222, 0x1e46, 0x3610, 0x0658,
- 0x4434, 0x1422, 0x2046, 0x3810, 0x0858,
- 0x4634, 0x1622, 0x2246, 0x3a10, 0x0a58,
- 0x0024, 0x1812, 0x2436, 0x3c00, 0x0c48,
- 0x0224, 0x1a12, 0x2636, 0x3e00, 0x0e48,
- 0x0424, 0x1c12, 0x2836, 0x4000, 0x1048,
- 0x0426, 0x1c14, 0x2838, 0x4002, 0x104a,
- 0x0226, 0x1a14, 0x2638, 0x3e02, 0x0e4a,
- 0x0026, 0x1814, 0x2438, 0x3c02, 0x0c4a,
- 0x0028, 0x1816, 0x243a, 0x3c04, 0x0c4c,
- 0x0228, 0x1a16, 0x263a, 0x3e04, 0x0e4c,
- 0x0428, 0x1c16, 0x283a, 0x4004, 0x104c,
- 0x042a, 0x1c18, 0x283c, 0x4006, 0x104e,
- 0x022a, 0x1a18, 0x263c, 0x3e06, 0x0e4e,
- 0x002a, 0x1818, 0x243c, 0x3c06, 0x0c4e,
- 0x002c, 0x181a, 0x243e, 0x3c08, 0x0c50,
- 0x022c, 0x1a1a, 0x263e, 0x3e08, 0x0e50,
- 0x042c, 0x1c1a, 0x283e, 0x4008, 0x1050,
- 0x042e, 0x1c1c, 0x2840, 0x400a, 0x1052,
- 0x022e, 0x1a1c, 0x2640, 0x3e0a, 0x0e52,
- 0x002e, 0x181c, 0x2440, 0x3c0a, 0x0c52,
- 0x0030, 0x181e, 0x2442, 0x3c0c, 0x0c54,
- 0x0230, 0x1a1e, 0x2642, 0x3e0c, 0x0e54,
- 0x0430, 0x1c1e, 0x2842, 0x400c, 0x1054,
- 0x0432, 0x1c20, 0x2844, 0x400e, 0x1056,
- 0x0232, 0x1a20, 0x2644, 0x3e0e, 0x0e56,
- 0x0032, 0x1820, 0x2444, 0x3c0e, 0x0c56,
- 0x0034, 0x1822, 0x2446, 0x3c10, 0x0c58,
- 0x0234, 0x1a22, 0x2646, 0x3e10, 0x0e58,
- 0x0434, 0x1c22, 0x2846, 0x4010, 0x1058,
- 0x0624, 0x1e12, 0x2a36, 0x4200, 0x1248,
- 0x0824, 0x2012, 0x2c36, 0x4400, 0x1448,
- 0x0a24, 0x2212, 0x2e36, 0x4600, 0x1648,
- 0x0a26, 0x2214, 0x2e38, 0x4602, 0x164a,
- 0x0826, 0x2014, 0x2c38, 0x4402, 0x144a,
- 0x0626, 0x1e14, 0x2a38, 0x4202, 0x124a,
- 0x0628, 0x1e16, 0x2a3a, 0x4204, 0x124c,
- 0x0828, 0x2016, 0x2c3a, 0x4404, 0x144c,
- 0x0a28, 0x2216, 0x2e3a, 0x4604, 0x164c,
- 0x0a2a, 0x2218, 0x2e3c, 0x4606, 0x164e,
- 0x082a, 0x2018, 0x2c3c, 0x4406, 0x144e,
- 0x062a, 0x1e18, 0x2a3c, 0x4206, 0x124e,
- 0x062c, 0x1e1a, 0x2a3e, 0x4208, 0x1250,
- 0x082c, 0x201a, 0x2c3e, 0x4408, 0x1450,
- 0x0a2c, 0x221a, 0x2e3e, 0x4608, 0x1650,
- 0x0a2e, 0x221c, 0x2e40, 0x460a, 0x1652,
- 0x082e, 0x201c, 0x2c40, 0x440a, 0x1452,
- 0x062e, 0x1e1c, 0x2a40, 0x420a, 0x1252,
- 0x0630, 0x1e1e, 0x2a42, 0x420c, 0x1254,
- 0x0830, 0x201e, 0x2c42, 0x440c, 0x1454,
- 0x0a30, 0x221e, 0x2e42, 0x460c, 0x1654,
- 0x0a32, 0x2220, 0x2e44, 0x460e, 0x1656,
- 0x0832, 0x2020, 0x2c44, 0x440e, 0x1456,
- 0x0632, 0x1e20, 0x2a44, 0x420e, 0x1256,
- 0x0634, 0x1e22, 0x2a46, 0x4210, 0x1258,
- 0x0834, 0x2022, 0x2c46, 0x4410, 0x1458,
- 0x0a34, 0x2222, 0x2e46, 0x4610, 0x1658,
-};
-
-static const uint16_t dv_place_411P[1620] = {
- 0x0c24, 0x2710, 0x3334, 0x0000, 0x1848, 
- 0x0d24, 0x2810, 0x3434, 0x0100, 0x1948, 
- 0x0e24, 0x2910, 0x3534, 0x0200, 0x1a48, 
- 0x0f24, 0x2914, 0x3538, 0x0300, 0x1b48, 
- 0x1024, 0x2814, 0x3438, 0x0400, 0x1c48, 
- 0x1124, 0x2714, 0x3338, 0x0500, 0x1d48, 
- 0x1128, 0x2614, 0x3238, 0x0504, 0x1d4c, 
- 0x1028, 0x2514, 0x3138, 0x0404, 0x1c4c, 
- 0x0f28, 0x2414, 0x3038, 0x0304, 0x1b4c, 
- 0x0e28, 0x2418, 0x303c, 0x0204, 0x1a4c, 
- 0x0d28, 0x2518, 0x313c, 0x0104, 0x194c, 
- 0x0c28, 0x2618, 0x323c, 0x0004, 0x184c, 
- 0x0c2c, 0x2718, 0x333c, 0x0008, 0x1850, 
- 0x0d2c, 0x2818, 0x343c, 0x0108, 0x1950, 
- 0x0e2c, 0x2918, 0x353c, 0x0208, 0x1a50, 
- 0x0f2c, 0x291c, 0x3540, 0x0308, 0x1b50, 
- 0x102c, 0x281c, 0x3440, 0x0408, 0x1c50, 
- 0x112c, 0x271c, 0x3340, 0x0508, 0x1d50, 
- 0x1130, 0x261c, 0x3240, 0x050c, 0x1d54, 
- 0x1030, 0x251c, 0x3140, 0x040c, 0x1c54, 
- 0x0f30, 0x241c, 0x3040, 0x030c, 0x1b54, 
- 0x0e30, 0x2420, 0x3044, 0x020c, 0x1a54, 
- 0x0d30, 0x2520, 0x3144, 0x010c, 0x1954, 
- 0x0c30, 0x2620, 0x3244, 0x000c, 0x1854, 
- 0x0c34, 0x2720, 0x3344, 0x0010, 0x1858, 
- 0x0d34, 0x2820, 0x3444, 0x0110, 0x1a58, 
- 0x0e34, 0x2920, 0x3544, 0x0210, 0x1c58, 
- 0x1224, 0x2d10, 0x3934, 0x0600, 0x1e48, 
- 0x1324, 0x2e10, 0x3a34, 0x0700, 0x1f48, 
- 0x1424, 0x2f10, 0x3b34, 0x0800, 0x2048, 
- 0x1524, 0x2f14, 0x3b38, 0x0900, 0x2148, 
- 0x1624, 0x2e14, 0x3a38, 0x0a00, 0x2248, 
- 0x1724, 0x2d14, 0x3938, 0x0b00, 0x2348, 
- 0x1728, 0x2c14, 0x3838, 0x0b04, 0x234c, 
- 0x1628, 0x2b14, 0x3738, 0x0a04, 0x224c, 
- 0x1528, 0x2a14, 0x3638, 0x0904, 0x214c, 
- 0x1428, 0x2a18, 0x363c, 0x0804, 0x204c, 
- 0x1328, 0x2b18, 0x373c, 0x0704, 0x1f4c, 
- 0x1228, 0x2c18, 0x383c, 0x0604, 0x1e4c, 
- 0x122c, 0x2d18, 0x393c, 0x0608, 0x1e50, 
- 0x132c, 0x2e18, 0x3a3c, 0x0708, 0x1f50, 
- 0x142c, 0x2f18, 0x3b3c, 0x0808, 0x2050, 
- 0x152c, 0x2f1c, 0x3b40, 0x0908, 0x2150, 
- 0x162c, 0x2e1c, 0x3a40, 0x0a08, 0x2250, 
- 0x172c, 0x2d1c, 0x3940, 0x0b08, 0x2350, 
- 0x1730, 0x2c1c, 0x3840, 0x0b0c, 0x2354, 
- 0x1630, 0x2b1c, 0x3740, 0x0a0c, 0x2254, 
- 0x1530, 0x2a1c, 0x3640, 0x090c, 0x2154, 
- 0x1430, 0x2a20, 0x3644, 0x080c, 0x2054, 
- 0x1330, 0x2b20, 0x3744, 0x070c, 0x1f54, 
- 0x1230, 0x2c20, 0x3844, 0x060c, 0x1e54, 
- 0x1234, 0x2d20, 0x3944, 0x0610, 0x1e58, 
- 0x1334, 0x2e20, 0x3a44, 0x0710, 0x2058, 
- 0x1434, 0x2f20, 0x3b44, 0x0810, 0x2258, 
- 0x1824, 0x3310, 0x3f34, 0x0c00, 0x2448, 
- 0x1924, 0x3410, 0x4034, 0x0d00, 0x2548, 
- 0x1a24, 0x3510, 0x4134, 0x0e00, 0x2648, 
- 0x1b24, 0x3514, 0x4138, 0x0f00, 0x2748, 
- 0x1c24, 0x3414, 0x4038, 0x1000, 0x2848, 
- 0x1d24, 0x3314, 0x3f38, 0x1100, 0x2948, 
- 0x1d28, 0x3214, 0x3e38, 0x1104, 0x294c, 
- 0x1c28, 0x3114, 0x3d38, 0x1004, 0x284c, 
- 0x1b28, 0x3014, 0x3c38, 0x0f04, 0x274c, 
- 0x1a28, 0x3018, 0x3c3c, 0x0e04, 0x264c, 
- 0x1928, 0x3118, 0x3d3c, 0x0d04, 0x254c, 
- 0x1828, 0x3218, 0x3e3c, 0x0c04, 0x244c, 
- 0x182c, 0x3318, 0x3f3c, 0x0c08, 0x2450, 
- 0x192c, 0x3418, 0x403c, 0x0d08, 0x2550, 
- 0x1a2c, 0x3518, 0x413c, 0x0e08, 0x2650, 
- 0x1b2c, 0x351c, 0x4140, 0x0f08, 0x2750, 
- 0x1c2c, 0x341c, 0x4040, 0x1008, 0x2850, 
- 0x1d2c, 0x331c, 0x3f40, 0x1108, 0x2950, 
- 0x1d30, 0x321c, 0x3e40, 0x110c, 0x2954, 
- 0x1c30, 0x311c, 0x3d40, 0x100c, 0x2854, 
- 0x1b30, 0x301c, 0x3c40, 0x0f0c, 0x2754, 
- 0x1a30, 0x3020, 0x3c44, 0x0e0c, 0x2654, 
- 0x1930, 0x3120, 0x3d44, 0x0d0c, 0x2554, 
- 0x1830, 0x3220, 0x3e44, 0x0c0c, 0x2454, 
- 0x1834, 0x3320, 0x3f44, 0x0c10, 0x2458, 
- 0x1934, 0x3420, 0x4044, 0x0d10, 0x2658, 
- 0x1a34, 0x3520, 0x4144, 0x0e10, 0x2858, 
- 0x1e24, 0x3910, 0x4534, 0x1200, 0x2a48, 
- 0x1f24, 0x3a10, 0x4634, 0x1300, 0x2b48, 
- 0x2024, 0x3b10, 0x4734, 0x1400, 0x2c48, 
- 0x2124, 0x3b14, 0x4738, 0x1500, 0x2d48, 
- 0x2224, 0x3a14, 0x4638, 0x1600, 0x2e48, 
- 0x2324, 0x3914, 0x4538, 0x1700, 0x2f48, 
- 0x2328, 0x3814, 0x4438, 0x1704, 0x2f4c, 
- 0x2228, 0x3714, 0x4338, 0x1604, 0x2e4c, 
- 0x2128, 0x3614, 0x4238, 0x1504, 0x2d4c, 
- 0x2028, 0x3618, 0x423c, 0x1404, 0x2c4c, 
- 0x1f28, 0x3718, 0x433c, 0x1304, 0x2b4c, 
- 0x1e28, 0x3818, 0x443c, 0x1204, 0x2a4c, 
- 0x1e2c, 0x3918, 0x453c, 0x1208, 0x2a50, 
- 0x1f2c, 0x3a18, 0x463c, 0x1308, 0x2b50, 
- 0x202c, 0x3b18, 0x473c, 0x1408, 0x2c50, 
- 0x212c, 0x3b1c, 0x4740, 0x1508, 0x2d50, 
- 0x222c, 0x3a1c, 0x4640, 0x1608, 0x2e50, 
- 0x232c, 0x391c, 0x4540, 0x1708, 0x2f50, 
- 0x2330, 0x381c, 0x4440, 0x170c, 0x2f54, 
- 0x2230, 0x371c, 0x4340, 0x160c, 0x2e54, 
- 0x2130, 0x361c, 0x4240, 0x150c, 0x2d54, 
- 0x2030, 0x3620, 0x4244, 0x140c, 0x2c54, 
- 0x1f30, 0x3720, 0x4344, 0x130c, 0x2b54, 
- 0x1e30, 0x3820, 0x4444, 0x120c, 0x2a54, 
- 0x1e34, 0x3920, 0x4544, 0x1210, 0x2a58, 
- 0x1f34, 0x3a20, 0x4644, 0x1310, 0x2c58, 
- 0x2034, 0x3b20, 0x4744, 0x1410, 0x2e58, 
- 0x2424, 0x3f10, 0x0334, 0x1800, 0x3048, 
- 0x2524, 0x4010, 0x0434, 0x1900, 0x3148, 
- 0x2624, 0x4110, 0x0534, 0x1a00, 0x3248, 
- 0x2724, 0x4114, 0x0538, 0x1b00, 0x3348, 
- 0x2824, 0x4014, 0x0438, 0x1c00, 0x3448, 
- 0x2924, 0x3f14, 0x0338, 0x1d00, 0x3548, 
- 0x2928, 0x3e14, 0x0238, 0x1d04, 0x354c, 
- 0x2828, 0x3d14, 0x0138, 0x1c04, 0x344c, 
- 0x2728, 0x3c14, 0x0038, 0x1b04, 0x334c, 
- 0x2628, 0x3c18, 0x003c, 0x1a04, 0x324c, 
- 0x2528, 0x3d18, 0x013c, 0x1904, 0x314c, 
- 0x2428, 0x3e18, 0x023c, 0x1804, 0x304c, 
- 0x242c, 0x3f18, 0x033c, 0x1808, 0x3050, 
- 0x252c, 0x4018, 0x043c, 0x1908, 0x3150, 
- 0x262c, 0x4118, 0x053c, 0x1a08, 0x3250, 
- 0x272c, 0x411c, 0x0540, 0x1b08, 0x3350, 
- 0x282c, 0x401c, 0x0440, 0x1c08, 0x3450, 
- 0x292c, 0x3f1c, 0x0340, 0x1d08, 0x3550, 
- 0x2930, 0x3e1c, 0x0240, 0x1d0c, 0x3554, 
- 0x2830, 0x3d1c, 0x0140, 0x1c0c, 0x3454, 
- 0x2730, 0x3c1c, 0x0040, 0x1b0c, 0x3354, 
- 0x2630, 0x3c20, 0x0044, 0x1a0c, 0x3254, 
- 0x2530, 0x3d20, 0x0144, 0x190c, 0x3154, 
- 0x2430, 0x3e20, 0x0244, 0x180c, 0x3054, 
- 0x2434, 0x3f20, 0x0344, 0x1810, 0x3058, 
- 0x2534, 0x4020, 0x0444, 0x1910, 0x3258, 
- 0x2634, 0x4120, 0x0544, 0x1a10, 0x3458, 
- 0x2a24, 0x4510, 0x0934, 0x1e00, 0x3648, 
- 0x2b24, 0x4610, 0x0a34, 0x1f00, 0x3748, 
- 0x2c24, 0x4710, 0x0b34, 0x2000, 0x3848, 
- 0x2d24, 0x4714, 0x0b38, 0x2100, 0x3948, 
- 0x2e24, 0x4614, 0x0a38, 0x2200, 0x3a48, 
- 0x2f24, 0x4514, 0x0938, 0x2300, 0x3b48, 
- 0x2f28, 0x4414, 0x0838, 0x2304, 0x3b4c, 
- 0x2e28, 0x4314, 0x0738, 0x2204, 0x3a4c, 
- 0x2d28, 0x4214, 0x0638, 0x2104, 0x394c, 
- 0x2c28, 0x4218, 0x063c, 0x2004, 0x384c, 
- 0x2b28, 0x4318, 0x073c, 0x1f04, 0x374c, 
- 0x2a28, 0x4418, 0x083c, 0x1e04, 0x364c, 
- 0x2a2c, 0x4518, 0x093c, 0x1e08, 0x3650, 
- 0x2b2c, 0x4618, 0x0a3c, 0x1f08, 0x3750, 
- 0x2c2c, 0x4718, 0x0b3c, 0x2008, 0x3850, 
- 0x2d2c, 0x471c, 0x0b40, 0x2108, 0x3950, 
- 0x2e2c, 0x461c, 0x0a40, 0x2208, 0x3a50, 
- 0x2f2c, 0x451c, 0x0940, 0x2308, 0x3b50, 
- 0x2f30, 0x441c, 0x0840, 0x230c, 0x3b54, 
- 0x2e30, 0x431c, 0x0740, 0x220c, 0x3a54, 
- 0x2d30, 0x421c, 0x0640, 0x210c, 0x3954, 
- 0x2c30, 0x4220, 0x0644, 0x200c, 0x3854, 
- 0x2b30, 0x4320, 0x0744, 0x1f0c, 0x3754, 
- 0x2a30, 0x4420, 0x0844, 0x1e0c, 0x3654, 
- 0x2a34, 0x4520, 0x0944, 0x1e10, 0x3658, 
- 0x2b34, 0x4620, 0x0a44, 0x1f10, 0x3858, 
- 0x2c34, 0x4720, 0x0b44, 0x2010, 0x3a58, 
- 0x3024, 0x0310, 0x0f34, 0x2400, 0x3c48, 
- 0x3124, 0x0410, 0x1034, 0x2500, 0x3d48, 
- 0x3224, 0x0510, 0x1134, 0x2600, 0x3e48, 
- 0x3324, 0x0514, 0x1138, 0x2700, 0x3f48, 
- 0x3424, 0x0414, 0x1038, 0x2800, 0x4048, 
- 0x3524, 0x0314, 0x0f38, 0x2900, 0x4148, 
- 0x3528, 0x0214, 0x0e38, 0x2904, 0x414c, 
- 0x3428, 0x0114, 0x0d38, 0x2804, 0x404c, 
- 0x3328, 0x0014, 0x0c38, 0x2704, 0x3f4c, 
- 0x3228, 0x0018, 0x0c3c, 0x2604, 0x3e4c, 
- 0x3128, 0x0118, 0x0d3c, 0x2504, 0x3d4c, 
- 0x3028, 0x0218, 0x0e3c, 0x2404, 0x3c4c, 
- 0x302c, 0x0318, 0x0f3c, 0x2408, 0x3c50, 
- 0x312c, 0x0418, 0x103c, 0x2508, 0x3d50, 
- 0x322c, 0x0518, 0x113c, 0x2608, 0x3e50, 
- 0x332c, 0x051c, 0x1140, 0x2708, 0x3f50, 
- 0x342c, 0x041c, 0x1040, 0x2808, 0x4050, 
- 0x352c, 0x031c, 0x0f40, 0x2908, 0x4150, 
- 0x3530, 0x021c, 0x0e40, 0x290c, 0x4154, 
- 0x3430, 0x011c, 0x0d40, 0x280c, 0x4054, 
- 0x3330, 0x001c, 0x0c40, 0x270c, 0x3f54, 
- 0x3230, 0x0020, 0x0c44, 0x260c, 0x3e54, 
- 0x3130, 0x0120, 0x0d44, 0x250c, 0x3d54, 
- 0x3030, 0x0220, 0x0e44, 0x240c, 0x3c54, 
- 0x3034, 0x0320, 0x0f44, 0x2410, 0x3c58, 
- 0x3134, 0x0420, 0x1044, 0x2510, 0x3e58, 
- 0x3234, 0x0520, 0x1144, 0x2610, 0x4058, 
- 0x3624, 0x0910, 0x1534, 0x2a00, 0x4248, 
- 0x3724, 0x0a10, 0x1634, 0x2b00, 0x4348, 
- 0x3824, 0x0b10, 0x1734, 0x2c00, 0x4448, 
- 0x3924, 0x0b14, 0x1738, 0x2d00, 0x4548, 
- 0x3a24, 0x0a14, 0x1638, 0x2e00, 0x4648, 
- 0x3b24, 0x0914, 0x1538, 0x2f00, 0x4748, 
- 0x3b28, 0x0814, 0x1438, 0x2f04, 0x474c, 
- 0x3a28, 0x0714, 0x1338, 0x2e04, 0x464c, 
- 0x3928, 0x0614, 0x1238, 0x2d04, 0x454c, 
- 0x3828, 0x0618, 0x123c, 0x2c04, 0x444c, 
- 0x3728, 0x0718, 0x133c, 0x2b04, 0x434c, 
- 0x3628, 0x0818, 0x143c, 0x2a04, 0x424c, 
- 0x362c, 0x0918, 0x153c, 0x2a08, 0x4250, 
- 0x372c, 0x0a18, 0x163c, 0x2b08, 0x4350, 
- 0x382c, 0x0b18, 0x173c, 0x2c08, 0x4450, 
- 0x392c, 0x0b1c, 0x1740, 0x2d08, 0x4550, 
- 0x3a2c, 0x0a1c, 0x1640, 0x2e08, 0x4650, 
- 0x3b2c, 0x091c, 0x1540, 0x2f08, 0x4750, 
- 0x3b30, 0x081c, 0x1440, 0x2f0c, 0x4754, 
- 0x3a30, 0x071c, 0x1340, 0x2e0c, 0x4654, 
- 0x3930, 0x061c, 0x1240, 0x2d0c, 0x4554, 
- 0x3830, 0x0620, 0x1244, 0x2c0c, 0x4454, 
- 0x3730, 0x0720, 0x1344, 0x2b0c, 0x4354, 
- 0x3630, 0x0820, 0x1444, 0x2a0c, 0x4254, 
- 0x3634, 0x0920, 0x1544, 0x2a10, 0x4258, 
- 0x3734, 0x0a20, 0x1644, 0x2b10, 0x4458, 
- 0x3834, 0x0b20, 0x1744, 0x2c10, 0x4658, 
- 0x3c24, 0x0f10, 0x1b34, 0x3000, 0x0048, 
- 0x3d24, 0x1010, 0x1c34, 0x3100, 0x0148, 
- 0x3e24, 0x1110, 0x1d34, 0x3200, 0x0248, 
- 0x3f24, 0x1114, 0x1d38, 0x3300, 0x0348, 
- 0x4024, 0x1014, 0x1c38, 0x3400, 0x0448, 
- 0x4124, 0x0f14, 0x1b38, 0x3500, 0x0548, 
- 0x4128, 0x0e14, 0x1a38, 0x3504, 0x054c, 
- 0x4028, 0x0d14, 0x1938, 0x3404, 0x044c, 
- 0x3f28, 0x0c14, 0x1838, 0x3304, 0x034c, 
- 0x3e28, 0x0c18, 0x183c, 0x3204, 0x024c, 
- 0x3d28, 0x0d18, 0x193c, 0x3104, 0x014c, 
- 0x3c28, 0x0e18, 0x1a3c, 0x3004, 0x004c, 
- 0x3c2c, 0x0f18, 0x1b3c, 0x3008, 0x0050, 
- 0x3d2c, 0x1018, 0x1c3c, 0x3108, 0x0150, 
- 0x3e2c, 0x1118, 0x1d3c, 0x3208, 0x0250, 
- 0x3f2c, 0x111c, 0x1d40, 0x3308, 0x0350, 
- 0x402c, 0x101c, 0x1c40, 0x3408, 0x0450, 
- 0x412c, 0x0f1c, 0x1b40, 0x3508, 0x0550, 
- 0x4130, 0x0e1c, 0x1a40, 0x350c, 0x0554, 
- 0x4030, 0x0d1c, 0x1940, 0x340c, 0x0454, 
- 0x3f30, 0x0c1c, 0x1840, 0x330c, 0x0354, 
- 0x3e30, 0x0c20, 0x1844, 0x320c, 0x0254, 
- 0x3d30, 0x0d20, 0x1944, 0x310c, 0x0154, 
- 0x3c30, 0x0e20, 0x1a44, 0x300c, 0x0054, 
- 0x3c34, 0x0f20, 0x1b44, 0x3010, 0x0058, 
- 0x3d34, 0x1020, 0x1c44, 0x3110, 0x0258, 
- 0x3e34, 0x1120, 0x1d44, 0x3210, 0x0458, 
- 0x4224, 0x1510, 0x2134, 0x3600, 0x0648, 
- 0x4324, 0x1610, 0x2234, 0x3700, 0x0748, 
- 0x4424, 0x1710, 0x2334, 0x3800, 0x0848, 
- 0x4524, 0x1714, 0x2338, 0x3900, 0x0948, 
- 0x4624, 0x1614, 0x2238, 0x3a00, 0x0a48, 
- 0x4724, 0x1514, 0x2138, 0x3b00, 0x0b48, 
- 0x4728, 0x1414, 0x2038, 0x3b04, 0x0b4c, 
- 0x4628, 0x1314, 0x1f38, 0x3a04, 0x0a4c, 
- 0x4528, 0x1214, 0x1e38, 0x3904, 0x094c, 
- 0x4428, 0x1218, 0x1e3c, 0x3804, 0x084c, 
- 0x4328, 0x1318, 0x1f3c, 0x3704, 0x074c, 
- 0x4228, 0x1418, 0x203c, 0x3604, 0x064c, 
- 0x422c, 0x1518, 0x213c, 0x3608, 0x0650, 
- 0x432c, 0x1618, 0x223c, 0x3708, 0x0750, 
- 0x442c, 0x1718, 0x233c, 0x3808, 0x0850, 
- 0x452c, 0x171c, 0x2340, 0x3908, 0x0950, 
- 0x462c, 0x161c, 0x2240, 0x3a08, 0x0a50, 
- 0x472c, 0x151c, 0x2140, 0x3b08, 0x0b50, 
- 0x4730, 0x141c, 0x2040, 0x3b0c, 0x0b54, 
- 0x4630, 0x131c, 0x1f40, 0x3a0c, 0x0a54, 
- 0x4530, 0x121c, 0x1e40, 0x390c, 0x0954, 
- 0x4430, 0x1220, 0x1e44, 0x380c, 0x0854, 
- 0x4330, 0x1320, 0x1f44, 0x370c, 0x0754, 
- 0x4230, 0x1420, 0x2044, 0x360c, 0x0654, 
- 0x4234, 0x1520, 0x2144, 0x3610, 0x0658, 
- 0x4334, 0x1620, 0x2244, 0x3710, 0x0858, 
- 0x4434, 0x1720, 0x2344, 0x3810, 0x0a58, 
- 0x0024, 0x1b10, 0x2734, 0x3c00, 0x0c48, 
- 0x0124, 0x1c10, 0x2834, 0x3d00, 0x0d48, 
- 0x0224, 0x1d10, 0x2934, 0x3e00, 0x0e48, 
- 0x0324, 0x1d14, 0x2938, 0x3f00, 0x0f48, 
- 0x0424, 0x1c14, 0x2838, 0x4000, 0x1048, 
- 0x0524, 0x1b14, 0x2738, 0x4100, 0x1148, 
- 0x0528, 0x1a14, 0x2638, 0x4104, 0x114c, 
- 0x0428, 0x1914, 0x2538, 0x4004, 0x104c, 
- 0x0328, 0x1814, 0x2438, 0x3f04, 0x0f4c, 
- 0x0228, 0x1818, 0x243c, 0x3e04, 0x0e4c, 
- 0x0128, 0x1918, 0x253c, 0x3d04, 0x0d4c, 
- 0x0028, 0x1a18, 0x263c, 0x3c04, 0x0c4c, 
- 0x002c, 0x1b18, 0x273c, 0x3c08, 0x0c50, 
- 0x012c, 0x1c18, 0x283c, 0x3d08, 0x0d50, 
- 0x022c, 0x1d18, 0x293c, 0x3e08, 0x0e50, 
- 0x032c, 0x1d1c, 0x2940, 0x3f08, 0x0f50, 
- 0x042c, 0x1c1c, 0x2840, 0x4008, 0x1050, 
- 0x052c, 0x1b1c, 0x2740, 0x4108, 0x1150, 
- 0x0530, 0x1a1c, 0x2640, 0x410c, 0x1154, 
- 0x0430, 0x191c, 0x2540, 0x400c, 0x1054, 
- 0x0330, 0x181c, 0x2440, 0x3f0c, 0x0f54, 
- 0x0230, 0x1820, 0x2444, 0x3e0c, 0x0e54, 
- 0x0130, 0x1920, 0x2544, 0x3d0c, 0x0d54, 
- 0x0030, 0x1a20, 0x2644, 0x3c0c, 0x0c54, 
- 0x0034, 0x1b20, 0x2744, 0x3c10, 0x0c58, 
- 0x0134, 0x1c20, 0x2844, 0x3d10, 0x0e58, 
- 0x0234, 0x1d20, 0x2944, 0x3e10, 0x1058, 
- 0x0624, 0x2110, 0x2d34, 0x4200, 0x1248, 
- 0x0724, 0x2210, 0x2e34, 0x4300, 0x1348, 
- 0x0824, 0x2310, 0x2f34, 0x4400, 0x1448, 
- 0x0924, 0x2314, 0x2f38, 0x4500, 0x1548, 
- 0x0a24, 0x2214, 0x2e38, 0x4600, 0x1648, 
- 0x0b24, 0x2114, 0x2d38, 0x4700, 0x1748, 
- 0x0b28, 0x2014, 0x2c38, 0x4704, 0x174c, 
- 0x0a28, 0x1f14, 0x2b38, 0x4604, 0x164c, 
- 0x0928, 0x1e14, 0x2a38, 0x4504, 0x154c, 
- 0x0828, 0x1e18, 0x2a3c, 0x4404, 0x144c, 
- 0x0728, 0x1f18, 0x2b3c, 0x4304, 0x134c, 
- 0x0628, 0x2018, 0x2c3c, 0x4204, 0x124c, 
- 0x062c, 0x2118, 0x2d3c, 0x4208, 0x1250, 
- 0x072c, 0x2218, 0x2e3c, 0x4308, 0x1350, 
- 0x082c, 0x2318, 0x2f3c, 0x4408, 0x1450, 
- 0x092c, 0x231c, 0x2f40, 0x4508, 0x1550, 
- 0x0a2c, 0x221c, 0x2e40, 0x4608, 0x1650, 
- 0x0b2c, 0x211c, 0x2d40, 0x4708, 0x1750, 
- 0x0b30, 0x201c, 0x2c40, 0x470c, 0x1754, 
- 0x0a30, 0x1f1c, 0x2b40, 0x460c, 0x1654, 
- 0x0930, 0x1e1c, 0x2a40, 0x450c, 0x1554, 
- 0x0830, 0x1e20, 0x2a44, 0x440c, 0x1454, 
- 0x0730, 0x1f20, 0x2b44, 0x430c, 0x1354, 
- 0x0630, 0x2020, 0x2c44, 0x420c, 0x1254, 
- 0x0634, 0x2120, 0x2d44, 0x4210, 0x1258, 
- 0x0734, 0x2220, 0x2e44, 0x4310, 0x1458, 
- 0x0834, 0x2320, 0x2f44, 0x4410, 0x1658,
-};
-
-static const uint16_t dv_place_411[1350] = {
- 0x0c24, 0x2710, 0x3334, 0x0000, 0x1848,
- 0x0d24, 0x2810, 0x3434, 0x0100, 0x1948,
- 0x0e24, 0x2910, 0x3534, 0x0200, 0x1a48,
- 0x0f24, 0x2914, 0x3538, 0x0300, 0x1b48,
- 0x1024, 0x2814, 0x3438, 0x0400, 0x1c48,
- 0x1124, 0x2714, 0x3338, 0x0500, 0x1d48,
- 0x1128, 0x2614, 0x3238, 0x0504, 0x1d4c,
- 0x1028, 0x2514, 0x3138, 0x0404, 0x1c4c,
- 0x0f28, 0x2414, 0x3038, 0x0304, 0x1b4c,
- 0x0e28, 0x2418, 0x303c, 0x0204, 0x1a4c,
- 0x0d28, 0x2518, 0x313c, 0x0104, 0x194c,
- 0x0c28, 0x2618, 0x323c, 0x0004, 0x184c,
- 0x0c2c, 0x2718, 0x333c, 0x0008, 0x1850,
- 0x0d2c, 0x2818, 0x343c, 0x0108, 0x1950,
- 0x0e2c, 0x2918, 0x353c, 0x0208, 0x1a50,
- 0x0f2c, 0x291c, 0x3540, 0x0308, 0x1b50,
- 0x102c, 0x281c, 0x3440, 0x0408, 0x1c50,
- 0x112c, 0x271c, 0x3340, 0x0508, 0x1d50,
- 0x1130, 0x261c, 0x3240, 0x050c, 0x1d54,
- 0x1030, 0x251c, 0x3140, 0x040c, 0x1c54,
- 0x0f30, 0x241c, 0x3040, 0x030c, 0x1b54,
- 0x0e30, 0x2420, 0x3044, 0x020c, 0x1a54,
- 0x0d30, 0x2520, 0x3144, 0x010c, 0x1954,
- 0x0c30, 0x2620, 0x3244, 0x000c, 0x1854,
- 0x0c34, 0x2720, 0x3344, 0x0010, 0x1858,
- 0x0d34, 0x2820, 0x3444, 0x0110, 0x1a58,
- 0x0e34, 0x2920, 0x3544, 0x0210, 0x1c58,
- 0x1224, 0x2d10, 0x3934, 0x0600, 0x1e48,
- 0x1324, 0x2e10, 0x3a34, 0x0700, 0x1f48,
- 0x1424, 0x2f10, 0x3b34, 0x0800, 0x2048,
- 0x1524, 0x2f14, 0x3b38, 0x0900, 0x2148,
- 0x1624, 0x2e14, 0x3a38, 0x0a00, 0x2248,
- 0x1724, 0x2d14, 0x3938, 0x0b00, 0x2348,
- 0x1728, 0x2c14, 0x3838, 0x0b04, 0x234c,
- 0x1628, 0x2b14, 0x3738, 0x0a04, 0x224c,
- 0x1528, 0x2a14, 0x3638, 0x0904, 0x214c,
- 0x1428, 0x2a18, 0x363c, 0x0804, 0x204c,
- 0x1328, 0x2b18, 0x373c, 0x0704, 0x1f4c,
- 0x1228, 0x2c18, 0x383c, 0x0604, 0x1e4c,
- 0x122c, 0x2d18, 0x393c, 0x0608, 0x1e50,
- 0x132c, 0x2e18, 0x3a3c, 0x0708, 0x1f50,
- 0x142c, 0x2f18, 0x3b3c, 0x0808, 0x2050,
- 0x152c, 0x2f1c, 0x3b40, 0x0908, 0x2150,
- 0x162c, 0x2e1c, 0x3a40, 0x0a08, 0x2250,
- 0x172c, 0x2d1c, 0x3940, 0x0b08, 0x2350,
- 0x1730, 0x2c1c, 0x3840, 0x0b0c, 0x2354,
- 0x1630, 0x2b1c, 0x3740, 0x0a0c, 0x2254,
- 0x1530, 0x2a1c, 0x3640, 0x090c, 0x2154,
- 0x1430, 0x2a20, 0x3644, 0x080c, 0x2054,
- 0x1330, 0x2b20, 0x3744, 0x070c, 0x1f54,
- 0x1230, 0x2c20, 0x3844, 0x060c, 0x1e54,
- 0x1234, 0x2d20, 0x3944, 0x0610, 0x1e58,
- 0x1334, 0x2e20, 0x3a44, 0x0710, 0x2058,
- 0x1434, 0x2f20, 0x3b44, 0x0810, 0x2258,
- 0x1824, 0x3310, 0x0334, 0x0c00, 0x2448,
- 0x1924, 0x3410, 0x0434, 0x0d00, 0x2548,
- 0x1a24, 0x3510, 0x0534, 0x0e00, 0x2648,
- 0x1b24, 0x3514, 0x0538, 0x0f00, 0x2748,
- 0x1c24, 0x3414, 0x0438, 0x1000, 0x2848,
- 0x1d24, 0x3314, 0x0338, 0x1100, 0x2948,
- 0x1d28, 0x3214, 0x0238, 0x1104, 0x294c,
- 0x1c28, 0x3114, 0x0138, 0x1004, 0x284c,
- 0x1b28, 0x3014, 0x0038, 0x0f04, 0x274c,
- 0x1a28, 0x3018, 0x003c, 0x0e04, 0x264c,
- 0x1928, 0x3118, 0x013c, 0x0d04, 0x254c,
- 0x1828, 0x3218, 0x023c, 0x0c04, 0x244c,
- 0x182c, 0x3318, 0x033c, 0x0c08, 0x2450,
- 0x192c, 0x3418, 0x043c, 0x0d08, 0x2550,
- 0x1a2c, 0x3518, 0x053c, 0x0e08, 0x2650,
- 0x1b2c, 0x351c, 0x0540, 0x0f08, 0x2750,
- 0x1c2c, 0x341c, 0x0440, 0x1008, 0x2850,
- 0x1d2c, 0x331c, 0x0340, 0x1108, 0x2950,
- 0x1d30, 0x321c, 0x0240, 0x110c, 0x2954,
- 0x1c30, 0x311c, 0x0140, 0x100c, 0x2854,
- 0x1b30, 0x301c, 0x0040, 0x0f0c, 0x2754,
- 0x1a30, 0x3020, 0x0044, 0x0e0c, 0x2654,
- 0x1930, 0x3120, 0x0144, 0x0d0c, 0x2554,
- 0x1830, 0x3220, 0x0244, 0x0c0c, 0x2454,
- 0x1834, 0x3320, 0x0344, 0x0c10, 0x2458,
- 0x1934, 0x3420, 0x0444, 0x0d10, 0x2658,
- 0x1a34, 0x3520, 0x0544, 0x0e10, 0x2858,
- 0x1e24, 0x3910, 0x0934, 0x1200, 0x2a48,
- 0x1f24, 0x3a10, 0x0a34, 0x1300, 0x2b48,
- 0x2024, 0x3b10, 0x0b34, 0x1400, 0x2c48,
- 0x2124, 0x3b14, 0x0b38, 0x1500, 0x2d48,
- 0x2224, 0x3a14, 0x0a38, 0x1600, 0x2e48,
- 0x2324, 0x3914, 0x0938, 0x1700, 0x2f48,
- 0x2328, 0x3814, 0x0838, 0x1704, 0x2f4c,
- 0x2228, 0x3714, 0x0738, 0x1604, 0x2e4c,
- 0x2128, 0x3614, 0x0638, 0x1504, 0x2d4c,
- 0x2028, 0x3618, 0x063c, 0x1404, 0x2c4c,
- 0x1f28, 0x3718, 0x073c, 0x1304, 0x2b4c,
- 0x1e28, 0x3818, 0x083c, 0x1204, 0x2a4c,
- 0x1e2c, 0x3918, 0x093c, 0x1208, 0x2a50,
- 0x1f2c, 0x3a18, 0x0a3c, 0x1308, 0x2b50,
- 0x202c, 0x3b18, 0x0b3c, 0x1408, 0x2c50,
- 0x212c, 0x3b1c, 0x0b40, 0x1508, 0x2d50,
- 0x222c, 0x3a1c, 0x0a40, 0x1608, 0x2e50,
- 0x232c, 0x391c, 0x0940, 0x1708, 0x2f50,
- 0x2330, 0x381c, 0x0840, 0x170c, 0x2f54,
- 0x2230, 0x371c, 0x0740, 0x160c, 0x2e54,
- 0x2130, 0x361c, 0x0640, 0x150c, 0x2d54,
- 0x2030, 0x3620, 0x0644, 0x140c, 0x2c54,
- 0x1f30, 0x3720, 0x0744, 0x130c, 0x2b54,
- 0x1e30, 0x3820, 0x0844, 0x120c, 0x2a54,
- 0x1e34, 0x3920, 0x0944, 0x1210, 0x2a58,
- 0x1f34, 0x3a20, 0x0a44, 0x1310, 0x2c58,
- 0x2034, 0x3b20, 0x0b44, 0x1410, 0x2e58,
- 0x2424, 0x0310, 0x0f34, 0x1800, 0x3048,
- 0x2524, 0x0410, 0x1034, 0x1900, 0x3148,
- 0x2624, 0x0510, 0x1134, 0x1a00, 0x3248,
- 0x2724, 0x0514, 0x1138, 0x1b00, 0x3348,
- 0x2824, 0x0414, 0x1038, 0x1c00, 0x3448,
- 0x2924, 0x0314, 0x0f38, 0x1d00, 0x3548,
- 0x2928, 0x0214, 0x0e38, 0x1d04, 0x354c,
- 0x2828, 0x0114, 0x0d38, 0x1c04, 0x344c,
- 0x2728, 0x0014, 0x0c38, 0x1b04, 0x334c,
- 0x2628, 0x0018, 0x0c3c, 0x1a04, 0x324c,
- 0x2528, 0x0118, 0x0d3c, 0x1904, 0x314c,
- 0x2428, 0x0218, 0x0e3c, 0x1804, 0x304c,
- 0x242c, 0x0318, 0x0f3c, 0x1808, 0x3050,
- 0x252c, 0x0418, 0x103c, 0x1908, 0x3150,
- 0x262c, 0x0518, 0x113c, 0x1a08, 0x3250,
- 0x272c, 0x051c, 0x1140, 0x1b08, 0x3350,
- 0x282c, 0x041c, 0x1040, 0x1c08, 0x3450,
- 0x292c, 0x031c, 0x0f40, 0x1d08, 0x3550,
- 0x2930, 0x021c, 0x0e40, 0x1d0c, 0x3554,
- 0x2830, 0x011c, 0x0d40, 0x1c0c, 0x3454,
- 0x2730, 0x001c, 0x0c40, 0x1b0c, 0x3354,
- 0x2630, 0x0020, 0x0c44, 0x1a0c, 0x3254,
- 0x2530, 0x0120, 0x0d44, 0x190c, 0x3154,
- 0x2430, 0x0220, 0x0e44, 0x180c, 0x3054,
- 0x2434, 0x0320, 0x0f44, 0x1810, 0x3058,
- 0x2534, 0x0420, 0x1044, 0x1910, 0x3258,
- 0x2634, 0x0520, 0x1144, 0x1a10, 0x3458,
- 0x2a24, 0x0910, 0x1534, 0x1e00, 0x3648,
- 0x2b24, 0x0a10, 0x1634, 0x1f00, 0x3748,
- 0x2c24, 0x0b10, 0x1734, 0x2000, 0x3848,
- 0x2d24, 0x0b14, 0x1738, 0x2100, 0x3948,
- 0x2e24, 0x0a14, 0x1638, 0x2200, 0x3a48,
- 0x2f24, 0x0914, 0x1538, 0x2300, 0x3b48,
- 0x2f28, 0x0814, 0x1438, 0x2304, 0x3b4c,
- 0x2e28, 0x0714, 0x1338, 0x2204, 0x3a4c,
- 0x2d28, 0x0614, 0x1238, 0x2104, 0x394c,
- 0x2c28, 0x0618, 0x123c, 0x2004, 0x384c,
- 0x2b28, 0x0718, 0x133c, 0x1f04, 0x374c,
- 0x2a28, 0x0818, 0x143c, 0x1e04, 0x364c,
- 0x2a2c, 0x0918, 0x153c, 0x1e08, 0x3650,
- 0x2b2c, 0x0a18, 0x163c, 0x1f08, 0x3750,
- 0x2c2c, 0x0b18, 0x173c, 0x2008, 0x3850,
- 0x2d2c, 0x0b1c, 0x1740, 0x2108, 0x3950,
- 0x2e2c, 0x0a1c, 0x1640, 0x2208, 0x3a50,
- 0x2f2c, 0x091c, 0x1540, 0x2308, 0x3b50,
- 0x2f30, 0x081c, 0x1440, 0x230c, 0x3b54,
- 0x2e30, 0x071c, 0x1340, 0x220c, 0x3a54,
- 0x2d30, 0x061c, 0x1240, 0x210c, 0x3954,
- 0x2c30, 0x0620, 0x1244, 0x200c, 0x3854,
- 0x2b30, 0x0720, 0x1344, 0x1f0c, 0x3754,
- 0x2a30, 0x0820, 0x1444, 0x1e0c, 0x3654,
- 0x2a34, 0x0920, 0x1544, 0x1e10, 0x3658,
- 0x2b34, 0x0a20, 0x1644, 0x1f10, 0x3858,
- 0x2c34, 0x0b20, 0x1744, 0x2010, 0x3a58,
- 0x3024, 0x0f10, 0x1b34, 0x2400, 0x0048,
- 0x3124, 0x1010, 0x1c34, 0x2500, 0x0148,
- 0x3224, 0x1110, 0x1d34, 0x2600, 0x0248,
- 0x3324, 0x1114, 0x1d38, 0x2700, 0x0348,
- 0x3424, 0x1014, 0x1c38, 0x2800, 0x0448,
- 0x3524, 0x0f14, 0x1b38, 0x2900, 0x0548,
- 0x3528, 0x0e14, 0x1a38, 0x2904, 0x054c,
- 0x3428, 0x0d14, 0x1938, 0x2804, 0x044c,
- 0x3328, 0x0c14, 0x1838, 0x2704, 0x034c,
- 0x3228, 0x0c18, 0x183c, 0x2604, 0x024c,
- 0x3128, 0x0d18, 0x193c, 0x2504, 0x014c,
- 0x3028, 0x0e18, 0x1a3c, 0x2404, 0x004c,
- 0x302c, 0x0f18, 0x1b3c, 0x2408, 0x0050,
- 0x312c, 0x1018, 0x1c3c, 0x2508, 0x0150,
- 0x322c, 0x1118, 0x1d3c, 0x2608, 0x0250,
- 0x332c, 0x111c, 0x1d40, 0x2708, 0x0350,
- 0x342c, 0x101c, 0x1c40, 0x2808, 0x0450,
- 0x352c, 0x0f1c, 0x1b40, 0x2908, 0x0550,
- 0x3530, 0x0e1c, 0x1a40, 0x290c, 0x0554,
- 0x3430, 0x0d1c, 0x1940, 0x280c, 0x0454,
- 0x3330, 0x0c1c, 0x1840, 0x270c, 0x0354,
- 0x3230, 0x0c20, 0x1844, 0x260c, 0x0254,
- 0x3130, 0x0d20, 0x1944, 0x250c, 0x0154,
- 0x3030, 0x0e20, 0x1a44, 0x240c, 0x0054,
- 0x3034, 0x0f20, 0x1b44, 0x2410, 0x0058,
- 0x3134, 0x1020, 0x1c44, 0x2510, 0x0258,
- 0x3234, 0x1120, 0x1d44, 0x2610, 0x0458,
- 0x3624, 0x1510, 0x2134, 0x2a00, 0x0648,
- 0x3724, 0x1610, 0x2234, 0x2b00, 0x0748,
- 0x3824, 0x1710, 0x2334, 0x2c00, 0x0848,
- 0x3924, 0x1714, 0x2338, 0x2d00, 0x0948,
- 0x3a24, 0x1614, 0x2238, 0x2e00, 0x0a48,
- 0x3b24, 0x1514, 0x2138, 0x2f00, 0x0b48,
- 0x3b28, 0x1414, 0x2038, 0x2f04, 0x0b4c,
- 0x3a28, 0x1314, 0x1f38, 0x2e04, 0x0a4c,
- 0x3928, 0x1214, 0x1e38, 0x2d04, 0x094c,
- 0x3828, 0x1218, 0x1e3c, 0x2c04, 0x084c,
- 0x3728, 0x1318, 0x1f3c, 0x2b04, 0x074c,
- 0x3628, 0x1418, 0x203c, 0x2a04, 0x064c,
- 0x362c, 0x1518, 0x213c, 0x2a08, 0x0650,
- 0x372c, 0x1618, 0x223c, 0x2b08, 0x0750,
- 0x382c, 0x1718, 0x233c, 0x2c08, 0x0850,
- 0x392c, 0x171c, 0x2340, 0x2d08, 0x0950,
- 0x3a2c, 0x161c, 0x2240, 0x2e08, 0x0a50,
- 0x3b2c, 0x151c, 0x2140, 0x2f08, 0x0b50,
- 0x3b30, 0x141c, 0x2040, 0x2f0c, 0x0b54,
- 0x3a30, 0x131c, 0x1f40, 0x2e0c, 0x0a54,
- 0x3930, 0x121c, 0x1e40, 0x2d0c, 0x0954,
- 0x3830, 0x1220, 0x1e44, 0x2c0c, 0x0854,
- 0x3730, 0x1320, 0x1f44, 0x2b0c, 0x0754,
- 0x3630, 0x1420, 0x2044, 0x2a0c, 0x0654,
- 0x3634, 0x1520, 0x2144, 0x2a10, 0x0658,
- 0x3734, 0x1620, 0x2244, 0x2b10, 0x0858,
- 0x3834, 0x1720, 0x2344, 0x2c10, 0x0a58,
- 0x0024, 0x1b10, 0x2734, 0x3000, 0x0c48,
- 0x0124, 0x1c10, 0x2834, 0x3100, 0x0d48,
- 0x0224, 0x1d10, 0x2934, 0x3200, 0x0e48,
- 0x0324, 0x1d14, 0x2938, 0x3300, 0x0f48,
- 0x0424, 0x1c14, 0x2838, 0x3400, 0x1048,
- 0x0524, 0x1b14, 0x2738, 0x3500, 0x1148,
- 0x0528, 0x1a14, 0x2638, 0x3504, 0x114c,
- 0x0428, 0x1914, 0x2538, 0x3404, 0x104c,
- 0x0328, 0x1814, 0x2438, 0x3304, 0x0f4c,
- 0x0228, 0x1818, 0x243c, 0x3204, 0x0e4c,
- 0x0128, 0x1918, 0x253c, 0x3104, 0x0d4c,
- 0x0028, 0x1a18, 0x263c, 0x3004, 0x0c4c,
- 0x002c, 0x1b18, 0x273c, 0x3008, 0x0c50,
- 0x012c, 0x1c18, 0x283c, 0x3108, 0x0d50,
- 0x022c, 0x1d18, 0x293c, 0x3208, 0x0e50,
- 0x032c, 0x1d1c, 0x2940, 0x3308, 0x0f50,
- 0x042c, 0x1c1c, 0x2840, 0x3408, 0x1050,
- 0x052c, 0x1b1c, 0x2740, 0x3508, 0x1150,
- 0x0530, 0x1a1c, 0x2640, 0x350c, 0x1154,
- 0x0430, 0x191c, 0x2540, 0x340c, 0x1054,
- 0x0330, 0x181c, 0x2440, 0x330c, 0x0f54,
- 0x0230, 0x1820, 0x2444, 0x320c, 0x0e54,
- 0x0130, 0x1920, 0x2544, 0x310c, 0x0d54,
- 0x0030, 0x1a20, 0x2644, 0x300c, 0x0c54,
- 0x0034, 0x1b20, 0x2744, 0x3010, 0x0c58,
- 0x0134, 0x1c20, 0x2844, 0x3110, 0x0e58,
- 0x0234, 0x1d20, 0x2944, 0x3210, 0x1058,
- 0x0624, 0x2110, 0x2d34, 0x3600, 0x1248,
- 0x0724, 0x2210, 0x2e34, 0x3700, 0x1348,
- 0x0824, 0x2310, 0x2f34, 0x3800, 0x1448,
- 0x0924, 0x2314, 0x2f38, 0x3900, 0x1548,
- 0x0a24, 0x2214, 0x2e38, 0x3a00, 0x1648,
- 0x0b24, 0x2114, 0x2d38, 0x3b00, 0x1748,
- 0x0b28, 0x2014, 0x2c38, 0x3b04, 0x174c,
- 0x0a28, 0x1f14, 0x2b38, 0x3a04, 0x164c,
- 0x0928, 0x1e14, 0x2a38, 0x3904, 0x154c,
- 0x0828, 0x1e18, 0x2a3c, 0x3804, 0x144c,
- 0x0728, 0x1f18, 0x2b3c, 0x3704, 0x134c,
- 0x0628, 0x2018, 0x2c3c, 0x3604, 0x124c,
- 0x062c, 0x2118, 0x2d3c, 0x3608, 0x1250,
- 0x072c, 0x2218, 0x2e3c, 0x3708, 0x1350,
- 0x082c, 0x2318, 0x2f3c, 0x3808, 0x1450,
- 0x092c, 0x231c, 0x2f40, 0x3908, 0x1550,
- 0x0a2c, 0x221c, 0x2e40, 0x3a08, 0x1650,
- 0x0b2c, 0x211c, 0x2d40, 0x3b08, 0x1750,
- 0x0b30, 0x201c, 0x2c40, 0x3b0c, 0x1754,
- 0x0a30, 0x1f1c, 0x2b40, 0x3a0c, 0x1654,
- 0x0930, 0x1e1c, 0x2a40, 0x390c, 0x1554,
- 0x0830, 0x1e20, 0x2a44, 0x380c, 0x1454,
- 0x0730, 0x1f20, 0x2b44, 0x370c, 0x1354,
- 0x0630, 0x2020, 0x2c44, 0x360c, 0x1254,
- 0x0634, 0x2120, 0x2d44, 0x3610, 0x1258,
- 0x0734, 0x2220, 0x2e44, 0x3710, 0x1458,
- 0x0834, 0x2320, 0x2f44, 0x3810, 0x1658,
-};
-
-static const uint16_t dv_audio_shuffle525[10][9] = {
-  {  0, 30, 60, 20, 50, 80, 10, 40, 70 }, /* 1st channel */
-  {  6, 36, 66, 26, 56, 86, 16, 46, 76 },
-  { 12, 42, 72,  2, 32, 62, 22, 52, 82 },
-  { 18, 48, 78,  8, 38, 68, 28, 58, 88 },
-  { 24, 54, 84, 14, 44, 74,  4, 34, 64 },
-  
-  {  1, 31, 61, 21, 51, 81, 11, 41, 71 }, /* 2nd channel */
-  {  7, 37, 67, 27, 57, 87, 17, 47, 77 },
-  { 13, 43, 73,  3, 33, 63, 23, 53, 83 },
-  { 19, 49, 79,  9, 39, 69, 29, 59, 89 },
-  { 25, 55, 85, 15, 45, 75,  5, 35, 65 },
-};
-
-static const uint16_t dv_audio_shuffle625[12][9] = {
-  {   0,  36,  72,  26,  62,  98,  16,  52,  88}, /* 1st channel */
-  {   6,  42,  78,  32,  68, 104,  22,  58,  94},
-  {  12,  48,  84,   2,  38,  74,  28,  64, 100},
-  {  18,  54,  90,   8,  44,  80,  34,  70, 106},
-  {  24,  60,  96,  14,  50,  86,   4,  40,  76},  
-  {  30,  66, 102,  20,  56,  92,  10,  46,  82},
-	
-  {   1,  37,  73,  27,  63,  99,  17,  53,  89}, /* 2nd channel */
-  {   7,  43,  79,  33,  69, 105,  23,  59,  95},
-  {  13,  49,  85,   3,  39,  75,  29,  65, 101},
-  {  19,  55,  91,   9,  45,  81,  35,  71, 107},
-  {  25,  61,  97,  15,  51,  87,   5,  41,  77},  
-  {  31,  67, 103,  21,  57,  93,  11,  47,  83},
-};
-
-static const __attribute__((unused)) int dv_audio_frequency[3] = {
-    48000, 44100, 32000,
-};
-    
-static const DVprofile dv_profiles[] = {
-    { .dsf = 0,
-      .frame_size = 120000,        /* IEC 61834, SMPTE-314M - 525/60 (NTSC) */
-      .difseg_size = 10,
-      .frame_rate = 30000,
-      .ltc_divisor = 30,
-      .frame_rate_base = 1001,
-      .height = 480,
-      .width = 720,
-      .sar = {{10, 11}, {40, 33}},
-      .video_place = dv_place_411,
-      .pix_fmt = PIX_FMT_YUV411P,
-      .audio_stride = 90,
-      .audio_min_samples = { 1580, 1452, 1053 }, /* for 48, 44.1 and 32Khz */
-      .audio_samples_dist = { 1602, 1601, 1602, 1601, 1602 },
-      .audio_shuffle = dv_audio_shuffle525,
-    }, 
-    { .dsf = 1,
-      .frame_size = 144000,        /* IEC 61834 - 625/50 (PAL) */
-      .difseg_size = 12,
-      .frame_rate = 25,
-      .frame_rate_base = 1,
-      .ltc_divisor = 25,
-      .height = 576,
-      .width = 720,
-      .sar = {{59, 54}, {118, 81}},
-      .video_place = dv_place_420,
-      .pix_fmt = PIX_FMT_YUV420P,
-      .audio_stride = 108,
-      .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32Khz */
-      .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
-      .audio_shuffle = dv_audio_shuffle625,
-    },
-    { .dsf = 1,
-      .frame_size = 144000,        /* SMPTE-314M - 625/50 (PAL) */
-      .difseg_size = 12,
-      .frame_rate = 25,
-      .frame_rate_base = 1,
-      .ltc_divisor = 25,
-      .height = 576,
-      .width = 720,
-      .sar = {{59, 54}, {118, 81}},
-      .video_place = dv_place_411P,
-      .pix_fmt = PIX_FMT_YUV411P,
-      .audio_stride = 108,
-      .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32Khz */
-      .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 },
-      .audio_shuffle = dv_audio_shuffle625,
-     }
-};
-
-static inline const DVprofile* dv_frame_profile(uint8_t* frame)
-{
-    if ((frame[3] & 0x80) == 0) {      /* DSF flag */
-        return &dv_profiles[0];
-    }
-    else if ((frame[5] & 0x07) == 0) { /* APT flag */
-        return &dv_profiles[1];
-    }
-    else 
-        return &dv_profiles[2];
-}
-
-static inline const DVprofile* dv_codec_profile(AVCodecContext* codec)
-{
-    if (codec->width != 720) {
-        return NULL;
-    } 
-    else if (codec->height == 480) {
-        return &dv_profiles[0];
-    } 
-    else 
-        return &dv_profiles[1];
-}
diff --git a/ffmpeg.src/libavcodec/dvdsub.c b/ffmpeg.src/libavcodec/dvdsub.c
deleted file mode 100644
index da44c94..0000000
--- a/ffmpeg.src/libavcodec/dvdsub.c
+++ /dev/null
@@ -1,478 +0,0 @@
-/*
- * DVD subtitle decoding for ffmpeg
- * Copyright (c) 2005 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avcodec.h"
-
-//#define DEBUG
-
-typedef struct DVDSubContext {
-} DVDSubContext;
-
-static int dvdsub_init_decoder(AVCodecContext *avctx)
-{
-    return 0;
-}
-
-uint16_t getbe16(const uint8_t *p)
-{
-    return (p[0] << 8) | p[1];
-}
-
-int get_nibble(const uint8_t *buf, int nibble_offset)
-{
-    return (buf[nibble_offset >> 1] >> ((1 - (nibble_offset & 1)) << 2)) & 0xf;
-}
-
-static int decode_rle(uint8_t *bitmap, int linesize, int w, int h, 
-                      const uint8_t *buf, int nibble_offset, int buf_size)
-{
-    unsigned int v;
-    int x, y, len, color, nibble_end;
-    uint8_t *d;
-
-    nibble_end = buf_size * 2;
-    x = 0;
-    y = 0;
-    d = bitmap;
-    for(;;) {
-        if (nibble_offset >= nibble_end)
-            return -1;
-        v = get_nibble(buf, nibble_offset++);
-        if (v < 0x4) {
-            v = (v << 4) | get_nibble(buf, nibble_offset++);
-            if (v < 0x10) {
-                v = (v << 4) | get_nibble(buf, nibble_offset++);
-                if (v < 0x040) {
-                    v = (v << 4) | get_nibble(buf, nibble_offset++);
-                    if (v < 4) {
-                        v |= (w - x) << 2;
-                    }
-                }
-            }
-        }
-        len = v >> 2;
-        if (len > (w - x))
-            len = (w - x);
-        color = v & 0x03;
-        memset(d + x, color, len);
-        x += len;
-        if (x >= w) {
-            y++;
-            if (y >= h)
-                break;
-            d += linesize;
-            x = 0;
-            /* byte align */
-            nibble_offset += (nibble_offset & 1);
-        }
-    }
-    return 0;
-}
-
-static void guess_palette(uint32_t *rgba_palette,
-                          uint8_t *palette,
-                          uint8_t *alpha,
-                          uint32_t subtitle_color)
-{
-    uint8_t color_used[16];
-    int nb_opaque_colors, i, level, j, r, g, b;
-    
-    for(i = 0; i < 4; i++)
-        rgba_palette[i] = 0;
-
-    memset(color_used, 0, 16);
-    nb_opaque_colors = 0;
-    for(i = 0; i < 4; i++) {
-        if (alpha[i] != 0 && !color_used[palette[i]]) {
-            color_used[palette[i]] = 1;
-            nb_opaque_colors++;
-        }
-    }
-    
-    if (nb_opaque_colors == 0)
-        return;
-    
-    j = nb_opaque_colors;
-    memset(color_used, 0, 16);
-    for(i = 0; i < 4; i++) {
-        if (alpha[i] != 0) {
-            if (!color_used[palette[i]])  {
-                level = (0xff * j) / nb_opaque_colors;
-                r = (((subtitle_color >> 16) & 0xff) * level) >> 8;
-                g = (((subtitle_color >> 8) & 0xff) * level) >> 8;
-                b = (((subtitle_color >> 0) & 0xff) * level) >> 8;
-                rgba_palette[i] = b | (g << 8) | (r << 16) | ((alpha[i] * 17) << 24);
-                color_used[palette[i]] = (i + 1);
-                j--;
-            } else {
-                rgba_palette[i] = (rgba_palette[color_used[palette[i]] - 1] & 0x00ffffff) |
-                                    ((alpha[i] * 17) << 24);
-            }
-        }
-    }
-}
-
-static int decode_dvd_subtitles(AVSubtitle *sub_header, 
-                                const uint8_t *buf, int buf_size)
-{
-    int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos;
-    uint8_t palette[4], alpha[4];
-    int date;
-    int i;
-    int is_menu = 0;
-    
-    if (buf_size < 4)
-        return -1;
-    sub_header->rects = NULL;
-    sub_header->num_rects = 0;
-    sub_header->start_display_time = 0;
-    sub_header->end_display_time = 0;
-
-    cmd_pos = getbe16(buf + 2);
-    while ((cmd_pos + 4) < buf_size) {
-        date = getbe16(buf + cmd_pos);
-        next_cmd_pos = getbe16(buf + cmd_pos + 2);
-#ifdef DEBUG
-        av_log(NULL, AV_LOG_INFO, "cmd_pos=0x%04x next=0x%04x date=%d\n", 
-               cmd_pos, next_cmd_pos, date);
-#endif
-        pos = cmd_pos + 4;
-        offset1 = -1;
-        offset2 = -1;
-        x1 = y1 = x2 = y2 = 0;
-        while (pos < buf_size) {
-            cmd = buf[pos++];
-#ifdef DEBUG
-            av_log(NULL, AV_LOG_INFO, "cmd=%02x\n", cmd);
-#endif
-            switch(cmd) {
-            case 0x00:
-                /* menu subpicture */
-                is_menu = 1;
-                break;
-            case 0x01:
-                /* set start date */
-                sub_header->start_display_time = (date << 10) / 90;
-                break;
-            case 0x02:
-                /* set end date */
-                sub_header->end_display_time = (date << 10) / 90;
-                break;
-            case 0x03:
-                /* set palette */
-                if ((buf_size - pos) < 2)
-                    goto fail;
-                palette[3] = buf[pos] >> 4;
-                palette[2] = buf[pos] & 0x0f;
-                palette[1] = buf[pos + 1] >> 4;
-                palette[0] = buf[pos + 1] & 0x0f;
-                pos += 2;
-                break;
-            case 0x04:
-                /* set alpha */
-                if ((buf_size - pos) < 2)
-                    goto fail;
-                alpha[3] = buf[pos] >> 4;
-                alpha[2] = buf[pos] & 0x0f;
-                alpha[1] = buf[pos + 1] >> 4;
-                alpha[0] = buf[pos + 1] & 0x0f;
-                pos += 2;
-#ifdef DEBUG
-            av_log(NULL, AV_LOG_INFO, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
-#endif
-                break;
-            case 0x05:
-                if ((buf_size - pos) < 6)
-                    goto fail;
-                x1 = (buf[pos] << 4) | (buf[pos + 1] >> 4);
-                x2 = ((buf[pos + 1] & 0x0f) << 8) | buf[pos + 2];
-                y1 = (buf[pos + 3] << 4) | (buf[pos + 4] >> 4);
-                y2 = ((buf[pos + 4] & 0x0f) << 8) | buf[pos + 5];
-#ifdef DEBUG
-                av_log(NULL, AV_LOG_INFO, "x1=%d x2=%d y1=%d y2=%d\n",
-                       x1, x2, y1, y2);
-#endif
-                pos += 6;
-                break;
-            case 0x06:
-                if ((buf_size - pos) < 4)
-                    goto fail;
-                offset1 = getbe16(buf + pos);
-                offset2 = getbe16(buf + pos + 2);
-#ifdef DEBUG
-                av_log(NULL, AV_LOG_INFO, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
-#endif
-                pos += 4;
-                break;
-            case 0xff:
-            default:
-                goto the_end;
-            }
-        }
-    the_end:
-        if (offset1 >= 0) {
-            int w, h;
-            uint8_t *bitmap;
-            
-            /* decode the bitmap */
-            w = x2 - x1 + 1;
-            if (w < 0)
-                w = 0;
-            h = y2 - y1;
-            if (h < 0)
-                h = 0;
-            if (w > 0 && h > 0) {
-                if (sub_header->rects != NULL) {
-                    for (i = 0; i < sub_header->num_rects; i++) {
-                        av_free(sub_header->rects[i].bitmap);
-                        av_free(sub_header->rects[i].rgba_palette);
-                    }
-                    av_freep(&sub_header->rects);
-                    sub_header->num_rects = 0;
-                }
-
-                bitmap = av_malloc(w * h);
-                sub_header->rects = av_mallocz(sizeof(AVSubtitleRect));
-                sub_header->num_rects = 1;
-                sub_header->rects[0].rgba_palette = av_malloc(4 * 4);
-                decode_rle(bitmap, w * 2, w, h / 2,
-                           buf, offset1 * 2, buf_size);
-                decode_rle(bitmap + w, w * 2, w, h / 2,
-                           buf, offset2 * 2, buf_size);
-                guess_palette(sub_header->rects[0].rgba_palette,
-                              palette, alpha, 0xffff00);
-                sub_header->rects[0].x = x1;
-                sub_header->rects[0].y = y1;
-                sub_header->rects[0].w = w;
-                sub_header->rects[0].h = h;
-                sub_header->rects[0].nb_colors = 4;
-                sub_header->rects[0].linesize = w;
-                sub_header->rects[0].bitmap = bitmap;
-            }
-        }
-        if (next_cmd_pos == cmd_pos)
-            break;
-        cmd_pos = next_cmd_pos;
-    }
-    if (sub_header->num_rects > 0)
-        return is_menu;
- fail:
-    return -1;
-}
-
-static int is_transp(const uint8_t *buf, int pitch, int n, 
-                     const uint8_t *transp_color)
-{
-    int i;
-    for(i = 0; i < n; i++) {
-        if (!transp_color[*buf])
-            return 0;
-        buf += pitch;
-    }
-    return 1;
-}
-
-/* return 0 if empty rectangle, 1 if non empty */
-static int find_smallest_bounding_rectangle(AVSubtitle *s)
-{
-    uint8_t transp_color[256];
-    int y1, y2, x1, x2, y, w, h, i;
-    uint8_t *bitmap;
-
-    if (s->num_rects == 0 || s->rects == NULL || s->rects[0].w <= 0 || s->rects[0].h <= 0)
-        return 0;
-
-    memset(transp_color, 0, 256);
-    for(i = 0; i < s->rects[0].nb_colors; i++) {
-        if ((s->rects[0].rgba_palette[i] >> 24) == 0)
-            transp_color[i] = 1;
-    }
-    y1 = 0;
-    while (y1 < s->rects[0].h && is_transp(s->rects[0].bitmap + y1 * s->rects[0].linesize,
-                                  1, s->rects[0].w, transp_color))
-        y1++;
-    if (y1 == s->rects[0].h) {
-        av_freep(&s->rects[0].bitmap);
-        s->rects[0].w = s->rects[0].h = 0;
-        return 0;
-    }
-
-    y2 = s->rects[0].h - 1;
-    while (y2 > 0 && is_transp(s->rects[0].bitmap + y2 * s->rects[0].linesize, 1,
-                               s->rects[0].w, transp_color))
-        y2--;
-    x1 = 0;
-    while (x1 < (s->rects[0].w - 1) && is_transp(s->rects[0].bitmap + x1, s->rects[0].linesize,
-                                        s->rects[0].h, transp_color))
-        x1++;
-    x2 = s->rects[0].w - 1;
-    while (x2 > 0 && is_transp(s->rects[0].bitmap + x2, s->rects[0].linesize, s->rects[0].h,
-                                  transp_color))
-        x2--;
-    w = x2 - x1 + 1;
-    h = y2 - y1 + 1;
-    bitmap = av_malloc(w * h);
-    if (!bitmap)
-        return 1;
-    for(y = 0; y < h; y++) {
-        memcpy(bitmap + w * y, s->rects[0].bitmap + x1 + (y1 + y) * s->rects[0].linesize, w);
-    }
-    av_freep(&s->rects[0].bitmap);
-    s->rects[0].bitmap = bitmap;
-    s->rects[0].linesize = w;
-    s->rects[0].w = w;
-    s->rects[0].h = h;
-    s->rects[0].x += x1;
-    s->rects[0].y += y1;
-    return 1;
-}
-
-static int dvdsub_close_decoder(AVCodecContext *avctx)
-{
-    return 0;
-}
-
-#ifdef DEBUG
-#undef fprintf
-static void ppm_save(const char *filename, uint8_t *bitmap, int w, int h,
-                     uint32_t *rgba_palette)
-{
-    int x, y, v;
-    FILE *f;
-
-    f = fopen(filename, "w");
-    if (!f) {
-        perror(filename);
-        exit(1);
-    }
-    fprintf(f, "P6\n"
-            "%d %d\n"
-            "%d\n",
-            w, h, 255);
-    for(y = 0; y < h; y++) {
-        for(x = 0; x < w; x++) {
-            v = rgba_palette[bitmap[y * w + x]];
-            putc((v >> 16) & 0xff, f);
-            putc((v >> 8) & 0xff, f);
-            putc((v >> 0) & 0xff, f);
-        }
-    }
-    fclose(f);
-}
-#endif
-
-static int dvdsub_decode(AVCodecContext *avctx,
-                         void *data, int *data_size,
-                         uint8_t *buf, int buf_size)
-{
-    AVSubtitle *sub = (void *)data;
-    int is_menu;
-
-    is_menu = decode_dvd_subtitles(sub, buf, buf_size);
-
-    if (is_menu < 0) {
-    no_subtitle:
-        *data_size = 0;
-
-        return buf_size;
-    }
-    if (!is_menu && find_smallest_bounding_rectangle(sub) == 0)
-        goto no_subtitle;
-
-#if defined(DEBUG)
-    av_log(NULL, AV_LOG_INFO, "start=%d ms end =%d ms\n", 
-           sub->start_display_time,
-           sub->end_display_time);
-    ppm_save("/tmp/a.ppm", sub->rects[0].bitmap,
-             sub->rects[0].w, sub->rects[0].h, sub->rects[0].rgba_palette);
-#endif
-
-    *data_size = 1;
-    return buf_size;
-}
-
-AVCodec dvdsub_decoder = {
-    "dvdsub",
-    CODEC_TYPE_SUBTITLE,
-    CODEC_ID_DVD_SUBTITLE,
-    sizeof(DVDSubContext),
-    dvdsub_init_decoder,
-    NULL,
-    dvdsub_close_decoder,
-    dvdsub_decode,
-};
-
-/* parser definition */
-typedef struct DVDSubParseContext {
-    uint8_t *packet;
-    int packet_len;
-    int packet_index;
-} DVDSubParseContext;
-
-static int dvdsub_parse_init(AVCodecParserContext *s)
-{
-    return 0;
-}
-
-static int dvdsub_parse(AVCodecParserContext *s,
-                        AVCodecContext *avctx,
-                        uint8_t **poutbuf, int *poutbuf_size, 
-                        const uint8_t *buf, int buf_size)
-{
-    DVDSubParseContext *pc = s->priv_data;
-    
-    if (pc->packet_index == 0) {
-        if (buf_size < 2)
-            return 0;
-        pc->packet_len = (buf[0] << 8) | buf[1];
-        av_freep(&pc->packet);
-        pc->packet = av_malloc(pc->packet_len);
-    }
-    if (pc->packet) {
-        if (pc->packet_index + buf_size <= pc->packet_len) {
-            memcpy(pc->packet + pc->packet_index, buf, buf_size);
-            pc->packet_index += buf_size;
-            if (pc->packet_index >= pc->packet_len) {
-                *poutbuf = pc->packet;
-                *poutbuf_size = pc->packet_len;
-                pc->packet_index = 0;
-                return buf_size;
-            }
-        } else {
-            /* erroneous size */
-            pc->packet_index = 0;
-        }
-    }
-    *poutbuf = NULL;
-    *poutbuf_size = 0;
-    return buf_size;
-}
-
-static void dvdsub_parse_close(AVCodecParserContext *s)
-{
-    DVDSubParseContext *pc = s->priv_data;
-    av_freep(&pc->packet);
-}
-
-AVCodecParser dvdsub_parser = {
-    { CODEC_ID_DVD_SUBTITLE },
-    sizeof(DVDSubParseContext),
-    dvdsub_parse_init,
-    dvdsub_parse,
-    dvdsub_parse_close,
-};
diff --git a/ffmpeg.src/libavcodec/error_resilience.c b/ffmpeg.src/libavcodec/error_resilience.c
deleted file mode 100644
index 2bb2276..0000000
--- a/ffmpeg.src/libavcodec/error_resilience.c
+++ /dev/null
@@ -1,1028 +0,0 @@
-/*
- * Error resilience / concealment
- *
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-/**
- * @file error_resilience.c
- * Error resilience / concealment.
- */
-
-#include <limits.h>
- 
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-#include "common.h"
-
-static void decode_mb(MpegEncContext *s){
-    s->dest[0] = s->current_picture.data[0] + (s->mb_y * 16* s->linesize  ) + s->mb_x * 16;
-    s->dest[1] = s->current_picture.data[1] + (s->mb_y * 8 * s->uvlinesize) + s->mb_x * 8;
-    s->dest[2] = s->current_picture.data[2] + (s->mb_y * 8 * s->uvlinesize) + s->mb_x * 8;
-
-    MPV_decode_mb(s, s->block);    
-}
-
-/**
- * replaces the current MB with a flat dc only version.
- */
-static void put_dc(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int mb_x, int mb_y)
-{
-    int dc, dcu, dcv, y, i;
-    for(i=0; i<4; i++){
-        dc= s->dc_val[0][mb_x*2 + (i&1) + (mb_y*2 + (i>>1))*s->b8_stride];
-        if(dc<0) dc=0;
-        else if(dc>2040) dc=2040;
-        for(y=0; y<8; y++){
-            int x;
-            for(x=0; x<8; x++){
-                dest_y[x + (i&1)*8 + (y + (i>>1)*8)*s->linesize]= dc/8;
-            }
-        }
-    }
-    dcu = s->dc_val[1][mb_x + mb_y*s->mb_stride];
-    dcv = s->dc_val[2][mb_x + mb_y*s->mb_stride];
-    if     (dcu<0   ) dcu=0;
-    else if(dcu>2040) dcu=2040;
-    if     (dcv<0   ) dcv=0;
-    else if(dcv>2040) dcv=2040;
-    for(y=0; y<8; y++){
-        int x;
-        for(x=0; x<8; x++){
-            dest_cb[x + y*(s->uvlinesize)]= dcu/8;
-            dest_cr[x + y*(s->uvlinesize)]= dcv/8;
-        }
-    }
-}
-
-static void filter181(int16_t *data, int width, int height, int stride){
-    int x,y;
-
-    /* horizontal filter */
-    for(y=1; y<height-1; y++){
-        int prev_dc= data[0 + y*stride];
-
-        for(x=1; x<width-1; x++){
-            int dc;
-            
-            dc= - prev_dc 
-                + data[x     + y*stride]*8
-                - data[x + 1 + y*stride];
-            dc= (dc*10923 + 32768)>>16;
-            prev_dc= data[x + y*stride];
-            data[x + y*stride]= dc;
-        }
-    }
-    
-    /* vertical filter */
-    for(x=1; x<width-1; x++){
-        int prev_dc= data[x];
-
-        for(y=1; y<height-1; y++){
-            int dc;
-            
-            dc= - prev_dc 
-                + data[x +  y   *stride]*8
-                - data[x + (y+1)*stride];
-            dc= (dc*10923 + 32768)>>16;
-            prev_dc= data[x + y*stride];
-            data[x + y*stride]= dc;
-        }
-    }
-}
-
-/**
- * guess the dc of blocks which dont have a undamaged dc
- * @param w	width in 8 pixel blocks
- * @param h	height in 8 pixel blocks
- */
-static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, int is_luma){
-    int b_x, b_y;
-
-    for(b_y=0; b_y<h; b_y++){
-        for(b_x=0; b_x<w; b_x++){
-            int color[4]={1024,1024,1024,1024};
-            int distance[4]={9999,9999,9999,9999};
-            int mb_index, error, j;
-            int64_t guess, weight_sum;
-            
-            mb_index= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
-            
-            error= s->error_status_table[mb_index];
-            
-            if(IS_INTER(s->current_picture.mb_type[mb_index])) continue; //inter
-            if(!(error&DC_ERROR)) continue;           //dc-ok
-            
-            /* right block */
-            for(j=b_x+1; j<w; j++){
-                int mb_index_j= (j>>is_luma) + (b_y>>is_luma)*s->mb_stride;
-                int error_j= s->error_status_table[mb_index_j];
-                int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]);
-                if(intra_j==0 || !(error_j&DC_ERROR)){
-                    color[0]= dc[j + b_y*stride];
-                    distance[0]= j-b_x;
-                    break;
-                }
-            }
-            
-            /* left block */
-            for(j=b_x-1; j>=0; j--){
-                int mb_index_j= (j>>is_luma) + (b_y>>is_luma)*s->mb_stride;
-                int error_j= s->error_status_table[mb_index_j];
-                int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]);
-                if(intra_j==0 || !(error_j&DC_ERROR)){
-                    color[1]= dc[j + b_y*stride];
-                    distance[1]= b_x-j;
-                    break;
-                }
-            }
-
-            /* bottom block */
-            for(j=b_y+1; j<h; j++){
-                int mb_index_j= (b_x>>is_luma) + (j>>is_luma)*s->mb_stride;
-                int error_j= s->error_status_table[mb_index_j];
-                int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]);
-                if(intra_j==0 || !(error_j&DC_ERROR)){
-                    color[2]= dc[b_x + j*stride];
-                    distance[2]= j-b_y;
-                    break;
-                }
-            }
-
-            /* top block */
-            for(j=b_y-1; j>=0; j--){
-                int mb_index_j= (b_x>>is_luma) + (j>>is_luma)*s->mb_stride;
-                int error_j= s->error_status_table[mb_index_j];
-                int intra_j= IS_INTRA(s->current_picture.mb_type[mb_index_j]);
-                if(intra_j==0 || !(error_j&DC_ERROR)){
-                    color[3]= dc[b_x + j*stride];
-                    distance[3]= b_y-j;
-                    break;
-                }
-            }
-            
-            weight_sum=0;
-            guess=0;
-            for(j=0; j<4; j++){
-                int64_t weight= 256*256*256*16/distance[j];
-                guess+= weight*(int64_t)color[j];
-                weight_sum+= weight;
-            }
-            guess= (guess + weight_sum/2) / weight_sum;
-
-            dc[b_x + b_y*stride]= guess;
-        }
-    }
-}
-
-/**
- * simple horizontal deblocking filter used for error resilience
- * @param w	width in 8 pixel blocks
- * @param h	height in 8 pixel blocks
- */
-static void h_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int stride, int is_luma){
-    int b_x, b_y;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-    for(b_y=0; b_y<h; b_y++){
-        for(b_x=0; b_x<w-1; b_x++){
-            int y;
-            int left_status = s->error_status_table[( b_x   >>is_luma) + (b_y>>is_luma)*s->mb_stride];
-            int right_status= s->error_status_table[((b_x+1)>>is_luma) + (b_y>>is_luma)*s->mb_stride];
-            int left_intra=   IS_INTRA(s->current_picture.mb_type      [( b_x   >>is_luma) + (b_y>>is_luma)*s->mb_stride]);
-            int right_intra=  IS_INTRA(s->current_picture.mb_type      [((b_x+1)>>is_luma) + (b_y>>is_luma)*s->mb_stride]);
-            int left_damage =  left_status&(DC_ERROR|AC_ERROR|MV_ERROR);
-            int right_damage= right_status&(DC_ERROR|AC_ERROR|MV_ERROR);
-            int offset= b_x*8 + b_y*stride*8;
-            int16_t *left_mv=  s->current_picture.motion_val[0][s->b8_stride*(b_y<<(1-is_luma)) + ( b_x   <<(1-is_luma))];
-            int16_t *right_mv= s->current_picture.motion_val[0][s->b8_stride*(b_y<<(1-is_luma)) + ((b_x+1)<<(1-is_luma))];
-            
-            if(!(left_damage||right_damage)) continue; // both undamaged
-            
-            if(   (!left_intra) && (!right_intra) 
-               && ABS(left_mv[0]-right_mv[0]) + ABS(left_mv[1]+right_mv[1]) < 2) continue;
-            
-            for(y=0; y<8; y++){
-                int a,b,c,d;
-                
-                a= dst[offset + 7 + y*stride] - dst[offset + 6 + y*stride];
-                b= dst[offset + 8 + y*stride] - dst[offset + 7 + y*stride];
-                c= dst[offset + 9 + y*stride] - dst[offset + 8 + y*stride];
-                
-                d= ABS(b) - ((ABS(a) + ABS(c) + 1)>>1);
-                d= FFMAX(d, 0);
-                if(b<0) d= -d;
-                
-                if(d==0) continue;
-
-                if(!(left_damage && right_damage))
-                    d= d*16/9;
-                
-                if(left_damage){
-                    dst[offset + 7 + y*stride] = cm[dst[offset + 7 + y*stride] + ((d*7)>>4)];
-                    dst[offset + 6 + y*stride] = cm[dst[offset + 6 + y*stride] + ((d*5)>>4)];
-                    dst[offset + 5 + y*stride] = cm[dst[offset + 5 + y*stride] + ((d*3)>>4)];
-                    dst[offset + 4 + y*stride] = cm[dst[offset + 4 + y*stride] + ((d*1)>>4)];
-                }
-                if(right_damage){
-                    dst[offset + 8 + y*stride] = cm[dst[offset + 8 + y*stride] - ((d*7)>>4)];
-                    dst[offset + 9 + y*stride] = cm[dst[offset + 9 + y*stride] - ((d*5)>>4)];
-                    dst[offset + 10+ y*stride] = cm[dst[offset +10 + y*stride] - ((d*3)>>4)];
-                    dst[offset + 11+ y*stride] = cm[dst[offset +11 + y*stride] - ((d*1)>>4)];
-                }
-            }
-        }
-    }
-}
-
-/**
- * simple vertical deblocking filter used for error resilience
- * @param w	width in 8 pixel blocks
- * @param h	height in 8 pixel blocks
- */
-static void v_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int stride, int is_luma){
-    int b_x, b_y;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-    for(b_y=0; b_y<h-1; b_y++){
-        for(b_x=0; b_x<w; b_x++){
-            int x;
-            int top_status   = s->error_status_table[(b_x>>is_luma) + ( b_y   >>is_luma)*s->mb_stride];
-            int bottom_status= s->error_status_table[(b_x>>is_luma) + ((b_y+1)>>is_luma)*s->mb_stride];
-            int top_intra=     IS_INTRA(s->current_picture.mb_type      [(b_x>>is_luma) + ( b_y   >>is_luma)*s->mb_stride]);
-            int bottom_intra=  IS_INTRA(s->current_picture.mb_type      [(b_x>>is_luma) + ((b_y+1)>>is_luma)*s->mb_stride]);
-            int top_damage =      top_status&(DC_ERROR|AC_ERROR|MV_ERROR);
-            int bottom_damage= bottom_status&(DC_ERROR|AC_ERROR|MV_ERROR);
-            int offset= b_x*8 + b_y*stride*8;
-            int16_t *top_mv=    s->current_picture.motion_val[0][s->b8_stride*( b_y   <<(1-is_luma)) + (b_x<<(1-is_luma))];
-            int16_t *bottom_mv= s->current_picture.motion_val[0][s->b8_stride*((b_y+1)<<(1-is_luma)) + (b_x<<(1-is_luma))];
-            
-            if(!(top_damage||bottom_damage)) continue; // both undamaged
-            
-            if(   (!top_intra) && (!bottom_intra) 
-               && ABS(top_mv[0]-bottom_mv[0]) + ABS(top_mv[1]+bottom_mv[1]) < 2) continue;
-            
-            for(x=0; x<8; x++){
-                int a,b,c,d;
-                
-                a= dst[offset + x + 7*stride] - dst[offset + x + 6*stride];
-                b= dst[offset + x + 8*stride] - dst[offset + x + 7*stride];
-                c= dst[offset + x + 9*stride] - dst[offset + x + 8*stride];
-                
-                d= ABS(b) - ((ABS(a) + ABS(c)+1)>>1);
-                d= FFMAX(d, 0);
-                if(b<0) d= -d;
-                
-                if(d==0) continue;
-
-                if(!(top_damage && bottom_damage))
-                    d= d*16/9;
-                
-                if(top_damage){
-                    dst[offset + x +  7*stride] = cm[dst[offset + x +  7*stride] + ((d*7)>>4)];
-                    dst[offset + x +  6*stride] = cm[dst[offset + x +  6*stride] + ((d*5)>>4)];
-                    dst[offset + x +  5*stride] = cm[dst[offset + x +  5*stride] + ((d*3)>>4)];
-                    dst[offset + x +  4*stride] = cm[dst[offset + x +  4*stride] + ((d*1)>>4)];
-                }
-                if(bottom_damage){
-                    dst[offset + x +  8*stride] = cm[dst[offset + x +  8*stride] - ((d*7)>>4)];
-                    dst[offset + x +  9*stride] = cm[dst[offset + x +  9*stride] - ((d*5)>>4)];
-                    dst[offset + x + 10*stride] = cm[dst[offset + x + 10*stride] - ((d*3)>>4)];
-                    dst[offset + x + 11*stride] = cm[dst[offset + x + 11*stride] - ((d*1)>>4)];
-                }
-            }
-        }
-    }
-}
-
-static void guess_mv(MpegEncContext *s){
-    uint8_t fixed[s->mb_stride * s->mb_height];
-#define MV_FROZEN    3
-#define MV_CHANGED   2
-#define MV_UNCHANGED 1
-    const int mb_stride = s->mb_stride;
-    const int mb_width = s->mb_width;
-    const int mb_height= s->mb_height;
-    int i, depth, num_avail;
-    int mb_x, mb_y;
-   
-    num_avail=0;
-    for(i=0; i<s->mb_num; i++){
-        const int mb_xy= s->mb_index2xy[ i ];
-        int f=0;
-        int error= s->error_status_table[mb_xy];
-
-        if(IS_INTRA(s->current_picture.mb_type[mb_xy])) f=MV_FROZEN; //intra //FIXME check
-        if(!(error&MV_ERROR)) f=MV_FROZEN;           //inter with undamaged MV
-        
-        fixed[mb_xy]= f;
-        if(f==MV_FROZEN)
-            num_avail++;
-    }
-    
-    if((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) || num_avail <= mb_width/2){
-        for(mb_y=0; mb_y<s->mb_height; mb_y++){
-            for(mb_x=0; mb_x<s->mb_width; mb_x++){
-                const int mb_xy= mb_x + mb_y*s->mb_stride;
-                
-                if(IS_INTRA(s->current_picture.mb_type[mb_xy]))  continue;
-                if(!(s->error_status_table[mb_xy]&MV_ERROR)) continue;
-
-                s->mv_dir = MV_DIR_FORWARD;
-                s->mb_intra=0;
-                s->mv_type = MV_TYPE_16X16;
-                s->mb_skipped=0;
-
-		s->dsp.clear_blocks(s->block[0]);
-
-                s->mb_x= mb_x;
-                s->mb_y= mb_y;
-                s->mv[0][0][0]= 0;
-                s->mv[0][0][1]= 0;
-                decode_mb(s);
-            }
-        }
-        return;
-    }
-    
-    for(depth=0;; depth++){
-        int changed, pass, none_left;
-
-        none_left=1;
-        changed=1;
-        for(pass=0; (changed || pass<2) && pass<10; pass++){
-            int mb_x, mb_y;
-int score_sum=0;
- 
-            changed=0;
-            for(mb_y=0; mb_y<s->mb_height; mb_y++){
-                for(mb_x=0; mb_x<s->mb_width; mb_x++){
-                    const int mb_xy= mb_x + mb_y*s->mb_stride;
-                    int mv_predictor[8][2]={{0}};
-                    int pred_count=0;
-                    int j;
-                    int best_score=256*256*256*64;
-                    int best_pred=0;
-                    const int mot_stride= s->b8_stride;
-                    const int mot_index= mb_x*2 + mb_y*2*mot_stride;
-                    int prev_x= s->current_picture.motion_val[0][mot_index][0];
-                    int prev_y= s->current_picture.motion_val[0][mot_index][1];
-
-                    if((mb_x^mb_y^pass)&1) continue;
-                    
-                    if(fixed[mb_xy]==MV_FROZEN) continue;
-                    assert(!IS_INTRA(s->current_picture.mb_type[mb_xy]));
-                    assert(s->last_picture_ptr && s->last_picture_ptr->data[0]);
-                    
-                    j=0;
-                    if(mb_x>0           && fixed[mb_xy-1        ]==MV_FROZEN) j=1;
-                    if(mb_x+1<mb_width  && fixed[mb_xy+1        ]==MV_FROZEN) j=1;
-                    if(mb_y>0           && fixed[mb_xy-mb_stride]==MV_FROZEN) j=1;
-                    if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]==MV_FROZEN) j=1;
-                    if(j==0) continue;
-
-                    j=0;
-                    if(mb_x>0           && fixed[mb_xy-1        ]==MV_CHANGED) j=1;
-                    if(mb_x+1<mb_width  && fixed[mb_xy+1        ]==MV_CHANGED) j=1;
-                    if(mb_y>0           && fixed[mb_xy-mb_stride]==MV_CHANGED) j=1;
-                    if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]==MV_CHANGED) j=1;
-                    if(j==0 && pass>1) continue;
-                    
-                    none_left=0;
-                    
-                    if(mb_x>0 && fixed[mb_xy-1]){
-                        mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - 2][0];
-                        mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - 2][1];
-                        pred_count++;
-                    }
-                    if(mb_x+1<mb_width && fixed[mb_xy+1]){
-                        mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + 2][0];
-                        mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + 2][1];
-                        pred_count++;
-                    }
-                    if(mb_y>0 && fixed[mb_xy-mb_stride]){
-                        mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - mot_stride*2][0];
-                        mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - mot_stride*2][1];
-                        pred_count++;
-                    }
-                    if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){
-                        mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + mot_stride*2][0];
-                        mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + mot_stride*2][1];
-                        pred_count++;
-                    }
-                    if(pred_count==0) continue;
-                    
-                    if(pred_count>1){
-                        int sum_x=0, sum_y=0;
-                        int max_x, max_y, min_x, min_y;
-
-                        for(j=0; j<pred_count; j++){
-                            sum_x+= mv_predictor[j][0];
-                            sum_y+= mv_predictor[j][1];
-                        }
-                    
-                        /* mean */
-                        mv_predictor[pred_count][0] = sum_x/j;
-                        mv_predictor[pred_count][1] = sum_y/j;
-                    
-                        /* median */
-                        if(pred_count>=3){
-                            min_y= min_x= 99999;
-                            max_y= max_x=-99999;
-                        }else{
-                            min_x=min_y=max_x=max_y=0;
-                        }
-                        for(j=0; j<pred_count; j++){
-                            max_x= FFMAX(max_x, mv_predictor[j][0]);
-                            max_y= FFMAX(max_y, mv_predictor[j][1]);
-                            min_x= FFMIN(min_x, mv_predictor[j][0]);
-                            min_y= FFMIN(min_y, mv_predictor[j][1]);
-                        }
-                        mv_predictor[pred_count+1][0] = sum_x - max_x - min_x;
-                        mv_predictor[pred_count+1][1] = sum_y - max_y - min_y;
-                        
-                        if(pred_count==4){
-                            mv_predictor[pred_count+1][0] /= 2;
-                            mv_predictor[pred_count+1][1] /= 2;
-                        }
-                        pred_count+=2;
-                    }
-                    
-                    /* zero MV */
-                    pred_count++;
-
-                    /* last MV */
-                    mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index][0];
-                    mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index][1];
-                    pred_count++;                    
-                    
-                    s->mv_dir = MV_DIR_FORWARD;
-                    s->mb_intra=0;
-                    s->mv_type = MV_TYPE_16X16;
-                    s->mb_skipped=0;
-
-		    s->dsp.clear_blocks(s->block[0]);
-
-                    s->mb_x= mb_x;
-                    s->mb_y= mb_y;
-
-                    for(j=0; j<pred_count; j++){
-                        int score=0;
-                        uint8_t *src= s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize;
-
-                        s->current_picture.motion_val[0][mot_index][0]= s->mv[0][0][0]= mv_predictor[j][0];
-                        s->current_picture.motion_val[0][mot_index][1]= s->mv[0][0][1]= mv_predictor[j][1];
-
-                        decode_mb(s);
-                        
-                        if(mb_x>0 && fixed[mb_xy-1]){
-                            int k;
-                            for(k=0; k<16; k++)
-                                score += ABS(src[k*s->linesize-1 ]-src[k*s->linesize   ]);
-                        }
-                        if(mb_x+1<mb_width && fixed[mb_xy+1]){
-                            int k;
-                            for(k=0; k<16; k++)
-                                score += ABS(src[k*s->linesize+15]-src[k*s->linesize+16]);
-                        }
-                        if(mb_y>0 && fixed[mb_xy-mb_stride]){
-                            int k;
-                            for(k=0; k<16; k++)
-                                score += ABS(src[k-s->linesize   ]-src[k               ]);
-                        }
-                        if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){
-                            int k;
-                            for(k=0; k<16; k++)
-                                score += ABS(src[k+s->linesize*15]-src[k+s->linesize*16]);
-                        }
-                        
-                        if(score <= best_score){ // <= will favor the last MV
-                            best_score= score;
-                            best_pred= j;
-                        }
-                    }
-score_sum+= best_score;
-//FIXME no need to set s->current_picture.motion_val[0][mot_index][0] explicit
-                    s->current_picture.motion_val[0][mot_index][0]= s->mv[0][0][0]= mv_predictor[best_pred][0];
-                    s->current_picture.motion_val[0][mot_index][1]= s->mv[0][0][1]= mv_predictor[best_pred][1];
-
-                    decode_mb(s);
-
-                    
-                    if(s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y){
-                        fixed[mb_xy]=MV_CHANGED;
-                        changed++;
-                    }else
-                        fixed[mb_xy]=MV_UNCHANGED;
-                }
-            }
-
-//            printf(".%d/%d", changed, score_sum); fflush(stdout);
-        }
-        
-        if(none_left) 
-            return;
-            
-        for(i=0; i<s->mb_num; i++){
-            int mb_xy= s->mb_index2xy[i];
-            if(fixed[mb_xy])
-                fixed[mb_xy]=MV_FROZEN;
-        }
-//        printf(":"); fflush(stdout);
-    }
-}
-    
-static int is_intra_more_likely(MpegEncContext *s){
-    int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y;
-    
-    if(s->last_picture_ptr==NULL) return 1; //no previous frame available -> use spatial prediction
-
-    undamaged_count=0;
-    for(i=0; i<s->mb_num; i++){
-        const int mb_xy= s->mb_index2xy[i];
-        const int error= s->error_status_table[mb_xy];
-        if(!((error&DC_ERROR) && (error&MV_ERROR)))
-            undamaged_count++;
-    }
-    
-    if(undamaged_count < 5) return 0; //allmost all MBs damaged -> use temporal prediction
-    
-    skip_amount= FFMAX(undamaged_count/50, 1); //check only upto 50 MBs 
-    is_intra_likely=0;
-
-    j=0;
-    for(mb_y= 0; mb_y<s->mb_height-1; mb_y++){
-        for(mb_x= 0; mb_x<s->mb_width; mb_x++){
-            int error;
-            const int mb_xy= mb_x + mb_y*s->mb_stride;
-
-            error= s->error_status_table[mb_xy];
-            if((error&DC_ERROR) && (error&MV_ERROR))
-                continue; //skip damaged
-        
-            j++;    
-            if((j%skip_amount) != 0) continue; //skip a few to speed things up
-    
-            if(s->pict_type==I_TYPE){
-                uint8_t *mb_ptr     = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize;
-                uint8_t *last_mb_ptr= s->last_picture.data   [0] + mb_x*16 + mb_y*16*s->linesize;
-    
-		is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr                    , s->linesize, 16);
-                is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize, 16);
-            }else{
-                if(IS_INTRA(s->current_picture.mb_type[mb_xy]))
-                   is_intra_likely++;
-                else
-                   is_intra_likely--;
-            }
-        }
-    }
-//printf("is_intra_likely: %d type:%d\n", is_intra_likely, s->pict_type);
-    return is_intra_likely > 0;    
-}
-
-void ff_er_frame_start(MpegEncContext *s){
-    if(!s->error_resilience) return;
-
-    memset(s->error_status_table, MV_ERROR|AC_ERROR|DC_ERROR|VP_START|AC_END|DC_END|MV_END, s->mb_stride*s->mb_height*sizeof(uint8_t));
-    s->error_count= 3*s->mb_num;
-}
-
-/**
- * adds a slice.
- * @param endx x component of the last macroblock, can be -1 for the last of the previous line
- * @param status the status at the end (MV_END, AC_ERROR, ...), it is assumed that no earlier end or
- *               error of the same type occured
- */
-void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int endy, int status){
-    const int start_i= clip(startx + starty * s->mb_width    , 0, s->mb_num-1);
-    const int end_i  = clip(endx   + endy   * s->mb_width    , 0, s->mb_num);
-    const int start_xy= s->mb_index2xy[start_i];
-    const int end_xy  = s->mb_index2xy[end_i];
-    int mask= -1;
-    
-    if(!s->error_resilience) return;
-
-    mask &= ~VP_START;
-    if(status & (AC_ERROR|AC_END)){
-        mask &= ~(AC_ERROR|AC_END);
-        s->error_count -= end_i - start_i + 1;
-    }
-    if(status & (DC_ERROR|DC_END)){
-        mask &= ~(DC_ERROR|DC_END);
-        s->error_count -= end_i - start_i + 1;
-    }
-    if(status & (MV_ERROR|MV_END)){
-        mask &= ~(MV_ERROR|MV_END);
-        s->error_count -= end_i - start_i + 1;
-    }
-
-    if(status & (AC_ERROR|DC_ERROR|MV_ERROR)) s->error_count= INT_MAX;
-
-    if(mask == ~0x7F){
-        memset(&s->error_status_table[start_xy], 0, (end_xy - start_xy) * sizeof(uint8_t));
-    }else{
-        int i;
-        for(i=start_xy; i<end_xy; i++){
-            s->error_status_table[ i ] &= mask;
-        }
-    }
-
-    if(end_i == s->mb_num) 
-        s->error_count= INT_MAX;
-    else{
-        s->error_status_table[end_xy] &= mask;
-        s->error_status_table[end_xy] |= status;
-    }
- 
-    s->error_status_table[start_xy] |= VP_START;
-
-    if(start_xy > 0 && s->avctx->thread_count <= 1 && s->avctx->skip_top*s->mb_width < start_i){
-        int prev_status= s->error_status_table[ s->mb_index2xy[start_i - 1] ];
-        
-        prev_status &= ~ VP_START;
-        if(prev_status != (MV_END|DC_END|AC_END)) s->error_count= INT_MAX;
-    }
-}
-
-void ff_er_frame_end(MpegEncContext *s){
-    int i, mb_x, mb_y, error, error_type, dc_error, mv_error, ac_error;
-    int distance;
-    int threshold_part[4]= {100,100,100};
-    int threshold= 50;
-    int is_intra_likely;
-    int size = s->b8_stride * 2 * s->mb_height;
-    Picture *pic= s->current_picture_ptr;
-    
-    if(!s->error_resilience || s->error_count==0 || 
-       s->error_count==3*s->mb_width*(s->avctx->skip_top + s->avctx->skip_bottom)) return;
-
-    if(s->current_picture.motion_val[0] == NULL){
-        av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
-            
-        for(i=0; i<2; i++){
-            pic->ref_index[i]= av_mallocz(size * sizeof(uint8_t));
-            pic->motion_val_base[i]= av_mallocz((size+4) * 2 * sizeof(uint16_t));
-            pic->motion_val[i]= pic->motion_val_base[i]+4;
-        }
-        pic->motion_subsample_log2= 3;
-        s->current_picture= *s->current_picture_ptr;
-    }
-    
-    for(i=0; i<2; i++){
-        if(pic->ref_index[i])
-            memset(pic->ref_index[i], 0, size * sizeof(uint8_t));
-    }
-
-    if(s->avctx->debug&FF_DEBUG_ER){
-        for(mb_y=0; mb_y<s->mb_height; mb_y++){
-            for(mb_x=0; mb_x<s->mb_width; mb_x++){
-                int status= s->error_status_table[mb_x + mb_y*s->mb_stride];
-            
-                av_log(s->avctx, AV_LOG_DEBUG, "%2X ", status); 
-            }
-            av_log(s->avctx, AV_LOG_DEBUG, "\n");
-        }
-    }
-    
-#if 1
-    /* handle overlapping slices */
-    for(error_type=1; error_type<=3; error_type++){
-        int end_ok=0;
-
-        for(i=s->mb_num-1; i>=0; i--){
-            const int mb_xy= s->mb_index2xy[i];
-            int error= s->error_status_table[mb_xy];
-        
-            if(error&(1<<error_type))
-                end_ok=1;
-            if(error&(8<<error_type))
-                end_ok=1;
-
-            if(!end_ok)
-                s->error_status_table[mb_xy]|= 1<<error_type;
-
-            if(error&VP_START)
-                end_ok=0;
-        }
-    }
-#endif
-#if 1
-    /* handle slices with partitions of different length */
-    if(s->partitioned_frame){
-        int end_ok=0;
-
-        for(i=s->mb_num-1; i>=0; i--){
-            const int mb_xy= s->mb_index2xy[i];
-            int error= s->error_status_table[mb_xy];
-        
-            if(error&AC_END)
-                end_ok=0;
-            if((error&MV_END) || (error&DC_END) || (error&AC_ERROR))
-                end_ok=1;
-
-            if(!end_ok)
-                s->error_status_table[mb_xy]|= AC_ERROR;
-
-            if(error&VP_START)
-                end_ok=0;
-        }
-    }
-#endif
-    /* handle missing slices */
-    if(s->error_resilience>=4){
-        int end_ok=1;
-                
-        for(i=s->mb_num-2; i>=s->mb_width+100; i--){ //FIXME +100 hack
-            const int mb_xy= s->mb_index2xy[i];
-            int error1= s->error_status_table[mb_xy  ];
-            int error2= s->error_status_table[s->mb_index2xy[i+1]];
-        
-            if(error1&VP_START)
-                end_ok=1;
-             
-            if(   error2==(VP_START|DC_ERROR|AC_ERROR|MV_ERROR|AC_END|DC_END|MV_END)
-               && error1!=(VP_START|DC_ERROR|AC_ERROR|MV_ERROR|AC_END|DC_END|MV_END) 
-               && ((error1&AC_END) || (error1&DC_END) || (error1&MV_END))){ //end & uninited
-                end_ok=0;
-            }
-        
-            if(!end_ok)
-                s->error_status_table[mb_xy]|= DC_ERROR|AC_ERROR|MV_ERROR;
-        }
-    }
-    
-#if 1
-    /* backward mark errors */
-    distance=9999999;
-    for(error_type=1; error_type<=3; error_type++){
-        for(i=s->mb_num-1; i>=0; i--){
-            const int mb_xy= s->mb_index2xy[i];
-            int error= s->error_status_table[mb_xy];
-            
-            if(!s->mbskip_table[mb_xy]) //FIXME partition specific
-                distance++;            
-            if(error&(1<<error_type))
-                distance= 0;
-
-            if(s->partitioned_frame){
-                if(distance < threshold_part[error_type-1])
-                    s->error_status_table[mb_xy]|= 1<<error_type;
-            }else{
-                if(distance < threshold)
-                    s->error_status_table[mb_xy]|= 1<<error_type;
-            }
-
-            if(error&VP_START)
-                distance= 9999999;
-        }
-    }
-#endif
-
-    /* forward mark errors */
-    error=0;
-    for(i=0; i<s->mb_num; i++){
-        const int mb_xy= s->mb_index2xy[i];
-        int old_error= s->error_status_table[mb_xy];
-        
-        if(old_error&VP_START)
-            error= old_error& (DC_ERROR|AC_ERROR|MV_ERROR);
-        else{
-            error|= old_error& (DC_ERROR|AC_ERROR|MV_ERROR);
-            s->error_status_table[mb_xy]|= error;
-        }
-    }
-#if 1
-    /* handle not partitioned case */
-    if(!s->partitioned_frame){
-        for(i=0; i<s->mb_num; i++){
-            const int mb_xy= s->mb_index2xy[i];
-            error= s->error_status_table[mb_xy];
-            if(error&(AC_ERROR|DC_ERROR|MV_ERROR))
-                error|= AC_ERROR|DC_ERROR|MV_ERROR;
-            s->error_status_table[mb_xy]= error;
-        }
-    }
-#endif
-
-    dc_error= ac_error= mv_error=0;
-    for(i=0; i<s->mb_num; i++){
-        const int mb_xy= s->mb_index2xy[i];
-        error= s->error_status_table[mb_xy];
-        if(error&DC_ERROR) dc_error ++;
-        if(error&AC_ERROR) ac_error ++;
-        if(error&MV_ERROR) mv_error ++;
-    }
-    av_log(s->avctx, AV_LOG_INFO, "concealing %d DC, %d AC, %d MV errors\n", dc_error, ac_error, mv_error);
-
-    is_intra_likely= is_intra_more_likely(s);
-
-    /* set unknown mb-type to most likely */
-    for(i=0; i<s->mb_num; i++){
-        const int mb_xy= s->mb_index2xy[i];
-        error= s->error_status_table[mb_xy];
-        if(!((error&DC_ERROR) && (error&MV_ERROR)))
-            continue;
-
-        if(is_intra_likely)
-            s->current_picture.mb_type[mb_xy]= MB_TYPE_INTRA4x4;
-        else
-            s->current_picture.mb_type[mb_xy]= MB_TYPE_16x16 | MB_TYPE_L0;
-    }
-    
-    /* handle inter blocks with damaged AC */
-    for(mb_y=0; mb_y<s->mb_height; mb_y++){
-        for(mb_x=0; mb_x<s->mb_width; mb_x++){
-            const int mb_xy= mb_x + mb_y * s->mb_stride;
-            const int mb_type= s->current_picture.mb_type[mb_xy];
-            error= s->error_status_table[mb_xy];
-
-            if(IS_INTRA(mb_type)) continue; //intra
-            if(error&MV_ERROR) continue;              //inter with damaged MV
-            if(!(error&AC_ERROR)) continue;           //undamaged inter
-            
-            s->mv_dir = MV_DIR_FORWARD;
-            s->mb_intra=0;
-            s->mb_skipped=0;
-            if(IS_8X8(mb_type)){
-                int mb_index= mb_x*2 + mb_y*2*s->b8_stride;
-                int j;
-                s->mv_type = MV_TYPE_8X8;
-                for(j=0; j<4; j++){
-                    s->mv[0][j][0] = s->current_picture.motion_val[0][ mb_index + (j&1) + (j>>1)*s->b8_stride ][0];
-                    s->mv[0][j][1] = s->current_picture.motion_val[0][ mb_index + (j&1) + (j>>1)*s->b8_stride ][1];
-                }
-            }else{
-                s->mv_type = MV_TYPE_16X16;
-                s->mv[0][0][0] = s->current_picture.motion_val[0][ mb_x*2 + mb_y*2*s->b8_stride ][0];
-                s->mv[0][0][1] = s->current_picture.motion_val[0][ mb_x*2 + mb_y*2*s->b8_stride ][1];
-            }
-        
-	    s->dsp.clear_blocks(s->block[0]);
-
-            s->mb_x= mb_x;
-            s->mb_y= mb_y;
-            decode_mb(s);
-        }
-    }
-
-    /* guess MVs */
-    if(s->pict_type==B_TYPE){
-        for(mb_y=0; mb_y<s->mb_height; mb_y++){
-            for(mb_x=0; mb_x<s->mb_width; mb_x++){
-                int xy= mb_x*2 + mb_y*2*s->b8_stride;
-                const int mb_xy= mb_x + mb_y * s->mb_stride;
-                const int mb_type= s->current_picture.mb_type[mb_xy];
-                error= s->error_status_table[mb_xy];
-
-                if(IS_INTRA(mb_type)) continue;
-                if(!(error&MV_ERROR)) continue;           //inter with undamaged MV
-                if(!(error&AC_ERROR)) continue;           //undamaged inter
-            
-                s->mv_dir = MV_DIR_FORWARD|MV_DIR_BACKWARD;
-                s->mb_intra=0;
-                s->mv_type = MV_TYPE_16X16;
-                s->mb_skipped=0;
-                
-                if(s->pp_time){
-                    int time_pp= s->pp_time;
-                    int time_pb= s->pb_time;
-            
-                    s->mv[0][0][0] = s->next_picture.motion_val[0][xy][0]*time_pb/time_pp;
-                    s->mv[0][0][1] = s->next_picture.motion_val[0][xy][1]*time_pb/time_pp;
-                    s->mv[1][0][0] = s->next_picture.motion_val[0][xy][0]*(time_pb - time_pp)/time_pp;
-                    s->mv[1][0][1] = s->next_picture.motion_val[0][xy][1]*(time_pb - time_pp)/time_pp;
-                }else{
-                    s->mv[0][0][0]= 0;
-                    s->mv[0][0][1]= 0;
-                    s->mv[1][0][0]= 0;
-                    s->mv[1][0][1]= 0;
-                }
-
-                s->dsp.clear_blocks(s->block[0]);
-                s->mb_x= mb_x;
-                s->mb_y= mb_y;
-                decode_mb(s);
-            }
-        }
-    }else
-        guess_mv(s);
-
-#ifdef HAVE_XVMC
-    /* the filters below are not XvMC compatible, skip them */
-    if(s->avctx->xvmc_acceleration) goto ec_clean;
-#endif
-    /* fill DC for inter blocks */
-    for(mb_y=0; mb_y<s->mb_height; mb_y++){
-        for(mb_x=0; mb_x<s->mb_width; mb_x++){
-            int dc, dcu, dcv, y, n;
-            int16_t *dc_ptr;
-            uint8_t *dest_y, *dest_cb, *dest_cr;
-            const int mb_xy= mb_x + mb_y * s->mb_stride;
-            const int mb_type= s->current_picture.mb_type[mb_xy];
-           
-            error= s->error_status_table[mb_xy];
-
-            if(IS_INTRA(mb_type) && s->partitioned_frame) continue;
-//            if(error&MV_ERROR) continue; //inter data damaged FIXME is this good?
-            
-            dest_y = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize;
-            dest_cb= s->current_picture.data[1] + mb_x*8  + mb_y*8 *s->uvlinesize;
-            dest_cr= s->current_picture.data[2] + mb_x*8  + mb_y*8 *s->uvlinesize;
-           
-            dc_ptr= &s->dc_val[0][mb_x*2 + mb_y*2*s->b8_stride];
-            for(n=0; n<4; n++){
-                dc=0;
-                for(y=0; y<8; y++){
-                    int x;
-                    for(x=0; x<8; x++){
-                       dc+= dest_y[x + (n&1)*8 + (y + (n>>1)*8)*s->linesize];
-                    }
-                }
-                dc_ptr[(n&1) + (n>>1)*s->b8_stride]= (dc+4)>>3;
-            }
-
-            dcu=dcv=0;
-            for(y=0; y<8; y++){
-                int x;
-                for(x=0; x<8; x++){
-                    dcu+=dest_cb[x + y*(s->uvlinesize)];
-                    dcv+=dest_cr[x + y*(s->uvlinesize)];
-                }
-            }
-            s->dc_val[1][mb_x + mb_y*s->mb_stride]= (dcu+4)>>3;
-            s->dc_val[2][mb_x + mb_y*s->mb_stride]= (dcv+4)>>3;   
-        }
-    }
-#if 1
-    /* guess DC for damaged blocks */
-    guess_dc(s, s->dc_val[0], s->mb_width*2, s->mb_height*2, s->b8_stride, 1);
-    guess_dc(s, s->dc_val[1], s->mb_width  , s->mb_height  , s->mb_stride, 0);
-    guess_dc(s, s->dc_val[2], s->mb_width  , s->mb_height  , s->mb_stride, 0);
-#endif   
-    /* filter luma DC */
-    filter181(s->dc_val[0], s->mb_width*2, s->mb_height*2, s->b8_stride);
-    
-#if 1
-    /* render DC only intra */
-    for(mb_y=0; mb_y<s->mb_height; mb_y++){
-        for(mb_x=0; mb_x<s->mb_width; mb_x++){
-            uint8_t *dest_y, *dest_cb, *dest_cr;
-            const int mb_xy= mb_x + mb_y * s->mb_stride;
-            const int mb_type= s->current_picture.mb_type[mb_xy];
-
-            error= s->error_status_table[mb_xy];
-
-            if(IS_INTER(mb_type)) continue;
-            if(!(error&AC_ERROR)) continue;              //undamaged
-            
-            dest_y = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize;
-            dest_cb= s->current_picture.data[1] + mb_x*8  + mb_y*8 *s->uvlinesize;
-            dest_cr= s->current_picture.data[2] + mb_x*8  + mb_y*8 *s->uvlinesize;
-            
-            put_dc(s, dest_y, dest_cb, dest_cr, mb_x, mb_y);
-        }
-    }
-#endif
-    
-    if(s->avctx->error_concealment&FF_EC_DEBLOCK){
-        /* filter horizontal block boundaries */
-        h_block_filter(s, s->current_picture.data[0], s->mb_width*2, s->mb_height*2, s->linesize  , 1);
-        h_block_filter(s, s->current_picture.data[1], s->mb_width  , s->mb_height  , s->uvlinesize, 0);
-        h_block_filter(s, s->current_picture.data[2], s->mb_width  , s->mb_height  , s->uvlinesize, 0);
-
-        /* filter vertical block boundaries */
-        v_block_filter(s, s->current_picture.data[0], s->mb_width*2, s->mb_height*2, s->linesize  , 1);
-        v_block_filter(s, s->current_picture.data[1], s->mb_width  , s->mb_height  , s->uvlinesize, 0);
-        v_block_filter(s, s->current_picture.data[2], s->mb_width  , s->mb_height  , s->uvlinesize, 0);
-    }
-
-#ifdef HAVE_XVMC
-ec_clean:
-#endif
-    /* clean a few tables */
-    for(i=0; i<s->mb_num; i++){
-        const int mb_xy= s->mb_index2xy[i];
-        int error= s->error_status_table[mb_xy];
-        
-        if(s->pict_type!=B_TYPE && (error&(DC_ERROR|MV_ERROR|AC_ERROR))){
-            s->mbskip_table[mb_xy]=0;
-        }
-        s->mbintra_table[mb_xy]=1;
-    }    
-}
diff --git a/ffmpeg.src/libavcodec/eval.c b/ffmpeg.src/libavcodec/eval.c
deleted file mode 100644
index 3307815..0000000
--- a/ffmpeg.src/libavcodec/eval.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * simple arithmetic expression evaluator
- *
- * Copyright (c) 2002 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-/**
- * @file eval.c
- * simple arithmetic expression evaluator.
- *
- * see http://joe.hotchkiss.com/programming/eval/eval.html
- */
-
-#include "avcodec.h"
-#include "mpegvideo.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#ifndef NAN
-  #define NAN 0
-#endif
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-typedef struct Parser{
-    int stack_index;
-    char *s;
-    double *const_value;
-    const char **const_name;          // NULL terminated
-    double (**func1)(void *, double a); // NULL terminated
-    const char **func1_name;          // NULL terminated
-    double (**func2)(void *, double a, double b); // NULL terminated
-    char **func2_name;          // NULL terminated
-    void *opaque;
-} Parser;
-
-static double evalExpression(Parser *p);
-
-static int strmatch(const char *s, const char *prefix){
-    int i;
-    for(i=0; prefix[i]; i++){
-        if(prefix[i] != s[i]) return 0;
-    }
-    return 1;
-}
-
-static double evalPrimary(Parser *p){
-    double d, d2=NAN;
-    char *next= p->s;
-    int i;
-
-    /* number */
-    d= strtod(p->s, &next);
-    if(next != p->s){
-        p->s= next;
-        return d;
-    }
-    
-    /* named constants */
-    for(i=0; p->const_name && p->const_name[i]; i++){
-        if(strmatch(p->s, p->const_name[i])){
-            p->s+= strlen(p->const_name[i]);
-            return p->const_value[i];
-        }
-    }
-    
-    p->s= strchr(p->s, '(');
-    if(p->s==NULL){
-        av_log(NULL, AV_LOG_ERROR, "Parser: missing ( in \"%s\"\n", next);
-        return NAN;
-    }
-    p->s++; // "("
-    d= evalExpression(p);
-    if(p->s[0]== ','){
-        p->s++; // ","
-        d2= evalExpression(p);
-    }
-    if(p->s[0] != ')'){
-        av_log(NULL, AV_LOG_ERROR, "Parser: missing ) in \"%s\"\n", next);
-        return NAN;
-    }
-    p->s++; // ")"
-    
-         if( strmatch(next, "sinh"  ) ) d= sinh(d);
-    else if( strmatch(next, "cosh"  ) ) d= cosh(d);
-    else if( strmatch(next, "tanh"  ) ) d= tanh(d);
-    else if( strmatch(next, "sin"   ) ) d= sin(d);
-    else if( strmatch(next, "cos"   ) ) d= cos(d);
-    else if( strmatch(next, "tan"   ) ) d= tan(d);
-    else if( strmatch(next, "exp"   ) ) d= exp(d);
-    else if( strmatch(next, "log"   ) ) d= log(d);
-    else if( strmatch(next, "squish") ) d= 1/(1+exp(4*d));
-    else if( strmatch(next, "gauss" ) ) d= exp(-d*d/2)/sqrt(2*M_PI);
-    else if( strmatch(next, "abs"   ) ) d= fabs(d);
-    else if( strmatch(next, "max"   ) ) d= d > d2 ? d : d2;
-    else if( strmatch(next, "min"   ) ) d= d < d2 ? d : d2;
-    else if( strmatch(next, "gt"    ) ) d= d > d2 ? 1.0 : 0.0;
-    else if( strmatch(next, "gte"    ) ) d= d >= d2 ? 1.0 : 0.0;
-    else if( strmatch(next, "lt"    ) ) d= d > d2 ? 0.0 : 1.0;
-    else if( strmatch(next, "lte"    ) ) d= d >= d2 ? 0.0 : 1.0;
-    else if( strmatch(next, "eq"    ) ) d= d == d2 ? 1.0 : 0.0;
-    else if( strmatch(next, "("     ) ) d= d;
-//    else if( strmatch(next, "l1"    ) ) d= 1 + d2*(d - 1);
-//    else if( strmatch(next, "sq01"  ) ) d= (d >= 0.0 && d <=1.0) ? 1.0 : 0.0;
-    else{
-        for(i=0; p->func1_name && p->func1_name[i]; i++){
-            if(strmatch(next, p->func1_name[i])){
-                return p->func1[i](p->opaque, d);
-            }
-        }
-
-        for(i=0; p->func2_name && p->func2_name[i]; i++){
-            if(strmatch(next, p->func2_name[i])){
-                return p->func2[i](p->opaque, d, d2);
-            }
-        }
-
-        av_log(NULL, AV_LOG_ERROR, "Parser: unknown function in \"%s\"\n", next);
-        return NAN;
-    }
-
-    return d;
-}      
-
-static double evalPow(Parser *p){
-    int sign= (*p->s == '+') - (*p->s == '-');
-    p->s += sign&1;
-    return (sign|1) * evalPrimary(p);
-}
-
-static double evalFactor(Parser *p){
-    double ret= evalPow(p);
-    while(p->s[0]=='^'){
-        p->s++;
-        ret= pow(ret, evalPow(p));
-    }
-    return ret;
-}
-
-static double evalTerm(Parser *p){
-    double ret= evalFactor(p);
-    while(p->s[0]=='*' || p->s[0]=='/'){
-        if(*p->s++ == '*') ret*= evalFactor(p);
-        else               ret/= evalFactor(p);
-    }
-    return ret;
-}
-
-static double evalExpression(Parser *p){
-    double ret= 0;
-
-    if(p->stack_index <= 0) //protect against stack overflows
-        return NAN;
-    p->stack_index--;
-
-    do{
-        ret += evalTerm(p);
-    }while(*p->s == '+' || *p->s == '-');
-
-    p->stack_index++;
-
-    return ret;
-}
-
-double ff_eval(char *s, double *const_value, const char **const_name,
-               double (**func1)(void *, double), const char **func1_name,
-               double (**func2)(void *, double, double), char **func2_name,
-               void *opaque){
-    Parser p;
-    
-    p.stack_index=100;
-    p.s= s;
-    p.const_value= const_value;
-    p.const_name = const_name;
-    p.func1      = func1;
-    p.func1_name = func1_name;
-    p.func2      = func2;
-    p.func2_name = func2_name;
-    p.opaque     = opaque;
-    
-    return evalExpression(&p);
-}
-
-#ifdef TEST
-#undef printf 
-static double const_values[]={
-    M_PI,
-    M_E,
-    0
-};
-static const char *const_names[]={
-    "PI",
-    "E",
-    0
-};
-main(){
-    int i;
-    printf("%f == 12.7\n", ff_eval("1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_values, const_names, NULL, NULL, NULL, NULL, NULL));
-    
-    for(i=0; i<1050; i++){
-        START_TIMER
-            ff_eval("1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_values, const_names, NULL, NULL, NULL, NULL, NULL);
-        STOP_TIMER("ff_eval")
-    }
-}
-#endif
diff --git a/ffmpeg.src/libavcodec/faandct.c b/ffmpeg.src/libavcodec/faandct.c
deleted file mode 100644
index 0462cee..0000000
--- a/ffmpeg.src/libavcodec/faandct.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Floating point AAN DCT
- * Copyright (c) 2003 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * this implementation is based upon the IJG integer AAN DCT (see jfdctfst.c)
- */
-
-/**
- * @file faandct.c
- * @brief 
- *     Floating point AAN DCT
- * @author Michael Niedermayer <michaelni at gmx.at>
- */
-
-#include "dsputil.h"
-#include "faandct.h"
-
-#define FLOAT float
-#ifdef FAAN_POSTSCALE
-#    define SCALE(x) postscale[x]
-#else
-#    define SCALE(x) 1
-#endif
-
-//numbers generated by simple c code (not as accurate as they could be)
-/*
-for(i=0; i<8; i++){
-    printf("#define B%d %1.20llf\n", i, (long double)1.0/(cosl(i*acosl(-1.0)/(long double)16.0)*sqrtl(2)));
-}
-*/
-#define B0 1.00000000000000000000
-#define B1 0.72095982200694791383 // (cos(pi*1/16)sqrt(2))^-1
-#define B2 0.76536686473017954350 // (cos(pi*2/16)sqrt(2))^-1
-#define B3 0.85043009476725644878 // (cos(pi*3/16)sqrt(2))^-1
-#define B4 1.00000000000000000000 // (cos(pi*4/16)sqrt(2))^-1
-#define B5 1.27275858057283393842 // (cos(pi*5/16)sqrt(2))^-1
-#define B6 1.84775906502257351242 // (cos(pi*6/16)sqrt(2))^-1
-#define B7 3.62450978541155137218 // (cos(pi*7/16)sqrt(2))^-1
-
-
-#define A1 0.70710678118654752438 // cos(pi*4/16)
-#define A2 0.54119610014619698435 // cos(pi*6/16)sqrt(2)
-#define A5 0.38268343236508977170 // cos(pi*6/16)
-#define A4 1.30656296487637652774 // cos(pi*2/16)sqrt(2)
-
-static FLOAT postscale[64]={
-B0*B0, B0*B1, B0*B2, B0*B3, B0*B4, B0*B5, B0*B6, B0*B7,
-B1*B0, B1*B1, B1*B2, B1*B3, B1*B4, B1*B5, B1*B6, B1*B7,
-B2*B0, B2*B1, B2*B2, B2*B3, B2*B4, B2*B5, B2*B6, B2*B7,
-B3*B0, B3*B1, B3*B2, B3*B3, B3*B4, B3*B5, B3*B6, B3*B7,
-B4*B0, B4*B1, B4*B2, B4*B3, B4*B4, B4*B5, B4*B6, B4*B7,
-B5*B0, B5*B1, B5*B2, B5*B3, B5*B4, B5*B5, B5*B6, B5*B7,
-B6*B0, B6*B1, B6*B2, B6*B3, B6*B4, B6*B5, B6*B6, B6*B7,
-B7*B0, B7*B1, B7*B2, B7*B3, B7*B4, B7*B5, B7*B6, B7*B7,
-};
-
-static always_inline void row_fdct(FLOAT temp[64], DCTELEM * data)
-{
-    FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
-    FLOAT tmp10, tmp11, tmp12, tmp13;
-    FLOAT z1, z2, z3, z4, z5, z11, z13;
-    int i;
-
-    for (i=0; i<8*8; i+=8) {
-        tmp0= data[0 + i] + data[7 + i];
-        tmp7= data[0 + i] - data[7 + i];
-        tmp1= data[1 + i] + data[6 + i];
-        tmp6= data[1 + i] - data[6 + i];
-        tmp2= data[2 + i] + data[5 + i];
-        tmp5= data[2 + i] - data[5 + i];
-        tmp3= data[3 + i] + data[4 + i];
-        tmp4= data[3 + i] - data[4 + i];
-        
-        tmp10= tmp0 + tmp3;
-        tmp13= tmp0 - tmp3;
-        tmp11= tmp1 + tmp2;
-        tmp12= tmp1 - tmp2;
-        
-        temp[0 + i]= tmp10 + tmp11;
-        temp[4 + i]= tmp10 - tmp11;
-        
-        z1= (tmp12 + tmp13)*A1;
-        temp[2 + i]= tmp13 + z1;
-        temp[6 + i]= tmp13 - z1;
-        
-        tmp10= tmp4 + tmp5;
-        tmp11= tmp5 + tmp6;
-        tmp12= tmp6 + tmp7;
-
-        z5= (tmp10 - tmp12) * A5;
-        z2= tmp10*A2 + z5;
-        z4= tmp12*A4 + z5;
-        z3= tmp11*A1;
-
-        z11= tmp7 + z3;
-        z13= tmp7 - z3;
-
-        temp[5 + i]= z13 + z2;
-        temp[3 + i]= z13 - z2;
-        temp[1 + i]= z11 + z4;
-        temp[7 + i]= z11 - z4;
-    }    
-}
-
-void ff_faandct(DCTELEM * data)
-{
-    FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
-    FLOAT tmp10, tmp11, tmp12, tmp13;
-    FLOAT z1, z2, z3, z4, z5, z11, z13;
-    FLOAT temp[64];
-    int i;
-
-    emms_c();
-
-    row_fdct(temp, data);
-
-    for (i=0; i<8; i++) {
-        tmp0= temp[8*0 + i] + temp[8*7 + i];
-        tmp7= temp[8*0 + i] - temp[8*7 + i];
-        tmp1= temp[8*1 + i] + temp[8*6 + i];
-        tmp6= temp[8*1 + i] - temp[8*6 + i];
-        tmp2= temp[8*2 + i] + temp[8*5 + i];
-        tmp5= temp[8*2 + i] - temp[8*5 + i];
-        tmp3= temp[8*3 + i] + temp[8*4 + i];
-        tmp4= temp[8*3 + i] - temp[8*4 + i];
-        
-        tmp10= tmp0 + tmp3;
-        tmp13= tmp0 - tmp3;
-        tmp11= tmp1 + tmp2;
-        tmp12= tmp1 - tmp2;
-        
-        data[8*0 + i]= lrintf(SCALE(8*0 + i) * (tmp10 + tmp11));
-        data[8*4 + i]= lrintf(SCALE(8*4 + i) * (tmp10 - tmp11));
-        
-        z1= (tmp12 + tmp13)* A1;
-        data[8*2 + i]= lrintf(SCALE(8*2 + i) * (tmp13 + z1));
-        data[8*6 + i]= lrintf(SCALE(8*6 + i) * (tmp13 - z1));
-        
-        tmp10= tmp4 + tmp5;
-        tmp11= tmp5 + tmp6;
-        tmp12= tmp6 + tmp7;
-
-        z5= (tmp10 - tmp12) * A5;
-        z2= tmp10*A2 + z5;
-        z4= tmp12*A4 + z5;
-        z3= tmp11*A1;
-
-        z11= tmp7 + z3;
-        z13= tmp7 - z3;
-
-        data[8*5 + i]= lrintf(SCALE(8*5 + i) * (z13 + z2));
-        data[8*3 + i]= lrintf(SCALE(8*3 + i) * (z13 - z2));
-        data[8*1 + i]= lrintf(SCALE(8*1 + i) * (z11 + z4));
-        data[8*7 + i]= lrintf(SCALE(8*7 + i) * (z11 - z4));
-    }
-}
-
-void ff_faandct248(DCTELEM * data)
-{
-    FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
-    FLOAT tmp10, tmp11, tmp12, tmp13;
-    FLOAT z1;
-    FLOAT temp[64];
-    int i;
-
-    emms_c();
-
-    row_fdct(temp, data);
-
-    for (i=0; i<8; i++) {
-        tmp0 = temp[8*0 + i] + temp[8*1 + i];
-        tmp1 = temp[8*2 + i] + temp[8*3 + i];
-        tmp2 = temp[8*4 + i] + temp[8*5 + i];
-        tmp3 = temp[8*6 + i] + temp[8*7 + i];
-        tmp4 = temp[8*0 + i] - temp[8*1 + i];
-        tmp5 = temp[8*2 + i] - temp[8*3 + i];
-        tmp6 = temp[8*4 + i] - temp[8*5 + i];
-        tmp7 = temp[8*6 + i] - temp[8*7 + i];
-        
-        tmp10 = tmp0 + tmp3;
-        tmp11 = tmp1 + tmp2;
-        tmp12 = tmp1 - tmp2;
-        tmp13 = tmp0 - tmp3;
-        
-        data[8*0 + i] = lrintf(SCALE(8*0 + i) * (tmp10 + tmp11));
-        data[8*4 + i] = lrintf(SCALE(8*4 + i) * (tmp10 - tmp11));
-        
-        z1 = (tmp12 + tmp13)* A1;
-        data[8*2 + i] = lrintf(SCALE(8*2 + i) * (tmp13 + z1));
-        data[8*6 + i] = lrintf(SCALE(8*6 + i) * (tmp13 - z1));
-        
-        tmp10 = tmp4 + tmp7;
-	tmp11 = tmp5 + tmp6;
-	tmp12 = tmp5 - tmp6;
-	tmp13 = tmp4 - tmp7;
-
-	data[8*1 + i] = lrintf(SCALE(8*0 + i) * (tmp10 + tmp11));
-	data[8*5 + i] = lrintf(SCALE(8*4 + i) * (tmp10 - tmp11));
-
-	z1 = (tmp12 + tmp13)* A1;
-	data[8*3 + i] = lrintf(SCALE(8*2 + i) * (tmp13 + z1));
-	data[8*7 + i] = lrintf(SCALE(8*6 + i) * (tmp13 - z1));
-    }
-}
diff --git a/ffmpeg.src/libavcodec/faandct.h b/ffmpeg.src/libavcodec/faandct.h
deleted file mode 100644
index c40f801..0000000
--- a/ffmpeg.src/libavcodec/faandct.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Floating point AAN DCT
- * Copyright (c) 2003 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-/**
- * @file faandct.h
- * @brief 
- *     Floating point AAN DCT
- * @author Michael Niedermayer <michaelni at gmx.at>
- */
- 
-#define FAAN_POSTSCALE
- 
-void ff_faandct(DCTELEM * data);
-void ff_faandct248(DCTELEM * data);
diff --git a/ffmpeg.src/libavcodec/fft.c b/ffmpeg.src/libavcodec/fft.c
deleted file mode 100644
index 912a2ed..0000000
--- a/ffmpeg.src/libavcodec/fft.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * FFT/IFFT transforms
- * Copyright (c) 2002 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file fft.c
- * FFT/IFFT transforms.
- */
-
-#include "dsputil.h"
-
-/**
- * The size of the FFT is 2^nbits. If inverse is TRUE, inverse FFT is
- * done 
- */
-int ff_fft_init(FFTContext *s, int nbits, int inverse)
-{
-    int i, j, m, n;
-    float alpha, c1, s1, s2;
-    
-    s->nbits = nbits;
-    n = 1 << nbits;
-
-    s->exptab = av_malloc((n / 2) * sizeof(FFTComplex));
-    if (!s->exptab)
-        goto fail;
-    s->revtab = av_malloc(n * sizeof(uint16_t));
-    if (!s->revtab)
-        goto fail;
-    s->inverse = inverse;
-
-    s2 = inverse ? 1.0 : -1.0;
-        
-    for(i=0;i<(n/2);i++) {
-        alpha = 2 * M_PI * (float)i / (float)n;
-        c1 = cos(alpha);
-        s1 = sin(alpha) * s2;
-        s->exptab[i].re = c1;
-        s->exptab[i].im = s1;
-    }
-    s->fft_calc = ff_fft_calc_c;
-    s->exptab1 = NULL;
-
-    /* compute constant table for HAVE_SSE version */
-#if (defined(HAVE_MMX) && defined(HAVE_BUILTIN_VECTOR)) || defined(HAVE_ALTIVEC)
-    {
-        int has_vectors = 0;
-
-#if defined(HAVE_MMX)
-        has_vectors = mm_support() & MM_SSE;
-#endif
-#if defined(HAVE_ALTIVEC) && !defined(ALTIVEC_USE_REFERENCE_C_CODE)
-        has_vectors = mm_support() & MM_ALTIVEC;
-#endif
-        if (has_vectors) {
-            int np, nblocks, np2, l;
-            FFTComplex *q;
-            
-            np = 1 << nbits;
-            nblocks = np >> 3;
-            np2 = np >> 1;
-            s->exptab1 = av_malloc(np * 2 * sizeof(FFTComplex));
-            if (!s->exptab1)
-                goto fail;
-            q = s->exptab1;
-            do {
-                for(l = 0; l < np2; l += 2 * nblocks) {
-                    *q++ = s->exptab[l];
-                    *q++ = s->exptab[l + nblocks];
-
-                    q->re = -s->exptab[l].im;
-                    q->im = s->exptab[l].re;
-                    q++;
-                    q->re = -s->exptab[l + nblocks].im;
-                    q->im = s->exptab[l + nblocks].re;
-                    q++;
-                }
-                nblocks = nblocks >> 1;
-            } while (nblocks != 0);
-            av_freep(&s->exptab);
-#if defined(HAVE_MMX)
-            s->fft_calc = ff_fft_calc_sse;
-#else
-            s->fft_calc = ff_fft_calc_altivec;
-#endif
-        }
-    }
-#endif
-
-    /* compute bit reverse table */
-
-    for(i=0;i<n;i++) {
-        m=0;
-        for(j=0;j<nbits;j++) {
-            m |= ((i >> j) & 1) << (nbits-j-1);
-        }
-        s->revtab[i]=m;
-    }
-    return 0;
- fail:
-    av_freep(&s->revtab);
-    av_freep(&s->exptab);
-    av_freep(&s->exptab1);
-    return -1;
-}
-
-/* butter fly op */
-#define BF(pre, pim, qre, qim, pre1, pim1, qre1, qim1) \
-{\
-  FFTSample ax, ay, bx, by;\
-  bx=pre1;\
-  by=pim1;\
-  ax=qre1;\
-  ay=qim1;\
-  pre = (bx + ax);\
-  pim = (by + ay);\
-  qre = (bx - ax);\
-  qim = (by - ay);\
-}
-
-#define MUL16(a,b) ((a) * (b))
-
-#define CMUL(pre, pim, are, aim, bre, bim) \
-{\
-   pre = (MUL16(are, bre) - MUL16(aim, bim));\
-   pim = (MUL16(are, bim) + MUL16(bre, aim));\
-}
-
-/**
- * Do a complex FFT with the parameters defined in ff_fft_init(). The
- * input data must be permuted before with s->revtab table. No
- * 1.0/sqrt(n) normalization is done.  
- */
-void ff_fft_calc_c(FFTContext *s, FFTComplex *z)
-{
-    int ln = s->nbits;
-    int	j, np, np2;
-    int	nblocks, nloops;
-    register FFTComplex *p, *q;
-    FFTComplex *exptab = s->exptab;
-    int l;
-    FFTSample tmp_re, tmp_im;
-
-    np = 1 << ln;
-
-    /* pass 0 */
-
-    p=&z[0];
-    j=(np >> 1);
-    do {
-        BF(p[0].re, p[0].im, p[1].re, p[1].im, 
-           p[0].re, p[0].im, p[1].re, p[1].im);
-        p+=2;
-    } while (--j != 0);
-
-    /* pass 1 */
-
-    
-    p=&z[0];
-    j=np >> 2;
-    if (s->inverse) {
-        do {
-            BF(p[0].re, p[0].im, p[2].re, p[2].im, 
-               p[0].re, p[0].im, p[2].re, p[2].im);
-            BF(p[1].re, p[1].im, p[3].re, p[3].im, 
-               p[1].re, p[1].im, -p[3].im, p[3].re);
-            p+=4;
-        } while (--j != 0);
-    } else {
-        do {
-            BF(p[0].re, p[0].im, p[2].re, p[2].im, 
-               p[0].re, p[0].im, p[2].re, p[2].im);
-            BF(p[1].re, p[1].im, p[3].re, p[3].im, 
-               p[1].re, p[1].im, p[3].im, -p[3].re);
-            p+=4;
-        } while (--j != 0);
-    }
-    /* pass 2 .. ln-1 */
-
-    nblocks = np >> 3;
-    nloops = 1 << 2;
-    np2 = np >> 1;
-    do {
-        p = z;
-        q = z + nloops;
-        for (j = 0; j < nblocks; ++j) {
-            BF(p->re, p->im, q->re, q->im,
-               p->re, p->im, q->re, q->im);
-            
-            p++;
-            q++;
-            for(l = nblocks; l < np2; l += nblocks) {
-                CMUL(tmp_re, tmp_im, exptab[l].re, exptab[l].im, q->re, q->im);
-                BF(p->re, p->im, q->re, q->im,
-                   p->re, p->im, tmp_re, tmp_im);
-                p++;
-                q++;
-            }
-
-            p += nloops;
-            q += nloops;
-        }
-        nblocks = nblocks >> 1;
-        nloops = nloops << 1;
-    } while (nblocks != 0);
-}
-
-/**
- * Do the permutation needed BEFORE calling ff_fft_calc()
- */
-void ff_fft_permute(FFTContext *s, FFTComplex *z)
-{
-    int j, k, np;
-    FFTComplex tmp;
-    const uint16_t *revtab = s->revtab;
-    
-    /* reverse */
-    np = 1 << s->nbits;
-    for(j=0;j<np;j++) {
-        k = revtab[j];
-        if (k < j) {
-            tmp = z[k];
-            z[k] = z[j];
-            z[j] = tmp;
-        }
-    }
-}
-
-void ff_fft_end(FFTContext *s)
-{
-    av_freep(&s->revtab);
-    av_freep(&s->exptab);
-    av_freep(&s->exptab1);
-}
-
diff --git a/ffmpeg.src/libavcodec/g726.c b/ffmpeg.src/libavcodec/g726.c
deleted file mode 100644
index efc3c5f..0000000
--- a/ffmpeg.src/libavcodec/g726.c
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- * G.726 ADPCM audio codec 
- * Copyright (c) 2004 Roman Shaposhnik.
- *
- * This is a very straightforward rendition of the G.726
- * Section 4 "Computational Details". 
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include <limits.h>
-#include "avcodec.h"
-#include "common.h"
-#include "bitstream.h"
-
-/**
- * G.726 11bit float.
- * G.726 Standard uses rather odd 11bit floating point arithmentic for 
- * numerous occasions. It's a mistery to me why they did it this way
- * instead of simply using 32bit integer arithmetic.
- */
-typedef struct Float11 {
-	int sign;   /**< 1bit sign */
-	int exp;    /**< 4bit exponent */
-	int mant;   /**< 6bit mantissa */
-} Float11;
-
-static inline Float11* i2f(int16_t i, Float11* f)
-{
-	f->sign = (i < 0);
-	if (f->sign)
-		i = -i;
-	f->exp = av_log2_16bit(i) + !!i;
-	f->mant = i? (i<<6) >> f->exp : 
-		         1<<5;
-	return f;
-}
-
-static inline int16_t mult(Float11* f1, Float11* f2)
-{
-	int res, exp;
-
-	exp = f1->exp + f2->exp;
-	res = (((f1->mant * f2->mant) + 0x30) >> 4) << 7;
-	res = exp > 26 ? res << (exp - 26) : res >> (26 - exp);
-	return (f1->sign ^ f2->sign) ? -res : res;
-}
-
-static inline int sgn(int value)
-{
-   return (value < 0) ? -1 : 1;
-}
-
-typedef struct G726Tables {
-	int  bits;            /**< bits per sample */
-	int* quant;           /**< quantization table */
-	int* iquant;          /**< inverse quantization table */
-	int* W;               /**< special table #1 ;-) */
-	int* F;               /**< special table #2 */
-} G726Tables;
-
-typedef struct G726Context {
-	 G726Tables* tbls;    /**< static tables needed for computation */
-	 
-	 Float11 sr[2];       /**< prev. reconstructed samples */
-	 Float11 dq[6];       /**< prev. difference */
-	 int a[2];            /**< second order predictor coeffs */
-	 int b[6];            /**< sixth order predictor coeffs */
-	 int pk[2];           /**< signs of prev. 2 sez + dq */
-	 
-	 int ap;              /**< scale factor control */
-	 int yu;              /**< fast scale factor */
-	 int yl;              /**< slow scale factor */
-	 int dms;             /**< short average magnitude of F[i] */
-	 int dml;             /**< long average magnitude of F[i] */
-	 int td;              /**< tone detect */
-
-	 int se;              /**< estimated signal for the next iteration */
-	 int sez;             /**< estimated second order prediction */
-	 int y;               /**< quantizer scaling factor for the next iteration */
-} G726Context;
-
-static int quant_tbl16[] =                       /**< 16kbit/s 2bits per sample */
-           { 260, INT_MAX }; 
-static int iquant_tbl16[] =
-           { 116, 365, 365, 116 };
-static int W_tbl16[] = 
-           { -22, 439, 439, -22 };
-static int F_tbl16[] =
-           { 0, 7, 7, 0 };
-	   
-static int quant_tbl24[] =                       /**< 24kbit/s 3bits per sample */
-           {  7, 217, 330, INT_MAX };
-static int iquant_tbl24[] =
-           { INT_MIN, 135, 273, 373, 373, 273, 135, INT_MIN };
-static int W_tbl24[] = 
-           { -4,  30, 137, 582, 582, 137,  30, -4 }; 
-static int F_tbl24[] =
-           { 0, 1, 2, 7, 7, 2, 1, 0 };
-	   
-static int quant_tbl32[] =                       /**< 32kbit/s 4bits per sample */
-           { -125,  79, 177, 245, 299, 348, 399, INT_MAX };
-static int iquant_tbl32[] =
-           { INT_MIN,   4, 135, 213, 273, 323, 373, 425,  
-	         425, 373, 323, 273, 213, 135,   4, INT_MIN };
-static int W_tbl32[] = 
-           { -12,  18,  41,  64, 112, 198, 355, 1122,
-	    1122, 355, 198, 112,  64,  41,  18, -12};
-static int F_tbl32[] = 
-           { 0, 0, 0, 1, 1, 1, 3, 7, 7, 3, 1, 1, 1, 0, 0, 0 };
-	   
-static int quant_tbl40[] =                      /**< 40kbit/s 5bits per sample */
-           { -122, -16,  67, 138, 197, 249, 297, 338,
-	      377, 412, 444, 474, 501, 527, 552, INT_MAX };
-static int iquant_tbl40[] =
-           { INT_MIN, -66,  28, 104, 169, 224, 274, 318,  
-	         358, 395, 429, 459, 488, 514, 539, 566,
-	         566, 539, 514, 488, 459, 429, 395, 358,
-	         318, 274, 224, 169, 104,  28, -66, INT_MIN };
-static int W_tbl40[] = 
-           {   14,  14,  24,  39,  40,  41,   58,  100,
-	      141, 179, 219, 280, 358, 440,  529,  696, 
-	      696, 529, 440, 358, 280, 219,  179,  141,
-	      100,  58,  41,  40,  39,  24,   14,   14 };
-static int F_tbl40[] = 
-           { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 6,
-	     6, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
-
-static G726Tables G726Tables_pool[] = 
-           {{ 2, quant_tbl16, iquant_tbl16, W_tbl16, F_tbl16 },
-	    { 3, quant_tbl24, iquant_tbl24, W_tbl24, F_tbl24 },
-	    { 4, quant_tbl32, iquant_tbl32, W_tbl32, F_tbl32 },
-            { 5, quant_tbl40, iquant_tbl40, W_tbl40, F_tbl40 }};
-					       
-
-/**
- * Para 4.2.2 page 18: Adaptive quantizer. 
- */
-static inline uint8_t quant(G726Context* c, int d)
-{
-   int sign, exp, i, dln;
-   
-   sign = i = 0;
-   if (d < 0) {
-       sign = 1;
-       d = -d;
-   }
-   exp = av_log2_16bit(d);
-   dln = ((exp<<7) + (((d<<7)>>exp)&0x7f)) - (c->y>>2);
-   
-   while (c->tbls->quant[i] < INT_MAX && c->tbls->quant[i] < dln)
-        ++i;
-   
-   if (sign)
-       i = ~i;
-   if (c->tbls->bits != 2 && i == 0) /* I'm not sure this is a good idea */
-       i = 0xff;
-
-   return i; 
-}
-
-/**
- * Para 4.2.3 page 22: Inverse adaptive quantizer.
- */
-static inline int16_t inverse_quant(G726Context* c, int i)
-{
-    int dql, dex, dqt;
-	
-    dql = c->tbls->iquant[i] + (c->y >> 2);
-    dex = (dql>>7) & 0xf;        /* 4bit exponent */
-    dqt = (1<<7) + (dql & 0x7f); /* log2 -> linear */
-    return (dql < 0) ? 0 : ((dqt<<7) >> (14-dex)); 
-}
-
-static inline int16_t g726_iterate(G726Context* c, int16_t I)
-{
-    int dq, re_signal, pk0, fa1, i, tr, ylint, ylfrac, thr2, al, dq0;
-    Float11 f;
-    
-    dq = inverse_quant(c, I);
-    if (I >> (c->tbls->bits - 1))  /* get the sign */
-        dq = -dq;
-    re_signal = c->se + dq;
-
-    /* Transition detect */
-    ylint = (c->yl >> 15);
-    ylfrac = (c->yl >> 10) & 0x1f;
-    thr2 = (ylint > 9) ? 0x1f << 10 : (0x20 + ylfrac) << ylint;
-    if (c->td == 1 && abs(dq) > ((thr2+(thr2>>1))>>1))
-        tr = 1;
-    else
-        tr = 0;
-    
-    /* Update second order predictor coefficient A2 and A1 */
-    pk0 = (c->sez + dq) ? sgn(c->sez + dq) : 0;
-    dq0 = dq ? sgn(dq) : 0;
-    if (tr) {
-        c->a[0] = 0;
-	c->a[1] = 0;
-        for (i=0; i<6; i++)
-	   c->b[i] = 0;
-    } else {
-	/* This is a bit crazy, but it really is +255 not +256 */
-	fa1 = clip((-c->a[0]*c->pk[0]*pk0)>>5, -256, 255);
-	
-	c->a[1] += 128*pk0*c->pk[1] + fa1 - (c->a[1]>>7);
-	c->a[1] = clip(c->a[1], -12288, 12288);
-        c->a[0] += 64*3*pk0*c->pk[0] - (c->a[0] >> 8);
-	c->a[0] = clip(c->a[0], -(15360 - c->a[1]), 15360 - c->a[1]);
-
-        for (i=0; i<6; i++)
-	     c->b[i] += 128*dq0*sgn(-c->dq[i].sign) - (c->b[i]>>8);
-    }
-
-    /* Update Dq and Sr and Pk */
-    c->pk[1] = c->pk[0];
-    c->pk[0] = pk0 ? pk0 : 1;
-    c->sr[1] = c->sr[0];
-    i2f(re_signal, &c->sr[0]);
-    for (i=5; i>0; i--)
-       c->dq[i] = c->dq[i-1];
-    i2f(dq, &c->dq[0]);
-    c->dq[0].sign = I >> (c->tbls->bits - 1); /* Isn't it crazy ?!?! */
-    
-    /* Update tone detect [I'm not sure 'tr == 0' is really needed] */
-    c->td = (tr == 0 && c->a[1] < -11776); 
-       
-    /* Update Ap */
-    c->dms += ((c->tbls->F[I]<<9) - c->dms) >> 5;
-    c->dml += ((c->tbls->F[I]<<11) - c->dml) >> 7;
-    if (tr) 
-       c->ap = 256;
-    else if (c->y > 1535 && !c->td && (abs((c->dms << 2) - c->dml) < (c->dml >> 3)))
-       c->ap += (-c->ap) >> 4;
-    else
-       c->ap += (0x200 - c->ap) >> 4; 
-
-    /* Update Yu and Yl */
-    c->yu = clip(c->y + (((c->tbls->W[I] << 5) - c->y) >> 5), 544, 5120);
-    c->yl += c->yu + ((-c->yl)>>6);
- 
-    /* Next iteration for Y */
-    al = (c->ap >= 256) ? 1<<6 : c->ap >> 2;
-    c->y = (c->yl + (c->yu - (c->yl>>6))*al) >> 6;
-	
-    /* Next iteration for SE and SEZ */
-    c->se = 0;
-    for (i=0; i<6; i++)
-       c->se += mult(i2f(c->b[i] >> 2, &f), &c->dq[i]);
-    c->sez = c->se >> 1;
-    for (i=0; i<2; i++)
-       c->se += mult(i2f(c->a[i] >> 2, &f), &c->sr[i]);
-    c->se >>= 1;
-
-    return clip(re_signal << 2, -0xffff, 0xffff);
-}
-
-static int g726_reset(G726Context* c, int bit_rate)
-{
-    int i;
-
-    c->tbls = &G726Tables_pool[bit_rate/8000 - 2];
-    for (i=0; i<2; i++) {
-       i2f(0, &c->sr[i]);
-       c->a[i] = 0;
-       c->pk[i] = 1;
-    }
-    for (i=0; i<6; i++) {
-       i2f(0, &c->dq[i]);
-       c->b[i] = 0;
-    }
-    c->ap = 0;
-    c->dms = 0;
-    c->dml = 0;
-    c->yu = 544;
-    c->yl = 34816;
-    c->td = 0;
-
-    c->se = 0;
-    c->sez = 0;
-    c->y = 544;
-
-    return 0;
-}
-
-static int16_t g726_decode(G726Context* c, int16_t i)
-{
-    return g726_iterate(c, i);
-}
-
-static int16_t g726_encode(G726Context* c, int16_t sig)
-{
-   uint8_t i;
-   
-   i = quant(c, sig/4 - c->se) & ((1<<c->tbls->bits) - 1);
-   g726_iterate(c, i);
-   return i;
-}
-
-/* Interfacing to the libavcodec */
-
-typedef struct AVG726Context {
-   G726Context c;
-   int bits_left;
-   int bit_buffer;
-   int code_size;
-} AVG726Context;
-
-static int g726_init(AVCodecContext * avctx)
-{
-    AVG726Context* c = (AVG726Context*)avctx->priv_data;
-    
-    if (avctx->channels != 1 ||
-        (avctx->bit_rate != 16000 && avctx->bit_rate != 24000 &&
-	 avctx->bit_rate != 32000 && avctx->bit_rate != 40000)) {
-        av_log(avctx, AV_LOG_ERROR, "G726: unsupported audio format\n");
-	return -1;
-    }
-    if (avctx->sample_rate != 8000 && avctx->strict_std_compliance>FF_COMPLIANCE_INOFFICIAL) {
-        av_log(avctx, AV_LOG_ERROR, "G726: unsupported audio format\n");
-	return -1;
-    }
-    g726_reset(&c->c, avctx->bit_rate);
-    c->code_size = c->c.tbls->bits;
-    c->bit_buffer = 0;
-    c->bits_left = 0;
-
-    avctx->coded_frame = avcodec_alloc_frame();
-    if (!avctx->coded_frame)
-        return -ENOMEM;
-    avctx->coded_frame->key_frame = 1;
-
-    return 0;
-}
-
-static int g726_close(AVCodecContext *avctx)
-{
-    av_freep(&avctx->coded_frame);
-    return 0;
-}
-
-static int g726_encode_frame(AVCodecContext *avctx,
-                            uint8_t *dst, int buf_size, void *data)
-{
-    AVG726Context *c = avctx->priv_data;
-    short *samples = data;
-    PutBitContext pb;
-
-    init_put_bits(&pb, dst, 1024*1024);
-
-    for (; buf_size; buf_size--)
-       put_bits(&pb, c->code_size, g726_encode(&c->c, *samples++));
-
-    flush_put_bits(&pb);
-
-    return put_bits_count(&pb)>>3; 
-}		
-
-static int g726_decode_frame(AVCodecContext *avctx,
-                             void *data, int *data_size,
-                             uint8_t *buf, int buf_size)
-{
-    AVG726Context *c = avctx->priv_data;
-    short *samples = data;
-    uint8_t code;
-    uint8_t mask;
-    GetBitContext gb; 
-   
-    if (!buf_size)
-        goto out;
-    
-    mask = (1<<c->code_size) - 1;
-    init_get_bits(&gb, buf, buf_size * 8);
-    if (c->bits_left) {
-        int s = c->code_size - c->bits_left;;
-	code = (c->bit_buffer << s) | get_bits(&gb, s);
-	*samples++ = g726_decode(&c->c, code & mask);
-    }
-    
-    while (get_bits_count(&gb) + c->code_size <= buf_size*8)
-	*samples++ = g726_decode(&c->c, get_bits(&gb, c->code_size) & mask);
-    
-    c->bits_left = buf_size*8 - get_bits_count(&gb);
-    c->bit_buffer = get_bits(&gb, c->bits_left);
-    
-out:
-    *data_size = (uint8_t*)samples - (uint8_t*)data;
-    return buf_size;
-}
-
-#ifdef CONFIG_ENCODERS
-AVCodec adpcm_g726_encoder = {
-    "g726",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_ADPCM_G726,
-    sizeof(AVG726Context),
-    g726_init,
-    g726_encode_frame,
-    g726_close,
-    NULL,
-};
-#endif //CONFIG_ENCODERS
-
-AVCodec adpcm_g726_decoder = {
-    "g726",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_ADPCM_G726,
-    sizeof(AVG726Context),
-    g726_init,
-    NULL,
-    g726_close,
-    g726_decode_frame,
-};
diff --git a/ffmpeg.src/libavcodec/golomb.c b/ffmpeg.src/libavcodec/golomb.c
deleted file mode 100644
index a63f822..0000000
--- a/ffmpeg.src/libavcodec/golomb.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * exp golomb vlc stuff
- * Copyright (c) 2003 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
- 
-/**
- * @file golomb.c
- * @brief 
- *     exp golomb vlc stuff
- * @author Michael Niedermayer <michaelni at gmx.at>
- */
-
-#include "common.h"
- 
-const uint8_t ff_golomb_vlc_len[512]={
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
-7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
-5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,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 uint8_t ff_ue_golomb_vlc_code[512]={ 
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,
- 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,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 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, 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, 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, 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, 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, 0
-};
-
-const int8_t ff_se_golomb_vlc_code[512]={ 
-  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  8, -8,  9, -9, 10,-10, 11,-11, 12,-12, 13,-13, 14,-14, 15,-15,
-  4,  4,  4,  4, -4, -4, -4, -4,  5,  5,  5,  5, -5, -5, -5, -5,  6,  6,  6,  6, -6, -6, -6, -6,  7,  7,  7,  7, -7, -7, -7, -7,
-  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
-  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
-  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -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,  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,  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,  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,  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,  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,
-};
-
-
-const uint8_t ff_ue_golomb_len[256]={ 
- 1, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,11,
-11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,13,
-13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
-13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,15,
-15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
-15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
-15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
-15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,17,
-};
-
-const uint8_t ff_interleaved_golomb_vlc_len[256]={
-9,9,7,7,9,9,7,7,5,5,5,5,5,5,5,5,
-9,9,7,7,9,9,7,7,5,5,5,5,5,5,5,5,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-9,9,7,7,9,9,7,7,5,5,5,5,5,5,5,5,
-9,9,7,7,9,9,7,7,5,5,5,5,5,5,5,5,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-1,1,1,1,1,1,1,1,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 uint8_t ff_interleaved_ue_golomb_vlc_code[256]={ 
- 15,16,7, 7, 17,18,8, 8, 3, 3, 3, 3, 3, 3, 3, 3,
- 19,20,9, 9, 21,22,10,10,4, 4, 4, 4, 4, 4, 4, 4, 
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 23,24,11,11,25,26,12,12,5, 5, 5, 5, 5, 5, 5, 5, 
- 27,28,13,13,29,30,14,14,6, 6, 6, 6, 6, 6, 6, 6,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 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, 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, 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,
-};
-
-const int8_t ff_interleaved_se_golomb_vlc_code[256]={ 
-  8, -8,  4,  4,  9, -9, -4, -4,  2,  2,  2,  2,  2,  2,  2,  2,
- 10,-10,  5,  5, 11,-11, -5, -5, -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,
- 12,-12,  6,  6, 13,-13, -6, -6,  3,  3,  3,  3,  3,  3,  3,  3,
- 14,-14,  7,  7, 15,-15, -7, -7, -3, -3, -3, -3, -3, -3, -3, -3,
- -1, -1, -1, -1, -1, -1, -1, -1, -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,  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,  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,  0,  0,  0,  0,  0,  0,  0,  0,
-  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-};
diff --git a/ffmpeg.src/libavcodec/golomb.h b/ffmpeg.src/libavcodec/golomb.h
deleted file mode 100644
index 1204a52..0000000
--- a/ffmpeg.src/libavcodec/golomb.h
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * exp golomb vlc stuff
- * Copyright (c) 2003 Michael Niedermayer <michaelni at gmx.at>
- * Copyright (c) 2004 Alex Beregszaszi
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
- 
-/**
- * @file golomb.h
- * @brief 
- *     exp golomb vlc stuff
- * @author Michael Niedermayer <michaelni at gmx.at> and Alex Beregszaszi
- */
-
-#define INVALID_VLC           0x80000000
-
-extern const uint8_t ff_golomb_vlc_len[512];
-extern const uint8_t ff_ue_golomb_vlc_code[512];
-extern const  int8_t ff_se_golomb_vlc_code[512];
-extern const uint8_t ff_ue_golomb_len[256];
-
-extern const uint8_t ff_interleaved_golomb_vlc_len[256];
-extern const uint8_t ff_interleaved_ue_golomb_vlc_code[256];
-extern const  int8_t ff_interleaved_se_golomb_vlc_code[256];
-
- 
- /**
- * read unsigned exp golomb code.
- */
-static inline int get_ue_golomb(GetBitContext *gb){
-    unsigned int buf;
-    int log;
-    
-    OPEN_READER(re, gb);
-    UPDATE_CACHE(re, gb);
-    buf=GET_CACHE(re, gb);
-    
-    if(buf >= (1<<27)){
-        buf >>= 32 - 9;
-        LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
-        CLOSE_READER(re, gb);
-    
-        return ff_ue_golomb_vlc_code[buf];
-    }else{
-        log= 2*av_log2(buf) - 31;
-        buf>>= log;
-        buf--;
-        LAST_SKIP_BITS(re, gb, 32 - log);
-        CLOSE_READER(re, gb);
-    
-        return buf;
-    }
-}
-
-static inline int svq3_get_ue_golomb(GetBitContext *gb){
-    uint32_t buf;
-    int log;
-
-    OPEN_READER(re, gb);
-    UPDATE_CACHE(re, gb);
-    buf=GET_CACHE(re, gb);
-    
-    if(buf&0xAA800000){
-        buf >>= 32 - 8;
-        LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
-        CLOSE_READER(re, gb);
-        
-        return ff_interleaved_ue_golomb_vlc_code[buf];
-    }else{
-        LAST_SKIP_BITS(re, gb, 8);
-        UPDATE_CACHE(re, gb);
-        buf |= 1 | (GET_CACHE(re, gb) >> 8);
-
-        if((buf & 0xAAAAAAAA) == 0)
-            return INVALID_VLC;
-
-        for(log=31; (buf & 0x80000000) == 0; log--){
-            buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
-        }
-
-        LAST_SKIP_BITS(re, gb, 63 - 2*log - 8);
-        CLOSE_READER(re, gb);
-
-        return ((buf << log) >> log) - 1;
-    }
-}
-
-/**
- * read unsigned truncated exp golomb code.
- */
-static inline int get_te0_golomb(GetBitContext *gb, int range){
-    assert(range >= 1);
-    
-    if(range==1)      return 0;
-    else if(range==2) return get_bits1(gb)^1;
-    else              return get_ue_golomb(gb);
-}
-
-/**
- * read unsigned truncated exp golomb code.
- */
-static inline int get_te_golomb(GetBitContext *gb, int range){
-    assert(range >= 1);
-    
-    if(range==2) return get_bits1(gb)^1;
-    else         return get_ue_golomb(gb);
-}
-
-
-/**
- * read signed exp golomb code.
- */
-static inline int get_se_golomb(GetBitContext *gb){
-    unsigned int buf;
-    int log;
-    
-    OPEN_READER(re, gb);
-    UPDATE_CACHE(re, gb);
-    buf=GET_CACHE(re, gb);
-    
-    if(buf >= (1<<27)){
-        buf >>= 32 - 9;
-        LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
-        CLOSE_READER(re, gb);
-    
-        return ff_se_golomb_vlc_code[buf];
-    }else{
-        log= 2*av_log2(buf) - 31;
-        buf>>= log;
-        
-        LAST_SKIP_BITS(re, gb, 32 - log);
-        CLOSE_READER(re, gb);
-    
-        if(buf&1) buf= -(buf>>1);
-        else      buf=  (buf>>1);
-
-        return buf;
-    }
-}
-
-static inline int svq3_get_se_golomb(GetBitContext *gb){
-    unsigned int buf;
-    int log;
-
-    OPEN_READER(re, gb);
-    UPDATE_CACHE(re, gb);
-    buf=GET_CACHE(re, gb);
-
-    if(buf&0xAA800000){
-        buf >>= 32 - 8;
-        LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
-        CLOSE_READER(re, gb);
-        
-        return ff_interleaved_se_golomb_vlc_code[buf];
-    }else{
-        LAST_SKIP_BITS(re, gb, 8);
-        UPDATE_CACHE(re, gb);
-        buf |= 1 | (GET_CACHE(re, gb) >> 8);
-
-        if((buf & 0xAAAAAAAA) == 0)
-            return INVALID_VLC;
-
-        for(log=31; (buf & 0x80000000) == 0; log--){
-            buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
-        }
-
-        LAST_SKIP_BITS(re, gb, 63 - 2*log - 8);
-        CLOSE_READER(re, gb);
-
-        return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1;
-    }
-}
-
-/**
- * read unsigned golomb rice code (ffv1).
- */
-static inline int get_ur_golomb(GetBitContext *gb, int k, int limit, int esc_len){
-    unsigned int buf;
-    int log;
-    
-    OPEN_READER(re, gb);
-    UPDATE_CACHE(re, gb);
-    buf=GET_CACHE(re, gb);
-
-    log= av_log2(buf);
-
-    if(log > 31-limit){
-        buf >>= log - k;
-        buf += (30-log)<<k;
-        LAST_SKIP_BITS(re, gb, 32 + k - log);
-        CLOSE_READER(re, gb);
-    
-        return buf;
-    }else{
-        buf >>= 32 - limit - esc_len;
-        LAST_SKIP_BITS(re, gb, esc_len + limit);
-        CLOSE_READER(re, gb);
-    
-        return buf + limit - 1;
-    }
-}
-
-/**
- * read unsigned golomb rice code (jpegls).
- */
-static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int esc_len){
-    unsigned int buf;
-    int log;
-    
-    OPEN_READER(re, gb);
-    UPDATE_CACHE(re, gb);
-    buf=GET_CACHE(re, gb);
-
-    log= av_log2(buf);
-    
-    if(log > 31-11){
-        buf >>= log - k;
-        buf += (30-log)<<k;
-        LAST_SKIP_BITS(re, gb, 32 + k - log);
-        CLOSE_READER(re, gb);
-    
-        return buf;
-    }else{
-        int i;
-        for(i=0; SHOW_UBITS(re, gb, 1) == 0; i++){
-            LAST_SKIP_BITS(re, gb, 1);
-            UPDATE_CACHE(re, gb);
-        }
-        SKIP_BITS(re, gb, 1);
-
-        if(i < limit - 1){
-            if(k){
-                buf = SHOW_UBITS(re, gb, k);
-                LAST_SKIP_BITS(re, gb, k);
-            }else{
-                buf=0;
-            }
-
-            CLOSE_READER(re, gb);
-            return buf + (i<<k);
-        }else if(i == limit - 1){
-            buf = SHOW_UBITS(re, gb, esc_len);
-            LAST_SKIP_BITS(re, gb, esc_len);
-            CLOSE_READER(re, gb);
-    
-            return buf + 1;
-        }else
-            return -1;
-    }
-}
-
-/**
- * read signed golomb rice code (ffv1).
- */
-static inline int get_sr_golomb(GetBitContext *gb, int k, int limit, int esc_len){
-    int v= get_ur_golomb(gb, k, limit, esc_len);
-    
-    v++;
-    if (v&1) return v>>1;
-    else return -(v>>1);
-    
-//    return (v>>1) ^ -(v&1);
-}
-
-/**
- * read signed golomb rice code (flac).
- */
-static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit, int esc_len){
-    int v= get_ur_golomb_jpegls(gb, k, limit, esc_len);
-    return (v>>1) ^ -(v&1);
-}
-
-/**
- * read unsigned golomb rice code (shorten).
- */
-static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k){
-	return get_ur_golomb_jpegls(gb, k, INT_MAX, 0);
-}
-
-/**
- * read signed golomb rice code (shorten).
- */
-static inline int get_sr_golomb_shorten(GetBitContext* gb, int k)
-{
-    int uvar = get_ur_golomb_jpegls(gb, k + 1, INT_MAX, 0);
-    if (uvar & 1)
-        return ~(uvar >> 1);
-    else
-        return uvar >> 1;
-}
-
-
-
-#ifdef TRACE
-
-static inline int get_ue(GetBitContext *s, char *file, const char *func, int line){
-    int show= show_bits(s, 24);
-    int pos= get_bits_count(s);
-    int i= get_ue_golomb(s);
-    int len= get_bits_count(s) - pos;
-    int bits= show>>(24-len);
-    
-    print_bin(bits, len);
-    
-    av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d ue  @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
-    
-    return i;
-}
-
-static inline int get_se(GetBitContext *s, char *file, const char *func, int line){
-    int show= show_bits(s, 24);
-    int pos= get_bits_count(s);
-    int i= get_se_golomb(s);
-    int len= get_bits_count(s) - pos;
-    int bits= show>>(24-len);
-    
-    print_bin(bits, len);
-    
-    av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d se  @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
-    
-    return i;
-}
-
-static inline int get_te(GetBitContext *s, int r, char *file, const char *func, int line){
-    int show= show_bits(s, 24);
-    int pos= get_bits_count(s);
-    int i= get_te0_golomb(s, r);
-    int len= get_bits_count(s) - pos;
-    int bits= show>>(24-len);
-    
-    print_bin(bits, len);
-    
-    av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d te  @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
-    
-    return i;
-}
-
-#define get_ue_golomb(a) get_ue(a, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#define get_se_golomb(a) get_se(a, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#define get_te_golomb(a, r) get_te(a, r, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#define get_te0_golomb(a, r) get_te(a, r, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-
-#endif
-
-/**
- * write unsigned exp golomb code.
- */
-static inline void set_ue_golomb(PutBitContext *pb, int i){
-    int e;
-    
-    assert(i>=0);
-
-#if 0
-    if(i=0){
-        put_bits(pb, 1, 1);
-        return;
-    }
-#endif
-    if(i<256)
-        put_bits(pb, ff_ue_golomb_len[i], i+1);
-    else{
-        e= av_log2(i+1);
-    
-        put_bits(pb, 2*e+1, i+1);
-    }
-}
-
-/**
- * write truncated unsigned exp golomb code.
- */
-static inline void set_te_golomb(PutBitContext *pb, int i, int range){
-    assert(range >= 1);
-    assert(i<=range);
-
-    if(range==2) put_bits(pb, 1, i^1);
-    else         set_ue_golomb(pb, i);
-}
-
-/**
- * write signed exp golomb code.
- */
-static inline void set_se_golomb(PutBitContext *pb, int i){
-#if 0 
-    if(i<=0) i= -2*i;
-    else     i=  2*i-1;
-#elif 1
-    i= 2*i-1;
-    if(i<0) i^= -1; //FIXME check if gcc does the right thing
-#else
-    i= 2*i-1;
-    i^= (i>>31);
-#endif
-    set_ue_golomb(pb, i);
-}
-
-/**
- * write unsigned golomb rice code (ffv1).
- */
-static inline void set_ur_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len){
-    int e;
-    
-    assert(i>=0);
-    
-    e= i>>k;
-    if(e<limit){
-        put_bits(pb, e + k + 1, (1<<k) + (i&((1<<k)-1)));
-    }else{
-        put_bits(pb, limit + esc_len, i - limit + 1);
-    }
-}
-
-/**
- * write unsigned golomb rice code (jpegls).
- */
-static inline void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k, int limit, int esc_len){
-    int e;
-    
-    assert(i>=0);
-    
-    e= (i>>k) + 1;
-    if(e<limit){
-        put_bits(pb, e, 1);
-        if(k)
-            put_bits(pb, k, i&((1<<k)-1));
-    }else{
-        put_bits(pb, limit  , 1);
-        put_bits(pb, esc_len, i - 1);
-    }
-}
-
-/**
- * write signed golomb rice code (ffv1).
- */
-static inline void set_sr_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len){
-    int v;
-
-    v = -2*i-1;
-    v ^= (v>>31);
-
-    set_ur_golomb(pb, v, k, limit, esc_len);
-}
-
-/**
- * write signed golomb rice code (flac).
- */
-static inline void set_sr_golomb_flac(PutBitContext *pb, int i, int k, int limit, int esc_len){
-    int v;
-
-    v = -2*i-1;
-    v ^= (v>>31);
-
-    set_ur_golomb_jpegls(pb, v, k, limit, esc_len);
-}
diff --git a/ffmpeg.src/libavcodec/h261data.h b/ffmpeg.src/libavcodec/h261data.h
deleted file mode 100644
index 9ea991b..0000000
--- a/ffmpeg.src/libavcodec/h261data.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * @file h261data.h
- * H.261 tables.
- */
-#define MB_TYPE_H261_FIL 0x800000
-
-// H.261 VLC table for macroblock addressing
-const uint8_t h261_mba_code[35] = {
-     1,  3,  2,  3,
-     2,  3,  2,  7,
-     6, 11, 10,  9,
-     8,  7,  6, 23,
-    22, 21, 20, 19,
-    18, 35, 34, 33,
-    32, 31, 30, 29,
-    28, 27, 26, 25,
-    24,
-    15,           //(MBA stuffing)
-    1             //(start code)
-};
-
-const uint8_t h261_mba_bits[35] = {
-     1,  3,  3,  4,
-     4,  5,  5,  7,
-     7,  8,  8,  8,
-     8,  8,  8, 10,
-    10, 10, 10, 10,
-    10, 11, 11, 11,
-    11, 11, 11, 11,
-    11, 11, 11, 11,
-    11,
-    11,           //(MBA stuffing)
-    16            //(start code)
-};
-
-//H.261 VLC table for macroblock type
-const uint8_t h261_mtype_code[10] = {
-    1,  1,  1,  1,
-    1,  1,  1,  1,
-    1,  1
-};
-
-const uint8_t h261_mtype_bits[10] = {
-    4,  7,  1,  5,
-    9,  8, 10,  3,
-    2,  6
-};
-
-static const int h261_mtype_map[10]= {
-        MB_TYPE_INTRA4x4,
-        MB_TYPE_INTRA4x4  |  MB_TYPE_QUANT,
-                                               MB_TYPE_CBP,
-                             MB_TYPE_QUANT  |  MB_TYPE_CBP,
-                                                               MB_TYPE_16x16,
-                                               MB_TYPE_CBP  |  MB_TYPE_16x16,
-                             MB_TYPE_QUANT  |  MB_TYPE_CBP  |  MB_TYPE_16x16,
-                                                               MB_TYPE_16x16  |  MB_TYPE_H261_FIL,
-                                               MB_TYPE_CBP  |  MB_TYPE_16x16  |  MB_TYPE_H261_FIL,
-                             MB_TYPE_QUANT  |  MB_TYPE_CBP  |  MB_TYPE_16x16  |  MB_TYPE_H261_FIL
-};
-
-//H.261 VLC table for motion vectors
-const uint8_t h261_mv_tab[17][2] = {
-    {1,1}, {1,2}, {1,3}, {1,4}, {3,6}, {5,7}, {4,7}, {3,7},
-    {11,9}, {10,9}, {9,9}, {17,10}, {16,10}, {15,10}, {14,10}, {13,10}, {12,10}
-};
-
-static const int mvmap[17] =
-{
-    0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16
-};
-
-//H.261 VLC table for coded block pattern
-const uint8_t h261_cbp_tab[63][2] =
-{
-    {11,5}, {9,5}, {13,6}, {13,4}, {23,7}, {19,7}, {31,8}, {12,4},
-    {22,7}, {18,7}, {30,8}, {19,5}, {27,8}, {23,8}, {19,8}, {11,4},
-    {21,7}, {17,7}, {29,8}, {17,5}, {25,8}, {21,8}, {17,8}, {15,6},
-    {15,8}, {13,8}, {3,9}, {15,5}, {11,8}, {7,8}, {7,9}, {10,4},
-    {20,7}, {16,7}, {28,8}, {14,6}, {14,8}, {12,8}, {2,9}, {16,5},
-    {24,8}, {20,8}, {16,8}, {14,5}, {10,8}, {6,8}, {6,9}, {18,5},
-    {26,8}, {22,8}, {18,8}, {13,5}, {9,8}, {5,8}, {5,9}, {12,5},
-    {8,8}, {4,8}, {4,9}, {7,3}, {10,5}, {8,5}, {12,6}
-};
-
-//H.261 VLC table for transform coefficients
-const uint16_t h261_tcoeff_vlc[65][2] = {
-{ 0x2, 2 }, { 0x3, 2 },{ 0x4, 4 },{ 0x5, 5 },
-{ 0x6, 7 },{ 0x26, 8 },{ 0x21, 8 },{ 0xa, 10 },
-{ 0x1d, 12 },{ 0x18, 12 },{ 0x13, 12 },{ 0x10 , 12 },
-{ 0x1a, 13},{ 0x19, 13 }, { 0x18, 13 }, { 0x17, 13 },
-{ 0x3, 3 }, { 0x6, 6 }, { 0x25 , 8 }, { 0xc, 10 },
-{ 0x1b, 12 }, { 0x16, 13 }, { 0x15, 13 }, { 0x5, 4},
-{ 0x4, 7}, { 0xb, 10 }, { 0x14, 12 }, { 0x14, 13 },
-{ 0x7, 5 }, { 0x24, 8 }, { 0x1c, 12 }, { 0x13, 13 },
-{ 0x6, 5 }, { 0xf, 10 }, { 0x12, 12}, { 0x7, 6},
-{ 0x9 , 10 }, { 0x12, 13 }, { 0x5, 6 }, { 0x1e, 12 },
-{ 0x4, 6 }, { 0x15, 12 }, { 0x7, 7 }, { 0x11, 12},
-{ 0x5, 7 }, { 0x11, 13 }, { 0x27, 8 }, { 0x10, 13 },
-{ 0x23, 8 }, { 0x22, 8 }, { 0x20, 8 }, { 0xe , 10 },
-{ 0xd, 10 }, { 0x8, 10 },{ 0x1f, 12 }, { 0x1a, 12 },
-{ 0x19, 12 }, { 0x17, 12 }, { 0x16, 12}, { 0x1f, 13},
-{ 0x1e, 13 }, { 0x1d, 13 }, { 0x1c, 13}, { 0x1b, 13},
-{ 0x1, 6 }                                             //escape
-};
-
-const int8_t h261_tcoeff_level[64] = {
-    0,  1,  2,  3,  4,  5,  6,  7,
-    8,  9, 10, 11, 12, 13, 14, 15,
-    1,  2,  3,  4,  5,  6,  7,  1,
-    2,  3,  4,  5,  1,  2,  3,  4,
-    1,  2,  3,  1,  2,  3,  1,  2,
-    1,  2,  1,  2,  1,  2,  1,  2,
-    1,  1,  1,  1,  1,  1,  1,  1,
-    1,  1,  1,  1,  1,  1,  1,  1
-};
-
-const int8_t h261_tcoeff_run[64] = {
-    0,
-    0,  0,  0,  0,  0,  0,  0,  0,
-    0,  0,  0,  0,  0,  0,  0,  1,
-    1,  1,  1,  1,  1,  1,  2,  2,
-    2,  2,  2,  3,  3,  3,  3,  4,
-    4,  4,  5,  5,  5,  6,  6,  7,
-    7,  8,  8,  9,  9, 10, 10, 11,
-   12, 13, 14, 15, 16, 17, 18, 19,
-   20, 21, 22, 23, 24, 25, 26
-};
-
-static RLTable h261_rl_tcoeff = {
-    64,
-    64,
-    h261_tcoeff_vlc,
-    h261_tcoeff_run,
-    h261_tcoeff_level,
-};
diff --git a/ffmpeg.src/libavcodec/h263.c b/ffmpeg.src/libavcodec/h263.c
deleted file mode 100644
index 5ba6a66..0000000
--- a/ffmpeg.src/libavcodec/h263.c
+++ /dev/null
@@ -1,6231 +0,0 @@
-/*
- * H263/MPEG4 backend for ffmpeg encoder and decoder
- * Copyright (c) 2000,2001 Fabrice Bellard.
- * H263+ support.
- * Copyright (c) 2001 Juan J. Sierralta P.
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * ac prediction encoding, b-frame support, error resilience, optimizations,
- * qpel decoding, gmc decoding, interlaced decoding, 
- * by Michael Niedermayer <michaelni at gmx.at>
- */
-
-/**
- * @file h263.c
- * h263/mpeg4 codec.
- */
- 
-//#define DEBUG
-#include <limits.h>
-
-#include "common.h"
-#include "dsputil.h"
-#include "avcodec.h"
-#include "mpegvideo.h"
-#include "h263data.h"
-#include "mpeg4data.h"
-
-//#undef NDEBUG
-//#include <assert.h>
-
-#define INTRA_MCBPC_VLC_BITS 6
-#define INTER_MCBPC_VLC_BITS 7
-#define CBPY_VLC_BITS 6
-#define MV_VLC_BITS 9
-#define DC_VLC_BITS 9
-#define SPRITE_TRAJ_VLC_BITS 6
-#define MB_TYPE_B_VLC_BITS 4
-#define TEX_VLC_BITS 9
-#define H263_MBTYPE_B_VLC_BITS 6
-#define CBPC_B_VLC_BITS 3
-
-#ifdef CONFIG_ENCODERS
-static void h263_encode_block(MpegEncContext * s, DCTELEM * block,
-                              int n);
-static void h263p_encode_umotion(MpegEncContext * s, int val);
-static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block,
-                               int n, int dc, uint8_t *scan_table, 
-                               PutBitContext *dc_pb, PutBitContext *ac_pb);
-#endif
-
-static int h263_decode_motion(MpegEncContext * s, int pred, int fcode);
-static int h263p_decode_umotion(MpegEncContext * s, int pred);
-static int h263_decode_block(MpegEncContext * s, DCTELEM * block,
-                             int n, int coded);
-static inline int mpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr);
-static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
-                              int n, int coded, int intra, int rvlc);
-static int mpeg4_get_block_length(MpegEncContext * s, DCTELEM * block, int n, int intra_dc, 
-                               uint8_t *scan_table);
-static int h263_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr);
-#ifdef CONFIG_ENCODERS
-static void mpeg4_encode_visual_object_header(MpegEncContext * s);
-static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_number);
-#endif //CONFIG_ENCODERS
-static void mpeg4_decode_sprite_trajectory(MpegEncContext * s, GetBitContext *gb);
-static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, int level, int *dir_ptr, int encoding);
-
-#ifdef CONFIG_ENCODERS
-static uint8_t uni_DCtab_lum_len[512];
-static uint8_t uni_DCtab_chrom_len[512];
-static uint16_t uni_DCtab_lum_bits[512];
-static uint16_t uni_DCtab_chrom_bits[512];
-
-static uint8_t (*mv_penalty)[MAX_MV*2+1]= NULL;
-static uint8_t fcode_tab[MAX_MV*2+1];
-static uint8_t umv_fcode_tab[MAX_MV*2+1];
-
-static uint32_t uni_mpeg4_intra_rl_bits[64*64*2*2];
-static uint8_t  uni_mpeg4_intra_rl_len [64*64*2*2];
-static uint32_t uni_mpeg4_inter_rl_bits[64*64*2*2];
-static uint8_t  uni_mpeg4_inter_rl_len [64*64*2*2];
-static uint8_t  uni_h263_intra_aic_rl_len [64*64*2*2];
-static uint8_t  uni_h263_inter_rl_len [64*64*2*2];
-//#define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128 + (run)*256 + (level))
-//#define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run) + (level)*64)
-#define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level))
-
-/* mpeg4
-inter
-max level: 24/6
-max run: 53/63
-
-intra
-max level: 53/16
-max run: 29/41
-*/
-#endif
-
-#if 0 //3IV1 is quite rare and it slows things down a tiny bit
-#define IS_3IV1 s->avctx->codec_tag == ff_get_fourcc("3IV1")
-#else 
-#define IS_3IV1 0
-#endif
-
-int h263_get_picture_format(int width, int height)
-{
-    int format;
-
-    if (width == 128 && height == 96)
-        format = 1;
-    else if (width == 176 && height == 144)
-        format = 2;
-    else if (width == 352 && height == 288)
-        format = 3;
-    else if (width == 704 && height == 576)
-        format = 4;
-    else if (width == 1408 && height == 1152)
-        format = 5;
-    else
-        format = 7;
-    return format;
-}
-
-#ifdef CONFIG_ENCODERS
-
-static void aspect_to_info(MpegEncContext * s, AVRational aspect){
-    int i;
-
-    if(aspect.num==0) aspect= (AVRational){1,1};
-
-    for(i=1; i<6; i++){
-        if(av_cmp_q(pixel_aspect[i], aspect) == 0){
-            s->aspect_ratio_info=i;
-            return;
-        }
-    }
-    
-    s->aspect_ratio_info= FF_ASPECT_EXTENDED;
-}
-
-void ff_flv_encode_picture_header(MpegEncContext * s, int picture_number)
-{
-      int format;
-
-      align_put_bits(&s->pb);
-
-      put_bits(&s->pb, 17, 1);
-      put_bits(&s->pb, 5, (s->h263_flv-1)); /* 0: h263 escape codes 1: 11-bit escape codes */
-      put_bits(&s->pb, 8, (((int64_t)s->picture_number * 30 * s->avctx->time_base.num) / //FIXME use timestamp
-                           s->avctx->time_base.den) & 0xff); /* TemporalReference */
-      if (s->width == 352 && s->height == 288)
-        format = 2;
-      else if (s->width == 176 && s->height == 144)
-        format = 3;
-      else if (s->width == 128 && s->height == 96)
-        format = 4;
-      else if (s->width == 320 && s->height == 240)
-        format = 5;
-      else if (s->width == 160 && s->height == 120)
-        format = 6;
-      else if (s->width <= 255 && s->height <= 255)
-        format = 0; /* use 1 byte width & height */
-      else
-        format = 1; /* use 2 bytes width & height */
-      put_bits(&s->pb, 3, format); /* PictureSize */
-      if (format == 0) {
-        put_bits(&s->pb, 8, s->width);
-        put_bits(&s->pb, 8, s->height);
-      } else if (format == 1) {
-        put_bits(&s->pb, 16, s->width);
-        put_bits(&s->pb, 16, s->height);
-      }
-      put_bits(&s->pb, 2, s->pict_type == P_TYPE); /* PictureType */
-      put_bits(&s->pb, 1, 1); /* DeblockingFlag: on */
-      put_bits(&s->pb, 5, s->qscale); /* Quantizer */
-      put_bits(&s->pb, 1, 0); /* ExtraInformation */
-
-      if(s->h263_aic){
-        s->y_dc_scale_table= 
-          s->c_dc_scale_table= ff_aic_dc_scale_table;
-      }else{
-        s->y_dc_scale_table=
-          s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
-      }
-}
-
-void h263_encode_picture_header(MpegEncContext * s, int picture_number)
-{
-    int format, coded_frame_rate, coded_frame_rate_base, i, temp_ref;
-    int best_clock_code=1;
-    int best_divisor=60;
-    int best_error= INT_MAX;
-   
-    if(s->h263_plus){
-        for(i=0; i<2; i++){
-            int div, error;
-            div= (s->avctx->time_base.num*1800000LL + 500LL*s->avctx->time_base.den) / ((1000LL+i)*s->avctx->time_base.den);
-            div= clip(1, div, 127);
-            error= ABS(s->avctx->time_base.num*1800000LL - (1000LL+i)*s->avctx->time_base.den*div);
-            if(error < best_error){
-                best_error= error;
-                best_divisor= div;
-                best_clock_code= i;
-            }
-        }
-    }
-    s->custom_pcf= best_clock_code!=1 || best_divisor!=60;
-    coded_frame_rate= 1800000;
-    coded_frame_rate_base= (1000+best_clock_code)*best_divisor;
-
-    align_put_bits(&s->pb);
-
-    /* Update the pointer to last GOB */
-    s->ptr_lastgob = pbBufPtr(&s->pb);
-    put_bits(&s->pb, 22, 0x20); /* PSC */
-    temp_ref= s->picture_number * (int64_t)coded_frame_rate * s->avctx->time_base.num / //FIXME use timestamp
-                         (coded_frame_rate_base * (int64_t)s->avctx->time_base.den);
-    put_bits(&s->pb, 8, temp_ref & 0xff); /* TemporalReference */
-
-    put_bits(&s->pb, 1, 1);	/* marker */
-    put_bits(&s->pb, 1, 0);	/* h263 id */
-    put_bits(&s->pb, 1, 0);	/* split screen off */
-    put_bits(&s->pb, 1, 0);	/* camera  off */
-    put_bits(&s->pb, 1, 0);	/* freeze picture release off */
-    
-    format = h263_get_picture_format(s->width, s->height);
-    if (!s->h263_plus) {
-        /* H.263v1 */
-        put_bits(&s->pb, 3, format);
-        put_bits(&s->pb, 1, (s->pict_type == P_TYPE));
-        /* By now UMV IS DISABLED ON H.263v1, since the restrictions
-        of H.263v1 UMV implies to check the predicted MV after
-        calculation of the current MB to see if we're on the limits */
-        put_bits(&s->pb, 1, 0);	/* Unrestricted Motion Vector: off */
-        put_bits(&s->pb, 1, 0);	/* SAC: off */
-        put_bits(&s->pb, 1, s->obmc);	/* Advanced Prediction */
-        put_bits(&s->pb, 1, 0);	/* only I/P frames, no PB frame */
-        put_bits(&s->pb, 5, s->qscale);
-        put_bits(&s->pb, 1, 0);	/* Continuous Presence Multipoint mode: off */
-    } else {
-        int ufep=1;
-        /* H.263v2 */
-        /* H.263 Plus PTYPE */
-        
-        put_bits(&s->pb, 3, 7);
-        put_bits(&s->pb,3,ufep); /* Update Full Extended PTYPE */
-        if (format == 7)
-            put_bits(&s->pb,3,6); /* Custom Source Format */
-        else
-            put_bits(&s->pb, 3, format);
-            
-        put_bits(&s->pb,1, s->custom_pcf);
-        put_bits(&s->pb,1, s->umvplus); /* Unrestricted Motion Vector */
-        put_bits(&s->pb,1,0); /* SAC: off */
-        put_bits(&s->pb,1,s->obmc); /* Advanced Prediction Mode */
-        put_bits(&s->pb,1,s->h263_aic); /* Advanced Intra Coding */
-        put_bits(&s->pb,1,s->loop_filter); /* Deblocking Filter */
-        put_bits(&s->pb,1,s->h263_slice_structured); /* Slice Structured */
-        put_bits(&s->pb,1,0); /* Reference Picture Selection: off */
-        put_bits(&s->pb,1,0); /* Independent Segment Decoding: off */
-        put_bits(&s->pb,1,s->alt_inter_vlc); /* Alternative Inter VLC */
-        put_bits(&s->pb,1,s->modified_quant); /* Modified Quantization: */
-        put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
-        put_bits(&s->pb,3,0); /* Reserved */
-		
-        put_bits(&s->pb, 3, s->pict_type == P_TYPE);
-		
-        put_bits(&s->pb,1,0); /* Reference Picture Resampling: off */
-        put_bits(&s->pb,1,0); /* Reduced-Resolution Update: off */
-        put_bits(&s->pb,1,s->no_rounding); /* Rounding Type */
-        put_bits(&s->pb,2,0); /* Reserved */
-        put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
-		
-        /* This should be here if PLUSPTYPE */
-        put_bits(&s->pb, 1, 0);	/* Continuous Presence Multipoint mode: off */
-		
-		if (format == 7) {
-            /* Custom Picture Format (CPFMT) */
-            aspect_to_info(s, s->avctx->sample_aspect_ratio);
-
-            put_bits(&s->pb,4,s->aspect_ratio_info);
-            put_bits(&s->pb,9,(s->width >> 2) - 1);
-            put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
-            put_bits(&s->pb,9,(s->height >> 2));
-            if (s->aspect_ratio_info == FF_ASPECT_EXTENDED){
-                put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.num);
-                put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den);
-	    }
-        }
-        if(s->custom_pcf){
-            if(ufep){
-                put_bits(&s->pb, 1, best_clock_code);
-                put_bits(&s->pb, 7, best_divisor);
-            }
-            put_bits(&s->pb, 2, (temp_ref>>8)&3);
-        }
-        
-        /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
-        if (s->umvplus)
-//            put_bits(&s->pb,1,1); /* Limited according tables of Annex D */
-//FIXME check actual requested range
-            put_bits(&s->pb,2,1); /* unlimited */
-        if(s->h263_slice_structured)
-            put_bits(&s->pb,2,0); /* no weird submodes */
-
-        put_bits(&s->pb, 5, s->qscale);
-    }
-
-    put_bits(&s->pb, 1, 0);	/* no PEI */
-
-    if(s->h263_slice_structured){
-        put_bits(&s->pb, 1, 1);
-        
-        assert(s->mb_x == 0 && s->mb_y == 0);
-        ff_h263_encode_mba(s);
-
-        put_bits(&s->pb, 1, 1);
-    }
-
-    if(s->h263_aic){
-         s->y_dc_scale_table= 
-         s->c_dc_scale_table= ff_aic_dc_scale_table;
-    }else{
-        s->y_dc_scale_table=
-        s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
-    }
-}
-
-/**
- * Encodes a group of blocks header.
- */
-void h263_encode_gob_header(MpegEncContext * s, int mb_line)
-{
-    put_bits(&s->pb, 17, 1); /* GBSC */
-
-    if(s->h263_slice_structured){
-        put_bits(&s->pb, 1, 1);
-
-        ff_h263_encode_mba(s);
-
-        if(s->mb_num > 1583)
-            put_bits(&s->pb, 1, 1);
-        put_bits(&s->pb, 5, s->qscale); /* GQUANT */
-        put_bits(&s->pb, 1, 1);
-        put_bits(&s->pb, 2, s->pict_type == I_TYPE); /* GFID */
-    }else{
-        int gob_number= mb_line / s->gob_index;
-
-        put_bits(&s->pb, 5, gob_number); /* GN */
-        put_bits(&s->pb, 2, s->pict_type == I_TYPE); /* GFID */
-        put_bits(&s->pb, 5, s->qscale); /* GQUANT */
-    }
-}
-
-static inline int get_block_rate(MpegEncContext * s, DCTELEM block[64], int block_last_index, uint8_t scantable[64]){
-    int last=0;
-    int j;
-    int rate=0;
-
-    for(j=1; j<=block_last_index; j++){
-        const int index= scantable[j];
-        int level= block[index];
-        if(level){
-            level+= 64;
-            if((level&(~127)) == 0){
-                if(j<block_last_index) rate+= s->intra_ac_vlc_length     [UNI_AC_ENC_INDEX(j-last-1, level)];
-                else                   rate+= s->intra_ac_vlc_last_length[UNI_AC_ENC_INDEX(j-last-1, level)];
-            }else
-                rate += s->ac_esc_length;
-            level-= 64;
-
-            last= j;
-        }
-    }
-    
-    return rate;
-}
-
-static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int dir[6], uint8_t *st[6], int zigzag_last_index[6])
-{
-    int score= 0;
-    int i, n;
-    int8_t * const qscale_table= s->current_picture.qscale_table;
-
-    memcpy(zigzag_last_index, s->block_last_index, sizeof(int)*6);
-    
-    for(n=0; n<6; n++){
-        int16_t *ac_val, *ac_val1;
-        
-        score -= get_block_rate(s, block[n], s->block_last_index[n], s->intra_scantable.permutated);
-
-        ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
-        ac_val1= ac_val;
-        if(dir[n]){
-            const int xy= s->mb_x + s->mb_y*s->mb_stride - s->mb_stride;
-            /* top prediction */
-            ac_val-= s->block_wrap[n]*16;
-            if(s->mb_y==0 || s->qscale == qscale_table[xy] || n==2 || n==3){
-                /* same qscale */
-                for(i=1; i<8; i++){
-                    const int level= block[n][s->dsp.idct_permutation[i   ]];
-                    block[n][s->dsp.idct_permutation[i   ]] = level - ac_val[i+8];
-                    ac_val1[i  ]=    block[n][s->dsp.idct_permutation[i<<3]];
-                    ac_val1[i+8]= level;
-                }
-            }else{
-                /* different qscale, we must rescale */
-                for(i=1; i<8; i++){
-                    const int level= block[n][s->dsp.idct_permutation[i   ]];
-                    block[n][s->dsp.idct_permutation[i   ]] = level - ROUNDED_DIV(ac_val[i + 8]*qscale_table[xy], s->qscale);
-                    ac_val1[i  ]=    block[n][s->dsp.idct_permutation[i<<3]];
-                    ac_val1[i+8]= level;
-                }
-            }
-            st[n]= s->intra_h_scantable.permutated;
-        }else{
-            const int xy= s->mb_x-1 + s->mb_y*s->mb_stride;
-            /* left prediction */
-            ac_val-= 16;
-            if(s->mb_x==0 || s->qscale == qscale_table[xy] || n==1 || n==3){
-                /* same qscale */
-                for(i=1; i<8; i++){
-                    const int level= block[n][s->dsp.idct_permutation[i<<3]];
-                    block[n][s->dsp.idct_permutation[i<<3]]= level - ac_val[i];
-                    ac_val1[i  ]= level;
-                    ac_val1[i+8]=    block[n][s->dsp.idct_permutation[i   ]];
-                }
-            }else{
-                /* different qscale, we must rescale */
-                for(i=1; i<8; i++){
-                    const int level= block[n][s->dsp.idct_permutation[i<<3]];
-                    block[n][s->dsp.idct_permutation[i<<3]]= level - ROUNDED_DIV(ac_val[i]*qscale_table[xy], s->qscale);
-                    ac_val1[i  ]= level;
-                    ac_val1[i+8]=    block[n][s->dsp.idct_permutation[i   ]];
-                }
-            }
-            st[n]= s->intra_v_scantable.permutated;
-        }
-
-        for(i=63; i>0; i--) //FIXME optimize
-            if(block[n][ st[n][i] ]) break;
-        s->block_last_index[n]= i;
-
-        score += get_block_rate(s, block[n], s->block_last_index[n], st[n]);
-    }
-
-    return score < 0;
-}
-
-static inline void restore_ac_coeffs(MpegEncContext * s, DCTELEM block[6][64], int dir[6], uint8_t *st[6], int zigzag_last_index[6])
-{
-    int i, n;
-    memcpy(s->block_last_index, zigzag_last_index, sizeof(int)*6);
-
-    for(n=0; n<6; n++){
-        int16_t *ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
-
-        st[n]= s->intra_scantable.permutated;
-        if(dir[n]){
-            /* top prediction */
-            for(i=1; i<8; i++){
-                block[n][s->dsp.idct_permutation[i   ]] = ac_val[i+8];
-            }
-        }else{
-            /* left prediction */
-            for(i=1; i<8; i++){
-                block[n][s->dsp.idct_permutation[i<<3]]= ac_val[i  ];
-            }
-        }
-    }
-}
-
-/**
- * modify qscale so that encoding is acually possible in h263 (limit difference to -2..2)
- */
-void ff_clean_h263_qscales(MpegEncContext *s){
-    int i;
-    int8_t * const qscale_table= s->current_picture.qscale_table;
-    
-    for(i=1; i<s->mb_num; i++){
-        if(qscale_table[ s->mb_index2xy[i] ] - qscale_table[ s->mb_index2xy[i-1] ] >2)
-            qscale_table[ s->mb_index2xy[i] ]= qscale_table[ s->mb_index2xy[i-1] ]+2;
-    }
-    for(i=s->mb_num-2; i>=0; i--){
-        if(qscale_table[ s->mb_index2xy[i] ] - qscale_table[ s->mb_index2xy[i+1] ] >2)
-            qscale_table[ s->mb_index2xy[i] ]= qscale_table[ s->mb_index2xy[i+1] ]+2;
-    }
-
-    if(s->codec_id != CODEC_ID_H263P){
-        for(i=1; i<s->mb_num; i++){
-            int mb_xy= s->mb_index2xy[i];
-        
-            if(qscale_table[mb_xy] != qscale_table[s->mb_index2xy[i-1]] && (s->mb_type[mb_xy]&CANDIDATE_MB_TYPE_INTER4V)){
-                s->mb_type[mb_xy]&= ~CANDIDATE_MB_TYPE_INTER4V;
-                s->mb_type[mb_xy]|= CANDIDATE_MB_TYPE_INTER;
-            }
-        }
-    }
-}
-
-/**
- * modify mb_type & qscale so that encoding is acually possible in mpeg4
- */
-void ff_clean_mpeg4_qscales(MpegEncContext *s){
-    int i;
-    int8_t * const qscale_table= s->current_picture.qscale_table;
-
-    ff_clean_h263_qscales(s);
-    
-    if(s->pict_type== B_TYPE){
-        int odd=0;
-        /* ok, come on, this isn't funny anymore, there's more code for handling this mpeg4 mess than for the actual adaptive quantization */
-        
-        for(i=0; i<s->mb_num; i++){
-            int mb_xy= s->mb_index2xy[i];
-            odd += qscale_table[mb_xy]&1;
-        }
-        
-        if(2*odd > s->mb_num) odd=1;
-        else                  odd=0;
-        
-        for(i=0; i<s->mb_num; i++){
-            int mb_xy= s->mb_index2xy[i];
-            if((qscale_table[mb_xy]&1) != odd)
-                qscale_table[mb_xy]++;
-            if(qscale_table[mb_xy] > 31)
-                qscale_table[mb_xy]= 31;
-        }            
-    
-        for(i=1; i<s->mb_num; i++){
-            int mb_xy= s->mb_index2xy[i];
-            if(qscale_table[mb_xy] != qscale_table[s->mb_index2xy[i-1]] && (s->mb_type[mb_xy]&CANDIDATE_MB_TYPE_DIRECT)){
-                s->mb_type[mb_xy]&= ~CANDIDATE_MB_TYPE_DIRECT;
-                s->mb_type[mb_xy]|= CANDIDATE_MB_TYPE_BIDIR;
-            }
-        }
-    }
-}
-
-#endif //CONFIG_ENCODERS
-/**
- *
- * @return the mb_type
- */
-int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my){
-    const int mb_index= s->mb_x + s->mb_y*s->mb_stride;
-    const int colocated_mb_type= s->next_picture.mb_type[mb_index];
-    int xy= s->block_index[0];
-    uint16_t time_pp= s->pp_time;
-    uint16_t time_pb= s->pb_time;
-    int i;
-    
-    //FIXME avoid divides
-    
-    if(IS_8X8(colocated_mb_type)){
-        s->mv_type = MV_TYPE_8X8;
-        for(i=0; i<4; i++){
-            xy= s->block_index[i];
-            s->mv[0][i][0] = s->next_picture.motion_val[0][xy][0]*time_pb/time_pp + mx;
-            s->mv[0][i][1] = s->next_picture.motion_val[0][xy][1]*time_pb/time_pp + my;
-            s->mv[1][i][0] = mx ? s->mv[0][i][0] - s->next_picture.motion_val[0][xy][0]
-                                : s->next_picture.motion_val[0][xy][0]*(time_pb - time_pp)/time_pp;
-            s->mv[1][i][1] = my ? s->mv[0][i][1] - s->next_picture.motion_val[0][xy][1] 
-                                : s->next_picture.motion_val[0][xy][1]*(time_pb - time_pp)/time_pp;
-        }
-        return MB_TYPE_DIRECT2 | MB_TYPE_8x8 | MB_TYPE_L0L1;
-    } else if(IS_INTERLACED(colocated_mb_type)){
-        s->mv_type = MV_TYPE_FIELD;
-        for(i=0; i<2; i++){
-            int field_select= s->next_picture.ref_index[0][s->block_index[2*i]];
-            if(s->top_field_first){
-                time_pp= s->pp_field_time - field_select + i;
-                time_pb= s->pb_field_time - field_select + i;
-            }else{
-                time_pp= s->pp_field_time + field_select - i;
-                time_pb= s->pb_field_time + field_select - i;
-            }
-            s->mv[0][i][0] = s->p_field_mv_table[i][0][mb_index][0]*time_pb/time_pp + mx;
-            s->mv[0][i][1] = s->p_field_mv_table[i][0][mb_index][1]*time_pb/time_pp + my;
-            s->mv[1][i][0] = mx ? s->mv[0][i][0] - s->p_field_mv_table[i][0][mb_index][0]
-                                : s->p_field_mv_table[i][0][mb_index][0]*(time_pb - time_pp)/time_pp;
-            s->mv[1][i][1] = my ? s->mv[0][i][1] - s->p_field_mv_table[i][0][mb_index][1] 
-                                : s->p_field_mv_table[i][0][mb_index][1]*(time_pb - time_pp)/time_pp;
-        }
-        return MB_TYPE_DIRECT2 | MB_TYPE_16x8 | MB_TYPE_L0L1 | MB_TYPE_INTERLACED;
-    }else{
-        s->mv[0][0][0] = s->mv[0][1][0] = s->mv[0][2][0] = s->mv[0][3][0] = s->next_picture.motion_val[0][xy][0]*time_pb/time_pp + mx;
-        s->mv[0][0][1] = s->mv[0][1][1] = s->mv[0][2][1] = s->mv[0][3][1] = s->next_picture.motion_val[0][xy][1]*time_pb/time_pp + my;
-        s->mv[1][0][0] = s->mv[1][1][0] = s->mv[1][2][0] = s->mv[1][3][0] = mx ? s->mv[0][0][0] - s->next_picture.motion_val[0][xy][0]
-                            : s->next_picture.motion_val[0][xy][0]*(time_pb - time_pp)/time_pp;
-        s->mv[1][0][1] = s->mv[1][1][1] = s->mv[1][2][1] = s->mv[1][3][1] = my ? s->mv[0][0][1] - s->next_picture.motion_val[0][xy][1] 
-                            : s->next_picture.motion_val[0][xy][1]*(time_pb - time_pp)/time_pp;
-        if((s->avctx->workaround_bugs & FF_BUG_DIRECT_BLOCKSIZE) || !s->quarter_sample)
-            s->mv_type= MV_TYPE_16X16;
-        else
-            s->mv_type= MV_TYPE_8X8;
-        return MB_TYPE_DIRECT2 | MB_TYPE_16x16 | MB_TYPE_L0L1; //Note see prev line
-    }
-}
-
-void ff_h263_update_motion_val(MpegEncContext * s){
-    const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
-               //FIXME a lot of that is only needed for !low_delay
-    const int wrap = s->b8_stride;
-    const int xy = s->block_index[0];
-    
-    s->current_picture.mbskip_table[mb_xy]= s->mb_skipped; 
-
-    if(s->mv_type != MV_TYPE_8X8){
-        int motion_x, motion_y;
-        if (s->mb_intra) {
-            motion_x = 0;
-            motion_y = 0;
-        } else if (s->mv_type == MV_TYPE_16X16) {
-            motion_x = s->mv[0][0][0];
-            motion_y = s->mv[0][0][1];
-        } else /*if (s->mv_type == MV_TYPE_FIELD)*/ {
-            int i;
-            motion_x = s->mv[0][0][0] + s->mv[0][1][0];
-            motion_y = s->mv[0][0][1] + s->mv[0][1][1];
-            motion_x = (motion_x>>1) | (motion_x&1);
-            for(i=0; i<2; i++){
-                s->p_field_mv_table[i][0][mb_xy][0]= s->mv[0][i][0];
-                s->p_field_mv_table[i][0][mb_xy][1]= s->mv[0][i][1];
-            }
-            s->current_picture.ref_index[0][xy           ]=
-            s->current_picture.ref_index[0][xy        + 1]= s->field_select[0][0];
-            s->current_picture.ref_index[0][xy + wrap    ]=
-            s->current_picture.ref_index[0][xy + wrap + 1]= s->field_select[0][1];
-        }
-
-        /* no update if 8X8 because it has been done during parsing */
-        s->current_picture.motion_val[0][xy][0] = motion_x;
-        s->current_picture.motion_val[0][xy][1] = motion_y;
-        s->current_picture.motion_val[0][xy + 1][0] = motion_x;
-        s->current_picture.motion_val[0][xy + 1][1] = motion_y;
-        s->current_picture.motion_val[0][xy + wrap][0] = motion_x;
-        s->current_picture.motion_val[0][xy + wrap][1] = motion_y;
-        s->current_picture.motion_val[0][xy + 1 + wrap][0] = motion_x;
-        s->current_picture.motion_val[0][xy + 1 + wrap][1] = motion_y;
-    }
-
-    if(s->encoding){ //FIXME encoding MUST be cleaned up
-        if (s->mv_type == MV_TYPE_8X8) 
-            s->current_picture.mb_type[mb_xy]= MB_TYPE_L0 | MB_TYPE_8x8;
-        else if(s->mb_intra)
-            s->current_picture.mb_type[mb_xy]= MB_TYPE_INTRA;
-        else
-            s->current_picture.mb_type[mb_xy]= MB_TYPE_L0 | MB_TYPE_16x16;
-    }
-}
-
-#ifdef CONFIG_ENCODERS
-
-static inline int h263_get_motion_length(MpegEncContext * s, int val, int f_code){
-    int l, bit_size, code;
-
-    if (val == 0) {
-        return mvtab[0][1];
-    } else {
-        bit_size = f_code - 1;
-        /* modulo encoding */
-        l= INT_BIT - 6 - bit_size;
-        val = (val<<l)>>l;
-        val--;
-        code = (val >> bit_size) + 1;
-
-        return mvtab[code][1] + 1 + bit_size;
-    }
-}
-
-static inline void ff_h263_encode_motion_vector(MpegEncContext * s, int x, int y, int f_code){
-    if(s->flags2 & CODEC_FLAG2_NO_OUTPUT){
-        skip_put_bits(&s->pb, 
-            h263_get_motion_length(s, x, f_code)
-           +h263_get_motion_length(s, y, f_code));
-    }else{
-        ff_h263_encode_motion(s, x, f_code);
-        ff_h263_encode_motion(s, y, f_code);
-    }
-}
-
-static inline int get_p_cbp(MpegEncContext * s,
-                      DCTELEM block[6][64],
-                      int motion_x, int motion_y){
-    int cbp, i;
-
-    if(s->flags & CODEC_FLAG_CBP_RD){
-        int best_cbpy_score= INT_MAX;
-        int best_cbpc_score= INT_MAX;
-        int cbpc = (-1), cbpy= (-1);
-        const int offset= (s->mv_type==MV_TYPE_16X16 ? 0 : 16) + (s->dquant ? 8 : 0);
-        const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
-
-        for(i=0; i<4; i++){
-            int score= inter_MCBPC_bits[i + offset] * lambda;
-            if(i&1) score += s->coded_score[5];
-            if(i&2) score += s->coded_score[4];
-
-            if(score < best_cbpc_score){
-                best_cbpc_score= score;
-                cbpc= i;
-            }
-        }
-
-        for(i=0; i<16; i++){
-            int score= cbpy_tab[i ^ 0xF][1] * lambda;
-            if(i&1) score += s->coded_score[3];
-            if(i&2) score += s->coded_score[2];
-            if(i&4) score += s->coded_score[1];
-            if(i&8) score += s->coded_score[0];
-
-            if(score < best_cbpy_score){
-                best_cbpy_score= score;
-                cbpy= i;
-            }
-        }
-        cbp= cbpc + 4*cbpy;
-        if ((motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16){
-            if(best_cbpy_score + best_cbpc_score + 2*lambda >= 0)
-                cbp= 0;
-        }
-
-        for (i = 0; i < 6; i++) {
-            if (s->block_last_index[i] >= 0 && ((cbp >> (5 - i))&1)==0 ){
-                s->block_last_index[i]= -1;
-                memset(s->block[i], 0, sizeof(DCTELEM)*64);
-            }
-        }
-    }else{
-        cbp= 0;
-        for (i = 0; i < 6; i++) {
-            if (s->block_last_index[i] >= 0)
-                cbp |= 1 << (5 - i);
-        }
-    }
-    return cbp;
-}
-
-static inline int get_b_cbp(MpegEncContext * s, DCTELEM block[6][64],
-                            int motion_x, int motion_y, int mb_type){
-    int cbp=0, i;
-
-    if(s->flags & CODEC_FLAG_CBP_RD){
-        int score=0;
-        const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
-        
-        for(i=0; i<6; i++){
-            if(s->coded_score[i] < 0){
-                score += s->coded_score[i];
-                cbp |= 1 << (5 - i);
-            }
-        }
-        
-        if(cbp){
-            int zero_score= -6;
-            if ((motion_x | motion_y | s->dquant | mb_type) == 0){
-                zero_score-= 4; //2*MV + mb_type + cbp bit
-            }
-
-            zero_score*= lambda;
-            if(zero_score <= score){
-                cbp=0;
-            }
-        }
-
-        for (i = 0; i < 6; i++) {
-            if (s->block_last_index[i] >= 0 && ((cbp >> (5 - i))&1)==0 ){
-                s->block_last_index[i]= -1;
-                memset(s->block[i], 0, sizeof(DCTELEM)*64);
-            }
-        }
-    }else{
-        for (i = 0; i < 6; i++) {
-            if (s->block_last_index[i] >= 0)
-                cbp |= 1 << (5 - i);
-        }
-    }
-    return cbp;
-}
-
-static inline void mpeg4_encode_blocks(MpegEncContext * s, DCTELEM block[6][64], int intra_dc[6], 
-                               uint8_t **scan_table, PutBitContext *dc_pb, PutBitContext *ac_pb){
-    int i;
-    
-    if(scan_table){
-        if(s->flags2 & CODEC_FLAG2_NO_OUTPUT){
-            for (i = 0; i < 6; i++) {
-                skip_put_bits(&s->pb, mpeg4_get_block_length(s, block[i], i, intra_dc[i], scan_table[i]));
-            }
-        }else{
-            /* encode each block */
-            for (i = 0; i < 6; i++) {
-                mpeg4_encode_block(s, block[i], i, intra_dc[i], scan_table[i], dc_pb, ac_pb);
-            }
-        }
-    }else{
-        if(s->flags2 & CODEC_FLAG2_NO_OUTPUT){
-            for (i = 0; i < 6; i++) {
-                skip_put_bits(&s->pb, mpeg4_get_block_length(s, block[i], i, 0, s->intra_scantable.permutated));
-            }
-        }else{
-            /* encode each block */
-            for (i = 0; i < 6; i++) {
-                mpeg4_encode_block(s, block[i], i, 0, s->intra_scantable.permutated, dc_pb, ac_pb);
-            }
-        }
-    }
-}
-
-void mpeg4_encode_mb(MpegEncContext * s,
-		    DCTELEM block[6][64],
-		    int motion_x, int motion_y)
-{
-    int cbpc, cbpy, pred_x, pred_y;
-    PutBitContext * const pb2    = s->data_partitioning                         ? &s->pb2    : &s->pb;
-    PutBitContext * const tex_pb = s->data_partitioning && s->pict_type!=B_TYPE ? &s->tex_pb : &s->pb;
-    PutBitContext * const dc_pb  = s->data_partitioning && s->pict_type!=I_TYPE ? &s->pb2    : &s->pb;
-    const int interleaved_stats= (s->flags&CODEC_FLAG_PASS1) && !s->data_partitioning ? 1 : 0;
-    const int dquant_code[5]= {1,0,9,2,3};
-    
-    //    printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
-    if (!s->mb_intra) {
-        int i, cbp;
-        
-        if(s->pict_type==B_TYPE){
-            static const int mb_type_table[8]= {-1, 2, 3, 1,-1,-1,-1, 0}; /* convert from mv_dir to type */
-            int mb_type=  mb_type_table[s->mv_dir];
-
-            if(s->mb_x==0){
-                for(i=0; i<2; i++){
-                    s->last_mv[i][0][0]= 
-                    s->last_mv[i][0][1]= 
-                    s->last_mv[i][1][0]= 
-                    s->last_mv[i][1][1]= 0;
-                }
-            }
-            
-            assert(s->dquant>=-2 && s->dquant<=2);
-            assert((s->dquant&1)==0);
-            assert(mb_type>=0);
-
-            /* nothing to do if this MB was skipped in the next P Frame */
-            if(s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]){ //FIXME avoid DCT & ...
-                s->skip_count++;
-                s->mv[0][0][0]= 
-                s->mv[0][0][1]= 
-                s->mv[1][0][0]= 
-                s->mv[1][0][1]= 0;
-                s->mv_dir= MV_DIR_FORWARD; //doesn't matter
-                s->qscale -= s->dquant;
-//                s->mb_skipped=1;
-
-                return;
-            }
-            
-            cbp= get_b_cbp(s, block, motion_x, motion_y, mb_type);
-            
-            if ((cbp | motion_x | motion_y | mb_type) ==0) {
-                /* direct MB with MV={0,0} */
-                assert(s->dquant==0);
-                
-                put_bits(&s->pb, 1, 1); /* mb not coded modb1=1 */
-
-                if(interleaved_stats){
-                    s->misc_bits++;
-                    s->last_bits++;
-                }
-                s->skip_count++;
-                return;
-            }
-            
-            put_bits(&s->pb, 1, 0);	/* mb coded modb1=0 */
-            put_bits(&s->pb, 1, cbp ? 0 : 1); /* modb2 */ //FIXME merge
-            put_bits(&s->pb, mb_type+1, 1); // this table is so simple that we don't need it :)
-            if(cbp) put_bits(&s->pb, 6, cbp);
-            
-            if(cbp && mb_type){
-                if(s->dquant)
-                    put_bits(&s->pb, 2, (s->dquant>>2)+3);
-                else
-                    put_bits(&s->pb, 1, 0);
-            }else
-                s->qscale -= s->dquant;
-            
-            if(!s->progressive_sequence){
-                if(cbp)
-                    put_bits(&s->pb, 1, s->interlaced_dct);
-                if(mb_type) // not direct mode
-                    put_bits(&s->pb, 1, s->mv_type == MV_TYPE_FIELD);
-            }
-
-            if(interleaved_stats){
-                s->misc_bits+= get_bits_diff(s);
-            }
-
-            if(mb_type == 0){
-                assert(s->mv_dir & MV_DIRECT);
-                ff_h263_encode_motion_vector(s, motion_x, motion_y, 1);
-                s->b_count++;
-                s->f_count++;
-            }else{
-                assert(mb_type > 0 && mb_type < 4);
-                if(s->mv_type != MV_TYPE_FIELD){
-                    if(s->mv_dir & MV_DIR_FORWARD){
-                        ff_h263_encode_motion_vector(s, s->mv[0][0][0] - s->last_mv[0][0][0],
-                                                        s->mv[0][0][1] - s->last_mv[0][0][1], s->f_code);
-                        s->last_mv[0][0][0]= s->last_mv[0][1][0]= s->mv[0][0][0];
-                        s->last_mv[0][0][1]= s->last_mv[0][1][1]= s->mv[0][0][1];
-                        s->f_count++;
-                    }
-                    if(s->mv_dir & MV_DIR_BACKWARD){
-                        ff_h263_encode_motion_vector(s, s->mv[1][0][0] - s->last_mv[1][0][0],
-                                                        s->mv[1][0][1] - s->last_mv[1][0][1], s->b_code);
-                        s->last_mv[1][0][0]= s->last_mv[1][1][0]= s->mv[1][0][0];
-                        s->last_mv[1][0][1]= s->last_mv[1][1][1]= s->mv[1][0][1];
-                        s->b_count++;
-                    }
-                }else{
-                    if(s->mv_dir & MV_DIR_FORWARD){
-                        put_bits(&s->pb, 1, s->field_select[0][0]);
-                        put_bits(&s->pb, 1, s->field_select[0][1]);
-                    }
-                    if(s->mv_dir & MV_DIR_BACKWARD){
-                        put_bits(&s->pb, 1, s->field_select[1][0]);
-                        put_bits(&s->pb, 1, s->field_select[1][1]);
-                    }
-                    if(s->mv_dir & MV_DIR_FORWARD){
-                        for(i=0; i<2; i++){
-                            ff_h263_encode_motion_vector(s, s->mv[0][i][0] - s->last_mv[0][i][0]  ,
-                                                            s->mv[0][i][1] - s->last_mv[0][i][1]/2, s->f_code);
-                            s->last_mv[0][i][0]= s->mv[0][i][0];
-                            s->last_mv[0][i][1]= s->mv[0][i][1]*2;
-                        }
-                        s->f_count++;
-                    }
-                    if(s->mv_dir & MV_DIR_BACKWARD){
-                        for(i=0; i<2; i++){
-                            ff_h263_encode_motion_vector(s, s->mv[1][i][0] - s->last_mv[1][i][0]  ,
-                                                            s->mv[1][i][1] - s->last_mv[1][i][1]/2, s->b_code);
-                            s->last_mv[1][i][0]= s->mv[1][i][0];
-                            s->last_mv[1][i][1]= s->mv[1][i][1]*2;
-                        }
-                        s->b_count++;
-                    }
-                }
-            }
-
-            if(interleaved_stats){
-                s->mv_bits+= get_bits_diff(s);
-            }
-
-            mpeg4_encode_blocks(s, block, NULL, NULL, NULL, &s->pb);
-
-            if(interleaved_stats){
-                s->p_tex_bits+= get_bits_diff(s);
-            }
-
-        }else{ /* s->pict_type==B_TYPE */
-            cbp= get_p_cbp(s, block, motion_x, motion_y);
-        
-            if ((cbp | motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16) {
-                /* check if the B frames can skip it too, as we must skip it if we skip here 
-                   why didn't they just compress the skip-mb bits instead of reusing them ?! */
-                if(s->max_b_frames>0){
-                    int i;
-                    int x,y, offset;
-                    uint8_t *p_pic;
-
-                    x= s->mb_x*16;
-                    y= s->mb_y*16;
-                    if(x+16 > s->width)  x= s->width-16;
-                    if(y+16 > s->height) y= s->height-16;
-
-                    offset= x + y*s->linesize;
-                    p_pic= s->new_picture.data[0] + offset;
-                    
-                    s->mb_skipped=1;
-                    for(i=0; i<s->max_b_frames; i++){
-                        uint8_t *b_pic;
-                        int diff;
-                        Picture *pic= s->reordered_input_picture[i+1];
-
-                        if(pic==NULL || pic->pict_type!=B_TYPE) break;
-
-                        b_pic= pic->data[0] + offset + 16; //FIXME +16
-			diff= s->dsp.sad[0](NULL, p_pic, b_pic, s->linesize, 16);
-                        if(diff>s->qscale*70){ //FIXME check that 70 is optimal
-                            s->mb_skipped=0;
-                            break;
-                        }
-                    }
-                }else
-                    s->mb_skipped=1; 
-
-                if(s->mb_skipped==1){
-                    /* skip macroblock */
-                    put_bits(&s->pb, 1, 1);
-
-                    if(interleaved_stats){
-                        s->misc_bits++;
-                        s->last_bits++;
-                    }
-                    s->skip_count++;
-                    
-                    return;
-                }
-            }
-
-            put_bits(&s->pb, 1, 0);	/* mb coded */
-            cbpc = cbp & 3;
-            cbpy = cbp >> 2;
-            cbpy ^= 0xf;
-            if(s->mv_type==MV_TYPE_16X16){
-                if(s->dquant) cbpc+= 8;
-                put_bits(&s->pb,
-                        inter_MCBPC_bits[cbpc],
-                        inter_MCBPC_code[cbpc]);
-
-                put_bits(pb2, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
-                if(s->dquant)
-                    put_bits(pb2, 2, dquant_code[s->dquant+2]);
-
-                if(!s->progressive_sequence){
-                    if(cbp)
-                        put_bits(pb2, 1, s->interlaced_dct);
-                    put_bits(pb2, 1, 0);
-                }
-                    
-                if(interleaved_stats){
-                    s->misc_bits+= get_bits_diff(s);
-                }
-
-                /* motion vectors: 16x16 mode */
-                h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
-            
-                ff_h263_encode_motion_vector(s, motion_x - pred_x,
-                                                motion_y - pred_y, s->f_code);
-            }else if(s->mv_type==MV_TYPE_FIELD){
-                if(s->dquant) cbpc+= 8;
-                put_bits(&s->pb,
-                        inter_MCBPC_bits[cbpc],
-                        inter_MCBPC_code[cbpc]);
-
-                put_bits(pb2, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
-                if(s->dquant)
-                    put_bits(pb2, 2, dquant_code[s->dquant+2]);
-
-                assert(!s->progressive_sequence);
-                if(cbp)
-                    put_bits(pb2, 1, s->interlaced_dct);
-                put_bits(pb2, 1, 1);
-                    
-                if(interleaved_stats){
-                    s->misc_bits+= get_bits_diff(s);
-                }
-
-                /* motion vectors: 16x8 interlaced mode */
-                h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
-                pred_y /=2;
-                
-                put_bits(&s->pb, 1, s->field_select[0][0]);
-                put_bits(&s->pb, 1, s->field_select[0][1]);
-            
-                ff_h263_encode_motion_vector(s, s->mv[0][0][0] - pred_x,
-                                                s->mv[0][0][1] - pred_y, s->f_code);
-                ff_h263_encode_motion_vector(s, s->mv[0][1][0] - pred_x,
-                                                s->mv[0][1][1] - pred_y, s->f_code);
-            }else{
-                assert(s->mv_type==MV_TYPE_8X8);
-                put_bits(&s->pb,
-                        inter_MCBPC_bits[cbpc+16],
-                        inter_MCBPC_code[cbpc+16]);
-                put_bits(pb2, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
-
-                if(!s->progressive_sequence){
-                    if(cbp)
-                        put_bits(pb2, 1, s->interlaced_dct);
-                }
-    
-                if(interleaved_stats){
-                    s->misc_bits+= get_bits_diff(s);
-                }
-
-                for(i=0; i<4; i++){
-                    /* motion vectors: 8x8 mode*/
-                    h263_pred_motion(s, i, 0, &pred_x, &pred_y);
-
-                    ff_h263_encode_motion_vector(s, s->current_picture.motion_val[0][ s->block_index[i] ][0] - pred_x,
-                                                    s->current_picture.motion_val[0][ s->block_index[i] ][1] - pred_y, s->f_code);
-                }
-            }
-
-            if(interleaved_stats){ 
-                s->mv_bits+= get_bits_diff(s);
-            }
-
-            mpeg4_encode_blocks(s, block, NULL, NULL, NULL, tex_pb);
-
-            if(interleaved_stats){
-                s->p_tex_bits+= get_bits_diff(s);
-            }
-            s->f_count++;
-        }
-    } else {
-        int cbp;
-        int dc_diff[6];   //dc values with the dc prediction subtracted 
-        int dir[6];  //prediction direction
-        int zigzag_last_index[6];
-	uint8_t *scan_table[6];
-        int i;
-
-        for(i=0; i<6; i++){
-            dc_diff[i]= ff_mpeg4_pred_dc(s, i, block[i][0], &dir[i], 1);
-        }
-
-        if(s->flags & CODEC_FLAG_AC_PRED){
-            s->ac_pred= decide_ac_pred(s, block, dir, scan_table, zigzag_last_index);
-            if(!s->ac_pred)
-                restore_ac_coeffs(s, block, dir, scan_table, zigzag_last_index);
-        }else{
-            for(i=0; i<6; i++)
-                scan_table[i]= s->intra_scantable.permutated;
-        }
-
-        /* compute cbp */
-        cbp = 0;
-        for (i = 0; i < 6; i++) {
-            if (s->block_last_index[i] >= 1)
-                cbp |= 1 << (5 - i);
-        }
-
-        cbpc = cbp & 3;
-        if (s->pict_type == I_TYPE) {
-            if(s->dquant) cbpc+=4;
-            put_bits(&s->pb,
-                intra_MCBPC_bits[cbpc],
-                intra_MCBPC_code[cbpc]);
-        } else {
-            if(s->dquant) cbpc+=8;
-            put_bits(&s->pb, 1, 0);	/* mb coded */
-            put_bits(&s->pb,
-                inter_MCBPC_bits[cbpc + 4],
-                inter_MCBPC_code[cbpc + 4]);
-        }
-        put_bits(pb2, 1, s->ac_pred);
-        cbpy = cbp >> 2;
-        put_bits(pb2, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
-        if(s->dquant)
-            put_bits(dc_pb, 2, dquant_code[s->dquant+2]);
-
-        if(!s->progressive_sequence){
-            put_bits(dc_pb, 1, s->interlaced_dct);
-        }
-
-        if(interleaved_stats){
-            s->misc_bits+= get_bits_diff(s);
-        }
-
-        mpeg4_encode_blocks(s, block, dc_diff, scan_table, dc_pb, tex_pb);
-
-        if(interleaved_stats){
-            s->i_tex_bits+= get_bits_diff(s);
-        }
-        s->i_count++;
-
-        /* restore ac coeffs & last_index stuff if we messed them up with the prediction */
-        if(s->ac_pred)
-            restore_ac_coeffs(s, block, dir, scan_table, zigzag_last_index);
-    }
-}
-
-void h263_encode_mb(MpegEncContext * s,
-		    DCTELEM block[6][64],
-		    int motion_x, int motion_y)
-{
-    int cbpc, cbpy, i, cbp, pred_x, pred_y;
-    int16_t pred_dc;
-    int16_t rec_intradc[6];
-    uint16_t *dc_ptr[6];
-    const int interleaved_stats= (s->flags&CODEC_FLAG_PASS1);
-    const int dquant_code[5]= {1,0,9,2,3};
-           
-    //printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
-    if (!s->mb_intra) {
-        /* compute cbp */
-        cbp= get_p_cbp(s, block, motion_x, motion_y);
-
-        if ((cbp | motion_x | motion_y | s->dquant | (s->mv_type - MV_TYPE_16X16)) == 0) {
-            /* skip macroblock */
-            put_bits(&s->pb, 1, 1);
-            if(interleaved_stats){
-                s->misc_bits++;
-                s->last_bits++;
-            }
-            s->skip_count++;
-
-            return;
-        }
-        put_bits(&s->pb, 1, 0);	/* mb coded */
-        
-        cbpc = cbp & 3;
-        cbpy = cbp >> 2;
-        if(s->alt_inter_vlc==0 || cbpc!=3)
-            cbpy ^= 0xF;
-        if(s->dquant) cbpc+= 8;
-        if(s->mv_type==MV_TYPE_16X16){
-            put_bits(&s->pb,
-                    inter_MCBPC_bits[cbpc],
-                    inter_MCBPC_code[cbpc]);
-
-            put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
-            if(s->dquant)
-                put_bits(&s->pb, 2, dquant_code[s->dquant+2]);
-                
-            if(interleaved_stats){
-                s->misc_bits+= get_bits_diff(s);
-            }
-
-            /* motion vectors: 16x16 mode */
-            h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
-            
-            if (!s->umvplus) {  
-                ff_h263_encode_motion_vector(s, motion_x - pred_x,
-                                                motion_y - pred_y, 1);
-            }
-            else {
-                h263p_encode_umotion(s, motion_x - pred_x);
-                h263p_encode_umotion(s, motion_y - pred_y);
-                if (((motion_x - pred_x) == 1) && ((motion_y - pred_y) == 1))
-                    /* To prevent Start Code emulation */
-                    put_bits(&s->pb,1,1);
-            }
-        }else{
-            put_bits(&s->pb,
-                    inter_MCBPC_bits[cbpc+16],
-                    inter_MCBPC_code[cbpc+16]);
-            put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
-            if(s->dquant)
-                put_bits(&s->pb, 2, dquant_code[s->dquant+2]);
-
-            if(interleaved_stats){
-                s->misc_bits+= get_bits_diff(s);
-            }
-
-            for(i=0; i<4; i++){
-                /* motion vectors: 8x8 mode*/
-                h263_pred_motion(s, i, 0, &pred_x, &pred_y);
-
-                motion_x= s->current_picture.motion_val[0][ s->block_index[i] ][0];
-                motion_y= s->current_picture.motion_val[0][ s->block_index[i] ][1];
-                if (!s->umvplus) {  
-                    ff_h263_encode_motion_vector(s, motion_x - pred_x,
-                                                    motion_y - pred_y, 1);
-                }
-                else {
-                    h263p_encode_umotion(s, motion_x - pred_x);
-                    h263p_encode_umotion(s, motion_y - pred_y);
-                    if (((motion_x - pred_x) == 1) && ((motion_y - pred_y) == 1))
-                        /* To prevent Start Code emulation */
-                        put_bits(&s->pb,1,1);
-                }
-            }
-        }
-
-        if(interleaved_stats){
-            s->mv_bits+= get_bits_diff(s);
-        }
-    } else {
-        assert(s->mb_intra);
-        
-        cbp = 0;
-        if (s->h263_aic) {
-            /* Predict DC */
-            for(i=0; i<6; i++) {
-                int16_t level = block[i][0];
-                int scale;
-                
-                if(i<4) scale= s->y_dc_scale;
-                else    scale= s->c_dc_scale;
-
-                pred_dc = h263_pred_dc(s, i, &dc_ptr[i]);
-                level -= pred_dc;
-                /* Quant */
-                if (level >= 0)
-                    level = (level + (scale>>1))/scale;
-                else
-                    level = (level - (scale>>1))/scale;
-                    
-                /* AIC can change CBP */
-                if (level == 0 && s->block_last_index[i] == 0)
-                    s->block_last_index[i] = -1;
-
-                if(!s->modified_quant){
-                    if (level < -127)
-                        level = -127;
-                    else if (level > 127)
-                        level = 127;
-                }
-
-                block[i][0] = level;
-                /* Reconstruction */ 
-                rec_intradc[i] = scale*level + pred_dc;
-                /* Oddify */
-                rec_intradc[i] |= 1;
-                //if ((rec_intradc[i] % 2) == 0)
-                //    rec_intradc[i]++;
-                /* Clipping */
-                if (rec_intradc[i] < 0)
-                    rec_intradc[i] = 0;
-                else if (rec_intradc[i] > 2047)
-                    rec_intradc[i] = 2047;
-                                
-                /* Update AC/DC tables */
-                *dc_ptr[i] = rec_intradc[i];
-                if (s->block_last_index[i] >= 0)
-                    cbp |= 1 << (5 - i);
-            }
-        }else{
-            for(i=0; i<6; i++) {
-                /* compute cbp */
-                if (s->block_last_index[i] >= 1)
-                    cbp |= 1 << (5 - i);
-            }
-        }
-
-        cbpc = cbp & 3;
-        if (s->pict_type == I_TYPE) {
-            if(s->dquant) cbpc+=4;
-            put_bits(&s->pb,
-                intra_MCBPC_bits[cbpc],
-                intra_MCBPC_code[cbpc]);
-        } else {
-            if(s->dquant) cbpc+=8;
-            put_bits(&s->pb, 1, 0);	/* mb coded */
-            put_bits(&s->pb,
-                inter_MCBPC_bits[cbpc + 4],
-                inter_MCBPC_code[cbpc + 4]);
-        }
-        if (s->h263_aic) {
-            /* XXX: currently, we do not try to use ac prediction */
-            put_bits(&s->pb, 1, 0);	/* no AC prediction */
-        }
-        cbpy = cbp >> 2;
-        put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
-        if(s->dquant)
-            put_bits(&s->pb, 2, dquant_code[s->dquant+2]);
-
-        if(interleaved_stats){
-            s->misc_bits+= get_bits_diff(s);
-        }
-    }
-
-    for(i=0; i<6; i++) {
-        /* encode each block */
-        h263_encode_block(s, block[i], i);
-    
-        /* Update INTRADC for decoding */
-        if (s->h263_aic && s->mb_intra) {
-            block[i][0] = rec_intradc[i];
-            
-        }
-    }
-
-    if(interleaved_stats){
-        if (!s->mb_intra) {
-            s->p_tex_bits+= get_bits_diff(s);
-            s->f_count++;
-        }else{
-            s->i_tex_bits+= get_bits_diff(s);
-            s->i_count++;
-        }
-    }
-}
-#endif
-
-void ff_h263_loop_filter(MpegEncContext * s){
-    int qp_c;
-    const int linesize  = s->linesize;
-    const int uvlinesize= s->uvlinesize;
-    const int xy = s->mb_y * s->mb_stride + s->mb_x;
-    uint8_t *dest_y = s->dest[0];
-    uint8_t *dest_cb= s->dest[1];
-    uint8_t *dest_cr= s->dest[2];
-    
-//    if(s->pict_type==B_TYPE && !s->readable) return;
-
-    /*
-       Diag Top
-       Left Center
-    */
-    if(!IS_SKIP(s->current_picture.mb_type[xy])){
-        qp_c= s->qscale;
-        s->dsp.h263_v_loop_filter(dest_y+8*linesize  , linesize, qp_c);
-        s->dsp.h263_v_loop_filter(dest_y+8*linesize+8, linesize, qp_c);
-    }else
-        qp_c= 0;
-
-    if(s->mb_y){
-        int qp_dt, qp_t, qp_tc;
-
-        if(IS_SKIP(s->current_picture.mb_type[xy-s->mb_stride]))
-            qp_t=0;
-        else 
-            qp_t= s->current_picture.qscale_table[xy-s->mb_stride];
-
-        if(qp_c) 
-            qp_tc= qp_c;
-        else
-            qp_tc= qp_t;
-            
-        if(qp_tc){
-            const int chroma_qp= s->chroma_qscale_table[qp_tc];
-            s->dsp.h263_v_loop_filter(dest_y  ,   linesize, qp_tc);
-            s->dsp.h263_v_loop_filter(dest_y+8,   linesize, qp_tc);
-        
-            s->dsp.h263_v_loop_filter(dest_cb , uvlinesize, chroma_qp);
-            s->dsp.h263_v_loop_filter(dest_cr , uvlinesize, chroma_qp);
-        }
-        
-        if(qp_t)
-            s->dsp.h263_h_loop_filter(dest_y-8*linesize+8  ,   linesize, qp_t);
-        
-        if(s->mb_x){
-            if(qp_t || IS_SKIP(s->current_picture.mb_type[xy-1-s->mb_stride]))
-                qp_dt= qp_t;
-            else
-                qp_dt= s->current_picture.qscale_table[xy-1-s->mb_stride];
-            
-            if(qp_dt){
-                const int chroma_qp= s->chroma_qscale_table[qp_dt];
-                s->dsp.h263_h_loop_filter(dest_y -8*linesize  ,   linesize, qp_dt);
-                s->dsp.h263_h_loop_filter(dest_cb-8*uvlinesize, uvlinesize, chroma_qp);
-                s->dsp.h263_h_loop_filter(dest_cr-8*uvlinesize, uvlinesize, chroma_qp);
-            }
-        }
-    }
-
-    if(qp_c){
-        s->dsp.h263_h_loop_filter(dest_y +8,   linesize, qp_c);
-        if(s->mb_y + 1 == s->mb_height)
-            s->dsp.h263_h_loop_filter(dest_y+8*linesize+8,   linesize, qp_c);
-    }
-    
-    if(s->mb_x){
-        int qp_lc;
-        if(qp_c || IS_SKIP(s->current_picture.mb_type[xy-1]))
-            qp_lc= qp_c;
-        else
-            qp_lc= s->current_picture.qscale_table[xy-1];
-        
-        if(qp_lc){
-            s->dsp.h263_h_loop_filter(dest_y,   linesize, qp_lc);
-            if(s->mb_y + 1 == s->mb_height){
-                const int chroma_qp= s->chroma_qscale_table[qp_lc];
-                s->dsp.h263_h_loop_filter(dest_y +8*  linesize,   linesize, qp_lc);
-                s->dsp.h263_h_loop_filter(dest_cb             , uvlinesize, chroma_qp);
-                s->dsp.h263_h_loop_filter(dest_cr             , uvlinesize, chroma_qp);
-            }
-        }
-    }
-}
-
-static int h263_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr)
-{
-    int x, y, wrap, a, c, pred_dc, scale;
-    int16_t *dc_val, *ac_val;
-
-    /* find prediction */
-    if (n < 4) {
-        x = 2 * s->mb_x + (n & 1);
-        y = 2 * s->mb_y + ((n & 2) >> 1);
-        wrap = s->b8_stride;
-        dc_val = s->dc_val[0];
-        ac_val = s->ac_val[0][0];
-        scale = s->y_dc_scale;
-    } else {
-        x = s->mb_x;
-        y = s->mb_y;
-        wrap = s->mb_stride;
-        dc_val = s->dc_val[n - 4 + 1];
-        ac_val = s->ac_val[n - 4 + 1][0];
-        scale = s->c_dc_scale;
-    }
-    /* B C
-     * A X 
-     */
-    a = dc_val[(x - 1) + (y) * wrap];
-    c = dc_val[(x) + (y - 1) * wrap];
-    
-    /* No prediction outside GOB boundary */
-    if(s->first_slice_line && n!=3){
-        if(n!=2) c= 1024;
-        if(n!=1 && s->mb_x == s->resync_mb_x) a= 1024;
-    }
-    pred_dc = 1024;
-    /* just DC prediction */
-    if (a != 1024 && c != 1024)
-        pred_dc = (a + c) >> 1;
-    else if (a != 1024)
-        pred_dc = a;
-    else
-        pred_dc = c;
-    
-    /* we assume pred is positive */
-    //pred_dc = (pred_dc + (scale >> 1)) / scale;
-    *dc_val_ptr = &dc_val[x + y * wrap];
-    return pred_dc;
-}
-
-static void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n)
-{
-    int x, y, wrap, a, c, pred_dc, scale, i;
-    int16_t *dc_val, *ac_val, *ac_val1;
-
-    /* find prediction */
-    if (n < 4) {
-        x = 2 * s->mb_x + (n & 1);
-        y = 2 * s->mb_y + (n>> 1);
-        wrap = s->b8_stride;
-        dc_val = s->dc_val[0];
-        ac_val = s->ac_val[0][0];
-        scale = s->y_dc_scale;
-    } else {
-        x = s->mb_x;
-        y = s->mb_y;
-        wrap = s->mb_stride;
-        dc_val = s->dc_val[n - 4 + 1];
-        ac_val = s->ac_val[n - 4 + 1][0];
-        scale = s->c_dc_scale;
-    }
-    
-    ac_val += ((y) * wrap + (x)) * 16;
-    ac_val1 = ac_val;
-    
-    /* B C
-     * A X 
-     */
-    a = dc_val[(x - 1) + (y) * wrap];
-    c = dc_val[(x) + (y - 1) * wrap];
-    
-    /* No prediction outside GOB boundary */
-    if(s->first_slice_line && n!=3){
-        if(n!=2) c= 1024;
-        if(n!=1 && s->mb_x == s->resync_mb_x) a= 1024;
-    }
-    
-    if (s->ac_pred) {
-        pred_dc = 1024;
-        if (s->h263_aic_dir) {
-            /* left prediction */
-            if (a != 1024) {
-                ac_val -= 16;
-                for(i=1;i<8;i++) {
-                    block[s->dsp.idct_permutation[i<<3]] += ac_val[i];
-                }
-                pred_dc = a;
-            }
-        } else {
-            /* top prediction */
-            if (c != 1024) {
-                ac_val -= 16 * wrap;
-                for(i=1;i<8;i++) {
-                    block[s->dsp.idct_permutation[i   ]] += ac_val[i + 8];
-                }
-                pred_dc = c;
-            }
-        }
-    } else {
-        /* just DC prediction */
-        if (a != 1024 && c != 1024)
-            pred_dc = (a + c) >> 1;
-        else if (a != 1024)
-            pred_dc = a;
-        else
-            pred_dc = c;
-    }
-    
-    /* we assume pred is positive */
-    block[0]=block[0]*scale + pred_dc;
-    
-    if (block[0] < 0)
-        block[0] = 0;
-    else 
-        block[0] |= 1;
-    
-    /* Update AC/DC tables */
-    dc_val[(x) + (y) * wrap] = block[0];
-    
-    /* left copy */
-    for(i=1;i<8;i++)
-        ac_val1[i    ] = block[s->dsp.idct_permutation[i<<3]];
-    /* top copy */
-    for(i=1;i<8;i++)
-        ac_val1[8 + i] = block[s->dsp.idct_permutation[i   ]];
-}
-
-int16_t *h263_pred_motion(MpegEncContext * s, int block, int dir,
-                        int *px, int *py)
-{
-    int wrap;
-    int16_t *A, *B, *C, (*mot_val)[2];
-    static const int off[4]= {2, 1, 1, -1};
-
-    wrap = s->b8_stride;
-    mot_val = s->current_picture.motion_val[dir] + s->block_index[block];
-
-    A = mot_val[ - 1];
-    /* special case for first (slice) line */
-    if (s->first_slice_line && block<3) {
-        // we can't just change some MVs to simulate that as we need them for the B frames (and ME)
-        // and if we ever support non rectangular objects than we need to do a few ifs here anyway :(
-        if(block==0){ //most common case
-            if(s->mb_x  == s->resync_mb_x){ //rare
-                *px= *py = 0;
-            }else if(s->mb_x + 1 == s->resync_mb_x && s->h263_pred){ //rare
-                C = mot_val[off[block] - wrap];
-                if(s->mb_x==0){
-                    *px = C[0];
-                    *py = C[1];
-                }else{
-                    *px = mid_pred(A[0], 0, C[0]);
-                    *py = mid_pred(A[1], 0, C[1]);
-                }
-            }else{
-                *px = A[0];
-                *py = A[1];
-            }
-        }else if(block==1){
-            if(s->mb_x + 1 == s->resync_mb_x && s->h263_pred){ //rare
-                C = mot_val[off[block] - wrap];
-                *px = mid_pred(A[0], 0, C[0]);
-                *py = mid_pred(A[1], 0, C[1]);
-            }else{
-                *px = A[0];
-                *py = A[1];
-            }
-        }else{ /* block==2*/
-            B = mot_val[ - wrap];
-            C = mot_val[off[block] - wrap];
-            if(s->mb_x == s->resync_mb_x) //rare
-                A[0]=A[1]=0;
-    
-            *px = mid_pred(A[0], B[0], C[0]);
-            *py = mid_pred(A[1], B[1], C[1]);
-        }
-    } else {
-        B = mot_val[ - wrap];
-        C = mot_val[off[block] - wrap];
-        *px = mid_pred(A[0], B[0], C[0]);
-        *py = mid_pred(A[1], B[1], C[1]);
-    }
-    return *mot_val;
-}
-
-#ifdef CONFIG_ENCODERS
-void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code)
-{
-    int range, l, bit_size, sign, code, bits;
-
-    if (val == 0) {
-        /* zero vector */
-        code = 0;
-        put_bits(&s->pb, mvtab[code][1], mvtab[code][0]);
-    } else {
-        bit_size = f_code - 1;
-        range = 1 << bit_size;
-        /* modulo encoding */
-        l= INT_BIT - 6 - bit_size;
-        val = (val<<l)>>l;
-        sign = val>>31;
-        val= (val^sign)-sign;
-        sign&=1;
-
-        val--;
-        code = (val >> bit_size) + 1;
-        bits = val & (range - 1);
-
-        put_bits(&s->pb, mvtab[code][1] + 1, (mvtab[code][0] << 1) | sign); 
-        if (bit_size > 0) {
-            put_bits(&s->pb, bit_size, bits);
-        }
-    }
-}
-
-/* Encode MV differences on H.263+ with Unrestricted MV mode */
-static void h263p_encode_umotion(MpegEncContext * s, int val)
-{
-    short sval = 0; 
-    short i = 0;
-    short n_bits = 0;
-    short temp_val;
-    int code = 0;
-    int tcode;
-    
-    if ( val == 0)
-        put_bits(&s->pb, 1, 1);
-    else if (val == 1)
-        put_bits(&s->pb, 3, 0);
-    else if (val == -1)
-        put_bits(&s->pb, 3, 2);
-    else {
-        
-        sval = ((val < 0) ? (short)(-val):(short)val);
-        temp_val = sval;
-        
-        while (temp_val != 0) {
-            temp_val = temp_val >> 1;
-            n_bits++;
-        }
-        
-        i = n_bits - 1;
-        while (i > 0) {
-            tcode = (sval & (1 << (i-1))) >> (i-1);
-            tcode = (tcode << 1) | 1;
-            code = (code << 2) | tcode;
-            i--;
-        }
-        code = ((code << 1) | (val < 0)) << 1;
-        put_bits(&s->pb, (2*n_bits)+1, code);
-        //printf("\nVal = %d\tCode = %d", sval, code);
-    }
-}
-
-static void init_mv_penalty_and_fcode(MpegEncContext *s)
-{
-    int f_code;
-    int mv;
-    
-    if(mv_penalty==NULL)
-        mv_penalty= av_mallocz( sizeof(uint8_t)*(MAX_FCODE+1)*(2*MAX_MV+1) );
-    
-    for(f_code=1; f_code<=MAX_FCODE; f_code++){
-        for(mv=-MAX_MV; mv<=MAX_MV; mv++){
-            int len;
-
-            if(mv==0) len= mvtab[0][1];
-            else{
-                int val, bit_size, range, code;
-
-                bit_size = f_code - 1;
-                range = 1 << bit_size;
-
-                val=mv;
-                if (val < 0) 
-                    val = -val;
-                val--;
-                code = (val >> bit_size) + 1;
-                if(code<33){
-                    len= mvtab[code][1] + 1 + bit_size;
-                }else{
-                    len= mvtab[32][1] + 2 + bit_size;
-                }
-            }
-
-            mv_penalty[f_code][mv+MAX_MV]= len;
-        }
-    }
-
-    for(f_code=MAX_FCODE; f_code>0; f_code--){
-        for(mv=-(16<<f_code); mv<(16<<f_code); mv++){
-            fcode_tab[mv+MAX_MV]= f_code;
-        }
-    }
-
-    for(mv=0; mv<MAX_MV*2+1; mv++){
-        umv_fcode_tab[mv]= 1;
-    }
-}
-#endif
-
-#ifdef CONFIG_ENCODERS
-
-static void init_uni_dc_tab(void)
-{
-    int level, uni_code, uni_len;
-
-    for(level=-256; level<256; level++){
-        int size, v, l;
-        /* find number of bits */
-        size = 0;
-        v = abs(level);
-        while (v) {
-            v >>= 1;
-	    size++;
-        }
-
-        if (level < 0)
-            l= (-level) ^ ((1 << size) - 1);
-        else
-            l= level;
-
-        /* luminance */
-        uni_code= DCtab_lum[size][0];
-        uni_len = DCtab_lum[size][1];
-
-        if (size > 0) {
-            uni_code<<=size; uni_code|=l;
-            uni_len+=size;
-            if (size > 8){
-                uni_code<<=1; uni_code|=1;
-                uni_len++;
-            }
-        }
-        uni_DCtab_lum_bits[level+256]= uni_code;
-        uni_DCtab_lum_len [level+256]= uni_len;
-
-        /* chrominance */
-        uni_code= DCtab_chrom[size][0];
-        uni_len = DCtab_chrom[size][1];
-        
-        if (size > 0) {
-            uni_code<<=size; uni_code|=l;
-            uni_len+=size;
-            if (size > 8){
-                uni_code<<=1; uni_code|=1;
-                uni_len++;
-            }
-        }
-        uni_DCtab_chrom_bits[level+256]= uni_code;
-        uni_DCtab_chrom_len [level+256]= uni_len;
-
-    }
-}
-
-#endif //CONFIG_ENCODERS
-
-#ifdef CONFIG_ENCODERS
-static void init_uni_mpeg4_rl_tab(RLTable *rl, uint32_t *bits_tab, uint8_t *len_tab){
-    int slevel, run, last;
-    
-    assert(MAX_LEVEL >= 64);
-    assert(MAX_RUN   >= 63);
-
-    for(slevel=-64; slevel<64; slevel++){
-        if(slevel==0) continue;
-        for(run=0; run<64; run++){
-            for(last=0; last<=1; last++){
-                const int index= UNI_MPEG4_ENC_INDEX(last, run, slevel+64);
-                int level= slevel < 0 ? -slevel : slevel;
-                int sign= slevel < 0 ? 1 : 0;
-                int bits, len, code;
-                int level1, run1;
-                
-                len_tab[index]= 100;
-                     
-                /* ESC0 */
-                code= get_rl_index(rl, last, run, level);
-                bits= rl->table_vlc[code][0];
-                len=  rl->table_vlc[code][1];
-                bits=bits*2+sign; len++;
-                
-                if(code!=rl->n && len < len_tab[index]){
-                    bits_tab[index]= bits;
-                    len_tab [index]= len;
-                }
-#if 1
-                /* ESC1 */
-                bits= rl->table_vlc[rl->n][0];
-                len=  rl->table_vlc[rl->n][1];
-                bits=bits*2;    len++; //esc1
-                level1= level - rl->max_level[last][run];
-                if(level1>0){
-                    code= get_rl_index(rl, last, run, level1);
-                    bits<<= rl->table_vlc[code][1];
-                    len  += rl->table_vlc[code][1];
-                    bits += rl->table_vlc[code][0];
-                    bits=bits*2+sign; len++;
-                
-                    if(code!=rl->n && len < len_tab[index]){
-                        bits_tab[index]= bits;
-                        len_tab [index]= len;
-                    }
-                }
-#endif 
-#if 1
-                /* ESC2 */
-                bits= rl->table_vlc[rl->n][0];
-                len=  rl->table_vlc[rl->n][1];
-                bits=bits*4+2;    len+=2; //esc2
-                run1 = run - rl->max_run[last][level] - 1;
-                if(run1>=0){
-                    code= get_rl_index(rl, last, run1, level);
-                    bits<<= rl->table_vlc[code][1];
-                    len  += rl->table_vlc[code][1];
-                    bits += rl->table_vlc[code][0];
-                    bits=bits*2+sign; len++;
-                
-                    if(code!=rl->n && len < len_tab[index]){
-                        bits_tab[index]= bits;
-                        len_tab [index]= len;
-                    }
-                }
-#endif           
-                /* ESC3 */        
-                bits= rl->table_vlc[rl->n][0];
-                len = rl->table_vlc[rl->n][1];
-                bits=bits*4+3;    len+=2; //esc3
-                bits=bits*2+last; len++;
-                bits=bits*64+run; len+=6;
-                bits=bits*2+1;    len++;  //marker
-                bits=bits*4096+(slevel&0xfff); len+=12;
-                bits=bits*2+1;    len++;  //marker
-                
-                if(len < len_tab[index]){
-                    bits_tab[index]= bits;
-                    len_tab [index]= len;
-                }
-            }
-        }
-    }
-}
-
-static void init_uni_h263_rl_tab(RLTable *rl, uint32_t *bits_tab, uint8_t *len_tab){
-    int slevel, run, last;
-    
-    assert(MAX_LEVEL >= 64);
-    assert(MAX_RUN   >= 63);
-
-    for(slevel=-64; slevel<64; slevel++){
-        if(slevel==0) continue;
-        for(run=0; run<64; run++){
-            for(last=0; last<=1; last++){
-                const int index= UNI_MPEG4_ENC_INDEX(last, run, slevel+64);
-                int level= slevel < 0 ? -slevel : slevel;
-                int sign= slevel < 0 ? 1 : 0;
-                int bits, len, code;
-                
-                len_tab[index]= 100;
-                     
-                /* ESC0 */
-                code= get_rl_index(rl, last, run, level);
-                bits= rl->table_vlc[code][0];
-                len=  rl->table_vlc[code][1];
-                bits=bits*2+sign; len++;
-                
-                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];
-                bits=bits*2+last; len++;
-                bits=bits*64+run; len+=6;
-                bits=bits*256+(level&0xff); len+=8;
-                
-                if(len < len_tab[index]){
-                    if(bits_tab) bits_tab[index]= bits;
-                    len_tab [index]= len;
-                }
-            }
-        }
-    }
-}
-
-void h263_encode_init(MpegEncContext *s)
-{
-    static int done = 0;
-
-    if (!done) {
-        done = 1;
-
-        init_uni_dc_tab();
-
-        init_rl(&rl_inter, 1);
-        init_rl(&rl_intra, 1);
-        init_rl(&rl_intra_aic, 1);
-        
-        init_uni_mpeg4_rl_tab(&rl_intra, uni_mpeg4_intra_rl_bits, uni_mpeg4_intra_rl_len);
-        init_uni_mpeg4_rl_tab(&rl_inter, uni_mpeg4_inter_rl_bits, uni_mpeg4_inter_rl_len);
-
-        init_uni_h263_rl_tab(&rl_intra_aic, NULL, uni_h263_intra_aic_rl_len);
-        init_uni_h263_rl_tab(&rl_inter    , NULL, uni_h263_inter_rl_len);
-
-        init_mv_penalty_and_fcode(s);
-    }
-    s->me.mv_penalty= mv_penalty; //FIXME exact table for msmpeg4 & h263p
-    
-    s->intra_ac_vlc_length     =s->inter_ac_vlc_length     = uni_h263_inter_rl_len;
-    s->intra_ac_vlc_last_length=s->inter_ac_vlc_last_length= uni_h263_inter_rl_len + 128*64;
-    if(s->h263_aic){
-        s->intra_ac_vlc_length     = uni_h263_intra_aic_rl_len;
-        s->intra_ac_vlc_last_length= uni_h263_intra_aic_rl_len + 128*64;
-    }
-    s->ac_esc_length= 7+1+6+8;
-
-    // use fcodes >1 only for mpeg4 & h263 & h263p FIXME
-    switch(s->codec_id){
-    case CODEC_ID_MPEG4:
-        s->fcode_tab= fcode_tab;
-        s->min_qcoeff= -2048;
-        s->max_qcoeff=  2047;
-        s->intra_ac_vlc_length     = uni_mpeg4_intra_rl_len;
-        s->intra_ac_vlc_last_length= uni_mpeg4_intra_rl_len + 128*64;
-        s->inter_ac_vlc_length     = uni_mpeg4_inter_rl_len;
-        s->inter_ac_vlc_last_length= uni_mpeg4_inter_rl_len + 128*64;
-        s->luma_dc_vlc_length= uni_DCtab_lum_len;
-        s->chroma_dc_vlc_length= uni_DCtab_chrom_len;
-        s->ac_esc_length= 7+2+1+6+1+12+1;
-        s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table;
-        s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;
-
-        if(s->flags & CODEC_FLAG_GLOBAL_HEADER){
-
-            s->avctx->extradata= av_malloc(1024);
-            init_put_bits(&s->pb, s->avctx->extradata, 1024);
-            
-            if(!(s->workaround_bugs & FF_BUG_MS))
-                mpeg4_encode_visual_object_header(s);
-            mpeg4_encode_vol_header(s, 0, 0);
-
-//            ff_mpeg4_stuffing(&s->pb); ?
-            flush_put_bits(&s->pb);
-            s->avctx->extradata_size= (put_bits_count(&s->pb)+7)>>3;
-        }
-        
-        break;
-    case CODEC_ID_H263P:
-        if(s->umvplus)
-            s->fcode_tab= umv_fcode_tab;
-        if(s->modified_quant){
-            s->min_qcoeff= -2047;
-            s->max_qcoeff=  2047;
-        }else{
-            s->min_qcoeff= -127;
-            s->max_qcoeff=  127;
-        }
-        break;
-        //Note for mpeg4 & h263 the dc-scale table will be set per frame as needed later 
-    case CODEC_ID_FLV1:
-        if (s->h263_flv > 1) {
-            s->min_qcoeff= -1023;
-            s->max_qcoeff=  1023;
-        } else {
-            s->min_qcoeff= -127;
-            s->max_qcoeff=  127;
-        }
-        s->y_dc_scale_table=
-        s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
-        break;
-    default: //nothing needed - default table already set in mpegvideo.c
-        s->min_qcoeff= -127;
-        s->max_qcoeff=  127;
-        s->y_dc_scale_table=
-        s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
-    }
-}
-
-/**
- * encodes a 8x8 block.
- * @param block the 8x8 block
- * @param n block index (0-3 are luma, 4-5 are chroma)
- */
-static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
-{
-    int level, run, last, i, j, last_index, last_non_zero, sign, slevel, code;
-    RLTable *rl;
-
-    rl = &rl_inter;
-    if (s->mb_intra && !s->h263_aic) {
-        /* DC coef */
-        level = block[0];
-        /* 255 cannot be represented, so we clamp */
-        if (level > 254) {
-            level = 254;
-            block[0] = 254;
-        }
-        /* 0 cannot be represented also */
-        else if (level < 1) {
-            level = 1;
-            block[0] = 1;
-        }
-        if (level == 128) //FIXME check rv10
-            put_bits(&s->pb, 8, 0xff);
-        else
-            put_bits(&s->pb, 8, level);
-        i = 1;
-    } else {
-        i = 0;
-        if (s->h263_aic && s->mb_intra)
-            rl = &rl_intra_aic;
-            
-        if(s->alt_inter_vlc && !s->mb_intra){
-            int aic_vlc_bits=0;
-            int inter_vlc_bits=0;
-            int wrong_pos=-1;
-            int aic_code;
-            
-            last_index = s->block_last_index[n];
-            last_non_zero = i - 1;
-            for (; i <= last_index; i++) {
-                j = s->intra_scantable.permutated[i];
-                level = block[j];
-                if (level) {
-                    run = i - last_non_zero - 1;
-                    last = (i == last_index);
-                    
-                    if(level<0) level= -level;
-                
-                    code = get_rl_index(rl, last, run, level);
-                    aic_code = get_rl_index(&rl_intra_aic, last, run, level);
-                    inter_vlc_bits += rl->table_vlc[code][1]+1;
-                    aic_vlc_bits   += rl_intra_aic.table_vlc[aic_code][1]+1;
-
-                    if (code == rl->n) {
-                        inter_vlc_bits += 1+6+8-1;
-                    }                
-                    if (aic_code == rl_intra_aic.n) {
-                        aic_vlc_bits += 1+6+8-1;
-                        wrong_pos += run + 1;
-                    }else
-                        wrong_pos += wrong_run[aic_code];
-                    last_non_zero = i;
-                }    
-            }
-            i = 0;
-            if(aic_vlc_bits < inter_vlc_bits && wrong_pos > 63)
-                rl = &rl_intra_aic;
-        }
-    }
-   
-    /* AC coefs */
-    last_index = s->block_last_index[n];
-    last_non_zero = i - 1;
-    for (; i <= last_index; i++) {
-        j = s->intra_scantable.permutated[i];
-        level = block[j];
-        if (level) {
-            run = i - last_non_zero - 1;
-            last = (i == last_index);
-            sign = 0;
-            slevel = level;
-            if (level < 0) {
-                sign = 1;
-                level = -level;
-            }
-            code = get_rl_index(rl, last, run, level);
-            put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
-            if (code == rl->n) {
-              if(s->h263_flv <= 1){
-                put_bits(&s->pb, 1, last);
-                put_bits(&s->pb, 6, run);
-                
-                assert(slevel != 0);
-
-                if(level < 128) 
-                    put_bits(&s->pb, 8, slevel & 0xff);
-                else{
-                    put_bits(&s->pb, 8, 128);
-                    put_bits(&s->pb, 5, slevel & 0x1f);
-                    put_bits(&s->pb, 6, (slevel>>5)&0x3f);
-                }
-              }else{
-                if(level < 64) { // 7-bit level
-                        put_bits(&s->pb, 1, 0);
-                        put_bits(&s->pb, 1, last);
-                        put_bits(&s->pb, 6, run);
-
-                        put_bits(&s->pb, 7, slevel & 0x7f);
-                    } else {
-                        /* 11-bit level */
-                        put_bits(&s->pb, 1, 1);
-                        put_bits(&s->pb, 1, last);
-                        put_bits(&s->pb, 6, run);
-
-                        put_bits(&s->pb, 11, slevel & 0x7ff);
-                    }
-              }
-            } else {
-                put_bits(&s->pb, 1, sign);
-            }
-            last_non_zero = i;
-        }
-    }
-}
-#endif
-
-#ifdef CONFIG_ENCODERS
-
-/***************************************************/
-/**
- * add mpeg4 stuffing bits (01...1)
- */
-void ff_mpeg4_stuffing(PutBitContext * pbc)
-{
-    int length;
-    put_bits(pbc, 1, 0);
-    length= (-put_bits_count(pbc))&7;
-    if(length) put_bits(pbc, length, (1<<length)-1);
-}
-
-/* must be called before writing the header */
-void ff_set_mpeg4_time(MpegEncContext * s, int picture_number){
-    int time_div, time_mod;
-
-    assert(s->current_picture_ptr->pts != AV_NOPTS_VALUE);
-    s->time= s->current_picture_ptr->pts*s->avctx->time_base.num;
-
-    time_div= s->time/s->avctx->time_base.den;
-    time_mod= s->time%s->avctx->time_base.den;
-
-    if(s->pict_type==B_TYPE){
-        s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
-        assert(s->pb_time > 0 && s->pb_time < s->pp_time);
-    }else{
-        s->last_time_base= s->time_base;
-        s->time_base= time_div;
-        s->pp_time= s->time - s->last_non_b_time;
-        s->last_non_b_time= s->time;
-        assert(picture_number==0 || s->pp_time > 0);
-    }
-}
-
-static void mpeg4_encode_gop_header(MpegEncContext * s){
-    int hours, minutes, seconds;
-    int64_t time;
-    
-    put_bits(&s->pb, 16, 0);
-    put_bits(&s->pb, 16, GOP_STARTCODE);
-    
-    time= s->current_picture_ptr->pts;
-    if(s->reordered_input_picture[1])
-        time= FFMIN(time, s->reordered_input_picture[1]->pts);
-    time= time*s->avctx->time_base.num;
-
-    seconds= time/s->avctx->time_base.den;
-    minutes= seconds/60; seconds %= 60;
-    hours= minutes/60; minutes %= 60;
-    hours%=24;
-
-    put_bits(&s->pb, 5, hours);
-    put_bits(&s->pb, 6, minutes);
-    put_bits(&s->pb, 1, 1);
-    put_bits(&s->pb, 6, seconds);
-    
-    put_bits(&s->pb, 1, !!(s->flags&CODEC_FLAG_CLOSED_GOP)); 
-    put_bits(&s->pb, 1, 0); //broken link == NO
-    
-    s->last_time_base= time / s->avctx->time_base.den; 
-
-    ff_mpeg4_stuffing(&s->pb);
-}
-
-static void mpeg4_encode_visual_object_header(MpegEncContext * s){
-    int profile_and_level_indication;
-    int vo_ver_id;
-    
-    if(s->avctx->profile != FF_PROFILE_UNKNOWN){
-        profile_and_level_indication = s->avctx->profile << 4;
-    }else if(s->max_b_frames || s->quarter_sample){
-        profile_and_level_indication= 0xF0; // adv simple
-    }else{
-        profile_and_level_indication= 0x00; // simple
-    }
-
-    if(s->avctx->level != FF_LEVEL_UNKNOWN){
-        profile_and_level_indication |= s->avctx->level;
-    }else{
-        profile_and_level_indication |= 1; //level 1
-    }
-
-    if(profile_and_level_indication>>4 == 0xF){
-        vo_ver_id= 5;
-    }else{
-        vo_ver_id= 1;
-    }
-
-    //FIXME levels
-
-    put_bits(&s->pb, 16, 0);
-    put_bits(&s->pb, 16, VOS_STARTCODE);
-
-    put_bits(&s->pb, 8, profile_and_level_indication);
-
-    put_bits(&s->pb, 16, 0);
-    put_bits(&s->pb, 16, VISUAL_OBJ_STARTCODE);
-    
-    put_bits(&s->pb, 1, 1);
-        put_bits(&s->pb, 4, vo_ver_id);
-        put_bits(&s->pb, 3, 1); //priority
- 
-    put_bits(&s->pb, 4, 1); //visual obj type== video obj
-    
-    put_bits(&s->pb, 1, 0); //video signal type == no clue //FIXME
-
-    ff_mpeg4_stuffing(&s->pb);
-}
-
-static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_number)
-{
-    int vo_ver_id;
-
-    if(s->max_b_frames || s->quarter_sample){
-        vo_ver_id= 5;
-        s->vo_type= ADV_SIMPLE_VO_TYPE;
-    }else{
-        vo_ver_id= 1;
-        s->vo_type= SIMPLE_VO_TYPE;
-    }
-
-    put_bits(&s->pb, 16, 0);
-    put_bits(&s->pb, 16, 0x100 + vo_number);        /* video obj */
-    put_bits(&s->pb, 16, 0);
-    put_bits(&s->pb, 16, 0x120 + vol_number);       /* video obj layer */
-
-    put_bits(&s->pb, 1, 0);		/* random access vol */
-    put_bits(&s->pb, 8, s->vo_type);	/* video obj type indication */
-    if(s->workaround_bugs & FF_BUG_MS) {
-        put_bits(&s->pb, 1, 0);        /* is obj layer id= no */
-    } else {
-        put_bits(&s->pb, 1, 1);        /* is obj layer id= yes */
-        put_bits(&s->pb, 4, vo_ver_id);    /* is obj layer ver id */
-        put_bits(&s->pb, 3, 1);        /* is obj layer priority */
-    }
-    
-    aspect_to_info(s, s->avctx->sample_aspect_ratio);
-
-    put_bits(&s->pb, 4, s->aspect_ratio_info);/* aspect ratio info */
-    if (s->aspect_ratio_info == FF_ASPECT_EXTENDED){
-        put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.num);
-        put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den);
-    }
-
-    if(s->workaround_bugs & FF_BUG_MS) { //
-        put_bits(&s->pb, 1, 0);        /* vol control parameters= no @@@ */
-    } else {
-        put_bits(&s->pb, 1, 1);        /* vol control parameters= yes */
-        put_bits(&s->pb, 2, 1);        /* chroma format YUV 420/YV12 */
-        put_bits(&s->pb, 1, s->low_delay);
-        put_bits(&s->pb, 1, 0);        /* vbv parameters= no */
-    }
-
-    put_bits(&s->pb, 2, RECT_SHAPE);	/* vol shape= rectangle */
-    put_bits(&s->pb, 1, 1);		/* marker bit */
-    
-    put_bits(&s->pb, 16, s->avctx->time_base.den);
-    if (s->time_increment_bits < 1)
-        s->time_increment_bits = 1;
-    put_bits(&s->pb, 1, 1);		/* marker bit */
-    put_bits(&s->pb, 1, 0);		/* fixed vop rate=no */
-    put_bits(&s->pb, 1, 1);		/* marker bit */
-    put_bits(&s->pb, 13, s->width);	/* vol width */
-    put_bits(&s->pb, 1, 1);		/* marker bit */
-    put_bits(&s->pb, 13, s->height);	/* vol height */
-    put_bits(&s->pb, 1, 1);		/* marker bit */
-    put_bits(&s->pb, 1, s->progressive_sequence ? 0 : 1);
-    put_bits(&s->pb, 1, 1);		/* obmc disable */
-    if (vo_ver_id == 1) {
-        put_bits(&s->pb, 1, s->vol_sprite_usage);		/* sprite enable */
-    }else{
-        put_bits(&s->pb, 2, s->vol_sprite_usage);		/* sprite enable */
-    }
-    
-    put_bits(&s->pb, 1, 0);		/* not 8 bit == false */
-    put_bits(&s->pb, 1, s->mpeg_quant);	/* quant type= (0=h263 style)*/
-
-    if(s->mpeg_quant){
-        ff_write_quant_matrix(&s->pb, s->avctx->intra_matrix);
-        ff_write_quant_matrix(&s->pb, s->avctx->inter_matrix);
-    }
-
-    if (vo_ver_id != 1)
-        put_bits(&s->pb, 1, s->quarter_sample);
-    put_bits(&s->pb, 1, 1);		/* complexity estimation disable */
-    s->resync_marker= s->rtp_mode;
-    put_bits(&s->pb, 1, s->resync_marker ? 0 : 1);/* resync marker disable */
-    put_bits(&s->pb, 1, s->data_partitioning ? 1 : 0);
-    if(s->data_partitioning){
-        put_bits(&s->pb, 1, 0);		/* no rvlc */
-    }
-
-    if (vo_ver_id != 1){
-        put_bits(&s->pb, 1, 0);		/* newpred */
-        put_bits(&s->pb, 1, 0);		/* reduced res vop */
-    }
-    put_bits(&s->pb, 1, 0);		/* scalability */
-    
-    ff_mpeg4_stuffing(&s->pb);
-
-    /* user data */
-    if(!(s->flags & CODEC_FLAG_BITEXACT)){
-        put_bits(&s->pb, 16, 0);
-        put_bits(&s->pb, 16, 0x1B2);	/* user_data */
-	put_string(&s->pb, LIBAVCODEC_IDENT, 0);
-    }
-}
-
-/* write mpeg4 VOP header */
-void mpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
-{
-    int time_incr;
-    int time_div, time_mod;
-    
-    if(s->pict_type==I_TYPE){
-        if(!(s->flags&CODEC_FLAG_GLOBAL_HEADER)){
-            if(s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT) //HACK, the reference sw is buggy
-                mpeg4_encode_visual_object_header(s);
-            if(s->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT || picture_number==0) //HACK, the reference sw is buggy
-                mpeg4_encode_vol_header(s, 0, 0);
-        }
-        if(!(s->workaround_bugs & FF_BUG_MS))
-            mpeg4_encode_gop_header(s);
-    }
-    
-    s->partitioned_frame= s->data_partitioning && s->pict_type!=B_TYPE;
-
-//printf("num:%d rate:%d base:%d\n", s->picture_number, s->time_base.den, FRAME_RATE_BASE);
-    
-    put_bits(&s->pb, 16, 0);	        /* vop header */
-    put_bits(&s->pb, 16, VOP_STARTCODE);	/* vop header */
-    put_bits(&s->pb, 2, s->pict_type - 1);	/* pict type: I = 0 , P = 1 */
-
-    assert(s->time>=0);
-    time_div= s->time/s->avctx->time_base.den;
-    time_mod= s->time%s->avctx->time_base.den;
-    time_incr= time_div - s->last_time_base;
-    assert(time_incr >= 0);
-    while(time_incr--)
-        put_bits(&s->pb, 1, 1);
-        
-    put_bits(&s->pb, 1, 0);
-
-    put_bits(&s->pb, 1, 1);	/* marker */
-    put_bits(&s->pb, s->time_increment_bits, time_mod);	/* time increment */
-    put_bits(&s->pb, 1, 1);	/* marker */
-    put_bits(&s->pb, 1, 1);	/* vop coded */
-    if (    s->pict_type == P_TYPE 
-        || (s->pict_type == S_TYPE && s->vol_sprite_usage==GMC_SPRITE)) {
-	put_bits(&s->pb, 1, s->no_rounding);	/* rounding type */
-    }
-    put_bits(&s->pb, 3, 0);	/* intra dc VLC threshold */
-    if(!s->progressive_sequence){
-         put_bits(&s->pb, 1, s->current_picture_ptr->top_field_first);
-         put_bits(&s->pb, 1, s->alternate_scan);
-    }
-    //FIXME sprite stuff
-
-    put_bits(&s->pb, 5, s->qscale);
-
-    if (s->pict_type != I_TYPE)
-	put_bits(&s->pb, 3, s->f_code);	/* fcode_for */
-    if (s->pict_type == B_TYPE)
-	put_bits(&s->pb, 3, s->b_code);	/* fcode_back */
-    //    printf("****frame %d\n", picture_number);
-}
-
-#endif //CONFIG_ENCODERS
-
-/**
- * set qscale and update qscale dependant variables.
- */
-void ff_set_qscale(MpegEncContext * s, int qscale)
-{
-    if (qscale < 1)
-        qscale = 1;
-    else if (qscale > 31)
-        qscale = 31;
-        
-    s->qscale = qscale;
-    s->chroma_qscale= s->chroma_qscale_table[qscale];
-
-    s->y_dc_scale= s->y_dc_scale_table[ qscale ];
-    s->c_dc_scale= s->c_dc_scale_table[ s->chroma_qscale ];
-}
-
-/**
- * predicts the dc.
- * encoding quantized level -> quantized diff
- * decoding quantized diff -> quantized level  
- * @param n block index (0-3 are luma, 4-5 are chroma)
- * @param dir_ptr pointer to an integer where the prediction direction will be stored
- */
-static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, int level, int *dir_ptr, int encoding)
-{
-    int a, b, c, wrap, pred, scale, ret;
-    uint16_t *dc_val;
-
-    /* find prediction */
-    if (n < 4) {
-	scale = s->y_dc_scale;
-    } else {
-	scale = s->c_dc_scale;
-    }
-    if(IS_3IV1)
-        scale= 8;
-
-    wrap= s->block_wrap[n];
-    dc_val = s->dc_val[0] + s->block_index[n];
-
-    /* B C
-     * A X 
-     */
-    a = dc_val[ - 1];
-    b = dc_val[ - 1 - wrap];
-    c = dc_val[ - wrap];
-
-    /* outside slice handling (we can't do that by memset as we need the dc for error resilience) */
-    if(s->first_slice_line && n!=3){
-        if(n!=2) b=c= 1024;
-        if(n!=1 && s->mb_x == s->resync_mb_x) b=a= 1024;
-    }
-    if(s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y+1){
-        if(n==0 || n==4 || n==5)
-            b=1024;
-    }
-
-    if (abs(a - b) < abs(b - c)) {
-	pred = c;
-        *dir_ptr = 1; /* top */
-    } else {
-	pred = a;
-        *dir_ptr = 0; /* left */
-    }
-    /* we assume pred is positive */
-    pred = FASTDIV((pred + (scale >> 1)), scale);
-
-    if(encoding){
-        ret = level - pred;
-    }else{
-        level += pred;
-        ret= level;
-        if(s->error_resilience>=3){
-            if(level<0){
-                av_log(s->avctx, AV_LOG_ERROR, "dc<0 at %dx%d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-            if(level*scale > 2048 + scale){
-                av_log(s->avctx, AV_LOG_ERROR, "dc overflow at %dx%d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-        }
-    }
-    level *=scale;
-    if(level&(~2047)){
-        if(level<0) 
-            level=0;
-        else if(!(s->workaround_bugs&FF_BUG_DC_CLIP))
-            level=2047;
-    }
-    dc_val[0]= level;
-
-    return ret;
-}
-
-/**
- * predicts the ac.
- * @param n block index (0-3 are luma, 4-5 are chroma)
- * @param dir the ac prediction direction
- */
-void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
-                   int dir)
-{
-    int i;
-    int16_t *ac_val, *ac_val1;
-    int8_t * const qscale_table= s->current_picture.qscale_table;
-
-    /* find prediction */
-    ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
-    ac_val1 = ac_val;
-    if (s->ac_pred) {
-        if (dir == 0) {
-            const int xy= s->mb_x-1 + s->mb_y*s->mb_stride;
-            /* left prediction */
-            ac_val -= 16;
-            
-            if(s->mb_x==0 || s->qscale == qscale_table[xy] || n==1 || n==3){
-                /* same qscale */
-                for(i=1;i<8;i++) {
-                    block[s->dsp.idct_permutation[i<<3]] += ac_val[i];
-                }
-            }else{
-                /* different qscale, we must rescale */
-                for(i=1;i<8;i++) {
-                    block[s->dsp.idct_permutation[i<<3]] += ROUNDED_DIV(ac_val[i]*qscale_table[xy], s->qscale);
-                }
-            }
-        } else {
-            const int xy= s->mb_x + s->mb_y*s->mb_stride - s->mb_stride;
-            /* top prediction */
-            ac_val -= 16 * s->block_wrap[n];
-
-            if(s->mb_y==0 || s->qscale == qscale_table[xy] || n==2 || n==3){
-                /* same qscale */
-                for(i=1;i<8;i++) {
-                    block[s->dsp.idct_permutation[i]] += ac_val[i + 8];
-                }
-            }else{
-                /* different qscale, we must rescale */
-                for(i=1;i<8;i++) {
-                    block[s->dsp.idct_permutation[i]] += ROUNDED_DIV(ac_val[i + 8]*qscale_table[xy], s->qscale);
-                }
-            }
-        }
-    }
-    /* left copy */
-    for(i=1;i<8;i++)
-        ac_val1[i    ] = block[s->dsp.idct_permutation[i<<3]];
-
-    /* top copy */
-    for(i=1;i<8;i++)
-        ac_val1[8 + i] = block[s->dsp.idct_permutation[i   ]];
-
-}
-
-#ifdef CONFIG_ENCODERS
-
-/**
- * encodes the dc value.
- * @param n block index (0-3 are luma, 4-5 are chroma)
- */
-static inline void mpeg4_encode_dc(PutBitContext * s, int level, int n)
-{
-#if 1
-//    if(level<-255 || level>255) printf("dc overflow\n");
-    level+=256;
-    if (n < 4) {
-	/* luminance */
-	put_bits(s, uni_DCtab_lum_len[level], uni_DCtab_lum_bits[level]);
-    } else {
-	/* chrominance */
-	put_bits(s, uni_DCtab_chrom_len[level], uni_DCtab_chrom_bits[level]);
-    }
-#else
-    int size, v;
-    /* find number of bits */
-    size = 0;
-    v = abs(level);
-    while (v) {
-	v >>= 1;
-	size++;
-    }
-
-    if (n < 4) {
-	/* luminance */
-	put_bits(&s->pb, DCtab_lum[size][1], DCtab_lum[size][0]);
-    } else {
-	/* chrominance */
-	put_bits(&s->pb, DCtab_chrom[size][1], DCtab_chrom[size][0]);
-    }
-
-    /* encode remaining bits */
-    if (size > 0) {
-	if (level < 0)
-	    level = (-level) ^ ((1 << size) - 1);
-	put_bits(&s->pb, size, level);
-	if (size > 8)
-	    put_bits(&s->pb, 1, 1);
-    }
-#endif
-}
-
-static inline int mpeg4_get_dc_length(int level, int n){
-    if (n < 4) {
-        return uni_DCtab_lum_len[level + 256];
-    } else {
-        return uni_DCtab_chrom_len[level + 256];
-    }
-}
-
-/**
- * encodes a 8x8 block
- * @param n block index (0-3 are luma, 4-5 are chroma)
- */
-static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n, int intra_dc, 
-                               uint8_t *scan_table, PutBitContext *dc_pb, PutBitContext *ac_pb)
-{
-    int i, last_non_zero;
-#if 0 //variables for the outcommented version
-    int code, sign, last;
-#endif
-    const RLTable *rl;
-    uint32_t *bits_tab;
-    uint8_t *len_tab;
-    const int last_index = s->block_last_index[n];
-
-    if (s->mb_intra) { //Note gcc (3.2.1 at least) will optimize this away
-	/* mpeg4 based DC predictor */
-	mpeg4_encode_dc(dc_pb, intra_dc, n);
-        if(last_index<1) return;
-	i = 1;
-        rl = &rl_intra;
-        bits_tab= uni_mpeg4_intra_rl_bits;
-        len_tab = uni_mpeg4_intra_rl_len;
-    } else {
-        if(last_index<0) return;
-	i = 0;
-        rl = &rl_inter;
-        bits_tab= uni_mpeg4_inter_rl_bits;
-        len_tab = uni_mpeg4_inter_rl_len;
-    }
-
-    /* AC coefs */
-    last_non_zero = i - 1;
-#if 1
-    for (; i < last_index; i++) {
-	int level = block[ scan_table[i] ];
-	if (level) {
-	    int run = i - last_non_zero - 1;
-            level+=64;
-            if((level&(~127)) == 0){
-                const int index= UNI_MPEG4_ENC_INDEX(0, run, level);
-                put_bits(ac_pb, len_tab[index], bits_tab[index]);
-            }else{ //ESC3
-                put_bits(ac_pb, 7+2+1+6+1+12+1, (3<<23)+(3<<21)+(0<<20)+(run<<14)+(1<<13)+(((level-64)&0xfff)<<1)+1);
-            }
-	    last_non_zero = i;
-	}
-    }
-    /*if(i<=last_index)*/{
-	int level = block[ scan_table[i] ];
-        int run = i - last_non_zero - 1;
-        level+=64;
-        if((level&(~127)) == 0){
-            const int index= UNI_MPEG4_ENC_INDEX(1, run, level);
-            put_bits(ac_pb, len_tab[index], bits_tab[index]);
-        }else{ //ESC3
-            put_bits(ac_pb, 7+2+1+6+1+12+1, (3<<23)+(3<<21)+(1<<20)+(run<<14)+(1<<13)+(((level-64)&0xfff)<<1)+1);
-        }
-    }
-#else
-    for (; i <= last_index; i++) {
-	const int slevel = block[ scan_table[i] ];
-	if (slevel) {
-            int level;
-	    int run = i - last_non_zero - 1;
-	    last = (i == last_index);
-	    sign = 0;
-	    level = slevel;
-	    if (level < 0) {
-		sign = 1;
-		level = -level;
-	    }
-            code = get_rl_index(rl, last, run, level);
-            put_bits(ac_pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
-            if (code == rl->n) {
-                int level1, run1;
-                level1 = level - rl->max_level[last][run];
-                if (level1 < 1) 
-                    goto esc2;
-                code = get_rl_index(rl, last, run, level1);
-                if (code == rl->n) {
-                esc2:
-                    put_bits(ac_pb, 1, 1);
-                    if (level > MAX_LEVEL)
-                        goto esc3;
-                    run1 = run - rl->max_run[last][level] - 1;
-                    if (run1 < 0)
-                        goto esc3;
-                    code = get_rl_index(rl, last, run1, level);
-                    if (code == rl->n) {
-                    esc3:
-                        /* third escape */
-                        put_bits(ac_pb, 1, 1);
-                        put_bits(ac_pb, 1, last);
-                        put_bits(ac_pb, 6, run);
-                        put_bits(ac_pb, 1, 1);
-                        put_bits(ac_pb, 12, slevel & 0xfff);
-                        put_bits(ac_pb, 1, 1);
-                    } else {
-                        /* second escape */
-                        put_bits(ac_pb, 1, 0);
-                        put_bits(ac_pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
-                        put_bits(ac_pb, 1, sign);
-                    }
-                } else {
-                    /* first escape */
-                    put_bits(ac_pb, 1, 0);
-                    put_bits(ac_pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
-                    put_bits(ac_pb, 1, sign);
-                }
-            } else {
-                put_bits(ac_pb, 1, sign);
-            }
-	    last_non_zero = i;
-	}
-    }
-#endif
-}
-
-static int mpeg4_get_block_length(MpegEncContext * s, DCTELEM * block, int n, int intra_dc, 
-                               uint8_t *scan_table)
-{
-    int i, last_non_zero;
-    const RLTable *rl;
-    uint8_t *len_tab;
-    const int last_index = s->block_last_index[n];
-    int len=0;
-
-    if (s->mb_intra) { //Note gcc (3.2.1 at least) will optimize this away
-	/* mpeg4 based DC predictor */
-	len += mpeg4_get_dc_length(intra_dc, n);
-        if(last_index<1) return len;
-	i = 1;
-        rl = &rl_intra;
-        len_tab = uni_mpeg4_intra_rl_len;
-    } else {
-        if(last_index<0) return 0;
-	i = 0;
-        rl = &rl_inter;
-        len_tab = uni_mpeg4_inter_rl_len;
-    }
-
-    /* AC coefs */
-    last_non_zero = i - 1;
-    for (; i < last_index; i++) {
-	int level = block[ scan_table[i] ];
-	if (level) {
-	    int run = i - last_non_zero - 1;
-            level+=64;
-            if((level&(~127)) == 0){
-                const int index= UNI_MPEG4_ENC_INDEX(0, run, level);
-                len += len_tab[index];
-            }else{ //ESC3
-                len += 7+2+1+6+1+12+1;
-            }
-	    last_non_zero = i;
-	}
-    }
-    /*if(i<=last_index)*/{
-	int level = block[ scan_table[i] ];
-        int run = i - last_non_zero - 1;
-        level+=64;
-        if((level&(~127)) == 0){
-            const int index= UNI_MPEG4_ENC_INDEX(1, run, level);
-            len += len_tab[index];
-        }else{ //ESC3
-            len += 7+2+1+6+1+12+1;
-        }
-    }
-    
-    return len;
-}
-
-#endif
-
-
-/***********************************************/
-/* decoding */
-
-static VLC intra_MCBPC_vlc;
-static VLC inter_MCBPC_vlc;
-static VLC cbpy_vlc;
-static VLC mv_vlc;
-static VLC dc_lum, dc_chrom;
-static VLC sprite_trajectory;
-static VLC mb_type_b_vlc;
-static VLC h263_mbtype_b_vlc;
-static VLC cbpc_b_vlc;
-
-void init_vlc_rl(RLTable *rl, int use_static)
-{
-    int i, q;
- 
-    /* Return if static table is already initialized */
-    if(use_static && rl->rl_vlc[0])
-        return;    
-
-    init_vlc(&rl->vlc, 9, rl->n + 1, 
-             &rl->table_vlc[0][1], 4, 2,
-             &rl->table_vlc[0][0], 4, 2, use_static);
-
-    
-    for(q=0; q<32; q++){
-        int qmul= q*2;
-        int qadd= (q-1)|1;
-        
-        if(q==0){
-            qmul=1;
-            qadd=0;
-        }
-        if(use_static)        
-            rl->rl_vlc[q]= av_mallocz_static(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
-        else
-            rl->rl_vlc[q]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
-        for(i=0; i<rl->vlc.table_size; i++){
-            int code= rl->vlc.table[i][0];
-            int len = rl->vlc.table[i][1];
-            int level, run;
-        
-            if(len==0){ // illegal code
-                run= 66;
-                level= MAX_LEVEL;
-            }else if(len<0){ //more bits needed
-                run= 0;
-                level= code;
-            }else{
-                if(code==rl->n){ //esc
-                    run= 66;
-                    level= 0;
-                }else{
-                    run=   rl->table_run  [code] + 1;
-                    level= rl->table_level[code] * qmul + qadd;
-                    if(code >= rl->last) run+=192;
-                }
-            }
-            rl->rl_vlc[q][i].len= len;
-            rl->rl_vlc[q][i].level= level;
-            rl->rl_vlc[q][i].run= run;
-        }
-    }
-}
-
-/* init vlcs */
-
-/* XXX: find a better solution to handle static init */
-void h263_decode_init_vlc(MpegEncContext *s)
-{
-    static int done = 0;
-
-    if (!done) {
-        done = 1;
-
-        init_vlc(&intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9, 
-                 intra_MCBPC_bits, 1, 1,
-                 intra_MCBPC_code, 1, 1, 1);
-        init_vlc(&inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 28, 
-                 inter_MCBPC_bits, 1, 1,
-                 inter_MCBPC_code, 1, 1, 1);
-        init_vlc(&cbpy_vlc, CBPY_VLC_BITS, 16,
-                 &cbpy_tab[0][1], 2, 1,
-                 &cbpy_tab[0][0], 2, 1, 1);
-        init_vlc(&mv_vlc, MV_VLC_BITS, 33,
-                 &mvtab[0][1], 2, 1,
-                 &mvtab[0][0], 2, 1, 1);
-        init_rl(&rl_inter, 1);
-        init_rl(&rl_intra, 1);
-        init_rl(&rvlc_rl_inter, 1);
-        init_rl(&rvlc_rl_intra, 1);
-        init_rl(&rl_intra_aic, 1);
-        init_vlc_rl(&rl_inter, 1);
-        init_vlc_rl(&rl_intra, 1);
-        init_vlc_rl(&rvlc_rl_inter, 1);
-        init_vlc_rl(&rvlc_rl_intra, 1);
-        init_vlc_rl(&rl_intra_aic, 1);
-        init_vlc(&dc_lum, DC_VLC_BITS, 10 /* 13 */,
-                 &DCtab_lum[0][1], 2, 1,
-                 &DCtab_lum[0][0], 2, 1, 1);
-        init_vlc(&dc_chrom, DC_VLC_BITS, 10 /* 13 */,
-                 &DCtab_chrom[0][1], 2, 1,
-                 &DCtab_chrom[0][0], 2, 1, 1);
-        init_vlc(&sprite_trajectory, SPRITE_TRAJ_VLC_BITS, 15,
-                 &sprite_trajectory_tab[0][1], 4, 2,
-                 &sprite_trajectory_tab[0][0], 4, 2, 1);
-        init_vlc(&mb_type_b_vlc, MB_TYPE_B_VLC_BITS, 4,
-                 &mb_type_b_tab[0][1], 2, 1,
-                 &mb_type_b_tab[0][0], 2, 1, 1);
-        init_vlc(&h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15,
-                 &h263_mbtype_b_tab[0][1], 2, 1,
-                 &h263_mbtype_b_tab[0][0], 2, 1, 1);
-        init_vlc(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4,
-                 &cbpc_b_tab[0][1], 2, 1,
-                 &cbpc_b_tab[0][0], 2, 1, 1);
-    }
-}
-
-/**
- * Get the GOB height based on picture height.
- */
-int ff_h263_get_gob_height(MpegEncContext *s){
-    if (s->height <= 400)
-        return 1;
-    else if (s->height <= 800)
-        return  2;
-    else
-        return 4;
-}
-
-int ff_h263_decode_mba(MpegEncContext *s)
-{
-    int i, mb_pos;
-
-    for(i=0; i<6; i++){
-        if(s->mb_num-1 <= ff_mba_max[i]) break;
-    }
-    mb_pos= get_bits(&s->gb, ff_mba_length[i]);
-    s->mb_x= mb_pos % s->mb_width;
-    s->mb_y= mb_pos / s->mb_width;
-
-    return mb_pos;
-}
-
-void ff_h263_encode_mba(MpegEncContext *s)
-{
-    int i, mb_pos;
-
-    for(i=0; i<6; i++){
-        if(s->mb_num-1 <= ff_mba_max[i]) break;
-    }
-    mb_pos= s->mb_x + s->mb_width*s->mb_y;
-    put_bits(&s->pb, ff_mba_length[i], mb_pos);
-}
-
-/**
- * decodes the group of blocks header or slice header.
- * @return <0 if an error occured
- */
-static int h263_decode_gob_header(MpegEncContext *s)
-{
-    unsigned int val, gfid, gob_number;
-    int left;
-    
-    /* Check for GOB Start Code */
-    val = show_bits(&s->gb, 16);
-    if(val)
-        return -1;
-
-        /* We have a GBSC probably with GSTUFF */
-    skip_bits(&s->gb, 16); /* Drop the zeros */
-    left= s->gb.size_in_bits - get_bits_count(&s->gb);
-    //MN: we must check the bits left or we might end in a infinite loop (or segfault)
-    for(;left>13; left--){
-        if(get_bits1(&s->gb)) break; /* Seek the '1' bit */
-    }
-    if(left<=13) 
-        return -1;
-
-    if(s->h263_slice_structured){
-        if(get_bits1(&s->gb)==0)
-            return -1;
-
-        ff_h263_decode_mba(s);
-
-        if(s->mb_num > 1583)
-            if(get_bits1(&s->gb)==0)
-                return -1;
-        
-        s->qscale = get_bits(&s->gb, 5); /* SQUANT */
-        if(get_bits1(&s->gb)==0)
-            return -1;
-        gfid = get_bits(&s->gb, 2); /* GFID */
-    }else{
-        gob_number = get_bits(&s->gb, 5); /* GN */
-        s->mb_x= 0;
-        s->mb_y= s->gob_index* gob_number;
-        gfid = get_bits(&s->gb, 2); /* GFID */
-        s->qscale = get_bits(&s->gb, 5); /* GQUANT */
-    }
-        
-    if(s->mb_y >= s->mb_height) 
-        return -1;
-
-    if(s->qscale==0) 
-        return -1;
-
-    return 0;
-}
-
-static inline void memsetw(short *tab, int val, int n)
-{
-    int i;
-    for(i=0;i<n;i++)
-        tab[i] = val;
-}
-
-#ifdef CONFIG_ENCODERS
-
-void ff_mpeg4_init_partitions(MpegEncContext *s)
-{
-    uint8_t *start= pbBufPtr(&s->pb);
-    uint8_t *end= s->pb.buf_end;
-    int size= end - start;
-    int pb_size = (((long)start + size/3)&(~3)) - (long)start;
-    int tex_size= (size - 2*pb_size)&(~3);
-    
-    set_put_bits_buffer_size(&s->pb, pb_size);
-    init_put_bits(&s->tex_pb, start + pb_size           , tex_size);
-    init_put_bits(&s->pb2   , start + pb_size + tex_size, pb_size);
-}
-
-void ff_mpeg4_merge_partitions(MpegEncContext *s)
-{
-    const int pb2_len   = put_bits_count(&s->pb2   );
-    const int tex_pb_len= put_bits_count(&s->tex_pb);
-    const int bits= put_bits_count(&s->pb);
-
-    if(s->pict_type==I_TYPE){
-        put_bits(&s->pb, 19, DC_MARKER);
-        s->misc_bits+=19 + pb2_len + bits - s->last_bits;
-        s->i_tex_bits+= tex_pb_len;
-    }else{
-        put_bits(&s->pb, 17, MOTION_MARKER);
-        s->misc_bits+=17 + pb2_len;
-        s->mv_bits+= bits - s->last_bits;
-        s->p_tex_bits+= tex_pb_len;
-    }
-
-    flush_put_bits(&s->pb2);
-    flush_put_bits(&s->tex_pb);
-
-    set_put_bits_buffer_size(&s->pb, s->pb2.buf_end - s->pb.buf);
-    ff_copy_bits(&s->pb, s->pb2.buf   , pb2_len);
-    ff_copy_bits(&s->pb, s->tex_pb.buf, tex_pb_len);
-    s->last_bits= put_bits_count(&s->pb);
-}
-
-#endif //CONFIG_ENCODERS
-
-int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s){
-    switch(s->pict_type){
-        case I_TYPE:
-            return 16;
-        case P_TYPE:
-        case S_TYPE:
-            return s->f_code+15;
-        case B_TYPE:
-            return FFMAX(FFMAX(s->f_code, s->b_code)+15, 17);
-        default:
-            return -1;
-    }
-}
-
-#ifdef CONFIG_ENCODERS
-
-void ff_mpeg4_encode_video_packet_header(MpegEncContext *s)
-{
-    int mb_num_bits= av_log2(s->mb_num - 1) + 1;
-
-    put_bits(&s->pb, ff_mpeg4_get_video_packet_prefix_length(s), 0);
-    put_bits(&s->pb, 1, 1);
-    
-    put_bits(&s->pb, mb_num_bits, s->mb_x + s->mb_y*s->mb_width);
-    put_bits(&s->pb, s->quant_precision, s->qscale);
-    put_bits(&s->pb, 1, 0); /* no HEC */
-}
-
-#endif //CONFIG_ENCODERS
-
-/**
- * check if the next stuff is a resync marker or the end.
- * @return 0 if not
- */
-static inline int mpeg4_is_resync(MpegEncContext *s){
-    const int bits_count= get_bits_count(&s->gb);
-    
-    if(s->workaround_bugs&FF_BUG_NO_PADDING){
-        return 0;
-    }
-
-    if(bits_count + 8 >= s->gb.size_in_bits){
-        int v= show_bits(&s->gb, 8);
-        v|= 0x7F >> (7-(bits_count&7));
-                
-        if(v==0x7F)
-            return 1;
-    }else{
-        if(show_bits(&s->gb, 16) == ff_mpeg4_resync_prefix[bits_count&7]){
-            int len;
-            GetBitContext gb= s->gb;
-        
-            skip_bits(&s->gb, 1);
-            align_get_bits(&s->gb);
-        
-            for(len=0; len<32; len++){
-                if(get_bits1(&s->gb)) break;
-            }
-
-            s->gb= gb;
-
-            if(len>=ff_mpeg4_get_video_packet_prefix_length(s))
-                return 1;
-        }
-    }
-    return 0;
-}
-
-/**
- * decodes the next video packet.
- * @return <0 if something went wrong
- */
-static int mpeg4_decode_video_packet_header(MpegEncContext *s)
-{
-    int mb_num_bits= av_log2(s->mb_num - 1) + 1;
-    int header_extension=0, mb_num, len;
-    
-    /* is there enough space left for a video packet + header */
-    if( get_bits_count(&s->gb) > s->gb.size_in_bits-20) return -1;
-
-    for(len=0; len<32; len++){
-        if(get_bits1(&s->gb)) break;
-    }
-
-    if(len!=ff_mpeg4_get_video_packet_prefix_length(s)){
-        av_log(s->avctx, AV_LOG_ERROR, "marker does not match f_code\n");
-        return -1;
-    }
-    
-    if(s->shape != RECT_SHAPE){
-        header_extension= get_bits1(&s->gb);
-        //FIXME more stuff here
-    }
-
-    mb_num= get_bits(&s->gb, mb_num_bits);
-    if(mb_num>=s->mb_num){
-        av_log(s->avctx, AV_LOG_ERROR, "illegal mb_num in video packet (%d %d) \n", mb_num, s->mb_num);
-        return -1;
-    }
-    if(s->pict_type == B_TYPE){
-        while(s->next_picture.mbskip_table[ s->mb_index2xy[ mb_num ] ]) mb_num++;
-        if(mb_num >= s->mb_num) return -1; // slice contains just skipped MBs which where allready decoded
-    }
-    
-    s->mb_x= mb_num % s->mb_width;
-    s->mb_y= mb_num / s->mb_width;
-
-    if(s->shape != BIN_ONLY_SHAPE){
-        int qscale= get_bits(&s->gb, s->quant_precision); 
-        if(qscale)
-            s->chroma_qscale=s->qscale= qscale;
-    }
-
-    if(s->shape == RECT_SHAPE){
-        header_extension= get_bits1(&s->gb);
-    }
-    if(header_extension){
-        int time_increment;
-        int time_incr=0;
-
-        while (get_bits1(&s->gb) != 0) 
-            time_incr++;
-
-        check_marker(&s->gb, "before time_increment in video packed header");
-        time_increment= get_bits(&s->gb, s->time_increment_bits);
-        check_marker(&s->gb, "before vop_coding_type in video packed header");
-        
-        skip_bits(&s->gb, 2); /* vop coding type */
-        //FIXME not rect stuff here
-
-        if(s->shape != BIN_ONLY_SHAPE){
-            skip_bits(&s->gb, 3); /* intra dc vlc threshold */
-//FIXME don't just ignore everything
-            if(s->pict_type == S_TYPE && s->vol_sprite_usage==GMC_SPRITE){
-                mpeg4_decode_sprite_trajectory(s, &s->gb);
-                av_log(s->avctx, AV_LOG_ERROR, "untested\n");
-            }
-
-            //FIXME reduced res stuff here
-            
-            if (s->pict_type != I_TYPE) {
-                int f_code = get_bits(&s->gb, 3);	/* fcode_for */
-                if(f_code==0){
-                    av_log(s->avctx, AV_LOG_ERROR, "Error, video packet header damaged (f_code=0)\n");
-                }
-            }
-            if (s->pict_type == B_TYPE) {
-                int b_code = get_bits(&s->gb, 3);
-                if(b_code==0){
-                    av_log(s->avctx, AV_LOG_ERROR, "Error, video packet header damaged (b_code=0)\n");
-                }
-            }       
-        }
-    }
-    //FIXME new-pred stuff
-    
-//printf("parse ok %d %d %d %d\n", mb_num, s->mb_x + s->mb_y*s->mb_width, get_bits_count(gb), get_bits_count(&s->gb));
-
-    return 0;
-}
-
-void ff_mpeg4_clean_buffers(MpegEncContext *s)
-{
-    int c_wrap, c_xy, l_wrap, l_xy;
-
-    l_wrap= s->b8_stride;
-    l_xy= (2*s->mb_y-1)*l_wrap + s->mb_x*2 - 1;
-    c_wrap= s->mb_stride;
-    c_xy= (s->mb_y-1)*c_wrap + s->mb_x - 1;
-
-#if 0
-    /* clean DC */
-    memsetw(s->dc_val[0] + l_xy, 1024, l_wrap*2+1);
-    memsetw(s->dc_val[1] + c_xy, 1024, c_wrap+1);
-    memsetw(s->dc_val[2] + c_xy, 1024, c_wrap+1);
-#endif
-
-    /* clean AC */
-    memset(s->ac_val[0] + l_xy, 0, (l_wrap*2+1)*16*sizeof(int16_t));
-    memset(s->ac_val[1] + c_xy, 0, (c_wrap  +1)*16*sizeof(int16_t));
-    memset(s->ac_val[2] + c_xy, 0, (c_wrap  +1)*16*sizeof(int16_t));
-
-    /* clean MV */
-    // we can't clear the MVs as they might be needed by a b frame
-//    memset(s->motion_val + l_xy, 0, (l_wrap*2+1)*2*sizeof(int16_t));
-//    memset(s->motion_val, 0, 2*sizeof(int16_t)*(2 + s->mb_width*2)*(2 + s->mb_height*2));
-    s->last_mv[0][0][0]=
-    s->last_mv[0][0][1]=
-    s->last_mv[1][0][0]=
-    s->last_mv[1][0][1]= 0;
-}
-
-/**
- * decodes the group of blocks / video packet header.
- * @return <0 if no resync found
- */
-int ff_h263_resync(MpegEncContext *s){
-    int left, ret;
-    
-    if(s->codec_id==CODEC_ID_MPEG4){
-        skip_bits1(&s->gb);
-        align_get_bits(&s->gb);
-    }
-
-    if(show_bits(&s->gb, 16)==0){
-        if(s->codec_id==CODEC_ID_MPEG4)
-            ret= mpeg4_decode_video_packet_header(s);
-        else
-            ret= h263_decode_gob_header(s);
-        if(ret>=0)
-            return 0;
-    }
-    //ok, it's not where its supposed to be ...
-    s->gb= s->last_resync_gb;
-    align_get_bits(&s->gb);
-    left= s->gb.size_in_bits - get_bits_count(&s->gb);
-    
-    for(;left>16+1+5+5; left-=8){ 
-        if(show_bits(&s->gb, 16)==0){
-            GetBitContext bak= s->gb;
-
-            if(s->codec_id==CODEC_ID_MPEG4)
-                ret= mpeg4_decode_video_packet_header(s);
-            else
-                ret= h263_decode_gob_header(s);
-            if(ret>=0)
-                return 0;
-
-            s->gb= bak;
-        }
-        skip_bits(&s->gb, 8);
-    }
-    
-    return -1;
-}
-
-/**
- * gets the average motion vector for a GMC MB.
- * @param n either 0 for the x component or 1 for y
- * @returns the average MV for a GMC MB
- */
-static inline int get_amv(MpegEncContext *s, int n){
-    int x, y, mb_v, sum, dx, dy, shift;
-    int len = 1 << (s->f_code + 4);
-    const int a= s->sprite_warping_accuracy;
-    
-    if(s->workaround_bugs & FF_BUG_AMV)
-        len >>= s->quarter_sample;
-
-    if(s->real_sprite_warping_points==1){
-        if(s->divx_version==500 && s->divx_build==413)
-            sum= s->sprite_offset[0][n] / (1<<(a - s->quarter_sample));
-        else
-            sum= RSHIFT(s->sprite_offset[0][n]<<s->quarter_sample, a);
-    }else{
-        dx= s->sprite_delta[n][0];
-        dy= s->sprite_delta[n][1];
-        shift= s->sprite_shift[0];
-        if(n) dy -= 1<<(shift + a + 1);
-        else  dx -= 1<<(shift + a + 1);
-        mb_v= s->sprite_offset[0][n] + dx*s->mb_x*16 + dy*s->mb_y*16;
-
-        sum=0;
-        for(y=0; y<16; y++){
-            int v;
-        
-            v= mb_v + dy*y;
-            //XXX FIXME optimize
-            for(x=0; x<16; x++){
-                sum+= v>>shift;
-                v+= dx;
-            }
-        }
-        sum= RSHIFT(sum, a+8-s->quarter_sample);
-    }
-
-    if      (sum < -len) sum= -len;
-    else if (sum >= len) sum= len-1;
-
-    return sum;
-}
-
-/**
- * decodes first partition.
- * @return number of MBs decoded or <0 if an error occured
- */
-static int mpeg4_decode_partition_a(MpegEncContext *s){
-    int mb_num;
-    static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
-    
-    /* decode first partition */
-    mb_num=0;
-    s->first_slice_line=1;
-    for(; s->mb_y<s->mb_height; s->mb_y++){
-        ff_init_block_index(s);
-        for(; s->mb_x<s->mb_width; s->mb_x++){
-            const int xy= s->mb_x + s->mb_y*s->mb_stride;
-            int cbpc;
-            int dir=0;
-            
-            mb_num++;
-            ff_update_block_index(s);
-            if(s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y+1)
-                s->first_slice_line=0;
-            
-            if(s->pict_type==I_TYPE){
-                int i;
-
-                do{
-                    if(show_bits_long(&s->gb, 19)==DC_MARKER){
-                        return mb_num-1;
-                    }
-
-                    cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
-                    if (cbpc < 0){
-                        av_log(s->avctx, AV_LOG_ERROR, "cbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
-                        return -1;
-                    }
-                }while(cbpc == 8);
-                
-                s->cbp_table[xy]= cbpc & 3;
-                s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
-                s->mb_intra = 1;
-
-                if(cbpc & 4) {
-                    ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
-                }
-                s->current_picture.qscale_table[xy]= s->qscale;
-
-                s->mbintra_table[xy]= 1;
-                for(i=0; i<6; i++){
-                    int dc_pred_dir;
-                    int dc= mpeg4_decode_dc(s, i, &dc_pred_dir); 
-                    if(dc < 0){
-                        av_log(s->avctx, AV_LOG_ERROR, "DC corrupted at %d %d\n", s->mb_x, s->mb_y);
-                        return -1;
-                    }
-                    dir<<=1;
-                    if(dc_pred_dir) dir|=1;
-                }
-                s->pred_dir_table[xy]= dir;
-            }else{ /* P/S_TYPE */
-                int mx, my, pred_x, pred_y, bits;
-                int16_t * const mot_val= s->current_picture.motion_val[0][s->block_index[0]];
-                const int stride= s->b8_stride*2;
-
-try_again:
-                bits= show_bits(&s->gb, 17);
-                if(bits==MOTION_MARKER){
-                    return mb_num-1;
-                }
-                skip_bits1(&s->gb);
-                if(bits&0x10000){
-                    /* skip mb */
-                    if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE){
-                        s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0;
-                        mx= get_amv(s, 0);
-                        my= get_amv(s, 1);
-                    }else{
-                        s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
-                        mx=my=0;
-                    }
-                    mot_val[0       ]= mot_val[2       ]=
-                    mot_val[0+stride]= mot_val[2+stride]= mx;
-                    mot_val[1       ]= mot_val[3       ]=
-                    mot_val[1+stride]= mot_val[3+stride]= my;
-
-                    if(s->mbintra_table[xy])
-                        ff_clean_intra_table_entries(s);
-                    continue;
-                }
-
-                cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
-                if (cbpc < 0){
-                    av_log(s->avctx, AV_LOG_ERROR, "cbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
-                    return -1;
-                }
-                if(cbpc == 20)
-                    goto try_again;
-
-                s->cbp_table[xy]= cbpc&(8+3); //8 is dquant
-    
-                s->mb_intra = ((cbpc & 4) != 0);
-        
-                if(s->mb_intra){
-                    s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
-                    s->mbintra_table[xy]= 1;
-                    mot_val[0       ]= mot_val[2       ]= 
-                    mot_val[0+stride]= mot_val[2+stride]= 0;
-                    mot_val[1       ]= mot_val[3       ]=
-                    mot_val[1+stride]= mot_val[3+stride]= 0;
-                }else{
-                    if(s->mbintra_table[xy])
-                        ff_clean_intra_table_entries(s);
-
-                    if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE && (cbpc & 16) == 0)
-                        s->mcsel= get_bits1(&s->gb);
-                    else s->mcsel= 0;
-        
-                    if ((cbpc & 16) == 0) {
-                        /* 16x16 motion prediction */
-
-                        h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
-                        if(!s->mcsel){
-                            mx = h263_decode_motion(s, pred_x, s->f_code);
-                            if (mx >= 0xffff)
-                                return -1;
-
-                            my = h263_decode_motion(s, pred_y, s->f_code);
-                            if (my >= 0xffff)
-                                return -1;
-                            s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0;
-                        } else {
-                            mx = get_amv(s, 0);
-                            my = get_amv(s, 1);
-                            s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0;
-                        }
-
-                        mot_val[0       ]= mot_val[2       ] =
-                        mot_val[0+stride]= mot_val[2+stride]= mx;
-                        mot_val[1       ]= mot_val[3       ]=
-                        mot_val[1+stride]= mot_val[3+stride]= my;
-                    } else {
-                        int i;
-                        s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0;
-                        for(i=0;i<4;i++) {
-                            int16_t *mot_val= h263_pred_motion(s, i, 0, &pred_x, &pred_y);
-                            mx = h263_decode_motion(s, pred_x, s->f_code);
-                            if (mx >= 0xffff)
-                                return -1;
-                
-                            my = h263_decode_motion(s, pred_y, s->f_code);
-                            if (my >= 0xffff)
-                                return -1;
-                            mot_val[0] = mx;
-                            mot_val[1] = my;
-                        }
-                    }
-                }
-            }
-        }
-        s->mb_x= 0;
-    }
-
-    return mb_num;
-}
-
-/**
- * decode second partition.
- * @return <0 if an error occured
- */
-static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){
-    int mb_num=0;
-    static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
-
-    s->mb_x= s->resync_mb_x;
-    s->first_slice_line=1;
-    for(s->mb_y= s->resync_mb_y; mb_num < mb_count; s->mb_y++){
-        ff_init_block_index(s);
-        for(; mb_num < mb_count && s->mb_x<s->mb_width; s->mb_x++){
-            const int xy= s->mb_x + s->mb_y*s->mb_stride;
-
-            mb_num++;
-            ff_update_block_index(s);
-            if(s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y+1)
-                s->first_slice_line=0;
-            
-            if(s->pict_type==I_TYPE){
-                int ac_pred= get_bits1(&s->gb);
-                int cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
-                if(cbpy<0){
-                    av_log(s->avctx, AV_LOG_ERROR, "cbpy corrupted at %d %d\n", s->mb_x, s->mb_y);
-                    return -1;
-                }
-                
-                s->cbp_table[xy]|= cbpy<<2;
-                s->current_picture.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED; 
-            }else{ /* P || S_TYPE */
-                if(IS_INTRA(s->current_picture.mb_type[xy])){          
-                    int dir=0,i;
-                    int ac_pred = get_bits1(&s->gb);
-                    int cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
-
-                    if(cbpy<0){
-                        av_log(s->avctx, AV_LOG_ERROR, "I cbpy corrupted at %d %d\n", s->mb_x, s->mb_y);
-                        return -1;
-                    }
-                    
-                    if(s->cbp_table[xy] & 8) {
-                        ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
-                    }
-                    s->current_picture.qscale_table[xy]= s->qscale;
-
-                    for(i=0; i<6; i++){
-                        int dc_pred_dir;
-                        int dc= mpeg4_decode_dc(s, i, &dc_pred_dir); 
-                        if(dc < 0){
-                            av_log(s->avctx, AV_LOG_ERROR, "DC corrupted at %d %d\n", s->mb_x, s->mb_y);
-                            return -1;
-                        }
-                        dir<<=1;
-                        if(dc_pred_dir) dir|=1;
-                    }
-                    s->cbp_table[xy]&= 3; //remove dquant
-                    s->cbp_table[xy]|= cbpy<<2;
-                    s->current_picture.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED; 
-                    s->pred_dir_table[xy]= dir;
-                }else if(IS_SKIP(s->current_picture.mb_type[xy])){
-                    s->current_picture.qscale_table[xy]= s->qscale;
-                    s->cbp_table[xy]= 0;
-                }else{
-                    int cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
-
-                    if(cbpy<0){
-                        av_log(s->avctx, AV_LOG_ERROR, "P cbpy corrupted at %d %d\n", s->mb_x, s->mb_y);
-                        return -1;
-                    }
-                    
-                    if(s->cbp_table[xy] & 8) {
-                        ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
-                    }
-                    s->current_picture.qscale_table[xy]= s->qscale;
-
-                    s->cbp_table[xy]&= 3; //remove dquant
-                    s->cbp_table[xy]|= (cbpy^0xf)<<2;
-                }
-            }
-        }
-        if(mb_num >= mb_count) return 0;
-        s->mb_x= 0;
-    }
-    return 0;
-}
-
-/**
- * decodes the first & second partition
- * @return <0 if error (and sets error type in the error_status_table)
- */
-int ff_mpeg4_decode_partitions(MpegEncContext *s)
-{
-    int mb_num;
-    const int part_a_error= s->pict_type==I_TYPE ? (DC_ERROR|MV_ERROR) : MV_ERROR;
-    const int part_a_end  = s->pict_type==I_TYPE ? (DC_END  |MV_END)   : MV_END;
-    
-    mb_num= mpeg4_decode_partition_a(s);    
-    if(mb_num<0){
-        ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, part_a_error);
-        return -1;
-    }
-    
-    if(s->resync_mb_x + s->resync_mb_y*s->mb_width + mb_num > s->mb_num){
-        av_log(s->avctx, AV_LOG_ERROR, "slice below monitor ...\n");
-        ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, part_a_error);
-        return -1;
-    }
-
-    s->mb_num_left= mb_num;
-        
-    if(s->pict_type==I_TYPE){
-        while(show_bits(&s->gb, 9) == 1)
-            skip_bits(&s->gb, 9);
-        if(get_bits_long(&s->gb, 19)!=DC_MARKER){
-            av_log(s->avctx, AV_LOG_ERROR, "marker missing after first I partition at %d %d\n", s->mb_x, s->mb_y);
-            return -1;
-        }
-    }else{
-        while(show_bits(&s->gb, 10) == 1)
-            skip_bits(&s->gb, 10);
-        if(get_bits(&s->gb, 17)!=MOTION_MARKER){
-            av_log(s->avctx, AV_LOG_ERROR, "marker missing after first P partition at %d %d\n", s->mb_x, s->mb_y);
-            return -1;
-        }
-    }
-    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, part_a_end);
-    
-    if( mpeg4_decode_partition_b(s, mb_num) < 0){
-        if(s->pict_type==P_TYPE)
-            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, DC_ERROR);
-        return -1;
-    }else{
-        if(s->pict_type==P_TYPE)
-            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, DC_END);
-    }
-
-    return 0;        
-}
-
-/**
- * decode partition C of one MB.
- * @return <0 if an error occured
- */
-static int mpeg4_decode_partitioned_mb(MpegEncContext *s, DCTELEM block[6][64])
-{
-    int cbp, mb_type;
-    const int xy= s->mb_x + s->mb_y*s->mb_stride;
-
-    mb_type= s->current_picture.mb_type[xy];
-    cbp = s->cbp_table[xy];
-
-    if(s->current_picture.qscale_table[xy] != s->qscale){
-        ff_set_qscale(s, s->current_picture.qscale_table[xy] );
-    }
-    
-    if (s->pict_type == P_TYPE || s->pict_type==S_TYPE) {
-        int i;
-        for(i=0; i<4; i++){
-            s->mv[0][i][0] = s->current_picture.motion_val[0][ s->block_index[i] ][0];
-            s->mv[0][i][1] = s->current_picture.motion_val[0][ s->block_index[i] ][1];
-        }
-        s->mb_intra = IS_INTRA(mb_type);
-
-        if (IS_SKIP(mb_type)) {
-            /* skip mb */
-            for(i=0;i<6;i++)
-                s->block_last_index[i] = -1;
-            s->mv_dir = MV_DIR_FORWARD;
-            s->mv_type = MV_TYPE_16X16;
-            if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE){
-                s->mcsel=1;
-                s->mb_skipped = 0;
-            }else{
-                s->mcsel=0;
-                s->mb_skipped = 1;
-            }
-        }else if(s->mb_intra){
-            s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]);
-        }else if(!s->mb_intra){
-//            s->mcsel= 0; //FIXME do we need to init that
-            
-            s->mv_dir = MV_DIR_FORWARD;
-            if (IS_8X8(mb_type)) {
-                s->mv_type = MV_TYPE_8X8;
-            } else {
-                s->mv_type = MV_TYPE_16X16;
-            }
-        }
-    } else { /* I-Frame */
-        s->mb_intra = 1;
-        s->ac_pred = IS_ACPRED(s->current_picture.mb_type[xy]);
-    }
-
-    if (!IS_SKIP(mb_type)) {
-        int i;
-        s->dsp.clear_blocks(s->block[0]);
-        /* decode each block */
-        for (i = 0; i < 6; i++) {
-            if(mpeg4_decode_block(s, block[i], i, cbp&32, s->mb_intra, s->rvlc) < 0){
-                av_log(s->avctx, AV_LOG_ERROR, "texture corrupted at %d %d %d\n", s->mb_x, s->mb_y, s->mb_intra);
-                return -1;
-            }
-            cbp+=cbp;
-        }
-    }
-
-    /* per-MB end of slice check */
-
-    if(--s->mb_num_left <= 0){
-//printf("%06X %d\n", show_bits(&s->gb, 24), s->gb.size_in_bits - get_bits_count(&s->gb));
-        if(mpeg4_is_resync(s))
-            return SLICE_END;
-        else
-            return SLICE_NOEND;     
-    }else{
-        if(mpeg4_is_resync(s)){
-            const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1;
-            if(s->cbp_table[xy+delta])
-                return SLICE_END;
-        }
-        return SLICE_OK;
-    }
-}
-
-/**
- * read the next MVs for OBMC. yes this is a ugly hack, feel free to send a patch :)
- */
-static void preview_obmc(MpegEncContext *s){
-    GetBitContext gb= s->gb;
-    
-    int cbpc, i, pred_x, pred_y, mx, my;
-    int16_t *mot_val;
-    const int xy= s->mb_x + 1 + s->mb_y * s->mb_stride;
-    const int stride= s->b8_stride*2;
-    
-    for(i=0; i<4; i++)
-        s->block_index[i]+= 2;
-    for(i=4; i<6; i++)
-        s->block_index[i]+= 1;
-    s->mb_x++;
-    
-    assert(s->pict_type == P_TYPE);
-
-    do{
-        if (get_bits1(&s->gb)) {
-            /* skip mb */
-            mot_val = s->current_picture.motion_val[0][ s->block_index[0] ];
-            mot_val[0       ]= mot_val[2       ]= 
-            mot_val[0+stride]= mot_val[2+stride]= 0;
-            mot_val[1       ]= mot_val[3       ]=
-            mot_val[1+stride]= mot_val[3+stride]= 0;
-            
-            s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
-            goto end;
-        }
-        cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
-    }while(cbpc == 20);
-    
-    if(cbpc & 4){
-        s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
-    }else{
-        get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
-        if (cbpc & 8) {
-            if(s->modified_quant){
-                if(get_bits1(&s->gb)) skip_bits(&s->gb, 1);
-                else                  skip_bits(&s->gb, 5);
-            }else
-                skip_bits(&s->gb, 2);
-        }
-        
-        if ((cbpc & 16) == 0) {
-                s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; 
-                /* 16x16 motion prediction */
-                mot_val= h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
-                if (s->umvplus)
-                   mx = h263p_decode_umotion(s, pred_x);
-                else
-                   mx = h263_decode_motion(s, pred_x, 1);
-            
-                if (s->umvplus)
-                   my = h263p_decode_umotion(s, pred_y);
-                else
-                   my = h263_decode_motion(s, pred_y, 1);
-            
-                mot_val[0       ]= mot_val[2       ]= 
-                mot_val[0+stride]= mot_val[2+stride]= mx;
-                mot_val[1       ]= mot_val[3       ]=
-                mot_val[1+stride]= mot_val[3+stride]= my;
-        } else {
-            s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0; 
-            for(i=0;i<4;i++) {
-                mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y);
-                if (s->umvplus)
-                  mx = h263p_decode_umotion(s, pred_x);
-                else
-                  mx = h263_decode_motion(s, pred_x, 1);
-                
-                if (s->umvplus)
-                  my = h263p_decode_umotion(s, pred_y);
-                else    
-                  my = h263_decode_motion(s, pred_y, 1);
-                if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
-                  skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
-                mot_val[0] = mx;
-                mot_val[1] = my;
-            }
-        }
-    }
-end:
-        
-    for(i=0; i<4; i++)
-        s->block_index[i]-= 2;
-    for(i=4; i<6; i++)
-        s->block_index[i]-= 1;
-    s->mb_x--;
-
-    s->gb= gb;
-}
-
-static void h263_decode_dquant(MpegEncContext *s){
-    static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
-
-    if(s->modified_quant){
-        if(get_bits1(&s->gb))
-            s->qscale= modified_quant_tab[get_bits1(&s->gb)][ s->qscale ];
-        else
-            s->qscale= get_bits(&s->gb, 5);
-    }else
-        s->qscale += quant_tab[get_bits(&s->gb, 2)];
-    ff_set_qscale(s, s->qscale);
-}
-
-int ff_h263_decode_mb(MpegEncContext *s,
-                      DCTELEM block[6][64])
-{
-    int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
-    int16_t *mot_val;
-    const int xy= s->mb_x + s->mb_y * s->mb_stride;
-    
-    assert(!s->h263_pred);
-    
-    if (s->pict_type == P_TYPE) {
-        do{
-            if (get_bits1(&s->gb)) {
-                /* skip mb */
-                s->mb_intra = 0;
-                for(i=0;i<6;i++)
-                    s->block_last_index[i] = -1;
-                s->mv_dir = MV_DIR_FORWARD;
-                s->mv_type = MV_TYPE_16X16;
-                s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
-                s->mv[0][0][0] = 0;
-                s->mv[0][0][1] = 0;
-                s->mb_skipped = !(s->obmc | s->loop_filter);
-                goto end;
-            }
-            cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
-            //fprintf(stderr, "\tCBPC: %d", cbpc);
-            if (cbpc < 0){
-                av_log(s->avctx, AV_LOG_ERROR, "cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-        }while(cbpc == 20);
-        
-        s->dsp.clear_blocks(s->block[0]);
-        
-        dquant = cbpc & 8;
-        s->mb_intra = ((cbpc & 4) != 0);
-        if (s->mb_intra) goto intra;
-        
-        cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
-        
-        if(s->alt_inter_vlc==0 || (cbpc & 3)!=3)
-            cbpy ^= 0xF;
-        
-        cbp = (cbpc & 3) | (cbpy << 2);
-        if (dquant) {
-            h263_decode_dquant(s);
-        }
-        
-        s->mv_dir = MV_DIR_FORWARD;
-        if ((cbpc & 16) == 0) {
-            s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; 
-            /* 16x16 motion prediction */
-            s->mv_type = MV_TYPE_16X16;
-            h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
-            if (s->umvplus)
-               mx = h263p_decode_umotion(s, pred_x);
-            else
-               mx = h263_decode_motion(s, pred_x, 1);
-            
-            if (mx >= 0xffff)
-                return -1;
-            
-            if (s->umvplus)
-               my = h263p_decode_umotion(s, pred_y);
-            else
-               my = h263_decode_motion(s, pred_y, 1);
-            
-            if (my >= 0xffff)
-                return -1;
-            s->mv[0][0][0] = mx;
-            s->mv[0][0][1] = my;
-
-            if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
-               skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */                   
-        } else {
-            s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0; 
-            s->mv_type = MV_TYPE_8X8;
-            for(i=0;i<4;i++) {
-                mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y);
-                if (s->umvplus)
-                  mx = h263p_decode_umotion(s, pred_x);
-                else
-                  mx = h263_decode_motion(s, pred_x, 1);
-                if (mx >= 0xffff)
-                    return -1;
-                
-                if (s->umvplus)
-                  my = h263p_decode_umotion(s, pred_y);
-                else    
-                  my = h263_decode_motion(s, pred_y, 1);
-                if (my >= 0xffff)
-                    return -1;
-                s->mv[0][i][0] = mx;
-                s->mv[0][i][1] = my;
-                if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
-                  skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
-                mot_val[0] = mx;
-                mot_val[1] = my;
-            }
-        }
-
-        /* decode each block */
-        for (i = 0; i < 6; i++) {
-            if (h263_decode_block(s, block[i], i, cbp&32) < 0)
-                return -1;
-            cbp+=cbp;
-        }
-
-        if(s->obmc){
-            if(s->pict_type == P_TYPE && s->mb_x+1<s->mb_width && s->mb_num_left != 1)
-                preview_obmc(s);
-        }
-    } else if(s->pict_type==B_TYPE) {
-        int mb_type;
-        const int stride= s->b8_stride;
-        int16_t *mot_val0 = s->current_picture.motion_val[0][ 2*(s->mb_x + s->mb_y*stride) ];
-        int16_t *mot_val1 = s->current_picture.motion_val[1][ 2*(s->mb_x + s->mb_y*stride) ];
-//        const int mv_xy= s->mb_x + 1 + s->mb_y * s->mb_stride;
-
-        //FIXME ugly 
-        mot_val0[0       ]= mot_val0[2       ]= mot_val0[0+2*stride]= mot_val0[2+2*stride]= 
-        mot_val0[1       ]= mot_val0[3       ]= mot_val0[1+2*stride]= mot_val0[3+2*stride]= 
-        mot_val1[0       ]= mot_val1[2       ]= mot_val1[0+2*stride]= mot_val1[2+2*stride]= 
-        mot_val1[1       ]= mot_val1[3       ]= mot_val1[1+2*stride]= mot_val1[3+2*stride]= 0;
-
-        do{
-            mb_type= get_vlc2(&s->gb, h263_mbtype_b_vlc.table, H263_MBTYPE_B_VLC_BITS, 2);
-            if (mb_type < 0){
-                av_log(s->avctx, AV_LOG_ERROR, "b mb_type damaged at %d %d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-
-            mb_type= h263_mb_type_b_map[ mb_type ];
-        }while(!mb_type);
-
-        s->mb_intra = IS_INTRA(mb_type);
-        if(HAS_CBP(mb_type)){
-            s->dsp.clear_blocks(s->block[0]);
-            cbpc = get_vlc2(&s->gb, cbpc_b_vlc.table, CBPC_B_VLC_BITS, 1);
-            if(s->mb_intra){
-                dquant = IS_QUANT(mb_type);
-                goto intra;
-            }
-
-            cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
-
-            if (cbpy < 0){
-                av_log(s->avctx, AV_LOG_ERROR, "b cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-        
-            if(s->alt_inter_vlc==0 || (cbpc & 3)!=3)
-                cbpy ^= 0xF;
-        
-            cbp = (cbpc & 3) | (cbpy << 2);
-        }else
-            cbp=0;
-            
-        assert(!s->mb_intra);
-
-        if(IS_QUANT(mb_type)){
-            h263_decode_dquant(s);
-        }
-
-        if(IS_DIRECT(mb_type)){
-            s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
-            mb_type |= ff_mpeg4_set_direct_mv(s, 0, 0);
-        }else{
-            s->mv_dir = 0;
-            s->mv_type= MV_TYPE_16X16;
-//FIXME UMV
-
-            if(USES_LIST(mb_type, 0)){
-                int16_t *mot_val= h263_pred_motion(s, 0, 0, &mx, &my);
-                s->mv_dir = MV_DIR_FORWARD;
-
-                mx = h263_decode_motion(s, mx, 1);
-                my = h263_decode_motion(s, my, 1);
-                
-                s->mv[0][0][0] = mx;
-                s->mv[0][0][1] = my;
-                mot_val[0       ]= mot_val[2       ]= mot_val[0+2*stride]= mot_val[2+2*stride]= mx;
-                mot_val[1       ]= mot_val[3       ]= mot_val[1+2*stride]= mot_val[3+2*stride]= my;
-            }
-    
-            if(USES_LIST(mb_type, 1)){
-                int16_t *mot_val= h263_pred_motion(s, 0, 1, &mx, &my);
-                s->mv_dir |= MV_DIR_BACKWARD;
-                
-                mx = h263_decode_motion(s, mx, 1);
-                my = h263_decode_motion(s, my, 1);
-
-                s->mv[1][0][0] = mx;
-                s->mv[1][0][1] = my;
-                mot_val[0       ]= mot_val[2       ]= mot_val[0+2*stride]= mot_val[2+2*stride]= mx;
-                mot_val[1       ]= mot_val[3       ]= mot_val[1+2*stride]= mot_val[3+2*stride]= my;
-            }
-        }
-          
-        s->current_picture.mb_type[xy]= mb_type;
-
-        /* decode each block */
-        for (i = 0; i < 6; i++) {
-            if (h263_decode_block(s, block[i], i, cbp&32) < 0)
-                return -1;
-            cbp+=cbp;
-        }
-    } else { /* I-Frame */
-        do{
-            cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
-            if (cbpc < 0){
-                av_log(s->avctx, AV_LOG_ERROR, "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-        }while(cbpc == 8);
-
-        s->dsp.clear_blocks(s->block[0]);
-
-        dquant = cbpc & 4;
-        s->mb_intra = 1;
-intra:
-        s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
-        if (s->h263_aic) {
-            s->ac_pred = get_bits1(&s->gb);
-            if(s->ac_pred){
-                s->current_picture.mb_type[xy]= MB_TYPE_INTRA | MB_TYPE_ACPRED;
-            
-                s->h263_aic_dir = get_bits1(&s->gb);
-            }
-        }else
-            s->ac_pred = 0;
-        
-        cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
-        if(cbpy<0){
-            av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
-            return -1;
-        }
-        cbp = (cbpc & 3) | (cbpy << 2);
-        if (dquant) {
-            h263_decode_dquant(s);
-        }
-
-        /* decode each block */
-        for (i = 0; i < 6; i++) {
-            if (h263_decode_block(s, block[i], i, cbp&32) < 0)
-                return -1;
-            cbp+=cbp;
-        }
-    }
-end:
-
-        /* per-MB end of slice check */
-    {
-        int v= show_bits(&s->gb, 16);
-    
-        if(get_bits_count(&s->gb) + 16 > s->gb.size_in_bits){
-            v>>= get_bits_count(&s->gb) + 16 - s->gb.size_in_bits;
-        }
-
-        if(v==0)
-            return SLICE_END;
-    }
-
-    return SLICE_OK;     
-}
-
-int ff_mpeg4_decode_mb(MpegEncContext *s,
-                      DCTELEM block[6][64])
-{
-    int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
-    int16_t *mot_val;
-    static int8_t quant_tab[4] = { -1, -2, 1, 2 };
-    const int xy= s->mb_x + s->mb_y * s->mb_stride;
-    
-    assert(s->h263_pred);
-    
-    if (s->pict_type == P_TYPE || s->pict_type==S_TYPE) {
-        do{
-            if (get_bits1(&s->gb)) {
-                /* skip mb */
-                s->mb_intra = 0;
-                for(i=0;i<6;i++)
-                    s->block_last_index[i] = -1;
-                s->mv_dir = MV_DIR_FORWARD;
-                s->mv_type = MV_TYPE_16X16;
-                if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE){
-                    s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0;
-                    s->mcsel=1;
-                    s->mv[0][0][0]= get_amv(s, 0);
-                    s->mv[0][0][1]= get_amv(s, 1);
-
-                    s->mb_skipped = 0;
-                }else{
-                    s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
-                    s->mcsel=0;
-                    s->mv[0][0][0] = 0;
-                    s->mv[0][0][1] = 0;
-                    s->mb_skipped = 1;
-                }
-                goto end;
-            }
-            cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
-            //fprintf(stderr, "\tCBPC: %d", cbpc);
-            if (cbpc < 0){
-                av_log(s->avctx, AV_LOG_ERROR, "cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-        }while(cbpc == 20);
-        
-        s->dsp.clear_blocks(s->block[0]);
-        dquant = cbpc & 8;
-        s->mb_intra = ((cbpc & 4) != 0);
-        if (s->mb_intra) goto intra;
-        
-        if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE && (cbpc & 16) == 0)
-            s->mcsel= get_bits1(&s->gb);
-        else s->mcsel= 0;
-        cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1) ^ 0x0F;
-        
-        cbp = (cbpc & 3) | (cbpy << 2);
-        if (dquant) {
-            ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
-        }
-        if((!s->progressive_sequence) && (cbp || (s->workaround_bugs&FF_BUG_XVID_ILACE)))
-            s->interlaced_dct= get_bits1(&s->gb);
-        
-        s->mv_dir = MV_DIR_FORWARD;
-        if ((cbpc & 16) == 0) {
-            if(s->mcsel){
-                s->current_picture.mb_type[xy]= MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0;
-                /* 16x16 global motion prediction */
-                s->mv_type = MV_TYPE_16X16;
-                mx= get_amv(s, 0);
-                my= get_amv(s, 1);
-                s->mv[0][0][0] = mx;
-                s->mv[0][0][1] = my;
-            }else if((!s->progressive_sequence) && get_bits1(&s->gb)){
-                s->current_picture.mb_type[xy]= MB_TYPE_16x8 | MB_TYPE_L0 | MB_TYPE_INTERLACED; 
-                /* 16x8 field motion prediction */
-                s->mv_type= MV_TYPE_FIELD;
-
-                s->field_select[0][0]= get_bits1(&s->gb);
-                s->field_select[0][1]= get_bits1(&s->gb);
-
-                h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
-                
-                for(i=0; i<2; i++){
-                    mx = h263_decode_motion(s, pred_x, s->f_code);
-                    if (mx >= 0xffff)
-                        return -1;
-            
-                    my = h263_decode_motion(s, pred_y/2, s->f_code);
-                    if (my >= 0xffff)
-                        return -1;
-
-                    s->mv[0][i][0] = mx;
-                    s->mv[0][i][1] = my;
-                }
-            }else{
-                s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; 
-                /* 16x16 motion prediction */
-                s->mv_type = MV_TYPE_16X16;
-                h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
-                mx = h263_decode_motion(s, pred_x, s->f_code);
-            
-                if (mx >= 0xffff)
-                    return -1;
-            
-                my = h263_decode_motion(s, pred_y, s->f_code);
-            
-                if (my >= 0xffff)
-                    return -1;
-                s->mv[0][0][0] = mx;
-                s->mv[0][0][1] = my;
-            }
-        } else {
-            s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0; 
-            s->mv_type = MV_TYPE_8X8;
-            for(i=0;i<4;i++) {
-                mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y);
-                mx = h263_decode_motion(s, pred_x, s->f_code);
-                if (mx >= 0xffff)
-                    return -1;
-                
-                my = h263_decode_motion(s, pred_y, s->f_code);
-                if (my >= 0xffff)
-                    return -1;
-                s->mv[0][i][0] = mx;
-                s->mv[0][i][1] = my;
-                mot_val[0] = mx;
-                mot_val[1] = my;
-            }
-        }
-    } else if(s->pict_type==B_TYPE) {
-        int modb1; // first bit of modb
-        int modb2; // second bit of modb
-        int mb_type;
-
-        s->mb_intra = 0; //B-frames never contain intra blocks
-        s->mcsel=0;      //     ...               true gmc blocks
-
-        if(s->mb_x==0){
-            for(i=0; i<2; i++){
-                s->last_mv[i][0][0]= 
-                s->last_mv[i][0][1]= 
-                s->last_mv[i][1][0]= 
-                s->last_mv[i][1][1]= 0;
-            }
-        }
-
-        /* if we skipped it in the future P Frame than skip it now too */
-        s->mb_skipped= s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]; // Note, skiptab=0 if last was GMC
-
-        if(s->mb_skipped){
-                /* skip mb */
-            for(i=0;i<6;i++)
-                s->block_last_index[i] = -1;
-
-            s->mv_dir = MV_DIR_FORWARD;
-            s->mv_type = MV_TYPE_16X16;
-            s->mv[0][0][0] = 0;
-            s->mv[0][0][1] = 0;
-            s->mv[1][0][0] = 0;
-            s->mv[1][0][1] = 0;
-            s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; 
-            goto end;
-        }
-
-        modb1= get_bits1(&s->gb); 
-        if(modb1){
-            mb_type= MB_TYPE_DIRECT2 | MB_TYPE_SKIP | MB_TYPE_L0L1; //like MB_TYPE_B_DIRECT but no vectors coded
-            cbp=0;
-        }else{
-            modb2= get_bits1(&s->gb);
-            mb_type= get_vlc2(&s->gb, mb_type_b_vlc.table, MB_TYPE_B_VLC_BITS, 1);
-            if(mb_type<0){
-                av_log(s->avctx, AV_LOG_ERROR, "illegal MB_type\n");
-                return -1;
-            }
-            mb_type= mb_type_b_map[ mb_type ];
-            if(modb2) cbp= 0;
-            else{
-                s->dsp.clear_blocks(s->block[0]);
-                cbp= get_bits(&s->gb, 6);
-            }
-
-            if ((!IS_DIRECT(mb_type)) && cbp) {
-                if(get_bits1(&s->gb)){
-                    ff_set_qscale(s, s->qscale + get_bits1(&s->gb)*4 - 2);
-                }
-            }
-
-            if(!s->progressive_sequence){
-                if(cbp)
-                    s->interlaced_dct= get_bits1(&s->gb);
-
-                if(!IS_DIRECT(mb_type) && get_bits1(&s->gb)){
-                    mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
-                    mb_type &= ~MB_TYPE_16x16;
-
-                    if(USES_LIST(mb_type, 0)){
-                        s->field_select[0][0]= get_bits1(&s->gb);
-                        s->field_select[0][1]= get_bits1(&s->gb);
-                    }
-                    if(USES_LIST(mb_type, 1)){
-                        s->field_select[1][0]= get_bits1(&s->gb);
-                        s->field_select[1][1]= get_bits1(&s->gb);
-                    }
-                }
-            }
-
-            s->mv_dir = 0;
-            if((mb_type & (MB_TYPE_DIRECT2|MB_TYPE_INTERLACED)) == 0){
-                s->mv_type= MV_TYPE_16X16;
-
-                if(USES_LIST(mb_type, 0)){
-                    s->mv_dir = MV_DIR_FORWARD;
-
-                    mx = h263_decode_motion(s, s->last_mv[0][0][0], s->f_code);
-                    my = h263_decode_motion(s, s->last_mv[0][0][1], s->f_code);
-                    s->last_mv[0][1][0]= s->last_mv[0][0][0]= s->mv[0][0][0] = mx;
-                    s->last_mv[0][1][1]= s->last_mv[0][0][1]= s->mv[0][0][1] = my;
-                }
-    
-                if(USES_LIST(mb_type, 1)){
-                    s->mv_dir |= MV_DIR_BACKWARD;
-
-                    mx = h263_decode_motion(s, s->last_mv[1][0][0], s->b_code);
-                    my = h263_decode_motion(s, s->last_mv[1][0][1], s->b_code);
-                    s->last_mv[1][1][0]= s->last_mv[1][0][0]= s->mv[1][0][0] = mx;
-                    s->last_mv[1][1][1]= s->last_mv[1][0][1]= s->mv[1][0][1] = my;
-                }
-            }else if(!IS_DIRECT(mb_type)){
-                s->mv_type= MV_TYPE_FIELD;
-
-                if(USES_LIST(mb_type, 0)){
-                    s->mv_dir = MV_DIR_FORWARD;
-                
-                    for(i=0; i<2; i++){
-                        mx = h263_decode_motion(s, s->last_mv[0][i][0]  , s->f_code);
-                        my = h263_decode_motion(s, s->last_mv[0][i][1]/2, s->f_code);
-                        s->last_mv[0][i][0]=  s->mv[0][i][0] = mx;
-                        s->last_mv[0][i][1]= (s->mv[0][i][1] = my)*2;
-                    }
-                }
-    
-                if(USES_LIST(mb_type, 1)){
-                    s->mv_dir |= MV_DIR_BACKWARD;
-
-                    for(i=0; i<2; i++){
-                        mx = h263_decode_motion(s, s->last_mv[1][i][0]  , s->b_code);
-                        my = h263_decode_motion(s, s->last_mv[1][i][1]/2, s->b_code);
-                        s->last_mv[1][i][0]=  s->mv[1][i][0] = mx;
-                        s->last_mv[1][i][1]= (s->mv[1][i][1] = my)*2;
-                    }
-                }
-            }
-        }
-          
-        if(IS_DIRECT(mb_type)){
-            if(IS_SKIP(mb_type))
-                mx=my=0;
-            else{
-                mx = h263_decode_motion(s, 0, 1);
-                my = h263_decode_motion(s, 0, 1);
-            }
- 
-            s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
-            mb_type |= ff_mpeg4_set_direct_mv(s, mx, my);
-        }
-        s->current_picture.mb_type[xy]= mb_type;
-    } else { /* I-Frame */
-        do{
-            cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
-            if (cbpc < 0){
-                av_log(s->avctx, AV_LOG_ERROR, "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-        }while(cbpc == 8);
-
-        dquant = cbpc & 4;
-        s->mb_intra = 1;
-intra:
-        s->ac_pred = get_bits1(&s->gb);
-        if(s->ac_pred)
-            s->current_picture.mb_type[xy]= MB_TYPE_INTRA | MB_TYPE_ACPRED;
-        else
-            s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
-        
-        cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
-        if(cbpy<0){
-            av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
-            return -1;
-        }
-        cbp = (cbpc & 3) | (cbpy << 2);
-        if (dquant) {
-            ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
-        }
-        
-        if(!s->progressive_sequence)
-            s->interlaced_dct= get_bits1(&s->gb);
-
-        s->dsp.clear_blocks(s->block[0]);
-        /* decode each block */
-        for (i = 0; i < 6; i++) {
-            if (mpeg4_decode_block(s, block[i], i, cbp&32, 1, 0) < 0)
-                return -1;
-            cbp+=cbp;
-        }
-        goto end;
-    }
-
-    /* decode each block */
-    for (i = 0; i < 6; i++) {
-        if (mpeg4_decode_block(s, block[i], i, cbp&32, 0, 0) < 0)
-            return -1;
-        cbp+=cbp;
-    }
-end:
-
-        /* per-MB end of slice check */
-    if(s->codec_id==CODEC_ID_MPEG4){
-        if(mpeg4_is_resync(s)){
-            const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1;
-            if(s->pict_type==B_TYPE && s->next_picture.mbskip_table[xy + delta])
-                return SLICE_OK;
-            return SLICE_END;
-        }
-    }
-
-    return SLICE_OK;     
-}
-
-static int h263_decode_motion(MpegEncContext * s, int pred, int f_code)
-{
-    int code, val, sign, shift, l;
-    code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2);
-
-    if (code == 0)
-        return pred;
-    if (code < 0)
-        return 0xffff;
-
-    sign = get_bits1(&s->gb);
-    shift = f_code - 1;
-    val = code;
-    if (shift) {
-        val = (val - 1) << shift;
-        val |= get_bits(&s->gb, shift);
-        val++;
-    }
-    if (sign)
-        val = -val;
-    val += pred;
-
-    /* modulo decoding */
-    if (!s->h263_long_vectors) {
-        l = INT_BIT - 5 - f_code;
-        val = (val<<l)>>l;
-    } else {
-        /* horrible h263 long vector mode */
-        if (pred < -31 && val < -63)
-            val += 64;
-        if (pred > 32 && val > 63)
-            val -= 64;
-        
-    }
-    return val;
-}
-
-/* Decodes RVLC of H.263+ UMV */
-static int h263p_decode_umotion(MpegEncContext * s, int pred)
-{
-   int code = 0, sign;
-   
-   if (get_bits1(&s->gb)) /* Motion difference = 0 */
-      return pred;
-   
-   code = 2 + get_bits1(&s->gb);
-   
-   while (get_bits1(&s->gb))
-   {
-      code <<= 1;
-      code += get_bits1(&s->gb);
-   }
-   sign = code & 1;
-   code >>= 1;
-   
-   code = (sign) ? (pred - code) : (pred + code);
-#ifdef DEBUG
-   av_log( s->avctx, AV_LOG_DEBUG,"H.263+ UMV Motion = %d\n", code);
-#endif
-   return code;   
-
-}
-
-static int h263_decode_block(MpegEncContext * s, DCTELEM * block,
-                             int n, int coded)
-{
-    int code, level, i, j, last, run;
-    RLTable *rl = &rl_inter;
-    const uint8_t *scan_table;
-    GetBitContext gb= s->gb;
-
-    scan_table = s->intra_scantable.permutated;
-    if (s->h263_aic && s->mb_intra) {
-        rl = &rl_intra_aic;
-        i = 0;
-        if (s->ac_pred) {
-            if (s->h263_aic_dir) 
-                scan_table = s->intra_v_scantable.permutated; /* left */
-            else
-                scan_table = s->intra_h_scantable.permutated; /* top */
-        }
-    } else if (s->mb_intra) {
-        /* DC coef */
-        if(s->codec_id == CODEC_ID_RV10){
-#ifdef CONFIG_RV10_DECODER
-          if (s->rv10_version == 3 && s->pict_type == I_TYPE) {
-            int component, diff;
-            component = (n <= 3 ? 0 : n - 4 + 1);
-            level = s->last_dc[component];
-            if (s->rv10_first_dc_coded[component]) {
-                diff = rv_decode_dc(s, n);
-                if (diff == 0xffff)
-                    return -1;
-                level += diff;
-                level = level & 0xff; /* handle wrap round */
-                s->last_dc[component] = level;
-            } else {
-                s->rv10_first_dc_coded[component] = 1;
-            }
-          } else {
-                level = get_bits(&s->gb, 8);
-                if (level == 255)
-                    level = 128;
-          }
-#endif
-        }else{
-            level = get_bits(&s->gb, 8);
-            if((level&0x7F) == 0){
-                av_log(s->avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n", level, s->mb_x, s->mb_y);
-                if(s->error_resilience >= FF_ER_COMPLIANT)
-                    return -1;
-            }
-            if (level == 255)
-                level = 128;
-        }
-        block[0] = level;
-        i = 1;
-    } else {
-        i = 0;
-    }
-    if (!coded) {
-        if (s->mb_intra && s->h263_aic)
-            goto not_coded;
-        s->block_last_index[n] = i - 1;
-        return 0;
-    }
-retry:
-    for(;;) {
-        code = get_vlc2(&s->gb, rl->vlc.table, TEX_VLC_BITS, 2);
-        if (code < 0){
-            av_log(s->avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n", s->mb_x, s->mb_y);
-            return -1;
-        }
-        if (code == rl->n) {
-            /* escape */
-            if (s->h263_flv > 1) {
-                int is11 = get_bits1(&s->gb);
-                last = get_bits1(&s->gb);
-                run = get_bits(&s->gb, 6);
-                if(is11){
-                    level = get_sbits(&s->gb, 11);
-                } else {
-                    level = get_sbits(&s->gb, 7);
-                }
-            } else {
-                last = get_bits1(&s->gb);
-                run = get_bits(&s->gb, 6);
-                level = (int8_t)get_bits(&s->gb, 8);
-                if(level == -128){
-                    if (s->codec_id == CODEC_ID_RV10) {
-                        /* XXX: should patch encoder too */
-                        level = get_sbits(&s->gb, 12);
-                    }else{
-                        level = get_bits(&s->gb, 5);
-                        level |= get_sbits(&s->gb, 6)<<5;
-                    }
-                }
-            }
-        } else {
-            run = rl->table_run[code];
-            level = rl->table_level[code];
-            last = code >= rl->last;
-            if (get_bits1(&s->gb))
-                level = -level;
-        }
-        i += run;
-        if (i >= 64){
-            if(s->alt_inter_vlc && rl == &rl_inter && !s->mb_intra){
-                //looks like a hack but no, it's the way its supposed to work ...
-                rl = &rl_intra_aic;
-                i = 0;
-                s->gb= gb;
-                memset(block, 0, sizeof(DCTELEM)*64);
-                goto retry;
-            }
-            av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d i:%d\n", s->mb_x, s->mb_y, s->mb_intra);
-            return -1;
-        }
-        j = scan_table[i];
-        block[j] = level;
-        if (last)
-            break;
-        i++;
-    }
-not_coded:    
-    if (s->mb_intra && s->h263_aic) {
-        h263_pred_acdc(s, block, n);
-        i = 63;
-    }
-    s->block_last_index[n] = i;
-    return 0;
-}
-
-/**
- * decodes the dc value.
- * @param n block index (0-3 are luma, 4-5 are chroma)
- * @param dir_ptr the prediction direction will be stored here
- * @return the quantized dc
- */
-static inline int mpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
-{
-    int level, code;
-
-    if (n < 4) 
-        code = get_vlc2(&s->gb, dc_lum.table, DC_VLC_BITS, 1);
-    else 
-        code = get_vlc2(&s->gb, dc_chrom.table, DC_VLC_BITS, 1);
-    if (code < 0 || code > 9 /* && s->nbit<9 */){
-        av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
-        return -1;
-    }
-    if (code == 0) {
-        level = 0;
-    } else {
-        if(IS_3IV1){
-            if(code==1)
-                level= 2*get_bits1(&s->gb)-1;
-            else{
-                if(get_bits1(&s->gb))
-                    level = get_bits(&s->gb, code-1) + (1<<(code-1));
-                else
-                    level = -get_bits(&s->gb, code-1) - (1<<(code-1));
-            }
-        }else{
-            level = get_xbits(&s->gb, code);
-        }
-
-        if (code > 8){
-            if(get_bits1(&s->gb)==0){ /* marker */
-                if(s->error_resilience>=2){
-                    av_log(s->avctx, AV_LOG_ERROR, "dc marker bit missing\n");
-                    return -1;
-                }
-            }
-        }
-    }
-
-    return ff_mpeg4_pred_dc(s, n, level, dir_ptr, 0);
-}
-
-/**
- * decodes a block.
- * @return <0 if an error occured
- */
-static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
-                              int n, int coded, int intra, int rvlc)
-{
-    int level, i, last, run;
-    int dc_pred_dir;
-    RLTable * rl;
-    RL_VLC_ELEM * rl_vlc;
-    const uint8_t * scan_table;
-    int qmul, qadd;
-
-    //Note intra & rvlc should be optimized away if this is inlined
-    
-    if(intra) {
-      if(s->qscale < s->intra_dc_threshold){
-	/* DC coef */
-        if(s->partitioned_frame){
-            level = s->dc_val[0][ s->block_index[n] ];
-            if(n<4) level= FASTDIV((level + (s->y_dc_scale>>1)), s->y_dc_scale);
-            else    level= FASTDIV((level + (s->c_dc_scale>>1)), s->c_dc_scale);
-            dc_pred_dir= (s->pred_dir_table[s->mb_x + s->mb_y*s->mb_stride]<<n)&32;
-        }else{
-            level = mpeg4_decode_dc(s, n, &dc_pred_dir);
-            if (level < 0)
-                return -1;
-        }
-        block[0] = level;
-        i = 0;
-      }else{
-            i = -1;
-      }  
-        if (!coded) 
-            goto not_coded;
-        
-        if(rvlc){        
-            rl = &rvlc_rl_intra;
-            rl_vlc = rvlc_rl_intra.rl_vlc[0];
-        }else{
-            rl = &rl_intra;
-            rl_vlc = rl_intra.rl_vlc[0];
-        }
-        if (s->ac_pred) {
-            if (dc_pred_dir == 0) 
-                scan_table = s->intra_v_scantable.permutated; /* left */
-            else
-                scan_table = s->intra_h_scantable.permutated; /* top */
-        } else {
-            scan_table = s->intra_scantable.permutated;
-        }
-        qmul=1;
-        qadd=0;
-    } else {
-        i = -1;
-        if (!coded) {
-            s->block_last_index[n] = i;
-            return 0;
-        }
-        if(rvlc) rl = &rvlc_rl_inter;
-        else     rl = &rl_inter;
-   
-        scan_table = s->intra_scantable.permutated;
-
-        if(s->mpeg_quant){
-            qmul=1;
-            qadd=0;
-            if(rvlc){        
-                rl_vlc = rvlc_rl_inter.rl_vlc[0];        
-            }else{
-                rl_vlc = rl_inter.rl_vlc[0];        
-            }
-        }else{
-            qmul = s->qscale << 1;
-            qadd = (s->qscale - 1) | 1;
-            if(rvlc){        
-                rl_vlc = rvlc_rl_inter.rl_vlc[s->qscale];        
-            }else{
-                rl_vlc = rl_inter.rl_vlc[s->qscale];        
-            }
-        }
-    }
-  {
-    OPEN_READER(re, &s->gb);
-    for(;;) {
-        UPDATE_CACHE(re, &s->gb);
-        GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
-        if (level==0) {
-          /* escape */                
-          if(rvlc){
-                if(SHOW_UBITS(re, &s->gb, 1)==0){
-                    av_log(s->avctx, AV_LOG_ERROR, "1. marker bit missing in rvlc esc\n");
-                    return -1;
-                }; SKIP_CACHE(re, &s->gb, 1);
- 
-                last=  SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
-                run=   SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6);
-                SKIP_COUNTER(re, &s->gb, 1+1+6);
-                UPDATE_CACHE(re, &s->gb);
-              
-                if(SHOW_UBITS(re, &s->gb, 1)==0){
-                    av_log(s->avctx, AV_LOG_ERROR, "2. marker bit missing in rvlc esc\n");
-                    return -1;
-                }; SKIP_CACHE(re, &s->gb, 1);
- 
-                level= SHOW_UBITS(re, &s->gb, 11); SKIP_CACHE(re, &s->gb, 11);
- 
-                if(SHOW_UBITS(re, &s->gb, 5)!=0x10){
-                    av_log(s->avctx, AV_LOG_ERROR, "reverse esc missing\n");
-                    return -1;
-                }; SKIP_CACHE(re, &s->gb, 5);
-
-                level=  level * qmul + qadd;
-                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_CACHE(re, &s->gb, 1);
-                SKIP_COUNTER(re, &s->gb, 1+11+5+1);
-
-                i+= run + 1;
-                if(last) i+=192;
-          }else{
-            int cache;
-            cache= GET_CACHE(re, &s->gb);
-
-            if(IS_3IV1) 
-                cache ^= 0xC0000000;
-
-            if (cache&0x80000000) {
-                if (cache&0x40000000) {
-                    /* third escape */
-                    SKIP_CACHE(re, &s->gb, 2);
-                    last=  SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
-                    run=   SHOW_UBITS(re, &s->gb, 6); LAST_SKIP_CACHE(re, &s->gb, 6);
-                    SKIP_COUNTER(re, &s->gb, 2+1+6);
-                    UPDATE_CACHE(re, &s->gb);
-
-                    if(IS_3IV1){
-                        level= SHOW_SBITS(re, &s->gb, 12); LAST_SKIP_BITS(re, &s->gb, 12);
-                    }else{
-                        if(SHOW_UBITS(re, &s->gb, 1)==0){
-                            av_log(s->avctx, AV_LOG_ERROR, "1. marker bit missing in 3. esc\n");
-                            return -1;
-                        }; SKIP_CACHE(re, &s->gb, 1);
-
-                        level= SHOW_SBITS(re, &s->gb, 12); SKIP_CACHE(re, &s->gb, 12);
-
-                        if(SHOW_UBITS(re, &s->gb, 1)==0){
-                            av_log(s->avctx, AV_LOG_ERROR, "2. marker bit missing in 3. esc\n");
-                            return -1;
-                        }; LAST_SKIP_CACHE(re, &s->gb, 1);
-
-                        SKIP_COUNTER(re, &s->gb, 1+12+1);
-                    }
- 
-#if 0
-                    if(s->error_resilience >= FF_ER_COMPLIANT){
-                        const int abs_level= ABS(level);
-                        if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
-                            const int run1= run - rl->max_run[last][abs_level] - 1;
-                            if(abs_level <= rl->max_level[last][run]){
-                                av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, vlc encoding possible\n");
-                                return -1;
-                            }
-                            if(s->error_resilience > FF_ER_COMPLIANT){
-                                if(abs_level <= rl->max_level[last][run]*2){
-                                    av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 1 encoding possible\n");
-                                    return -1;
-                                }
-                                if(run1 >= 0 && abs_level <= rl->max_level[last][run1]){
-                                    av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 2 encoding possible\n");
-                                    return -1;
-                                }
-                            }
-                        }
-                    }
-#endif
-		    if (level>0) level= level * qmul + qadd;
-                    else         level= level * qmul - qadd;
-
-                    if((unsigned)(level + 2048) > 4095){
-                        if(s->error_resilience > FF_ER_COMPLIANT){
-                            if(level > 2560 || level<-2560){
-                                av_log(s->avctx, AV_LOG_ERROR, "|level| overflow in 3. esc, qp=%d\n", s->qscale);
-                                return -1;
-                            }
-                        }
-                        level= level<0 ? -2048 : 2047;
-                    }
-
-                    i+= run + 1;
-                    if(last) i+=192;
-                } else {
-                    /* second escape */
-#if MIN_CACHE_BITS < 20
-                    LAST_SKIP_BITS(re, &s->gb, 2);
-                    UPDATE_CACHE(re, &s->gb);
-#else
-                    SKIP_BITS(re, &s->gb, 2);
-#endif
-                    GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
-                    i+= run + rl->max_run[run>>7][level/qmul] +1; //FIXME opt indexing
-                    level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
-                    LAST_SKIP_BITS(re, &s->gb, 1);
-                }
-            } else {
-                /* first escape */
-#if MIN_CACHE_BITS < 19
-                LAST_SKIP_BITS(re, &s->gb, 1);
-                UPDATE_CACHE(re, &s->gb);
-#else
-                SKIP_BITS(re, &s->gb, 1);
-#endif
-                GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
-                i+= run;
-                level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
-                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
-                LAST_SKIP_BITS(re, &s->gb, 1);
-            }
-          }
-        } else {
-            i+= run;
-            level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
-            LAST_SKIP_BITS(re, &s->gb, 1);
-        }
-        if (i > 62){
-            i-= 192;
-            if(i&(~63)){
-                av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-
-            block[scan_table[i]] = level;
-            break;
-        }
-
-        block[scan_table[i]] = level;
-    }
-    CLOSE_READER(re, &s->gb);
-  }
- not_coded:
-    if (intra) {
-        if(s->qscale >= s->intra_dc_threshold){
-            block[0] = ff_mpeg4_pred_dc(s, n, block[0], &dc_pred_dir, 0);
-            
-            if(i == -1) i=0;
-        }
-
-        mpeg4_pred_ac(s, block, n, dc_pred_dir);
-        if (s->ac_pred) {
-            i = 63; /* XXX: not optimal */
-        }
-    }
-    s->block_last_index[n] = i;
-    return 0;
-}
-
-/* most is hardcoded. should extend to handle all h263 streams */
-int h263_decode_picture_header(MpegEncContext *s)
-{
-    int format, width, height, i;
-    uint32_t startcode;
-    
-    align_get_bits(&s->gb);
-
-    startcode= get_bits(&s->gb, 22-8);
-
-    for(i= s->gb.size_in_bits - get_bits_count(&s->gb); i>24; i-=8) {
-        startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF;
-        
-        if(startcode == 0x20)
-            break;
-    }
-        
-    if (startcode != 0x20) {
-        av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
-        return -1;
-    }
-    /* temporal reference */
-    i = get_bits(&s->gb, 8); /* picture timestamp */
-    if( (s->picture_number&~0xFF)+i < s->picture_number)
-        i+= 256;
-    s->picture_number= (s->picture_number&~0xFF) + i;
-
-    /* PTYPE starts here */    
-    if (get_bits1(&s->gb) != 1) {
-        /* marker */
-        av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
-        return -1;
-    }
-    if (get_bits1(&s->gb) != 0) {
-        av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
-        return -1;	/* h263 id */
-    }
-    skip_bits1(&s->gb);	/* split screen off */
-    skip_bits1(&s->gb);	/* camera  off */
-    skip_bits1(&s->gb);	/* freeze picture release off */
-
-    format = get_bits(&s->gb, 3);
-    /*
-        0    forbidden
-        1    sub-QCIF
-        10   QCIF
-        7	extended PTYPE (PLUSPTYPE)
-    */
-
-    if (format != 7 && format != 6) {
-        s->h263_plus = 0;
-        /* H.263v1 */
-        width = h263_format[format][0];
-        height = h263_format[format][1];
-        if (!width)
-            return -1;
-        
-        s->pict_type = I_TYPE + get_bits1(&s->gb);
-
-        s->h263_long_vectors = get_bits1(&s->gb); 
-
-        if (get_bits1(&s->gb) != 0) {
-            av_log(s->avctx, AV_LOG_ERROR, "H263 SAC not supported\n");
-            return -1;	/* SAC: off */
-        }
-        s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
-        s->unrestricted_mv = s->h263_long_vectors || s->obmc;
-        
-        if (get_bits1(&s->gb) != 0) {
-            av_log(s->avctx, AV_LOG_ERROR, "H263 PB frame not supported\n");
-            return -1;	/* not PB frame */
-        }
-        s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
-        skip_bits1(&s->gb);	/* Continuous Presence Multipoint mode: off */
-
-        s->width = width;
-        s->height = height;
-        s->avctx->sample_aspect_ratio= (AVRational){12,11};
-        s->avctx->time_base= (AVRational){1001, 30000};
-    } else {
-        int ufep;
-        
-        /* H.263v2 */
-        s->h263_plus = 1;
-        ufep = get_bits(&s->gb, 3); /* Update Full Extended PTYPE */
-
-        /* ufep other than 0 and 1 are reserved */        
-        if (ufep == 1) {
-            /* OPPTYPE */       
-            format = get_bits(&s->gb, 3);
-            dprintf("ufep=1, format: %d\n", format);
-            s->custom_pcf= get_bits1(&s->gb);
-            s->umvplus = get_bits(&s->gb, 1); /* Unrestricted Motion Vector */
-            if (get_bits1(&s->gb) != 0) {
-                av_log(s->avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n");
-            }
-            s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
-            s->h263_aic = get_bits1(&s->gb); /* Advanced Intra Coding (AIC) */
-            s->loop_filter= get_bits1(&s->gb);
-            s->unrestricted_mv = s->umvplus || s->obmc || s->loop_filter;
-            
-            s->h263_slice_structured= get_bits1(&s->gb);
-            if (get_bits1(&s->gb) != 0) {
-                av_log(s->avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n");
-            }
-            if (get_bits1(&s->gb) != 0) {
-                av_log(s->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n");
-            }
-            s->alt_inter_vlc= get_bits1(&s->gb);
-            s->modified_quant= get_bits1(&s->gb);
-            if(s->modified_quant)
-                s->chroma_qscale_table= ff_h263_chroma_qscale_table;
-            
-            skip_bits(&s->gb, 1); /* Prevent start code emulation */
-
-            skip_bits(&s->gb, 3); /* Reserved */
-        } else if (ufep != 0) {
-            av_log(s->avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", ufep);
-            return -1;
-        }
-            
-        /* MPPTYPE */
-        s->pict_type = get_bits(&s->gb, 3);
-        switch(s->pict_type){
-        case 0: s->pict_type= I_TYPE;break;
-        case 1: s->pict_type= P_TYPE;break;
-        case 3: s->pict_type= B_TYPE;break;
-        case 7: s->pict_type= I_TYPE;break; //ZYGO
-        default:
-            return -1;
-        }
-        skip_bits(&s->gb, 2);
-        s->no_rounding = get_bits1(&s->gb);
-        skip_bits(&s->gb, 4);
-        
-        /* Get the picture dimensions */
-        if (ufep) {
-            if (format == 6) {
-                /* Custom Picture Format (CPFMT) */
-                s->aspect_ratio_info = get_bits(&s->gb, 4);
-                dprintf("aspect: %d\n", s->aspect_ratio_info);
-                /* aspect ratios:
-                0 - forbidden
-                1 - 1:1
-                2 - 12:11 (CIF 4:3)
-                3 - 10:11 (525-type 4:3)
-                4 - 16:11 (CIF 16:9)
-                5 - 40:33 (525-type 16:9)
-                6-14 - reserved
-                */
-                width = (get_bits(&s->gb, 9) + 1) * 4;
-                skip_bits1(&s->gb);
-                height = get_bits(&s->gb, 9) * 4;
-                dprintf("\nH.263+ Custom picture: %dx%d\n",width,height);
-                if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
-                    /* aspected dimensions */
-                    s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8);
-                    s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8);
-                }else{
-                    s->avctx->sample_aspect_ratio= pixel_aspect[s->aspect_ratio_info];
-                }
-            } else {
-                width = h263_format[format][0];
-                height = h263_format[format][1];
-                s->avctx->sample_aspect_ratio= (AVRational){12,11};
-            }
-            if ((width == 0) || (height == 0))
-                return -1;
-            s->width = width;
-            s->height = height;
-
-            if(s->custom_pcf){
-                int gcd;
-                s->avctx->time_base.den= 1800000;
-                s->avctx->time_base.num= 1000 + get_bits1(&s->gb);
-                s->avctx->time_base.num*= get_bits(&s->gb, 7);
-                if(s->avctx->time_base.num == 0){
-                    av_log(s, AV_LOG_ERROR, "zero framerate\n");
-                    return -1;
-                }
-                gcd= ff_gcd(s->avctx->time_base.den, s->avctx->time_base.num);
-                s->avctx->time_base.den /= gcd;
-                s->avctx->time_base.num /= gcd;
-//                av_log(s->avctx, AV_LOG_DEBUG, "%d/%d\n", s->avctx->time_base.den, s->avctx->time_base.num);
-            }else{
-                s->avctx->time_base= (AVRational){1001, 30000};
-            }
-        }
-            
-        if(s->custom_pcf){
-            skip_bits(&s->gb, 2); //extended Temporal reference
-        }
-
-        if (ufep) {
-            if (s->umvplus) {
-                if(get_bits1(&s->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
-                    skip_bits1(&s->gb); 
-            }
-            if(s->h263_slice_structured){
-                if (get_bits1(&s->gb) != 0) {
-                    av_log(s->avctx, AV_LOG_ERROR, "rectangular slices not supported\n");
-                }
-                if (get_bits1(&s->gb) != 0) {
-                    av_log(s->avctx, AV_LOG_ERROR, "unordered slices not supported\n");
-                }
-            }
-        }
-            
-        s->qscale = get_bits(&s->gb, 5);
-    }
-
-    s->mb_width = (s->width  + 15) / 16;
-    s->mb_height = (s->height  + 15) / 16;
-    s->mb_num = s->mb_width * s->mb_height;
-
-    /* PEI */
-    while (get_bits1(&s->gb) != 0) {
-        skip_bits(&s->gb, 8);
-    }
-
-    if(s->h263_slice_structured){
-        if (get_bits1(&s->gb) != 1) {
-            av_log(s->avctx, AV_LOG_ERROR, "SEPB1 marker missing\n");
-            return -1;
-        }
-
-        ff_h263_decode_mba(s);
-
-        if (get_bits1(&s->gb) != 1) {
-            av_log(s->avctx, AV_LOG_ERROR, "SEPB2 marker missing\n");
-            return -1;
-        }
-    }
-    s->f_code = 1;
-    
-    if(s->h263_aic){
-         s->y_dc_scale_table= 
-         s->c_dc_scale_table= ff_aic_dc_scale_table;
-    }else{
-        s->y_dc_scale_table=
-        s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
-    }
-
-     if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-         av_log(s->avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d%s%s%s%s%s%s%s%s%s %d/%d\n", 
-         s->qscale, av_get_pict_type_char(s->pict_type),
-         s->gb.size_in_bits, 1-s->no_rounding,
-         s->obmc ? " AP" : "",
-         s->umvplus ? " UMV" : "",
-         s->h263_long_vectors ? " LONG" : "",
-         s->h263_plus ? " +" : "",
-         s->h263_aic ? " AIC" : "",
-         s->alt_inter_vlc ? " AIV" : "",
-         s->modified_quant ? " MQ" : "",
-         s->loop_filter ? " LOOP" : "",
-         s->h263_slice_structured ? " SS" : "",
-         s->avctx->time_base.den, s->avctx->time_base.num
-         ); 
-     }
-#if 1
-    if (s->pict_type == I_TYPE && s->avctx->codec_tag == ff_get_fourcc("ZYGO")){
-        int i,j;
-        for(i=0; i<85; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
-        av_log(s->avctx, AV_LOG_DEBUG, "\n");
-        for(i=0; i<13; i++){
-            for(j=0; j<3; j++){
-                int v= get_bits(&s->gb, 8);
-                v |= get_sbits(&s->gb, 8)<<8;
-                av_log(s->avctx, AV_LOG_DEBUG, " %5d", v);
-            }
-            av_log(s->avctx, AV_LOG_DEBUG, "\n");
-        }
-        for(i=0; i<50; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
-    }
-#endif
-
-    return 0;
-}
-
-static void mpeg4_decode_sprite_trajectory(MpegEncContext * s, GetBitContext *gb)
-{
-    int i;
-    int a= 2<<s->sprite_warping_accuracy;
-    int rho= 3-s->sprite_warping_accuracy;
-    int r=16/a;
-    const int vop_ref[4][2]= {{0,0}, {s->width,0}, {0, s->height}, {s->width, s->height}}; // only true for rectangle shapes
-    int d[4][2]={{0,0}, {0,0}, {0,0}, {0,0}};
-    int sprite_ref[4][2];
-    int virtual_ref[2][2];
-    int w2, h2, w3, h3;
-    int alpha=0, beta=0;
-    int w= s->width;
-    int h= s->height;
-    int min_ab;
-
-    for(i=0; i<s->num_sprite_warping_points; i++){
-        int length;
-        int x=0, y=0;
-
-        length= get_vlc(gb, &sprite_trajectory);
-        if(length){
-            x= get_xbits(gb, length);
-        }
-        if(!(s->divx_version==500 && s->divx_build==413)) skip_bits1(gb); /* marker bit */
-        
-        length= get_vlc(gb, &sprite_trajectory);
-        if(length){
-            y=get_xbits(gb, length);
-        }
-        skip_bits1(gb); /* marker bit */
-//printf("%d %d %d %d\n", x, y, i, s->sprite_warping_accuracy);
-        d[i][0]= x;
-        d[i][1]= y;
-    }
-
-    while((1<<alpha)<w) alpha++;
-    while((1<<beta )<h) beta++; // there seems to be a typo in the mpeg4 std for the definition of w' and h'
-    w2= 1<<alpha;
-    h2= 1<<beta;
-
-// Note, the 4th point isn't used for GMC
-    if(s->divx_version==500 && s->divx_build==413){
-        sprite_ref[0][0]= a*vop_ref[0][0] + d[0][0];
-        sprite_ref[0][1]= a*vop_ref[0][1] + d[0][1];
-        sprite_ref[1][0]= a*vop_ref[1][0] + d[0][0] + d[1][0];
-        sprite_ref[1][1]= a*vop_ref[1][1] + d[0][1] + d[1][1];
-        sprite_ref[2][0]= a*vop_ref[2][0] + d[0][0] + d[2][0];
-        sprite_ref[2][1]= a*vop_ref[2][1] + d[0][1] + d[2][1];
-    } else {
-        sprite_ref[0][0]= (a>>1)*(2*vop_ref[0][0] + d[0][0]);
-        sprite_ref[0][1]= (a>>1)*(2*vop_ref[0][1] + d[0][1]);
-        sprite_ref[1][0]= (a>>1)*(2*vop_ref[1][0] + d[0][0] + d[1][0]);
-        sprite_ref[1][1]= (a>>1)*(2*vop_ref[1][1] + d[0][1] + d[1][1]);
-        sprite_ref[2][0]= (a>>1)*(2*vop_ref[2][0] + d[0][0] + d[2][0]);
-        sprite_ref[2][1]= (a>>1)*(2*vop_ref[2][1] + d[0][1] + d[2][1]);
-    }
-/*    sprite_ref[3][0]= (a>>1)*(2*vop_ref[3][0] + d[0][0] + d[1][0] + d[2][0] + d[3][0]);
-    sprite_ref[3][1]= (a>>1)*(2*vop_ref[3][1] + d[0][1] + d[1][1] + d[2][1] + d[3][1]); */
-    
-// this is mostly identical to the mpeg4 std (and is totally unreadable because of that ...)
-// perhaps it should be reordered to be more readable ...
-// the idea behind this virtual_ref mess is to be able to use shifts later per pixel instead of divides
-// so the distance between points is converted from w&h based to w2&h2 based which are of the 2^x form
-    virtual_ref[0][0]= 16*(vop_ref[0][0] + w2) 
-        + ROUNDED_DIV(((w - w2)*(r*sprite_ref[0][0] - 16*vop_ref[0][0]) + w2*(r*sprite_ref[1][0] - 16*vop_ref[1][0])),w);
-    virtual_ref[0][1]= 16*vop_ref[0][1] 
-        + ROUNDED_DIV(((w - w2)*(r*sprite_ref[0][1] - 16*vop_ref[0][1]) + w2*(r*sprite_ref[1][1] - 16*vop_ref[1][1])),w);
-    virtual_ref[1][0]= 16*vop_ref[0][0] 
-        + ROUNDED_DIV(((h - h2)*(r*sprite_ref[0][0] - 16*vop_ref[0][0]) + h2*(r*sprite_ref[2][0] - 16*vop_ref[2][0])),h);
-    virtual_ref[1][1]= 16*(vop_ref[0][1] + h2) 
-        + ROUNDED_DIV(((h - h2)*(r*sprite_ref[0][1] - 16*vop_ref[0][1]) + h2*(r*sprite_ref[2][1] - 16*vop_ref[2][1])),h);
-        
-    switch(s->num_sprite_warping_points)
-    {
-        case 0:
-            s->sprite_offset[0][0]= 0;
-            s->sprite_offset[0][1]= 0;
-            s->sprite_offset[1][0]= 0;
-            s->sprite_offset[1][1]= 0;
-            s->sprite_delta[0][0]= a;
-            s->sprite_delta[0][1]= 0;
-            s->sprite_delta[1][0]= 0;
-            s->sprite_delta[1][1]= a;
-            s->sprite_shift[0]= 0;
-            s->sprite_shift[1]= 0;
-            break;
-        case 1: //GMC only
-            s->sprite_offset[0][0]= sprite_ref[0][0] - a*vop_ref[0][0];
-            s->sprite_offset[0][1]= sprite_ref[0][1] - a*vop_ref[0][1];
-            s->sprite_offset[1][0]= ((sprite_ref[0][0]>>1)|(sprite_ref[0][0]&1)) - a*(vop_ref[0][0]/2);
-            s->sprite_offset[1][1]= ((sprite_ref[0][1]>>1)|(sprite_ref[0][1]&1)) - a*(vop_ref[0][1]/2);
-            s->sprite_delta[0][0]= a;
-            s->sprite_delta[0][1]= 0;
-            s->sprite_delta[1][0]= 0;
-            s->sprite_delta[1][1]= a;
-            s->sprite_shift[0]= 0;
-            s->sprite_shift[1]= 0;
-            break;
-        case 2:
-            s->sprite_offset[0][0]= (sprite_ref[0][0]<<(alpha+rho))
-                                                  + (-r*sprite_ref[0][0] + virtual_ref[0][0])*(-vop_ref[0][0])
-                                                  + ( r*sprite_ref[0][1] - virtual_ref[0][1])*(-vop_ref[0][1])
-                                                  + (1<<(alpha+rho-1));
-            s->sprite_offset[0][1]= (sprite_ref[0][1]<<(alpha+rho))
-                                                  + (-r*sprite_ref[0][1] + virtual_ref[0][1])*(-vop_ref[0][0])
-                                                  + (-r*sprite_ref[0][0] + virtual_ref[0][0])*(-vop_ref[0][1])
-                                                  + (1<<(alpha+rho-1));
-            s->sprite_offset[1][0]= ( (-r*sprite_ref[0][0] + virtual_ref[0][0])*(-2*vop_ref[0][0] + 1)
-                                     +( r*sprite_ref[0][1] - virtual_ref[0][1])*(-2*vop_ref[0][1] + 1)
-                                     +2*w2*r*sprite_ref[0][0] 
-                                     - 16*w2 
-                                     + (1<<(alpha+rho+1)));
-            s->sprite_offset[1][1]= ( (-r*sprite_ref[0][1] + virtual_ref[0][1])*(-2*vop_ref[0][0] + 1) 
-                                     +(-r*sprite_ref[0][0] + virtual_ref[0][0])*(-2*vop_ref[0][1] + 1)
-                                     +2*w2*r*sprite_ref[0][1] 
-                                     - 16*w2
-                                     + (1<<(alpha+rho+1)));
-            s->sprite_delta[0][0]=   (-r*sprite_ref[0][0] + virtual_ref[0][0]);
-            s->sprite_delta[0][1]=   (+r*sprite_ref[0][1] - virtual_ref[0][1]);
-            s->sprite_delta[1][0]=   (-r*sprite_ref[0][1] + virtual_ref[0][1]);
-            s->sprite_delta[1][1]=   (-r*sprite_ref[0][0] + virtual_ref[0][0]);
-            
-            s->sprite_shift[0]= alpha+rho;
-            s->sprite_shift[1]= alpha+rho+2;
-            break;
-        case 3:
-            min_ab= FFMIN(alpha, beta);
-            w3= w2>>min_ab;
-            h3= h2>>min_ab;
-            s->sprite_offset[0][0]=  (sprite_ref[0][0]<<(alpha+beta+rho-min_ab))
-                                   + (-r*sprite_ref[0][0] + virtual_ref[0][0])*h3*(-vop_ref[0][0])
-                                   + (-r*sprite_ref[0][0] + virtual_ref[1][0])*w3*(-vop_ref[0][1])
-                                   + (1<<(alpha+beta+rho-min_ab-1));
-            s->sprite_offset[0][1]=  (sprite_ref[0][1]<<(alpha+beta+rho-min_ab))
-                                   + (-r*sprite_ref[0][1] + virtual_ref[0][1])*h3*(-vop_ref[0][0])
-                                   + (-r*sprite_ref[0][1] + virtual_ref[1][1])*w3*(-vop_ref[0][1])
-                                   + (1<<(alpha+beta+rho-min_ab-1));
-            s->sprite_offset[1][0]=  (-r*sprite_ref[0][0] + virtual_ref[0][0])*h3*(-2*vop_ref[0][0] + 1)
-                                   + (-r*sprite_ref[0][0] + virtual_ref[1][0])*w3*(-2*vop_ref[0][1] + 1)
-                                   + 2*w2*h3*r*sprite_ref[0][0]
-                                   - 16*w2*h3
-                                   + (1<<(alpha+beta+rho-min_ab+1));
-            s->sprite_offset[1][1]=  (-r*sprite_ref[0][1] + virtual_ref[0][1])*h3*(-2*vop_ref[0][0] + 1)
-                                   + (-r*sprite_ref[0][1] + virtual_ref[1][1])*w3*(-2*vop_ref[0][1] + 1)
-                                   + 2*w2*h3*r*sprite_ref[0][1]
-                                   - 16*w2*h3
-                                   + (1<<(alpha+beta+rho-min_ab+1));
-            s->sprite_delta[0][0]=   (-r*sprite_ref[0][0] + virtual_ref[0][0])*h3;
-            s->sprite_delta[0][1]=   (-r*sprite_ref[0][0] + virtual_ref[1][0])*w3;
-            s->sprite_delta[1][0]=   (-r*sprite_ref[0][1] + virtual_ref[0][1])*h3;
-            s->sprite_delta[1][1]=   (-r*sprite_ref[0][1] + virtual_ref[1][1])*w3;
-                                   
-            s->sprite_shift[0]= alpha + beta + rho - min_ab;
-            s->sprite_shift[1]= alpha + beta + rho - min_ab + 2;
-            break;
-    }
-    /* try to simplify the situation */ 
-    if(   s->sprite_delta[0][0] == a<<s->sprite_shift[0]
-       && s->sprite_delta[0][1] == 0
-       && s->sprite_delta[1][0] == 0
-       && s->sprite_delta[1][1] == a<<s->sprite_shift[0])
-    {
-        s->sprite_offset[0][0]>>=s->sprite_shift[0];
-        s->sprite_offset[0][1]>>=s->sprite_shift[0];
-        s->sprite_offset[1][0]>>=s->sprite_shift[1];
-        s->sprite_offset[1][1]>>=s->sprite_shift[1];
-        s->sprite_delta[0][0]= a;
-        s->sprite_delta[0][1]= 0;
-        s->sprite_delta[1][0]= 0;
-        s->sprite_delta[1][1]= a;
-        s->sprite_shift[0]= 0;
-        s->sprite_shift[1]= 0;
-        s->real_sprite_warping_points=1;
-    }
-    else{
-        int shift_y= 16 - s->sprite_shift[0];
-        int shift_c= 16 - s->sprite_shift[1];
-//printf("shifts %d %d\n", shift_y, shift_c);
-        for(i=0; i<2; i++){
-            s->sprite_offset[0][i]<<= shift_y;
-            s->sprite_offset[1][i]<<= shift_c;
-            s->sprite_delta[0][i]<<= shift_y;
-            s->sprite_delta[1][i]<<= shift_y;
-            s->sprite_shift[i]= 16;
-        }
-        s->real_sprite_warping_points= s->num_sprite_warping_points;
-    }
-#if 0
-printf("vop:%d:%d %d:%d %d:%d, sprite:%d:%d %d:%d %d:%d, virtual: %d:%d %d:%d\n",
-    vop_ref[0][0], vop_ref[0][1],
-    vop_ref[1][0], vop_ref[1][1],
-    vop_ref[2][0], vop_ref[2][1],
-    sprite_ref[0][0], sprite_ref[0][1], 
-    sprite_ref[1][0], sprite_ref[1][1], 
-    sprite_ref[2][0], sprite_ref[2][1], 
-    virtual_ref[0][0], virtual_ref[0][1], 
-    virtual_ref[1][0], virtual_ref[1][1]
-    );
-    
-printf("offset: %d:%d , delta: %d %d %d %d, shift %d\n",
-    s->sprite_offset[0][0], s->sprite_offset[0][1],
-    s->sprite_delta[0][0], s->sprite_delta[0][1],
-    s->sprite_delta[1][0], s->sprite_delta[1][1],
-    s->sprite_shift[0]
-    );
-#endif
-}
-
-static int mpeg4_decode_gop_header(MpegEncContext * s, GetBitContext *gb){
-    int hours, minutes, seconds;
-
-    hours= get_bits(gb, 5);
-    minutes= get_bits(gb, 6);
-    skip_bits1(gb);
-    seconds= get_bits(gb, 6);
-
-    s->time_base= seconds + 60*(minutes + 60*hours);
-
-    skip_bits1(gb);
-    skip_bits1(gb);
-    
-    return 0;
-}
-
-static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
-    int width, height, vo_ver_id;
-
-    /* vol header */
-    skip_bits(gb, 1); /* random access */
-    s->vo_type= get_bits(gb, 8);
-    if (get_bits1(gb) != 0) { /* is_ol_id */
-        vo_ver_id = get_bits(gb, 4); /* vo_ver_id */
-        skip_bits(gb, 3); /* vo_priority */
-    } else {
-        vo_ver_id = 1;
-    }
-//printf("vo type:%d\n",s->vo_type);
-    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= pixel_aspect[s->aspect_ratio_info];
-    }
-
-    if ((s->vol_control_parameters=get_bits1(gb))) { /* vol control parameter */
-        int chroma_format= get_bits(gb, 2);
-        if(chroma_format!=1){
-            av_log(s->avctx, AV_LOG_ERROR, "illegal chroma format\n");
-        }
-        s->low_delay= get_bits1(gb);
-        if(get_bits1(gb)){ /* vbv parameters */
-            get_bits(gb, 15);	/* first_half_bitrate */
-            skip_bits1(gb);	/* marker */
-            get_bits(gb, 15);	/* latter_half_bitrate */
-            skip_bits1(gb);	/* marker */
-            get_bits(gb, 15);	/* first_half_vbv_buffer_size */
-            skip_bits1(gb);	/* marker */
-            get_bits(gb, 3);	/* latter_half_vbv_buffer_size */
-            get_bits(gb, 11);	/* first_half_vbv_occupancy */
-            skip_bits1(gb);	/* marker */
-            get_bits(gb, 15);	/* latter_half_vbv_occupancy */
-            skip_bits1(gb);	/* marker */               
-        }
-    }else{
-        // set low delay flag only once the smartest? low delay detection won't be overriden
-        if(s->picture_number==0)
-            s->low_delay=0;
-    }
-
-    s->shape = get_bits(gb, 2); /* vol shape */
-    if(s->shape != RECT_SHAPE) av_log(s->avctx, AV_LOG_ERROR, "only rectangular vol supported\n");
-    if(s->shape == GRAY_SHAPE && vo_ver_id != 1){
-        av_log(s->avctx, AV_LOG_ERROR, "Gray shape not supported\n");
-        skip_bits(gb, 4);  //video_object_layer_shape_extension
-    }
-
-    check_marker(gb, "before time_increment_resolution");
-    
-    s->avctx->time_base.den = get_bits(gb, 16);
-    if(!s->avctx->time_base.den){
-        av_log(s->avctx, AV_LOG_ERROR, "time_base.den==0\n");
-        return -1;
-    }
-    
-    s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
-    if (s->time_increment_bits < 1)
-        s->time_increment_bits = 1;
-        
-    check_marker(gb, "before fixed_vop_rate");
-
-    if (get_bits1(gb) != 0) {   /* fixed_vop_rate  */
-        s->avctx->time_base.num = get_bits(gb, s->time_increment_bits);
-    }else
-        s->avctx->time_base.num = 1;
-
-    s->t_frame=0;
-
-    if (s->shape != BIN_ONLY_SHAPE) {
-        if (s->shape == RECT_SHAPE) {
-            skip_bits1(gb);   /* marker */
-            width = get_bits(gb, 13);
-            skip_bits1(gb);   /* marker */
-            height = get_bits(gb, 13);
-            skip_bits1(gb);   /* marker */
-            if(width && height && !(s->width && s->avctx->codec_tag == ff_get_fourcc("MP4S"))){ /* they should be non zero but who knows ... */
-                s->width = width;
-                s->height = height;
-//                printf("width/height: %d %d\n", width, height);
-            }
-        }
-        
-        s->progressive_sequence= 
-        s->progressive_frame= get_bits1(gb)^1;
-        if(!get_bits1(gb) && (s->avctx->debug & FF_DEBUG_PICT_INFO)) 
-            av_log(s->avctx, AV_LOG_INFO, "MPEG4 OBMC not supported (very likely buggy encoder)\n");   /* OBMC Disable */
-        if (vo_ver_id == 1) {
-            s->vol_sprite_usage = get_bits1(gb); /* vol_sprite_usage */
-        } else {
-            s->vol_sprite_usage = get_bits(gb, 2); /* vol_sprite_usage */
-        }
-        if(s->vol_sprite_usage==STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "Static Sprites not supported\n");
-        if(s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE){
-            if(s->vol_sprite_usage==STATIC_SPRITE){
-                s->sprite_width = get_bits(gb, 13);
-                skip_bits1(gb); /* marker */
-                s->sprite_height= get_bits(gb, 13);
-                skip_bits1(gb); /* marker */
-                s->sprite_left  = get_bits(gb, 13);
-                skip_bits1(gb); /* marker */
-                s->sprite_top   = get_bits(gb, 13);
-                skip_bits1(gb); /* marker */
-            }
-            s->num_sprite_warping_points= get_bits(gb, 6);
-            s->sprite_warping_accuracy = get_bits(gb, 2);
-            s->sprite_brightness_change= get_bits1(gb);
-            if(s->vol_sprite_usage==STATIC_SPRITE)
-                s->low_latency_sprite= get_bits1(gb);            
-        }
-        // FIXME sadct disable bit if verid!=1 && shape not rect
-        
-        if (get_bits1(gb) == 1) {   /* not_8_bit */
-            s->quant_precision = get_bits(gb, 4); /* quant_precision */
-            if(get_bits(gb, 4)!=8) av_log(s->avctx, AV_LOG_ERROR, "N-bit not supported\n"); /* bits_per_pixel */
-            if(s->quant_precision!=5) av_log(s->avctx, AV_LOG_ERROR, "quant precision %d\n", s->quant_precision);
-        } else {
-            s->quant_precision = 5;
-        }
-        
-        // FIXME a bunch of grayscale shape things
-
-        if((s->mpeg_quant=get_bits1(gb))){ /* vol_quant_type */
-            int i, v;
-            
-            /* load default matrixes */
-            for(i=0; i<64; i++){
-                int j= s->dsp.idct_permutation[i];
-                v= ff_mpeg4_default_intra_matrix[i];
-                s->intra_matrix[j]= v;
-                s->chroma_intra_matrix[j]= v;
-                
-                v= ff_mpeg4_default_non_intra_matrix[i];
-                s->inter_matrix[j]= v;
-                s->chroma_inter_matrix[j]= v;
-            }
-
-            /* load custom intra matrix */
-            if(get_bits1(gb)){
-                int last=0;
-		for(i=0; i<64; i++){
-                    int j;
-                    v= get_bits(gb, 8);
-                    if(v==0) break;
-                    
-                    last= v;
-                    j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
-                    s->intra_matrix[j]= v;
-                    s->chroma_intra_matrix[j]= v;
-                }
-
-                /* replicate last value */
-                for(; i<64; i++){
-		    int j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
-                    s->intra_matrix[j]= last;
-                    s->chroma_intra_matrix[j]= last;
-                }
-            }
-
-            /* load custom non intra matrix */
-            if(get_bits1(gb)){
-                int last=0;
-		for(i=0; i<64; i++){
-                    int j;
-                    v= get_bits(gb, 8);
-                    if(v==0) break;
-
-                    last= v;
-                    j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
-                    s->inter_matrix[j]= v;
-                    s->chroma_inter_matrix[j]= v;
-                }
-
-                /* replicate last value */
-                for(; i<64; i++){
-		    int j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
-                    s->inter_matrix[j]= last;
-                    s->chroma_inter_matrix[j]= last;
-                }
-            }
-
-            // FIXME a bunch of grayscale shape things
-        }
-
-        if(vo_ver_id != 1)
-             s->quarter_sample= get_bits1(gb);
-        else s->quarter_sample=0;
-
-        if(!get_bits1(gb)) av_log(s->avctx, AV_LOG_ERROR, "Complexity estimation not supported\n");
-
-        s->resync_marker= !get_bits1(gb); /* resync_marker_disabled */
-
-        s->data_partitioning= get_bits1(gb);
-        if(s->data_partitioning){
-            s->rvlc= get_bits1(gb);
-        }
-        
-        if(vo_ver_id != 1) {
-            s->new_pred= get_bits1(gb);
-            if(s->new_pred){
-                av_log(s->avctx, AV_LOG_ERROR, "new pred not supported\n");
-                skip_bits(gb, 2); /* requested upstream message type */
-                skip_bits1(gb); /* newpred segment type */
-            }
-            s->reduced_res_vop= get_bits1(gb);
-            if(s->reduced_res_vop) av_log(s->avctx, AV_LOG_ERROR, "reduced resolution VOP not supported\n");
-        }
-        else{
-            s->new_pred=0;
-            s->reduced_res_vop= 0;
-        }
-
-        s->scalability= get_bits1(gb);
-
-        if (s->scalability) {
-            GetBitContext bak= *gb;
-            int ref_layer_id;
-            int ref_layer_sampling_dir;
-            int h_sampling_factor_n;
-            int h_sampling_factor_m;
-            int v_sampling_factor_n;
-            int v_sampling_factor_m;
-            
-            s->hierachy_type= get_bits1(gb);
-            ref_layer_id= get_bits(gb, 4);
-            ref_layer_sampling_dir= get_bits1(gb);
-            h_sampling_factor_n= get_bits(gb, 5);
-            h_sampling_factor_m= get_bits(gb, 5);
-            v_sampling_factor_n= get_bits(gb, 5);
-            v_sampling_factor_m= get_bits(gb, 5);
-            s->enhancement_type= get_bits1(gb);
-            
-            if(   h_sampling_factor_n==0 || h_sampling_factor_m==0 
-               || v_sampling_factor_n==0 || v_sampling_factor_m==0){
-               
-//                fprintf(stderr, "illegal scalability header (VERY broken encoder), trying to workaround\n");
-                s->scalability=0;
-               
-                *gb= bak;
-            }else
-                av_log(s->avctx, AV_LOG_ERROR, "scalability not supported\n");
-            
-            // bin shape stuff FIXME
-        }
-    }
-    return 0;
-}
-
-/**
- * decodes the user data stuff in the header.
- * allso inits divx/xvid/lavc_version/build
- */
-static int decode_user_data(MpegEncContext *s, GetBitContext *gb){
-    char buf[256];
-    int i;
-    int e;
-    int ver, build, ver2, ver3;
-    char last;
-
-    for(i=0; i<255; i++){
-        if(show_bits(gb, 23) == 0) break;
-        buf[i]= get_bits(gb, 8);
-    }
-    buf[i]=0;
-
-    /* divx detection */
-    e=sscanf(buf, "DivX%dBuild%d%c", &ver, &build, &last);
-    if(e<2)
-        e=sscanf(buf, "DivX%db%d%c", &ver, &build, &last);
-    if(e>=2){
-        s->divx_version= ver;
-        s->divx_build= build;
-        s->divx_packed= e==3 && last=='p';
-    }
-    
-    /* ffmpeg detection */
-    e=sscanf(buf, "FFmpe%*[^b]b%d", &build)+3;
-    if(e!=4)
-        e=sscanf(buf, "FFmpeg v%d.%d.%d / libavcodec build: %d", &ver, &ver2, &ver3, &build); 
-    if(e!=4){
-        e=sscanf(buf, "Lavc%d.%d.%d", &ver, &ver2, &ver3)+1;
-        build= (ver<<16) + (ver2<<8) + ver3;
-    }
-    if(e!=4){
-        if(strcmp(buf, "ffmpeg")==0){
-            s->lavc_build= 4600;
-        }
-    }
-    if(e==4){
-        s->lavc_build= build;
-    }
-    
-    /* xvid detection */
-    e=sscanf(buf, "XviD%d", &build);
-    if(e==1){
-        s->xvid_build= build;
-    }
-
-//printf("User Data: %s\n", buf);
-    return 0;
-}
-
-static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
-    int time_incr, time_increment;
-
-    s->pict_type = get_bits(gb, 2) + I_TYPE;	/* pict type: I = 0 , P = 1 */
-    if(s->pict_type==B_TYPE && s->low_delay && s->vol_control_parameters==0 && !(s->flags & CODEC_FLAG_LOW_DELAY)){
-        av_log(s->avctx, AV_LOG_ERROR, "low_delay flag incorrectly, clearing it\n");
-        s->low_delay=0;
-    }
- 
-    s->partitioned_frame= s->data_partitioning && s->pict_type!=B_TYPE;
-    if(s->partitioned_frame)
-        s->decode_mb= mpeg4_decode_partitioned_mb;
-    else
-        s->decode_mb= ff_mpeg4_decode_mb;
-
-    time_incr=0;
-    while (get_bits1(gb) != 0) 
-        time_incr++;
-
-    check_marker(gb, "before time_increment");
-
-    if(s->time_increment_bits==0 || !(show_bits(gb, s->time_increment_bits+1)&1)){
-        av_log(s->avctx, AV_LOG_ERROR, "hmm, seems the headers are not complete, trying to guess time_increment_bits\n");
-
-        for(s->time_increment_bits=1 ;s->time_increment_bits<16; s->time_increment_bits++){
-            if(show_bits(gb, s->time_increment_bits+1)&1) break;
-        }
-
-        av_log(s->avctx, AV_LOG_ERROR, "my guess is %d bits ;)\n",s->time_increment_bits);
-    }
-    
-    if(IS_3IV1) time_increment= get_bits1(gb); //FIXME investigate further
-    else time_increment= get_bits(gb, s->time_increment_bits);
-    
-//    printf("%d %X\n", s->time_increment_bits, time_increment);
-//av_log(s->avctx, AV_LOG_DEBUG, " type:%d modulo_time_base:%d increment:%d t_frame %d\n", s->pict_type, time_incr, time_increment, s->t_frame);
-    if(s->pict_type!=B_TYPE){
-        s->last_time_base= s->time_base;
-        s->time_base+= time_incr;
-        s->time= s->time_base*s->avctx->time_base.den + time_increment;
-        if(s->workaround_bugs&FF_BUG_UMP4){
-            if(s->time < s->last_non_b_time){
-//                fprintf(stderr, "header is not mpeg4 compatible, broken encoder, trying to workaround\n");
-                s->time_base++;
-                s->time+= s->avctx->time_base.den;
-            }
-        }
-        s->pp_time= s->time - s->last_non_b_time;
-        s->last_non_b_time= s->time;
-    }else{
-        s->time= (s->last_time_base + time_incr)*s->avctx->time_base.den + time_increment;
-        s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
-        if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){
-//            printf("messed up order, maybe after seeking? skipping current b frame\n");
-            return FRAME_SKIPPED;
-        }
-        
-        if(s->t_frame==0) s->t_frame= s->pb_time;
-        if(s->t_frame==0) s->t_frame=1; // 1/0 protection
-        s->pp_field_time= (  ROUNDED_DIV(s->last_non_b_time, s->t_frame) 
-                           - ROUNDED_DIV(s->last_non_b_time - s->pp_time, s->t_frame))*2;
-        s->pb_field_time= (  ROUNDED_DIV(s->time, s->t_frame) 
-                           - ROUNDED_DIV(s->last_non_b_time - s->pp_time, s->t_frame))*2;
-    }
-//av_log(s->avctx, AV_LOG_DEBUG, "last nonb %Ld last_base %d time %Ld pp %d pb %d t %d ppf %d pbf %d\n", s->last_non_b_time, s->last_time_base, s->time, s->pp_time, s->pb_time, s->t_frame, s->pp_field_time, s->pb_field_time);
-    
-    if(s->avctx->time_base.num)
-        s->current_picture_ptr->pts= (s->time + s->avctx->time_base.num/2) / s->avctx->time_base.num;
-    else
-        s->current_picture_ptr->pts= AV_NOPTS_VALUE;
-    if(s->avctx->debug&FF_DEBUG_PTS)
-        av_log(s->avctx, AV_LOG_DEBUG, "MPEG4 PTS: %Ld\n", s->current_picture_ptr->pts);
-
-    check_marker(gb, "before vop_coded");
-    
-    /* vop coded */
-    if (get_bits1(gb) != 1){
-        if(s->avctx->debug&FF_DEBUG_PICT_INFO)
-            av_log(s->avctx, AV_LOG_ERROR, "vop not coded\n");
-        return FRAME_SKIPPED;
-    }
-//printf("time %d %d %d || %Ld %Ld %Ld\n", s->time_increment_bits, s->avctx->time_base.den, s->time_base,
-//s->time, s->last_non_b_time, s->last_non_b_time - s->pp_time);  
-    if (s->shape != BIN_ONLY_SHAPE && ( s->pict_type == P_TYPE
-                          || (s->pict_type == S_TYPE && s->vol_sprite_usage==GMC_SPRITE))) {
-        /* rounding type for motion estimation */
-	s->no_rounding = get_bits1(gb);
-    } else {
-	s->no_rounding = 0;
-    }
-//FIXME reduced res stuff
-
-     if (s->shape != RECT_SHAPE) {
-         if (s->vol_sprite_usage != 1 || s->pict_type != I_TYPE) {
-             int width, height, hor_spat_ref, ver_spat_ref;
- 
-             width = get_bits(gb, 13);
-             skip_bits1(gb);   /* marker */
-             height = get_bits(gb, 13);
-             skip_bits1(gb);   /* marker */
-             hor_spat_ref = get_bits(gb, 13); /* hor_spat_ref */
-             skip_bits1(gb);   /* marker */
-             ver_spat_ref = get_bits(gb, 13); /* ver_spat_ref */
-         }
-         skip_bits1(gb); /* change_CR_disable */
- 
-         if (get_bits1(gb) != 0) {
-             skip_bits(gb, 8); /* constant_alpha_value */
-         }
-     }
-//FIXME complexity estimation stuff
-     
-     if (s->shape != BIN_ONLY_SHAPE) {
-         s->intra_dc_threshold= mpeg4_dc_threshold[ get_bits(gb, 3) ];
-         if(!s->progressive_sequence){
-             s->top_field_first= get_bits1(gb);
-             s->alternate_scan= get_bits1(gb);
-         }else
-             s->alternate_scan= 0;
-     }
-
-     if(s->alternate_scan){
-         ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable  , ff_alternate_vertical_scan);
-         ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable  , ff_alternate_vertical_scan);
-         ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_vertical_scan);
-         ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
-     } else{
-         ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable  , ff_zigzag_direct);
-         ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable  , ff_zigzag_direct);
-         ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
-         ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
-     }
- 
-     if(s->pict_type == S_TYPE && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){
-         mpeg4_decode_sprite_trajectory(s, gb);
-         if(s->sprite_brightness_change) av_log(s->avctx, AV_LOG_ERROR, "sprite_brightness_change not supported\n");
-         if(s->vol_sprite_usage==STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "static sprite not supported\n");
-     }
-
-     if (s->shape != BIN_ONLY_SHAPE) {
-         s->chroma_qscale= s->qscale = get_bits(gb, s->quant_precision);
-         if(s->qscale==0){
-             av_log(s->avctx, AV_LOG_ERROR, "Error, header damaged or not MPEG4 header (qscale=0)\n");
-             return -1; // makes no sense to continue, as there is nothing left from the image then
-         }
-  
-         if (s->pict_type != I_TYPE) {
-             s->f_code = get_bits(gb, 3);	/* fcode_for */
-             if(s->f_code==0){
-                 av_log(s->avctx, AV_LOG_ERROR, "Error, header damaged or not MPEG4 header (f_code=0)\n");
-                 return -1; // makes no sense to continue, as the MV decoding will break very quickly
-             }
-         }else
-             s->f_code=1;
-     
-         if (s->pict_type == B_TYPE) {
-             s->b_code = get_bits(gb, 3);
-         }else
-             s->b_code=1;
-
-         if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-             av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d rnd:%d vot:%d%s dc:%d\n", 
-                 s->qscale, s->f_code, s->b_code, 
-                 s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")), 
-                 gb->size_in_bits,s->progressive_sequence, s->alternate_scan, s->top_field_first, 
-                 s->quarter_sample ? "q" : "h", s->data_partitioning, s->resync_marker, s->num_sprite_warping_points,
-                 s->sprite_warping_accuracy, 1-s->no_rounding, s->vo_type, s->vol_control_parameters ? " VOLC" : " ", s->intra_dc_threshold); 
-         }
-
-         if(!s->scalability){
-             if (s->shape!=RECT_SHAPE && s->pict_type!=I_TYPE) {
-                 skip_bits1(gb); // vop shape coding type
-             }
-         }else{
-             if(s->enhancement_type){
-                 int load_backward_shape= get_bits1(gb);
-                 if(load_backward_shape){
-                     av_log(s->avctx, AV_LOG_ERROR, "load backward shape isn't supported\n");
-                 }
-             }
-             skip_bits(gb, 2); //ref_select_code
-         }
-     }
-     /* detect buggy encoders which don't set the low_delay flag (divx4/xvid/opendivx)*/
-     // note we cannot detect divx5 without b-frames easily (although it's buggy too)
-     if(s->vo_type==0 && s->vol_control_parameters==0 && s->divx_version==0 && s->picture_number==0){
-         av_log(s->avctx, AV_LOG_ERROR, "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
-         s->low_delay=1;
-     }
-
-     s->picture_number++; // better than pic number==0 always ;)
-
-     s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table; //FIXME add short header support 
-     s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;
-
-     if(s->workaround_bugs&FF_BUG_EDGE){
-         s->h_edge_pos= s->width;
-         s->v_edge_pos= s->height;
-     }
-     return 0;
-}
-
-/**
- * decode mpeg4 headers
- * @return <0 if no VOP found (or a damaged one)
- *         FRAME_SKIPPED if a not coded VOP is found
- *         0 if a VOP is found
- */
-int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb)
-{
-    int startcode, v;
-
-    /* search next start code */
-    align_get_bits(gb);
-
-    if(s->avctx->codec_tag == ff_get_fourcc("WV1F") && show_bits(gb, 24) == 0x575630){
-        skip_bits(gb, 24);
-        if(get_bits(gb, 8) == 0xF0)
-            return decode_vop_header(s, gb);
-    }
-
-    startcode = 0xff;
-    for(;;) {
-        v = get_bits(gb, 8);
-        startcode = ((startcode << 8) | v) & 0xffffffff;
-        
-        if(get_bits_count(gb) >= gb->size_in_bits){
-            if(gb->size_in_bits==8 && (s->divx_version || s->xvid_build)){
-                av_log(s->avctx, AV_LOG_ERROR, "frame skip %d\n", gb->size_in_bits);
-                return FRAME_SKIPPED; //divx bug
-            }else
-                return -1; //end of stream
-        }
-
-        if((startcode&0xFFFFFF00) != 0x100)
-            continue; //no startcode
-        
-        if(s->avctx->debug&FF_DEBUG_STARTCODE){
-            av_log(s->avctx, AV_LOG_DEBUG, "startcode: %3X ", startcode);
-            if     (startcode<=0x11F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Start");
-            else if(startcode<=0x12F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Layer Start");
-            else if(startcode<=0x13F) av_log(s->avctx, AV_LOG_DEBUG, "Reserved");
-            else if(startcode<=0x15F) av_log(s->avctx, AV_LOG_DEBUG, "FGS bp start");
-            else if(startcode<=0x1AF) av_log(s->avctx, AV_LOG_DEBUG, "Reserved");
-            else if(startcode==0x1B0) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq Start");
-            else if(startcode==0x1B1) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq End");
-            else if(startcode==0x1B2) av_log(s->avctx, AV_LOG_DEBUG, "User Data");
-            else if(startcode==0x1B3) av_log(s->avctx, AV_LOG_DEBUG, "Group of VOP start");
-            else if(startcode==0x1B4) av_log(s->avctx, AV_LOG_DEBUG, "Video Session Error");
-            else if(startcode==0x1B5) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Start");
-            else if(startcode==0x1B6) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Plane start");
-            else if(startcode==0x1B7) av_log(s->avctx, AV_LOG_DEBUG, "slice start");
-            else if(startcode==0x1B8) av_log(s->avctx, AV_LOG_DEBUG, "extension start");
-            else if(startcode==0x1B9) av_log(s->avctx, AV_LOG_DEBUG, "fgs start");
-            else if(startcode==0x1BA) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object start");
-            else if(startcode==0x1BB) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object Plane start");
-            else if(startcode==0x1BC) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object start");
-            else if(startcode==0x1BD) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object Plane start");
-            else if(startcode==0x1BE) av_log(s->avctx, AV_LOG_DEBUG, "Still Texture Object start");
-            else if(startcode==0x1BF) av_log(s->avctx, AV_LOG_DEBUG, "Texture Spatial Layer start");
-            else if(startcode==0x1C0) av_log(s->avctx, AV_LOG_DEBUG, "Texture SNR Layer start");
-            else if(startcode==0x1C1) av_log(s->avctx, AV_LOG_DEBUG, "Texture Tile start");
-            else if(startcode==0x1C2) av_log(s->avctx, AV_LOG_DEBUG, "Texture Shape Layer start");
-            else if(startcode==0x1C3) av_log(s->avctx, AV_LOG_DEBUG, "stuffing start");
-            else if(startcode<=0x1C5) av_log(s->avctx, AV_LOG_DEBUG, "reserved");
-            else if(startcode<=0x1FF) av_log(s->avctx, AV_LOG_DEBUG, "System start");
-            av_log(s->avctx, AV_LOG_DEBUG, " at %d\n", get_bits_count(gb));
-        }
-
-        if(startcode >= 0x120 && startcode <= 0x12F){
-            if(decode_vol_header(s, gb) < 0) 
-                return -1;
-        }
-        else if(startcode == USER_DATA_STARTCODE){
-            decode_user_data(s, gb);
-        }
-        else if(startcode == GOP_STARTCODE){
-            mpeg4_decode_gop_header(s, gb);
-        }
-        else if(startcode == VOP_STARTCODE){
-            return decode_vop_header(s, gb);
-        }
-
-        align_get_bits(gb);
-        startcode = 0xff;
-    }
-}
-
-/* don't understand why they choose a different header ! */
-int intel_h263_decode_picture_header(MpegEncContext *s)
-{
-    int format;
-
-    /* picture header */
-    if (get_bits_long(&s->gb, 22) != 0x20) {
-        av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
-        return -1;
-    }
-    s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
-
-    if (get_bits1(&s->gb) != 1) {
-        av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
-        return -1;	/* marker */
-    }
-    if (get_bits1(&s->gb) != 0) {
-        av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
-        return -1;	/* h263 id */
-    }
-    skip_bits1(&s->gb);	/* split screen off */
-    skip_bits1(&s->gb);	/* camera  off */
-    skip_bits1(&s->gb);	/* freeze picture release off */
-
-    format = get_bits(&s->gb, 3);
-    if (format != 7) {
-        av_log(s->avctx, AV_LOG_ERROR, "Intel H263 free format not supported\n");
-        return -1;
-    }
-    s->h263_plus = 0;
-
-    s->pict_type = I_TYPE + get_bits1(&s->gb);
-    
-    s->unrestricted_mv = get_bits1(&s->gb); 
-    s->h263_long_vectors = s->unrestricted_mv;
-
-    if (get_bits1(&s->gb) != 0) {
-        av_log(s->avctx, AV_LOG_ERROR, "SAC not supported\n");
-        return -1;	/* SAC: off */
-    }
-    if (get_bits1(&s->gb) != 0) {
-        s->obmc= 1;
-        av_log(s->avctx, AV_LOG_ERROR, "Advanced Prediction Mode not supported\n");
-//        return -1;	/* advanced prediction mode: off */
-    }
-    if (get_bits1(&s->gb) != 0) {
-        av_log(s->avctx, AV_LOG_ERROR, "PB frame mode no supported\n");
-        return -1;	/* PB frame mode */
-    }
-
-    /* skip unknown header garbage */
-    skip_bits(&s->gb, 41);
-
-    s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
-    skip_bits1(&s->gb);	/* Continuous Presence Multipoint mode: off */
-
-    /* PEI */
-    while (get_bits1(&s->gb) != 0) {
-        skip_bits(&s->gb, 8);
-    }
-    s->f_code = 1;
-
-    s->y_dc_scale_table=
-    s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
-
-    return 0;
-}
-
-int flv_h263_decode_picture_header(MpegEncContext *s)
-{
-    int format, width, height;
-
-    /* picture header */
-    if (get_bits_long(&s->gb, 17) != 1) {
-        av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
-        return -1;
-    }
-    format = get_bits(&s->gb, 5);
-    if (format != 0 && format != 1) {
-        av_log(s->avctx, AV_LOG_ERROR, "Bad picture format\n");
-        return -1;
-    }
-    s->h263_flv = format+1;
-    s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
-    format = get_bits(&s->gb, 3);
-    switch (format) {
-    case 0:
-        width = get_bits(&s->gb, 8);
-        height = get_bits(&s->gb, 8);
-        break;
-    case 1:
-        width = get_bits(&s->gb, 16);
-        height = get_bits(&s->gb, 16);
-        break;
-    case 2:
-        width = 352;
-        height = 288;
-        break;
-    case 3:
-        width = 176;
-        height = 144;
-        break;
-    case 4:
-        width = 128;
-        height = 96;
-        break;
-    case 5:
-        width = 320;
-        height = 240;
-        break;
-    case 6:
-        width = 160;
-        height = 120;
-        break;
-    default:
-        width = height = 0;
-        break;
-    }
-    if(avcodec_check_dimensions(s->avctx, width, height))
-        return -1;
-    s->width = width;
-    s->height = height;
-
-    s->pict_type = I_TYPE + get_bits(&s->gb, 2);
-    s->dropable= s->pict_type > P_TYPE;
-    if (s->dropable)
-        s->pict_type = P_TYPE;
-    
-    skip_bits1(&s->gb);	/* deblocking flag */
-    s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
-
-    s->h263_plus = 0;
-
-    s->unrestricted_mv = 1;
-    s->h263_long_vectors = 0;
-
-    /* PEI */
-    while (get_bits1(&s->gb) != 0) {
-        skip_bits(&s->gb, 8);
-    }
-    s->f_code = 1;
-
-    if(s->avctx->debug & FF_DEBUG_PICT_INFO){
-        av_log(s->avctx, AV_LOG_DEBUG, "%c esc_type:%d, qp:%d num:%d\n",
-               s->dropable ? 'D' : av_get_pict_type_char(s->pict_type), s->h263_flv-1, s->qscale, s->picture_number);
-    }
-    
-    s->y_dc_scale_table=
-    s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
-
-    return 0;
-}
diff --git a/ffmpeg.src/libavcodec/h263data.h b/ffmpeg.src/libavcodec/h263data.h
deleted file mode 100644
index f380378..0000000
--- a/ffmpeg.src/libavcodec/h263data.h
+++ /dev/null
@@ -1,285 +0,0 @@
-/**
- * @file h263data.h
- * H.263 tables.
- */
-
-
-/* intra MCBPC, mb_type = (intra), then (intraq) */
-const uint8_t intra_MCBPC_code[9] = { 1, 1, 2, 3, 1, 1, 2, 3, 1 };
-const uint8_t intra_MCBPC_bits[9] = { 1, 3, 3, 3, 4, 6, 6, 6, 9 };
-
-/* inter MCBPC, mb_type = (inter), (intra), (interq), (intraq), (inter4v) */
-/* Changed the tables for interq and inter4v+q, following the standard ** Juanjo ** */
-const uint8_t inter_MCBPC_code[28] = { 
-    1, 3, 2, 5, 
-    3, 4, 3, 3, 
-    3, 7, 6, 5,
-    4, 4, 3, 2,
-    2, 5, 4, 5,
-    1, 0, 0, 0, /* Stuffing */
-    2, 12, 14, 15,
-};
-const uint8_t inter_MCBPC_bits[28] = { 
-    1, 4, 4, 6, /* inter  */
-    5, 8, 8, 7, /* intra  */
-    3, 7, 7, 9, /* interQ */
-    6, 9, 9, 9, /* intraQ */
-    3, 7, 7, 8, /* inter4 */
-    9, 0, 0, 0, /* Stuffing */
-    11, 13, 13, 13,/* inter4Q*/
-};
-
-static const uint8_t h263_mbtype_b_tab[15][2] = {
- {1, 1}, 
- {3, 3}, 
- {1, 5}, 
- {4, 4},
- {5, 4},
- {6, 6},
- {2, 4},
- {3, 4},
- {7, 6},
- {4, 6},
- {5, 6},
- {1, 6},
- {1,10},
- {1, 7},
- {1, 8},
-};
-
-static const int h263_mb_type_b_map[15]= {
-    MB_TYPE_DIRECT2 | MB_TYPE_L0L1,
-    MB_TYPE_DIRECT2 | MB_TYPE_L0L1 | MB_TYPE_CBP,
-    MB_TYPE_DIRECT2 | MB_TYPE_L0L1 | MB_TYPE_CBP | MB_TYPE_QUANT,
-                      MB_TYPE_L0                                 | MB_TYPE_16x16,
-                      MB_TYPE_L0   | MB_TYPE_CBP                 | MB_TYPE_16x16,
-                      MB_TYPE_L0   | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,
-                      MB_TYPE_L1                                 | MB_TYPE_16x16,
-                      MB_TYPE_L1   | MB_TYPE_CBP                 | MB_TYPE_16x16,
-                      MB_TYPE_L1   | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,
-                      MB_TYPE_L0L1                               | MB_TYPE_16x16,
-                      MB_TYPE_L0L1 | MB_TYPE_CBP                 | MB_TYPE_16x16,
-                      MB_TYPE_L0L1 | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,
-    0, //stuffing
-    MB_TYPE_INTRA4x4                | MB_TYPE_CBP,
-    MB_TYPE_INTRA4x4                | MB_TYPE_CBP | MB_TYPE_QUANT,
-};
-
-const uint8_t cbpc_b_tab[4][2] = {
-{0, 1},
-{2, 2},
-{7, 3},
-{6, 3},
-};
-
-const uint8_t cbpy_tab[16][2] =
-{
-  {3,4}, {5,5}, {4,5}, {9,4}, {3,5}, {7,4}, {2,6}, {11,4},
-  {2,5}, {3,6}, {5,4}, {10,4}, {4,4}, {8,4}, {6,4}, {3,2}
-};
-
-const uint8_t mvtab[33][2] =
-{
-  {1,1}, {1,2}, {1,3}, {1,4}, {3,6}, {5,7}, {4,7}, {3,7},
-  {11,9}, {10,9}, {9,9}, {17,10}, {16,10}, {15,10}, {14,10}, {13,10},
-  {12,10}, {11,10}, {10,10}, {9,10}, {8,10}, {7,10}, {6,10}, {5,10},
-  {4,10}, {7,11}, {6,11}, {5,11}, {4,11}, {3,11}, {2,11}, {3,12},
-  {2,12}
-};
-
-/* third non intra table */
-const uint16_t inter_vlc[103][2] = {
-{ 0x2, 2 },{ 0xf, 4 },{ 0x15, 6 },{ 0x17, 7 },
-{ 0x1f, 8 },{ 0x25, 9 },{ 0x24, 9 },{ 0x21, 10 },
-{ 0x20, 10 },{ 0x7, 11 },{ 0x6, 11 },{ 0x20, 11 },
-{ 0x6, 3 },{ 0x14, 6 },{ 0x1e, 8 },{ 0xf, 10 },
-{ 0x21, 11 },{ 0x50, 12 },{ 0xe, 4 },{ 0x1d, 8 },
-{ 0xe, 10 },{ 0x51, 12 },{ 0xd, 5 },{ 0x23, 9 },
-{ 0xd, 10 },{ 0xc, 5 },{ 0x22, 9 },{ 0x52, 12 },
-{ 0xb, 5 },{ 0xc, 10 },{ 0x53, 12 },{ 0x13, 6 },
-{ 0xb, 10 },{ 0x54, 12 },{ 0x12, 6 },{ 0xa, 10 },
-{ 0x11, 6 },{ 0x9, 10 },{ 0x10, 6 },{ 0x8, 10 },
-{ 0x16, 7 },{ 0x55, 12 },{ 0x15, 7 },{ 0x14, 7 },
-{ 0x1c, 8 },{ 0x1b, 8 },{ 0x21, 9 },{ 0x20, 9 },
-{ 0x1f, 9 },{ 0x1e, 9 },{ 0x1d, 9 },{ 0x1c, 9 },
-{ 0x1b, 9 },{ 0x1a, 9 },{ 0x22, 11 },{ 0x23, 11 },
-{ 0x56, 12 },{ 0x57, 12 },{ 0x7, 4 },{ 0x19, 9 },
-{ 0x5, 11 },{ 0xf, 6 },{ 0x4, 11 },{ 0xe, 6 },
-{ 0xd, 6 },{ 0xc, 6 },{ 0x13, 7 },{ 0x12, 7 },
-{ 0x11, 7 },{ 0x10, 7 },{ 0x1a, 8 },{ 0x19, 8 },
-{ 0x18, 8 },{ 0x17, 8 },{ 0x16, 8 },{ 0x15, 8 },
-{ 0x14, 8 },{ 0x13, 8 },{ 0x18, 9 },{ 0x17, 9 },
-{ 0x16, 9 },{ 0x15, 9 },{ 0x14, 9 },{ 0x13, 9 },
-{ 0x12, 9 },{ 0x11, 9 },{ 0x7, 10 },{ 0x6, 10 },
-{ 0x5, 10 },{ 0x4, 10 },{ 0x24, 11 },{ 0x25, 11 },
-{ 0x26, 11 },{ 0x27, 11 },{ 0x58, 12 },{ 0x59, 12 },
-{ 0x5a, 12 },{ 0x5b, 12 },{ 0x5c, 12 },{ 0x5d, 12 },
-{ 0x5e, 12 },{ 0x5f, 12 },{ 0x3, 7 },
-};
-
-const int8_t inter_level[102] = {
-  1,  2,  3,  4,  5,  6,  7,  8,
-  9, 10, 11, 12,  1,  2,  3,  4,
-  5,  6,  1,  2,  3,  4,  1,  2,
-  3,  1,  2,  3,  1,  2,  3,  1,
-  2,  3,  1,  2,  1,  2,  1,  2,
-  1,  2,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  2,  3,  1,  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,  1,
-  1,  1,  1,  1,  1,  1,
-};
-
-const int8_t inter_run[102] = {
-  0,  0,  0,  0,  0,  0,  0,  0,
-  0,  0,  0,  0,  1,  1,  1,  1,
-  1,  1,  2,  2,  2,  2,  3,  3,
-  3,  4,  4,  4,  5,  5,  5,  6,
-  6,  6,  7,  7,  8,  8,  9,  9,
- 10, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26,  0,  0,  0,  1,  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, 32, 33, 34,
- 35, 36, 37, 38, 39, 40,
-};
-
-static RLTable rl_inter = {
-    102,
-    58,
-    inter_vlc,
-    inter_run,
-    inter_level,
-};
-
-const uint16_t intra_vlc_aic[103][2] = {
-{  0x2,  2 }, {  0x6,  3 }, {  0xe,  4 }, {  0xc,  5 }, 
-{  0xd,  5 }, { 0x10,  6 }, { 0x11,  6 }, { 0x12,  6 }, 
-{ 0x16,  7 }, { 0x1b,  8 }, { 0x20,  9 }, { 0x21,  9 }, 
-{ 0x1a,  9 }, { 0x1b,  9 }, { 0x1c,  9 }, { 0x1d,  9 }, 
-{ 0x1e,  9 }, { 0x1f,  9 }, { 0x23, 11 }, { 0x22, 11 }, 
-{ 0x57, 12 }, { 0x56, 12 }, { 0x55, 12 }, { 0x54, 12 }, 
-{ 0x53, 12 }, {  0xf,  4 }, { 0x14,  6 }, { 0x14,  7 }, 
-{ 0x1e,  8 }, {  0xf, 10 }, { 0x21, 11 }, { 0x50, 12 }, 
-{  0xb,  5 }, { 0x15,  7 }, {  0xe, 10 }, {  0x9, 10 }, 
-{ 0x15,  6 }, { 0x1d,  8 }, {  0xd, 10 }, { 0x51, 12 }, 
-{ 0x13,  6 }, { 0x23,  9 }, {  0x7, 11 }, { 0x17,  7 }, 
-{ 0x22,  9 }, { 0x52, 12 }, { 0x1c,  8 }, {  0xc, 10 }, 
-{ 0x1f,  8 }, {  0xb, 10 }, { 0x25,  9 }, {  0xa, 10 }, 
-{ 0x24,  9 }, {  0x6, 11 }, { 0x21, 10 }, { 0x20, 10 }, 
-{  0x8, 10 }, { 0x20, 11 }, {  0x7,  4 }, {  0xc,  6 }, 
-{ 0x10,  7 }, { 0x13,  8 }, { 0x11,  9 }, { 0x12,  9 }, 
-{  0x4, 10 }, { 0x27, 11 }, { 0x26, 11 }, { 0x5f, 12 }, 
-{  0xf,  6 }, { 0x13,  9 }, {  0x5, 10 }, { 0x25, 11 }, 
-{  0xe,  6 }, { 0x14,  9 }, { 0x24, 11 }, {  0xd,  6 }, 
-{  0x6, 10 }, { 0x5e, 12 }, { 0x11,  7 }, {  0x7, 10 }, 
-{ 0x13,  7 }, { 0x5d, 12 }, { 0x12,  7 }, { 0x5c, 12 }, 
-{ 0x14,  8 }, { 0x5b, 12 }, { 0x15,  8 }, { 0x1a,  8 }, 
-{ 0x19,  8 }, { 0x18,  8 }, { 0x17,  8 }, { 0x16,  8 }, 
-{ 0x19,  9 }, { 0x15,  9 }, { 0x16,  9 }, { 0x18,  9 }, 
-{ 0x17,  9 }, {  0x4, 11 }, {  0x5, 11 }, { 0x58, 12 }, 
-{ 0x59, 12 }, { 0x5a, 12 }, {  0x3,  7 },
-};
-
-const int8_t intra_run_aic[102] = {
- 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,  1,  1,  1,  1,  1,  1, 
- 2,  2,  2,  2,  3,  3,  3,  3, 
- 4,  4,  4,  5,  5,  5,  6,  6, 
- 7,  7,  8,  8,  9,  9, 10, 11, 
-12, 13,  0,  0,  0,  0,  0,  0, 
- 0,  0,  0,  0,  1,  1,  1,  1, 
- 2,  2,  2,  3,  3,  3,  4,  4, 
- 5,  5,  6,  6,  7,  7,  8,  9, 
-10, 11, 12, 13, 14, 15, 16, 17, 
-18, 19, 20, 21, 22, 23, 
-};
-
-const int8_t intra_level_aic[102] = {
- 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,  1,  2,  3,  4,  5,  6,  7, 
- 1,  2,  3,  4,  1,  2,  3,  4, 
- 1,  2,  3,  1,  2,  3,  1,  2, 
- 1,  2,  1,  2,  1,  2,  1,  1, 
- 1,  1,  1,  2,  3,  4,  5,  6, 
- 7,  8,  9, 10,  1,  2,  3,  4, 
- 1,  2,  3,  1,  2,  3,  1,  2, 
- 1,  2,  1,  2,  1,  2,  1,  1, 
- 1,  1,  1,  1,  1,  1,  1,  1, 
- 1,  1,  1,  1,  1,  1,
-};
-
-static RLTable rl_intra_aic = {
-    102,
-    58,
-    intra_vlc_aic,
-    intra_run_aic,
-    intra_level_aic,
-};
-
-static const uint8_t wrong_run[102] = {
- 1,  2,  3,  5,  4, 10,  9,  8, 
-11, 15, 17, 16, 23, 22, 21, 20, 
-19, 18, 25, 24, 27, 26, 11,  7,  
- 6,  1,  2, 13,  2,  2,  2,  2, 
- 6, 12,  3,  9,  1,  3,  4,  3, 
- 7,  4,  1,  1,  5,  5, 14,  6, 
- 1,  7,  1,  8,  1,  1,  1,  1, 
-10,  1,  1,  5,  9, 17, 25, 24, 
-29, 33, 32, 41,  2, 23, 28, 31,  
- 3, 22, 30,  4, 27, 40,  8, 26,  
- 6, 39,  7, 38, 16, 37, 15, 10, 
-11, 12, 13, 14,  1, 21, 20, 18, 
-19,  2,  1, 34, 35, 36
-};
-
-static const uint16_t h263_format[8][2] = {
-    { 0, 0 },
-    { 128, 96 },
-    { 176, 144 },
-    { 352, 288 },
-    { 704, 576 },
-    { 1408, 1152 },
-};
-
-const uint8_t ff_aic_dc_scale_table[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, 2, 4, 6, 8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62
-};
-
-static const uint8_t modified_quant_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
-}   
-};
-
-const uint8_t ff_h263_chroma_qscale_table[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, 1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 9,10,10,11,11,12,12,12,13,13,13,14,14,14,14,14,15,15,15,15,15
-};
-
-const uint16_t ff_mba_max[6]={
-     47,  98, 395,1583,6335,9215
-};
-
-const uint8_t ff_mba_length[6]={
-      6,   7,   9,  11,  13,  14
-};
-
-const uint8_t ff_h263_loop_filter_strength[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, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9,10,10,10,11,11,11,12,12,12
-};
-
diff --git a/ffmpeg.src/libavcodec/h263dec.c b/ffmpeg.src/libavcodec/h263dec.c
deleted file mode 100644
index 87e1179..0000000
--- a/ffmpeg.src/libavcodec/h263dec.c
+++ /dev/null
@@ -1,893 +0,0 @@
-/*
- * H.263 decoder
- * Copyright (c) 2001 Fabrice Bellard.
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-/**
- * @file h263dec.c
- * H.263 decoder.
- */
- 
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-
-//#define DEBUG
-//#define PRINT_FRAME_TIME
-
-int ff_h263_decode_init(AVCodecContext *avctx)
-{
-    MpegEncContext *s = avctx->priv_data;
-
-    s->avctx = avctx;
-    s->out_format = FMT_H263;
-
-    s->width  = avctx->coded_width;
-    s->height = avctx->coded_height;
-    s->workaround_bugs= avctx->workaround_bugs;
-
-    // set defaults
-    MPV_decode_defaults(s);
-    s->quant_precision=5;
-    s->decode_mb= ff_h263_decode_mb;
-    s->low_delay= 1;
-    avctx->pix_fmt= PIX_FMT_YUV420P;
-    s->unrestricted_mv= 1;
-
-    /* select sub codec */
-    switch(avctx->codec->id) {
-    case CODEC_ID_H263:
-        s->unrestricted_mv= 0;
-        break;
-    case CODEC_ID_MPEG4:
-        s->decode_mb= ff_mpeg4_decode_mb;
-        s->time_increment_bits = 4; /* default value for broken headers */
-        s->h263_pred = 1;
-        s->low_delay = 0; //default, might be overriden in the vol header during header parsing
-        break;
-    case CODEC_ID_MSMPEG4V1:
-        s->h263_msmpeg4 = 1;
-        s->h263_pred = 1;
-        s->msmpeg4_version=1;
-        break;
-    case CODEC_ID_MSMPEG4V2:
-        s->h263_msmpeg4 = 1;
-        s->h263_pred = 1;
-        s->msmpeg4_version=2;
-        break;
-    case CODEC_ID_MSMPEG4V3:
-        s->h263_msmpeg4 = 1;
-        s->h263_pred = 1;
-        s->msmpeg4_version=3;
-        break;
-    case CODEC_ID_WMV1:
-        s->h263_msmpeg4 = 1;
-        s->h263_pred = 1;
-        s->msmpeg4_version=4;
-        break;
-    case CODEC_ID_WMV2:
-        s->h263_msmpeg4 = 1;
-        s->h263_pred = 1;
-        s->msmpeg4_version=5;
-        break;
-    case CODEC_ID_WMV3:
-        s->h263_msmpeg4 = 1;
-        s->h263_pred = 1;
-        s->msmpeg4_version=6;
-        break;
-    case CODEC_ID_H263I:
-        break;
-    case CODEC_ID_FLV1:
-        s->h263_flv = 1;
-        break;
-    default:
-        return -1;
-    }
-    s->codec_id= avctx->codec->id;
-
-    /* for h263, we allocate the images after having read the header */
-    if (avctx->codec->id != CODEC_ID_H263 && avctx->codec->id != CODEC_ID_MPEG4)
-        if (MPV_common_init(s) < 0)
-            return -1;
-
-    if (s->h263_msmpeg4)
-        ff_msmpeg4_decode_init(s);
-    else
-        h263_decode_init_vlc(s);
-    
-    return 0;
-}
-
-int ff_h263_decode_end(AVCodecContext *avctx)
-{
-    MpegEncContext *s = avctx->priv_data;
-
-    MPV_common_end(s);
-    return 0;
-}
-
-/**
- * returns the number of bytes consumed for building the current frame
- */
-static int get_consumed_bytes(MpegEncContext *s, int buf_size){
-    int pos= (get_bits_count(&s->gb)+7)>>3;
-    
-    if(s->divx_packed){
-        //we would have to scan through the whole buf to handle the weird reordering ...
-        return buf_size; 
-    }else if(s->flags&CODEC_FLAG_TRUNCATED){
-        pos -= s->parse_context.last_index;
-        if(pos<0) pos=0; // padding is not really read so this might be -1
-        return pos;
-    }else{
-        if(pos==0) pos=1; //avoid infinite loops (i doubt thats needed but ...)
-        if(pos+10>buf_size) pos=buf_size; // oops ;)
-
-        return pos;
-    }
-}
-
-static int decode_slice(MpegEncContext *s){
-    const int part_mask= s->partitioned_frame ? (AC_END|AC_ERROR) : 0x7F;
-    const int mb_size= 16>>s->avctx->lowres;
-    s->last_resync_gb= s->gb;
-    s->first_slice_line= 1;
-        
-    s->resync_mb_x= s->mb_x;
-    s->resync_mb_y= s->mb_y;
-
-    ff_set_qscale(s, s->qscale);
-    
-    if(s->partitioned_frame){
-        const int qscale= s->qscale;
-
-        if(s->codec_id==CODEC_ID_MPEG4){
-            if(ff_mpeg4_decode_partitions(s) < 0)
-                return -1; 
-        }
-        
-        /* restore variables which were modified */
-        s->first_slice_line=1;
-        s->mb_x= s->resync_mb_x;
-        s->mb_y= s->resync_mb_y;
-        ff_set_qscale(s, qscale);
-    }
-
-    for(; s->mb_y < s->mb_height; s->mb_y++) {
-        /* per-row end of slice checks */
-        if(s->msmpeg4_version){
-            if(s->resync_mb_y + s->slice_height == s->mb_y){
-                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
-
-                return 0;
-            }
-        }
-        
-        if(s->msmpeg4_version==1){
-            s->last_dc[0]=
-            s->last_dc[1]=
-            s->last_dc[2]= 128;
-        }
-    
-        ff_init_block_index(s);
-        for(; s->mb_x < s->mb_width; s->mb_x++) {
-            int ret;
-
-            ff_update_block_index(s);
-
-            if(s->resync_mb_x == s->mb_x && s->resync_mb_y+1 == s->mb_y){
-                s->first_slice_line=0; 
-            }
-
-            /* DCT & quantize */
-           
-            s->mv_dir = MV_DIR_FORWARD;
-            s->mv_type = MV_TYPE_16X16;
-//            s->mb_skipped = 0;
-//printf("%d %d %06X\n", ret, get_bits_count(&s->gb), show_bits(&s->gb, 24));
-            ret= s->decode_mb(s, s->block);
-
-            if (s->pict_type!=B_TYPE)
-                ff_h263_update_motion_val(s);
-
-            if(ret<0){
-                const int xy= s->mb_x + s->mb_y*s->mb_stride;
-                if(ret==SLICE_END){
-                    MPV_decode_mb(s, s->block);
-                    if(s->loop_filter)
-                        ff_h263_loop_filter(s);
-
-//printf("%d %d %d %06X\n", s->mb_x, s->mb_y, s->gb.size*8 - get_bits_count(&s->gb), show_bits(&s->gb, 24));
-                    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
-
-                    s->padding_bug_score--;
-                        
-                    if(++s->mb_x >= s->mb_width){
-                        s->mb_x=0;
-                        ff_draw_horiz_band(s, s->mb_y*mb_size, mb_size);
-                        s->mb_y++;
-                    }
-                    return 0; 
-                }else if(ret==SLICE_NOEND){
-                    av_log(s->avctx, AV_LOG_ERROR, "Slice mismatch at MB: %d\n", xy);
-                    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x+1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
-                    return -1;
-                }
-                av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", xy);
-                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
-    
-                return -1;
-            }
-
-            MPV_decode_mb(s, s->block);
-            if(s->loop_filter)
-                ff_h263_loop_filter(s);
-        }
-        
-        ff_draw_horiz_band(s, s->mb_y*mb_size, mb_size);
-        
-        s->mb_x= 0;
-    }
-    
-    assert(s->mb_x==0 && s->mb_y==s->mb_height);
-
-    /* try to detect the padding bug */
-    if(      s->codec_id==CODEC_ID_MPEG4
-       &&   (s->workaround_bugs&FF_BUG_AUTODETECT) 
-       &&    s->gb.size_in_bits - get_bits_count(&s->gb) >=0
-       &&    s->gb.size_in_bits - get_bits_count(&s->gb) < 48
-//       &&   !s->resync_marker
-       &&   !s->data_partitioning){
-        
-        const int bits_count= get_bits_count(&s->gb);
-        const int bits_left = s->gb.size_in_bits - bits_count;
-        
-        if(bits_left==0){
-            s->padding_bug_score+=16;
-        } else if(bits_left != 1){
-            int v= show_bits(&s->gb, 8);
-            v|= 0x7F >> (7-(bits_count&7));
-
-            if(v==0x7F && bits_left<=8)
-                s->padding_bug_score--;
-            else if(v==0x7F && ((get_bits_count(&s->gb)+8)&8) && bits_left<=16)
-                s->padding_bug_score+= 4;
-            else
-                s->padding_bug_score++;            
-        }                          
-    }
-    
-    if(s->workaround_bugs&FF_BUG_AUTODETECT){
-        if(s->padding_bug_score > -2 && !s->data_partitioning /*&& (s->divx_version || !s->resync_marker)*/)
-            s->workaround_bugs |=  FF_BUG_NO_PADDING;
-        else
-            s->workaround_bugs &= ~FF_BUG_NO_PADDING;
-    }
-
-    // handle formats which don't have unique end markers
-    if(s->msmpeg4_version || (s->workaround_bugs&FF_BUG_NO_PADDING)){ //FIXME perhaps solve this more cleanly
-        int left= s->gb.size_in_bits - get_bits_count(&s->gb);
-        int max_extra=7;
-        
-        /* no markers in M$ crap */
-        if(s->msmpeg4_version && s->pict_type==I_TYPE)
-            max_extra+= 17;
-        
-        /* buggy padding but the frame should still end approximately at the bitstream end */
-        if((s->workaround_bugs&FF_BUG_NO_PADDING) && s->error_resilience>=3)
-            max_extra+= 48;
-        else if((s->workaround_bugs&FF_BUG_NO_PADDING))
-            max_extra+= 256*256*256*64;
-        
-        if(left>max_extra){
-            av_log(s->avctx, AV_LOG_ERROR, "discarding %d junk bits at end, next would be %X\n", left, show_bits(&s->gb, 24));
-        }
-        else if(left<0){
-            av_log(s->avctx, AV_LOG_ERROR, "overreading %d bits\n", -left);
-        }else
-            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
-        
-        return 0;
-    }
-
-    av_log(s->avctx, AV_LOG_ERROR, "slice end not reached but screenspace end (%d left %06X, score= %d)\n", 
-            s->gb.size_in_bits - get_bits_count(&s->gb),
-            show_bits(&s->gb, 24), s->padding_bug_score);
-            
-    ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
-
-    return -1;
-}
-
-/**
- * finds the end of the current frame in the bitstream.
- * @return the position of the first byte of the next frame, or -1
- */
-int ff_mpeg4_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size){
-    int vop_found, i;
-    uint32_t state;
-    
-    vop_found= pc->frame_start_found;
-    state= pc->state;
-    
-    i=0;
-    if(!vop_found){
-        for(i=0; i<buf_size; i++){
-            state= (state<<8) | buf[i];
-            if(state == 0x1B6){
-                i++;
-                vop_found=1;
-                break;
-            }
-        }
-    }
-
-    if(vop_found){
-        /* EOF considered as end of frame */
-        if (buf_size == 0)
-            return 0;
-        for(; i<buf_size; i++){
-            state= (state<<8) | buf[i];
-            if((state&0xFFFFFF00) == 0x100){
-                pc->frame_start_found=0;
-                pc->state=-1; 
-                return i-3;
-            }
-        }
-    }
-    pc->frame_start_found= vop_found;
-    pc->state= state;
-    return END_NOT_FOUND;
-}
-
-static int h263_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size){
-    int vop_found, i;
-    uint32_t state;
-    
-    vop_found= pc->frame_start_found;
-    state= pc->state;
-    
-    i=0;
-    if(!vop_found){
-        for(i=0; i<buf_size; i++){
-            state= (state<<8) | buf[i];
-            if(state>>(32-22) == 0x20){
-                i++;
-                vop_found=1;
-                break;
-            }
-        }
-    }
-
-    if(vop_found){    
-      for(; i<buf_size; i++){
-        state= (state<<8) | buf[i];
-        if(state>>(32-22) == 0x20){
-            pc->frame_start_found=0;
-            pc->state=-1; 
-            return i-3;
-        }
-      }
-    }
-    pc->frame_start_found= vop_found;
-    pc->state= state;
-    
-    return END_NOT_FOUND;
-}
-
-static int h263_parse(AVCodecParserContext *s,
-                           AVCodecContext *avctx,
-                           uint8_t **poutbuf, int *poutbuf_size, 
-                           const uint8_t *buf, int buf_size)
-{
-    ParseContext *pc = s->priv_data;
-    int next;
-    
-    next= h263_find_frame_end(pc, buf, buf_size);
-
-    if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
-        *poutbuf = NULL;
-        *poutbuf_size = 0;
-        return buf_size;
-    }
-
-    *poutbuf = (uint8_t *)buf;
-    *poutbuf_size = buf_size;
-    return next;
-}
-
-int ff_h263_decode_frame(AVCodecContext *avctx, 
-                             void *data, int *data_size,
-                             uint8_t *buf, int buf_size)
-{
-    MpegEncContext *s = avctx->priv_data;
-    int ret;
-    AVFrame *pict = data; 
-    
-#ifdef PRINT_FRAME_TIME
-uint64_t time= rdtsc();
-#endif
-#ifdef DEBUG
-    printf("*****frame %d size=%d\n", avctx->frame_number, buf_size);
-    printf("bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
-#endif
-    s->flags= avctx->flags;
-    s->flags2= avctx->flags2;
-
-    /* no supplementary picture */
-    if (buf_size == 0) {
-        /* special case for last picture */
-        if (s->low_delay==0 && s->next_picture_ptr) {
-            *pict= *(AVFrame*)s->next_picture_ptr;
-            s->next_picture_ptr= NULL;
-
-            *data_size = sizeof(AVFrame);
-        }
-
-        return 0;
-    }
-
-    if(s->flags&CODEC_FLAG_TRUNCATED){
-        int next;
-        
-        if(s->codec_id==CODEC_ID_MPEG4){
-            next= ff_mpeg4_find_frame_end(&s->parse_context, buf, buf_size);
-        }else if(s->codec_id==CODEC_ID_H263){
-            next= h263_find_frame_end(&s->parse_context, buf, buf_size);
-        }else{
-            av_log(s->avctx, AV_LOG_ERROR, "this codec does not support truncated bitstreams\n");
-            return -1;
-        }
-        
-        if( ff_combine_frame(&s->parse_context, next, &buf, &buf_size) < 0 )
-            return buf_size;
-    }
-
-    
-retry:
-    
-    if(s->bitstream_buffer_size && (s->divx_packed || buf_size<20)){ //divx 5.01+/xvid frame reorder
-        init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8);
-    }else
-        init_get_bits(&s->gb, buf, buf_size*8);
-    s->bitstream_buffer_size=0;
-
-    if (!s->context_initialized) {
-        if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix
-            return -1;
-    }
-    
-    //we need to set current_picture_ptr before reading the header, otherwise we cant store anyting im there
-    if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){
-        int i= ff_find_unused_picture(s, 0);
-        s->current_picture_ptr= &s->picture[i];
-    }
-      
-    /* let's go :-) */
-    if (s->msmpeg4_version==5) {
-        ret= ff_wmv2_decode_picture_header(s);
-    } else if (s->msmpeg4_version) {
-        ret = msmpeg4_decode_picture_header(s);
-    } else if (s->h263_pred) {
-        if(s->avctx->extradata_size && s->picture_number==0){
-            GetBitContext gb;
-            
-            init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);
-            ret = ff_mpeg4_decode_picture_header(s, &gb);
-        }
-        ret = ff_mpeg4_decode_picture_header(s, &s->gb);
-
-        if(s->flags& CODEC_FLAG_LOW_DELAY)
-            s->low_delay=1;
-    } else if (s->codec_id == CODEC_ID_H263I) {
-        ret = intel_h263_decode_picture_header(s);
-    } else if (s->h263_flv) {
-        ret = flv_h263_decode_picture_header(s);
-    } else {
-        ret = h263_decode_picture_header(s);
-    }
-    
-    if(ret==FRAME_SKIPPED) return get_consumed_bytes(s, buf_size);
-
-    /* skip if the header was thrashed */
-    if (ret < 0){
-        av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
-        return -1;
-    }
-    
-    avctx->has_b_frames= !s->low_delay;
-    
-    if(s->xvid_build==0 && s->divx_version==0 && s->lavc_build==0){
-        if(s->avctx->stream_codec_tag == ff_get_fourcc("XVID") || 
-           s->avctx->codec_tag == ff_get_fourcc("XVID") || s->avctx->codec_tag == ff_get_fourcc("XVIX"))
-            s->xvid_build= -1;
-#if 0
-        if(s->avctx->codec_tag == ff_get_fourcc("DIVX") && s->vo_type==0 && s->vol_control_parameters==1
-           && s->padding_bug_score > 0 && s->low_delay) // XVID with modified fourcc 
-            s->xvid_build= -1;
-#endif
-    }
-
-    if(s->xvid_build==0 && s->divx_version==0 && s->lavc_build==0){
-        if(s->avctx->codec_tag == ff_get_fourcc("DIVX") && s->vo_type==0 && s->vol_control_parameters==0)
-            s->divx_version= 400; //divx 4
-    }
-    
-    if(s->xvid_build && s->divx_version){
-        s->divx_version=
-        s->divx_build= 0;
-    }
-
-    if(s->workaround_bugs&FF_BUG_AUTODETECT){
-        if(s->avctx->codec_tag == ff_get_fourcc("XVIX")) 
-            s->workaround_bugs|= FF_BUG_XVID_ILACE;
-
-        if(s->avctx->codec_tag == ff_get_fourcc("UMP4")){
-            s->workaround_bugs|= FF_BUG_UMP4;
-        }
-
-        if(s->divx_version>=500){
-            s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
-        }
-
-        if(s->divx_version>502){
-            s->workaround_bugs|= FF_BUG_QPEL_CHROMA2;
-        }
-
-        if(s->xvid_build && s->xvid_build<=3)
-            s->padding_bug_score= 256*256*256*64;
-        
-        if(s->xvid_build && s->xvid_build<=1)
-            s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
-
-        if(s->xvid_build && s->xvid_build<=12)
-            s->workaround_bugs|= FF_BUG_EDGE;
-
-        if(s->xvid_build && s->xvid_build<=32)
-            s->workaround_bugs|= FF_BUG_DC_CLIP;
-
-#define SET_QPEL_FUNC(postfix1, postfix2) \
-    s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\
-    s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\
-    s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2;
-
-        if(s->lavc_build && s->lavc_build<4653)
-            s->workaround_bugs|= FF_BUG_STD_QPEL;
-        
-        if(s->lavc_build && s->lavc_build<4655)
-            s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
-
-        if(s->lavc_build && s->lavc_build<4670){
-            s->workaround_bugs|= FF_BUG_EDGE;
-        }
-        
-        if(s->lavc_build && s->lavc_build<=4712)
-            s->workaround_bugs|= FF_BUG_DC_CLIP;
-
-        if(s->divx_version)
-            s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
-//printf("padding_bug_score: %d\n", s->padding_bug_score);
-        if(s->divx_version==501 && s->divx_build==20020416)
-            s->padding_bug_score= 256*256*256*64;
-
-        if(s->divx_version && s->divx_version<500){
-            s->workaround_bugs|= FF_BUG_EDGE;
-        }
-        
-        if(s->divx_version)
-            s->workaround_bugs|= FF_BUG_HPEL_CHROMA;
-#if 0
-        if(s->divx_version==500)
-            s->padding_bug_score= 256*256*256*64;
-
-        /* very ugly XVID padding bug detection FIXME/XXX solve this differently
-         * lets hope this at least works
-         */
-        if(   s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==0
-           && s->codec_id==CODEC_ID_MPEG4 && s->vo_type==0)
-            s->workaround_bugs|= FF_BUG_NO_PADDING;
-        
-        if(s->lavc_build && s->lavc_build<4609) //FIXME not sure about the version num but a 4609 file seems ok
-            s->workaround_bugs|= FF_BUG_NO_PADDING;
-#endif
-    }
-    
-    if(s->workaround_bugs& FF_BUG_STD_QPEL){
-        SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c)
-        SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c)
-        SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c)
-        SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c)
-        SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c)
-        SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c)
-
-        SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c)
-        SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c)
-        SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c)
-        SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c)
-        SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c)
-        SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c)
-    }
-
-    if(avctx->debug & FF_DEBUG_BUGS)
-        av_log(s->avctx, AV_LOG_DEBUG, "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n", 
-               s->workaround_bugs, s->lavc_build, s->xvid_build, s->divx_version, s->divx_build,
-               s->divx_packed ? "p" : "");
-    
-#if 0 // dump bits per frame / qp / complexity
-{
-    static FILE *f=NULL;
-    if(!f) f=fopen("rate_qp_cplx.txt", "w");
-    fprintf(f, "%d %d %f\n", buf_size, s->qscale, buf_size*(double)s->qscale);
-}
-#endif
-
-#if defined(HAVE_MMX) && defined(CONFIG_GPL)
-    if(s->codec_id == CODEC_ID_MPEG4 && s->xvid_build && avctx->idct_algo == FF_IDCT_AUTO && (mm_flags & MM_MMX) && !(s->flags&CODEC_FLAG_BITEXACT)){
-        avctx->idct_algo= FF_IDCT_XVIDMMX;
-        avctx->coded_width= 0; // force reinit
-    }
-#endif
-
-        /* After H263 & mpeg4 header decode we have the height, width,*/
-        /* and other parameters. So then we could init the picture   */
-        /* FIXME: By the way H263 decoder is evolving it should have */
-        /* an H263EncContext                                         */
-    
-    if (   s->width  != avctx->coded_width 
-        || s->height != avctx->coded_height) {
-        /* H.263 could change picture size any time */
-        ParseContext pc= s->parse_context; //FIXME move these demuxng hack to avformat
-        s->parse_context.buffer=0;
-        MPV_common_end(s);
-        s->parse_context= pc;
-    }
-    if (!s->context_initialized) {
-        avcodec_set_dimensions(avctx, s->width, s->height);
-
-        goto retry;
-    }
-
-    if((s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P))
-        s->gob_index = ff_h263_get_gob_height(s);
-    
-    // for hurry_up==5
-    s->current_picture.pict_type= s->pict_type;
-    s->current_picture.key_frame= s->pict_type == I_TYPE;
-
-    /* skip B-frames if we don't have reference frames */
-    if(s->last_picture_ptr==NULL && (s->pict_type==B_TYPE || s->dropable)) return get_consumed_bytes(s, buf_size);
-    /* skip b frames if we are in a hurry */
-    if(avctx->hurry_up && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size);
-    if(   (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE)
-       || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE)
-       ||  avctx->skip_frame >= AVDISCARD_ALL) 
-        return get_consumed_bytes(s, buf_size);
-    /* skip everything if we are in a hurry>=5 */
-    if(avctx->hurry_up>=5) return get_consumed_bytes(s, buf_size);
-    
-    if(s->next_p_frame_damaged){
-        if(s->pict_type==B_TYPE)
-            return get_consumed_bytes(s, buf_size);
-        else
-            s->next_p_frame_damaged=0;
-    }
-
-    if(MPV_frame_start(s, avctx) < 0)
-        return -1;
-
-#ifdef DEBUG
-    printf("qscale=%d\n", s->qscale);
-#endif
-
-    ff_er_frame_start(s);
-    
-    //the second part of the wmv2 header contains the MB skip bits which are stored in current_picture->mb_type
-    //which isnt available before MPV_frame_start()
-    if (s->msmpeg4_version==5){
-        if(ff_wmv2_decode_secondary_picture_header(s) < 0)
-            return -1;
-    }
-
-    /* decode each macroblock */
-    s->mb_x=0; 
-    s->mb_y=0;
-    
-    decode_slice(s);
-    while(s->mb_y<s->mb_height){
-        if(s->msmpeg4_version){
-            if(s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_count(&s->gb) > s->gb.size_in_bits)
-                break;
-        }else{
-            if(ff_h263_resync(s)<0)
-                break;
-        }
-        
-        if(s->msmpeg4_version<4 && s->h263_pred)
-            ff_mpeg4_clean_buffers(s);
-
-        decode_slice(s);
-    }
-
-    if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE)
-        if(msmpeg4_decode_ext_header(s, buf_size) < 0){
-            s->error_status_table[s->mb_num-1]= AC_ERROR|DC_ERROR|MV_ERROR;
-        }
-    
-    /* divx 5.01+ bistream reorder stuff */
-    if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0 && s->divx_packed){
-        int current_pos= get_bits_count(&s->gb)>>3;
-        int startcode_found=0;
-        
-        if(buf_size - current_pos > 5){
-            int i;
-            for(i=current_pos; i<buf_size-3; i++){
-                if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){
-                    startcode_found=1;
-                    break;
-                }
-            }
-        }
-        if(s->gb.buffer == s->bitstream_buffer && buf_size>20){ //xvid style
-            startcode_found=1;
-            current_pos=0;
-        }
-
-        if(startcode_found){
-            s->bitstream_buffer= av_fast_realloc(
-                s->bitstream_buffer, 
-                &s->allocated_bitstream_buffer_size, 
-                buf_size - current_pos + FF_INPUT_BUFFER_PADDING_SIZE);
-            memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos);
-            s->bitstream_buffer_size= buf_size - current_pos;
-        }
-    }
-
-    ff_er_frame_end(s);
-
-    MPV_frame_end(s);
-
-assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);
-assert(s->current_picture.pict_type == s->pict_type);
-    if(s->pict_type==B_TYPE || s->low_delay){
-        *pict= *(AVFrame*)&s->current_picture;
-        ff_print_debug_info(s, pict);
-    } else {
-        *pict= *(AVFrame*)&s->last_picture;
-        if(pict)
-            ff_print_debug_info(s, pict);
-    }
-
-    /* Return the Picture timestamp as the frame number */
-    /* we substract 1 because it is added on utils.c    */
-    avctx->frame_number = s->picture_number - 1;
-
-    /* don't output the last pic after seeking */
-    if(s->last_picture_ptr || s->low_delay)
-        *data_size = sizeof(AVFrame);
-#ifdef PRINT_FRAME_TIME
-printf("%Ld\n", rdtsc()-time);
-#endif
-
-    return get_consumed_bytes(s, buf_size);
-}
-
-AVCodec mpeg4_decoder = {
-    "mpeg4",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MPEG4,
-    sizeof(MpegEncContext),
-    ff_h263_decode_init,
-    NULL,
-    ff_h263_decode_end,
-    ff_h263_decode_frame,
-    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
-    .flush= ff_mpeg_flush,
-};
-
-AVCodec h263_decoder = {
-    "h263",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_H263,
-    sizeof(MpegEncContext),
-    ff_h263_decode_init,
-    NULL,
-    ff_h263_decode_end,
-    ff_h263_decode_frame,
-    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
-    .flush= ff_mpeg_flush,
-};
-
-AVCodec msmpeg4v1_decoder = {
-    "msmpeg4v1",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MSMPEG4V1,
-    sizeof(MpegEncContext),
-    ff_h263_decode_init,
-    NULL,
-    ff_h263_decode_end,
-    ff_h263_decode_frame,
-    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
-};
-
-AVCodec msmpeg4v2_decoder = {
-    "msmpeg4v2",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MSMPEG4V2,
-    sizeof(MpegEncContext),
-    ff_h263_decode_init,
-    NULL,
-    ff_h263_decode_end,
-    ff_h263_decode_frame,
-    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
-};
-
-AVCodec msmpeg4v3_decoder = {
-    "msmpeg4",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MSMPEG4V3,
-    sizeof(MpegEncContext),
-    ff_h263_decode_init,
-    NULL,
-    ff_h263_decode_end,
-    ff_h263_decode_frame,
-    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
-};
-
-AVCodec wmv1_decoder = {
-    "wmv1",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_WMV1,
-    sizeof(MpegEncContext),
-    ff_h263_decode_init,
-    NULL,
-    ff_h263_decode_end,
-    ff_h263_decode_frame,
-    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
-};
-
-AVCodec h263i_decoder = {
-    "h263i",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_H263I,
-    sizeof(MpegEncContext),
-    ff_h263_decode_init,
-    NULL,
-    ff_h263_decode_end,
-    ff_h263_decode_frame,
-    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
-};
-
-AVCodec flv_decoder = {
-    "flv",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_FLV1,
-    sizeof(MpegEncContext),
-    ff_h263_decode_init,
-    NULL,
-    ff_h263_decode_end,
-    ff_h263_decode_frame,
-    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1
-};
-
-AVCodecParser h263_parser = {
-    { CODEC_ID_H263 },
-    sizeof(ParseContext),
-    NULL,
-    h263_parse,
-    ff_parse_close,
-};
diff --git a/ffmpeg.src/libavcodec/h264data.h b/ffmpeg.src/libavcodec/h264data.h
deleted file mode 100644
index 3e326bf..0000000
--- a/ffmpeg.src/libavcodec/h264data.h
+++ /dev/null
@@ -1,1256 +0,0 @@
-/*
- * H26L/H264/AVC/JVT/14496-10/... encoder/decoder
- * Copyright (c) 2003 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-/**
- * @file h264data.h
- * @brief 
- *     H264 / AVC / MPEG4 part10 codec data table
- * @author Michael Niedermayer <michaelni at gmx.at>
- */
-
-#define VERT_PRED             0
-#define HOR_PRED              1
-#define DC_PRED               2
-#define DIAG_DOWN_LEFT_PRED   3
-#define DIAG_DOWN_RIGHT_PRED  4
-#define VERT_RIGHT_PRED       5
-#define HOR_DOWN_PRED         6
-#define VERT_LEFT_PRED        7
-#define HOR_UP_PRED           8
-
-#define LEFT_DC_PRED          9
-#define TOP_DC_PRED           10
-#define DC_128_PRED           11
-
-
-#define DC_PRED8x8            0
-#define HOR_PRED8x8           1
-#define VERT_PRED8x8          2
-#define PLANE_PRED8x8         3
-
-#define LEFT_DC_PRED8x8       4
-#define TOP_DC_PRED8x8        5
-#define DC_128_PRED8x8        6
-
-#define EXTENDED_SAR          255
-
-static const AVRational pixel_aspect[14]={
- {0, 1},
- {1, 1},
- {12, 11},
- {10, 11},
- {16, 11},
- {40, 33},
- {24, 11},
- {20, 11},
- {32, 11},
- {80, 33},
- {18, 11},
- {15, 11},
- {64, 33},
- {160,99},
-};
-
-static const uint8_t golomb_to_pict_type[5]=
-{P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE};
-
-static const uint8_t pict_type_to_golomb[7]=
-{-1, 2, 0, 1, -1, 4, 3};
-
-static const uint8_t chroma_qp[52]={
-    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,29,30,31,32,32,33,34,34,35,35,36,36,37,37,
-   37,38,38,38,39,39,39,39
-
-};
-
-static const uint8_t golomb_to_intra4x4_cbp[48]={
- 47, 31, 15,  0, 23, 27, 29, 30,  7, 11, 13, 14, 39, 43, 45, 46,
- 16,  3,  5, 10, 12, 19, 21, 26, 28, 35, 37, 42, 44,  1,  2,  4,
-  8, 17, 18, 20, 24,  6,  9, 22, 25, 32, 33, 34, 36, 40, 38, 41
-};
- 
-static const uint8_t golomb_to_inter_cbp[48]={
-  0, 16,  1,  2,  4,  8, 32,  3,  5, 10, 12, 15, 47,  7, 11, 13,
- 14,  6,  9, 31, 35, 37, 42, 44, 33, 34, 36, 40, 39, 43, 45, 46,
- 17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41
-};
-
-static const uint8_t intra4x4_cbp_to_golomb[48]={
-  3, 29, 30, 17, 31, 18, 37,  8, 32, 38, 19,  9, 20, 10, 11,  2,
- 16, 33, 34, 21, 35, 22, 39,  4, 36, 40, 23,  5, 24,  6,  7,  1,
- 41, 42, 43, 25, 44, 26, 46, 12, 45, 47, 27, 13, 28, 14, 15,  0
-};
- 
-static const uint8_t inter_cbp_to_golomb[48]={
-  0,  2,  3,  7,  4,  8, 17, 13,  5, 18,  9, 14, 10, 15, 16, 11,
-  1, 32, 33, 36, 34, 37, 44, 40, 35, 45, 38, 41, 39, 42, 43, 19,
-  6, 24, 25, 20, 26, 21, 46, 28, 27, 47, 22, 29, 23, 30, 31, 12
-};
-
-static const uint8_t chroma_dc_coeff_token_len[4*5]={
- 2, 0, 0, 0,
- 6, 1, 0, 0,
- 6, 6, 3, 0,
- 6, 7, 7, 6,
- 6, 8, 8, 7,
-};
-
-static const uint8_t chroma_dc_coeff_token_bits[4*5]={
- 1, 0, 0, 0,
- 7, 1, 0, 0,
- 4, 6, 1, 0,
- 3, 3, 2, 5,
- 2, 3, 2, 0,
-};
-
-static const uint8_t coeff_token_len[4][4*17]={
-{
-     1, 0, 0, 0,
-     6, 2, 0, 0,     8, 6, 3, 0,     9, 8, 7, 5,    10, 9, 8, 6,
-    11,10, 9, 7,    13,11,10, 8,    13,13,11, 9,    13,13,13,10,
-    14,14,13,11,    14,14,14,13,    15,15,14,14,    15,15,15,14,
-    16,15,15,15,    16,16,16,15,    16,16,16,16,    16,16,16,16,
-},
-{
-     2, 0, 0, 0,
-     6, 2, 0, 0,     6, 5, 3, 0,     7, 6, 6, 4,     8, 6, 6, 4,
-     8, 7, 7, 5,     9, 8, 8, 6,    11, 9, 9, 6,    11,11,11, 7,
-    12,11,11, 9,    12,12,12,11,    12,12,12,11,    13,13,13,12,
-    13,13,13,13,    13,14,13,13,    14,14,14,13,    14,14,14,14,
-},
-{
-     4, 0, 0, 0,
-     6, 4, 0, 0,     6, 5, 4, 0,     6, 5, 5, 4,     7, 5, 5, 4,
-     7, 5, 5, 4,     7, 6, 6, 4,     7, 6, 6, 4,     8, 7, 7, 5,
-     8, 8, 7, 6,     9, 8, 8, 7,     9, 9, 8, 8,     9, 9, 9, 8,
-    10, 9, 9, 9,    10,10,10,10,    10,10,10,10,    10,10,10,10,
-},
-{
-     6, 0, 0, 0,
-     6, 6, 0, 0,     6, 6, 6, 0,     6, 6, 6, 6,     6, 6, 6, 6,
-     6, 6, 6, 6,     6, 6, 6, 6,     6, 6, 6, 6,     6, 6, 6, 6,
-     6, 6, 6, 6,     6, 6, 6, 6,     6, 6, 6, 6,     6, 6, 6, 6,
-     6, 6, 6, 6,     6, 6, 6, 6,     6, 6, 6, 6,     6, 6, 6, 6,
-}
-};
-
-static const uint8_t coeff_token_bits[4][4*17]={
-{
-     1, 0, 0, 0,
-     5, 1, 0, 0,     7, 4, 1, 0,     7, 6, 5, 3,     7, 6, 5, 3,
-     7, 6, 5, 4,    15, 6, 5, 4,    11,14, 5, 4,     8,10,13, 4,
-    15,14, 9, 4,    11,10,13,12,    15,14, 9,12,    11,10,13, 8,
-    15, 1, 9,12,    11,14,13, 8,     7,10, 9,12,     4, 6, 5, 8,
-},
-{
-     3, 0, 0, 0,
-    11, 2, 0, 0,     7, 7, 3, 0,     7,10, 9, 5,     7, 6, 5, 4,
-     4, 6, 5, 6,     7, 6, 5, 8,    15, 6, 5, 4,    11,14,13, 4,
-    15,10, 9, 4,    11,14,13,12,     8,10, 9, 8,    15,14,13,12,
-    11,10, 9,12,     7,11, 6, 8,     9, 8,10, 1,     7, 6, 5, 4,
-},
-{
-    15, 0, 0, 0,
-    15,14, 0, 0,    11,15,13, 0,     8,12,14,12,    15,10,11,11,
-    11, 8, 9,10,     9,14,13, 9,     8,10, 9, 8,    15,14,13,13,
-    11,14,10,12,    15,10,13,12,    11,14, 9,12,     8,10,13, 8,
-    13, 7, 9,12,     9,12,11,10,     5, 8, 7, 6,     1, 4, 3, 2,
-},
-{
-     3, 0, 0, 0,
-     0, 1, 0, 0,     4, 5, 6, 0,     8, 9,10,11,    12,13,14,15,
-    16,17,18,19,    20,21,22,23,    24,25,26,27,    28,29,30,31,
-    32,33,34,35,    36,37,38,39,    40,41,42,43,    44,45,46,47,
-    48,49,50,51,    52,53,54,55,    56,57,58,59,    60,61,62,63,
-}
-};
-
-static const uint8_t total_zeros_len[16][16]= {
-    {1,3,3,4,4,5,5,6,6,7,7,8,8,9,9,9},  
-    {3,3,3,3,3,4,4,4,4,5,5,6,6,6,6},  
-    {4,3,3,3,4,4,3,3,4,5,5,6,5,6},  
-    {5,3,4,4,3,3,3,4,3,4,5,5,5},  
-    {4,4,4,3,3,3,3,3,4,5,4,5},  
-    {6,5,3,3,3,3,3,3,4,3,6},  
-    {6,5,3,3,3,2,3,4,3,6},  
-    {6,4,5,3,2,2,3,3,6},  
-    {6,6,4,2,2,3,2,5},  
-    {5,5,3,2,2,2,4},  
-    {4,4,3,3,1,3},  
-    {4,4,2,1,3},  
-    {3,3,1,2},  
-    {2,2,1},  
-    {1,1},  
-};
-
-static const uint8_t total_zeros_bits[16][16]= {
-    {1,3,2,3,2,3,2,3,2,3,2,3,2,3,2,1},
-    {7,6,5,4,3,5,4,3,2,3,2,3,2,1,0},
-    {5,7,6,5,4,3,4,3,2,3,2,1,1,0},
-    {3,7,5,4,6,5,4,3,3,2,2,1,0},
-    {5,4,3,7,6,5,4,3,2,1,1,0},
-    {1,1,7,6,5,4,3,2,1,1,0},
-    {1,1,5,4,3,3,2,1,1,0},
-    {1,1,1,3,3,2,2,1,0},
-    {1,0,1,3,2,1,1,1},
-    {1,0,1,3,2,1,1},
-    {0,1,1,2,1,3},
-    {0,1,1,1,1},
-    {0,1,1,1},
-    {0,1,1},
-    {0,1},
-};
-
-static const uint8_t chroma_dc_total_zeros_len[3][4]= {
-    { 1, 2, 3, 3,},
-    { 1, 2, 2, 0,},
-    { 1, 1, 0, 0,}, 
-};
-
-static const uint8_t chroma_dc_total_zeros_bits[3][4]= {
-    { 1, 1, 1, 0,},
-    { 1, 1, 0, 0,},
-    { 1, 0, 0, 0,},
-};
-
-static const uint8_t run_len[7][16]={
-    {1,1},
-    {1,2,2},
-    {2,2,2,2},
-    {2,2,2,3,3},
-    {2,2,3,3,3,3},
-    {2,3,3,3,3,3,3},
-    {3,3,3,3,3,3,3,4,5,6,7,8,9,10,11},
-};
-
-static const uint8_t run_bits[7][16]={
-    {1,0},
-    {1,1,0},
-    {3,2,1,0},
-    {3,2,1,1,0},
-    {3,2,3,2,1,0},
-    {3,0,1,3,2,5,4},
-    {7,6,5,4,3,2,1,1,1,1,1,1,1,1,1},
-};
-
-/*
-o-o o-o
- / / /
-o-o o-o
- ,---'
-o-o o-o
- / / /
-o-o o-o
-*/
-
-static const uint8_t scan8[16 + 2*4]={
- 4+1*8, 5+1*8, 4+2*8, 5+2*8,
- 6+1*8, 7+1*8, 6+2*8, 7+2*8,
- 4+3*8, 5+3*8, 4+4*8, 5+4*8,
- 6+3*8, 7+3*8, 6+4*8, 7+4*8,
- 1+1*8, 2+1*8,
- 1+2*8, 2+2*8,
- 1+4*8, 2+4*8,
- 1+5*8, 2+5*8,
-};
-
-static const uint8_t zigzag_scan[16]={
- 0+0*4, 1+0*4, 0+1*4, 0+2*4, 
- 1+1*4, 2+0*4, 3+0*4, 2+1*4, 
- 1+2*4, 0+3*4, 1+3*4, 2+2*4, 
- 3+1*4, 3+2*4, 2+3*4, 3+3*4, 
-};
-
-static const uint8_t field_scan[16]={
- 0+0*4, 0+1*4, 1+0*4, 0+2*4, 
- 0+3*4, 1+1*4, 1+2*4, 1+3*4,
- 2+0*4, 2+1*4, 2+2*4, 2+3*4, 
- 3+0*4, 3+1*4, 3+2*4, 3+3*4,
-};
-
-static const uint8_t luma_dc_zigzag_scan[16]={
- 0*16 + 0*64, 1*16 + 0*64, 2*16 + 0*64, 0*16 + 2*64,
- 3*16 + 0*64, 0*16 + 1*64, 1*16 + 1*64, 2*16 + 1*64,
- 1*16 + 2*64, 2*16 + 2*64, 3*16 + 2*64, 0*16 + 3*64,
- 3*16 + 1*64, 1*16 + 3*64, 2*16 + 3*64, 3*16 + 3*64,
-};
-
-static const uint8_t luma_dc_field_scan[16]={
- 0*16 + 0*64, 2*16 + 0*64, 1*16 + 0*64, 0*16 + 2*64, 
- 2*16 + 2*64, 3*16 + 0*64, 1*16 + 2*64, 3*16 + 2*64, 
- 0*16 + 1*64, 2*16 + 1*64, 0*16 + 3*64, 2*16 + 3*64, 
- 1*16 + 1*64, 3*16 + 1*64, 1*16 + 3*64, 3*16 + 3*64,
-};
-
-static const uint8_t chroma_dc_scan[4]={
- (0+0*2)*16, (1+0*2)*16, 
- (0+1*2)*16, (1+1*2)*16,  //FIXME
-};
-
-static const uint8_t zigzag_scan8x8[64]={
- 0+0*8, 1+0*8, 0+1*8, 0+2*8,
- 1+1*8, 2+0*8, 3+0*8, 2+1*8,
- 1+2*8, 0+3*8, 0+4*8, 1+3*8,
- 2+2*8, 3+1*8, 4+0*8, 5+0*8,
- 4+1*8, 3+2*8, 2+3*8, 1+4*8,
- 0+5*8, 0+6*8, 1+5*8, 2+4*8,
- 3+3*8, 4+2*8, 5+1*8, 6+0*8,
- 7+0*8, 6+1*8, 5+2*8, 4+3*8,
- 3+4*8, 2+5*8, 1+6*8, 0+7*8,
- 1+7*8, 2+6*8, 3+5*8, 4+4*8,
- 5+3*8, 6+2*8, 7+1*8, 7+2*8,
- 6+3*8, 5+4*8, 4+5*8, 3+6*8,
- 2+7*8, 3+7*8, 4+6*8, 5+5*8,
- 6+4*8, 7+3*8, 7+4*8, 6+5*8,
- 5+6*8, 4+7*8, 5+7*8, 6+6*8,
- 7+5*8, 7+6*8, 6+7*8, 7+7*8,
-};
-
-// zigzag_scan8x8_cavlc[i] = zigzag_scan8x8[(i/4) + 16*(i%4)]
-static const uint8_t zigzag_scan8x8_cavlc[64]={
- 0+0*8, 1+1*8, 1+2*8, 2+2*8,
- 4+1*8, 0+5*8, 3+3*8, 7+0*8,
- 3+4*8, 1+7*8, 5+3*8, 6+3*8,
- 2+7*8, 6+4*8, 5+6*8, 7+5*8,
- 1+0*8, 2+0*8, 0+3*8, 3+1*8,
- 3+2*8, 0+6*8, 4+2*8, 6+1*8,
- 2+5*8, 2+6*8, 6+2*8, 5+4*8,
- 3+7*8, 7+3*8, 4+7*8, 7+6*8,
- 0+1*8, 3+0*8, 0+4*8, 4+0*8,
- 2+3*8, 1+5*8, 5+1*8, 5+2*8,
- 1+6*8, 3+5*8, 7+1*8, 4+5*8,
- 4+6*8, 7+4*8, 5+7*8, 6+7*8,
- 0+2*8, 2+1*8, 1+3*8, 5+0*8,
- 1+4*8, 2+4*8, 6+0*8, 4+3*8,
- 0+7*8, 4+4*8, 7+2*8, 3+6*8,
- 5+5*8, 6+5*8, 6+6*8, 7+7*8,
-};
-
-#define MB_TYPE_REF0       MB_TYPE_ACPRED //dirty but it fits in 16bit
-#define MB_TYPE_8x8DCT     0x01000000
-#define IS_REF0(a)       ((a)&MB_TYPE_REF0)
-#define IS_8x8DCT(a)     ((a)&MB_TYPE_8x8DCT)
-
-
-typedef struct IMbInfo{
-    uint16_t type;
-    uint8_t pred_mode;
-    uint8_t cbp;
-} IMbInfo;
-
-static const IMbInfo i_mb_type_info[26]={
-{MB_TYPE_INTRA4x4  , -1, -1},
-{MB_TYPE_INTRA16x16,  2,  0},
-{MB_TYPE_INTRA16x16,  1,  0},
-{MB_TYPE_INTRA16x16,  0,  0},
-{MB_TYPE_INTRA16x16,  3,  0},
-{MB_TYPE_INTRA16x16,  2,  16},
-{MB_TYPE_INTRA16x16,  1,  16},
-{MB_TYPE_INTRA16x16,  0,  16},
-{MB_TYPE_INTRA16x16,  3,  16},
-{MB_TYPE_INTRA16x16,  2,  32},
-{MB_TYPE_INTRA16x16,  1,  32},
-{MB_TYPE_INTRA16x16,  0,  32},
-{MB_TYPE_INTRA16x16,  3,  32},
-{MB_TYPE_INTRA16x16,  2,  15+0},
-{MB_TYPE_INTRA16x16,  1,  15+0},
-{MB_TYPE_INTRA16x16,  0,  15+0},
-{MB_TYPE_INTRA16x16,  3,  15+0},
-{MB_TYPE_INTRA16x16,  2,  15+16},
-{MB_TYPE_INTRA16x16,  1,  15+16},
-{MB_TYPE_INTRA16x16,  0,  15+16},
-{MB_TYPE_INTRA16x16,  3,  15+16},
-{MB_TYPE_INTRA16x16,  2,  15+32},
-{MB_TYPE_INTRA16x16,  1,  15+32},
-{MB_TYPE_INTRA16x16,  0,  15+32},
-{MB_TYPE_INTRA16x16,  3,  15+32},
-{MB_TYPE_INTRA_PCM , -1, -1},
-};
-
-typedef struct PMbInfo{
-    uint16_t type;
-    uint8_t partition_count;
-} PMbInfo;
-
-static const PMbInfo p_mb_type_info[5]={
-{MB_TYPE_16x16|MB_TYPE_P0L0             , 1},
-{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P1L0, 2},
-{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P1L0, 2},
-{MB_TYPE_8x8  |MB_TYPE_P0L0|MB_TYPE_P1L0, 4},
-{MB_TYPE_8x8  |MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_REF0, 4},
-};
-
-static const PMbInfo p_sub_mb_type_info[4]={
-{MB_TYPE_16x16|MB_TYPE_P0L0             , 1},
-{MB_TYPE_16x8 |MB_TYPE_P0L0             , 2},
-{MB_TYPE_8x16 |MB_TYPE_P0L0             , 2},
-{MB_TYPE_8x8  |MB_TYPE_P0L0             , 4},
-};
-
-static const PMbInfo b_mb_type_info[23]={
-{MB_TYPE_DIRECT2                                                   , 1, },
-{MB_TYPE_16x16|MB_TYPE_P0L0                                       , 1, },
-{MB_TYPE_16x16             |MB_TYPE_P0L1                          , 1, },
-{MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1                          , 1, },
-{MB_TYPE_16x8 |MB_TYPE_P0L0             |MB_TYPE_P1L0             , 2, },
-{MB_TYPE_8x16 |MB_TYPE_P0L0             |MB_TYPE_P1L0             , 2, },
-{MB_TYPE_16x8              |MB_TYPE_P0L1             |MB_TYPE_P1L1, 2, },
-{MB_TYPE_8x16              |MB_TYPE_P0L1             |MB_TYPE_P1L1, 2, },
-{MB_TYPE_16x8 |MB_TYPE_P0L0                          |MB_TYPE_P1L1, 2, },
-{MB_TYPE_8x16 |MB_TYPE_P0L0                          |MB_TYPE_P1L1, 2, },
-{MB_TYPE_16x8              |MB_TYPE_P0L1|MB_TYPE_P1L0             , 2, },
-{MB_TYPE_8x16              |MB_TYPE_P0L1|MB_TYPE_P1L0             , 2, },
-{MB_TYPE_16x8 |MB_TYPE_P0L0             |MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
-{MB_TYPE_8x16 |MB_TYPE_P0L0             |MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
-{MB_TYPE_16x8              |MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
-{MB_TYPE_8x16              |MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
-{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0             , 2, },
-{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0             , 2, },
-{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1             |MB_TYPE_P1L1, 2, },
-{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1             |MB_TYPE_P1L1, 2, },
-{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
-{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
-{MB_TYPE_8x8  |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 4, },
-};
-
-static const PMbInfo b_sub_mb_type_info[13]={
-{MB_TYPE_DIRECT2                                                   , 1, },
-{MB_TYPE_16x16|MB_TYPE_P0L0                                       , 1, },
-{MB_TYPE_16x16             |MB_TYPE_P0L1                          , 1, },
-{MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1                          , 1, },
-{MB_TYPE_16x8 |MB_TYPE_P0L0             |MB_TYPE_P1L0             , 2, },
-{MB_TYPE_8x16 |MB_TYPE_P0L0             |MB_TYPE_P1L0             , 2, },
-{MB_TYPE_16x8              |MB_TYPE_P0L1             |MB_TYPE_P1L1, 2, },
-{MB_TYPE_8x16              |MB_TYPE_P0L1             |MB_TYPE_P1L1, 2, },
-{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
-{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, },
-{MB_TYPE_8x8  |MB_TYPE_P0L0             |MB_TYPE_P1L0             , 4, },
-{MB_TYPE_8x8               |MB_TYPE_P0L1             |MB_TYPE_P1L1, 4, },
-{MB_TYPE_8x8  |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 4, },
-};
-
-
-static const uint8_t rem6[52]={
-0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 
-};
-
-static const uint8_t div6[52]={
-0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,
-};
-
-static const uint16_t dequant_coeff[52][16]={
-{  10,  13,  10,  13,   13,  16,  13,  16,   10,  13,  10,  13,   13,  16,  13,  16, },
-{  11,  14,  11,  14,   14,  18,  14,  18,   11,  14,  11,  14,   14,  18,  14,  18, },
-{  13,  16,  13,  16,   16,  20,  16,  20,   13,  16,  13,  16,   16,  20,  16,  20, },
-{  14,  18,  14,  18,   18,  23,  18,  23,   14,  18,  14,  18,   18,  23,  18,  23, },
-{  16,  20,  16,  20,   20,  25,  20,  25,   16,  20,  16,  20,   20,  25,  20,  25, },
-{  18,  23,  18,  23,   23,  29,  23,  29,   18,  23,  18,  23,   23,  29,  23,  29, },
-{  20,  26,  20,  26,   26,  32,  26,  32,   20,  26,  20,  26,   26,  32,  26,  32, },
-{  22,  28,  22,  28,   28,  36,  28,  36,   22,  28,  22,  28,   28,  36,  28,  36, },
-{  26,  32,  26,  32,   32,  40,  32,  40,   26,  32,  26,  32,   32,  40,  32,  40, },
-{  28,  36,  28,  36,   36,  46,  36,  46,   28,  36,  28,  36,   36,  46,  36,  46, },
-{  32,  40,  32,  40,   40,  50,  40,  50,   32,  40,  32,  40,   40,  50,  40,  50, },
-{  36,  46,  36,  46,   46,  58,  46,  58,   36,  46,  36,  46,   46,  58,  46,  58, },
-{  40,  52,  40,  52,   52,  64,  52,  64,   40,  52,  40,  52,   52,  64,  52,  64, },
-{  44,  56,  44,  56,   56,  72,  56,  72,   44,  56,  44,  56,   56,  72,  56,  72, },
-{  52,  64,  52,  64,   64,  80,  64,  80,   52,  64,  52,  64,   64,  80,  64,  80, },
-{  56,  72,  56,  72,   72,  92,  72,  92,   56,  72,  56,  72,   72,  92,  72,  92, },
-{  64,  80,  64,  80,   80, 100,  80, 100,   64,  80,  64,  80,   80, 100,  80, 100, },
-{  72,  92,  72,  92,   92, 116,  92, 116,   72,  92,  72,  92,   92, 116,  92, 116, },
-{  80, 104,  80, 104,  104, 128, 104, 128,   80, 104,  80, 104,  104, 128, 104, 128, },
-{  88, 112,  88, 112,  112, 144, 112, 144,   88, 112,  88, 112,  112, 144, 112, 144, },
-{ 104, 128, 104, 128,  128, 160, 128, 160,  104, 128, 104, 128,  128, 160, 128, 160, },
-{ 112, 144, 112, 144,  144, 184, 144, 184,  112, 144, 112, 144,  144, 184, 144, 184, },
-{ 128, 160, 128, 160,  160, 200, 160, 200,  128, 160, 128, 160,  160, 200, 160, 200, },
-{ 144, 184, 144, 184,  184, 232, 184, 232,  144, 184, 144, 184,  184, 232, 184, 232, },
-{ 160, 208, 160, 208,  208, 256, 208, 256,  160, 208, 160, 208,  208, 256, 208, 256, },
-{ 176, 224, 176, 224,  224, 288, 224, 288,  176, 224, 176, 224,  224, 288, 224, 288, },
-{ 208, 256, 208, 256,  256, 320, 256, 320,  208, 256, 208, 256,  256, 320, 256, 320, },
-{ 224, 288, 224, 288,  288, 368, 288, 368,  224, 288, 224, 288,  288, 368, 288, 368, },
-{ 256, 320, 256, 320,  320, 400, 320, 400,  256, 320, 256, 320,  320, 400, 320, 400, },
-{ 288, 368, 288, 368,  368, 464, 368, 464,  288, 368, 288, 368,  368, 464, 368, 464, },
-{ 320, 416, 320, 416,  416, 512, 416, 512,  320, 416, 320, 416,  416, 512, 416, 512, },
-{ 352, 448, 352, 448,  448, 576, 448, 576,  352, 448, 352, 448,  448, 576, 448, 576, },
-{ 416, 512, 416, 512,  512, 640, 512, 640,  416, 512, 416, 512,  512, 640, 512, 640, },
-{ 448, 576, 448, 576,  576, 736, 576, 736,  448, 576, 448, 576,  576, 736, 576, 736, },
-{ 512, 640, 512, 640,  640, 800, 640, 800,  512, 640, 512, 640,  640, 800, 640, 800, },
-{ 576, 736, 576, 736,  736, 928, 736, 928,  576, 736, 576, 736,  736, 928, 736, 928, },
-{ 640, 832, 640, 832,  832,1024, 832,1024,  640, 832, 640, 832,  832,1024, 832,1024, },
-{ 704, 896, 704, 896,  896,1152, 896,1152,  704, 896, 704, 896,  896,1152, 896,1152, },
-{ 832,1024, 832,1024, 1024,1280,1024,1280,  832,1024, 832,1024, 1024,1280,1024,1280, },
-{ 896,1152, 896,1152, 1152,1472,1152,1472,  896,1152, 896,1152, 1152,1472,1152,1472, },
-{1024,1280,1024,1280, 1280,1600,1280,1600, 1024,1280,1024,1280, 1280,1600,1280,1600, },
-{1152,1472,1152,1472, 1472,1856,1472,1856, 1152,1472,1152,1472, 1472,1856,1472,1856, },
-{1280,1664,1280,1664, 1664,2048,1664,2048, 1280,1664,1280,1664, 1664,2048,1664,2048, },
-{1408,1792,1408,1792, 1792,2304,1792,2304, 1408,1792,1408,1792, 1792,2304,1792,2304, },
-{1664,2048,1664,2048, 2048,2560,2048,2560, 1664,2048,1664,2048, 2048,2560,2048,2560, },
-{1792,2304,1792,2304, 2304,2944,2304,2944, 1792,2304,1792,2304, 2304,2944,2304,2944, },
-{2048,2560,2048,2560, 2560,3200,2560,3200, 2048,2560,2048,2560, 2560,3200,2560,3200, },
-{2304,2944,2304,2944, 2944,3712,2944,3712, 2304,2944,2304,2944, 2944,3712,2944,3712, },
-{2560,3328,2560,3328, 3328,4096,3328,4096, 2560,3328,2560,3328, 3328,4096,3328,4096, },
-{2816,3584,2816,3584, 3584,4608,3584,4608, 2816,3584,2816,3584, 3584,4608,3584,4608, },
-{3328,4096,3328,4096, 4096,5120,4096,5120, 3328,4096,3328,4096, 4096,5120,4096,5120, },
-{3584,4608,3584,4608, 4608,5888,4608,5888, 3584,4608,3584,4608, 4608,5888,4608,5888, },
-//{4096,5120,4096,5120, 5120,6400,5120,6400, 4096,5120,4096,5120, 5120,6400,5120,6400, },
-//{4608,5888,4608,5888, 5888,7424,5888,7424, 4608,5888,4608,5888, 5888,7424,5888,7424, },
-};
-
-static const int dequant8_coeff_init_scan[16] = {
-  0,3,4,3, 3,1,5,1, 4,5,2,5, 3,1,5,1
-};
-static const int dequant8_coeff_init[6][6]={
-  {20,18,32,19,25,24},
-  {22,19,35,21,28,26},
-  {26,23,42,24,33,31},
-  {28,25,45,26,35,33},
-  {32,28,51,30,40,38},
-  {36,32,58,34,46,43},
-};
-
-#define QUANT_SHIFT 22
-
-static const int quant_coeff[52][16]={
-    { 419430,258111,419430,258111,258111,167772,258111,167772,419430,258111,419430,258111,258111,167772,258111,167772,},
-    { 381300,239675,381300,239675,239675,149131,239675,149131,381300,239675,381300,239675,239675,149131,239675,149131,},
-    { 322639,209715,322639,209715,209715,134218,209715,134218,322639,209715,322639,209715,209715,134218,209715,134218,},
-    { 299593,186414,299593,186414,186414,116711,186414,116711,299593,186414,299593,186414,186414,116711,186414,116711,},
-    { 262144,167772,262144,167772,167772,107374,167772,107374,262144,167772,262144,167772,167772,107374,167772,107374,},
-    { 233017,145889,233017,145889,145889, 92564,145889, 92564,233017,145889,233017,145889,145889, 92564,145889, 92564,},
-    { 209715,129056,209715,129056,129056, 83886,129056, 83886,209715,129056,209715,129056,129056, 83886,129056, 83886,},
-    { 190650,119837,190650,119837,119837, 74565,119837, 74565,190650,119837,190650,119837,119837, 74565,119837, 74565,},
-    { 161319,104858,161319,104858,104858, 67109,104858, 67109,161319,104858,161319,104858,104858, 67109,104858, 67109,},
-    { 149797, 93207,149797, 93207, 93207, 58356, 93207, 58356,149797, 93207,149797, 93207, 93207, 58356, 93207, 58356,},
-    { 131072, 83886,131072, 83886, 83886, 53687, 83886, 53687,131072, 83886,131072, 83886, 83886, 53687, 83886, 53687,},
-    { 116508, 72944,116508, 72944, 72944, 46282, 72944, 46282,116508, 72944,116508, 72944, 72944, 46282, 72944, 46282,},
-    { 104858, 64528,104858, 64528, 64528, 41943, 64528, 41943,104858, 64528,104858, 64528, 64528, 41943, 64528, 41943,},
-    {  95325, 59919, 95325, 59919, 59919, 37283, 59919, 37283, 95325, 59919, 95325, 59919, 59919, 37283, 59919, 37283,},
-    {  80660, 52429, 80660, 52429, 52429, 33554, 52429, 33554, 80660, 52429, 80660, 52429, 52429, 33554, 52429, 33554,},
-    {  74898, 46603, 74898, 46603, 46603, 29178, 46603, 29178, 74898, 46603, 74898, 46603, 46603, 29178, 46603, 29178,},
-    {  65536, 41943, 65536, 41943, 41943, 26844, 41943, 26844, 65536, 41943, 65536, 41943, 41943, 26844, 41943, 26844,},
-    {  58254, 36472, 58254, 36472, 36472, 23141, 36472, 23141, 58254, 36472, 58254, 36472, 36472, 23141, 36472, 23141,},
-    {  52429, 32264, 52429, 32264, 32264, 20972, 32264, 20972, 52429, 32264, 52429, 32264, 32264, 20972, 32264, 20972,},
-    {  47663, 29959, 47663, 29959, 29959, 18641, 29959, 18641, 47663, 29959, 47663, 29959, 29959, 18641, 29959, 18641,},
-    {  40330, 26214, 40330, 26214, 26214, 16777, 26214, 16777, 40330, 26214, 40330, 26214, 26214, 16777, 26214, 16777,},
-    {  37449, 23302, 37449, 23302, 23302, 14589, 23302, 14589, 37449, 23302, 37449, 23302, 23302, 14589, 23302, 14589,},
-    {  32768, 20972, 32768, 20972, 20972, 13422, 20972, 13422, 32768, 20972, 32768, 20972, 20972, 13422, 20972, 13422,},
-    {  29127, 18236, 29127, 18236, 18236, 11570, 18236, 11570, 29127, 18236, 29127, 18236, 18236, 11570, 18236, 11570,},
-    {  26214, 16132, 26214, 16132, 16132, 10486, 16132, 10486, 26214, 16132, 26214, 16132, 16132, 10486, 16132, 10486,},
-    {  23831, 14980, 23831, 14980, 14980,  9321, 14980,  9321, 23831, 14980, 23831, 14980, 14980,  9321, 14980,  9321,},
-    {  20165, 13107, 20165, 13107, 13107,  8389, 13107,  8389, 20165, 13107, 20165, 13107, 13107,  8389, 13107,  8389,},
-    {  18725, 11651, 18725, 11651, 11651,  7294, 11651,  7294, 18725, 11651, 18725, 11651, 11651,  7294, 11651,  7294,},
-    {  16384, 10486, 16384, 10486, 10486,  6711, 10486,  6711, 16384, 10486, 16384, 10486, 10486,  6711, 10486,  6711,},
-    {  14564,  9118, 14564,  9118,  9118,  5785,  9118,  5785, 14564,  9118, 14564,  9118,  9118,  5785,  9118,  5785,},
-    {  13107,  8066, 13107,  8066,  8066,  5243,  8066,  5243, 13107,  8066, 13107,  8066,  8066,  5243,  8066,  5243,},
-    {  11916,  7490, 11916,  7490,  7490,  4660,  7490,  4660, 11916,  7490, 11916,  7490,  7490,  4660,  7490,  4660,},
-    {  10082,  6554, 10082,  6554,  6554,  4194,  6554,  4194, 10082,  6554, 10082,  6554,  6554,  4194,  6554,  4194,},
-    {   9362,  5825,  9362,  5825,  5825,  3647,  5825,  3647,  9362,  5825,  9362,  5825,  5825,  3647,  5825,  3647,},
-    {   8192,  5243,  8192,  5243,  5243,  3355,  5243,  3355,  8192,  5243,  8192,  5243,  5243,  3355,  5243,  3355,},
-    {   7282,  4559,  7282,  4559,  4559,  2893,  4559,  2893,  7282,  4559,  7282,  4559,  4559,  2893,  4559,  2893,},
-    {   6554,  4033,  6554,  4033,  4033,  2621,  4033,  2621,  6554,  4033,  6554,  4033,  4033,  2621,  4033,  2621,},
-    {   5958,  3745,  5958,  3745,  3745,  2330,  3745,  2330,  5958,  3745,  5958,  3745,  3745,  2330,  3745,  2330,},
-    {   5041,  3277,  5041,  3277,  3277,  2097,  3277,  2097,  5041,  3277,  5041,  3277,  3277,  2097,  3277,  2097,},
-    {   4681,  2913,  4681,  2913,  2913,  1824,  2913,  1824,  4681,  2913,  4681,  2913,  2913,  1824,  2913,  1824,},
-    {   4096,  2621,  4096,  2621,  2621,  1678,  2621,  1678,  4096,  2621,  4096,  2621,  2621,  1678,  2621,  1678,},
-    {   3641,  2280,  3641,  2280,  2280,  1446,  2280,  1446,  3641,  2280,  3641,  2280,  2280,  1446,  2280,  1446,},
-    {   3277,  2016,  3277,  2016,  2016,  1311,  2016,  1311,  3277,  2016,  3277,  2016,  2016,  1311,  2016,  1311,},
-    {   2979,  1872,  2979,  1872,  1872,  1165,  1872,  1165,  2979,  1872,  2979,  1872,  1872,  1165,  1872,  1165,},
-    {   2521,  1638,  2521,  1638,  1638,  1049,  1638,  1049,  2521,  1638,  2521,  1638,  1638,  1049,  1638,  1049,},
-    {   2341,  1456,  2341,  1456,  1456,   912,  1456,   912,  2341,  1456,  2341,  1456,  1456,   912,  1456,   912,},
-    {   2048,  1311,  2048,  1311,  1311,   839,  1311,   839,  2048,  1311,  2048,  1311,  1311,   839,  1311,   839,},
-    {   1820,  1140,  1820,  1140,  1140,   723,  1140,   723,  1820,  1140,  1820,  1140,  1140,   723,  1140,   723,},
-    {   1638,  1008,  1638,  1008,  1008,   655,  1008,   655,  1638,  1008,  1638,  1008,  1008,   655,  1008,   655,},
-    {   1489,   936,  1489,   936,   936,   583,   936,   583,  1489,   936,  1489,   936,   936,   583,   936,   583,},
-    {   1260,   819,  1260,   819,   819,   524,   819,   524,  1260,   819,  1260,   819,   819,   524,   819,   524,},
-    {   1170,   728,  1170,   728,   728,   456,   728,   456,  1170,   728,  1170,   728,   728,   456,   728,   456,},
-};
-
-
-/* Deblocking filter (p153) */
-static const int alpha_table[52] = {
-     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-     0,  0,  0,  0,  0,  0,  4,  4,  5,  6,
-     7,  8,  9, 10, 12, 13, 15, 17, 20, 22,
-    25, 28, 32, 36, 40, 45, 50, 56, 63, 71,
-    80, 90,101,113,127,144,162,182,203,226,
-    255, 255
-};
-static const int beta_table[52] = {
-     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-     0,  0,  0,  0,  0,  0,  2,  2,  2,  3,
-     3,  3,  3,  4,  4,  4,  6,  6,  7,  7,
-     8,  8,  9,  9, 10, 10, 11, 11, 12, 12,
-    13, 13, 14, 14, 15, 15, 16, 16, 17, 17,
-    18, 18
-};
-static const int tc0_table[52][3] = {
-    { 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 }, { 0, 0, 1 },
-    { 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 }, { 0, 1, 1 }, { 0, 1, 1 }, { 1, 1, 1 },
-    { 1, 1, 1 }, { 1, 1, 1 }, { 1, 1, 1 }, { 1, 1, 2 }, { 1, 1, 2 }, { 1, 1, 2 },
-    { 1, 1, 2 }, { 1, 2, 3 }, { 1, 2, 3 }, { 2, 2, 3 }, { 2, 2, 4 }, { 2, 3, 4 },
-    { 2, 3, 4 }, { 3, 3, 5 }, { 3, 4, 6 }, { 3, 4, 6 }, { 4, 5, 7 }, { 4, 5, 8 },
-    { 4, 6, 9 }, { 5, 7,10 }, { 6, 8,11 }, { 6, 8,13 }, { 7,10,14 }, { 8,11,16 },
-    { 9,12,18 }, {10,13,20 }, {11,15,23 }, {13,17,25 }
-};
-
-/* Cabac pre state table */
-
-static const int cabac_context_init_I[460][2] =
-{
-    /* 0 - 10 */
-    { 20, -15 }, {  2, 54 },  {  3,  74 }, { 20, -15 },
-    {  2,  54 }, {  3, 74 },  { -28,127 }, { -23, 104 },
-    { -6,  53 }, { -1, 54 },  {  7,  51 },
-
-    /* 11 - 23 unsused for I */
-    { 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 },
-
-    /* 24- 39 */
-    { 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 },
-
-    /* 40 - 53 */
-    { 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 },
-
-    /* 54 - 59 */
-    { 0, 0 },    { 0, 0 },    { 0, 0 },      { 0, 0 },
-    { 0, 0 },    { 0, 0 },
-
-    /* 60 - 69 */
-    { 0, 41 },   { 0, 63 },   { 0, 63 },     { 0, 63 },
-    { -9, 83 },  { 4, 86 },   { 0, 97 },     { -7, 72 },
-    { 13, 41 },  { 3, 62 },
-
-    /* 70 -> 87 */
-    { 0, 11 },   { 1, 55 },   { 0, 69 },     { -17, 127 },
-    { -13, 102 },{ 0, 82 },   { -7, 74 },    { -21, 107 },
-    { -27, 127 },{ -31, 127 },{ -24, 127 },  { -18, 95 },
-    { -27, 127 },{ -21, 114 },{ -30, 127 },  { -17, 123 },
-    { -12, 115 },{ -16, 122 },
-
-    /* 88 -> 104 */
-    { -11, 115 },{ -12, 63 }, { -2, 68 },    { -15, 84 },
-    { -13, 104 },{ -3, 70 },  { -8, 93 },    { -10, 90 },
-    { -30, 127 },{ -1, 74 },  { -6, 97 },    { -7, 91 },
-    { -20, 127 },{ -4, 56 },  { -5, 82 },    { -7, 76 },
-    { -22, 125 },
-
-    /* 105 -> 135 */
-    { -7, 93 },  { -11, 87 }, { -3, 77 },    { -5, 71 },
-    { -4, 63 },  { -4, 68 },  { -12, 84 },   { -7, 62 },
-    { -7, 65 },  { 8, 61 },   { 5, 56 },     { -2, 66 },
-    { 1, 64 },   { 0, 61 },   { -2, 78 },    { 1, 50 },
-    { 7, 52 },   { 10, 35 },  { 0, 44 },     { 11, 38 },
-    { 1, 45 },   { 0, 46 },   { 5, 44 },     { 31, 17 },
-    { 1, 51 },   { 7, 50 },   { 28, 19 },    { 16, 33 },
-    { 14, 62 },  { -13, 108 },{ -15, 100 },
-
-    /* 136 -> 165 */
-    { -13, 101 },{ -13, 91 }, { -12, 94 },   { -10, 88 },
-    { -16, 84 }, { -10, 86 }, { -7, 83 },    { -13, 87 },
-    { -19, 94 }, { 1, 70 },   { 0, 72 },     { -5, 74 },
-    { 18, 59 },  { -8, 102 }, { -15, 100 },  { 0, 95 },
-    { -4, 75 },  { 2, 72 },   { -11, 75 },   { -3, 71 },
-    { 15, 46 },  { -13, 69 }, { 0, 62 },     { 0, 65 },
-    { 21, 37 },  { -15, 72 }, { 9, 57 },     { 16, 54 },
-    { 0, 62 },   { 12, 72 },
-
-    /* 166 -> 196 */
-    { 24, 0 },   { 15, 9 },   { 8, 25 },     { 13, 18 },
-    { 15, 9 },   { 13, 19 },  { 10, 37 },    { 12, 18 },
-    { 6, 29 },   { 20, 33 },  { 15, 30 },    { 4, 45 },
-    { 1, 58 },   { 0, 62 },   { 7, 61 },     { 12, 38 },
-    { 11, 45 },  { 15, 39 },  { 11, 42 },    { 13, 44 },
-    { 16, 45 },  { 12, 41 },  { 10, 49 },    { 30, 34 },
-    { 18, 42 },  { 10, 55 },  { 17, 51 },    { 17, 46 },
-    { 0, 89 },   { 26, -19 }, { 22, -17 },
-
-    /* 197 -> 226 */
-    { 26, -17 }, { 30, -25 }, { 28, -20 },   { 33, -23 },
-    { 37, -27 }, { 33, -23 }, { 40, -28 },   { 38, -17 },
-    { 33, -11 }, { 40, -15 }, { 41, -6 },    { 38, 1 },
-    { 41, 17 },  { 30, -6 },  { 27, 3 },     { 26, 22 },
-    { 37, -16 }, { 35, -4 },  { 38, -8 },    { 38, -3 },
-    { 37, 3 },   { 38, 5 },   { 42, 0 },     { 35, 16 },
-    { 39, 22 },  { 14, 48 },  { 27, 37 },    { 21, 60 },
-    { 12, 68 },  { 2, 97 },
-
-    /* 227 -> 251 */
-    { -3, 71 },  { -6, 42 },  { -5, 50 },    { -3, 54 },
-    { -2, 62 },  { 0, 58 },   { 1, 63 },     { -2, 72 },
-    { -1, 74 },  { -9, 91 },  { -5, 67 },    { -5, 27 },
-    { -3, 39 },  { -2, 44 },  { 0, 46 },     { -16, 64 },
-    { -8, 68 },  { -10, 78 }, { -6, 77 },    { -10, 86 },
-    { -12, 92 }, { -15, 55 }, { -10, 60 },   { -6, 62 },
-    { -4, 65 },
-
-    /* 252 -> 275 */
-    { -12, 73 }, { -8, 76 },  { -7, 80 },    { -9, 88 },
-    { -17, 110 },{ -11, 97 }, { -20, 84 },   { -11, 79 },
-    { -6, 73 },  { -4, 74 },  { -13, 86 },   { -13, 96 },
-    { -11, 97 }, { -19, 117 },{ -8, 78 },    { -5, 33 },
-    { -4, 48 },  { -2, 53 },  { -3, 62 },    { -13, 71 },
-    { -10, 79 }, { -12, 86 }, { -13, 90 },   { -14, 97 },
-
-    /* 276 a bit special (not used, bypass is used instead) */
-    { 0, 0 },
-
-    /* 277 -> 307 */
-    { -6, 93 },  { -6, 84 },  { -8, 79 },    { 0, 66 },
-    { -1, 71 },  { 0, 62 },   { -2, 60 },    { -2, 59 },
-    { -5, 75 },  { -3, 62 },  { -4, 58 },    { -9, 66 },
-    { -1, 79 },  { 0, 71 },   { 3, 68 },     { 10, 44 },
-    { -7, 62 },  { 15, 36 },  { 14, 40 },    { 16, 27 },
-    { 12, 29 },  { 1, 44 },   { 20, 36 },    { 18, 32 },
-    { 5, 42 },   { 1, 48 },   { 10, 62 },    { 17, 46 },
-    { 9, 64 },   { -12, 104 },{ -11, 97 },
-
-    /* 308 -> 337 */
-    { -16, 96 }, { -7, 88 },  { -8, 85 },    { -7, 85 },
-    { -9, 85 },  { -13, 88 }, { 4, 66 },     { -3, 77 },
-    { -3, 76 },  { -6, 76 },  { 10, 58 },    { -1, 76 },
-    { -1, 83 },  { -7, 99 },  { -14, 95 },   { 2, 95 },
-    { 0, 76 },   { -5, 74 },  { 0, 70 },     { -11, 75 },
-    { 1, 68 },   { 0, 65 },   { -14, 73 },   { 3, 62 },
-    { 4, 62 },   { -1, 68 },  { -13, 75 },   { 11, 55 },
-    { 5, 64 },   { 12, 70 },
-
-    /* 338 -> 368 */
-    { 15, 6 },   { 6, 19 },   { 7, 16 },     { 12, 14 },
-    { 18, 13 },  { 13, 11 },  { 13, 15 },    { 15, 16 },
-    { 12, 23 },  { 13, 23 },  { 15, 20 },    { 14, 26 },
-    { 14, 44 },  { 17, 40 },  { 17, 47 },    { 24, 17 },
-    { 21, 21 },  { 25, 22 },  { 31, 27 },    { 22, 29 },
-    { 19, 35 },  { 14, 50 },  { 10, 57 },    { 7, 63 },
-    { -2, 77 },  { -4, 82 },  { -3, 94 },    { 9, 69 },
-    { -12, 109 },{ 36, -35 }, { 36, -34 },
-
-    /* 369 -> 398 */
-    { 32, -26 }, { 37, -30 }, { 44, -32 },   { 34, -18 },
-    { 34, -15 }, { 40, -15 }, { 33, -7 },    { 35, -5 },
-    { 33, 0 },   { 38, 2 },   { 33, 13 },    { 23, 35 },
-    { 13, 58 },  { 29, -3 },  { 26, 0 },     { 22, 30 },
-    { 31, -7 },  { 35, -15 }, { 34, -3 },    { 34, 3 },
-    { 36, -1 },  { 34, 5 },   { 32, 11 },    { 35, 5 },
-    { 34, 12 },  { 39, 11 },  { 30, 29 },    { 34, 26 },
-    { 29, 39 },  { 19, 66 },
-
-    /* 399 -> 435 */
-    {  31,  21 }, {  31,  31 }, {  25,  50 },
-    { -17, 120 }, { -20, 112 }, { -18, 114 }, { -11,  85 },
-    { -15,  92 }, { -14,  89 }, { -26,  71 }, { -15,  81 },
-    { -14,  80 }, {   0,  68 }, { -14,  70 }, { -24,  56 },
-    { -23,  68 }, { -24,  50 }, { -11,  74 }, {  23, -13 },
-    {  26, -13 }, {  40, -15 }, {  49, -14 }, {  44,   3 },
-    {  45,   6 }, {  44,  34 }, {  33,  54 }, {  19,  82 },
-    {  -3,  75 }, {  -1,  23 }, {   1,  34 }, {   1,  43 },
-    {   0,  54 }, {  -2,  55 }, {   0,  61 }, {   1,  64 },
-    {   0,  68 }, {  -9,  92 },
-
-    /* 436 -> 459 */
-    { -14, 106 }, { -13,  97 }, { -15,  90 }, { -12,  90 },
-    { -18,  88 }, { -10,  73 }, {  -9,  79 }, { -14,  86 },
-    { -10,  73 }, { -10,  70 }, { -10,  69 }, {  -5,  66 },
-    {  -9,  64 }, {  -5,  58 }, {   2,  59 }, {  21, -10 },
-    {  24, -11 }, {  28,  -8 }, {  28,  -1 }, {  29,   3 },
-    {  29,   9 }, {  35,  20 }, {  29,  36 }, {  14,  67 }
-};
-
-static const int cabac_context_init_PB[3][460][2] =
-{
-    /* i_cabac_init_idc == 0 */
-    {
-        /* 0 - 10 */
-        {  20, -15 }, {   2,  54 }, {   3,  74 }, {  20, -15 },
-        {   2,  54 }, {   3,  74 }, { -28, 127 }, { -23, 104 },
-        {  -6,  53 }, {  -1,  54 }, {   7,  51 },
-
-        /* 11 - 23 */
-        {  23,  33 }, {  23,   2 }, {  21,   0 }, {   1,   9 },
-        {   0,  49 }, { -37, 118 }, {   5,  57 }, { -13,  78 },
-        { -11,  65 }, {   1,  62 }, {  12,  49 }, {  -4,  73 },
-        {  17,  50 },
-
-        /* 24 - 39 */
-        {  18,  64 }, {   9,  43 }, {  29,   0 }, {  26,  67 },
-        {  16,  90 }, {   9, 104 }, { -46, 127 }, { -20, 104 },
-        {   1,  67 }, { -13,  78 }, { -11,  65 }, {   1,  62 },
-        {  -6,  86 }, { -17,  95 }, {  -6,  61 }, {   9,  45 },
-
-        /* 40 - 53 */
-        {  -3,  69 }, {  -6,  81 }, { -11,  96 }, {   6,  55 },
-        {   7,  67 }, {  -5,  86 }, {   2,  88 }, {   0,  58 },
-        {  -3,  76 }, { -10,  94 }, {   5,  54 }, {   4,  69 },
-        {  -3,  81 }, {   0,  88 },
-
-        /* 54 - 59 */
-        {  -7,  67 }, {  -5,  74 }, {  -4,  74 }, {  -5,  80 },
-        {  -7,  72 }, {   1,  58 },
-
-        /* 60 - 69 */
-        {   0,  41 }, {   0,  63 }, {   0,  63 }, { 0, 63 },
-        {  -9,  83 }, {   4,  86 }, {   0,  97 }, { -7, 72 },
-        {  13,  41 }, {   3,  62 },
-
-        /* 70 - 87 */
-        {   0,  45 }, {  -4,  78 }, {  -3,  96 }, { -27,  126 },
-        { -28,  98 }, { -25, 101 }, { -23,  67 }, { -28,  82 },
-        { -20,  94 }, { -16,  83 }, { -22, 110 }, { -21,  91 },
-        { -18, 102 }, { -13,  93 }, { -29, 127 }, {  -7,  92 },
-        {  -5,  89 }, {  -7,  96 }, { -13, 108 }, {  -3,  46 },
-        {  -1,  65 }, {  -1,  57 }, {  -9,  93 }, {  -3,  74 },
-        {  -9,  92 }, {  -8,  87 }, { -23, 126 }, {   5,  54 },
-        {   6,  60 }, {   6,  59 }, {   6,  69 }, {  -1,  48 },
-        {   0,  68 }, {  -4,  69 }, {  -8,  88 },
-
-        /* 105 -> 165 */
-        {  -2,  85 }, {  -6,  78 }, {  -1,  75 }, {  -7,  77 },
-        {   2,  54 }, {   5,  50 }, {  -3,  68 }, {   1,  50 },
-        {   6,  42 }, {  -4,  81 }, {   1,  63 }, {  -4,  70 },
-        {   0,  67 }, {   2,  57 }, {  -2,  76 }, {  11,  35 },
-        {   4,  64 }, {   1,  61 }, {  11,  35 }, {  18,  25 },
-        {  12,  24 }, {  13,  29 }, {  13,  36 }, { -10,  93 },
-        {  -7,  73 }, {  -2,  73 }, {  13,  46 }, {   9,  49 },
-        {  -7, 100 }, {   9,  53 }, {   2,  53 }, {   5,  53 },
-        {  -2,  61 }, {   0,  56 }, {   0,  56 }, { -13,  63 },
-        {  -5,  60 }, {  -1,  62 }, {   4,  57 }, {  -6,  69 },
-        {   4,  57 }, {  14,  39 }, {   4,  51 }, {  13,  68 },
-        {   3,  64 }, {   1,  61 }, {   9,  63 }, {   7,  50 },
-        {  16,  39 }, {   5,  44 }, {   4,  52 }, {  11,  48 },
-        {  -5,  60 }, {  -1,  59 }, {   0,  59 }, {  22,  33 },
-        {   5,  44 }, {  14,  43 }, {  -1,  78 }, {   0,  60 },
-        {   9,  69 },
-
-        /* 166 - 226 */
-        {  11,  28 }, {   2,  40 }, {   3,  44 }, {   0,  49 },
-        {   0,  46 }, {   2,  44 }, {   2,  51 }, {   0,  47 },
-        {   4,  39 }, {   2,  62 }, {   6,  46 }, {   0,  54 },
-        {   3,  54 }, {   2,  58 }, {   4,  63 }, {   6,  51 },
-        {   6,  57 }, {   7,  53 }, {   6,  52 }, {   6,  55 },
-        {  11,  45 }, {  14,  36 }, {   8,  53 }, {  -1,  82 },
-        {   7,  55 }, {  -3,  78 }, {  15,  46 }, {  22,  31 },
-        {  -1,  84 }, {  25,   7 }, {  30,  -7 }, {  28,   3 },
-        {  28,   4 }, {  32,   0 }, {  34,  -1 }, {  30,   6 },
-        {  30,   6 }, {  32,   9 }, {  31,  19 }, {  26,  27 },
-        {  26,  30 }, {  37,  20 }, {  28,  34 }, {  17,  70 },
-        {   1,  67 }, {   5,  59 }, {   9,  67 }, {  16,  30 },
-        {  18,  32 }, {  18,  35 }, {  22,  29 }, {  24,  31 },
-        {  23,  38 }, {  18,  43 }, {  20,  41 }, {  11,  63 },
-        {   9,  59 }, {   9,  64 }, {  -1,  94 }, {  -2,  89 },
-        {  -9, 108 },
-
-        /* 227 - 275 */
-        {  -6,  76 }, {  -2,  44 }, {   0,  45 }, {   0,  52 },
-        {  -3,  64 }, {  -2,  59 }, {  -4,  70 }, {  -4,  75 },
-        {  -8,  82 }, { -17, 102 }, {  -9,  77 }, {   3,  24 },
-        {   0,  42 }, {   0,  48 }, {   0,  55 }, {  -6,  59 },
-        {  -7,  71 }, { -12,  83 }, { -11,  87 }, { -30, 119 },
-        {   1,  58 }, {  -3,  29 }, {  -1,  36 }, {   1,  38 },
-        {   2,  43 }, {  -6,  55 }, {   0,  58 }, {   0,  64 },
-        {  -3,  74 }, { -10,  90 }, {   0,  70 }, {  -4,  29 },
-        {   5,  31 }, {   7,  42 }, {   1,  59 }, {  -2,  58 },
-        {  -3,  72 }, {  -3,  81 }, { -11,  97 }, {   0,  58 },
-        {   8,   5 }, {  10,  14 }, {  14,  18 }, {  13,  27 },
-        {   2,  40 }, {   0,  58 }, {  -3,  70 }, {  -6,  79 },
-        {  -8,  85 },
-
-        /* 276 a bit special (not used, bypass is used instead) */
-        { 0, 0 },
-
-        /* 277 - 337 */
-        { -13, 106 }, { -16, 106 }, { -10,  87 }, { -21, 114 },
-        { -18, 110 }, { -14,  98 }, { -22, 110 }, { -21, 106 },
-        { -18, 103 }, { -21, 107 }, { -23, 108 }, { -26, 112 },
-        { -10,  96 }, { -12,  95 }, {  -5,  91 }, {  -9,  93 },
-        { -22,  94 }, {  -5,  86 }, {   9,  67 }, {  -4,  80 },
-        { -10,  85 }, {  -1,  70 }, {   7,  60 }, {   9,  58 },
-        {   5,  61 }, {  12,  50 }, {  15,  50 }, {  18,  49 },
-        {  17,  54 }, {  10,  41 }, {   7,  46 }, {  -1,  51 },
-        {   7,  49 }, {   8,  52 }, {   9,  41 }, {   6,  47 },
-        {   2,  55 }, {  13,  41 }, {  10,  44 }, {   6,  50 },
-        {   5,  53 }, {  13,  49 }, {   4,  63 }, {   6,  64 },
-        {  -2,  69 }, {  -2,  59 }, {   6,  70 }, {  10,  44 },
-        {   9,  31 }, {  12,  43 }, {   3,  53 }, {  14,  34 },
-        {  10,  38 }, {  -3,  52 }, {  13,  40 }, {  17,  32 },
-        {   7,  44 }, {   7,  38 }, {  13,  50 }, {  10,  57 },
-        {  26,  43 },
-
-        /* 338 - 398 */
-        {  14,  11 }, {  11,  14 }, {   9,  11 }, {  18,  11 },
-        {  21,   9 }, {  23,  -2 }, {  32, -15 }, {  32, -15 },
-        {  34, -21 }, {  39, -23 }, {  42, -33 }, {  41, -31 },
-        {  46, -28 }, {  38, -12 }, {  21,  29 }, {  45, -24 },
-        {  53, -45 }, {  48, -26 }, {  65, -43 }, {  43, -19 },
-        {  39, -10 }, {  30,   9 }, {  18,  26 }, {  20,  27 },
-        {   0,  57 }, { -14,  82 }, {  -5,  75 }, { -19,  97 },
-        { -35, 125 }, {  27,   0 }, {  28,   0 }, {  31,  -4 },
-        {  27,   6 }, {  34,   8 }, {  30,  10 }, {  24,  22 },
-        {  33,  19 }, {  22,  32 }, {  26,  31 }, {  21,  41 },
-        {  26,  44 }, {  23,  47 }, {  16,  65 }, {  14,  71 },
-        {   8,  60 }, {   6,  63 }, {  17,  65 }, {  21,  24 },
-        {  23,  20 }, {  26,  23 }, {  27,  32 }, {  28,  23 },
-        {  28,  24 }, {  23,  40 }, {  24,  32 }, {  28,  29 },
-        {  23,  42 }, {  19,  57 }, {  22,  53 }, {  22,  61 },
-        {  11,  86 },
-
-        /* 399 - 435 */
-        {  12,  40 }, {  11,  51 }, {  14,  59 },
-        {  -4,  79 }, {  -7,  71 }, {  -5,  69 }, {  -9,  70 },
-        {  -8,  66 }, { -10,  68 }, { -19,  73 }, { -12,  69 },
-        { -16,  70 }, { -15,  67 }, { -20,  62 }, { -19,  70 },
-        { -16,  66 }, { -22,  65 }, { -20,  63 }, {   9,  -2 },
-        {  26,  -9 }, {  33,  -9 }, {  39,  -7 }, {  41,  -2 },
-        {  45,   3 }, {  49,   9 }, {  45,  27 }, {  36,  59 },
-        {  -6,  66 }, {  -7,  35 }, {  -7,  42 }, {  -8,  45 },
-        {  -5,  48 }, { -12,  56 }, {  -6,  60 }, {  -5,  62 },
-        {  -8,  66 }, {  -8,  76 },
-
-        /* 436 - 459 */
-        {  -5,  85 }, {  -6,  81 }, { -10,  77 }, {  -7,  81 },
-        { -17,  80 }, { -18,  73 }, {  -4,  74 }, { -10,  83 },
-        {  -9,  71 }, {  -9,  67 }, {  -1,  61 }, {  -8,  66 },
-        { -14,  66 }, {   0,  59 }, {   2,  59 }, {  21, -13 },
-        {  33, -14 }, {  39,  -7 }, {  46,  -2 }, {  51,   2 },
-        {  60,   6 }, {  61,  17 }, {  55,  34 }, {  42,  62 },
-    },
-
-    /* i_cabac_init_idc == 1 */
-    {
-        /* 0 - 10 */
-        {  20, -15 }, {   2,  54 }, {   3,  74 }, {  20, -15 },
-        {   2,  54 }, {   3,  74 }, { -28, 127 }, { -23, 104 },
-        {  -6,  53 }, {  -1,  54 }, {   7,  51 },
-
-        /* 11 - 23 */
-        {  22,  25 }, {  34,   0 }, {  16,   0 }, {  -2,   9 },
-        {   4,  41 }, { -29, 118 }, {   2,  65 }, {  -6,  71 },
-        { -13,  79 }, {   5,  52 }, {   9,  50 }, {  -3,  70 },
-        {  10,  54 },
-
-        /* 24 - 39 */
-        {  26,  34 }, {  19,  22 }, {  40,   0 }, {  57,   2 },
-        {  41,  36 }, {  26,  69 }, { -45, 127 }, { -15, 101 },
-        {  -4,  76 }, {  -6,  71 }, { -13,  79 }, {   5,  52 },
-        {   6,  69 }, { -13,  90 }, {   0,  52 }, {   8,  43 },
-
-        /* 40 - 53 */
-        {  -2,  69 },{  -5,  82 },{ -10,  96 },{   2,  59 },
-        {   2,  75 },{  -3,  87 },{  -3,  100 },{   1,  56 },
-        {  -3,  74 },{  -6,  85 },{   0,  59 },{  -3,  81 },
-        {  -7,  86 },{  -5,  95 },
-
-        /* 54 - 59 */
-        {  -1,  66 },{  -1,  77 },{   1,  70 },{  -2,  86 },
-        {  -5,  72 },{   0,  61 },
-
-        /* 60 - 69 */
-        { 0, 41 },   { 0, 63 },   { 0, 63 },     { 0, 63 },
-        { -9, 83 },  { 4, 86 },   { 0, 97 },     { -7, 72 },
-        { 13, 41 },  { 3, 62 },
-
-        /* 70 - 104 */
-        {  13,  15 }, {   7,  51 }, {   2,  80 }, { -39, 127 },
-        { -18,  91 }, { -17,  96 }, { -26,  81 }, { -35,  98 },
-        { -24, 102 }, { -23,  97 }, { -27, 119 }, { -24,  99 },
-        { -21, 110 }, { -18, 102 }, { -36, 127 }, {   0,  80 },
-        {  -5,  89 }, {  -7,  94 }, {  -4,  92 }, {   0,  39 },
-        {   0,  65 }, { -15,  84 }, { -35, 127 }, {  -2,  73 },
-        { -12, 104 }, {  -9,  91 }, { -31, 127 }, {   3,  55 },
-        {   7,  56 }, {   7,  55 }, {   8,  61 }, {  -3,  53 },
-        {   0,  68 }, {  -7,  74 }, {  -9,  88 },
-
-        /* 105 -> 165 */
-        { -13, 103 }, { -13,  91 }, {  -9,  89 }, { -14,  92 },
-        {  -8,  76 }, { -12,  87 }, { -23, 110 }, { -24, 105 },
-        { -10,  78 }, { -20, 112 }, { -17,  99 }, { -78, 127 },
-        { -70, 127 }, { -50, 127 }, { -46, 127 }, {  -4,  66 },
-        {  -5,  78 }, {  -4,  71 }, {  -8,  72 }, {   2,  59 },
-        {  -1,  55 }, {  -7,  70 }, {  -6,  75 }, {  -8,  89 },
-        { -34, 119 }, {  -3,  75 }, {  32,  20 }, {  30,  22 },
-        { -44, 127 }, {   0,  54 }, {  -5,  61 }, {   0,  58 },
-        {  -1,  60 }, {  -3,  61 }, {  -8,  67 }, { -25,  84 },
-        { -14,  74 }, {  -5,  65 }, {   5,  52 }, {   2,  57 },
-        {   0,  61 }, {  -9,  69 }, { -11,  70 }, {  18,  55 },
-        {  -4,  71 }, {   0,  58 }, {   7,  61 }, {   9,  41 },
-        {  18,  25 }, {   9,  32 }, {   5,  43 }, {   9,  47 },
-        {   0,  44 }, {   0,  51 }, {   2,  46 }, {  19,  38 },
-        {  -4,  66 }, {  15,  38 }, {  12,  42 }, {   9,  34 },
-        {   0,  89 },
-
-        /* 166 - 226 */
-        {   4,  45 }, {  10,  28 }, {  10,  31 }, {  33, -11 },
-        {  52, -43 }, {  18,  15 }, {  28,   0 }, {  35, -22 },
-        {  38, -25 }, {  34,   0 }, {  39, -18 }, {  32, -12 },
-        { 102, -94 }, {   0,   0 }, {  56, -15 }, {  33,  -4 },
-        {  29,  10 }, {  37,  -5 }, {  51, -29 }, {  39,  -9 },
-        {  52, -34 }, {  69, -58 }, {  67, -63 }, {  44,  -5 },
-        {  32,   7 }, {  55, -29 }, {  32,   1 }, {   0,   0 },
-        {  27,  36 }, {  33, -25 }, {  34, -30 }, {  36, -28 },
-        {  38, -28 }, {  38, -27 }, {  34, -18 }, {  35, -16 },
-        {  34, -14 }, {  32,  -8 }, {  37,  -6 }, {  35,   0 },
-        {  30,  10 }, {  28,  18 }, {  26,  25 }, {  29,  41 },
-        {   0,  75 }, {   2,  72 }, {   8,  77 }, {  14,  35 },
-        {  18,  31 }, {  17,  35 }, {  21,  30 }, {  17,  45 },
-        {  20,  42 }, {  18,  45 }, {  27,  26 }, {  16,  54 },
-        {   7,  66 }, {  16,  56 }, {  11,  73 }, {  10,  67 },
-        { -10, 116 },
-
-        /* 227 - 275 */
-        { -23, 112 }, { -15,  71 }, {  -7,  61 }, {   0,  53 },
-        {  -5,  66 }, { -11,  77 }, {  -9,  80 }, {  -9,  84 },
-        { -10,  87 }, { -34, 127 }, { -21, 101 }, {  -3,  39 },
-        {  -5,  53 }, {  -7,  61 }, { -11,  75 }, { -15,  77 },
-        { -17,  91 }, { -25, 107 }, { -25, 111 }, { -28, 122 },
-        { -11,  76 }, { -10,  44 }, { -10,  52 }, { -10,  57 },
-        {  -9,  58 }, { -16,  72 }, {  -7,  69 }, {  -4,  69 },
-        {  -5,  74 }, {  -9,  86 }, {   2,  66 }, {  -9,  34 },
-        {   1,  32 }, {  11,  31 }, {   5,  52 }, {  -2,  55 },
-        {  -2,  67 }, {   0,  73 }, {  -8,  89 }, {   3,  52 },
-        {   7,   4 }, {  10,   8 }, {  17,   8 }, {  16,  19 },
-        {   3,  37 }, {  -1,  61 }, {  -5,  73 }, {  -1,  70 },
-        {  -4,  78 },
-
-        /* 276 a bit special (not used, bypass is used instead) */
-        { 0, 0 },
-
-        /* 277 - 337 */
-        { -21, 126 }, { -23, 124 }, { -20, 110 }, { -26, 126 },
-        { -25, 124 }, { -17, 105 }, { -27, 121 }, { -27, 117 },
-        { -17, 102 }, { -26, 117 }, { -27, 116 }, { -33, 122 },
-        { -10,  95 }, { -14, 100 }, {  -8,  95 }, { -17, 111 },
-        { -28, 114 }, {  -6,  89 }, {  -2,  80 }, {  -4,  82 },
-        {  -9,  85 }, {  -8,  81 }, {  -1,  72 }, {   5,  64 },
-        {   1,  67 }, {   9,  56 }, {   0,  69 }, {   1,  69 },
-        {   7,  69 }, {  -7,  69 }, {  -6,  67 }, { -16,  77 },
-        {  -2,  64 }, {   2,  61 }, {  -6,  67 }, {  -3,  64 },
-        {   2,  57 }, {  -3,  65 }, {  -3,  66 }, {   0,  62 },
-        {   9,  51 }, {  -1,  66 }, {  -2,  71 }, {  -2,  75 },
-        {  -1,  70 }, {  -9,  72 }, {  14,  60 }, {  16,  37 },
-        {   0,  47 }, {  18,  35 }, {  11,  37 }, {  12,  41 },
-        {  10,  41 }, {   2,  48 }, {  12,  41 }, {  13,  41 },
-        {   0,  59 }, {   3,  50 }, {  19,  40 }, {   3,  66 },
-        {  18,  50 },
-
-        /* 338 - 398 */
-        {  19,  -6 }, {  18,  -6 }, {  14,   0 }, {  26, -12 },
-        {  31, -16 }, {  33, -25 }, {  33, -22 }, {  37, -28 },
-        {  39, -30 }, {  42, -30 }, {  47, -42 }, {  45, -36 },
-        {  49, -34 }, {  41, -17 }, {  32,   9 }, {  69, -71 },
-        {  63, -63 }, {  66, -64 }, {  77, -74 }, {  54, -39 },
-        {  52, -35 }, {  41, -10 }, {  36,   0 }, {  40,  -1 },
-        {  30,  14 }, {  28,  26 }, {  23,  37 }, {  12,  55 },
-        {  11,  65 }, {  37, -33 }, {  39, -36 }, {  40, -37 },
-        {  38, -30 }, {  46, -33 }, {  42, -30 }, {  40, -24 },
-        {  49, -29 }, {  38, -12 }, {  40, -10 }, {  38,  -3 },
-        {  46,  -5 }, {  31,  20 }, {  29,  30 }, {  25,  44 },
-        {  12,  48 }, {  11,  49 }, {  26,  45 }, {  22,  22 },
-        {  23,  22 }, {  27,  21 }, {  33,  20 }, {  26,  28 },
-        {  30,  24 }, {  27,  34 }, {  18,  42 }, {  25,  39 },
-        {  18,  50 }, {  12,  70 }, {  21,  54 }, {  14,  71 },
-        {  11,  83 },
-
-        /* 399 - 435 */
-        {  25,  32 }, {  21,  49 }, {  21,  54 },
-        {  -5,  85 }, {  -6,  81 }, { -10,  77 }, {  -7,  81 },
-        { -17,  80 }, { -18,  73 }, {  -4,  74 }, { -10,  83 },
-        {  -9,  71 }, {  -9,  67 }, {  -1,  61 }, {  -8,  66 },
-        { -14,  66 }, {   0,  59 }, {   2,  59 }, {  17, -10 },
-        {  32, -13 }, {  42,  -9 }, {  49,  -5 }, {  53,   0 },
-        {  64,   3 }, {  68,  10 }, {  66,  27 }, {  47,  57 },
-        {  -5,  71 }, {   0,  24 }, {  -1,  36 }, {  -2,  42 },
-        {  -2,  52 }, {  -9,  57 }, {  -6,  63 }, {  -4,  65 },
-        {  -4,  67 }, {  -7,  82 },
-
-        /* 436 - 459 */
-        {  -3,  81 }, {  -3,  76 }, {  -7,  72 }, {  -6,  78 },
-        { -12,  72 }, { -14,  68 }, {  -3,  70 }, {  -6,  76 },
-        {  -5,  66 }, {  -5,  62 }, {   0,  57 }, {  -4,  61 },
-        {  -9,  60 }, {   1,  54 }, {   2,  58 }, {  17, -10 },
-        {  32, -13 }, {  42,  -9 }, {  49,  -5 }, {  53,   0 },
-        {  64,   3 }, {  68,  10 }, {  66,  27 }, {  47,  57 },
-    },
-
-    /* i_cabac_init_idc == 2 */
-    {
-        /* 0 - 10 */
-        {  20, -15 }, {   2,  54 }, {   3,  74 }, {  20, -15 },
-        {   2,  54 }, {   3,  74 }, { -28, 127 }, { -23, 104 },
-        {  -6,  53 }, {  -1,  54 }, {   7,  51 },
-
-        /* 11 - 23 */
-        {  29,  16 }, {  25,   0 }, {  14,   0 }, { -10,  51 },
-        {  -3,  62 }, { -27,  99 }, {  26,  16 }, {  -4,  85 },
-        { -24, 102 }, {   5,  57 }, {   6,  57 }, { -17,  73 },
-        {  14,  57 },
-
-        /* 24 - 39 */
-        {  20,  40 }, {  20,  10 }, {  29,   0 }, {  54,   0 },
-        {  37,  42 }, {  12,  97 }, { -32, 127 }, { -22, 117 },
-        {  -2,  74 }, {  -4,  85 }, { -24, 102 }, {   5,  57 },
-        {  -6,  93 }, { -14,  88 }, {  -6,  44 }, {   4,  55 },
-
-        /* 40 - 53 */
-        { -11,  89 },{ -15,  103 },{ -21,  116 },{  19,  57 },
-        {  20,  58 },{   4,  84 },{   6,  96 },{   1,  63 },
-        {  -5,  85 },{ -13,  106 },{   5,  63 },{   6,  75 },
-        {  -3,  90 },{  -1,  101 },
-
-        /* 54 - 59 */
-        {   3,  55 },{  -4,  79 },{  -2,  75 },{ -12,  97 },
-        {  -7,  50 },{   1,  60 },
-
-        /* 60 - 69 */
-        { 0, 41 },   { 0, 63 },   { 0, 63 },     { 0, 63 },
-        { -9, 83 },  { 4, 86 },   { 0, 97 },     { -7, 72 },
-        { 13, 41 },  { 3, 62 },
-
-        /* 70 - 104 */
-        {   7,  34 }, {  -9,  88 }, { -20, 127 }, { -36, 127 },
-        { -17,  91 }, { -14,  95 }, { -25,  84 }, { -25,  86 },
-        { -12,  89 }, { -17,  91 }, { -31, 127 }, { -14,  76 },
-        { -18, 103 }, { -13,  90 }, { -37, 127 }, {  11,  80 },
-        {   5,  76 }, {   2,  84 }, {   5,  78 }, {  -6,  55 },
-        {   4,  61 }, { -14,  83 }, { -37, 127 }, {  -5,  79 },
-        { -11, 104 }, { -11,  91 }, { -30, 127 }, {   0,  65 },
-        {  -2,  79 }, {   0,  72 }, {  -4,  92 }, {  -6,  56 },
-        {   3,  68 }, {  -8,  71 }, { -13,  98 },
-
-        /* 105 -> 165 */
-        {  -4,  86 }, { -12,  88 }, {  -5,  82 }, {  -3,  72 },
-        {  -4,  67 }, {  -8,  72 }, { -16,  89 }, {  -9,  69 },
-        {  -1,  59 }, {   5,  66 }, {   4,  57 }, {  -4,  71 },
-        {  -2,  71 }, {   2,  58 }, {  -1,  74 }, {  -4,  44 },
-        {  -1,  69 }, {   0,  62 }, {  -7,  51 }, {  -4,  47 },
-        {  -6,  42 }, {  -3,  41 }, {  -6,  53 }, {   8,  76 },
-        {  -9,  78 }, { -11,  83 }, {   9,  52 }, {   0,  67 },
-        {  -5,  90 }, {   1,  67 }, { -15,  72 }, {  -5,  75 },
-        {  -8,  80 }, { -21,  83 }, { -21,  64 }, { -13,  31 },
-        { -25,  64 }, { -29,  94 }, {   9,  75 }, {  17,  63 },
-        {  -8,  74 }, {  -5,  35 }, {  -2,  27 }, {  13,  91 },
-        {   3,  65 }, {  -7,  69 }, {   8,  77 }, { -10,  66 },
-        {   3,  62 }, {  -3,  68 }, { -20,  81 }, {   0,  30 },
-        {   1,   7 }, {  -3,  23 }, { -21,  74 }, {  16,  66 },
-        { -23, 124 }, {  17,  37 }, {  44, -18 }, {  50, -34 },
-        { -22, 127 },
-
-        /* 166 - 226 */
-        {   4,  39 }, {   0,  42 }, {   7,  34 }, {  11,  29 },
-        {   8,  31 }, {   6,  37 }, {   7,  42 }, {   3,  40 },
-        {   8,  33 }, {  13,  43 }, {  13,  36 }, {   4,  47 },
-        {   3,  55 }, {   2,  58 }, {   6,  60 }, {   8,  44 },
-        {  11,  44 }, {  14,  42 }, {   7,  48 }, {   4,  56 },
-        {   4,  52 }, {  13,  37 }, {   9,  49 }, {  19,  58 },
-        {  10,  48 }, {  12,  45 }, {   0,  69 }, {  20,  33 },
-        {   8,  63 }, {  35, -18 }, {  33, -25 }, {  28,  -3 },
-        {  24,  10 }, {  27,   0 }, {  34, -14 }, {  52, -44 },
-        {  39, -24 }, {  19,  17 }, {  31,  25 }, {  36,  29 },
-        {  24,  33 }, {  34,  15 }, {  30,  20 }, {  22,  73 },
-        {  20,  34 }, {  19,  31 }, {  27,  44 }, {  19,  16 },
-        {  15,  36 }, {  15,  36 }, {  21,  28 }, {  25,  21 },
-        {  30,  20 }, {  31,  12 }, {  27,  16 }, {  24,  42 },
-        {   0,  93 }, {  14,  56 }, {  15,  57 }, {  26,  38 },
-        { -24, 127 },
-
-        /* 227 - 275 */
-        { -24, 115 }, { -22,  82 }, {  -9,  62 }, {   0,  53 },
-        {   0,  59 }, { -14,  85 }, { -13,  89 }, { -13,  94 },
-        { -11,  92 }, { -29, 127 }, { -21, 100 }, { -14,  57 },
-        { -12,  67 }, { -11,  71 }, { -10,  77 }, { -21,  85 },
-        { -16,  88 }, { -23, 104 }, { -15,  98 }, { -37, 127 },
-        { -10,  82 }, {  -8,  48 }, {  -8,  61 }, {  -8,  66 },
-        {  -7,  70 }, { -14,  75 }, { -10,  79 }, {  -9,  83 },
-        { -12,  92 }, { -18, 108 }, {  -4,  79 }, { -22,  69 },
-        { -16,  75 }, {  -2,  58 }, {   1,  58 }, { -13,  78 },
-        {  -9,  83 }, {  -4,  81 }, { -13,  99 }, { -13,  81 },
-        {  -6,  38 }, { -13,  62 }, {  -6,  58 }, {  -2,  59 },
-        { -16,  73 }, { -10,  76 }, { -13,  86 }, {  -9,  83 },
-        { -10,  87 },
-
-        /* 276 a bit special (not used, bypass is used instead) */
-        { 0, 0 },
-
-        /* 277 - 337 */
-        { -22, 127 }, { -25, 127 }, { -25, 120 }, { -27, 127 },
-        { -19, 114 }, { -23, 117 }, { -25, 118 }, { -26, 117 },
-        { -24, 113 }, { -28, 118 }, { -31, 120 }, { -37, 124 },
-        { -10,  94 }, { -15, 102 }, { -10,  99 }, { -13, 106 },
-        { -50, 127 }, {  -5,  92 }, {  17,  57 }, {  -5,  86 },
-        { -13,  94 }, { -12,  91 }, {  -2,  77 }, {   0,  71 },
-        {  -1,  73 }, {   4,  64 }, {  -7,  81 }, {   5,  64 },
-        {  15,  57 }, {   1,  67 }, {   0,  68 }, { -10,  67 },
-        {   1,  68 }, {   0,  77 }, {   2,  64 }, {   0,  68 },
-        {  -5,  78 }, {   7,  55 }, {   5,  59 }, {   2,  65 },
-        {  14,  54 }, {  15,  44 }, {   5,  60 }, {   2,  70 },
-        {  -2,  76 }, { -18,  86 }, {  12,  70 }, {   5,  64 },
-        { -12,  70 }, {  11,  55 }, {   5,  56 }, {   0,  69 },
-        {   2,  65 }, {  -6,  74 }, {   5,  54 }, {   7,  54 },
-        {  -6,  76 }, { -11,  82 }, {  -2,  77 }, {  -2,  77 },
-        {  25,  42 },
-
-        /* 338 - 398 */
-        {  17, -13 }, {  16,  -9 }, {  17, -12 }, {  27, -21 },
-        {  37, -30 }, {  41, -40 }, {  42, -41 }, {  48, -47 },
-        {  39, -32 }, {  46, -40 }, {  52, -51 }, {  46, -41 },
-        {  52, -39 }, {  43, -19 }, {  32,  11 }, {  61, -55 },
-        {  56, -46 }, {  62, -50 }, {  81, -67 }, {  45, -20 },
-        {  35,  -2 }, {  28,  15 }, {  34,   1 }, {  39,   1 },
-        {  30,  17 }, {  20,  38 }, {  18,  45 }, {  15,  54 },
-        {   0,  79 }, {  36, -16 }, {  37, -14 }, {  37, -17 },
-        {  32,   1 }, {  34,  15 }, {  29,  15 }, {  24,  25 },
-        {  34,  22 }, {  31,  16 }, {  35,  18 }, {  31,  28 },
-        {  33,  41 }, {  36,  28 }, {  27,  47 }, {  21,  62 },
-        {  18,  31 }, {  19,  26 }, {  36,  24 }, {  24,  23 },
-        {  27,  16 }, {  24,  30 }, {  31,  29 }, {  22,  41 },
-        {  22,  42 }, {  16,  60 }, {  15,  52 }, {  14,  60 },
-        {   3,  78 }, { -16, 123 }, {  21,  53 }, {  22,  56 },
-        {  25,  61 },
-
-        /* 399 - 435 */
-        {  21,  33 }, {  19,  50 }, {  17,  61 },
-        {  -3,  78 }, {  -8,  74 }, {  -9,  72 }, { -10,  72 },
-        { -18,  75 }, { -12,  71 }, { -11,  63 }, {  -5,  70 },
-        { -17,  75 }, { -14,  72 }, { -16,  67 }, {  -8,  53 },
-        { -14,  59 }, {  -9,  52 }, { -11,  68 }, {   9,  -2 },
-        {  30, -10 }, {  31,  -4 }, {  33,  -1 }, {  33,   7 },
-        {  31,  12 }, {  37,  23 }, {  31,  38 }, {  20,  64 },
-        {  -9,  71 }, {  -7,  37 }, {  -8,  44 }, { -11,  49 },
-        { -10,  56 }, { -12,  59 }, {  -8,  63 }, {  -9,  67 },
-        {  -6,  68 }, { -10,  79 },
-
-        /* 436 - 459 */
-        {  -3,  78 }, {  -8,  74 }, {  -9,  72 }, { -10,  72 },
-        { -18,  75 }, { -12,  71 }, { -11,  63 }, {  -5,  70 },
-        { -17,  75 }, { -14,  72 }, { -16,  67 }, {  -8,  53 },
-        { -14,  59 }, {  -9,  52 }, { -11,  68 }, {   9,  -2 },
-        {  30, -10 }, {  31,  -4 }, {  33,  -1 }, {  33,   7 },
-        {  31,  12 }, {  37,  23 }, {  31,  38 }, {  20,  64 },
-    }
-};
diff --git a/ffmpeg.src/libavcodec/h264idct.c b/ffmpeg.src/libavcodec/h264idct.c
deleted file mode 100644
index e59324d..0000000
--- a/ffmpeg.src/libavcodec/h264idct.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * H.264 IDCT
- * Copyright (c) 2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
- 
-/**
- * @file h264-idct.c
- * H.264 IDCT.
- * @author Michael Niedermayer <michaelni at gmx.at>
- */
- 
-#include "dsputil.h"
-
-static always_inline void idct_internal(uint8_t *dst, DCTELEM *block, int stride, int block_stride, int shift, int add){
-    int i;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-    block[0] += 1<<(shift-1);
-
-    for(i=0; i<4; i++){
-        const int z0=  block[0 + block_stride*i]     +  block[2 + block_stride*i];
-        const int z1=  block[0 + block_stride*i]     -  block[2 + block_stride*i];
-        const int z2= (block[1 + block_stride*i]>>1) -  block[3 + block_stride*i];
-        const int z3=  block[1 + block_stride*i]     + (block[3 + block_stride*i]>>1);
-
-        block[0 + block_stride*i]= z0 + z3;
-        block[1 + block_stride*i]= z1 + z2;
-        block[2 + block_stride*i]= z1 - z2;
-        block[3 + block_stride*i]= z0 - z3;
-    }
-
-    for(i=0; i<4; i++){
-        const int z0=  block[i + block_stride*0]     +  block[i + block_stride*2];
-        const int z1=  block[i + block_stride*0]     -  block[i + block_stride*2];
-        const int z2= (block[i + block_stride*1]>>1) -  block[i + block_stride*3];
-        const int z3=  block[i + block_stride*1]     + (block[i + block_stride*3]>>1);
-
-        dst[i + 0*stride]= cm[ add*dst[i + 0*stride] + ((z0 + z3) >> shift) ];
-        dst[i + 1*stride]= cm[ add*dst[i + 1*stride] + ((z1 + z2) >> shift) ];
-        dst[i + 2*stride]= cm[ add*dst[i + 2*stride] + ((z1 - z2) >> shift) ];
-        dst[i + 3*stride]= cm[ add*dst[i + 3*stride] + ((z0 - z3) >> shift) ];
-    }
-}
-
-void ff_h264_idct_add_c(uint8_t *dst, DCTELEM *block, int stride){
-    idct_internal(dst, block, stride, 4, 6, 1);
-}
-
-void ff_h264_lowres_idct_add_c(uint8_t *dst, int stride, DCTELEM *block){
-    idct_internal(dst, block, stride, 8, 3, 1);
-}
-
-void ff_h264_lowres_idct_put_c(uint8_t *dst, int stride, DCTELEM *block){
-    idct_internal(dst, block, stride, 8, 3, 0);
-}
-
-void ff_h264_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride){
-    int i;
-    DCTELEM (*src)[8] = (DCTELEM(*)[8])block;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-    block[0] += 32;
-
-    for( i = 0; i < 8; i++ )
-    {
-        const int a0 =  src[i][0] + src[i][4];
-        const int a2 =  src[i][0] - src[i][4];
-        const int a4 = (src[i][2]>>1) - src[i][6];
-        const int a6 = (src[i][6]>>1) + src[i][2];
-
-        const int b0 = a0 + a6;
-        const int b2 = a2 + a4;
-        const int b4 = a2 - a4;
-        const int b6 = a0 - a6;
-
-        const int a1 = -src[i][3] + src[i][5] - src[i][7] - (src[i][7]>>1);
-        const int a3 =  src[i][1] + src[i][7] - src[i][3] - (src[i][3]>>1);
-        const int a5 = -src[i][1] + src[i][7] + src[i][5] + (src[i][5]>>1);
-        const int a7 =  src[i][3] + src[i][5] + src[i][1] + (src[i][1]>>1);
-
-        const int b1 = (a7>>2) + a1;
-        const int b3 =  a3 + (a5>>2);
-        const int b5 = (a3>>2) - a5;
-        const int b7 =  a7 - (a1>>2);
-
-        src[i][0] = b0 + b7;
-        src[i][7] = b0 - b7;
-        src[i][1] = b2 + b5;
-        src[i][6] = b2 - b5;
-        src[i][2] = b4 + b3;
-        src[i][5] = b4 - b3;
-        src[i][3] = b6 + b1;
-        src[i][4] = b6 - b1;
-    }
-    for( i = 0; i < 8; i++ )
-    {
-        const int a0 =  src[0][i] + src[4][i];
-        const int a2 =  src[0][i] - src[4][i];
-        const int a4 = (src[2][i]>>1) - src[6][i];
-        const int a6 = (src[6][i]>>1) + src[2][i];
-
-        const int b0 = a0 + a6;
-        const int b2 = a2 + a4;
-        const int b4 = a2 - a4;
-        const int b6 = a0 - a6;
-
-        const int a1 = -src[3][i] + src[5][i] - src[7][i] - (src[7][i]>>1);
-        const int a3 =  src[1][i] + src[7][i] - src[3][i] - (src[3][i]>>1);
-        const int a5 = -src[1][i] + src[7][i] + src[5][i] + (src[5][i]>>1);
-        const int a7 =  src[3][i] + src[5][i] + src[1][i] + (src[1][i]>>1);
-
-        const int b1 = (a7>>2) + a1;
-        const int b3 =  a3 + (a5>>2);
-        const int b5 = (a3>>2) - a5;
-        const int b7 =  a7 - (a1>>2);
-
-        dst[i + 0*stride] = cm[ dst[i + 0*stride] + ((b0 + b7) >> 6) ];
-        dst[i + 1*stride] = cm[ dst[i + 1*stride] + ((b2 + b5) >> 6) ];
-        dst[i + 2*stride] = cm[ dst[i + 2*stride] + ((b4 + b3) >> 6) ];
-        dst[i + 3*stride] = cm[ dst[i + 3*stride] + ((b6 + b1) >> 6) ];
-        dst[i + 4*stride] = cm[ dst[i + 4*stride] + ((b6 - b1) >> 6) ];
-        dst[i + 5*stride] = cm[ dst[i + 5*stride] + ((b4 - b3) >> 6) ];
-        dst[i + 6*stride] = cm[ dst[i + 6*stride] + ((b2 - b5) >> 6) ];
-        dst[i + 7*stride] = cm[ dst[i + 7*stride] + ((b0 - b7) >> 6) ];
-    }
-}
diff --git a/ffmpeg.src/libavcodec/i386/cputest.c b/ffmpeg.src/libavcodec/i386/cputest.c
deleted file mode 100644
index 593e055..0000000
--- a/ffmpeg.src/libavcodec/i386/cputest.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/* Cpu detection code, extracted from mmx.h ((c)1997-99 by H. Dietz
-   and R. Fisher). Converted to C and improved by Fabrice Bellard */
-
-#include <stdlib.h>
-#include "../dsputil.h"
-
-#ifdef ARCH_X86_64
-#  define REG_b "rbx"
-#  define REG_S "rsi"
-#else
-#  define REG_b "ebx"
-#  define REG_S "esi"
-#endif
-
-/* ebx saving is necessary for PIC. gcc seems unable to see it alone */
-#define cpuid(index,eax,ebx,ecx,edx)\
-    __asm __volatile\
-	("mov %%"REG_b", %%"REG_S"\n\t"\
-         "cpuid\n\t"\
-         "xchg %%"REG_b", %%"REG_S\
-         : "=a" (eax), "=S" (ebx),\
-           "=c" (ecx), "=d" (edx)\
-         : "0" (index));
-
-/* Function to test if multimedia instructions are supported...  */
-int mm_support(void)
-{
-    int rval = 0;
-    int eax, ebx, ecx, edx;
-    int max_std_level, max_ext_level, std_caps=0, ext_caps=0;
-    long a, c;
-    
-    __asm__ __volatile__ (
-                          /* See if CPUID instruction is supported ... */
-                          /* ... Get copies of EFLAGS into eax and ecx */
-                          "pushf\n\t"
-                          "pop %0\n\t"
-                          "mov %0, %1\n\t"
-                          
-                          /* ... Toggle the ID bit in one copy and store */
-                          /*     to the EFLAGS reg */
-                          "xor $0x200000, %0\n\t"
-                          "push %0\n\t"
-                          "popf\n\t"
-                          
-                          /* ... Get the (hopefully modified) EFLAGS */
-                          "pushf\n\t"
-                          "pop %0\n\t"
-                          : "=a" (a), "=c" (c)
-                          :
-                          : "cc" 
-                          );
-    
-    if (a == c)
-        return 0; /* CPUID not supported */
-
-    cpuid(0, max_std_level, ebx, ecx, edx);
-
-    if(max_std_level >= 1){
-        cpuid(1, eax, ebx, ecx, std_caps);
-        if (std_caps & (1<<23))
-            rval |= MM_MMX;
-        if (std_caps & (1<<25)) 
-            rval |= MM_MMXEXT | MM_SSE;
-        if (std_caps & (1<<26)) 
-            rval |= MM_SSE2;
-    }
-
-    cpuid(0x80000000, max_ext_level, ebx, ecx, edx);
-
-    if(max_ext_level >= 0x80000001){
-        cpuid(0x80000001, eax, ebx, ecx, ext_caps);
-        if (ext_caps & (1<<31))
-            rval |= MM_3DNOW;
-        if (ext_caps & (1<<30))
-            rval |= MM_3DNOWEXT;
-        if (ext_caps & (1<<23))
-            rval |= MM_MMX;
-    }
-
-    cpuid(0, eax, ebx, ecx, edx);
-    if (       ebx == 0x68747541 &&
-               edx == 0x69746e65 &&
-               ecx == 0x444d4163) {
-        /* AMD */
-        if(ext_caps & (1<<22))
-            rval |= MM_MMXEXT;
-    } else if (ebx == 0x746e6543 &&
-               edx == 0x48727561 &&
-               ecx == 0x736c7561) {  /*  "CentaurHauls" */
-        /* VIA C3 */
-	if(ext_caps & (1<<24))
-	  rval |= MM_MMXEXT;
-    } else if (ebx == 0x69727943 &&
-               edx == 0x736e4978 &&
-               ecx == 0x64616574) {
-        /* Cyrix Section */
-        /* See if extended CPUID level 80000001 is supported */
-        /* The value of CPUID/80000001 for the 6x86MX is undefined
-           according to the Cyrix CPU Detection Guide (Preliminary
-           Rev. 1.01 table 1), so we'll check the value of eax for
-           CPUID/0 to see if standard CPUID level 2 is supported.
-           According to the table, the only CPU which supports level
-           2 is also the only one which supports extended CPUID levels.
-        */
-        if (eax < 2) 
-            return rval;
-        if (ext_caps & (1<<24))
-            rval |= MM_MMXEXT;
-    }
-#if 0
-    av_log(NULL, AV_LOG_DEBUG, "%s%s%s%s%s%s\n", 
-        (rval&MM_MMX) ? "MMX ":"", 
-        (rval&MM_MMXEXT) ? "MMX2 ":"", 
-        (rval&MM_SSE) ? "SSE ":"", 
-        (rval&MM_SSE2) ? "SSE2 ":"", 
-        (rval&MM_3DNOW) ? "3DNow ":"", 
-        (rval&MM_3DNOWEXT) ? "3DNowExt ":"");
-#endif
-    return rval;
-}
-
-#ifdef __TEST__
-int main ( void )
-{
-  int mm_flags;
-  mm_flags = mm_support();
-  printf("mm_support = 0x%08X\n",mm_flags);
-  return 0;
-}
-#endif
diff --git a/ffmpeg.src/libavcodec/i386/dsputil_h264_template_mmx.c b/ffmpeg.src/libavcodec/i386/dsputil_h264_template_mmx.c
deleted file mode 100644
index 4cd4d52..0000000
--- a/ffmpeg.src/libavcodec/i386/dsputil_h264_template_mmx.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2005 Zoltan Hidvegi <hzoli -a- hzoli -d- com>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * MMX optimized version of (put|avg)_h264_chroma_mc8.
- * H264_CHROMA_MC8_TMPL must be defined to the desired function name and
- * H264_CHROMA_OP must be defined to empty for put and pavgb/pavgusb for avg.
- */
-static void H264_CHROMA_MC8_TMPL(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y)
-{
-    uint64_t AA __align8;
-    uint64_t DD __align8;
-    unsigned long srcos = (long)src & 7;
-    uint64_t sh1 __align8 = srcos * 8;
-    uint64_t sh2 __align8 = 56 - sh1;
-    int i;
-
-    assert(x<8 && y<8 && x>=0 && y>=0);
-
-    asm volatile("movd %1, %%mm4\n\t"
-                 "movd %2, %%mm6\n\t"
-                 "punpcklwd %%mm4, %%mm4\n\t"
-                 "punpcklwd %%mm6, %%mm6\n\t"
-                 "punpckldq %%mm4, %%mm4\n\t" /* mm4 = x words */
-                 "punpckldq %%mm6, %%mm6\n\t" /* mm6 = y words */
-                 "movq %%mm4, %%mm5\n\t"
-                 "pmullw %%mm6, %%mm4\n\t"    /* mm4 = x * y */
-                 "psllw $3, %%mm5\n\t"
-                 "psllw $3, %%mm6\n\t"
-                 "movq %%mm5, %%mm7\n\t"
-                 "paddw %%mm6, %%mm7\n\t"
-                 "movq %%mm4, %0\n\t"         /* DD = x * y */
-                 "psubw %%mm4, %%mm5\n\t"     /* mm5 = B = 8x - xy */
-                 "psubw %%mm4, %%mm6\n\t"     /* mm6 = C = 8y - xy */
-                 "paddw %3, %%mm4\n\t"
-                 "psubw %%mm7, %%mm4\n\t"     /* mm4 = A = xy - (8x+8y) + 64 */
-                 "pxor %%mm7, %%mm7\n\t"
-                 : "=m" (DD) : "rm" (x), "rm" (y), "m" (ff_pw_64));
-
-    asm volatile("movq %%mm4, %0" : "=m" (AA));
-
-    src -= srcos;
-    asm volatile(
-        /* mm0 = src[0..7], mm1 = src[1..8] */
-        "movq %0, %%mm1\n\t"
-        "movq %1, %%mm0\n\t"
-        "psrlq %2, %%mm1\n\t"
-        "psllq %3, %%mm0\n\t"
-        "movq %%mm0, %%mm4\n\t"
-        "psllq $8, %%mm0\n\t"
-        "por %%mm1, %%mm0\n\t"
-        "psrlq $8, %%mm1\n\t"
-        "por %%mm4, %%mm1\n\t"
-        : : "m" (src[0]), "m" (src[8]), "m" (sh1), "m" (sh2));
-
-    for(i=0; i<h; i++) {
-        asm volatile(
-            /* [mm2,mm3] = A * src[0..7] */
-            "movq %%mm0, %%mm2\n\t"
-            "punpcklbw %%mm7, %%mm2\n\t"
-            "pmullw %0, %%mm2\n\t"
-            "movq %%mm0, %%mm3\n\t"
-            "punpckhbw %%mm7, %%mm3\n\t"
-            "pmullw %0, %%mm3\n\t"
-
-            /* [mm2,mm3] += B * src[1..8] */
-            "movq %%mm1, %%mm0\n\t"
-            "punpcklbw %%mm7, %%mm0\n\t"
-            "pmullw %%mm5, %%mm0\n\t"
-            "punpckhbw %%mm7, %%mm1\n\t"
-            "pmullw %%mm5, %%mm1\n\t"
-            "paddw %%mm0, %%mm2\n\t"
-            "paddw %%mm1, %%mm3\n\t"
-            : : "m" (AA));
-
-        src += stride;
-        asm volatile(
-            /* mm0 = src[0..7], mm1 = src[1..8] */
-            "movq %0, %%mm1\n\t"
-            "movq %1, %%mm0\n\t"
-            "psrlq %2, %%mm1\n\t"
-            "psllq %3, %%mm0\n\t"
-            "movq %%mm0, %%mm4\n\t"
-            "psllq $8, %%mm0\n\t"
-            "por %%mm1, %%mm0\n\t"
-            "psrlq $8, %%mm1\n\t"
-            "por %%mm4, %%mm1\n\t"
-            : : "m" (src[0]), "m" (src[8]), "m" (sh1), "m" (sh2));
-
-        asm volatile(
-            /* [mm2,mm3] += C *  src[0..7] */
-            "movq %mm0, %mm4\n\t"
-            "punpcklbw %mm7, %mm4\n\t"
-            "pmullw %mm6, %mm4\n\t"
-            "paddw %mm4, %mm2\n\t"
-            "movq %mm0, %mm4\n\t"
-            "punpckhbw %mm7, %mm4\n\t"
-            "pmullw %mm6, %mm4\n\t"
-            "paddw %mm4, %mm3\n\t");
-
-        asm volatile(
-            /* [mm2,mm3] += D *  src[1..8] */
-            "movq %%mm1, %%mm4\n\t"
-            "punpcklbw %%mm7, %%mm4\n\t"
-            "pmullw %0, %%mm4\n\t"
-            "paddw %%mm4, %%mm2\n\t"
-            "movq %%mm1, %%mm4\n\t"
-            "punpckhbw %%mm7, %%mm4\n\t"
-            "pmullw %0, %%mm4\n\t"
-            "paddw %%mm4, %%mm3\n\t"
-            : : "m" (DD));
-
-        asm volatile(
-            /* dst[0..7] = pack(([mm2,mm3] + 32) >> 6) */
-            "paddw %1, %%mm2\n\t"
-            "paddw %1, %%mm3\n\t"
-            "psrlw $6, %%mm2\n\t"
-            "psrlw $6, %%mm3\n\t"
-            "packuswb %%mm3, %%mm2\n\t"
-            H264_CHROMA_OP(%0, %%mm2)
-            "movq %%mm2, %0\n\t"
-            : "=m" (dst[0]) : "m" (ff_pw_32));
-        dst+= stride;
-    }
-}
diff --git a/ffmpeg.src/libavcodec/i386/dsputil_mmx.c b/ffmpeg.src/libavcodec/i386/dsputil_mmx.c
deleted file mode 100644
index 5d9d499..0000000
--- a/ffmpeg.src/libavcodec/i386/dsputil_mmx.c
+++ /dev/null
@@ -1,2883 +0,0 @@
-/*
- * MMX optimized DSP utils
- * Copyright (c) 2000, 2001 Fabrice Bellard.
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * MMX optimization by Nick Kurshev <nickols_k at mail.ru>
- */
-
-#include "../dsputil.h"
-#include "../simple_idct.h"
-#include "../mpegvideo.h"
-#include "mmx.h"
-
-//#undef NDEBUG
-//#include <assert.h>
-
-extern const uint8_t ff_h263_loop_filter_strength[32];
-extern void ff_idct_xvid_mmx(short *block);
-extern void ff_idct_xvid_mmx2(short *block);
-
-int mm_flags; /* multimedia extension flags */
-
-/* pixel operations */
-static const uint64_t mm_bone attribute_used __attribute__ ((aligned(8))) = 0x0101010101010101ULL;
-static const uint64_t mm_wone attribute_used __attribute__ ((aligned(8))) = 0x0001000100010001ULL;
-static const uint64_t mm_wtwo attribute_used __attribute__ ((aligned(8))) = 0x0002000200020002ULL;
-
-static const uint64_t ff_pw_20 attribute_used __attribute__ ((aligned(8))) = 0x0014001400140014ULL;
-static const uint64_t ff_pw_3  attribute_used __attribute__ ((aligned(8))) = 0x0003000300030003ULL;
-static const uint64_t ff_pw_4  attribute_used __attribute__ ((aligned(8))) = 0x0004000400040004ULL;
-static const uint64_t ff_pw_5  attribute_used __attribute__ ((aligned(8))) = 0x0005000500050005ULL;
-static const uint64_t ff_pw_16 attribute_used __attribute__ ((aligned(8))) = 0x0010001000100010ULL;
-static const uint64_t ff_pw_32 attribute_used __attribute__ ((aligned(8))) = 0x0020002000200020ULL;
-static const uint64_t ff_pw_64 attribute_used __attribute__ ((aligned(8))) = 0x0040004000400040ULL;
-static const uint64_t ff_pw_15 attribute_used __attribute__ ((aligned(8))) = 0x000F000F000F000FULL;
-
-static const uint64_t ff_pb_3F attribute_used __attribute__ ((aligned(8))) = 0x3F3F3F3F3F3F3F3FULL;
-static const uint64_t ff_pb_FC attribute_used __attribute__ ((aligned(8))) = 0xFCFCFCFCFCFCFCFCULL;
-
-#define JUMPALIGN() __asm __volatile (".balign 8"::)
-#define MOVQ_ZERO(regd)  __asm __volatile ("pxor %%" #regd ", %%" #regd ::)
-
-#define MOVQ_WONE(regd) \
-    __asm __volatile ( \
-    "pcmpeqd %%" #regd ", %%" #regd " \n\t" \
-    "psrlw $15, %%" #regd ::)
-
-#define MOVQ_BFE(regd) \
-    __asm __volatile ( \
-    "pcmpeqd %%" #regd ", %%" #regd " \n\t"\
-    "paddb %%" #regd ", %%" #regd " \n\t" ::)
-
-#ifndef PIC
-#define MOVQ_BONE(regd)  __asm __volatile ("movq %0, %%" #regd " \n\t" ::"m"(mm_bone))
-#define MOVQ_WTWO(regd)  __asm __volatile ("movq %0, %%" #regd " \n\t" ::"m"(mm_wtwo))
-#else
-// for shared library it's better to use this way for accessing constants
-// pcmpeqd -> -1
-#define MOVQ_BONE(regd) \
-    __asm __volatile ( \
-    "pcmpeqd %%" #regd ", %%" #regd " \n\t" \
-    "psrlw $15, %%" #regd " \n\t" \
-    "packuswb %%" #regd ", %%" #regd " \n\t" ::)
-
-#define MOVQ_WTWO(regd) \
-    __asm __volatile ( \
-    "pcmpeqd %%" #regd ", %%" #regd " \n\t" \
-    "psrlw $15, %%" #regd " \n\t" \
-    "psllw $1, %%" #regd " \n\t"::)
-
-#endif
-
-// using regr as temporary and for the output result
-// first argument is unmodifed and second is trashed
-// regfe is supposed to contain 0xfefefefefefefefe
-#define PAVGB_MMX_NO_RND(rega, regb, regr, regfe) \
-    "movq " #rega ", " #regr "	\n\t"\
-    "pand " #regb ", " #regr "	\n\t"\
-    "pxor " #rega ", " #regb "	\n\t"\
-    "pand " #regfe "," #regb "	\n\t"\
-    "psrlq $1, " #regb " 	\n\t"\
-    "paddb " #regb ", " #regr "	\n\t"
-
-#define PAVGB_MMX(rega, regb, regr, regfe) \
-    "movq " #rega ", " #regr "	\n\t"\
-    "por  " #regb ", " #regr "	\n\t"\
-    "pxor " #rega ", " #regb "	\n\t"\
-    "pand " #regfe "," #regb "	\n\t"\
-    "psrlq $1, " #regb "	\n\t"\
-    "psubb " #regb ", " #regr "	\n\t"
-
-// mm6 is supposed to contain 0xfefefefefefefefe
-#define PAVGBP_MMX_NO_RND(rega, regb, regr,  regc, regd, regp) \
-    "movq " #rega ", " #regr "	\n\t"\
-    "movq " #regc ", " #regp "	\n\t"\
-    "pand " #regb ", " #regr "	\n\t"\
-    "pand " #regd ", " #regp "	\n\t"\
-    "pxor " #rega ", " #regb "	\n\t"\
-    "pxor " #regc ", " #regd "	\n\t"\
-    "pand %%mm6, " #regb "	\n\t"\
-    "pand %%mm6, " #regd "	\n\t"\
-    "psrlq $1, " #regb " 	\n\t"\
-    "psrlq $1, " #regd " 	\n\t"\
-    "paddb " #regb ", " #regr "	\n\t"\
-    "paddb " #regd ", " #regp "	\n\t"
-
-#define PAVGBP_MMX(rega, regb, regr, regc, regd, regp) \
-    "movq " #rega ", " #regr "	\n\t"\
-    "movq " #regc ", " #regp "	\n\t"\
-    "por  " #regb ", " #regr "	\n\t"\
-    "por  " #regd ", " #regp "	\n\t"\
-    "pxor " #rega ", " #regb "	\n\t"\
-    "pxor " #regc ", " #regd "	\n\t"\
-    "pand %%mm6, " #regb "     	\n\t"\
-    "pand %%mm6, " #regd "     	\n\t"\
-    "psrlq $1, " #regd "	\n\t"\
-    "psrlq $1, " #regb "	\n\t"\
-    "psubb " #regb ", " #regr "	\n\t"\
-    "psubb " #regd ", " #regp "	\n\t"
-
-/***********************************/
-/* MMX no rounding */
-#define DEF(x, y) x ## _no_rnd_ ## y ##_mmx
-#define SET_RND  MOVQ_WONE
-#define PAVGBP(a, b, c, d, e, f)	PAVGBP_MMX_NO_RND(a, b, c, d, e, f)
-#define PAVGB(a, b, c, e)		PAVGB_MMX_NO_RND(a, b, c, e)
-
-#include "dsputil_mmx_rnd.h"
-
-#undef DEF
-#undef SET_RND
-#undef PAVGBP
-#undef PAVGB
-/***********************************/
-/* MMX rounding */
-
-#define DEF(x, y) x ## _ ## y ##_mmx
-#define SET_RND  MOVQ_WTWO
-#define PAVGBP(a, b, c, d, e, f)	PAVGBP_MMX(a, b, c, d, e, f)
-#define PAVGB(a, b, c, e)		PAVGB_MMX(a, b, c, e)
-
-#include "dsputil_mmx_rnd.h"
-
-#undef DEF
-#undef SET_RND
-#undef PAVGBP
-#undef PAVGB
-
-/***********************************/
-/* 3Dnow specific */
-
-#define DEF(x) x ## _3dnow
-/* for Athlons PAVGUSB is prefered */
-#define PAVGB "pavgusb"
-
-#include "dsputil_mmx_avg.h"
-
-#undef DEF
-#undef PAVGB
-
-/***********************************/
-/* MMX2 specific */
-
-#define DEF(x) x ## _mmx2
-
-/* Introduced only in MMX2 set */
-#define PAVGB "pavgb"
-
-#include "dsputil_mmx_avg.h"
-
-#undef DEF
-#undef PAVGB
-
-/***********************************/
-/* standard MMX */
-
-#ifdef CONFIG_ENCODERS
-static void get_pixels_mmx(DCTELEM *block, const uint8_t *pixels, int line_size)
-{
-    asm volatile(
-        "mov $-128, %%"REG_a"	\n\t"
-        "pxor %%mm7, %%mm7	\n\t"
-        ".balign 16		\n\t"
-        "1:			\n\t"
-        "movq (%0), %%mm0	\n\t"
-        "movq (%0, %2), %%mm2	\n\t"
-        "movq %%mm0, %%mm1	\n\t"
-        "movq %%mm2, %%mm3	\n\t"
-        "punpcklbw %%mm7, %%mm0	\n\t"
-        "punpckhbw %%mm7, %%mm1	\n\t"
-        "punpcklbw %%mm7, %%mm2	\n\t"
-        "punpckhbw %%mm7, %%mm3	\n\t"
-        "movq %%mm0, (%1, %%"REG_a")\n\t"
-        "movq %%mm1, 8(%1, %%"REG_a")\n\t"
-        "movq %%mm2, 16(%1, %%"REG_a")\n\t"
-        "movq %%mm3, 24(%1, %%"REG_a")\n\t"
-        "add %3, %0		\n\t"
-        "add $32, %%"REG_a"	\n\t"
-        "js 1b			\n\t"
-        : "+r" (pixels)
-        : "r" (block+64), "r" ((long)line_size), "r" ((long)line_size*2)
-        : "%"REG_a
-    );
-}
-
-static inline void diff_pixels_mmx(DCTELEM *block, const uint8_t *s1, const uint8_t *s2, int stride)
-{
-    asm volatile(
-        "pxor %%mm7, %%mm7	\n\t"
-        "mov $-128, %%"REG_a"	\n\t"
-        ".balign 16		\n\t"
-        "1:			\n\t"
-        "movq (%0), %%mm0	\n\t"
-        "movq (%1), %%mm2	\n\t"
-        "movq %%mm0, %%mm1	\n\t"
-        "movq %%mm2, %%mm3	\n\t"
-        "punpcklbw %%mm7, %%mm0	\n\t"
-        "punpckhbw %%mm7, %%mm1	\n\t"
-        "punpcklbw %%mm7, %%mm2	\n\t"
-        "punpckhbw %%mm7, %%mm3	\n\t"
-        "psubw %%mm2, %%mm0	\n\t"
-        "psubw %%mm3, %%mm1	\n\t"
-        "movq %%mm0, (%2, %%"REG_a")\n\t"
-        "movq %%mm1, 8(%2, %%"REG_a")\n\t"
-        "add %3, %0		\n\t"
-        "add %3, %1		\n\t"
-        "add $16, %%"REG_a"	\n\t"
-        "jnz 1b			\n\t"
-        : "+r" (s1), "+r" (s2)
-        : "r" (block+64), "r" ((long)stride)
-        : "%"REG_a
-    );
-}
-#endif //CONFIG_ENCODERS
-
-void put_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
-{
-    const DCTELEM *p;
-    uint8_t *pix;
-
-    /* read the pixels */
-    p = block;
-    pix = pixels;
-    /* unrolled loop */
-	__asm __volatile(
-		"movq	%3, %%mm0\n\t"
-		"movq	8%3, %%mm1\n\t"
-		"movq	16%3, %%mm2\n\t"
-		"movq	24%3, %%mm3\n\t"
-		"movq	32%3, %%mm4\n\t"
-		"movq	40%3, %%mm5\n\t"
-		"movq	48%3, %%mm6\n\t"
-		"movq	56%3, %%mm7\n\t"
-		"packuswb %%mm1, %%mm0\n\t"
-		"packuswb %%mm3, %%mm2\n\t"
-		"packuswb %%mm5, %%mm4\n\t"
-		"packuswb %%mm7, %%mm6\n\t"
-		"movq	%%mm0, (%0)\n\t"
-		"movq	%%mm2, (%0, %1)\n\t"
-		"movq	%%mm4, (%0, %1, 2)\n\t"
-		"movq	%%mm6, (%0, %2)\n\t"
-		::"r" (pix), "r" ((long)line_size), "r" ((long)line_size*3), "m"(*p)
-		:"memory");
-        pix += line_size*4;
-        p += 32;
-
-    // if here would be an exact copy of the code above
-    // compiler would generate some very strange code
-    // thus using "r"
-    __asm __volatile(
-	    "movq	(%3), %%mm0\n\t"
-	    "movq	8(%3), %%mm1\n\t"
-	    "movq	16(%3), %%mm2\n\t"
-	    "movq	24(%3), %%mm3\n\t"
-	    "movq	32(%3), %%mm4\n\t"
-	    "movq	40(%3), %%mm5\n\t"
-	    "movq	48(%3), %%mm6\n\t"
-	    "movq	56(%3), %%mm7\n\t"
-	    "packuswb %%mm1, %%mm0\n\t"
-	    "packuswb %%mm3, %%mm2\n\t"
-	    "packuswb %%mm5, %%mm4\n\t"
-	    "packuswb %%mm7, %%mm6\n\t"
-	    "movq	%%mm0, (%0)\n\t"
-	    "movq	%%mm2, (%0, %1)\n\t"
-	    "movq	%%mm4, (%0, %1, 2)\n\t"
-	    "movq	%%mm6, (%0, %2)\n\t"
-	    ::"r" (pix), "r" ((long)line_size), "r" ((long)line_size*3), "r"(p)
-	    :"memory");
-}
-
-static const unsigned char __align8 vector128[8] =
-  { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };
-
-void put_signed_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
-{
-    int i;
-
-    movq_m2r(*vector128, mm1);
-    for (i = 0; i < 8; i++) {
-        movq_m2r(*(block), mm0);
-        packsswb_m2r(*(block + 4), mm0);
-        block += 8;
-        paddb_r2r(mm1, mm0);
-        movq_r2m(mm0, *pixels);
-        pixels += line_size;
-    }
-}
-
-void add_pixels_clamped_mmx(const DCTELEM *block, uint8_t *pixels, int line_size)
-{
-    const DCTELEM *p;
-    uint8_t *pix;
-    int i;
-
-    /* read the pixels */
-    p = block;
-    pix = pixels;
-    MOVQ_ZERO(mm7);
-    i = 4;
-    do {
-	__asm __volatile(
-		"movq	(%2), %%mm0\n\t"
-		"movq	8(%2), %%mm1\n\t"
-		"movq	16(%2), %%mm2\n\t"
-		"movq	24(%2), %%mm3\n\t"
-		"movq	%0, %%mm4\n\t"
-		"movq	%1, %%mm6\n\t"
-		"movq	%%mm4, %%mm5\n\t"
-		"punpcklbw %%mm7, %%mm4\n\t"
-		"punpckhbw %%mm7, %%mm5\n\t"
-		"paddsw	%%mm4, %%mm0\n\t"
-		"paddsw	%%mm5, %%mm1\n\t"
-		"movq	%%mm6, %%mm5\n\t"
-		"punpcklbw %%mm7, %%mm6\n\t"
-		"punpckhbw %%mm7, %%mm5\n\t"
-		"paddsw	%%mm6, %%mm2\n\t"
-		"paddsw	%%mm5, %%mm3\n\t"
-		"packuswb %%mm1, %%mm0\n\t"
-		"packuswb %%mm3, %%mm2\n\t"
-		"movq	%%mm0, %0\n\t"
-		"movq	%%mm2, %1\n\t"
-		:"+m"(*pix), "+m"(*(pix+line_size))
-		:"r"(p)
-		:"memory");
-        pix += line_size*2;
-        p += 16;
-    } while (--i);
-}
-
-static void put_pixels4_mmx(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    __asm __volatile(
-	 "lea (%3, %3), %%"REG_a"	\n\t"
-	 ".balign 8			\n\t"
-	 "1:				\n\t"
-	 "movd (%1), %%mm0		\n\t"
-	 "movd (%1, %3), %%mm1		\n\t"
-	 "movd %%mm0, (%2)		\n\t"
-	 "movd %%mm1, (%2, %3)		\n\t"
-	 "add %%"REG_a", %1		\n\t"
-	 "add %%"REG_a", %2		\n\t"
-	 "movd (%1), %%mm0		\n\t"
-	 "movd (%1, %3), %%mm1		\n\t"
-	 "movd %%mm0, (%2)		\n\t"
-	 "movd %%mm1, (%2, %3)		\n\t"
-	 "add %%"REG_a", %1		\n\t"
-	 "add %%"REG_a", %2		\n\t"
-	 "subl $4, %0			\n\t"
-	 "jnz 1b			\n\t"
-	 : "+g"(h), "+r" (pixels),  "+r" (block)
-	 : "r"((long)line_size)
-	 : "%"REG_a, "memory"
-	);
-}
-
-static void put_pixels8_mmx(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    __asm __volatile(
-	 "lea (%3, %3), %%"REG_a"	\n\t"
-	 ".balign 8			\n\t"
-	 "1:				\n\t"
-	 "movq (%1), %%mm0		\n\t"
-	 "movq (%1, %3), %%mm1		\n\t"
-     	 "movq %%mm0, (%2)		\n\t"
-	 "movq %%mm1, (%2, %3)		\n\t"
-	 "add %%"REG_a", %1		\n\t"
-	 "add %%"REG_a", %2		\n\t"
-	 "movq (%1), %%mm0		\n\t"
-	 "movq (%1, %3), %%mm1		\n\t"
-	 "movq %%mm0, (%2)		\n\t"
-	 "movq %%mm1, (%2, %3)		\n\t"
-	 "add %%"REG_a", %1		\n\t"
-	 "add %%"REG_a", %2		\n\t"
-	 "subl $4, %0			\n\t"
-	 "jnz 1b			\n\t"
-	 : "+g"(h), "+r" (pixels),  "+r" (block)
-	 : "r"((long)line_size)
-	 : "%"REG_a, "memory"
-	);
-}
-
-static void put_pixels16_mmx(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    __asm __volatile(
-	 "lea (%3, %3), %%"REG_a"	\n\t"
-	 ".balign 8			\n\t"
-	 "1:				\n\t"
-	 "movq (%1), %%mm0		\n\t"
-	 "movq 8(%1), %%mm4		\n\t"
-	 "movq (%1, %3), %%mm1		\n\t"
-	 "movq 8(%1, %3), %%mm5		\n\t"
-     	 "movq %%mm0, (%2)		\n\t"
-     	 "movq %%mm4, 8(%2)		\n\t"
-	 "movq %%mm1, (%2, %3)		\n\t"
-	 "movq %%mm5, 8(%2, %3)		\n\t"
-	 "add %%"REG_a", %1		\n\t"
-	 "add %%"REG_a", %2       	\n\t"
-	 "movq (%1), %%mm0		\n\t"
-	 "movq 8(%1), %%mm4		\n\t"
-	 "movq (%1, %3), %%mm1		\n\t"
-	 "movq 8(%1, %3), %%mm5		\n\t"
-	 "movq %%mm0, (%2)		\n\t"
-	 "movq %%mm4, 8(%2)		\n\t"
-	 "movq %%mm1, (%2, %3)		\n\t"
-	 "movq %%mm5, 8(%2, %3)		\n\t"
-	 "add %%"REG_a", %1		\n\t"
-	 "add %%"REG_a", %2       	\n\t"
-	 "subl $4, %0			\n\t"
-	 "jnz 1b			\n\t"
-	 : "+g"(h), "+r" (pixels),  "+r" (block)
-	 : "r"((long)line_size)
-	 : "%"REG_a, "memory"
-	);
-}
-
-static void clear_blocks_mmx(DCTELEM *blocks)
-{
-    __asm __volatile(
-                "pxor %%mm7, %%mm7		\n\t"
-                "mov $-128*6, %%"REG_a"	\n\t"
-                "1:				\n\t"
-                "movq %%mm7, (%0, %%"REG_a")	\n\t"
-                "movq %%mm7, 8(%0, %%"REG_a")	\n\t"
-                "movq %%mm7, 16(%0, %%"REG_a")	\n\t"
-                "movq %%mm7, 24(%0, %%"REG_a")	\n\t"
-                "add $32, %%"REG_a"		\n\t"
-                " js 1b				\n\t"
-                : : "r" (((uint8_t *)blocks)+128*6)
-                : "%"REG_a
-        );
-}
-
-#ifdef CONFIG_ENCODERS
-static int pix_sum16_mmx(uint8_t * pix, int line_size){
-    const int h=16;
-    int sum;
-    long index= -line_size*h;
-
-    __asm __volatile(
-                "pxor %%mm7, %%mm7		\n\t"
-                "pxor %%mm6, %%mm6		\n\t"
-                "1:				\n\t"
-                "movq (%2, %1), %%mm0		\n\t"
-                "movq (%2, %1), %%mm1		\n\t"
-                "movq 8(%2, %1), %%mm2		\n\t"
-                "movq 8(%2, %1), %%mm3		\n\t"
-                "punpcklbw %%mm7, %%mm0		\n\t"
-                "punpckhbw %%mm7, %%mm1		\n\t"
-                "punpcklbw %%mm7, %%mm2		\n\t"
-                "punpckhbw %%mm7, %%mm3		\n\t"
-                "paddw %%mm0, %%mm1		\n\t"
-                "paddw %%mm2, %%mm3		\n\t"
-                "paddw %%mm1, %%mm3		\n\t"
-                "paddw %%mm3, %%mm6		\n\t"
-                "add %3, %1			\n\t"
-                " js 1b				\n\t"
-                "movq %%mm6, %%mm5		\n\t"
-                "psrlq $32, %%mm6		\n\t"
-                "paddw %%mm5, %%mm6		\n\t"
-                "movq %%mm6, %%mm5		\n\t"
-                "psrlq $16, %%mm6		\n\t"
-                "paddw %%mm5, %%mm6		\n\t"
-                "movd %%mm6, %0			\n\t"
-                "andl $0xFFFF, %0		\n\t"
-                : "=&r" (sum), "+r" (index)
-                : "r" (pix - index), "r" ((long)line_size)
-        );
-
-        return sum;
-}
-#endif //CONFIG_ENCODERS
-
-static void add_bytes_mmx(uint8_t *dst, uint8_t *src, int w){
-    long i=0;
-    asm volatile(
-        "1:				\n\t"
-        "movq  (%1, %0), %%mm0		\n\t"
-        "movq  (%2, %0), %%mm1		\n\t"
-        "paddb %%mm0, %%mm1		\n\t"
-        "movq %%mm1, (%2, %0)		\n\t"
-        "movq 8(%1, %0), %%mm0		\n\t"
-        "movq 8(%2, %0), %%mm1		\n\t"
-        "paddb %%mm0, %%mm1		\n\t"
-        "movq %%mm1, 8(%2, %0)		\n\t"
-        "add $16, %0			\n\t"
-        "cmp %3, %0			\n\t"
-        " jb 1b				\n\t"
-        : "+r" (i)
-        : "r"(src), "r"(dst), "r"((long)w-15)
-    );
-    for(; i<w; i++)
-        dst[i+0] += src[i+0];
-}
-
-#define H263_LOOP_FILTER \
-        "pxor %%mm7, %%mm7		\n\t"\
-        "movq  %0, %%mm0		\n\t"\
-        "movq  %0, %%mm1		\n\t"\
-        "movq  %3, %%mm2		\n\t"\
-        "movq  %3, %%mm3		\n\t"\
-        "punpcklbw %%mm7, %%mm0		\n\t"\
-        "punpckhbw %%mm7, %%mm1		\n\t"\
-        "punpcklbw %%mm7, %%mm2		\n\t"\
-        "punpckhbw %%mm7, %%mm3		\n\t"\
-        "psubw %%mm2, %%mm0		\n\t"\
-        "psubw %%mm3, %%mm1		\n\t"\
-        "movq  %1, %%mm2		\n\t"\
-        "movq  %1, %%mm3		\n\t"\
-        "movq  %2, %%mm4		\n\t"\
-        "movq  %2, %%mm5		\n\t"\
-        "punpcklbw %%mm7, %%mm2		\n\t"\
-        "punpckhbw %%mm7, %%mm3		\n\t"\
-        "punpcklbw %%mm7, %%mm4		\n\t"\
-        "punpckhbw %%mm7, %%mm5		\n\t"\
-        "psubw %%mm2, %%mm4		\n\t"\
-        "psubw %%mm3, %%mm5		\n\t"\
-        "psllw $2, %%mm4		\n\t"\
-        "psllw $2, %%mm5		\n\t"\
-        "paddw %%mm0, %%mm4		\n\t"\
-        "paddw %%mm1, %%mm5		\n\t"\
-        "pxor %%mm6, %%mm6		\n\t"\
-        "pcmpgtw %%mm4, %%mm6		\n\t"\
-        "pcmpgtw %%mm5, %%mm7		\n\t"\
-        "pxor %%mm6, %%mm4		\n\t"\
-        "pxor %%mm7, %%mm5		\n\t"\
-        "psubw %%mm6, %%mm4		\n\t"\
-        "psubw %%mm7, %%mm5		\n\t"\
-        "psrlw $3, %%mm4		\n\t"\
-        "psrlw $3, %%mm5		\n\t"\
-        "packuswb %%mm5, %%mm4		\n\t"\
-        "packsswb %%mm7, %%mm6		\n\t"\
-        "pxor %%mm7, %%mm7		\n\t"\
-        "movd %4, %%mm2			\n\t"\
-        "punpcklbw %%mm2, %%mm2		\n\t"\
-        "punpcklbw %%mm2, %%mm2		\n\t"\
-        "punpcklbw %%mm2, %%mm2		\n\t"\
-        "psubusb %%mm4, %%mm2		\n\t"\
-        "movq %%mm2, %%mm3		\n\t"\
-        "psubusb %%mm4, %%mm3		\n\t"\
-        "psubb %%mm3, %%mm2		\n\t"\
-        "movq %1, %%mm3			\n\t"\
-        "movq %2, %%mm4			\n\t"\
-        "pxor %%mm6, %%mm3		\n\t"\
-        "pxor %%mm6, %%mm4		\n\t"\
-        "paddusb %%mm2, %%mm3		\n\t"\
-        "psubusb %%mm2, %%mm4		\n\t"\
-        "pxor %%mm6, %%mm3		\n\t"\
-        "pxor %%mm6, %%mm4		\n\t"\
-        "paddusb %%mm2, %%mm2		\n\t"\
-        "packsswb %%mm1, %%mm0		\n\t"\
-        "pcmpgtb %%mm0, %%mm7		\n\t"\
-        "pxor %%mm7, %%mm0		\n\t"\
-        "psubb %%mm7, %%mm0		\n\t"\
-        "movq %%mm0, %%mm1		\n\t"\
-        "psubusb %%mm2, %%mm0		\n\t"\
-        "psubb %%mm0, %%mm1		\n\t"\
-        "pand %5, %%mm1			\n\t"\
-        "psrlw $2, %%mm1		\n\t"\
-        "pxor %%mm7, %%mm1		\n\t"\
-        "psubb %%mm7, %%mm1		\n\t"\
-        "movq %0, %%mm5			\n\t"\
-        "movq %3, %%mm6			\n\t"\
-        "psubb %%mm1, %%mm5		\n\t"\
-        "paddb %%mm1, %%mm6		\n\t"
-
-static void h263_v_loop_filter_mmx(uint8_t *src, int stride, int qscale){
-    const int strength= ff_h263_loop_filter_strength[qscale];
-
-    asm volatile(
-    
-        H263_LOOP_FILTER
-        
-        "movq %%mm3, %1			\n\t"
-        "movq %%mm4, %2			\n\t"
-        "movq %%mm5, %0			\n\t"
-        "movq %%mm6, %3			\n\t"
-        : "+m" (*(uint64_t*)(src - 2*stride)),
-          "+m" (*(uint64_t*)(src - 1*stride)),
-          "+m" (*(uint64_t*)(src + 0*stride)),
-          "+m" (*(uint64_t*)(src + 1*stride))
-        : "g" (2*strength), "m"(ff_pb_FC)
-    );
-}
-
-static inline void transpose4x4(uint8_t *dst, uint8_t *src, int dst_stride, int src_stride){
-    asm volatile( //FIXME could save 1 instruction if done as 8x4 ...
-        "movd  %4, %%mm0		\n\t"
-        "movd  %5, %%mm1		\n\t"
-        "movd  %6, %%mm2		\n\t"
-        "movd  %7, %%mm3		\n\t"
-        "punpcklbw %%mm1, %%mm0		\n\t"
-        "punpcklbw %%mm3, %%mm2		\n\t"
-        "movq %%mm0, %%mm1		\n\t"
-        "punpcklwd %%mm2, %%mm0		\n\t"
-        "punpckhwd %%mm2, %%mm1		\n\t"
-        "movd  %%mm0, %0		\n\t"
-        "punpckhdq %%mm0, %%mm0		\n\t"
-        "movd  %%mm0, %1		\n\t"
-        "movd  %%mm1, %2		\n\t"
-        "punpckhdq %%mm1, %%mm1		\n\t"
-        "movd  %%mm1, %3		\n\t"
-        
-        : "=m" (*(uint32_t*)(dst + 0*dst_stride)),
-          "=m" (*(uint32_t*)(dst + 1*dst_stride)),
-          "=m" (*(uint32_t*)(dst + 2*dst_stride)),
-          "=m" (*(uint32_t*)(dst + 3*dst_stride))
-        :  "m" (*(uint32_t*)(src + 0*src_stride)),
-           "m" (*(uint32_t*)(src + 1*src_stride)),
-           "m" (*(uint32_t*)(src + 2*src_stride)),
-           "m" (*(uint32_t*)(src + 3*src_stride))
-    );
-}
-
-static void h263_h_loop_filter_mmx(uint8_t *src, int stride, int qscale){
-    const int strength= ff_h263_loop_filter_strength[qscale];
-    uint64_t temp[4] __attribute__ ((aligned(8)));
-    uint8_t *btemp= (uint8_t*)temp;
-    
-    src -= 2;
-
-    transpose4x4(btemp  , src           , 8, stride);
-    transpose4x4(btemp+4, src + 4*stride, 8, stride);
-    asm volatile(
-        H263_LOOP_FILTER // 5 3 4 6
-        
-        : "+m" (temp[0]),
-          "+m" (temp[1]),
-          "+m" (temp[2]),
-          "+m" (temp[3])
-        : "g" (2*strength), "m"(ff_pb_FC)
-    );
-
-    asm volatile(
-        "movq %%mm5, %%mm1		\n\t"
-        "movq %%mm4, %%mm0		\n\t"
-        "punpcklbw %%mm3, %%mm5		\n\t"
-        "punpcklbw %%mm6, %%mm4		\n\t"
-        "punpckhbw %%mm3, %%mm1		\n\t"
-        "punpckhbw %%mm6, %%mm0		\n\t"
-        "movq %%mm5, %%mm3		\n\t"
-        "movq %%mm1, %%mm6		\n\t"
-        "punpcklwd %%mm4, %%mm5		\n\t"
-        "punpcklwd %%mm0, %%mm1		\n\t"
-        "punpckhwd %%mm4, %%mm3		\n\t"
-        "punpckhwd %%mm0, %%mm6		\n\t"
-        "movd %%mm5, (%0)		\n\t"
-        "punpckhdq %%mm5, %%mm5		\n\t"
-        "movd %%mm5, (%0,%2)		\n\t"
-        "movd %%mm3, (%0,%2,2)		\n\t"
-        "punpckhdq %%mm3, %%mm3		\n\t"
-        "movd %%mm3, (%0,%3)		\n\t"
-        "movd %%mm1, (%1)		\n\t"
-        "punpckhdq %%mm1, %%mm1		\n\t"
-        "movd %%mm1, (%1,%2)		\n\t"
-        "movd %%mm6, (%1,%2,2)		\n\t"
-        "punpckhdq %%mm6, %%mm6		\n\t"
-        "movd %%mm6, (%1,%3)		\n\t"
-        :: "r" (src),
-           "r" (src + 4*stride),
-           "r" ((long)   stride ),
-           "r" ((long)(3*stride))
-    );
-}
-
-#ifdef CONFIG_ENCODERS
-static int pix_norm1_mmx(uint8_t *pix, int line_size) {
-    int tmp;
-  asm volatile (
-      "movl $16,%%ecx\n"
-      "pxor %%mm0,%%mm0\n"
-      "pxor %%mm7,%%mm7\n"
-      "1:\n"
-      "movq (%0),%%mm2\n"	/* mm2 = pix[0-7] */
-      "movq 8(%0),%%mm3\n"	/* mm3 = pix[8-15] */
-
-      "movq %%mm2,%%mm1\n"	/* mm1 = mm2 = pix[0-7] */
-
-      "punpckhbw %%mm0,%%mm1\n"	/* mm1 = [pix4-7] */
-      "punpcklbw %%mm0,%%mm2\n"	/* mm2 = [pix0-3] */
-
-      "movq %%mm3,%%mm4\n"	/* mm4 = mm3 = pix[8-15] */
-      "punpckhbw %%mm0,%%mm3\n"	/* mm3 = [pix12-15] */
-      "punpcklbw %%mm0,%%mm4\n"	/* mm4 = [pix8-11] */
-
-      "pmaddwd %%mm1,%%mm1\n"	/* mm1 = (pix0^2+pix1^2,pix2^2+pix3^2) */
-      "pmaddwd %%mm2,%%mm2\n"	/* mm2 = (pix4^2+pix5^2,pix6^2+pix7^2) */
-
-      "pmaddwd %%mm3,%%mm3\n"
-      "pmaddwd %%mm4,%%mm4\n"
-
-      "paddd %%mm1,%%mm2\n"	/* mm2 = (pix0^2+pix1^2+pix4^2+pix5^2,
-					  pix2^2+pix3^2+pix6^2+pix7^2) */
-      "paddd %%mm3,%%mm4\n"
-      "paddd %%mm2,%%mm7\n"
-
-      "add %2, %0\n"
-      "paddd %%mm4,%%mm7\n"
-      "dec %%ecx\n"
-      "jnz 1b\n"
-
-      "movq %%mm7,%%mm1\n"
-      "psrlq $32, %%mm7\n"	/* shift hi dword to lo */
-      "paddd %%mm7,%%mm1\n"
-      "movd %%mm1,%1\n"
-      : "+r" (pix), "=r"(tmp) : "r" ((long)line_size) : "%ecx" );
-    return tmp;
-}
-
-static int sse8_mmx(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
-    int tmp;
-  asm volatile (
-      "movl %4,%%ecx\n"
-      "pxor %%mm0,%%mm0\n"	/* mm0 = 0 */
-      "pxor %%mm7,%%mm7\n"	/* mm7 holds the sum */
-      "1:\n"
-      "movq (%0),%%mm1\n"	/* mm1 = pix1[0-7] */
-      "movq (%1),%%mm2\n"	/* mm2 = pix2[0-7] */
-
-      "movq %%mm1,%%mm5\n"
-      "psubusb %%mm2,%%mm1\n"
-      "psubusb %%mm5,%%mm2\n"
-
-      "por %%mm1,%%mm2\n"
-
-      "movq %%mm2,%%mm1\n"
-
-      "punpckhbw %%mm0,%%mm2\n"
-      "punpcklbw %%mm0,%%mm1\n"	/* mm1 now spread over (mm1,mm2) */
-
-      "pmaddwd %%mm2,%%mm2\n"
-      "pmaddwd %%mm1,%%mm1\n"
-
-      "add %3,%0\n"
-      "add %3,%1\n"
-
-      "paddd %%mm2,%%mm1\n"
-      "paddd %%mm1,%%mm7\n"
-
-      "decl %%ecx\n"
-      "jnz 1b\n"
-
-      "movq %%mm7,%%mm1\n"
-      "psrlq $32, %%mm7\n"	/* shift hi dword to lo */
-      "paddd %%mm7,%%mm1\n"
-      "movd %%mm1,%2\n"
-      : "+r" (pix1), "+r" (pix2), "=r"(tmp) 
-      : "r" ((long)line_size) , "m" (h)
-      : "%ecx");
-    return tmp;
-}
-
-static int sse16_mmx(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
-    int tmp;
-  asm volatile (
-      "movl %4,%%ecx\n"
-      "pxor %%mm0,%%mm0\n"	/* mm0 = 0 */
-      "pxor %%mm7,%%mm7\n"	/* mm7 holds the sum */
-      "1:\n"
-      "movq (%0),%%mm1\n"	/* mm1 = pix1[0-7] */
-      "movq (%1),%%mm2\n"	/* mm2 = pix2[0-7] */
-      "movq 8(%0),%%mm3\n"	/* mm3 = pix1[8-15] */
-      "movq 8(%1),%%mm4\n"	/* mm4 = pix2[8-15] */
-
-      /* todo: mm1-mm2, mm3-mm4 */
-      /* algo: substract mm1 from mm2 with saturation and vice versa */
-      /*       OR the results to get absolute difference */
-      "movq %%mm1,%%mm5\n"
-      "movq %%mm3,%%mm6\n"
-      "psubusb %%mm2,%%mm1\n"
-      "psubusb %%mm4,%%mm3\n"
-      "psubusb %%mm5,%%mm2\n"
-      "psubusb %%mm6,%%mm4\n"
-
-      "por %%mm1,%%mm2\n"
-      "por %%mm3,%%mm4\n"
-
-      /* now convert to 16-bit vectors so we can square them */
-      "movq %%mm2,%%mm1\n"
-      "movq %%mm4,%%mm3\n"
-
-      "punpckhbw %%mm0,%%mm2\n"
-      "punpckhbw %%mm0,%%mm4\n"
-      "punpcklbw %%mm0,%%mm1\n"	/* mm1 now spread over (mm1,mm2) */
-      "punpcklbw %%mm0,%%mm3\n"	/* mm4 now spread over (mm3,mm4) */
-
-      "pmaddwd %%mm2,%%mm2\n"
-      "pmaddwd %%mm4,%%mm4\n"
-      "pmaddwd %%mm1,%%mm1\n"
-      "pmaddwd %%mm3,%%mm3\n"
-
-      "add %3,%0\n"
-      "add %3,%1\n"
-
-      "paddd %%mm2,%%mm1\n"
-      "paddd %%mm4,%%mm3\n"
-      "paddd %%mm1,%%mm7\n"
-      "paddd %%mm3,%%mm7\n"
-
-      "decl %%ecx\n"
-      "jnz 1b\n"
-
-      "movq %%mm7,%%mm1\n"
-      "psrlq $32, %%mm7\n"	/* shift hi dword to lo */
-      "paddd %%mm7,%%mm1\n"
-      "movd %%mm1,%2\n"
-      : "+r" (pix1), "+r" (pix2), "=r"(tmp) 
-      : "r" ((long)line_size) , "m" (h)
-      : "%ecx");
-    return tmp;
-}
-
-static int hf_noise8_mmx(uint8_t * pix1, int line_size, int h) {
-    int tmp;
-  asm volatile (
-      "movl %3,%%ecx\n"
-      "pxor %%mm7,%%mm7\n"
-      "pxor %%mm6,%%mm6\n"
-      
-      "movq (%0),%%mm0\n"
-      "movq %%mm0, %%mm1\n"
-      "psllq $8, %%mm0\n"
-      "psrlq $8, %%mm1\n"
-      "psrlq $8, %%mm0\n"
-      "movq %%mm0, %%mm2\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm0\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm2\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm0\n"
-      "psubw %%mm3, %%mm2\n"
-      
-      "add %2,%0\n"
-      
-      "movq (%0),%%mm4\n"
-      "movq %%mm4, %%mm1\n"
-      "psllq $8, %%mm4\n"
-      "psrlq $8, %%mm1\n"
-      "psrlq $8, %%mm4\n"
-      "movq %%mm4, %%mm5\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm4\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm5\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm4\n"
-      "psubw %%mm3, %%mm5\n"
-      "psubw %%mm4, %%mm0\n"
-      "psubw %%mm5, %%mm2\n"
-      "pxor %%mm3, %%mm3\n"
-      "pxor %%mm1, %%mm1\n"
-      "pcmpgtw %%mm0, %%mm3\n\t"
-      "pcmpgtw %%mm2, %%mm1\n\t"
-      "pxor %%mm3, %%mm0\n"
-      "pxor %%mm1, %%mm2\n"
-      "psubw %%mm3, %%mm0\n" 
-      "psubw %%mm1, %%mm2\n"
-      "paddw %%mm0, %%mm2\n"
-      "paddw %%mm2, %%mm6\n"
-
-      "add %2,%0\n"
-      "1:\n"
-  
-      "movq (%0),%%mm0\n"
-      "movq %%mm0, %%mm1\n"
-      "psllq $8, %%mm0\n"
-      "psrlq $8, %%mm1\n"
-      "psrlq $8, %%mm0\n"
-      "movq %%mm0, %%mm2\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm0\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm2\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm0\n"
-      "psubw %%mm3, %%mm2\n"
-      "psubw %%mm0, %%mm4\n"
-      "psubw %%mm2, %%mm5\n"
-      "pxor %%mm3, %%mm3\n"
-      "pxor %%mm1, %%mm1\n"
-      "pcmpgtw %%mm4, %%mm3\n\t"
-      "pcmpgtw %%mm5, %%mm1\n\t"
-      "pxor %%mm3, %%mm4\n"
-      "pxor %%mm1, %%mm5\n"
-      "psubw %%mm3, %%mm4\n" 
-      "psubw %%mm1, %%mm5\n"
-      "paddw %%mm4, %%mm5\n"
-      "paddw %%mm5, %%mm6\n"
-      
-      "add %2,%0\n"
-      
-      "movq (%0),%%mm4\n"
-      "movq %%mm4, %%mm1\n"
-      "psllq $8, %%mm4\n"
-      "psrlq $8, %%mm1\n"
-      "psrlq $8, %%mm4\n"
-      "movq %%mm4, %%mm5\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm4\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm5\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm4\n"
-      "psubw %%mm3, %%mm5\n"
-      "psubw %%mm4, %%mm0\n"
-      "psubw %%mm5, %%mm2\n"
-      "pxor %%mm3, %%mm3\n"
-      "pxor %%mm1, %%mm1\n"
-      "pcmpgtw %%mm0, %%mm3\n\t"
-      "pcmpgtw %%mm2, %%mm1\n\t"
-      "pxor %%mm3, %%mm0\n"
-      "pxor %%mm1, %%mm2\n"
-      "psubw %%mm3, %%mm0\n" 
-      "psubw %%mm1, %%mm2\n"
-      "paddw %%mm0, %%mm2\n"
-      "paddw %%mm2, %%mm6\n"
-
-      "add %2,%0\n"
-      "subl $2, %%ecx\n"
-      " jnz 1b\n"
-
-      "movq %%mm6, %%mm0\n"
-      "punpcklwd %%mm7,%%mm0\n"
-      "punpckhwd %%mm7,%%mm6\n"
-      "paddd %%mm0, %%mm6\n"
-      
-      "movq %%mm6,%%mm0\n"
-      "psrlq $32, %%mm6\n"
-      "paddd %%mm6,%%mm0\n"
-      "movd %%mm0,%1\n"
-      : "+r" (pix1), "=r"(tmp) 
-      : "r" ((long)line_size) , "g" (h-2)
-      : "%ecx");
-      return tmp;
-}
-
-static int hf_noise16_mmx(uint8_t * pix1, int line_size, int h) {
-    int tmp;
-    uint8_t * pix= pix1;
-  asm volatile (
-      "movl %3,%%ecx\n"
-      "pxor %%mm7,%%mm7\n"
-      "pxor %%mm6,%%mm6\n"
-      
-      "movq (%0),%%mm0\n"
-      "movq 1(%0),%%mm1\n"
-      "movq %%mm0, %%mm2\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm0\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm2\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm0\n"
-      "psubw %%mm3, %%mm2\n"
-      
-      "add %2,%0\n"
-      
-      "movq (%0),%%mm4\n"
-      "movq 1(%0),%%mm1\n"
-      "movq %%mm4, %%mm5\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm4\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm5\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm4\n"
-      "psubw %%mm3, %%mm5\n"
-      "psubw %%mm4, %%mm0\n"
-      "psubw %%mm5, %%mm2\n"
-      "pxor %%mm3, %%mm3\n"
-      "pxor %%mm1, %%mm1\n"
-      "pcmpgtw %%mm0, %%mm3\n\t"
-      "pcmpgtw %%mm2, %%mm1\n\t"
-      "pxor %%mm3, %%mm0\n"
-      "pxor %%mm1, %%mm2\n"
-      "psubw %%mm3, %%mm0\n" 
-      "psubw %%mm1, %%mm2\n"
-      "paddw %%mm0, %%mm2\n"
-      "paddw %%mm2, %%mm6\n"
-
-      "add %2,%0\n"
-      "1:\n"
-  
-      "movq (%0),%%mm0\n"
-      "movq 1(%0),%%mm1\n"
-      "movq %%mm0, %%mm2\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm0\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm2\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm0\n"
-      "psubw %%mm3, %%mm2\n"
-      "psubw %%mm0, %%mm4\n"
-      "psubw %%mm2, %%mm5\n"
-      "pxor %%mm3, %%mm3\n"
-      "pxor %%mm1, %%mm1\n"
-      "pcmpgtw %%mm4, %%mm3\n\t"
-      "pcmpgtw %%mm5, %%mm1\n\t"
-      "pxor %%mm3, %%mm4\n"
-      "pxor %%mm1, %%mm5\n"
-      "psubw %%mm3, %%mm4\n"
-      "psubw %%mm1, %%mm5\n"
-      "paddw %%mm4, %%mm5\n"
-      "paddw %%mm5, %%mm6\n"
-      
-      "add %2,%0\n"
-      
-      "movq (%0),%%mm4\n"
-      "movq 1(%0),%%mm1\n"
-      "movq %%mm4, %%mm5\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm4\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm5\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm4\n"
-      "psubw %%mm3, %%mm5\n"
-      "psubw %%mm4, %%mm0\n"
-      "psubw %%mm5, %%mm2\n"
-      "pxor %%mm3, %%mm3\n"
-      "pxor %%mm1, %%mm1\n"
-      "pcmpgtw %%mm0, %%mm3\n\t"
-      "pcmpgtw %%mm2, %%mm1\n\t"
-      "pxor %%mm3, %%mm0\n"
-      "pxor %%mm1, %%mm2\n"
-      "psubw %%mm3, %%mm0\n" 
-      "psubw %%mm1, %%mm2\n"
-      "paddw %%mm0, %%mm2\n"
-      "paddw %%mm2, %%mm6\n"
-
-      "add %2,%0\n"
-      "subl $2, %%ecx\n"
-      " jnz 1b\n"
-
-      "movq %%mm6, %%mm0\n"
-      "punpcklwd %%mm7,%%mm0\n"
-      "punpckhwd %%mm7,%%mm6\n"
-      "paddd %%mm0, %%mm6\n"
-      
-      "movq %%mm6,%%mm0\n"
-      "psrlq $32, %%mm6\n"
-      "paddd %%mm6,%%mm0\n"
-      "movd %%mm0,%1\n"
-      : "+r" (pix1), "=r"(tmp) 
-      : "r" ((long)line_size) , "g" (h-2)
-      : "%ecx");
-      return tmp + hf_noise8_mmx(pix+8, line_size, h);
-}
-
-static int nsse16_mmx(void *p, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
-    MpegEncContext *c = p;
-    int score1= sse16_mmx(c, pix1, pix2, line_size, h);
-    int score2= hf_noise16_mmx(pix1, line_size, h) - hf_noise16_mmx(pix2, line_size, h);
-
-    if(c) return score1 + ABS(score2)*c->avctx->nsse_weight;
-    else  return score1 + ABS(score2)*8;
-}
-
-static int nsse8_mmx(void *p, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
-    MpegEncContext *c = p;
-    int score1= sse8_mmx(c, pix1, pix2, line_size, h);
-    int score2= hf_noise8_mmx(pix1, line_size, h) - hf_noise8_mmx(pix2, line_size, h);
-
-    if(c) return score1 + ABS(score2)*c->avctx->nsse_weight;
-    else  return score1 + ABS(score2)*8;
-}
-
-static int vsad_intra16_mmx(void *v, uint8_t * pix, uint8_t * dummy, int line_size, int h) {
-    int tmp;
-    
-    assert( (((int)pix) & 7) == 0);
-    assert((line_size &7) ==0);
-    
-#define SUM(in0, in1, out0, out1) \
-      "movq (%0), %%mm2\n"\
-      "movq 8(%0), %%mm3\n"\
-      "add %2,%0\n"\
-      "movq %%mm2, " #out0 "\n"\
-      "movq %%mm3, " #out1 "\n"\
-      "psubusb " #in0 ", %%mm2\n"\
-      "psubusb " #in1 ", %%mm3\n"\
-      "psubusb " #out0 ", " #in0 "\n"\
-      "psubusb " #out1 ", " #in1 "\n"\
-      "por %%mm2, " #in0 "\n"\
-      "por %%mm3, " #in1 "\n"\
-      "movq " #in0 ", %%mm2\n"\
-      "movq " #in1 ", %%mm3\n"\
-      "punpcklbw %%mm7, " #in0 "\n"\
-      "punpcklbw %%mm7, " #in1 "\n"\
-      "punpckhbw %%mm7, %%mm2\n"\
-      "punpckhbw %%mm7, %%mm3\n"\
-      "paddw " #in1 ", " #in0 "\n"\
-      "paddw %%mm3, %%mm2\n"\
-      "paddw %%mm2, " #in0 "\n"\
-      "paddw " #in0 ", %%mm6\n"
-
-    
-  asm volatile (
-      "movl %3,%%ecx\n"
-      "pxor %%mm6,%%mm6\n"
-      "pxor %%mm7,%%mm7\n"
-      "movq (%0),%%mm0\n"
-      "movq 8(%0),%%mm1\n"
-      "add %2,%0\n"
-      "subl $2, %%ecx\n"
-      SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-      "1:\n"
-      
-      SUM(%%mm4, %%mm5, %%mm0, %%mm1)
-      
-      SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-      
-      "subl $2, %%ecx\n"
-      "jnz 1b\n"
-
-      "movq %%mm6,%%mm0\n"
-      "psrlq $32, %%mm6\n"
-      "paddw %%mm6,%%mm0\n"
-      "movq %%mm0,%%mm6\n"
-      "psrlq $16, %%mm0\n"
-      "paddw %%mm6,%%mm0\n"
-      "movd %%mm0,%1\n"
-      : "+r" (pix), "=r"(tmp) 
-      : "r" ((long)line_size) , "m" (h)
-      : "%ecx");
-    return tmp & 0xFFFF;
-}
-#undef SUM
-
-static int vsad_intra16_mmx2(void *v, uint8_t * pix, uint8_t * dummy, int line_size, int h) {
-    int tmp;
-    
-    assert( (((int)pix) & 7) == 0);
-    assert((line_size &7) ==0);
-    
-#define SUM(in0, in1, out0, out1) \
-      "movq (%0), " #out0 "\n"\
-      "movq 8(%0), " #out1 "\n"\
-      "add %2,%0\n"\
-      "psadbw " #out0 ", " #in0 "\n"\
-      "psadbw " #out1 ", " #in1 "\n"\
-      "paddw " #in1 ", " #in0 "\n"\
-      "paddw " #in0 ", %%mm6\n"
-
-  asm volatile (
-      "movl %3,%%ecx\n"
-      "pxor %%mm6,%%mm6\n"
-      "pxor %%mm7,%%mm7\n"
-      "movq (%0),%%mm0\n"
-      "movq 8(%0),%%mm1\n"
-      "add %2,%0\n"
-      "subl $2, %%ecx\n"
-      SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-      "1:\n"
-      
-      SUM(%%mm4, %%mm5, %%mm0, %%mm1)
-      
-      SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-      
-      "subl $2, %%ecx\n"
-      "jnz 1b\n"
-
-      "movd %%mm6,%1\n"
-      : "+r" (pix), "=r"(tmp) 
-      : "r" ((long)line_size) , "m" (h)
-      : "%ecx");
-    return tmp;
-}
-#undef SUM
-
-static int vsad16_mmx(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
-    int tmp;
-    
-    assert( (((int)pix1) & 7) == 0);
-    assert( (((int)pix2) & 7) == 0);
-    assert((line_size &7) ==0);
-    
-#define SUM(in0, in1, out0, out1) \
-      "movq (%0),%%mm2\n"\
-      "movq (%1)," #out0 "\n"\
-      "movq 8(%0),%%mm3\n"\
-      "movq 8(%1)," #out1 "\n"\
-      "add %3,%0\n"\
-      "add %3,%1\n"\
-      "psubb " #out0 ", %%mm2\n"\
-      "psubb " #out1 ", %%mm3\n"\
-      "pxor %%mm7, %%mm2\n"\
-      "pxor %%mm7, %%mm3\n"\
-      "movq %%mm2, " #out0 "\n"\
-      "movq %%mm3, " #out1 "\n"\
-      "psubusb " #in0 ", %%mm2\n"\
-      "psubusb " #in1 ", %%mm3\n"\
-      "psubusb " #out0 ", " #in0 "\n"\
-      "psubusb " #out1 ", " #in1 "\n"\
-      "por %%mm2, " #in0 "\n"\
-      "por %%mm3, " #in1 "\n"\
-      "movq " #in0 ", %%mm2\n"\
-      "movq " #in1 ", %%mm3\n"\
-      "punpcklbw %%mm7, " #in0 "\n"\
-      "punpcklbw %%mm7, " #in1 "\n"\
-      "punpckhbw %%mm7, %%mm2\n"\
-      "punpckhbw %%mm7, %%mm3\n"\
-      "paddw " #in1 ", " #in0 "\n"\
-      "paddw %%mm3, %%mm2\n"\
-      "paddw %%mm2, " #in0 "\n"\
-      "paddw " #in0 ", %%mm6\n"
-
-    
-  asm volatile (
-      "movl %4,%%ecx\n"
-      "pxor %%mm6,%%mm6\n"
-      "pcmpeqw %%mm7,%%mm7\n"
-      "psllw $15, %%mm7\n"
-      "packsswb %%mm7, %%mm7\n"
-      "movq (%0),%%mm0\n"
-      "movq (%1),%%mm2\n"
-      "movq 8(%0),%%mm1\n"
-      "movq 8(%1),%%mm3\n"
-      "add %3,%0\n"
-      "add %3,%1\n"
-      "subl $2, %%ecx\n"
-      "psubb %%mm2, %%mm0\n"
-      "psubb %%mm3, %%mm1\n"
-      "pxor %%mm7, %%mm0\n"
-      "pxor %%mm7, %%mm1\n"
-      SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-      "1:\n"
-      
-      SUM(%%mm4, %%mm5, %%mm0, %%mm1)
-      
-      SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-      
-      "subl $2, %%ecx\n"
-      "jnz 1b\n"
-
-      "movq %%mm6,%%mm0\n"
-      "psrlq $32, %%mm6\n"
-      "paddw %%mm6,%%mm0\n"
-      "movq %%mm0,%%mm6\n"
-      "psrlq $16, %%mm0\n"
-      "paddw %%mm6,%%mm0\n"
-      "movd %%mm0,%2\n"
-      : "+r" (pix1), "+r" (pix2), "=r"(tmp) 
-      : "r" ((long)line_size) , "m" (h)
-      : "%ecx");
-    return tmp & 0x7FFF;
-}
-#undef SUM
-
-static int vsad16_mmx2(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
-    int tmp;
-    
-    assert( (((int)pix1) & 7) == 0);
-    assert( (((int)pix2) & 7) == 0);
-    assert((line_size &7) ==0);
-    
-#define SUM(in0, in1, out0, out1) \
-      "movq (%0)," #out0 "\n"\
-      "movq (%1),%%mm2\n"\
-      "movq 8(%0)," #out1 "\n"\
-      "movq 8(%1),%%mm3\n"\
-      "add %3,%0\n"\
-      "add %3,%1\n"\
-      "psubb %%mm2, " #out0 "\n"\
-      "psubb %%mm3, " #out1 "\n"\
-      "pxor %%mm7, " #out0 "\n"\
-      "pxor %%mm7, " #out1 "\n"\
-      "psadbw " #out0 ", " #in0 "\n"\
-      "psadbw " #out1 ", " #in1 "\n"\
-      "paddw " #in1 ", " #in0 "\n"\
-      "paddw " #in0 ", %%mm6\n"
-
-  asm volatile (
-      "movl %4,%%ecx\n"
-      "pxor %%mm6,%%mm6\n"
-      "pcmpeqw %%mm7,%%mm7\n"
-      "psllw $15, %%mm7\n"
-      "packsswb %%mm7, %%mm7\n"
-      "movq (%0),%%mm0\n"
-      "movq (%1),%%mm2\n"
-      "movq 8(%0),%%mm1\n"
-      "movq 8(%1),%%mm3\n"
-      "add %3,%0\n"
-      "add %3,%1\n"
-      "subl $2, %%ecx\n"
-      "psubb %%mm2, %%mm0\n"
-      "psubb %%mm3, %%mm1\n"
-      "pxor %%mm7, %%mm0\n"
-      "pxor %%mm7, %%mm1\n"
-      SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-      "1:\n"
-      
-      SUM(%%mm4, %%mm5, %%mm0, %%mm1)
-      
-      SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-      
-      "subl $2, %%ecx\n"
-      "jnz 1b\n"
-
-      "movd %%mm6,%2\n"
-      : "+r" (pix1), "+r" (pix2), "=r"(tmp) 
-      : "r" ((long)line_size) , "m" (h)
-      : "%ecx");
-    return tmp;
-}
-#undef SUM
-
-static void diff_bytes_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
-    long i=0;
-    asm volatile(
-        "1:				\n\t"
-        "movq  (%2, %0), %%mm0		\n\t"
-        "movq  (%1, %0), %%mm1		\n\t"
-        "psubb %%mm0, %%mm1		\n\t"
-        "movq %%mm1, (%3, %0)		\n\t"
-        "movq 8(%2, %0), %%mm0		\n\t"
-        "movq 8(%1, %0), %%mm1		\n\t"
-        "psubb %%mm0, %%mm1		\n\t"
-        "movq %%mm1, 8(%3, %0)		\n\t"
-        "add $16, %0			\n\t"
-        "cmp %4, %0			\n\t"
-        " jb 1b				\n\t"
-        : "+r" (i)
-        : "r"(src1), "r"(src2), "r"(dst), "r"((long)w-15)
-    );
-    for(; i<w; i++)
-        dst[i+0] = src1[i+0]-src2[i+0];
-}
-
-static void sub_hfyu_median_prediction_mmx2(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top){
-    long i=0;
-    uint8_t l, lt;
-    
-    asm volatile(
-        "1:				\n\t"
-        "movq  -1(%1, %0), %%mm0	\n\t" // LT
-        "movq  (%1, %0), %%mm1		\n\t" // T
-        "movq  -1(%2, %0), %%mm2	\n\t" // L
-        "movq  (%2, %0), %%mm3		\n\t" // X
-        "movq %%mm2, %%mm4		\n\t" // L
-        "psubb %%mm0, %%mm2		\n\t"
-        "paddb %%mm1, %%mm2		\n\t" // L + T - LT
-        "movq %%mm4, %%mm5		\n\t" // L
-        "pmaxub %%mm1, %%mm4		\n\t" // max(T, L)
-        "pminub %%mm5, %%mm1		\n\t" // min(T, L)
-        "pminub %%mm2, %%mm4		\n\t" 
-        "pmaxub %%mm1, %%mm4		\n\t"
-        "psubb %%mm4, %%mm3		\n\t" // dst - pred
-        "movq %%mm3, (%3, %0)		\n\t"
-        "add $8, %0			\n\t"
-        "cmp %4, %0			\n\t"
-        " jb 1b				\n\t"
-        : "+r" (i)
-        : "r"(src1), "r"(src2), "r"(dst), "r"((long)w)
-    );
-
-    l= *left;
-    lt= *left_top;
-    
-    dst[0]= src2[0] - mid_pred(l, src1[0], (l + src1[0] - lt)&0xFF);
-    
-    *left_top= src1[w-1];
-    *left    = src2[w-1];
-}
-
-#define LBUTTERFLY2(a1,b1,a2,b2)\
-    "paddw " #b1 ", " #a1 "		\n\t"\
-    "paddw " #b2 ", " #a2 "		\n\t"\
-    "paddw " #b1 ", " #b1 "		\n\t"\
-    "paddw " #b2 ", " #b2 "		\n\t"\
-    "psubw " #a1 ", " #b1 "		\n\t"\
-    "psubw " #a2 ", " #b2 "		\n\t"
-
-#define HADAMARD48\
-        LBUTTERFLY2(%%mm0, %%mm1, %%mm2, %%mm3)\
-        LBUTTERFLY2(%%mm4, %%mm5, %%mm6, %%mm7)\
-        LBUTTERFLY2(%%mm0, %%mm2, %%mm1, %%mm3)\
-        LBUTTERFLY2(%%mm4, %%mm6, %%mm5, %%mm7)\
-        LBUTTERFLY2(%%mm0, %%mm4, %%mm1, %%mm5)\
-        LBUTTERFLY2(%%mm2, %%mm6, %%mm3, %%mm7)\
-
-#define MMABS(a,z)\
-    "pxor " #z ", " #z "		\n\t"\
-    "pcmpgtw " #a ", " #z "		\n\t"\
-    "pxor " #z ", " #a "		\n\t"\
-    "psubw " #z ", " #a "		\n\t"
-
-#define MMABS_SUM(a,z, sum)\
-    "pxor " #z ", " #z "		\n\t"\
-    "pcmpgtw " #a ", " #z "		\n\t"\
-    "pxor " #z ", " #a "		\n\t"\
-    "psubw " #z ", " #a "		\n\t"\
-    "paddusw " #a ", " #sum "		\n\t"
-
-#define MMABS_MMX2(a,z)\
-    "pxor " #z ", " #z "		\n\t"\
-    "psubw " #a ", " #z "		\n\t"\
-    "pmaxsw " #z ", " #a "		\n\t"
-
-#define MMABS_SUM_MMX2(a,z, sum)\
-    "pxor " #z ", " #z "		\n\t"\
-    "psubw " #a ", " #z "		\n\t"\
-    "pmaxsw " #z ", " #a "		\n\t"\
-    "paddusw " #a ", " #sum "		\n\t"
-        
-#define SBUTTERFLY(a,b,t,n)\
-    "movq " #a ", " #t "		\n\t" /* abcd */\
-    "punpckl" #n " " #b ", " #a "	\n\t" /* aebf */\
-    "punpckh" #n " " #b ", " #t "	\n\t" /* cgdh */\
-
-#define TRANSPOSE4(a,b,c,d,t)\
-    SBUTTERFLY(a,b,t,wd) /* a=aebf t=cgdh */\
-    SBUTTERFLY(c,d,b,wd) /* c=imjn b=kolp */\
-    SBUTTERFLY(a,c,d,dq) /* a=aeim d=bfjn */\
-    SBUTTERFLY(t,b,c,dq) /* t=cgko c=dhlp */
-
-#define LOAD4(o, a, b, c, d)\
-        "movq "#o"(%1), " #a "		\n\t"\
-        "movq "#o"+16(%1), " #b "	\n\t"\
-        "movq "#o"+32(%1), " #c "	\n\t"\
-        "movq "#o"+48(%1), " #d "	\n\t"
-
-#define STORE4(o, a, b, c, d)\
-        "movq "#a", "#o"(%1)		\n\t"\
-        "movq "#b", "#o"+16(%1)		\n\t"\
-        "movq "#c", "#o"+32(%1)		\n\t"\
-        "movq "#d", "#o"+48(%1)		\n\t"\
-
-static int hadamard8_diff_mmx(void *s, uint8_t *src1, uint8_t *src2, int stride, int h){
-    uint64_t temp[16] __align8;
-    int sum=0;
-    
-    assert(h==8);
-
-    diff_pixels_mmx((DCTELEM*)temp, src1, src2, stride);
-
-    asm volatile(
-        LOAD4(0 , %%mm0, %%mm1, %%mm2, %%mm3)
-        LOAD4(64, %%mm4, %%mm5, %%mm6, %%mm7)
-        
-        HADAMARD48
-        
-        "movq %%mm7, 112(%1)		\n\t"
-        
-        TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm7)
-        STORE4(0 , %%mm0, %%mm3, %%mm7, %%mm2)
-        
-        "movq 112(%1), %%mm7 		\n\t"
-        TRANSPOSE4(%%mm4, %%mm5, %%mm6, %%mm7, %%mm0)
-        STORE4(64, %%mm4, %%mm7, %%mm0, %%mm6)
-
-        LOAD4(8 , %%mm0, %%mm1, %%mm2, %%mm3)
-        LOAD4(72, %%mm4, %%mm5, %%mm6, %%mm7)
-        
-        HADAMARD48
-        
-        "movq %%mm7, 120(%1)		\n\t"
-        
-        TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm7)
-        STORE4(8 , %%mm0, %%mm3, %%mm7, %%mm2)
-        
-        "movq 120(%1), %%mm7 		\n\t"
-        TRANSPOSE4(%%mm4, %%mm5, %%mm6, %%mm7, %%mm0)
-        "movq %%mm7, %%mm5		\n\t"//FIXME remove
-        "movq %%mm6, %%mm7		\n\t"
-        "movq %%mm0, %%mm6		\n\t"
-//        STORE4(72, %%mm4, %%mm7, %%mm0, %%mm6) //FIXME remove
-        
-        LOAD4(64, %%mm0, %%mm1, %%mm2, %%mm3)
-//        LOAD4(72, %%mm4, %%mm5, %%mm6, %%mm7)
-        
-        HADAMARD48
-        "movq %%mm7, 64(%1)		\n\t"
-        MMABS(%%mm0, %%mm7)
-        MMABS_SUM(%%mm1, %%mm7, %%mm0)
-        MMABS_SUM(%%mm2, %%mm7, %%mm0)
-        MMABS_SUM(%%mm3, %%mm7, %%mm0)
-        MMABS_SUM(%%mm4, %%mm7, %%mm0)
-        MMABS_SUM(%%mm5, %%mm7, %%mm0)
-        MMABS_SUM(%%mm6, %%mm7, %%mm0)
-        "movq 64(%1), %%mm1		\n\t"
-        MMABS_SUM(%%mm1, %%mm7, %%mm0)
-        "movq %%mm0, 64(%1)		\n\t"
-        
-        LOAD4(0 , %%mm0, %%mm1, %%mm2, %%mm3)
-        LOAD4(8 , %%mm4, %%mm5, %%mm6, %%mm7)
-        
-        HADAMARD48
-        "movq %%mm7, (%1)		\n\t"
-        MMABS(%%mm0, %%mm7)
-        MMABS_SUM(%%mm1, %%mm7, %%mm0)
-        MMABS_SUM(%%mm2, %%mm7, %%mm0)
-        MMABS_SUM(%%mm3, %%mm7, %%mm0)
-        MMABS_SUM(%%mm4, %%mm7, %%mm0)
-        MMABS_SUM(%%mm5, %%mm7, %%mm0)
-        MMABS_SUM(%%mm6, %%mm7, %%mm0)
-        "movq (%1), %%mm1		\n\t"
-        MMABS_SUM(%%mm1, %%mm7, %%mm0)
-        "movq 64(%1), %%mm1		\n\t"
-        MMABS_SUM(%%mm1, %%mm7, %%mm0)
-        
-        "movq %%mm0, %%mm1		\n\t"
-        "psrlq $32, %%mm0		\n\t"
-        "paddusw %%mm1, %%mm0		\n\t"
-        "movq %%mm0, %%mm1		\n\t"
-        "psrlq $16, %%mm0		\n\t"
-        "paddusw %%mm1, %%mm0		\n\t"
-        "movd %%mm0, %0			\n\t"
-                
-        : "=r" (sum)
-        : "r"(temp)
-    );
-    return sum&0xFFFF;
-}
-
-static int hadamard8_diff_mmx2(void *s, uint8_t *src1, uint8_t *src2, int stride, int h){
-    uint64_t temp[16] __align8;
-    int sum=0;
-    
-    assert(h==8);
-
-    diff_pixels_mmx((DCTELEM*)temp, src1, src2, stride);
-
-    asm volatile(
-        LOAD4(0 , %%mm0, %%mm1, %%mm2, %%mm3)
-        LOAD4(64, %%mm4, %%mm5, %%mm6, %%mm7)
-        
-        HADAMARD48
-        
-        "movq %%mm7, 112(%1)		\n\t"
-        
-        TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm7)
-        STORE4(0 , %%mm0, %%mm3, %%mm7, %%mm2)
-        
-        "movq 112(%1), %%mm7 		\n\t"
-        TRANSPOSE4(%%mm4, %%mm5, %%mm6, %%mm7, %%mm0)
-        STORE4(64, %%mm4, %%mm7, %%mm0, %%mm6)
-
-        LOAD4(8 , %%mm0, %%mm1, %%mm2, %%mm3)
-        LOAD4(72, %%mm4, %%mm5, %%mm6, %%mm7)
-        
-        HADAMARD48
-        
-        "movq %%mm7, 120(%1)		\n\t"
-        
-        TRANSPOSE4(%%mm0, %%mm1, %%mm2, %%mm3, %%mm7)
-        STORE4(8 , %%mm0, %%mm3, %%mm7, %%mm2)
-        
-        "movq 120(%1), %%mm7 		\n\t"
-        TRANSPOSE4(%%mm4, %%mm5, %%mm6, %%mm7, %%mm0)
-        "movq %%mm7, %%mm5		\n\t"//FIXME remove
-        "movq %%mm6, %%mm7		\n\t"
-        "movq %%mm0, %%mm6		\n\t"
-//        STORE4(72, %%mm4, %%mm7, %%mm0, %%mm6) //FIXME remove
-        
-        LOAD4(64, %%mm0, %%mm1, %%mm2, %%mm3)
-//        LOAD4(72, %%mm4, %%mm5, %%mm6, %%mm7)
-        
-        HADAMARD48
-        "movq %%mm7, 64(%1)		\n\t"
-        MMABS_MMX2(%%mm0, %%mm7)
-        MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
-        MMABS_SUM_MMX2(%%mm2, %%mm7, %%mm0)
-        MMABS_SUM_MMX2(%%mm3, %%mm7, %%mm0)
-        MMABS_SUM_MMX2(%%mm4, %%mm7, %%mm0)
-        MMABS_SUM_MMX2(%%mm5, %%mm7, %%mm0)
-        MMABS_SUM_MMX2(%%mm6, %%mm7, %%mm0)
-        "movq 64(%1), %%mm1		\n\t"
-        MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
-        "movq %%mm0, 64(%1)		\n\t"
-        
-        LOAD4(0 , %%mm0, %%mm1, %%mm2, %%mm3)
-        LOAD4(8 , %%mm4, %%mm5, %%mm6, %%mm7)
-        
-        HADAMARD48
-        "movq %%mm7, (%1)		\n\t"
-        MMABS_MMX2(%%mm0, %%mm7)
-        MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
-        MMABS_SUM_MMX2(%%mm2, %%mm7, %%mm0)
-        MMABS_SUM_MMX2(%%mm3, %%mm7, %%mm0)
-        MMABS_SUM_MMX2(%%mm4, %%mm7, %%mm0)
-        MMABS_SUM_MMX2(%%mm5, %%mm7, %%mm0)
-        MMABS_SUM_MMX2(%%mm6, %%mm7, %%mm0)
-        "movq (%1), %%mm1		\n\t"
-        MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
-        "movq 64(%1), %%mm1		\n\t"
-        MMABS_SUM_MMX2(%%mm1, %%mm7, %%mm0)
-        
-        "movq %%mm0, %%mm1		\n\t"
-        "psrlq $32, %%mm0		\n\t"
-        "paddusw %%mm1, %%mm0		\n\t"
-        "movq %%mm0, %%mm1		\n\t"
-        "psrlq $16, %%mm0		\n\t"
-        "paddusw %%mm1, %%mm0		\n\t"
-        "movd %%mm0, %0			\n\t"
-                
-        : "=r" (sum)
-        : "r"(temp)
-    );
-    return sum&0xFFFF;
-}
-
-
-WARPER8_16_SQ(hadamard8_diff_mmx, hadamard8_diff16_mmx)
-WARPER8_16_SQ(hadamard8_diff_mmx2, hadamard8_diff16_mmx2)
-#endif //CONFIG_ENCODERS
-
-#define put_no_rnd_pixels8_mmx(a,b,c,d) put_pixels8_mmx(a,b,c,d)
-#define put_no_rnd_pixels16_mmx(a,b,c,d) put_pixels16_mmx(a,b,c,d)
-
-#define QPEL_V_LOW(m3,m4,m5,m6, pw_20, pw_3, rnd, in0, in1, in2, in7, out, OP)\
-        "paddw " #m4 ", " #m3 "		\n\t" /* x1 */\
-        "movq "MANGLE(ff_pw_20)", %%mm4		\n\t" /* 20 */\
-        "pmullw " #m3 ", %%mm4		\n\t" /* 20x1 */\
-        "movq "#in7", " #m3 "		\n\t" /* d */\
-        "movq "#in0", %%mm5		\n\t" /* D */\
-        "paddw " #m3 ", %%mm5		\n\t" /* x4 */\
-        "psubw %%mm5, %%mm4		\n\t" /* 20x1 - x4 */\
-        "movq "#in1", %%mm5		\n\t" /* C */\
-        "movq "#in2", %%mm6		\n\t" /* B */\
-        "paddw " #m6 ", %%mm5		\n\t" /* x3 */\
-        "paddw " #m5 ", %%mm6		\n\t" /* x2 */\
-        "paddw %%mm6, %%mm6		\n\t" /* 2x2 */\
-        "psubw %%mm6, %%mm5		\n\t" /* -2x2 + x3 */\
-        "pmullw "MANGLE(ff_pw_3)", %%mm5	\n\t" /* -6x2 + 3x3 */\
-        "paddw " #rnd ", %%mm4		\n\t" /* x2 */\
-        "paddw %%mm4, %%mm5		\n\t" /* 20x1 - 6x2 + 3x3 - x4 */\
-        "psraw $5, %%mm5		\n\t"\
-        "packuswb %%mm5, %%mm5		\n\t"\
-        OP(%%mm5, out, %%mm7, d)
-
-#define QPEL_BASE(OPNAME, ROUNDER, RND, OP_MMX2, OP_3DNOW)\
-static void OPNAME ## mpeg4_qpel16_h_lowpass_mmx2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
-    uint64_t temp;\
-\
-    asm volatile(\
-        "pxor %%mm7, %%mm7		\n\t"\
-        "1:				\n\t"\
-        "movq  (%0), %%mm0		\n\t" /* ABCDEFGH */\
-        "movq %%mm0, %%mm1		\n\t" /* ABCDEFGH */\
-        "movq %%mm0, %%mm2		\n\t" /* ABCDEFGH */\
-        "punpcklbw %%mm7, %%mm0		\n\t" /* 0A0B0C0D */\
-        "punpckhbw %%mm7, %%mm1		\n\t" /* 0E0F0G0H */\
-        "pshufw $0x90, %%mm0, %%mm5	\n\t" /* 0A0A0B0C */\
-        "pshufw $0x41, %%mm0, %%mm6	\n\t" /* 0B0A0A0B */\
-        "movq %%mm2, %%mm3		\n\t" /* ABCDEFGH */\
-        "movq %%mm2, %%mm4		\n\t" /* ABCDEFGH */\
-        "psllq $8, %%mm2		\n\t" /* 0ABCDEFG */\
-        "psllq $16, %%mm3		\n\t" /* 00ABCDEF */\
-        "psllq $24, %%mm4		\n\t" /* 000ABCDE */\
-        "punpckhbw %%mm7, %%mm2		\n\t" /* 0D0E0F0G */\
-        "punpckhbw %%mm7, %%mm3		\n\t" /* 0C0D0E0F */\
-        "punpckhbw %%mm7, %%mm4		\n\t" /* 0B0C0D0E */\
-        "paddw %%mm3, %%mm5		\n\t" /* b */\
-        "paddw %%mm2, %%mm6		\n\t" /* c */\
-        "paddw %%mm5, %%mm5		\n\t" /* 2b */\
-        "psubw %%mm5, %%mm6		\n\t" /* c - 2b */\
-        "pshufw $0x06, %%mm0, %%mm5	\n\t" /* 0C0B0A0A */\
-        "pmullw "MANGLE(ff_pw_3)", %%mm6		\n\t" /* 3c - 6b */\
-        "paddw %%mm4, %%mm0		\n\t" /* a */\
-        "paddw %%mm1, %%mm5		\n\t" /* d */\
-        "pmullw "MANGLE(ff_pw_20)", %%mm0		\n\t" /* 20a */\
-        "psubw %%mm5, %%mm0		\n\t" /* 20a - d */\
-        "paddw %6, %%mm6		\n\t"\
-        "paddw %%mm6, %%mm0		\n\t" /* 20a - 6b + 3c - d */\
-        "psraw $5, %%mm0		\n\t"\
-        "movq %%mm0, %5			\n\t"\
-        /* mm1=EFGH, mm2=DEFG, mm3=CDEF, mm4=BCDE, mm7=0 */\
-        \
-        "movq 5(%0), %%mm0		\n\t" /* FGHIJKLM */\
-        "movq %%mm0, %%mm5		\n\t" /* FGHIJKLM */\
-        "movq %%mm0, %%mm6		\n\t" /* FGHIJKLM */\
-        "psrlq $8, %%mm0		\n\t" /* GHIJKLM0 */\
-        "psrlq $16, %%mm5		\n\t" /* HIJKLM00 */\
-        "punpcklbw %%mm7, %%mm0		\n\t" /* 0G0H0I0J */\
-        "punpcklbw %%mm7, %%mm5		\n\t" /* 0H0I0J0K */\
-        "paddw %%mm0, %%mm2		\n\t" /* b */\
-        "paddw %%mm5, %%mm3		\n\t" /* c */\
-        "paddw %%mm2, %%mm2		\n\t" /* 2b */\
-        "psubw %%mm2, %%mm3		\n\t" /* c - 2b */\
-        "movq %%mm6, %%mm2		\n\t" /* FGHIJKLM */\
-        "psrlq $24, %%mm6		\n\t" /* IJKLM000 */\
-        "punpcklbw %%mm7, %%mm2		\n\t" /* 0F0G0H0I */\
-        "punpcklbw %%mm7, %%mm6		\n\t" /* 0I0J0K0L */\
-        "pmullw "MANGLE(ff_pw_3)", %%mm3		\n\t" /* 3c - 6b */\
-        "paddw %%mm2, %%mm1		\n\t" /* a */\
-        "paddw %%mm6, %%mm4		\n\t" /* d */\
-        "pmullw "MANGLE(ff_pw_20)", %%mm1		\n\t" /* 20a */\
-        "psubw %%mm4, %%mm3		\n\t" /* - 6b +3c - d */\
-        "paddw %6, %%mm1		\n\t"\
-        "paddw %%mm1, %%mm3		\n\t" /* 20a - 6b +3c - d */\
-        "psraw $5, %%mm3		\n\t"\
-        "movq %5, %%mm1			\n\t"\
-        "packuswb %%mm3, %%mm1		\n\t"\
-        OP_MMX2(%%mm1, (%1),%%mm4, q)\
-        /* mm0= GHIJ, mm2=FGHI, mm5=HIJK, mm6=IJKL, mm7=0 */\
-        \
-        "movq 9(%0), %%mm1		\n\t" /* JKLMNOPQ */\
-        "movq %%mm1, %%mm4		\n\t" /* JKLMNOPQ */\
-        "movq %%mm1, %%mm3		\n\t" /* JKLMNOPQ */\
-        "psrlq $8, %%mm1		\n\t" /* KLMNOPQ0 */\
-        "psrlq $16, %%mm4		\n\t" /* LMNOPQ00 */\
-        "punpcklbw %%mm7, %%mm1		\n\t" /* 0K0L0M0N */\
-        "punpcklbw %%mm7, %%mm4		\n\t" /* 0L0M0N0O */\
-        "paddw %%mm1, %%mm5		\n\t" /* b */\
-        "paddw %%mm4, %%mm0		\n\t" /* c */\
-        "paddw %%mm5, %%mm5		\n\t" /* 2b */\
-        "psubw %%mm5, %%mm0		\n\t" /* c - 2b */\
-        "movq %%mm3, %%mm5		\n\t" /* JKLMNOPQ */\
-        "psrlq $24, %%mm3		\n\t" /* MNOPQ000 */\
-        "pmullw "MANGLE(ff_pw_3)", %%mm0		\n\t" /* 3c - 6b */\
-        "punpcklbw %%mm7, %%mm3		\n\t" /* 0M0N0O0P */\
-        "paddw %%mm3, %%mm2		\n\t" /* d */\
-        "psubw %%mm2, %%mm0		\n\t" /* -6b + 3c - d */\
-        "movq %%mm5, %%mm2		\n\t" /* JKLMNOPQ */\
-        "punpcklbw %%mm7, %%mm2		\n\t" /* 0J0K0L0M */\
-        "punpckhbw %%mm7, %%mm5		\n\t" /* 0N0O0P0Q */\
-        "paddw %%mm2, %%mm6		\n\t" /* a */\
-        "pmullw "MANGLE(ff_pw_20)", %%mm6		\n\t" /* 20a */\
-        "paddw %6, %%mm0		\n\t"\
-        "paddw %%mm6, %%mm0		\n\t" /* 20a - 6b + 3c - d */\
-        "psraw $5, %%mm0		\n\t"\
-        /* mm1=KLMN, mm2=JKLM, mm3=MNOP, mm4=LMNO, mm5=NOPQ mm7=0 */\
-        \
-        "paddw %%mm5, %%mm3		\n\t" /* a */\
-        "pshufw $0xF9, %%mm5, %%mm6	\n\t" /* 0O0P0Q0Q */\
-        "paddw %%mm4, %%mm6		\n\t" /* b */\
-        "pshufw $0xBE, %%mm5, %%mm4	\n\t" /* 0P0Q0Q0P */\
-        "pshufw $0x6F, %%mm5, %%mm5	\n\t" /* 0Q0Q0P0O */\
-        "paddw %%mm1, %%mm4		\n\t" /* c */\
-        "paddw %%mm2, %%mm5		\n\t" /* d */\
-        "paddw %%mm6, %%mm6		\n\t" /* 2b */\
-        "psubw %%mm6, %%mm4		\n\t" /* c - 2b */\
-        "pmullw "MANGLE(ff_pw_20)", %%mm3		\n\t" /* 20a */\
-        "pmullw "MANGLE(ff_pw_3)", %%mm4		\n\t" /* 3c - 6b */\
-        "psubw %%mm5, %%mm3		\n\t" /* -6b + 3c - d */\
-        "paddw %6, %%mm4		\n\t"\
-        "paddw %%mm3, %%mm4		\n\t" /* 20a - 6b + 3c - d */\
-        "psraw $5, %%mm4		\n\t"\
-        "packuswb %%mm4, %%mm0		\n\t"\
-        OP_MMX2(%%mm0, 8(%1), %%mm4, q)\
-        \
-        "add %3, %0			\n\t"\
-        "add %4, %1			\n\t"\
-        "decl %2			\n\t"\
-        " jnz 1b				\n\t"\
-        : "+a"(src), "+c"(dst), "+m"(h)\
-        : "d"((long)srcStride), "S"((long)dstStride), /*"m"(ff_pw_20), "m"(ff_pw_3),*/ "m"(temp), "m"(ROUNDER)\
-        : "memory"\
-    );\
-}\
-\
-static void OPNAME ## mpeg4_qpel16_h_lowpass_3dnow(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
-    int i;\
-    int16_t temp[16];\
-    /* quick HACK, XXX FIXME MUST be optimized */\
-    for(i=0; i<h; i++)\
-    {\
-        temp[ 0]= (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]);\
-        temp[ 1]= (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]);\
-        temp[ 2]= (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]);\
-        temp[ 3]= (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]);\
-        temp[ 4]= (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]);\
-        temp[ 5]= (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 9]);\
-        temp[ 6]= (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 9])*3 - (src[ 3]+src[10]);\
-        temp[ 7]= (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 9])*6 + (src[ 5]+src[10])*3 - (src[ 4]+src[11]);\
-        temp[ 8]= (src[ 8]+src[ 9])*20 - (src[ 7]+src[10])*6 + (src[ 6]+src[11])*3 - (src[ 5]+src[12]);\
-        temp[ 9]= (src[ 9]+src[10])*20 - (src[ 8]+src[11])*6 + (src[ 7]+src[12])*3 - (src[ 6]+src[13]);\
-        temp[10]= (src[10]+src[11])*20 - (src[ 9]+src[12])*6 + (src[ 8]+src[13])*3 - (src[ 7]+src[14]);\
-        temp[11]= (src[11]+src[12])*20 - (src[10]+src[13])*6 + (src[ 9]+src[14])*3 - (src[ 8]+src[15]);\
-        temp[12]= (src[12]+src[13])*20 - (src[11]+src[14])*6 + (src[10]+src[15])*3 - (src[ 9]+src[16]);\
-        temp[13]= (src[13]+src[14])*20 - (src[12]+src[15])*6 + (src[11]+src[16])*3 - (src[10]+src[16]);\
-        temp[14]= (src[14]+src[15])*20 - (src[13]+src[16])*6 + (src[12]+src[16])*3 - (src[11]+src[15]);\
-        temp[15]= (src[15]+src[16])*20 - (src[14]+src[16])*6 + (src[13]+src[15])*3 - (src[12]+src[14]);\
-        asm volatile(\
-            "movq (%0), %%mm0		\n\t"\
-            "movq 8(%0), %%mm1		\n\t"\
-            "paddw %2, %%mm0		\n\t"\
-            "paddw %2, %%mm1		\n\t"\
-            "psraw $5, %%mm0		\n\t"\
-            "psraw $5, %%mm1		\n\t"\
-            "packuswb %%mm1, %%mm0	\n\t"\
-            OP_3DNOW(%%mm0, (%1), %%mm1, q)\
-            "movq 16(%0), %%mm0		\n\t"\
-            "movq 24(%0), %%mm1		\n\t"\
-            "paddw %2, %%mm0		\n\t"\
-            "paddw %2, %%mm1		\n\t"\
-            "psraw $5, %%mm0		\n\t"\
-            "psraw $5, %%mm1		\n\t"\
-            "packuswb %%mm1, %%mm0	\n\t"\
-            OP_3DNOW(%%mm0, 8(%1), %%mm1, q)\
-            :: "r"(temp), "r"(dst), "m"(ROUNDER)\
-            : "memory"\
-        );\
-        dst+=dstStride;\
-        src+=srcStride;\
-    }\
-}\
-\
-static void OPNAME ## mpeg4_qpel8_h_lowpass_mmx2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
-    uint64_t temp;\
-\
-    asm volatile(\
-        "pxor %%mm7, %%mm7		\n\t"\
-        "1:				\n\t"\
-        "movq  (%0), %%mm0		\n\t" /* ABCDEFGH */\
-        "movq %%mm0, %%mm1		\n\t" /* ABCDEFGH */\
-        "movq %%mm0, %%mm2		\n\t" /* ABCDEFGH */\
-        "punpcklbw %%mm7, %%mm0		\n\t" /* 0A0B0C0D */\
-        "punpckhbw %%mm7, %%mm1		\n\t" /* 0E0F0G0H */\
-        "pshufw $0x90, %%mm0, %%mm5	\n\t" /* 0A0A0B0C */\
-        "pshufw $0x41, %%mm0, %%mm6	\n\t" /* 0B0A0A0B */\
-        "movq %%mm2, %%mm3		\n\t" /* ABCDEFGH */\
-        "movq %%mm2, %%mm4		\n\t" /* ABCDEFGH */\
-        "psllq $8, %%mm2		\n\t" /* 0ABCDEFG */\
-        "psllq $16, %%mm3		\n\t" /* 00ABCDEF */\
-        "psllq $24, %%mm4		\n\t" /* 000ABCDE */\
-        "punpckhbw %%mm7, %%mm2		\n\t" /* 0D0E0F0G */\
-        "punpckhbw %%mm7, %%mm3		\n\t" /* 0C0D0E0F */\
-        "punpckhbw %%mm7, %%mm4		\n\t" /* 0B0C0D0E */\
-        "paddw %%mm3, %%mm5		\n\t" /* b */\
-        "paddw %%mm2, %%mm6		\n\t" /* c */\
-        "paddw %%mm5, %%mm5		\n\t" /* 2b */\
-        "psubw %%mm5, %%mm6		\n\t" /* c - 2b */\
-        "pshufw $0x06, %%mm0, %%mm5	\n\t" /* 0C0B0A0A */\
-        "pmullw "MANGLE(ff_pw_3)", %%mm6		\n\t" /* 3c - 6b */\
-        "paddw %%mm4, %%mm0		\n\t" /* a */\
-        "paddw %%mm1, %%mm5		\n\t" /* d */\
-        "pmullw "MANGLE(ff_pw_20)", %%mm0		\n\t" /* 20a */\
-        "psubw %%mm5, %%mm0		\n\t" /* 20a - d */\
-        "paddw %6, %%mm6		\n\t"\
-        "paddw %%mm6, %%mm0		\n\t" /* 20a - 6b + 3c - d */\
-        "psraw $5, %%mm0		\n\t"\
-        /* mm1=EFGH, mm2=DEFG, mm3=CDEF, mm4=BCDE, mm7=0 */\
-        \
-        "movd 5(%0), %%mm5		\n\t" /* FGHI */\
-        "punpcklbw %%mm7, %%mm5		\n\t" /* 0F0G0H0I */\
-        "pshufw $0xF9, %%mm5, %%mm6	\n\t" /* 0G0H0I0I */\
-        "paddw %%mm5, %%mm1		\n\t" /* a */\
-        "paddw %%mm6, %%mm2		\n\t" /* b */\
-        "pshufw $0xBE, %%mm5, %%mm6	\n\t" /* 0H0I0I0H */\
-        "pshufw $0x6F, %%mm5, %%mm5	\n\t" /* 0I0I0H0G */\
-        "paddw %%mm6, %%mm3		\n\t" /* c */\
-        "paddw %%mm5, %%mm4		\n\t" /* d */\
-        "paddw %%mm2, %%mm2		\n\t" /* 2b */\
-        "psubw %%mm2, %%mm3		\n\t" /* c - 2b */\
-        "pmullw "MANGLE(ff_pw_20)", %%mm1		\n\t" /* 20a */\
-        "pmullw "MANGLE(ff_pw_3)", %%mm3		\n\t" /* 3c - 6b */\
-        "psubw %%mm4, %%mm3		\n\t" /* -6b + 3c - d */\
-        "paddw %6, %%mm1		\n\t"\
-        "paddw %%mm1, %%mm3		\n\t" /* 20a - 6b + 3c - d */\
-        "psraw $5, %%mm3		\n\t"\
-        "packuswb %%mm3, %%mm0		\n\t"\
-        OP_MMX2(%%mm0, (%1), %%mm4, q)\
-        \
-        "add %3, %0			\n\t"\
-        "add %4, %1			\n\t"\
-        "decl %2			\n\t"\
-        " jnz 1b			\n\t"\
-        : "+a"(src), "+c"(dst), "+m"(h)\
-        : "S"((long)srcStride), "D"((long)dstStride), /*"m"(ff_pw_20), "m"(ff_pw_3),*/ "m"(temp), "m"(ROUNDER)\
-        : "memory"\
-    );\
-}\
-\
-static void OPNAME ## mpeg4_qpel8_h_lowpass_3dnow(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
-    int i;\
-    int16_t temp[8];\
-    /* quick HACK, XXX FIXME MUST be optimized */\
-    for(i=0; i<h; i++)\
-    {\
-        temp[ 0]= (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]);\
-        temp[ 1]= (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]);\
-        temp[ 2]= (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]);\
-        temp[ 3]= (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]);\
-        temp[ 4]= (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]);\
-        temp[ 5]= (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 8]);\
-        temp[ 6]= (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 8])*3 - (src[ 3]+src[ 7]);\
-        temp[ 7]= (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 8])*6 + (src[ 5]+src[ 7])*3 - (src[ 4]+src[ 6]);\
-        asm volatile(\
-            "movq (%0), %%mm0		\n\t"\
-            "movq 8(%0), %%mm1		\n\t"\
-            "paddw %2, %%mm0		\n\t"\
-            "paddw %2, %%mm1		\n\t"\
-            "psraw $5, %%mm0		\n\t"\
-            "psraw $5, %%mm1		\n\t"\
-            "packuswb %%mm1, %%mm0	\n\t"\
-            OP_3DNOW(%%mm0, (%1), %%mm1, q)\
-            :: "r"(temp), "r"(dst), "m"(ROUNDER)\
-            :"memory"\
-        );\
-        dst+=dstStride;\
-        src+=srcStride;\
-    }\
-}
-
-#define QPEL_OP(OPNAME, ROUNDER, RND, OP, MMX)\
-\
-static void OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    uint64_t temp[17*4];\
-    uint64_t *temp_ptr= temp;\
-    int count= 17;\
-\
-    /*FIXME unroll */\
-    asm volatile(\
-        "pxor %%mm7, %%mm7		\n\t"\
-        "1:				\n\t"\
-        "movq (%0), %%mm0		\n\t"\
-        "movq (%0), %%mm1		\n\t"\
-        "movq 8(%0), %%mm2		\n\t"\
-        "movq 8(%0), %%mm3		\n\t"\
-        "punpcklbw %%mm7, %%mm0		\n\t"\
-        "punpckhbw %%mm7, %%mm1		\n\t"\
-        "punpcklbw %%mm7, %%mm2		\n\t"\
-        "punpckhbw %%mm7, %%mm3		\n\t"\
-        "movq %%mm0, (%1)		\n\t"\
-        "movq %%mm1, 17*8(%1)		\n\t"\
-        "movq %%mm2, 2*17*8(%1)		\n\t"\
-        "movq %%mm3, 3*17*8(%1)		\n\t"\
-        "add $8, %1			\n\t"\
-        "add %3, %0			\n\t"\
-        "decl %2			\n\t"\
-        " jnz 1b			\n\t"\
-        : "+r" (src), "+r" (temp_ptr), "+r"(count)\
-        : "r" ((long)srcStride)\
-        : "memory"\
-    );\
-    \
-    temp_ptr= temp;\
-    count=4;\
-    \
-/*FIXME reorder for speed */\
-    asm volatile(\
-        /*"pxor %%mm7, %%mm7		\n\t"*/\
-        "1:				\n\t"\
-        "movq (%0), %%mm0		\n\t"\
-        "movq 8(%0), %%mm1		\n\t"\
-        "movq 16(%0), %%mm2		\n\t"\
-        "movq 24(%0), %%mm3		\n\t"\
-        QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 16(%0),  8(%0),   (%0), 32(%0), (%1), OP)\
-        QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5,  8(%0),   (%0),   (%0), 40(%0), (%1, %3), OP)\
-        "add %4, %1			\n\t"\
-        QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5,   (%0),   (%0),  8(%0), 48(%0), (%1), OP)\
-        \
-        QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5,   (%0),  8(%0), 16(%0), 56(%0), (%1, %3), OP)\
-        "add %4, %1			\n\t"\
-        QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5,  8(%0), 16(%0), 24(%0), 64(%0), (%1), OP)\
-        QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 16(%0), 24(%0), 32(%0), 72(%0), (%1, %3), OP)\
-        "add %4, %1			\n\t"\
-        QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, 24(%0), 32(%0), 40(%0), 80(%0), (%1), OP)\
-        QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, 32(%0), 40(%0), 48(%0), 88(%0), (%1, %3), OP)\
-        "add %4, %1			\n\t"\
-        QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 40(%0), 48(%0), 56(%0), 96(%0), (%1), OP)\
-        QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 48(%0), 56(%0), 64(%0),104(%0), (%1, %3), OP)\
-        "add %4, %1			\n\t"\
-        QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, 56(%0), 64(%0), 72(%0),112(%0), (%1), OP)\
-        QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, 64(%0), 72(%0), 80(%0),120(%0), (%1, %3), OP)\
-        "add %4, %1			\n\t"\
-        QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 72(%0), 80(%0), 88(%0),128(%0), (%1), OP)\
-        \
-        QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 80(%0), 88(%0), 96(%0),128(%0), (%1, %3), OP)\
-        "add %4, %1			\n\t"  \
-        QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, 88(%0), 96(%0),104(%0),120(%0), (%1), OP)\
-        QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, 96(%0),104(%0),112(%0),112(%0), (%1, %3), OP)\
-        \
-        "add $136, %0			\n\t"\
-        "add %6, %1			\n\t"\
-        "decl %2			\n\t"\
-        " jnz 1b			\n\t"\
-        \
-        : "+r"(temp_ptr), "+r"(dst), "+g"(count)\
-        : "r"((long)dstStride), "r"(2*(long)dstStride), /*"m"(ff_pw_20), "m"(ff_pw_3),*/ "m"(ROUNDER), "g"(4-14*(long)dstStride)\
-        :"memory"\
-    );\
-}\
-\
-static void OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    uint64_t temp[9*2];\
-    uint64_t *temp_ptr= temp;\
-    int count= 9;\
-\
-    /*FIXME unroll */\
-    asm volatile(\
-        "pxor %%mm7, %%mm7		\n\t"\
-        "1:				\n\t"\
-        "movq (%0), %%mm0		\n\t"\
-        "movq (%0), %%mm1		\n\t"\
-        "punpcklbw %%mm7, %%mm0		\n\t"\
-        "punpckhbw %%mm7, %%mm1		\n\t"\
-        "movq %%mm0, (%1)		\n\t"\
-        "movq %%mm1, 9*8(%1)		\n\t"\
-        "add $8, %1			\n\t"\
-        "add %3, %0			\n\t"\
-        "decl %2			\n\t"\
-        " jnz 1b			\n\t"\
-        : "+r" (src), "+r" (temp_ptr), "+r"(count)\
-        : "r" ((long)srcStride)\
-        : "memory"\
-    );\
-    \
-    temp_ptr= temp;\
-    count=2;\
-    \
-/*FIXME reorder for speed */\
-    asm volatile(\
-        /*"pxor %%mm7, %%mm7		\n\t"*/\
-        "1:				\n\t"\
-        "movq (%0), %%mm0		\n\t"\
-        "movq 8(%0), %%mm1		\n\t"\
-        "movq 16(%0), %%mm2		\n\t"\
-        "movq 24(%0), %%mm3		\n\t"\
-        QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5, 16(%0),  8(%0),   (%0), 32(%0), (%1), OP)\
-        QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5,  8(%0),   (%0),   (%0), 40(%0), (%1, %3), OP)\
-        "add %4, %1			\n\t"\
-        QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5,   (%0),   (%0),  8(%0), 48(%0), (%1), OP)\
-        \
-        QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5,   (%0),  8(%0), 16(%0), 56(%0), (%1, %3), OP)\
-        "add %4, %1			\n\t"\
-        QPEL_V_LOW(%%mm0, %%mm1, %%mm2, %%mm3, %5, %6, %5,  8(%0), 16(%0), 24(%0), 64(%0), (%1), OP)\
-        \
-        QPEL_V_LOW(%%mm1, %%mm2, %%mm3, %%mm0, %5, %6, %5, 16(%0), 24(%0), 32(%0), 64(%0), (%1, %3), OP)\
-        "add %4, %1			\n\t"\
-        QPEL_V_LOW(%%mm2, %%mm3, %%mm0, %%mm1, %5, %6, %5, 24(%0), 32(%0), 40(%0), 56(%0), (%1), OP)\
-        QPEL_V_LOW(%%mm3, %%mm0, %%mm1, %%mm2, %5, %6, %5, 32(%0), 40(%0), 48(%0), 48(%0), (%1, %3), OP)\
-                \
-        "add $72, %0			\n\t"\
-        "add %6, %1			\n\t"\
-        "decl %2			\n\t"\
-        " jnz 1b			\n\t"\
-         \
-        : "+r"(temp_ptr), "+r"(dst), "+g"(count)\
-        : "r"((long)dstStride), "r"(2*(long)dstStride), /*"m"(ff_pw_20), "m"(ff_pw_3),*/ "m"(ROUNDER), "g"(4-6*(long)dstStride)\
-        : "memory"\
-   );\
-}\
-\
-static void OPNAME ## qpel8_mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## pixels8_mmx(dst, src, stride, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[8];\
-    uint8_t * const half= (uint8_t*)temp;\
-    put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8, stride, 8);\
-    OPNAME ## pixels8_l2_ ## MMX(dst, src, half, stride, stride, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## mpeg4_qpel8_h_lowpass_ ## MMX(dst, src, stride, stride, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[8];\
-    uint8_t * const half= (uint8_t*)temp;\
-    put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8, stride, 8);\
-    OPNAME ## pixels8_l2_ ## MMX(dst, src+1, half, stride, stride, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[8];\
-    uint8_t * const half= (uint8_t*)temp;\
-    put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src, 8, stride);\
-    OPNAME ## pixels8_l2_ ## MMX(dst, src, half, stride, stride, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## qpel8_mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[8];\
-    uint8_t * const half= (uint8_t*)temp;\
-    put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src, 8, stride);\
-    OPNAME ## pixels8_l2_ ## MMX(dst, src+stride, half, stride, stride, 8);\
-}\
-static void OPNAME ## qpel8_mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[8 + 9];\
-    uint8_t * const halfH= ((uint8_t*)half) + 64;\
-    uint8_t * const halfHV= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
-    put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV, stride, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[8 + 9];\
-    uint8_t * const halfH= ((uint8_t*)half) + 64;\
-    uint8_t * const halfHV= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
-    put ## RND ## pixels8_l2_ ## MMX(halfH, src+1, halfH, 8, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV, stride, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[8 + 9];\
-    uint8_t * const halfH= ((uint8_t*)half) + 64;\
-    uint8_t * const halfHV= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
-    put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_ ## MMX(dst, halfH+8, halfHV, stride, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[8 + 9];\
-    uint8_t * const halfH= ((uint8_t*)half) + 64;\
-    uint8_t * const halfHV= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
-    put ## RND ## pixels8_l2_ ## MMX(halfH, src+1, halfH, 8, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_ ## MMX(dst, halfH+8, halfHV, stride, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[8 + 9];\
-    uint8_t * const halfH= ((uint8_t*)half) + 64;\
-    uint8_t * const halfHV= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV, stride, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[8 + 9];\
-    uint8_t * const halfH= ((uint8_t*)half) + 64;\
-    uint8_t * const halfHV= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_ ## MMX(dst, halfH+8, halfHV, stride, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[8 + 9];\
-    uint8_t * const halfH= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
-    put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8, stride, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8);\
-}\
-static void OPNAME ## qpel8_mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[8 + 9];\
-    uint8_t * const halfH= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
-    put ## RND ## pixels8_l2_ ## MMX(halfH, src+1, halfH, 8, stride, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8);\
-}\
-static void OPNAME ## qpel8_mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[9];\
-    uint8_t * const halfH= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8, stride, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, stride, 8);\
-}\
-static void OPNAME ## qpel16_mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## pixels16_mmx(dst, src, stride, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[32];\
-    uint8_t * const half= (uint8_t*)temp;\
-    put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16, stride, 16);\
-    OPNAME ## pixels16_l2_ ## MMX(dst, src, half, stride, stride, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## mpeg4_qpel16_h_lowpass_ ## MMX(dst, src, stride, stride, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[32];\
-    uint8_t * const half= (uint8_t*)temp;\
-    put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16, stride, 16);\
-    OPNAME ## pixels16_l2_ ## MMX(dst, src+1, half, stride, stride, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[32];\
-    uint8_t * const half= (uint8_t*)temp;\
-    put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16, stride);\
-    OPNAME ## pixels16_l2_ ## MMX(dst, src, half, stride, stride, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## qpel16_mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[32];\
-    uint8_t * const half= (uint8_t*)temp;\
-    put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16, stride);\
-    OPNAME ## pixels16_l2_ ## MMX(dst, src+stride, half, stride, stride, 16);\
-}\
-static void OPNAME ## qpel16_mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[16*2 + 17*2];\
-    uint8_t * const halfH= ((uint8_t*)half) + 256;\
-    uint8_t * const halfHV= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
-    put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV, stride, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[16*2 + 17*2];\
-    uint8_t * const halfH= ((uint8_t*)half) + 256;\
-    uint8_t * const halfHV= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
-    put ## RND ## pixels16_l2_ ## MMX(halfH, src+1, halfH, 16, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV, stride, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[16*2 + 17*2];\
-    uint8_t * const halfH= ((uint8_t*)half) + 256;\
-    uint8_t * const halfHV= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
-    put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_ ## MMX(dst, halfH+16, halfHV, stride, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[16*2 + 17*2];\
-    uint8_t * const halfH= ((uint8_t*)half) + 256;\
-    uint8_t * const halfHV= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
-    put ## RND ## pixels16_l2_ ## MMX(halfH, src+1, halfH, 16, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_ ## MMX(dst, halfH+16, halfHV, stride, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[16*2 + 17*2];\
-    uint8_t * const halfH= ((uint8_t*)half) + 256;\
-    uint8_t * const halfHV= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV, stride, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[16*2 + 17*2];\
-    uint8_t * const halfH= ((uint8_t*)half) + 256;\
-    uint8_t * const halfHV= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_ ## MMX(dst, halfH+16, halfHV, stride, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[17*2];\
-    uint8_t * const halfH= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
-    put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16, stride, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, stride, 16);\
-}\
-static void OPNAME ## qpel16_mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[17*2];\
-    uint8_t * const halfH= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
-    put ## RND ## pixels16_l2_ ## MMX(halfH, src+1, halfH, 16, stride, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, stride, 16);\
-}\
-static void OPNAME ## qpel16_mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t half[17*2];\
-    uint8_t * const halfH= ((uint8_t*)half);\
-    put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16, stride, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, stride, 16);\
-}
-
-#define PUT_OP(a,b,temp, size) "mov" #size " " #a ", " #b "	\n\t"
-#define AVG_3DNOW_OP(a,b,temp, size) \
-"mov" #size " " #b ", " #temp "	\n\t"\
-"pavgusb " #temp ", " #a "	\n\t"\
-"mov" #size " " #a ", " #b "	\n\t"
-#define AVG_MMX2_OP(a,b,temp, size) \
-"mov" #size " " #b ", " #temp "	\n\t"\
-"pavgb " #temp ", " #a "	\n\t"\
-"mov" #size " " #a ", " #b "	\n\t"
-
-QPEL_BASE(put_       , ff_pw_16, _       , PUT_OP, PUT_OP)
-QPEL_BASE(avg_       , ff_pw_16, _       , AVG_MMX2_OP, AVG_3DNOW_OP)
-QPEL_BASE(put_no_rnd_, ff_pw_15, _no_rnd_, PUT_OP, PUT_OP)
-QPEL_OP(put_       , ff_pw_16, _       , PUT_OP, 3dnow)
-QPEL_OP(avg_       , ff_pw_16, _       , AVG_3DNOW_OP, 3dnow)
-QPEL_OP(put_no_rnd_, ff_pw_15, _no_rnd_, PUT_OP, 3dnow)
-QPEL_OP(put_       , ff_pw_16, _       , PUT_OP, mmx2)
-QPEL_OP(avg_       , ff_pw_16, _       , AVG_MMX2_OP, mmx2)
-QPEL_OP(put_no_rnd_, ff_pw_15, _no_rnd_, PUT_OP, mmx2)
-
-#if 0
-static void just_return() { return; }
-#endif
-
-#define SET_QPEL_FUNC(postfix1, postfix2) \
-    c->put_ ## postfix1 = put_ ## postfix2;\
-    c->put_no_rnd_ ## postfix1 = put_no_rnd_ ## postfix2;\
-    c->avg_ ## postfix1 = avg_ ## postfix2;
-
-static int try_8x8basis_mmx(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale){
-    long i=0;
-    
-    assert(ABS(scale) < 256);
-    scale<<= 16 + 1 - BASIS_SHIFT + RECON_SHIFT;
-
-    asm volatile(
-        "pcmpeqw %%mm6, %%mm6		\n\t" // -1w
-        "psrlw $15, %%mm6		\n\t" //  1w
-        "pxor %%mm7, %%mm7		\n\t"
-        "movd  %4, %%mm5		\n\t" 
-        "punpcklwd %%mm5, %%mm5		\n\t" 
-        "punpcklwd %%mm5, %%mm5		\n\t" 
-        "1:				\n\t"
-        "movq  (%1, %0), %%mm0		\n\t" 
-        "movq  8(%1, %0), %%mm1		\n\t"
-        "pmulhw %%mm5, %%mm0		\n\t"
-        "pmulhw %%mm5, %%mm1		\n\t"
-        "paddw %%mm6, %%mm0		\n\t"
-        "paddw %%mm6, %%mm1		\n\t"
-        "psraw $1, %%mm0		\n\t"
-        "psraw $1, %%mm1		\n\t"
-        "paddw (%2, %0), %%mm0		\n\t"
-        "paddw 8(%2, %0), %%mm1		\n\t"
-        "psraw $6, %%mm0		\n\t"
-        "psraw $6, %%mm1		\n\t"
-        "pmullw (%3, %0), %%mm0		\n\t"
-        "pmullw 8(%3, %0), %%mm1	\n\t"
-        "pmaddwd %%mm0, %%mm0		\n\t"
-        "pmaddwd %%mm1, %%mm1		\n\t"
-        "paddd %%mm1, %%mm0		\n\t"
-        "psrld $4, %%mm0		\n\t"
-        "paddd %%mm0, %%mm7		\n\t"
-        "add $16, %0			\n\t"
-        "cmp $128, %0			\n\t" //FIXME optimize & bench
-        " jb 1b				\n\t"
-        "movq %%mm7, %%mm6		\n\t"
-        "psrlq $32, %%mm7		\n\t"
-        "paddd %%mm6, %%mm7		\n\t"
-        "psrld $2, %%mm7		\n\t"
-        "movd %%mm7, %0			\n\t"
-        
-        : "+r" (i)
-        : "r"(basis), "r"(rem), "r"(weight), "g"(scale)
-    );
-    return i;
-}
-
-static void add_8x8basis_mmx(int16_t rem[64], int16_t basis[64], int scale){
-    long i=0;
-    
-    if(ABS(scale) < 256){
-        scale<<= 16 + 1 - BASIS_SHIFT + RECON_SHIFT;
-        asm volatile(
-                "pcmpeqw %%mm6, %%mm6		\n\t" // -1w
-                "psrlw $15, %%mm6		\n\t" //  1w
-                "movd  %3, %%mm5		\n\t" 
-                "punpcklwd %%mm5, %%mm5		\n\t" 
-                "punpcklwd %%mm5, %%mm5		\n\t" 
-                "1:				\n\t"
-                "movq  (%1, %0), %%mm0		\n\t" 
-                "movq  8(%1, %0), %%mm1		\n\t"
-                "pmulhw %%mm5, %%mm0		\n\t"
-                "pmulhw %%mm5, %%mm1		\n\t"
-                "paddw %%mm6, %%mm0		\n\t" 
-                "paddw %%mm6, %%mm1		\n\t"
-                "psraw $1, %%mm0		\n\t"
-                "psraw $1, %%mm1		\n\t"
-                "paddw (%2, %0), %%mm0		\n\t"
-                "paddw 8(%2, %0), %%mm1		\n\t"
-                "movq %%mm0, (%2, %0)		\n\t"
-                "movq %%mm1, 8(%2, %0)		\n\t"
-                "add $16, %0			\n\t"
-                "cmp $128, %0			\n\t" //FIXME optimize & bench
-                " jb 1b				\n\t"
-                
-                : "+r" (i)
-                : "r"(basis), "r"(rem), "g"(scale)
-        );
-    }else{
-        for(i=0; i<8*8; i++){
-            rem[i] += (basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT);
-        }    
-    }
-}
-
-#include "h264dsp_mmx.c"
-    
-/* external functions, from idct_mmx.c */
-void ff_mmx_idct(DCTELEM *block);
-void ff_mmxext_idct(DCTELEM *block);
-
-void ff_vp3_idct_sse2(int16_t *input_data);
-void ff_vp3_idct_mmx(int16_t *data);
-void ff_vp3_dsp_init_mmx(void);
-
-/* XXX: those functions should be suppressed ASAP when all IDCTs are
-   converted */
-static void ff_libmpeg2mmx_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    ff_mmx_idct (block);
-    put_pixels_clamped_mmx(block, dest, line_size);
-}
-static void ff_libmpeg2mmx_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    ff_mmx_idct (block);
-    add_pixels_clamped_mmx(block, dest, line_size);
-}
-static void ff_libmpeg2mmx2_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    ff_mmxext_idct (block);
-    put_pixels_clamped_mmx(block, dest, line_size);
-}
-static void ff_libmpeg2mmx2_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    ff_mmxext_idct (block);
-    add_pixels_clamped_mmx(block, dest, line_size);
-}
-static void ff_vp3_idct_put_sse2(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    ff_vp3_idct_sse2(block);
-    put_signed_pixels_clamped_mmx(block, dest, line_size);
-}
-static void ff_vp3_idct_add_sse2(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    ff_vp3_idct_sse2(block);
-    add_pixels_clamped_mmx(block, dest, line_size);
-}
-static void ff_vp3_idct_put_mmx(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    ff_vp3_idct_mmx(block);
-    put_signed_pixels_clamped_mmx(block, dest, line_size);
-}
-static void ff_vp3_idct_add_mmx(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    ff_vp3_idct_mmx(block);
-    add_pixels_clamped_mmx(block, dest, line_size);
-}
-#ifdef CONFIG_GPL
-static void ff_idct_xvid_mmx_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    ff_idct_xvid_mmx (block);
-    put_pixels_clamped_mmx(block, dest, line_size);
-}
-static void ff_idct_xvid_mmx_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    ff_idct_xvid_mmx (block);
-    add_pixels_clamped_mmx(block, dest, line_size);
-}
-static void ff_idct_xvid_mmx2_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    ff_idct_xvid_mmx2 (block);
-    put_pixels_clamped_mmx(block, dest, line_size);
-}
-static void ff_idct_xvid_mmx2_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    ff_idct_xvid_mmx2 (block);
-    add_pixels_clamped_mmx(block, dest, line_size);
-}
-#endif
-    
-void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
-{
-    mm_flags = mm_support();
-
-    if (avctx->dsp_mask) {
-	if (avctx->dsp_mask & FF_MM_FORCE)
-	    mm_flags |= (avctx->dsp_mask & 0xffff);
-	else
-	    mm_flags &= ~(avctx->dsp_mask & 0xffff);
-    }
-
-#if 0
-    av_log(avctx, AV_LOG_INFO, "libavcodec: CPU flags:");
-    if (mm_flags & MM_MMX)
-        av_log(avctx, AV_LOG_INFO, " mmx");
-    if (mm_flags & MM_MMXEXT)
-        av_log(avctx, AV_LOG_INFO, " mmxext");
-    if (mm_flags & MM_3DNOW)
-        av_log(avctx, AV_LOG_INFO, " 3dnow");
-    if (mm_flags & MM_SSE)
-        av_log(avctx, AV_LOG_INFO, " sse");
-    if (mm_flags & MM_SSE2)
-        av_log(avctx, AV_LOG_INFO, " sse2");
-    av_log(avctx, AV_LOG_INFO, "\n");
-#endif
-
-    if (mm_flags & MM_MMX) {
-        const int idct_algo= avctx->idct_algo;
-
-#ifdef CONFIG_ENCODERS
-        const int dct_algo = avctx->dct_algo;
-        if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX){
-            if(mm_flags & MM_SSE2){
-                c->fdct = ff_fdct_sse2;
-	    }else if(mm_flags & MM_MMXEXT){
-                c->fdct = ff_fdct_mmx2;
-            }else{
-                c->fdct = ff_fdct_mmx;
-            }
-        }
-#endif //CONFIG_ENCODERS
-        if(avctx->lowres==0){
-            if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){
-                c->idct_put= ff_simple_idct_put_mmx;
-                c->idct_add= ff_simple_idct_add_mmx;
-                c->idct    = ff_simple_idct_mmx;
-                c->idct_permutation_type= FF_SIMPLE_IDCT_PERM;
-            }else if(idct_algo==FF_IDCT_LIBMPEG2MMX){
-                if(mm_flags & MM_MMXEXT){
-                    c->idct_put= ff_libmpeg2mmx2_idct_put;
-                    c->idct_add= ff_libmpeg2mmx2_idct_add;
-                    c->idct    = ff_mmxext_idct;
-                }else{
-                    c->idct_put= ff_libmpeg2mmx_idct_put;
-                    c->idct_add= ff_libmpeg2mmx_idct_add;
-                    c->idct    = ff_mmx_idct;
-                }
-                c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
-            }else if(idct_algo==FF_IDCT_VP3){
-                if(mm_flags & MM_SSE2){
-                    c->idct_put= ff_vp3_idct_put_sse2;
-                    c->idct_add= ff_vp3_idct_add_sse2;
-                    c->idct    = ff_vp3_idct_sse2;
-                    c->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM;
-                }else{
-                    ff_vp3_dsp_init_mmx();
-                    c->idct_put= ff_vp3_idct_put_mmx;
-                    c->idct_add= ff_vp3_idct_add_mmx;
-                    c->idct    = ff_vp3_idct_mmx;
-                    c->idct_permutation_type= FF_PARTTRANS_IDCT_PERM;
-                }
-#ifdef CONFIG_GPL
-            }else if(idct_algo==FF_IDCT_XVIDMMX){
-                if(mm_flags & MM_MMXEXT){
-                    c->idct_put= ff_idct_xvid_mmx2_put;
-                    c->idct_add= ff_idct_xvid_mmx2_add;
-                    c->idct    = ff_idct_xvid_mmx2;
-                }else{
-                    c->idct_put= ff_idct_xvid_mmx_put;
-                    c->idct_add= ff_idct_xvid_mmx_add;
-                    c->idct    = ff_idct_xvid_mmx;
-                }
-#endif
-            }
-        }
-
-#ifdef CONFIG_ENCODERS
-        c->get_pixels = get_pixels_mmx;
-        c->diff_pixels = diff_pixels_mmx;
-#endif //CONFIG_ENCODERS
-        c->put_pixels_clamped = put_pixels_clamped_mmx;
-        c->put_signed_pixels_clamped = put_signed_pixels_clamped_mmx;
-        c->add_pixels_clamped = add_pixels_clamped_mmx;
-        c->clear_blocks = clear_blocks_mmx;
-#ifdef CONFIG_ENCODERS
-        c->pix_sum = pix_sum16_mmx;
-#endif //CONFIG_ENCODERS
-
-        c->put_pixels_tab[0][0] = put_pixels16_mmx;
-        c->put_pixels_tab[0][1] = put_pixels16_x2_mmx;
-        c->put_pixels_tab[0][2] = put_pixels16_y2_mmx;
-        c->put_pixels_tab[0][3] = put_pixels16_xy2_mmx;
-
-        c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mmx;
-        c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx;
-        c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx;
-        c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_mmx;
-
-        c->avg_pixels_tab[0][0] = avg_pixels16_mmx;
-        c->avg_pixels_tab[0][1] = avg_pixels16_x2_mmx;
-        c->avg_pixels_tab[0][2] = avg_pixels16_y2_mmx;
-        c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx;
-
-        c->avg_no_rnd_pixels_tab[0][0] = avg_no_rnd_pixels16_mmx;
-        c->avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_mmx;
-        c->avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_mmx;
-        c->avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_mmx;
-
-        c->put_pixels_tab[1][0] = put_pixels8_mmx;
-        c->put_pixels_tab[1][1] = put_pixels8_x2_mmx;
-        c->put_pixels_tab[1][2] = put_pixels8_y2_mmx;
-        c->put_pixels_tab[1][3] = put_pixels8_xy2_mmx;
-
-        c->put_no_rnd_pixels_tab[1][0] = put_pixels8_mmx;
-        c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx;
-        c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx;
-        c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels8_xy2_mmx;
-
-        c->avg_pixels_tab[1][0] = avg_pixels8_mmx;
-        c->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx;
-        c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx;
-        c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx;
-
-        c->avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels8_mmx;
-        c->avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels8_x2_mmx;
-        c->avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels8_y2_mmx;
-        c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels8_xy2_mmx;
-                
-        c->add_bytes= add_bytes_mmx;
-#ifdef CONFIG_ENCODERS
-        c->diff_bytes= diff_bytes_mmx;
-        
-        c->hadamard8_diff[0]= hadamard8_diff16_mmx;
-        c->hadamard8_diff[1]= hadamard8_diff_mmx;
-        
-	c->pix_norm1 = pix_norm1_mmx;
-	c->sse[0] = sse16_mmx;
-  	c->sse[1] = sse8_mmx;
-        c->vsad[4]= vsad_intra16_mmx;
-
-	c->nsse[0] = nsse16_mmx;
-	c->nsse[1] = nsse8_mmx;
-        if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
-            c->vsad[0] = vsad16_mmx;
-        }
-        
-        if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
-            c->try_8x8basis= try_8x8basis_mmx;
-        }
-        c->add_8x8basis= add_8x8basis_mmx;
-        
-#endif //CONFIG_ENCODERS
-
-        c->h263_v_loop_filter= h263_v_loop_filter_mmx;
-        c->h263_h_loop_filter= h263_h_loop_filter_mmx;        
-	c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx;
-        
-        if (mm_flags & MM_MMXEXT) {
-            c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2;
-            c->put_pixels_tab[0][2] = put_pixels16_y2_mmx2;
-
-            c->avg_pixels_tab[0][0] = avg_pixels16_mmx2;
-            c->avg_pixels_tab[0][1] = avg_pixels16_x2_mmx2;
-            c->avg_pixels_tab[0][2] = avg_pixels16_y2_mmx2;
-
-            c->put_pixels_tab[1][1] = put_pixels8_x2_mmx2;
-            c->put_pixels_tab[1][2] = put_pixels8_y2_mmx2;
-
-            c->avg_pixels_tab[1][0] = avg_pixels8_mmx2;
-            c->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx2;
-            c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2;
-
-#ifdef CONFIG_ENCODERS
-            c->hadamard8_diff[0]= hadamard8_diff16_mmx2;
-            c->hadamard8_diff[1]= hadamard8_diff_mmx2;
-            c->vsad[4]= vsad_intra16_mmx2;
-#endif //CONFIG_ENCODERS
-
-            c->h264_idct_add= ff_h264_idct_add_mmx2;
-
-            if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
-                c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2;
-                c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2;
-                c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2;
-                c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2;
-                c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2;
-                c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2;
-#ifdef CONFIG_ENCODERS
-                c->vsad[0] = vsad16_mmx2;
-#endif //CONFIG_ENCODERS
-            }
-
-#if 1
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 0], qpel16_mc00_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 1], qpel16_mc10_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 2], qpel16_mc20_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 3], qpel16_mc30_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 4], qpel16_mc01_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 6], qpel16_mc21_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 8], qpel16_mc02_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][10], qpel16_mc22_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][12], qpel16_mc03_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][14], qpel16_mc23_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 0], qpel8_mc00_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 1], qpel8_mc10_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 2], qpel8_mc20_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 3], qpel8_mc30_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 4], qpel8_mc01_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 6], qpel8_mc21_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 8], qpel8_mc02_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][10], qpel8_mc22_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][12], qpel8_mc03_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][14], qpel8_mc23_mmx2)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_mmx2)
-#endif
-
-//FIXME 3dnow too
-#define dspfunc(PFX, IDX, NUM) \
-    c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_mmx2; \
-    c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_mmx2; \
-    c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_mmx2; \
-    c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_mmx2; \
-    c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_mmx2; \
-    c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_mmx2; \
-    c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_mmx2; \
-    c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_mmx2; \
-    c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_mmx2; \
-    c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_mmx2; \
-    c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_mmx2; \
-    c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_mmx2; \
-    c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_mmx2; \
-    c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_mmx2; \
-    c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_mmx2; \
-    c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_mmx2
-
-            dspfunc(put_h264_qpel, 0, 16);
-            dspfunc(put_h264_qpel, 1, 8);
-            dspfunc(put_h264_qpel, 2, 4);
-            dspfunc(avg_h264_qpel, 0, 16);
-            dspfunc(avg_h264_qpel, 1, 8);
-            dspfunc(avg_h264_qpel, 2, 4);
-#undef dspfunc
-
-	    c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_mmx2;
-            c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_mmx2;
-            c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_mmx2;
-            c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_mmx2;
-            c->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_mmx2;
-            c->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_mmx2;
-            c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_mmx2;
-
-#ifdef CONFIG_ENCODERS
-            c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_mmx2;
-#endif //CONFIG_ENCODERS
-        } else if (mm_flags & MM_3DNOW) {
-            c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow;
-            c->put_pixels_tab[0][2] = put_pixels16_y2_3dnow;
-
-            c->avg_pixels_tab[0][0] = avg_pixels16_3dnow;
-            c->avg_pixels_tab[0][1] = avg_pixels16_x2_3dnow;
-            c->avg_pixels_tab[0][2] = avg_pixels16_y2_3dnow;
-
-            c->put_pixels_tab[1][1] = put_pixels8_x2_3dnow;
-            c->put_pixels_tab[1][2] = put_pixels8_y2_3dnow;
-
-            c->avg_pixels_tab[1][0] = avg_pixels8_3dnow;
-            c->avg_pixels_tab[1][1] = avg_pixels8_x2_3dnow;
-            c->avg_pixels_tab[1][2] = avg_pixels8_y2_3dnow;
-
-            if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
-                c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow;
-                c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow;
-                c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_3dnow;
-                c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_3dnow;
-                c->avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow;
-                c->avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow;
-            }
-
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 0], qpel16_mc00_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 1], qpel16_mc10_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 2], qpel16_mc20_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 3], qpel16_mc30_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 4], qpel16_mc01_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 6], qpel16_mc21_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 8], qpel16_mc02_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][10], qpel16_mc22_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][12], qpel16_mc03_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][14], qpel16_mc23_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 0], qpel8_mc00_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 1], qpel8_mc10_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 2], qpel8_mc20_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 3], qpel8_mc30_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 4], qpel8_mc01_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 6], qpel8_mc21_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 8], qpel8_mc02_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][10], qpel8_mc22_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][12], qpel8_mc03_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][14], qpel8_mc23_3dnow)
-            SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_3dnow)
-
-#define dspfunc(PFX, IDX, NUM) \
-    c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_3dnow; \
-    c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_3dnow; \
-    c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_3dnow; \
-    c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_3dnow; \
-    c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_3dnow; \
-    c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_3dnow; \
-    c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_3dnow; \
-    c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_3dnow; \
-    c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_3dnow; \
-    c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_3dnow; \
-    c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_3dnow; \
-    c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_3dnow; \
-    c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_3dnow; \
-    c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_3dnow; \
-    c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_3dnow; \
-    c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_3dnow
-
-            dspfunc(put_h264_qpel, 0, 16);
-            dspfunc(put_h264_qpel, 1, 8);
-            dspfunc(put_h264_qpel, 2, 4);
-            dspfunc(avg_h264_qpel, 0, 16);
-            dspfunc(avg_h264_qpel, 1, 8);
-            dspfunc(avg_h264_qpel, 2, 4);
-
-	    c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_3dnow;
-        }
-    }
-        
-#ifdef CONFIG_ENCODERS
-    dsputil_init_pix_mmx(c, avctx);
-#endif //CONFIG_ENCODERS
-#if 0
-    // for speed testing
-    get_pixels = just_return;
-    put_pixels_clamped = just_return;
-    add_pixels_clamped = just_return;
-
-    pix_abs16x16 = just_return;
-    pix_abs16x16_x2 = just_return;
-    pix_abs16x16_y2 = just_return;
-    pix_abs16x16_xy2 = just_return;
-
-    put_pixels_tab[0] = just_return;
-    put_pixels_tab[1] = just_return;
-    put_pixels_tab[2] = just_return;
-    put_pixels_tab[3] = just_return;
-
-    put_no_rnd_pixels_tab[0] = just_return;
-    put_no_rnd_pixels_tab[1] = just_return;
-    put_no_rnd_pixels_tab[2] = just_return;
-    put_no_rnd_pixels_tab[3] = just_return;
-
-    avg_pixels_tab[0] = just_return;
-    avg_pixels_tab[1] = just_return;
-    avg_pixels_tab[2] = just_return;
-    avg_pixels_tab[3] = just_return;
-
-    avg_no_rnd_pixels_tab[0] = just_return;
-    avg_no_rnd_pixels_tab[1] = just_return;
-    avg_no_rnd_pixels_tab[2] = just_return;
-    avg_no_rnd_pixels_tab[3] = just_return;
-
-    //av_fdct = just_return;
-    //ff_idct = just_return;
-#endif
-}
diff --git a/ffmpeg.src/libavcodec/i386/dsputil_mmx_avg.h b/ffmpeg.src/libavcodec/i386/dsputil_mmx_avg.h
deleted file mode 100644
index c708913..0000000
--- a/ffmpeg.src/libavcodec/i386/dsputil_mmx_avg.h
+++ /dev/null
@@ -1,820 +0,0 @@
-/*
- * DSP utils : average functions are compiled twice for 3dnow/mmx2
- * Copyright (c) 2000, 2001 Fabrice Bellard.
- * Copyright (c) 2002-2004 Michael Niedermayer
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * MMX optimization by Nick Kurshev <nickols_k at mail.ru>
- * mostly rewritten by Michael Niedermayer <michaelni at gmx.at>
- * and improved by Zdenek Kabelac <kabi at users.sf.net>
- */
- 
-/* XXX: we use explicit registers to avoid a gcc 2.95.2 register asm
-   clobber bug - now it will work with 2.95.2 and also with -fPIC
- */
-static void DEF(put_pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    __asm __volatile(
-	"lea (%3, %3), %%"REG_a"	\n\t"
-	"1:				\n\t"
-	"movq (%1), %%mm0		\n\t"
-	"movq (%1, %3), %%mm1		\n\t"
-	PAVGB" 1(%1), %%mm0		\n\t"
-	PAVGB" 1(%1, %3), %%mm1		\n\t"
-	"movq %%mm0, (%2)		\n\t"
-	"movq %%mm1, (%2, %3)		\n\t"
-	"add %%"REG_a", %1		\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"movq (%1), %%mm0		\n\t"
-	"movq (%1, %3), %%mm1		\n\t"
-	PAVGB" 1(%1), %%mm0		\n\t"
-	PAVGB" 1(%1, %3), %%mm1		\n\t"
-	"add %%"REG_a", %1		\n\t"
-	"movq %%mm0, (%2)		\n\t"
-	"movq %%mm1, (%2, %3)		\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"subl $4, %0			\n\t"
-	"jnz 1b				\n\t"
-	:"+g"(h), "+S"(pixels), "+D"(block)
-	:"r" ((long)line_size)
-	:"%"REG_a, "memory");
-}
-
-static void DEF(put_pixels4_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
-    __asm __volatile(
-	"testl $1, %0			\n\t"
-	    " jz 1f				\n\t"
-	"movd	(%1), %%mm0		\n\t"
-	"movd	(%2), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"add	$4, %2			\n\t"
-	PAVGB" %%mm1, %%mm0		\n\t"
-	"movd	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"decl	%0			\n\t"
-	"1:				\n\t"
-	"movd	(%1), %%mm0		\n\t"
-	"add	%4, %1			\n\t"
-	"movd	(%1), %%mm1		\n\t"
-	"movd	(%2), %%mm2		\n\t"
-	"movd	4(%2), %%mm3		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGB" %%mm2, %%mm0		\n\t"
-	PAVGB" %%mm3, %%mm1		\n\t"
-	"movd	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movd	%%mm1, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movd	(%1), %%mm0		\n\t"
-	"add	%4, %1			\n\t"
-	"movd	(%1), %%mm1		\n\t"
-	"movd	8(%2), %%mm2		\n\t"
-	"movd	12(%2), %%mm3		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGB" %%mm2, %%mm0		\n\t"
-	PAVGB" %%mm3, %%mm1		\n\t"
-	"movd	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movd	%%mm1, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"add	$16, %2			\n\t"
-	"subl	$4, %0			\n\t"
-	"jnz	1b			\n\t"
-#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
-	:"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#else
-	:"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#endif
-	:"S"((long)src1Stride), "D"((long)dstStride)
-	:"memory"); 
-}
-
-
-static void DEF(put_pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
-    __asm __volatile(
-	"testl $1, %0			\n\t"
-	    " jz 1f				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	(%2), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"add	$8, %2			\n\t"
-	PAVGB" %%mm1, %%mm0		\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"decl	%0			\n\t"
-	"1:				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"add	%4, %1			\n\t"
-	"movq	(%1), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGB" (%2), %%mm0		\n\t"
-	PAVGB" 8(%2), %%mm1		\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movq	%%mm1, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"add	%4, %1			\n\t"
-	"movq	(%1), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGB" 16(%2), %%mm0		\n\t"
-	PAVGB" 24(%2), %%mm1		\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movq	%%mm1, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"add	$32, %2			\n\t"
-	"subl	$4, %0			\n\t"
-	"jnz	1b			\n\t"
-#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
-	:"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#else
-	:"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#endif
-	:"S"((long)src1Stride), "D"((long)dstStride)
-	:"memory"); 
-//the following should be used, though better not with gcc ...
-/*	:"+g"(h), "+r"(src1), "+r"(src2), "+r"(dst)
-	:"r"(src1Stride), "r"(dstStride)
-	:"memory");*/
-}
-
-static void DEF(put_no_rnd_pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
-    __asm __volatile(
-	"pcmpeqb %%mm6, %%mm6	\n\t"
-	"testl $1, %0			\n\t"
-	    " jz 1f				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	(%2), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"add	$8, %2			\n\t"
-	"pxor %%mm6, %%mm0		\n\t"
-	"pxor %%mm6, %%mm1		\n\t"
-	PAVGB" %%mm1, %%mm0		\n\t"
-	"pxor %%mm6, %%mm0		\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"decl	%0			\n\t"
-	"1:				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"add	%4, %1			\n\t"
-	"movq	(%1), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"movq	(%2), %%mm2		\n\t"
-	"movq	8(%2), %%mm3		\n\t"
-	"pxor %%mm6, %%mm0		\n\t"
-	"pxor %%mm6, %%mm1		\n\t"
-	"pxor %%mm6, %%mm2		\n\t"
-	"pxor %%mm6, %%mm3		\n\t"
-	PAVGB" %%mm2, %%mm0		\n\t"
-	PAVGB" %%mm3, %%mm1		\n\t"
-	"pxor %%mm6, %%mm0		\n\t"
-	"pxor %%mm6, %%mm1		\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movq	%%mm1, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"add	%4, %1			\n\t"
-	"movq	(%1), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"movq	16(%2), %%mm2		\n\t"
-	"movq	24(%2), %%mm3		\n\t"
-	"pxor %%mm6, %%mm0		\n\t"
-	"pxor %%mm6, %%mm1		\n\t"
-	"pxor %%mm6, %%mm2		\n\t"
-	"pxor %%mm6, %%mm3		\n\t"
-	PAVGB" %%mm2, %%mm0		\n\t"
-	PAVGB" %%mm3, %%mm1		\n\t"
-	"pxor %%mm6, %%mm0		\n\t"
-	"pxor %%mm6, %%mm1		\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movq	%%mm1, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"add	$32, %2			\n\t"
-	"subl	$4, %0			\n\t"
-	"jnz	1b			\n\t"
-#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
-	:"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#else
-	:"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#endif
-	:"S"((long)src1Stride), "D"((long)dstStride)
-	:"memory"); 
-//the following should be used, though better not with gcc ...
-/*	:"+g"(h), "+r"(src1), "+r"(src2), "+r"(dst)
-	:"r"(src1Stride), "r"(dstStride)
-	:"memory");*/
-}
-
-static void DEF(avg_pixels4_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
-    __asm __volatile(
-	"testl $1, %0			\n\t"
-	    " jz 1f				\n\t"
-	"movd	(%1), %%mm0		\n\t"
-	"movd	(%2), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"add	$4, %2			\n\t"
-	PAVGB" %%mm1, %%mm0		\n\t"
-	PAVGB" (%3), %%mm0		\n\t"
-	"movd	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"decl	%0			\n\t"
-	"1:				\n\t"
-	"movd	(%1), %%mm0		\n\t"
-	"add	%4, %1			\n\t"
-	"movd	(%1), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGB" (%2), %%mm0		\n\t"
-	PAVGB" 4(%2), %%mm1		\n\t"
-	PAVGB" (%3), %%mm0	 	\n\t"
-	"movd	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	PAVGB" (%3), %%mm1	 	\n\t"
-	"movd	%%mm1, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movd	(%1), %%mm0		\n\t"
-	"add	%4, %1			\n\t"
-	"movd	(%1), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGB" 8(%2), %%mm0		\n\t"
-	PAVGB" 12(%2), %%mm1		\n\t"
-	PAVGB" (%3), %%mm0	 	\n\t"
-	"movd	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	PAVGB" (%3), %%mm1	 	\n\t"
-	"movd	%%mm1, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"add	$16, %2			\n\t"
-	"subl	$4, %0			\n\t"
-	"jnz	1b			\n\t"
-#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
-	:"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#else
-	:"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#endif
-	:"S"((long)src1Stride), "D"((long)dstStride)
-	:"memory"); 
-}
-
-
-static void DEF(avg_pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
-    __asm __volatile(
-	"testl $1, %0			\n\t"
-	    " jz 1f				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	(%2), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"add	$8, %2			\n\t"
-	PAVGB" %%mm1, %%mm0		\n\t"
-	PAVGB" (%3), %%mm0		\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"decl	%0			\n\t"
-	"1:				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"add	%4, %1			\n\t"
-	"movq	(%1), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGB" (%2), %%mm0		\n\t"
-	PAVGB" 8(%2), %%mm1		\n\t"
-	PAVGB" (%3), %%mm0	 	\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	PAVGB" (%3), %%mm1	 	\n\t"
-	"movq	%%mm1, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"add	%4, %1			\n\t"
-	"movq	(%1), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGB" 16(%2), %%mm0		\n\t"
-	PAVGB" 24(%2), %%mm1		\n\t"
-	PAVGB" (%3), %%mm0	 	\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	PAVGB" (%3), %%mm1	 	\n\t"
-	"movq	%%mm1, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"add	$32, %2			\n\t"
-	"subl	$4, %0			\n\t"
-	"jnz	1b			\n\t"
-#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
-	:"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#else
-	:"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#endif
-	:"S"((long)src1Stride), "D"((long)dstStride)
-	:"memory"); 
-//the following should be used, though better not with gcc ...
-/*	:"+g"(h), "+r"(src1), "+r"(src2), "+r"(dst)
-	:"r"(src1Stride), "r"(dstStride)
-	:"memory");*/
-}
-
-static void DEF(put_pixels16_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    __asm __volatile(
-	"lea (%3, %3), %%"REG_a"	\n\t"
-	"1:				\n\t"
-	"movq (%1), %%mm0		\n\t"
-	"movq (%1, %3), %%mm1		\n\t"
-	"movq 8(%1), %%mm2		\n\t"
-	"movq 8(%1, %3), %%mm3		\n\t"
-	PAVGB" 1(%1), %%mm0		\n\t"
-	PAVGB" 1(%1, %3), %%mm1		\n\t"
-	PAVGB" 9(%1), %%mm2		\n\t"
-	PAVGB" 9(%1, %3), %%mm3		\n\t"
-	"movq %%mm0, (%2)		\n\t"
-	"movq %%mm1, (%2, %3)		\n\t"
-	"movq %%mm2, 8(%2)		\n\t"
-	"movq %%mm3, 8(%2, %3)		\n\t"
-	"add %%"REG_a", %1		\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"movq (%1), %%mm0		\n\t"
-	"movq (%1, %3), %%mm1		\n\t"
-	"movq 8(%1), %%mm2		\n\t"
-	"movq 8(%1, %3), %%mm3		\n\t"
-	PAVGB" 1(%1), %%mm0		\n\t"
-	PAVGB" 1(%1, %3), %%mm1		\n\t"
-	PAVGB" 9(%1), %%mm2		\n\t"
-	PAVGB" 9(%1, %3), %%mm3		\n\t"
-	"add %%"REG_a", %1		\n\t"
-	"movq %%mm0, (%2)		\n\t"
-	"movq %%mm1, (%2, %3)		\n\t"
-	"movq %%mm2, 8(%2)		\n\t"
-	"movq %%mm3, 8(%2, %3)		\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"subl $4, %0			\n\t"
-	"jnz 1b				\n\t"
-	:"+g"(h), "+S"(pixels), "+D"(block)
-	:"r" ((long)line_size)
-	:"%"REG_a, "memory");
-}
-
-static void DEF(put_pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
-    __asm __volatile(
-	"testl $1, %0			\n\t"
-	    " jz 1f				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	8(%1), %%mm1		\n\t"
-	PAVGB" (%2), %%mm0		\n\t"
-	PAVGB" 8(%2), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"add	$16, %2			\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"movq	%%mm1, 8(%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"decl	%0			\n\t"
-	"1:				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	8(%1), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGB" (%2), %%mm0		\n\t"
-	PAVGB" 8(%2), %%mm1		\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"movq	%%mm1, 8(%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	8(%1), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGB" 16(%2), %%mm0		\n\t"
-	PAVGB" 24(%2), %%mm1		\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"movq	%%mm1, 8(%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"add	$32, %2			\n\t"
-	"subl	$2, %0			\n\t"
-	"jnz	1b			\n\t"
-#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
-	:"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#else
-	:"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#endif
-	:"S"((long)src1Stride), "D"((long)dstStride)
-	:"memory"); 
-//the following should be used, though better not with gcc ...
-/*	:"+g"(h), "+r"(src1), "+r"(src2), "+r"(dst)
-	:"r"(src1Stride), "r"(dstStride)
-	:"memory");*/
-}
-
-static void DEF(avg_pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
-    __asm __volatile(
-	"testl $1, %0			\n\t"
-	    " jz 1f				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	8(%1), %%mm1		\n\t"
-	PAVGB" (%2), %%mm0		\n\t"
-	PAVGB" 8(%2), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"add	$16, %2			\n\t"
-	PAVGB" (%3), %%mm0		\n\t"
-	PAVGB" 8(%3), %%mm1		\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"movq	%%mm1, 8(%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"decl	%0			\n\t"
-	"1:				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	8(%1), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGB" (%2), %%mm0		\n\t"
-	PAVGB" 8(%2), %%mm1		\n\t"
-	PAVGB" (%3), %%mm0		\n\t"
-	PAVGB" 8(%3), %%mm1		\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"movq	%%mm1, 8(%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	8(%1), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGB" 16(%2), %%mm0		\n\t"
-	PAVGB" 24(%2), %%mm1		\n\t"
-	PAVGB" (%3), %%mm0		\n\t"
-	PAVGB" 8(%3), %%mm1		\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"movq	%%mm1, 8(%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"add	$32, %2			\n\t"
-	"subl	$2, %0			\n\t"
-	"jnz	1b			\n\t"
-#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
-	:"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#else
-	:"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#endif
-	:"S"((long)src1Stride), "D"((long)dstStride)
-	:"memory"); 
-//the following should be used, though better not with gcc ...
-/*	:"+g"(h), "+r"(src1), "+r"(src2), "+r"(dst)
-	:"r"(src1Stride), "r"(dstStride)
-	:"memory");*/
-}
-
-static void DEF(put_no_rnd_pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
-    __asm __volatile(
-	"pcmpeqb %%mm6, %%mm6\n\t"
-	"testl $1, %0			\n\t"
-	    " jz 1f				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	8(%1), %%mm1		\n\t"
-	"movq	(%2), %%mm2		\n\t"
-	"movq	8(%2), %%mm3		\n\t"
-	"pxor %%mm6, %%mm0		\n\t"
-	"pxor %%mm6, %%mm1		\n\t"
-	"pxor %%mm6, %%mm2		\n\t"
-	"pxor %%mm6, %%mm3		\n\t"
-	PAVGB" %%mm2, %%mm0		\n\t"
-	PAVGB" %%mm3, %%mm1		\n\t"
-	"pxor %%mm6, %%mm0		\n\t"
-	"pxor %%mm6, %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"add	$16, %2			\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"movq	%%mm1, 8(%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"decl	%0			\n\t"
-	"1:				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	8(%1), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"movq	(%2), %%mm2		\n\t"
-	"movq	8(%2), %%mm3		\n\t"
-	"pxor %%mm6, %%mm0		\n\t"
-	"pxor %%mm6, %%mm1		\n\t"
-	"pxor %%mm6, %%mm2		\n\t"
-	"pxor %%mm6, %%mm3		\n\t"
-	PAVGB" %%mm2, %%mm0		\n\t"
-	PAVGB" %%mm3, %%mm1		\n\t"
-	"pxor %%mm6, %%mm0		\n\t"
-	"pxor %%mm6, %%mm1		\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"movq	%%mm1, 8(%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	8(%1), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"movq	16(%2), %%mm2		\n\t"
-	"movq	24(%2), %%mm3		\n\t"
-	"pxor %%mm6, %%mm0		\n\t"
-	"pxor %%mm6, %%mm1		\n\t"
-	"pxor %%mm6, %%mm2		\n\t"
-	"pxor %%mm6, %%mm3		\n\t"
-	PAVGB" %%mm2, %%mm0		\n\t"
-	PAVGB" %%mm3, %%mm1		\n\t"
-	"pxor %%mm6, %%mm0		\n\t"
-	"pxor %%mm6, %%mm1		\n\t"
-	"movq	%%mm0, (%3)		\n\t"
-	"movq	%%mm1, 8(%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"add	$32, %2			\n\t"
-	"subl	$2, %0			\n\t"
-	"jnz	1b			\n\t"
-#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
-	:"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#else
-	:"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#endif
-	:"S"((long)src1Stride), "D"((long)dstStride)
-	:"memory"); 
-//the following should be used, though better not with gcc ...
-/*	:"+g"(h), "+r"(src1), "+r"(src2), "+r"(dst)
-	:"r"(src1Stride), "r"(dstStride)
-	:"memory");*/
-}
- 
-/* GL: this function does incorrect rounding if overflow */
-static void DEF(put_no_rnd_pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    MOVQ_BONE(mm6);
-    __asm __volatile(
-	"lea (%3, %3), %%"REG_a"	\n\t"
-	"1:				\n\t"
-	"movq (%1), %%mm0		\n\t"
-	"movq (%1, %3), %%mm2		\n\t"
-	"movq 1(%1), %%mm1		\n\t"
-	"movq 1(%1, %3), %%mm3		\n\t"
-	"add %%"REG_a", %1		\n\t"
-	"psubusb %%mm6, %%mm0		\n\t"
-	"psubusb %%mm6, %%mm2		\n\t"
-	PAVGB" %%mm1, %%mm0		\n\t"
-	PAVGB" %%mm3, %%mm2		\n\t"
-	"movq %%mm0, (%2)		\n\t"
-	"movq %%mm2, (%2, %3)		\n\t"
-	"movq (%1), %%mm0		\n\t"
-	"movq 1(%1), %%mm1		\n\t"
-	"movq (%1, %3), %%mm2		\n\t"
-	"movq 1(%1, %3), %%mm3		\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"add %%"REG_a", %1		\n\t"
-	"psubusb %%mm6, %%mm0		\n\t"
-	"psubusb %%mm6, %%mm2		\n\t"
-	PAVGB" %%mm1, %%mm0		\n\t"
-	PAVGB" %%mm3, %%mm2		\n\t"
-	"movq %%mm0, (%2)		\n\t"
-	"movq %%mm2, (%2, %3)		\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"subl $4, %0			\n\t"
-	"jnz 1b				\n\t"
-	:"+g"(h), "+S"(pixels), "+D"(block)
-	:"r" ((long)line_size)
-	:"%"REG_a, "memory");
-}
-
-static void DEF(put_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    __asm __volatile(
-	"lea (%3, %3), %%"REG_a"	\n\t"
-	"movq (%1), %%mm0		\n\t"
-	"sub %3, %2			\n\t"
-	"1:				\n\t"
-	"movq (%1, %3), %%mm1		\n\t"
-	"movq (%1, %%"REG_a"), %%mm2	\n\t"
-	"add %%"REG_a", %1		\n\t"
-	PAVGB" %%mm1, %%mm0		\n\t"
-	PAVGB" %%mm2, %%mm1		\n\t"
-	"movq %%mm0, (%2, %3)		\n\t"
-	"movq %%mm1, (%2, %%"REG_a")	\n\t"
-	"movq (%1, %3), %%mm1		\n\t"
-	"movq (%1, %%"REG_a"), %%mm0	\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"add %%"REG_a", %1		\n\t"
-	PAVGB" %%mm1, %%mm2		\n\t"
-	PAVGB" %%mm0, %%mm1		\n\t"
-	"movq %%mm2, (%2, %3)		\n\t"
-	"movq %%mm1, (%2, %%"REG_a")	\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"subl $4, %0			\n\t"
-	"jnz 1b				\n\t"
-	:"+g"(h), "+S"(pixels), "+D" (block)
-	:"r" ((long)line_size)
-	:"%"REG_a, "memory");
-}
-
-/* GL: this function does incorrect rounding if overflow */
-static void DEF(put_no_rnd_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    MOVQ_BONE(mm6);
-    __asm __volatile(
-	"lea (%3, %3), %%"REG_a"	\n\t"
-	"movq (%1), %%mm0		\n\t"
-	"sub %3, %2			\n\t"
-	"1:				\n\t"
-	"movq (%1, %3), %%mm1		\n\t"
-	"movq (%1, %%"REG_a"), %%mm2	\n\t"
-	"add %%"REG_a", %1		\n\t"
-	"psubusb %%mm6, %%mm1		\n\t"
-	PAVGB" %%mm1, %%mm0		\n\t"
-	PAVGB" %%mm2, %%mm1		\n\t"
-	"movq %%mm0, (%2, %3)		\n\t"
-	"movq %%mm1, (%2, %%"REG_a")	\n\t"
-	"movq (%1, %3), %%mm1		\n\t"
-	"movq (%1, %%"REG_a"), %%mm0	\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"add %%"REG_a", %1		\n\t"
-	"psubusb %%mm6, %%mm1		\n\t"
-	PAVGB" %%mm1, %%mm2		\n\t"
-	PAVGB" %%mm0, %%mm1		\n\t"
-	"movq %%mm2, (%2, %3)		\n\t"
-	"movq %%mm1, (%2, %%"REG_a")	\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"subl $4, %0			\n\t"
-	"jnz 1b				\n\t"
-	:"+g"(h), "+S"(pixels), "+D" (block)
-	:"r" ((long)line_size)
-	:"%"REG_a, "memory");
-}
-
-static void DEF(avg_pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    __asm __volatile(
-	"lea (%3, %3), %%"REG_a"	\n\t"
-	"1:				\n\t"
-	"movq (%2), %%mm0		\n\t"
-	"movq (%2, %3), %%mm1		\n\t"
-	PAVGB" (%1), %%mm0		\n\t"
-	PAVGB" (%1, %3), %%mm1		\n\t"
-	"movq %%mm0, (%2)		\n\t"
-	"movq %%mm1, (%2, %3)		\n\t"
-	"add %%"REG_a", %1		\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"movq (%2), %%mm0		\n\t"
-	"movq (%2, %3), %%mm1		\n\t"
-	PAVGB" (%1), %%mm0		\n\t"
-	PAVGB" (%1, %3), %%mm1		\n\t"
-	"add %%"REG_a", %1		\n\t"
-	"movq %%mm0, (%2)		\n\t"
-	"movq %%mm1, (%2, %3)		\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"subl $4, %0			\n\t"
-	"jnz 1b				\n\t"
-	:"+g"(h), "+S"(pixels), "+D"(block)
-	:"r" ((long)line_size)
-	:"%"REG_a, "memory");
-}
-
-static void DEF(avg_pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    __asm __volatile(
-	"lea (%3, %3), %%"REG_a"	\n\t"
-	"1:				\n\t"
-	"movq (%1), %%mm0		\n\t"
-	"movq (%1, %3), %%mm2		\n\t"
-	PAVGB" 1(%1), %%mm0		\n\t"
-	PAVGB" 1(%1, %3), %%mm2		\n\t"
-	PAVGB" (%2), %%mm0		\n\t"
-	PAVGB" (%2, %3), %%mm2		\n\t"
-	"add %%"REG_a", %1		\n\t"
-	"movq %%mm0, (%2)		\n\t"
-	"movq %%mm2, (%2, %3)		\n\t"
-	"movq (%1), %%mm0		\n\t"
-	"movq (%1, %3), %%mm2		\n\t"
-	PAVGB" 1(%1), %%mm0		\n\t"
-	PAVGB" 1(%1, %3), %%mm2		\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"add %%"REG_a", %1		\n\t"
-	PAVGB" (%2), %%mm0		\n\t"
-	PAVGB" (%2, %3), %%mm2		\n\t"
-	"movq %%mm0, (%2)		\n\t"
-	"movq %%mm2, (%2, %3)		\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"subl $4, %0			\n\t"
-	"jnz 1b				\n\t"
-	:"+g"(h), "+S"(pixels), "+D"(block)
-	:"r" ((long)line_size)
-	:"%"REG_a, "memory");
-}
-
-static void DEF(avg_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    __asm __volatile(
-	"lea (%3, %3), %%"REG_a"	\n\t"
-	"movq (%1), %%mm0		\n\t"
-	"sub %3, %2			\n\t"
-	"1:				\n\t"
-	"movq (%1, %3), %%mm1		\n\t"
-	"movq (%1, %%"REG_a"), %%mm2	\n\t"
-	"add %%"REG_a", %1		\n\t"
-	PAVGB" %%mm1, %%mm0		\n\t"
-	PAVGB" %%mm2, %%mm1		\n\t"
-	"movq (%2, %3), %%mm3		\n\t"
-	"movq (%2, %%"REG_a"), %%mm4	\n\t"
-	PAVGB" %%mm3, %%mm0		\n\t"
-	PAVGB" %%mm4, %%mm1		\n\t"
-	"movq %%mm0, (%2, %3)		\n\t"
-	"movq %%mm1, (%2, %%"REG_a")	\n\t"
-	"movq (%1, %3), %%mm1		\n\t"
-	"movq (%1, %%"REG_a"), %%mm0	\n\t"
-	PAVGB" %%mm1, %%mm2		\n\t"
-	PAVGB" %%mm0, %%mm1		\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"add %%"REG_a", %1		\n\t"
-	"movq (%2, %3), %%mm3		\n\t"
-	"movq (%2, %%"REG_a"), %%mm4	\n\t"
-	PAVGB" %%mm3, %%mm2		\n\t"
-	PAVGB" %%mm4, %%mm1		\n\t"
-	"movq %%mm2, (%2, %3)		\n\t"
-	"movq %%mm1, (%2, %%"REG_a")	\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"subl $4, %0			\n\t"
-	"jnz 1b				\n\t"
-	:"+g"(h), "+S"(pixels), "+D"(block)
-	:"r" ((long)line_size)
-	:"%"REG_a, "memory");
-}
-
-// Note this is not correctly rounded, but this function is only used for b frames so it doesnt matter 
-static void DEF(avg_pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    MOVQ_BONE(mm6);
-    __asm __volatile(
-	"lea (%3, %3), %%"REG_a"	\n\t"
-	"movq (%1), %%mm0		\n\t"
-	PAVGB" 1(%1), %%mm0		\n\t"
-	".balign 8			\n\t"
-	"1:				\n\t"
-	"movq (%1, %%"REG_a"), %%mm2	\n\t"
-	"movq (%1, %3), %%mm1		\n\t"
-	"psubusb %%mm6, %%mm2		\n\t"
-	PAVGB" 1(%1, %3), %%mm1		\n\t"
-	PAVGB" 1(%1, %%"REG_a"), %%mm2	\n\t"
-	"add %%"REG_a", %1		\n\t"
-	PAVGB" %%mm1, %%mm0		\n\t"
-	PAVGB" %%mm2, %%mm1		\n\t"
-	PAVGB" (%2), %%mm0		\n\t"
-	PAVGB" (%2, %3), %%mm1		\n\t"
-	"movq %%mm0, (%2)		\n\t"
-	"movq %%mm1, (%2, %3)		\n\t"
-	"movq (%1, %3), %%mm1		\n\t"
-	"movq (%1, %%"REG_a"), %%mm0	\n\t"
-	PAVGB" 1(%1, %3), %%mm1		\n\t"
-	PAVGB" 1(%1, %%"REG_a"), %%mm0	\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"add %%"REG_a", %1		\n\t"
-	PAVGB" %%mm1, %%mm2		\n\t"
-	PAVGB" %%mm0, %%mm1		\n\t"
-	PAVGB" (%2), %%mm2		\n\t"
-	PAVGB" (%2, %3), %%mm1		\n\t"
-	"movq %%mm2, (%2)		\n\t"
-	"movq %%mm1, (%2, %3)		\n\t"
-	"add %%"REG_a", %2		\n\t"
-	"subl $4, %0			\n\t"
-	"jnz 1b				\n\t"
-	:"+g"(h), "+S"(pixels), "+D"(block)
-	:"r" ((long)line_size)
-	:"%"REG_a,  "memory");
-}
-
-//FIXME the following could be optimized too ...
-static void DEF(put_no_rnd_pixels16_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
-    DEF(put_no_rnd_pixels8_x2)(block  , pixels  , line_size, h);
-    DEF(put_no_rnd_pixels8_x2)(block+8, pixels+8, line_size, h);
-}
-static void DEF(put_pixels16_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
-    DEF(put_pixels8_y2)(block  , pixels  , line_size, h);
-    DEF(put_pixels8_y2)(block+8, pixels+8, line_size, h);
-}
-static void DEF(put_no_rnd_pixels16_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
-    DEF(put_no_rnd_pixels8_y2)(block  , pixels  , line_size, h);
-    DEF(put_no_rnd_pixels8_y2)(block+8, pixels+8, line_size, h);
-}
-static void DEF(avg_pixels16)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
-    DEF(avg_pixels8)(block  , pixels  , line_size, h);
-    DEF(avg_pixels8)(block+8, pixels+8, line_size, h);
-}
-static void DEF(avg_pixels16_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
-    DEF(avg_pixels8_x2)(block  , pixels  , line_size, h);
-    DEF(avg_pixels8_x2)(block+8, pixels+8, line_size, h);
-}
-static void DEF(avg_pixels16_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
-    DEF(avg_pixels8_y2)(block  , pixels  , line_size, h);
-    DEF(avg_pixels8_y2)(block+8, pixels+8, line_size, h);
-}
-static void DEF(avg_pixels16_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
-    DEF(avg_pixels8_xy2)(block  , pixels  , line_size, h);
-    DEF(avg_pixels8_xy2)(block+8, pixels+8, line_size, h);
-}
-
diff --git a/ffmpeg.src/libavcodec/i386/dsputil_mmx_rnd.h b/ffmpeg.src/libavcodec/i386/dsputil_mmx_rnd.h
deleted file mode 100644
index a56374b..0000000
--- a/ffmpeg.src/libavcodec/i386/dsputil_mmx_rnd.h
+++ /dev/null
@@ -1,590 +0,0 @@
-/*
- * DSP utils mmx functions are compiled twice for rnd/no_rnd
- * Copyright (c) 2000, 2001 Fabrice Bellard.
- * Copyright (c) 2003-2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * MMX optimization by Nick Kurshev <nickols_k at mail.ru>
- * mostly rewritten by Michael Niedermayer <michaelni at gmx.at>
- * and improved by Zdenek Kabelac <kabi at users.sf.net>
- */
-
-// put_pixels
-static void DEF(put, pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    MOVQ_BFE(mm6);
-    __asm __volatile(
-	"lea	(%3, %3), %%"REG_a"	\n\t"
-	".balign 8			\n\t"
-	"1:				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	1(%1), %%mm1		\n\t"
-	"movq	(%1, %3), %%mm2		\n\t"
-	"movq	1(%1, %3), %%mm3	\n\t"
-	PAVGBP(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
-	"movq	%%mm4, (%2)		\n\t"
-	"movq	%%mm5, (%2, %3)		\n\t"
-	"add	%%"REG_a", %1		\n\t"
-	"add	%%"REG_a", %2		\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	1(%1), %%mm1		\n\t"
-	"movq	(%1, %3), %%mm2		\n\t"
-	"movq	1(%1, %3), %%mm3	\n\t"
-	PAVGBP(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
-	"movq	%%mm4, (%2)		\n\t"
-	"movq	%%mm5, (%2, %3)		\n\t"
-	"add	%%"REG_a", %1		\n\t"
-	"add	%%"REG_a", %2		\n\t"
-	"subl	$4, %0			\n\t"
-	"jnz	1b			\n\t"
-	:"+g"(h), "+S"(pixels), "+D"(block)
-	:"r"((long)line_size)
-	:REG_a, "memory");
-}
-
-static void attribute_unused DEF(put, pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
-    MOVQ_BFE(mm6);
-    __asm __volatile(
-	"testl $1, %0			\n\t"
-        " jz 1f				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	(%2), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"add	$8, %2			\n\t"
-	PAVGB(%%mm0, %%mm1, %%mm4, %%mm6)
-	"movq	%%mm4, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-        "decl	%0			\n\t"
-	".balign 8			\n\t"
-	"1:				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	(%2), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"movq	(%1), %%mm2		\n\t"
-	"movq	8(%2), %%mm3		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGBP(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
-	"movq	%%mm4, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movq	%%mm5, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	16(%2), %%mm1		\n\t"
-	"add	%4, %1			\n\t"
-	"movq	(%1), %%mm2		\n\t"
-	"movq	24(%2), %%mm3		\n\t"
-	"add	%4, %1			\n\t"
-	"add	$32, %2			\n\t"
-	PAVGBP(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
-	"movq	%%mm4, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movq	%%mm5, (%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"subl	$4, %0			\n\t"
-	"jnz	1b			\n\t"
-#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
-        :"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#else
-        :"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#endif
-	:"S"((long)src1Stride), "D"((long)dstStride)
-	:"memory");
-}
-
-static void DEF(put, pixels16_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    MOVQ_BFE(mm6);
-    __asm __volatile(
-	"lea	(%3, %3), %%"REG_a"	\n\t"
-	".balign 8			\n\t"
-	"1:				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	1(%1), %%mm1		\n\t"
-	"movq	(%1, %3), %%mm2		\n\t"
-	"movq	1(%1, %3), %%mm3	\n\t"
-	PAVGBP(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
-	"movq	%%mm4, (%2)		\n\t"
-	"movq	%%mm5, (%2, %3)		\n\t"
-	"movq	8(%1), %%mm0		\n\t"
-	"movq	9(%1), %%mm1		\n\t"
-	"movq	8(%1, %3), %%mm2	\n\t"
-	"movq	9(%1, %3), %%mm3	\n\t"
-	PAVGBP(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
-	"movq	%%mm4, 8(%2)		\n\t"
-	"movq	%%mm5, 8(%2, %3)	\n\t"
-	"add	%%"REG_a", %1		\n\t"
-	"add	%%"REG_a", %2		\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	1(%1), %%mm1		\n\t"
-	"movq	(%1, %3), %%mm2		\n\t"
-	"movq	1(%1, %3), %%mm3	\n\t"
-	PAVGBP(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
-	"movq	%%mm4, (%2)		\n\t"
-	"movq	%%mm5, (%2, %3)		\n\t"
-	"movq	8(%1), %%mm0		\n\t"
-	"movq	9(%1), %%mm1		\n\t"
-	"movq	8(%1, %3), %%mm2	\n\t"
-	"movq	9(%1, %3), %%mm3	\n\t"
-	PAVGBP(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
-	"movq	%%mm4, 8(%2)		\n\t"
-	"movq	%%mm5, 8(%2, %3)	\n\t"
-	"add	%%"REG_a", %1		\n\t"
-	"add	%%"REG_a", %2		\n\t"
-	"subl	$4, %0			\n\t"
-	"jnz	1b			\n\t"
-	:"+g"(h), "+S"(pixels), "+D"(block)
-	:"r"((long)line_size)
-	:REG_a, "memory");
-}
-
-static void attribute_unused DEF(put, pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
-    MOVQ_BFE(mm6);
-    __asm __volatile(
-	"testl $1, %0			\n\t"
-        " jz 1f				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	(%2), %%mm1		\n\t"
-	"movq	8(%1), %%mm2		\n\t"
-	"movq	8(%2), %%mm3		\n\t"
-	"add	%4, %1			\n\t"
-	"add	$16, %2			\n\t"
-	PAVGBP(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
-	"movq	%%mm4, (%3)		\n\t"
-	"movq	%%mm5, 8(%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"decl	%0			\n\t"
-	".balign 8			\n\t"
-	"1:				\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	(%2), %%mm1		\n\t"
-	"movq	8(%1), %%mm2		\n\t"
-	"movq	8(%2), %%mm3		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGBP(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
-	"movq	%%mm4, (%3)		\n\t"
-	"movq	%%mm5, 8(%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	"movq	16(%2), %%mm1		\n\t"
-	"movq	8(%1), %%mm2		\n\t"
-	"movq	24(%2), %%mm3		\n\t"
-	"add	%4, %1			\n\t"
-	PAVGBP(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
-	"movq	%%mm4, (%3)		\n\t"
-	"movq	%%mm5, 8(%3)		\n\t"
-	"add	%5, %3			\n\t"
-	"add	$32, %2			\n\t"
-	"subl	$2, %0			\n\t"
-	"jnz	1b			\n\t"
-#ifdef PIC //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cant be used
-	:"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#else
-	:"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#endif
-	:"S"((long)src1Stride), "D"((long)dstStride)
-	:"memory"); 
-}
-
-static void DEF(put, pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    MOVQ_BFE(mm6);
-    __asm __volatile(
-	"lea (%3, %3), %%"REG_a"	\n\t"
-	"movq (%1), %%mm0		\n\t"
-	".balign 8			\n\t"
-	"1:				\n\t"
-	"movq	(%1, %3), %%mm1		\n\t"
-	"movq	(%1, %%"REG_a"),%%mm2	\n\t"
-	PAVGBP(%%mm1, %%mm0, %%mm4,   %%mm2, %%mm1, %%mm5)
-	"movq	%%mm4, (%2)		\n\t"
-	"movq	%%mm5, (%2, %3)		\n\t"
-	"add	%%"REG_a", %1		\n\t"
-	"add	%%"REG_a", %2		\n\t"
-	"movq	(%1, %3), %%mm1		\n\t"
-	"movq	(%1, %%"REG_a"),%%mm0	\n\t"
-	PAVGBP(%%mm1, %%mm2, %%mm4,   %%mm0, %%mm1, %%mm5)
-	"movq	%%mm4, (%2)		\n\t"
-	"movq	%%mm5, (%2, %3)		\n\t"
-	"add	%%"REG_a", %1		\n\t"
-	"add	%%"REG_a", %2		\n\t"
-	"subl	$4, %0			\n\t"
-	"jnz	1b			\n\t"
-	:"+g"(h), "+S"(pixels), "+D"(block)
-	:"r"((long)line_size)
-	:REG_a, "memory");
-}
-
-static void DEF(put, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    MOVQ_ZERO(mm7);
-    SET_RND(mm6); // =2 for rnd  and  =1 for no_rnd version
-    __asm __volatile(
-	"movq	(%1), %%mm0		\n\t"
-	"movq	1(%1), %%mm4		\n\t"
-	"movq	%%mm0, %%mm1		\n\t"
-	"movq	%%mm4, %%mm5		\n\t"
-	"punpcklbw %%mm7, %%mm0		\n\t"
-	"punpcklbw %%mm7, %%mm4		\n\t"
-	"punpckhbw %%mm7, %%mm1		\n\t"
-	"punpckhbw %%mm7, %%mm5		\n\t"
-	"paddusw %%mm0, %%mm4		\n\t"
-	"paddusw %%mm1, %%mm5		\n\t"
-	"xor	%%"REG_a", %%"REG_a"	\n\t"
-	"add	%3, %1			\n\t"
-	".balign 8      		\n\t"
-	"1:				\n\t"
-	"movq	(%1, %%"REG_a"), %%mm0	\n\t"
-	"movq	1(%1, %%"REG_a"), %%mm2	\n\t"
-	"movq	%%mm0, %%mm1		\n\t"
-	"movq	%%mm2, %%mm3		\n\t"
-	"punpcklbw %%mm7, %%mm0		\n\t"
-	"punpcklbw %%mm7, %%mm2		\n\t"
-	"punpckhbw %%mm7, %%mm1		\n\t"
-	"punpckhbw %%mm7, %%mm3		\n\t"
-	"paddusw %%mm2, %%mm0	 	\n\t"
-	"paddusw %%mm3, %%mm1		\n\t"
-	"paddusw %%mm6, %%mm4		\n\t"
-	"paddusw %%mm6, %%mm5		\n\t"
-	"paddusw %%mm0, %%mm4		\n\t"
-	"paddusw %%mm1, %%mm5		\n\t"
-	"psrlw	$2, %%mm4		\n\t"
-	"psrlw	$2, %%mm5		\n\t"
-	"packuswb  %%mm5, %%mm4		\n\t"
-	"movq	%%mm4, (%2, %%"REG_a")	\n\t"
-	"add	%3, %%"REG_a"		\n\t"
-
-	"movq	(%1, %%"REG_a"), %%mm2	\n\t" // 0 <-> 2   1 <-> 3
-	"movq	1(%1, %%"REG_a"), %%mm4	\n\t"
-	"movq	%%mm2, %%mm3		\n\t"
-	"movq	%%mm4, %%mm5		\n\t"
-	"punpcklbw %%mm7, %%mm2		\n\t"
-	"punpcklbw %%mm7, %%mm4		\n\t"
-	"punpckhbw %%mm7, %%mm3		\n\t"
-	"punpckhbw %%mm7, %%mm5		\n\t"
-	"paddusw %%mm2, %%mm4	 	\n\t"
-	"paddusw %%mm3, %%mm5		\n\t"
-	"paddusw %%mm6, %%mm0		\n\t"
-	"paddusw %%mm6, %%mm1		\n\t"
-	"paddusw %%mm4, %%mm0		\n\t"
-	"paddusw %%mm5, %%mm1		\n\t"
-	"psrlw	$2, %%mm0		\n\t"
-	"psrlw	$2, %%mm1		\n\t"
-	"packuswb  %%mm1, %%mm0		\n\t"
-	"movq	%%mm0, (%2, %%"REG_a")	\n\t"
-	"add	%3, %%"REG_a"		\n\t"
-
-	"subl	$2, %0			\n\t"
-	"jnz	1b			\n\t"
-	:"+g"(h), "+S"(pixels)
-	:"D"(block), "r"((long)line_size)
-	:REG_a, "memory");
-}
-
-// avg_pixels
-static void attribute_unused DEF(avg, pixels4)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    MOVQ_BFE(mm6);
-    JUMPALIGN();
-    do {
-	__asm __volatile(
-	     "movd  %0, %%mm0		\n\t"
-	     "movd  %1, %%mm1		\n\t"
-	     PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-	     "movd  %%mm2, %0		\n\t"
-	     :"+m"(*block)
-	     :"m"(*pixels)
-	     :"memory");
-	pixels += line_size;
-	block += line_size;
-    }
-    while (--h);
-}
-
-// in case more speed is needed - unroling would certainly help
-static void DEF(avg, pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    MOVQ_BFE(mm6);
-    JUMPALIGN();
-    do {
-	__asm __volatile(
-	     "movq  %0, %%mm0		\n\t"
-	     "movq  %1, %%mm1		\n\t"
-	     PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-	     "movq  %%mm2, %0		\n\t"
-	     :"+m"(*block)
-	     :"m"(*pixels)
-	     :"memory");
-	pixels += line_size;
-	block += line_size;
-    }
-    while (--h);
-}
-
-static void DEF(avg, pixels16)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    MOVQ_BFE(mm6);
-    JUMPALIGN();
-    do {
-	__asm __volatile(
-	     "movq  %0, %%mm0		\n\t"
-	     "movq  %1, %%mm1		\n\t"
-	     PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-	     "movq  %%mm2, %0		\n\t"
-	     "movq  8%0, %%mm0		\n\t"
-	     "movq  8%1, %%mm1		\n\t"
-	     PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-	     "movq  %%mm2, 8%0		\n\t"
-	     :"+m"(*block)
-	     :"m"(*pixels)
-	     :"memory");
-	pixels += line_size;
-	block += line_size;
-    }
-    while (--h);
-}
-
-static void DEF(avg, pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    MOVQ_BFE(mm6);
-    JUMPALIGN();
-    do {
-	__asm __volatile(
-	    "movq  %1, %%mm0		\n\t"
-	    "movq  1%1, %%mm1		\n\t"
-	    "movq  %0, %%mm3		\n\t"
-	    PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-	    PAVGB(%%mm3, %%mm2, %%mm0, %%mm6)
-	    "movq  %%mm0, %0		\n\t"
-	    :"+m"(*block)
-	    :"m"(*pixels)
-	    :"memory");
-	pixels += line_size;
-	block += line_size;
-    } while (--h);
-}
-
-static __attribute__((unused)) void DEF(avg, pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
-    MOVQ_BFE(mm6);
-    JUMPALIGN();
-    do {
-	__asm __volatile(
-	    "movq  %1, %%mm0		\n\t"
-	    "movq  %2, %%mm1		\n\t"
-	    "movq  %0, %%mm3		\n\t"
-	    PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-	    PAVGB(%%mm3, %%mm2, %%mm0, %%mm6)
-	    "movq  %%mm0, %0		\n\t"
-	    :"+m"(*dst)
-	    :"m"(*src1), "m"(*src2)
-	    :"memory");
-	dst += dstStride;
-        src1 += src1Stride;
-        src2 += 8;
-    } while (--h);
-}
-
-static void DEF(avg, pixels16_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    MOVQ_BFE(mm6);
-    JUMPALIGN();
-    do {
-	__asm __volatile(
-	    "movq  %1, %%mm0		\n\t"
-	    "movq  1%1, %%mm1		\n\t"
-	    "movq  %0, %%mm3		\n\t"
-	    PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-	    PAVGB(%%mm3, %%mm2, %%mm0, %%mm6)
-	    "movq  %%mm0, %0		\n\t"
-	    "movq  8%1, %%mm0		\n\t"
-	    "movq  9%1, %%mm1		\n\t"
-	    "movq  8%0, %%mm3		\n\t"
-	    PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-	    PAVGB(%%mm3, %%mm2, %%mm0, %%mm6)
-	    "movq  %%mm0, 8%0		\n\t"
-	    :"+m"(*block)
-	    :"m"(*pixels)
-	    :"memory");
-	pixels += line_size;
-	block += line_size;
-    } while (--h);
-}
-
-static __attribute__((unused)) void DEF(avg, pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
-    MOVQ_BFE(mm6);
-    JUMPALIGN();
-    do {
-	__asm __volatile(
-	    "movq  %1, %%mm0		\n\t"
-	    "movq  %2, %%mm1		\n\t"
-	    "movq  %0, %%mm3		\n\t"
-	    PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-	    PAVGB(%%mm3, %%mm2, %%mm0, %%mm6)
-	    "movq  %%mm0, %0		\n\t"
-	    "movq  8%1, %%mm0		\n\t"
-	    "movq  8%2, %%mm1		\n\t"
-	    "movq  8%0, %%mm3		\n\t"
-	    PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
-	    PAVGB(%%mm3, %%mm2, %%mm0, %%mm6)
-	    "movq  %%mm0, 8%0		\n\t"
-	    :"+m"(*dst)
-	    :"m"(*src1), "m"(*src2)
-	    :"memory");
-	dst += dstStride;
-        src1 += src1Stride;
-        src2 += 16;
-    } while (--h);
-}
-
-static void DEF(avg, pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    MOVQ_BFE(mm6);
-    __asm __volatile(
-	"lea	(%3, %3), %%"REG_a"	\n\t"
-	"movq	(%1), %%mm0		\n\t"
-	".balign 8			\n\t"
-	"1:				\n\t"
-	"movq	(%1, %3), %%mm1		\n\t"
-	"movq	(%1, %%"REG_a"), %%mm2	\n\t"
-	PAVGBP(%%mm1, %%mm0, %%mm4,   %%mm2, %%mm1, %%mm5)
-	"movq	(%2), %%mm3		\n\t"
-	PAVGB(%%mm3, %%mm4, %%mm0, %%mm6)
-	"movq	(%2, %3), %%mm3		\n\t"
-	PAVGB(%%mm3, %%mm5, %%mm1, %%mm6)
-	"movq	%%mm0, (%2)		\n\t"
-	"movq	%%mm1, (%2, %3)		\n\t"
-	"add	%%"REG_a", %1		\n\t"
-	"add	%%"REG_a", %2		\n\t"
-
-	"movq	(%1, %3), %%mm1		\n\t"
-	"movq	(%1, %%"REG_a"), %%mm0	\n\t"
-	PAVGBP(%%mm1, %%mm2, %%mm4,   %%mm0, %%mm1, %%mm5)
-	"movq	(%2), %%mm3		\n\t"
-	PAVGB(%%mm3, %%mm4, %%mm2, %%mm6)
-	"movq	(%2, %3), %%mm3		\n\t"
-	PAVGB(%%mm3, %%mm5, %%mm1, %%mm6)
-	"movq	%%mm2, (%2)		\n\t"
-	"movq	%%mm1, (%2, %3)		\n\t"
-	"add	%%"REG_a", %1		\n\t"
-	"add	%%"REG_a", %2		\n\t"
-
-	"subl	$4, %0			\n\t"
-	"jnz	1b			\n\t"
-	:"+g"(h), "+S"(pixels), "+D"(block)
-	:"r"((long)line_size)
-	:REG_a, "memory");
-}
-
-// this routine is 'slightly' suboptimal but mostly unused
-static void DEF(avg, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-    MOVQ_ZERO(mm7);
-    SET_RND(mm6); // =2 for rnd  and  =1 for no_rnd version
-    __asm __volatile(
-	"movq	(%1), %%mm0		\n\t"
-	"movq	1(%1), %%mm4		\n\t"
-	"movq	%%mm0, %%mm1		\n\t"
-	"movq	%%mm4, %%mm5		\n\t"
-	"punpcklbw %%mm7, %%mm0		\n\t"
-	"punpcklbw %%mm7, %%mm4		\n\t"
-	"punpckhbw %%mm7, %%mm1		\n\t"
-	"punpckhbw %%mm7, %%mm5		\n\t"
-	"paddusw %%mm0, %%mm4		\n\t"
-	"paddusw %%mm1, %%mm5		\n\t"
-	"xor	%%"REG_a", %%"REG_a"	\n\t"
-	"add	%3, %1			\n\t"
-	".balign 8			\n\t"
-	"1:				\n\t"
-	"movq	(%1, %%"REG_a"), %%mm0	\n\t"
-	"movq	1(%1, %%"REG_a"), %%mm2	\n\t"
-	"movq	%%mm0, %%mm1		\n\t"
-	"movq	%%mm2, %%mm3		\n\t"
-	"punpcklbw %%mm7, %%mm0		\n\t"
-	"punpcklbw %%mm7, %%mm2		\n\t"
-	"punpckhbw %%mm7, %%mm1		\n\t"
-	"punpckhbw %%mm7, %%mm3		\n\t"
-	"paddusw %%mm2, %%mm0	 	\n\t"
-	"paddusw %%mm3, %%mm1		\n\t"
-	"paddusw %%mm6, %%mm4		\n\t"
-	"paddusw %%mm6, %%mm5		\n\t"
-	"paddusw %%mm0, %%mm4		\n\t"
-	"paddusw %%mm1, %%mm5		\n\t"
-	"psrlw	$2, %%mm4		\n\t"
-	"psrlw	$2, %%mm5		\n\t"
-		"movq	(%2, %%"REG_a"), %%mm3	\n\t"
-	"packuswb  %%mm5, %%mm4		\n\t"
-		"pcmpeqd %%mm2, %%mm2	\n\t"
-		"paddb %%mm2, %%mm2	\n\t"
-		PAVGB(%%mm3, %%mm4, %%mm5, %%mm2)
-		"movq	%%mm5, (%2, %%"REG_a")	\n\t"
-	"add	%3, %%"REG_a"		\n\t"
-
-	"movq	(%1, %%"REG_a"), %%mm2	\n\t" // 0 <-> 2   1 <-> 3
-	"movq	1(%1, %%"REG_a"), %%mm4	\n\t"
-	"movq	%%mm2, %%mm3		\n\t"
-	"movq	%%mm4, %%mm5		\n\t"
-	"punpcklbw %%mm7, %%mm2		\n\t"
-	"punpcklbw %%mm7, %%mm4		\n\t"
-	"punpckhbw %%mm7, %%mm3		\n\t"
-	"punpckhbw %%mm7, %%mm5		\n\t"
-	"paddusw %%mm2, %%mm4	 	\n\t"
-	"paddusw %%mm3, %%mm5		\n\t"
-	"paddusw %%mm6, %%mm0		\n\t"
-	"paddusw %%mm6, %%mm1		\n\t"
-	"paddusw %%mm4, %%mm0		\n\t"
-	"paddusw %%mm5, %%mm1		\n\t"
-	"psrlw	$2, %%mm0		\n\t"
-	"psrlw	$2, %%mm1		\n\t"
-		"movq	(%2, %%"REG_a"), %%mm3	\n\t"
-	"packuswb  %%mm1, %%mm0		\n\t"
-		"pcmpeqd %%mm2, %%mm2	\n\t"
-		"paddb %%mm2, %%mm2	\n\t"
-		PAVGB(%%mm3, %%mm0, %%mm1, %%mm2)
-		"movq	%%mm1, (%2, %%"REG_a")	\n\t"
-	"add	%3, %%"REG_a"		\n\t"
-
-	"subl	$2, %0			\n\t"
-	"jnz	1b			\n\t"
-	:"+g"(h), "+S"(pixels)
-	:"D"(block), "r"((long)line_size)
-	:REG_a, "memory");
-}
-
-//FIXME optimize
-static void DEF(put, pixels16_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
-    DEF(put, pixels8_y2)(block  , pixels  , line_size, h);
-    DEF(put, pixels8_y2)(block+8, pixels+8, line_size, h);
-}
-
-static void DEF(put, pixels16_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
-    DEF(put, pixels8_xy2)(block  , pixels  , line_size, h);
-    DEF(put, pixels8_xy2)(block+8, pixels+8, line_size, h);
-}
-
-static void DEF(avg, pixels16_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
-    DEF(avg, pixels8_y2)(block  , pixels  , line_size, h);
-    DEF(avg, pixels8_y2)(block+8, pixels+8, line_size, h);
-}
-
-static void DEF(avg, pixels16_xy2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){
-    DEF(avg, pixels8_xy2)(block  , pixels  , line_size, h);
-    DEF(avg, pixels8_xy2)(block+8, pixels+8, line_size, h);
-}
-
-
diff --git a/ffmpeg.src/libavcodec/i386/fdct_mmx.c b/ffmpeg.src/libavcodec/i386/fdct_mmx.c
deleted file mode 100644
index 6a13090..0000000
--- a/ffmpeg.src/libavcodec/i386/fdct_mmx.c
+++ /dev/null
@@ -1,562 +0,0 @@
-/*
- * MMX optimized forward DCT
- * The gcc porting is Copyright (c) 2001 Fabrice Bellard.
- * cleanup/optimizations are Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
- * SSE2 optimization is Copyright (c) 2004 Denes Balatoni.
- *
- * from  fdctam32.c - AP922 MMX(3D-Now) forward-DCT
- * 
- *  Intel Application Note AP-922 - fast, precise implementation of DCT
- *        http://developer.intel.com/vtune/cbts/appnotes.htm
- *
- * Also of inspiration:
- * a page about fdct at http://www.geocities.com/ssavekar/dct.htm
- * Skal's fdct at http://skal.planet-d.net/coding/dct.html
- */
-#include "common.h"
-#include "../dsputil.h"
-#include "mmx.h"
-
-#define ATTR_ALIGN(align) __attribute__ ((__aligned__ (align)))
-
-//////////////////////////////////////////////////////////////////////
-//
-// constants for the forward DCT
-// -----------------------------
-//
-// Be sure to check that your compiler is aligning all constants to QWORD
-// (8-byte) memory boundaries!  Otherwise the unaligned memory access will
-// severely stall MMX execution.
-//
-//////////////////////////////////////////////////////////////////////
-
-#define BITS_FRW_ACC	3 //; 2 or 3 for accuracy
-#define SHIFT_FRW_COL	BITS_FRW_ACC
-#define SHIFT_FRW_ROW	(BITS_FRW_ACC + 17 - 3)
-#define RND_FRW_ROW		(1 << (SHIFT_FRW_ROW-1))
-//#define RND_FRW_COL		(1 << (SHIFT_FRW_COL-1))
-
-//concatenated table, for forward DCT transformation
-static const int16_t fdct_tg_all_16[] ATTR_ALIGN(8) = {
-    13036, 13036, 13036, 13036,		// tg * (2<<16) + 0.5
-    27146, 27146, 27146, 27146,		// tg * (2<<16) + 0.5
-    -21746, -21746, -21746, -21746,	// tg * (2<<16) + 0.5
-};
-
-static const int16_t ocos_4_16[4] ATTR_ALIGN(8) = {
-    23170, 23170, 23170, 23170,	//cos * (2<<15) + 0.5
-};
-
-static const int64_t fdct_one_corr ATTR_ALIGN(8) = 0x0001000100010001LL;
-
-static const int32_t fdct_r_row[2] ATTR_ALIGN(8) = {RND_FRW_ROW, RND_FRW_ROW };
-
-struct 
-{
- const int32_t fdct_r_row_sse2[4] ATTR_ALIGN(16);
-} fdct_r_row_sse2 ATTR_ALIGN(16)=
-{{
- RND_FRW_ROW, RND_FRW_ROW, RND_FRW_ROW, RND_FRW_ROW
-}};
-//static const long fdct_r_row_sse2[4] ATTR_ALIGN(16) = {RND_FRW_ROW, RND_FRW_ROW, RND_FRW_ROW, RND_FRW_ROW};
-
-static const int16_t tab_frw_01234567[] ATTR_ALIGN(8) = {  // forward_dct coeff table
-  16384,   16384,   22725,   19266, 
-  16384,   16384,   12873,    4520, 
-  21407,    8867,   19266,   -4520, 
-  -8867,  -21407,  -22725,  -12873, 
-  16384,  -16384,   12873,  -22725, 
- -16384,   16384,    4520,   19266, 
-   8867,  -21407,    4520,  -12873, 
-  21407,   -8867,   19266,  -22725, 
-
-  22725,   22725,   31521,   26722, 
-  22725,   22725,   17855,    6270, 
-  29692,   12299,   26722,   -6270, 
- -12299,  -29692,  -31521,  -17855, 
-  22725,  -22725,   17855,  -31521, 
- -22725,   22725,    6270,   26722, 
-  12299,  -29692,    6270,  -17855, 
-  29692,  -12299,   26722,  -31521, 
-
-  21407,   21407,   29692,   25172, 
-  21407,   21407,   16819,    5906, 
-  27969,   11585,   25172,   -5906, 
- -11585,  -27969,  -29692,  -16819, 
-  21407,  -21407,   16819,  -29692, 
- -21407,   21407,    5906,   25172, 
-  11585,  -27969,    5906,  -16819, 
-  27969,  -11585,   25172,  -29692, 
-
-  19266,   19266,   26722,   22654, 
-  19266,   19266,   15137,    5315, 
-  25172,   10426,   22654,   -5315, 
- -10426,  -25172,  -26722,  -15137, 
-  19266,  -19266,   15137,  -26722, 
- -19266,   19266,    5315,   22654, 
-  10426,  -25172,    5315,  -15137, 
-  25172,  -10426,   22654,  -26722, 
-
-  16384,   16384,   22725,   19266, 
-  16384,   16384,   12873,    4520, 
-  21407,    8867,   19266,   -4520, 
-  -8867,  -21407,  -22725,  -12873, 
-  16384,  -16384,   12873,  -22725, 
- -16384,   16384,    4520,   19266, 
-   8867,  -21407,    4520,  -12873, 
-  21407,   -8867,   19266,  -22725, 
-
-  19266,   19266,   26722,   22654, 
-  19266,   19266,   15137,    5315, 
-  25172,   10426,   22654,   -5315, 
- -10426,  -25172,  -26722,  -15137, 
-  19266,  -19266,   15137,  -26722, 
- -19266,   19266,    5315,   22654, 
-  10426,  -25172,    5315,  -15137, 
-  25172,  -10426,   22654,  -26722, 
-
-  21407,   21407,   29692,   25172, 
-  21407,   21407,   16819,    5906, 
-  27969,   11585,   25172,   -5906, 
- -11585,  -27969,  -29692,  -16819, 
-  21407,  -21407,   16819,  -29692, 
- -21407,   21407,    5906,   25172, 
-  11585,  -27969,    5906,  -16819, 
-  27969,  -11585,   25172,  -29692, 
-
-  22725,   22725,   31521,   26722, 
-  22725,   22725,   17855,    6270, 
-  29692,   12299,   26722,   -6270, 
- -12299,  -29692,  -31521,  -17855, 
-  22725,  -22725,   17855,  -31521, 
- -22725,   22725,    6270,   26722, 
-  12299,  -29692,    6270,  -17855, 
-  29692,  -12299,   26722,  -31521, 
-};
-
-struct 
-{
- const int16_t tab_frw_01234567_sse2[256] ATTR_ALIGN(16);
-} tab_frw_01234567_sse2 ATTR_ALIGN(16) =
-{{
-//static const int16_t tab_frw_01234567_sse2[] ATTR_ALIGN(16) = {  // forward_dct coeff table  
-#define TABLE_SSE2 C4,  C4,  C1,  C3, -C6, -C2, -C1, -C5, \
-                   C4,  C4,  C5,  C7,  C2,  C6,  C3, -C7, \
-                  -C4,  C4,  C7,  C3,  C6, -C2,  C7, -C5, \
-                   C4, -C4,  C5, -C1,  C2, -C6,  C3, -C1, 
-// c1..c7 * cos(pi/4) * 2^15 
-#define C1 22725
-#define C2 21407
-#define C3 19266
-#define C4 16384
-#define C5 12873
-#define C6 8867
-#define C7 4520
-TABLE_SSE2
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#define C1 31521
-#define C2 29692
-#define C3 26722
-#define C4 22725
-#define C5 17855
-#define C6 12299
-#define C7 6270
-TABLE_SSE2
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#define C1 29692
-#define C2 27969
-#define C3 25172
-#define C4 21407
-#define C5 16819
-#define C6 11585
-#define C7 5906
-TABLE_SSE2
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#define C1 26722
-#define C2 25172
-#define C3 22654
-#define C4 19266
-#define C5 15137
-#define C6 10426
-#define C7 5315
-TABLE_SSE2
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#define C1 22725
-#define C2 21407
-#define C3 19266
-#define C4 16384
-#define C5 12873
-#define C6 8867
-#define C7 4520
-TABLE_SSE2
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#define C1 26722
-#define C2 25172
-#define C3 22654
-#define C4 19266
-#define C5 15137
-#define C6 10426
-#define C7 5315
-TABLE_SSE2
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#define C1 29692
-#define C2 27969
-#define C3 25172
-#define C4 21407
-#define C5 16819
-#define C6 11585
-#define C7 5906
-TABLE_SSE2
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#define C1 31521
-#define C2 29692
-#define C3 26722
-#define C4 22725
-#define C5 17855
-#define C6 12299
-#define C7 6270
-TABLE_SSE2
-}};
-
-
-static always_inline void fdct_col(const int16_t *in, int16_t *out, int offset)
-{
-    movq_m2r(*(in + offset + 1 * 8), mm0);
-    movq_m2r(*(in + offset + 6 * 8), mm1);
-    movq_r2r(mm0, mm2);
-    movq_m2r(*(in + offset + 2 * 8), mm3);
-    paddsw_r2r(mm1, mm0);
-    movq_m2r(*(in + offset + 5 * 8), mm4);
-    psllw_i2r(SHIFT_FRW_COL, mm0);
-    movq_m2r(*(in + offset + 0 * 8), mm5);
-    paddsw_r2r(mm3, mm4);
-    paddsw_m2r(*(in + offset + 7 * 8), mm5);
-    psllw_i2r(SHIFT_FRW_COL, mm4);
-    movq_r2r(mm0, mm6);
-    psubsw_r2r(mm1, mm2);
-    movq_m2r(*(fdct_tg_all_16 + 4), mm1);
-    psubsw_r2r(mm4, mm0);
-    movq_m2r(*(in + offset + 3 * 8), mm7);
-    pmulhw_r2r(mm0, mm1);
-    paddsw_m2r(*(in + offset + 4 * 8), mm7);
-    psllw_i2r(SHIFT_FRW_COL, mm5);
-    paddsw_r2r(mm4, mm6);
-    psllw_i2r(SHIFT_FRW_COL, mm7);
-    movq_r2r(mm5, mm4);
-    psubsw_r2r(mm7, mm5);
-    paddsw_r2r(mm5, mm1);
-    paddsw_r2r(mm7, mm4);
-    por_m2r(fdct_one_corr, mm1);
-    psllw_i2r(SHIFT_FRW_COL + 1, mm2);
-    pmulhw_m2r(*(fdct_tg_all_16 + 4), mm5);
-    movq_r2r(mm4, mm7);
-    psubsw_m2r(*(in + offset + 5 * 8), mm3);
-    psubsw_r2r(mm6, mm4);
-    movq_r2m(mm1, *(out + offset + 2 * 8));
-    paddsw_r2r(mm6, mm7);
-    movq_m2r(*(in + offset + 3 * 8), mm1);
-    psllw_i2r(SHIFT_FRW_COL + 1, mm3);
-    psubsw_m2r(*(in + offset + 4 * 8), mm1);
-    movq_r2r(mm2, mm6);
-    movq_r2m(mm4, *(out + offset + 4 * 8));
-    paddsw_r2r(mm3, mm2);
-    pmulhw_m2r(*ocos_4_16, mm2);
-    psubsw_r2r(mm3, mm6);
-    pmulhw_m2r(*ocos_4_16, mm6);
-    psubsw_r2r(mm0, mm5);
-    por_m2r(fdct_one_corr, mm5);
-    psllw_i2r(SHIFT_FRW_COL, mm1);
-    por_m2r(fdct_one_corr, mm2);
-    movq_r2r(mm1, mm4);
-    movq_m2r(*(in + offset + 0 * 8), mm3);
-    paddsw_r2r(mm6, mm1);
-    psubsw_m2r(*(in + offset + 7 * 8), mm3);
-    psubsw_r2r(mm6, mm4);
-    movq_m2r(*(fdct_tg_all_16 + 0), mm0);
-    psllw_i2r(SHIFT_FRW_COL, mm3);
-    movq_m2r(*(fdct_tg_all_16 + 8), mm6);
-    pmulhw_r2r(mm1, mm0);
-    movq_r2m(mm7, *(out + offset + 0 * 8));
-    pmulhw_r2r(mm4, mm6);
-    movq_r2m(mm5, *(out + offset + 6 * 8));
-    movq_r2r(mm3, mm7);
-    movq_m2r(*(fdct_tg_all_16 + 8), mm5);
-    psubsw_r2r(mm2, mm7);
-    paddsw_r2r(mm2, mm3);
-    pmulhw_r2r(mm7, mm5);
-    paddsw_r2r(mm3, mm0);
-    paddsw_r2r(mm4, mm6);
-    pmulhw_m2r(*(fdct_tg_all_16 + 0), mm3);
-    por_m2r(fdct_one_corr, mm0);
-    paddsw_r2r(mm7, mm5);
-    psubsw_r2r(mm6, mm7);
-    movq_r2m(mm0, *(out + offset + 1 * 8));
-    paddsw_r2r(mm4, mm5);
-    movq_r2m(mm7, *(out + offset + 3 * 8));
-    psubsw_r2r(mm1, mm3);
-    movq_r2m(mm5, *(out + offset + 5 * 8));
-    movq_r2m(mm3, *(out + offset + 7 * 8));
-}
-
-
-static always_inline void fdct_row_sse2(const int16_t *in, int16_t *out)
-{
-    asm volatile(
-        ".macro FDCT_ROW_SSE2_H1 i t   \n\t"
-	"movq      \\i(%0), %%xmm2     \n\t"
-	"movq      \\i+8(%0), %%xmm0   \n\t"
-	"movdqa    \\t+32(%1), %%xmm3  \n\t"
-	"movdqa    \\t+48(%1), %%xmm7  \n\t"	
-	"movdqa    \\t(%1), %%xmm4     \n\t"
-	"movdqa    \\t+16(%1), %%xmm5  \n\t"	
-	".endm                         \n\t"
-        ".macro FDCT_ROW_SSE2_H2 i t   \n\t"
-	"movq      \\i(%0), %%xmm2     \n\t"
-	"movq      \\i+8(%0), %%xmm0   \n\t"
-	"movdqa    \\t+32(%1), %%xmm3  \n\t"
-	"movdqa    \\t+48(%1), %%xmm7  \n\t"	
-	".endm                         \n\t"
-	".macro FDCT_ROW_SSE2 i        \n\t"	
-	"movq      %%xmm2, %%xmm1      \n\t"
-	"pshuflw   $27, %%xmm0, %%xmm0 \n\t"
-	"paddsw    %%xmm0, %%xmm1      \n\t"
-	"psubsw    %%xmm0, %%xmm2      \n\t"
-	"punpckldq %%xmm2, %%xmm1      \n\t"
-	"pshufd    $78, %%xmm1, %%xmm2 \n\t"
-	"pmaddwd   %%xmm2, %%xmm3      \n\t"
-	"pmaddwd   %%xmm1, %%xmm7      \n\t"
-	"pmaddwd   %%xmm5, %%xmm2      \n\t"
-	"pmaddwd   %%xmm4, %%xmm1      \n\t"
-	"paddd     %%xmm7, %%xmm3      \n\t"	
-	"paddd     %%xmm2, %%xmm1      \n\t"
-	"paddd     %%xmm6, %%xmm3      \n\t"
-	"paddd     %%xmm6, %%xmm1      \n\t"
-	"psrad     %3, %%xmm3          \n\t"
-	"psrad     %3, %%xmm1          \n\t"
-	"packssdw  %%xmm3, %%xmm1      \n\t"
-	"movdqa    %%xmm1, \\i(%4)     \n\t"
-	".endm                         \n\t"	
-	"movdqa    (%2), %%xmm6        \n\t"		
-	"FDCT_ROW_SSE2_H1 0 0 \n\t"
-	"FDCT_ROW_SSE2 0 \n\t"
-	"FDCT_ROW_SSE2_H2 64 0 \n\t"
-	"FDCT_ROW_SSE2 64 \n\t"
-
-	"FDCT_ROW_SSE2_H1 16 64 \n\t"
-	"FDCT_ROW_SSE2 16 \n\t"
-	"FDCT_ROW_SSE2_H2 112 64 \n\t"
-	"FDCT_ROW_SSE2 112 \n\t"
-
-	"FDCT_ROW_SSE2_H1 32 128 \n\t"
-	"FDCT_ROW_SSE2 32 \n\t"
-	"FDCT_ROW_SSE2_H2 96 128 \n\t"
-	"FDCT_ROW_SSE2 96 \n\t"
-
-	"FDCT_ROW_SSE2_H1 48 192 \n\t"
-	"FDCT_ROW_SSE2 48 \n\t"
-	"FDCT_ROW_SSE2_H2 80 192 \n\t"
-	"FDCT_ROW_SSE2 80 \n\t"
-	:
-	: "r" (in), "r" (tab_frw_01234567_sse2.tab_frw_01234567_sse2), "r" (fdct_r_row_sse2.fdct_r_row_sse2), "i" (SHIFT_FRW_ROW), "r" (out)
-    );
-}
-
-static always_inline void fdct_row_mmx2(const int16_t *in, int16_t *out, const int16_t *table)
-{ 
-    pshufw_m2r(*(in + 4), mm5, 0x1B);
-    movq_m2r(*(in + 0), mm0);
-    movq_r2r(mm0, mm1);
-    paddsw_r2r(mm5, mm0);
-    psubsw_r2r(mm5, mm1);
-    movq_r2r(mm0, mm2);
-    punpckldq_r2r(mm1, mm0);
-    punpckhdq_r2r(mm1, mm2);
-    movq_m2r(*(table + 0), mm1);
-    movq_m2r(*(table + 4), mm3);
-    movq_m2r(*(table + 8), mm4);
-    movq_m2r(*(table + 12), mm5);
-    movq_m2r(*(table + 16), mm6);
-    movq_m2r(*(table + 20), mm7);
-    pmaddwd_r2r(mm0, mm1);
-    pmaddwd_r2r(mm2, mm3);
-    pmaddwd_r2r(mm0, mm4);
-    pmaddwd_r2r(mm2, mm5);
-    pmaddwd_r2r(mm0, mm6);
-    pmaddwd_r2r(mm2, mm7);
-    pmaddwd_m2r(*(table + 24), mm0);
-    pmaddwd_m2r(*(table + 28), mm2);
-    paddd_r2r(mm1, mm3);
-    paddd_r2r(mm4, mm5);
-    paddd_r2r(mm6, mm7);
-    paddd_r2r(mm0, mm2);
-    movq_m2r(*fdct_r_row, mm0);
-    paddd_r2r(mm0, mm3);
-    paddd_r2r(mm0, mm5);
-    paddd_r2r(mm0, mm7);
-    paddd_r2r(mm0, mm2);
-    psrad_i2r(SHIFT_FRW_ROW, mm3);
-    psrad_i2r(SHIFT_FRW_ROW, mm5);
-    psrad_i2r(SHIFT_FRW_ROW, mm7);
-    psrad_i2r(SHIFT_FRW_ROW, mm2);
-    packssdw_r2r(mm5, mm3);
-    packssdw_r2r(mm2, mm7);
-    movq_r2m(mm3, *(out + 0));
-    movq_r2m(mm7, *(out + 4));
-}
-
-static always_inline void fdct_row_mmx(const int16_t *in, int16_t *out, const int16_t *table)
-{ 
-//FIXME reorder (i dont have a old mmx only cpu here to benchmark ...)
-    movd_m2r(*(in + 6), mm1);
-    punpcklwd_m2r(*(in + 4), mm1);
-    movq_r2r(mm1, mm2);
-    psrlq_i2r(0x20, mm1);
-    movq_m2r(*(in + 0), mm0);
-    punpcklwd_r2r(mm2, mm1);
-    movq_r2r(mm0, mm5);
-    paddsw_r2r(mm1, mm0);
-    psubsw_r2r(mm1, mm5);
-    movq_r2r(mm0, mm2);
-    punpckldq_r2r(mm5, mm0);
-    punpckhdq_r2r(mm5, mm2);
-    movq_m2r(*(table + 0), mm1);
-    movq_m2r(*(table + 4), mm3);
-    movq_m2r(*(table + 8), mm4);
-    movq_m2r(*(table + 12), mm5);
-    movq_m2r(*(table + 16), mm6);
-    movq_m2r(*(table + 20), mm7);
-    pmaddwd_r2r(mm0, mm1);
-    pmaddwd_r2r(mm2, mm3);
-    pmaddwd_r2r(mm0, mm4);
-    pmaddwd_r2r(mm2, mm5);
-    pmaddwd_r2r(mm0, mm6);
-    pmaddwd_r2r(mm2, mm7);
-    pmaddwd_m2r(*(table + 24), mm0);
-    pmaddwd_m2r(*(table + 28), mm2);
-    paddd_r2r(mm1, mm3);
-    paddd_r2r(mm4, mm5);
-    paddd_r2r(mm6, mm7);
-    paddd_r2r(mm0, mm2);
-    movq_m2r(*fdct_r_row, mm0);
-    paddd_r2r(mm0, mm3);
-    paddd_r2r(mm0, mm5);
-    paddd_r2r(mm0, mm7);
-    paddd_r2r(mm0, mm2);
-    psrad_i2r(SHIFT_FRW_ROW, mm3);
-    psrad_i2r(SHIFT_FRW_ROW, mm5);
-    psrad_i2r(SHIFT_FRW_ROW, mm7);
-    psrad_i2r(SHIFT_FRW_ROW, mm2);
-    packssdw_r2r(mm5, mm3);
-    packssdw_r2r(mm2, mm7);
-    movq_r2m(mm3, *(out + 0));
-    movq_r2m(mm7, *(out + 4));
-}
-
-void ff_fdct_mmx(int16_t *block)
-{
-    int64_t align_tmp[16] ATTR_ALIGN(8);
-    int16_t * const block_tmp= (int16_t*)align_tmp;
-    int16_t *block1, *out;
-    const int16_t *table;
-    int i;
-
-    block1 = block_tmp;
-    fdct_col(block, block1, 0);
-    fdct_col(block, block1, 4);
-
-    block1 = block_tmp;
-    table = tab_frw_01234567;
-    out = block;
-    for(i=8;i>0;i--) {
-        fdct_row_mmx(block1, out, table);
-        block1 += 8;
-        table += 32;
-        out += 8;
-    }
-}
-
-void ff_fdct_mmx2(int16_t *block)
-{
-    int64_t align_tmp[16] ATTR_ALIGN(8);
-    int16_t * const block_tmp= (int16_t*)align_tmp;
-    int16_t *block1, *out;
-    const int16_t *table;
-    int i;
-
-    block1 = block_tmp;
-    fdct_col(block, block1, 0);
-    fdct_col(block, block1, 4);
-
-    block1 = block_tmp;
-    table = tab_frw_01234567;
-    out = block;
-    for(i=8;i>0;i--) {
-        fdct_row_mmx2(block1, out, table);
-        block1 += 8;
-        table += 32;
-        out += 8;
-    }
-}
-
-void ff_fdct_sse2(int16_t *block) 
-{
-    int64_t align_tmp[16] ATTR_ALIGN(8);
-    int16_t * const block_tmp= (int16_t*)align_tmp;
-    int16_t *block1;
-
-    block1 = block_tmp;
-    fdct_col(block, block1, 0);
-    fdct_col(block, block1, 4);
-
-    fdct_row_sse2(block1, block);
-}
-
diff --git a/ffmpeg.src/libavcodec/i386/fft_sse.c b/ffmpeg.src/libavcodec/i386/fft_sse.c
deleted file mode 100644
index d07c943..0000000
--- a/ffmpeg.src/libavcodec/i386/fft_sse.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * FFT/MDCT transform with SSE optimizations
- * Copyright (c) 2002 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "../dsputil.h"
-#include <math.h>
-
-#ifdef HAVE_BUILTIN_VECTOR
-
-#include <xmmintrin.h>
-
-static const float p1p1p1m1[4] __attribute__((aligned(16))) = 
-    { 1.0, 1.0, 1.0, -1.0 };
-
-static const float p1p1m1p1[4] __attribute__((aligned(16))) = 
-    { 1.0, 1.0, -1.0, 1.0 };
-
-static const float p1p1m1m1[4] __attribute__((aligned(16))) = 
-    { 1.0, 1.0, -1.0, -1.0 };
-
-#if 0
-static void print_v4sf(const char *str, __m128 a)
-{
-    float *p = (float *)&a;
-    printf("%s: %f %f %f %f\n",
-           str, p[0], p[1], p[2], p[3]);
-}
-#endif
-
-/* XXX: handle reverse case */
-void ff_fft_calc_sse(FFTContext *s, FFTComplex *z)
-{
-    int ln = s->nbits;
-    int	j, np, np2;
-    int	nblocks, nloops;
-    register FFTComplex *p, *q;
-    FFTComplex *cptr, *cptr1;
-    int k;
-
-    np = 1 << ln;
-
-    {
-        __m128 *r, a, b, a1, c1, c2;
-
-        r = (__m128 *)&z[0];
-        c1 = *(__m128 *)p1p1m1m1;
-        c2 = *(__m128 *)p1p1p1m1;
-        if (s->inverse)
-            c2 = *(__m128 *)p1p1m1p1;
-        else
-            c2 = *(__m128 *)p1p1p1m1;
-
-        j = (np >> 2);
-        do {
-            a = r[0];
-            b = _mm_shuffle_ps(a, a, _MM_SHUFFLE(1, 0, 3, 2));
-            a = _mm_mul_ps(a, c1);
-            /* do the pass 0 butterfly */
-            a = _mm_add_ps(a, b);
-
-            a1 = r[1];
-            b = _mm_shuffle_ps(a1, a1, _MM_SHUFFLE(1, 0, 3, 2));
-            a1 = _mm_mul_ps(a1, c1);
-            /* do the pass 0 butterfly */
-            b = _mm_add_ps(a1, b);
-
-            /* multiply third by -i */
-            b = _mm_shuffle_ps(b, b, _MM_SHUFFLE(2, 3, 1, 0));
-            b = _mm_mul_ps(b, c2);
-
-            /* do the pass 1 butterfly */
-            r[0] = _mm_add_ps(a, b);
-            r[1] = _mm_sub_ps(a, b);
-            r += 2;
-        } while (--j != 0);
-    }
-    /* pass 2 .. ln-1 */
-
-    nblocks = np >> 3;
-    nloops = 1 << 2;
-    np2 = np >> 1;
-
-    cptr1 = s->exptab1;
-    do {
-        p = z;
-        q = z + nloops;
-        j = nblocks;
-        do {
-            cptr = cptr1;
-            k = nloops >> 1;
-            do {
-                __m128 a, b, c, t1, t2;
-
-                a = *(__m128 *)p;
-                b = *(__m128 *)q;
-                
-                /* complex mul */
-                c = *(__m128 *)cptr;
-                /*  cre*re cim*re */
-                t1 = _mm_mul_ps(c, 
-                                _mm_shuffle_ps(b, b, _MM_SHUFFLE(2, 2, 0, 0))); 
-                c = *(__m128 *)(cptr + 2);
-                /*  -cim*im cre*im */
-                t2 = _mm_mul_ps(c,
-                                _mm_shuffle_ps(b, b, _MM_SHUFFLE(3, 3, 1, 1))); 
-                b = _mm_add_ps(t1, t2);
-                
-                /* butterfly */
-                *(__m128 *)p = _mm_add_ps(a, b);
-                *(__m128 *)q = _mm_sub_ps(a, b);
-                
-                p += 2;
-                q += 2;
-                cptr += 4;
-            } while (--k);
-        
-            p += nloops;
-            q += nloops;
-        } while (--j);
-        cptr1 += nloops * 2;
-        nblocks = nblocks >> 1;
-        nloops = nloops << 1;
-    } while (nblocks != 0);
-}
-
-#endif
diff --git a/ffmpeg.src/libavcodec/i386/h264dsp_mmx.c b/ffmpeg.src/libavcodec/i386/h264dsp_mmx.c
deleted file mode 100644
index cf2a445..0000000
--- a/ffmpeg.src/libavcodec/i386/h264dsp_mmx.c
+++ /dev/null
@@ -1,911 +0,0 @@
-/*
- * Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-/***********************************/
-/* IDCT */
-
-/* in/out: mma=mma+mmb, mmb=mmb-mma */
-#define SUMSUB_BA( a, b ) \
-    "paddw "#b", "#a" \n\t"\
-    "paddw "#b", "#b" \n\t"\
-    "psubw "#a", "#b" \n\t"
-
-#define SUMSUB_BADC( a, b, c, d ) \
-    "paddw "#b", "#a" \n\t"\
-    "paddw "#d", "#c" \n\t"\
-    "paddw "#b", "#b" \n\t"\
-    "paddw "#d", "#d" \n\t"\
-    "psubw "#a", "#b" \n\t"\
-    "psubw "#c", "#d" \n\t"
-
-#define SUMSUBD2_AB( a, b, t ) \
-    "movq  "#b", "#t" \n\t"\
-    "psraw  $1 , "#b" \n\t"\
-    "paddw "#a", "#b" \n\t"\
-    "psraw  $1 , "#a" \n\t"\
-    "psubw "#t", "#a" \n\t"
-
-#define IDCT4_1D( s02, s13, d02, d13, t ) \
-    SUMSUB_BA  ( s02, d02 )\
-    SUMSUBD2_AB( s13, d13, t )\
-    SUMSUB_BADC( d13, s02, s13, d02 )
-
-#define SBUTTERFLY(a,b,t,n)\
-    "movq " #a ", " #t "		\n\t" /* abcd */\
-    "punpckl" #n " " #b ", " #a "	\n\t" /* aebf */\
-    "punpckh" #n " " #b ", " #t "	\n\t" /* cgdh */\
-
-#define TRANSPOSE4(a,b,c,d,t)\
-    SBUTTERFLY(a,b,t,wd) /* a=aebf t=cgdh */\
-    SBUTTERFLY(c,d,b,wd) /* c=imjn b=kolp */\
-    SBUTTERFLY(a,c,d,dq) /* a=aeim d=bfjn */\
-    SBUTTERFLY(t,b,c,dq) /* t=cgko c=dhlp */
-
-#define STORE_DIFF_4P( p, t, z ) \
-    "psraw      $6,     "#p" \n\t"\
-    "movd       (%0),   "#t" \n\t"\
-    "punpcklbw "#z",    "#t" \n\t"\
-    "paddsw    "#t",    "#p" \n\t"\
-    "packuswb  "#z",    "#p" \n\t"\
-    "movd      "#p",    (%0) \n\t"
-
-void ff_h264_idct_add_mmx2(uint8_t *dst, int16_t *block, int stride)
-{
-    /* Load dct coeffs */
-    asm volatile(
-        "movq   (%0), %%mm0 \n\t"
-        "movq  8(%0), %%mm1 \n\t"
-        "movq 16(%0), %%mm2 \n\t"
-        "movq 24(%0), %%mm3 \n\t"
-    :: "r"(block) );
-
-    asm volatile(
-        /* mm1=s02+s13  mm2=s02-s13  mm4=d02+d13  mm0=d02-d13 */
-        IDCT4_1D( %%mm2, %%mm1, %%mm0, %%mm3, %%mm4 )
-
-        "movq      %0,    %%mm6 \n\t"
-        /* in: 1,4,0,2  out: 1,2,3,0 */
-        TRANSPOSE4( %%mm3, %%mm1, %%mm0, %%mm2, %%mm4 )
-
-        "paddw     %%mm6, %%mm3 \n\t"
-
-        /* mm2=s02+s13  mm3=s02-s13  mm4=d02+d13  mm1=d02-d13 */
-        IDCT4_1D( %%mm4, %%mm2, %%mm3, %%mm0, %%mm1 )
-
-        "pxor %%mm7, %%mm7    \n\t"
-    :: "m"(ff_pw_32));
-
-    asm volatile(
-    STORE_DIFF_4P( %%mm0, %%mm1, %%mm7)
-        "add %1, %0             \n\t"
-    STORE_DIFF_4P( %%mm2, %%mm1, %%mm7)
-        "add %1, %0             \n\t"
-    STORE_DIFF_4P( %%mm3, %%mm1, %%mm7)
-        "add %1, %0             \n\t"
-    STORE_DIFF_4P( %%mm4, %%mm1, %%mm7)
-        : "+r"(dst)
-        : "r" ((long)stride)
-    );
-}
-
-
-/***********************************/
-/* deblocking */
-
-// out: o = |x-y|>a
-// clobbers: t
-#define DIFF_GT_MMX(x,y,a,o,t)\
-    "movq     "#y", "#t"  \n\t"\
-    "movq     "#x", "#o"  \n\t"\
-    "psubusb  "#x", "#t"  \n\t"\
-    "psubusb  "#y", "#o"  \n\t"\
-    "por      "#t", "#o"  \n\t"\
-    "psubusb  "#a", "#o"  \n\t"
-
-// in: mm0=p1 mm1=p0 mm2=q0 mm3=q1
-// out: mm5=beta-1, mm7=mask
-// clobbers: mm4,mm6
-#define H264_DEBLOCK_MASK(alpha1, beta1) \
-    "pshufw $0, "#alpha1", %%mm4 \n\t"\
-    "pshufw $0, "#beta1 ", %%mm5 \n\t"\
-    "packuswb  %%mm4, %%mm4      \n\t"\
-    "packuswb  %%mm5, %%mm5      \n\t"\
-    DIFF_GT_MMX(%%mm1, %%mm2, %%mm4, %%mm7, %%mm6) /* |p0-q0| > alpha-1 */\
-    DIFF_GT_MMX(%%mm0, %%mm1, %%mm5, %%mm4, %%mm6) /* |p1-p0| > beta-1 */\
-    "por       %%mm4, %%mm7      \n\t"\
-    DIFF_GT_MMX(%%mm3, %%mm2, %%mm5, %%mm4, %%mm6) /* |q1-q0| > beta-1 */\
-    "por       %%mm4, %%mm7      \n\t"\
-    "pxor      %%mm6, %%mm6      \n\t"\
-    "pcmpeqb   %%mm6, %%mm7      \n\t"
-
-// in: mm0=p1 mm1=p0 mm2=q0 mm3=q1 mm7=(tc&mask)
-// out: mm1=p0' mm2=q0'
-// clobbers: mm0,3-6
-#define H264_DEBLOCK_P0_Q0(pb_01, pb_3f)\
-        /* a = q0^p0^((p1-q1)>>2) */\
-        "movq    %%mm0, %%mm4  \n\t"\
-        "psubb   %%mm3, %%mm4  \n\t"\
-        "psrlw   $2,    %%mm4  \n\t"\
-        "pxor    %%mm1, %%mm4  \n\t"\
-        "pxor    %%mm2, %%mm4  \n\t"\
-        /* b = p0^(q1>>2) */\
-        "psrlw   $2,    %%mm3  \n\t"\
-        "pand "#pb_3f", %%mm3  \n\t"\
-        "movq    %%mm1, %%mm5  \n\t"\
-        "pxor    %%mm3, %%mm5  \n\t"\
-        /* c = q0^(p1>>2) */\
-        "psrlw   $2,    %%mm0  \n\t"\
-        "pand "#pb_3f", %%mm0  \n\t"\
-        "movq    %%mm2, %%mm6  \n\t"\
-        "pxor    %%mm0, %%mm6  \n\t"\
-        /* d = (c^b) & ~(b^a) & 1 */\
-        "pxor    %%mm5, %%mm6  \n\t"\
-        "pxor    %%mm4, %%mm5  \n\t"\
-        "pandn   %%mm6, %%mm5  \n\t"\
-        "pand "#pb_01", %%mm5  \n\t"\
-        /* delta = (avg(q0, p1>>2) + (d&a))
-         *       - (avg(p0, q1>>2) + (d&~a)) */\
-        "pavgb   %%mm2, %%mm0  \n\t"\
-        "pand    %%mm5, %%mm4  \n\t"\
-        "paddusb %%mm4, %%mm0  \n\t"\
-        "pavgb   %%mm1, %%mm3  \n\t"\
-        "pxor    %%mm5, %%mm4  \n\t"\
-        "paddusb %%mm4, %%mm3  \n\t"\
-        /* p0 += clip(delta, -tc0, tc0)
-         * q0 -= clip(delta, -tc0, tc0) */\
-        "movq    %%mm0, %%mm4  \n\t"\
-        "psubusb %%mm3, %%mm0  \n\t"\
-        "psubusb %%mm4, %%mm3  \n\t"\
-        "pminub  %%mm7, %%mm0  \n\t"\
-        "pminub  %%mm7, %%mm3  \n\t"\
-        "paddusb %%mm0, %%mm1  \n\t"\
-        "paddusb %%mm3, %%mm2  \n\t"\
-        "psubusb %%mm3, %%mm1  \n\t"\
-        "psubusb %%mm0, %%mm2  \n\t"
-
-// in: mm0=p1 mm1=p0 mm2=q0 mm3=q1 mm7=(tc&mask) %8=mm_bone
-// out: (q1addr) = clip( (q2+((p0+q0+1)>>1))>>1, q1-tc0, q1+tc0 )
-// clobbers: q2, tmp, tc0
-#define H264_DEBLOCK_Q1(p1, q2, q2addr, q1addr, tc0, tmp)\
-        "movq     %%mm1,  "#tmp"   \n\t"\
-        "pavgb    %%mm2,  "#tmp"   \n\t"\
-        "pavgb    "#tmp", "#q2"    \n\t" /* avg(p2,avg(p0,q0)) */\
-        "pxor   "q2addr", "#tmp"   \n\t"\
-        "pand     %8,     "#tmp"   \n\t" /* (p2^avg(p0,q0))&1 */\
-        "psubusb  "#tmp", "#q2"    \n\t" /* (p2+((p0+q0+1)>>1))>>1 */\
-        "movq     "#p1",  "#tmp"   \n\t"\
-        "psubusb  "#tc0", "#tmp"   \n\t"\
-        "paddusb  "#p1",  "#tc0"   \n\t"\
-        "pmaxub   "#tmp", "#q2"    \n\t"\
-        "pminub   "#tc0", "#q2"    \n\t"\
-        "movq     "#q2",  "q1addr" \n\t"
-
-static inline void h264_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha1, int beta1, int8_t *tc0)
-{
-    uint64_t tmp0;
-    uint64_t tc = (uint8_t)tc0[1]*0x01010000 | (uint8_t)tc0[0]*0x0101;
-    // with luma, tc0=0 doesn't mean no filtering, so we need a separate input mask
-    uint32_t mask[2] = { (tc0[0]>=0)*0xffffffff, (tc0[1]>=0)*0xffffffff };
-
-    asm volatile(
-        "movq    (%1,%3), %%mm0    \n\t" //p1
-        "movq    (%1,%3,2), %%mm1  \n\t" //p0
-        "movq    (%2),    %%mm2    \n\t" //q0
-        "movq    (%2,%3), %%mm3    \n\t" //q1
-        H264_DEBLOCK_MASK(%6, %7)
-        "pand     %5,     %%mm7    \n\t"
-        "movq     %%mm7,  %0       \n\t"
-
-        /* filter p1 */
-        "movq     (%1),   %%mm3    \n\t" //p2
-        DIFF_GT_MMX(%%mm1, %%mm3, %%mm5, %%mm6, %%mm4) // |p2-p0|>beta-1
-        "pandn    %%mm7,  %%mm6    \n\t"
-        "pcmpeqb  %%mm7,  %%mm6    \n\t"
-        "pand     %%mm7,  %%mm6    \n\t" // mask & |p2-p0|<beta
-        "pshufw  $80, %4, %%mm4    \n\t"
-        "pand     %%mm7,  %%mm4    \n\t" // mask & tc0
-        "movq     %8,     %%mm7    \n\t"
-        "pand     %%mm6,  %%mm7    \n\t" // mask & |p2-p0|<beta & 1
-        "pand     %%mm4,  %%mm6    \n\t" // mask & |p2-p0|<beta & tc0
-        "paddb    %%mm4,  %%mm7    \n\t" // tc++
-        H264_DEBLOCK_Q1(%%mm0, %%mm3, "(%1)", "(%1,%3)", %%mm6, %%mm4)
-
-        /* filter q1 */
-        "movq    (%2,%3,2), %%mm4  \n\t" //q2
-        DIFF_GT_MMX(%%mm2, %%mm4, %%mm5, %%mm6, %%mm3) // |q2-q0|>beta-1
-        "pandn    %0,     %%mm6    \n\t"
-        "pcmpeqb  %0,     %%mm6    \n\t"
-        "pand     %0,     %%mm6    \n\t"
-        "pshufw  $80, %4, %%mm5    \n\t"
-        "pand     %%mm6,  %%mm5    \n\t"
-        "pand     %8,     %%mm6    \n\t"
-        "paddb    %%mm6,  %%mm7    \n\t"
-        "movq    (%2,%3), %%mm3    \n\t"
-        H264_DEBLOCK_Q1(%%mm3, %%mm4, "(%2,%3,2)", "(%2,%3)", %%mm5, %%mm6)
-
-        /* filter p0, q0 */
-        H264_DEBLOCK_P0_Q0(%8, %9)
-        "movq      %%mm1, (%1,%3,2) \n\t"
-        "movq      %%mm2, (%2)      \n\t"
-
-        : "=m"(tmp0)
-        : "r"(pix-3*stride), "r"(pix), "r"((long)stride),
-          "m"(tc), "m"(*(uint64_t*)mask), "m"(alpha1), "m"(beta1),
-          "m"(mm_bone), "m"(ff_pb_3F)
-    );
-}
-
-static void h264_v_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
-    if((tc0[0] & tc0[1]) >= 0)
-        h264_loop_filter_luma_mmx2(pix, stride, alpha-1, beta-1, tc0);
-    if((tc0[2] & tc0[3]) >= 0)
-        h264_loop_filter_luma_mmx2(pix+8, stride, alpha-1, beta-1, tc0+2);
-}
-static void h264_h_loop_filter_luma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
-    //FIXME: could cut some load/stores by merging transpose with filter
-    // also, it only needs to transpose 6x8
-    uint8_t trans[8*8];
-    int i;
-    for(i=0; i<2; i++, pix+=8*stride, tc0+=2) {
-        if((tc0[0] & tc0[1]) < 0)
-            continue;
-        transpose4x4(trans,       pix-4,          8, stride);
-        transpose4x4(trans  +4*8, pix,            8, stride);
-        transpose4x4(trans+4,     pix-4+4*stride, 8, stride);
-        transpose4x4(trans+4+4*8, pix  +4*stride, 8, stride);
-        h264_loop_filter_luma_mmx2(trans+4*8, 8, alpha-1, beta-1, tc0);
-        transpose4x4(pix-2,          trans  +2*8, stride, 8);
-        transpose4x4(pix-2+4*stride, trans+4+2*8, stride, 8);
-    }
-}
-
-static inline void h264_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha1, int beta1, int8_t *tc0)
-{
-    asm volatile(
-        "movq    (%0),    %%mm0     \n\t" //p1
-        "movq    (%0,%2), %%mm1     \n\t" //p0
-        "movq    (%1),    %%mm2     \n\t" //q0
-        "movq    (%1,%2), %%mm3     \n\t" //q1
-        H264_DEBLOCK_MASK(%4, %5)
-        "movd      %3,    %%mm6     \n\t"
-        "punpcklbw %%mm6, %%mm6     \n\t"
-        "pand      %%mm6, %%mm7     \n\t" // mm7 = tc&mask
-        H264_DEBLOCK_P0_Q0(%6, %7)
-        "movq      %%mm1, (%0,%2)   \n\t"
-        "movq      %%mm2, (%1)      \n\t"
-
-        :: "r"(pix-2*stride), "r"(pix), "r"((long)stride),
-           "r"(*(uint32_t*)tc0),
-           "m"(alpha1), "m"(beta1), "m"(mm_bone), "m"(ff_pb_3F)
-    );
-}
-
-static void h264_v_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
-    h264_loop_filter_chroma_mmx2(pix, stride, alpha-1, beta-1, tc0);
-}
-
-static void h264_h_loop_filter_chroma_mmx2(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
-    //FIXME: could cut some load/stores by merging transpose with filter
-    uint8_t trans[8*4];
-    transpose4x4(trans, pix-2, 8, stride);
-    transpose4x4(trans+4, pix-2+4*stride, 8, stride);
-    h264_loop_filter_chroma_mmx2(trans+2*8, 8, alpha-1, beta-1, tc0);
-    transpose4x4(pix-2, trans, stride, 8);
-    transpose4x4(pix-2+4*stride, trans+4, stride, 8);
-}
-
-// p0 = (p0 + q1 + 2*p1 + 2) >> 2
-#define H264_FILTER_CHROMA4(p0, p1, q1, one) \
-    "movq    "#p0", %%mm4  \n\t"\
-    "pxor    "#q1", %%mm4  \n\t"\
-    "pand   "#one", %%mm4  \n\t" /* mm4 = (p0^q1)&1 */\
-    "pavgb   "#q1", "#p0"  \n\t"\
-    "psubusb %%mm4, "#p0"  \n\t"\
-    "pavgb   "#p1", "#p0"  \n\t" /* dst = avg(p1, avg(p0,q1) - ((p0^q1)&1)) */\
-
-static inline void h264_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha1, int beta1)
-{
-    asm volatile(
-        "movq    (%0),    %%mm0     \n\t"
-        "movq    (%0,%2), %%mm1     \n\t"
-        "movq    (%1),    %%mm2     \n\t"
-        "movq    (%1,%2), %%mm3     \n\t"
-        H264_DEBLOCK_MASK(%3, %4)
-        "movq    %%mm1,   %%mm5     \n\t"
-        "movq    %%mm2,   %%mm6     \n\t"
-        H264_FILTER_CHROMA4(%%mm1, %%mm0, %%mm3, %5) //p0'
-        H264_FILTER_CHROMA4(%%mm2, %%mm3, %%mm0, %5) //q0'
-        "psubb   %%mm5,   %%mm1     \n\t"
-        "psubb   %%mm6,   %%mm2     \n\t"
-        "pand    %%mm7,   %%mm1     \n\t"
-        "pand    %%mm7,   %%mm2     \n\t"
-        "paddb   %%mm5,   %%mm1     \n\t"
-        "paddb   %%mm6,   %%mm2     \n\t"
-        "movq    %%mm1,   (%0,%2)   \n\t"
-        "movq    %%mm2,   (%1)      \n\t"
-        :: "r"(pix-2*stride), "r"(pix), "r"((long)stride),
-           "m"(alpha1), "m"(beta1), "m"(mm_bone)
-    );
-}
-
-static void h264_v_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha, int beta)
-{
-    h264_loop_filter_chroma_intra_mmx2(pix, stride, alpha-1, beta-1);
-}
-
-static void h264_h_loop_filter_chroma_intra_mmx2(uint8_t *pix, int stride, int alpha, int beta)
-{
-    //FIXME: could cut some load/stores by merging transpose with filter
-    uint8_t trans[8*4];
-    transpose4x4(trans, pix-2, 8, stride);
-    transpose4x4(trans+4, pix-2+4*stride, 8, stride);
-    h264_loop_filter_chroma_intra_mmx2(trans+2*8, 8, alpha-1, beta-1);
-    transpose4x4(pix-2, trans, stride, 8);
-    transpose4x4(pix-2+4*stride, trans+4, stride, 8);
-}
-
-
-/***********************************/
-/* motion compensation */
-
-#define QPEL_H264V(A,B,C,D,E,F,OP)\
-        "movd (%0), "#F"		\n\t"\
-        "movq "#C", %%mm6		\n\t"\
-        "paddw "#D", %%mm6		\n\t"\
-        "psllw $2, %%mm6		\n\t"\
-        "psubw "#B", %%mm6		\n\t"\
-        "psubw "#E", %%mm6		\n\t"\
-        "pmullw %4, %%mm6		\n\t"\
-        "add %2, %0			\n\t"\
-        "punpcklbw %%mm7, "#F"		\n\t"\
-        "paddw %5, "#A"			\n\t"\
-        "paddw "#F", "#A"		\n\t"\
-        "paddw "#A", %%mm6		\n\t"\
-        "psraw $5, %%mm6		\n\t"\
-        "packuswb %%mm6, %%mm6		\n\t"\
-        OP(%%mm6, (%1), A, d)\
-        "add %3, %1			\n\t"     
-
-#define QPEL_H264HV(A,B,C,D,E,F,OF)\
-        "movd (%0), "#F"		\n\t"\
-        "movq "#C", %%mm6		\n\t"\
-        "paddw "#D", %%mm6		\n\t"\
-        "psllw $2, %%mm6		\n\t"\
-        "psubw "#B", %%mm6		\n\t"\
-        "psubw "#E", %%mm6		\n\t"\
-        "pmullw %3, %%mm6		\n\t"\
-        "add %2, %0			\n\t"\
-        "punpcklbw %%mm7, "#F"		\n\t"\
-        "paddw "#F", "#A"		\n\t"\
-        "paddw "#A", %%mm6		\n\t"\
-        "movq %%mm6, "#OF"(%1)		\n\t"
-        
-#define QPEL_H264(OPNAME, OP, MMX)\
-static void OPNAME ## h264_qpel4_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    int h=4;\
-\
-    asm volatile(\
-        "pxor %%mm7, %%mm7		\n\t"\
-        "movq %5, %%mm4			\n\t"\
-        "movq %6, %%mm5			\n\t"\
-        "1:				\n\t"\
-        "movd  -1(%0), %%mm1		\n\t"\
-        "movd    (%0), %%mm2		\n\t"\
-        "movd   1(%0), %%mm3		\n\t"\
-        "movd   2(%0), %%mm0		\n\t"\
-        "punpcklbw %%mm7, %%mm1		\n\t"\
-        "punpcklbw %%mm7, %%mm2		\n\t"\
-        "punpcklbw %%mm7, %%mm3		\n\t"\
-        "punpcklbw %%mm7, %%mm0		\n\t"\
-        "paddw %%mm0, %%mm1		\n\t"\
-        "paddw %%mm3, %%mm2		\n\t"\
-        "movd  -2(%0), %%mm0		\n\t"\
-        "movd   3(%0), %%mm3		\n\t"\
-        "punpcklbw %%mm7, %%mm0		\n\t"\
-        "punpcklbw %%mm7, %%mm3		\n\t"\
-        "paddw %%mm3, %%mm0		\n\t"\
-        "psllw $2, %%mm2		\n\t"\
-        "psubw %%mm1, %%mm2		\n\t"\
-        "pmullw %%mm4, %%mm2		\n\t"\
-        "paddw %%mm5, %%mm0		\n\t"\
-        "paddw %%mm2, %%mm0		\n\t"\
-        "psraw $5, %%mm0		\n\t"\
-        "packuswb %%mm0, %%mm0		\n\t"\
-        OP(%%mm0, (%1),%%mm6, d)\
-        "add %3, %0			\n\t"\
-        "add %4, %1			\n\t"\
-        "decl %2			\n\t"\
-        " jnz 1b			\n\t"\
-        : "+a"(src), "+c"(dst), "+m"(h)\
-        : "d"((long)srcStride), "S"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\
-        : "memory"\
-    );\
-}\
-static void OPNAME ## h264_qpel4_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    src -= 2*srcStride;\
-    asm volatile(\
-        "pxor %%mm7, %%mm7		\n\t"\
-        "movd (%0), %%mm0		\n\t"\
-        "add %2, %0			\n\t"\
-        "movd (%0), %%mm1		\n\t"\
-        "add %2, %0			\n\t"\
-        "movd (%0), %%mm2		\n\t"\
-        "add %2, %0			\n\t"\
-        "movd (%0), %%mm3		\n\t"\
-        "add %2, %0			\n\t"\
-        "movd (%0), %%mm4		\n\t"\
-        "add %2, %0			\n\t"\
-        "punpcklbw %%mm7, %%mm0		\n\t"\
-        "punpcklbw %%mm7, %%mm1		\n\t"\
-        "punpcklbw %%mm7, %%mm2		\n\t"\
-        "punpcklbw %%mm7, %%mm3		\n\t"\
-        "punpcklbw %%mm7, %%mm4		\n\t"\
-        QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\
-        QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\
-        QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\
-        QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\
-         \
-        : "+a"(src), "+c"(dst)\
-        : "S"((long)srcStride), "D"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\
-        : "memory"\
-    );\
-}\
-static void OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
-    int h=4;\
-    int w=3;\
-    src -= 2*srcStride+2;\
-    while(w--){\
-        asm volatile(\
-            "pxor %%mm7, %%mm7			\n\t"\
-            "movd (%0), %%mm0			\n\t"\
-            "add %2, %0				\n\t"\
-            "movd (%0), %%mm1			\n\t"\
-            "add %2, %0				\n\t"\
-            "movd (%0), %%mm2			\n\t"\
-            "add %2, %0				\n\t"\
-            "movd (%0), %%mm3			\n\t"\
-            "add %2, %0				\n\t"\
-            "movd (%0), %%mm4			\n\t"\
-            "add %2, %0				\n\t"\
-            "punpcklbw %%mm7, %%mm0		\n\t"\
-            "punpcklbw %%mm7, %%mm1		\n\t"\
-            "punpcklbw %%mm7, %%mm2		\n\t"\
-            "punpcklbw %%mm7, %%mm3		\n\t"\
-            "punpcklbw %%mm7, %%mm4		\n\t"\
-            QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 0*8*3)\
-            QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 1*8*3)\
-            QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 2*8*3)\
-            QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 3*8*3)\
-             \
-            : "+a"(src)\
-            : "c"(tmp), "S"((long)srcStride), "m"(ff_pw_5)\
-            : "memory"\
-        );\
-        tmp += 4;\
-        src += 4 - 9*srcStride;\
-    }\
-    tmp -= 3*4;\
-    asm volatile(\
-        "movq %4, %%mm6			\n\t"\
-        "1:				\n\t"\
-        "movq     (%0), %%mm0		\n\t"\
-        "paddw  10(%0), %%mm0		\n\t"\
-        "movq    2(%0), %%mm1		\n\t"\
-        "paddw   8(%0), %%mm1		\n\t"\
-        "movq    4(%0), %%mm2		\n\t"\
-        "paddw   6(%0), %%mm2		\n\t"\
-        "psubw %%mm1, %%mm0		\n\t"/*a-b   (abccba)*/\
-        "psraw $2, %%mm0		\n\t"/*(a-b)/4 */\
-        "psubw %%mm1, %%mm0		\n\t"/*(a-b)/4-b */\
-        "paddsw %%mm2, %%mm0		\n\t"\
-        "psraw $2, %%mm0		\n\t"/*((a-b)/4-b)/4 */\
-        "paddw %%mm6, %%mm2		\n\t"\
-        "paddw %%mm2, %%mm0		\n\t"\
-        "psraw $6, %%mm0		\n\t"\
-        "packuswb %%mm0, %%mm0		\n\t"\
-        OP(%%mm0, (%1),%%mm7, d)\
-        "add $24, %0			\n\t"\
-        "add %3, %1			\n\t"\
-        "decl %2			\n\t"\
-        " jnz 1b			\n\t"\
-        : "+a"(tmp), "+c"(dst), "+m"(h)\
-        : "S"((long)dstStride), "m"(ff_pw_32)\
-        : "memory"\
-    );\
-}\
-\
-static void OPNAME ## h264_qpel8_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    int h=8;\
-    asm volatile(\
-        "pxor %%mm7, %%mm7		\n\t"\
-        "movq %5, %%mm6			\n\t"\
-        "1:				\n\t"\
-        "movq    (%0), %%mm0		\n\t"\
-        "movq   1(%0), %%mm2		\n\t"\
-        "movq %%mm0, %%mm1		\n\t"\
-        "movq %%mm2, %%mm3		\n\t"\
-        "punpcklbw %%mm7, %%mm0		\n\t"\
-        "punpckhbw %%mm7, %%mm1		\n\t"\
-        "punpcklbw %%mm7, %%mm2		\n\t"\
-        "punpckhbw %%mm7, %%mm3		\n\t"\
-        "paddw %%mm2, %%mm0		\n\t"\
-        "paddw %%mm3, %%mm1		\n\t"\
-        "psllw $2, %%mm0		\n\t"\
-        "psllw $2, %%mm1		\n\t"\
-        "movq   -1(%0), %%mm2		\n\t"\
-        "movq    2(%0), %%mm4		\n\t"\
-        "movq %%mm2, %%mm3		\n\t"\
-        "movq %%mm4, %%mm5		\n\t"\
-        "punpcklbw %%mm7, %%mm2		\n\t"\
-        "punpckhbw %%mm7, %%mm3		\n\t"\
-        "punpcklbw %%mm7, %%mm4		\n\t"\
-        "punpckhbw %%mm7, %%mm5		\n\t"\
-        "paddw %%mm4, %%mm2		\n\t"\
-        "paddw %%mm3, %%mm5		\n\t"\
-        "psubw %%mm2, %%mm0		\n\t"\
-        "psubw %%mm5, %%mm1		\n\t"\
-        "pmullw %%mm6, %%mm0		\n\t"\
-        "pmullw %%mm6, %%mm1		\n\t"\
-        "movd   -2(%0), %%mm2		\n\t"\
-        "movd    7(%0), %%mm5		\n\t"\
-        "punpcklbw %%mm7, %%mm2		\n\t"\
-        "punpcklbw %%mm7, %%mm5		\n\t"\
-        "paddw %%mm3, %%mm2		\n\t"\
-        "paddw %%mm5, %%mm4		\n\t"\
-        "movq %6, %%mm5			\n\t"\
-        "paddw %%mm5, %%mm2		\n\t"\
-        "paddw %%mm5, %%mm4		\n\t"\
-        "paddw %%mm2, %%mm0		\n\t"\
-        "paddw %%mm4, %%mm1		\n\t"\
-        "psraw $5, %%mm0		\n\t"\
-        "psraw $5, %%mm1		\n\t"\
-        "packuswb %%mm1, %%mm0		\n\t"\
-        OP(%%mm0, (%1),%%mm5, q)\
-        "add %3, %0			\n\t"\
-        "add %4, %1			\n\t"\
-        "decl %2			\n\t"\
-        " jnz 1b			\n\t"\
-        : "+a"(src), "+c"(dst), "+m"(h)\
-        : "d"((long)srcStride), "S"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\
-        : "memory"\
-    );\
-}\
-\
-static void OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    int h= 2;\
-    src -= 2*srcStride;\
-    \
-    while(h--){\
-      asm volatile(\
-        "pxor %%mm7, %%mm7		\n\t"\
-        "movd (%0), %%mm0		\n\t"\
-        "add %2, %0			\n\t"\
-        "movd (%0), %%mm1		\n\t"\
-        "add %2, %0			\n\t"\
-        "movd (%0), %%mm2		\n\t"\
-        "add %2, %0			\n\t"\
-        "movd (%0), %%mm3		\n\t"\
-        "add %2, %0			\n\t"\
-        "movd (%0), %%mm4		\n\t"\
-        "add %2, %0			\n\t"\
-        "punpcklbw %%mm7, %%mm0		\n\t"\
-        "punpcklbw %%mm7, %%mm1		\n\t"\
-        "punpcklbw %%mm7, %%mm2		\n\t"\
-        "punpcklbw %%mm7, %%mm3		\n\t"\
-        "punpcklbw %%mm7, %%mm4		\n\t"\
-        QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\
-        QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\
-        QPEL_H264V(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP)\
-        QPEL_H264V(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP)\
-        QPEL_H264V(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP)\
-        QPEL_H264V(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP)\
-        QPEL_H264V(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP)\
-        QPEL_H264V(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP)\
-         \
-        : "+a"(src), "+c"(dst)\
-        : "S"((long)srcStride), "D"((long)dstStride), "m"(ff_pw_5), "m"(ff_pw_16)\
-        : "memory"\
-     );\
-     src += 4-13*srcStride;\
-     dst +=  4-8*dstStride;\
-   }\
-}\
-static void OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
-    int h=8;\
-    int w=4;\
-    src -= 2*srcStride+2;\
-    while(w--){\
-        asm volatile(\
-            "pxor %%mm7, %%mm7			\n\t"\
-            "movd (%0), %%mm0			\n\t"\
-            "add %2, %0				\n\t"\
-            "movd (%0), %%mm1			\n\t"\
-            "add %2, %0				\n\t"\
-            "movd (%0), %%mm2			\n\t"\
-            "add %2, %0				\n\t"\
-            "movd (%0), %%mm3			\n\t"\
-            "add %2, %0				\n\t"\
-            "movd (%0), %%mm4			\n\t"\
-            "add %2, %0				\n\t"\
-            "punpcklbw %%mm7, %%mm0		\n\t"\
-            "punpcklbw %%mm7, %%mm1		\n\t"\
-            "punpcklbw %%mm7, %%mm2		\n\t"\
-            "punpcklbw %%mm7, %%mm3		\n\t"\
-            "punpcklbw %%mm7, %%mm4		\n\t"\
-            QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 0*8*4)\
-            QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 1*8*4)\
-            QPEL_H264HV(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, 2*8*4)\
-            QPEL_H264HV(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, 3*8*4)\
-            QPEL_H264HV(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, 4*8*4)\
-            QPEL_H264HV(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, 5*8*4)\
-            QPEL_H264HV(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, 6*8*4)\
-            QPEL_H264HV(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, 7*8*4)\
-             \
-            : "+a"(src)\
-            : "c"(tmp), "S"((long)srcStride), "m"(ff_pw_5)\
-            : "memory"\
-        );\
-        tmp += 4;\
-        src += 4 - 13*srcStride;\
-    }\
-    tmp -= 4*4;\
-    asm volatile(\
-        "movq %4, %%mm6			\n\t"\
-        "1:				\n\t"\
-        "movq     (%0), %%mm0		\n\t"\
-        "movq    8(%0), %%mm3		\n\t"\
-        "movq    2(%0), %%mm1		\n\t"\
-        "movq   10(%0), %%mm4		\n\t"\
-        "paddw   %%mm4, %%mm0		\n\t"\
-        "paddw   %%mm3, %%mm1		\n\t"\
-        "paddw  18(%0), %%mm3		\n\t"\
-        "paddw  16(%0), %%mm4		\n\t"\
-        "movq    4(%0), %%mm2		\n\t"\
-        "movq   12(%0), %%mm5		\n\t"\
-        "paddw   6(%0), %%mm2		\n\t"\
-        "paddw  14(%0), %%mm5		\n\t"\
-        "psubw %%mm1, %%mm0		\n\t"\
-        "psubw %%mm4, %%mm3		\n\t"\
-        "psraw $2, %%mm0		\n\t"\
-        "psraw $2, %%mm3		\n\t"\
-        "psubw %%mm1, %%mm0		\n\t"\
-        "psubw %%mm4, %%mm3		\n\t"\
-        "paddsw %%mm2, %%mm0		\n\t"\
-        "paddsw %%mm5, %%mm3		\n\t"\
-        "psraw $2, %%mm0		\n\t"\
-        "psraw $2, %%mm3		\n\t"\
-        "paddw %%mm6, %%mm2		\n\t"\
-        "paddw %%mm6, %%mm5		\n\t"\
-        "paddw %%mm2, %%mm0		\n\t"\
-        "paddw %%mm5, %%mm3		\n\t"\
-        "psraw $6, %%mm0		\n\t"\
-        "psraw $6, %%mm3		\n\t"\
-        "packuswb %%mm3, %%mm0		\n\t"\
-        OP(%%mm0, (%1),%%mm7, q)\
-        "add $32, %0			\n\t"\
-        "add %3, %1			\n\t"\
-        "decl %2			\n\t"\
-        " jnz 1b			\n\t"\
-        : "+a"(tmp), "+c"(dst), "+m"(h)\
-        : "S"((long)dstStride), "m"(ff_pw_32)\
-        : "memory"\
-    );\
-}\
-static void OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    OPNAME ## h264_qpel8_v_lowpass_ ## MMX(dst  , src  , dstStride, srcStride);\
-    OPNAME ## h264_qpel8_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
-    src += 8*srcStride;\
-    dst += 8*dstStride;\
-    OPNAME ## h264_qpel8_v_lowpass_ ## MMX(dst  , src  , dstStride, srcStride);\
-    OPNAME ## h264_qpel8_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
-}\
-\
-static void OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst  , src  , dstStride, srcStride);\
-    OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
-    src += 8*srcStride;\
-    dst += 8*dstStride;\
-    OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst  , src  , dstStride, srcStride);\
-    OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
-}\
-\
-static void OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
-    OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(dst  , tmp  , src  , dstStride, tmpStride, srcStride);\
-    OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(dst+8, tmp  , src+8, dstStride, tmpStride, srcStride);\
-    src += 8*srcStride;\
-    dst += 8*dstStride;\
-    OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(dst  , tmp  , src  , dstStride, tmpStride, srcStride);\
-    OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(dst+8, tmp  , src+8, dstStride, tmpStride, srcStride);\
-}\
-
-#define H264_MC(OPNAME, SIZE, MMX) \
-static void OPNAME ## h264_qpel ## SIZE ## _mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## pixels ## SIZE ## _mmx(dst, src, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/8];\
-    uint8_t * const half= (uint8_t*)temp;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(half, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src, half, stride, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## h264_qpel ## SIZE ## _h_lowpass_ ## MMX(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/8];\
-    uint8_t * const half= (uint8_t*)temp;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(half, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src+1, half, stride, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/8];\
-    uint8_t * const half= (uint8_t*)temp;\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(half, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src, half, stride, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## h264_qpel ## SIZE ## _v_lowpass_ ## MMX(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/8];\
-    uint8_t * const half= (uint8_t*)temp;\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(half, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src+stride, half, stride, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/4];\
-    uint8_t * const halfH= (uint8_t*)temp;\
-    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(halfH, src, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfH, halfV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/4];\
-    uint8_t * const halfH= (uint8_t*)temp;\
-    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(halfH, src, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src+1, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfH, halfV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/4];\
-    uint8_t * const halfH= (uint8_t*)temp;\
-    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(halfH, src + stride, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfH, halfV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/4];\
-    uint8_t * const halfH= (uint8_t*)temp;\
-    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(halfH, src + stride, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src+1, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfH, halfV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*(SIZE+8)/4];\
-    int16_t * const tmp= (int16_t*)temp;\
-    OPNAME ## h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(dst, tmp, src, stride, SIZE, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4];\
-    uint8_t * const halfH= (uint8_t*)temp;\
-    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\
-    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(halfH, src, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfH, halfHV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4];\
-    uint8_t * const halfH= (uint8_t*)temp;\
-    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\
-    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## MMX(halfH, src + stride, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfH, halfHV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4];\
-    uint8_t * const halfV= (uint8_t*)temp;\
-    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\
-    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfV, halfHV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4];\
-    uint8_t * const halfV= (uint8_t*)temp;\
-    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\
-    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(halfV, src+1, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, halfV, halfHV, stride, SIZE, SIZE);\
-}\
-
-
-#define PUT_OP(a,b,temp, size) "mov" #size " " #a ", " #b "	\n\t"
-#define AVG_3DNOW_OP(a,b,temp, size) \
-"mov" #size " " #b ", " #temp "	\n\t"\
-"pavgusb " #temp ", " #a "	\n\t"\
-"mov" #size " " #a ", " #b "	\n\t"
-#define AVG_MMX2_OP(a,b,temp, size) \
-"mov" #size " " #b ", " #temp "	\n\t"\
-"pavgb " #temp ", " #a "	\n\t"\
-"mov" #size " " #a ", " #b "	\n\t"
-
-QPEL_H264(put_,       PUT_OP, 3dnow)
-QPEL_H264(avg_, AVG_3DNOW_OP, 3dnow)
-QPEL_H264(put_,       PUT_OP, mmx2)
-QPEL_H264(avg_,  AVG_MMX2_OP, mmx2)
-
-H264_MC(put_, 4, 3dnow)
-H264_MC(put_, 8, 3dnow)
-H264_MC(put_, 16,3dnow)
-H264_MC(avg_, 4, 3dnow)
-H264_MC(avg_, 8, 3dnow)
-H264_MC(avg_, 16,3dnow)
-H264_MC(put_, 4, mmx2)
-H264_MC(put_, 8, mmx2)
-H264_MC(put_, 16,mmx2)
-H264_MC(avg_, 4, mmx2)
-H264_MC(avg_, 8, mmx2)
-H264_MC(avg_, 16,mmx2)
-
-
-#define H264_CHROMA_OP(S,D)
-#define H264_CHROMA_MC8_TMPL put_h264_chroma_mc8_mmx
-#include "dsputil_h264_template_mmx.c"
-#undef H264_CHROMA_OP
-#undef H264_CHROMA_MC8_TMPL
-
-#define H264_CHROMA_OP(S,D) "pavgb " #S ", " #D " \n\t"
-#define H264_CHROMA_MC8_TMPL avg_h264_chroma_mc8_mmx2
-#include "dsputil_h264_template_mmx.c"
-#undef H264_CHROMA_OP
-#undef H264_CHROMA_MC8_TMPL
-
-#define H264_CHROMA_OP(S,D) "pavgusb " #S ", " #D " \n\t"
-#define H264_CHROMA_MC8_TMPL avg_h264_chroma_mc8_3dnow
-#include "dsputil_h264_template_mmx.c"
-#undef H264_CHROMA_OP
-#undef H264_CHROMA_MC8_TMPL
-
diff --git a/ffmpeg.src/libavcodec/i386/idct_mmx.c b/ffmpeg.src/libavcodec/i386/idct_mmx.c
deleted file mode 100644
index d1a8454..0000000
--- a/ffmpeg.src/libavcodec/i386/idct_mmx.c
+++ /dev/null
@@ -1,600 +0,0 @@
-/*
- * Note: For libavcodec, this code can also be used under the LGPL license
- */
-/*
- * idct_mmx.c
- * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma at ess.engr.uvic.ca>
- *
- * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
- *
- * mpeg2dec 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.
- *
- * mpeg2dec 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "common.h"
-#include "../dsputil.h"
-
-#include "mmx.h"
-
-#define ATTR_ALIGN(align) __attribute__ ((__aligned__ (align)))
-
-#define ROW_SHIFT 11
-#define COL_SHIFT 6
-
-#define round(bias) ((int)(((bias)+0.5) * (1<<ROW_SHIFT)))
-#define rounder(bias) {round (bias), round (bias)}
-
-#if 0
-/* C row IDCT - its just here to document the MMXEXT and MMX versions */
-static inline void idct_row (int16_t * row, int offset,
-			     int16_t * table, int32_t * rounder)
-{
-    int C1, C2, C3, C4, C5, C6, C7;
-    int a0, a1, a2, a3, b0, b1, b2, b3;
-
-    row += offset;
-
-    C1 = table[1];
-    C2 = table[2];
-    C3 = table[3];
-    C4 = table[4];
-    C5 = table[5];
-    C6 = table[6];
-    C7 = table[7];
-
-    a0 = C4*row[0] + C2*row[2] + C4*row[4] + C6*row[6] + *rounder;
-    a1 = C4*row[0] + C6*row[2] - C4*row[4] - C2*row[6] + *rounder;
-    a2 = C4*row[0] - C6*row[2] - C4*row[4] + C2*row[6] + *rounder;
-    a3 = C4*row[0] - C2*row[2] + C4*row[4] - C6*row[6] + *rounder;
-
-    b0 = C1*row[1] + C3*row[3] + C5*row[5] + C7*row[7];
-    b1 = C3*row[1] - C7*row[3] - C1*row[5] - C5*row[7];
-    b2 = C5*row[1] - C1*row[3] + C7*row[5] + C3*row[7];
-    b3 = C7*row[1] - C5*row[3] + C3*row[5] - C1*row[7];
-
-    row[0] = (a0 + b0) >> ROW_SHIFT;
-    row[1] = (a1 + b1) >> ROW_SHIFT;
-    row[2] = (a2 + b2) >> ROW_SHIFT;
-    row[3] = (a3 + b3) >> ROW_SHIFT;
-    row[4] = (a3 - b3) >> ROW_SHIFT;
-    row[5] = (a2 - b2) >> ROW_SHIFT;
-    row[6] = (a1 - b1) >> ROW_SHIFT;
-    row[7] = (a0 - b0) >> ROW_SHIFT;
-}
-#endif
-
-
-/* MMXEXT row IDCT */
-
-#define mmxext_table(c1,c2,c3,c4,c5,c6,c7)	{  c4,  c2, -c4, -c2,	\
-						   c4,  c6,  c4,  c6,	\
-						   c1,  c3, -c1, -c5,	\
-						   c5,  c7,  c3, -c7,	\
-						   c4, -c6,  c4, -c6,	\
-						  -c4,  c2,  c4, -c2,	\
-						   c5, -c1,  c3, -c1,	\
-						   c7,  c3,  c7, -c5 }
-
-static inline void mmxext_row_head (int16_t * row, int offset, const int16_t * table)
-{
-    movq_m2r (*(row+offset), mm2);	// mm2 = x6 x4 x2 x0
-
-    movq_m2r (*(row+offset+4), mm5);	// mm5 = x7 x5 x3 x1
-    movq_r2r (mm2, mm0);		// mm0 = x6 x4 x2 x0
-
-    movq_m2r (*table, mm3);		// mm3 = -C2 -C4 C2 C4
-    movq_r2r (mm5, mm6);		// mm6 = x7 x5 x3 x1
-
-    movq_m2r (*(table+4), mm4);		// mm4 = C6 C4 C6 C4
-    pmaddwd_r2r (mm0, mm3);		// mm3 = -C4*x4-C2*x6 C4*x0+C2*x2
-
-    pshufw_r2r (mm2, mm2, 0x4e);	// mm2 = x2 x0 x6 x4
-}
-
-static inline void mmxext_row (const int16_t * table, const int32_t * rounder)
-{
-    movq_m2r (*(table+8), mm1);		// mm1 = -C5 -C1 C3 C1
-    pmaddwd_r2r (mm2, mm4);		// mm4 = C4*x0+C6*x2 C4*x4+C6*x6
-
-    pmaddwd_m2r (*(table+16), mm0);	// mm0 = C4*x4-C6*x6 C4*x0-C6*x2
-    pshufw_r2r (mm6, mm6, 0x4e);	// mm6 = x3 x1 x7 x5
-
-    movq_m2r (*(table+12), mm7);	// mm7 = -C7 C3 C7 C5
-    pmaddwd_r2r (mm5, mm1);		// mm1 = -C1*x5-C5*x7 C1*x1+C3*x3
-
-    paddd_m2r (*rounder, mm3);		// mm3 += rounder
-    pmaddwd_r2r (mm6, mm7);		// mm7 = C3*x1-C7*x3 C5*x5+C7*x7
-
-    pmaddwd_m2r (*(table+20), mm2);	// mm2 = C4*x0-C2*x2 -C4*x4+C2*x6
-    paddd_r2r (mm4, mm3);		// mm3 = a1 a0 + rounder
-
-    pmaddwd_m2r (*(table+24), mm5);	// mm5 = C3*x5-C1*x7 C5*x1-C1*x3
-    movq_r2r (mm3, mm4);		// mm4 = a1 a0 + rounder
-
-    pmaddwd_m2r (*(table+28), mm6);	// mm6 = C7*x1-C5*x3 C7*x5+C3*x7
-    paddd_r2r (mm7, mm1);		// mm1 = b1 b0
-
-    paddd_m2r (*rounder, mm0);		// mm0 += rounder
-    psubd_r2r (mm1, mm3);		// mm3 = a1-b1 a0-b0 + rounder
-
-    psrad_i2r (ROW_SHIFT, mm3);		// mm3 = y6 y7
-    paddd_r2r (mm4, mm1);		// mm1 = a1+b1 a0+b0 + rounder
-
-    paddd_r2r (mm2, mm0);		// mm0 = a3 a2 + rounder
-    psrad_i2r (ROW_SHIFT, mm1);		// mm1 = y1 y0
-
-    paddd_r2r (mm6, mm5);		// mm5 = b3 b2
-    movq_r2r (mm0, mm4);		// mm4 = a3 a2 + rounder
-
-    paddd_r2r (mm5, mm0);		// mm0 = a3+b3 a2+b2 + rounder
-    psubd_r2r (mm5, mm4);		// mm4 = a3-b3 a2-b2 + rounder
-}
-
-static inline void mmxext_row_tail (int16_t * row, int store)
-{
-    psrad_i2r (ROW_SHIFT, mm0);		// mm0 = y3 y2
-
-    psrad_i2r (ROW_SHIFT, mm4);		// mm4 = y4 y5
-
-    packssdw_r2r (mm0, mm1);		// mm1 = y3 y2 y1 y0
-
-    packssdw_r2r (mm3, mm4);		// mm4 = y6 y7 y4 y5
-
-    movq_r2m (mm1, *(row+store));	// save y3 y2 y1 y0
-    pshufw_r2r (mm4, mm4, 0xb1);	// mm4 = y7 y6 y5 y4
-
-    /* slot */
-
-    movq_r2m (mm4, *(row+store+4));	// save y7 y6 y5 y4
-}
-
-static inline void mmxext_row_mid (int16_t * row, int store,
-				   int offset, const int16_t * table)
-{
-    movq_m2r (*(row+offset), mm2);	// mm2 = x6 x4 x2 x0
-    psrad_i2r (ROW_SHIFT, mm0);		// mm0 = y3 y2
-
-    movq_m2r (*(row+offset+4), mm5);	// mm5 = x7 x5 x3 x1
-    psrad_i2r (ROW_SHIFT, mm4);		// mm4 = y4 y5
-
-    packssdw_r2r (mm0, mm1);		// mm1 = y3 y2 y1 y0
-    movq_r2r (mm5, mm6);		// mm6 = x7 x5 x3 x1
-
-    packssdw_r2r (mm3, mm4);		// mm4 = y6 y7 y4 y5
-    movq_r2r (mm2, mm0);		// mm0 = x6 x4 x2 x0
-
-    movq_r2m (mm1, *(row+store));	// save y3 y2 y1 y0
-    pshufw_r2r (mm4, mm4, 0xb1);	// mm4 = y7 y6 y5 y4
-
-    movq_m2r (*table, mm3);		// mm3 = -C2 -C4 C2 C4
-    movq_r2m (mm4, *(row+store+4));	// save y7 y6 y5 y4
-
-    pmaddwd_r2r (mm0, mm3);		// mm3 = -C4*x4-C2*x6 C4*x0+C2*x2
-
-    movq_m2r (*(table+4), mm4);		// mm4 = C6 C4 C6 C4
-    pshufw_r2r (mm2, mm2, 0x4e);	// mm2 = x2 x0 x6 x4
-}
-
-
-/* MMX row IDCT */
-
-#define mmx_table(c1,c2,c3,c4,c5,c6,c7)	{  c4,  c2,  c4,  c6,	\
-					   c4,  c6, -c4, -c2,	\
-					   c1,  c3,  c3, -c7,	\
-					   c5,  c7, -c1, -c5,	\
-					   c4, -c6,  c4, -c2,	\
-					  -c4,  c2,  c4, -c6,	\
-					   c5, -c1,  c7, -c5,	\
-					   c7,  c3,  c3, -c1 }
-
-static inline void mmx_row_head (int16_t * row, int offset, const int16_t * table)
-{
-    movq_m2r (*(row+offset), mm2);	// mm2 = x6 x4 x2 x0
-
-    movq_m2r (*(row+offset+4), mm5);	// mm5 = x7 x5 x3 x1
-    movq_r2r (mm2, mm0);		// mm0 = x6 x4 x2 x0
-
-    movq_m2r (*table, mm3);		// mm3 = C6 C4 C2 C4
-    movq_r2r (mm5, mm6);		// mm6 = x7 x5 x3 x1
-
-    punpckldq_r2r (mm0, mm0);		// mm0 = x2 x0 x2 x0
-
-    movq_m2r (*(table+4), mm4);		// mm4 = -C2 -C4 C6 C4
-    pmaddwd_r2r (mm0, mm3);		// mm3 = C4*x0+C6*x2 C4*x0+C2*x2
-
-    movq_m2r (*(table+8), mm1);		// mm1 = -C7 C3 C3 C1
-    punpckhdq_r2r (mm2, mm2);		// mm2 = x6 x4 x6 x4
-}
-
-static inline void mmx_row (const int16_t * table, const int32_t * rounder)
-{
-    pmaddwd_r2r (mm2, mm4);		// mm4 = -C4*x4-C2*x6 C4*x4+C6*x6
-    punpckldq_r2r (mm5, mm5);		// mm5 = x3 x1 x3 x1
-
-    pmaddwd_m2r (*(table+16), mm0);	// mm0 = C4*x0-C2*x2 C4*x0-C6*x2
-    punpckhdq_r2r (mm6, mm6);		// mm6 = x7 x5 x7 x5
-
-    movq_m2r (*(table+12), mm7);	// mm7 = -C5 -C1 C7 C5
-    pmaddwd_r2r (mm5, mm1);		// mm1 = C3*x1-C7*x3 C1*x1+C3*x3
-
-    paddd_m2r (*rounder, mm3);		// mm3 += rounder
-    pmaddwd_r2r (mm6, mm7);		// mm7 = -C1*x5-C5*x7 C5*x5+C7*x7
-
-    pmaddwd_m2r (*(table+20), mm2);	// mm2 = C4*x4-C6*x6 -C4*x4+C2*x6
-    paddd_r2r (mm4, mm3);		// mm3 = a1 a0 + rounder
-
-    pmaddwd_m2r (*(table+24), mm5);	// mm5 = C7*x1-C5*x3 C5*x1-C1*x3
-    movq_r2r (mm3, mm4);		// mm4 = a1 a0 + rounder
-
-    pmaddwd_m2r (*(table+28), mm6);	// mm6 = C3*x5-C1*x7 C7*x5+C3*x7
-    paddd_r2r (mm7, mm1);		// mm1 = b1 b0
-
-    paddd_m2r (*rounder, mm0);		// mm0 += rounder
-    psubd_r2r (mm1, mm3);		// mm3 = a1-b1 a0-b0 + rounder
-
-    psrad_i2r (ROW_SHIFT, mm3);		// mm3 = y6 y7
-    paddd_r2r (mm4, mm1);		// mm1 = a1+b1 a0+b0 + rounder
-
-    paddd_r2r (mm2, mm0);		// mm0 = a3 a2 + rounder
-    psrad_i2r (ROW_SHIFT, mm1);		// mm1 = y1 y0
-
-    paddd_r2r (mm6, mm5);		// mm5 = b3 b2
-    movq_r2r (mm0, mm7);		// mm7 = a3 a2 + rounder
-
-    paddd_r2r (mm5, mm0);		// mm0 = a3+b3 a2+b2 + rounder
-    psubd_r2r (mm5, mm7);		// mm7 = a3-b3 a2-b2 + rounder
-}
-
-static inline void mmx_row_tail (int16_t * row, int store)
-{
-    psrad_i2r (ROW_SHIFT, mm0);		// mm0 = y3 y2
-
-    psrad_i2r (ROW_SHIFT, mm7);		// mm7 = y4 y5
-
-    packssdw_r2r (mm0, mm1);		// mm1 = y3 y2 y1 y0
-
-    packssdw_r2r (mm3, mm7);		// mm7 = y6 y7 y4 y5
-
-    movq_r2m (mm1, *(row+store));	// save y3 y2 y1 y0
-    movq_r2r (mm7, mm4);		// mm4 = y6 y7 y4 y5
-
-    pslld_i2r (16, mm7);		// mm7 = y7 0 y5 0
-
-    psrld_i2r (16, mm4);		// mm4 = 0 y6 0 y4
-
-    por_r2r (mm4, mm7);			// mm7 = y7 y6 y5 y4
-
-    /* slot */
-
-    movq_r2m (mm7, *(row+store+4));	// save y7 y6 y5 y4
-}
-
-static inline void mmx_row_mid (int16_t * row, int store,
-				int offset, const int16_t * table)
-{
-    movq_m2r (*(row+offset), mm2);	// mm2 = x6 x4 x2 x0
-    psrad_i2r (ROW_SHIFT, mm0);		// mm0 = y3 y2
-
-    movq_m2r (*(row+offset+4), mm5);	// mm5 = x7 x5 x3 x1
-    psrad_i2r (ROW_SHIFT, mm7);		// mm7 = y4 y5
-
-    packssdw_r2r (mm0, mm1);		// mm1 = y3 y2 y1 y0
-    movq_r2r (mm5, mm6);		// mm6 = x7 x5 x3 x1
-
-    packssdw_r2r (mm3, mm7);		// mm7 = y6 y7 y4 y5
-    movq_r2r (mm2, mm0);		// mm0 = x6 x4 x2 x0
-
-    movq_r2m (mm1, *(row+store));	// save y3 y2 y1 y0
-    movq_r2r (mm7, mm1);		// mm1 = y6 y7 y4 y5
-
-    punpckldq_r2r (mm0, mm0);		// mm0 = x2 x0 x2 x0
-    psrld_i2r (16, mm7);		// mm7 = 0 y6 0 y4
-
-    movq_m2r (*table, mm3);		// mm3 = C6 C4 C2 C4
-    pslld_i2r (16, mm1);		// mm1 = y7 0 y5 0
-
-    movq_m2r (*(table+4), mm4);		// mm4 = -C2 -C4 C6 C4
-    por_r2r (mm1, mm7);			// mm7 = y7 y6 y5 y4
-
-    movq_m2r (*(table+8), mm1);		// mm1 = -C7 C3 C3 C1
-    punpckhdq_r2r (mm2, mm2);		// mm2 = x6 x4 x6 x4
-
-    movq_r2m (mm7, *(row+store+4));	// save y7 y6 y5 y4
-    pmaddwd_r2r (mm0, mm3);		// mm3 = C4*x0+C6*x2 C4*x0+C2*x2
-}
-
-
-#if 0
-// C column IDCT - its just here to document the MMXEXT and MMX versions
-static inline void idct_col (int16_t * col, int offset)
-{
-/* multiplication - as implemented on mmx */
-#define F(c,x) (((c) * (x)) >> 16)
-
-/* saturation - it helps us handle torture test cases */
-#define S(x) (((x)>32767) ? 32767 : ((x)<-32768) ? -32768 : (x))
-
-    int16_t x0, x1, x2, x3, x4, x5, x6, x7;
-    int16_t y0, y1, y2, y3, y4, y5, y6, y7;
-    int16_t a0, a1, a2, a3, b0, b1, b2, b3;
-    int16_t u04, v04, u26, v26, u17, v17, u35, v35, u12, v12;
-
-    col += offset;
-
-    x0 = col[0*8];
-    x1 = col[1*8];
-    x2 = col[2*8];
-    x3 = col[3*8];
-    x4 = col[4*8];
-    x5 = col[5*8];
-    x6 = col[6*8];
-    x7 = col[7*8];
-
-    u04 = S (x0 + x4);
-    v04 = S (x0 - x4);
-    u26 = S (F (T2, x6) + x2);
-    v26 = S (F (T2, x2) - x6);
-
-    a0 = S (u04 + u26);
-    a1 = S (v04 + v26);
-    a2 = S (v04 - v26);
-    a3 = S (u04 - u26);
-
-    u17 = S (F (T1, x7) + x1);
-    v17 = S (F (T1, x1) - x7);
-    u35 = S (F (T3, x5) + x3);
-    v35 = S (F (T3, x3) - x5);
-
-    b0 = S (u17 + u35);
-    b3 = S (v17 - v35);
-    u12 = S (u17 - u35);
-    v12 = S (v17 + v35);
-    u12 = S (2 * F (C4, u12));
-    v12 = S (2 * F (C4, v12));
-    b1 = S (u12 + v12);
-    b2 = S (u12 - v12);
-
-    y0 = S (a0 + b0) >> COL_SHIFT;
-    y1 = S (a1 + b1) >> COL_SHIFT;
-    y2 = S (a2 + b2) >> COL_SHIFT;
-    y3 = S (a3 + b3) >> COL_SHIFT;
-
-    y4 = S (a3 - b3) >> COL_SHIFT;
-    y5 = S (a2 - b2) >> COL_SHIFT;
-    y6 = S (a1 - b1) >> COL_SHIFT;
-    y7 = S (a0 - b0) >> COL_SHIFT;
-
-    col[0*8] = y0;
-    col[1*8] = y1;
-    col[2*8] = y2;
-    col[3*8] = y3;
-    col[4*8] = y4;
-    col[5*8] = y5;
-    col[6*8] = y6;
-    col[7*8] = y7;
-}
-#endif
-
-
-// MMX column IDCT
-static inline void idct_col (int16_t * col, int offset)
-{
-#define T1 13036
-#define T2 27146
-#define T3 43790
-#define C4 23170
-
-    static const short _T1[] ATTR_ALIGN(8) = {T1,T1,T1,T1};
-    static const short _T2[] ATTR_ALIGN(8) = {T2,T2,T2,T2};
-    static const short _T3[] ATTR_ALIGN(8) = {T3,T3,T3,T3};
-    static const short _C4[] ATTR_ALIGN(8) = {C4,C4,C4,C4};
-
-    /* column code adapted from peter gubanov */
-    /* http://www.elecard.com/peter/idct.shtml */
-
-    movq_m2r (*_T1, mm0);		// mm0 = T1
-
-    movq_m2r (*(col+offset+1*8), mm1);	// mm1 = x1
-    movq_r2r (mm0, mm2);		// mm2 = T1
-
-    movq_m2r (*(col+offset+7*8), mm4);	// mm4 = x7
-    pmulhw_r2r (mm1, mm0);		// mm0 = T1*x1
-
-    movq_m2r (*_T3, mm5);		// mm5 = T3
-    pmulhw_r2r (mm4, mm2);		// mm2 = T1*x7
-
-    movq_m2r (*(col+offset+5*8), mm6);	// mm6 = x5
-    movq_r2r (mm5, mm7);		// mm7 = T3-1
-
-    movq_m2r (*(col+offset+3*8), mm3);	// mm3 = x3
-    psubsw_r2r (mm4, mm0);		// mm0 = v17
-
-    movq_m2r (*_T2, mm4);		// mm4 = T2
-    pmulhw_r2r (mm3, mm5);		// mm5 = (T3-1)*x3
-
-    paddsw_r2r (mm2, mm1);		// mm1 = u17
-    pmulhw_r2r (mm6, mm7);		// mm7 = (T3-1)*x5
-
-    /* slot */
-
-    movq_r2r (mm4, mm2);		// mm2 = T2
-    paddsw_r2r (mm3, mm5);		// mm5 = T3*x3
-
-    pmulhw_m2r (*(col+offset+2*8), mm4);// mm4 = T2*x2
-    paddsw_r2r (mm6, mm7);		// mm7 = T3*x5
-
-    psubsw_r2r (mm6, mm5);		// mm5 = v35
-    paddsw_r2r (mm3, mm7);		// mm7 = u35
-
-    movq_m2r (*(col+offset+6*8), mm3);	// mm3 = x6
-    movq_r2r (mm0, mm6);		// mm6 = v17
-
-    pmulhw_r2r (mm3, mm2);		// mm2 = T2*x6
-    psubsw_r2r (mm5, mm0);		// mm0 = b3
-
-    psubsw_r2r (mm3, mm4);		// mm4 = v26
-    paddsw_r2r (mm6, mm5);		// mm5 = v12
-
-    movq_r2m (mm0, *(col+offset+3*8));	// save b3 in scratch0
-    movq_r2r (mm1, mm6);		// mm6 = u17
-
-    paddsw_m2r (*(col+offset+2*8), mm2);// mm2 = u26
-    paddsw_r2r (mm7, mm6);		// mm6 = b0
-
-    psubsw_r2r (mm7, mm1);		// mm1 = u12
-    movq_r2r (mm1, mm7);		// mm7 = u12
-
-    movq_m2r (*(col+offset+0*8), mm3);	// mm3 = x0
-    paddsw_r2r (mm5, mm1);		// mm1 = u12+v12
-
-    movq_m2r (*_C4, mm0);		// mm0 = C4/2
-    psubsw_r2r (mm5, mm7);		// mm7 = u12-v12
-
-    movq_r2m (mm6, *(col+offset+5*8));	// save b0 in scratch1
-    pmulhw_r2r (mm0, mm1);		// mm1 = b1/2
-
-    movq_r2r (mm4, mm6);		// mm6 = v26
-    pmulhw_r2r (mm0, mm7);		// mm7 = b2/2
-
-    movq_m2r (*(col+offset+4*8), mm5);	// mm5 = x4
-    movq_r2r (mm3, mm0);		// mm0 = x0
-
-    psubsw_r2r (mm5, mm3);		// mm3 = v04
-    paddsw_r2r (mm5, mm0);		// mm0 = u04
-
-    paddsw_r2r (mm3, mm4);		// mm4 = a1
-    movq_r2r (mm0, mm5);		// mm5 = u04
-
-    psubsw_r2r (mm6, mm3);		// mm3 = a2
-    paddsw_r2r (mm2, mm5);		// mm5 = a0
-
-    paddsw_r2r (mm1, mm1);		// mm1 = b1
-    psubsw_r2r (mm2, mm0);		// mm0 = a3
-
-    paddsw_r2r (mm7, mm7);		// mm7 = b2
-    movq_r2r (mm3, mm2);		// mm2 = a2
-
-    movq_r2r (mm4, mm6);		// mm6 = a1
-    paddsw_r2r (mm7, mm3);		// mm3 = a2+b2
-
-    psraw_i2r (COL_SHIFT, mm3);		// mm3 = y2
-    paddsw_r2r (mm1, mm4);		// mm4 = a1+b1
-
-    psraw_i2r (COL_SHIFT, mm4);		// mm4 = y1
-    psubsw_r2r (mm1, mm6);		// mm6 = a1-b1
-
-    movq_m2r (*(col+offset+5*8), mm1);	// mm1 = b0
-    psubsw_r2r (mm7, mm2);		// mm2 = a2-b2
-
-    psraw_i2r (COL_SHIFT, mm6);		// mm6 = y6
-    movq_r2r (mm5, mm7);		// mm7 = a0
-
-    movq_r2m (mm4, *(col+offset+1*8));	// save y1
-    psraw_i2r (COL_SHIFT, mm2);		// mm2 = y5
-
-    movq_r2m (mm3, *(col+offset+2*8));	// save y2
-    paddsw_r2r (mm1, mm5);		// mm5 = a0+b0
-
-    movq_m2r (*(col+offset+3*8), mm4);	// mm4 = b3
-    psubsw_r2r (mm1, mm7);		// mm7 = a0-b0
-
-    psraw_i2r (COL_SHIFT, mm5);		// mm5 = y0
-    movq_r2r (mm0, mm3);		// mm3 = a3
-
-    movq_r2m (mm2, *(col+offset+5*8));	// save y5
-    psubsw_r2r (mm4, mm3);		// mm3 = a3-b3
-
-    psraw_i2r (COL_SHIFT, mm7);		// mm7 = y7
-    paddsw_r2r (mm0, mm4);		// mm4 = a3+b3
-
-    movq_r2m (mm5, *(col+offset+0*8));	// save y0
-    psraw_i2r (COL_SHIFT, mm3);		// mm3 = y4
-
-    movq_r2m (mm6, *(col+offset+6*8));	// save y6
-    psraw_i2r (COL_SHIFT, mm4);		// mm4 = y3
-
-    movq_r2m (mm7, *(col+offset+7*8));	// save y7
-
-    movq_r2m (mm3, *(col+offset+4*8));	// save y4
-
-    movq_r2m (mm4, *(col+offset+3*8));	// save y3
-
-#undef T1
-#undef T2
-#undef T3
-#undef C4
-}
-
-static const int32_t rounder0[] ATTR_ALIGN(8) =
-    rounder ((1 << (COL_SHIFT - 1)) - 0.5);
-static const int32_t rounder4[] ATTR_ALIGN(8) = rounder (0);
-static const int32_t rounder1[] ATTR_ALIGN(8) =
-    rounder (1.25683487303);	/* C1*(C1/C4+C1+C7)/2 */
-static const int32_t rounder7[] ATTR_ALIGN(8) =
-    rounder (-0.25);		/* C1*(C7/C4+C7-C1)/2 */
-static const int32_t rounder2[] ATTR_ALIGN(8) =
-    rounder (0.60355339059);	/* C2 * (C6+C2)/2 */
-static const int32_t rounder6[] ATTR_ALIGN(8) =
-    rounder (-0.25);		/* C2 * (C6-C2)/2 */
-static const int32_t rounder3[] ATTR_ALIGN(8) =
-    rounder (0.087788325588);	/* C3*(-C3/C4+C3+C5)/2 */
-static const int32_t rounder5[] ATTR_ALIGN(8) =
-    rounder (-0.441341716183);	/* C3*(-C5/C4+C5-C3)/2 */
-
-#undef COL_SHIFT
-#undef ROW_SHIFT
-
-#define declare_idct(idct,table,idct_row_head,idct_row,idct_row_tail,idct_row_mid)	\
-void idct (int16_t * block)					\
-{									\
-    static const int16_t table04[] ATTR_ALIGN(16) =				\
-	table (22725, 21407, 19266, 16384, 12873,  8867, 4520);		\
-    static const int16_t table17[] ATTR_ALIGN(16) =				\
-	table (31521, 29692, 26722, 22725, 17855, 12299, 6270);		\
-    static const int16_t table26[] ATTR_ALIGN(16) =				\
-	table (29692, 27969, 25172, 21407, 16819, 11585, 5906);		\
-    static const int16_t table35[] ATTR_ALIGN(16) =				\
-	table (26722, 25172, 22654, 19266, 15137, 10426, 5315);		\
-									\
-    idct_row_head (block, 0*8, table04);				\
-    idct_row (table04, rounder0);					\
-    idct_row_mid (block, 0*8, 4*8, table04);				\
-    idct_row (table04, rounder4);					\
-    idct_row_mid (block, 4*8, 1*8, table17);				\
-    idct_row (table17, rounder1);					\
-    idct_row_mid (block, 1*8, 7*8, table17);				\
-    idct_row (table17, rounder7);					\
-    idct_row_mid (block, 7*8, 2*8, table26);				\
-    idct_row (table26, rounder2);					\
-    idct_row_mid (block, 2*8, 6*8, table26);				\
-    idct_row (table26, rounder6);					\
-    idct_row_mid (block, 6*8, 3*8, table35);				\
-    idct_row (table35, rounder3);					\
-    idct_row_mid (block, 3*8, 5*8, table35);				\
-    idct_row (table35, rounder5);					\
-    idct_row_tail (block, 5*8);						\
-									\
-    idct_col (block, 0);						\
-    idct_col (block, 4);						\
-}
-
-void ff_mmx_idct(DCTELEM *block);
-void ff_mmxext_idct(DCTELEM *block);
-
-declare_idct (ff_mmxext_idct, mmxext_table,
-	      mmxext_row_head, mmxext_row, mmxext_row_tail, mmxext_row_mid)
-
-declare_idct (ff_mmx_idct, mmx_table,
-	      mmx_row_head, mmx_row, mmx_row_tail, mmx_row_mid)
-
diff --git a/ffmpeg.src/libavcodec/i386/idct_mmx_xvid.c b/ffmpeg.src/libavcodec/i386/idct_mmx_xvid.c
deleted file mode 100644
index 943c50f..0000000
--- a/ffmpeg.src/libavcodec/i386/idct_mmx_xvid.c
+++ /dev/null
@@ -1,533 +0,0 @@
-///****************************************************************************
-// *
-// *  XVID MPEG-4 VIDEO CODEC
-// *  - MMX and XMM forward discrete cosine transform -
-// *
-// *  Copyright(C) 2001 Peter Ross <pross at xvid.org>
-// *
-// *  This program 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.
-// *
-// *  This program 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 this program; if not, write to the Free Software
-// *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-// *
-// * $Id$
-// *
-// ***************************************************************************/
-
-// ****************************************************************************
-//
-// Originally provided by Intel at AP-922
-// http://developer.intel.com/vtune/cbts/strmsimd/922down.htm
-// (See more app notes at http://developer.intel.com/vtune/cbts/strmsimd/appnotes.htm)
-// but in a limited edition.
-// New macro implements a column part for precise iDCT
-// The routine precision now satisfies IEEE standard 1180-1990.
-//
-// Copyright(C) 2000-2001 Peter Gubanov <peter at elecard.net.ru>
-// Rounding trick Copyright(C) 2000 Michel Lespinasse <walken at zoy.org>
-//
-// http://www.elecard.com/peter/idct.html
-// http://www.linuxvideo.org/mpeg2dec/
-//
-// ***************************************************************************/
-//
-// These examples contain code fragments for first stage iDCT 8x8
-// (for rows) and first stage DCT 8x8 (for columns)
-//
-
-// conversion to gcc syntax by michael niedermayer
-
-
-#include <inttypes.h>
-#include "../avcodec.h"
-
-//=============================================================================
-// Macros and other preprocessor constants
-//=============================================================================
-
-#define BITS_INV_ACC    5                              // 4 or 5 for IEEE
-#define SHIFT_INV_ROW   (16 - BITS_INV_ACC) //11
-#define SHIFT_INV_COL   (1 + BITS_INV_ACC) //6
-#define RND_INV_ROW     (1024 * (6 - BITS_INV_ACC))
-#define RND_INV_COL     (16 * (BITS_INV_ACC - 3))
-#define RND_INV_CORR    (RND_INV_COL - 1)
-
-#define BITS_FRW_ACC    3                              // 2 or 3 for accuracy
-#define SHIFT_FRW_COL   BITS_FRW_ACC
-#define SHIFT_FRW_ROW   (BITS_FRW_ACC + 17)
-#define RND_FRW_ROW     (262144*(BITS_FRW_ACC - 1))
-
-
-//-----------------------------------------------------------------------------
-// Various memory constants (trigonometric values or rounding values)
-//-----------------------------------------------------------------------------
-
-
-static const int16_t tg_1_16[4*4] attribute_used __attribute__ ((aligned(8))) = { 
-  13036,13036,13036,13036,        // tg * (2<<16) + 0.5
-  27146,27146,27146,27146,        // tg * (2<<16) + 0.5
-  -21746,-21746,-21746,-21746,    // tg * (2<<16) + 0.5
-  23170,23170,23170,23170};       // cos * (2<<15) + 0.5
-
-static const int32_t rounder_0[2*8] attribute_used __attribute__ ((aligned(8))) = { 
-  65536,65536,
-  3597,3597,
-  2260,2260,
-  1203,1203,
-  0,0,
-  120,120,
-  512,512,
-  512,512};
-
-//-----------------------------------------------------------------------------
-//
-// The first stage iDCT 8x8 - inverse DCTs of rows
-//
-//-----------------------------------------------------------------------------
-// The 8-point inverse DCT direct algorithm
-//-----------------------------------------------------------------------------
-//
-// static const short w[32] = {
-//       FIX(cos_4_16),  FIX(cos_2_16),  FIX(cos_4_16),  FIX(cos_6_16),
-//       FIX(cos_4_16),  FIX(cos_6_16), -FIX(cos_4_16), -FIX(cos_2_16),
-//       FIX(cos_4_16), -FIX(cos_6_16), -FIX(cos_4_16),  FIX(cos_2_16),
-//       FIX(cos_4_16), -FIX(cos_2_16),  FIX(cos_4_16), -FIX(cos_6_16),
-//       FIX(cos_1_16),  FIX(cos_3_16),  FIX(cos_5_16),  FIX(cos_7_16),
-//       FIX(cos_3_16), -FIX(cos_7_16), -FIX(cos_1_16), -FIX(cos_5_16),
-//       FIX(cos_5_16), -FIX(cos_1_16),  FIX(cos_7_16),  FIX(cos_3_16),
-//       FIX(cos_7_16), -FIX(cos_5_16),  FIX(cos_3_16), -FIX(cos_1_16) };
-//
-// #define DCT_8_INV_ROW(x, y)
-// {
-//       int a0, a1, a2, a3, b0, b1, b2, b3;
-//
-//       a0 =x[0]*w[0]+x[2]*w[1]+x[4]*w[2]+x[6]*w[3];
-//       a1 =x[0]*w[4]+x[2]*w[5]+x[4]*w[6]+x[6]*w[7];
-//       a2 = x[0] * w[ 8] + x[2] * w[ 9] + x[4] * w[10] + x[6] * w[11];
-//       a3 = x[0] * w[12] + x[2] * w[13] + x[4] * w[14] + x[6] * w[15];
-//       b0 = x[1] * w[16] + x[3] * w[17] + x[5] * w[18] + x[7] * w[19];
-//       b1 = x[1] * w[20] + x[3] * w[21] + x[5] * w[22] + x[7] * w[23];
-//       b2 = x[1] * w[24] + x[3] * w[25] + x[5] * w[26] + x[7] * w[27];
-//       b3 = x[1] * w[28] + x[3] * w[29] + x[5] * w[30] + x[7] * w[31];
-//
-//       y[0] = SHIFT_ROUND ( a0 + b0 );
-//       y[1] = SHIFT_ROUND ( a1 + b1 );
-//       y[2] = SHIFT_ROUND ( a2 + b2 );
-//       y[3] = SHIFT_ROUND ( a3 + b3 );
-//       y[4] = SHIFT_ROUND ( a3 - b3 );
-//       y[5] = SHIFT_ROUND ( a2 - b2 );
-//       y[6] = SHIFT_ROUND ( a1 - b1 );
-//       y[7] = SHIFT_ROUND ( a0 - b0 );
-// }
-//
-//-----------------------------------------------------------------------------
-//
-// In this implementation the outputs of the iDCT-1D are multiplied
-//       for rows 0,4 - by cos_4_16,
-//       for rows 1,7 - by cos_1_16,
-//       for rows 2,6 - by cos_2_16,
-//       for rows 3,5 - by cos_3_16
-// and are shifted to the left for better accuracy
-//
-// For the constants used,
-//       FIX(float_const) = (short) (float_const * (1<<15) + 0.5)
-//
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-// Tables for mmx processors
-//-----------------------------------------------------------------------------
-
-// Table for rows 0,4 - constants are multiplied by cos_4_16
-static const int16_t tab_i_04_mmx[32*4] attribute_used __attribute__ ((aligned(8))) = { 
-  16384,16384,16384,-16384,       // movq-> w06 w04 w02 w00
-  21407,8867,8867,-21407,         // w07 w05 w03 w01
-  16384,-16384,16384,16384,       // w14 w12 w10 w08
-  -8867,21407,-21407,-8867,       // w15 w13 w11 w09
-  22725,12873,19266,-22725,       // w22 w20 w18 w16
-  19266,4520,-4520,-12873,        // w23 w21 w19 w17
-  12873,4520,4520,19266,          // w30 w28 w26 w24
-  -22725,19266,-12873,-22725,     // w31 w29 w27 w25
-// Table for rows 1,7 - constants are multiplied by cos_1_16
-  22725,22725,22725,-22725,       // movq-> w06 w04 w02 w00
-  29692,12299,12299,-29692,       // w07 w05 w03 w01
-  22725,-22725,22725,22725,       // w14 w12 w10 w08
-  -12299,29692,-29692,-12299,     // w15 w13 w11 w09
-  31521,17855,26722,-31521,       // w22 w20 w18 w16
-  26722,6270,-6270,-17855,        // w23 w21 w19 w17
-  17855,6270,6270,26722,          // w30 w28 w26 w24
-  -31521,26722,-17855,-31521,     // w31 w29 w27 w25
-// Table for rows 2,6 - constants are multiplied by cos_2_16
-  21407,21407,21407,-21407,       // movq-> w06 w04 w02 w00
-  27969,11585,11585,-27969,       // w07 w05 w03 w01
-  21407,-21407,21407,21407,       // w14 w12 w10 w08
-  -11585,27969,-27969,-11585,     // w15 w13 w11 w09
-  29692,16819,25172,-29692,       // w22 w20 w18 w16
-  25172,5906,-5906,-16819,        // w23 w21 w19 w17
-  16819,5906,5906,25172,          // w30 w28 w26 w24
-  -29692,25172,-16819,-29692,     // w31 w29 w27 w25
-// Table for rows 3,5 - constants are multiplied by cos_3_16
-  19266,19266,19266,-19266,       // movq-> w06 w04 w02 w00
-  25172,10426,10426,-25172,       // w07 w05 w03 w01
-  19266,-19266,19266,19266,       // w14 w12 w10 w08
-  -10426,25172,-25172,-10426,     // w15 w13 w11 w09
-  26722,15137,22654,-26722,       // w22 w20 w18 w16
-  22654,5315,-5315,-15137,        // w23 w21 w19 w17
-  15137,5315,5315,22654,          // w30 w28 w26 w24
-  -26722,22654,-15137,-26722,     // w31 w29 w27 w25
-};
-//-----------------------------------------------------------------------------
-// Tables for xmm processors
-//-----------------------------------------------------------------------------
-
-// %3 for rows 0,4 - constants are multiplied by cos_4_16
-static const int16_t tab_i_04_xmm[32*4] attribute_used __attribute__ ((aligned(8))) = { 
-  16384,21407,16384,8867,      // movq-> w05 w04 w01 w00
-  16384,8867,-16384,-21407,    // w07 w06 w03 w02
-  16384,-8867,16384,-21407,    // w13 w12 w09 w08
-  -16384,21407,16384,-8867,    // w15 w14 w11 w10
-  22725,19266,19266,-4520,     // w21 w20 w17 w16
-  12873,4520,-22725,-12873,    // w23 w22 w19 w18
-  12873,-22725,4520,-12873,    // w29 w28 w25 w24
-  4520,19266,19266,-22725,     // w31 w30 w27 w26
-// %3 for rows 1,7 - constants are multiplied by cos_1_16
-  22725,29692,22725,12299,     // movq-> w05 w04 w01 w00
-  22725,12299,-22725,-29692,   // w07 w06 w03 w02
-  22725,-12299,22725,-29692,   // w13 w12 w09 w08
-  -22725,29692,22725,-12299,   // w15 w14 w11 w10
-  31521,26722,26722,-6270,     // w21 w20 w17 w16
-  17855,6270,-31521,-17855,    // w23 w22 w19 w18
-  17855,-31521,6270,-17855,    // w29 w28 w25 w24
-  6270,26722,26722,-31521,     // w31 w30 w27 w26
-// %3 for rows 2,6 - constants are multiplied by cos_2_16
-  21407,27969,21407,11585,     // movq-> w05 w04 w01 w00
-  21407,11585,-21407,-27969,   // w07 w06 w03 w02
-  21407,-11585,21407,-27969,   // w13 w12 w09 w08
-  -21407,27969,21407,-11585,   // w15 w14 w11 w10
-  29692,25172,25172,-5906,     // w21 w20 w17 w16
-  16819,5906,-29692,-16819,    // w23 w22 w19 w18
-  16819,-29692,5906,-16819,    // w29 w28 w25 w24
-  5906,25172,25172,-29692,     // w31 w30 w27 w26
-// %3 for rows 3,5 - constants are multiplied by cos_3_16
-  19266,25172,19266,10426,     // movq-> w05 w04 w01 w00
-  19266,10426,-19266,-25172,   // w07 w06 w03 w02
-  19266,-10426,19266,-25172,   // w13 w12 w09 w08
-  -19266,25172,19266,-10426,   // w15 w14 w11 w10
-  26722,22654,22654,-5315,     // w21 w20 w17 w16
-  15137,5315,-26722,-15137,    // w23 w22 w19 w18
-  15137,-26722,5315,-15137,    // w29 w28 w25 w24
-  5315,22654,22654,-26722,     // w31 w30 w27 w26
-};
-//=============================================================================
-// Helper macros for the code
-//=============================================================================
-
-//-----------------------------------------------------------------------------
-// DCT_8_INV_ROW_MMX( INP, OUT, TABLE, ROUNDER
-//-----------------------------------------------------------------------------
-
-#define DCT_8_INV_ROW_MMX(A1,A2,A3,A4)\
-  "movq " #A1 ",%%mm0              \n\t"/* 0 ; x3 x2 x1 x0*/\
-  "movq 8+" #A1 ",%%mm1            \n\t"/* 1 ; x7 x6 x5 x4*/\
-  "movq %%mm0,%%mm2            \n\t"/* 2  ; x3 x2 x1 x0*/\
-  "movq " #A3 ",%%mm3              \n\t"/* 3 ; w06 w04 w02 w00*/\
-  "punpcklwd %%mm1,%%mm0       \n\t"/* x5 x1 x4 x0*/\
-  "movq %%mm0,%%mm5            \n\t"/* 5 ; x5 x1 x4 x0*/\
-  "punpckldq %%mm0,%%mm0       \n\t"/* x4 x0 x4 x0*/\
-  "movq 8+" #A3 ",%%mm4            \n\t"/* 4 ; w07 w05 w03 w01*/\
-  "punpckhwd %%mm1,%%mm2       \n\t"/* 1 ; x7 x3 x6 x2*/\
-  "pmaddwd %%mm0,%%mm3         \n\t"/* x4*w06+x0*w04 x4*w02+x0*w00*/\
-  "movq %%mm2,%%mm6            \n\t"/* 6 ; x7 x3 x6 x2*/\
-  "movq 32+" #A3 ",%%mm1           \n\t"/* 1 ; w22 w20 w18 w16*/\
-  "punpckldq %%mm2,%%mm2       \n\t"/* x6 x2 x6 x2*/\
-  "pmaddwd %%mm2,%%mm4         \n\t"/* x6*w07+x2*w05 x6*w03+x2*w01*/\
-  "punpckhdq %%mm5,%%mm5       \n\t"/* x5 x1 x5 x1*/\
-  "pmaddwd 16+" #A3 ",%%mm0        \n\t"/* x4*w14+x0*w12 x4*w10+x0*w08*/\
-  "punpckhdq %%mm6,%%mm6       \n\t"/* x7 x3 x7 x3*/\
-  "movq 40+" #A3 ",%%mm7           \n\t"/* 7 ; w23 w21 w19 w17*/\
-  "pmaddwd %%mm5,%%mm1         \n\t"/* x5*w22+x1*w20 x5*w18+x1*w16*/\
-  "paddd " #A4 ",%%mm3             \n\t"/* +%4*/\
-  "pmaddwd %%mm6,%%mm7         \n\t"/* x7*w23+x3*w21 x7*w19+x3*w17*/\
-  "pmaddwd 24+" #A3 ",%%mm2        \n\t"/* x6*w15+x2*w13 x6*w11+x2*w09*/\
-  "paddd %%mm4,%%mm3           \n\t"/* 4 ; a1=sum(even1) a0=sum(even0)*/\
-  "pmaddwd 48+" #A3 ",%%mm5        \n\t"/* x5*w30+x1*w28 x5*w26+x1*w24*/\
-  "movq %%mm3,%%mm4            \n\t"/* 4 ; a1 a0*/\
-  "pmaddwd 56+" #A3 ",%%mm6        \n\t"/* x7*w31+x3*w29 x7*w27+x3*w25*/\
-  "paddd %%mm7,%%mm1           \n\t"/* 7 ; b1=sum(odd1) b0=sum(odd0)*/\
-  "paddd " #A4 ",%%mm0             \n\t"/* +%4*/\
-  "psubd %%mm1,%%mm3           \n\t"/* a1-b1 a0-b0*/\
-  "psrad $11,%%mm3 \n\t"/* y6=a1-b1 y7=a0-b0*/\
-  "paddd %%mm4,%%mm1           \n\t"/* 4 ; a1+b1 a0+b0*/\
-  "paddd %%mm2,%%mm0           \n\t"/* 2 ; a3=sum(even3) a2=sum(even2)*/\
-  "psrad $11,%%mm1 \n\t"/* y1=a1+b1 y0=a0+b0*/\
-  "paddd %%mm6,%%mm5           \n\t"/* 6 ; b3=sum(odd3) b2=sum(odd2)*/\
-  "movq %%mm0,%%mm4            \n\t"/* 4 ; a3 a2*/\
-  "paddd %%mm5,%%mm0           \n\t"/* a3+b3 a2+b2*/\
-  "psubd %%mm5,%%mm4           \n\t"/* 5 ; a3-b3 a2-b2*/\
-  "psrad $11,%%mm0 \n\t"/* y3=a3+b3 y2=a2+b2*/\
-  "psrad $11,%%mm4 \n\t"/* y4=a3-b3 y5=a2-b2*/\
-  "packssdw %%mm0,%%mm1        \n\t"/* 0 ; y3 y2 y1 y0*/\
-  "packssdw %%mm3,%%mm4        \n\t"/* 3 ; y6 y7 y4 y5*/\
-  "movq %%mm4,%%mm7            \n\t"/* 7 ; y6 y7 y4 y5*/\
-  "psrld $16,%%mm4            \n\t"/* 0 y6 0 y4*/\
-  "pslld $16,%%mm7            \n\t"/* y7 0 y5 0*/\
-  "movq %%mm1," #A2 "              \n\t"/* 1 ; save y3 y2 y1 y0*/\
-  "por %%mm4,%%mm7             \n\t"/* 4 ; y7 y6 y5 y4*/\
-  "movq %%mm7,8            +" #A2 "\n\t"/* 7 ; save y7 y6 y5 y4*/\
-
-
-//-----------------------------------------------------------------------------
-// DCT_8_INV_ROW_XMM( INP, OUT, TABLE, ROUNDER
-//-----------------------------------------------------------------------------
-
-#define DCT_8_INV_ROW_XMM(A1,A2,A3,A4)\
-  "movq " #A1 ",%%mm0                  \n\t"/* 0     ; x3 x2 x1 x0*/\
-  "movq 8+" #A1 ",%%mm1                \n\t"/* 1     ; x7 x6 x5 x4*/\
-  "movq %%mm0,%%mm2                \n\t"/* 2     ; x3 x2 x1 x0*/\
-  "movq " #A3 ",%%mm3                  \n\t"/* 3     ; w05 w04 w01 w00*/\
-  "pshufw $0b10001000,%%mm0,%%mm0  \n\t"/* x2 x0 x2 x0*/\
-  "movq 8+" #A3 ",%%mm4                \n\t"/* 4     ; w07 w06 w03 w02*/\
-  "movq %%mm1,%%mm5                \n\t"/* 5     ; x7 x6 x5 x4*/\
-  "pmaddwd %%mm0,%%mm3             \n\t"/* x2*w05+x0*w04 x2*w01+x0*w00*/\
-  "movq 32+" #A3 ",%%mm6               \n\t"/* 6     ; w21 w20 w17 w16*/\
-  "pshufw $0b10001000,%%mm1,%%mm1  \n\t"/* x6 x4 x6 x4*/\
-  "pmaddwd %%mm1,%%mm4             \n\t"/* x6*w07+x4*w06 x6*w03+x4*w02*/\
-  "movq 40+" #A3 ",%%mm7               \n\t"/* 7    ; w23 w22 w19 w18*/\
-  "pshufw $0b11011101,%%mm2,%%mm2  \n\t"/* x3 x1 x3 x1*/\
-  "pmaddwd %%mm2,%%mm6             \n\t"/* x3*w21+x1*w20 x3*w17+x1*w16*/\
-  "pshufw $0b11011101,%%mm5,%%mm5  \n\t"/* x7 x5 x7 x5*/\
-  "pmaddwd %%mm5,%%mm7             \n\t"/* x7*w23+x5*w22 x7*w19+x5*w18*/\
-  "paddd " #A4 ",%%mm3                 \n\t"/* +%4*/\
-  "pmaddwd 16+" #A3 ",%%mm0            \n\t"/* x2*w13+x0*w12 x2*w09+x0*w08*/\
-  "paddd %%mm4,%%mm3               \n\t"/* 4     ; a1=sum(even1) a0=sum(even0)*/\
-  "pmaddwd 24+" #A3 ",%%mm1            \n\t"/* x6*w15+x4*w14 x6*w11+x4*w10*/\
-  "movq %%mm3,%%mm4                \n\t"/* 4     ; a1 a0*/\
-  "pmaddwd 48+" #A3 ",%%mm2            \n\t"/* x3*w29+x1*w28 x3*w25+x1*w24*/\
-  "paddd %%mm7,%%mm6               \n\t"/* 7     ; b1=sum(odd1) b0=sum(odd0)*/\
-  "pmaddwd 56+" #A3 ",%%mm5            \n\t"/* x7*w31+x5*w30 x7*w27+x5*w26*/\
-  "paddd %%mm6,%%mm3               \n\t"/* a1+b1 a0+b0*/\
-  "paddd " #A4 ",%%mm0                 \n\t"/* +%4*/\
-  "psrad $11,%%mm3     \n\t"/* y1=a1+b1 y0=a0+b0*/\
-  "paddd %%mm1,%%mm0               \n\t"/* 1     ; a3=sum(even3) a2=sum(even2)*/\
-  "psubd %%mm6,%%mm4               \n\t"/* 6     ; a1-b1 a0-b0*/\
-  "movq %%mm0,%%mm7                \n\t"/* 7     ; a3 a2*/\
-  "paddd %%mm5,%%mm2               \n\t"/* 5     ; b3=sum(odd3) b2=sum(odd2)*/\
-  "paddd %%mm2,%%mm0               \n\t"/* a3+b3 a2+b2*/\
-  "psrad $11,%%mm4     \n\t"/* y6=a1-b1 y7=a0-b0*/\
-  "psubd %%mm2,%%mm7               \n\t"/* 2     ; a3-b3 a2-b2*/\
-  "psrad $11,%%mm0     \n\t"/* y3=a3+b3 y2=a2+b2*/\
-  "psrad $11,%%mm7     \n\t"/* y4=a3-b3 y5=a2-b2*/\
-  "packssdw %%mm0,%%mm3            \n\t"/* 0     ; y3 y2 y1 y0*/\
-  "packssdw %%mm4,%%mm7            \n\t"/* 4     ; y6 y7 y4 y5*/\
-  "movq %%mm3, " #A2 "                  \n\t"/* 3     ; save y3 y2 y1 y0*/\
-  "pshufw $0b10110001,%%mm7,%%mm7  \n\t"/* y7 y6 y5 y4*/\
-  "movq %%mm7,8                +" #A2 "\n\t"/* 7     ; save y7 y6 y5 y4*/\
-
-
-//-----------------------------------------------------------------------------
-//
-// The first stage DCT 8x8 - forward DCTs of columns
-//
-// The %2puts are multiplied
-// for rows 0,4 - on cos_4_16,
-// for rows 1,7 - on cos_1_16,
-// for rows 2,6 - on cos_2_16,
-// for rows 3,5 - on cos_3_16
-// and are shifted to the left for rise of accuracy
-//
-//-----------------------------------------------------------------------------
-//
-// The 8-point scaled forward DCT algorithm (26a8m)
-//
-//-----------------------------------------------------------------------------
-//
-// #define DCT_8_FRW_COL(x, y)
-//{
-// short t0, t1, t2, t3, t4, t5, t6, t7;
-// short tp03, tm03, tp12, tm12, tp65, tm65;
-// short tp465, tm465, tp765, tm765;
-//
-// t0 = LEFT_SHIFT ( x[0] + x[7] );
-// t1 = LEFT_SHIFT ( x[1] + x[6] );
-// t2 = LEFT_SHIFT ( x[2] + x[5] );
-// t3 = LEFT_SHIFT ( x[3] + x[4] );
-// t4 = LEFT_SHIFT ( x[3] - x[4] );
-// t5 = LEFT_SHIFT ( x[2] - x[5] );
-// t6 = LEFT_SHIFT ( x[1] - x[6] );
-// t7 = LEFT_SHIFT ( x[0] - x[7] );
-//
-// tp03 = t0 + t3;
-// tm03 = t0 - t3;
-// tp12 = t1 + t2;
-// tm12 = t1 - t2;
-//
-// y[0] = tp03 + tp12;
-// y[4] = tp03 - tp12;
-//
-// y[2] = tm03 + tm12 * tg_2_16;
-// y[6] = tm03 * tg_2_16 - tm12;
-//
-// tp65 =(t6 +t5 )*cos_4_16;
-// tm65 =(t6 -t5 )*cos_4_16;
-//
-// tp765 = t7 + tp65;
-// tm765 = t7 - tp65;
-// tp465 = t4 + tm65;
-// tm465 = t4 - tm65;
-//
-// y[1] = tp765 + tp465 * tg_1_16;
-// y[7] = tp765 * tg_1_16 - tp465;
-// y[5] = tm765 * tg_3_16 + tm465;
-// y[3] = tm765 - tm465 * tg_3_16;
-//}
-//
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-// DCT_8_INV_COL_4  INP,OUT
-//-----------------------------------------------------------------------------
-
-#define DCT_8_INV_COL(A1,A2)\
-  "movq 2*8(%3),%%mm0\n\t"\
-  "movq 16*3+" #A1 ",%%mm3\n\t"\
-  "movq %%mm0,%%mm1            \n\t"/* tg_3_16*/\
-  "movq 16*5+" #A1 ",%%mm5\n\t"\
-  "pmulhw %%mm3,%%mm0          \n\t"/* x3*(tg_3_16-1)*/\
-  "movq (%3),%%mm4\n\t"\
-  "pmulhw %%mm5,%%mm1          \n\t"/* x5*(tg_3_16-1)*/\
-  "movq 16*7+" #A1 ",%%mm7\n\t"\
-  "movq %%mm4,%%mm2            \n\t"/* tg_1_16*/\
-  "movq 16*1+" #A1 ",%%mm6\n\t"\
-  "pmulhw %%mm7,%%mm4          \n\t"/* x7*tg_1_16*/\
-  "paddsw %%mm3,%%mm0          \n\t"/* x3*tg_3_16*/\
-  "pmulhw %%mm6,%%mm2          \n\t"/* x1*tg_1_16*/\
-  "paddsw %%mm3,%%mm1          \n\t"/* x3+x5*(tg_3_16-1)*/\
-  "psubsw %%mm5,%%mm0          \n\t"/* x3*tg_3_16-x5 = tm35*/\
-  "movq 3*8(%3),%%mm3\n\t"\
-  "paddsw %%mm5,%%mm1          \n\t"/* x3+x5*tg_3_16 = tp35*/\
-  "paddsw %%mm6,%%mm4          \n\t"/* x1+tg_1_16*x7 = tp17*/\
-  "psubsw %%mm7,%%mm2          \n\t"/* x1*tg_1_16-x7 = tm17*/\
-  "movq %%mm4,%%mm5            \n\t"/* tp17*/\
-  "movq %%mm2,%%mm6            \n\t"/* tm17*/\
-  "paddsw %%mm1,%%mm5          \n\t"/* tp17+tp35 = b0*/\
-  "psubsw %%mm0,%%mm6          \n\t"/* tm17-tm35 = b3*/\
-  "psubsw %%mm1,%%mm4          \n\t"/* tp17-tp35 = t1*/\
-  "paddsw %%mm0,%%mm2          \n\t"/* tm17+tm35 = t2*/\
-  "movq 1*8(%3),%%mm7\n\t"\
-  "movq %%mm4,%%mm1            \n\t"/* t1*/\
-  "movq %%mm5,3*16         +" #A2 "\n\t"/* save b0*/\
-  "paddsw %%mm2,%%mm1          \n\t"/* t1+t2*/\
-  "movq %%mm6,5*16         +" #A2 "\n\t"/* save b3*/\
-  "psubsw %%mm2,%%mm4          \n\t"/* t1-t2*/\
-  "movq 2*16+" #A1 ",%%mm5\n\t"\
-  "movq %%mm7,%%mm0            \n\t"/* tg_2_16*/\
-  "movq 6*16+" #A1 ",%%mm6\n\t"\
-  "pmulhw %%mm5,%%mm0          \n\t"/* x2*tg_2_16*/\
-  "pmulhw %%mm6,%%mm7          \n\t"/* x6*tg_2_16*/\
-  "pmulhw %%mm3,%%mm1          \n\t"/* ocos_4_16*(t1+t2) = b1/2*/\
-  "movq 0*16+" #A1 ",%%mm2\n\t"\
-  "pmulhw %%mm3,%%mm4          \n\t"/* ocos_4_16*(t1-t2) = b2/2*/\
-  "psubsw %%mm6,%%mm0          \n\t"/* t2*tg_2_16-x6 = tm26*/\
-  "movq %%mm2,%%mm3            \n\t"/* x0*/\
-  "movq 4*16+" #A1 ",%%mm6\n\t"\
-  "paddsw %%mm5,%%mm7          \n\t"/* x2+x6*tg_2_16 = tp26*/\
-  "paddsw %%mm6,%%mm2          \n\t"/* x0+x4 = tp04*/\
-  "psubsw %%mm6,%%mm3          \n\t"/* x0-x4 = tm04*/\
-  "movq %%mm2,%%mm5            \n\t"/* tp04*/\
-  "movq %%mm3,%%mm6            \n\t"/* tm04*/\
-  "psubsw %%mm7,%%mm2          \n\t"/* tp04-tp26 = a3*/\
-  "paddsw %%mm0,%%mm3          \n\t"/* tm04+tm26 = a1*/\
-  "paddsw %%mm1,%%mm1          \n\t"/* b1*/\
-  "paddsw %%mm4,%%mm4          \n\t"/* b2*/\
-  "paddsw %%mm7,%%mm5          \n\t"/* tp04+tp26 = a0*/\
-  "psubsw %%mm0,%%mm6          \n\t"/* tm04-tm26 = a2*/\
-  "movq %%mm3,%%mm7            \n\t"/* a1*/\
-  "movq %%mm6,%%mm0            \n\t"/* a2*/\
-  "paddsw %%mm1,%%mm3          \n\t"/* a1+b1*/\
-  "paddsw %%mm4,%%mm6          \n\t"/* a2+b2*/\
-  "psraw $6,%%mm3 \n\t"/* dst1*/\
-  "psubsw %%mm1,%%mm7          \n\t"/* a1-b1*/\
-  "psraw $6,%%mm6 \n\t"/* dst2*/\
-  "psubsw %%mm4,%%mm0          \n\t"/* a2-b2*/\
-  "movq 3*16+" #A2 ",%%mm1         \n\t"/* load b0*/\
-  "psraw $6,%%mm7 \n\t"/* dst6*/\
-  "movq %%mm5,%%mm4            \n\t"/* a0*/\
-  "psraw $6,%%mm0 \n\t"/* dst5*/\
-  "movq %%mm3,1*16+" #A2 "\n\t"\
-  "paddsw %%mm1,%%mm5          \n\t"/* a0+b0*/\
-  "movq %%mm6,2*16+" #A2 "\n\t"\
-  "psubsw %%mm1,%%mm4          \n\t"/* a0-b0*/\
-  "movq 5*16+" #A2 ",%%mm3         \n\t"/* load b3*/\
-  "psraw $6,%%mm5 \n\t"/* dst0*/\
-  "movq %%mm2,%%mm6            \n\t"/* a3*/\
-  "psraw $6,%%mm4 \n\t"/* dst7*/\
-  "movq %%mm0,5*16+" #A2 "\n\t"\
-  "paddsw %%mm3,%%mm2          \n\t"/* a3+b3*/\
-  "movq %%mm7,6*16+" #A2 "\n\t"\
-  "psubsw %%mm3,%%mm6          \n\t"/* a3-b3*/\
-  "movq %%mm5,0*16+" #A2 "\n\t"\
-  "psraw $6,%%mm2 \n\t"/* dst3*/\
-  "movq %%mm4,7*16+" #A2 "\n\t"\
-  "psraw $6,%%mm6 \n\t"/* dst4*/\
-  "movq %%mm2,3*16+" #A2 "\n\t"\
-  "movq %%mm6,4*16+" #A2 "\n\t"
-
-//=============================================================================
-// Code
-//=============================================================================
-
-//-----------------------------------------------------------------------------
-// void idct_mmx(uint16_t block[64]);
-//-----------------------------------------------------------------------------
-
-
-void ff_idct_xvid_mmx(short *block){
-asm volatile(
-            //# Process each row
-    DCT_8_INV_ROW_MMX(0*16(%0), 0*16(%0), 64*0(%2), 8*0(%1))
-    DCT_8_INV_ROW_MMX(1*16(%0), 1*16(%0), 64*1(%2), 8*1(%1))
-    DCT_8_INV_ROW_MMX(2*16(%0), 2*16(%0), 64*2(%2), 8*2(%1))
-    DCT_8_INV_ROW_MMX(3*16(%0), 3*16(%0), 64*3(%2), 8*3(%1))
-    DCT_8_INV_ROW_MMX(4*16(%0), 4*16(%0), 64*0(%2), 8*4(%1))
-    DCT_8_INV_ROW_MMX(5*16(%0), 5*16(%0), 64*3(%2), 8*5(%1))
-    DCT_8_INV_ROW_MMX(6*16(%0), 6*16(%0), 64*2(%2), 8*6(%1))
-    DCT_8_INV_ROW_MMX(7*16(%0), 7*16(%0), 64*1(%2), 8*7(%1))
-    
-            //# Process the columns (4 at a time)
-    DCT_8_INV_COL(0(%0), 0(%0))
-    DCT_8_INV_COL(8(%0), 8(%0))
-    :: "r"(block), "r"(rounder_0), "r"(tab_i_04_mmx), "r"(tg_1_16));
-}
-
-//-----------------------------------------------------------------------------
-// void idct_xmm(uint16_t block[64]);
-//-----------------------------------------------------------------------------
-
-
-void ff_idct_xvid_mmx2(short *block){
-asm volatile(
-            //# Process each row
-    DCT_8_INV_ROW_XMM(0*16(%0), 0*16(%0), 64*0(%2), 8*0(%1))
-    DCT_8_INV_ROW_XMM(1*16(%0), 1*16(%0), 64*1(%2), 8*1(%1))
-    DCT_8_INV_ROW_XMM(2*16(%0), 2*16(%0), 64*2(%2), 8*2(%1))
-    DCT_8_INV_ROW_XMM(3*16(%0), 3*16(%0), 64*3(%2), 8*3(%1))
-    DCT_8_INV_ROW_XMM(4*16(%0), 4*16(%0), 64*0(%2), 8*4(%1))
-    DCT_8_INV_ROW_XMM(5*16(%0), 5*16(%0), 64*3(%2), 8*5(%1))
-    DCT_8_INV_ROW_XMM(6*16(%0), 6*16(%0), 64*2(%2), 8*6(%1))
-    DCT_8_INV_ROW_XMM(7*16(%0), 7*16(%0), 64*1(%2), 8*7(%1))
-    
-            //# Process the columns (4 at a time)
-    DCT_8_INV_COL(0(%0), 0(%0))
-    DCT_8_INV_COL(8(%0), 8(%0))
-    :: "r"(block), "r"(rounder_0), "r"(tab_i_04_xmm), "r"(tg_1_16));
-}
-
diff --git a/ffmpeg.src/libavcodec/i386/mmx.h b/ffmpeg.src/libavcodec/i386/mmx.h
deleted file mode 100644
index f0ef1b7..0000000
--- a/ffmpeg.src/libavcodec/i386/mmx.h
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * mmx.h
- * Copyright (C) 1997-2001 H. Dietz and R. Fisher
- */
-#ifndef AVCODEC_I386MMX_H
-#define AVCODEC_I386MMX_H
-
-#ifdef ARCH_X86_64
-#  define REG_a "rax"
-#else
-#  define REG_a "eax"
-#endif
-
-/*
- * The type of an value that fits in an MMX register (note that long
- * long constant values MUST be suffixed by LL and unsigned long long
- * values by ULL, lest they be truncated by the compiler)
- */
-
-typedef	union {
-	long long		q;	/* Quadword (64-bit) value */
-	unsigned long long	uq;	/* Unsigned Quadword */
-	int			d[2];	/* 2 Doubleword (32-bit) values */
-	unsigned int		ud[2];	/* 2 Unsigned Doubleword */
-	short			w[4];	/* 4 Word (16-bit) values */
-	unsigned short		uw[4];	/* 4 Unsigned Word */
-	char			b[8];	/* 8 Byte (8-bit) values */
-	unsigned char		ub[8];	/* 8 Unsigned Byte */
-	float			s[2];	/* Single-precision (32-bit) value */
-} mmx_t;	/* On an 8-byte (64-bit) boundary */
-
-
-#define	mmx_i2r(op,imm,reg) \
-	__asm__ __volatile__ (#op " %0, %%" #reg \
-			      : /* nothing */ \
-			      : "i" (imm) )
-
-#define	mmx_m2r(op,mem,reg) \
-	__asm__ __volatile__ (#op " %0, %%" #reg \
-			      : /* nothing */ \
-			      : "m" (mem))
-
-#define	mmx_r2m(op,reg,mem) \
-	__asm__ __volatile__ (#op " %%" #reg ", %0" \
-			      : "=m" (mem) \
-			      : /* nothing */ )
-
-#define	mmx_r2r(op,regs,regd) \
-	__asm__ __volatile__ (#op " %" #regs ", %" #regd)
-
-
-#define	emms() __asm__ __volatile__ ("emms")
-
-#define	movd_m2r(var,reg)	mmx_m2r (movd, var, reg)
-#define	movd_r2m(reg,var)	mmx_r2m (movd, reg, var)
-#define	movd_r2r(regs,regd)	mmx_r2r (movd, regs, regd)
-
-#define	movq_m2r(var,reg)	mmx_m2r (movq, var, reg)
-#define	movq_r2m(reg,var)	mmx_r2m (movq, reg, var)
-#define	movq_r2r(regs,regd)	mmx_r2r (movq, regs, regd)
-
-#define	packssdw_m2r(var,reg)	mmx_m2r (packssdw, var, reg)
-#define	packssdw_r2r(regs,regd) mmx_r2r (packssdw, regs, regd)
-#define	packsswb_m2r(var,reg)	mmx_m2r (packsswb, var, reg)
-#define	packsswb_r2r(regs,regd) mmx_r2r (packsswb, regs, regd)
-
-#define	packuswb_m2r(var,reg)	mmx_m2r (packuswb, var, reg)
-#define	packuswb_r2r(regs,regd) mmx_r2r (packuswb, regs, regd)
-
-#define	paddb_m2r(var,reg)	mmx_m2r (paddb, var, reg)
-#define	paddb_r2r(regs,regd)	mmx_r2r (paddb, regs, regd)
-#define	paddd_m2r(var,reg)	mmx_m2r (paddd, var, reg)
-#define	paddd_r2r(regs,regd)	mmx_r2r (paddd, regs, regd)
-#define	paddw_m2r(var,reg)	mmx_m2r (paddw, var, reg)
-#define	paddw_r2r(regs,regd)	mmx_r2r (paddw, regs, regd)
-
-#define	paddsb_m2r(var,reg)	mmx_m2r (paddsb, var, reg)
-#define	paddsb_r2r(regs,regd)	mmx_r2r (paddsb, regs, regd)
-#define	paddsw_m2r(var,reg)	mmx_m2r (paddsw, var, reg)
-#define	paddsw_r2r(regs,regd)	mmx_r2r (paddsw, regs, regd)
-
-#define	paddusb_m2r(var,reg)	mmx_m2r (paddusb, var, reg)
-#define	paddusb_r2r(regs,regd)	mmx_r2r (paddusb, regs, regd)
-#define	paddusw_m2r(var,reg)	mmx_m2r (paddusw, var, reg)
-#define	paddusw_r2r(regs,regd)	mmx_r2r (paddusw, regs, regd)
-
-#define	pand_m2r(var,reg)	mmx_m2r (pand, var, reg)
-#define	pand_r2r(regs,regd)	mmx_r2r (pand, regs, regd)
-
-#define	pandn_m2r(var,reg)	mmx_m2r (pandn, var, reg)
-#define	pandn_r2r(regs,regd)	mmx_r2r (pandn, regs, regd)
-
-#define	pcmpeqb_m2r(var,reg)	mmx_m2r (pcmpeqb, var, reg)
-#define	pcmpeqb_r2r(regs,regd)	mmx_r2r (pcmpeqb, regs, regd)
-#define	pcmpeqd_m2r(var,reg)	mmx_m2r (pcmpeqd, var, reg)
-#define	pcmpeqd_r2r(regs,regd)	mmx_r2r (pcmpeqd, regs, regd)
-#define	pcmpeqw_m2r(var,reg)	mmx_m2r (pcmpeqw, var, reg)
-#define	pcmpeqw_r2r(regs,regd)	mmx_r2r (pcmpeqw, regs, regd)
-
-#define	pcmpgtb_m2r(var,reg)	mmx_m2r (pcmpgtb, var, reg)
-#define	pcmpgtb_r2r(regs,regd)	mmx_r2r (pcmpgtb, regs, regd)
-#define	pcmpgtd_m2r(var,reg)	mmx_m2r (pcmpgtd, var, reg)
-#define	pcmpgtd_r2r(regs,regd)	mmx_r2r (pcmpgtd, regs, regd)
-#define	pcmpgtw_m2r(var,reg)	mmx_m2r (pcmpgtw, var, reg)
-#define	pcmpgtw_r2r(regs,regd)	mmx_r2r (pcmpgtw, regs, regd)
-
-#define	pmaddwd_m2r(var,reg)	mmx_m2r (pmaddwd, var, reg)
-#define	pmaddwd_r2r(regs,regd)	mmx_r2r (pmaddwd, regs, regd)
-
-#define	pmulhw_m2r(var,reg)	mmx_m2r (pmulhw, var, reg)
-#define	pmulhw_r2r(regs,regd)	mmx_r2r (pmulhw, regs, regd)
-
-#define	pmullw_m2r(var,reg)	mmx_m2r (pmullw, var, reg)
-#define	pmullw_r2r(regs,regd)	mmx_r2r (pmullw, regs, regd)
-
-#define	por_m2r(var,reg)	mmx_m2r (por, var, reg)
-#define	por_r2r(regs,regd)	mmx_r2r (por, regs, regd)
-
-#define	pslld_i2r(imm,reg)	mmx_i2r (pslld, imm, reg)
-#define	pslld_m2r(var,reg)	mmx_m2r (pslld, var, reg)
-#define	pslld_r2r(regs,regd)	mmx_r2r (pslld, regs, regd)
-#define	psllq_i2r(imm,reg)	mmx_i2r (psllq, imm, reg)
-#define	psllq_m2r(var,reg)	mmx_m2r (psllq, var, reg)
-#define	psllq_r2r(regs,regd)	mmx_r2r (psllq, regs, regd)
-#define	psllw_i2r(imm,reg)	mmx_i2r (psllw, imm, reg)
-#define	psllw_m2r(var,reg)	mmx_m2r (psllw, var, reg)
-#define	psllw_r2r(regs,regd)	mmx_r2r (psllw, regs, regd)
-
-#define	psrad_i2r(imm,reg)	mmx_i2r (psrad, imm, reg)
-#define	psrad_m2r(var,reg)	mmx_m2r (psrad, var, reg)
-#define	psrad_r2r(regs,regd)	mmx_r2r (psrad, regs, regd)
-#define	psraw_i2r(imm,reg)	mmx_i2r (psraw, imm, reg)
-#define	psraw_m2r(var,reg)	mmx_m2r (psraw, var, reg)
-#define	psraw_r2r(regs,regd)	mmx_r2r (psraw, regs, regd)
-
-#define	psrld_i2r(imm,reg)	mmx_i2r (psrld, imm, reg)
-#define	psrld_m2r(var,reg)	mmx_m2r (psrld, var, reg)
-#define	psrld_r2r(regs,regd)	mmx_r2r (psrld, regs, regd)
-#define	psrlq_i2r(imm,reg)	mmx_i2r (psrlq, imm, reg)
-#define	psrlq_m2r(var,reg)	mmx_m2r (psrlq, var, reg)
-#define	psrlq_r2r(regs,regd)	mmx_r2r (psrlq, regs, regd)
-#define	psrlw_i2r(imm,reg)	mmx_i2r (psrlw, imm, reg)
-#define	psrlw_m2r(var,reg)	mmx_m2r (psrlw, var, reg)
-#define	psrlw_r2r(regs,regd)	mmx_r2r (psrlw, regs, regd)
-
-#define	psubb_m2r(var,reg)	mmx_m2r (psubb, var, reg)
-#define	psubb_r2r(regs,regd)	mmx_r2r (psubb, regs, regd)
-#define	psubd_m2r(var,reg)	mmx_m2r (psubd, var, reg)
-#define	psubd_r2r(regs,regd)	mmx_r2r (psubd, regs, regd)
-#define	psubw_m2r(var,reg)	mmx_m2r (psubw, var, reg)
-#define	psubw_r2r(regs,regd)	mmx_r2r (psubw, regs, regd)
-
-#define	psubsb_m2r(var,reg)	mmx_m2r (psubsb, var, reg)
-#define	psubsb_r2r(regs,regd)	mmx_r2r (psubsb, regs, regd)
-#define	psubsw_m2r(var,reg)	mmx_m2r (psubsw, var, reg)
-#define	psubsw_r2r(regs,regd)	mmx_r2r (psubsw, regs, regd)
-
-#define	psubusb_m2r(var,reg)	mmx_m2r (psubusb, var, reg)
-#define	psubusb_r2r(regs,regd)	mmx_r2r (psubusb, regs, regd)
-#define	psubusw_m2r(var,reg)	mmx_m2r (psubusw, var, reg)
-#define	psubusw_r2r(regs,regd)	mmx_r2r (psubusw, regs, regd)
-
-#define	punpckhbw_m2r(var,reg)		mmx_m2r (punpckhbw, var, reg)
-#define	punpckhbw_r2r(regs,regd)	mmx_r2r (punpckhbw, regs, regd)
-#define	punpckhdq_m2r(var,reg)		mmx_m2r (punpckhdq, var, reg)
-#define	punpckhdq_r2r(regs,regd)	mmx_r2r (punpckhdq, regs, regd)
-#define	punpckhwd_m2r(var,reg)		mmx_m2r (punpckhwd, var, reg)
-#define	punpckhwd_r2r(regs,regd)	mmx_r2r (punpckhwd, regs, regd)
-
-#define	punpcklbw_m2r(var,reg) 		mmx_m2r (punpcklbw, var, reg)
-#define	punpcklbw_r2r(regs,regd)	mmx_r2r (punpcklbw, regs, regd)
-#define	punpckldq_m2r(var,reg)		mmx_m2r (punpckldq, var, reg)
-#define	punpckldq_r2r(regs,regd)	mmx_r2r (punpckldq, regs, regd)
-#define	punpcklwd_m2r(var,reg)		mmx_m2r (punpcklwd, var, reg)
-#define	punpcklwd_r2r(regs,regd)	mmx_r2r (punpcklwd, regs, regd)
-
-#define	pxor_m2r(var,reg)	mmx_m2r (pxor, var, reg)
-#define	pxor_r2r(regs,regd)	mmx_r2r (pxor, regs, regd)
-
-
-/* 3DNOW extensions */
-
-#define pavgusb_m2r(var,reg)	mmx_m2r (pavgusb, var, reg)
-#define pavgusb_r2r(regs,regd)	mmx_r2r (pavgusb, regs, regd)
-
-
-/* AMD MMX extensions - also available in intel SSE */
-
-
-#define mmx_m2ri(op,mem,reg,imm) \
-        __asm__ __volatile__ (#op " %1, %0, %%" #reg \
-                              : /* nothing */ \
-                              : "X" (mem), "X" (imm))
-#define mmx_r2ri(op,regs,regd,imm) \
-        __asm__ __volatile__ (#op " %0, %%" #regs ", %%" #regd \
-                              : /* nothing */ \
-                              : "X" (imm) )
-
-#define	mmx_fetch(mem,hint) \
-	__asm__ __volatile__ ("prefetch" #hint " %0" \
-			      : /* nothing */ \
-			      : "X" (mem))
-
-
-#define	maskmovq(regs,maskreg)		mmx_r2ri (maskmovq, regs, maskreg)
-
-#define	movntq_r2m(mmreg,var)		mmx_r2m (movntq, mmreg, var)
-
-#define	pavgb_m2r(var,reg)		mmx_m2r (pavgb, var, reg)
-#define	pavgb_r2r(regs,regd)		mmx_r2r (pavgb, regs, regd)
-#define	pavgw_m2r(var,reg)		mmx_m2r (pavgw, var, reg)
-#define	pavgw_r2r(regs,regd)		mmx_r2r (pavgw, regs, regd)
-
-#define	pextrw_r2r(mmreg,reg,imm)	mmx_r2ri (pextrw, mmreg, reg, imm)
-
-#define	pinsrw_r2r(reg,mmreg,imm)	mmx_r2ri (pinsrw, reg, mmreg, imm)
-
-#define	pmaxsw_m2r(var,reg)		mmx_m2r (pmaxsw, var, reg)
-#define	pmaxsw_r2r(regs,regd)		mmx_r2r (pmaxsw, regs, regd)
-
-#define	pmaxub_m2r(var,reg)		mmx_m2r (pmaxub, var, reg)
-#define	pmaxub_r2r(regs,regd)		mmx_r2r (pmaxub, regs, regd)
-
-#define	pminsw_m2r(var,reg)		mmx_m2r (pminsw, var, reg)
-#define	pminsw_r2r(regs,regd)		mmx_r2r (pminsw, regs, regd)
-
-#define	pminub_m2r(var,reg)		mmx_m2r (pminub, var, reg)
-#define	pminub_r2r(regs,regd)		mmx_r2r (pminub, regs, regd)
-
-#define	pmovmskb(mmreg,reg) \
-	__asm__ __volatile__ ("movmskps %" #mmreg ", %" #reg)
-
-#define	pmulhuw_m2r(var,reg)		mmx_m2r (pmulhuw, var, reg)
-#define	pmulhuw_r2r(regs,regd)		mmx_r2r (pmulhuw, regs, regd)
-
-#define	prefetcht0(mem)			mmx_fetch (mem, t0)
-#define	prefetcht1(mem)			mmx_fetch (mem, t1)
-#define	prefetcht2(mem)			mmx_fetch (mem, t2)
-#define	prefetchnta(mem)		mmx_fetch (mem, nta)
-
-#define	psadbw_m2r(var,reg)		mmx_m2r (psadbw, var, reg)
-#define	psadbw_r2r(regs,regd)		mmx_r2r (psadbw, regs, regd)
-
-#define	pshufw_m2r(var,reg,imm)		mmx_m2ri(pshufw, var, reg, imm)
-#define	pshufw_r2r(regs,regd,imm)	mmx_r2ri(pshufw, regs, regd, imm)
-
-#define	sfence() __asm__ __volatile__ ("sfence\n\t")
-
-/* SSE2 */
-#define	pshufhw_m2r(var,reg,imm)	mmx_m2ri(pshufhw, var, reg, imm)
-#define	pshufhw_r2r(regs,regd,imm)	mmx_r2ri(pshufhw, regs, regd, imm)
-#define	pshuflw_m2r(var,reg,imm)	mmx_m2ri(pshuflw, var, reg, imm)
-#define	pshuflw_r2r(regs,regd,imm)	mmx_r2ri(pshuflw, regs, regd, imm)
-
-#define	pshufd_r2r(regs,regd,imm)	mmx_r2ri(pshufd, regs, regd, imm)
-
-#define	movdqa_m2r(var,reg)		mmx_m2r (movdqa, var, reg)
-#define	movdqa_r2m(reg,var)		mmx_r2m (movdqa, reg, var)
-#define	movdqa_r2r(regs,regd)		mmx_r2r (movdqa, regs, regd)
-#define	movdqu_m2r(var,reg)		mmx_m2r (movdqu, var, reg)
-#define	movdqu_r2m(reg,var)		mmx_r2m (movdqu, reg, var)
-#define	movdqu_r2r(regs,regd)		mmx_r2r (movdqu, regs, regd)
-
-#define	pmullw_r2m(reg,var)		mmx_r2m (pmullw, reg, var)
-
-#define	pslldq_i2r(imm,reg)		mmx_i2r (pslldq, imm, reg)
-#define	psrldq_i2r(imm,reg)		mmx_i2r (psrldq, imm, reg)
-
-#define	punpcklqdq_r2r(regs,regd)	mmx_r2r (punpcklqdq, regs, regd)
-#define	punpckhqdq_r2r(regs,regd)	mmx_r2r (punpckhqdq, regs, regd)
-
-
-#endif /* AVCODEC_I386MMX_H */
diff --git a/ffmpeg.src/libavcodec/i386/motion_est_mmx.c b/ffmpeg.src/libavcodec/i386/motion_est_mmx.c
deleted file mode 100644
index 1b90f8e..0000000
--- a/ffmpeg.src/libavcodec/i386/motion_est_mmx.c
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * MMX optimized motion estimation
- * Copyright (c) 2001 Fabrice Bellard.
- * Copyright (c) 2002-2004 Michael Niedermayer
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * mostly by Michael Niedermayer <michaelni at gmx.at>
- */
-#include "../dsputil.h"
-#include "mmx.h"
-
-static const __attribute__ ((aligned(8))) uint64_t round_tab[3]={
-0x0000000000000000ULL,
-0x0001000100010001ULL,
-0x0002000200020002ULL,
-};
-
-static attribute_used __attribute__ ((aligned(8))) uint64_t bone= 0x0101010101010101LL;
-
-static inline void sad8_1_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
-{
-    long len= -(stride*h);
-    asm volatile(
-        ".balign 16			\n\t"
-        "1:				\n\t"
-        "movq (%1, %%"REG_a"), %%mm0	\n\t"
-        "movq (%2, %%"REG_a"), %%mm2	\n\t"
-        "movq (%2, %%"REG_a"), %%mm4	\n\t"
-        "add %3, %%"REG_a"		\n\t"
-        "psubusb %%mm0, %%mm2		\n\t"
-        "psubusb %%mm4, %%mm0		\n\t"
-        "movq (%1, %%"REG_a"), %%mm1	\n\t"
-        "movq (%2, %%"REG_a"), %%mm3	\n\t"
-        "movq (%2, %%"REG_a"), %%mm5	\n\t"
-        "psubusb %%mm1, %%mm3		\n\t"
-        "psubusb %%mm5, %%mm1		\n\t"
-        "por %%mm2, %%mm0		\n\t"
-        "por %%mm1, %%mm3		\n\t"
-        "movq %%mm0, %%mm1		\n\t"
-        "movq %%mm3, %%mm2		\n\t"
-        "punpcklbw %%mm7, %%mm0		\n\t"
-        "punpckhbw %%mm7, %%mm1		\n\t"
-        "punpcklbw %%mm7, %%mm3		\n\t"
-        "punpckhbw %%mm7, %%mm2		\n\t"
-        "paddw %%mm1, %%mm0		\n\t"
-        "paddw %%mm3, %%mm2		\n\t"
-        "paddw %%mm2, %%mm0		\n\t"
-        "paddw %%mm0, %%mm6		\n\t"
-        "add %3, %%"REG_a"		\n\t"
-        " js 1b				\n\t"
-        : "+a" (len)
-        : "r" (blk1 - len), "r" (blk2 - len), "r" ((long)stride)
-    );
-}
-
-static inline void sad8_1_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h)
-{
-    long len= -(stride*h);
-    asm volatile(
-        ".balign 16			\n\t"
-        "1:				\n\t"
-        "movq (%1, %%"REG_a"), %%mm0	\n\t"
-        "movq (%2, %%"REG_a"), %%mm2	\n\t"
-        "psadbw %%mm2, %%mm0		\n\t"
-        "add %3, %%"REG_a"		\n\t"
-        "movq (%1, %%"REG_a"), %%mm1	\n\t"
-        "movq (%2, %%"REG_a"), %%mm3	\n\t"
-        "psadbw %%mm1, %%mm3		\n\t"
-        "paddw %%mm3, %%mm0		\n\t"
-        "paddw %%mm0, %%mm6		\n\t"
-        "add %3, %%"REG_a"		\n\t"
-        " js 1b				\n\t"
-        : "+a" (len)
-        : "r" (blk1 - len), "r" (blk2 - len), "r" ((long)stride)
-    );
-}
-
-static inline void sad8_2_mmx2(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2, int stride, int h)
-{
-    long len= -(stride*h);
-    asm volatile(
-        ".balign 16			\n\t"
-        "1:				\n\t"
-        "movq (%1, %%"REG_a"), %%mm0	\n\t"
-        "movq (%2, %%"REG_a"), %%mm2	\n\t"
-        "pavgb %%mm2, %%mm0		\n\t"
-        "movq (%3, %%"REG_a"), %%mm2	\n\t"
-        "psadbw %%mm2, %%mm0		\n\t"
-        "add %4, %%"REG_a"		\n\t"
-        "movq (%1, %%"REG_a"), %%mm1	\n\t"
-        "movq (%2, %%"REG_a"), %%mm3	\n\t"
-        "pavgb %%mm1, %%mm3		\n\t"
-        "movq (%3, %%"REG_a"), %%mm1	\n\t"
-        "psadbw %%mm1, %%mm3		\n\t"
-        "paddw %%mm3, %%mm0		\n\t"
-        "paddw %%mm0, %%mm6		\n\t"
-        "add %4, %%"REG_a"		\n\t"
-        " js 1b				\n\t"
-        : "+a" (len)
-        : "r" (blk1a - len), "r" (blk1b -len), "r" (blk2 - len), "r" ((long)stride)
-    );
-}
-
-static inline void sad8_4_mmx2(uint8_t *blk1, uint8_t *blk2, int stride, int h)
-{ //FIXME reuse src
-    long len= -(stride*h);
-    asm volatile(
-        ".balign 16			\n\t"
-        "movq "MANGLE(bone)", %%mm5	\n\t"
-        "1:				\n\t"
-        "movq (%1, %%"REG_a"), %%mm0	\n\t"
-        "movq (%2, %%"REG_a"), %%mm2	\n\t"
-        "movq 1(%1, %%"REG_a"), %%mm1	\n\t"
-        "movq 1(%2, %%"REG_a"), %%mm3	\n\t"
-        "pavgb %%mm2, %%mm0		\n\t"
-        "pavgb %%mm1, %%mm3		\n\t"
-        "psubusb %%mm5, %%mm3		\n\t"
-        "pavgb %%mm3, %%mm0		\n\t"
-        "movq (%3, %%"REG_a"), %%mm2	\n\t"
-        "psadbw %%mm2, %%mm0		\n\t"
-        "add %4, %%"REG_a"		\n\t"
-        "movq (%1, %%"REG_a"), %%mm1	\n\t"
-        "movq (%2, %%"REG_a"), %%mm3	\n\t"
-        "movq 1(%1, %%"REG_a"), %%mm2	\n\t"
-        "movq 1(%2, %%"REG_a"), %%mm4	\n\t"
-        "pavgb %%mm3, %%mm1		\n\t"
-        "pavgb %%mm4, %%mm2		\n\t"
-        "psubusb %%mm5, %%mm2		\n\t"
-        "pavgb %%mm1, %%mm2		\n\t"
-        "movq (%3, %%"REG_a"), %%mm1	\n\t"
-        "psadbw %%mm1, %%mm2		\n\t"
-        "paddw %%mm2, %%mm0		\n\t"
-        "paddw %%mm0, %%mm6		\n\t"
-        "add %4, %%"REG_a"		\n\t"
-        " js 1b				\n\t"
-        : "+a" (len)
-        : "r" (blk1 - len), "r" (blk1 - len + stride), "r" (blk2 - len), "r" ((long)stride)
-    );
-}
-
-static inline void sad8_2_mmx(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2, int stride, int h)
-{
-    long len= -(stride*h);
-    asm volatile(
-        ".balign 16			\n\t"
-        "1:				\n\t"
-        "movq (%1, %%"REG_a"), %%mm0	\n\t"
-        "movq (%2, %%"REG_a"), %%mm1	\n\t"
-        "movq (%1, %%"REG_a"), %%mm2	\n\t"
-        "movq (%2, %%"REG_a"), %%mm3	\n\t"
-        "punpcklbw %%mm7, %%mm0		\n\t"
-        "punpcklbw %%mm7, %%mm1		\n\t"
-        "punpckhbw %%mm7, %%mm2		\n\t"
-        "punpckhbw %%mm7, %%mm3		\n\t"
-        "paddw %%mm0, %%mm1		\n\t"
-        "paddw %%mm2, %%mm3		\n\t"
-        "movq (%3, %%"REG_a"), %%mm4	\n\t"
-        "movq (%3, %%"REG_a"), %%mm2	\n\t"
-        "paddw %%mm5, %%mm1		\n\t"
-        "paddw %%mm5, %%mm3		\n\t"
-        "psrlw $1, %%mm1		\n\t"
-        "psrlw $1, %%mm3		\n\t"
-        "packuswb %%mm3, %%mm1		\n\t"
-        "psubusb %%mm1, %%mm4		\n\t"
-        "psubusb %%mm2, %%mm1		\n\t"
-        "por %%mm4, %%mm1		\n\t"
-        "movq %%mm1, %%mm0		\n\t"
-        "punpcklbw %%mm7, %%mm0		\n\t"
-        "punpckhbw %%mm7, %%mm1		\n\t"
-        "paddw %%mm1, %%mm0		\n\t"
-        "paddw %%mm0, %%mm6		\n\t"
-        "add %4, %%"REG_a"		\n\t"
-        " js 1b				\n\t"
-        : "+a" (len)
-        : "r" (blk1a - len), "r" (blk1b -len), "r" (blk2 - len), "r" ((long)stride)
-    );
-}
-
-static inline void sad8_4_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
-{
-    long len= -(stride*h);
-    asm volatile(
-        ".balign 16			\n\t"
-        "1:				\n\t"
-        "movq (%1, %%"REG_a"), %%mm0	\n\t"
-        "movq (%2, %%"REG_a"), %%mm1	\n\t"
-        "movq %%mm0, %%mm4		\n\t"
-        "movq %%mm1, %%mm2		\n\t"
-        "punpcklbw %%mm7, %%mm0		\n\t"
-        "punpcklbw %%mm7, %%mm1		\n\t"
-        "punpckhbw %%mm7, %%mm4		\n\t"
-        "punpckhbw %%mm7, %%mm2		\n\t"
-        "paddw %%mm1, %%mm0		\n\t"
-        "paddw %%mm2, %%mm4		\n\t"
-        "movq 1(%1, %%"REG_a"), %%mm2	\n\t"
-        "movq 1(%2, %%"REG_a"), %%mm3	\n\t"
-        "movq %%mm2, %%mm1		\n\t"
-        "punpcklbw %%mm7, %%mm2		\n\t"
-        "punpckhbw %%mm7, %%mm1		\n\t"
-        "paddw %%mm0, %%mm2		\n\t"
-        "paddw %%mm4, %%mm1		\n\t"
-        "movq %%mm3, %%mm4		\n\t"
-        "punpcklbw %%mm7, %%mm3		\n\t"
-        "punpckhbw %%mm7, %%mm4		\n\t"
-        "paddw %%mm3, %%mm2		\n\t"
-        "paddw %%mm4, %%mm1		\n\t"
-        "movq (%3, %%"REG_a"), %%mm3	\n\t"
-        "movq (%3, %%"REG_a"), %%mm4	\n\t"
-        "paddw %%mm5, %%mm2		\n\t"
-        "paddw %%mm5, %%mm1		\n\t"
-        "psrlw $2, %%mm2		\n\t"
-        "psrlw $2, %%mm1		\n\t"
-        "packuswb %%mm1, %%mm2		\n\t"
-        "psubusb %%mm2, %%mm3		\n\t"
-        "psubusb %%mm4, %%mm2		\n\t"
-        "por %%mm3, %%mm2		\n\t"
-        "movq %%mm2, %%mm0		\n\t"
-        "punpcklbw %%mm7, %%mm0		\n\t"
-        "punpckhbw %%mm7, %%mm2		\n\t"
-        "paddw %%mm2, %%mm0		\n\t"
-        "paddw %%mm0, %%mm6		\n\t"
-        "add %4, %%"REG_a"		\n\t"
-        " js 1b				\n\t"
-        : "+a" (len)
-        : "r" (blk1 - len), "r" (blk1 -len + stride), "r" (blk2 - len), "r" ((long)stride)
-    );
-}
-
-static inline int sum_mmx(void)
-{
-    int ret;
-    asm volatile(
-        "movq %%mm6, %%mm0		\n\t"
-        "psrlq $32, %%mm6		\n\t"
-        "paddw %%mm0, %%mm6		\n\t"
-        "movq %%mm6, %%mm0		\n\t"
-        "psrlq $16, %%mm6		\n\t"
-        "paddw %%mm0, %%mm6		\n\t"
-        "movd %%mm6, %0			\n\t"
-        : "=r" (ret)
-    );
-    return ret&0xFFFF;
-}
-
-static inline int sum_mmx2(void)
-{
-    int ret;
-    asm volatile(
-        "movd %%mm6, %0			\n\t"
-        : "=r" (ret)
-    );
-    return ret;
-}
-
-
-#define PIX_SAD(suf)\
-static int sad8_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    assert(h==8);\
-    asm volatile("pxor %%mm7, %%mm7		\n\t"\
-                 "pxor %%mm6, %%mm6		\n\t":);\
-\
-    sad8_1_ ## suf(blk1, blk2, stride, 8);\
-\
-    return sum_ ## suf();\
-}\
-static int sad8_x2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    assert(h==8);\
-    asm volatile("pxor %%mm7, %%mm7		\n\t"\
-                 "pxor %%mm6, %%mm6		\n\t"\
-                 "movq %0, %%mm5		\n\t"\
-                 :: "m"(round_tab[1]) \
-                 );\
-\
-    sad8_2_ ## suf(blk1, blk1+1, blk2, stride, 8);\
-\
-    return sum_ ## suf();\
-}\
-\
-static int sad8_y2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    assert(h==8);\
-    asm volatile("pxor %%mm7, %%mm7		\n\t"\
-                 "pxor %%mm6, %%mm6		\n\t"\
-                 "movq %0, %%mm5		\n\t"\
-                 :: "m"(round_tab[1]) \
-                 );\
-\
-    sad8_2_ ## suf(blk1, blk1+stride, blk2, stride, 8);\
-\
-    return sum_ ## suf();\
-}\
-\
-static int sad8_xy2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    assert(h==8);\
-    asm volatile("pxor %%mm7, %%mm7		\n\t"\
-                 "pxor %%mm6, %%mm6		\n\t"\
-                 "movq %0, %%mm5		\n\t"\
-                 :: "m"(round_tab[2]) \
-                 );\
-\
-    sad8_4_ ## suf(blk1, blk2, stride, 8);\
-\
-    return sum_ ## suf();\
-}\
-\
-static int sad16_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    asm volatile("pxor %%mm7, %%mm7		\n\t"\
-                 "pxor %%mm6, %%mm6		\n\t":);\
-\
-    sad8_1_ ## suf(blk1  , blk2  , stride, h);\
-    sad8_1_ ## suf(blk1+8, blk2+8, stride, h);\
-\
-    return sum_ ## suf();\
-}\
-static int sad16_x2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    asm volatile("pxor %%mm7, %%mm7		\n\t"\
-                 "pxor %%mm6, %%mm6		\n\t"\
-                 "movq %0, %%mm5		\n\t"\
-                 :: "m"(round_tab[1]) \
-                 );\
-\
-    sad8_2_ ## suf(blk1  , blk1+1, blk2  , stride, h);\
-    sad8_2_ ## suf(blk1+8, blk1+9, blk2+8, stride, h);\
-\
-    return sum_ ## suf();\
-}\
-static int sad16_y2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    asm volatile("pxor %%mm7, %%mm7		\n\t"\
-                 "pxor %%mm6, %%mm6		\n\t"\
-                 "movq %0, %%mm5		\n\t"\
-                 :: "m"(round_tab[1]) \
-                 );\
-\
-    sad8_2_ ## suf(blk1  , blk1+stride,  blk2  , stride, h);\
-    sad8_2_ ## suf(blk1+8, blk1+stride+8,blk2+8, stride, h);\
-\
-    return sum_ ## suf();\
-}\
-static int sad16_xy2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    asm volatile("pxor %%mm7, %%mm7		\n\t"\
-                 "pxor %%mm6, %%mm6		\n\t"\
-                 "movq %0, %%mm5		\n\t"\
-                 :: "m"(round_tab[2]) \
-                 );\
-\
-    sad8_4_ ## suf(blk1  , blk2  , stride, h);\
-    sad8_4_ ## suf(blk1+8, blk2+8, stride, h);\
-\
-    return sum_ ## suf();\
-}\
-
-PIX_SAD(mmx)
-PIX_SAD(mmx2)
-
-void dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx)
-{
-    if (mm_flags & MM_MMX) {
-        c->pix_abs[0][0] = sad16_mmx;
-        c->pix_abs[0][1] = sad16_x2_mmx;
-        c->pix_abs[0][2] = sad16_y2_mmx;
-        c->pix_abs[0][3] = sad16_xy2_mmx;
-        c->pix_abs[1][0] = sad8_mmx;
-        c->pix_abs[1][1] = sad8_x2_mmx;
-        c->pix_abs[1][2] = sad8_y2_mmx;
-        c->pix_abs[1][3] = sad8_xy2_mmx;
-
-	c->sad[0]= sad16_mmx;
-        c->sad[1]= sad8_mmx;
-    }
-    if (mm_flags & MM_MMXEXT) {
-	c->pix_abs[0][0] = sad16_mmx2;
-	c->pix_abs[1][0] = sad8_mmx2;
-
-	c->sad[0]= sad16_mmx2;
-	c->sad[1]= sad8_mmx2;
-        
-        if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
-            c->pix_abs[0][1] = sad16_x2_mmx2;
-            c->pix_abs[0][2] = sad16_y2_mmx2;
-            c->pix_abs[0][3] = sad16_xy2_mmx2;
-            c->pix_abs[1][1] = sad8_x2_mmx2;
-            c->pix_abs[1][2] = sad8_y2_mmx2;
-            c->pix_abs[1][3] = sad8_xy2_mmx2;
-        }
-    }
-}
diff --git a/ffmpeg.src/libavcodec/i386/mpegvideo_mmx.c b/ffmpeg.src/libavcodec/i386/mpegvideo_mmx.c
deleted file mode 100644
index 70c81f6..0000000
--- a/ffmpeg.src/libavcodec/i386/mpegvideo_mmx.c
+++ /dev/null
@@ -1,723 +0,0 @@
-/*
- * The simplest mpeg encoder (well, it was the simplest!)
- * Copyright (c) 2000,2001 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Optimized for ia32 cpus by Nick Kurshev <nickols_k at mail.ru>
- * h263, mpeg1, mpeg2 dequantizer & draw_edges by Michael Niedermayer <michaelni at gmx.at>
- */
-
-#include "../dsputil.h"
-#include "../mpegvideo.h"
-#include "../avcodec.h"
-#include "mmx.h"
-
-extern uint8_t zigzag_direct_noperm[64];
-extern uint16_t inv_zigzag_direct16[64];
-
-static const unsigned long long int mm_wabs __attribute__ ((aligned(8))) = 0xffffffffffffffffULL;
-static const unsigned long long int mm_wone __attribute__ ((aligned(8))) = 0x0001000100010001ULL;
-
-
-static void dct_unquantize_h263_intra_mmx(MpegEncContext *s,
-                                  DCTELEM *block, int n, int qscale)
-{
-    long level, qmul, qadd, nCoeffs;
-
-    qmul = qscale << 1;
-
-    assert(s->block_last_index[n]>=0 || s->h263_aic);
-        
-    if (!s->h263_aic) {
-        if (n < 4)
-            level = block[0] * s->y_dc_scale;
-        else
-            level = block[0] * s->c_dc_scale;
-        qadd = (qscale - 1) | 1;
-    }else{
-        qadd = 0;
-        level= block[0];
-    }
-    if(s->ac_pred)
-        nCoeffs=63;
-    else
-        nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
-//printf("%d %d  ", qmul, qadd);
-asm volatile(
-		"movd %1, %%mm6			\n\t" //qmul
-		"packssdw %%mm6, %%mm6		\n\t"
-		"packssdw %%mm6, %%mm6		\n\t"
-		"movd %2, %%mm5			\n\t" //qadd
-		"pxor %%mm7, %%mm7		\n\t"
-		"packssdw %%mm5, %%mm5		\n\t"
-		"packssdw %%mm5, %%mm5		\n\t"
-		"psubw %%mm5, %%mm7		\n\t"
-		"pxor %%mm4, %%mm4		\n\t"
-		".balign 16\n\t"
-		"1:				\n\t"
-		"movq (%0, %3), %%mm0		\n\t"
-		"movq 8(%0, %3), %%mm1		\n\t"
-
-		"pmullw %%mm6, %%mm0		\n\t"
-		"pmullw %%mm6, %%mm1		\n\t"
-
-		"movq (%0, %3), %%mm2		\n\t"
-		"movq 8(%0, %3), %%mm3		\n\t"
-
-		"pcmpgtw %%mm4, %%mm2		\n\t" // block[i] < 0 ? -1 : 0
-		"pcmpgtw %%mm4, %%mm3		\n\t" // block[i] < 0 ? -1 : 0
-
-		"pxor %%mm2, %%mm0		\n\t"
-		"pxor %%mm3, %%mm1		\n\t"
-
-		"paddw %%mm7, %%mm0		\n\t"
-		"paddw %%mm7, %%mm1		\n\t"
-
-		"pxor %%mm0, %%mm2		\n\t"
-		"pxor %%mm1, %%mm3		\n\t"
-
-		"pcmpeqw %%mm7, %%mm0		\n\t" // block[i] == 0 ? -1 : 0
-		"pcmpeqw %%mm7, %%mm1		\n\t" // block[i] == 0 ? -1 : 0
-
-		"pandn %%mm2, %%mm0		\n\t"
-		"pandn %%mm3, %%mm1		\n\t"
-
-		"movq %%mm0, (%0, %3)		\n\t"
-		"movq %%mm1, 8(%0, %3)		\n\t"
-
-		"add $16, %3			\n\t"
-		"jng 1b				\n\t"
-		::"r" (block+nCoeffs), "g"(qmul), "g" (qadd), "r" (2*(-nCoeffs))
-		: "memory"
-	);
-        block[0]= level;
-}
-
-
-static void dct_unquantize_h263_inter_mmx(MpegEncContext *s,
-                                  DCTELEM *block, int n, int qscale)
-{
-    long qmul, qadd, nCoeffs;
-
-    qmul = qscale << 1;
-    qadd = (qscale - 1) | 1;
-
-    assert(s->block_last_index[n]>=0 || s->h263_aic);
-        
-    nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
-//printf("%d %d  ", qmul, qadd);
-asm volatile(
-		"movd %1, %%mm6			\n\t" //qmul
-		"packssdw %%mm6, %%mm6		\n\t"
-		"packssdw %%mm6, %%mm6		\n\t"
-		"movd %2, %%mm5			\n\t" //qadd
-		"pxor %%mm7, %%mm7		\n\t"
-		"packssdw %%mm5, %%mm5		\n\t"
-		"packssdw %%mm5, %%mm5		\n\t"
-		"psubw %%mm5, %%mm7		\n\t"
-		"pxor %%mm4, %%mm4		\n\t"
-		".balign 16\n\t"
-		"1:				\n\t"
-		"movq (%0, %3), %%mm0		\n\t"
-		"movq 8(%0, %3), %%mm1		\n\t"
-
-		"pmullw %%mm6, %%mm0		\n\t"
-		"pmullw %%mm6, %%mm1		\n\t"
-
-		"movq (%0, %3), %%mm2		\n\t"
-		"movq 8(%0, %3), %%mm3		\n\t"
-
-		"pcmpgtw %%mm4, %%mm2		\n\t" // block[i] < 0 ? -1 : 0
-		"pcmpgtw %%mm4, %%mm3		\n\t" // block[i] < 0 ? -1 : 0
-
-		"pxor %%mm2, %%mm0		\n\t"
-		"pxor %%mm3, %%mm1		\n\t"
-
-		"paddw %%mm7, %%mm0		\n\t"
-		"paddw %%mm7, %%mm1		\n\t"
-
-		"pxor %%mm0, %%mm2		\n\t"
-		"pxor %%mm1, %%mm3		\n\t"
-
-		"pcmpeqw %%mm7, %%mm0		\n\t" // block[i] == 0 ? -1 : 0
-		"pcmpeqw %%mm7, %%mm1		\n\t" // block[i] == 0 ? -1 : 0
-
-		"pandn %%mm2, %%mm0		\n\t"
-		"pandn %%mm3, %%mm1		\n\t"
-
-		"movq %%mm0, (%0, %3)		\n\t"
-		"movq %%mm1, 8(%0, %3)		\n\t"
-
-		"add $16, %3			\n\t"
-		"jng 1b				\n\t"
-		::"r" (block+nCoeffs), "g"(qmul), "g" (qadd), "r" (2*(-nCoeffs))
-		: "memory"
-	);
-}
-
-
-/*
-  NK:
-  Note: looking at PARANOID:
-  "enable all paranoid tests for rounding, overflows, etc..."
-
-#ifdef PARANOID
-                if (level < -2048 || level > 2047)
-                    fprintf(stderr, "unquant error %d %d\n", i, level);
-#endif
-  We can suppose that result of two multiplications can't be greate of 0xFFFF
-  i.e. is 16-bit, so we use here only PMULLW instruction and can avoid
-  a complex multiplication.
-=====================================================
- Full formula for multiplication of 2 integer numbers
- which are represent as high:low words:
- input: value1 = high1:low1
-        value2 = high2:low2
- output: value3 = value1*value2
- value3=high3:low3 (on overflow: modulus 2^32 wrap-around)
- this mean that for 0x123456 * 0x123456 correct result is 0x766cb0ce4
- but this algorithm will compute only 0x66cb0ce4
- this limited by 16-bit size of operands
- ---------------------------------
- tlow1 = high1*low2
- tlow2 = high2*low1
- tlow1 = tlow1 + tlow2
- high3:low3 = low1*low2
- high3 += tlow1
-*/
-static void dct_unquantize_mpeg1_intra_mmx(MpegEncContext *s,
-                                     DCTELEM *block, int n, int qscale)
-{
-    long nCoeffs;
-    const uint16_t *quant_matrix;
-    int block0;
-
-    assert(s->block_last_index[n]>=0);
-
-    nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]+1;
-
-    if (n < 4) 
-        block0 = block[0] * s->y_dc_scale;
-    else
-        block0 = block[0] * s->c_dc_scale;
-    /* XXX: only mpeg1 */
-    quant_matrix = s->intra_matrix;
-asm volatile(
-		"pcmpeqw %%mm7, %%mm7		\n\t"
-		"psrlw $15, %%mm7		\n\t"
-		"movd %2, %%mm6			\n\t"
-		"packssdw %%mm6, %%mm6		\n\t"
-		"packssdw %%mm6, %%mm6		\n\t"
-		"mov %3, %%"REG_a"		\n\t"
-		".balign 16\n\t"
-		"1:				\n\t"
-		"movq (%0, %%"REG_a"), %%mm0	\n\t"
-		"movq 8(%0, %%"REG_a"), %%mm1	\n\t"
-		"movq (%1, %%"REG_a"), %%mm4	\n\t"
-		"movq 8(%1, %%"REG_a"), %%mm5	\n\t"
-		"pmullw %%mm6, %%mm4		\n\t" // q=qscale*quant_matrix[i]
-		"pmullw %%mm6, %%mm5		\n\t" // q=qscale*quant_matrix[i]
-		"pxor %%mm2, %%mm2		\n\t"
-		"pxor %%mm3, %%mm3		\n\t"
-		"pcmpgtw %%mm0, %%mm2		\n\t" // block[i] < 0 ? -1 : 0
-		"pcmpgtw %%mm1, %%mm3		\n\t" // block[i] < 0 ? -1 : 0
-		"pxor %%mm2, %%mm0		\n\t"
-		"pxor %%mm3, %%mm1		\n\t"
-		"psubw %%mm2, %%mm0		\n\t" // abs(block[i])
-		"psubw %%mm3, %%mm1		\n\t" // abs(block[i])
-		"pmullw %%mm4, %%mm0		\n\t" // abs(block[i])*q
-		"pmullw %%mm5, %%mm1		\n\t" // abs(block[i])*q
-		"pxor %%mm4, %%mm4		\n\t"
-		"pxor %%mm5, %%mm5		\n\t" // FIXME slow
-		"pcmpeqw (%0, %%"REG_a"), %%mm4	\n\t" // block[i] == 0 ? -1 : 0
-		"pcmpeqw 8(%0, %%"REG_a"), %%mm5\n\t" // block[i] == 0 ? -1 : 0
-		"psraw $3, %%mm0		\n\t"
-		"psraw $3, %%mm1		\n\t"
-		"psubw %%mm7, %%mm0		\n\t"
-		"psubw %%mm7, %%mm1		\n\t"
-		"por %%mm7, %%mm0		\n\t"
-		"por %%mm7, %%mm1		\n\t"
-		"pxor %%mm2, %%mm0		\n\t"
-		"pxor %%mm3, %%mm1		\n\t"
-		"psubw %%mm2, %%mm0		\n\t"
-		"psubw %%mm3, %%mm1		\n\t"
-		"pandn %%mm0, %%mm4		\n\t"
-		"pandn %%mm1, %%mm5		\n\t"
-		"movq %%mm4, (%0, %%"REG_a")	\n\t"
-		"movq %%mm5, 8(%0, %%"REG_a")	\n\t"
-
-		"add $16, %%"REG_a"		\n\t"
-		"js 1b				\n\t"
-		::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs)
-		: "%"REG_a, "memory"
-	);    
-    block[0]= block0;
-}
-
-static void dct_unquantize_mpeg1_inter_mmx(MpegEncContext *s,
-                                     DCTELEM *block, int n, int qscale)
-{
-    long nCoeffs;
-    const uint16_t *quant_matrix;
-
-    assert(s->block_last_index[n]>=0);
-
-    nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]+1;
-
-        quant_matrix = s->inter_matrix;
-asm volatile(
-		"pcmpeqw %%mm7, %%mm7		\n\t"
-		"psrlw $15, %%mm7		\n\t"
-		"movd %2, %%mm6			\n\t"
-		"packssdw %%mm6, %%mm6		\n\t"
-		"packssdw %%mm6, %%mm6		\n\t"
-		"mov %3, %%"REG_a"		\n\t"
-		".balign 16\n\t"
-		"1:				\n\t"
-		"movq (%0, %%"REG_a"), %%mm0	\n\t"
-		"movq 8(%0, %%"REG_a"), %%mm1	\n\t"
-		"movq (%1, %%"REG_a"), %%mm4	\n\t"
-		"movq 8(%1, %%"REG_a"), %%mm5	\n\t"
-		"pmullw %%mm6, %%mm4		\n\t" // q=qscale*quant_matrix[i]
-		"pmullw %%mm6, %%mm5		\n\t" // q=qscale*quant_matrix[i]
-		"pxor %%mm2, %%mm2		\n\t"
-		"pxor %%mm3, %%mm3		\n\t"
-		"pcmpgtw %%mm0, %%mm2		\n\t" // block[i] < 0 ? -1 : 0
-		"pcmpgtw %%mm1, %%mm3		\n\t" // block[i] < 0 ? -1 : 0
-		"pxor %%mm2, %%mm0		\n\t"
-		"pxor %%mm3, %%mm1		\n\t"
-		"psubw %%mm2, %%mm0		\n\t" // abs(block[i])
-		"psubw %%mm3, %%mm1		\n\t" // abs(block[i])
-		"paddw %%mm0, %%mm0		\n\t" // abs(block[i])*2
-		"paddw %%mm1, %%mm1		\n\t" // abs(block[i])*2
-		"paddw %%mm7, %%mm0		\n\t" // abs(block[i])*2 + 1
-		"paddw %%mm7, %%mm1		\n\t" // abs(block[i])*2 + 1
-		"pmullw %%mm4, %%mm0		\n\t" // (abs(block[i])*2 + 1)*q
-		"pmullw %%mm5, %%mm1		\n\t" // (abs(block[i])*2 + 1)*q
-		"pxor %%mm4, %%mm4		\n\t"
-		"pxor %%mm5, %%mm5		\n\t" // FIXME slow
-		"pcmpeqw (%0, %%"REG_a"), %%mm4	\n\t" // block[i] == 0 ? -1 : 0
-		"pcmpeqw 8(%0, %%"REG_a"), %%mm5\n\t" // block[i] == 0 ? -1 : 0
-		"psraw $4, %%mm0		\n\t"
-		"psraw $4, %%mm1		\n\t"
-		"psubw %%mm7, %%mm0		\n\t"
-		"psubw %%mm7, %%mm1		\n\t"
-		"por %%mm7, %%mm0		\n\t"
-		"por %%mm7, %%mm1		\n\t"
-		"pxor %%mm2, %%mm0		\n\t"
-		"pxor %%mm3, %%mm1		\n\t"
-		"psubw %%mm2, %%mm0		\n\t"
-		"psubw %%mm3, %%mm1		\n\t"
-		"pandn %%mm0, %%mm4		\n\t"
-		"pandn %%mm1, %%mm5		\n\t"
-		"movq %%mm4, (%0, %%"REG_a")	\n\t"
-		"movq %%mm5, 8(%0, %%"REG_a")	\n\t"
-
-		"add $16, %%"REG_a"		\n\t"
-		"js 1b				\n\t"
-		::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs)
-		: "%"REG_a, "memory"
-	);
-}
-
-static void dct_unquantize_mpeg2_intra_mmx(MpegEncContext *s,
-                                     DCTELEM *block, int n, int qscale)
-{
-    long nCoeffs;
-    const uint16_t *quant_matrix;
-    int block0;
-    
-    assert(s->block_last_index[n]>=0);
-
-    if(s->alternate_scan) nCoeffs= 63; //FIXME
-    else nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
-
-    if (n < 4) 
-        block0 = block[0] * s->y_dc_scale;
-    else
-        block0 = block[0] * s->c_dc_scale;
-    quant_matrix = s->intra_matrix;
-asm volatile(
-		"pcmpeqw %%mm7, %%mm7		\n\t"
-		"psrlw $15, %%mm7		\n\t"
-		"movd %2, %%mm6			\n\t"
-		"packssdw %%mm6, %%mm6		\n\t"
-		"packssdw %%mm6, %%mm6		\n\t"
-		"mov %3, %%"REG_a"		\n\t"
-		".balign 16\n\t"
-		"1:				\n\t"
-		"movq (%0, %%"REG_a"), %%mm0	\n\t"
-		"movq 8(%0, %%"REG_a"), %%mm1	\n\t"
-		"movq (%1, %%"REG_a"), %%mm4	\n\t"
-		"movq 8(%1, %%"REG_a"), %%mm5	\n\t"
-		"pmullw %%mm6, %%mm4		\n\t" // q=qscale*quant_matrix[i]
-		"pmullw %%mm6, %%mm5		\n\t" // q=qscale*quant_matrix[i]
-		"pxor %%mm2, %%mm2		\n\t"
-		"pxor %%mm3, %%mm3		\n\t"
-		"pcmpgtw %%mm0, %%mm2		\n\t" // block[i] < 0 ? -1 : 0
-		"pcmpgtw %%mm1, %%mm3		\n\t" // block[i] < 0 ? -1 : 0
-		"pxor %%mm2, %%mm0		\n\t"
-		"pxor %%mm3, %%mm1		\n\t"
-		"psubw %%mm2, %%mm0		\n\t" // abs(block[i])
-		"psubw %%mm3, %%mm1		\n\t" // abs(block[i])
-		"pmullw %%mm4, %%mm0		\n\t" // abs(block[i])*q
-		"pmullw %%mm5, %%mm1		\n\t" // abs(block[i])*q
-		"pxor %%mm4, %%mm4		\n\t"
-		"pxor %%mm5, %%mm5		\n\t" // FIXME slow
-		"pcmpeqw (%0, %%"REG_a"), %%mm4	\n\t" // block[i] == 0 ? -1 : 0
-		"pcmpeqw 8(%0, %%"REG_a"), %%mm5\n\t" // block[i] == 0 ? -1 : 0
-		"psraw $3, %%mm0		\n\t"
-		"psraw $3, %%mm1		\n\t"
-		"pxor %%mm2, %%mm0		\n\t"
-		"pxor %%mm3, %%mm1		\n\t"
-		"psubw %%mm2, %%mm0		\n\t"
-		"psubw %%mm3, %%mm1		\n\t"
-		"pandn %%mm0, %%mm4		\n\t"
-		"pandn %%mm1, %%mm5		\n\t"
-		"movq %%mm4, (%0, %%"REG_a")	\n\t"
-		"movq %%mm5, 8(%0, %%"REG_a")	\n\t"
-
-		"add $16, %%"REG_a"		\n\t"
-		"jng 1b				\n\t"
-		::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs)
-		: "%"REG_a, "memory"
-	);    
-    block[0]= block0;
-        //Note, we dont do mismatch control for intra as errors cannot accumulate
-}
-
-static void dct_unquantize_mpeg2_inter_mmx(MpegEncContext *s,
-                                     DCTELEM *block, int n, int qscale)
-{
-    long nCoeffs;
-    const uint16_t *quant_matrix;
-    
-    assert(s->block_last_index[n]>=0);
-
-    if(s->alternate_scan) nCoeffs= 63; //FIXME
-    else nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
-
-        quant_matrix = s->inter_matrix;
-asm volatile(
-		"pcmpeqw %%mm7, %%mm7		\n\t"
-                "psrlq $48, %%mm7		\n\t"
-		"movd %2, %%mm6			\n\t"
-		"packssdw %%mm6, %%mm6		\n\t"
-		"packssdw %%mm6, %%mm6		\n\t"
-		"mov %3, %%"REG_a"		\n\t"
-		".balign 16\n\t"
-		"1:				\n\t"
-		"movq (%0, %%"REG_a"), %%mm0	\n\t"
-		"movq 8(%0, %%"REG_a"), %%mm1	\n\t"
-		"movq (%1, %%"REG_a"), %%mm4	\n\t"
-		"movq 8(%1, %%"REG_a"), %%mm5	\n\t"
-		"pmullw %%mm6, %%mm4		\n\t" // q=qscale*quant_matrix[i]
-		"pmullw %%mm6, %%mm5		\n\t" // q=qscale*quant_matrix[i]
-		"pxor %%mm2, %%mm2		\n\t"
-		"pxor %%mm3, %%mm3		\n\t"
-		"pcmpgtw %%mm0, %%mm2		\n\t" // block[i] < 0 ? -1 : 0
-		"pcmpgtw %%mm1, %%mm3		\n\t" // block[i] < 0 ? -1 : 0
-		"pxor %%mm2, %%mm0		\n\t"
-		"pxor %%mm3, %%mm1		\n\t"
-		"psubw %%mm2, %%mm0		\n\t" // abs(block[i])
-		"psubw %%mm3, %%mm1		\n\t" // abs(block[i])
-		"paddw %%mm0, %%mm0		\n\t" // abs(block[i])*2
-		"paddw %%mm1, %%mm1		\n\t" // abs(block[i])*2
-		"pmullw %%mm4, %%mm0		\n\t" // abs(block[i])*2*q
-		"pmullw %%mm5, %%mm1		\n\t" // abs(block[i])*2*q
-		"paddw %%mm4, %%mm0		\n\t" // (abs(block[i])*2 + 1)*q
-		"paddw %%mm5, %%mm1		\n\t" // (abs(block[i])*2 + 1)*q
-		"pxor %%mm4, %%mm4		\n\t"
-		"pxor %%mm5, %%mm5		\n\t" // FIXME slow
-		"pcmpeqw (%0, %%"REG_a"), %%mm4	\n\t" // block[i] == 0 ? -1 : 0
-		"pcmpeqw 8(%0, %%"REG_a"), %%mm5\n\t" // block[i] == 0 ? -1 : 0
-		"psrlw $4, %%mm0		\n\t"
-		"psrlw $4, %%mm1		\n\t"
-		"pxor %%mm2, %%mm0		\n\t"
-		"pxor %%mm3, %%mm1		\n\t"
-		"psubw %%mm2, %%mm0		\n\t"
-		"psubw %%mm3, %%mm1		\n\t"
-		"pandn %%mm0, %%mm4		\n\t"
-		"pandn %%mm1, %%mm5		\n\t"
-                "pxor %%mm4, %%mm7		\n\t"
-                "pxor %%mm5, %%mm7		\n\t"
-		"movq %%mm4, (%0, %%"REG_a")	\n\t"
-		"movq %%mm5, 8(%0, %%"REG_a")	\n\t"
-
-		"add $16, %%"REG_a"		\n\t"
-		"jng 1b				\n\t"
-                "movd 124(%0, %3), %%mm0	\n\t"
-                "movq %%mm7, %%mm6		\n\t"
-                "psrlq $32, %%mm7		\n\t"
-                "pxor %%mm6, %%mm7		\n\t"
-                "movq %%mm7, %%mm6		\n\t"
-                "psrlq $16, %%mm7		\n\t"
-                "pxor %%mm6, %%mm7		\n\t"
-                "pslld $31, %%mm7		\n\t"
-                "psrlq $15, %%mm7		\n\t"
-                "pxor %%mm7, %%mm0		\n\t"
-                "movd %%mm0, 124(%0, %3)	\n\t"
-                
-		::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "r" (-2*nCoeffs)
-		: "%"REG_a, "memory"
-	);
-}
-
-/* draw the edges of width 'w' of an image of size width, height 
-   this mmx version can only handle w==8 || w==16 */
-static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, int w)
-{
-    uint8_t *ptr, *last_line;
-    int i;
-
-    last_line = buf + (height - 1) * wrap;
-    /* left and right */
-    ptr = buf;
-    if(w==8)
-    {
-	asm volatile(
-		"1:				\n\t"
-		"movd (%0), %%mm0		\n\t"
-		"punpcklbw %%mm0, %%mm0		\n\t" 
-		"punpcklwd %%mm0, %%mm0		\n\t"
-		"punpckldq %%mm0, %%mm0		\n\t"
-		"movq %%mm0, -8(%0)		\n\t"
-		"movq -8(%0, %2), %%mm1		\n\t"
-		"punpckhbw %%mm1, %%mm1		\n\t"
-		"punpckhwd %%mm1, %%mm1		\n\t"
-		"punpckhdq %%mm1, %%mm1		\n\t"
-		"movq %%mm1, (%0, %2)		\n\t"
-		"add %1, %0			\n\t"
-		"cmp %3, %0			\n\t"
-		" jb 1b				\n\t"
-		: "+r" (ptr)
-		: "r" ((long)wrap), "r" ((long)width), "r" (ptr + wrap*height)
-	);
-    }
-    else
-    {
-	asm volatile(
-		"1:				\n\t"
-		"movd (%0), %%mm0		\n\t"
-		"punpcklbw %%mm0, %%mm0		\n\t" 
-		"punpcklwd %%mm0, %%mm0		\n\t"
-		"punpckldq %%mm0, %%mm0		\n\t"
-		"movq %%mm0, -8(%0)		\n\t"
-		"movq %%mm0, -16(%0)		\n\t"
-		"movq -8(%0, %2), %%mm1		\n\t"
-		"punpckhbw %%mm1, %%mm1		\n\t"
-		"punpckhwd %%mm1, %%mm1		\n\t"
-		"punpckhdq %%mm1, %%mm1		\n\t"
-		"movq %%mm1, (%0, %2)		\n\t"
-		"movq %%mm1, 8(%0, %2)		\n\t"
-		"add %1, %0			\n\t"
-		"cmp %3, %0			\n\t"
-		" jb 1b				\n\t"		
-		: "+r" (ptr)
-		: "r" ((long)wrap), "r" ((long)width), "r" (ptr + wrap*height)
-	);
-    }
-    
-    for(i=0;i<w;i+=4) {
-        /* top and bottom (and hopefully also the corners) */
-	ptr= buf - (i + 1) * wrap - w;
-	asm volatile(
-		"1:				\n\t"
-		"movq (%1, %0), %%mm0		\n\t"
-		"movq %%mm0, (%0)		\n\t"
-		"movq %%mm0, (%0, %2)		\n\t"
-		"movq %%mm0, (%0, %2, 2)	\n\t"
-		"movq %%mm0, (%0, %3)		\n\t"
-		"add $8, %0			\n\t"
-		"cmp %4, %0			\n\t"
-		" jb 1b				\n\t"
-		: "+r" (ptr)
-		: "r" ((long)buf - (long)ptr - w), "r" ((long)-wrap), "r" ((long)-wrap*3), "r" (ptr+width+2*w)
-	);
-	ptr= last_line + (i + 1) * wrap - w;
-	asm volatile(
-		"1:				\n\t"
-		"movq (%1, %0), %%mm0		\n\t"
-		"movq %%mm0, (%0)		\n\t"
-		"movq %%mm0, (%0, %2)		\n\t"
-		"movq %%mm0, (%0, %2, 2)	\n\t"
-		"movq %%mm0, (%0, %3)		\n\t"
-		"add $8, %0			\n\t"
-		"cmp %4, %0			\n\t"
-		" jb 1b				\n\t"
-		: "+r" (ptr)
-		: "r" ((long)last_line - (long)ptr - w), "r" ((long)wrap), "r" ((long)wrap*3), "r" (ptr+width+2*w)
-	);
-    }
-}
-
-static void  denoise_dct_mmx(MpegEncContext *s, DCTELEM *block){
-    const int intra= s->mb_intra;
-    int *sum= s->dct_error_sum[intra];
-    uint16_t *offset= s->dct_offset[intra];
-
-    s->dct_count[intra]++;
-
-    asm volatile(
-        "pxor %%mm7, %%mm7		\n\t"
-        "1:				\n\t"
-        "pxor %%mm0, %%mm0		\n\t"
-        "pxor %%mm1, %%mm1		\n\t"
-        "movq (%0), %%mm2		\n\t"
-        "movq 8(%0), %%mm3		\n\t"
-        "pcmpgtw %%mm2, %%mm0		\n\t"
-        "pcmpgtw %%mm3, %%mm1		\n\t"
-        "pxor %%mm0, %%mm2		\n\t"
-        "pxor %%mm1, %%mm3		\n\t"
-        "psubw %%mm0, %%mm2		\n\t"
-        "psubw %%mm1, %%mm3		\n\t"
-        "movq %%mm2, %%mm4		\n\t"
-        "movq %%mm3, %%mm5		\n\t"
-        "psubusw (%2), %%mm2		\n\t"
-        "psubusw 8(%2), %%mm3		\n\t"
-        "pxor %%mm0, %%mm2		\n\t"
-        "pxor %%mm1, %%mm3		\n\t"
-        "psubw %%mm0, %%mm2		\n\t"
-        "psubw %%mm1, %%mm3		\n\t"
-        "movq %%mm2, (%0)		\n\t"
-        "movq %%mm3, 8(%0)		\n\t"
-        "movq %%mm4, %%mm2		\n\t"
-        "movq %%mm5, %%mm3		\n\t"
-        "punpcklwd %%mm7, %%mm4		\n\t"
-        "punpckhwd %%mm7, %%mm2		\n\t"
-        "punpcklwd %%mm7, %%mm5		\n\t"
-        "punpckhwd %%mm7, %%mm3		\n\t"
-        "paddd (%1), %%mm4		\n\t"
-        "paddd 8(%1), %%mm2		\n\t"
-        "paddd 16(%1), %%mm5		\n\t"
-        "paddd 24(%1), %%mm3		\n\t"
-        "movq %%mm4, (%1)		\n\t"
-        "movq %%mm2, 8(%1)		\n\t"
-        "movq %%mm5, 16(%1)		\n\t"
-        "movq %%mm3, 24(%1)		\n\t"
-        "add $16, %0			\n\t"
-        "add $32, %1			\n\t"
-        "add $16, %2			\n\t"
-        "cmp %3, %0			\n\t"
-            " jb 1b			\n\t"
-        : "+r" (block), "+r" (sum), "+r" (offset)
-        : "r"(block+64)
-    );
-}
-
-static void  denoise_dct_sse2(MpegEncContext *s, DCTELEM *block){
-    const int intra= s->mb_intra;
-    int *sum= s->dct_error_sum[intra];
-    uint16_t *offset= s->dct_offset[intra];
-
-    s->dct_count[intra]++;
-
-    asm volatile(
-        "pxor %%xmm7, %%xmm7		\n\t"
-        "1:				\n\t"
-        "pxor %%xmm0, %%xmm0		\n\t"
-        "pxor %%xmm1, %%xmm1		\n\t"
-        "movdqa (%0), %%xmm2		\n\t"
-        "movdqa 16(%0), %%xmm3		\n\t"
-        "pcmpgtw %%xmm2, %%xmm0		\n\t"
-        "pcmpgtw %%xmm3, %%xmm1		\n\t"
-        "pxor %%xmm0, %%xmm2		\n\t"
-        "pxor %%xmm1, %%xmm3		\n\t"
-        "psubw %%xmm0, %%xmm2		\n\t"
-        "psubw %%xmm1, %%xmm3		\n\t"
-        "movdqa %%xmm2, %%xmm4		\n\t"
-        "movdqa %%xmm3, %%xmm5		\n\t"
-        "psubusw (%2), %%xmm2		\n\t"
-        "psubusw 16(%2), %%xmm3		\n\t"
-        "pxor %%xmm0, %%xmm2		\n\t"
-        "pxor %%xmm1, %%xmm3		\n\t"
-        "psubw %%xmm0, %%xmm2		\n\t"
-        "psubw %%xmm1, %%xmm3		\n\t"
-        "movdqa %%xmm2, (%0)		\n\t"
-        "movdqa %%xmm3, 16(%0)		\n\t"
-        "movdqa %%xmm4, %%xmm6		\n\t"
-        "movdqa %%xmm5, %%xmm0		\n\t"
-        "punpcklwd %%xmm7, %%xmm4	\n\t"
-        "punpckhwd %%xmm7, %%xmm6	\n\t"
-        "punpcklwd %%xmm7, %%xmm5	\n\t"
-        "punpckhwd %%xmm7, %%xmm0	\n\t"
-        "paddd (%1), %%xmm4		\n\t"
-        "paddd 16(%1), %%xmm6		\n\t"
-        "paddd 32(%1), %%xmm5		\n\t"
-        "paddd 48(%1), %%xmm0		\n\t"
-        "movdqa %%xmm4, (%1)		\n\t"
-        "movdqa %%xmm6, 16(%1)		\n\t"
-        "movdqa %%xmm5, 32(%1)		\n\t"
-        "movdqa %%xmm0, 48(%1)		\n\t"
-        "add $32, %0			\n\t"
-        "add $64, %1			\n\t"
-        "add $32, %2			\n\t"
-        "cmp %3, %0			\n\t"
-            " jb 1b			\n\t"
-        : "+r" (block), "+r" (sum), "+r" (offset)
-        : "r"(block+64)
-    );
-}
-
-#undef HAVE_MMX2
-#define RENAME(a) a ## _MMX
-#define RENAMEl(a) a ## _mmx
-#include "mpegvideo_mmx_template.c"
-
-#define HAVE_MMX2
-#undef RENAME
-#undef RENAMEl
-#define RENAME(a) a ## _MMX2
-#define RENAMEl(a) a ## _mmx2
-#include "mpegvideo_mmx_template.c"
-
-#undef RENAME
-#undef RENAMEl
-#define RENAME(a) a ## _SSE2
-#define RENAMEl(a) a ## _sse2
-#include "mpegvideo_mmx_template.c"
-
-void MPV_common_init_mmx(MpegEncContext *s)
-{
-    if (mm_flags & MM_MMX) {
-        const int dct_algo = s->avctx->dct_algo;
-        
-        s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_mmx;
-        s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_mmx;
-        s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_mmx;
-        s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_mmx;
-        s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_mmx;
-        s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_mmx;
-
-        draw_edges = draw_edges_mmx;
-        
-        if (mm_flags & MM_SSE2) {
-	    s->denoise_dct= denoise_dct_sse2;
-	} else {
-    	    s->denoise_dct= denoise_dct_mmx;
-	}
-
-        if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX){
-            if(mm_flags & MM_SSE2){
-                s->dct_quantize= dct_quantize_SSE2;
-            } else if(mm_flags & MM_MMXEXT){
-                s->dct_quantize= dct_quantize_MMX2;
-            } else {
-                s->dct_quantize= dct_quantize_MMX;
-            }
-        }
-    }
-}
diff --git a/ffmpeg.src/libavcodec/i386/mpegvideo_mmx_template.c b/ffmpeg.src/libavcodec/i386/mpegvideo_mmx_template.c
deleted file mode 100644
index c9354dc..0000000
--- a/ffmpeg.src/libavcodec/i386/mpegvideo_mmx_template.c
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * MPEG video MMX templates
- *
- * Copyright (c) 2002 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#undef SPREADW
-#undef PMAXW
-#ifdef HAVE_MMX2
-#define SPREADW(a) "pshufw $0, " #a ", " #a " \n\t"
-#define PMAXW(a,b) "pmaxsw " #a ", " #b " \n\t"
-
-#else
-#define SPREADW(a) \
-	"punpcklwd " #a ", " #a " \n\t"\
-	"punpcklwd " #a ", " #a " \n\t"
-#define PMAXW(a,b) \
-	"psubusw " #a ", " #b " \n\t"\
-	"paddw " #a ", " #b " \n\t"
-#endif
-
-static int RENAME(dct_quantize)(MpegEncContext *s,
-                            DCTELEM *block, int n,
-                            int qscale, int *overflow)
-{
-    long last_non_zero_p1;
-    int level=0, q; //=0 is cuz gcc says uninitalized ...
-    const uint16_t *qmat, *bias;
-    __align8 int16_t temp_block[64];
-    
-    assert((7&(int)(&temp_block[0])) == 0); //did gcc align it correctly?
-
-    //s->fdct (block);
-    RENAMEl(ff_fdct) (block); //cant be anything else ...
-
-    if(s->dct_error_sum)
-        s->denoise_dct(s, block);
-
-    if (s->mb_intra) {
-        int dummy;
-        if (n < 4)
-            q = s->y_dc_scale;
-        else
-            q = s->c_dc_scale;
-        /* note: block[0] is assumed to be positive */
-        if (!s->h263_aic) {
-#if 1
-        asm volatile (
-        	"mul %%ecx		\n\t"
-        	: "=d" (level), "=a"(dummy)
-        	: "a" ((block[0]>>2) + q), "c" (inverse[q<<1])
-        );
-#else
-        asm volatile (
-        	"xorl %%edx, %%edx	\n\t"
-        	"divw %%cx		\n\t"
-        	"movzwl %%ax, %%eax	\n\t"
-        	: "=a" (level)
-        	: "a" ((block[0]>>2) + q), "c" (q<<1)
-        	: "%edx"
-        );
-#endif
-        } else
-            /* For AIC we skip quant/dequant of INTRADC */
-            level = (block[0] + 4)>>3;
-            
-        block[0]=0; //avoid fake overflow
-//        temp_block[0] = (block[0] + (q >> 1)) / q;
-        last_non_zero_p1 = 1;
-        bias = s->q_intra_matrix16[qscale][1];
-        qmat = s->q_intra_matrix16[qscale][0];
-    } else {
-        last_non_zero_p1 = 0;
-        bias = s->q_inter_matrix16[qscale][1];
-        qmat = s->q_inter_matrix16[qscale][0];
-    }
-
-    if((s->out_format == FMT_H263 || s->out_format == FMT_H261) && s->mpeg_quant==0){
-    
-        asm volatile(
-            "movd %%"REG_a", %%mm3		\n\t" // last_non_zero_p1
-            SPREADW(%%mm3)
-            "pxor %%mm7, %%mm7			\n\t" // 0
-            "pxor %%mm4, %%mm4			\n\t" // 0
-            "movq (%2), %%mm5			\n\t" // qmat[0]
-            "pxor %%mm6, %%mm6			\n\t"
-            "psubw (%3), %%mm6			\n\t" // -bias[0]
-            "mov $-128, %%"REG_a"		\n\t"
-            ".balign 16				\n\t"
-            "1:					\n\t"
-            "pxor %%mm1, %%mm1			\n\t" // 0
-            "movq (%1, %%"REG_a"), %%mm0	\n\t" // block[i]
-            "pcmpgtw %%mm0, %%mm1		\n\t" // block[i] <= 0 ? 0xFF : 0x00
-            "pxor %%mm1, %%mm0			\n\t" 
-            "psubw %%mm1, %%mm0			\n\t" // ABS(block[i])
-            "psubusw %%mm6, %%mm0		\n\t" // ABS(block[i]) + bias[0]
-            "pmulhw %%mm5, %%mm0		\n\t" // (ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16
-            "por %%mm0, %%mm4			\n\t" 
-            "pxor %%mm1, %%mm0			\n\t" 
-            "psubw %%mm1, %%mm0			\n\t" // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i])
-            "movq %%mm0, (%5, %%"REG_a")	\n\t"
-            "pcmpeqw %%mm7, %%mm0		\n\t" // out==0 ? 0xFF : 0x00
-            "movq (%4, %%"REG_a"), %%mm1	\n\t" 
-            "movq %%mm7, (%1, %%"REG_a")	\n\t" // 0
-            "pandn %%mm1, %%mm0			\n\t"
-	    PMAXW(%%mm0, %%mm3)
-            "add $8, %%"REG_a"			\n\t"
-            " js 1b				\n\t"
-            "movq %%mm3, %%mm0			\n\t"
-            "psrlq $32, %%mm3			\n\t"
-	    PMAXW(%%mm0, %%mm3)
-            "movq %%mm3, %%mm0			\n\t"
-            "psrlq $16, %%mm3			\n\t"
-	    PMAXW(%%mm0, %%mm3)
-            "movd %%mm3, %%"REG_a"		\n\t"
-            "movzb %%al, %%"REG_a"		\n\t" // last_non_zero_p1
-	    : "+a" (last_non_zero_p1)
-            : "r" (block+64), "r" (qmat), "r" (bias),
-              "r" (inv_zigzag_direct16+64), "r" (temp_block+64)
-        );
-        // note the asm is split cuz gcc doesnt like that many operands ...
-        asm volatile(
-            "movd %1, %%mm1			\n\t" // max_qcoeff
-	    SPREADW(%%mm1)
-            "psubusw %%mm1, %%mm4		\n\t" 
-            "packuswb %%mm4, %%mm4		\n\t"
-            "movd %%mm4, %0			\n\t" // *overflow
-        : "=g" (*overflow)
-        : "g" (s->max_qcoeff)
-        );
-    }else{ // FMT_H263
-        asm volatile(
-            "movd %%"REG_a", %%mm3		\n\t" // last_non_zero_p1
-            SPREADW(%%mm3)
-            "pxor %%mm7, %%mm7			\n\t" // 0
-            "pxor %%mm4, %%mm4			\n\t" // 0
-            "mov $-128, %%"REG_a"		\n\t"
-            ".balign 16				\n\t"
-            "1:					\n\t"
-            "pxor %%mm1, %%mm1			\n\t" // 0
-            "movq (%1, %%"REG_a"), %%mm0	\n\t" // block[i]
-            "pcmpgtw %%mm0, %%mm1		\n\t" // block[i] <= 0 ? 0xFF : 0x00
-            "pxor %%mm1, %%mm0			\n\t" 
-            "psubw %%mm1, %%mm0			\n\t" // ABS(block[i])
-            "movq (%3, %%"REG_a"), %%mm6	\n\t" // bias[0]
-            "paddusw %%mm6, %%mm0		\n\t" // ABS(block[i]) + bias[0]
-            "movq (%2, %%"REG_a"), %%mm5		\n\t" // qmat[i]
-            "pmulhw %%mm5, %%mm0		\n\t" // (ABS(block[i])*qmat[0] + bias[0]*qmat[0])>>16
-            "por %%mm0, %%mm4			\n\t" 
-            "pxor %%mm1, %%mm0			\n\t" 
-            "psubw %%mm1, %%mm0			\n\t" // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i])
-            "movq %%mm0, (%5, %%"REG_a")	\n\t"
-            "pcmpeqw %%mm7, %%mm0		\n\t" // out==0 ? 0xFF : 0x00
-            "movq (%4, %%"REG_a"), %%mm1		\n\t" 
-            "movq %%mm7, (%1, %%"REG_a")		\n\t" // 0
-            "pandn %%mm1, %%mm0			\n\t"
-	    PMAXW(%%mm0, %%mm3)
-            "add $8, %%"REG_a"			\n\t"
-            " js 1b				\n\t"
-            "movq %%mm3, %%mm0			\n\t"
-            "psrlq $32, %%mm3			\n\t"
-	    PMAXW(%%mm0, %%mm3)
-            "movq %%mm3, %%mm0			\n\t"
-            "psrlq $16, %%mm3			\n\t"
-	    PMAXW(%%mm0, %%mm3)
-            "movd %%mm3, %%"REG_a"		\n\t"
-            "movzb %%al, %%"REG_a"		\n\t" // last_non_zero_p1
-	    : "+a" (last_non_zero_p1)
-            : "r" (block+64), "r" (qmat+64), "r" (bias+64),
-              "r" (inv_zigzag_direct16+64), "r" (temp_block+64)
-        );
-        // note the asm is split cuz gcc doesnt like that many operands ...
-        asm volatile(
-            "movd %1, %%mm1			\n\t" // max_qcoeff
-	    SPREADW(%%mm1)
-            "psubusw %%mm1, %%mm4		\n\t" 
-            "packuswb %%mm4, %%mm4		\n\t"
-            "movd %%mm4, %0			\n\t" // *overflow
-        : "=g" (*overflow)
-        : "g" (s->max_qcoeff)
-        );
-    }
-
-    if(s->mb_intra) block[0]= level;
-    else            block[0]= temp_block[0];
-
-    if(s->dsp.idct_permutation_type == FF_SIMPLE_IDCT_PERM){
-        if(last_non_zero_p1 <= 1) goto end;
-        block[0x08] = temp_block[0x01]; block[0x10] = temp_block[0x08]; 
-        block[0x20] = temp_block[0x10]; 
-        if(last_non_zero_p1 <= 4) goto end;
-        block[0x18] = temp_block[0x09]; block[0x04] = temp_block[0x02]; 
-        block[0x09] = temp_block[0x03]; 
-        if(last_non_zero_p1 <= 7) goto end;
-        block[0x14] = temp_block[0x0A]; block[0x28] = temp_block[0x11]; 
-        block[0x12] = temp_block[0x18]; block[0x02] = temp_block[0x20]; 
-        if(last_non_zero_p1 <= 11) goto end;
-        block[0x1A] = temp_block[0x19]; block[0x24] = temp_block[0x12]; 
-        block[0x19] = temp_block[0x0B]; block[0x01] = temp_block[0x04]; 
-        block[0x0C] = temp_block[0x05]; 
-        if(last_non_zero_p1 <= 16) goto end;
-        block[0x11] = temp_block[0x0C]; block[0x29] = temp_block[0x13]; 
-        block[0x16] = temp_block[0x1A]; block[0x0A] = temp_block[0x21]; 
-        block[0x30] = temp_block[0x28]; block[0x22] = temp_block[0x30]; 
-        block[0x38] = temp_block[0x29]; block[0x06] = temp_block[0x22]; 
-        if(last_non_zero_p1 <= 24) goto end;
-        block[0x1B] = temp_block[0x1B]; block[0x21] = temp_block[0x14]; 
-        block[0x1C] = temp_block[0x0D]; block[0x05] = temp_block[0x06]; 
-        block[0x0D] = temp_block[0x07]; block[0x15] = temp_block[0x0E]; 
-        block[0x2C] = temp_block[0x15]; block[0x13] = temp_block[0x1C]; 
-        if(last_non_zero_p1 <= 32) goto end;
-        block[0x0B] = temp_block[0x23]; block[0x34] = temp_block[0x2A]; 
-        block[0x2A] = temp_block[0x31]; block[0x32] = temp_block[0x38]; 
-        block[0x3A] = temp_block[0x39]; block[0x26] = temp_block[0x32]; 
-        block[0x39] = temp_block[0x2B]; block[0x03] = temp_block[0x24]; 
-        if(last_non_zero_p1 <= 40) goto end;
-        block[0x1E] = temp_block[0x1D]; block[0x25] = temp_block[0x16]; 
-        block[0x1D] = temp_block[0x0F]; block[0x2D] = temp_block[0x17]; 
-        block[0x17] = temp_block[0x1E]; block[0x0E] = temp_block[0x25]; 
-        block[0x31] = temp_block[0x2C]; block[0x2B] = temp_block[0x33]; 
-        if(last_non_zero_p1 <= 48) goto end;
-        block[0x36] = temp_block[0x3A]; block[0x3B] = temp_block[0x3B]; 
-        block[0x23] = temp_block[0x34]; block[0x3C] = temp_block[0x2D]; 
-        block[0x07] = temp_block[0x26]; block[0x1F] = temp_block[0x1F]; 
-        block[0x0F] = temp_block[0x27]; block[0x35] = temp_block[0x2E]; 
-        if(last_non_zero_p1 <= 56) goto end;
-        block[0x2E] = temp_block[0x35]; block[0x33] = temp_block[0x3C]; 
-        block[0x3E] = temp_block[0x3D]; block[0x27] = temp_block[0x36]; 
-        block[0x3D] = temp_block[0x2F]; block[0x2F] = temp_block[0x37]; 
-        block[0x37] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F];
-    }else if(s->dsp.idct_permutation_type == FF_LIBMPEG2_IDCT_PERM){
-        if(last_non_zero_p1 <= 1) goto end;
-        block[0x04] = temp_block[0x01]; 
-        block[0x08] = temp_block[0x08]; block[0x10] = temp_block[0x10]; 
-        if(last_non_zero_p1 <= 4) goto end;
-        block[0x0C] = temp_block[0x09]; block[0x01] = temp_block[0x02]; 
-        block[0x05] = temp_block[0x03]; 
-        if(last_non_zero_p1 <= 7) goto end;
-        block[0x09] = temp_block[0x0A]; block[0x14] = temp_block[0x11]; 
-        block[0x18] = temp_block[0x18]; block[0x20] = temp_block[0x20]; 
-        if(last_non_zero_p1 <= 11) goto end;
-        block[0x1C] = temp_block[0x19]; 
-        block[0x11] = temp_block[0x12]; block[0x0D] = temp_block[0x0B]; 
-        block[0x02] = temp_block[0x04]; block[0x06] = temp_block[0x05]; 
-        if(last_non_zero_p1 <= 16) goto end;
-        block[0x0A] = temp_block[0x0C]; block[0x15] = temp_block[0x13]; 
-        block[0x19] = temp_block[0x1A]; block[0x24] = temp_block[0x21]; 
-        block[0x28] = temp_block[0x28]; block[0x30] = temp_block[0x30]; 
-        block[0x2C] = temp_block[0x29]; block[0x21] = temp_block[0x22]; 
-        if(last_non_zero_p1 <= 24) goto end;
-        block[0x1D] = temp_block[0x1B]; block[0x12] = temp_block[0x14]; 
-        block[0x0E] = temp_block[0x0D]; block[0x03] = temp_block[0x06]; 
-        block[0x07] = temp_block[0x07]; block[0x0B] = temp_block[0x0E]; 
-        block[0x16] = temp_block[0x15]; block[0x1A] = temp_block[0x1C]; 
-        if(last_non_zero_p1 <= 32) goto end;
-        block[0x25] = temp_block[0x23]; block[0x29] = temp_block[0x2A]; 
-        block[0x34] = temp_block[0x31]; block[0x38] = temp_block[0x38]; 
-        block[0x3C] = temp_block[0x39]; block[0x31] = temp_block[0x32]; 
-        block[0x2D] = temp_block[0x2B]; block[0x22] = temp_block[0x24]; 
-        if(last_non_zero_p1 <= 40) goto end;
-        block[0x1E] = temp_block[0x1D]; block[0x13] = temp_block[0x16]; 
-        block[0x0F] = temp_block[0x0F]; block[0x17] = temp_block[0x17]; 
-        block[0x1B] = temp_block[0x1E]; block[0x26] = temp_block[0x25]; 
-        block[0x2A] = temp_block[0x2C]; block[0x35] = temp_block[0x33]; 
-        if(last_non_zero_p1 <= 48) goto end;
-        block[0x39] = temp_block[0x3A]; block[0x3D] = temp_block[0x3B]; 
-        block[0x32] = temp_block[0x34]; block[0x2E] = temp_block[0x2D]; 
-            block[0x23] = temp_block[0x26]; block[0x1F] = temp_block[0x1F]; 
-        block[0x27] = temp_block[0x27]; block[0x2B] = temp_block[0x2E]; 
-        if(last_non_zero_p1 <= 56) goto end;
-        block[0x36] = temp_block[0x35]; block[0x3A] = temp_block[0x3C]; 
-        block[0x3E] = temp_block[0x3D]; block[0x33] = temp_block[0x36]; 
-        block[0x2F] = temp_block[0x2F]; block[0x37] = temp_block[0x37]; 
-        block[0x3B] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F];
-    }else{
-        if(last_non_zero_p1 <= 1) goto end;
-        block[0x01] = temp_block[0x01]; 
-        block[0x08] = temp_block[0x08]; block[0x10] = temp_block[0x10]; 
-        if(last_non_zero_p1 <= 4) goto end;
-        block[0x09] = temp_block[0x09]; block[0x02] = temp_block[0x02]; 
-        block[0x03] = temp_block[0x03]; 
-        if(last_non_zero_p1 <= 7) goto end;
-        block[0x0A] = temp_block[0x0A]; block[0x11] = temp_block[0x11]; 
-        block[0x18] = temp_block[0x18]; block[0x20] = temp_block[0x20]; 
-        if(last_non_zero_p1 <= 11) goto end;
-        block[0x19] = temp_block[0x19]; 
-        block[0x12] = temp_block[0x12]; block[0x0B] = temp_block[0x0B]; 
-        block[0x04] = temp_block[0x04]; block[0x05] = temp_block[0x05]; 
-        if(last_non_zero_p1 <= 16) goto end;
-        block[0x0C] = temp_block[0x0C]; block[0x13] = temp_block[0x13]; 
-        block[0x1A] = temp_block[0x1A]; block[0x21] = temp_block[0x21]; 
-        block[0x28] = temp_block[0x28]; block[0x30] = temp_block[0x30]; 
-        block[0x29] = temp_block[0x29]; block[0x22] = temp_block[0x22]; 
-        if(last_non_zero_p1 <= 24) goto end;
-        block[0x1B] = temp_block[0x1B]; block[0x14] = temp_block[0x14]; 
-        block[0x0D] = temp_block[0x0D]; block[0x06] = temp_block[0x06]; 
-        block[0x07] = temp_block[0x07]; block[0x0E] = temp_block[0x0E]; 
-        block[0x15] = temp_block[0x15]; block[0x1C] = temp_block[0x1C]; 
-        if(last_non_zero_p1 <= 32) goto end;
-        block[0x23] = temp_block[0x23]; block[0x2A] = temp_block[0x2A]; 
-        block[0x31] = temp_block[0x31]; block[0x38] = temp_block[0x38]; 
-        block[0x39] = temp_block[0x39]; block[0x32] = temp_block[0x32]; 
-        block[0x2B] = temp_block[0x2B]; block[0x24] = temp_block[0x24]; 
-        if(last_non_zero_p1 <= 40) goto end;
-        block[0x1D] = temp_block[0x1D]; block[0x16] = temp_block[0x16]; 
-        block[0x0F] = temp_block[0x0F]; block[0x17] = temp_block[0x17]; 
-        block[0x1E] = temp_block[0x1E]; block[0x25] = temp_block[0x25]; 
-        block[0x2C] = temp_block[0x2C]; block[0x33] = temp_block[0x33]; 
-        if(last_non_zero_p1 <= 48) goto end;
-        block[0x3A] = temp_block[0x3A]; block[0x3B] = temp_block[0x3B]; 
-        block[0x34] = temp_block[0x34]; block[0x2D] = temp_block[0x2D]; 
-        block[0x26] = temp_block[0x26]; block[0x1F] = temp_block[0x1F]; 
-        block[0x27] = temp_block[0x27]; block[0x2E] = temp_block[0x2E]; 
-        if(last_non_zero_p1 <= 56) goto end;
-        block[0x35] = temp_block[0x35]; block[0x3C] = temp_block[0x3C]; 
-        block[0x3D] = temp_block[0x3D]; block[0x36] = temp_block[0x36]; 
-        block[0x2F] = temp_block[0x2F]; block[0x37] = temp_block[0x37]; 
-        block[0x3E] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F];
-    }
-    end:
-/*
-    for(i=0; i<last_non_zero_p1; i++)
-    {
-       int j= zigzag_direct_noperm[i];
-       block[block_permute_op(j)]= temp_block[j];
-    }
-*/
-
-    return last_non_zero_p1 - 1;
-}
diff --git a/ffmpeg.src/libavcodec/i386/simple_idct_mmx.c b/ffmpeg.src/libavcodec/i386/simple_idct_mmx.c
deleted file mode 100644
index 92a366f..0000000
--- a/ffmpeg.src/libavcodec/i386/simple_idct_mmx.c
+++ /dev/null
@@ -1,1314 +0,0 @@
-/*
- * Simple IDCT MMX
- *
- * Copyright (c) 2001, 2002 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "../dsputil.h"
-#include "../simple_idct.h"
-
-/*
-23170.475006
-22725.260826
-21406.727617
-19265.545870
-16384.000000
-12872.826198
-8866.956905
-4520.335430
-*/
-#define C0 23170 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define C1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define C2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define C3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#if 0
-#define C4 16384 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#else
-#define C4 16383 //cos(i*M_PI/16)*sqrt(2)*(1<<14) - 0.5
-#endif
-#define C5 12873 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define C6 8867 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define C7 4520 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-
-#define ROW_SHIFT 11
-#define COL_SHIFT 20 // 6
-
-static const uint64_t attribute_used __attribute__((aligned(8))) wm1010= 0xFFFF0000FFFF0000ULL;
-static const uint64_t attribute_used __attribute__((aligned(8))) d40000= 0x0000000000040000ULL;
-
-static const int16_t __attribute__((aligned(8))) coeffs[]= {
-	1<<(ROW_SHIFT-1), 0, 1<<(ROW_SHIFT-1), 0,
-//	1<<(COL_SHIFT-1), 0, 1<<(COL_SHIFT-1), 0,
-//	0, 1<<(COL_SHIFT-1-16), 0, 1<<(COL_SHIFT-1-16),
-	1<<(ROW_SHIFT-1), 1, 1<<(ROW_SHIFT-1), 0,
-	// the 1 = ((1<<(COL_SHIFT-1))/C4)<<ROW_SHIFT :)
-//	0, 0, 0, 0,
-//	0, 0, 0, 0,
-
- C4,  C4,  C4,  C4,
- C4, -C4,  C4, -C4,
- 
- C2,  C6,  C2,  C6,
- C6, -C2,  C6, -C2,
- 
- C1,  C3,  C1,  C3,
- C5,  C7,  C5,  C7,
- 
- C3, -C7,  C3, -C7,
--C1, -C5, -C1, -C5,
- 
- C5, -C1,  C5, -C1,
- C7,  C3,  C7,  C3,
- 
- C7, -C5,  C7, -C5,
- C3, -C1,  C3, -C1
-};
-
-#if 0
-static void unused_var_killer(){
-	int a= wm1010 + d40000;
-	temp[0]=a;
-}
-
-static void inline idctCol (int16_t * col, int16_t *input)
-{
-#undef C0
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-	int a0, a1, a2, a3, b0, b1, b2, b3;
-	const int C0 = 23170; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-	const int C1 = 22725; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-	const int C2 = 21407; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-	const int C3 = 19266; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-	const int C4 = 16383; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-	const int C5 = 12873; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-	const int C6 = 8867; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-	const int C7 = 4520; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-/*
-	if( !(col[8*1] | col[8*2] |col[8*3] |col[8*4] |col[8*5] |col[8*6] | col[8*7])) {
-		col[8*0] = col[8*1] = col[8*2] = col[8*3] = col[8*4] =
-			col[8*5] = col[8*6] = col[8*7] = col[8*0]<<3;
-		return;
-	}*/
-
-col[8*0] = input[8*0 + 0];
-col[8*1] = input[8*2 + 0];
-col[8*2] = input[8*0 + 1];
-col[8*3] = input[8*2 + 1];
-col[8*4] = input[8*4 + 0];
-col[8*5] = input[8*6 + 0];
-col[8*6] = input[8*4 + 1];
-col[8*7] = input[8*6 + 1];
-
-	a0 = C4*col[8*0] + C2*col[8*2] + C4*col[8*4] + C6*col[8*6] + (1<<(COL_SHIFT-1));
-	a1 = C4*col[8*0] + C6*col[8*2] - C4*col[8*4] - C2*col[8*6] + (1<<(COL_SHIFT-1));
-	a2 = C4*col[8*0] - C6*col[8*2] - C4*col[8*4] + C2*col[8*6] + (1<<(COL_SHIFT-1));
-	a3 = C4*col[8*0] - C2*col[8*2] + C4*col[8*4] - C6*col[8*6] + (1<<(COL_SHIFT-1));
-
-	b0 = C1*col[8*1] + C3*col[8*3] + C5*col[8*5] + C7*col[8*7];
-	b1 = C3*col[8*1] - C7*col[8*3] - C1*col[8*5] - C5*col[8*7];
-	b2 = C5*col[8*1] - C1*col[8*3] + C7*col[8*5] + C3*col[8*7];
-	b3 = C7*col[8*1] - C5*col[8*3] + C3*col[8*5] - C1*col[8*7];
-
-	col[8*0] = (a0 + b0) >> COL_SHIFT;
-	col[8*1] = (a1 + b1) >> COL_SHIFT;
-	col[8*2] = (a2 + b2) >> COL_SHIFT;
-	col[8*3] = (a3 + b3) >> COL_SHIFT;
-	col[8*4] = (a3 - b3) >> COL_SHIFT;
-	col[8*5] = (a2 - b2) >> COL_SHIFT;
-	col[8*6] = (a1 - b1) >> COL_SHIFT;
-	col[8*7] = (a0 - b0) >> COL_SHIFT;
-}
-
-static void inline idctRow (int16_t * output, int16_t * input)
-{
-	int16_t row[8];
-
-	int a0, a1, a2, a3, b0, b1, b2, b3;
-	const int C0 = 23170; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-	const int C1 = 22725; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-	const int C2 = 21407; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-	const int C3 = 19266; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-	const int C4 = 16383; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-	const int C5 = 12873; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-	const int C6 = 8867; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-	const int C7 = 4520; //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-
-row[0] = input[0];
-row[2] = input[1];
-row[4] = input[4];
-row[6] = input[5];
-row[1] = input[8];
-row[3] = input[9];
-row[5] = input[12];
-row[7] = input[13];
-
-	if( !(row[1] | row[2] |row[3] |row[4] |row[5] |row[6] | row[7]) ) {
-		row[0] = row[1] = row[2] = row[3] = row[4] =
-			row[5] = row[6] = row[7] = row[0]<<3;
-	output[0] = row[0];
-	output[2] = row[1];
-	output[4] = row[2];
-	output[6] = row[3];
-	output[8] = row[4];
-	output[10] = row[5];
-	output[12] = row[6];
-	output[14] = row[7];
-		return;
-	}
-
-	a0 = C4*row[0] + C2*row[2] + C4*row[4] + C6*row[6] + (1<<(ROW_SHIFT-1));
-	a1 = C4*row[0] + C6*row[2] - C4*row[4] - C2*row[6] + (1<<(ROW_SHIFT-1));
-	a2 = C4*row[0] - C6*row[2] - C4*row[4] + C2*row[6] + (1<<(ROW_SHIFT-1));
-	a3 = C4*row[0] - C2*row[2] + C4*row[4] - C6*row[6] + (1<<(ROW_SHIFT-1));
-
-	b0 = C1*row[1] + C3*row[3] + C5*row[5] + C7*row[7];
-	b1 = C3*row[1] - C7*row[3] - C1*row[5] - C5*row[7];
-	b2 = C5*row[1] - C1*row[3] + C7*row[5] + C3*row[7];
-	b3 = C7*row[1] - C5*row[3] + C3*row[5] - C1*row[7];
-
-	row[0] = (a0 + b0) >> ROW_SHIFT;
-	row[1] = (a1 + b1) >> ROW_SHIFT;
-	row[2] = (a2 + b2) >> ROW_SHIFT;
-	row[3] = (a3 + b3) >> ROW_SHIFT;
-	row[4] = (a3 - b3) >> ROW_SHIFT;
-	row[5] = (a2 - b2) >> ROW_SHIFT;
-	row[6] = (a1 - b1) >> ROW_SHIFT;
-	row[7] = (a0 - b0) >> ROW_SHIFT;
-
-	output[0] = row[0];
-	output[2] = row[1];
-	output[4] = row[2];
-	output[6] = row[3];
-	output[8] = row[4];
-	output[10] = row[5];
-	output[12] = row[6];
-	output[14] = row[7];
-}
-#endif
-
-static inline void idct(int16_t *block)
-{
-	int64_t __attribute__((aligned(8))) align_tmp[16];
-	int16_t * const temp= (int16_t*)align_tmp;
-
-	asm volatile(
-#if 0 //Alternative, simpler variant
-
-#define ROW_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
-	"movq " #src0 ", %%mm0			\n\t" /* R4	R0	r4	r0 */\
-	"movq " #src4 ", %%mm1			\n\t" /* R6	R2	r6	r2 */\
-	"movq " #src1 ", %%mm2			\n\t" /* R3	R1	r3	r1 */\
-	"movq " #src5 ", %%mm3			\n\t" /* R7	R5	r7	r5 */\
-	"movq 16(%2), %%mm4			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm5			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm5, %%mm0			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 32(%2), %%mm5			\n\t" /* C6	C2	C6	C2 */\
-	"pmaddwd %%mm1, %%mm5			\n\t" /* C6R6+C2R2	C6r6+C2r2 */\
-	"movq 40(%2), %%mm6			\n\t" /* -C2	C6	-C2	C6 */\
-	"pmaddwd %%mm6, %%mm1			\n\t" /* -C2R6+C6R2	-C2r6+C6r2 */\
-	"movq 48(%2), %%mm7			\n\t" /* C3	C1	C3	C1 */\
-	"pmaddwd %%mm2, %%mm7			\n\t" /* C3R3+C1R1	C3r3+C1r1 */\
-	#rounder ", %%mm4			\n\t"\
-	"movq %%mm4, %%mm6			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"paddd %%mm5, %%mm4			\n\t" /* A0		a0 */\
-	"psubd %%mm5, %%mm6			\n\t" /* A3		a3 */\
-	"movq 56(%2), %%mm5			\n\t" /* C7	C5	C7	C5 */\
-	"pmaddwd %%mm3, %%mm5			\n\t" /* C7R7+C5R5	C7r7+C5r5 */\
-	#rounder ", %%mm0			\n\t"\
-	"paddd %%mm0, %%mm1			\n\t" /* A1		a1 */\
-	"paddd %%mm0, %%mm0			\n\t" \
-	"psubd %%mm1, %%mm0			\n\t" /* A2		a2 */\
-	"pmaddwd 64(%2), %%mm2			\n\t" /* -C7R3+C3R1	-C7r3+C3r1 */\
-	"paddd %%mm5, %%mm7			\n\t" /* B0		b0 */\
-	"movq 72(%2), %%mm5			\n\t" /* -C5	-C1	-C5	-C1 */\
-	"pmaddwd %%mm3, %%mm5			\n\t" /* -C5R7-C1R5	-C5r7-C1r5 */\
-	"paddd %%mm4, %%mm7			\n\t" /* A0+B0		a0+b0 */\
-	"paddd %%mm4, %%mm4			\n\t" /* 2A0		2a0 */\
-	"psubd %%mm7, %%mm4			\n\t" /* A0-B0		a0-b0 */\
-	"paddd %%mm2, %%mm5			\n\t" /* B1		b1 */\
-	"psrad $" #shift ", %%mm7		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"movq %%mm1, %%mm2			\n\t" /* A1		a1 */\
-	"paddd %%mm5, %%mm1			\n\t" /* A1+B1		a1+b1 */\
-	"psubd %%mm5, %%mm2			\n\t" /* A1-B1		a1-b1 */\
-	"psrad $" #shift ", %%mm1		\n\t"\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"packssdw %%mm1, %%mm7			\n\t" /* A1+B1	a1+b1	A0+B0	a0+b0 */\
-	"packssdw %%mm4, %%mm2			\n\t" /* A0-B0	a0-b0	A1-B1	a1-b1 */\
-	"movq %%mm7, " #dst "			\n\t"\
-	"movq " #src1 ", %%mm1			\n\t" /* R3	R1	r3	r1 */\
-	"movq 80(%2), %%mm4			\n\t" /* -C1	C5	-C1 	C5 */\
-	"movq %%mm2, 24+" #dst "		\n\t"\
-	"pmaddwd %%mm1, %%mm4			\n\t" /* -C1R3+C5R1	-C1r3+C5r1 */\
-	"movq 88(%2), %%mm7			\n\t" /* C3	C7	C3 	C7 */\
-	"pmaddwd 96(%2), %%mm1			\n\t" /* -C5R3+C7R1	-C5r3+C7r1 */\
-	"pmaddwd %%mm3, %%mm7			\n\t" /* C3R7+C7R5	C3r7+C7r5 */\
-	"movq %%mm0, %%mm2			\n\t" /* A2		a2 */\
-	"pmaddwd 104(%2), %%mm3			\n\t" /* -C1R7+C3R5	-C1r7+C3r5 */\
-	"paddd %%mm7, %%mm4			\n\t" /* B2		b2 */\
-	"paddd %%mm4, %%mm2			\n\t" /* A2+B2		a2+b2 */\
-	"psubd %%mm4, %%mm0			\n\t" /* a2-B2		a2-b2 */\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"psrad $" #shift ", %%mm0		\n\t"\
-	"movq %%mm6, %%mm4			\n\t" /* A3		a3 */\
-	"paddd %%mm1, %%mm3			\n\t" /* B3		b3 */\
-	"paddd %%mm3, %%mm6			\n\t" /* A3+B3		a3+b3 */\
-	"psubd %%mm3, %%mm4			\n\t" /* a3-B3		a3-b3 */\
-	"psrad $" #shift ", %%mm6		\n\t"\
-	"packssdw %%mm6, %%mm2			\n\t" /* A3+B3	a3+b3	A2+B2	a2+b2 */\
-	"movq %%mm2, 8+" #dst "			\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"packssdw %%mm0, %%mm4			\n\t" /* A2-B2	a2-b2	A3-B3	a3-b3 */\
-	"movq %%mm4, 16+" #dst "		\n\t"\
-
-#define COL_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
-	"movq " #src0 ", %%mm0			\n\t" /* R4	R0	r4	r0 */\
-	"movq " #src4 ", %%mm1			\n\t" /* R6	R2	r6	r2 */\
-	"movq " #src1 ", %%mm2			\n\t" /* R3	R1	r3	r1 */\
-	"movq " #src5 ", %%mm3			\n\t" /* R7	R5	r7	r5 */\
-	"movq 16(%2), %%mm4			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm5			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm5, %%mm0			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 32(%2), %%mm5			\n\t" /* C6	C2	C6	C2 */\
-	"pmaddwd %%mm1, %%mm5			\n\t" /* C6R6+C2R2	C6r6+C2r2 */\
-	"movq 40(%2), %%mm6			\n\t" /* -C2	C6	-C2	C6 */\
-	"pmaddwd %%mm6, %%mm1			\n\t" /* -C2R6+C6R2	-C2r6+C6r2 */\
-	#rounder ", %%mm4			\n\t"\
-	"movq %%mm4, %%mm6			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 48(%2), %%mm7			\n\t" /* C3	C1	C3	C1 */\
-	#rounder ", %%mm0			\n\t"\
-	"pmaddwd %%mm2, %%mm7			\n\t" /* C3R3+C1R1	C3r3+C1r1 */\
-	"paddd %%mm5, %%mm4			\n\t" /* A0		a0 */\
-	"psubd %%mm5, %%mm6			\n\t" /* A3		a3 */\
-	"movq %%mm0, %%mm5			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"paddd %%mm1, %%mm0			\n\t" /* A1		a1 */\
-	"psubd %%mm1, %%mm5			\n\t" /* A2		a2 */\
-	"movq 56(%2), %%mm1			\n\t" /* C7	C5	C7	C5 */\
-	"pmaddwd %%mm3, %%mm1			\n\t" /* C7R7+C5R5	C7r7+C5r5 */\
-	"pmaddwd 64(%2), %%mm2			\n\t" /* -C7R3+C3R1	-C7r3+C3r1 */\
-	"paddd %%mm1, %%mm7			\n\t" /* B0		b0 */\
-	"movq 72(%2), %%mm1			\n\t" /* -C5	-C1	-C5	-C1 */\
-	"pmaddwd %%mm3, %%mm1			\n\t" /* -C5R7-C1R5	-C5r7-C1r5 */\
-	"paddd %%mm4, %%mm7			\n\t" /* A0+B0		a0+b0 */\
-	"paddd %%mm4, %%mm4			\n\t" /* 2A0		2a0 */\
-	"psubd %%mm7, %%mm4			\n\t" /* A0-B0		a0-b0 */\
-	"paddd %%mm2, %%mm1			\n\t" /* B1		b1 */\
-	"psrad $" #shift ", %%mm7		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"movq %%mm0, %%mm2			\n\t" /* A1		a1 */\
-	"paddd %%mm1, %%mm0			\n\t" /* A1+B1		a1+b1 */\
-	"psubd %%mm1, %%mm2			\n\t" /* A1-B1		a1-b1 */\
-	"psrad $" #shift ", %%mm0		\n\t"\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"packssdw %%mm7, %%mm7			\n\t" /* A0+B0	a0+b0 */\
-	"movd %%mm7, " #dst "			\n\t"\
-	"packssdw %%mm0, %%mm0			\n\t" /* A1+B1	a1+b1 */\
-	"movd %%mm0, 16+" #dst "		\n\t"\
-	"packssdw %%mm2, %%mm2			\n\t" /* A1-B1	a1-b1 */\
-	"movd %%mm2, 96+" #dst "		\n\t"\
-	"packssdw %%mm4, %%mm4			\n\t" /* A0-B0	a0-b0 */\
-	"movd %%mm4, 112+" #dst "		\n\t"\
-	"movq " #src1 ", %%mm0			\n\t" /* R3	R1	r3	r1 */\
-	"movq 80(%2), %%mm4			\n\t" /* -C1	C5	-C1 	C5 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* -C1R3+C5R1	-C1r3+C5r1 */\
-	"movq 88(%2), %%mm7			\n\t" /* C3	C7	C3 	C7 */\
-	"pmaddwd 96(%2), %%mm0			\n\t" /* -C5R3+C7R1	-C5r3+C7r1 */\
-	"pmaddwd %%mm3, %%mm7			\n\t" /* C3R7+C7R5	C3r7+C7r5 */\
-	"movq %%mm5, %%mm2			\n\t" /* A2		a2 */\
-	"pmaddwd 104(%2), %%mm3			\n\t" /* -C1R7+C3R5	-C1r7+C3r5 */\
-	"paddd %%mm7, %%mm4			\n\t" /* B2		b2 */\
-	"paddd %%mm4, %%mm2			\n\t" /* A2+B2		a2+b2 */\
-	"psubd %%mm4, %%mm5			\n\t" /* a2-B2		a2-b2 */\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"psrad $" #shift ", %%mm5		\n\t"\
-	"movq %%mm6, %%mm4			\n\t" /* A3		a3 */\
-	"paddd %%mm0, %%mm3			\n\t" /* B3		b3 */\
-	"paddd %%mm3, %%mm6			\n\t" /* A3+B3		a3+b3 */\
-	"psubd %%mm3, %%mm4			\n\t" /* a3-B3		a3-b3 */\
-	"psrad $" #shift ", %%mm6		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"packssdw %%mm2, %%mm2			\n\t" /* A2+B2	a2+b2 */\
-	"packssdw %%mm6, %%mm6			\n\t" /* A3+B3	a3+b3 */\
-	"movd %%mm2, 32+" #dst "		\n\t"\
-	"packssdw %%mm4, %%mm4			\n\t" /* A3-B3	a3-b3 */\
-	"packssdw %%mm5, %%mm5			\n\t" /* A2-B2	a2-b2 */\
-	"movd %%mm6, 48+" #dst "		\n\t"\
-	"movd %%mm4, 64+" #dst "		\n\t"\
-	"movd %%mm5, 80+" #dst "		\n\t"\
-
-	
-#define DC_COND_ROW_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
-	"movq " #src0 ", %%mm0			\n\t" /* R4	R0	r4	r0 */\
-	"movq " #src4 ", %%mm1			\n\t" /* R6	R2	r6	r2 */\
-	"movq " #src1 ", %%mm2			\n\t" /* R3	R1	r3	r1 */\
-	"movq " #src5 ", %%mm3			\n\t" /* R7	R5	r7	r5 */\
-	"movq "MANGLE(wm1010)", %%mm4		\n\t"\
-	"pand %%mm0, %%mm4			\n\t"\
-	"por %%mm1, %%mm4			\n\t"\
-	"por %%mm2, %%mm4			\n\t"\
-	"por %%mm3, %%mm4			\n\t"\
-	"packssdw %%mm4,%%mm4			\n\t"\
-	"movd %%mm4, %%eax			\n\t"\
-	"orl %%eax, %%eax			\n\t"\
-	"jz 1f					\n\t"\
-	"movq 16(%2), %%mm4			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm5			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm5, %%mm0			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 32(%2), %%mm5			\n\t" /* C6	C2	C6	C2 */\
-	"pmaddwd %%mm1, %%mm5			\n\t" /* C6R6+C2R2	C6r6+C2r2 */\
-	"movq 40(%2), %%mm6			\n\t" /* -C2	C6	-C2	C6 */\
-	"pmaddwd %%mm6, %%mm1			\n\t" /* -C2R6+C6R2	-C2r6+C6r2 */\
-	"movq 48(%2), %%mm7			\n\t" /* C3	C1	C3	C1 */\
-	"pmaddwd %%mm2, %%mm7			\n\t" /* C3R3+C1R1	C3r3+C1r1 */\
-	#rounder ", %%mm4			\n\t"\
-	"movq %%mm4, %%mm6			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"paddd %%mm5, %%mm4			\n\t" /* A0		a0 */\
-	"psubd %%mm5, %%mm6			\n\t" /* A3		a3 */\
-	"movq 56(%2), %%mm5			\n\t" /* C7	C5	C7	C5 */\
-	"pmaddwd %%mm3, %%mm5			\n\t" /* C7R7+C5R5	C7r7+C5r5 */\
-	#rounder ", %%mm0			\n\t"\
-	"paddd %%mm0, %%mm1			\n\t" /* A1		a1 */\
-	"paddd %%mm0, %%mm0			\n\t" \
-	"psubd %%mm1, %%mm0			\n\t" /* A2		a2 */\
-	"pmaddwd 64(%2), %%mm2			\n\t" /* -C7R3+C3R1	-C7r3+C3r1 */\
-	"paddd %%mm5, %%mm7			\n\t" /* B0		b0 */\
-	"movq 72(%2), %%mm5			\n\t" /* -C5	-C1	-C5	-C1 */\
-	"pmaddwd %%mm3, %%mm5			\n\t" /* -C5R7-C1R5	-C5r7-C1r5 */\
-	"paddd %%mm4, %%mm7			\n\t" /* A0+B0		a0+b0 */\
-	"paddd %%mm4, %%mm4			\n\t" /* 2A0		2a0 */\
-	"psubd %%mm7, %%mm4			\n\t" /* A0-B0		a0-b0 */\
-	"paddd %%mm2, %%mm5			\n\t" /* B1		b1 */\
-	"psrad $" #shift ", %%mm7		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"movq %%mm1, %%mm2			\n\t" /* A1		a1 */\
-	"paddd %%mm5, %%mm1			\n\t" /* A1+B1		a1+b1 */\
-	"psubd %%mm5, %%mm2			\n\t" /* A1-B1		a1-b1 */\
-	"psrad $" #shift ", %%mm1		\n\t"\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"packssdw %%mm1, %%mm7			\n\t" /* A1+B1	a1+b1	A0+B0	a0+b0 */\
-	"packssdw %%mm4, %%mm2			\n\t" /* A0-B0	a0-b0	A1-B1	a1-b1 */\
-	"movq %%mm7, " #dst "			\n\t"\
-	"movq " #src1 ", %%mm1			\n\t" /* R3	R1	r3	r1 */\
-	"movq 80(%2), %%mm4			\n\t" /* -C1	C5	-C1 	C5 */\
-	"movq %%mm2, 24+" #dst "		\n\t"\
-	"pmaddwd %%mm1, %%mm4			\n\t" /* -C1R3+C5R1	-C1r3+C5r1 */\
-	"movq 88(%2), %%mm7			\n\t" /* C3	C7	C3 	C7 */\
-	"pmaddwd 96(%2), %%mm1			\n\t" /* -C5R3+C7R1	-C5r3+C7r1 */\
-	"pmaddwd %%mm3, %%mm7			\n\t" /* C3R7+C7R5	C3r7+C7r5 */\
-	"movq %%mm0, %%mm2			\n\t" /* A2		a2 */\
-	"pmaddwd 104(%2), %%mm3			\n\t" /* -C1R7+C3R5	-C1r7+C3r5 */\
-	"paddd %%mm7, %%mm4			\n\t" /* B2		b2 */\
-	"paddd %%mm4, %%mm2			\n\t" /* A2+B2		a2+b2 */\
-	"psubd %%mm4, %%mm0			\n\t" /* a2-B2		a2-b2 */\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"psrad $" #shift ", %%mm0		\n\t"\
-	"movq %%mm6, %%mm4			\n\t" /* A3		a3 */\
-	"paddd %%mm1, %%mm3			\n\t" /* B3		b3 */\
-	"paddd %%mm3, %%mm6			\n\t" /* A3+B3		a3+b3 */\
-	"psubd %%mm3, %%mm4			\n\t" /* a3-B3		a3-b3 */\
-	"psrad $" #shift ", %%mm6		\n\t"\
-	"packssdw %%mm6, %%mm2			\n\t" /* A3+B3	a3+b3	A2+B2	a2+b2 */\
-	"movq %%mm2, 8+" #dst "			\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"packssdw %%mm0, %%mm4			\n\t" /* A2-B2	a2-b2	A3-B3	a3-b3 */\
-	"movq %%mm4, 16+" #dst "		\n\t"\
-	"jmp 2f					\n\t"\
-	"1:					\n\t"\
-	"pslld $16, %%mm0			\n\t"\
-	"#paddd "MANGLE(d40000)", %%mm0		\n\t"\
-	"psrad $13, %%mm0			\n\t"\
-	"packssdw %%mm0, %%mm0			\n\t"\
-	"movq %%mm0, " #dst "			\n\t"\
-	"movq %%mm0, 8+" #dst "			\n\t"\
-	"movq %%mm0, 16+" #dst "		\n\t"\
-	"movq %%mm0, 24+" #dst "		\n\t"\
-	"2:					\n\t"
-
-
-//IDCT(      src0,   src4,   src1,   src5,    dst,    rounder, shift)
-ROW_IDCT(    (%0),  8(%0), 16(%0), 24(%0),  0(%1),paddd 8(%2), 11)
-/*ROW_IDCT(  32(%0), 40(%0), 48(%0), 56(%0), 32(%1), paddd (%2), 11)
-ROW_IDCT(  64(%0), 72(%0), 80(%0), 88(%0), 64(%1), paddd (%2), 11)
-ROW_IDCT(  96(%0),104(%0),112(%0),120(%0), 96(%1), paddd (%2), 11)*/
-
-DC_COND_ROW_IDCT(  32(%0), 40(%0), 48(%0), 56(%0), 32(%1),paddd (%2), 11)
-DC_COND_ROW_IDCT(  64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddd (%2), 11)
-DC_COND_ROW_IDCT(  96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11)
-
-
-//IDCT(      src0,   src4,   src1,    src5,    dst, rounder, shift)
-COL_IDCT(    (%1), 64(%1), 32(%1),  96(%1),  0(%0),/nop, 20)
-COL_IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),/nop, 20)
-COL_IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),/nop, 20)
-COL_IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
-
-#else
-
-#define DC_COND_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
-	"movq " #src0 ", %%mm0			\n\t" /* R4	R0	r4	r0 */\
-	"movq " #src4 ", %%mm1			\n\t" /* R6	R2	r6	r2 */\
-	"movq " #src1 ", %%mm2			\n\t" /* R3	R1	r3	r1 */\
-	"movq " #src5 ", %%mm3			\n\t" /* R7	R5	r7	r5 */\
-	"movq "MANGLE(wm1010)", %%mm4		\n\t"\
-	"pand %%mm0, %%mm4			\n\t"\
-	"por %%mm1, %%mm4			\n\t"\
-	"por %%mm2, %%mm4			\n\t"\
-	"por %%mm3, %%mm4			\n\t"\
-	"packssdw %%mm4,%%mm4			\n\t"\
-	"movd %%mm4, %%eax			\n\t"\
-	"orl %%eax, %%eax			\n\t"\
-	"jz 1f					\n\t"\
-	"movq 16(%2), %%mm4			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm5			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm5, %%mm0			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 32(%2), %%mm5			\n\t" /* C6	C2	C6	C2 */\
-	"pmaddwd %%mm1, %%mm5			\n\t" /* C6R6+C2R2	C6r6+C2r2 */\
-	"movq 40(%2), %%mm6			\n\t" /* -C2	C6	-C2	C6 */\
-	"pmaddwd %%mm6, %%mm1			\n\t" /* -C2R6+C6R2	-C2r6+C6r2 */\
-	"movq 48(%2), %%mm7			\n\t" /* C3	C1	C3	C1 */\
-	"pmaddwd %%mm2, %%mm7			\n\t" /* C3R3+C1R1	C3r3+C1r1 */\
-	#rounder ", %%mm4			\n\t"\
-	"movq %%mm4, %%mm6			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"paddd %%mm5, %%mm4			\n\t" /* A0		a0 */\
-	"psubd %%mm5, %%mm6			\n\t" /* A3		a3 */\
-	"movq 56(%2), %%mm5			\n\t" /* C7	C5	C7	C5 */\
-	"pmaddwd %%mm3, %%mm5			\n\t" /* C7R7+C5R5	C7r7+C5r5 */\
-	#rounder ", %%mm0			\n\t"\
-	"paddd %%mm0, %%mm1			\n\t" /* A1		a1 */\
-	"paddd %%mm0, %%mm0			\n\t" \
-	"psubd %%mm1, %%mm0			\n\t" /* A2		a2 */\
-	"pmaddwd 64(%2), %%mm2			\n\t" /* -C7R3+C3R1	-C7r3+C3r1 */\
-	"paddd %%mm5, %%mm7			\n\t" /* B0		b0 */\
-	"movq 72(%2), %%mm5			\n\t" /* -C5	-C1	-C5	-C1 */\
-	"pmaddwd %%mm3, %%mm5			\n\t" /* -C5R7-C1R5	-C5r7-C1r5 */\
-	"paddd %%mm4, %%mm7			\n\t" /* A0+B0		a0+b0 */\
-	"paddd %%mm4, %%mm4			\n\t" /* 2A0		2a0 */\
-	"psubd %%mm7, %%mm4			\n\t" /* A0-B0		a0-b0 */\
-	"paddd %%mm2, %%mm5			\n\t" /* B1		b1 */\
-	"psrad $" #shift ", %%mm7		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"movq %%mm1, %%mm2			\n\t" /* A1		a1 */\
-	"paddd %%mm5, %%mm1			\n\t" /* A1+B1		a1+b1 */\
-	"psubd %%mm5, %%mm2			\n\t" /* A1-B1		a1-b1 */\
-	"psrad $" #shift ", %%mm1		\n\t"\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"packssdw %%mm1, %%mm7			\n\t" /* A1+B1	a1+b1	A0+B0	a0+b0 */\
-	"packssdw %%mm4, %%mm2			\n\t" /* A0-B0	a0-b0	A1-B1	a1-b1 */\
-	"movq %%mm7, " #dst "			\n\t"\
-	"movq " #src1 ", %%mm1			\n\t" /* R3	R1	r3	r1 */\
-	"movq 80(%2), %%mm4			\n\t" /* -C1	C5	-C1 	C5 */\
-	"movq %%mm2, 24+" #dst "		\n\t"\
-	"pmaddwd %%mm1, %%mm4			\n\t" /* -C1R3+C5R1	-C1r3+C5r1 */\
-	"movq 88(%2), %%mm7			\n\t" /* C3	C7	C3 	C7 */\
-	"pmaddwd 96(%2), %%mm1			\n\t" /* -C5R3+C7R1	-C5r3+C7r1 */\
-	"pmaddwd %%mm3, %%mm7			\n\t" /* C3R7+C7R5	C3r7+C7r5 */\
-	"movq %%mm0, %%mm2			\n\t" /* A2		a2 */\
-	"pmaddwd 104(%2), %%mm3			\n\t" /* -C1R7+C3R5	-C1r7+C3r5 */\
-	"paddd %%mm7, %%mm4			\n\t" /* B2		b2 */\
-	"paddd %%mm4, %%mm2			\n\t" /* A2+B2		a2+b2 */\
-	"psubd %%mm4, %%mm0			\n\t" /* a2-B2		a2-b2 */\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"psrad $" #shift ", %%mm0		\n\t"\
-	"movq %%mm6, %%mm4			\n\t" /* A3		a3 */\
-	"paddd %%mm1, %%mm3			\n\t" /* B3		b3 */\
-	"paddd %%mm3, %%mm6			\n\t" /* A3+B3		a3+b3 */\
-	"psubd %%mm3, %%mm4			\n\t" /* a3-B3		a3-b3 */\
-	"psrad $" #shift ", %%mm6		\n\t"\
-	"packssdw %%mm6, %%mm2			\n\t" /* A3+B3	a3+b3	A2+B2	a2+b2 */\
-	"movq %%mm2, 8+" #dst "			\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"packssdw %%mm0, %%mm4			\n\t" /* A2-B2	a2-b2	A3-B3	a3-b3 */\
-	"movq %%mm4, 16+" #dst "		\n\t"\
-	"jmp 2f					\n\t"\
-	"1:					\n\t"\
-	"pslld $16, %%mm0			\n\t"\
-	"paddd "MANGLE(d40000)", %%mm0		\n\t"\
-	"psrad $13, %%mm0			\n\t"\
-	"packssdw %%mm0, %%mm0			\n\t"\
-	"movq %%mm0, " #dst "			\n\t"\
-	"movq %%mm0, 8+" #dst "			\n\t"\
-	"movq %%mm0, 16+" #dst "		\n\t"\
-	"movq %%mm0, 24+" #dst "		\n\t"\
-	"2:					\n\t"
-
-#define Z_COND_IDCT(src0, src4, src1, src5, dst, rounder, shift, bt) \
-	"movq " #src0 ", %%mm0			\n\t" /* R4	R0	r4	r0 */\
-	"movq " #src4 ", %%mm1			\n\t" /* R6	R2	r6	r2 */\
-	"movq " #src1 ", %%mm2			\n\t" /* R3	R1	r3	r1 */\
-	"movq " #src5 ", %%mm3			\n\t" /* R7	R5	r7	r5 */\
-	"movq %%mm0, %%mm4			\n\t"\
-	"por %%mm1, %%mm4			\n\t"\
-	"por %%mm2, %%mm4			\n\t"\
-	"por %%mm3, %%mm4			\n\t"\
-	"packssdw %%mm4,%%mm4			\n\t"\
-	"movd %%mm4, %%eax			\n\t"\
-	"orl %%eax, %%eax			\n\t"\
-	"jz " #bt "				\n\t"\
-	"movq 16(%2), %%mm4			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm5			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm5, %%mm0			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 32(%2), %%mm5			\n\t" /* C6	C2	C6	C2 */\
-	"pmaddwd %%mm1, %%mm5			\n\t" /* C6R6+C2R2	C6r6+C2r2 */\
-	"movq 40(%2), %%mm6			\n\t" /* -C2	C6	-C2	C6 */\
-	"pmaddwd %%mm6, %%mm1			\n\t" /* -C2R6+C6R2	-C2r6+C6r2 */\
-	"movq 48(%2), %%mm7			\n\t" /* C3	C1	C3	C1 */\
-	"pmaddwd %%mm2, %%mm7			\n\t" /* C3R3+C1R1	C3r3+C1r1 */\
-	#rounder ", %%mm4			\n\t"\
-	"movq %%mm4, %%mm6			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"paddd %%mm5, %%mm4			\n\t" /* A0		a0 */\
-	"psubd %%mm5, %%mm6			\n\t" /* A3		a3 */\
-	"movq 56(%2), %%mm5			\n\t" /* C7	C5	C7	C5 */\
-	"pmaddwd %%mm3, %%mm5			\n\t" /* C7R7+C5R5	C7r7+C5r5 */\
-	#rounder ", %%mm0			\n\t"\
-	"paddd %%mm0, %%mm1			\n\t" /* A1		a1 */\
-	"paddd %%mm0, %%mm0			\n\t" \
-	"psubd %%mm1, %%mm0			\n\t" /* A2		a2 */\
-	"pmaddwd 64(%2), %%mm2			\n\t" /* -C7R3+C3R1	-C7r3+C3r1 */\
-	"paddd %%mm5, %%mm7			\n\t" /* B0		b0 */\
-	"movq 72(%2), %%mm5			\n\t" /* -C5	-C1	-C5	-C1 */\
-	"pmaddwd %%mm3, %%mm5			\n\t" /* -C5R7-C1R5	-C5r7-C1r5 */\
-	"paddd %%mm4, %%mm7			\n\t" /* A0+B0		a0+b0 */\
-	"paddd %%mm4, %%mm4			\n\t" /* 2A0		2a0 */\
-	"psubd %%mm7, %%mm4			\n\t" /* A0-B0		a0-b0 */\
-	"paddd %%mm2, %%mm5			\n\t" /* B1		b1 */\
-	"psrad $" #shift ", %%mm7		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"movq %%mm1, %%mm2			\n\t" /* A1		a1 */\
-	"paddd %%mm5, %%mm1			\n\t" /* A1+B1		a1+b1 */\
-	"psubd %%mm5, %%mm2			\n\t" /* A1-B1		a1-b1 */\
-	"psrad $" #shift ", %%mm1		\n\t"\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"packssdw %%mm1, %%mm7			\n\t" /* A1+B1	a1+b1	A0+B0	a0+b0 */\
-	"packssdw %%mm4, %%mm2			\n\t" /* A0-B0	a0-b0	A1-B1	a1-b1 */\
-	"movq %%mm7, " #dst "			\n\t"\
-	"movq " #src1 ", %%mm1			\n\t" /* R3	R1	r3	r1 */\
-	"movq 80(%2), %%mm4			\n\t" /* -C1	C5	-C1 	C5 */\
-	"movq %%mm2, 24+" #dst "		\n\t"\
-	"pmaddwd %%mm1, %%mm4			\n\t" /* -C1R3+C5R1	-C1r3+C5r1 */\
-	"movq 88(%2), %%mm7			\n\t" /* C3	C7	C3 	C7 */\
-	"pmaddwd 96(%2), %%mm1			\n\t" /* -C5R3+C7R1	-C5r3+C7r1 */\
-	"pmaddwd %%mm3, %%mm7			\n\t" /* C3R7+C7R5	C3r7+C7r5 */\
-	"movq %%mm0, %%mm2			\n\t" /* A2		a2 */\
-	"pmaddwd 104(%2), %%mm3			\n\t" /* -C1R7+C3R5	-C1r7+C3r5 */\
-	"paddd %%mm7, %%mm4			\n\t" /* B2		b2 */\
-	"paddd %%mm4, %%mm2			\n\t" /* A2+B2		a2+b2 */\
-	"psubd %%mm4, %%mm0			\n\t" /* a2-B2		a2-b2 */\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"psrad $" #shift ", %%mm0		\n\t"\
-	"movq %%mm6, %%mm4			\n\t" /* A3		a3 */\
-	"paddd %%mm1, %%mm3			\n\t" /* B3		b3 */\
-	"paddd %%mm3, %%mm6			\n\t" /* A3+B3		a3+b3 */\
-	"psubd %%mm3, %%mm4			\n\t" /* a3-B3		a3-b3 */\
-	"psrad $" #shift ", %%mm6		\n\t"\
-	"packssdw %%mm6, %%mm2			\n\t" /* A3+B3	a3+b3	A2+B2	a2+b2 */\
-	"movq %%mm2, 8+" #dst "			\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"packssdw %%mm0, %%mm4			\n\t" /* A2-B2	a2-b2	A3-B3	a3-b3 */\
-	"movq %%mm4, 16+" #dst "		\n\t"\
-
-#define ROW_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
-	"movq " #src0 ", %%mm0			\n\t" /* R4	R0	r4	r0 */\
-	"movq " #src4 ", %%mm1			\n\t" /* R6	R2	r6	r2 */\
-	"movq " #src1 ", %%mm2			\n\t" /* R3	R1	r3	r1 */\
-	"movq " #src5 ", %%mm3			\n\t" /* R7	R5	r7	r5 */\
-	"movq 16(%2), %%mm4			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm5			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm5, %%mm0			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 32(%2), %%mm5			\n\t" /* C6	C2	C6	C2 */\
-	"pmaddwd %%mm1, %%mm5			\n\t" /* C6R6+C2R2	C6r6+C2r2 */\
-	"movq 40(%2), %%mm6			\n\t" /* -C2	C6	-C2	C6 */\
-	"pmaddwd %%mm6, %%mm1			\n\t" /* -C2R6+C6R2	-C2r6+C6r2 */\
-	"movq 48(%2), %%mm7			\n\t" /* C3	C1	C3	C1 */\
-	"pmaddwd %%mm2, %%mm7			\n\t" /* C3R3+C1R1	C3r3+C1r1 */\
-	#rounder ", %%mm4			\n\t"\
-	"movq %%mm4, %%mm6			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"paddd %%mm5, %%mm4			\n\t" /* A0		a0 */\
-	"psubd %%mm5, %%mm6			\n\t" /* A3		a3 */\
-	"movq 56(%2), %%mm5			\n\t" /* C7	C5	C7	C5 */\
-	"pmaddwd %%mm3, %%mm5			\n\t" /* C7R7+C5R5	C7r7+C5r5 */\
-	#rounder ", %%mm0			\n\t"\
-	"paddd %%mm0, %%mm1			\n\t" /* A1		a1 */\
-	"paddd %%mm0, %%mm0			\n\t" \
-	"psubd %%mm1, %%mm0			\n\t" /* A2		a2 */\
-	"pmaddwd 64(%2), %%mm2			\n\t" /* -C7R3+C3R1	-C7r3+C3r1 */\
-	"paddd %%mm5, %%mm7			\n\t" /* B0		b0 */\
-	"movq 72(%2), %%mm5			\n\t" /* -C5	-C1	-C5	-C1 */\
-	"pmaddwd %%mm3, %%mm5			\n\t" /* -C5R7-C1R5	-C5r7-C1r5 */\
-	"paddd %%mm4, %%mm7			\n\t" /* A0+B0		a0+b0 */\
-	"paddd %%mm4, %%mm4			\n\t" /* 2A0		2a0 */\
-	"psubd %%mm7, %%mm4			\n\t" /* A0-B0		a0-b0 */\
-	"paddd %%mm2, %%mm5			\n\t" /* B1		b1 */\
-	"psrad $" #shift ", %%mm7		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"movq %%mm1, %%mm2			\n\t" /* A1		a1 */\
-	"paddd %%mm5, %%mm1			\n\t" /* A1+B1		a1+b1 */\
-	"psubd %%mm5, %%mm2			\n\t" /* A1-B1		a1-b1 */\
-	"psrad $" #shift ", %%mm1		\n\t"\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"packssdw %%mm1, %%mm7			\n\t" /* A1+B1	a1+b1	A0+B0	a0+b0 */\
-	"packssdw %%mm4, %%mm2			\n\t" /* A0-B0	a0-b0	A1-B1	a1-b1 */\
-	"movq %%mm7, " #dst "			\n\t"\
-	"movq " #src1 ", %%mm1			\n\t" /* R3	R1	r3	r1 */\
-	"movq 80(%2), %%mm4			\n\t" /* -C1	C5	-C1 	C5 */\
-	"movq %%mm2, 24+" #dst "		\n\t"\
-	"pmaddwd %%mm1, %%mm4			\n\t" /* -C1R3+C5R1	-C1r3+C5r1 */\
-	"movq 88(%2), %%mm7			\n\t" /* C3	C7	C3 	C7 */\
-	"pmaddwd 96(%2), %%mm1			\n\t" /* -C5R3+C7R1	-C5r3+C7r1 */\
-	"pmaddwd %%mm3, %%mm7			\n\t" /* C3R7+C7R5	C3r7+C7r5 */\
-	"movq %%mm0, %%mm2			\n\t" /* A2		a2 */\
-	"pmaddwd 104(%2), %%mm3			\n\t" /* -C1R7+C3R5	-C1r7+C3r5 */\
-	"paddd %%mm7, %%mm4			\n\t" /* B2		b2 */\
-	"paddd %%mm4, %%mm2			\n\t" /* A2+B2		a2+b2 */\
-	"psubd %%mm4, %%mm0			\n\t" /* a2-B2		a2-b2 */\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"psrad $" #shift ", %%mm0		\n\t"\
-	"movq %%mm6, %%mm4			\n\t" /* A3		a3 */\
-	"paddd %%mm1, %%mm3			\n\t" /* B3		b3 */\
-	"paddd %%mm3, %%mm6			\n\t" /* A3+B3		a3+b3 */\
-	"psubd %%mm3, %%mm4			\n\t" /* a3-B3		a3-b3 */\
-	"psrad $" #shift ", %%mm6		\n\t"\
-	"packssdw %%mm6, %%mm2			\n\t" /* A3+B3	a3+b3	A2+B2	a2+b2 */\
-	"movq %%mm2, 8+" #dst "			\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"packssdw %%mm0, %%mm4			\n\t" /* A2-B2	a2-b2	A3-B3	a3-b3 */\
-	"movq %%mm4, 16+" #dst "		\n\t"\
-
-//IDCT(         src0,   src4,   src1,   src5,    dst,   rounder, shift)
-DC_COND_IDCT(  0(%0),  8(%0), 16(%0), 24(%0),  0(%1),paddd 8(%2), 11)
-Z_COND_IDCT(  32(%0), 40(%0), 48(%0), 56(%0), 32(%1),paddd (%2), 11, 4f)
-Z_COND_IDCT(  64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddd (%2), 11, 2f)
-Z_COND_IDCT(  96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 1f)
-
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
-	"movq " #src0 ", %%mm0			\n\t" /* R4	R0	r4	r0 */\
-	"movq " #src4 ", %%mm1			\n\t" /* R6	R2	r6	r2 */\
-	"movq " #src1 ", %%mm2			\n\t" /* R3	R1	r3	r1 */\
-	"movq " #src5 ", %%mm3			\n\t" /* R7	R5	r7	r5 */\
-	"movq 16(%2), %%mm4			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm5			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm5, %%mm0			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 32(%2), %%mm5			\n\t" /* C6	C2	C6	C2 */\
-	"pmaddwd %%mm1, %%mm5			\n\t" /* C6R6+C2R2	C6r6+C2r2 */\
-	"movq 40(%2), %%mm6			\n\t" /* -C2	C6	-C2	C6 */\
-	"pmaddwd %%mm6, %%mm1			\n\t" /* -C2R6+C6R2	-C2r6+C6r2 */\
-	#rounder ", %%mm4			\n\t"\
-	"movq %%mm4, %%mm6			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 48(%2), %%mm7			\n\t" /* C3	C1	C3	C1 */\
-	#rounder ", %%mm0			\n\t"\
-	"pmaddwd %%mm2, %%mm7			\n\t" /* C3R3+C1R1	C3r3+C1r1 */\
-	"paddd %%mm5, %%mm4			\n\t" /* A0		a0 */\
-	"psubd %%mm5, %%mm6			\n\t" /* A3		a3 */\
-	"movq %%mm0, %%mm5			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"paddd %%mm1, %%mm0			\n\t" /* A1		a1 */\
-	"psubd %%mm1, %%mm5			\n\t" /* A2		a2 */\
-	"movq 56(%2), %%mm1			\n\t" /* C7	C5	C7	C5 */\
-	"pmaddwd %%mm3, %%mm1			\n\t" /* C7R7+C5R5	C7r7+C5r5 */\
-	"pmaddwd 64(%2), %%mm2			\n\t" /* -C7R3+C3R1	-C7r3+C3r1 */\
-	"paddd %%mm1, %%mm7			\n\t" /* B0		b0 */\
-	"movq 72(%2), %%mm1			\n\t" /* -C5	-C1	-C5	-C1 */\
-	"pmaddwd %%mm3, %%mm1			\n\t" /* -C5R7-C1R5	-C5r7-C1r5 */\
-	"paddd %%mm4, %%mm7			\n\t" /* A0+B0		a0+b0 */\
-	"paddd %%mm4, %%mm4			\n\t" /* 2A0		2a0 */\
-	"psubd %%mm7, %%mm4			\n\t" /* A0-B0		a0-b0 */\
-	"paddd %%mm2, %%mm1			\n\t" /* B1		b1 */\
-	"psrad $" #shift ", %%mm7		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"movq %%mm0, %%mm2			\n\t" /* A1		a1 */\
-	"paddd %%mm1, %%mm0			\n\t" /* A1+B1		a1+b1 */\
-	"psubd %%mm1, %%mm2			\n\t" /* A1-B1		a1-b1 */\
-	"psrad $" #shift ", %%mm0		\n\t"\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"packssdw %%mm7, %%mm7			\n\t" /* A0+B0	a0+b0 */\
-	"movd %%mm7, " #dst "			\n\t"\
-	"packssdw %%mm0, %%mm0			\n\t" /* A1+B1	a1+b1 */\
-	"movd %%mm0, 16+" #dst "		\n\t"\
-	"packssdw %%mm2, %%mm2			\n\t" /* A1-B1	a1-b1 */\
-	"movd %%mm2, 96+" #dst "		\n\t"\
-	"packssdw %%mm4, %%mm4			\n\t" /* A0-B0	a0-b0 */\
-	"movd %%mm4, 112+" #dst "		\n\t"\
-	"movq " #src1 ", %%mm0			\n\t" /* R3	R1	r3	r1 */\
-	"movq 80(%2), %%mm4			\n\t" /* -C1	C5	-C1 	C5 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* -C1R3+C5R1	-C1r3+C5r1 */\
-	"movq 88(%2), %%mm7			\n\t" /* C3	C7	C3 	C7 */\
-	"pmaddwd 96(%2), %%mm0			\n\t" /* -C5R3+C7R1	-C5r3+C7r1 */\
-	"pmaddwd %%mm3, %%mm7			\n\t" /* C3R7+C7R5	C3r7+C7r5 */\
-	"movq %%mm5, %%mm2			\n\t" /* A2		a2 */\
-	"pmaddwd 104(%2), %%mm3			\n\t" /* -C1R7+C3R5	-C1r7+C3r5 */\
-	"paddd %%mm7, %%mm4			\n\t" /* B2		b2 */\
-	"paddd %%mm4, %%mm2			\n\t" /* A2+B2		a2+b2 */\
-	"psubd %%mm4, %%mm5			\n\t" /* a2-B2		a2-b2 */\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"psrad $" #shift ", %%mm5		\n\t"\
-	"movq %%mm6, %%mm4			\n\t" /* A3		a3 */\
-	"paddd %%mm0, %%mm3			\n\t" /* B3		b3 */\
-	"paddd %%mm3, %%mm6			\n\t" /* A3+B3		a3+b3 */\
-	"psubd %%mm3, %%mm4			\n\t" /* a3-B3		a3-b3 */\
-	"psrad $" #shift ", %%mm6		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"packssdw %%mm2, %%mm2			\n\t" /* A2+B2	a2+b2 */\
-	"packssdw %%mm6, %%mm6			\n\t" /* A3+B3	a3+b3 */\
-	"movd %%mm2, 32+" #dst "		\n\t"\
-	"packssdw %%mm4, %%mm4			\n\t" /* A3-B3	a3-b3 */\
-	"packssdw %%mm5, %%mm5			\n\t" /* A2-B2	a2-b2 */\
-	"movd %%mm6, 48+" #dst "		\n\t"\
-	"movd %%mm4, 64+" #dst "		\n\t"\
-	"movd %%mm5, 80+" #dst "		\n\t"
-
-
-//IDCT(  src0,   src4,   src1,    src5,    dst, rounder, shift)
-IDCT(    (%1), 64(%1), 32(%1),  96(%1),  0(%0),/nop, 20)
-IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),/nop, 20)
-IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),/nop, 20)
-IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
-	"jmp 9f					\n\t"
-
-	"#.balign 16				\n\t"\
-	"4:					\n\t"
-Z_COND_IDCT(  64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddd (%2), 11, 6f)
-Z_COND_IDCT(  96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 5f)
-
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
-	"movq " #src0 ", %%mm0			\n\t" /* R4	R0	r4	r0 */\
-	"movq " #src4 ", %%mm1			\n\t" /* R6	R2	r6	r2 */\
-	"movq " #src5 ", %%mm3			\n\t" /* R7	R5	r7	r5 */\
-	"movq 16(%2), %%mm4			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm5			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm5, %%mm0			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 32(%2), %%mm5			\n\t" /* C6	C2	C6	C2 */\
-	"pmaddwd %%mm1, %%mm5			\n\t" /* C6R6+C2R2	C6r6+C2r2 */\
-	"movq 40(%2), %%mm6			\n\t" /* -C2	C6	-C2	C6 */\
-	"pmaddwd %%mm6, %%mm1			\n\t" /* -C2R6+C6R2	-C2r6+C6r2 */\
-	#rounder ", %%mm4			\n\t"\
-	"movq %%mm4, %%mm6			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	#rounder ", %%mm0			\n\t"\
-	"paddd %%mm5, %%mm4			\n\t" /* A0		a0 */\
-	"psubd %%mm5, %%mm6			\n\t" /* A3		a3 */\
-	"movq %%mm0, %%mm5			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"paddd %%mm1, %%mm0			\n\t" /* A1		a1 */\
-	"psubd %%mm1, %%mm5			\n\t" /* A2		a2 */\
-	"movq 56(%2), %%mm1			\n\t" /* C7	C5	C7	C5 */\
-	"pmaddwd %%mm3, %%mm1			\n\t" /* C7R7+C5R5	C7r7+C5r5 */\
-	"movq 72(%2), %%mm7			\n\t" /* -C5	-C1	-C5	-C1 */\
-	"pmaddwd %%mm3, %%mm7			\n\t" /* -C5R7-C1R5	-C5r7-C1r5 */\
-	"paddd %%mm4, %%mm1			\n\t" /* A0+B0		a0+b0 */\
-	"paddd %%mm4, %%mm4			\n\t" /* 2A0		2a0 */\
-	"psubd %%mm1, %%mm4			\n\t" /* A0-B0		a0-b0 */\
-	"psrad $" #shift ", %%mm1		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"movq %%mm0, %%mm2			\n\t" /* A1		a1 */\
-	"paddd %%mm7, %%mm0			\n\t" /* A1+B1		a1+b1 */\
-	"psubd %%mm7, %%mm2			\n\t" /* A1-B1		a1-b1 */\
-	"psrad $" #shift ", %%mm0		\n\t"\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"packssdw %%mm1, %%mm1			\n\t" /* A0+B0	a0+b0 */\
-	"movd %%mm1, " #dst "			\n\t"\
-	"packssdw %%mm0, %%mm0			\n\t" /* A1+B1	a1+b1 */\
-	"movd %%mm0, 16+" #dst "		\n\t"\
-	"packssdw %%mm2, %%mm2			\n\t" /* A1-B1	a1-b1 */\
-	"movd %%mm2, 96+" #dst "		\n\t"\
-	"packssdw %%mm4, %%mm4			\n\t" /* A0-B0	a0-b0 */\
-	"movd %%mm4, 112+" #dst "		\n\t"\
-	"movq 88(%2), %%mm1			\n\t" /* C3	C7	C3 	C7 */\
-	"pmaddwd %%mm3, %%mm1			\n\t" /* C3R7+C7R5	C3r7+C7r5 */\
-	"movq %%mm5, %%mm2			\n\t" /* A2		a2 */\
-	"pmaddwd 104(%2), %%mm3			\n\t" /* -C1R7+C3R5	-C1r7+C3r5 */\
-	"paddd %%mm1, %%mm2			\n\t" /* A2+B2		a2+b2 */\
-	"psubd %%mm1, %%mm5			\n\t" /* a2-B2		a2-b2 */\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"psrad $" #shift ", %%mm5		\n\t"\
-	"movq %%mm6, %%mm1			\n\t" /* A3		a3 */\
-	"paddd %%mm3, %%mm6			\n\t" /* A3+B3		a3+b3 */\
-	"psubd %%mm3, %%mm1			\n\t" /* a3-B3		a3-b3 */\
-	"psrad $" #shift ", %%mm6		\n\t"\
-	"psrad $" #shift ", %%mm1		\n\t"\
-	"packssdw %%mm2, %%mm2			\n\t" /* A2+B2	a2+b2 */\
-	"packssdw %%mm6, %%mm6			\n\t" /* A3+B3	a3+b3 */\
-	"movd %%mm2, 32+" #dst "		\n\t"\
-	"packssdw %%mm1, %%mm1			\n\t" /* A3-B3	a3-b3 */\
-	"packssdw %%mm5, %%mm5			\n\t" /* A2-B2	a2-b2 */\
-	"movd %%mm6, 48+" #dst "		\n\t"\
-	"movd %%mm1, 64+" #dst "		\n\t"\
-	"movd %%mm5, 80+" #dst "		\n\t"	
-
-//IDCT(  src0,   src4,   src1,    src5,    dst, rounder, shift)
-IDCT(    (%1), 64(%1), 32(%1),  96(%1),  0(%0),/nop, 20)
-IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),/nop, 20)
-IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),/nop, 20)
-IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
-	"jmp 9f					\n\t"
-
-	"#.balign 16				\n\t"\
-	"6:					\n\t"
-Z_COND_IDCT(  96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 7f)
-
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
-	"movq " #src0 ", %%mm0			\n\t" /* R4	R0	r4	r0 */\
-	"movq " #src5 ", %%mm3			\n\t" /* R7	R5	r7	r5 */\
-	"movq 16(%2), %%mm4			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm5			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm5, %%mm0			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	#rounder ", %%mm4			\n\t"\
-	"movq %%mm4, %%mm6			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	#rounder ", %%mm0			\n\t"\
-	"movq %%mm0, %%mm5			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 56(%2), %%mm1			\n\t" /* C7	C5	C7	C5 */\
-	"pmaddwd %%mm3, %%mm1			\n\t" /* C7R7+C5R5	C7r7+C5r5 */\
-	"movq 72(%2), %%mm7			\n\t" /* -C5	-C1	-C5	-C1 */\
-	"pmaddwd %%mm3, %%mm7			\n\t" /* -C5R7-C1R5	-C5r7-C1r5 */\
-	"paddd %%mm4, %%mm1			\n\t" /* A0+B0		a0+b0 */\
-	"paddd %%mm4, %%mm4			\n\t" /* 2A0		2a0 */\
-	"psubd %%mm1, %%mm4			\n\t" /* A0-B0		a0-b0 */\
-	"psrad $" #shift ", %%mm1		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"movq %%mm0, %%mm2			\n\t" /* A1		a1 */\
-	"paddd %%mm7, %%mm0			\n\t" /* A1+B1		a1+b1 */\
-	"psubd %%mm7, %%mm2			\n\t" /* A1-B1		a1-b1 */\
-	"psrad $" #shift ", %%mm0		\n\t"\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"packssdw %%mm1, %%mm1			\n\t" /* A0+B0	a0+b0 */\
-	"movd %%mm1, " #dst "			\n\t"\
-	"packssdw %%mm0, %%mm0			\n\t" /* A1+B1	a1+b1 */\
-	"movd %%mm0, 16+" #dst "		\n\t"\
-	"packssdw %%mm2, %%mm2			\n\t" /* A1-B1	a1-b1 */\
-	"movd %%mm2, 96+" #dst "		\n\t"\
-	"packssdw %%mm4, %%mm4			\n\t" /* A0-B0	a0-b0 */\
-	"movd %%mm4, 112+" #dst "		\n\t"\
-	"movq 88(%2), %%mm1			\n\t" /* C3	C7	C3 	C7 */\
-	"pmaddwd %%mm3, %%mm1			\n\t" /* C3R7+C7R5	C3r7+C7r5 */\
-	"movq %%mm5, %%mm2			\n\t" /* A2		a2 */\
-	"pmaddwd 104(%2), %%mm3			\n\t" /* -C1R7+C3R5	-C1r7+C3r5 */\
-	"paddd %%mm1, %%mm2			\n\t" /* A2+B2		a2+b2 */\
-	"psubd %%mm1, %%mm5			\n\t" /* a2-B2		a2-b2 */\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"psrad $" #shift ", %%mm5		\n\t"\
-	"movq %%mm6, %%mm1			\n\t" /* A3		a3 */\
-	"paddd %%mm3, %%mm6			\n\t" /* A3+B3		a3+b3 */\
-	"psubd %%mm3, %%mm1			\n\t" /* a3-B3		a3-b3 */\
-	"psrad $" #shift ", %%mm6		\n\t"\
-	"psrad $" #shift ", %%mm1		\n\t"\
-	"packssdw %%mm2, %%mm2			\n\t" /* A2+B2	a2+b2 */\
-	"packssdw %%mm6, %%mm6			\n\t" /* A3+B3	a3+b3 */\
-	"movd %%mm2, 32+" #dst "		\n\t"\
-	"packssdw %%mm1, %%mm1			\n\t" /* A3-B3	a3-b3 */\
-	"packssdw %%mm5, %%mm5			\n\t" /* A2-B2	a2-b2 */\
-	"movd %%mm6, 48+" #dst "		\n\t"\
-	"movd %%mm1, 64+" #dst "		\n\t"\
-	"movd %%mm5, 80+" #dst "		\n\t"	
-
-
-//IDCT(  src0,   src4,   src1,    src5,    dst, rounder, shift)
-IDCT(    (%1), 64(%1), 32(%1),  96(%1),  0(%0),/nop, 20)
-IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),/nop, 20)
-IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),/nop, 20)
-IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
-	"jmp 9f					\n\t"
-
-	"#.balign 16				\n\t"\
-	"2:					\n\t"
-Z_COND_IDCT(  96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 3f)
-
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
-	"movq " #src0 ", %%mm0			\n\t" /* R4	R0	r4	r0 */\
-	"movq " #src1 ", %%mm2			\n\t" /* R3	R1	r3	r1 */\
-	"movq " #src5 ", %%mm3			\n\t" /* R7	R5	r7	r5 */\
-	"movq 16(%2), %%mm4			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm5			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm5, %%mm0			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	#rounder ", %%mm4			\n\t"\
-	"movq %%mm4, %%mm6			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 48(%2), %%mm7			\n\t" /* C3	C1	C3	C1 */\
-	#rounder ", %%mm0			\n\t"\
-	"pmaddwd %%mm2, %%mm7			\n\t" /* C3R3+C1R1	C3r3+C1r1 */\
-	"movq %%mm0, %%mm5			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 56(%2), %%mm1			\n\t" /* C7	C5	C7	C5 */\
-	"pmaddwd %%mm3, %%mm1			\n\t" /* C7R7+C5R5	C7r7+C5r5 */\
-	"pmaddwd 64(%2), %%mm2			\n\t" /* -C7R3+C3R1	-C7r3+C3r1 */\
-	"paddd %%mm1, %%mm7			\n\t" /* B0		b0 */\
-	"movq 72(%2), %%mm1			\n\t" /* -C5	-C1	-C5	-C1 */\
-	"pmaddwd %%mm3, %%mm1			\n\t" /* -C5R7-C1R5	-C5r7-C1r5 */\
-	"paddd %%mm4, %%mm7			\n\t" /* A0+B0		a0+b0 */\
-	"paddd %%mm4, %%mm4			\n\t" /* 2A0		2a0 */\
-	"psubd %%mm7, %%mm4			\n\t" /* A0-B0		a0-b0 */\
-	"paddd %%mm2, %%mm1			\n\t" /* B1		b1 */\
-	"psrad $" #shift ", %%mm7		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"movq %%mm0, %%mm2			\n\t" /* A1		a1 */\
-	"paddd %%mm1, %%mm0			\n\t" /* A1+B1		a1+b1 */\
-	"psubd %%mm1, %%mm2			\n\t" /* A1-B1		a1-b1 */\
-	"psrad $" #shift ", %%mm0		\n\t"\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"packssdw %%mm7, %%mm7			\n\t" /* A0+B0	a0+b0 */\
-	"movd %%mm7, " #dst "			\n\t"\
-	"packssdw %%mm0, %%mm0			\n\t" /* A1+B1	a1+b1 */\
-	"movd %%mm0, 16+" #dst "		\n\t"\
-	"packssdw %%mm2, %%mm2			\n\t" /* A1-B1	a1-b1 */\
-	"movd %%mm2, 96+" #dst "		\n\t"\
-	"packssdw %%mm4, %%mm4			\n\t" /* A0-B0	a0-b0 */\
-	"movd %%mm4, 112+" #dst "		\n\t"\
-	"movq " #src1 ", %%mm0			\n\t" /* R3	R1	r3	r1 */\
-	"movq 80(%2), %%mm4			\n\t" /* -C1	C5	-C1 	C5 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* -C1R3+C5R1	-C1r3+C5r1 */\
-	"movq 88(%2), %%mm7			\n\t" /* C3	C7	C3 	C7 */\
-	"pmaddwd 96(%2), %%mm0			\n\t" /* -C5R3+C7R1	-C5r3+C7r1 */\
-	"pmaddwd %%mm3, %%mm7			\n\t" /* C3R7+C7R5	C3r7+C7r5 */\
-	"movq %%mm5, %%mm2			\n\t" /* A2		a2 */\
-	"pmaddwd 104(%2), %%mm3			\n\t" /* -C1R7+C3R5	-C1r7+C3r5 */\
-	"paddd %%mm7, %%mm4			\n\t" /* B2		b2 */\
-	"paddd %%mm4, %%mm2			\n\t" /* A2+B2		a2+b2 */\
-	"psubd %%mm4, %%mm5			\n\t" /* a2-B2		a2-b2 */\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"psrad $" #shift ", %%mm5		\n\t"\
-	"movq %%mm6, %%mm4			\n\t" /* A3		a3 */\
-	"paddd %%mm0, %%mm3			\n\t" /* B3		b3 */\
-	"paddd %%mm3, %%mm6			\n\t" /* A3+B3		a3+b3 */\
-	"psubd %%mm3, %%mm4			\n\t" /* a3-B3		a3-b3 */\
-	"psrad $" #shift ", %%mm6		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"packssdw %%mm2, %%mm2			\n\t" /* A2+B2	a2+b2 */\
-	"packssdw %%mm6, %%mm6			\n\t" /* A3+B3	a3+b3 */\
-	"movd %%mm2, 32+" #dst "		\n\t"\
-	"packssdw %%mm4, %%mm4			\n\t" /* A3-B3	a3-b3 */\
-	"packssdw %%mm5, %%mm5			\n\t" /* A2-B2	a2-b2 */\
-	"movd %%mm6, 48+" #dst "		\n\t"\
-	"movd %%mm4, 64+" #dst "		\n\t"\
-	"movd %%mm5, 80+" #dst "		\n\t"
-
-//IDCT(  src0,   src4,   src1,    src5,    dst, rounder, shift)
-IDCT(    (%1), 64(%1), 32(%1),  96(%1),  0(%0),/nop, 20)
-IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),/nop, 20)
-IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),/nop, 20)
-IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
-	"jmp 9f					\n\t"
-
-	"#.balign 16				\n\t"\
-	"3:					\n\t"
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
-	"movq " #src0 ", %%mm0			\n\t" /* R4	R0	r4	r0 */\
-	"movq " #src1 ", %%mm2			\n\t" /* R3	R1	r3	r1 */\
-	"movq 16(%2), %%mm4			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm5			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm5, %%mm0			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	#rounder ", %%mm4			\n\t"\
-	"movq %%mm4, %%mm6			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 48(%2), %%mm7			\n\t" /* C3	C1	C3	C1 */\
-	#rounder ", %%mm0			\n\t"\
-	"pmaddwd %%mm2, %%mm7			\n\t" /* C3R3+C1R1	C3r3+C1r1 */\
-	"movq %%mm0, %%mm5			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 64(%2), %%mm3			\n\t"\
-	"pmaddwd %%mm2, %%mm3			\n\t" /* -C7R3+C3R1	-C7r3+C3r1 */\
-	"paddd %%mm4, %%mm7			\n\t" /* A0+B0		a0+b0 */\
-	"paddd %%mm4, %%mm4			\n\t" /* 2A0		2a0 */\
-	"psubd %%mm7, %%mm4			\n\t" /* A0-B0		a0-b0 */\
-	"psrad $" #shift ", %%mm7		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"movq %%mm0, %%mm1			\n\t" /* A1		a1 */\
-	"paddd %%mm3, %%mm0			\n\t" /* A1+B1		a1+b1 */\
-	"psubd %%mm3, %%mm1			\n\t" /* A1-B1		a1-b1 */\
-	"psrad $" #shift ", %%mm0		\n\t"\
-	"psrad $" #shift ", %%mm1		\n\t"\
-	"packssdw %%mm7, %%mm7			\n\t" /* A0+B0	a0+b0 */\
-	"movd %%mm7, " #dst "			\n\t"\
-	"packssdw %%mm0, %%mm0			\n\t" /* A1+B1	a1+b1 */\
-	"movd %%mm0, 16+" #dst "		\n\t"\
-	"packssdw %%mm1, %%mm1			\n\t" /* A1-B1	a1-b1 */\
-	"movd %%mm1, 96+" #dst "		\n\t"\
-	"packssdw %%mm4, %%mm4			\n\t" /* A0-B0	a0-b0 */\
-	"movd %%mm4, 112+" #dst "		\n\t"\
-	"movq 80(%2), %%mm4			\n\t" /* -C1	C5	-C1 	C5 */\
-	"pmaddwd %%mm2, %%mm4			\n\t" /* -C1R3+C5R1	-C1r3+C5r1 */\
-	"pmaddwd 96(%2), %%mm2			\n\t" /* -C5R3+C7R1	-C5r3+C7r1 */\
-	"movq %%mm5, %%mm1			\n\t" /* A2		a2 */\
-	"paddd %%mm4, %%mm1			\n\t" /* A2+B2		a2+b2 */\
-	"psubd %%mm4, %%mm5			\n\t" /* a2-B2		a2-b2 */\
-	"psrad $" #shift ", %%mm1		\n\t"\
-	"psrad $" #shift ", %%mm5		\n\t"\
-	"movq %%mm6, %%mm4			\n\t" /* A3		a3 */\
-	"paddd %%mm2, %%mm6			\n\t" /* A3+B3		a3+b3 */\
-	"psubd %%mm2, %%mm4			\n\t" /* a3-B3		a3-b3 */\
-	"psrad $" #shift ", %%mm6		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"packssdw %%mm1, %%mm1			\n\t" /* A2+B2	a2+b2 */\
-	"packssdw %%mm6, %%mm6			\n\t" /* A3+B3	a3+b3 */\
-	"movd %%mm1, 32+" #dst "		\n\t"\
-	"packssdw %%mm4, %%mm4			\n\t" /* A3-B3	a3-b3 */\
-	"packssdw %%mm5, %%mm5			\n\t" /* A2-B2	a2-b2 */\
-	"movd %%mm6, 48+" #dst "		\n\t"\
-	"movd %%mm4, 64+" #dst "		\n\t"\
-	"movd %%mm5, 80+" #dst "		\n\t"
-
-
-//IDCT(  src0,   src4,   src1,    src5,    dst, rounder, shift)
-IDCT(    (%1), 64(%1), 32(%1),  96(%1),  0(%0),/nop, 20)
-IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),/nop, 20)
-IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),/nop, 20)
-IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
-	"jmp 9f					\n\t"
-
-	"#.balign 16				\n\t"\
-	"5:					\n\t"
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
-	"movq " #src0 ", %%mm0			\n\t" /* R4	R0	r4	r0 */\
-	"movq " #src4 ", %%mm1			\n\t" /* R6	R2	r6	r2 */\
-	"movq 16(%2), %%mm4			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm5			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm5, %%mm0			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 32(%2), %%mm5			\n\t" /* C6	C2	C6	C2 */\
-	"pmaddwd %%mm1, %%mm5			\n\t" /* C6R6+C2R2	C6r6+C2r2 */\
-	"movq 40(%2), %%mm6			\n\t" /* -C2	C6	-C2	C6 */\
-	"pmaddwd %%mm6, %%mm1			\n\t" /* -C2R6+C6R2	-C2r6+C6r2 */\
-	#rounder ", %%mm4			\n\t"\
-	"movq %%mm4, %%mm6			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"paddd %%mm5, %%mm4			\n\t" /* A0		a0 */\
-	#rounder ", %%mm0			\n\t"\
-	"psubd %%mm5, %%mm6			\n\t" /* A3		a3 */\
-	"movq %%mm0, %%mm5			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"paddd %%mm1, %%mm0			\n\t" /* A1		a1 */\
-	"psubd %%mm1, %%mm5			\n\t" /* A2		a2 */\
-	"movq 8+" #src0 ", %%mm2		\n\t" /* R4	R0	r4	r0 */\
-	"movq 8+" #src4 ", %%mm3		\n\t" /* R6	R2	r6	r2 */\
-	"movq 16(%2), %%mm1			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm2, %%mm1			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm7			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm7, %%mm2			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 32(%2), %%mm7			\n\t" /* C6	C2	C6	C2 */\
-	"pmaddwd %%mm3, %%mm7			\n\t" /* C6R6+C2R2	C6r6+C2r2 */\
-	"pmaddwd 40(%2), %%mm3			\n\t" /* -C2R6+C6R2	-C2r6+C6r2 */\
-	#rounder ", %%mm1			\n\t"\
-	"paddd %%mm1, %%mm7			\n\t" /* A0		a0 */\
-	"paddd %%mm1, %%mm1			\n\t" /* 2C0		2c0 */\
-	#rounder ", %%mm2			\n\t"\
-	"psubd %%mm7, %%mm1			\n\t" /* A3		a3 */\
-	"paddd %%mm2, %%mm3			\n\t" /* A1		a1 */\
-	"paddd %%mm2, %%mm2			\n\t" /* 2C1		2c1 */\
-	"psubd %%mm3, %%mm2			\n\t" /* A2		a2 */\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"psrad $" #shift ", %%mm7		\n\t"\
-	"psrad $" #shift ", %%mm3		\n\t"\
-	"packssdw %%mm7, %%mm4			\n\t" /* A0	a0 */\
-	"movq %%mm4, " #dst "			\n\t"\
-	"psrad $" #shift ", %%mm0		\n\t"\
-	"packssdw %%mm3, %%mm0			\n\t" /* A1	a1 */\
-	"movq %%mm0, 16+" #dst "		\n\t"\
-	"movq %%mm0, 96+" #dst "		\n\t"\
-	"movq %%mm4, 112+" #dst "		\n\t"\
-	"psrad $" #shift ", %%mm5		\n\t"\
-	"psrad $" #shift ", %%mm6		\n\t"\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"packssdw %%mm2, %%mm5			\n\t" /* A2-B2	a2-b2 */\
-	"movq %%mm5, 32+" #dst "		\n\t"\
-	"psrad $" #shift ", %%mm1		\n\t"\
-	"packssdw %%mm1, %%mm6			\n\t" /* A3+B3	a3+b3 */\
-	"movq %%mm6, 48+" #dst "		\n\t"\
-	"movq %%mm6, 64+" #dst "		\n\t"\
-	"movq %%mm5, 80+" #dst "		\n\t"	
-	
-
-//IDCT(  src0,   src4,   src1,    src5,    dst, rounder, shift)
-IDCT(    0(%1), 64(%1), 32(%1),  96(%1),  0(%0),/nop, 20)
-//IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),/nop, 20)
-IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),/nop, 20)
-//IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
-	"jmp 9f					\n\t"
-
-
-	"#.balign 16				\n\t"\
-	"1:					\n\t"
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
-	"movq " #src0 ", %%mm0			\n\t" /* R4	R0	r4	r0 */\
-	"movq " #src4 ", %%mm1			\n\t" /* R6	R2	r6	r2 */\
-	"movq " #src1 ", %%mm2			\n\t" /* R3	R1	r3	r1 */\
-	"movq 16(%2), %%mm4			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm5			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm5, %%mm0			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 32(%2), %%mm5			\n\t" /* C6	C2	C6	C2 */\
-	"pmaddwd %%mm1, %%mm5			\n\t" /* C6R6+C2R2	C6r6+C2r2 */\
-	"movq 40(%2), %%mm6			\n\t" /* -C2	C6	-C2	C6 */\
-	"pmaddwd %%mm6, %%mm1			\n\t" /* -C2R6+C6R2	-C2r6+C6r2 */\
-	#rounder ", %%mm4			\n\t"\
-	"movq %%mm4, %%mm6			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 48(%2), %%mm7			\n\t" /* C3	C1	C3	C1 */\
-	#rounder ", %%mm0			\n\t"\
-	"pmaddwd %%mm2, %%mm7			\n\t" /* C3R3+C1R1	C3r3+C1r1 */\
-	"paddd %%mm5, %%mm4			\n\t" /* A0		a0 */\
-	"psubd %%mm5, %%mm6			\n\t" /* A3		a3 */\
-	"movq %%mm0, %%mm5			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"paddd %%mm1, %%mm0			\n\t" /* A1		a1 */\
-	"psubd %%mm1, %%mm5			\n\t" /* A2		a2 */\
-	"movq 64(%2), %%mm1			\n\t"\
-	"pmaddwd %%mm2, %%mm1			\n\t" /* -C7R3+C3R1	-C7r3+C3r1 */\
-	"paddd %%mm4, %%mm7			\n\t" /* A0+B0		a0+b0 */\
-	"paddd %%mm4, %%mm4			\n\t" /* 2A0		2a0 */\
-	"psubd %%mm7, %%mm4			\n\t" /* A0-B0		a0-b0 */\
-	"psrad $" #shift ", %%mm7		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"movq %%mm0, %%mm3			\n\t" /* A1		a1 */\
-	"paddd %%mm1, %%mm0			\n\t" /* A1+B1		a1+b1 */\
-	"psubd %%mm1, %%mm3			\n\t" /* A1-B1		a1-b1 */\
-	"psrad $" #shift ", %%mm0		\n\t"\
-	"psrad $" #shift ", %%mm3		\n\t"\
-	"packssdw %%mm7, %%mm7			\n\t" /* A0+B0	a0+b0 */\
-	"movd %%mm7, " #dst "			\n\t"\
-	"packssdw %%mm0, %%mm0			\n\t" /* A1+B1	a1+b1 */\
-	"movd %%mm0, 16+" #dst "		\n\t"\
-	"packssdw %%mm3, %%mm3			\n\t" /* A1-B1	a1-b1 */\
-	"movd %%mm3, 96+" #dst "		\n\t"\
-	"packssdw %%mm4, %%mm4			\n\t" /* A0-B0	a0-b0 */\
-	"movd %%mm4, 112+" #dst "		\n\t"\
-	"movq 80(%2), %%mm4			\n\t" /* -C1	C5	-C1 	C5 */\
-	"pmaddwd %%mm2, %%mm4			\n\t" /* -C1R3+C5R1	-C1r3+C5r1 */\
-	"pmaddwd 96(%2), %%mm2			\n\t" /* -C5R3+C7R1	-C5r3+C7r1 */\
-	"movq %%mm5, %%mm3			\n\t" /* A2		a2 */\
-	"paddd %%mm4, %%mm3			\n\t" /* A2+B2		a2+b2 */\
-	"psubd %%mm4, %%mm5			\n\t" /* a2-B2		a2-b2 */\
-	"psrad $" #shift ", %%mm3		\n\t"\
-	"psrad $" #shift ", %%mm5		\n\t"\
-	"movq %%mm6, %%mm4			\n\t" /* A3		a3 */\
-	"paddd %%mm2, %%mm6			\n\t" /* A3+B3		a3+b3 */\
-	"psubd %%mm2, %%mm4			\n\t" /* a3-B3		a3-b3 */\
-	"psrad $" #shift ", %%mm6		\n\t"\
-	"packssdw %%mm3, %%mm3			\n\t" /* A2+B2	a2+b2 */\
-	"movd %%mm3, 32+" #dst "		\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"packssdw %%mm6, %%mm6			\n\t" /* A3+B3	a3+b3 */\
-	"movd %%mm6, 48+" #dst "		\n\t"\
-	"packssdw %%mm4, %%mm4			\n\t" /* A3-B3	a3-b3 */\
-	"packssdw %%mm5, %%mm5			\n\t" /* A2-B2	a2-b2 */\
-	"movd %%mm4, 64+" #dst "		\n\t"\
-	"movd %%mm5, 80+" #dst "		\n\t"
-	
-
-//IDCT(  src0,   src4,   src1,    src5,    dst, rounder, shift)
-IDCT(    (%1), 64(%1), 32(%1),  96(%1),  0(%0),/nop, 20)
-IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),/nop, 20)
-IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),/nop, 20)
-IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
-	"jmp 9f					\n\t"
-
-
-	"#.balign 16				\n\t"
-	"7:					\n\t"
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
-	"movq " #src0 ", %%mm0			\n\t" /* R4	R0	r4	r0 */\
-	"movq 16(%2), %%mm4			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm0, %%mm4			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm5			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm5, %%mm0			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	#rounder ", %%mm4			\n\t"\
-	#rounder ", %%mm0			\n\t"\
-	"psrad $" #shift ", %%mm4		\n\t"\
-	"psrad $" #shift ", %%mm0		\n\t"\
-	"movq 8+" #src0 ", %%mm2		\n\t" /* R4	R0	r4	r0 */\
-	"movq 16(%2), %%mm1			\n\t" /* C4	C4	C4	C4 */\
-	"pmaddwd %%mm2, %%mm1			\n\t" /* C4R4+C4R0	C4r4+C4r0 */\
-	"movq 24(%2), %%mm7			\n\t" /* -C4	C4	-C4	C4 */\
-	"pmaddwd %%mm7, %%mm2			\n\t" /* -C4R4+C4R0	-C4r4+C4r0 */\
-	"movq 32(%2), %%mm7			\n\t" /* C6	C2	C6	C2 */\
-	#rounder ", %%mm1			\n\t"\
-	#rounder ", %%mm2			\n\t"\
-	"psrad $" #shift ", %%mm1		\n\t"\
-	"packssdw %%mm1, %%mm4			\n\t" /* A0	a0 */\
-	"movq %%mm4, " #dst "			\n\t"\
-	"psrad $" #shift ", %%mm2		\n\t"\
-	"packssdw %%mm2, %%mm0			\n\t" /* A1	a1 */\
-	"movq %%mm0, 16+" #dst "		\n\t"\
-	"movq %%mm0, 96+" #dst "		\n\t"\
-	"movq %%mm4, 112+" #dst "		\n\t"\
-	"movq %%mm0, 32+" #dst "		\n\t"\
-	"movq %%mm4, 48+" #dst "		\n\t"\
-	"movq %%mm4, 64+" #dst "		\n\t"\
-	"movq %%mm0, 80+" #dst "		\n\t"	
-
-//IDCT(  src0,   src4,   src1,    src5,    dst, rounder, shift)
-IDCT(   0(%1), 64(%1), 32(%1),  96(%1),  0(%0),/nop, 20)
-//IDCT(   8(%1), 72(%1), 40(%1), 104(%1),  4(%0),/nop, 20)
-IDCT(  16(%1), 80(%1), 48(%1), 112(%1),  8(%0),/nop, 20)
-//IDCT(  24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
-
-
-#endif
-
-/*
-Input
- 00 40 04 44 20 60 24 64
- 10 30 14 34 50 70 54 74
- 01 41 03 43 21 61 23 63
- 11 31 13 33 51 71 53 73
- 02 42 06 46 22 62 26 66
- 12 32 16 36 52 72 56 76
- 05 45 07 47 25 65 27 67
- 15 35 17 37 55 75 57 77
-  
-Temp
- 00 04 10 14 20 24 30 34
- 40 44 50 54 60 64 70 74
- 01 03 11 13 21 23 31 33
- 41 43 51 53 61 63 71 73
- 02 06 12 16 22 26 32 36
- 42 46 52 56 62 66 72 76
- 05 07 15 17 25 27 35 37
- 45 47 55 57 65 67 75 77
-*/
-
-"9: \n\t"
-		:: "r" (block), "r" (temp), "r" (coeffs)
-		: "%eax"
-	);
-}
-
-void ff_simple_idct_mmx(int16_t *block)
-{
-    idct(block);
-}
-
-//FIXME merge add/put into the idct
-
-void ff_simple_idct_put_mmx(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    idct(block);
-    put_pixels_clamped_mmx(block, dest, line_size);
-}
-void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    idct(block);
-    add_pixels_clamped_mmx(block, dest, line_size);
-}
diff --git a/ffmpeg.src/libavcodec/i386/vp3dsp_mmx.c b/ffmpeg.src/libavcodec/i386/vp3dsp_mmx.c
deleted file mode 100644
index 3d220c1..0000000
--- a/ffmpeg.src/libavcodec/i386/vp3dsp_mmx.c
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Copyright (C) 2004 the ffmpeg project
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file vp3dsp_mmx.c
- * MMX-optimized functions cribbed from the original VP3 source code.
- */
-
-#include "../dsputil.h"
-#include "mmx.h"
-
-#define IdctAdjustBeforeShift 8
-
-/* (12 * 4) 2-byte memory locations ( = 96 bytes total)
- * idct_constants[0..15] = Mask table (M(I))
- * idct_constants[16..43] = Cosine table (C(I))
- * idct_constants[44..47] = 8
- */
-static uint16_t idct_constants[(4 + 7 + 1) * 4];
-static const uint16_t idct_cosine_table[7] = {
-    64277, 60547, 54491, 46341, 36410, 25080, 12785
-};
-
-#define r0 mm0
-#define r1 mm1
-#define r2 mm2
-#define r3 mm3
-#define r4 mm4
-#define r5 mm5
-#define r6 mm6
-#define r7 mm7
-
-/* from original comments: The Macro does IDct on 4 1-D Dcts */
-#define BeginIDCT() { \
-    movq_m2r(*I(3), r2); \
-    movq_m2r(*C(3), r6); \
-    movq_r2r(r2, r4); \
-    movq_m2r(*J(5), r7); \
-    pmulhw_r2r(r6, r4);       /* r4 = c3*i3 - i3 */ \
-    movq_m2r(*C(5), r1); \
-    pmulhw_r2r(r7, r6);       /* r6 = c3*i5 - i5 */ \
-    movq_r2r(r1, r5); \
-    pmulhw_r2r(r2, r1);       /* r1 = c5*i3 - i3 */ \
-    movq_m2r(*I(1), r3); \
-    pmulhw_r2r(r7, r5);       /* r5 = c5*i5 - i5 */ \
-    movq_m2r(*C(1), r0);      /* (all registers are in use) */ \
-    paddw_r2r(r2, r4);        /* r4 = c3*i3 */ \
-    paddw_r2r(r7, r6);        /* r6 = c3*i5 */ \
-    paddw_r2r(r1, r2);        /* r2 = c5*i3 */ \
-    movq_m2r(*J(7), r1); \
-    paddw_r2r(r5, r7);        /* r7 = c5*i5 */ \
-    movq_r2r(r0, r5);         /* r5 = c1 */ \
-    pmulhw_r2r(r3, r0);       /* r0 = c1*i1 - i1 */ \
-    paddsw_r2r(r7, r4);       /* r4 = C = c3*i3 + c5*i5 */ \
-    pmulhw_r2r(r1, r5);       /* r5 = c1*i7 - i7 */ \
-    movq_m2r(*C(7), r7); \
-    psubsw_r2r(r2, r6);       /* r6 = D = c3*i5 - c5*i3 */ \
-    paddw_r2r(r3, r0);        /* r0 = c1*i1 */ \
-    pmulhw_r2r(r7, r3);       /* r3 = c7*i1 */ \
-    movq_m2r(*I(2), r2); \
-    pmulhw_r2r(r1, r7);       /* r7 = c7*i7 */ \
-    paddw_r2r(r1, r5);        /* r5 = c1*i7 */ \
-    movq_r2r(r2, r1);         /* r1 = i2 */ \
-    pmulhw_m2r(*C(2), r2);    /* r2 = c2*i2 - i2 */ \
-    psubsw_r2r(r5, r3);       /* r3 = B = c7*i1 - c1*i7 */ \
-    movq_m2r(*J(6), r5); \
-    paddsw_r2r(r7, r0);       /* r0 = A = c1*i1 + c7*i7 */ \
-    movq_r2r(r5, r7);         /* r7 = i6 */ \
-    psubsw_r2r(r4, r0);       /* r0 = A - C */ \
-    pmulhw_m2r(*C(2), r5);    /* r5 = c2*i6 - i6 */ \
-    paddw_r2r(r1, r2);        /* r2 = c2*i2 */ \
-    pmulhw_m2r(*C(6), r1);    /* r1 = c6*i2 */ \
-    paddsw_r2r(r4, r4);       /* r4 = C + C */ \
-    paddsw_r2r(r0, r4);       /* r4 = C. = A + C */ \
-    psubsw_r2r(r6, r3);       /* r3 = B - D */ \
-    paddw_r2r(r7, r5);        /* r5 = c2*i6 */ \
-    paddsw_r2r(r6, r6);       /* r6 = D + D */ \
-    pmulhw_m2r(*C(6), r7);    /* r7 = c6*i6 */ \
-    paddsw_r2r(r3, r6);       /* r6 = D. = B + D */ \
-    movq_r2m(r4, *I(1));      /* save C. at I(1) */ \
-    psubsw_r2r(r5, r1);       /* r1 = H = c6*i2 - c2*i6 */ \
-    movq_m2r(*C(4), r4); \
-    movq_r2r(r3, r5);         /* r5 = B - D */ \
-    pmulhw_r2r(r4, r3);       /* r3 = (c4 - 1) * (B - D) */ \
-    paddsw_r2r(r2, r7);       /* r7 = G = c6*i6 + c2*i2 */ \
-    movq_r2m(r6, *I(2));      /* save D. at I(2) */ \
-    movq_r2r(r0, r2);         /* r2 = A - C */ \
-    movq_m2r(*I(0), r6); \
-    pmulhw_r2r(r4, r0);       /* r0 = (c4 - 1) * (A - C) */ \
-    paddw_r2r(r3, r5);        /* r5 = B. = c4 * (B - D) */ \
-    movq_m2r(*J(4), r3); \
-    psubsw_r2r(r1, r5);       /* r5 = B.. = B. - H */ \
-    paddw_r2r(r0, r2);        /* r0 = A. = c4 * (A - C) */ \
-    psubsw_r2r(r3, r6);       /* r6 = i0 - i4 */ \
-    movq_r2r(r6, r0); \
-    pmulhw_r2r(r4, r6);       /* r6 = (c4 - 1) * (i0 - i4) */ \
-    paddsw_r2r(r3, r3);       /* r3 = i4 + i4 */ \
-    paddsw_r2r(r1, r1);       /* r1 = H + H */ \
-    paddsw_r2r(r0, r3);       /* r3 = i0 + i4 */ \
-    paddsw_r2r(r5, r1);       /* r1 = H. = B + H */ \
-    pmulhw_r2r(r3, r4);       /* r4 = (c4 - 1) * (i0 + i4) */ \
-    paddsw_r2r(r0, r6);       /* r6 = F = c4 * (i0 - i4) */ \
-    psubsw_r2r(r2, r6);       /* r6 = F. = F - A. */ \
-    paddsw_r2r(r2, r2);       /* r2 = A. + A. */ \
-    movq_m2r(*I(1), r0);      /* r0 = C. */ \
-    paddsw_r2r(r6, r2);       /* r2 = A.. = F + A. */ \
-    paddw_r2r(r3, r4);        /* r4 = E = c4 * (i0 + i4) */ \
-    psubsw_r2r(r1, r2);       /* r2 = R2 = A.. - H. */ \
-}
-
-/* RowIDCT gets ready to transpose */
-#define RowIDCT() { \
-    \
-    BeginIDCT(); \
-    \
-    movq_m2r(*I(2), r3);   /* r3 = D. */ \
-    psubsw_r2r(r7, r4);    /* r4 = E. = E - G */ \
-    paddsw_r2r(r1, r1);    /* r1 = H. + H. */ \
-    paddsw_r2r(r7, r7);    /* r7 = G + G */ \
-    paddsw_r2r(r2, r1);    /* r1 = R1 = A.. + H. */ \
-    paddsw_r2r(r4, r7);    /* r7 = G. = E + G */ \
-    psubsw_r2r(r3, r4);    /* r4 = R4 = E. - D. */ \
-    paddsw_r2r(r3, r3); \
-    psubsw_r2r(r5, r6);    /* r6 = R6 = F. - B.. */ \
-    paddsw_r2r(r5, r5); \
-    paddsw_r2r(r4, r3);    /* r3 = R3 = E. + D. */ \
-    paddsw_r2r(r6, r5);    /* r5 = R5 = F. + B.. */ \
-    psubsw_r2r(r0, r7);    /* r7 = R7 = G. - C. */ \
-    paddsw_r2r(r0, r0); \
-    movq_r2m(r1, *I(1));   /* save R1 */ \
-    paddsw_r2r(r7, r0);    /* r0 = R0 = G. + C. */ \
-}
-
-/* Column IDCT normalizes and stores final results */
-#define ColumnIDCT() { \
-    \
-    BeginIDCT(); \
-    \
-    paddsw_m2r(*Eight, r2);    /* adjust R2 (and R1) for shift */ \
-    paddsw_r2r(r1, r1);        /* r1 = H. + H. */ \
-    paddsw_r2r(r2, r1);        /* r1 = R1 = A.. + H. */ \
-    psraw_i2r(4, r2);          /* r2 = NR2 */ \
-    psubsw_r2r(r7, r4);        /* r4 = E. = E - G */ \
-    psraw_i2r(4, r1);          /* r1 = NR1 */ \
-    movq_m2r(*I(2), r3);       /* r3 = D. */ \
-    paddsw_r2r(r7, r7);        /* r7 = G + G */ \
-    movq_r2m(r2, *I(2));       /* store NR2 at I2 */ \
-    paddsw_r2r(r4, r7);        /* r7 = G. = E + G */ \
-    movq_r2m(r1, *I(1));       /* store NR1 at I1 */ \
-    psubsw_r2r(r3, r4);        /* r4 = R4 = E. - D. */ \
-    paddsw_m2r(*Eight, r4);    /* adjust R4 (and R3) for shift */ \
-    paddsw_r2r(r3, r3);        /* r3 = D. + D. */ \
-    paddsw_r2r(r4, r3);        /* r3 = R3 = E. + D. */ \
-    psraw_i2r(4, r4);          /* r4 = NR4 */ \
-    psubsw_r2r(r5, r6);        /* r6 = R6 = F. - B.. */ \
-    psraw_i2r(4, r3);          /* r3 = NR3 */ \
-    paddsw_m2r(*Eight, r6);    /* adjust R6 (and R5) for shift */ \
-    paddsw_r2r(r5, r5);        /* r5 = B.. + B.. */ \
-    paddsw_r2r(r6, r5);        /* r5 = R5 = F. + B.. */ \
-    psraw_i2r(4, r6);          /* r6 = NR6 */ \
-    movq_r2m(r4, *J(4));       /* store NR4 at J4 */ \
-    psraw_i2r(4, r5);          /* r5 = NR5 */ \
-    movq_r2m(r3, *I(3));       /* store NR3 at I3 */ \
-    psubsw_r2r(r0, r7);        /* r7 = R7 = G. - C. */ \
-    paddsw_m2r(*Eight, r7);    /* adjust R7 (and R0) for shift */ \
-    paddsw_r2r(r0, r0);        /* r0 = C. + C. */ \
-    paddsw_r2r(r7, r0);        /* r0 = R0 = G. + C. */ \
-    psraw_i2r(4, r7);          /* r7 = NR7 */ \
-    movq_r2m(r6, *J(6));       /* store NR6 at J6 */ \
-    psraw_i2r(4, r0);          /* r0 = NR0 */ \
-    movq_r2m(r5, *J(5));       /* store NR5 at J5 */ \
-    movq_r2m(r7, *J(7));       /* store NR7 at J7 */ \
-    movq_r2m(r0, *I(0));       /* store NR0 at I0 */ \
-}
-
-/* Following macro does two 4x4 transposes in place.
-
-  At entry (we assume):
-
-    r0 = a3 a2 a1 a0
-    I(1) = b3 b2 b1 b0
-    r2 = c3 c2 c1 c0
-    r3 = d3 d2 d1 d0
-
-    r4 = e3 e2 e1 e0
-    r5 = f3 f2 f1 f0
-    r6 = g3 g2 g1 g0
-    r7 = h3 h2 h1 h0
-
-  At exit, we have:
-
-    I(0) = d0 c0 b0 a0
-    I(1) = d1 c1 b1 a1
-    I(2) = d2 c2 b2 a2
-    I(3) = d3 c3 b3 a3
-    
-    J(4) = h0 g0 f0 e0
-    J(5) = h1 g1 f1 e1
-    J(6) = h2 g2 f2 e2
-    J(7) = h3 g3 f3 e3
-
-   I(0) I(1) I(2) I(3)  is the transpose of r0 I(1) r2 r3.
-   J(4) J(5) J(6) J(7)  is the transpose of r4 r5 r6 r7.
-
-   Since r1 is free at entry, we calculate the Js first. */
-
-#define Transpose() { \
-    movq_r2r(r4, r1);         /* r1 = e3 e2 e1 e0 */ \
-    punpcklwd_r2r(r5, r4);    /* r4 = f1 e1 f0 e0 */ \
-    movq_r2m(r0, *I(0));      /* save a3 a2 a1 a0 */ \
-    punpckhwd_r2r(r5, r1);    /* r1 = f3 e3 f2 e2 */ \
-    movq_r2r(r6, r0);         /* r0 = g3 g2 g1 g0 */ \
-    punpcklwd_r2r(r7, r6);    /* r6 = h1 g1 h0 g0 */ \
-    movq_r2r(r4, r5);         /* r5 = f1 e1 f0 e0 */ \
-    punpckldq_r2r(r6, r4);    /* r4 = h0 g0 f0 e0 = R4 */ \
-    punpckhdq_r2r(r6, r5);    /* r5 = h1 g1 f1 e1 = R5 */ \
-    movq_r2r(r1, r6);         /* r6 = f3 e3 f2 e2 */ \
-    movq_r2m(r4, *J(4)); \
-    punpckhwd_r2r(r7, r0);    /* r0 = h3 g3 h2 g2 */ \
-    movq_r2m(r5, *J(5)); \
-    punpckhdq_r2r(r0, r6);    /* r6 = h3 g3 f3 e3 = R7 */ \
-    movq_m2r(*I(0), r4);      /* r4 = a3 a2 a1 a0 */ \
-    punpckldq_r2r(r0, r1);    /* r1 = h2 g2 f2 e2 = R6 */ \
-    movq_m2r(*I(1), r5);      /* r5 = b3 b2 b1 b0 */ \
-    movq_r2r(r4, r0);         /* r0 = a3 a2 a1 a0 */ \
-    movq_r2m(r6, *J(7)); \
-    punpcklwd_r2r(r5, r0);    /* r0 = b1 a1 b0 a0 */ \
-    movq_r2m(r1, *J(6)); \
-    punpckhwd_r2r(r5, r4);    /* r4 = b3 a3 b2 a2 */ \
-    movq_r2r(r2, r5);         /* r5 = c3 c2 c1 c0 */ \
-    punpcklwd_r2r(r3, r2);    /* r2 = d1 c1 d0 c0 */ \
-    movq_r2r(r0, r1);         /* r1 = b1 a1 b0 a0 */ \
-    punpckldq_r2r(r2, r0);    /* r0 = d0 c0 b0 a0 = R0 */ \
-    punpckhdq_r2r(r2, r1);    /* r1 = d1 c1 b1 a1 = R1 */ \
-    movq_r2r(r4, r2);         /* r2 = b3 a3 b2 a2 */ \
-    movq_r2m(r0, *I(0)); \
-    punpckhwd_r2r(r3, r5);    /* r5 = d3 c3 d2 c2 */ \
-    movq_r2m(r1, *I(1)); \
-    punpckhdq_r2r(r5, r4);    /* r4 = d3 c3 b3 a3 = R3 */ \
-    punpckldq_r2r(r5, r2);    /* r2 = d2 c2 b2 a2 = R2 */ \
-    movq_r2m(r4, *I(3)); \
-    movq_r2m(r2, *I(2)); \
-}
-
-void ff_vp3_dsp_init_mmx(void)
-{
-    int j = 16;
-    uint16_t *p;
-
-    j = 1;
-    do {
-        p = idct_constants + ((j + 3) << 2);
-        p[0] = p[1] = p[2] = p[3] = idct_cosine_table[j - 1];
-    } while (++j <= 7);
-
-    idct_constants[44] = idct_constants[45] =
-    idct_constants[46] = idct_constants[47] = IdctAdjustBeforeShift;
-}
-
-void ff_vp3_idct_mmx(int16_t *output_data)
-{
-    /* eax = quantized input
-     * ebx = dequantizer matrix
-     * ecx = IDCT constants
-     *  M(I) = ecx + MaskOffset(0) + I * 8
-     *  C(I) = ecx + CosineOffset(32) + (I-1) * 8
-     * edx = output
-     * r0..r7 = mm0..mm7
-     */
-
-#define C(x) (idct_constants + 16 + (x - 1) * 4)
-#define Eight (idct_constants + 44)
-
-    /* at this point, function has completed dequantization + dezigzag +
-     * partial transposition; now do the idct itself */
-#define I(K) (output_data + K * 8)
-#define J(K) (output_data + ((K - 4) * 8) + 4)
-
-    RowIDCT();
-    Transpose();
-
-#undef I
-#undef J
-#define I(K) (output_data + (K * 8) + 32)
-#define J(K) (output_data + ((K - 4) * 8) + 36)
-
-    RowIDCT();
-    Transpose();
-
-#undef I
-#undef J
-#define I(K) (output_data + K * 8)
-#define J(K) (output_data + K * 8)
-
-    ColumnIDCT();
-
-#undef I
-#undef J
-#define I(K) (output_data + (K * 8) + 4)
-#define J(K) (output_data + (K * 8) + 4)
-
-    ColumnIDCT();
-
-#undef I
-#undef J
-
-}
diff --git a/ffmpeg.src/libavcodec/i386/vp3dsp_sse2.c b/ffmpeg.src/libavcodec/i386/vp3dsp_sse2.c
deleted file mode 100644
index ed17891..0000000
--- a/ffmpeg.src/libavcodec/i386/vp3dsp_sse2.c
+++ /dev/null
@@ -1,825 +0,0 @@
-/*
- * Copyright (C) 2004 the ffmpeg project
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file vp3dsp_sse2.c
- * SSE2-optimized functions cribbed from the original VP3 source code.
- */
-
-#include "../dsputil.h"
-#include "mmx.h"
-
-static const unsigned short __align16 SSE2_dequant_const[] =
-{
-    0,65535,65535,0,0,0,0,0,    // 0x0000 0000 0000 0000 0000 FFFF FFFF 0000
-    0,0,0,0,65535,65535,0,0,    // 0x0000 0000 FFFF FFFF 0000 0000 0000 0000
-    65535,65535,65535,0,0,0,0,0,// 0x0000 0000 0000 0000 0000 FFFF FFFF FFFF
-    0,0,0,65535,0,0,0,0,        // 0x0000 0000 0000 0000 FFFF 0000 0000 0000
-    0,0,0,65535,65535,0,0,0,    // 0x0000 0000 0000 FFFF FFFF 0000 0000 0000
-    65535,0,0,0,0,65535,0,0,    // 0x0000 0000 FFFF 0000 0000 0000 0000 FFFF
-    0,0,65535,65535, 0,0,0,0    // 0x0000 0000 0000 0000 FFFF FFFF 0000 0000
-};
-
-static const unsigned int __align16 eight_data[] =
-{ 
-    0x00080008, 
-    0x00080008,
-    0x00080008, 
-    0x00080008 
-}; 
-
-static const unsigned short __align16 SSE2_idct_data[7 * 8] =
-{
-    64277,64277,64277,64277,64277,64277,64277,64277, 
-    60547,60547,60547,60547,60547,60547,60547,60547, 
-    54491,54491,54491,54491,54491,54491,54491,54491, 
-    46341,46341,46341,46341,46341,46341,46341,46341, 
-    36410,36410,36410,36410,36410,36410,36410,36410, 
-    25080,25080,25080,25080,25080,25080,25080,25080, 
-    12785,12785,12785,12785,12785,12785,12785,12785
-};
-
-
-#define SSE2_Column_IDCT() {        \
-    \
-    movdqu_m2r(*I(3), xmm2);     /* xmm2 = i3 */ \
-    movdqu_m2r(*C(3), xmm6);     /* xmm6 = c3 */ \
-    \
-    movdqu_r2r(xmm2, xmm4);      /* xmm4 = i3 */ \
-    movdqu_m2r(*I(5), xmm7);     /* xmm7 = i5 */ \
-    \
-    pmulhw_r2r(xmm6, xmm4);      /* xmm4 = c3 * i3 - i3 */ \
-    movdqu_m2r(*C(5), xmm1);     /* xmm1 = c5 */ \
-    \
-    pmulhw_r2r(xmm7, xmm6);      /* xmm6 = c3 * i5 - i5 */ \
-    movdqu_r2r(xmm1, xmm5);      /* xmm5 = c5 */ \
-    \
-    pmulhw_r2r(xmm2, xmm1);      /* xmm1 = c5 * i3 - i3 */ \
-    movdqu_m2r(*I(1), xmm3);     /* xmm3 = i1 */ \
-    \
-    pmulhw_r2r(xmm7, xmm5);      /* xmm5 = c5 * i5 - i5 */ \
-    movdqu_m2r(*C(1), xmm0);     /* xmm0 = c1 */ \
-    \
-    /* all registers are in use */ \
-    \
-    paddw_r2r(xmm2, xmm4);       /* xmm4 = c3 * i3 */ \
-    paddw_r2r(xmm7, xmm6);       /* xmm6 = c3 * i5 */ \
-    \
-    paddw_r2r(xmm1, xmm2);       /* xmm2 = c5 * i3 */ \
-    movdqu_m2r(*I(7), xmm1);     /* xmm1 = i7 */ \
-    \
-    paddw_r2r(xmm5, xmm7);       /* xmm7 = c5 * i5 */ \
-    movdqu_r2r(xmm0, xmm5);      /* xmm5 = c1 */ \
-    \
-    pmulhw_r2r(xmm3, xmm0);      /* xmm0 = c1 * i1 - i1 */ \
-    paddsw_r2r(xmm7, xmm4);      /* xmm4 = c3 * i3 + c5 * i5 = C */ \
-    \
-    pmulhw_r2r(xmm1, xmm5);      /* xmm5 = c1 * i7 - i7 */ \
-    movdqu_m2r(*C(7), xmm7);     /* xmm7 = c7 */ \
-    \
-    psubsw_r2r(xmm2, xmm6);      /* xmm6 = c3 * i5 - c5 * i3 = D */ \
-    paddw_r2r(xmm3, xmm0);       /* xmm0 = c1 * i1 */ \
-    \
-    pmulhw_r2r(xmm7, xmm3);      /* xmm3 = c7 * i1 */ \
-    movdqu_m2r(*I(2), xmm2);     /* xmm2 = i2 */ \
-    \
-    pmulhw_r2r(xmm1, xmm7);      /* xmm7 = c7 * i7 */ \
-    paddw_r2r(xmm1, xmm5);       /* xmm5 = c1 * i7 */ \
-    \
-    movdqu_r2r(xmm2, xmm1);      /* xmm1 = i2 */ \
-    pmulhw_m2r(*C(2), xmm2);     /* xmm2 = i2 * c2 -i2 */ \
-    \
-    psubsw_r2r(xmm5, xmm3);      /* xmm3 = c7 * i1 - c1 * i7 = B */ \
-    movdqu_m2r(*I(6), xmm5);     /* xmm5 = i6 */ \
-    \
-    paddsw_r2r(xmm7, xmm0);      /* xmm0 = c1 * i1 + c7 * i7 = A */ \
-    movdqu_r2r(xmm5, xmm7);      /* xmm7 = i6 */ \
-    \
-    psubsw_r2r(xmm4, xmm0);      /* xmm0 = A - C */ \
-    pmulhw_m2r(*C(2), xmm5);     /* xmm5 = c2 * i6 - i6 */ \
-    \
-    paddw_r2r(xmm1, xmm2);       /* xmm2 = i2 * c2 */ \
-    pmulhw_m2r(*C(6), xmm1);     /* xmm1 = c6 * i2 */ \
-    \
-    paddsw_r2r(xmm4, xmm4);      /* xmm4 = C + C */ \
-    paddsw_r2r(xmm0, xmm4);      /* xmm4 = A + C = C. */ \
-    \
-    psubsw_r2r(xmm6, xmm3);      /* xmm3 = B - D */ \
-    paddw_r2r(xmm7, xmm5);       /* xmm5 = c2 * i6 */ \
-    \
-    paddsw_r2r(xmm6, xmm6);      /* xmm6 = D + D */ \
-    pmulhw_m2r(*C(6), xmm7);     /* xmm7 = c6 * i6 */ \
-    \
-    paddsw_r2r(xmm3, xmm6);      /* xmm6 = B + D = D. */ \
-    movdqu_r2m(xmm4, *I(1));     /* Save C. at I(1) */ \
-    \
-    psubsw_r2r(xmm5, xmm1);      /* xmm1 = c6 * i2 - c2 * i6 = H */ \
-    movdqu_m2r(*C(4), xmm4);     /* xmm4 = c4 */ \
-    \
-    movdqu_r2r(xmm3, xmm5);      /* xmm5 = B - D */ \
-    pmulhw_r2r(xmm4, xmm3);      /* xmm3 = ( c4 -1 ) * ( B - D ) */ \
-    \
-    paddsw_r2r(xmm2, xmm7);      /* xmm7 = c2 * i2 + c6 * i6 = G */ \
-    movdqu_r2m(xmm6, *I(2));     /* Save D. at I(2) */ \
-    \
-    movdqu_r2r(xmm0, xmm2);      /* xmm2 = A - C */ \
-    movdqu_m2r(*I(0), xmm6);     /* xmm6 = i0 */ \
-    \
-    pmulhw_r2r(xmm4, xmm0);      /* xmm0 = ( c4 - 1 ) * ( A - C ) = A. */ \
-    paddw_r2r(xmm3, xmm5);       /* xmm5 = c4 * ( B - D ) = B. */ \
-    \
-    movdqu_m2r(*I(4), xmm3);     /* xmm3 = i4 */ \
-    psubsw_r2r(xmm1, xmm5);      /* xmm5 = B. - H = B.. */ \
-    \
-    paddw_r2r(xmm0, xmm2);       /* xmm2 = c4 * ( A - C) = A. */ \
-    psubsw_r2r(xmm3, xmm6);      /* xmm6 = i0 - i4 */ \
-    \
-    movdqu_r2r(xmm6, xmm0);      /* xmm0 = i0 - i4 */ \
-    pmulhw_r2r(xmm4, xmm6);      /* xmm6 = (c4 - 1) * (i0 - i4) = F */ \
-    \
-    paddsw_r2r(xmm3, xmm3);      /* xmm3 = i4 + i4 */ \
-    paddsw_r2r(xmm1, xmm1);      /* xmm1 = H + H */ \
-    \
-    paddsw_r2r(xmm0, xmm3);      /* xmm3 = i0 + i4 */ \
-    paddsw_r2r(xmm5, xmm1);      /* xmm1 = B. + H = H. */ \
-    \
-    pmulhw_r2r(xmm3, xmm4);      /* xmm4 = ( c4 - 1 ) * ( i0 + i4 )  */ \
-    paddw_r2r(xmm0, xmm6);       /* xmm6 = c4 * ( i0 - i4 ) */ \
-    \
-    psubsw_r2r(xmm2, xmm6);      /* xmm6 = F - A. = F. */ \
-    paddsw_r2r(xmm2, xmm2);      /* xmm2 = A. + A. */ \
-    \
-    movdqu_m2r(*I(1), xmm0);     /* Load        C. from I(1) */ \
-    paddsw_r2r(xmm6, xmm2);      /* xmm2 = F + A. = A.. */ \
-    \
-    paddw_r2r(xmm3, xmm4);       /* xmm4 = c4 * ( i0 + i4 ) = 3 */ \
-    psubsw_r2r(xmm1, xmm2);      /* xmm2 = A.. - H. = R2 */ \
-    \
-    paddsw_m2r(*Eight, xmm2);    /* Adjust R2 and R1 before shifting */ \
-    paddsw_r2r(xmm1, xmm1);      /* xmm1 = H. + H. */ \
-    \
-    paddsw_r2r(xmm2, xmm1);      /* xmm1 = A.. + H. = R1 */ \
-    psraw_i2r(4, xmm2);          /* xmm2 = op2 */ \
-    \
-    psubsw_r2r(xmm7, xmm4);      /* xmm4 = E - G = E. */ \
-    psraw_i2r(4, xmm1);          /* xmm1 = op1 */ \
-    \
-    movdqu_m2r(*I(2), xmm3);     /* Load D. from I(2) */ \
-    paddsw_r2r(xmm7, xmm7);      /* xmm7 = G + G */ \
-    \
-    movdqu_r2m(xmm2, *O(2));     /* Write out op2 */ \
-    paddsw_r2r(xmm4, xmm7);      /* xmm7 = E + G = G. */ \
-    \
-    movdqu_r2m(xmm1, *O(1));     /* Write out op1 */ \
-    psubsw_r2r(xmm3, xmm4);      /* xmm4 = E. - D. = R4 */ \
-    \
-    paddsw_m2r(*Eight, xmm4);    /* Adjust R4 and R3 before shifting */ \
-    paddsw_r2r(xmm3, xmm3);      /* xmm3 = D. + D. */ \
-    \
-    paddsw_r2r(xmm4, xmm3);      /* xmm3 = E. + D. = R3 */ \
-    psraw_i2r(4, xmm4);          /* xmm4 = op4 */ \
-    \
-    psubsw_r2r(xmm5, xmm6);      /* xmm6 = F. - B..= R6 */ \
-    psraw_i2r(4, xmm3);          /* xmm3 = op3 */ \
-    \
-    paddsw_m2r(*Eight, xmm6);    /* Adjust R6 and R5 before shifting */ \
-    paddsw_r2r(xmm5, xmm5);      /* xmm5 = B.. + B.. */ \
-    \
-    paddsw_r2r(xmm6, xmm5);      /* xmm5 = F. + B.. = R5 */ \
-    psraw_i2r(4, xmm6);          /* xmm6 = op6 */ \
-    \
-    movdqu_r2m(xmm4, *O(4));     /* Write out op4 */ \
-    psraw_i2r(4, xmm5);          /* xmm5 = op5 */ \
-    \
-    movdqu_r2m(xmm3, *O(3));     /* Write out op3 */ \
-    psubsw_r2r(xmm0, xmm7);      /* xmm7 = G. - C. = R7 */ \
-    \
-    paddsw_m2r(*Eight, xmm7);    /* Adjust R7 and R0 before shifting */ \
-    paddsw_r2r(xmm0, xmm0);      /* xmm0 = C. + C. */ \
-    \
-    paddsw_r2r(xmm7, xmm0);      /* xmm0 = G. + C. */ \
-    psraw_i2r(4, xmm7);          /* xmm7 = op7 */ \
-    \
-    movdqu_r2m(xmm6, *O(6));     /* Write out op6 */ \
-    psraw_i2r(4, xmm0);          /* xmm0 = op0 */ \
-    \
-    movdqu_r2m(xmm5, *O(5));     /* Write out op5 */ \
-    movdqu_r2m(xmm7, *O(7));     /* Write out op7 */ \
-    \
-    movdqu_r2m(xmm0, *O(0));     /* Write out op0 */ \
-    \
-} /* End of SSE2_Column_IDCT macro */
-
-
-#define SSE2_Row_IDCT() {        \
-    \
-    movdqu_m2r(*I(3), xmm2);     /* xmm2 = i3 */ \
-    movdqu_m2r(*C(3), xmm6);     /* xmm6 = c3 */ \
-    \
-    movdqu_r2r(xmm2, xmm4);      /* xmm4 = i3 */ \
-    movdqu_m2r(*I(5), xmm7);     /* xmm7 = i5 */ \
-    \
-    pmulhw_r2r(xmm6, xmm4);      /* xmm4 = c3 * i3 - i3 */ \
-    movdqu_m2r(*C(5), xmm1);     /* xmm1 = c5 */ \
-    \
-    pmulhw_r2r(xmm7, xmm6);      /* xmm6 = c3 * i5 - i5 */ \
-    movdqu_r2r(xmm1, xmm5);      /* xmm5 = c5 */ \
-    \
-    pmulhw_r2r(xmm2, xmm1);      /* xmm1 = c5 * i3 - i3 */ \
-    movdqu_m2r(*I(1), xmm3);     /* xmm3 = i1 */ \
-    \
-    pmulhw_r2r(xmm7, xmm5);      /* xmm5 = c5 * i5 - i5 */ \
-    movdqu_m2r(*C(1), xmm0);     /* xmm0 = c1 */ \
-    \
-    /* all registers are in use */ \
-    \
-    paddw_r2r(xmm2, xmm4);      /* xmm4 = c3 * i3 */ \
-    paddw_r2r(xmm7, xmm6);      /* xmm6 = c3 * i5 */ \
-    \
-    paddw_r2r(xmm1, xmm2);      /* xmm2 = c5 * i3 */ \
-    movdqu_m2r(*I(7), xmm1);    /* xmm1 = i7 */ \
-    \
-    paddw_r2r(xmm5, xmm7);      /* xmm7 = c5 * i5 */ \
-    movdqu_r2r(xmm0, xmm5);     /* xmm5 = c1 */ \
-    \
-    pmulhw_r2r(xmm3, xmm0);     /* xmm0 = c1 * i1 - i1 */ \
-    paddsw_r2r(xmm7, xmm4);     /* xmm4 = c3 * i3 + c5 * i5 = C */ \
-    \
-    pmulhw_r2r(xmm1, xmm5);     /* xmm5 = c1 * i7 - i7 */ \
-    movdqu_m2r(*C(7), xmm7);    /* xmm7 = c7 */ \
-    \
-    psubsw_r2r(xmm2, xmm6);     /* xmm6 = c3 * i5 - c5 * i3 = D */ \
-    paddw_r2r(xmm3, xmm0);      /* xmm0 = c1 * i1 */ \
-    \
-    pmulhw_r2r(xmm7, xmm3);     /* xmm3 = c7 * i1 */ \
-    movdqu_m2r(*I(2), xmm2);    /* xmm2 = i2 */ \
-    \
-    pmulhw_r2r(xmm1, xmm7);     /* xmm7 = c7 * i7 */ \
-    paddw_r2r(xmm1, xmm5);      /* xmm5 = c1 * i7 */ \
-    \
-    movdqu_r2r(xmm2, xmm1);     /* xmm1 = i2 */ \
-    pmulhw_m2r(*C(2), xmm2);    /* xmm2 = i2 * c2 -i2 */ \
-    \
-    psubsw_r2r(xmm5, xmm3);     /* xmm3 = c7 * i1 - c1 * i7 = B */ \
-    movdqu_m2r(*I(6), xmm5);    /* xmm5 = i6 */ \
-    \
-    paddsw_r2r(xmm7, xmm0);     /* xmm0 = c1 * i1 + c7 * i7        = A */ \
-    movdqu_r2r(xmm5, xmm7);     /* xmm7 = i6 */ \
-    \
-    psubsw_r2r(xmm4, xmm0);     /* xmm0 = A - C */ \
-    pmulhw_m2r(*C(2), xmm5);    /* xmm5 = c2 * i6 - i6 */ \
-    \
-    paddw_r2r(xmm1, xmm2);      /* xmm2 = i2 * c2 */ \
-    pmulhw_m2r(*C(6), xmm1);    /* xmm1 = c6 * i2 */ \
-    \
-    paddsw_r2r(xmm4, xmm4);     /* xmm4 = C + C */ \
-    paddsw_r2r(xmm0, xmm4);     /* xmm4 = A + C = C. */ \
-    \
-    psubsw_r2r(xmm6, xmm3);     /* xmm3 = B - D */ \
-    paddw_r2r(xmm7, xmm5);      /* xmm5 = c2 * i6 */ \
-    \
-    paddsw_r2r(xmm6, xmm6);     /* xmm6 = D + D */ \
-    pmulhw_m2r(*C(6), xmm7);    /* xmm7 = c6 * i6 */ \
-    \
-    paddsw_r2r(xmm3, xmm6);     /* xmm6 = B + D = D. */ \
-    movdqu_r2m(xmm4, *I(1));    /* Save C. at I(1)        */ \
-    \
-    psubsw_r2r(xmm5, xmm1);     /* xmm1 = c6 * i2 - c2 * i6 = H */ \
-    movdqu_m2r(*C(4), xmm4);    /* xmm4 = c4 */ \
-    \
-    movdqu_r2r(xmm3, xmm5);     /* xmm5 = B - D */ \
-    pmulhw_r2r(xmm4, xmm3);     /* xmm3 = ( c4 -1 ) * ( B - D ) */ \
-    \
-    paddsw_r2r(xmm2, xmm7);     /* xmm7 = c2 * i2 + c6 * i6 = G */ \
-    movdqu_r2m(xmm6, *I(2));    /* Save D. at I(2) */ \
-    \
-    movdqu_r2r(xmm0, xmm2);     /* xmm2 = A - C */ \
-    movdqu_m2r(*I(0), xmm6);    /* xmm6 = i0 */ \
-    \
-    pmulhw_r2r(xmm4, xmm0);     /* xmm0 = ( c4 - 1 ) * ( A - C ) = A. */ \
-    paddw_r2r(xmm3, xmm5);      /* xmm5 = c4 * ( B - D ) = B. */ \
-    \
-    movdqu_m2r(*I(4), xmm3);    /* xmm3 = i4 */ \
-    psubsw_r2r(xmm1, xmm5);     /* xmm5 = B. - H = B.. */ \
-    \
-    paddw_r2r(xmm0, xmm2);      /* xmm2 = c4 * ( A - C) = A. */ \
-    psubsw_r2r(xmm3, xmm6);     /* xmm6 = i0 - i4 */ \
-    \
-    movdqu_r2r(xmm6, xmm0);     /* xmm0 = i0 - i4 */ \
-    pmulhw_r2r(xmm4, xmm6);     /* xmm6 = ( c4 - 1 ) * ( i0 - i4 ) = F */ \
-    \
-    paddsw_r2r(xmm3, xmm3);     /* xmm3 = i4 + i4 */ \
-    paddsw_r2r(xmm1, xmm1);     /* xmm1 = H + H */ \
-    \
-    paddsw_r2r(xmm0, xmm3);     /* xmm3 = i0 + i4 */ \
-    paddsw_r2r(xmm5, xmm1);     /* xmm1 = B. + H = H. */ \
-    \
-    pmulhw_r2r(xmm3, xmm4);     /* xmm4 = ( c4 - 1 ) * ( i0 + i4 )  */ \
-    paddw_r2r(xmm0, xmm6);      /* xmm6 = c4 * ( i0 - i4 ) */ \
-    \
-    psubsw_r2r(xmm2, xmm6);     /* xmm6 = F - A. = F. */ \
-    paddsw_r2r(xmm2, xmm2);     /* xmm2 = A. + A. */ \
-    \
-    movdqu_m2r(*I(1), xmm0);    /* Load C. from I(1) */ \
-    paddsw_r2r(xmm6, xmm2);     /* xmm2 = F + A. = A.. */ \
-    \
-    paddw_r2r(xmm3, xmm4);      /* xmm4 = c4 * ( i0 + i4 ) = 3 */ \
-    psubsw_r2r(xmm1, xmm2);     /* xmm2 = A.. - H. = R2 */ \
-    \
-    paddsw_r2r(xmm1, xmm1);     /* xmm1 = H. + H. */ \
-    paddsw_r2r(xmm2, xmm1);     /* xmm1 = A.. + H. = R1 */ \
-    \
-    psubsw_r2r(xmm7, xmm4);     /* xmm4 = E - G = E. */ \
-    \
-    movdqu_m2r(*I(2), xmm3);    /* Load D. from I(2) */ \
-    paddsw_r2r(xmm7, xmm7);     /* xmm7 = G + G */ \
-    \
-    movdqu_r2m(xmm2, *I(2));    /* Write out op2 */ \
-    paddsw_r2r(xmm4, xmm7);     /* xmm7 = E + G = G. */ \
-    \
-    movdqu_r2m(xmm1, *I(1));    /* Write out op1 */ \
-    psubsw_r2r(xmm3, xmm4);     /* xmm4 = E. - D. = R4 */ \
-    \
-    paddsw_r2r(xmm3, xmm3);     /* xmm3 = D. + D. */ \
-    \
-    paddsw_r2r(xmm4, xmm3);     /* xmm3 = E. + D. = R3 */ \
-    \
-    psubsw_r2r(xmm5, xmm6);     /* xmm6 = F. - B..= R6 */ \
-    \
-    paddsw_r2r(xmm5, xmm5);     /* xmm5 = B.. + B.. */ \
-    \
-    paddsw_r2r(xmm6, xmm5);     /* xmm5 = F. + B.. = R5 */ \
-    \
-    movdqu_r2m(xmm4, *I(4));    /* Write out op4 */ \
-    \
-    movdqu_r2m(xmm3, *I(3));    /* Write out op3 */ \
-    psubsw_r2r(xmm0, xmm7);     /* xmm7 = G. - C. = R7 */ \
-    \
-    paddsw_r2r(xmm0, xmm0);     /* xmm0 = C. + C. */ \
-    \
-    paddsw_r2r(xmm7, xmm0);     /* xmm0 = G. + C. */ \
-    \
-    movdqu_r2m(xmm6, *I(6));    /* Write out op6 */ \
-    \
-    movdqu_r2m(xmm5, *I(5));    /* Write out op5 */ \
-    movdqu_r2m(xmm7, *I(7));    /* Write out op7 */ \
-    \
-    movdqu_r2m(xmm0, *I(0));    /* Write out op0 */ \
-    \
-} /* End of SSE2_Row_IDCT macro */
-
-
-#define SSE2_Transpose() {    \
-    \
-    movdqu_m2r(*I(4), xmm4);    /* xmm4=e7e6e5e4e3e2e1e0 */ \
-    movdqu_m2r(*I(5), xmm0);    /* xmm4=f7f6f5f4f3f2f1f0 */ \
-    \
-    movdqu_r2r(xmm4, xmm5);     /* make a copy */ \
-    punpcklwd_r2r(xmm0, xmm4);  /* xmm4=f3e3f2e2f1e1f0e0 */ \
-    \
-    punpckhwd_r2r(xmm0, xmm5);  /* xmm5=f7e7f6e6f5e5f4e4 */ \
-    movdqu_m2r(*I(6), xmm6);    /* xmm6=g7g6g5g4g3g2g1g0 */ \
-    \
-    movdqu_m2r(*I(7), xmm0);    /* xmm0=h7h6h5h4h3h2h1h0 */ \
-    movdqu_r2r(xmm6, xmm7);     /* make a copy */ \
-    \
-    punpcklwd_r2r(xmm0, xmm6);  /* xmm6=h3g3h3g2h1g1h0g0 */ \
-    punpckhwd_r2r(xmm0, xmm7);  /* xmm7=h7g7h6g6h5g5h4g4 */ \
-    \
-    movdqu_r2r(xmm4, xmm3);     /* make a copy */ \
-    punpckldq_r2r(xmm6, xmm4);  /* xmm4=h1g1f1e1h0g0f0e0 */ \
-    \
-    punpckhdq_r2r(xmm6, xmm3);  /* xmm3=h3g3g3e3h2g2f2e2 */ \
-    movdqu_r2m(xmm3, *I(6));    /* save h3g3g3e3h2g2f2e2 */ \
-    /* Free xmm6 */ \
-    movdqu_r2r(xmm5, xmm6);     /* make a copy */ \
-    punpckldq_r2r(xmm7, xmm5);  /* xmm5=h5g5f5e5h4g4f4e4 */ \
-    \
-    punpckhdq_r2r(xmm7, xmm6);  /* xmm6=h7g7f7e7h6g6f6e6 */ \
-    movdqu_m2r(*I(0), xmm0);    /* xmm0=a7a6a5a4a3a2a1a0 */ \
-    /* Free xmm7 */ \
-    movdqu_m2r(*I(1), xmm1);    /* xmm1=b7b6b5b4b3b2b1b0 */ \
-    movdqu_r2r(xmm0, xmm7);     /* make a copy */ \
-    \
-    punpcklwd_r2r(xmm1, xmm0);  /* xmm0=b3a3b2a2b1a1b0a0 */ \
-    punpckhwd_r2r(xmm1, xmm7);  /* xmm7=b7a7b6a6b5a5b4a4 */ \
-    /* Free xmm1 */ \
-    movdqu_m2r(*I(2), xmm2);    /* xmm2=c7c6c5c4c3c2c1c0 */ \
-    movdqu_m2r(*I(3), xmm3);    /* xmm3=d7d6d5d4d3d2d1d0 */ \
-    \
-    movdqu_r2r(xmm2, xmm1);     /* make a copy */ \
-    punpcklwd_r2r(xmm3, xmm2);  /* xmm2=d3c3d2c2d1c1d0c0 */ \
-    \
-    punpckhwd_r2r(xmm3, xmm1);  /* xmm1=d7c7d6c6d5c5d4c4 */ \
-    movdqu_r2r(xmm0, xmm3);     /* make a copy        */ \
-    \
-    punpckldq_r2r(xmm2, xmm0);  /* xmm0=d1c1b1a1d0c0b0a0 */ \
-    punpckhdq_r2r(xmm2, xmm3);  /* xmm3=d3c3b3a3d2c2b2a2 */ \
-    /* Free xmm2 */ \
-    movdqu_r2r(xmm7, xmm2);     /* make a copy */ \
-    punpckldq_r2r(xmm1, xmm2);  /* xmm2=d5c5b5a5d4c4b4a4 */ \
-    \
-    punpckhdq_r2r(xmm1, xmm7);  /* xmm7=d7c7b7a7d6c6b6a6 */ \
-    movdqu_r2r(xmm0, xmm1);     /* make a copy */ \
-    \
-    punpcklqdq_r2r(xmm4, xmm0); /* xmm0=h0g0f0e0d0c0b0a0 */ \
-    punpckhqdq_r2r(xmm4, xmm1); /* xmm1=h1g1g1e1d1c1b1a1 */ \
-    \
-    movdqu_r2m(xmm0, *I(0));    /* save I(0) */ \
-    movdqu_r2m(xmm1, *I(1));    /* save I(1) */ \
-    \
-    movdqu_m2r(*I(6), xmm0);    /* load h3g3g3e3h2g2f2e2 */ \
-    movdqu_r2r(xmm3, xmm1);     /* make a copy */ \
-    \
-    punpcklqdq_r2r(xmm0, xmm1); /* xmm1=h2g2f2e2d2c2b2a2 */ \
-    punpckhqdq_r2r(xmm0, xmm3); /* xmm3=h3g3f3e3d3c3b3a3 */ \
-    \
-    movdqu_r2r(xmm2, xmm4);     /* make a copy */ \
-    punpcklqdq_r2r(xmm5, xmm4); /* xmm4=h4g4f4e4d4c4b4a4 */ \
-    \
-    punpckhqdq_r2r(xmm5, xmm2); /* xmm2=h5g5f5e5d5c5b5a5 */ \
-    movdqu_r2m(xmm1, *I(2));    /* save I(2) */ \
-    \
-    movdqu_r2m(xmm3, *I(3));    /* save I(3) */ \
-    movdqu_r2m(xmm4, *I(4));    /* save I(4) */ \
-    \
-    movdqu_r2m(xmm2, *I(5));    /* save I(5) */ \
-    movdqu_r2r(xmm7, xmm5);     /* make a copy */ \
-    \
-    punpcklqdq_r2r(xmm6, xmm5); /* xmm5=h6g6f6e6d6c6b6a6 */ \
-    punpckhqdq_r2r(xmm6, xmm7); /* xmm7=h7g7f7e7d7c7b7a7 */ \
-    \
-    movdqu_r2m(xmm5, *I(6));    /* save I(6) */ \
-    movdqu_r2m(xmm7, *I(7));    /* save I(7) */ \
-    \
-} /* End of Transpose Macro */
-
-
-#define SSE2_Dequantize() {        \
-    movdqu_m2r(*(eax), xmm0);     \
-    \
-    pmullw_m2r(*(ebx), xmm0);          /* xmm0 = 07 06 05 04 03 02 01 00 */ \
-    movdqu_m2r(*(eax + 16), xmm1);     \
-    \
-    pmullw_m2r(*(ebx + 16), xmm1);     /* xmm1 = 17 16 15 14 13 12 11 10 */ \
-    pshuflw_r2r(xmm0, xmm3, 0x078);    /* xmm3 = 07 06 05 04 01 03 02 00 */ \
-    \
-    movdqu_r2r(xmm1, xmm2);            /* xmm2 = 17 16 15 14 13 12 11 10 */ \
-    movdqu_m2r(*(ecx), xmm7);          /* xmm7 = -- -- -- -- -- FF FF -- */ \
-    \
-    movdqu_m2r(*(eax + 32), xmm4);     \
-    movdqu_m2r(*(eax + 64), xmm5);     \
-    \
-    pmullw_m2r(*(ebx + 32), xmm4);     /* xmm4 = 27 26 25 24 23 22 21 20 */ \
-    pmullw_m2r(*(ebx + 64), xmm5);     /* xmm5 = 47 46 45 44 43 42 41 40 */ \
-    \
-    movdqu_m2r(*(ecx + 16), xmm6);     /* xmm6 = -- -- FF FF -- -- -- -- */ \
-    pand_r2r(xmm2, xmm7);              /* xmm7 = -- -- -- -- -- 12 11 -- */ \
-    \
-    pand_r2r(xmm4, xmm6);              /* xmm6 = -- -- 25 24 -- -- -- -- */ \
-    pxor_r2r(xmm7, xmm2);              /* xmm2 = 17 16 15 14 13 -- -- 10 */ \
-    \
-    pxor_r2r(xmm6, xmm4);              /* xmm4 = 27 26 -- -- 23 22 21 20 */ \
-    pslldq_i2r(4, xmm7);               /* xmm7 = -- -- -- 12 11 -- -- -- */ \
-    \
-    pslldq_i2r(2, xmm6);               /* xmm6 = -- 25 24 -- -- -- -- -- */ \
-    por_r2r(xmm6, xmm7);               /* xmm7 = -- 25 24 12 11 -- -- -- */ \
-    \
-    movdqu_m2r(*(ecx + 32), xmm0);     /* xmm0 = -- -- -- -- -- FF FF FF */ \
-    movdqu_m2r(*(ecx + 48), xmm6);     /* xmm6 = -- -- -- -- FF -- -- -- */ \
-    \
-    pand_r2r(xmm3, xmm0);              /* xmm0 = -- -- -- -- -- 03 02 00 */ \
-    pand_r2r(xmm5, xmm6);              /* xmm6 = -- -- -- -- 43 -- -- -- */ \
-    \
-    pxor_r2r(xmm0, xmm3);              /* xmm3 = 07 06 05 04 01 -- -- -- */ \
-    pxor_r2r(xmm6, xmm5);              /* xmm5 = 47 46 45 44 -- 42 41 40 */ \
-    \
-    por_r2r(xmm7, xmm0);               /* xmm0 = -- 25 24 12 11 03 02 00 */ \
-    pslldq_i2r(8, xmm6);               /* xmm6 = 43 -- -- -- -- -- -- -- */ \
-    \
-    por_r2r(xmm6, xmm0);               /* xmm0 = 43 25 24 12 11 03 02 00 */ \
-    /* 02345 in use */ \
-    \
-    movdqu_m2r(*(ecx + 64 ), xmm1);    /* xmm1 = -- -- -- FF FF -- -- -- */ \
-    pshuflw_r2r(xmm5, xmm5, 0x0B4);    /* xmm5 = 47 46 45 44 42 -- 41 40 */ \
-    \
-    movdqu_r2r(xmm1, xmm7);            /* xmm7 = -- -- -- FF FF -- -- -- */ \
-    movdqu_r2r(xmm1, xmm6);            /* xmm6 = -- -- -- FF FF -- -- -- */ \
-    \
-    movdqu_r2m(xmm0, *(eax));          /* write  43 25 24 12 11 03 02 00 */ \
-    pshufhw_r2r(xmm4, xmm4, 0x0C2);    /* xmm4 = 27 -- -- 26 23 22 21 20 */ \
-    \
-    pand_r2r(xmm4, xmm7);              /* xmm7 = -- -- -- 26 23 -- -- -- */ \
-    pand_r2r(xmm5, xmm1);              /* xmm1 = -- -- -- 44 42 -- -- -- */ \
-    \
-    pxor_r2r(xmm7, xmm4);              /* xmm4 = 27 -- -- -- -- 22 21 20 */ \
-    pxor_r2r(xmm1, xmm5);              /* xmm5 = 47 46 45 -- -- -- 41 40 */ \
-    \
-    pshuflw_r2r(xmm2, xmm2, 0x0C6);    /* xmm2 = 17 16 15 14 13 10 -- -- */ \
-    movdqu_r2r(xmm6, xmm0);            /* xmm0 = -- -- -- FF FF -- -- -- */ \
-    \
-    pslldq_i2r(2, xmm7);               /* xmm7 = -- -- 26 23 -- -- -- -- */ \
-    pslldq_i2r(6, xmm1);               /* xmm1 = 44 42 -- -- -- -- -- -- */ \
-    \
-    psrldq_i2r(2, xmm0);               /* xmm0 = -- -- -- -- FF FF -- -- */ \
-    pand_r2r(xmm3, xmm6);              /* xmm6 = -- -- -- 04 01 -- -- -- */ \
-    \
-    pand_r2r(xmm2, xmm0);              /* xmm0 = -- -- -- -- 13 10 -- -- */ \
-    pxor_r2r(xmm6, xmm3);              /* xmm3 = 07 06 05 -- -- -- -- -- */ \
-    \
-    pxor_r2r(xmm0, xmm2);              /* xmm2 = 17 16 15 14 -- -- -- -- */ \
-    psrldq_i2r(6, xmm6);               /* xmm0 = -- -- -- -- -- -- 04 01 */ \
-    \
-    por_r2r(xmm7, xmm1);               /* xmm1 = 44 42 26 23 -- -- -- -- */ \
-    por_r2r(xmm6, xmm0);               /* xmm1 = -- -- -- -- 13 10 04 01 */ \
-    /* 12345 in use */    \
-    por_r2r(xmm0, xmm1);               /* xmm1 = 44 42 26 23 13 10 04 01 */ \
-    pshuflw_r2r(xmm4, xmm4, 0x093);    /* xmm4 = 27 -- -- -- 22 21 20 -- */ \
-    \
-    pshufhw_r2r(xmm4, xmm4, 0x093);    /* xmm4 = -- -- -- 27 22 21 20 -- */ \
-    movdqu_r2m(xmm1, *(eax + 16));     /* write  44 42 26 23 13 10 04 01 */ \
-    \
-    pshufhw_r2r(xmm3, xmm3, 0x0D2);    /* xmm3 = 07 05 -- 06 -- -- -- -- */ \
-    movdqu_m2r(*(ecx + 64), xmm0);     /* xmm0 = -- -- -- FF FF -- -- -- */ \
-    \
-    pand_r2r(xmm3, xmm0);              /* xmm0 = -- -- -- 06 -- -- -- -- */ \
-    psrldq_i2r(12, xmm3);              /* xmm3 = -- -- -- -- -- -- 07 05 */ \
-    \
-    psrldq_i2r(8, xmm0);               /* xmm0 = -- -- -- -- -- -- -- 06 */ \
-    \
-    movdqu_m2r(*(ecx + 64), xmm6);     /* xmm6 = -- -- -- FF FF -- -- -- */ \
-    movdqu_m2r(*(ecx + 96), xmm7);     /* xmm7 = -- -- -- -- FF FF -- -- */ \
-    \
-    pand_r2r(xmm4, xmm6);              /* xmm6 = -- -- -- 27 22 -- -- -- */ \
-    pxor_r2r(xmm6, xmm4);              /* xmm4 = -- -- -- -- -- 21 20 -- */ \
-    \
-    por_r2r(xmm6, xmm3);               /* xmm3 = -- -- -- 27 22 -- 07 05 */ \
-    pand_r2r(xmm4, xmm7);              /* xmm7 = -- -- -- -- -- 21 -- -- */ \
-    \
-    por_r2r(xmm7, xmm0);               /* xmm0 = -- -- -- -- -- 21 -- 06 */ \
-    pxor_r2r(xmm7, xmm4);              /* xmm4 = -- -- -- -- -- -- 20 -- */ \
-    \
-    movdqu_m2r(*(ecx + 16 ), xmm6);    /* xmm6 = -- -- FF FF -- -- -- -- */ \
-    movdqu_m2r(*(ecx + 64 ), xmm1);    /* xmm1 = -- -- -- FF FF -- -- -- */ \
-    \
-    pand_r2r(xmm2, xmm6);              /* xmm6 = -- -- 15 14 -- -- -- -- */ \
-    pand_r2r(xmm6, xmm1);              /* xmm1 = -- -- -- 14 -- -- -- -- */ \
-    \
-    pxor_r2r(xmm6, xmm2);              /* xmm2 = 17 16 -- -- -- -- -- -- */ \
-    pxor_r2r(xmm1, xmm6);              /* xmm6 = -- -- 15 -- -- -- -- -- */ \
-    \
-    psrldq_i2r(4, xmm1);               /* xmm1 = -- -- -- -- -- 14 -- -- */ \
-    \
-    psrldq_i2r(8, xmm6);               /* xmm6 = -- -- -- -- -- -- 15 -- */ \
-    por_r2r(xmm1, xmm3);               /* xmm3 = -- -- -- 27 22 14 07 05 */ \
-    \
-    por_r2r(xmm6, xmm0);               /* xmm0 = -- -- -- -- -- 21 15 06 */ \
-    pshufhw_r2r(xmm5, xmm5, 0x0E1);    /* xmm5 = 47 46 -- 45 -- -- 41 40 */ \
-    \
-    movdqu_m2r(*(ecx + 64), xmm1);     /* xmm1 = -- -- -- FF FF -- -- -- */ \
-    pshuflw_r2r(xmm5, xmm5, 0x072);    /* xmm5 = 47 46 -- 45 41 -- 40 -- */ \
-    \
-    movdqu_r2r(xmm1, xmm6);            /* xmm6 = -- -- -- FF FF -- -- -- */ \
-    pand_r2r(xmm5, xmm1);              /* xmm1 = -- -- -- 45 41 -- -- -- */ \
-    \
-    pxor_r2r(xmm1, xmm5);              /* xmm5 = 47 46 -- -- -- -- 40 -- */ \
-    pslldq_i2r(4, xmm1);               /* xmm1 = -- 45 41 -- -- -- -- -- */ \
-    \
-    pshufd_r2r(xmm5, xmm5, 0x09C);     /* xmm5 = -- -- -- -- 47 46 40 -- */ \
-    por_r2r(xmm1, xmm3);               /* xmm3 = -- 45 41 27 22 14 07 05 */ \
-    \
-    movdqu_m2r(*(eax + 96), xmm1);     /* xmm1 = 67 66 65 64 63 62 61 60 */ \
-    pmullw_m2r(*(ebx + 96), xmm1);     \
-    \
-    movdqu_m2r(*(ecx), xmm7);          /* xmm7 = -- -- -- -- -- FF FF -- */ \
-    \
-    psrldq_i2r(8, xmm6);               /* xmm6 = -- -- -- -- -- -- -- FF */ \
-    pand_r2r(xmm5, xmm7);              /* xmm7 = -- -- -- -- -- 46 40 -- */ \
-    \
-    pand_r2r(xmm1, xmm6);              /* xmm6 = -- -- -- -- -- -- -- 60 */ \
-    pxor_r2r(xmm7, xmm5);              /* xmm5 = -- -- -- -- 47 -- -- -- */ \
-    \
-    pxor_r2r(xmm6, xmm1);              /* xmm1 = 67 66 65 64 63 62 61 -- */ \
-    pslldq_i2r(2, xmm5);               /* xmm5 = -- -- -- 47 -- -- -- -- */ \
-    \
-    pslldq_i2r(14, xmm6);              /* xmm6 = 60 -- -- -- -- -- -- -- */ \
-    por_r2r(xmm5, xmm4);               /* xmm4 = -- -- -- 47 -- -- 20 -- */ \
-    \
-    por_r2r(xmm6, xmm3);               /* xmm3 = 60 45 41 27 22 14 07 05 */ \
-    pslldq_i2r(6, xmm7);               /* xmm7 = -- -- 46 40 -- -- -- -- */ \
-    \
-    movdqu_r2m(xmm3, *(eax+32));       /* write  60 45 41 27 22 14 07 05 */ \
-    por_r2r(xmm7, xmm0);               /* xmm0 = -- -- 46 40 -- 21 15 06 */ \
-    /* 0, 1, 2, 4 in use */    \
-    movdqu_m2r(*(eax + 48), xmm3);     /* xmm3 = 37 36 35 34 33 32 31 30 */ \
-    movdqu_m2r(*(eax + 80), xmm5);     /* xmm5 = 57 56 55 54 53 52 51 50 */ \
-    \
-    pmullw_m2r(*(ebx + 48), xmm3);     \
-    pmullw_m2r(*(ebx + 80), xmm5);     \
-    \
-    movdqu_m2r(*(ecx + 64), xmm6);     /* xmm6 = -- -- -- FF FF -- -- -- */ \
-    movdqu_m2r(*(ecx + 64), xmm7);     /* xmm7 = -- -- -- FF FF -- -- -- */ \
-    \
-    psrldq_i2r(8, xmm6);               /* xmm6 = -- -- -- -- -- -- -- FF */ \
-    pslldq_i2r(8, xmm7);               /* xmm7 = FF -- -- -- -- -- -- -- */ \
-    \
-    pand_r2r(xmm3, xmm6);              /* xmm6 = -- -- -- -- -- -- -- 30 */ \
-    pand_r2r(xmm5, xmm7);              /* xmm7 = 57 -- -- -- -- -- -- -- */ \
-    \
-    pxor_r2r(xmm6, xmm3);              /* xmm3 = 37 36 35 34 33 32 31 -- */ \
-    pxor_r2r(xmm7, xmm5);              /* xmm5 = __ 56 55 54 53 52 51 50 */ \
-    \
-    pslldq_i2r(6, xmm6);               /* xmm6 = -- -- -- -- 30 -- -- -- */ \
-    psrldq_i2r(2, xmm7);               /* xmm7 = -- 57 -- -- -- -- -- -- */ \
-    \
-    por_r2r(xmm7, xmm6);               /* xmm6 = -- 57 -- -- 30 -- -- -- */ \
-    movdqu_m2r(*(ecx), xmm7);          /* xmm7 = -- -- -- -- -- FF FF -- */ \
-    \
-    por_r2r(xmm6, xmm0);               /* xmm0 = -- 57 46 40 30 21 15 06 */ \
-    psrldq_i2r(2, xmm7);               /* xmm7 = -- -- -- -- -- -- FF FF */ \
-    \
-    movdqu_r2r(xmm2, xmm6);            /* xmm6 = 17 16 -- -- -- -- -- -- */ \
-    pand_r2r(xmm1, xmm7);              /* xmm7 = -- -- -- -- -- -- 61 -- */ \
-    \
-    pslldq_i2r(2, xmm6);               /* xmm6 = 16 -- -- -- -- -- -- -- */ \
-    psrldq_i2r(14, xmm2);              /* xmm2 = -- -- -- -- -- -- -- 17 */ \
-    \
-    pxor_r2r(xmm7, xmm1);              /* xmm1 = 67 66 65 64 63 62 -- -- */ \
-    pslldq_i2r(12, xmm7);              /* xmm7 = 61 -- -- -- -- -- -- -- */ \
-    \
-    psrldq_i2r(14, xmm6);              /* xmm6 = -- -- -- -- -- -- -- 16 */ \
-    por_r2r(xmm6, xmm4);               /* xmm4 = -- -- -- 47 -- -- 20 16 */ \
-    \
-    por_r2r(xmm7, xmm0);               /* xmm0 = 61 57 46 40 30 21 15 06 */ \
-    movdqu_m2r(*(ecx), xmm6);          /* xmm6 = -- -- -- -- -- FF FF -- */ \
-    \
-    psrldq_i2r(2, xmm6);               /* xmm6 = -- -- -- -- -- -- FF FF */ \
-    movdqu_r2m(xmm0, *(eax+48));       /* write  61 57 46 40 30 21 15 06 */ \
-    /* 1, 2, 3, 4, 5 in use */\
-    movdqu_m2r(*(ecx), xmm0);          /* xmm0 = -- -- -- -- -- FF FF -- */ \
-    pand_r2r(xmm3, xmm6);              /* xmm6 = -- -- -- -- -- -- 31 -- */ \
-    \
-    movdqu_r2r(xmm3, xmm7);            /* xmm7 = 37 36 35 34 33 32 31 -- */ \
-    pxor_r2r(xmm6, xmm3);              /* xmm3 = 37 36 35 34 33 32 -- -- */ \
-    \
-    pslldq_i2r(2, xmm3);               /* xmm3 = 36 35 34 33 32 -- -- -- */ \
-    pand_r2r(xmm1, xmm0);              /* xmm0 = -- -- -- -- -- 62 -- -- */ \
-    \
-    psrldq_i2r(14, xmm7);              /* xmm7 = -- -- -- -- -- -- -- 37 */ \
-    pxor_r2r(xmm0, xmm1);              /* xmm1 = 67 66 65 64 63 -- -- -- */ \
-    \
-    por_r2r(xmm7, xmm6);               /* xmm6 = -- -- -- -- -- -- 31 37 */ \
-    movdqu_m2r(*(ecx + 64), xmm7);     /* xmm7 = -- -- -- FF FF -- -- -- */ \
-    \
-    pshuflw_r2r(xmm6, xmm6, 0x01E);    /* xmm6 = -- -- -- -- 37 31 -- -- */ \
-    pslldq_i2r(6, xmm7);               /* xmm7 = FF FF -- -- -- -- -- -- */ \
-    \
-    por_r2r(xmm6, xmm4);               /* xmm4 = -- -- -- 47 37 31 20 16 */ \
-    pand_r2r(xmm5, xmm7);              /* xmm7 = -- 56 -- -- -- -- -- -- */ \
-    \
-    pslldq_i2r(8, xmm0);               /* xmm0 = -- 62 -- -- -- -- -- -- */ \
-    pxor_r2r(xmm7, xmm5);              /* xmm5 = -- -- 55 54 53 52 51 50 */ \
-    \
-    psrldq_i2r(2, xmm7);               /* xmm7 = -- -- 56 -- -- -- -- -- */ \
-    \
-    pshufhw_r2r(xmm3, xmm3, 0x087);    /* xmm3 = 35 33 34 36 32 -- -- -- */ \
-    por_r2r(xmm7, xmm0);               /* xmm0 = -- 62 56 -- -- -- -- -- */ \
-    \
-    movdqu_m2r(*(eax + 112), xmm7);    /* xmm7 = 77 76 75 74 73 72 71 70 */ \
-    pmullw_m2r(*(ebx + 112), xmm7);     \
-    \
-    movdqu_m2r(*(ecx + 64), xmm6);     /* xmm6 = -- -- -- FF FF -- -- -- */ \
-    por_r2r(xmm0, xmm4);               /* xmm4 = -- 62 56 47 37 31 20 16 */ \
-    \
-    pshuflw_r2r(xmm7, xmm7, 0x0E1);    /* xmm7 = 77 76 75 74 73 72 70 71 */ \
-    psrldq_i2r(8, xmm6);               /* xmm6 = -- -- -- -- -- -- -- FF */ \
-    \
-    movdqu_m2r(*(ecx + 64), xmm0);     /* xmm0 = -- -- -- FF FF -- -- -- */ \
-    pand_r2r(xmm7, xmm6);              /* xmm6 = -- -- -- -- -- -- -- 71 */ \
-    \
-    pand_r2r(xmm3, xmm0);              /* xmm0 = -- -- -- 36 32 -- -- -- */ \
-    pxor_r2r(xmm6, xmm7);              /* xmm7 = 77 76 75 74 73 72 70 -- */ \
-    \
-    pxor_r2r(xmm0, xmm3);              /* xmm3 = 35 33 34 -- -- -- -- -- */ \
-    pslldq_i2r(14, xmm6);              /* xmm6 = 71 -- -- -- -- -- -- -- */ \
-    \
-    psrldq_i2r(4, xmm0);               /* xmm0 = -- -- -- -- -- 36 32 -- */ \
-    por_r2r(xmm6, xmm4);               /* xmm4 = 71 62 56 47 37 31 20 16 */ \
-    \
-    por_r2r(xmm0, xmm2);               /* xmm2 = -- -- -- -- -- 36 32 17 */ \
-    movdqu_r2m(xmm4, *(eax + 64));     /* write  71 62 56 47 37 31 20 16 */ \
-    /* 1, 2, 3, 5, 7 in use */ \
-    movdqu_m2r(*(ecx + 80), xmm6);     /* xmm6 = -- -- FF -- -- -- -- FF */ \
-    pshufhw_r2r(xmm7, xmm7, 0x0D2);    /* xmm7 = 77 75 74 76 73 72 70 __ */ \
-    \
-    movdqu_m2r(*(ecx), xmm4);          /* xmm4 = -- -- -- -- -- FF FF -- */ \
-    movdqu_m2r(*(ecx+48), xmm0);       /* xmm0 = -- -- -- -- FF -- -- -- */ \
-    \
-    pand_r2r(xmm5, xmm6);              /* xmm6 = -- -- 55 -- -- -- -- 50 */ \
-    pand_r2r(xmm7, xmm4);              /* xmm4 = -- -- -- -- -- 72 70 -- */ \
-    \
-    pand_r2r(xmm1, xmm0);              /* xmm0 = -- -- -- -- 63 -- -- -- */ \
-    pxor_r2r(xmm6, xmm5);              /* xmm5 = -- -- -- 54 53 52 51 -- */ \
-    \
-    pxor_r2r(xmm4, xmm7);              /* xmm7 = 77 75 74 76 73 -- -- -- */ \
-    pxor_r2r(xmm0, xmm1);              /* xmm1 = 67 66 65 64 -- -- -- -- */ \
-    \
-    pshuflw_r2r(xmm6, xmm6, 0x02B);    /* xmm6 = -- -- 55 -- 50 -- -- -- */ \
-    pslldq_i2r(10, xmm4);              /* xmm4 = 72 20 -- -- -- -- -- -- */ \
-    \
-    pshufhw_r2r(xmm6, xmm6, 0x0B1);    /* xmm6 = -- -- -- 55 50 -- -- -- */ \
-    pslldq_i2r(4, xmm0);               /* xmm0 = -- -- 63 -- -- -- -- -- */ \
-    \
-    por_r2r(xmm4, xmm6);               /* xmm6 = 72 70 -- 55 50 -- -- -- */ \
-    por_r2r(xmm0, xmm2);               /* xmm2 = -- -- 63 -- -- 36 32 17 */ \
-    \
-    por_r2r(xmm6, xmm2);               /* xmm2 = 72 70 64 55 50 36 32 17 */ \
-    pshufhw_r2r(xmm1, xmm1, 0x0C9);    /* xmm1 = 67 64 66 65 -- -- -- -- */ \
-    \
-    movdqu_r2r(xmm3, xmm6);            /* xmm6 = 35 33 34 -- -- -- -- -- */ \
-    movdqu_r2m(xmm2, *(eax+80));       /* write  72 70 64 55 50 36 32 17 */ \
-    \
-    psrldq_i2r(12, xmm6);              /* xmm6 = -- -- -- -- -- -- 35 33 */ \
-    pslldq_i2r(4, xmm3);               /* xmm3 = 34 -- -- -- -- -- -- -- */ \
-    \
-    pshuflw_r2r(xmm5, xmm5, 0x04E);    /* xmm5 = -- -- -- 54 51 -- 53 52 */ \
-    movdqu_r2r(xmm7, xmm4);            /* xmm4 = 77 75 74 76 73 -- -- -- */ \
-    \
-    movdqu_r2r(xmm5, xmm2);            /* xmm2 = -- -- -- 54 51 -- 53 52 */ \
-    psrldq_i2r(10, xmm7);              /* xmm7 = -- -- -- -- -- 77 75 74 */ \
-    \
-    pslldq_i2r(6, xmm4);               /* xmm4 = 76 73 -- -- -- -- -- -- */ \
-    pslldq_i2r(12, xmm2);              /* xmm2 = 53 52 -- -- -- -- -- -- */ \
-    \
-    movdqu_r2r(xmm1, xmm0);            /* xmm0 = 67 64 66 65 -- -- -- -- */ \
-    psrldq_i2r(12, xmm1);              /* xmm1 = -- -- -- -- -- -- 67 64 */ \
-    \
-    psrldq_i2r(6, xmm5);               /* xmm5 = -- -- -- -- -- -- 54 51 */ \
-    psrldq_i2r(14, xmm3);              /* xmm3 = -- -- -- -- -- -- -- 34 */ \
-    \
-    pslldq_i2r(10, xmm7);              /* xmm7 = 77 75 74 -- -- -- -- -- */ \
-    por_r2r(xmm6, xmm4);               /* xmm4 = 76 73 -- -- -- -- 35 33 */ \
-    \
-    psrldq_i2r(10, xmm2);              /* xmm2 = -- -- -- -- -- 53 52 -- */ \
-    pslldq_i2r(4, xmm0);               /* xmm0 = 66 65 -- -- -- -- -- -- */ \
-    \
-    pslldq_i2r(8, xmm1);               /* xmm1 = -- -- 67 64 -- -- -- -- */ \
-    por_r2r(xmm7, xmm3);               /* xmm3 = 77 75 74 -- -- -- -- 34 */ \
-    \
-    psrldq_i2r(6, xmm0);               /* xmm0 = -- -- -- 66 65 -- -- -- */ \
-    pslldq_i2r(4, xmm5);               /* xmm5 = -- -- -- -- 54 51 -- -- */ \
-    \
-    por_r2r(xmm1, xmm4);               /* xmm4 = 76 73 67 64 -- -- 35 33 */ \
-    por_r2r(xmm2, xmm3);               /* xmm3 = 77 75 74 -- -- 53 52 34 */ \
-    \
-    por_r2r(xmm5, xmm4);               /* xmm4 = 76 73 67 64 54 51 35 33 */ \
-    por_r2r(xmm0, xmm3);               /* xmm3 = 77 75 74 66 65 53 52 34 */ \
-    \
-    movdqu_r2m(xmm4, *(eax+96));       /* write  76 73 67 64 54 51 35 33 */ \
-    movdqu_r2m(xmm3, *(eax+112));      /* write  77 75 74 66 65 53 52 34 */ \
-    \
-} /* end of SSE2_Dequantize Macro */
-
-
-void ff_vp3_idct_sse2(int16_t *input_data)
-{
-    unsigned char *input_bytes = (unsigned char *)input_data;
-    unsigned char *output_data_bytes = (unsigned char *)input_data;
-    unsigned char *idct_data_bytes = (unsigned char *)SSE2_idct_data;
-    unsigned char *Eight = (unsigned char *)eight_data;
-
-#define eax input_bytes
-//#define ebx dequant_matrix_bytes
-#define ecx dequant_const_bytes
-#define edx idct_data_bytes
-
-#define I(i) (eax + 16 * i)
-#define O(i) (ebx + 16 * i)
-#define C(i) (edx + 16 * (i-1))
-
- //   SSE2_Dequantize();
-
-#undef ebx
-#define ebx output_data_bytes
-
-    SSE2_Row_IDCT();
-
-    SSE2_Transpose();
-        
-    SSE2_Column_IDCT();
-}
diff --git a/ffmpeg.src/libavcodec/imgconvert.c b/ffmpeg.src/libavcodec/imgconvert.c
deleted file mode 100644
index afb66fa..0000000
--- a/ffmpeg.src/libavcodec/imgconvert.c
+++ /dev/null
@@ -1,2495 +0,0 @@
-/*
- * Misc image convertion routines
- * Copyright (c) 2001, 2002, 2003 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file imgconvert.c
- * Misc image convertion routines.
- */
-
-/* TODO:
- * - write 'ffimg' program to test all the image related stuff
- * - move all api to slice based system
- * - integrate deinterlacing, postprocessing and scaling in the conversion process
- */
-
-#include "avcodec.h"
-#include "dsputil.h"
-
-#ifdef USE_FASTMEMCPY
-#include "fastmemcpy.h"
-#endif
-
-#ifdef HAVE_MMX
-#include "i386/mmx.h"
-#endif
-
-#define xglue(x, y) x ## y
-#define glue(x, y) xglue(x, y)
-
-#define FF_COLOR_RGB      0 /* RGB color space */
-#define FF_COLOR_GRAY     1 /* gray color space */
-#define FF_COLOR_YUV      2 /* YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */
-#define FF_COLOR_YUV_JPEG 3 /* YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */
-
-#define FF_PIXEL_PLANAR   0 /* each channel has one component in AVPicture */
-#define FF_PIXEL_PACKED   1 /* only one components containing all the channels */
-#define FF_PIXEL_PALETTE  2  /* one components containing indexes for a palette */
-
-typedef struct PixFmtInfo {
-    const char *name;
-    uint8_t nb_channels;     /* number of channels (including alpha) */
-    uint8_t color_type;      /* color type (see FF_COLOR_xxx constants) */
-    uint8_t pixel_type;      /* pixel storage type (see FF_PIXEL_xxx constants) */
-    uint8_t is_alpha : 1;    /* true if alpha can be specified */
-    uint8_t x_chroma_shift;  /* X chroma subsampling factor is 2 ^ shift */
-    uint8_t y_chroma_shift;  /* Y chroma subsampling factor is 2 ^ shift */
-    uint8_t depth;           /* bit depth of the color components */
-} PixFmtInfo;
-
-/* this table gives more information about formats */
-static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
-    /* YUV formats */
-    [PIX_FMT_YUV420P] = {
-        .name = "yuv420p",
-        .nb_channels = 3,
-        .color_type = FF_COLOR_YUV,
-        .pixel_type = FF_PIXEL_PLANAR,
-        .depth = 8,
-        .x_chroma_shift = 1, .y_chroma_shift = 1, 
-    },
-    [PIX_FMT_YUV422P] = {
-        .name = "yuv422p",
-        .nb_channels = 3,
-        .color_type = FF_COLOR_YUV,
-        .pixel_type = FF_PIXEL_PLANAR,
-        .depth = 8,
-        .x_chroma_shift = 1, .y_chroma_shift = 0, 
-    },
-    [PIX_FMT_YUV444P] = {
-        .name = "yuv444p",
-        .nb_channels = 3,
-        .color_type = FF_COLOR_YUV,
-        .pixel_type = FF_PIXEL_PLANAR,
-        .depth = 8,
-        .x_chroma_shift = 0, .y_chroma_shift = 0, 
-    },
-    [PIX_FMT_YUV422] = {
-        .name = "yuv422",
-        .nb_channels = 1,
-        .color_type = FF_COLOR_YUV,
-        .pixel_type = FF_PIXEL_PACKED,
-        .depth = 8,
-        .x_chroma_shift = 1, .y_chroma_shift = 0,
-    },
-    [PIX_FMT_UYVY422] = {
-        .name = "uyvy422",
-        .nb_channels = 1,
-        .color_type = FF_COLOR_YUV,
-        .pixel_type = FF_PIXEL_PACKED,
-        .depth = 8,
-        .x_chroma_shift = 1, .y_chroma_shift = 0,
-    },
-    [PIX_FMT_YUV410P] = {
-        .name = "yuv410p",
-        .nb_channels = 3,
-        .color_type = FF_COLOR_YUV,
-        .pixel_type = FF_PIXEL_PLANAR,
-        .depth = 8,
-        .x_chroma_shift = 2, .y_chroma_shift = 2,
-    },
-    [PIX_FMT_YUV411P] = {
-        .name = "yuv411p",
-        .nb_channels = 3,
-        .color_type = FF_COLOR_YUV,
-        .pixel_type = FF_PIXEL_PLANAR,
-        .depth = 8,
-        .x_chroma_shift = 2, .y_chroma_shift = 0,
-    },
-
-    /* JPEG YUV */
-    [PIX_FMT_YUVJ420P] = {
-        .name = "yuvj420p",
-        .nb_channels = 3,
-        .color_type = FF_COLOR_YUV_JPEG,
-        .pixel_type = FF_PIXEL_PLANAR,
-        .depth = 8,
-        .x_chroma_shift = 1, .y_chroma_shift = 1, 
-    },
-    [PIX_FMT_YUVJ422P] = {
-        .name = "yuvj422p",
-        .nb_channels = 3,
-        .color_type = FF_COLOR_YUV_JPEG,
-        .pixel_type = FF_PIXEL_PLANAR,
-        .depth = 8,
-        .x_chroma_shift = 1, .y_chroma_shift = 0, 
-    },
-    [PIX_FMT_YUVJ444P] = {
-        .name = "yuvj444p",
-        .nb_channels = 3,
-        .color_type = FF_COLOR_YUV_JPEG,
-        .pixel_type = FF_PIXEL_PLANAR,
-        .depth = 8,
-        .x_chroma_shift = 0, .y_chroma_shift = 0, 
-    },
-
-    /* RGB formats */
-    [PIX_FMT_RGB24] = {
-        .name = "rgb24",
-        .nb_channels = 3,
-        .color_type = FF_COLOR_RGB,
-        .pixel_type = FF_PIXEL_PACKED,
-        .depth = 8,
-        .x_chroma_shift = 0, .y_chroma_shift = 0,
-    },
-    [PIX_FMT_BGR24] = {
-        .name = "bgr24",
-        .nb_channels = 3,
-        .color_type = FF_COLOR_RGB,
-        .pixel_type = FF_PIXEL_PACKED,
-        .depth = 8,
-        .x_chroma_shift = 0, .y_chroma_shift = 0,
-    },
-    [PIX_FMT_RGBA32] = {
-        .name = "rgba32",
-        .nb_channels = 4, .is_alpha = 1,
-        .color_type = FF_COLOR_RGB,
-        .pixel_type = FF_PIXEL_PACKED,
-        .depth = 8,
-        .x_chroma_shift = 0, .y_chroma_shift = 0,
-    },
-    [PIX_FMT_RGB565] = {
-        .name = "rgb565",
-        .nb_channels = 3,
-        .color_type = FF_COLOR_RGB,
-        .pixel_type = FF_PIXEL_PACKED,
-        .depth = 5,
-        .x_chroma_shift = 0, .y_chroma_shift = 0,
-    },
-    [PIX_FMT_RGB555] = {
-        .name = "rgb555",
-        .nb_channels = 4, .is_alpha = 1,
-        .color_type = FF_COLOR_RGB,
-        .pixel_type = FF_PIXEL_PACKED,
-        .depth = 5,
-        .x_chroma_shift = 0, .y_chroma_shift = 0,
-    },
-
-    /* gray / mono formats */
-    [PIX_FMT_GRAY8] = {
-        .name = "gray",
-        .nb_channels = 1,
-        .color_type = FF_COLOR_GRAY,
-        .pixel_type = FF_PIXEL_PLANAR,
-        .depth = 8,
-    },
-    [PIX_FMT_MONOWHITE] = {
-        .name = "monow",
-        .nb_channels = 1,
-        .color_type = FF_COLOR_GRAY,
-        .pixel_type = FF_PIXEL_PLANAR,
-        .depth = 1,
-    },
-    [PIX_FMT_MONOBLACK] = {
-        .name = "monob",
-        .nb_channels = 1,
-        .color_type = FF_COLOR_GRAY,
-        .pixel_type = FF_PIXEL_PLANAR,
-        .depth = 1,
-    },
-
-    /* paletted formats */
-    [PIX_FMT_PAL8] = {
-        .name = "pal8",
-        .nb_channels = 4, .is_alpha = 1,
-        .color_type = FF_COLOR_RGB,
-        .pixel_type = FF_PIXEL_PALETTE,
-        .depth = 8,
-    },
-    [PIX_FMT_XVMC_MPEG2_MC] = {
-        .name = "xvmcmc",
-    },
-    [PIX_FMT_XVMC_MPEG2_IDCT] = {
-        .name = "xvmcidct",
-    },
-    [PIX_FMT_UYVY411] = {
-        .name = "uyvy411",
-        .nb_channels = 1,
-        .color_type = FF_COLOR_YUV,
-        .pixel_type = FF_PIXEL_PACKED,
-        .depth = 8,
-        .x_chroma_shift = 2, .y_chroma_shift = 0,
-    },
-};
-
-void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift)
-{
-    *h_shift = pix_fmt_info[pix_fmt].x_chroma_shift;
-    *v_shift = pix_fmt_info[pix_fmt].y_chroma_shift;
-}
-
-const char *avcodec_get_pix_fmt_name(int pix_fmt)
-{
-    if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB)
-        return "???";
-    else
-        return pix_fmt_info[pix_fmt].name;
-}
-
-enum PixelFormat avcodec_get_pix_fmt(const char* name)
-{
-    int i; 
-    
-    for (i=0; i < PIX_FMT_NB; i++)
-         if (!strcmp(pix_fmt_info[i].name, name))
-	     break;
-    return i;
-}
-
-/* Picture field are filled with 'ptr' addresses. Also return size */
-int avpicture_fill(AVPicture *picture, uint8_t *ptr,
-		   int pix_fmt, int width, int height)
-{
-    int size, w2, h2, size2;
-    PixFmtInfo *pinfo;
-    
-    if(avcodec_check_dimensions(NULL, width, height))
-        goto fail;
-
-    pinfo = &pix_fmt_info[pix_fmt];
-    size = width * height;
-    switch(pix_fmt) {
-    case PIX_FMT_YUV420P:
-    case PIX_FMT_YUV422P:
-    case PIX_FMT_YUV444P:
-    case PIX_FMT_YUV410P:
-    case PIX_FMT_YUV411P:
-    case PIX_FMT_YUVJ420P:
-    case PIX_FMT_YUVJ422P:
-    case PIX_FMT_YUVJ444P:
-        w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift;
-        h2 = (height + (1 << pinfo->y_chroma_shift) - 1) >> pinfo->y_chroma_shift;
-        size2 = w2 * h2;
-        picture->data[0] = ptr;
-        picture->data[1] = picture->data[0] + size;
-        picture->data[2] = picture->data[1] + size2;
-        picture->linesize[0] = width;
-        picture->linesize[1] = w2;
-        picture->linesize[2] = w2;
-        return size + 2 * size2;
-    case PIX_FMT_RGB24:
-    case PIX_FMT_BGR24:
-        picture->data[0] = ptr;
-        picture->data[1] = NULL;
-        picture->data[2] = NULL;
-        picture->linesize[0] = width * 3;
-        return size * 3;
-    case PIX_FMT_RGBA32:
-        picture->data[0] = ptr;
-        picture->data[1] = NULL;
-        picture->data[2] = NULL;
-        picture->linesize[0] = width * 4;
-        return size * 4;
-    case PIX_FMT_RGB555:
-    case PIX_FMT_RGB565:
-    case PIX_FMT_YUV422:
-        picture->data[0] = ptr;
-        picture->data[1] = NULL;
-        picture->data[2] = NULL;
-        picture->linesize[0] = width * 2;
-        return size * 2;
-    case PIX_FMT_UYVY422:
-        picture->data[0] = ptr;
-        picture->data[1] = NULL;
-        picture->data[2] = NULL;
-        picture->linesize[0] = width * 2;
-        return size * 2;
-    case PIX_FMT_UYVY411:
-        picture->data[0] = ptr;
-        picture->data[1] = NULL;
-        picture->data[2] = NULL;
-        picture->linesize[0] = width + width/2;
-        return size + size/2;
-    case PIX_FMT_GRAY8:
-        picture->data[0] = ptr;
-        picture->data[1] = NULL;
-        picture->data[2] = NULL;
-        picture->linesize[0] = width;
-        return size;
-    case PIX_FMT_MONOWHITE:
-    case PIX_FMT_MONOBLACK:
-        picture->data[0] = ptr;
-        picture->data[1] = NULL;
-        picture->data[2] = NULL;
-        picture->linesize[0] = (width + 7) >> 3;
-        return picture->linesize[0] * height;
-    case PIX_FMT_PAL8:
-        size2 = (size + 3) & ~3;
-        picture->data[0] = ptr;
-        picture->data[1] = ptr + size2; /* palette is stored here as 256 32 bit words */
-        picture->data[2] = NULL;
-        picture->linesize[0] = width;
-        picture->linesize[1] = 4;
-        return size2 + 256 * 4;
-    default:
-fail:
-        picture->data[0] = NULL;
-        picture->data[1] = NULL;
-        picture->data[2] = NULL;
-        picture->data[3] = NULL;
-        return -1;
-    }
-}
-
-int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
-                     unsigned char *dest, int dest_size)
-{
-    PixFmtInfo* pf = &pix_fmt_info[pix_fmt];
-    int i, j, w, h, data_planes;
-    const unsigned char* s; 
-    int size = avpicture_get_size(pix_fmt, width, height);
-
-    if (size > dest_size || size < 0)
-        return -1;
-
-    if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) {
-        if (pix_fmt == PIX_FMT_YUV422 || 
-            pix_fmt == PIX_FMT_UYVY422 || 
-            pix_fmt == PIX_FMT_RGB565 ||
-            pix_fmt == PIX_FMT_RGB555)
-            w = width * 2;
-	else if (pix_fmt == PIX_FMT_UYVY411)
-	  w = width + width/2;
-	else if (pix_fmt == PIX_FMT_PAL8)
-	  w = width;
-	else
-	  w = width * (pf->depth * pf->nb_channels / 8);
-	  
-	data_planes = 1;
-	h = height;
-    } else {
-        data_planes = pf->nb_channels;
-	w = (width*pf->depth + 7)/8;
-	h = height;
-    }
-    
-    for (i=0; i<data_planes; i++) {
-         if (i == 1) {
-	     w = width >> pf->x_chroma_shift;
-	     h = height >> pf->y_chroma_shift;
-	 }
-         s = src->data[i];
-	 for(j=0; j<h; j++) {
-	     memcpy(dest, s, w);
-	     dest += w;
-	     s += src->linesize[i];
-	 }
-    }
-    
-    if (pf->pixel_type == FF_PIXEL_PALETTE)
-	memcpy((unsigned char *)(((size_t)dest + 3) & ~3), src->data[1], 256 * 4);
-    
-    return size;
-}
-
-int avpicture_get_size(int pix_fmt, int width, int height)
-{
-    AVPicture dummy_pict;
-    return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height);
-}
-
-/**
- * compute the loss when converting from a pixel format to another 
- */
-int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
-                             int has_alpha)
-{
-    const PixFmtInfo *pf, *ps;
-    int loss;
-
-    ps = &pix_fmt_info[src_pix_fmt];
-    pf = &pix_fmt_info[dst_pix_fmt];
-
-    /* compute loss */
-    loss = 0;
-    pf = &pix_fmt_info[dst_pix_fmt];
-    if (pf->depth < ps->depth ||
-        (dst_pix_fmt == PIX_FMT_RGB555 && src_pix_fmt == PIX_FMT_RGB565))
-        loss |= FF_LOSS_DEPTH;
-    if (pf->x_chroma_shift > ps->x_chroma_shift ||
-        pf->y_chroma_shift > ps->y_chroma_shift)
-        loss |= FF_LOSS_RESOLUTION;
-    switch(pf->color_type) {
-    case FF_COLOR_RGB:
-        if (ps->color_type != FF_COLOR_RGB &&
-            ps->color_type != FF_COLOR_GRAY)
-            loss |= FF_LOSS_COLORSPACE;
-        break;
-    case FF_COLOR_GRAY:
-        if (ps->color_type != FF_COLOR_GRAY)
-            loss |= FF_LOSS_COLORSPACE;
-        break;
-    case FF_COLOR_YUV:
-        if (ps->color_type != FF_COLOR_YUV)
-            loss |= FF_LOSS_COLORSPACE;
-        break;
-    case FF_COLOR_YUV_JPEG:
-        if (ps->color_type != FF_COLOR_YUV_JPEG &&
-            ps->color_type != FF_COLOR_YUV && 
-            ps->color_type != FF_COLOR_GRAY)
-            loss |= FF_LOSS_COLORSPACE;
-        break;
-    default:
-        /* fail safe test */
-        if (ps->color_type != pf->color_type)
-            loss |= FF_LOSS_COLORSPACE;
-        break;
-    }
-    if (pf->color_type == FF_COLOR_GRAY &&
-        ps->color_type != FF_COLOR_GRAY)
-        loss |= FF_LOSS_CHROMA;
-    if (!pf->is_alpha && (ps->is_alpha && has_alpha))
-        loss |= FF_LOSS_ALPHA;
-    if (pf->pixel_type == FF_PIXEL_PALETTE && 
-        (ps->pixel_type != FF_PIXEL_PALETTE && ps->color_type != FF_COLOR_GRAY))
-        loss |= FF_LOSS_COLORQUANT;
-    return loss;
-}
-
-static int avg_bits_per_pixel(int pix_fmt)
-{
-    int bits;
-    const PixFmtInfo *pf;
-
-    pf = &pix_fmt_info[pix_fmt];
-    switch(pf->pixel_type) {
-    case FF_PIXEL_PACKED:
-        switch(pix_fmt) {
-        case PIX_FMT_YUV422:
-        case PIX_FMT_UYVY422:
-        case PIX_FMT_RGB565:
-        case PIX_FMT_RGB555:
-            bits = 16;
-            break;
-	case PIX_FMT_UYVY411:
-	    bits = 12;
-	    break;
-        default:
-            bits = pf->depth * pf->nb_channels;
-            break;
-        }
-        break;
-    case FF_PIXEL_PLANAR:
-        if (pf->x_chroma_shift == 0 && pf->y_chroma_shift == 0) {
-            bits = pf->depth * pf->nb_channels;
-        } else {
-            bits = pf->depth + ((2 * pf->depth) >> 
-                                (pf->x_chroma_shift + pf->y_chroma_shift));
-        }
-        break;
-    case FF_PIXEL_PALETTE:
-        bits = 8;
-        break;
-    default:
-        bits = -1;
-        break;
-    }
-    return bits;
-}
-
-static int avcodec_find_best_pix_fmt1(int pix_fmt_mask, 
-                                      int src_pix_fmt,
-                                      int has_alpha,
-                                      int loss_mask)
-{
-    int dist, i, loss, min_dist, dst_pix_fmt;
-
-    /* find exact color match with smallest size */
-    dst_pix_fmt = -1;
-    min_dist = 0x7fffffff;
-    for(i = 0;i < PIX_FMT_NB; i++) {
-        if (pix_fmt_mask & (1 << i)) {
-            loss = avcodec_get_pix_fmt_loss(i, src_pix_fmt, has_alpha) & loss_mask;
-            if (loss == 0) {
-                dist = avg_bits_per_pixel(i);
-                if (dist < min_dist) {
-                    min_dist = dist;
-                    dst_pix_fmt = i;
-                }
-            }
-        }
-    }
-    return dst_pix_fmt;
-}
-
-/** 
- * find best pixel format to convert to. Return -1 if none found 
- */
-int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
-                              int has_alpha, int *loss_ptr)
-{
-    int dst_pix_fmt, loss_mask, i;
-    static const int loss_mask_order[] = {
-        ~0, /* no loss first */
-        ~FF_LOSS_ALPHA,
-        ~FF_LOSS_RESOLUTION,
-        ~(FF_LOSS_COLORSPACE | FF_LOSS_RESOLUTION),
-        ~FF_LOSS_COLORQUANT,
-        ~FF_LOSS_DEPTH,
-        0,
-    };
-
-    /* try with successive loss */
-    i = 0;
-    for(;;) {
-        loss_mask = loss_mask_order[i++];
-        dst_pix_fmt = avcodec_find_best_pix_fmt1(pix_fmt_mask, src_pix_fmt, 
-                                                 has_alpha, loss_mask);
-        if (dst_pix_fmt >= 0)
-            goto found;
-        if (loss_mask == 0)
-            break;
-    }
-    return -1;
- found:
-    if (loss_ptr)
-        *loss_ptr = avcodec_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha);
-    return dst_pix_fmt;
-}
-
-static void img_copy_plane(uint8_t *dst, int dst_wrap, 
-                           const uint8_t *src, int src_wrap,
-                           int width, int height)
-{
-    if((!dst) || (!src)) 
-        return;
-    for(;height > 0; height--) {
-        memcpy(dst, src, width);
-        dst += dst_wrap;
-        src += src_wrap;
-    }
-}
-
-/**
- * Copy image 'src' to 'dst'.
- */
-void img_copy(AVPicture *dst, const AVPicture *src,
-              int pix_fmt, int width, int height)
-{
-    int bwidth, bits, i;
-    PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
-    
-    pf = &pix_fmt_info[pix_fmt];
-    switch(pf->pixel_type) {
-    case FF_PIXEL_PACKED:
-        switch(pix_fmt) {
-        case PIX_FMT_YUV422:
-        case PIX_FMT_UYVY422:
-        case PIX_FMT_RGB565:
-        case PIX_FMT_RGB555:
-            bits = 16;
-            break;
-	case PIX_FMT_UYVY411:
-	    bits = 12;
-	    break;
-        default:
-            bits = pf->depth * pf->nb_channels;
-            break;
-        }
-        bwidth = (width * bits + 7) >> 3;
-        img_copy_plane(dst->data[0], dst->linesize[0],
-                       src->data[0], src->linesize[0],
-                       bwidth, height);
-        break;
-    case FF_PIXEL_PLANAR:
-        for(i = 0; i < pf->nb_channels; i++) {
-            int w, h;
-            w = width;
-            h = height;
-            if (i == 1 || i == 2) {
-                w >>= pf->x_chroma_shift;
-                h >>= pf->y_chroma_shift;
-            }
-            bwidth = (w * pf->depth + 7) >> 3;
-            img_copy_plane(dst->data[i], dst->linesize[i],
-                           src->data[i], src->linesize[i],
-                           bwidth, h);
-        }
-        break;
-    case FF_PIXEL_PALETTE:
-        img_copy_plane(dst->data[0], dst->linesize[0],
-                       src->data[0], src->linesize[0],
-                       width, height);
-        /* copy the palette */
-        img_copy_plane(dst->data[1], dst->linesize[1],
-                       src->data[1], src->linesize[1],
-                       4, 256);
-        break;
-    }
-}
-
-/* XXX: totally non optimized */
-
-static void yuv422_to_yuv420p(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    const uint8_t *p, *p1;
-    uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
-    int w;
- 
-    p1 = src->data[0];
-    lum1 = dst->data[0];
-    cb1 = dst->data[1];
-    cr1 = dst->data[2];
-
-    for(;height >= 1; height -= 2) {
-        p = p1;
-        lum = lum1;
-        cb = cb1;
-        cr = cr1;
-        for(w = width; w >= 2; w -= 2) {
-            lum[0] = p[0];
-            cb[0] = p[1];
-            lum[1] = p[2];
-            cr[0] = p[3];
-            p += 4;
-            lum += 2;
-            cb++;
-            cr++;
-        }
-        if (w) {
-            lum[0] = p[0];
-            cb[0] = p[1];
-            cr[0] = p[3];
-            cb++;
-            cr++;
-        }
-        p1 += src->linesize[0];
-        lum1 += dst->linesize[0];
-        if (height>1) {
-            p = p1;
-            lum = lum1;
-            for(w = width; w >= 2; w -= 2) {
-                lum[0] = p[0];
-                lum[1] = p[2];
-                p += 4;
-                lum += 2;
-            }
-            if (w) {
-                lum[0] = p[0];
-            }
-            p1 += src->linesize[0];
-            lum1 += dst->linesize[0];
-        }
-        cb1 += dst->linesize[1];
-        cr1 += dst->linesize[2];
-    }
-}
-
-static void uyvy422_to_yuv420p(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    const uint8_t *p, *p1;
-    uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
-    int w;
- 
-    p1 = src->data[0];
-    
-    lum1 = dst->data[0];
-    cb1 = dst->data[1];
-    cr1 = dst->data[2];
-
-    for(;height >= 1; height -= 2) {
-        p = p1;
-        lum = lum1;
-        cb = cb1;
-        cr = cr1;
-        for(w = width; w >= 2; w -= 2) {
-            lum[0] = p[1];
-            cb[0] = p[0];
-            lum[1] = p[3];
-            cr[0] = p[2];
-            p += 4;
-            lum += 2;
-            cb++;
-            cr++;
-        }
-        if (w) {
-            lum[0] = p[1];
-            cb[0] = p[0];
-            cr[0] = p[2];
-            cb++;
-            cr++;
-        }
-        p1 += src->linesize[0];
-        lum1 += dst->linesize[0];
-        if (height>1) {
-            p = p1;
-            lum = lum1;
-            for(w = width; w >= 2; w -= 2) {
-                lum[0] = p[1];
-                lum[1] = p[3];
-                p += 4;
-                lum += 2;
-            }
-            if (w) {
-                lum[0] = p[1];
-            }
-            p1 += src->linesize[0];
-            lum1 += dst->linesize[0];
-        }
-        cb1 += dst->linesize[1];
-        cr1 += dst->linesize[2];
-    }
-}
-
-
-static void uyvy422_to_yuv422p(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    const uint8_t *p, *p1;
-    uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
-    int w;
-
-    p1 = src->data[0];
-    lum1 = dst->data[0];
-    cb1 = dst->data[1];
-    cr1 = dst->data[2];
-    for(;height > 0; height--) {
-        p = p1;
-        lum = lum1;
-        cb = cb1;
-        cr = cr1;
-        for(w = width; w >= 2; w -= 2) {
-            lum[0] = p[1];
-            cb[0] = p[0];
-            lum[1] = p[3];
-            cr[0] = p[2];
-            p += 4;
-            lum += 2;
-            cb++;
-            cr++;
-        }
-        p1 += src->linesize[0];
-        lum1 += dst->linesize[0];
-        cb1 += dst->linesize[1];
-        cr1 += dst->linesize[2];
-    }
-}
-
-
-static void yuv422_to_yuv422p(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    const uint8_t *p, *p1;
-    uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
-    int w;
-
-    p1 = src->data[0];
-    lum1 = dst->data[0];
-    cb1 = dst->data[1];
-    cr1 = dst->data[2];
-    for(;height > 0; height--) {
-        p = p1;
-        lum = lum1;
-        cb = cb1;
-        cr = cr1;
-        for(w = width; w >= 2; w -= 2) {
-            lum[0] = p[0];
-            cb[0] = p[1];
-            lum[1] = p[2];
-            cr[0] = p[3];
-            p += 4;
-            lum += 2;
-            cb++;
-            cr++;
-        }
-        p1 += src->linesize[0];
-        lum1 += dst->linesize[0];
-        cb1 += dst->linesize[1];
-        cr1 += dst->linesize[2];
-    }
-}
-
-static void yuv422p_to_yuv422(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    uint8_t *p, *p1;
-    const uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
-    int w;
-
-    p1 = dst->data[0];
-    lum1 = src->data[0];
-    cb1 = src->data[1];
-    cr1 = src->data[2];
-    for(;height > 0; height--) {
-        p = p1;
-        lum = lum1;
-        cb = cb1;
-        cr = cr1;
-        for(w = width; w >= 2; w -= 2) {
-            p[0] = lum[0];
-            p[1] = cb[0];
-            p[2] = lum[1];
-            p[3] = cr[0];
-            p += 4;
-            lum += 2;
-            cb++;
-            cr++;
-        }
-        p1 += dst->linesize[0];
-        lum1 += src->linesize[0];
-        cb1 += src->linesize[1];
-        cr1 += src->linesize[2];
-    }
-}
-
-static void yuv422p_to_uyvy422(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    uint8_t *p, *p1;
-    const uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
-    int w;
-
-    p1 = dst->data[0];
-    lum1 = src->data[0];
-    cb1 = src->data[1];
-    cr1 = src->data[2];
-    for(;height > 0; height--) {
-        p = p1;
-        lum = lum1;
-        cb = cb1;
-        cr = cr1;
-        for(w = width; w >= 2; w -= 2) {
-            p[1] = lum[0];
-            p[0] = cb[0];
-            p[3] = lum[1];
-            p[2] = cr[0];
-            p += 4;
-            lum += 2;
-            cb++;
-            cr++;
-        }
-        p1 += dst->linesize[0];
-        lum1 += src->linesize[0];
-        cb1 += src->linesize[1];
-        cr1 += src->linesize[2];
-    }
-}
-
-static void uyvy411_to_yuv411p(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    const uint8_t *p, *p1;
-    uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
-    int w;
-
-    p1 = src->data[0];
-    lum1 = dst->data[0];
-    cb1 = dst->data[1];
-    cr1 = dst->data[2];
-    for(;height > 0; height--) {
-        p = p1;
-        lum = lum1;
-        cb = cb1;
-        cr = cr1;
-        for(w = width; w >= 4; w -= 4) {
-            cb[0] = p[0];
-	    lum[0] = p[1];
-            lum[1] = p[2];
-            cr[0] = p[3];
-	    lum[2] = p[4];
-	    lum[3] = p[5];
-            p += 6;
-            lum += 4;
-            cb++;
-            cr++;
-        }
-        p1 += src->linesize[0];
-        lum1 += dst->linesize[0];
-        cb1 += dst->linesize[1];
-        cr1 += dst->linesize[2];
-    }
-}
-
-
-static void yuv420p_to_yuv422(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    int w, h;
-    uint8_t *line1, *line2, *linesrc = dst->data[0];
-    uint8_t *lum1, *lum2, *lumsrc = src->data[0];
-    uint8_t *cb1, *cb2 = src->data[1];
-    uint8_t *cr1, *cr2 = src->data[2];
-    
-    for(h = height / 2; h--;) {
-        line1 = linesrc;
-        line2 = linesrc + dst->linesize[0];
-        
-        lum1 = lumsrc;
-        lum2 = lumsrc + src->linesize[0];
-        
-        cb1 = cb2;
-        cr1 = cr2;
-        
-        for(w = width / 2; w--;) {
-                *line1++ = *lum1++; *line2++ = *lum2++;                     
-                *line1++ =          *line2++ = *cb1++;                      
-                *line1++ = *lum1++; *line2++ = *lum2++;                     
-                *line1++ =          *line2++ = *cr1++;
-        }
-        
-        linesrc += dst->linesize[0] * 2;
-        lumsrc += src->linesize[0] * 2;
-        cb2 += src->linesize[1];
-        cr2 += src->linesize[2];
-    }
-}
-
-static void yuv420p_to_uyvy422(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    int w, h;
-    uint8_t *line1, *line2, *linesrc = dst->data[0];
-    uint8_t *lum1, *lum2, *lumsrc = src->data[0];
-    uint8_t *cb1, *cb2 = src->data[1];
-    uint8_t *cr1, *cr2 = src->data[2];
-    
-    for(h = height / 2; h--;) {
-        line1 = linesrc;
-        line2 = linesrc + dst->linesize[0];
-        
-        lum1 = lumsrc;
-        lum2 = lumsrc + src->linesize[0];
-        
-        cb1 = cb2;
-        cr1 = cr2;
-        
-        for(w = width / 2; w--;) {
-                *line1++ =          *line2++ = *cb1++;                      
-                *line1++ = *lum1++; *line2++ = *lum2++;                     
-                *line1++ =          *line2++ = *cr1++;
-                *line1++ = *lum1++; *line2++ = *lum2++;                     
-        }
-        
-        linesrc += dst->linesize[0] * 2;
-        lumsrc += src->linesize[0] * 2;
-        cb2 += src->linesize[1];
-        cr2 += src->linesize[2];
-    }
-}
-
-#define SCALEBITS 10
-#define ONE_HALF  (1 << (SCALEBITS - 1))
-#define FIX(x)	  ((int) ((x) * (1<<SCALEBITS) + 0.5))
-
-#define YUV_TO_RGB1_CCIR(cb1, cr1)\
-{\
-    cb = (cb1) - 128;\
-    cr = (cr1) - 128;\
-    r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;\
-    g_add = - FIX(0.34414*255.0/224.0) * cb - FIX(0.71414*255.0/224.0) * cr + \
-            ONE_HALF;\
-    b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;\
-}
-
-#define YUV_TO_RGB2_CCIR(r, g, b, y1)\
-{\
-    y = ((y1) - 16) * FIX(255.0/219.0);\
-    r = cm[(y + r_add) >> SCALEBITS];\
-    g = cm[(y + g_add) >> SCALEBITS];\
-    b = cm[(y + b_add) >> SCALEBITS];\
-}
-
-#define YUV_TO_RGB1(cb1, cr1)\
-{\
-    cb = (cb1) - 128;\
-    cr = (cr1) - 128;\
-    r_add = FIX(1.40200) * cr + ONE_HALF;\
-    g_add = - FIX(0.34414) * cb - FIX(0.71414) * cr + ONE_HALF;\
-    b_add = FIX(1.77200) * cb + ONE_HALF;\
-}
-
-#define YUV_TO_RGB2(r, g, b, y1)\
-{\
-    y = (y1) << SCALEBITS;\
-    r = cm[(y + r_add) >> SCALEBITS];\
-    g = cm[(y + g_add) >> SCALEBITS];\
-    b = cm[(y + b_add) >> SCALEBITS];\
-}
-
-#define Y_CCIR_TO_JPEG(y)\
- cm[((y) * FIX(255.0/219.0) + (ONE_HALF - 16 * FIX(255.0/219.0))) >> SCALEBITS]
-
-#define Y_JPEG_TO_CCIR(y)\
- (((y) * FIX(219.0/255.0) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
-
-#define C_CCIR_TO_JPEG(y)\
- cm[(((y) - 128) * FIX(127.0/112.0) + (ONE_HALF + (128 << SCALEBITS))) >> SCALEBITS]
-
-/* NOTE: the clamp is really necessary! */
-static inline int C_JPEG_TO_CCIR(int y) {
-    y = (((y - 128) * FIX(112.0/127.0) + (ONE_HALF + (128 << SCALEBITS))) >> SCALEBITS);
-    if (y < 16)
-	y = 16;
-    return y;
-}
-
-
-#define RGB_TO_Y(r, g, b) \
-((FIX(0.29900) * (r) + FIX(0.58700) * (g) + \
-  FIX(0.11400) * (b) + ONE_HALF) >> SCALEBITS)
-
-#define RGB_TO_U(r1, g1, b1, shift)\
-(((- FIX(0.16874) * r1 - FIX(0.33126) * g1 +         \
-     FIX(0.50000) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
-
-#define RGB_TO_V(r1, g1, b1, shift)\
-(((FIX(0.50000) * r1 - FIX(0.41869) * g1 -           \
-   FIX(0.08131) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
-
-#define RGB_TO_Y_CCIR(r, g, b) \
-((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
-  FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
-
-#define RGB_TO_U_CCIR(r1, g1, b1, shift)\
-(((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 +         \
-     FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
-
-#define RGB_TO_V_CCIR(r1, g1, b1, shift)\
-(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 -           \
-   FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
-
-static uint8_t y_ccir_to_jpeg[256];
-static uint8_t y_jpeg_to_ccir[256];
-static uint8_t c_ccir_to_jpeg[256];
-static uint8_t c_jpeg_to_ccir[256];
-
-/* init various conversion tables */
-static void img_convert_init(void)
-{
-    int i;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-    for(i = 0;i < 256; i++) {
-        y_ccir_to_jpeg[i] = Y_CCIR_TO_JPEG(i);
-        y_jpeg_to_ccir[i] = Y_JPEG_TO_CCIR(i);
-        c_ccir_to_jpeg[i] = C_CCIR_TO_JPEG(i);
-        c_jpeg_to_ccir[i] = C_JPEG_TO_CCIR(i);
-    }
-}
-
-/* apply to each pixel the given table */
-static void img_apply_table(uint8_t *dst, int dst_wrap, 
-                            const uint8_t *src, int src_wrap,
-                            int width, int height, const uint8_t *table1)
-{
-    int n;
-    const uint8_t *s;
-    uint8_t *d;
-    const uint8_t *table;
-
-    table = table1;
-    for(;height > 0; height--) {
-        s = src;
-        d = dst;
-        n = width;
-        while (n >= 4) {
-            d[0] = table[s[0]];
-            d[1] = table[s[1]];
-            d[2] = table[s[2]];
-            d[3] = table[s[3]];
-            d += 4;
-            s += 4;
-            n -= 4;
-        }
-        while (n > 0) {
-            d[0] = table[s[0]];
-            d++;
-            s++;
-            n--;
-        }
-        dst += dst_wrap;
-        src += src_wrap;
-    }
-}
-
-/* XXX: use generic filter ? */
-/* XXX: in most cases, the sampling position is incorrect */
-
-/* 4x1 -> 1x1 */
-static void shrink41(uint8_t *dst, int dst_wrap, 
-                     const uint8_t *src, int src_wrap,
-                     int width, int height)
-{
-    int w;
-    const uint8_t *s;
-    uint8_t *d;
-
-    for(;height > 0; height--) {
-        s = src;
-        d = dst;
-        for(w = width;w > 0; w--) {
-            d[0] = (s[0] + s[1] + s[2] + s[3] + 2) >> 2;
-            s += 4;
-            d++;
-        }
-        src += src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-/* 2x1 -> 1x1 */
-static void shrink21(uint8_t *dst, int dst_wrap, 
-                     const uint8_t *src, int src_wrap,
-                     int width, int height)
-{
-    int w;
-    const uint8_t *s;
-    uint8_t *d;
-
-    for(;height > 0; height--) {
-        s = src;
-        d = dst;
-        for(w = width;w > 0; w--) {
-            d[0] = (s[0] + s[1]) >> 1;
-            s += 2;
-            d++;
-        }
-        src += src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-/* 1x2 -> 1x1 */
-static void shrink12(uint8_t *dst, int dst_wrap, 
-                     const uint8_t *src, int src_wrap,
-                     int width, int height)
-{
-    int w;
-    uint8_t *d;
-    const uint8_t *s1, *s2;
-
-    for(;height > 0; height--) {
-        s1 = src;
-        s2 = s1 + src_wrap;
-        d = dst;
-        for(w = width;w >= 4; w-=4) {
-            d[0] = (s1[0] + s2[0]) >> 1;
-            d[1] = (s1[1] + s2[1]) >> 1;
-            d[2] = (s1[2] + s2[2]) >> 1;
-            d[3] = (s1[3] + s2[3]) >> 1;
-            s1 += 4;
-            s2 += 4;
-            d += 4;
-        }
-        for(;w > 0; w--) {
-            d[0] = (s1[0] + s2[0]) >> 1;
-            s1++;
-            s2++;
-            d++;
-        }
-        src += 2 * src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-/* 2x2 -> 1x1 */
-static void shrink22(uint8_t *dst, int dst_wrap, 
-                     const uint8_t *src, int src_wrap,
-                     int width, int height)
-{
-    int w;
-    const uint8_t *s1, *s2;
-    uint8_t *d;
-
-    for(;height > 0; height--) {
-        s1 = src;
-        s2 = s1 + src_wrap;
-        d = dst;
-        for(w = width;w >= 4; w-=4) {
-            d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
-            d[1] = (s1[2] + s1[3] + s2[2] + s2[3] + 2) >> 2;
-            d[2] = (s1[4] + s1[5] + s2[4] + s2[5] + 2) >> 2;
-            d[3] = (s1[6] + s1[7] + s2[6] + s2[7] + 2) >> 2;
-            s1 += 8;
-            s2 += 8;
-            d += 4;
-        }
-        for(;w > 0; w--) {
-            d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
-            s1 += 2;
-            s2 += 2;
-            d++;
-        }
-        src += 2 * src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-/* 4x4 -> 1x1 */
-static void shrink44(uint8_t *dst, int dst_wrap, 
-                     const uint8_t *src, int src_wrap,
-                     int width, int height)
-{
-    int w;
-    const uint8_t *s1, *s2, *s3, *s4;
-    uint8_t *d;
-
-    for(;height > 0; height--) {
-        s1 = src;
-        s2 = s1 + src_wrap;
-        s3 = s2 + src_wrap;
-        s4 = s3 + src_wrap;
-        d = dst;
-        for(w = width;w > 0; w--) {
-            d[0] = (s1[0] + s1[1] + s1[2] + s1[3] +
-                    s2[0] + s2[1] + s2[2] + s2[3] +
-                    s3[0] + s3[1] + s3[2] + s3[3] +
-                    s4[0] + s4[1] + s4[2] + s4[3] + 8) >> 4;
-            s1 += 4;
-            s2 += 4;
-            s3 += 4;
-            s4 += 4;
-            d++;
-        }
-        src += 4 * src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-static void grow21_line(uint8_t *dst, const uint8_t *src,
-                        int width)
-{
-    int w;
-    const uint8_t *s1;
-    uint8_t *d;
-
-    s1 = src;
-    d = dst;
-    for(w = width;w >= 4; w-=4) {
-        d[1] = d[0] = s1[0];
-        d[3] = d[2] = s1[1];
-        s1 += 2;
-        d += 4;
-    }
-    for(;w >= 2; w -= 2) {
-        d[1] = d[0] = s1[0];
-        s1 ++;
-        d += 2;
-    }
-    /* only needed if width is not a multiple of two */
-    /* XXX: veryfy that */
-    if (w) {
-        d[0] = s1[0];
-    }
-}
-
-static void grow41_line(uint8_t *dst, const uint8_t *src,
-                        int width)
-{
-    int w, v;
-    const uint8_t *s1;
-    uint8_t *d;
-
-    s1 = src;
-    d = dst;
-    for(w = width;w >= 4; w-=4) {
-        v = s1[0];
-        d[0] = v;
-        d[1] = v;
-        d[2] = v;
-        d[3] = v;
-        s1 ++;
-        d += 4;
-    }
-}
-
-/* 1x1 -> 2x1 */
-static void grow21(uint8_t *dst, int dst_wrap,
-                   const uint8_t *src, int src_wrap,
-                   int width, int height)
-{
-    for(;height > 0; height--) {
-        grow21_line(dst, src, width);
-        src += src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-/* 1x1 -> 2x2 */
-static void grow22(uint8_t *dst, int dst_wrap,
-                   const uint8_t *src, int src_wrap,
-                   int width, int height)
-{
-    for(;height > 0; height--) {
-        grow21_line(dst, src, width);
-        if (height%2)
-            src += src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-/* 1x1 -> 4x1 */
-static void grow41(uint8_t *dst, int dst_wrap,
-                   const uint8_t *src, int src_wrap,
-                   int width, int height)
-{
-    for(;height > 0; height--) {
-        grow41_line(dst, src, width);
-        src += src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-/* 1x1 -> 4x4 */
-static void grow44(uint8_t *dst, int dst_wrap,
-                   const uint8_t *src, int src_wrap,
-                   int width, int height)
-{
-    for(;height > 0; height--) {
-        grow41_line(dst, src, width);
-        if ((height & 3) == 1)
-            src += src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-/* 1x2 -> 2x1 */
-static void conv411(uint8_t *dst, int dst_wrap, 
-                    const uint8_t *src, int src_wrap,
-                    int width, int height)
-{
-    int w, c;
-    const uint8_t *s1, *s2;
-    uint8_t *d;
-
-    width>>=1;
-
-    for(;height > 0; height--) {
-        s1 = src;
-        s2 = src + src_wrap;
-        d = dst;
-        for(w = width;w > 0; w--) {
-            c = (s1[0] + s2[0]) >> 1;
-            d[0] = c;
-            d[1] = c;
-            s1++;
-            s2++;
-            d += 2;
-        }
-        src += src_wrap * 2;
-        dst += dst_wrap;
-    }
-}
-
-/* XXX: add jpeg quantize code */
-
-#define TRANSP_INDEX (6*6*6)
-
-/* this is maybe slow, but allows for extensions */
-static inline unsigned char gif_clut_index(uint8_t r, uint8_t g, uint8_t b)
-{
-    return ((((r)/47)%6)*6*6+(((g)/47)%6)*6+(((b)/47)%6));
-}
-
-static void build_rgb_palette(uint8_t *palette, int has_alpha)
-{
-    uint32_t *pal;
-    static const uint8_t pal_value[6] = { 0x00, 0x33, 0x66, 0x99, 0xcc, 0xff };
-    int i, r, g, b;
-
-    pal = (uint32_t *)palette;
-    i = 0;
-    for(r = 0; r < 6; r++) {
-        for(g = 0; g < 6; g++) {
-            for(b = 0; b < 6; b++) {
-                pal[i++] = (0xff << 24) | (pal_value[r] << 16) | 
-                    (pal_value[g] << 8) | pal_value[b];
-            }
-        }
-    }
-    if (has_alpha)
-        pal[i++] = 0;
-    while (i < 256)
-        pal[i++] = 0xff000000;
-}
-
-/* copy bit n to bits 0 ... n - 1 */
-static inline unsigned int bitcopy_n(unsigned int a, int n)
-{
-    int mask;
-    mask = (1 << n) - 1;
-    return (a & (0xff & ~mask)) | ((-((a >> n) & 1)) & mask);
-}
-
-/* rgb555 handling */
-
-#define RGB_NAME rgb555
-
-#define RGB_IN(r, g, b, s)\
-{\
-    unsigned int v = ((const uint16_t *)(s))[0];\
-    r = bitcopy_n(v >> (10 - 3), 3);\
-    g = bitcopy_n(v >> (5 - 3), 3);\
-    b = bitcopy_n(v << 3, 3);\
-}
-
-#define RGBA_IN(r, g, b, a, s)\
-{\
-    unsigned int v = ((const uint16_t *)(s))[0];\
-    r = bitcopy_n(v >> (10 - 3), 3);\
-    g = bitcopy_n(v >> (5 - 3), 3);\
-    b = bitcopy_n(v << 3, 3);\
-    a = (-(v >> 15)) & 0xff;\
-}
-
-#define RGBA_OUT(d, r, g, b, a)\
-{\
-    ((uint16_t *)(d))[0] = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3) | \
-                           ((a << 8) & 0x8000);\
-}
-
-#define BPP 2
-
-#include "imgconvert_template.h"
-
-/* rgb565 handling */
-
-#define RGB_NAME rgb565
-
-#define RGB_IN(r, g, b, s)\
-{\
-    unsigned int v = ((const uint16_t *)(s))[0];\
-    r = bitcopy_n(v >> (11 - 3), 3);\
-    g = bitcopy_n(v >> (5 - 2), 2);\
-    b = bitcopy_n(v << 3, 3);\
-}
-
-#define RGB_OUT(d, r, g, b)\
-{\
-    ((uint16_t *)(d))[0] = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);\
-}
-
-#define BPP 2
-
-#include "imgconvert_template.h"
-
-/* bgr24 handling */
-
-#define RGB_NAME bgr24
-
-#define RGB_IN(r, g, b, s)\
-{\
-    b = (s)[0];\
-    g = (s)[1];\
-    r = (s)[2];\
-}
-
-#define RGB_OUT(d, r, g, b)\
-{\
-    (d)[0] = b;\
-    (d)[1] = g;\
-    (d)[2] = r;\
-}
-
-#define BPP 3
-
-#include "imgconvert_template.h"
-
-#undef RGB_IN
-#undef RGB_OUT
-#undef BPP
-
-/* rgb24 handling */
-
-#define RGB_NAME rgb24
-#define FMT_RGB24
-
-#define RGB_IN(r, g, b, s)\
-{\
-    r = (s)[0];\
-    g = (s)[1];\
-    b = (s)[2];\
-}
-
-#define RGB_OUT(d, r, g, b)\
-{\
-    (d)[0] = r;\
-    (d)[1] = g;\
-    (d)[2] = b;\
-}
-
-#define BPP 3
-
-#include "imgconvert_template.h"
-
-/* rgba32 handling */
-
-#define RGB_NAME rgba32
-#define FMT_RGBA32
-
-#define RGB_IN(r, g, b, s)\
-{\
-    unsigned int v = ((const uint32_t *)(s))[0];\
-    r = (v >> 16) & 0xff;\
-    g = (v >> 8) & 0xff;\
-    b = v & 0xff;\
-}
-
-#define RGBA_IN(r, g, b, a, s)\
-{\
-    unsigned int v = ((const uint32_t *)(s))[0];\
-    a = (v >> 24) & 0xff;\
-    r = (v >> 16) & 0xff;\
-    g = (v >> 8) & 0xff;\
-    b = v & 0xff;\
-}
-
-#define RGBA_OUT(d, r, g, b, a)\
-{\
-    ((uint32_t *)(d))[0] = (a << 24) | (r << 16) | (g << 8) | b;\
-}
-
-#define BPP 4
-
-#include "imgconvert_template.h"
-
-static void mono_to_gray(AVPicture *dst, const AVPicture *src,
-                         int width, int height, int xor_mask)
-{
-    const unsigned char *p;
-    unsigned char *q;
-    int v, dst_wrap, src_wrap;
-    int y, w;
-
-    p = src->data[0];
-    src_wrap = src->linesize[0] - ((width + 7) >> 3);
-
-    q = dst->data[0];
-    dst_wrap = dst->linesize[0] - width;
-    for(y=0;y<height;y++) {
-        w = width; 
-        while (w >= 8) {
-            v = *p++ ^ xor_mask;
-            q[0] = -(v >> 7);
-            q[1] = -((v >> 6) & 1);
-            q[2] = -((v >> 5) & 1);
-            q[3] = -((v >> 4) & 1);
-            q[4] = -((v >> 3) & 1);
-            q[5] = -((v >> 2) & 1);
-            q[6] = -((v >> 1) & 1);
-            q[7] = -((v >> 0) & 1);
-            w -= 8;
-            q += 8;
-        }
-        if (w > 0) {
-            v = *p++ ^ xor_mask;
-            do {
-                q[0] = -((v >> 7) & 1);
-                q++;
-                v <<= 1;
-            } while (--w);
-        }
-        p += src_wrap;
-        q += dst_wrap;
-    }
-}
-
-static void monowhite_to_gray(AVPicture *dst, const AVPicture *src,
-                               int width, int height)
-{
-    mono_to_gray(dst, src, width, height, 0xff);
-}
-
-static void monoblack_to_gray(AVPicture *dst, const AVPicture *src,
-                               int width, int height)
-{
-    mono_to_gray(dst, src, width, height, 0x00);
-}
-
-static void gray_to_mono(AVPicture *dst, const AVPicture *src,
-                         int width, int height, int xor_mask)
-{
-    int n;
-    const uint8_t *s;
-    uint8_t *d;
-    int j, b, v, n1, src_wrap, dst_wrap, y;
-
-    s = src->data[0];
-    src_wrap = src->linesize[0] - width;
-
-    d = dst->data[0];
-    dst_wrap = dst->linesize[0] - ((width + 7) >> 3);
-
-    for(y=0;y<height;y++) {
-        n = width;
-        while (n >= 8) {
-            v = 0;
-            for(j=0;j<8;j++) {
-                b = s[0];
-                s++;
-                v = (v << 1) | (b >> 7);
-            }
-            d[0] = v ^ xor_mask;
-            d++;
-            n -= 8;
-        }
-        if (n > 0) {
-            n1 = n;
-            v = 0;
-            while (n > 0) {
-                b = s[0];
-                s++;
-                v = (v << 1) | (b >> 7);
-                n--;
-            }
-            d[0] = (v << (8 - (n1 & 7))) ^ xor_mask;
-            d++;
-        }
-        s += src_wrap;
-        d += dst_wrap;
-    }
-}
-
-static void gray_to_monowhite(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    gray_to_mono(dst, src, width, height, 0xff);
-}
-
-static void gray_to_monoblack(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    gray_to_mono(dst, src, width, height, 0x00);
-}
-
-typedef struct ConvertEntry {
-    void (*convert)(AVPicture *dst,
-		    const AVPicture *src, int width, int height);
-} ConvertEntry;
-
-/* Add each new convertion function in this table. In order to be able
-   to convert from any format to any format, the following constraints
-   must be satisfied:
-
-   - all FF_COLOR_RGB formats must convert to and from PIX_FMT_RGB24 
-
-   - all FF_COLOR_GRAY formats must convert to and from PIX_FMT_GRAY8
-
-   - all FF_COLOR_RGB formats with alpha must convert to and from PIX_FMT_RGBA32
-
-   - PIX_FMT_YUV444P and PIX_FMT_YUVJ444P must convert to and from
-     PIX_FMT_RGB24.
-
-   - PIX_FMT_422 must convert to and from PIX_FMT_422P.
-
-   The other conversion functions are just optimisations for common cases.
-*/
-static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
-    [PIX_FMT_YUV420P] = {
-        [PIX_FMT_YUV422] = {
-            .convert = yuv420p_to_yuv422,
-        },
-        [PIX_FMT_RGB555] = { 
-            .convert = yuv420p_to_rgb555
-        },
-        [PIX_FMT_RGB565] = { 
-            .convert = yuv420p_to_rgb565
-        },
-        [PIX_FMT_BGR24] = { 
-            .convert = yuv420p_to_bgr24
-        },
-        [PIX_FMT_RGB24] = { 
-            .convert = yuv420p_to_rgb24
-        },
-        [PIX_FMT_RGBA32] = { 
-            .convert = yuv420p_to_rgba32
-        },
-	[PIX_FMT_UYVY422] = { 
-            .convert = yuv420p_to_uyvy422,
-        },
-    },
-    [PIX_FMT_YUV422P] = { 
-        [PIX_FMT_YUV422] = { 
-            .convert = yuv422p_to_yuv422,
-        },
-        [PIX_FMT_UYVY422] = { 
-            .convert = yuv422p_to_uyvy422,
-        },
-    },
-    [PIX_FMT_YUV444P] = { 
-        [PIX_FMT_RGB24] = { 
-            .convert = yuv444p_to_rgb24
-        },
-    },
-    [PIX_FMT_YUVJ420P] = {
-        [PIX_FMT_RGB555] = { 
-            .convert = yuvj420p_to_rgb555
-        },
-        [PIX_FMT_RGB565] = { 
-            .convert = yuvj420p_to_rgb565
-        },
-        [PIX_FMT_BGR24] = { 
-            .convert = yuvj420p_to_bgr24
-        },
-        [PIX_FMT_RGB24] = { 
-            .convert = yuvj420p_to_rgb24
-        },
-        [PIX_FMT_RGBA32] = { 
-            .convert = yuvj420p_to_rgba32
-        },
-    },
-    [PIX_FMT_YUVJ444P] = { 
-        [PIX_FMT_RGB24] = { 
-            .convert = yuvj444p_to_rgb24
-        },
-    },
-    [PIX_FMT_YUV422] = { 
-        [PIX_FMT_YUV420P] = { 
-            .convert = yuv422_to_yuv420p,
-        },
-        [PIX_FMT_YUV422P] = { 
-            .convert = yuv422_to_yuv422p,
-        },
-    },
-    [PIX_FMT_UYVY422] = { 
-        [PIX_FMT_YUV420P] = { 
-            .convert = uyvy422_to_yuv420p,
-        },
-        [PIX_FMT_YUV422P] = { 
-            .convert = uyvy422_to_yuv422p,
-        },
-    },
-    [PIX_FMT_RGB24] = {
-        [PIX_FMT_YUV420P] = { 
-            .convert = rgb24_to_yuv420p
-        },
-        [PIX_FMT_RGB565] = { 
-            .convert = rgb24_to_rgb565
-        },
-        [PIX_FMT_RGB555] = { 
-            .convert = rgb24_to_rgb555
-        },
-        [PIX_FMT_RGBA32] = { 
-            .convert = rgb24_to_rgba32
-        },
-        [PIX_FMT_BGR24] = { 
-            .convert = rgb24_to_bgr24
-        },
-        [PIX_FMT_GRAY8] = { 
-            .convert = rgb24_to_gray
-        },
-        [PIX_FMT_PAL8] = {
-            .convert = rgb24_to_pal8
-        },
-        [PIX_FMT_YUV444P] = { 
-            .convert = rgb24_to_yuv444p
-        },
-        [PIX_FMT_YUVJ420P] = { 
-            .convert = rgb24_to_yuvj420p
-        },
-        [PIX_FMT_YUVJ444P] = { 
-            .convert = rgb24_to_yuvj444p
-        },
-    },
-    [PIX_FMT_RGBA32] = {
-        [PIX_FMT_RGB24] = { 
-            .convert = rgba32_to_rgb24
-        },
-        [PIX_FMT_RGB555] = { 
-            .convert = rgba32_to_rgb555
-        },
-        [PIX_FMT_PAL8] = { 
-            .convert = rgba32_to_pal8
-        },
-        [PIX_FMT_YUV420P] = { 
-            .convert = rgba32_to_yuv420p
-        },
-        [PIX_FMT_GRAY8] = { 
-            .convert = rgba32_to_gray
-        },
-    },
-    [PIX_FMT_BGR24] = {
-        [PIX_FMT_RGB24] = { 
-            .convert = bgr24_to_rgb24
-        },
-        [PIX_FMT_YUV420P] = { 
-            .convert = bgr24_to_yuv420p
-        },
-        [PIX_FMT_GRAY8] = { 
-            .convert = bgr24_to_gray
-        },
-    },
-    [PIX_FMT_RGB555] = {
-        [PIX_FMT_RGB24] = { 
-            .convert = rgb555_to_rgb24
-        },
-        [PIX_FMT_RGBA32] = { 
-            .convert = rgb555_to_rgba32
-        },
-        [PIX_FMT_YUV420P] = { 
-            .convert = rgb555_to_yuv420p
-        },
-        [PIX_FMT_GRAY8] = { 
-            .convert = rgb555_to_gray
-        },
-    },
-    [PIX_FMT_RGB565] = {
-        [PIX_FMT_RGB24] = { 
-            .convert = rgb565_to_rgb24
-        },
-        [PIX_FMT_YUV420P] = { 
-            .convert = rgb565_to_yuv420p
-        },
-        [PIX_FMT_GRAY8] = { 
-            .convert = rgb565_to_gray
-        },
-    },
-    [PIX_FMT_GRAY8] = {
-        [PIX_FMT_RGB555] = { 
-            .convert = gray_to_rgb555
-        },
-        [PIX_FMT_RGB565] = { 
-            .convert = gray_to_rgb565
-        },
-        [PIX_FMT_RGB24] = { 
-            .convert = gray_to_rgb24
-        },
-        [PIX_FMT_BGR24] = { 
-            .convert = gray_to_bgr24
-        },
-        [PIX_FMT_RGBA32] = { 
-            .convert = gray_to_rgba32
-        },
-        [PIX_FMT_MONOWHITE] = { 
-            .convert = gray_to_monowhite
-        },
-        [PIX_FMT_MONOBLACK] = { 
-            .convert = gray_to_monoblack
-        },
-    },
-    [PIX_FMT_MONOWHITE] = {
-        [PIX_FMT_GRAY8] = { 
-            .convert = monowhite_to_gray
-        },
-    },
-    [PIX_FMT_MONOBLACK] = {
-        [PIX_FMT_GRAY8] = { 
-            .convert = monoblack_to_gray
-        },
-    },
-    [PIX_FMT_PAL8] = {
-        [PIX_FMT_RGB555] = { 
-            .convert = pal8_to_rgb555
-        },
-        [PIX_FMT_RGB565] = { 
-            .convert = pal8_to_rgb565
-        },
-        [PIX_FMT_BGR24] = { 
-            .convert = pal8_to_bgr24
-        },
-        [PIX_FMT_RGB24] = { 
-            .convert = pal8_to_rgb24
-        },
-        [PIX_FMT_RGBA32] = { 
-            .convert = pal8_to_rgba32
-        },
-    },
-    [PIX_FMT_UYVY411] = { 
-        [PIX_FMT_YUV411P] = { 
-            .convert = uyvy411_to_yuv411p,
-        },
-    },
-
-};
-
-int avpicture_alloc(AVPicture *picture,
-                           int pix_fmt, int width, int height)
-{
-    unsigned int size;
-    void *ptr;
-
-    size = avpicture_get_size(pix_fmt, width, height);
-    if(size<0)
-        goto fail;
-    ptr = av_malloc(size);
-    if (!ptr)
-        goto fail;
-    avpicture_fill(picture, ptr, pix_fmt, width, height);
-    return 0;
- fail:
-    memset(picture, 0, sizeof(AVPicture));
-    return -1;
-}
-
-void avpicture_free(AVPicture *picture)
-{
-    av_free(picture->data[0]);
-}
-
-/* return true if yuv planar */
-static inline int is_yuv_planar(PixFmtInfo *ps)
-{
-    return (ps->color_type == FF_COLOR_YUV ||
-            ps->color_type == FF_COLOR_YUV_JPEG) && 
-        ps->pixel_type == FF_PIXEL_PLANAR;
-}
-
-/* XXX: always use linesize. Return -1 if not supported */
-int img_convert(AVPicture *dst, int dst_pix_fmt,
-                const AVPicture *src, int src_pix_fmt, 
-                int src_width, int src_height)
-{
-    static int inited;
-    int i, ret, dst_width, dst_height, int_pix_fmt;
-    PixFmtInfo *src_pix, *dst_pix;
-    ConvertEntry *ce;
-    AVPicture tmp1, *tmp = &tmp1;
-
-    if (src_pix_fmt < 0 || src_pix_fmt >= PIX_FMT_NB ||
-        dst_pix_fmt < 0 || dst_pix_fmt >= PIX_FMT_NB)
-        return -1;
-    if (src_width <= 0 || src_height <= 0)
-        return 0;
-
-    if (!inited) {
-        inited = 1;
-        img_convert_init();
-    }
-
-    dst_width = src_width;
-    dst_height = src_height;
-
-    dst_pix = &pix_fmt_info[dst_pix_fmt];
-    src_pix = &pix_fmt_info[src_pix_fmt];
-    if (src_pix_fmt == dst_pix_fmt) {
-        /* no conversion needed: just copy */
-        img_copy(dst, src, dst_pix_fmt, dst_width, dst_height);
-        return 0;
-    }
-
-    ce = &convert_table[src_pix_fmt][dst_pix_fmt];
-    if (ce->convert) {
-        /* specific conversion routine */
-        ce->convert(dst, src, dst_width, dst_height);
-        return 0;
-    }
-
-    /* gray to YUV */
-    if (is_yuv_planar(dst_pix) &&
-        src_pix_fmt == PIX_FMT_GRAY8) {
-        int w, h, y;
-        uint8_t *d;
-
-        if (dst_pix->color_type == FF_COLOR_YUV_JPEG) {
-            img_copy_plane(dst->data[0], dst->linesize[0],
-                     src->data[0], src->linesize[0],
-                     dst_width, dst_height);
-        } else {
-            img_apply_table(dst->data[0], dst->linesize[0],
-                            src->data[0], src->linesize[0],
-                            dst_width, dst_height,
-                            y_jpeg_to_ccir);
-        }
-        /* fill U and V with 128 */
-        w = dst_width;
-        h = dst_height;
-        w >>= dst_pix->x_chroma_shift;
-        h >>= dst_pix->y_chroma_shift;
-        for(i = 1; i <= 2; i++) {
-            d = dst->data[i];
-            for(y = 0; y< h; y++) {
-                memset(d, 128, w);
-                d += dst->linesize[i];
-            }
-        }
-        return 0;
-    }
-
-    /* YUV to gray */
-    if (is_yuv_planar(src_pix) && 
-        dst_pix_fmt == PIX_FMT_GRAY8) {
-        if (src_pix->color_type == FF_COLOR_YUV_JPEG) {
-            img_copy_plane(dst->data[0], dst->linesize[0],
-                     src->data[0], src->linesize[0],
-                     dst_width, dst_height);
-        } else {
-            img_apply_table(dst->data[0], dst->linesize[0],
-                            src->data[0], src->linesize[0],
-                            dst_width, dst_height,
-                            y_ccir_to_jpeg);
-        }
-        return 0;
-    }
-
-    /* YUV to YUV planar */
-    if (is_yuv_planar(dst_pix) && is_yuv_planar(src_pix)) {
-        int x_shift, y_shift, w, h, xy_shift;
-        void (*resize_func)(uint8_t *dst, int dst_wrap, 
-                            const uint8_t *src, int src_wrap,
-                            int width, int height);
-
-        /* compute chroma size of the smallest dimensions */
-        w = dst_width;
-        h = dst_height;
-        if (dst_pix->x_chroma_shift >= src_pix->x_chroma_shift)
-            w >>= dst_pix->x_chroma_shift;
-        else
-            w >>= src_pix->x_chroma_shift;
-        if (dst_pix->y_chroma_shift >= src_pix->y_chroma_shift)
-            h >>= dst_pix->y_chroma_shift;
-        else
-            h >>= src_pix->y_chroma_shift;
-
-        x_shift = (dst_pix->x_chroma_shift - src_pix->x_chroma_shift);
-        y_shift = (dst_pix->y_chroma_shift - src_pix->y_chroma_shift);
-        xy_shift = ((x_shift & 0xf) << 4) | (y_shift & 0xf);
-        /* there must be filters for conversion at least from and to
-           YUV444 format */
-        switch(xy_shift) {
-        case 0x00:
-            resize_func = img_copy_plane;
-            break;
-        case 0x10:
-            resize_func = shrink21;
-            break;
-        case 0x20:
-            resize_func = shrink41;
-            break;
-        case 0x01:
-            resize_func = shrink12;
-            break;
-        case 0x11:
-            resize_func = shrink22;
-            break;
-        case 0x22:
-            resize_func = shrink44;
-            break;
-        case 0xf0:
-            resize_func = grow21;
-            break;
-        case 0xe0:
-            resize_func = grow41;
-            break;
-        case 0xff:
-            resize_func = grow22;
-            break;
-        case 0xee:
-            resize_func = grow44;
-            break;
-        case 0xf1:
-            resize_func = conv411;
-            break;
-        default:
-            /* currently not handled */
-            goto no_chroma_filter;
-        }
-
-        img_copy_plane(dst->data[0], dst->linesize[0],
-                       src->data[0], src->linesize[0],
-                       dst_width, dst_height);
-
-        for(i = 1;i <= 2; i++)
-            resize_func(dst->data[i], dst->linesize[i],
-                        src->data[i], src->linesize[i],
-                        dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift);
-        /* if yuv color space conversion is needed, we do it here on
-           the destination image */
-        if (dst_pix->color_type != src_pix->color_type) {
-            const uint8_t *y_table, *c_table;
-            if (dst_pix->color_type == FF_COLOR_YUV) {
-                y_table = y_jpeg_to_ccir;
-                c_table = c_jpeg_to_ccir;
-            } else {
-                y_table = y_ccir_to_jpeg;
-                c_table = c_ccir_to_jpeg;
-            }
-            img_apply_table(dst->data[0], dst->linesize[0],
-                            dst->data[0], dst->linesize[0],
-                            dst_width, dst_height,
-                            y_table);
-
-            for(i = 1;i <= 2; i++)
-                img_apply_table(dst->data[i], dst->linesize[i],
-                                dst->data[i], dst->linesize[i],
-                                dst_width>>dst_pix->x_chroma_shift, 
-                                dst_height>>dst_pix->y_chroma_shift,
-                                c_table);
-        }
-        return 0;
-    }
- no_chroma_filter:
-
-    /* try to use an intermediate format */
-    if (src_pix_fmt == PIX_FMT_YUV422 ||
-        dst_pix_fmt == PIX_FMT_YUV422) {
-        /* specific case: convert to YUV422P first */
-        int_pix_fmt = PIX_FMT_YUV422P;
-    } else if (src_pix_fmt == PIX_FMT_UYVY422 ||
-        dst_pix_fmt == PIX_FMT_UYVY422) {
-        /* specific case: convert to YUV422P first */
-        int_pix_fmt = PIX_FMT_YUV422P;
-    } else if (src_pix_fmt == PIX_FMT_UYVY411 ||
-        dst_pix_fmt == PIX_FMT_UYVY411) {
-        /* specific case: convert to YUV411P first */
-        int_pix_fmt = PIX_FMT_YUV411P;
-    } else if ((src_pix->color_type == FF_COLOR_GRAY &&
-                src_pix_fmt != PIX_FMT_GRAY8) || 
-               (dst_pix->color_type == FF_COLOR_GRAY &&
-                dst_pix_fmt != PIX_FMT_GRAY8)) {
-        /* gray8 is the normalized format */
-        int_pix_fmt = PIX_FMT_GRAY8;
-    } else if ((is_yuv_planar(src_pix) && 
-                src_pix_fmt != PIX_FMT_YUV444P &&
-                src_pix_fmt != PIX_FMT_YUVJ444P)) {
-        /* yuv444 is the normalized format */
-        if (src_pix->color_type == FF_COLOR_YUV_JPEG)
-            int_pix_fmt = PIX_FMT_YUVJ444P;
-        else
-            int_pix_fmt = PIX_FMT_YUV444P;
-    } else if ((is_yuv_planar(dst_pix) && 
-                dst_pix_fmt != PIX_FMT_YUV444P &&
-                dst_pix_fmt != PIX_FMT_YUVJ444P)) {
-        /* yuv444 is the normalized format */
-        if (dst_pix->color_type == FF_COLOR_YUV_JPEG)
-            int_pix_fmt = PIX_FMT_YUVJ444P;
-        else
-            int_pix_fmt = PIX_FMT_YUV444P;
-    } else {
-        /* the two formats are rgb or gray8 or yuv[j]444p */
-        if (src_pix->is_alpha && dst_pix->is_alpha)
-            int_pix_fmt = PIX_FMT_RGBA32;
-        else
-            int_pix_fmt = PIX_FMT_RGB24;
-    }
-    if (avpicture_alloc(tmp, int_pix_fmt, dst_width, dst_height) < 0)
-        return -1;
-    ret = -1;
-    if (img_convert(tmp, int_pix_fmt,
-                    src, src_pix_fmt, src_width, src_height) < 0)
-        goto fail1;
-    if (img_convert(dst, dst_pix_fmt,
-                    tmp, int_pix_fmt, dst_width, dst_height) < 0)
-        goto fail1;
-    ret = 0;
- fail1:
-    avpicture_free(tmp);
-    return ret;
-}
-
-/* NOTE: we scan all the pixels to have an exact information */
-static int get_alpha_info_pal8(const AVPicture *src, int width, int height)
-{
-    const unsigned char *p;
-    int src_wrap, ret, x, y;
-    unsigned int a;
-    uint32_t *palette = (uint32_t *)src->data[1];
-    
-    p = src->data[0];
-    src_wrap = src->linesize[0] - width;
-    ret = 0;
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-            a = palette[p[0]] >> 24;
-            if (a == 0x00) {
-                ret |= FF_ALPHA_TRANSP;
-            } else if (a != 0xff) {
-                ret |= FF_ALPHA_SEMI_TRANSP;
-            }
-            p++;
-        }
-        p += src_wrap;
-    }
-    return ret;
-}
-
-/**
- * Tell if an image really has transparent alpha values.
- * @return ored mask of FF_ALPHA_xxx constants
- */
-int img_get_alpha_info(const AVPicture *src,
-		       int pix_fmt, int width, int height)
-{
-    PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
-    int ret;
-
-    pf = &pix_fmt_info[pix_fmt];
-    /* no alpha can be represented in format */
-    if (!pf->is_alpha)
-        return 0;
-    switch(pix_fmt) {
-    case PIX_FMT_RGBA32:
-        ret = get_alpha_info_rgba32(src, width, height);
-        break;
-    case PIX_FMT_RGB555:
-        ret = get_alpha_info_rgb555(src, width, height);
-        break;
-    case PIX_FMT_PAL8:
-        ret = get_alpha_info_pal8(src, width, height);
-        break;
-    default:
-        /* we do not know, so everything is indicated */
-        ret = FF_ALPHA_TRANSP | FF_ALPHA_SEMI_TRANSP;
-        break;
-    }
-    return ret;
-}
-
-#ifdef HAVE_MMX
-#define DEINT_INPLACE_LINE_LUM \
-                    movd_m2r(lum_m4[0],mm0);\
-                    movd_m2r(lum_m3[0],mm1);\
-                    movd_m2r(lum_m2[0],mm2);\
-                    movd_m2r(lum_m1[0],mm3);\
-                    movd_m2r(lum[0],mm4);\
-                    punpcklbw_r2r(mm7,mm0);\
-                    movd_r2m(mm2,lum_m4[0]);\
-                    punpcklbw_r2r(mm7,mm1);\
-                    punpcklbw_r2r(mm7,mm2);\
-                    punpcklbw_r2r(mm7,mm3);\
-                    punpcklbw_r2r(mm7,mm4);\
-                    paddw_r2r(mm3,mm1);\
-                    psllw_i2r(1,mm2);\
-                    paddw_r2r(mm4,mm0);\
-                    psllw_i2r(2,mm1);\
-                    paddw_r2r(mm6,mm2);\
-                    paddw_r2r(mm2,mm1);\
-                    psubusw_r2r(mm0,mm1);\
-                    psrlw_i2r(3,mm1);\
-                    packuswb_r2r(mm7,mm1);\
-                    movd_r2m(mm1,lum_m2[0]);
-
-#define DEINT_LINE_LUM \
-                    movd_m2r(lum_m4[0],mm0);\
-                    movd_m2r(lum_m3[0],mm1);\
-                    movd_m2r(lum_m2[0],mm2);\
-                    movd_m2r(lum_m1[0],mm3);\
-                    movd_m2r(lum[0],mm4);\
-                    punpcklbw_r2r(mm7,mm0);\
-                    punpcklbw_r2r(mm7,mm1);\
-                    punpcklbw_r2r(mm7,mm2);\
-                    punpcklbw_r2r(mm7,mm3);\
-                    punpcklbw_r2r(mm7,mm4);\
-                    paddw_r2r(mm3,mm1);\
-                    psllw_i2r(1,mm2);\
-                    paddw_r2r(mm4,mm0);\
-                    psllw_i2r(2,mm1);\
-                    paddw_r2r(mm6,mm2);\
-                    paddw_r2r(mm2,mm1);\
-                    psubusw_r2r(mm0,mm1);\
-                    psrlw_i2r(3,mm1);\
-                    packuswb_r2r(mm7,mm1);\
-                    movd_r2m(mm1,dst[0]);
-#endif
-
-/* filter parameters: [-1 4 2 4 -1] // 8 */
-static void deinterlace_line(uint8_t *dst, 
-			     const uint8_t *lum_m4, const uint8_t *lum_m3, 
-			     const uint8_t *lum_m2, const uint8_t *lum_m1, 
-			     const uint8_t *lum,
-			     int size)
-{
-#ifndef HAVE_MMX
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-    int sum;
-
-    for(;size > 0;size--) {
-        sum = -lum_m4[0];
-        sum += lum_m3[0] << 2;
-        sum += lum_m2[0] << 1;
-        sum += lum_m1[0] << 2;
-        sum += -lum[0];
-        dst[0] = cm[(sum + 4) >> 3];
-        lum_m4++;
-        lum_m3++;
-        lum_m2++;
-        lum_m1++;
-        lum++;
-        dst++;
-    }
-#else
-
-    {
-        mmx_t rounder;
-        rounder.uw[0]=4;
-        rounder.uw[1]=4;
-        rounder.uw[2]=4;
-        rounder.uw[3]=4;
-        pxor_r2r(mm7,mm7);
-        movq_m2r(rounder,mm6);
-    }
-    for (;size > 3; size-=4) {
-        DEINT_LINE_LUM
-        lum_m4+=4;
-        lum_m3+=4;
-        lum_m2+=4;
-        lum_m1+=4;
-        lum+=4;
-        dst+=4;
-    }
-#endif
-}
-static void deinterlace_line_inplace(uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *lum_m2, uint8_t *lum_m1, uint8_t *lum,
-                             int size)
-{
-#ifndef HAVE_MMX
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-    int sum;
-
-    for(;size > 0;size--) {
-        sum = -lum_m4[0];
-        sum += lum_m3[0] << 2;
-        sum += lum_m2[0] << 1;
-        lum_m4[0]=lum_m2[0];
-        sum += lum_m1[0] << 2;
-        sum += -lum[0];
-        lum_m2[0] = cm[(sum + 4) >> 3];
-        lum_m4++;
-        lum_m3++;
-        lum_m2++;
-        lum_m1++;
-        lum++;
-    }
-#else
-
-    {
-        mmx_t rounder;
-        rounder.uw[0]=4;
-        rounder.uw[1]=4;
-        rounder.uw[2]=4;
-        rounder.uw[3]=4;
-        pxor_r2r(mm7,mm7);
-        movq_m2r(rounder,mm6);
-    }
-    for (;size > 3; size-=4) {
-        DEINT_INPLACE_LINE_LUM
-        lum_m4+=4;
-        lum_m3+=4;
-        lum_m2+=4;
-        lum_m1+=4;
-        lum+=4;
-    }
-#endif
-}
-
-/* deinterlacing : 2 temporal taps, 3 spatial taps linear filter. The
-   top field is copied as is, but the bottom field is deinterlaced
-   against the top field. */
-static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap,
-                                    const uint8_t *src1, int src_wrap,
-                                    int width, int height)
-{
-    const uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
-    int y;
-
-    src_m2 = src1;
-    src_m1 = src1;
-    src_0=&src_m1[src_wrap];
-    src_p1=&src_0[src_wrap];
-    src_p2=&src_p1[src_wrap];
-    for(y=0;y<(height-2);y+=2) {
-        memcpy(dst,src_m1,width);
-        dst += dst_wrap;
-        deinterlace_line(dst,src_m2,src_m1,src_0,src_p1,src_p2,width);
-        src_m2 = src_0;
-        src_m1 = src_p1;
-        src_0 = src_p2;
-        src_p1 += 2*src_wrap;
-        src_p2 += 2*src_wrap;
-        dst += dst_wrap;
-    }
-    memcpy(dst,src_m1,width);
-    dst += dst_wrap;
-    /* do last line */
-    deinterlace_line(dst,src_m2,src_m1,src_0,src_0,src_0,width);
-}
-
-static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap,
-					     int width, int height)
-{
-    uint8_t *src_m1, *src_0, *src_p1, *src_p2;
-    int y;
-    uint8_t *buf;
-    buf = (uint8_t*)av_malloc(width);
-
-    src_m1 = src1;
-    memcpy(buf,src_m1,width);
-    src_0=&src_m1[src_wrap];
-    src_p1=&src_0[src_wrap];
-    src_p2=&src_p1[src_wrap];
-    for(y=0;y<(height-2);y+=2) {
-        deinterlace_line_inplace(buf,src_m1,src_0,src_p1,src_p2,width);
-        src_m1 = src_p1;
-        src_0 = src_p2;
-        src_p1 += 2*src_wrap;
-        src_p2 += 2*src_wrap;
-    }
-    /* do last line */
-    deinterlace_line_inplace(buf,src_m1,src_0,src_0,src_0,width);
-    av_free(buf);
-}
-
-
-/* deinterlace - if not supported return -1 */
-int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
-                          int pix_fmt, int width, int height)
-{
-    int i;
-
-    if (pix_fmt != PIX_FMT_YUV420P &&
-        pix_fmt != PIX_FMT_YUV422P &&
-        pix_fmt != PIX_FMT_YUV444P &&
-	pix_fmt != PIX_FMT_YUV411P)
-        return -1;
-    if ((width & 3) != 0 || (height & 3) != 0)
-        return -1;
-
-    for(i=0;i<3;i++) {
-        if (i == 1) {
-            switch(pix_fmt) {
-            case PIX_FMT_YUV420P:
-                width >>= 1;
-                height >>= 1;
-                break;
-            case PIX_FMT_YUV422P:
-                width >>= 1;
-                break;
-            case PIX_FMT_YUV411P:
-                width >>= 2;
-                break;
-            default:
-                break;
-            }
-        }
-        if (src == dst) {
-            deinterlace_bottom_field_inplace(dst->data[i], dst->linesize[i],
-                                 width, height);
-        } else {
-            deinterlace_bottom_field(dst->data[i],dst->linesize[i],
-                                        src->data[i], src->linesize[i],
-                                        width, height);
-        }
-    }
-#ifdef HAVE_MMX
-    emms();
-#endif
-    return 0;
-}
-
-#undef FIX
diff --git a/ffmpeg.src/libavcodec/imgconvert_template.h b/ffmpeg.src/libavcodec/imgconvert_template.h
deleted file mode 100644
index cd5a731..0000000
--- a/ffmpeg.src/libavcodec/imgconvert_template.h
+++ /dev/null
@@ -1,857 +0,0 @@
-/*
- * Templates for image convertion routines
- * Copyright (c) 2001, 2002, 2003 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef RGB_OUT
-#define RGB_OUT(d, r, g, b) RGBA_OUT(d, r, g, b, 0xff)
-#endif
-
-static void glue(yuv420p_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
-                                        int width, int height)
-{
-    const uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr;
-    uint8_t *d, *d1, *d2;
-    int w, y, cb, cr, r_add, g_add, b_add, width2;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-    unsigned int r, g, b;
-
-    d = dst->data[0];
-    y1_ptr = src->data[0];
-    cb_ptr = src->data[1];
-    cr_ptr = src->data[2];
-    width2 = (width + 1) >> 1;
-    for(;height >= 2; height -= 2) {
-        d1 = d;
-        d2 = d + dst->linesize[0];
-        y2_ptr = y1_ptr + src->linesize[0];
-        for(w = width; w >= 2; w -= 2) {
-            YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
-            /* output 4 pixels */
-            YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-
-            YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[1]);
-            RGB_OUT(d1 + BPP, r, g, b);
-
-            YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[0]);
-            RGB_OUT(d2, r, g, b);
-
-            YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[1]);
-            RGB_OUT(d2 + BPP, r, g, b);
-
-            d1 += 2 * BPP;
-            d2 += 2 * BPP;
-
-            y1_ptr += 2;
-            y2_ptr += 2;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        /* handle odd width */
-        if (w) {
-            YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
-            YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-
-            YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[0]);
-            RGB_OUT(d2, r, g, b);
-            d1 += BPP;
-            d2 += BPP;
-            y1_ptr++;
-            y2_ptr++;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        d += 2 * dst->linesize[0];
-        y1_ptr += 2 * src->linesize[0] - width;
-        cb_ptr += src->linesize[1] - width2;
-        cr_ptr += src->linesize[2] - width2;
-    }
-    /* handle odd height */
-    if (height) {
-        d1 = d;
-        for(w = width; w >= 2; w -= 2) {
-            YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
-            /* output 2 pixels */
-            YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-
-            YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[1]);
-            RGB_OUT(d1 + BPP, r, g, b);
-
-            d1 += 2 * BPP;
-
-            y1_ptr += 2;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        /* handle width */
-        if (w) {
-            YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
-            /* output 2 pixels */
-            YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-            d1 += BPP;
-
-            y1_ptr++;
-            cb_ptr++;
-            cr_ptr++;
-        }
-    }
-}
-
-static void glue(yuvj420p_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
-                                         int width, int height)
-{
-    const uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr;
-    uint8_t *d, *d1, *d2;
-    int w, y, cb, cr, r_add, g_add, b_add, width2;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-    unsigned int r, g, b;
-
-    d = dst->data[0];
-    y1_ptr = src->data[0];
-    cb_ptr = src->data[1];
-    cr_ptr = src->data[2];
-    width2 = (width + 1) >> 1;
-    for(;height >= 2; height -= 2) {
-        d1 = d;
-        d2 = d + dst->linesize[0];
-        y2_ptr = y1_ptr + src->linesize[0];
-        for(w = width; w >= 2; w -= 2) {
-            YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
-            /* output 4 pixels */
-            YUV_TO_RGB2(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-
-            YUV_TO_RGB2(r, g, b, y1_ptr[1]);
-            RGB_OUT(d1 + BPP, r, g, b);
-
-            YUV_TO_RGB2(r, g, b, y2_ptr[0]);
-            RGB_OUT(d2, r, g, b);
-
-            YUV_TO_RGB2(r, g, b, y2_ptr[1]);
-            RGB_OUT(d2 + BPP, r, g, b);
-
-            d1 += 2 * BPP;
-            d2 += 2 * BPP;
-
-            y1_ptr += 2;
-            y2_ptr += 2;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        /* handle odd width */
-        if (w) {
-            YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
-            YUV_TO_RGB2(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-
-            YUV_TO_RGB2(r, g, b, y2_ptr[0]);
-            RGB_OUT(d2, r, g, b);
-            d1 += BPP;
-            d2 += BPP;
-            y1_ptr++;
-            y2_ptr++;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        d += 2 * dst->linesize[0];
-        y1_ptr += 2 * src->linesize[0] - width;
-        cb_ptr += src->linesize[1] - width2;
-        cr_ptr += src->linesize[2] - width2;
-    }
-    /* handle odd height */
-    if (height) {
-        d1 = d;
-        for(w = width; w >= 2; w -= 2) {
-            YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
-            /* output 2 pixels */
-            YUV_TO_RGB2(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-
-            YUV_TO_RGB2(r, g, b, y1_ptr[1]);
-            RGB_OUT(d1 + BPP, r, g, b);
-
-            d1 += 2 * BPP;
-
-            y1_ptr += 2;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        /* handle width */
-        if (w) {
-            YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
-            /* output 2 pixels */
-            YUV_TO_RGB2(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-            d1 += BPP;
-
-            y1_ptr++;
-            cb_ptr++;
-            cr_ptr++;
-        }
-    }
-}
-
-static void glue(RGB_NAME, _to_yuv420p)(AVPicture *dst, const AVPicture *src,
-                                        int width, int height)
-{
-    int wrap, wrap3, width2;
-    int r, g, b, r1, g1, b1, w;
-    uint8_t *lum, *cb, *cr;
-    const uint8_t *p;
-
-    lum = dst->data[0];
-    cb = dst->data[1];
-    cr = dst->data[2];
-
-    width2 = (width + 1) >> 1;
-    wrap = dst->linesize[0];
-    wrap3 = src->linesize[0];
-    p = src->data[0];
-    for(;height>=2;height -= 2) {
-        for(w = width; w >= 2; w -= 2) {
-            RGB_IN(r, g, b, p);
-            r1 = r;
-            g1 = g;
-            b1 = b;
-            lum[0] = RGB_TO_Y_CCIR(r, g, b);
-
-            RGB_IN(r, g, b, p + BPP);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = RGB_TO_Y_CCIR(r, g, b);
-            p += wrap3;
-            lum += wrap;
-
-            RGB_IN(r, g, b, p);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[0] = RGB_TO_Y_CCIR(r, g, b);
-
-            RGB_IN(r, g, b, p + BPP);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = RGB_TO_Y_CCIR(r, g, b);
-
-            cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 2);
-            cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 2);
-
-            cb++;
-            cr++;
-            p += -wrap3 + 2 * BPP;
-            lum += -wrap + 2;
-        }
-        if (w) {
-            RGB_IN(r, g, b, p);
-            r1 = r;
-            g1 = g;
-            b1 = b;
-            lum[0] = RGB_TO_Y_CCIR(r, g, b);
-            p += wrap3;
-            lum += wrap;
-            RGB_IN(r, g, b, p);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[0] = RGB_TO_Y_CCIR(r, g, b);
-            cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 1);
-            cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 1);
-            cb++;
-            cr++;
-            p += -wrap3 + BPP;
-            lum += -wrap + 1;
-        }
-        p += wrap3 + (wrap3 - width * BPP);
-        lum += wrap + (wrap - width);
-        cb += dst->linesize[1] - width2;
-        cr += dst->linesize[2] - width2;
-    }
-    /* handle odd height */
-    if (height) {
-        for(w = width; w >= 2; w -= 2) {
-            RGB_IN(r, g, b, p);
-            r1 = r;
-            g1 = g;
-            b1 = b;
-            lum[0] = RGB_TO_Y_CCIR(r, g, b);
-
-            RGB_IN(r, g, b, p + BPP);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = RGB_TO_Y_CCIR(r, g, b);
-            cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 1);
-            cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 1);
-            cb++;
-            cr++;
-            p += 2 * BPP;
-           lum += 2;
-        }
-        if (w) {
-            RGB_IN(r, g, b, p);
-            lum[0] = RGB_TO_Y_CCIR(r, g, b);
-            cb[0] = RGB_TO_U_CCIR(r, g, b, 0);
-            cr[0] = RGB_TO_V_CCIR(r, g, b, 0);
-        }
-    }
-}
-
-static void glue(RGB_NAME, _to_gray)(AVPicture *dst, const AVPicture *src,
-                                     int width, int height)
-{
-    const unsigned char *p;
-    unsigned char *q;
-    int r, g, b, dst_wrap, src_wrap;
-    int x, y;
-
-    p = src->data[0];
-    src_wrap = src->linesize[0] - BPP * width;
-
-    q = dst->data[0];
-    dst_wrap = dst->linesize[0] - width;
-
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-            RGB_IN(r, g, b, p);
-            q[0] = RGB_TO_Y(r, g, b);
-            q++;
-            p += BPP;
-        }
-        p += src_wrap;
-        q += dst_wrap;
-    }
-}
-
-static void glue(gray_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
-                                     int width, int height)
-{
-    const unsigned char *p;
-    unsigned char *q;
-    int r, dst_wrap, src_wrap;
-    int x, y;
-
-    p = src->data[0];
-    src_wrap = src->linesize[0] - width;
-
-    q = dst->data[0];
-    dst_wrap = dst->linesize[0] - BPP * width;
-
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-            r = p[0];
-            RGB_OUT(q, r, r, r);
-            q += BPP;
-            p ++;
-        }
-        p += src_wrap;
-        q += dst_wrap;
-    }
-}
-
-static void glue(pal8_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
-                                     int width, int height)
-{
-    const unsigned char *p;
-    unsigned char *q;
-    int r, g, b, dst_wrap, src_wrap;
-    int x, y;
-    uint32_t v;
-    const uint32_t *palette;
-
-    p = src->data[0];
-    src_wrap = src->linesize[0] - width;
-    palette = (uint32_t *)src->data[1];
-
-    q = dst->data[0];
-    dst_wrap = dst->linesize[0] - BPP * width;
-
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-            v = palette[p[0]];
-            r = (v >> 16) & 0xff;
-            g = (v >> 8) & 0xff;
-            b = (v) & 0xff;
-#ifdef RGBA_OUT
-            {
-                int a;
-                a = (v >> 24) & 0xff;
-                RGBA_OUT(q, r, g, b, a);
-            }
-#else
-            RGB_OUT(q, r, g, b);
-#endif
-            q += BPP;
-            p ++;
-        }
-        p += src_wrap;
-        q += dst_wrap;
-    }
-}
-
-#if !defined(FMT_RGBA32) && defined(RGBA_OUT)
-/* alpha support */
-
-static void glue(rgba32_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
-                                      int width, int height)
-{
-    const uint8_t *s;
-    uint8_t *d;
-    int src_wrap, dst_wrap, j, y;
-    unsigned int v, r, g, b, a;
-
-    s = src->data[0];
-    src_wrap = src->linesize[0] - width * 4;
-
-    d = dst->data[0];
-    dst_wrap = dst->linesize[0] - width * BPP;
-
-    for(y=0;y<height;y++) {
-        for(j = 0;j < width; j++) {
-            v = ((const uint32_t *)(s))[0];
-            a = (v >> 24) & 0xff;
-            r = (v >> 16) & 0xff;
-            g = (v >> 8) & 0xff;
-            b = v & 0xff;
-            RGBA_OUT(d, r, g, b, a);
-            s += 4;
-            d += BPP;
-        }
-        s += src_wrap;
-        d += dst_wrap;
-    }
-}
-
-static void glue(RGB_NAME, _to_rgba32)(AVPicture *dst, const AVPicture *src,
-                                       int width, int height)
-{
-    const uint8_t *s;
-    uint8_t *d;
-    int src_wrap, dst_wrap, j, y;
-    unsigned int r, g, b, a;
-
-    s = src->data[0];
-    src_wrap = src->linesize[0] - width * BPP;
-
-    d = dst->data[0];
-    dst_wrap = dst->linesize[0] - width * 4;
-
-    for(y=0;y<height;y++) {
-        for(j = 0;j < width; j++) {
-            RGBA_IN(r, g, b, a, s);
-            ((uint32_t *)(d))[0] = (a << 24) | (r << 16) | (g << 8) | b;
-            d += 4;
-            s += BPP;
-        }
-        s += src_wrap;
-        d += dst_wrap;
-    }
-}
-
-#endif /* !defined(FMT_RGBA32) && defined(RGBA_IN) */
-
-#ifndef FMT_RGB24
-
-static void glue(rgb24_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
-                                      int width, int height)
-{
-    const uint8_t *s;
-    uint8_t *d;
-    int src_wrap, dst_wrap, j, y;
-    unsigned int r, g, b;
-
-    s = src->data[0];
-    src_wrap = src->linesize[0] - width * 3;
-
-    d = dst->data[0];
-    dst_wrap = dst->linesize[0] - width * BPP;
-
-    for(y=0;y<height;y++) {
-        for(j = 0;j < width; j++) {
-            r = s[0];
-            g = s[1];
-            b = s[2];
-            RGB_OUT(d, r, g, b);
-            s += 3;
-            d += BPP;
-        }
-        s += src_wrap;
-        d += dst_wrap;
-    }
-}
-
-static void glue(RGB_NAME, _to_rgb24)(AVPicture *dst, const AVPicture *src,
-                                      int width, int height)
-{
-    const uint8_t *s;
-    uint8_t *d;
-    int src_wrap, dst_wrap, j, y;
-    unsigned int r, g , b;
-
-    s = src->data[0];
-    src_wrap = src->linesize[0] - width * BPP;
-
-    d = dst->data[0];
-    dst_wrap = dst->linesize[0] - width * 3;
-
-    for(y=0;y<height;y++) {
-        for(j = 0;j < width; j++) {
-            RGB_IN(r, g, b, s)
-            d[0] = r;
-            d[1] = g;
-            d[2] = b;
-            d += 3;
-            s += BPP;
-        }
-        s += src_wrap;
-        d += dst_wrap;
-    }
-}
-
-#endif /* !FMT_RGB24 */
-
-#ifdef FMT_RGB24
-
-static void yuv444p_to_rgb24(AVPicture *dst, const AVPicture *src,
-                             int width, int height)
-{
-    const uint8_t *y1_ptr, *cb_ptr, *cr_ptr;
-    uint8_t *d, *d1;
-    int w, y, cb, cr, r_add, g_add, b_add;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-    unsigned int r, g, b;
-
-    d = dst->data[0];
-    y1_ptr = src->data[0];
-    cb_ptr = src->data[1];
-    cr_ptr = src->data[2];
-    for(;height > 0; height --) {
-        d1 = d;
-        for(w = width; w > 0; w--) {
-            YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
-
-            YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-            d1 += BPP;
-
-            y1_ptr++;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        d += dst->linesize[0];
-        y1_ptr += src->linesize[0] - width;
-        cb_ptr += src->linesize[1] - width;
-        cr_ptr += src->linesize[2] - width;
-    }
-}
-
-static void yuvj444p_to_rgb24(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    const uint8_t *y1_ptr, *cb_ptr, *cr_ptr;
-    uint8_t *d, *d1;
-    int w, y, cb, cr, r_add, g_add, b_add;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-    unsigned int r, g, b;
-
-    d = dst->data[0];
-    y1_ptr = src->data[0];
-    cb_ptr = src->data[1];
-    cr_ptr = src->data[2];
-    for(;height > 0; height --) {
-        d1 = d;
-        for(w = width; w > 0; w--) {
-            YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
-
-            YUV_TO_RGB2(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-            d1 += BPP;
-
-            y1_ptr++;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        d += dst->linesize[0];
-        y1_ptr += src->linesize[0] - width;
-        cb_ptr += src->linesize[1] - width;
-        cr_ptr += src->linesize[2] - width;
-    }
-}
-
-static void rgb24_to_yuv444p(AVPicture *dst, const AVPicture *src,
-                             int width, int height)
-{
-    int src_wrap, x, y;
-    int r, g, b;
-    uint8_t *lum, *cb, *cr;
-    const uint8_t *p;
-
-    lum = dst->data[0];
-    cb = dst->data[1];
-    cr = dst->data[2];
-
-    src_wrap = src->linesize[0] - width * BPP;
-    p = src->data[0];
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-            RGB_IN(r, g, b, p);
-            lum[0] = RGB_TO_Y_CCIR(r, g, b);
-            cb[0] = RGB_TO_U_CCIR(r, g, b, 0);
-            cr[0] = RGB_TO_V_CCIR(r, g, b, 0);
-            p += BPP;
-            cb++;
-            cr++;
-            lum++;
-        }
-        p += src_wrap;
-        lum += dst->linesize[0] - width;
-        cb += dst->linesize[1] - width;
-        cr += dst->linesize[2] - width;
-    }
-}
-
-static void rgb24_to_yuvj420p(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    int wrap, wrap3, width2;
-    int r, g, b, r1, g1, b1, w;
-    uint8_t *lum, *cb, *cr;
-    const uint8_t *p;
-
-    lum = dst->data[0];
-    cb = dst->data[1];
-    cr = dst->data[2];
-
-    width2 = (width + 1) >> 1;
-    wrap = dst->linesize[0];
-    wrap3 = src->linesize[0];
-    p = src->data[0];
-    for(;height>=2;height -= 2) {
-        for(w = width; w >= 2; w -= 2) {
-            RGB_IN(r, g, b, p);
-            r1 = r;
-            g1 = g;
-            b1 = b;
-            lum[0] = RGB_TO_Y(r, g, b);
-
-            RGB_IN(r, g, b, p + BPP);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = RGB_TO_Y(r, g, b);
-            p += wrap3;
-            lum += wrap;
-
-            RGB_IN(r, g, b, p);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[0] = RGB_TO_Y(r, g, b);
-
-            RGB_IN(r, g, b, p + BPP);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = RGB_TO_Y(r, g, b);
-
-            cb[0] = RGB_TO_U(r1, g1, b1, 2);
-            cr[0] = RGB_TO_V(r1, g1, b1, 2);
-
-            cb++;
-            cr++;
-            p += -wrap3 + 2 * BPP;
-            lum += -wrap + 2;
-        }
-        if (w) {
-            RGB_IN(r, g, b, p);
-            r1 = r;
-            g1 = g;
-            b1 = b;
-            lum[0] = RGB_TO_Y(r, g, b);
-            p += wrap3;
-            lum += wrap;
-            RGB_IN(r, g, b, p);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[0] = RGB_TO_Y(r, g, b);
-            cb[0] = RGB_TO_U(r1, g1, b1, 1);
-            cr[0] = RGB_TO_V(r1, g1, b1, 1);
-            cb++;
-            cr++;
-            p += -wrap3 + BPP;
-            lum += -wrap + 1;
-        }
-        p += wrap3 + (wrap3 - width * BPP);
-        lum += wrap + (wrap - width);
-        cb += dst->linesize[1] - width2;
-        cr += dst->linesize[2] - width2;
-    }
-    /* handle odd height */
-    if (height) {
-        for(w = width; w >= 2; w -= 2) {
-            RGB_IN(r, g, b, p);
-            r1 = r;
-            g1 = g;
-            b1 = b;
-            lum[0] = RGB_TO_Y(r, g, b);
-
-            RGB_IN(r, g, b, p + BPP);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = RGB_TO_Y(r, g, b);
-            cb[0] = RGB_TO_U(r1, g1, b1, 1);
-            cr[0] = RGB_TO_V(r1, g1, b1, 1);
-            cb++;
-            cr++;
-            p += 2 * BPP;
-           lum += 2;
-        }
-        if (w) {
-            RGB_IN(r, g, b, p);
-            lum[0] = RGB_TO_Y(r, g, b);
-            cb[0] = RGB_TO_U(r, g, b, 0);
-            cr[0] = RGB_TO_V(r, g, b, 0);
-        }
-    }
-}
-
-static void rgb24_to_yuvj444p(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    int src_wrap, x, y;
-    int r, g, b;
-    uint8_t *lum, *cb, *cr;
-    const uint8_t *p;
-
-    lum = dst->data[0];
-    cb = dst->data[1];
-    cr = dst->data[2];
-
-    src_wrap = src->linesize[0] - width * BPP;
-    p = src->data[0];
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-            RGB_IN(r, g, b, p);
-            lum[0] = RGB_TO_Y(r, g, b);
-            cb[0] = RGB_TO_U(r, g, b, 0);
-            cr[0] = RGB_TO_V(r, g, b, 0);
-            p += BPP;
-            cb++;
-            cr++;
-            lum++;
-        }
-        p += src_wrap;
-        lum += dst->linesize[0] - width;
-        cb += dst->linesize[1] - width;
-        cr += dst->linesize[2] - width;
-    }
-}
-
-#endif /* FMT_RGB24 */
-
-#if defined(FMT_RGB24) || defined(FMT_RGBA32)
-
-static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, const AVPicture *src,
-                                     int width, int height)
-{
-    const unsigned char *p;
-    unsigned char *q;
-    int dst_wrap, src_wrap;
-    int x, y, has_alpha;
-    unsigned int r, g, b;
-
-    p = src->data[0];
-    src_wrap = src->linesize[0] - BPP * width;
-
-    q = dst->data[0];
-    dst_wrap = dst->linesize[0] - width;
-    has_alpha = 0;
-    
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-#ifdef RGBA_IN
-            {
-                unsigned int a;
-                RGBA_IN(r, g, b, a, p);
-                /* crude approximation for alpha ! */
-                if (a < 0x80) {
-                    has_alpha = 1;
-                    q[0] = TRANSP_INDEX;
-                } else {
-                    q[0] = gif_clut_index(r, g, b);
-                }
-            }
-#else
-            RGB_IN(r, g, b, p);
-            q[0] = gif_clut_index(r, g, b);
-#endif
-            q++;
-            p += BPP;
-        }
-        p += src_wrap;
-        q += dst_wrap;
-    }
-
-    build_rgb_palette(dst->data[1], has_alpha);
-}
-
-#endif /* defined(FMT_RGB24) || defined(FMT_RGBA32) */
-        
-#ifdef RGBA_IN
-
-static int glue(get_alpha_info_, RGB_NAME)(const AVPicture *src,
-					   int width, int height)
-{
-    const unsigned char *p;
-    int src_wrap, ret, x, y;
-    unsigned int r, g, b, a;
-
-    p = src->data[0];
-    src_wrap = src->linesize[0] - BPP * width;
-    ret = 0;
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-            RGBA_IN(r, g, b, a, p);
-            if (a == 0x00) {
-                ret |= FF_ALPHA_TRANSP;
-            } else if (a != 0xff) {
-                ret |= FF_ALPHA_SEMI_TRANSP;
-            }
-            p += BPP;
-        }
-        p += src_wrap;
-    }
-    return ret;
-}
-
-#endif /* RGBA_IN */
-
-#undef RGB_IN
-#undef RGBA_IN
-#undef RGB_OUT
-#undef RGBA_OUT
-#undef BPP
-#undef RGB_NAME
-#undef FMT_RGB24
-#undef FMT_RGBA32
diff --git a/ffmpeg.src/libavcodec/imgresample.c b/ffmpeg.src/libavcodec/imgresample.c
deleted file mode 100644
index 53471f4..0000000
--- a/ffmpeg.src/libavcodec/imgresample.c
+++ /dev/null
@@ -1,763 +0,0 @@
-/*
- * High quality image resampling with polyphase filters 
- * Copyright (c) 2001 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-/**
- * @file imgresample.c
- * High quality image resampling with polyphase filters .
- */
- 
-#include "avcodec.h"
-#include "dsputil.h"
-
-#ifdef USE_FASTMEMCPY
-#include "fastmemcpy.h"
-#endif
-
-#define NB_COMPONENTS 3
-
-#define PHASE_BITS 4
-#define NB_PHASES  (1 << PHASE_BITS)
-#define NB_TAPS    4
-#define FCENTER    1  /* index of the center of the filter */
-//#define TEST    1  /* Test it */
-
-#define POS_FRAC_BITS 16
-#define POS_FRAC      (1 << POS_FRAC_BITS)
-/* 6 bits precision is needed for MMX */
-#define FILTER_BITS   8
-
-#define LINE_BUF_HEIGHT (NB_TAPS * 4)
-
-struct ImgReSampleContext {
-    int iwidth, iheight, owidth, oheight;
-    int topBand, bottomBand, leftBand, rightBand;
-    int padtop, padbottom, padleft, padright;
-    int pad_owidth, pad_oheight;
-    int h_incr, v_incr;
-    int16_t h_filters[NB_PHASES][NB_TAPS] __align8; /* horizontal filters */
-    int16_t v_filters[NB_PHASES][NB_TAPS] __align8; /* vertical filters */
-    uint8_t *line_buf;
-};
-
-void av_build_filter(int16_t *filter, double factor, int tap_count, int phase_count, int scale, int type);
-
-static inline int get_phase(int pos)
-{
-    return ((pos) >> (POS_FRAC_BITS - PHASE_BITS)) & ((1 << PHASE_BITS) - 1);
-}
-
-/* This function must be optimized */
-static void h_resample_fast(uint8_t *dst, int dst_width, const uint8_t *src,
-			    int src_width, int src_start, int src_incr,
-			    int16_t *filters)
-{
-    int src_pos, phase, sum, i;
-    const uint8_t *s;
-    int16_t *filter;
-
-    src_pos = src_start;
-    for(i=0;i<dst_width;i++) {
-#ifdef TEST
-        /* test */
-        if ((src_pos >> POS_FRAC_BITS) < 0 ||
-            (src_pos >> POS_FRAC_BITS) > (src_width - NB_TAPS))
-            av_abort();
-#endif
-        s = src + (src_pos >> POS_FRAC_BITS);
-        phase = get_phase(src_pos);
-        filter = filters + phase * NB_TAPS;
-#if NB_TAPS == 4
-        sum = s[0] * filter[0] +
-            s[1] * filter[1] +
-            s[2] * filter[2] +
-            s[3] * filter[3];
-#else
-        {
-            int j;
-            sum = 0;
-            for(j=0;j<NB_TAPS;j++)
-                sum += s[j] * filter[j];
-        }
-#endif
-        sum = sum >> FILTER_BITS;
-        if (sum < 0)
-            sum = 0;
-        else if (sum > 255)
-            sum = 255;
-        dst[0] = sum;
-        src_pos += src_incr;
-        dst++;
-    }
-}
-
-/* This function must be optimized */
-static void v_resample(uint8_t *dst, int dst_width, const uint8_t *src,
-		       int wrap, int16_t *filter)
-{
-    int sum, i;
-    const uint8_t *s;
-
-    s = src;
-    for(i=0;i<dst_width;i++) {
-#if NB_TAPS == 4
-        sum = s[0 * wrap] * filter[0] +
-            s[1 * wrap] * filter[1] +
-            s[2 * wrap] * filter[2] +
-            s[3 * wrap] * filter[3];
-#else
-        {
-            int j;
-            uint8_t *s1 = s;
-
-            sum = 0;
-            for(j=0;j<NB_TAPS;j++) {
-                sum += s1[0] * filter[j];
-                s1 += wrap;
-            }
-        }
-#endif
-        sum = sum >> FILTER_BITS;
-        if (sum < 0)
-            sum = 0;
-        else if (sum > 255)
-            sum = 255;
-        dst[0] = sum;
-        dst++;
-        s++;
-    }
-}
-
-#ifdef HAVE_MMX
-
-#include "i386/mmx.h"
-
-#define FILTER4(reg) \
-{\
-        s = src + (src_pos >> POS_FRAC_BITS);\
-        phase = get_phase(src_pos);\
-        filter = filters + phase * NB_TAPS;\
-        movq_m2r(*s, reg);\
-        punpcklbw_r2r(mm7, reg);\
-        movq_m2r(*filter, mm6);\
-        pmaddwd_r2r(reg, mm6);\
-        movq_r2r(mm6, reg);\
-        psrlq_i2r(32, reg);\
-        paddd_r2r(mm6, reg);\
-        psrad_i2r(FILTER_BITS, reg);\
-        src_pos += src_incr;\
-}
-
-#define DUMP(reg) movq_r2m(reg, tmp); printf(#reg "=%016Lx\n", tmp.uq);
-
-/* XXX: do four pixels at a time */
-static void h_resample_fast4_mmx(uint8_t *dst, int dst_width,
-				 const uint8_t *src, int src_width,
-                                 int src_start, int src_incr, int16_t *filters)
-{
-    int src_pos, phase;
-    const uint8_t *s;
-    int16_t *filter;
-    mmx_t tmp;
-    
-    src_pos = src_start;
-    pxor_r2r(mm7, mm7);
-
-    while (dst_width >= 4) {
-
-        FILTER4(mm0);
-        FILTER4(mm1);
-        FILTER4(mm2);
-        FILTER4(mm3);
-
-        packuswb_r2r(mm7, mm0);
-        packuswb_r2r(mm7, mm1);
-        packuswb_r2r(mm7, mm3);
-        packuswb_r2r(mm7, mm2);
-        movq_r2m(mm0, tmp);
-        dst[0] = tmp.ub[0];
-        movq_r2m(mm1, tmp);
-        dst[1] = tmp.ub[0];
-        movq_r2m(mm2, tmp);
-        dst[2] = tmp.ub[0];
-        movq_r2m(mm3, tmp);
-        dst[3] = tmp.ub[0];
-        dst += 4;
-        dst_width -= 4;
-    }
-    while (dst_width > 0) {
-        FILTER4(mm0);
-        packuswb_r2r(mm7, mm0);
-        movq_r2m(mm0, tmp);
-        dst[0] = tmp.ub[0];
-        dst++;
-        dst_width--;
-    }
-    emms();
-}
-
-static void v_resample4_mmx(uint8_t *dst, int dst_width, const uint8_t *src,
-			    int wrap, int16_t *filter)
-{
-    int sum, i, v;
-    const uint8_t *s;
-    mmx_t tmp;
-    mmx_t coefs[4];
-    
-    for(i=0;i<4;i++) {
-        v = filter[i];
-        coefs[i].uw[0] = v;
-        coefs[i].uw[1] = v;
-        coefs[i].uw[2] = v;
-        coefs[i].uw[3] = v;
-    }
-    
-    pxor_r2r(mm7, mm7);
-    s = src;
-    while (dst_width >= 4) {
-        movq_m2r(s[0 * wrap], mm0);
-        punpcklbw_r2r(mm7, mm0);
-        movq_m2r(s[1 * wrap], mm1);
-        punpcklbw_r2r(mm7, mm1);
-        movq_m2r(s[2 * wrap], mm2);
-        punpcklbw_r2r(mm7, mm2);
-        movq_m2r(s[3 * wrap], mm3);
-        punpcklbw_r2r(mm7, mm3);
-
-        pmullw_m2r(coefs[0], mm0);
-        pmullw_m2r(coefs[1], mm1);
-        pmullw_m2r(coefs[2], mm2);
-        pmullw_m2r(coefs[3], mm3);
-
-        paddw_r2r(mm1, mm0);
-        paddw_r2r(mm3, mm2);
-        paddw_r2r(mm2, mm0);
-        psraw_i2r(FILTER_BITS, mm0);
-        
-        packuswb_r2r(mm7, mm0);
-        movq_r2m(mm0, tmp);
-
-        *(uint32_t *)dst = tmp.ud[0];
-        dst += 4;
-        s += 4;
-        dst_width -= 4;
-    }
-    while (dst_width > 0) {
-        sum = s[0 * wrap] * filter[0] +
-            s[1 * wrap] * filter[1] +
-            s[2 * wrap] * filter[2] +
-            s[3 * wrap] * filter[3];
-        sum = sum >> FILTER_BITS;
-        if (sum < 0)
-            sum = 0;
-        else if (sum > 255)
-            sum = 255;
-        dst[0] = sum;
-        dst++;
-        s++;
-        dst_width--;
-    }
-    emms();
-}
-#endif
-
-#ifdef HAVE_ALTIVEC
-typedef	union {
-    vector unsigned char v;
-    unsigned char c[16];
-} vec_uc_t;
-
-typedef	union {
-    vector signed short v;
-    signed short s[8];
-} vec_ss_t;
-
-void v_resample16_altivec(uint8_t *dst, int dst_width, const uint8_t *src,
-			  int wrap, int16_t *filter)
-{
-    int sum, i;
-    const uint8_t *s;
-    vector unsigned char *tv, tmp, dstv, zero;
-    vec_ss_t srchv[4], srclv[4], fv[4];
-    vector signed short zeros, sumhv, sumlv;    
-    s = src;
-
-    for(i=0;i<4;i++)
-    {
-        /*
-           The vec_madds later on does an implicit >>15 on the result.
-           Since FILTER_BITS is 8, and we have 15 bits of magnitude in
-           a signed short, we have just enough bits to pre-shift our
-           filter constants <<7 to compensate for vec_madds.
-        */
-        fv[i].s[0] = filter[i] << (15-FILTER_BITS);
-        fv[i].v = vec_splat(fv[i].v, 0);
-    }
-    
-    zero = vec_splat_u8(0);
-    zeros = vec_splat_s16(0);
-
-
-    /*
-       When we're resampling, we'd ideally like both our input buffers,
-       and output buffers to be 16-byte aligned, so we can do both aligned
-       reads and writes. Sadly we can't always have this at the moment, so
-       we opt for aligned writes, as unaligned writes have a huge overhead.
-       To do this, do enough scalar resamples to get dst 16-byte aligned.
-    */
-    i = (-(int)dst) & 0xf;
-    while(i>0) {
-        sum = s[0 * wrap] * filter[0] +
-        s[1 * wrap] * filter[1] +
-        s[2 * wrap] * filter[2] +
-        s[3 * wrap] * filter[3];
-        sum = sum >> FILTER_BITS;
-        if (sum<0) sum = 0; else if (sum>255) sum=255;
-        dst[0] = sum;
-        dst++;
-        s++;
-        dst_width--;
-        i--;
-    }
-    
-    /* Do our altivec resampling on 16 pixels at once. */
-    while(dst_width>=16) {
-        /*
-           Read 16 (potentially unaligned) bytes from each of
-           4 lines into 4 vectors, and split them into shorts.
-           Interleave the multipy/accumulate for the resample
-           filter with the loads to hide the 3 cycle latency
-           the vec_madds have.
-        */
-        tv = (vector unsigned char *) &s[0 * wrap];
-        tmp = vec_perm(tv[0], tv[1], vec_lvsl(0, &s[i * wrap]));
-        srchv[0].v = (vector signed short) vec_mergeh(zero, tmp);
-        srclv[0].v = (vector signed short) vec_mergel(zero, tmp);
-        sumhv = vec_madds(srchv[0].v, fv[0].v, zeros);
-        sumlv = vec_madds(srclv[0].v, fv[0].v, zeros);
-
-        tv = (vector unsigned char *) &s[1 * wrap];
-        tmp = vec_perm(tv[0], tv[1], vec_lvsl(0, &s[1 * wrap]));
-        srchv[1].v = (vector signed short) vec_mergeh(zero, tmp);
-        srclv[1].v = (vector signed short) vec_mergel(zero, tmp);
-        sumhv = vec_madds(srchv[1].v, fv[1].v, sumhv);
-        sumlv = vec_madds(srclv[1].v, fv[1].v, sumlv);
-
-        tv = (vector unsigned char *) &s[2 * wrap];
-        tmp = vec_perm(tv[0], tv[1], vec_lvsl(0, &s[2 * wrap]));
-        srchv[2].v = (vector signed short) vec_mergeh(zero, tmp);
-        srclv[2].v = (vector signed short) vec_mergel(zero, tmp);
-        sumhv = vec_madds(srchv[2].v, fv[2].v, sumhv);
-        sumlv = vec_madds(srclv[2].v, fv[2].v, sumlv);
-
-        tv = (vector unsigned char *) &s[3 * wrap];
-        tmp = vec_perm(tv[0], tv[1], vec_lvsl(0, &s[3 * wrap]));
-        srchv[3].v = (vector signed short) vec_mergeh(zero, tmp);
-        srclv[3].v = (vector signed short) vec_mergel(zero, tmp);
-        sumhv = vec_madds(srchv[3].v, fv[3].v, sumhv);
-        sumlv = vec_madds(srclv[3].v, fv[3].v, sumlv);
-    
-        /*
-           Pack the results into our destination vector,
-           and do an aligned write of that back to memory.
-        */
-        dstv = vec_packsu(sumhv, sumlv) ;
-        vec_st(dstv, 0, (vector unsigned char *) dst);
-        
-        dst+=16;
-        s+=16;
-        dst_width-=16;
-    }
-
-    /*
-       If there are any leftover pixels, resample them
-       with the slow scalar method.
-    */
-    while(dst_width>0) {
-        sum = s[0 * wrap] * filter[0] +
-        s[1 * wrap] * filter[1] +
-        s[2 * wrap] * filter[2] +
-        s[3 * wrap] * filter[3];
-        sum = sum >> FILTER_BITS;
-        if (sum<0) sum = 0; else if (sum>255) sum=255;
-        dst[0] = sum;
-        dst++;
-        s++;
-        dst_width--;
-    }
-}
-#endif
-
-/* slow version to handle limit cases. Does not need optimisation */
-static void h_resample_slow(uint8_t *dst, int dst_width,
-			    const uint8_t *src, int src_width,
-                            int src_start, int src_incr, int16_t *filters)
-{
-    int src_pos, phase, sum, j, v, i;
-    const uint8_t *s, *src_end;
-    int16_t *filter;
-
-    src_end = src + src_width;
-    src_pos = src_start;
-    for(i=0;i<dst_width;i++) {
-        s = src + (src_pos >> POS_FRAC_BITS);
-        phase = get_phase(src_pos);
-        filter = filters + phase * NB_TAPS;
-        sum = 0;
-        for(j=0;j<NB_TAPS;j++) {
-            if (s < src)
-                v = src[0];
-            else if (s >= src_end)
-                v = src_end[-1];
-            else
-                v = s[0];
-            sum += v * filter[j];
-            s++;
-        }
-        sum = sum >> FILTER_BITS;
-        if (sum < 0)
-            sum = 0;
-        else if (sum > 255)
-            sum = 255;
-        dst[0] = sum;
-        src_pos += src_incr;
-        dst++;
-    }
-}
-
-static void h_resample(uint8_t *dst, int dst_width, const uint8_t *src,
-		       int src_width, int src_start, int src_incr,
-		       int16_t *filters)
-{
-    int n, src_end;
-
-    if (src_start < 0) {
-        n = (0 - src_start + src_incr - 1) / src_incr;
-        h_resample_slow(dst, n, src, src_width, src_start, src_incr, filters);
-        dst += n;
-        dst_width -= n;
-        src_start += n * src_incr;
-    }
-    src_end = src_start + dst_width * src_incr;
-    if (src_end > ((src_width - NB_TAPS) << POS_FRAC_BITS)) {
-        n = (((src_width - NB_TAPS + 1) << POS_FRAC_BITS) - 1 - src_start) / 
-            src_incr;
-    } else {
-        n = dst_width;
-    }
-#ifdef HAVE_MMX
-    if ((mm_flags & MM_MMX) && NB_TAPS == 4)
-        h_resample_fast4_mmx(dst, n, 
-                             src, src_width, src_start, src_incr, filters);
-    else
-#endif
-        h_resample_fast(dst, n, 
-                        src, src_width, src_start, src_incr, filters);
-    if (n < dst_width) {
-        dst += n;
-        dst_width -= n;
-        src_start += n * src_incr;
-        h_resample_slow(dst, dst_width, 
-                        src, src_width, src_start, src_incr, filters);
-    }
-}
-
-static void component_resample(ImgReSampleContext *s, 
-                               uint8_t *output, int owrap, int owidth, int oheight,
-                               uint8_t *input, int iwrap, int iwidth, int iheight)
-{
-    int src_y, src_y1, last_src_y, ring_y, phase_y, y1, y;
-    uint8_t *new_line, *src_line;
-
-    last_src_y = - FCENTER - 1;
-    /* position of the bottom of the filter in the source image */
-    src_y = (last_src_y + NB_TAPS) * POS_FRAC; 
-    ring_y = NB_TAPS; /* position in ring buffer */
-    for(y=0;y<oheight;y++) {
-        /* apply horizontal filter on new lines from input if needed */
-        src_y1 = src_y >> POS_FRAC_BITS;
-        while (last_src_y < src_y1) {
-            if (++ring_y >= LINE_BUF_HEIGHT + NB_TAPS)
-                ring_y = NB_TAPS;
-            last_src_y++;
-            /* handle limit conditions : replicate line (slightly
-               inefficient because we filter multiple times) */
-            y1 = last_src_y;
-            if (y1 < 0) {
-                y1 = 0;
-            } else if (y1 >= iheight) {
-                y1 = iheight - 1;
-            }
-            src_line = input + y1 * iwrap;
-            new_line = s->line_buf + ring_y * owidth;
-            /* apply filter and handle limit cases correctly */
-            h_resample(new_line, owidth, 
-                       src_line, iwidth, - FCENTER * POS_FRAC, s->h_incr, 
-                       &s->h_filters[0][0]);
-            /* handle ring buffer wraping */
-            if (ring_y >= LINE_BUF_HEIGHT) {
-                memcpy(s->line_buf + (ring_y - LINE_BUF_HEIGHT) * owidth,
-                       new_line, owidth);
-            }
-        }
-        /* apply vertical filter */
-        phase_y = get_phase(src_y);
-#ifdef HAVE_MMX
-        /* desactivated MMX because loss of precision */
-        if ((mm_flags & MM_MMX) && NB_TAPS == 4 && 0)
-            v_resample4_mmx(output, owidth, 
-                            s->line_buf + (ring_y - NB_TAPS + 1) * owidth, owidth, 
-                            &s->v_filters[phase_y][0]);
-        else
-#endif
-#ifdef HAVE_ALTIVEC
-            if ((mm_flags & MM_ALTIVEC) && NB_TAPS == 4 && FILTER_BITS <= 6)
-                v_resample16_altivec(output, owidth,
-                                s->line_buf + (ring_y - NB_TAPS + 1) * owidth, owidth,
-                                &s->v_filters[phase_y][0]);
-        else
-#endif
-            v_resample(output, owidth, 
-                       s->line_buf + (ring_y - NB_TAPS + 1) * owidth, owidth, 
-                       &s->v_filters[phase_y][0]);
-            
-        src_y += s->v_incr;
-        
-        output += owrap;
-    }
-}
-
-ImgReSampleContext *img_resample_init(int owidth, int oheight,
-                                      int iwidth, int iheight)
-{
-    return img_resample_full_init(owidth, oheight, iwidth, iheight, 
-            0, 0, 0, 0, 0, 0, 0, 0);
-}
-
-ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
-                                      int iwidth, int iheight,
-                                      int topBand, int bottomBand,
-        int leftBand, int rightBand,
-        int padtop, int padbottom,
-        int padleft, int padright)
-{
-    ImgReSampleContext *s;
-
-    s = av_mallocz(sizeof(ImgReSampleContext));
-    if (!s)
-        return NULL;
-    if((unsigned)owidth >= UINT_MAX / (LINE_BUF_HEIGHT + NB_TAPS))
-        return NULL;
-    s->line_buf = av_mallocz(owidth * (LINE_BUF_HEIGHT + NB_TAPS));
-    if (!s->line_buf) 
-        goto fail;
-    
-    s->owidth = owidth;
-    s->oheight = oheight;
-    s->iwidth = iwidth;
-    s->iheight = iheight;
-  
-    s->topBand = topBand;
-    s->bottomBand = bottomBand;
-    s->leftBand = leftBand;
-    s->rightBand = rightBand;
-    
-    s->padtop = padtop;
-    s->padbottom = padbottom;
-    s->padleft = padleft;
-    s->padright = padright;
-
-    s->pad_owidth = owidth - (padleft + padright);
-    s->pad_oheight = oheight - (padtop + padbottom);
-
-    s->h_incr = ((iwidth - leftBand - rightBand) * POS_FRAC) / s->pad_owidth;
-    s->v_incr = ((iheight - topBand - bottomBand) * POS_FRAC) / s->pad_oheight; 
-
-    av_build_filter(&s->h_filters[0][0], (float) s->pad_owidth  / 
-            (float) (iwidth - leftBand - rightBand), NB_TAPS, NB_PHASES, 1<<FILTER_BITS, 0);
-    av_build_filter(&s->v_filters[0][0], (float) s->pad_oheight / 
-            (float) (iheight - topBand - bottomBand), NB_TAPS, NB_PHASES, 1<<FILTER_BITS, 0);
-
-    return s;
-fail:
-    av_free(s);
-    return NULL;
-}
-
-void img_resample(ImgReSampleContext *s, 
-                  AVPicture *output, const AVPicture *input)
-{
-    int i, shift;
-    uint8_t* optr;
-
-    for (i=0;i<3;i++) {
-        shift = (i == 0) ? 0 : 1;
-
-        optr = output->data[i] + (((output->linesize[i] * 
-                        s->padtop) + s->padleft) >> shift);
-
-        component_resample(s, optr, output->linesize[i], 
-                s->pad_owidth >> shift, s->pad_oheight >> shift,
-                input->data[i] + (input->linesize[i] * 
-                    (s->topBand >> shift)) + (s->leftBand >> shift),
-                input->linesize[i], ((s->iwidth - s->leftBand - 
-                        s->rightBand) >> shift),
-                           (s->iheight - s->topBand - s->bottomBand) >> shift);
-    }
-}
-
-void img_resample_close(ImgReSampleContext *s)
-{
-    av_free(s->line_buf);
-    av_free(s);
-}
-
-#ifdef TEST
-#include <stdio.h>
-
-/* input */
-#define XSIZE 256
-#define YSIZE 256
-uint8_t img[XSIZE * YSIZE];
-
-/* output */
-#define XSIZE1 512
-#define YSIZE1 512
-uint8_t img1[XSIZE1 * YSIZE1];
-uint8_t img2[XSIZE1 * YSIZE1];
-
-void save_pgm(const char *filename, uint8_t *img, int xsize, int ysize)
-{
-#undef fprintf
-    FILE *f;
-    f=fopen(filename,"w");
-    fprintf(f,"P5\n%d %d\n%d\n", xsize, ysize, 255);
-    fwrite(img,1, xsize * ysize,f);
-    fclose(f);
-#define fprintf please_use_av_log
-}
-
-static void dump_filter(int16_t *filter)
-{
-    int i, ph;
-
-    for(ph=0;ph<NB_PHASES;ph++) {
-        av_log(NULL, AV_LOG_INFO, "%2d: ", ph);
-        for(i=0;i<NB_TAPS;i++) {
-            av_log(NULL, AV_LOG_INFO, " %5.2f", filter[ph * NB_TAPS + i] / 256.0);
-        }
-        av_log(NULL, AV_LOG_INFO, "\n");
-    }
-}
-
-#ifdef HAVE_MMX
-int mm_flags;
-#endif
-
-int main(int argc, char **argv)
-{
-    int x, y, v, i, xsize, ysize;
-    ImgReSampleContext *s;
-    float fact, factors[] = { 1/2.0, 3.0/4.0, 1.0, 4.0/3.0, 16.0/9.0, 2.0 };
-    char buf[256];
-
-    /* build test image */
-    for(y=0;y<YSIZE;y++) {
-        for(x=0;x<XSIZE;x++) {
-            if (x < XSIZE/2 && y < YSIZE/2) {
-                if (x < XSIZE/4 && y < YSIZE/4) {
-                    if ((x % 10) <= 6 &&
-                        (y % 10) <= 6)
-                        v = 0xff;
-                    else
-                        v = 0x00;
-                } else if (x < XSIZE/4) {
-                    if (x & 1) 
-                        v = 0xff;
-                    else 
-                        v = 0;
-                } else if (y < XSIZE/4) {
-                    if (y & 1) 
-                        v = 0xff;
-                    else 
-                        v = 0;
-                } else {
-                    if (y < YSIZE*3/8) {
-                        if ((y+x) & 1) 
-                            v = 0xff;
-                        else 
-                            v = 0;
-                    } else {
-                        if (((x+3) % 4) <= 1 &&
-                            ((y+3) % 4) <= 1)
-                            v = 0xff;
-                        else
-                            v = 0x00;
-                    }
-                }
-            } else if (x < XSIZE/2) {
-                v = ((x - (XSIZE/2)) * 255) / (XSIZE/2);
-            } else if (y < XSIZE/2) {
-                v = ((y - (XSIZE/2)) * 255) / (XSIZE/2);
-            } else {
-                v = ((x + y - XSIZE) * 255) / XSIZE;
-            }
-            img[(YSIZE - y) * XSIZE + (XSIZE - x)] = v;
-        }
-    }
-    save_pgm("/tmp/in.pgm", img, XSIZE, YSIZE);
-    for(i=0;i<sizeof(factors)/sizeof(float);i++) {
-        fact = factors[i];
-        xsize = (int)(XSIZE * fact);
-        ysize = (int)((YSIZE - 100) * fact);
-        s = img_resample_full_init(xsize, ysize, XSIZE, YSIZE, 50 ,50, 0, 0, 0, 0, 0, 0);
-        av_log(NULL, AV_LOG_INFO, "Factor=%0.2f\n", fact);
-        dump_filter(&s->h_filters[0][0]);
-        component_resample(s, img1, xsize, xsize, ysize,
-                           img + 50 * XSIZE, XSIZE, XSIZE, YSIZE - 100);
-        img_resample_close(s);
-
-        snprintf(buf, sizeof(buf), "/tmp/out%d.pgm", i);
-        save_pgm(buf, img1, xsize, ysize);
-    }
-
-    /* mmx test */
-#ifdef HAVE_MMX
-    av_log(NULL, AV_LOG_INFO, "MMX test\n");
-    fact = 0.72;
-    xsize = (int)(XSIZE * fact);
-    ysize = (int)(YSIZE * fact);
-    mm_flags = MM_MMX;
-    s = img_resample_init(xsize, ysize, XSIZE, YSIZE);
-    component_resample(s, img1, xsize, xsize, ysize,
-                       img, XSIZE, XSIZE, YSIZE);
-
-    mm_flags = 0;
-    s = img_resample_init(xsize, ysize, XSIZE, YSIZE);
-    component_resample(s, img2, xsize, xsize, ysize,
-                       img, XSIZE, XSIZE, YSIZE);
-    if (memcmp(img1, img2, xsize * ysize) != 0) {
-        av_log(NULL, AV_LOG_ERROR, "mmx error\n");
-        exit(1);
-    }
-    av_log(NULL, AV_LOG_INFO, "MMX OK\n");
-#endif
-    return 0;
-}
-
-#endif
diff --git a/ffmpeg.src/libavcodec/jfdctfst.c b/ffmpeg.src/libavcodec/jfdctfst.c
deleted file mode 100644
index a393c5c..0000000
--- a/ffmpeg.src/libavcodec/jfdctfst.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * jfdctfst.c
- *
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README file.
- *
- * This file contains a fast, not so accurate integer implementation of the
- * forward DCT (Discrete Cosine Transform).
- *
- * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
- * on each column.  Direct algorithms are also available, but they are
- * much more complex and seem not to be any faster when reduced to code.
- *
- * This implementation is based on Arai, Agui, and Nakajima's algorithm for
- * scaled DCT.  Their original paper (Trans. IEICE E-71(11):1095) is in
- * Japanese, but the algorithm is described in the Pennebaker & Mitchell
- * JPEG textbook (see REFERENCES section in file README).  The following code
- * is based directly on figure 4-8 in P&M.
- * While an 8-point DCT cannot be done in less than 11 multiplies, it is
- * possible to arrange the computation so that many of the multiplies are
- * simple scalings of the final outputs.  These multiplies can then be
- * folded into the multiplications or divisions by the JPEG quantization
- * table entries.  The AA&N method leaves only 5 multiplies and 29 adds
- * to be done in the DCT itself.
- * The primary disadvantage of this method is that with fixed-point math,
- * accuracy is lost due to imprecise representation of the scaled
- * quantization values.  The smaller the quantization table entry, the less
- * precise the scaled value, so this implementation does worse with high-
- * quality-setting files than with low-quality ones.
- */
-
-/**
- * @file jfdctfst.c
- * Independent JPEG Group's fast AAN dct.
- */
- 
-#include <stdlib.h>
-#include <stdio.h>
-#include "common.h"
-#include "dsputil.h"
-
-#define DCTSIZE 8
-#define GLOBAL(x) x
-#define RIGHT_SHIFT(x, n) ((x) >> (n))
-#define SHIFT_TEMPS
-
-/*
- * This module is specialized to the case DCTSIZE = 8.
- */
-
-#if DCTSIZE != 8
-  Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
-#endif
-
-
-/* Scaling decisions are generally the same as in the LL&M algorithm;
- * see jfdctint.c for more details.  However, we choose to descale
- * (right shift) multiplication products as soon as they are formed,
- * rather than carrying additional fractional bits into subsequent additions.
- * This compromises accuracy slightly, but it lets us save a few shifts.
- * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples)
- * everywhere except in the multiplications proper; this saves a good deal
- * of work on 16-bit-int machines.
- *
- * Again to save a few shifts, the intermediate results between pass 1 and
- * pass 2 are not upscaled, but are represented only to integral precision.
- *
- * A final compromise is to represent the multiplicative constants to only
- * 8 fractional bits, rather than 13.  This saves some shifting work on some
- * machines, and may also reduce the cost of multiplication (since there
- * are fewer one-bits in the constants).
- */
-
-#define CONST_BITS  8
-
-
-/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
- * causing a lot of useless floating-point operations at run time.
- * To get around this we use the following pre-calculated constants.
- * If you change CONST_BITS you may want to add appropriate values.
- * (With a reasonable C compiler, you can just rely on the FIX() macro...)
- */
-
-#if CONST_BITS == 8
-#define FIX_0_382683433  ((int32_t)   98)		/* FIX(0.382683433) */
-#define FIX_0_541196100  ((int32_t)  139)		/* FIX(0.541196100) */
-#define FIX_0_707106781  ((int32_t)  181)		/* FIX(0.707106781) */
-#define FIX_1_306562965  ((int32_t)  334)		/* FIX(1.306562965) */
-#else
-#define FIX_0_382683433  FIX(0.382683433)
-#define FIX_0_541196100  FIX(0.541196100)
-#define FIX_0_707106781  FIX(0.707106781)
-#define FIX_1_306562965  FIX(1.306562965)
-#endif
-
-
-/* We can gain a little more speed, with a further compromise in accuracy,
- * by omitting the addition in a descaling shift.  This yields an incorrectly
- * rounded result half the time...
- */
-
-#ifndef USE_ACCURATE_ROUNDING
-#undef DESCALE
-#define DESCALE(x,n)  RIGHT_SHIFT(x, n)
-#endif
-
-
-/* Multiply a DCTELEM variable by an int32_t constant, and immediately
- * descale to yield a DCTELEM result.
- */
-
-#define MULTIPLY(var,const)  ((DCTELEM) DESCALE((var) * (const), CONST_BITS))
-
-static always_inline void row_fdct(DCTELEM * data){
-  int_fast16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
-  int_fast16_t tmp10, tmp11, tmp12, tmp13;
-  int_fast16_t z1, z2, z3, z4, z5, z11, z13;
-  DCTELEM *dataptr;
-  int ctr;
-  SHIFT_TEMPS
-
-  /* Pass 1: process rows. */
-
-  dataptr = data;
-  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
-    tmp0 = dataptr[0] + dataptr[7];
-    tmp7 = dataptr[0] - dataptr[7];
-    tmp1 = dataptr[1] + dataptr[6];
-    tmp6 = dataptr[1] - dataptr[6];
-    tmp2 = dataptr[2] + dataptr[5];
-    tmp5 = dataptr[2] - dataptr[5];
-    tmp3 = dataptr[3] + dataptr[4];
-    tmp4 = dataptr[3] - dataptr[4];
-    
-    /* Even part */
-    
-    tmp10 = tmp0 + tmp3;	/* phase 2 */
-    tmp13 = tmp0 - tmp3;
-    tmp11 = tmp1 + tmp2;
-    tmp12 = tmp1 - tmp2;
-    
-    dataptr[0] = tmp10 + tmp11; /* phase 3 */
-    dataptr[4] = tmp10 - tmp11;
-    
-    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */
-    dataptr[2] = tmp13 + z1;	/* phase 5 */
-    dataptr[6] = tmp13 - z1;
-    
-    /* Odd part */
-
-    tmp10 = tmp4 + tmp5;	/* phase 2 */
-    tmp11 = tmp5 + tmp6;
-    tmp12 = tmp6 + tmp7;
-
-    /* The rotator is modified from fig 4-8 to avoid extra negations. */
-    z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */
-    z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */
-    z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */
-    z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */
-
-    z11 = tmp7 + z3;		/* phase 5 */
-    z13 = tmp7 - z3;
-
-    dataptr[5] = z13 + z2;	/* phase 6 */
-    dataptr[3] = z13 - z2;
-    dataptr[1] = z11 + z4;
-    dataptr[7] = z11 - z4;
-
-    dataptr += DCTSIZE;		/* advance pointer to next row */
-  }
-}
-
-/*
- * Perform the forward DCT on one block of samples.
- */
-
-GLOBAL(void)
-fdct_ifast (DCTELEM * data)
-{
-  int_fast16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
-  int_fast16_t tmp10, tmp11, tmp12, tmp13;
-  int_fast16_t z1, z2, z3, z4, z5, z11, z13;
-  DCTELEM *dataptr;
-  int ctr;
-  SHIFT_TEMPS
-
-  row_fdct(data);
-  
-  /* Pass 2: process columns. */
-
-  dataptr = data;
-  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
-    tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
-    tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
-    tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
-    tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
-    tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
-    tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
-    tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
-    tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
-    
-    /* Even part */
-    
-    tmp10 = tmp0 + tmp3;	/* phase 2 */
-    tmp13 = tmp0 - tmp3;
-    tmp11 = tmp1 + tmp2;
-    tmp12 = tmp1 - tmp2;
-    
-    dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */
-    dataptr[DCTSIZE*4] = tmp10 - tmp11;
-    
-    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */
-    dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */
-    dataptr[DCTSIZE*6] = tmp13 - z1;
-    
-    /* Odd part */
-
-    tmp10 = tmp4 + tmp5;	/* phase 2 */
-    tmp11 = tmp5 + tmp6;
-    tmp12 = tmp6 + tmp7;
-
-    /* The rotator is modified from fig 4-8 to avoid extra negations. */
-    z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */
-    z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */
-    z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */
-    z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */
-
-    z11 = tmp7 + z3;		/* phase 5 */
-    z13 = tmp7 - z3;
-
-    dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */
-    dataptr[DCTSIZE*3] = z13 - z2;
-    dataptr[DCTSIZE*1] = z11 + z4;
-    dataptr[DCTSIZE*7] = z11 - z4;
-
-    dataptr++;			/* advance pointer to next column */
-  }
-}
-
-/*
- * Perform the forward 2-4-8 DCT on one block of samples.
- */
-
-GLOBAL(void)
-fdct_ifast248 (DCTELEM * data)
-{
-  int_fast16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
-  int_fast16_t tmp10, tmp11, tmp12, tmp13;
-  int_fast16_t z1;
-  DCTELEM *dataptr;
-  int ctr;
-  SHIFT_TEMPS
-
-  row_fdct(data);
-   
-  /* Pass 2: process columns. */
-
-  dataptr = data;
-  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
-    tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*1];
-    tmp1 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*3];
-    tmp2 = dataptr[DCTSIZE*4] + dataptr[DCTSIZE*5];
-    tmp3 = dataptr[DCTSIZE*6] + dataptr[DCTSIZE*7];
-    tmp4 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*1];
-    tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*3];
-    tmp6 = dataptr[DCTSIZE*4] - dataptr[DCTSIZE*5];
-    tmp7 = dataptr[DCTSIZE*6] - dataptr[DCTSIZE*7];
-
-    /* Even part */
-    
-    tmp10 = tmp0 + tmp3;
-    tmp11 = tmp1 + tmp2;
-    tmp12 = tmp1 - tmp2;
-    tmp13 = tmp0 - tmp3;
-    
-    dataptr[DCTSIZE*0] = tmp10 + tmp11;
-    dataptr[DCTSIZE*4] = tmp10 - tmp11;
-    
-    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781);
-    dataptr[DCTSIZE*2] = tmp13 + z1;
-    dataptr[DCTSIZE*6] = tmp13 - z1;
-
-    tmp10 = tmp4 + tmp7;
-    tmp11 = tmp5 + tmp6;
-    tmp12 = tmp5 - tmp6;
-    tmp13 = tmp4 - tmp7;
-    
-    dataptr[DCTSIZE*1] = tmp10 + tmp11;
-    dataptr[DCTSIZE*5] = tmp10 - tmp11;
-    
-    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781);
-    dataptr[DCTSIZE*3] = tmp13 + z1;
-    dataptr[DCTSIZE*7] = tmp13 - z1;
-    
-    dataptr++;			/* advance pointer to next column */
-  }
-}
-
-
-#undef GLOBAL
-#undef CONST_BITS
-#undef DESCALE
-#undef FIX_0_541196100
-#undef FIX_1_306562965
diff --git a/ffmpeg.src/libavcodec/jfdctint.c b/ffmpeg.src/libavcodec/jfdctint.c
deleted file mode 100644
index 1fbd85b..0000000
--- a/ffmpeg.src/libavcodec/jfdctint.c
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * jfdctint.c
- *
- * Copyright (C) 1991-1996, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README file.
- *
- * This file contains a slow-but-accurate integer implementation of the
- * forward DCT (Discrete Cosine Transform).
- *
- * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
- * on each column.  Direct algorithms are also available, but they are
- * much more complex and seem not to be any faster when reduced to code.
- *
- * This implementation is based on an algorithm described in
- *   C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT
- *   Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics,
- *   Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991.
- * The primary algorithm described there uses 11 multiplies and 29 adds.
- * We use their alternate method with 12 multiplies and 32 adds.
- * The advantage of this method is that no data path contains more than one
- * multiplication; this allows a very simple and accurate implementation in
- * scaled fixed-point arithmetic, with a minimal number of shifts.
- */
-
-/**
- * @file jfdctint.c
- * Independent JPEG Group's slow & accurate dct.
- */
- 
-#include <stdlib.h>
-#include <stdio.h>
-#include "common.h"
-#include "dsputil.h"
-
-#define SHIFT_TEMPS
-#define DCTSIZE 8
-#define BITS_IN_JSAMPLE 8
-#define GLOBAL(x) x
-#define RIGHT_SHIFT(x, n) ((x) >> (n))
-#define MULTIPLY16C16(var,const) ((var)*(const))
-
-#if 1 //def USE_ACCURATE_ROUNDING
-#define DESCALE(x,n)  RIGHT_SHIFT((x) + (1 << ((n) - 1)), n)
-#else
-#define DESCALE(x,n)  RIGHT_SHIFT(x, n)
-#endif
-
-
-/*
- * This module is specialized to the case DCTSIZE = 8.
- */
-
-#if DCTSIZE != 8
-  Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
-#endif
-
-
-/*
- * The poop on this scaling stuff is as follows:
- *
- * Each 1-D DCT step produces outputs which are a factor of sqrt(N)
- * larger than the true DCT outputs.  The final outputs are therefore
- * a factor of N larger than desired; since N=8 this can be cured by
- * a simple right shift at the end of the algorithm.  The advantage of
- * this arrangement is that we save two multiplications per 1-D DCT,
- * because the y0 and y4 outputs need not be divided by sqrt(N).
- * In the IJG code, this factor of 8 is removed by the quantization step
- * (in jcdctmgr.c), NOT in this module.
- *
- * We have to do addition and subtraction of the integer inputs, which
- * is no problem, and multiplication by fractional constants, which is
- * a problem to do in integer arithmetic.  We multiply all the constants
- * by CONST_SCALE and convert them to integer constants (thus retaining
- * CONST_BITS bits of precision in the constants).  After doing a
- * multiplication we have to divide the product by CONST_SCALE, with proper
- * rounding, to produce the correct output.  This division can be done
- * cheaply as a right shift of CONST_BITS bits.  We postpone shifting
- * as long as possible so that partial sums can be added together with
- * full fractional precision.
- *
- * The outputs of the first pass are scaled up by PASS1_BITS bits so that
- * they are represented to better-than-integral precision.  These outputs
- * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word
- * with the recommended scaling.  (For 12-bit sample data, the intermediate
- * array is int32_t anyway.)
- *
- * To avoid overflow of the 32-bit intermediate results in pass 2, we must
- * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26.  Error analysis
- * shows that the values given below are the most effective.
- */
-
-#if BITS_IN_JSAMPLE == 8
-#define CONST_BITS  13
-#define PASS1_BITS  4		/* set this to 2 if 16x16 multiplies are faster */
-#else
-#define CONST_BITS  13
-#define PASS1_BITS  1		/* lose a little precision to avoid overflow */
-#endif
-
-/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
- * causing a lot of useless floating-point operations at run time.
- * To get around this we use the following pre-calculated constants.
- * If you change CONST_BITS you may want to add appropriate values.
- * (With a reasonable C compiler, you can just rely on the FIX() macro...)
- */
-
-#if CONST_BITS == 13
-#define FIX_0_298631336  ((int32_t)  2446)	/* FIX(0.298631336) */
-#define FIX_0_390180644  ((int32_t)  3196)	/* FIX(0.390180644) */
-#define FIX_0_541196100  ((int32_t)  4433)	/* FIX(0.541196100) */
-#define FIX_0_765366865  ((int32_t)  6270)	/* FIX(0.765366865) */
-#define FIX_0_899976223  ((int32_t)  7373)	/* FIX(0.899976223) */
-#define FIX_1_175875602  ((int32_t)  9633)	/* FIX(1.175875602) */
-#define FIX_1_501321110  ((int32_t)  12299)	/* FIX(1.501321110) */
-#define FIX_1_847759065  ((int32_t)  15137)	/* FIX(1.847759065) */
-#define FIX_1_961570560  ((int32_t)  16069)	/* FIX(1.961570560) */
-#define FIX_2_053119869  ((int32_t)  16819)	/* FIX(2.053119869) */
-#define FIX_2_562915447  ((int32_t)  20995)	/* FIX(2.562915447) */
-#define FIX_3_072711026  ((int32_t)  25172)	/* FIX(3.072711026) */
-#else
-#define FIX_0_298631336  FIX(0.298631336)
-#define FIX_0_390180644  FIX(0.390180644)
-#define FIX_0_541196100  FIX(0.541196100)
-#define FIX_0_765366865  FIX(0.765366865)
-#define FIX_0_899976223  FIX(0.899976223)
-#define FIX_1_175875602  FIX(1.175875602)
-#define FIX_1_501321110  FIX(1.501321110)
-#define FIX_1_847759065  FIX(1.847759065)
-#define FIX_1_961570560  FIX(1.961570560)
-#define FIX_2_053119869  FIX(2.053119869)
-#define FIX_2_562915447  FIX(2.562915447)
-#define FIX_3_072711026  FIX(3.072711026)
-#endif
-
-
-/* Multiply an int32_t variable by an int32_t constant to yield an int32_t result.
- * For 8-bit samples with the recommended scaling, all the variable
- * and constant values involved are no more than 16 bits wide, so a
- * 16x16->32 bit multiply can be used instead of a full 32x32 multiply.
- * For 12-bit samples, a full 32-bit multiplication will be needed.
- */
-
-#if BITS_IN_JSAMPLE == 8 && CONST_BITS<=13 && PASS1_BITS<=2
-#define MULTIPLY(var,const)  MULTIPLY16C16(var,const)
-#else
-#define MULTIPLY(var,const)  ((var) * (const))
-#endif
-
-
-static always_inline void row_fdct(DCTELEM * data){
-  int_fast32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
-  int_fast32_t tmp10, tmp11, tmp12, tmp13;
-  int_fast32_t z1, z2, z3, z4, z5;
-  DCTELEM *dataptr;
-  int ctr;
-  SHIFT_TEMPS
-
-  /* Pass 1: process rows. */
-  /* Note results are scaled up by sqrt(8) compared to a true DCT; */
-  /* furthermore, we scale the results by 2**PASS1_BITS. */
-
-  dataptr = data;
-  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
-    tmp0 = dataptr[0] + dataptr[7];
-    tmp7 = dataptr[0] - dataptr[7];
-    tmp1 = dataptr[1] + dataptr[6];
-    tmp6 = dataptr[1] - dataptr[6];
-    tmp2 = dataptr[2] + dataptr[5];
-    tmp5 = dataptr[2] - dataptr[5];
-    tmp3 = dataptr[3] + dataptr[4];
-    tmp4 = dataptr[3] - dataptr[4];
-    
-    /* Even part per LL&M figure 1 --- note that published figure is faulty;
-     * rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
-     */
-    
-    tmp10 = tmp0 + tmp3;
-    tmp13 = tmp0 - tmp3;
-    tmp11 = tmp1 + tmp2;
-    tmp12 = tmp1 - tmp2;
-    
-    dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS);
-    dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);
-    
-    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
-    dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
-				   CONST_BITS-PASS1_BITS);
-    dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
-				   CONST_BITS-PASS1_BITS);
-    
-    /* Odd part per figure 8 --- note paper omits factor of sqrt(2).
-     * cK represents cos(K*pi/16).
-     * i0..i3 in the paper are tmp4..tmp7 here.
-     */
-    
-    z1 = tmp4 + tmp7;
-    z2 = tmp5 + tmp6;
-    z3 = tmp4 + tmp6;
-    z4 = tmp5 + tmp7;
-    z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
-    
-    tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
-    tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
-    tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
-    tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
-    z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
-    z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
-    z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
-    z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
-    
-    z3 += z5;
-    z4 += z5;
-    
-    dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS);
-    dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS);
-    dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS);
-    dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS);
-    
-    dataptr += DCTSIZE;		/* advance pointer to next row */
-  }
-}
-
-/*
- * Perform the forward DCT on one block of samples.
- */
-
-GLOBAL(void)
-ff_jpeg_fdct_islow (DCTELEM * data)
-{
-  int_fast32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
-  int_fast32_t tmp10, tmp11, tmp12, tmp13;
-  int_fast32_t z1, z2, z3, z4, z5;
-  DCTELEM *dataptr;
-  int ctr;
-  SHIFT_TEMPS
-
-  row_fdct(data);
-
-  /* Pass 2: process columns.
-   * We remove the PASS1_BITS scaling, but leave the results scaled up
-   * by an overall factor of 8.
-   */
-
-  dataptr = data;
-  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
-    tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7];
-    tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7];
-    tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6];
-    tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6];
-    tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5];
-    tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5];
-    tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4];
-    tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4];
-    
-    /* Even part per LL&M figure 1 --- note that published figure is faulty;
-     * rotator "sqrt(2)*c1" should be "sqrt(2)*c6".
-     */
-    
-    tmp10 = tmp0 + tmp3;
-    tmp13 = tmp0 - tmp3;
-    tmp11 = tmp1 + tmp2;
-    tmp12 = tmp1 - tmp2;
-    
-    dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS);
-    dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS);
-    
-    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
-    dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
-					   CONST_BITS+PASS1_BITS);
-    dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
-					   CONST_BITS+PASS1_BITS);
-    
-    /* Odd part per figure 8 --- note paper omits factor of sqrt(2).
-     * cK represents cos(K*pi/16).
-     * i0..i3 in the paper are tmp4..tmp7 here.
-     */
-    
-    z1 = tmp4 + tmp7;
-    z2 = tmp5 + tmp6;
-    z3 = tmp4 + tmp6;
-    z4 = tmp5 + tmp7;
-    z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
-    
-    tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
-    tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
-    tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
-    tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
-    z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
-    z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
-    z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
-    z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
-    
-    z3 += z5;
-    z4 += z5;
-    
-    dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3,
-					   CONST_BITS+PASS1_BITS);
-    dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4,
-					   CONST_BITS+PASS1_BITS);
-    dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3,
-					   CONST_BITS+PASS1_BITS);
-    dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4,
-					   CONST_BITS+PASS1_BITS);
-    
-    dataptr++;			/* advance pointer to next column */
-  }
-}
-
-/*
- * The secret of DCT2-4-8 is really simple -- you do the usual 1-DCT
- * on the rows and then, instead of doing even and odd, part on the colums
- * you do even part two times.
- */
-GLOBAL(void)
-ff_fdct248_islow (DCTELEM * data)
-{
-  int_fast32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
-  int_fast32_t tmp10, tmp11, tmp12, tmp13;
-  int_fast32_t z1;
-  DCTELEM *dataptr;
-  int ctr;
-  SHIFT_TEMPS
-
-  row_fdct(data);
-
-  /* Pass 2: process columns.
-   * We remove the PASS1_BITS scaling, but leave the results scaled up
-   * by an overall factor of 8.
-   */
-
-  dataptr = data;
-  for (ctr = DCTSIZE-1; ctr >= 0; ctr--) {
-     tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*1];
-     tmp1 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*3];
-     tmp2 = dataptr[DCTSIZE*4] + dataptr[DCTSIZE*5];
-     tmp3 = dataptr[DCTSIZE*6] + dataptr[DCTSIZE*7];
-     tmp4 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*1];
-     tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*3];
-     tmp6 = dataptr[DCTSIZE*4] - dataptr[DCTSIZE*5];
-     tmp7 = dataptr[DCTSIZE*6] - dataptr[DCTSIZE*7];
-      
-     tmp10 = tmp0 + tmp3;
-     tmp11 = tmp1 + tmp2;
-     tmp12 = tmp1 - tmp2;
-     tmp13 = tmp0 - tmp3;
-     
-     dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS);
-     dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS);
-     
-     z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
-     dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
-				            CONST_BITS+PASS1_BITS);
-     dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
-				            CONST_BITS+PASS1_BITS);
-
-     tmp10 = tmp4 + tmp7;
-     tmp11 = tmp5 + tmp6;
-     tmp12 = tmp5 - tmp6;
-     tmp13 = tmp4 - tmp7;
-
-     dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS);
-     dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS);
-     
-     z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
-     dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
-				            CONST_BITS+PASS1_BITS);
-     dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
-				            CONST_BITS+PASS1_BITS);
-    
-     dataptr++;			/* advance pointer to next column */
-  }
-}
diff --git a/ffmpeg.src/libavcodec/jrevdct.c b/ffmpeg.src/libavcodec/jrevdct.c
deleted file mode 100644
index c08d124..0000000
--- a/ffmpeg.src/libavcodec/jrevdct.c
+++ /dev/null
@@ -1,1126 +0,0 @@
-/*
- * jrevdct.c
- *
- * Copyright (C) 1991, 1992, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README file.
- *
- * This file contains the basic inverse-DCT transformation subroutine.
- *
- * This implementation is based on an algorithm described in
- *   C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT
- *   Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics,
- *   Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991.
- * The primary algorithm described there uses 11 multiplies and 29 adds.
- * We use their alternate method with 12 multiplies and 32 adds.
- * The advantage of this method is that no data path contains more than one
- * multiplication; this allows a very simple and accurate implementation in
- * scaled fixed-point arithmetic, with a minimal number of shifts.
- * 
- * I've made lots of modifications to attempt to take advantage of the
- * sparse nature of the DCT matrices we're getting.  Although the logic
- * is cumbersome, it's straightforward and the resulting code is much
- * faster.
- *
- * A better way to do this would be to pass in the DCT block as a sparse
- * matrix, perhaps with the difference cases encoded.
- */
- 
-/**
- * @file jrevdct.c
- * Independent JPEG Group's LLM idct.
- */
- 
-#include "common.h"
-#include "dsputil.h"
-
-#define EIGHT_BIT_SAMPLES
-
-#define DCTSIZE 8
-#define DCTSIZE2 64
-
-#define GLOBAL
-
-#define RIGHT_SHIFT(x, n) ((x) >> (n))
-
-typedef DCTELEM DCTBLOCK[DCTSIZE2];
-
-#define CONST_BITS 13
-
-/*
- * This routine is specialized to the case DCTSIZE = 8.
- */
-
-#if DCTSIZE != 8
-  Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
-#endif
-
-
-/*
- * A 2-D IDCT can be done by 1-D IDCT on each row followed by 1-D IDCT
- * on each column.  Direct algorithms are also available, but they are
- * much more complex and seem not to be any faster when reduced to code.
- *
- * The poop on this scaling stuff is as follows:
- *
- * Each 1-D IDCT step produces outputs which are a factor of sqrt(N)
- * larger than the true IDCT outputs.  The final outputs are therefore
- * a factor of N larger than desired; since N=8 this can be cured by
- * a simple right shift at the end of the algorithm.  The advantage of
- * this arrangement is that we save two multiplications per 1-D IDCT,
- * because the y0 and y4 inputs need not be divided by sqrt(N).
- *
- * We have to do addition and subtraction of the integer inputs, which
- * is no problem, and multiplication by fractional constants, which is
- * a problem to do in integer arithmetic.  We multiply all the constants
- * by CONST_SCALE and convert them to integer constants (thus retaining
- * CONST_BITS bits of precision in the constants).  After doing a
- * multiplication we have to divide the product by CONST_SCALE, with proper
- * rounding, to produce the correct output.  This division can be done
- * cheaply as a right shift of CONST_BITS bits.  We postpone shifting
- * as long as possible so that partial sums can be added together with
- * full fractional precision.
- *
- * The outputs of the first pass are scaled up by PASS1_BITS bits so that
- * they are represented to better-than-integral precision.  These outputs
- * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word
- * with the recommended scaling.  (To scale up 12-bit sample data further, an
- * intermediate int32 array would be needed.)
- *
- * To avoid overflow of the 32-bit intermediate results in pass 2, we must
- * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26.  Error analysis
- * shows that the values given below are the most effective.
- */
-
-#ifdef EIGHT_BIT_SAMPLES
-#define PASS1_BITS  2
-#else
-#define PASS1_BITS  1		/* lose a little precision to avoid overflow */
-#endif
-
-#define ONE	((int32_t) 1)
-
-#define CONST_SCALE (ONE << CONST_BITS)
-
-/* Convert a positive real constant to an integer scaled by CONST_SCALE.
- * IMPORTANT: if your compiler doesn't do this arithmetic at compile time,
- * you will pay a significant penalty in run time.  In that case, figure
- * the correct integer constant values and insert them by hand.
- */
-
-/* Actually FIX is no longer used, we precomputed them all */
-#define FIX(x)	((int32_t) ((x) * CONST_SCALE + 0.5)) 
-
-/* Descale and correctly round an int32_t value that's scaled by N bits.
- * We assume RIGHT_SHIFT rounds towards minus infinity, so adding
- * the fudge factor is correct for either sign of X.
- */
-
-#define DESCALE(x,n)  RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
-
-/* Multiply an int32_t variable by an int32_t constant to yield an int32_t result.
- * For 8-bit samples with the recommended scaling, all the variable
- * and constant values involved are no more than 16 bits wide, so a
- * 16x16->32 bit multiply can be used instead of a full 32x32 multiply;
- * this provides a useful speedup on many machines.
- * There is no way to specify a 16x16->32 multiply in portable C, but
- * some C compilers will do the right thing if you provide the correct
- * combination of casts.
- * NB: for 12-bit samples, a full 32-bit multiplication will be needed.
- */
-
-#ifdef EIGHT_BIT_SAMPLES
-#ifdef SHORTxSHORT_32		/* may work if 'int' is 32 bits */
-#define MULTIPLY(var,const)  (((int16_t) (var)) * ((int16_t) (const)))
-#endif
-#ifdef SHORTxLCONST_32		/* known to work with Microsoft C 6.0 */
-#define MULTIPLY(var,const)  (((int16_t) (var)) * ((int32_t) (const)))
-#endif
-#endif
-
-#ifndef MULTIPLY		/* default definition */
-#define MULTIPLY(var,const)  ((var) * (const))
-#endif
-
-
-/* 
-  Unlike our decoder where we approximate the FIXes, we need to use exact
-ones here or successive P-frames will drift too much with Reference frame coding 
-*/
-#define FIX_0_211164243 1730
-#define FIX_0_275899380 2260
-#define FIX_0_298631336 2446
-#define FIX_0_390180644 3196
-#define FIX_0_509795579 4176
-#define FIX_0_541196100 4433
-#define FIX_0_601344887 4926
-#define FIX_0_765366865 6270
-#define FIX_0_785694958 6436
-#define FIX_0_899976223 7373
-#define FIX_1_061594337 8697
-#define FIX_1_111140466 9102
-#define FIX_1_175875602 9633
-#define FIX_1_306562965 10703
-#define FIX_1_387039845 11363
-#define FIX_1_451774981 11893
-#define FIX_1_501321110 12299
-#define FIX_1_662939225 13623
-#define FIX_1_847759065 15137
-#define FIX_1_961570560 16069
-#define FIX_2_053119869 16819
-#define FIX_2_172734803 17799
-#define FIX_2_562915447 20995
-#define FIX_3_072711026 25172
-
-/*
- * Perform the inverse DCT on one block of coefficients.
- */
-
-void j_rev_dct(DCTBLOCK data)
-{
-  int32_t tmp0, tmp1, tmp2, tmp3;
-  int32_t tmp10, tmp11, tmp12, tmp13;
-  int32_t z1, z2, z3, z4, z5;
-  int32_t d0, d1, d2, d3, d4, d5, d6, d7;
-  register DCTELEM *dataptr;
-  int rowctr;
-   
-  /* Pass 1: process rows. */
-  /* Note results are scaled up by sqrt(8) compared to a true IDCT; */
-  /* furthermore, we scale the results by 2**PASS1_BITS. */
-
-  dataptr = data;
-
-  for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
-    /* Due to quantization, we will usually find that many of the input
-     * coefficients are zero, especially the AC terms.  We can exploit this
-     * by short-circuiting the IDCT calculation for any row in which all
-     * the AC terms are zero.  In that case each output is equal to the
-     * DC coefficient (with scale factor as needed).
-     * With typical images and quantization tables, half or more of the
-     * row DCT calculations can be simplified this way.
-     */
-
-    register int *idataptr = (int*)dataptr;
-
-    /* WARNING: we do the same permutation as MMX idct to simplify the
-       video core */
-    d0 = dataptr[0];
-    d2 = dataptr[1];
-    d4 = dataptr[2];
-    d6 = dataptr[3];
-    d1 = dataptr[4];
-    d3 = dataptr[5];
-    d5 = dataptr[6];
-    d7 = dataptr[7];
-
-    if ((d1 | d2 | d3 | d4 | d5 | d6 | d7) == 0) {
-      /* AC terms all zero */
-      if (d0) {
-	  /* Compute a 32 bit value to assign. */
-	  DCTELEM dcval = (DCTELEM) (d0 << PASS1_BITS);
-	  register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000);
-	  
-	  idataptr[0] = v;
-	  idataptr[1] = v;
-	  idataptr[2] = v;
-	  idataptr[3] = v;
-      }
-      
-      dataptr += DCTSIZE;	/* advance pointer to next row */
-      continue;
-    }
-
-    /* Even part: reverse the even part of the forward DCT. */
-    /* The rotator is sqrt(2)*c(-6). */
-{
-    if (d6) {
-	    if (d2) {
-		    /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
-		    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-		    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-		    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-	    } else {
-		    /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
-		    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-		    tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-	    }
-    } else {
-	    if (d2) {
-		    /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
-		    tmp2 = MULTIPLY(d2, FIX_0_541196100);
-		    tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-	    } else {
-		    /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
-		    tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
-		    tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
-	    }
-      }
-
-    /* Odd part per figure 8; the matrix is unitary and hence its
-     * transpose is its inverse.  i0..i3 are y7,y5,y3,y1 respectively.
-     */
-
-    if (d7) {
-	if (d5) {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z2 = d5 + d3;
-		    z3 = d7 + d3;
-		    z4 = d5 + d1;
-		    z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-z1, FIX_0_899976223);
-		    z2 = MULTIPLY(-z2, FIX_2_562915447);
-		    z3 = MULTIPLY(-z3, FIX_1_961570560);
-		    z4 = MULTIPLY(-z4, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */
-		    z2 = d5 + d3;
-		    z3 = d7 + d3;
-		    z5 = MULTIPLY(z3 + d5, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    z1 = MULTIPLY(-d7, FIX_0_899976223);
-		    z2 = MULTIPLY(-z2, FIX_2_562915447);
-		    z3 = MULTIPLY(-z3, FIX_1_961570560);
-		    z4 = MULTIPLY(-d5, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 = z1 + z4;
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z4 = d5 + d1;
-		    z5 = MULTIPLY(d7 + z4, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-z1, FIX_0_899976223);
-		    z2 = MULTIPLY(-d5, FIX_2_562915447);
-		    z3 = MULTIPLY(-d7, FIX_1_961570560);
-		    z4 = MULTIPLY(-z4, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 = z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */
-		    tmp0 = MULTIPLY(-d7, FIX_0_601344887); 
-		    z1 = MULTIPLY(-d7, FIX_0_899976223);
-		    z3 = MULTIPLY(-d7, FIX_1_961570560);
-		    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
-		    z2 = MULTIPLY(-d5, FIX_2_562915447);
-		    z4 = MULTIPLY(-d5, FIX_0_390180644);
-		    z5 = MULTIPLY(d5 + d7, FIX_1_175875602);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z3;
-		    tmp1 += z4;
-		    tmp2 = z2 + z3;
-		    tmp3 = z1 + z4;
-		}
-	    }
-	} else {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z3 = d7 + d3;
-		    z5 = MULTIPLY(z3 + d1, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-z1, FIX_0_899976223);
-		    z2 = MULTIPLY(-d3, FIX_2_562915447);
-		    z3 = MULTIPLY(-z3, FIX_1_961570560);
-		    z4 = MULTIPLY(-d1, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 = z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */
-		    z3 = d7 + d3;
-		    
-		    tmp0 = MULTIPLY(-d7, FIX_0_601344887); 
-		    z1 = MULTIPLY(-d7, FIX_0_899976223);
-		    tmp2 = MULTIPLY(d3, FIX_0_509795579);
-		    z2 = MULTIPLY(-d3, FIX_2_562915447);
-		    z5 = MULTIPLY(z3, FIX_1_175875602);
-		    z3 = MULTIPLY(-z3, FIX_0_785694958);
-		    
-		    tmp0 += z3;
-		    tmp1 = z2 + z5;
-		    tmp2 += z3;
-		    tmp3 = z1 + z5;
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z5 = MULTIPLY(z1, FIX_1_175875602);
-
-		    z1 = MULTIPLY(z1, FIX_0_275899380);
-		    z3 = MULTIPLY(-d7, FIX_1_961570560);
-		    tmp0 = MULTIPLY(-d7, FIX_1_662939225); 
-		    z4 = MULTIPLY(-d1, FIX_0_390180644);
-		    tmp3 = MULTIPLY(d1, FIX_1_111140466);
-
-		    tmp0 += z1;
-		    tmp1 = z4 + z5;
-		    tmp2 = z3 + z5;
-		    tmp3 += z1;
-		} else {
-		    /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */
-		    tmp0 = MULTIPLY(-d7, FIX_1_387039845);
-		    tmp1 = MULTIPLY(d7, FIX_1_175875602);
-		    tmp2 = MULTIPLY(-d7, FIX_0_785694958);
-		    tmp3 = MULTIPLY(d7, FIX_0_275899380);
-		}
-	    }
-	}
-    } else {
-	if (d5) {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */
-		    z2 = d5 + d3;
-		    z4 = d5 + d1;
-		    z5 = MULTIPLY(d3 + z4, FIX_1_175875602);
-		    
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-d1, FIX_0_899976223);
-		    z2 = MULTIPLY(-z2, FIX_2_562915447);
-		    z3 = MULTIPLY(-d3, FIX_1_961570560);
-		    z4 = MULTIPLY(-z4, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 = z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */
-		    z2 = d5 + d3;
-		    
-		    z5 = MULTIPLY(z2, FIX_1_175875602);
-		    tmp1 = MULTIPLY(d5, FIX_1_662939225);
-		    z4 = MULTIPLY(-d5, FIX_0_390180644);
-		    z2 = MULTIPLY(-z2, FIX_1_387039845);
-		    tmp2 = MULTIPLY(d3, FIX_1_111140466);
-		    z3 = MULTIPLY(-d3, FIX_1_961570560);
-		    
-		    tmp0 = z3 + z5;
-		    tmp1 += z2;
-		    tmp2 += z2;
-		    tmp3 = z4 + z5;
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */
-		    z4 = d5 + d1;
-		    
-		    z5 = MULTIPLY(z4, FIX_1_175875602);
-		    z1 = MULTIPLY(-d1, FIX_0_899976223);
-		    tmp3 = MULTIPLY(d1, FIX_0_601344887);
-		    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
-		    z2 = MULTIPLY(-d5, FIX_2_562915447);
-		    z4 = MULTIPLY(z4, FIX_0_785694958);
-		    
-		    tmp0 = z1 + z5;
-		    tmp1 += z4;
-		    tmp2 = z2 + z5;
-		    tmp3 += z4;
-		} else {
-		    /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */
-		    tmp0 = MULTIPLY(d5, FIX_1_175875602);
-		    tmp1 = MULTIPLY(d5, FIX_0_275899380);
-		    tmp2 = MULTIPLY(-d5, FIX_1_387039845);
-		    tmp3 = MULTIPLY(d5, FIX_0_785694958);
-		}
-	    }
-	} else {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */
-		    z5 = d1 + d3;
-		    tmp3 = MULTIPLY(d1, FIX_0_211164243);
-		    tmp2 = MULTIPLY(-d3, FIX_1_451774981);
-		    z1 = MULTIPLY(d1, FIX_1_061594337);
-		    z2 = MULTIPLY(-d3, FIX_2_172734803);
-		    z4 = MULTIPLY(z5, FIX_0_785694958);
-		    z5 = MULTIPLY(z5, FIX_1_175875602);
-		    
-		    tmp0 = z1 - z4;
-		    tmp1 = z2 + z4;
-		    tmp2 += z5;
-		    tmp3 += z5;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */
-		    tmp0 = MULTIPLY(-d3, FIX_0_785694958);
-		    tmp1 = MULTIPLY(-d3, FIX_1_387039845);
-		    tmp2 = MULTIPLY(-d3, FIX_0_275899380);
-		    tmp3 = MULTIPLY(d3, FIX_1_175875602);
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */
-		    tmp0 = MULTIPLY(d1, FIX_0_275899380);
-		    tmp1 = MULTIPLY(d1, FIX_0_785694958);
-		    tmp2 = MULTIPLY(d1, FIX_1_175875602);
-		    tmp3 = MULTIPLY(d1, FIX_1_387039845);
-		} else {
-		    /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */
-		    tmp0 = tmp1 = tmp2 = tmp3 = 0;
-		}
-	    }
-	}
-    }
-}
-    /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
-
-    dataptr[0] = (DCTELEM) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS);
-    dataptr[7] = (DCTELEM) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS);
-    dataptr[1] = (DCTELEM) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS);
-    dataptr[6] = (DCTELEM) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS);
-    dataptr[2] = (DCTELEM) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS);
-    dataptr[5] = (DCTELEM) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS);
-    dataptr[3] = (DCTELEM) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS);
-    dataptr[4] = (DCTELEM) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS);
-
-    dataptr += DCTSIZE;		/* advance pointer to next row */
-  }
-
-  /* Pass 2: process columns. */
-  /* Note that we must descale the results by a factor of 8 == 2**3, */
-  /* and also undo the PASS1_BITS scaling. */
-
-  dataptr = data;
-  for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
-    /* Columns of zeroes can be exploited in the same way as we did with rows.
-     * However, the row calculation has created many nonzero AC terms, so the
-     * simplification applies less often (typically 5% to 10% of the time).
-     * On machines with very fast multiplication, it's possible that the
-     * test takes more time than it's worth.  In that case this section
-     * may be commented out.
-     */
-
-    d0 = dataptr[DCTSIZE*0];
-    d1 = dataptr[DCTSIZE*1];
-    d2 = dataptr[DCTSIZE*2];
-    d3 = dataptr[DCTSIZE*3];
-    d4 = dataptr[DCTSIZE*4];
-    d5 = dataptr[DCTSIZE*5];
-    d6 = dataptr[DCTSIZE*6];
-    d7 = dataptr[DCTSIZE*7];
-
-    /* Even part: reverse the even part of the forward DCT. */
-    /* The rotator is sqrt(2)*c(-6). */
-    if (d6) {
-	    if (d2) {
-		    /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
-		    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-		    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-		    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-	    } else {
-		    /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
-		    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-		    tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-	    }
-    } else {
-	    if (d2) {
-		    /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
-		    tmp2 = MULTIPLY(d2, FIX_0_541196100);
-		    tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-	    } else {
-		    /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
-		    tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
-		    tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
-	    }
-    }
-
-    /* Odd part per figure 8; the matrix is unitary and hence its
-     * transpose is its inverse.  i0..i3 are y7,y5,y3,y1 respectively.
-     */
-    if (d7) {
-	if (d5) {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z2 = d5 + d3;
-		    z3 = d7 + d3;
-		    z4 = d5 + d1;
-		    z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-z1, FIX_0_899976223);
-		    z2 = MULTIPLY(-z2, FIX_2_562915447);
-		    z3 = MULTIPLY(-z3, FIX_1_961570560);
-		    z4 = MULTIPLY(-z4, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */
-		    z1 = d7;
-		    z2 = d5 + d3;
-		    z3 = d7 + d3;
-		    z5 = MULTIPLY(z3 + d5, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    z1 = MULTIPLY(-d7, FIX_0_899976223);
-		    z2 = MULTIPLY(-z2, FIX_2_562915447);
-		    z3 = MULTIPLY(-z3, FIX_1_961570560);
-		    z4 = MULTIPLY(-d5, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 = z1 + z4;
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z2 = d5;
-		    z3 = d7;
-		    z4 = d5 + d1;
-		    z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-z1, FIX_0_899976223);
-		    z2 = MULTIPLY(-d5, FIX_2_562915447);
-		    z3 = MULTIPLY(-d7, FIX_1_961570560);
-		    z4 = MULTIPLY(-z4, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 = z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */
-		    tmp0 = MULTIPLY(-d7, FIX_0_601344887); 
-		    z1 = MULTIPLY(-d7, FIX_0_899976223);
-		    z3 = MULTIPLY(-d7, FIX_1_961570560);
-		    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
-		    z2 = MULTIPLY(-d5, FIX_2_562915447);
-		    z4 = MULTIPLY(-d5, FIX_0_390180644);
-		    z5 = MULTIPLY(d5 + d7, FIX_1_175875602);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z3;
-		    tmp1 += z4;
-		    tmp2 = z2 + z3;
-		    tmp3 = z1 + z4;
-		}
-	    }
-	} else {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z3 = d7 + d3;
-		    z5 = MULTIPLY(z3 + d1, FIX_1_175875602);
-		    
-		    tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-z1, FIX_0_899976223);
-		    z2 = MULTIPLY(-d3, FIX_2_562915447);
-		    z3 = MULTIPLY(-z3, FIX_1_961570560);
-		    z4 = MULTIPLY(-d1, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 += z1 + z3;
-		    tmp1 = z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */
-		    z3 = d7 + d3;
-		    
-		    tmp0 = MULTIPLY(-d7, FIX_0_601344887); 
-		    z1 = MULTIPLY(-d7, FIX_0_899976223);
-		    tmp2 = MULTIPLY(d3, FIX_0_509795579);
-		    z2 = MULTIPLY(-d3, FIX_2_562915447);
-		    z5 = MULTIPLY(z3, FIX_1_175875602);
-		    z3 = MULTIPLY(-z3, FIX_0_785694958);
-		    
-		    tmp0 += z3;
-		    tmp1 = z2 + z5;
-		    tmp2 += z3;
-		    tmp3 = z1 + z5;
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */
-		    z1 = d7 + d1;
-		    z5 = MULTIPLY(z1, FIX_1_175875602);
-
-		    z1 = MULTIPLY(z1, FIX_0_275899380);
-		    z3 = MULTIPLY(-d7, FIX_1_961570560);
-		    tmp0 = MULTIPLY(-d7, FIX_1_662939225); 
-		    z4 = MULTIPLY(-d1, FIX_0_390180644);
-		    tmp3 = MULTIPLY(d1, FIX_1_111140466);
-
-		    tmp0 += z1;
-		    tmp1 = z4 + z5;
-		    tmp2 = z3 + z5;
-		    tmp3 += z1;
-		} else {
-		    /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */
-		    tmp0 = MULTIPLY(-d7, FIX_1_387039845);
-		    tmp1 = MULTIPLY(d7, FIX_1_175875602);
-		    tmp2 = MULTIPLY(-d7, FIX_0_785694958);
-		    tmp3 = MULTIPLY(d7, FIX_0_275899380);
-		}
-	    }
-	}
-    } else {
-	if (d5) {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */
-		    z2 = d5 + d3;
-		    z4 = d5 + d1;
-		    z5 = MULTIPLY(d3 + z4, FIX_1_175875602);
-		    
-		    tmp1 = MULTIPLY(d5, FIX_2_053119869);
-		    tmp2 = MULTIPLY(d3, FIX_3_072711026);
-		    tmp3 = MULTIPLY(d1, FIX_1_501321110);
-		    z1 = MULTIPLY(-d1, FIX_0_899976223);
-		    z2 = MULTIPLY(-z2, FIX_2_562915447);
-		    z3 = MULTIPLY(-d3, FIX_1_961570560);
-		    z4 = MULTIPLY(-z4, FIX_0_390180644);
-		    
-		    z3 += z5;
-		    z4 += z5;
-		    
-		    tmp0 = z1 + z3;
-		    tmp1 += z2 + z4;
-		    tmp2 += z2 + z3;
-		    tmp3 += z1 + z4;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */
-		    z2 = d5 + d3;
-		    
-		    z5 = MULTIPLY(z2, FIX_1_175875602);
-		    tmp1 = MULTIPLY(d5, FIX_1_662939225);
-		    z4 = MULTIPLY(-d5, FIX_0_390180644);
-		    z2 = MULTIPLY(-z2, FIX_1_387039845);
-		    tmp2 = MULTIPLY(d3, FIX_1_111140466);
-		    z3 = MULTIPLY(-d3, FIX_1_961570560);
-		    
-		    tmp0 = z3 + z5;
-		    tmp1 += z2;
-		    tmp2 += z2;
-		    tmp3 = z4 + z5;
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */
-		    z4 = d5 + d1;
-		    
-		    z5 = MULTIPLY(z4, FIX_1_175875602);
-		    z1 = MULTIPLY(-d1, FIX_0_899976223);
-		    tmp3 = MULTIPLY(d1, FIX_0_601344887);
-		    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
-		    z2 = MULTIPLY(-d5, FIX_2_562915447);
-		    z4 = MULTIPLY(z4, FIX_0_785694958);
-		    
-		    tmp0 = z1 + z5;
-		    tmp1 += z4;
-		    tmp2 = z2 + z5;
-		    tmp3 += z4;
-		} else {
-		    /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */
-		    tmp0 = MULTIPLY(d5, FIX_1_175875602);
-		    tmp1 = MULTIPLY(d5, FIX_0_275899380);
-		    tmp2 = MULTIPLY(-d5, FIX_1_387039845);
-		    tmp3 = MULTIPLY(d5, FIX_0_785694958);
-		}
-	    }
-	} else {
-	    if (d3) {
-		if (d1) {
-		    /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */
-		    z5 = d1 + d3;
-		    tmp3 = MULTIPLY(d1, FIX_0_211164243);
-		    tmp2 = MULTIPLY(-d3, FIX_1_451774981);
-		    z1 = MULTIPLY(d1, FIX_1_061594337);
-		    z2 = MULTIPLY(-d3, FIX_2_172734803);
-		    z4 = MULTIPLY(z5, FIX_0_785694958);
-		    z5 = MULTIPLY(z5, FIX_1_175875602);
-		    
-		    tmp0 = z1 - z4;
-		    tmp1 = z2 + z4;
-		    tmp2 += z5;
-		    tmp3 += z5;
-		} else {
-		    /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */
-		    tmp0 = MULTIPLY(-d3, FIX_0_785694958);
-		    tmp1 = MULTIPLY(-d3, FIX_1_387039845);
-		    tmp2 = MULTIPLY(-d3, FIX_0_275899380);
-		    tmp3 = MULTIPLY(d3, FIX_1_175875602);
-		}
-	    } else {
-		if (d1) {
-		    /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */
-		    tmp0 = MULTIPLY(d1, FIX_0_275899380);
-		    tmp1 = MULTIPLY(d1, FIX_0_785694958);
-		    tmp2 = MULTIPLY(d1, FIX_1_175875602);
-		    tmp3 = MULTIPLY(d1, FIX_1_387039845);
-		} else {
-		    /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */
-		    tmp0 = tmp1 = tmp2 = tmp3 = 0;
-		}
-	    }
-	}
-    }
-
-    /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
-
-    dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp3,
-					   CONST_BITS+PASS1_BITS+3);
-    dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp10 - tmp3,
-					   CONST_BITS+PASS1_BITS+3);
-    dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp11 + tmp2,
-					   CONST_BITS+PASS1_BITS+3);
-    dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(tmp11 - tmp2,
-					   CONST_BITS+PASS1_BITS+3);
-    dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(tmp12 + tmp1,
-					   CONST_BITS+PASS1_BITS+3);
-    dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12 - tmp1,
-					   CONST_BITS+PASS1_BITS+3);
-    dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp13 + tmp0,
-					   CONST_BITS+PASS1_BITS+3);
-    dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp13 - tmp0,
-					   CONST_BITS+PASS1_BITS+3);
-    
-    dataptr++;			/* advance pointer to next column */
-  }
-}
-
-#undef DCTSIZE
-#define DCTSIZE 4
-#define DCTSTRIDE 8
-
-void j_rev_dct4(DCTBLOCK data)
-{
-  int32_t tmp0, tmp1, tmp2, tmp3;
-  int32_t tmp10, tmp11, tmp12, tmp13;
-  int32_t z1;
-  int32_t d0, d2, d4, d6;
-  register DCTELEM *dataptr;
-  int rowctr;
-
-  /* Pass 1: process rows. */
-  /* Note results are scaled up by sqrt(8) compared to a true IDCT; */
-  /* furthermore, we scale the results by 2**PASS1_BITS. */
-
-  data[0] += 4;
-  
-  dataptr = data;
-
-  for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
-    /* Due to quantization, we will usually find that many of the input
-     * coefficients are zero, especially the AC terms.  We can exploit this
-     * by short-circuiting the IDCT calculation for any row in which all
-     * the AC terms are zero.  In that case each output is equal to the
-     * DC coefficient (with scale factor as needed).
-     * With typical images and quantization tables, half or more of the
-     * row DCT calculations can be simplified this way.
-     */
-
-    register int *idataptr = (int*)dataptr;
-
-    d0 = dataptr[0];
-    d2 = dataptr[1];
-    d4 = dataptr[2];
-    d6 = dataptr[3];
-
-    if ((d2 | d4 | d6) == 0) {
-      /* AC terms all zero */
-      if (d0) {
-	  /* Compute a 32 bit value to assign. */
-	  DCTELEM dcval = (DCTELEM) (d0 << PASS1_BITS);
-	  register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000);
-	  
-	  idataptr[0] = v;
-	  idataptr[1] = v;
-      }
-      
-      dataptr += DCTSTRIDE;	/* advance pointer to next row */
-      continue;
-    }
-    
-    /* Even part: reverse the even part of the forward DCT. */
-    /* The rotator is sqrt(2)*c(-6). */
-    if (d6) {
-	    if (d2) {
-		    /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
-		    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-		    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-		    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-	    } else {
-		    /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
-		    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-		    tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-	    }
-    } else {
-	    if (d2) {
-		    /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
-		    tmp2 = MULTIPLY(d2, FIX_0_541196100);
-		    tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-	    } else {
-		    /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
-		    tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
-		    tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
-	    }
-      }
-
-    /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
-
-    dataptr[0] = (DCTELEM) DESCALE(tmp10, CONST_BITS-PASS1_BITS);
-    dataptr[1] = (DCTELEM) DESCALE(tmp11, CONST_BITS-PASS1_BITS);
-    dataptr[2] = (DCTELEM) DESCALE(tmp12, CONST_BITS-PASS1_BITS);
-    dataptr[3] = (DCTELEM) DESCALE(tmp13, CONST_BITS-PASS1_BITS);
-
-    dataptr += DCTSTRIDE;		/* advance pointer to next row */
-  }
-
-  /* Pass 2: process columns. */
-  /* Note that we must descale the results by a factor of 8 == 2**3, */
-  /* and also undo the PASS1_BITS scaling. */
-
-  dataptr = data;
-  for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
-    /* Columns of zeroes can be exploited in the same way as we did with rows.
-     * However, the row calculation has created many nonzero AC terms, so the
-     * simplification applies less often (typically 5% to 10% of the time).
-     * On machines with very fast multiplication, it's possible that the
-     * test takes more time than it's worth.  In that case this section
-     * may be commented out.
-     */
-
-    d0 = dataptr[DCTSTRIDE*0];
-    d2 = dataptr[DCTSTRIDE*1];
-    d4 = dataptr[DCTSTRIDE*2];
-    d6 = dataptr[DCTSTRIDE*3];
-
-    /* Even part: reverse the even part of the forward DCT. */
-    /* The rotator is sqrt(2)*c(-6). */
-    if (d6) {
-	    if (d2) {
-		    /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
-		    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-		    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-		    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-	    } else {
-		    /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
-		    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-		    tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-	    }
-    } else {
-	    if (d2) {
-		    /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
-		    tmp2 = MULTIPLY(d2, FIX_0_541196100);
-		    tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-		    tmp0 = (d0 + d4) << CONST_BITS;
-		    tmp1 = (d0 - d4) << CONST_BITS;
-
-		    tmp10 = tmp0 + tmp3;
-		    tmp13 = tmp0 - tmp3;
-		    tmp11 = tmp1 + tmp2;
-		    tmp12 = tmp1 - tmp2;
-	    } else {
-		    /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
-		    tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
-		    tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
-	    }
-    }
-
-    /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
-
-    dataptr[DCTSTRIDE*0] = tmp10 >> (CONST_BITS+PASS1_BITS+3);
-    dataptr[DCTSTRIDE*1] = tmp11 >> (CONST_BITS+PASS1_BITS+3);
-    dataptr[DCTSTRIDE*2] = tmp12 >> (CONST_BITS+PASS1_BITS+3);
-    dataptr[DCTSTRIDE*3] = tmp13 >> (CONST_BITS+PASS1_BITS+3);
-    
-    dataptr++;			/* advance pointer to next column */
-  }
-}
-
-void j_rev_dct2(DCTBLOCK data){
-  int d00, d01, d10, d11;
-
-  data[0] += 4;
-  d00 = data[0+0*DCTSTRIDE] + data[1+0*DCTSTRIDE];
-  d01 = data[0+0*DCTSTRIDE] - data[1+0*DCTSTRIDE];
-  d10 = data[0+1*DCTSTRIDE] + data[1+1*DCTSTRIDE];
-  d11 = data[0+1*DCTSTRIDE] - data[1+1*DCTSTRIDE];
- 
-  data[0+0*DCTSTRIDE]= (d00 + d10)>>3;
-  data[1+0*DCTSTRIDE]= (d01 + d11)>>3;
-  data[0+1*DCTSTRIDE]= (d00 - d10)>>3;
-  data[1+1*DCTSTRIDE]= (d01 - d11)>>3;
-}
-
-void j_rev_dct1(DCTBLOCK data){
-  data[0] = (data[0] + 4)>>3;
-}
-
-#undef FIX
-#undef CONST_BITS
diff --git a/ffmpeg.src/libavcodec/liba52/a52.h b/ffmpeg.src/libavcodec/liba52/a52.h
deleted file mode 100644
index d3346ec..0000000
--- a/ffmpeg.src/libavcodec/liba52/a52.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * a52.h
- * Copyright (C) 2000-2003 Michel Lespinasse <walken at zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma at ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec 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.
- *
- * a52dec 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef A52_H
-#define A52_H
-
-#include "../avcodec.h"
-
-#undef malloc
-#undef free
-#undef realloc
-
-#if defined(LIBA52_FIXED)
-typedef int32_t sample_t;
-typedef int32_t level_t;
-#elif defined(LIBA52_DOUBLE)
-typedef double sample_t;
-typedef double level_t;
-#else
-typedef float sample_t;
-typedef float level_t;
-#endif
-
-typedef struct a52_state_s a52_state_t;
-
-#define A52_CHANNEL 0
-#define A52_MONO 1
-#define A52_STEREO 2
-#define A52_3F 3
-#define A52_2F1R 4
-#define A52_3F1R 5
-#define A52_2F2R 6
-#define A52_3F2R 7
-#define A52_CHANNEL1 8
-#define A52_CHANNEL2 9
-#define A52_DOLBY 10
-#define A52_CHANNEL_MASK 15
-
-#define A52_LFE 16
-#define A52_ADJUST_LEVEL 32
-
-a52_state_t * a52_init (uint32_t mm_accel);
-sample_t * a52_samples (a52_state_t * state);
-int a52_syncinfo (uint8_t * buf, int * flags,
-		  int * sample_rate, int * bit_rate);
-int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
-	       level_t * level, sample_t bias);
-void a52_dynrng (a52_state_t * state,
-		 level_t (* call) (level_t, void *), void * data);
-int a52_block (a52_state_t * state);
-void a52_free (a52_state_t * state);
-
-#endif /* A52_H */
diff --git a/ffmpeg.src/libavcodec/liba52/a52_internal.h b/ffmpeg.src/libavcodec/liba52/a52_internal.h
deleted file mode 100644
index 5235704..0000000
--- a/ffmpeg.src/libavcodec/liba52/a52_internal.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * a52_internal.h
- * Copyright (C) 2000-2003 Michel Lespinasse <walken at zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma at ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec 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.
- *
- * a52dec 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-typedef struct {
-    uint8_t bai;		/* fine SNR offset, fast gain */
-    uint8_t deltbae;		/* delta bit allocation exists */
-    int8_t deltba[50];		/* per-band delta bit allocation */
-} ba_t;
-
-typedef struct {
-    uint8_t exp[256];		/* decoded channel exponents */
-    int8_t bap[256];		/* derived channel bit allocation */
-} expbap_t;
-
-struct a52_state_s {
-    uint8_t fscod;		/* sample rate */
-    uint8_t halfrate;		/* halfrate factor */
-    uint8_t acmod;		/* coded channels */
-    uint8_t lfeon;		/* coded lfe channel */
-    level_t clev;		/* centre channel mix level */
-    level_t slev;		/* surround channels mix level */
-
-    int output;			/* type of output */
-    level_t level;		/* output level */
-    sample_t bias;		/* output bias */
-
-    int dynrnge;		/* apply dynamic range */
-    level_t dynrng;		/* dynamic range */
-    void * dynrngdata;		/* dynamic range callback funtion and data */
-    level_t (* dynrngcall) (level_t range, void * dynrngdata);
-
-    uint8_t chincpl;		/* channel coupled */
-    uint8_t phsflginu;		/* phase flags in use (stereo only) */
-    uint8_t cplstrtmant;	/* coupling channel start mantissa */
-    uint8_t cplendmant;		/* coupling channel end mantissa */
-    uint32_t cplbndstrc;	/* coupling band structure */
-    level_t cplco[5][18];	/* coupling coordinates */
-
-    /* derived information */
-    uint8_t cplstrtbnd;		/* coupling start band (for bit allocation) */
-    uint8_t ncplbnd;		/* number of coupling bands */
-
-    uint8_t rematflg;		/* stereo rematrixing */
-
-    uint8_t endmant[5];		/* channel end mantissa */
-
-    uint16_t bai;		/* bit allocation information */
-
-    uint32_t * buffer_start;
-    uint16_t lfsr_state;	/* dither state */
-    uint32_t bits_left;
-    uint32_t current_word;
-
-    uint8_t csnroffst;		/* coarse SNR offset */
-    ba_t cplba;			/* coupling bit allocation parameters */
-    ba_t ba[5];			/* channel bit allocation parameters */
-    ba_t lfeba;			/* lfe bit allocation parameters */
-
-    uint8_t cplfleak;		/* coupling fast leak init */
-    uint8_t cplsleak;		/* coupling slow leak init */
-
-    expbap_t cpl_expbap;
-    expbap_t fbw_expbap[5];
-    expbap_t lfe_expbap;
-
-    sample_t * samples;
-    int downmixed;
-};
-
-#define LEVEL_PLUS6DB 2.0
-#define LEVEL_PLUS3DB 1.4142135623730951
-#define LEVEL_3DB 0.7071067811865476
-#define LEVEL_45DB 0.5946035575013605
-#define LEVEL_6DB 0.5
-
-#define EXP_REUSE (0)
-#define EXP_D15   (1)
-#define EXP_D25   (2)
-#define EXP_D45   (3)
-
-#define DELTA_BIT_REUSE (0)
-#define DELTA_BIT_NEW (1)
-#define DELTA_BIT_NONE (2)
-#define DELTA_BIT_RESERVED (3)
-
-void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
-		       int start, int end, int fastleak, int slowleak,
-		       expbap_t * expbap);
-
-int a52_downmix_init (int input, int flags, level_t * level,
-		      level_t clev, level_t slev);
-int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
-		       level_t clev, level_t slev);
-void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias,
-		  level_t clev, level_t slev);
-void a52_upmix (sample_t * samples, int acmod, int output);
-
-void a52_imdct_init (uint32_t mm_accel);
-void a52_imdct_256 (sample_t * data, sample_t * delay, sample_t bias);
-void a52_imdct_512 (sample_t * data, sample_t * delay, sample_t bias);
-//extern void (* a52_imdct_256) (sample_t data[], sample_t delay[], sample_t bias);
-//extern void (* a52_imdct_512) (sample_t data[], sample_t delay[], sample_t bias);
-
-#define ROUND(x) ((int)((x) + ((x) > 0 ? 0.5 : -0.5)))
-
-#ifndef LIBA52_FIXED
-
-typedef sample_t quantizer_t;
-#define SAMPLE(x) (x)
-#define LEVEL(x) (x)
-#define MUL(a,b) ((a) * (b))
-#define MUL_L(a,b) ((a) * (b))
-#define MUL_C(a,b) ((a) * (b))
-#define DIV(a,b) ((a) / (b))
-#define BIAS(x) ((x) + bias)
-
-#else /* LIBA52_FIXED */
-
-typedef int16_t quantizer_t;
-#define SAMPLE(x) (sample_t)((x) * (1 << 30))
-#define LEVEL(x) (level_t)((x) * (1 << 26))
-
-#if 0
-#define MUL(a,b) ((int)(((int64_t)(a) * (b) + (1 << 29)) >> 30))
-#define MUL_L(a,b) ((int)(((int64_t)(a) * (b) + (1 << 25)) >> 26))
-#elif 1
-#define MUL(a,b) \
-({ int32_t _ta=(a), _tb=(b), _tc; \
-   _tc=(_ta & 0xffff)*(_tb >> 16)+(_ta >> 16)*(_tb & 0xffff); (int32_t)(((_tc >> 14))+ (((_ta >> 16)*(_tb >> 16)) << 2 )); })
-#define MUL_L(a,b) \
-({ int32_t _ta=(a), _tb=(b), _tc; \
-   _tc=(_ta & 0xffff)*(_tb >> 16)+(_ta >> 16)*(_tb & 0xffff); (int32_t)((_tc >> 10) + (((_ta >> 16)*(_tb >> 16)) << 6)); })
-#else
-#define MUL(a,b) (((a) >> 15) * ((b) >> 15))
-#define MUL_L(a,b) (((a) >> 13) * ((b) >> 13))
-#endif
-
-#define MUL_C(a,b) MUL_L (a, LEVEL (b))
-#define DIV(a,b) ((((int64_t)LEVEL (a)) << 26) / (b))
-#define BIAS(x) (x)
-
-#endif
diff --git a/ffmpeg.src/libavcodec/liba52/a52_util.h b/ffmpeg.src/libavcodec/liba52/a52_util.h
deleted file mode 100644
index 121393e..0000000
--- a/ffmpeg.src/libavcodec/liba52/a52_util.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * a52_util.h
- * Copyright (C) 2000-2003 Michel Lespinasse <walken at zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma at ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec 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.
- *
- * a52dec 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef A52_UTIL_H
-#define A52_UTIL_H
-
-uint16_t a52_crc16_block(uint8_t *data,uint32_t num_bytes);
-
-void* a52_resample_init(uint32_t mm_accel,int flags,int chans);
-extern int (* a52_resample) (float * _f, int16_t * s16);
-
-#endif /* A52_H */
diff --git a/ffmpeg.src/libavcodec/liba52/bit_allocate.c b/ffmpeg.src/libavcodec/liba52/bit_allocate.c
deleted file mode 100644
index 7b595a0..0000000
--- a/ffmpeg.src/libavcodec/liba52/bit_allocate.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * bit_allocate.c
- * Copyright (C) 2000-2003 Michel Lespinasse <walken at zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma at ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec 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.
- *
- * a52dec 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "a52.h"
-#include "a52_internal.h"
-
-static int hthtab[3][50] = {
-    {0x730, 0x730, 0x7c0, 0x800, 0x820, 0x840, 0x850, 0x850, 0x860, 0x860,
-     0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x890, 0x890,
-     0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900,
-     0x910, 0x910, 0x910, 0x910, 0x900, 0x8f0, 0x8c0, 0x870, 0x820, 0x7e0,
-     0x7a0, 0x770, 0x760, 0x7a0, 0x7c0, 0x7c0, 0x6e0, 0x400, 0x3c0, 0x3c0},
-    {0x710, 0x710, 0x7a0, 0x7f0, 0x820, 0x830, 0x840, 0x850, 0x850, 0x860,
-     0x860, 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880,
-     0x890, 0x890, 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8e0, 0x8f0,
-     0x900, 0x910, 0x910, 0x910, 0x910, 0x900, 0x8e0, 0x8b0, 0x870, 0x820,
-     0x7e0, 0x7b0, 0x760, 0x770, 0x7a0, 0x7c0, 0x780, 0x5d0, 0x3c0, 0x3c0},
-    {0x680, 0x680, 0x750, 0x7b0, 0x7e0, 0x810, 0x820, 0x830, 0x840, 0x850,
-     0x850, 0x850, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860,
-     0x870, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880, 0x890, 0x8a0, 0x8b0,
-     0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900, 0x910, 0x910, 0x910, 0x900, 0x8f0,
-     0x8d0, 0x8b0, 0x840, 0x7f0, 0x790, 0x760, 0x7a0, 0x7c0, 0x7b0, 0x720}
-};
-
-static int8_t baptab[305] = {
-    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-    16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,	/* 93 padding elems */
-
-    16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 14, 14, 14, 14, 14,
-    14, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10,  9,  9,  9,
-     9,  8,  8,  8,  8,  7,  7,  7,  7,  6,  6,  6,  6,  5,  5,  5,
-     5,  4,  4, -3, -3,  3,  3,  3, -2, -2, -1, -1, -1, -1, -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,  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,  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					/* 148 padding elems */
-};
-
-static int bndtab[30] = {21, 22,  23,  24,  25,  26,  27,  28,  31,  34,
-			 37, 40,  43,  46,  49,  55,  61,  67,  73,  79,
-			 85, 97, 109, 121, 133, 157, 181, 205, 229, 253};
-
-static int8_t latab[256] = {
-    -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,   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
-};
-
-#define UPDATE_LEAK() 		\
-do {				\
-    fastleak += fdecay;		\
-    if (fastleak > psd + fgain)	\
-	fastleak = psd + fgain;	\
-    slowleak += sdecay;		\
-    if (slowleak > psd + sgain)	\
-	slowleak = psd + sgain;	\
-} while (0)
-
-#define COMPUTE_MASK()				\
-do {						\
-    if (psd > dbknee)				\
-	mask -= (psd - dbknee) >> 2;		\
-    if (mask > hth [i >> halfrate])		\
-	mask = hth [i >> halfrate];		\
-    mask -= snroffset + 128 * deltba[i];	\
-    mask = (mask > 0) ? 0 : ((-mask) >> 5);	\
-    mask -= floor;				\
-} while (0)
-
-void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
-		       int start, int end, int fastleak, int slowleak,
-		       expbap_t * expbap)
-{
-    static int slowgain[4] = {0x540, 0x4d8, 0x478, 0x410};
-    static int dbpbtab[4]  = {0xc00, 0x500, 0x300, 0x100};
-    static int floortab[8] = {0x910, 0x950, 0x990, 0x9d0,
-			      0xa10, 0xa90, 0xb10, 0x1400};
-
-    int i, j;
-    uint8_t * exp;
-    int8_t * bap;
-    int fdecay, fgain, sdecay, sgain, dbknee, floor, snroffset;
-    int psd, mask;
-    int8_t * deltba;
-    int * hth;
-    int halfrate;
-
-    halfrate = state->halfrate;
-    fdecay = (63 + 20 * ((state->bai >> 7) & 3)) >> halfrate;	/* fdcycod */
-    fgain = 128 + 128 * (ba->bai & 7);				/* fgaincod */
-    sdecay = (15 + 2 * (state->bai >> 9)) >> halfrate;		/* sdcycod */
-    sgain = slowgain[(state->bai >> 5) & 3];			/* sgaincod */
-    dbknee = dbpbtab[(state->bai >> 3) & 3];			/* dbpbcod */
-    hth = hthtab[state->fscod];
-    /*
-     * if there is no delta bit allocation, make deltba point to an area
-     * known to contain zeroes. baptab+156 here.
-     */
-    deltba = (ba->deltbae == DELTA_BIT_NONE) ? baptab + 156 : ba->deltba;
-    floor = floortab[state->bai & 7];				/* floorcod */
-    snroffset = 960 - 64 * state->csnroffst - 4 * (ba->bai >> 3) + floor;
-    floor >>= 5;
-
-    exp = expbap->exp;
-    bap = expbap->bap;
-
-    i = bndstart;
-    j = start;
-    if (start == 0) {	/* not the coupling channel */
-	int lowcomp;
-
-	lowcomp = 0;
-	j = end - 1;
-	do {
-	    if (i < j) {
-		if (exp[i+1] == exp[i] - 2)
-		    lowcomp = 384;
-		else if (lowcomp && (exp[i+1] > exp[i]))
-		    lowcomp -= 64;
-	    }
-	    psd = 128 * exp[i];
-	    mask = psd + fgain + lowcomp;
-	    COMPUTE_MASK ();
-	    bap[i] = (baptab+156)[mask + 4 * exp[i]];
-	    i++;
-	} while ((i < 3) || ((i < 7) && (exp[i] > exp[i-1])));
-	fastleak = psd + fgain;
-	slowleak = psd + sgain;
-
-	while (i < 7) {
-	    if (i < j) {
-		if (exp[i+1] == exp[i] - 2)
-		    lowcomp = 384;
-		else if (lowcomp && (exp[i+1] > exp[i]))
-		    lowcomp -= 64;
-	    }
-	    psd = 128 * exp[i];
-	    UPDATE_LEAK ();
-	    mask = ((fastleak + lowcomp < slowleak) ?
-		    fastleak + lowcomp : slowleak);
-	    COMPUTE_MASK ();
-	    bap[i] = (baptab+156)[mask + 4 * exp[i]];
-	    i++;
-	}
-
-	if (end == 7)	/* lfe channel */
-	    return;
-
-	do {
-	    if (exp[i+1] == exp[i] - 2)
-		lowcomp = 320;
-	    else if (lowcomp && (exp[i+1] > exp[i]))
-		lowcomp -= 64;
-	    psd = 128 * exp[i];
-	    UPDATE_LEAK ();
-	    mask = ((fastleak + lowcomp < slowleak) ?
-		    fastleak + lowcomp : slowleak);
-	    COMPUTE_MASK ();
-	    bap[i] = (baptab+156)[mask + 4 * exp[i]];
-	    i++;
-	} while (i < 20);
-
-	while (lowcomp > 128) {		/* two iterations maximum */
-	    lowcomp -= 128;
-	    psd = 128 * exp[i];
-	    UPDATE_LEAK ();
-	    mask = ((fastleak + lowcomp < slowleak) ?
-		    fastleak + lowcomp : slowleak);
-	    COMPUTE_MASK ();
-	    bap[i] = (baptab+156)[mask + 4 * exp[i]];
-	    i++;
-	}
-	j = i;
-    }
-
-    do {
-	int startband, endband;
-
-	startband = j;
-	endband = (bndtab[i-20] < end) ? bndtab[i-20] : end;
-	psd = 128 * exp[j++];
-	while (j < endband) {
-	    int next, delta;
-
-	    next = 128 * exp[j++];
-	    delta = next - psd;
-	    switch (delta >> 9) {
-	    case -6: case -5: case -4: case -3: case -2:
-		psd = next;
-		break;
-	    case -1:
-		psd = next + latab[(-delta) >> 1];
-		break;
-	    case 0:
-		psd += latab[delta >> 1];
-		break;
-	    }
-	}
-	/* minpsd = -289 */
-	UPDATE_LEAK ();
-	mask = (fastleak < slowleak) ? fastleak : slowleak;
-	COMPUTE_MASK ();
-	i++;
-	j = startband;
-	do {
-	    /* max(mask+4*exp)=147=-(minpsd+fgain-deltba-snroffset)>>5+4*exp */
-	    /* min(mask+4*exp)=-156=-(sgain-deltba-snroffset)>>5 */
-	    bap[j] = (baptab+156)[mask + 4 * exp[j]];
-	} while (++j < endband);
-    } while (j < end);
-}
diff --git a/ffmpeg.src/libavcodec/liba52/bitstream.c b/ffmpeg.src/libavcodec/liba52/bitstream.c
deleted file mode 100644
index 89b69cf..0000000
--- a/ffmpeg.src/libavcodec/liba52/bitstream.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * bitstream.c
- * Copyright (C) 2000-2003 Michel Lespinasse <walken at zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma at ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec 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.
- *
- * a52dec 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "a52.h"
-#include "a52_internal.h"
-#include "bitstream.h"
-
-#define BUFFER_SIZE 4096
-
-void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf)
-{
-    int align;
-
-    align = (long)buf & 3;
-    state->buffer_start = (uint32_t *) (buf - align);
-    state->bits_left = 0;
-    state->current_word = 0;
-    bitstream_get (state, align * 8);
-}
-
-static inline void bitstream_fill_current (a52_state_t * state)
-{
-    uint32_t tmp;
-
-    tmp = *(state->buffer_start++);
-    state->current_word = swab32 (tmp);
-}
-
-/*
- * The fast paths for _get is in the
- * bitstream.h header file so it can be inlined.
- *
- * The "bottom half" of this routine is suffixed _bh
- *
- * -ah
- */
-
-uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits)
-{
-    uint32_t result;
-
-    num_bits -= state->bits_left;
-    result = ((state->current_word << (32 - state->bits_left)) >>
-	      (32 - state->bits_left));
-
-    bitstream_fill_current (state);
-
-    if (num_bits != 0)
-	result = (result << num_bits) | (state->current_word >> (32 - num_bits));
-
-    state->bits_left = 32 - num_bits;
-
-    return result;
-}
-
-int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits)
-{
-    int32_t result;
-
-    num_bits -= state->bits_left;
-    result = ((((int32_t)state->current_word) << (32 - state->bits_left)) >>
-	      (32 - state->bits_left));
-
-    bitstream_fill_current(state);
-
-    if (num_bits != 0)
-	result = (result << num_bits) | (state->current_word >> (32 - num_bits));
-	
-    state->bits_left = 32 - num_bits;
-
-    return result;
-}
diff --git a/ffmpeg.src/libavcodec/liba52/bitstream.h b/ffmpeg.src/libavcodec/liba52/bitstream.h
deleted file mode 100644
index f559fbf..0000000
--- a/ffmpeg.src/libavcodec/liba52/bitstream.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * bitstream.h
- * Copyright (C) 2000-2003 Michel Lespinasse <walken at zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma at ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec 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.
- *
- * a52dec 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/* (stolen from the kernel) */
-#ifdef WORDS_BIGENDIAN
-
-#	define swab32(x) (x)
-
-#else
-
-#	if 0 && defined (__i386__)
-
-#	define swab32(x) __i386_swab32(x)
-	static inline const uint32_t __i386_swab32(uint32_t x)
-	{
-		__asm__("bswap %0" : "=r" (x) : "0" (x));
-		return x;
-	}
-
-#	else
-
-#	define swab32(x)\
-((((uint8_t*)&x)[0] << 24) | (((uint8_t*)&x)[1] << 16) |  \
- (((uint8_t*)&x)[2] << 8)  | (((uint8_t*)&x)[3]))
-
-#	endif
-#endif
-
-void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf);
-uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits);
-int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits);
-
-static inline uint32_t bitstream_get (a52_state_t * state, uint32_t num_bits)
-{
-    uint32_t result;
-	
-    if (num_bits < state->bits_left) {
-	result = (state->current_word << (32 - state->bits_left)) >> (32 - num_bits);
-	state->bits_left -= num_bits;
-	return result;
-    }
-
-    return a52_bitstream_get_bh (state, num_bits);
-}
-
-static inline int32_t bitstream_get_2 (a52_state_t * state, uint32_t num_bits)
-{
-    int32_t result;
-	
-    if (num_bits < state->bits_left) {
-	result = (((int32_t)state->current_word) << (32 - state->bits_left)) >> (32 - num_bits);
-	state->bits_left -= num_bits;
-	return result;
-    }
-
-    return a52_bitstream_get_bh_2 (state, num_bits);
-}
diff --git a/ffmpeg.src/libavcodec/liba52/crc.c b/ffmpeg.src/libavcodec/liba52/crc.c
deleted file mode 100644
index 6698155..0000000
--- a/ffmpeg.src/libavcodec/liba52/crc.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* 
- *    crc.c
- *
- *	Copyright (C) Aaron Holtzman - May 1999
- *
- *  This file is part of ac3dec, a free Dolby AC-3 stream decoder.
- *	
- *  ac3dec 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, or (at your option)
- *  any later version.
- *   
- *  ac3dec 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 GNU Make; see the file COPYING.  If not, write to
- *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
- *
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <inttypes.h>
-
-static const uint16_t crc_lut[256] = 
-{
-	0x0000,0x8005,0x800f,0x000a,0x801b,0x001e,0x0014,0x8011,
-	0x8033,0x0036,0x003c,0x8039,0x0028,0x802d,0x8027,0x0022,
-	0x8063,0x0066,0x006c,0x8069,0x0078,0x807d,0x8077,0x0072,
-	0x0050,0x8055,0x805f,0x005a,0x804b,0x004e,0x0044,0x8041,
-	0x80c3,0x00c6,0x00cc,0x80c9,0x00d8,0x80dd,0x80d7,0x00d2,
-	0x00f0,0x80f5,0x80ff,0x00fa,0x80eb,0x00ee,0x00e4,0x80e1,
-	0x00a0,0x80a5,0x80af,0x00aa,0x80bb,0x00be,0x00b4,0x80b1,
-	0x8093,0x0096,0x009c,0x8099,0x0088,0x808d,0x8087,0x0082,
-	0x8183,0x0186,0x018c,0x8189,0x0198,0x819d,0x8197,0x0192,
-	0x01b0,0x81b5,0x81bf,0x01ba,0x81ab,0x01ae,0x01a4,0x81a1,
-	0x01e0,0x81e5,0x81ef,0x01ea,0x81fb,0x01fe,0x01f4,0x81f1,
-	0x81d3,0x01d6,0x01dc,0x81d9,0x01c8,0x81cd,0x81c7,0x01c2,
-	0x0140,0x8145,0x814f,0x014a,0x815b,0x015e,0x0154,0x8151,
-	0x8173,0x0176,0x017c,0x8179,0x0168,0x816d,0x8167,0x0162,
-	0x8123,0x0126,0x012c,0x8129,0x0138,0x813d,0x8137,0x0132,
-	0x0110,0x8115,0x811f,0x011a,0x810b,0x010e,0x0104,0x8101,
-	0x8303,0x0306,0x030c,0x8309,0x0318,0x831d,0x8317,0x0312,
-	0x0330,0x8335,0x833f,0x033a,0x832b,0x032e,0x0324,0x8321,
-	0x0360,0x8365,0x836f,0x036a,0x837b,0x037e,0x0374,0x8371,
-	0x8353,0x0356,0x035c,0x8359,0x0348,0x834d,0x8347,0x0342,
-	0x03c0,0x83c5,0x83cf,0x03ca,0x83db,0x03de,0x03d4,0x83d1,
-	0x83f3,0x03f6,0x03fc,0x83f9,0x03e8,0x83ed,0x83e7,0x03e2,
-	0x83a3,0x03a6,0x03ac,0x83a9,0x03b8,0x83bd,0x83b7,0x03b2,
-	0x0390,0x8395,0x839f,0x039a,0x838b,0x038e,0x0384,0x8381,
-	0x0280,0x8285,0x828f,0x028a,0x829b,0x029e,0x0294,0x8291,
-	0x82b3,0x02b6,0x02bc,0x82b9,0x02a8,0x82ad,0x82a7,0x02a2,
-	0x82e3,0x02e6,0x02ec,0x82e9,0x02f8,0x82fd,0x82f7,0x02f2,
-	0x02d0,0x82d5,0x82df,0x02da,0x82cb,0x02ce,0x02c4,0x82c1,
-	0x8243,0x0246,0x024c,0x8249,0x0258,0x825d,0x8257,0x0252,
-	0x0270,0x8275,0x827f,0x027a,0x826b,0x026e,0x0264,0x8261,
-	0x0220,0x8225,0x822f,0x022a,0x823b,0x023e,0x0234,0x8231,
-	0x8213,0x0216,0x021c,0x8219,0x0208,0x820d,0x8207,0x0202
-};
-
-uint16_t a52_crc16_block(uint8_t *data,uint32_t num_bytes)
-{
-	uint32_t i;
-	uint16_t state=0;
-
-	for(i=0;i<num_bytes;i++)
-		state = crc_lut[data[i] ^ (state>>8)] ^ (state<<8);
-
-	return state;
-}
diff --git a/ffmpeg.src/libavcodec/liba52/downmix.c b/ffmpeg.src/libavcodec/liba52/downmix.c
deleted file mode 100644
index a4ce747..0000000
--- a/ffmpeg.src/libavcodec/liba52/downmix.c
+++ /dev/null
@@ -1,679 +0,0 @@
-/*
- * downmix.c
- * Copyright (C) 2000-2003 Michel Lespinasse <walken at zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma at ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec 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.
- *
- * a52dec 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "a52.h"
-#include "a52_internal.h"
-
-#define CONVERT(acmod,output) (((output) << 3) + (acmod))
-
-int a52_downmix_init (int input, int flags, level_t * level,
-		      level_t clev, level_t slev)
-{
-    static uint8_t table[11][8] = {
-	{A52_CHANNEL,	A52_DOLBY,	A52_STEREO,	A52_STEREO,
-	 A52_STEREO,	A52_STEREO,	A52_STEREO,	A52_STEREO},
-	{A52_MONO,	A52_MONO,	A52_MONO,	A52_MONO,
-	 A52_MONO,	A52_MONO,	A52_MONO,	A52_MONO},
-	{A52_CHANNEL,	A52_DOLBY,	A52_STEREO,	A52_STEREO,
-	 A52_STEREO,	A52_STEREO,	A52_STEREO,	A52_STEREO},
-	{A52_CHANNEL,	A52_DOLBY,	A52_STEREO,	A52_3F,
-	 A52_STEREO,	A52_3F,		A52_STEREO,	A52_3F},
-	{A52_CHANNEL,	A52_DOLBY,	A52_STEREO,	A52_STEREO,
-	 A52_2F1R,	A52_2F1R,	A52_2F1R,	A52_2F1R},
-	{A52_CHANNEL,	A52_DOLBY,	A52_STEREO,	A52_STEREO,
-	 A52_2F1R,	A52_3F1R,	A52_2F1R,	A52_3F1R},
-	{A52_CHANNEL,	A52_DOLBY,	A52_STEREO,	A52_3F,
-	 A52_2F2R,	A52_2F2R,	A52_2F2R,	A52_2F2R},
-	{A52_CHANNEL,	A52_DOLBY,	A52_STEREO,	A52_3F,
-	 A52_2F2R,	A52_3F2R,	A52_2F2R,	A52_3F2R},
-	{A52_CHANNEL1,	A52_MONO,	A52_MONO,	A52_MONO,
-	 A52_MONO,	A52_MONO,	A52_MONO,	A52_MONO},
-	{A52_CHANNEL2,	A52_MONO,	A52_MONO,	A52_MONO,
-	 A52_MONO,	A52_MONO,	A52_MONO,	A52_MONO},
-	{A52_CHANNEL,	A52_DOLBY,	A52_STEREO,	A52_DOLBY,
-	 A52_DOLBY,	A52_DOLBY,	A52_DOLBY,	A52_DOLBY}
-    };
-    int output;
-
-    output = flags & A52_CHANNEL_MASK;
-    if (output > A52_DOLBY)
-	return -1;
-
-    output = table[output][input & 7];
-
-    if (output == A52_STEREO &&
-	(input == A52_DOLBY || (input == A52_3F && clev == LEVEL (LEVEL_3DB))))
-	output = A52_DOLBY;
-
-    if (flags & A52_ADJUST_LEVEL) {
-	level_t adjust;
-
-	switch (CONVERT (input & 7, output)) {
-
-	case CONVERT (A52_3F, A52_MONO):
-	    adjust = DIV (LEVEL_3DB, LEVEL (1) + clev);
-	    break;
-
-	case CONVERT (A52_STEREO, A52_MONO):
-	case CONVERT (A52_2F2R, A52_2F1R):
-	case CONVERT (A52_3F2R, A52_3F1R):
-	level_3db:
-	    adjust = LEVEL (LEVEL_3DB);
-	    break;
-
-	case CONVERT (A52_3F2R, A52_2F1R):
-	    if (clev < LEVEL (LEVEL_PLUS3DB - 1))
-		goto level_3db;
-	    /* break thru */
-	case CONVERT (A52_3F, A52_STEREO):
-	case CONVERT (A52_3F1R, A52_2F1R):
-	case CONVERT (A52_3F1R, A52_2F2R):
-	case CONVERT (A52_3F2R, A52_2F2R):
-	    adjust = DIV (1, LEVEL (1) + clev);
-	    break;
-
-	case CONVERT (A52_2F1R, A52_MONO):
-	    adjust = DIV (LEVEL_PLUS3DB, LEVEL (2) + slev);
-	    break;
-
-	case CONVERT (A52_2F1R, A52_STEREO):
-	case CONVERT (A52_3F1R, A52_3F):
-	    adjust = DIV (1, LEVEL (1) + MUL_C (slev, LEVEL_3DB));
-	    break;
-
-	case CONVERT (A52_3F1R, A52_MONO):
-	    adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + MUL_C (slev, 0.5));
-	    break;
-
-	case CONVERT (A52_3F1R, A52_STEREO):
-	    adjust = DIV (1, LEVEL (1) + clev + MUL_C (slev, LEVEL_3DB));
-	    break;
-
-	case CONVERT (A52_2F2R, A52_MONO):
-	    adjust = DIV (LEVEL_3DB, LEVEL (1) + slev);
-	    break;
-
-	case CONVERT (A52_2F2R, A52_STEREO):
-	case CONVERT (A52_3F2R, A52_3F):
-	    adjust = DIV (1, LEVEL (1) + slev);
-	    break;
-
-	case CONVERT (A52_3F2R, A52_MONO):
-	    adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + slev);
-	    break;
-
-	case CONVERT (A52_3F2R, A52_STEREO):
-	    adjust = DIV (1, LEVEL (1) + clev + slev);
-	    break;
-
-	case CONVERT (A52_MONO, A52_DOLBY):
-	    adjust = LEVEL (LEVEL_PLUS3DB);
-	    break;
-
-	case CONVERT (A52_3F, A52_DOLBY):
-	case CONVERT (A52_2F1R, A52_DOLBY):
-	    adjust = LEVEL (1 / (1 + LEVEL_3DB));
-	    break;
-
-	case CONVERT (A52_3F1R, A52_DOLBY):
-	case CONVERT (A52_2F2R, A52_DOLBY):
-	    adjust = LEVEL (1 / (1 + 2 * LEVEL_3DB));
-	    break;
-
-	case CONVERT (A52_3F2R, A52_DOLBY):
-	    adjust = LEVEL (1 / (1 + 3 * LEVEL_3DB));
-	    break;
-
-	default:
-	    return output;
-	}
-
-	*level = MUL_L (*level, adjust);
-    }
-
-    return output;
-}
-
-int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
-		       level_t clev, level_t slev)
-{
-    level_t level_3db;
-
-    level_3db = MUL_C (level, LEVEL_3DB);
-
-    switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
-
-    case CONVERT (A52_CHANNEL, A52_CHANNEL):
-    case CONVERT (A52_MONO, A52_MONO):
-    case CONVERT (A52_STEREO, A52_STEREO):
-    case CONVERT (A52_3F, A52_3F):
-    case CONVERT (A52_2F1R, A52_2F1R):
-    case CONVERT (A52_3F1R, A52_3F1R):
-    case CONVERT (A52_2F2R, A52_2F2R):
-    case CONVERT (A52_3F2R, A52_3F2R):
-    case CONVERT (A52_STEREO, A52_DOLBY):
-	coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level;
-	return 0;
-
-    case CONVERT (A52_CHANNEL, A52_MONO):
-	coeff[0] = coeff[1] = MUL_C (level, LEVEL_6DB);
-	return 3;
-
-    case CONVERT (A52_STEREO, A52_MONO):
-	coeff[0] = coeff[1] = level_3db;
-	return 3;
-
-    case CONVERT (A52_3F, A52_MONO):
-	coeff[0] = coeff[2] = level_3db;
-	coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
-	return 7;
-
-    case CONVERT (A52_2F1R, A52_MONO):
-	coeff[0] = coeff[1] = level_3db;
-	coeff[2] = MUL_L (level_3db, slev);
-	return 7;
-
-    case CONVERT (A52_2F2R, A52_MONO):
-	coeff[0] = coeff[1] = level_3db;
-	coeff[2] = coeff[3] = MUL_L (level_3db, slev);
-	return 15;
-
-    case CONVERT (A52_3F1R, A52_MONO):
-	coeff[0] = coeff[2] = level_3db;
-	coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
-	coeff[3] = MUL_L (level_3db, slev);
-	return 15;
-
-    case CONVERT (A52_3F2R, A52_MONO):
-	coeff[0] = coeff[2] = level_3db;
-	coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
-	coeff[3] = coeff[4] = MUL_L (level_3db, slev);
-	return 31;
-
-    case CONVERT (A52_MONO, A52_DOLBY):
-	coeff[0] = level_3db;
-	return 0;
-
-    case CONVERT (A52_3F, A52_DOLBY):
-	coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
-	coeff[1] = level_3db;
-	return 7;
-
-    case CONVERT (A52_3F, A52_STEREO):
-    case CONVERT (A52_3F1R, A52_2F1R):
-    case CONVERT (A52_3F2R, A52_2F2R):
-	coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
-	coeff[1] = MUL_L (level, clev);
-	return 7;
-
-    case CONVERT (A52_2F1R, A52_DOLBY):
-	coeff[0] = coeff[1] = level;
-	coeff[2] = level_3db;
-	return 7;
-
-    case CONVERT (A52_2F1R, A52_STEREO):
-	coeff[0] = coeff[1] = level;
-	coeff[2] = MUL_L (level_3db, slev);
-	return 7;
-
-    case CONVERT (A52_3F1R, A52_DOLBY):
-	coeff[0] = coeff[2] = level;
-	coeff[1] = coeff[3] = level_3db;
-	return 15;
-
-    case CONVERT (A52_3F1R, A52_STEREO):
-	coeff[0] = coeff[2] = level;
-	coeff[1] = MUL_L (level, clev);
-	coeff[3] = MUL_L (level_3db, slev);
-	return 15;
-
-    case CONVERT (A52_2F2R, A52_DOLBY):
-	coeff[0] = coeff[1] = level;
-	coeff[2] = coeff[3] = level_3db;
-	return 15;
-
-    case CONVERT (A52_2F2R, A52_STEREO):
-	coeff[0] = coeff[1] = level;
-	coeff[2] = coeff[3] = MUL_L (level, slev);
-	return 15;
-
-    case CONVERT (A52_3F2R, A52_DOLBY):
-	coeff[0] = coeff[2] = level;
-	coeff[1] = coeff[3] = coeff[4] = level_3db;
-	return 31;
-
-    case CONVERT (A52_3F2R, A52_2F1R):
-	coeff[0] = coeff[2] = level;
-	coeff[1] = MUL_L (level, clev);
-	coeff[3] = coeff[4] = level_3db;
-	return 31;
-
-    case CONVERT (A52_3F2R, A52_STEREO):
-	coeff[0] = coeff[2] = level;
-	coeff[1] = MUL_L (level, clev);
-	coeff[3] = coeff[4] = MUL_L (level, slev);
-	return 31;
-
-    case CONVERT (A52_3F1R, A52_3F):
-	coeff[0] = coeff[1] = coeff[2] = level;
-	coeff[3] = MUL_L (level_3db, slev);
-	return 13;
-
-    case CONVERT (A52_3F2R, A52_3F):
-	coeff[0] = coeff[1] = coeff[2] = level;
-	coeff[3] = coeff[4] = MUL_L (level, slev);
-	return 29;
-
-    case CONVERT (A52_2F2R, A52_2F1R):
-	coeff[0] = coeff[1] = level;
-	coeff[2] = coeff[3] = level_3db;
-	return 12;
-
-    case CONVERT (A52_3F2R, A52_3F1R):
-	coeff[0] = coeff[1] = coeff[2] = level;
-	coeff[3] = coeff[4] = level_3db;
-	return 24;
-
-    case CONVERT (A52_2F1R, A52_2F2R):
-	coeff[0] = coeff[1] = level;
-	coeff[2] = level_3db;
-	return 0;
-
-    case CONVERT (A52_3F1R, A52_2F2R):
-	coeff[0] = coeff[2] = level;
-	coeff[1] = MUL_L (level, clev);
-	coeff[3] = level_3db;
-	return 7;
-
-    case CONVERT (A52_3F1R, A52_3F2R):
-	coeff[0] = coeff[1] = coeff[2] = level;
-	coeff[3] = level_3db;
-	return 0;
-
-    case CONVERT (A52_CHANNEL, A52_CHANNEL1):
-	coeff[0] = level;
-	coeff[1] = 0;
-	return 0;
-
-    case CONVERT (A52_CHANNEL, A52_CHANNEL2):
-	coeff[0] = 0;
-	coeff[1] = level;
-	return 0;
-    }
-
-    return -1;	/* NOTREACHED */
-}
-
-static void mix2to1 (sample_t * dest, sample_t * src, sample_t bias)
-{
-    int i;
-
-    for (i = 0; i < 256; i++)
-	dest[i] += BIAS (src[i]);
-}
-
-static void mix3to1 (sample_t * samples, sample_t bias)
-{
-    int i;
-
-    for (i = 0; i < 256; i++)
-	samples[i] += BIAS (samples[i + 256] + samples[i + 512]);
-}
-
-static void mix4to1 (sample_t * samples, sample_t bias)
-{
-    int i;
-
-    for (i = 0; i < 256; i++)
-	samples[i] += BIAS (samples[i + 256] + samples[i + 512] +
-			    samples[i + 768]);
-}
-
-static void mix5to1 (sample_t * samples, sample_t bias)
-{
-    int i;
-
-    for (i = 0; i < 256; i++)
-	samples[i] += BIAS (samples[i + 256] + samples[i + 512] +
-			    samples[i + 768] + samples[i + 1024]);
-}
-
-static void mix3to2 (sample_t * samples, sample_t bias)
-{
-    int i;
-    sample_t common;
-
-    for (i = 0; i < 256; i++) {
-	common = BIAS (samples[i + 256]);
-	samples[i] += common;
-	samples[i + 256] = samples[i + 512] + common;
-    }
-}
-
-static void mix21to2 (sample_t * left, sample_t * right, sample_t bias)
-{
-    int i;
-    sample_t common;
-
-    for (i = 0; i < 256; i++) {
-	common = BIAS (right[i + 256]);
-	left[i] += common;
-	right[i] += common;
-    }
-}
-
-static void mix21toS (sample_t * samples, sample_t bias)
-{
-    int i;
-    sample_t surround;
-
-    for (i = 0; i < 256; i++) {
-	surround = samples[i + 512];
-	samples[i] += BIAS (-surround);
-	samples[i + 256] += BIAS (surround);
-    }
-}
-
-static void mix31to2 (sample_t * samples, sample_t bias)
-{
-    int i;
-    sample_t common;
-
-    for (i = 0; i < 256; i++) {
-	common = BIAS (samples[i + 256] + samples[i + 768]);
-	samples[i] += common;
-	samples[i + 256] = samples[i + 512] + common;
-    }
-}
-
-static void mix31toS (sample_t * samples, sample_t bias)
-{
-    int i;
-    sample_t common, surround;
-
-    for (i = 0; i < 256; i++) {
-	common = BIAS (samples[i + 256]);
-	surround = samples[i + 768];
-	samples[i] += common - surround;
-	samples[i + 256] = samples[i + 512] + common + surround;
-    }
-}
-
-static void mix22toS (sample_t * samples, sample_t bias)
-{
-    int i;
-    sample_t surround;
-
-    for (i = 0; i < 256; i++) {
-	surround = samples[i + 512] + samples[i + 768];
-	samples[i] += BIAS (-surround);
-	samples[i + 256] += BIAS (surround);
-    }
-}
-
-static void mix32to2 (sample_t * samples, sample_t bias)
-{
-    int i;
-    sample_t common;
-
-    for (i = 0; i < 256; i++) {
-	common = BIAS (samples[i + 256]);
-	samples[i] += common + samples[i + 768];
-	samples[i + 256] = common + samples[i + 512] + samples[i + 1024];
-    }
-}
-
-static void mix32toS (sample_t * samples, sample_t bias)
-{
-    int i;
-    sample_t common, surround;
-
-    for (i = 0; i < 256; i++) {
-	common = BIAS (samples[i + 256]);
-	surround = samples[i + 768] + samples[i + 1024];
-	samples[i] += common - surround;
-	samples[i + 256] = samples[i + 512] + common + surround;
-    }
-}
-
-static void move2to1 (sample_t * src, sample_t * dest, sample_t bias)
-{
-    int i;
-
-    for (i = 0; i < 256; i++)
-	dest[i] = BIAS (src[i] + src[i + 256]);
-}
-
-static void zero (sample_t * samples)
-{
-    int i;
-
-    for (i = 0; i < 256; i++)
-	samples[i] = 0;
-}
-
-void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias,
-		  level_t clev, level_t slev)
-{
-    switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
-
-    case CONVERT (A52_CHANNEL, A52_CHANNEL2):
-	memcpy (samples, samples + 256, 256 * sizeof (sample_t));
-	break;
-
-    case CONVERT (A52_CHANNEL, A52_MONO):
-    case CONVERT (A52_STEREO, A52_MONO):
-    mix_2to1:
-	mix2to1 (samples, samples + 256, bias);
-	break;
-
-    case CONVERT (A52_2F1R, A52_MONO):
-	if (slev == 0)
-	    goto mix_2to1;
-    case CONVERT (A52_3F, A52_MONO):
-    mix_3to1:
-	mix3to1 (samples, bias);
-	break;
-
-    case CONVERT (A52_3F1R, A52_MONO):
-	if (slev == 0)
-	    goto mix_3to1;
-    case CONVERT (A52_2F2R, A52_MONO):
-	if (slev == 0)
-	    goto mix_2to1;
-	mix4to1 (samples, bias);
-	break;
-
-    case CONVERT (A52_3F2R, A52_MONO):
-	if (slev == 0)
-	    goto mix_3to1;
-	mix5to1 (samples, bias);
-	break;
-
-    case CONVERT (A52_MONO, A52_DOLBY):
-	memcpy (samples + 256, samples, 256 * sizeof (sample_t));
-	break;
-
-    case CONVERT (A52_3F, A52_STEREO):
-    case CONVERT (A52_3F, A52_DOLBY):
-    mix_3to2:
-	mix3to2 (samples, bias);
-	break;
-
-    case CONVERT (A52_2F1R, A52_STEREO):
-	if (slev == 0)
-	    break;
-	mix21to2 (samples, samples + 256, bias);
-	break;
-
-    case CONVERT (A52_2F1R, A52_DOLBY):
-	mix21toS (samples, bias);
-	break;
-
-    case CONVERT (A52_3F1R, A52_STEREO):
-	if (slev == 0)
-	    goto mix_3to2;
-	mix31to2 (samples, bias);
-	break;
-
-    case CONVERT (A52_3F1R, A52_DOLBY):
-	mix31toS (samples, bias);
-	break;
-
-    case CONVERT (A52_2F2R, A52_STEREO):
-	if (slev == 0)
-	    break;
-	mix2to1 (samples, samples + 512, bias);
-	mix2to1 (samples + 256, samples + 768, bias);
-	break;
-
-    case CONVERT (A52_2F2R, A52_DOLBY):
-	mix22toS (samples, bias);
-	break;
-
-    case CONVERT (A52_3F2R, A52_STEREO):
-	if (slev == 0)
-	    goto mix_3to2;
-	mix32to2 (samples, bias);
-	break;
-
-    case CONVERT (A52_3F2R, A52_DOLBY):
-	mix32toS (samples, bias);
-	break;
-
-    case CONVERT (A52_3F1R, A52_3F):
-	if (slev == 0)
-	    break;
-	mix21to2 (samples, samples + 512, bias);
-	break;
-
-    case CONVERT (A52_3F2R, A52_3F):
-	if (slev == 0)
-	    break;
-	mix2to1 (samples, samples + 768, bias);
-	mix2to1 (samples + 512, samples + 1024, bias);
-	break;
-
-    case CONVERT (A52_3F1R, A52_2F1R):
-	mix3to2 (samples, bias);
-	memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
-	break;
-
-    case CONVERT (A52_2F2R, A52_2F1R):
-	mix2to1 (samples + 512, samples + 768, bias);
-	break;
-
-    case CONVERT (A52_3F2R, A52_2F1R):
-	mix3to2 (samples, bias);
-	move2to1 (samples + 768, samples + 512, bias);
-	break;
-
-    case CONVERT (A52_3F2R, A52_3F1R):
-	mix2to1 (samples + 768, samples + 1024, bias);
-	break;
-
-    case CONVERT (A52_2F1R, A52_2F2R):
-	memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
-	break;
-
-    case CONVERT (A52_3F1R, A52_2F2R):
-	mix3to2 (samples, bias);
-	memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
-	break;
-
-    case CONVERT (A52_3F2R, A52_2F2R):
-	mix3to2 (samples, bias);
-	memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
-	memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t));
-	break;
-
-    case CONVERT (A52_3F1R, A52_3F2R):
-	memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
-	break;
-    }
-}
-
-void a52_upmix (sample_t * samples, int acmod, int output)
-{
-    switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
-
-    case CONVERT (A52_CHANNEL, A52_CHANNEL2):
-	memcpy (samples + 256, samples, 256 * sizeof (sample_t));
-	break;
-
-    case CONVERT (A52_3F2R, A52_MONO):
-	zero (samples + 1024);
-    case CONVERT (A52_3F1R, A52_MONO):
-    case CONVERT (A52_2F2R, A52_MONO):
-	zero (samples + 768);
-    case CONVERT (A52_3F, A52_MONO):
-    case CONVERT (A52_2F1R, A52_MONO):
-	zero (samples + 512);
-    case CONVERT (A52_CHANNEL, A52_MONO):
-    case CONVERT (A52_STEREO, A52_MONO):
-	zero (samples + 256);
-	break;
-
-    case CONVERT (A52_3F2R, A52_STEREO):
-    case CONVERT (A52_3F2R, A52_DOLBY):
-	zero (samples + 1024);
-    case CONVERT (A52_3F1R, A52_STEREO):
-    case CONVERT (A52_3F1R, A52_DOLBY):
-	zero (samples + 768);
-    case CONVERT (A52_3F, A52_STEREO):
-    case CONVERT (A52_3F, A52_DOLBY):
-    mix_3to2:
-	memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t));
-	zero (samples + 256);
-	break;
-
-    case CONVERT (A52_2F2R, A52_STEREO):
-    case CONVERT (A52_2F2R, A52_DOLBY):
-	zero (samples + 768);
-    case CONVERT (A52_2F1R, A52_STEREO):
-    case CONVERT (A52_2F1R, A52_DOLBY):
-	zero (samples + 512);
-	break;
-
-    case CONVERT (A52_3F2R, A52_3F):
-	zero (samples + 1024);
-    case CONVERT (A52_3F1R, A52_3F):
-    case CONVERT (A52_2F2R, A52_2F1R):
-	zero (samples + 768);
-	break;
-
-    case CONVERT (A52_3F2R, A52_3F1R):
-	zero (samples + 1024);
-	break;
-
-    case CONVERT (A52_3F2R, A52_2F1R):
-	zero (samples + 1024);
-    case CONVERT (A52_3F1R, A52_2F1R):
-    mix_31to21:
-	memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
-	goto mix_3to2;
-
-    case CONVERT (A52_3F2R, A52_2F2R):
-	memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
-	goto mix_31to21;
-    }
-}
diff --git a/ffmpeg.src/libavcodec/liba52/imdct.c b/ffmpeg.src/libavcodec/liba52/imdct.c
deleted file mode 100644
index 7a1690b..0000000
--- a/ffmpeg.src/libavcodec/liba52/imdct.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * imdct.c
- * Copyright (C) 2000-2003 Michel Lespinasse <walken at zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma at ess.engr.uvic.ca>
- *
- * The ifft algorithms in this file have been largely inspired by Dan
- * Bernstein's work, djbfft, available at http://cr.yp.to/djbfft.html
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec 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.
- *
- * a52dec 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "a52.h"
-#include "a52_internal.h"
-#include "mm_accel.h"
-
-typedef struct complex_s {
-    sample_t real;
-    sample_t imag;
-} complex_t;
-
-static uint8_t fftorder[] = {
-      0,128, 64,192, 32,160,224, 96, 16,144, 80,208,240,112, 48,176,
-      8,136, 72,200, 40,168,232,104,248,120, 56,184, 24,152,216, 88,
-      4,132, 68,196, 36,164,228,100, 20,148, 84,212,244,116, 52,180,
-    252,124, 60,188, 28,156,220, 92, 12,140, 76,204,236,108, 44,172,
-      2,130, 66,194, 34,162,226, 98, 18,146, 82,210,242,114, 50,178,
-     10,138, 74,202, 42,170,234,106,250,122, 58,186, 26,154,218, 90,
-    254,126, 62,190, 30,158,222, 94, 14,142, 78,206,238,110, 46,174,
-      6,134, 70,198, 38,166,230,102,246,118, 54,182, 22,150,214, 86
-};
-
-/* Root values for IFFT */
-static sample_t roots16[3];
-static sample_t roots32[7];
-static sample_t roots64[15];
-static sample_t roots128[31];
-
-/* Twiddle factors for IMDCT */
-static complex_t pre1[128];
-static complex_t post1[64];
-static complex_t pre2[64];
-static complex_t post2[32];
-
-static sample_t a52_imdct_window[256];
-
-static void (* ifft128) (complex_t * buf);
-static void (* ifft64) (complex_t * buf);
-
-static inline void ifft2 (complex_t * buf)
-{
-    sample_t r, i;
-
-    r = buf[0].real;
-    i = buf[0].imag;
-    buf[0].real += buf[1].real;
-    buf[0].imag += buf[1].imag;
-    buf[1].real = r - buf[1].real;
-    buf[1].imag = i - buf[1].imag;
-}
-
-static inline void ifft4 (complex_t * buf)
-{
-    sample_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
-
-    tmp1 = buf[0].real + buf[1].real;
-    tmp2 = buf[3].real + buf[2].real;
-    tmp3 = buf[0].imag + buf[1].imag;
-    tmp4 = buf[2].imag + buf[3].imag;
-    tmp5 = buf[0].real - buf[1].real;
-    tmp6 = buf[0].imag - buf[1].imag;
-    tmp7 = buf[2].imag - buf[3].imag;
-    tmp8 = buf[3].real - buf[2].real;
-
-    buf[0].real = tmp1 + tmp2;
-    buf[0].imag = tmp3 + tmp4;
-    buf[2].real = tmp1 - tmp2;
-    buf[2].imag = tmp3 - tmp4;
-    buf[1].real = tmp5 + tmp7;
-    buf[1].imag = tmp6 + tmp8;
-    buf[3].real = tmp5 - tmp7;
-    buf[3].imag = tmp6 - tmp8;
-}
-
-/* basic radix-2 ifft butterfly */
-
-#define BUTTERFLY_0(t0,t1,W0,W1,d0,d1) do {	\
-    t0 = MUL (W1, d1) + MUL (W0, d0);		\
-    t1 = MUL (W0, d1) - MUL (W1, d0);		\
-} while (0)
-
-/* radix-2 ifft butterfly with bias */
-
-#define BUTTERFLY_B(t0,t1,W0,W1,d0,d1) do {	\
-    t0 = BIAS (MUL (d1, W1) + MUL (d0, W0));	\
-    t1 = BIAS (MUL (d1, W0) - MUL (d0, W1));	\
-} while (0)
-
-/* the basic split-radix ifft butterfly */
-
-#define BUTTERFLY(a0,a1,a2,a3,wr,wi) do {		\
-    BUTTERFLY_0 (tmp5, tmp6, wr, wi, a2.real, a2.imag);	\
-    BUTTERFLY_0 (tmp8, tmp7, wr, wi, a3.imag, a3.real);	\
-    tmp1 = tmp5 + tmp7;					\
-    tmp2 = tmp6 + tmp8;					\
-    tmp3 = tmp6 - tmp8;					\
-    tmp4 = tmp7 - tmp5;					\
-    a2.real = a0.real - tmp1;				\
-    a2.imag = a0.imag - tmp2;				\
-    a3.real = a1.real - tmp3;				\
-    a3.imag = a1.imag - tmp4;				\
-    a0.real += tmp1;					\
-    a0.imag += tmp2;					\
-    a1.real += tmp3;					\
-    a1.imag += tmp4;					\
-} while (0)
-
-/* split-radix ifft butterfly, specialized for wr=1 wi=0 */
-
-#define BUTTERFLY_ZERO(a0,a1,a2,a3) do {	\
-    tmp1 = a2.real + a3.real;			\
-    tmp2 = a2.imag + a3.imag;			\
-    tmp3 = a2.imag - a3.imag;			\
-    tmp4 = a3.real - a2.real;			\
-    a2.real = a0.real - tmp1;			\
-    a2.imag = a0.imag - tmp2;			\
-    a3.real = a1.real - tmp3;			\
-    a3.imag = a1.imag - tmp4;			\
-    a0.real += tmp1;				\
-    a0.imag += tmp2;				\
-    a1.real += tmp3;				\
-    a1.imag += tmp4;				\
-} while (0)
-
-/* split-radix ifft butterfly, specialized for wr=wi */
-
-#define BUTTERFLY_HALF(a0,a1,a2,a3,w) do {	\
-    tmp5 = MUL (a2.real + a2.imag, w);		\
-    tmp6 = MUL (a2.imag - a2.real, w);		\
-    tmp7 = MUL (a3.real - a3.imag, w);		\
-    tmp8 = MUL (a3.imag + a3.real, w);		\
-    tmp1 = tmp5 + tmp7;				\
-    tmp2 = tmp6 + tmp8;				\
-    tmp3 = tmp6 - tmp8;				\
-    tmp4 = tmp7 - tmp5;				\
-    a2.real = a0.real - tmp1;			\
-    a2.imag = a0.imag - tmp2;			\
-    a3.real = a1.real - tmp3;			\
-    a3.imag = a1.imag - tmp4;			\
-    a0.real += tmp1;				\
-    a0.imag += tmp2;				\
-    a1.real += tmp3;				\
-    a1.imag += tmp4;				\
-} while (0)
-
-static inline void ifft8 (complex_t * buf)
-{
-    sample_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
-
-    ifft4 (buf);
-    ifft2 (buf + 4);
-    ifft2 (buf + 6);
-    BUTTERFLY_ZERO (buf[0], buf[2], buf[4], buf[6]);
-    BUTTERFLY_HALF (buf[1], buf[3], buf[5], buf[7], roots16[1]);
-}
-
-static void ifft_pass (complex_t * buf, sample_t * weight, int n)
-{
-    complex_t * buf1;
-    complex_t * buf2;
-    complex_t * buf3;
-    sample_t tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
-    int i;
-
-    buf++;
-    buf1 = buf + n;
-    buf2 = buf + 2 * n;
-    buf3 = buf + 3 * n;
-
-    BUTTERFLY_ZERO (buf[-1], buf1[-1], buf2[-1], buf3[-1]);
-
-    i = n - 1;
-
-    do {
-	BUTTERFLY (buf[0], buf1[0], buf2[0], buf3[0],
-		   weight[0], weight[2*i-n]);
-	buf++;
-	buf1++;
-	buf2++;
-	buf3++;
-	weight++;
-    } while (--i);
-}
-
-static void ifft16 (complex_t * buf)
-{
-    ifft8 (buf);
-    ifft4 (buf + 8);
-    ifft4 (buf + 12);
-    ifft_pass (buf, roots16, 4);
-}
-
-static void ifft32 (complex_t * buf)
-{
-    ifft16 (buf);
-    ifft8 (buf + 16);
-    ifft8 (buf + 24);
-    ifft_pass (buf, roots32, 8);
-}
-
-static void ifft64_c (complex_t * buf)
-{
-    ifft32 (buf);
-    ifft16 (buf + 32);
-    ifft16 (buf + 48);
-    ifft_pass (buf, roots64, 16);
-}
-
-static void ifft128_c (complex_t * buf)
-{
-    ifft32 (buf);
-    ifft16 (buf + 32);
-    ifft16 (buf + 48);
-    ifft_pass (buf, roots64, 16);
-
-    ifft32 (buf + 64);
-    ifft32 (buf + 96);
-    ifft_pass (buf, roots128, 32);
-}
-
-void a52_imdct_512 (sample_t * data, sample_t * delay, sample_t bias)
-{
-    int i, k;
-    sample_t t_r, t_i, a_r, a_i, b_r, b_i, w_1, w_2;
-    const sample_t * window = a52_imdct_window;
-    complex_t buf[128];
-	
-    for (i = 0; i < 128; i++) {
-	k = fftorder[i];
-	t_r = pre1[i].real;
-	t_i = pre1[i].imag;
-	BUTTERFLY_0 (buf[i].real, buf[i].imag, t_r, t_i, data[k], data[255-k]);
-    }
-
-    ifft128 (buf);
-
-    /* Post IFFT complex multiply plus IFFT complex conjugate*/
-    /* Window and convert to real valued signal */
-    for (i = 0; i < 64; i++) {
-	/* y[n] = z[n] * (xcos1[n] + j * xsin1[n]) ; */
-	t_r = post1[i].real;
-	t_i = post1[i].imag;
-	BUTTERFLY_0 (a_r, a_i, t_i, t_r, buf[i].imag, buf[i].real);
-	BUTTERFLY_0 (b_r, b_i, t_r, t_i, buf[127-i].imag, buf[127-i].real);
-
-	w_1 = window[2*i];
-	w_2 = window[255-2*i];
-	BUTTERFLY_B (data[255-2*i], data[2*i], w_2, w_1, a_r, delay[2*i]);
-	delay[2*i] = a_i;
-
-	w_1 = window[2*i+1];
-	w_2 = window[254-2*i];
-	BUTTERFLY_B (data[2*i+1], data[254-2*i], w_1, w_2, b_r, delay[2*i+1]);
-	delay[2*i+1] = b_i;
-    }
-}
-
-void a52_imdct_256 (sample_t * data, sample_t * delay, sample_t bias)
-{
-    int i, k;
-    sample_t t_r, t_i, a_r, a_i, b_r, b_i, c_r, c_i, d_r, d_i, w_1, w_2;
-    const sample_t * window = a52_imdct_window;
-    complex_t buf1[64], buf2[64];
-
-    /* Pre IFFT complex multiply plus IFFT cmplx conjugate */
-    for (i = 0; i < 64; i++) {
-	k = fftorder[i];
-	t_r = pre2[i].real;
-	t_i = pre2[i].imag;
-	BUTTERFLY_0 (buf1[i].real, buf1[i].imag, t_r, t_i, data[k], data[254-k]);
-	BUTTERFLY_0 (buf2[i].real, buf2[i].imag, t_r, t_i, data[k+1], data[255-k]);
-    }
-
-    ifft64 (buf1);
-    ifft64 (buf2);
-
-    /* Post IFFT complex multiply */
-    /* Window and convert to real valued signal */
-    for (i = 0; i < 32; i++) {
-	/* y1[n] = z1[n] * (xcos2[n] + j * xs in2[n]) ; */ 
-	t_r = post2[i].real;
-	t_i = post2[i].imag;
-	BUTTERFLY_0 (a_r, a_i, t_i, t_r, buf1[i].imag, buf1[i].real);
-	BUTTERFLY_0 (b_r, b_i, t_r, t_i, buf1[63-i].imag, buf1[63-i].real);
-	BUTTERFLY_0 (c_r, c_i, t_i, t_r, buf2[i].imag, buf2[i].real);
-	BUTTERFLY_0 (d_r, d_i, t_r, t_i, buf2[63-i].imag, buf2[63-i].real);
-
-	w_1 = window[2*i];
-	w_2 = window[255-2*i];
-	BUTTERFLY_B (data[255-2*i], data[2*i], w_2, w_1, a_r, delay[2*i]);
-	delay[2*i] = c_i;
-
-	w_1 = window[128+2*i];
-	w_2 = window[127-2*i];
-	BUTTERFLY_B (data[128+2*i], data[127-2*i], w_1, w_2, a_i, delay[127-2*i]);
-	delay[127-2*i] = c_r;
-
-	w_1 = window[2*i+1];
-	w_2 = window[254-2*i];
-	BUTTERFLY_B (data[254-2*i], data[2*i+1], w_2, w_1, b_i, delay[2*i+1]);
-	delay[2*i+1] = d_r;
-
-	w_1 = window[129+2*i];
-	w_2 = window[126-2*i];
-	BUTTERFLY_B (data[129+2*i], data[126-2*i], w_1, w_2, b_r, delay[126-2*i]);
-	delay[126-2*i] = d_i;
-    }
-}
-
-static double besselI0 (double x)
-{
-    double bessel = 1;
-    int i = 100;
-
-    do
-	bessel = bessel * x / (i * i) + 1;
-    while (--i);
-    return bessel;
-}
-
-void a52_imdct_init (uint32_t mm_accel)
-{
-    int i, k;
-    double sum;
-    double local_imdct_window[256];
-
-    /* compute imdct window - kaiser-bessel derived window, alpha = 5.0 */
-    sum = 0;
-    for (i = 0; i < 256; i++) {
-	sum += besselI0 (i * (256 - i) * (5 * M_PI / 256) * (5 * M_PI / 256));
-	local_imdct_window[i] = sum;
-    }
-    sum++;
-    for (i = 0; i < 256; i++)
-	a52_imdct_window[i] = SAMPLE (sqrt (local_imdct_window[i] / sum));
-
-    for (i = 0; i < 3; i++)
-	roots16[i] = SAMPLE (cos ((M_PI / 8) * (i + 1)));
-
-    for (i = 0; i < 7; i++)
-	roots32[i] = SAMPLE (cos ((M_PI / 16) * (i + 1)));
-
-    for (i = 0; i < 15; i++)
-	roots64[i] = SAMPLE (cos ((M_PI / 32) * (i + 1)));
-
-    for (i = 0; i < 31; i++)
-	roots128[i] = SAMPLE (cos ((M_PI / 64) * (i + 1)));
-
-    for (i = 0; i < 64; i++) {
-	k = fftorder[i] / 2 + 64;
-	pre1[i].real = SAMPLE (cos ((M_PI / 256) * (k - 0.25)));
-	pre1[i].imag = SAMPLE (sin ((M_PI / 256) * (k - 0.25)));
-    }
-
-    for (i = 64; i < 128; i++) {
-	k = fftorder[i] / 2 + 64;
-	pre1[i].real = SAMPLE (-cos ((M_PI / 256) * (k - 0.25)));
-	pre1[i].imag = SAMPLE (-sin ((M_PI / 256) * (k - 0.25)));
-    }
-
-    for (i = 0; i < 64; i++) {
-	post1[i].real = SAMPLE (cos ((M_PI / 256) * (i + 0.5)));
-	post1[i].imag = SAMPLE (sin ((M_PI / 256) * (i + 0.5)));
-    }
-
-    for (i = 0; i < 64; i++) {
-	k = fftorder[i] / 4;
-	pre2[i].real = SAMPLE (cos ((M_PI / 128) * (k - 0.25)));
-	pre2[i].imag = SAMPLE (sin ((M_PI / 128) * (k - 0.25)));
-    }
-
-    for (i = 0; i < 32; i++) {
-	post2[i].real = SAMPLE (cos ((M_PI / 128) * (i + 0.5)));
-	post2[i].imag = SAMPLE (sin ((M_PI / 128) * (i + 0.5)));
-    }
-
-#ifdef LIBA52_DJBFFT
-    if (mm_accel & MM_ACCEL_DJBFFT) {
-	ifft128 = (void (*) (complex_t *)) fftc4_un128;
-	ifft64 = (void (*) (complex_t *)) fftc4_un64;
-    } else
-#endif
-    {
-	ifft128 = ifft128_c;
-	ifft64 = ifft64_c;
-    }
-}
diff --git a/ffmpeg.src/libavcodec/liba52/mm_accel.h b/ffmpeg.src/libavcodec/liba52/mm_accel.h
deleted file mode 100644
index 8afbd35..0000000
--- a/ffmpeg.src/libavcodec/liba52/mm_accel.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * mm_accel.h
- * Copyright (C) 2000-2002 Michel Lespinasse <walken at zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma at ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec 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.
- *
- * a52dec 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef MM_ACCEL_H
-#define MM_ACCEL_H
-
-/* generic accelerations */
-#define MM_ACCEL_DJBFFT		0x00000001
-
-/* x86 accelerations */
-#define MM_ACCEL_X86_MMX	0x80000000
-#define MM_ACCEL_X86_3DNOW	0x40000000
-#define MM_ACCEL_X86_MMXEXT	0x20000000
-#define MM_ACCEL_X86_SSE	0x10000000
-#define MM_ACCEL_X86_3DNOWEXT	0x08000000
-
-/* PPC accelerations */
-#define MM_ACCEL_PPC_ALTIVEC	0x00010000
-
-uint32_t mm_accel (void);
-
-#endif /* MM_ACCEL_H */
diff --git a/ffmpeg.src/libavcodec/liba52/parse.c b/ffmpeg.src/libavcodec/liba52/parse.c
deleted file mode 100644
index d3e6914..0000000
--- a/ffmpeg.src/libavcodec/liba52/parse.c
+++ /dev/null
@@ -1,939 +0,0 @@
-/*
- * parse.c
- * Copyright (C) 2000-2003 Michel Lespinasse <walken at zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma at ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec 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.
- *
- * a52dec 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "a52.h"
-#include "a52_internal.h"
-#include "bitstream.h"
-#include "tables.h"
-
-#if defined(HAVE_MEMALIGN) && !defined(__cplusplus)
-/* some systems have memalign() but no declaration for it */
-void * memalign (size_t align, size_t size);
-#else
-/* assume malloc alignment is sufficient */
-#define memalign(align,size) malloc (size)
-#endif
-
-typedef struct {
-    quantizer_t q1[2];
-    quantizer_t q2[2];
-    quantizer_t q4;
-    int q1_ptr;
-    int q2_ptr;
-    int q4_ptr;
-} quantizer_set_t;
-
-static uint8_t halfrate[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3};
-
-a52_state_t * a52_init (uint32_t mm_accel)
-{
-    a52_state_t * state;
-    int i;
-
-    state = (a52_state_t *) malloc (sizeof (a52_state_t));
-    if (state == NULL)
-	return NULL;
-
-    state->samples = (sample_t *) memalign (16, 256 * 12 * sizeof (sample_t));
-    if (state->samples == NULL) {
-	free (state);
-	return NULL;
-    }
-
-    for (i = 0; i < 256 * 12; i++)
-	state->samples[i] = 0;
-
-    state->downmixed = 1;
-
-    state->lfsr_state = 1;
-
-    a52_imdct_init (mm_accel);
-
-    return state;
-}
-
-sample_t * a52_samples (a52_state_t * state)
-{
-    return state->samples;
-}
-
-int a52_syncinfo (uint8_t * buf, int * flags,
-		  int * sample_rate, int * bit_rate)
-{
-    static int rate[] = { 32,  40,  48,  56,  64,  80,  96, 112,
-			 128, 160, 192, 224, 256, 320, 384, 448,
-			 512, 576, 640};
-    static uint8_t lfeon[8] = {0x10, 0x10, 0x04, 0x04, 0x04, 0x01, 0x04, 0x01};
-    int frmsizecod;
-    int bitrate;
-    int half;
-    int acmod;
-
-    if ((buf[0] != 0x0b) || (buf[1] != 0x77))	/* syncword */
-	return 0;
-
-    if (buf[5] >= 0x60)		/* bsid >= 12 */
-	return 0;
-    half = halfrate[buf[5] >> 3];
-
-    /* acmod, dsurmod and lfeon */
-    acmod = buf[6] >> 5;
-    *flags = ((((buf[6] & 0xf8) == 0x50) ? A52_DOLBY : acmod) |
-	      ((buf[6] & lfeon[acmod]) ? A52_LFE : 0));
-
-    frmsizecod = buf[4] & 63;
-    if (frmsizecod >= 38)
-	return 0;
-    bitrate = rate [frmsizecod >> 1];
-    *bit_rate = (bitrate * 1000) >> half;
-
-    switch (buf[4] & 0xc0) {
-    case 0:
-	*sample_rate = 48000 >> half;
-	return 4 * bitrate;
-    case 0x40:
-	*sample_rate = 44100 >> half;
-	return 2 * (320 * bitrate / 147 + (frmsizecod & 1));
-    case 0x80:
-	*sample_rate = 32000 >> half;
-	return 6 * bitrate;
-    default:
-	return 0;
-    }
-}
-
-int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
-	       level_t * level, sample_t bias)
-{
-    static level_t clev[4] = { LEVEL (LEVEL_3DB), LEVEL (LEVEL_45DB),
-			       LEVEL (LEVEL_6DB), LEVEL (LEVEL_45DB) };
-    static level_t slev[4] = { LEVEL (LEVEL_3DB), LEVEL (LEVEL_6DB), 
-			       0,                 LEVEL (LEVEL_6DB) };
-    int chaninfo;
-    int acmod;
-
-    state->fscod = buf[4] >> 6;
-    state->halfrate = halfrate[buf[5] >> 3];
-    state->acmod = acmod = buf[6] >> 5;
-
-    a52_bitstream_set_ptr (state, buf + 6);
-    bitstream_get (state, 3);	/* skip acmod we already parsed */
-
-    if ((acmod == 2) && (bitstream_get (state, 2) == 2))	/* dsurmod */
-	acmod = A52_DOLBY;
-
-    state->clev = state->slev = 0;
-
-    if ((acmod & 1) && (acmod != 1))
-	state->clev = clev[bitstream_get (state, 2)];	/* cmixlev */
-
-    if (acmod & 4)
-	state->slev = slev[bitstream_get (state, 2)];	/* surmixlev */
-
-    state->lfeon = bitstream_get (state, 1);
-
-    state->output = a52_downmix_init (acmod, *flags, level,
-				      state->clev, state->slev);
-    if (state->output < 0)
-	return 1;
-    if (state->lfeon && (*flags & A52_LFE))
-	state->output |= A52_LFE;
-    *flags = state->output;
-    /* the 2* compensates for differences in imdct */
-    state->dynrng = state->level = MUL_C (*level, 2);
-    state->bias = bias;
-    state->dynrnge = 1;
-    state->dynrngcall = NULL;
-    state->cplba.deltbae = DELTA_BIT_NONE;
-    state->ba[0].deltbae = state->ba[1].deltbae = state->ba[2].deltbae =
-	state->ba[3].deltbae = state->ba[4].deltbae = DELTA_BIT_NONE;
-
-    chaninfo = !acmod;
-    do {
-	bitstream_get (state, 5);	/* dialnorm */
-	if (bitstream_get (state, 1))	/* compre */
-	    bitstream_get (state, 8);	/* compr */
-	if (bitstream_get (state, 1))	/* langcode */
-	    bitstream_get (state, 8);	/* langcod */
-	if (bitstream_get (state, 1))	/* audprodie */
-	    bitstream_get (state, 7);	/* mixlevel + roomtyp */
-    } while (chaninfo--);
-
-    bitstream_get (state, 2);		/* copyrightb + origbs */
-
-    if (bitstream_get (state, 1))	/* timecod1e */
-	bitstream_get (state, 14);	/* timecod1 */
-    if (bitstream_get (state, 1))	/* timecod2e */
-	bitstream_get (state, 14);	/* timecod2 */
-
-    if (bitstream_get (state, 1)) {	/* addbsie */
-	int addbsil;
-
-	addbsil = bitstream_get (state, 6);
-	do {
-	    bitstream_get (state, 8);	/* addbsi */
-	} while (addbsil--);
-    }
-
-    return 0;
-}
-
-void a52_dynrng (a52_state_t * state,
-		 level_t (* call) (level_t, void *), void * data)
-{
-    state->dynrnge = 0;
-    if (call) {
-	state->dynrnge = 1;
-	state->dynrngcall = call;
-	state->dynrngdata = data;
-    }
-}
-
-static int parse_exponents (a52_state_t * state, int expstr, int ngrps,
-			    uint8_t exponent, uint8_t * dest)
-{
-    int exps;
-
-    while (ngrps--) {
-	exps = bitstream_get (state, 7);
-
-	exponent += exp_1[exps];
-	if (exponent > 24)
-	    return 1;
-
-	switch (expstr) {
-	case EXP_D45:
-	    *(dest++) = exponent;
-	    *(dest++) = exponent;
-	case EXP_D25:
-	    *(dest++) = exponent;
-	case EXP_D15:
-	    *(dest++) = exponent;
-	}
-
-	exponent += exp_2[exps];
-	if (exponent > 24)
-	    return 1;
-
-	switch (expstr) {
-	case EXP_D45:
-	    *(dest++) = exponent;
-	    *(dest++) = exponent;
-	case EXP_D25:
-	    *(dest++) = exponent;
-	case EXP_D15:
-	    *(dest++) = exponent;
-	}
-
-	exponent += exp_3[exps];
-	if (exponent > 24)
-	    return 1;
-
-	switch (expstr) {
-	case EXP_D45:
-	    *(dest++) = exponent;
-	    *(dest++) = exponent;
-	case EXP_D25:
-	    *(dest++) = exponent;
-	case EXP_D15:
-	    *(dest++) = exponent;
-	}
-    }	
-
-    return 0;
-}
-
-static int parse_deltba (a52_state_t * state, int8_t * deltba)
-{
-    int deltnseg, deltlen, delta, j;
-
-    memset (deltba, 0, 50);
-
-    deltnseg = bitstream_get (state, 3);
-    j = 0;
-    do {
-	j += bitstream_get (state, 5);
-	deltlen = bitstream_get (state, 4);
-	delta = bitstream_get (state, 3);
-	delta -= (delta >= 4) ? 3 : 4;
-	if (!deltlen)
-	    continue;
-	if (j + deltlen >= 50)
-	    return 1;
-	while (deltlen--)
-	    deltba[j++] = delta;
-    } while (deltnseg--);
-
-    return 0;
-}
-
-static inline int zero_snr_offsets (int nfchans, a52_state_t * state)
-{
-    int i;
-
-    if ((state->csnroffst) ||
-	(state->chincpl && state->cplba.bai >> 3) ||	/* cplinu, fsnroffst */
-	(state->lfeon && state->lfeba.bai >> 3))	/* fsnroffst */
-	return 0;
-    for (i = 0; i < nfchans; i++)
-	if (state->ba[i].bai >> 3)			/* fsnroffst */
-	    return 0;
-    return 1;
-}
-
-static inline int16_t dither_gen (a52_state_t * state)
-{
-    int16_t nstate;
-
-    nstate = dither_lut[state->lfsr_state >> 8] ^ (state->lfsr_state << 8);
-	
-    state->lfsr_state = (uint16_t) nstate;
-
-    return (3 * nstate) >> 2;
-}
-
-#ifndef LIBA52_FIXED
-#define COEFF(c,t,l,s,e) (c) = (t) * (s)[e]
-#else
-#define COEFF(c,_t,_l,s,e) do {					\
-    quantizer_t t = (_t);					\
-    level_t l = (_l);						\
-    int shift = e - 5;						\
-    sample_t tmp = t * (l >> 16) + ((t * (l & 0xffff)) >> 16);	\
-    if (shift >= 0)						\
-	(c) = tmp >> shift;					\
-    else							\
-	(c) = tmp << -shift;					\
-} while (0)
-#endif
-
-static void coeff_get (a52_state_t * state, sample_t * coeff,
-		       expbap_t * expbap, quantizer_set_t * quant,
-		       level_t level, int dither, int end)
-{
-    int i;
-    uint8_t * exp;
-    int8_t * bap;
-
-#ifndef LIBA52_FIXED
-    sample_t factor[25];
-
-    for (i = 0; i <= 24; i++)
-	factor[i] = scale_factor[i] * level;
-#endif
-
-    exp = expbap->exp;
-    bap = expbap->bap;
-
-    for (i = 0; i < end; i++) {
-	int bapi;
-
-	bapi = bap[i];
-	switch (bapi) {
-	case 0:
-	    if (dither) {
-		COEFF (coeff[i], dither_gen (state), level, factor, exp[i]);
-		continue;
-	    } else {
-		coeff[i] = 0;
-		continue;
-	    }
-
-	case -1:
-	    if (quant->q1_ptr >= 0) {
-		COEFF (coeff[i], quant->q1[quant->q1_ptr--], level,
-		       factor, exp[i]);
-		continue;
-	    } else {
-		int code;
-
-		code = bitstream_get (state, 5);
-
-		quant->q1_ptr = 1;
-		quant->q1[0] = q_1_2[code];
-		quant->q1[1] = q_1_1[code];
-		COEFF (coeff[i], q_1_0[code], level, factor, exp[i]);
-		continue;
-	    }
-
-	case -2:
-	    if (quant->q2_ptr >= 0) {
-		COEFF (coeff[i], quant->q2[quant->q2_ptr--], level,
-		       factor, exp[i]);
-		continue;
-	    } else {
-		int code;
-
-		code = bitstream_get (state, 7);
-
-		quant->q2_ptr = 1;
-		quant->q2[0] = q_2_2[code];
-		quant->q2[1] = q_2_1[code];
-		COEFF (coeff[i], q_2_0[code], level, factor, exp[i]);
-		continue;
-	    }
-
-	case 3:
-	    COEFF (coeff[i], q_3[bitstream_get (state, 3)], level,
-		   factor, exp[i]);
-	    continue;
-
-	case -3:
-	    if (quant->q4_ptr == 0) {
-		quant->q4_ptr = -1;
-		COEFF (coeff[i], quant->q4, level, factor, exp[i]);
-		continue;
-	    } else {
-		int code;
-
-		code = bitstream_get (state, 7);
-
-		quant->q4_ptr = 0;
-		quant->q4 = q_4_1[code];
-		COEFF (coeff[i], q_4_0[code], level, factor, exp[i]);
-		continue;
-	    }
-
-	case 4:
-	    COEFF (coeff[i], q_5[bitstream_get (state, 4)], level,
-		   factor, exp[i]);
-	    continue;
-
-	default:
-	    COEFF (coeff[i], bitstream_get_2 (state, bapi) << (16 - bapi),
-		   level, factor, exp[i]);
-	}
-    }
-}
-
-static void coeff_get_coupling (a52_state_t * state, int nfchans,
-				level_t * coeff, sample_t (* samples)[256],
-				quantizer_set_t * quant, uint8_t dithflag[5])
-{
-    int cplbndstrc, bnd, i, i_end, ch;
-    uint8_t * exp;
-    int8_t * bap;
-    level_t cplco[5];
-
-    exp = state->cpl_expbap.exp;
-    bap = state->cpl_expbap.bap;
-    bnd = 0;
-    cplbndstrc = state->cplbndstrc;
-    i = state->cplstrtmant;
-    while (i < state->cplendmant) {
-	i_end = i + 12;
-	while (cplbndstrc & 1) {
-	    cplbndstrc >>= 1;
-	    i_end += 12;
-	}
-	cplbndstrc >>= 1;
-	for (ch = 0; ch < nfchans; ch++)
-	    cplco[ch] = MUL_L (state->cplco[ch][bnd], coeff[ch]);
-	bnd++;
-
-	while (i < i_end) {
-	    quantizer_t cplcoeff;
-	    int bapi;
-
-	    bapi = bap[i];
-	    switch (bapi) {
-	    case 0:
-		for (ch = 0; ch < nfchans; ch++)
-		    if ((state->chincpl >> ch) & 1) {
-			if (dithflag[ch])
-#ifndef LIBA52_FIXED
-			    samples[ch][i] = (scale_factor[exp[i]] *
-					      cplco[ch] * dither_gen (state));
-#else
-			    COEFF (samples[ch][i], dither_gen (state),
-				   cplco[ch], scale_factor, exp[i]);
-#endif
-			else
-			    samples[ch][i] = 0;
-		    }
-		i++;
-		continue;
-
-	    case -1:
-		if (quant->q1_ptr >= 0) {
-		    cplcoeff = quant->q1[quant->q1_ptr--];
-		    break;
-		} else {
-		    int code;
-
-		    code = bitstream_get (state, 5);
-
-		    quant->q1_ptr = 1;
-		    quant->q1[0] = q_1_2[code];
-		    quant->q1[1] = q_1_1[code];
-		    cplcoeff = q_1_0[code];
-		    break;
-		}
-
-	    case -2:
-		if (quant->q2_ptr >= 0) {
-		    cplcoeff = quant->q2[quant->q2_ptr--];
-		    break;
-		} else {
-		    int code;
-
-		    code = bitstream_get (state, 7);
-
-		    quant->q2_ptr = 1;
-		    quant->q2[0] = q_2_2[code];
-		    quant->q2[1] = q_2_1[code];
-		    cplcoeff = q_2_0[code];
-		    break;
-		}
-
-	    case 3:
-		cplcoeff = q_3[bitstream_get (state, 3)];
-		break;
-
-	    case -3:
-		if (quant->q4_ptr == 0) {
-		    quant->q4_ptr = -1;
-		    cplcoeff = quant->q4;
-		    break;
-		} else {
-		    int code;
-
-		    code = bitstream_get (state, 7);
-
-		    quant->q4_ptr = 0;
-		    quant->q4 = q_4_1[code];
-		    cplcoeff = q_4_0[code];
-		    break;
-		}
-
-	    case 4:
-		cplcoeff = q_5[bitstream_get (state, 4)];
-		break;
-
-	    default:
-		cplcoeff = bitstream_get_2 (state, bapi) << (16 - bapi);
-	    }
-#ifndef LIBA52_FIXED
-	    cplcoeff *= scale_factor[exp[i]];
-#endif
-	    for (ch = 0; ch < nfchans; ch++)
-	       if ((state->chincpl >> ch) & 1)
-#ifndef LIBA52_FIXED
-		    samples[ch][i] = cplcoeff * cplco[ch];
-#else
-		    COEFF (samples[ch][i], cplcoeff, cplco[ch],
-			   scale_factor, exp[i]);
-#endif
-	    i++;
-	}
-    }
-}
-
-int a52_block (a52_state_t * state)
-{
-    static const uint8_t nfchans_tbl[] = {2, 1, 2, 3, 3, 4, 4, 5, 1, 1, 2};
-    static int rematrix_band[4] = {25, 37, 61, 253};
-    int i, nfchans, chaninfo;
-    uint8_t cplexpstr, chexpstr[5], lfeexpstr, do_bit_alloc, done_cpl;
-    uint8_t blksw[5], dithflag[5];
-    level_t coeff[5];
-    int chanbias;
-    quantizer_set_t quant;
-    sample_t * samples;
-
-    nfchans = nfchans_tbl[state->acmod];
-
-    for (i = 0; i < nfchans; i++)
-	blksw[i] = bitstream_get (state, 1);
-
-    for (i = 0; i < nfchans; i++)
-	dithflag[i] = bitstream_get (state, 1);
-
-    chaninfo = !state->acmod;
-    do {
-	if (bitstream_get (state, 1)) {	/* dynrnge */
-	    int dynrng;
-
-	    dynrng = bitstream_get_2 (state, 8);
-	    if (state->dynrnge) {
-		level_t range;
-
-#if !defined(LIBA52_FIXED)
-		range = ((((dynrng & 0x1f) | 0x20) << 13) *
-			 scale_factor[3 - (dynrng >> 5)]);
-#else
-		range = ((dynrng & 0x1f) | 0x20) << (21 + (dynrng >> 5));
-#endif
-		if (state->dynrngcall)
-		    range = state->dynrngcall (range, state->dynrngdata);
-		state->dynrng = MUL_L (state->level, range);
-	    }
-	}
-    } while (chaninfo--);
-
-    if (bitstream_get (state, 1)) {	/* cplstre */
-	state->chincpl = 0;
-	if (bitstream_get (state, 1)) {	/* cplinu */
-	    static uint8_t bndtab[16] = {31, 35, 37, 39, 41, 42, 43, 44,
-					 45, 45, 46, 46, 47, 47, 48, 48};
-	    int cplbegf;
-	    int cplendf;
-	    int ncplsubnd;
-
-	    for (i = 0; i < nfchans; i++)
-		state->chincpl |= bitstream_get (state, 1) << i;
-	    switch (state->acmod) {
-	    case 0: case 1:
-		return 1;
-	    case 2:
-		state->phsflginu = bitstream_get (state, 1);
-	    }
-	    cplbegf = bitstream_get (state, 4);
-	    cplendf = bitstream_get (state, 4);
-
-	    if (cplendf + 3 - cplbegf < 0)
-		return 1;
-	    state->ncplbnd = ncplsubnd = cplendf + 3 - cplbegf;
-	    state->cplstrtbnd = bndtab[cplbegf];
-	    state->cplstrtmant = cplbegf * 12 + 37;
-	    state->cplendmant = cplendf * 12 + 73;
-
-	    state->cplbndstrc = 0;
-	    for (i = 0; i < ncplsubnd - 1; i++)
-		if (bitstream_get (state, 1)) {
-		    state->cplbndstrc |= 1 << i;
-		    state->ncplbnd--;
-		}
-	}
-    }
-
-    if (state->chincpl) {	/* cplinu */
-	int j, cplcoe;
-
-	cplcoe = 0;
-	for (i = 0; i < nfchans; i++)
-	    if ((state->chincpl) >> i & 1)
-		if (bitstream_get (state, 1)) {	/* cplcoe */
-		    int mstrcplco, cplcoexp, cplcomant;
-
-		    cplcoe = 1;
-		    mstrcplco = 3 * bitstream_get (state, 2);
-		    for (j = 0; j < state->ncplbnd; j++) {
-			cplcoexp = bitstream_get (state, 4);
-			cplcomant = bitstream_get (state, 4);
-			if (cplcoexp == 15)
-			    cplcomant <<= 14;
-			else
-			    cplcomant = (cplcomant | 0x10) << 13;
-#ifndef LIBA52_FIXED
-			state->cplco[i][j] =
-			    cplcomant * scale_factor[cplcoexp + mstrcplco];
-#else
-			state->cplco[i][j] = (cplcomant << 11) >> (cplcoexp + mstrcplco);
-#endif
-
-		    }
-		}
-	if ((state->acmod == 2) && state->phsflginu && cplcoe)
-	    for (j = 0; j < state->ncplbnd; j++)
-		if (bitstream_get (state, 1))	/* phsflg */
-		    state->cplco[1][j] = -state->cplco[1][j];
-    }
-
-    if ((state->acmod == 2) && (bitstream_get (state, 1))) {	/* rematstr */
-	int end;
-
-	state->rematflg = 0;
-	end = (state->chincpl) ? state->cplstrtmant : 253;	/* cplinu */
-	i = 0;
-	do
-	    state->rematflg |= bitstream_get (state, 1) << i;
-	while (rematrix_band[i++] < end);
-    }
-
-    cplexpstr = EXP_REUSE;
-    lfeexpstr = EXP_REUSE;
-    if (state->chincpl)	/* cplinu */
-	cplexpstr = bitstream_get (state, 2);
-    for (i = 0; i < nfchans; i++)
-	chexpstr[i] = bitstream_get (state, 2);
-    if (state->lfeon) 
-	lfeexpstr = bitstream_get (state, 1);
-
-    for (i = 0; i < nfchans; i++)
-	if (chexpstr[i] != EXP_REUSE) {
-	    if ((state->chincpl >> i) & 1)
-		state->endmant[i] = state->cplstrtmant;
-	    else {
-		int chbwcod;
-
-		chbwcod = bitstream_get (state, 6);
-		if (chbwcod > 60)
-		    return 1;
-		state->endmant[i] = chbwcod * 3 + 73;
-	    }
-	}
-
-    do_bit_alloc = 0;
-
-    if (cplexpstr != EXP_REUSE) {
-	int cplabsexp, ncplgrps;
-
-	do_bit_alloc = 64;
-	ncplgrps = ((state->cplendmant - state->cplstrtmant) /
-		    (3 << (cplexpstr - 1)));
-	cplabsexp = bitstream_get (state, 4) << 1;
-	if (parse_exponents (state, cplexpstr, ncplgrps, cplabsexp,
-			     state->cpl_expbap.exp + state->cplstrtmant))
-	    return 1;
-    }
-    for (i = 0; i < nfchans; i++)
-	if (chexpstr[i] != EXP_REUSE) {
-	    int grp_size, nchgrps;
-
-	    do_bit_alloc |= 1 << i;
-	    grp_size = 3 << (chexpstr[i] - 1);
-	    nchgrps = (state->endmant[i] + grp_size - 4) / grp_size;
-	    state->fbw_expbap[i].exp[0] = bitstream_get (state, 4);
-	    if (parse_exponents (state, chexpstr[i], nchgrps,
-				 state->fbw_expbap[i].exp[0],
-				 state->fbw_expbap[i].exp + 1))
-		return 1;
-	    bitstream_get (state, 2);	/* gainrng */
-	}
-    if (lfeexpstr != EXP_REUSE) {
-	do_bit_alloc |= 32;
-	state->lfe_expbap.exp[0] = bitstream_get (state, 4);
-	if (parse_exponents (state, lfeexpstr, 2, state->lfe_expbap.exp[0],
-			     state->lfe_expbap.exp + 1))
-	    return 1;
-    }
-
-    if (bitstream_get (state, 1)) {	/* baie */
-	do_bit_alloc = 127;
-	state->bai = bitstream_get (state, 11);
-    }
-    if (bitstream_get (state, 1)) {	/* snroffste */
-	do_bit_alloc = 127;
-	state->csnroffst = bitstream_get (state, 6);
-	if (state->chincpl)	/* cplinu */
-	    state->cplba.bai = bitstream_get (state, 7);
-	for (i = 0; i < nfchans; i++)
-	    state->ba[i].bai = bitstream_get (state, 7);
-	if (state->lfeon)
-	    state->lfeba.bai = bitstream_get (state, 7);
-    }
-    if ((state->chincpl) && (bitstream_get (state, 1))) { /* cplleake */
-	do_bit_alloc |= 64;
-	state->cplfleak = 9 - bitstream_get (state, 3);
-	state->cplsleak = 9 - bitstream_get (state, 3);
-    }
-
-    if (bitstream_get (state, 1)) {	/* deltbaie */
-	do_bit_alloc = 127;
-	if (state->chincpl)	/* cplinu */
-	    state->cplba.deltbae = bitstream_get (state, 2);
-	for (i = 0; i < nfchans; i++)
-	    state->ba[i].deltbae = bitstream_get (state, 2);
-	if (state->chincpl &&	/* cplinu */
-	    (state->cplba.deltbae == DELTA_BIT_NEW) &&
-	    parse_deltba (state, state->cplba.deltba))
-	    return 1;
-	for (i = 0; i < nfchans; i++)
-	    if ((state->ba[i].deltbae == DELTA_BIT_NEW) &&
-		parse_deltba (state, state->ba[i].deltba))
-		return 1;
-    }
-
-    if (do_bit_alloc) {
-	if (zero_snr_offsets (nfchans, state)) {
-	    memset (state->cpl_expbap.bap, 0, sizeof (state->cpl_expbap.bap));
-	    for (i = 0; i < nfchans; i++)
-		memset (state->fbw_expbap[i].bap, 0,
-			sizeof (state->fbw_expbap[i].bap));
-	    memset (state->lfe_expbap.bap, 0, sizeof (state->lfe_expbap.bap));
-	} else {
-	    if (state->chincpl && (do_bit_alloc & 64))	/* cplinu */
-		a52_bit_allocate (state, &state->cplba, state->cplstrtbnd,
-				  state->cplstrtmant, state->cplendmant,
-				  state->cplfleak << 8, state->cplsleak << 8,
-				  &state->cpl_expbap);
-	    for (i = 0; i < nfchans; i++)
-		if (do_bit_alloc & (1 << i))
-		    a52_bit_allocate (state, state->ba + i, 0, 0,
-				      state->endmant[i], 0, 0,
-				      state->fbw_expbap +i);
-	    if (state->lfeon && (do_bit_alloc & 32)) {
-		state->lfeba.deltbae = DELTA_BIT_NONE;
-		a52_bit_allocate (state, &state->lfeba, 0, 0, 7, 0, 0,
-				  &state->lfe_expbap);
-	    }
-	}
-    }
-
-    if (bitstream_get (state, 1)) {	/* skiple */
-	i = bitstream_get (state, 9);	/* skipl */
-	while (i--)
-	    bitstream_get (state, 8);
-    }
-
-    samples = state->samples;
-    if (state->output & A52_LFE)
-	samples += 256;	/* shift for LFE channel */
-
-    chanbias = a52_downmix_coeff (coeff, state->acmod, state->output,
-				  state->dynrng, state->clev, state->slev);
-
-    quant.q1_ptr = quant.q2_ptr = quant.q4_ptr = -1;
-    done_cpl = 0;
-
-    for (i = 0; i < nfchans; i++) {
-	int j;
-
-	coeff_get (state, samples + 256 * i, state->fbw_expbap +i, &quant,
-		   coeff[i], dithflag[i], state->endmant[i]);
-
-	if ((state->chincpl >> i) & 1) {
-	    if (!done_cpl) {
-		done_cpl = 1;
-		coeff_get_coupling (state, nfchans, coeff,
-				    (sample_t (*)[256])samples, &quant,
-				    dithflag);
-	    }
-	    j = state->cplendmant;
-	} else
-	    j = state->endmant[i];
-	do
-	    (samples + 256 * i)[j] = 0;
-	while (++j < 256);
-    }
-
-    if (state->acmod == 2) {
-	int j, end, band, rematflg;
-
-	end = ((state->endmant[0] < state->endmant[1]) ?
-	       state->endmant[0] : state->endmant[1]);
-
-	i = 0;
-	j = 13;
-	rematflg = state->rematflg;
-	do {
-	    if (! (rematflg & 1)) {
-		rematflg >>= 1;
-		j = rematrix_band[i++];
-		continue;
-	    }
-	    rematflg >>= 1;
-	    band = rematrix_band[i++];
-	    if (band > end)
-		band = end;
-	    do {
-		sample_t tmp0, tmp1;
-
-		tmp0 = samples[j];
-		tmp1 = (samples+256)[j];
-		samples[j] = tmp0 + tmp1;
-		(samples+256)[j] = tmp0 - tmp1;
-	    } while (++j < band);
-	} while (j < end);
-    }
-
-    if (state->lfeon) {
-	if (state->output & A52_LFE) {
-	    coeff_get (state, samples - 256, &state->lfe_expbap, &quant,
-		       state->dynrng, 0, 7);
-	    for (i = 7; i < 256; i++)
-		(samples-256)[i] = 0;
-	    a52_imdct_512 (samples - 256, samples + 1536 - 256, state->bias);
-	} else {
-	    /* just skip the LFE coefficients */
-	    coeff_get (state, samples + 1280, &state->lfe_expbap, &quant,
-		       0, 0, 7);
-	}
-    }
-
-    i = 0;
-    if (nfchans_tbl[state->output & A52_CHANNEL_MASK] < nfchans)
-	for (i = 1; i < nfchans; i++)
-	    if (blksw[i] != blksw[0])
-		break;
-
-    if (i < nfchans) {
-	if (state->downmixed) {
-	    state->downmixed = 0;
-	    a52_upmix (samples + 1536, state->acmod, state->output);
-	}
-
-	for (i = 0; i < nfchans; i++) {
-	    sample_t bias;
-
-	    bias = 0;
-	    if (!(chanbias & (1 << i)))
-		bias = state->bias;
-
-	    if (coeff[i]) {
-		if (blksw[i])
-		    a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i,
-				   bias);
-		else 
-		    a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i,
-				   bias);
-	    } else {
-		int j;
-
-		for (j = 0; j < 256; j++)
-		    (samples + 256 * i)[j] = bias;
-	    }
-	}
-
-	a52_downmix (samples, state->acmod, state->output, state->bias,
-		     state->clev, state->slev);
-    } else {
-	nfchans = nfchans_tbl[state->output & A52_CHANNEL_MASK];
-
-	a52_downmix (samples, state->acmod, state->output, 0,
-		     state->clev, state->slev);
-
-	if (!state->downmixed) {
-	    state->downmixed = 1;
-	    a52_downmix (samples + 1536, state->acmod, state->output, 0,
-			 state->clev, state->slev);
-	}
-
-	if (blksw[0])
-	    for (i = 0; i < nfchans; i++)
-		a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i,
-			       state->bias);
-	else 
-	    for (i = 0; i < nfchans; i++)
-		a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i,
-			       state->bias);
-    }
-
-    return 0;
-}
-
-void a52_free (a52_state_t * state)
-{
-    free (state->samples);
-    free (state);
-}
diff --git a/ffmpeg.src/libavcodec/liba52/resample.c b/ffmpeg.src/libavcodec/liba52/resample.c
deleted file mode 100644
index 07e2d69..0000000
--- a/ffmpeg.src/libavcodec/liba52/resample.c
+++ /dev/null
@@ -1,43 +0,0 @@
-
-// a52_resample_init should find the requested converter (from type flags ->
-// given number of channels) and set up some function pointers...
-
-// a52_resample() should do the conversion.
-
-#include "a52.h"
-#include "mm_accel.h"
-#include "config.h"
-#include "../libpostproc/mangle.h"
-
-int (* a52_resample) (float * _f, int16_t * s16)=NULL;
-
-#include "resample_c.c"
-
-#ifdef ARCH_X86
-#include "resample_mmx.c"
-#endif
-
-void* a52_resample_init(uint32_t mm_accel,int flags,int chans){
-void* tmp;
-
-#ifdef ARCH_X86
-    if(mm_accel&MM_ACCEL_X86_MMX){
-	tmp=a52_resample_MMX(flags,chans);
-	if(tmp){
-	    if(a52_resample==NULL) av_log(NULL, AV_LOG_INFO, "Using MMX optimized resampler\n");
-	    a52_resample=tmp;
-	    return tmp;
-	}
-    }
-#endif
-
-    tmp=a52_resample_C(flags,chans);
-    if(tmp){
-	if(a52_resample==NULL) av_log(NULL, AV_LOG_INFO, "No accelerated resampler found\n");
-	a52_resample=tmp;
-	return tmp;
-    }
-    
-    av_log(NULL, AV_LOG_ERROR, "Unimplemented resampler for mode 0x%X -> %d channels conversion - Contact MPlayer developers!\n", flags, chans);
-    return NULL;
-}
diff --git a/ffmpeg.src/libavcodec/liba52/resample_c.c b/ffmpeg.src/libavcodec/liba52/resample_c.c
deleted file mode 100644
index a618ec6..0000000
--- a/ffmpeg.src/libavcodec/liba52/resample_c.c
+++ /dev/null
@@ -1,183 +0,0 @@
-// this code is based on a52dec/libao/audio_out_oss.c
-
-static inline int16_t convert (int32_t i)
-{
-    if (i > 0x43c07fff)
-	return 32767;
-    else if (i < 0x43bf8000)
-	return -32768;
-    else
-	return i - 0x43c00000;
-}
-
-static int a52_resample_MONO_to_5_C(float * _f, int16_t * s16){
-    int i;
-    int32_t * f = (int32_t *) _f;
-	for (i = 0; i < 256; i++) {
-	    s16[5*i] = s16[5*i+1] = s16[5*i+2] = s16[5*i+3] = 0;
-	    s16[5*i+4] = convert (f[i]);
-	}
-    return 5*256;
-}
-
-static int a52_resample_MONO_to_1_C(float * _f, int16_t * s16){
-    int i;
-    int32_t * f = (int32_t *) _f;
-	for (i = 0; i < 256; i++) {
-	    s16[i] = convert (f[i]);
-	}
-    return 1*256;
-}
-
-static int a52_resample_STEREO_to_2_C(float * _f, int16_t * s16){
-    int i;
-    int32_t * f = (int32_t *) _f;
-	for (i = 0; i < 256; i++) {
-	    s16[2*i] = convert (f[i]);
-	    s16[2*i+1] = convert (f[i+256]);
-	}
-    return 2*256;
-}
-
-static int a52_resample_3F_to_5_C(float * _f, int16_t * s16){
-    int i;
-    int32_t * f = (int32_t *) _f;
-	for (i = 0; i < 256; i++) {
-	    s16[5*i] = convert (f[i]);
-	    s16[5*i+1] = convert (f[i+512]);
-	    s16[5*i+2] = s16[5*i+3] = 0;
-	    s16[5*i+4] = convert (f[i+256]);
-	}
-    return 5*256;
-}
-
-static int a52_resample_2F_2R_to_4_C(float * _f, int16_t * s16){
-    int i;
-    int32_t * f = (int32_t *) _f;
-	for (i = 0; i < 256; i++) {
-	    s16[4*i] = convert (f[i]);
-	    s16[4*i+1] = convert (f[i+256]);
-	    s16[4*i+2] = convert (f[i+512]);
-	    s16[4*i+3] = convert (f[i+768]);
-	}
-    return 4*256;
-}
-
-static int a52_resample_3F_2R_to_5_C(float * _f, int16_t * s16){
-    int i;
-    int32_t * f = (int32_t *) _f;
-	for (i = 0; i < 256; i++) {
-	    s16[5*i] = convert (f[i]);
-	    s16[5*i+1] = convert (f[i+512]);
-	    s16[5*i+2] = convert (f[i+768]);
-	    s16[5*i+3] = convert (f[i+1024]);
-	    s16[5*i+4] = convert (f[i+256]);
-	}
-    return 5*256;
-}
-
-static int a52_resample_MONO_LFE_to_6_C(float * _f, int16_t * s16){
-    int i;
-    int32_t * f = (int32_t *) _f;
-	for (i = 0; i < 256; i++) {
-	    s16[6*i] = s16[6*i+1] = s16[6*i+2] = s16[6*i+3] = 0;
-	    s16[6*i+4] = convert (f[i+256]);
-	    s16[6*i+5] = convert (f[i]);
-	}
-    return 6*256;
-}
-
-static int a52_resample_STEREO_LFE_to_6_C(float * _f, int16_t * s16){
-    int i;
-    int32_t * f = (int32_t *) _f;
-	for (i = 0; i < 256; i++) {
-	    s16[6*i] = convert (f[i+256]);
-	    s16[6*i+1] = convert (f[i+512]);
-	    s16[6*i+2] = s16[6*i+3] = s16[6*i+4] = 0;
-	    s16[6*i+5] = convert (f[i]);
-	}
-    return 6*256;
-}
-
-static int a52_resample_3F_LFE_to_6_C(float * _f, int16_t * s16){
-    int i;
-    int32_t * f = (int32_t *) _f;
-	for (i = 0; i < 256; i++) {
-	    s16[6*i] = convert (f[i+256]);
-	    s16[6*i+1] = convert (f[i+768]);
-	    s16[6*i+2] = s16[6*i+3] = 0;
-	    s16[6*i+4] = convert (f[i+512]);
-	    s16[6*i+5] = convert (f[i]);
-	}
-    return 6*256;
-}
-
-static int a52_resample_2F_2R_LFE_to_6_C(float * _f, int16_t * s16){
-    int i;
-    int32_t * f = (int32_t *) _f;
-	for (i = 0; i < 256; i++) {
-	    s16[6*i] = convert (f[i+256]);
-	    s16[6*i+1] = convert (f[i+512]);
-	    s16[6*i+2] = convert (f[i+768]);
-	    s16[6*i+3] = convert (f[i+1024]);
-	    s16[6*i+4] = 0;
-	    s16[6*i+5] = convert (f[i]);
-	}
-    return 6*256;
-}
-
-static int a52_resample_3F_2R_LFE_to_6_C(float * _f, int16_t * s16){
-    int i;
-    int32_t * f = (int32_t *) _f;
-	for (i = 0; i < 256; i++) {
-	    s16[6*i] = convert (f[i+256]);
-	    s16[6*i+1] = convert (f[i+768]);
-	    s16[6*i+2] = convert (f[i+1024]);
-	    s16[6*i+3] = convert (f[i+1280]);
-	    s16[6*i+4] = convert (f[i+512]);
-	    s16[6*i+5] = convert (f[i]);
-	}
-    return 6*256;
-}
-
-
-static void* a52_resample_C(int flags, int ch){
-    switch (flags) {
-    case A52_MONO:
-	if(ch==5) return a52_resample_MONO_to_5_C;
-	if(ch==1) return a52_resample_MONO_to_1_C;
-	break;
-    case A52_CHANNEL:
-    case A52_STEREO:
-    case A52_DOLBY:
-	if(ch==2) return a52_resample_STEREO_to_2_C;
-	break;
-    case A52_3F:
-	if(ch==5) return a52_resample_3F_to_5_C;
-	break;
-    case A52_2F2R:
-	if(ch==4) return a52_resample_2F_2R_to_4_C;
-	break;
-    case A52_3F2R:
-	if(ch==5) return a52_resample_3F_2R_to_5_C;
-	break;
-    case A52_MONO | A52_LFE:
-	if(ch==6) return a52_resample_MONO_LFE_to_6_C;
-	break;
-    case A52_CHANNEL | A52_LFE:
-    case A52_STEREO | A52_LFE:
-    case A52_DOLBY | A52_LFE:
-	if(ch==6) return a52_resample_STEREO_LFE_to_6_C;
-	break;
-    case A52_3F | A52_LFE:
-	if(ch==6) return a52_resample_3F_LFE_to_6_C;
-	break;
-    case A52_2F2R | A52_LFE:
-	if(ch==6) return a52_resample_2F_2R_LFE_to_6_C;
-	break;
-    case A52_3F2R | A52_LFE:
-	if(ch==6) return a52_resample_3F_2R_LFE_to_6_C;
-	break;
-    }
-    return NULL;
-}
diff --git a/ffmpeg.src/libavcodec/liba52/resample_mmx.c b/ffmpeg.src/libavcodec/liba52/resample_mmx.c
deleted file mode 100644
index 315322e..0000000
--- a/ffmpeg.src/libavcodec/liba52/resample_mmx.c
+++ /dev/null
@@ -1,518 +0,0 @@
-
-// MMX optimizations from Michael Niedermayer (michaelni at gmx.at) (under GPL)
-
-/* optimization TODO / NOTES 
-    movntq is slightly faster (0.5% with the current test.c benchmark) 
-	(but thats just test.c so that needs to be testd in reallity)
-	and it would mean (C / MMX2 / MMX / 3DNOW) versions 
-*/
-
-static uint64_t __attribute__((aligned(8))) attribute_used magicF2W= 0x43c0000043c00000LL;
-static uint64_t __attribute__((aligned(8))) attribute_used wm1010= 0xFFFF0000FFFF0000LL;
-static uint64_t __attribute__((aligned(8))) attribute_used wm0101= 0x0000FFFF0000FFFFLL;
-static uint64_t __attribute__((aligned(8))) attribute_used wm1100= 0xFFFFFFFF00000000LL;
-
-static int a52_resample_MONO_to_5_MMX(float * _f, int16_t * s16){
-    int32_t * f = (int32_t *) _f;
-	asm volatile(
-		"movl $-512, %%esi		\n\t"
-		"movq "MANGLE(magicF2W)", %%mm7	\n\t"
-		"movq "MANGLE(wm1100)", %%mm3	\n\t"
-		"movq "MANGLE(wm0101)", %%mm4	\n\t"
-		"movq "MANGLE(wm1010)", %%mm5	\n\t"
-		"pxor %%mm6, %%mm6		\n\t"
-		"1:				\n\t"
-		"movq (%1, %%esi, 2), %%mm0	\n\t"
-		"movq 8(%1, %%esi, 2), %%mm1	\n\t"
-		"leal (%%esi, %%esi, 4), %%edi	\n\t"
-		"psubd %%mm7, %%mm0		\n\t"
-		"psubd %%mm7, %%mm1		\n\t"
-		"packssdw %%mm1, %%mm0		\n\t"
-		"movq %%mm0, %%mm1		\n\t"
-		"pand %%mm4, %%mm0		\n\t"
-		"pand %%mm5, %%mm1		\n\t"
-		"movq %%mm6, (%0, %%edi)	\n\t" // 0 0 0 0
-		"movd %%mm0, 8(%0, %%edi)	\n\t" // A 0
-		"pand %%mm3, %%mm0		\n\t"
-		"movd %%mm6, 12(%0, %%edi)	\n\t" // 0 0
-		"movd %%mm1, 16(%0, %%edi)	\n\t" // 0 B
-		"pand %%mm3, %%mm1		\n\t"
-		"movd %%mm6, 20(%0, %%edi)	\n\t" // 0 0
-		"movq %%mm0, 24(%0, %%edi)	\n\t" // 0 0 C 0
-		"movq %%mm1, 32(%0, %%edi)	\n\t" // 0 0 0 B
-		"addl $8, %%esi			\n\t"
-		" jnz 1b			\n\t"
-		"emms				\n\t"
-		:: "r" (s16+1280), "r" (f+256)
-		:"%esi", "%edi", "memory"
-	);
-    return 5*256;
-}
-
-static int a52_resample_STEREO_to_2_MMX(float * _f, int16_t * s16){
-    int32_t * f = (int32_t *) _f;
-/* benchmark scores are 0.3% better with SSE but we would need to set bias=0 and premultiply it
-#ifdef HAVE_SSE
-	asm volatile(
-		"movl $-1024, %%esi		\n\t"
-		"1:				\n\t"
-		"cvtps2pi (%1, %%esi), %%mm0	\n\t"
-		"cvtps2pi 1024(%1, %%esi), %%mm2\n\t"
-		"movq %%mm0, %%mm1		\n\t"
-		"punpcklwd %%mm2, %%mm0		\n\t"
-		"punpckhwd %%mm2, %%mm1		\n\t"
-		"movq %%mm0, (%0, %%esi)	\n\t"
-		"movq %%mm1, 8(%0, %%esi)	\n\t"
-		"addl $16, %%esi		\n\t"
-		" jnz 1b			\n\t"
-		"emms				\n\t"
-		:: "r" (s16+512), "r" (f+256)
-		:"%esi", "memory"
-	);*/
-	asm volatile(
-		"movl $-1024, %%esi		\n\t"
-		"movq "MANGLE(magicF2W)", %%mm7	\n\t"
-		"1:				\n\t"
-		"movq (%1, %%esi), %%mm0	\n\t"
-		"movq 8(%1, %%esi), %%mm1	\n\t"
-		"movq 1024(%1, %%esi), %%mm2	\n\t"
-		"movq 1032(%1, %%esi), %%mm3	\n\t"
-		"psubd %%mm7, %%mm0		\n\t"
-		"psubd %%mm7, %%mm1		\n\t"
-		"psubd %%mm7, %%mm2		\n\t"
-		"psubd %%mm7, %%mm3		\n\t"
-		"packssdw %%mm1, %%mm0		\n\t"
-		"packssdw %%mm3, %%mm2		\n\t"
-		"movq %%mm0, %%mm1		\n\t"
-		"punpcklwd %%mm2, %%mm0		\n\t"
-		"punpckhwd %%mm2, %%mm1		\n\t"
-		"movq %%mm0, (%0, %%esi)	\n\t"
-		"movq %%mm1, 8(%0, %%esi)	\n\t"
-		"addl $16, %%esi		\n\t"
-		" jnz 1b			\n\t"
-		"emms				\n\t"
-		:: "r" (s16+512), "r" (f+256)
-		:"%esi", "memory"
-	);
-    return 2*256;
-}
-
-static int a52_resample_3F_to_5_MMX(float * _f, int16_t * s16){
-    int32_t * f = (int32_t *) _f;
-	asm volatile(
-		"movl $-1024, %%esi		\n\t"
-		"movq "MANGLE(magicF2W)", %%mm7	\n\t"
-		"pxor %%mm6, %%mm6		\n\t"
-		"movq %%mm7, %%mm5		\n\t"
-		"punpckldq %%mm6, %%mm5		\n\t"
-		"1:				\n\t"
-		"movd (%1, %%esi), %%mm0	\n\t"
-		"punpckldq 2048(%1, %%esi), %%mm0\n\t"
-		"movd 1024(%1, %%esi), %%mm1	\n\t"
-		"punpckldq 4(%1, %%esi), %%mm1	\n\t"
-		"movd 2052(%1, %%esi), %%mm2	\n\t"
-		"movq %%mm7, %%mm3		\n\t"
-		"punpckldq 1028(%1, %%esi), %%mm3\n\t"
-		"movd 8(%1, %%esi), %%mm4	\n\t"
-		"punpckldq 2056(%1, %%esi), %%mm4\n\t"
-		"leal (%%esi, %%esi, 4), %%edi	\n\t"
-		"sarl $1, %%edi			\n\t"
-		"psubd %%mm7, %%mm0		\n\t"
-		"psubd %%mm7, %%mm1		\n\t"
-		"psubd %%mm5, %%mm2		\n\t"
-		"psubd %%mm7, %%mm3		\n\t"
-		"psubd %%mm7, %%mm4		\n\t"
-		"packssdw %%mm6, %%mm0		\n\t"
-		"packssdw %%mm2, %%mm1		\n\t"
-		"packssdw %%mm4, %%mm3		\n\t"
-		"movq %%mm0, (%0, %%edi)	\n\t"
-		"movq %%mm1, 8(%0, %%edi)	\n\t"
-		"movq %%mm3, 16(%0, %%edi)	\n\t"
-		
-		"movd 1032(%1, %%esi), %%mm1	\n\t"
-		"punpckldq 12(%1, %%esi), %%mm1\n\t"
-		"movd 2060(%1, %%esi), %%mm2	\n\t"
-		"movq %%mm7, %%mm3		\n\t"
-		"punpckldq 1036(%1, %%esi), %%mm3\n\t"
-		"pxor %%mm0, %%mm0		\n\t"
-		"psubd %%mm7, %%mm1		\n\t"
-		"psubd %%mm5, %%mm2		\n\t"
-		"psubd %%mm7, %%mm3		\n\t"
-		"packssdw %%mm1, %%mm0		\n\t"
-		"packssdw %%mm3, %%mm2		\n\t"
-		"movq %%mm0, 24(%0, %%edi)	\n\t"
-		"movq %%mm2, 32(%0, %%edi)	\n\t"
-				
-		"addl $16, %%esi		\n\t"
-		" jnz 1b			\n\t"
-		"emms				\n\t"
-		:: "r" (s16+1280), "r" (f+256)
-		:"%esi", "%edi", "memory"
-	);
-    return 5*256;
-}
-
-static int a52_resample_2F_2R_to_4_MMX(float * _f, int16_t * s16){
-    int32_t * f = (int32_t *) _f;
-	asm volatile(
-		"movl $-1024, %%esi		\n\t"
-		"movq "MANGLE(magicF2W)", %%mm7	\n\t"
-		"1:				\n\t"
-		"movq (%1, %%esi), %%mm0	\n\t"
-		"movq 8(%1, %%esi), %%mm1	\n\t"
-		"movq 1024(%1, %%esi), %%mm2	\n\t"
-		"movq 1032(%1, %%esi), %%mm3	\n\t"
-		"psubd %%mm7, %%mm0		\n\t"
-		"psubd %%mm7, %%mm1		\n\t"
-		"psubd %%mm7, %%mm2		\n\t"
-		"psubd %%mm7, %%mm3		\n\t"
-		"packssdw %%mm1, %%mm0		\n\t"
-		"packssdw %%mm3, %%mm2		\n\t"
-		"movq 2048(%1, %%esi), %%mm3	\n\t"
-		"movq 2056(%1, %%esi), %%mm4	\n\t"
-		"movq 3072(%1, %%esi), %%mm5	\n\t"
-		"movq 3080(%1, %%esi), %%mm6	\n\t"
-		"psubd %%mm7, %%mm3		\n\t"
-		"psubd %%mm7, %%mm4		\n\t"
-		"psubd %%mm7, %%mm5		\n\t"
-		"psubd %%mm7, %%mm6		\n\t"
-		"packssdw %%mm4, %%mm3		\n\t"
-		"packssdw %%mm6, %%mm5		\n\t"
-		"movq %%mm0, %%mm1		\n\t"
-		"movq %%mm3, %%mm4		\n\t"
-		"punpcklwd %%mm2, %%mm0		\n\t"
-		"punpckhwd %%mm2, %%mm1		\n\t"
-		"punpcklwd %%mm5, %%mm3		\n\t"
-		"punpckhwd %%mm5, %%mm4		\n\t"
-		"movq %%mm0, %%mm2		\n\t"
-		"movq %%mm1, %%mm5		\n\t"
-		"punpckldq %%mm3, %%mm0		\n\t"
-		"punpckhdq %%mm3, %%mm2		\n\t"
-		"punpckldq %%mm4, %%mm1		\n\t"
-		"punpckhdq %%mm4, %%mm5		\n\t"
-		"movq %%mm0, (%0, %%esi,2)	\n\t"
-		"movq %%mm2, 8(%0, %%esi,2)	\n\t"
-		"movq %%mm1, 16(%0, %%esi,2)	\n\t"
-		"movq %%mm5, 24(%0, %%esi,2)	\n\t"
-		"addl $16, %%esi		\n\t"
-		" jnz 1b			\n\t"
-		"emms				\n\t"
-		:: "r" (s16+1024), "r" (f+256)
-		:"%esi", "memory"
-	);
-    return 4*256;
-}
-
-static int a52_resample_3F_2R_to_5_MMX(float * _f, int16_t * s16){
-    int32_t * f = (int32_t *) _f;
-	asm volatile(
-		"movl $-1024, %%esi		\n\t"
-		"movq "MANGLE(magicF2W)", %%mm7	\n\t"
-		"1:				\n\t"
-		"movd (%1, %%esi), %%mm0	\n\t"
-		"punpckldq 2048(%1, %%esi), %%mm0\n\t"
-		"movd 3072(%1, %%esi), %%mm1	\n\t"
-		"punpckldq 4096(%1, %%esi), %%mm1\n\t"
-		"movd 1024(%1, %%esi), %%mm2	\n\t"
-		"punpckldq 4(%1, %%esi), %%mm2	\n\t"
-		"movd 2052(%1, %%esi), %%mm3	\n\t"
-		"punpckldq 3076(%1, %%esi), %%mm3\n\t"
-		"movd 4100(%1, %%esi), %%mm4	\n\t"
-		"punpckldq 1028(%1, %%esi), %%mm4\n\t"
-		"movd 8(%1, %%esi), %%mm5	\n\t"
-		"punpckldq 2056(%1, %%esi), %%mm5\n\t"
-		"leal (%%esi, %%esi, 4), %%edi	\n\t"
-		"sarl $1, %%edi			\n\t"
-		"psubd %%mm7, %%mm0		\n\t"
-		"psubd %%mm7, %%mm1		\n\t"
-		"psubd %%mm7, %%mm2		\n\t"
-		"psubd %%mm7, %%mm3		\n\t"
-		"psubd %%mm7, %%mm4		\n\t"
-		"psubd %%mm7, %%mm5		\n\t"
-		"packssdw %%mm1, %%mm0		\n\t"
-		"packssdw %%mm3, %%mm2		\n\t"
-		"packssdw %%mm5, %%mm4		\n\t"
-		"movq %%mm0, (%0, %%edi)	\n\t"
-		"movq %%mm2, 8(%0, %%edi)	\n\t"
-		"movq %%mm4, 16(%0, %%edi)	\n\t"
-		
-		"movd 3080(%1, %%esi), %%mm0	\n\t"
-		"punpckldq 4104(%1, %%esi), %%mm0\n\t"
-		"movd 1032(%1, %%esi), %%mm1	\n\t"
-		"punpckldq 12(%1, %%esi), %%mm1\n\t"
-		"movd 2060(%1, %%esi), %%mm2	\n\t"
-		"punpckldq 3084(%1, %%esi), %%mm2\n\t"
-		"movd 4108(%1, %%esi), %%mm3	\n\t"
-		"punpckldq 1036(%1, %%esi), %%mm3\n\t"
-		"psubd %%mm7, %%mm0		\n\t"
-		"psubd %%mm7, %%mm1		\n\t"
-		"psubd %%mm7, %%mm2		\n\t"
-		"psubd %%mm7, %%mm3		\n\t"
-		"packssdw %%mm1, %%mm0		\n\t"
-		"packssdw %%mm3, %%mm2		\n\t"
-		"movq %%mm0, 24(%0, %%edi)	\n\t"
-		"movq %%mm2, 32(%0, %%edi)	\n\t"
-				
-		"addl $16, %%esi		\n\t"
-		" jnz 1b			\n\t"
-		"emms				\n\t"
-		:: "r" (s16+1280), "r" (f+256)
-		:"%esi", "%edi", "memory"
-	);
-    return 5*256;
-}
-
-static int a52_resample_MONO_LFE_to_6_MMX(float * _f, int16_t * s16){
-    int32_t * f = (int32_t *) _f;
-	asm volatile(
-		"movl $-1024, %%esi		\n\t"
-		"movq "MANGLE(magicF2W)", %%mm7	\n\t"
-		"pxor %%mm6, %%mm6		\n\t"
-		"1:				\n\t"
-		"movq 1024(%1, %%esi), %%mm0	\n\t"
-		"movq 1032(%1, %%esi), %%mm1	\n\t"
-		"movq (%1, %%esi), %%mm2	\n\t"
-		"movq 8(%1, %%esi), %%mm3	\n\t"
-		"psubd %%mm7, %%mm0		\n\t"
-		"psubd %%mm7, %%mm1		\n\t"
-		"psubd %%mm7, %%mm2		\n\t"
-		"psubd %%mm7, %%mm3		\n\t"
-		"packssdw %%mm1, %%mm0		\n\t"
-		"packssdw %%mm3, %%mm2		\n\t"
-		"movq %%mm0, %%mm1		\n\t"
-		"punpcklwd %%mm2, %%mm0		\n\t"
-		"punpckhwd %%mm2, %%mm1		\n\t"
-		"leal (%%esi, %%esi, 2), %%edi	\n\t"
-		"movq %%mm6, (%0, %%edi)	\n\t"
-		"movd %%mm0, 8(%0, %%edi)	\n\t"
-		"punpckhdq %%mm0, %%mm0		\n\t"
-		"movq %%mm6, 12(%0, %%edi)	\n\t"
-		"movd %%mm0, 20(%0, %%edi)	\n\t"
-		"movq %%mm6, 24(%0, %%edi)	\n\t"
-		"movd %%mm1, 32(%0, %%edi)	\n\t"
-		"punpckhdq %%mm1, %%mm1		\n\t"
-		"movq %%mm6, 36(%0, %%edi)	\n\t"
-		"movd %%mm1, 44(%0, %%edi)	\n\t"
-		"addl $16, %%esi		\n\t"
-		" jnz 1b			\n\t"
-		"emms				\n\t"
-		:: "r" (s16+1536), "r" (f+256)
-		:"%esi", "%edi", "memory"
-	);
-    return 6*256;
-}
-
-static int a52_resample_STEREO_LFE_to_6_MMX(float * _f, int16_t * s16){
-    int32_t * f = (int32_t *) _f;
-	asm volatile(
-		"movl $-1024, %%esi		\n\t"
-		"movq "MANGLE(magicF2W)", %%mm7	\n\t"
-		"pxor %%mm6, %%mm6		\n\t"
-		"1:				\n\t"
-		"movq 1024(%1, %%esi), %%mm0	\n\t"
-		"movq 2048(%1, %%esi), %%mm1	\n\t"
-		"movq (%1, %%esi), %%mm5	\n\t" 
-		"psubd %%mm7, %%mm0		\n\t"
-		"psubd %%mm7, %%mm1		\n\t"
-		"psubd %%mm7, %%mm5		\n\t"
-		"leal (%%esi, %%esi, 2), %%edi	\n\t"
-		
-		"pxor %%mm4, %%mm4		\n\t"
-		"packssdw %%mm5, %%mm0		\n\t" // FfAa
-		"packssdw %%mm4, %%mm1		\n\t" // 00Bb
-		"punpckhwd %%mm0, %%mm4		\n\t" // F0f0
-		"punpcklwd %%mm1, %%mm0		\n\t" // BAba
-		"movq %%mm0, %%mm1		\n\t" // BAba
-		"punpckldq %%mm4, %%mm3		\n\t" // f0XX
-		"punpckldq %%mm6, %%mm0		\n\t" // 00ba
-		"punpckhdq %%mm1, %%mm3		\n\t" // BAf0
-		
-		"movq %%mm0, (%0, %%edi)	\n\t" // 00ba
-		"punpckhdq %%mm4, %%mm0		\n\t" // F000
-		"movq %%mm3, 8(%0, %%edi)	\n\t" // BAf0
-		"movq %%mm0, 16(%0, %%edi)	\n\t" // F000
-		"addl $8, %%esi			\n\t"
-		" jnz 1b			\n\t"
-		"emms				\n\t"
-		:: "r" (s16+1536), "r" (f+256)
-		:"%esi", "%edi", "memory"
-	);
-    return 6*256;
-}
-
-static int a52_resample_3F_LFE_to_6_MMX(float * _f, int16_t * s16){
-    int32_t * f = (int32_t *) _f;
-	asm volatile(
-		"movl $-1024, %%esi		\n\t"
-		"movq "MANGLE(magicF2W)", %%mm7	\n\t"
-		"pxor %%mm6, %%mm6		\n\t"
-		"1:				\n\t"
-		"movq 1024(%1, %%esi), %%mm0	\n\t"
-		"movq 3072(%1, %%esi), %%mm1	\n\t"
-		"movq 2048(%1, %%esi), %%mm4	\n\t"
-		"movq (%1, %%esi), %%mm5	\n\t" 
-		"psubd %%mm7, %%mm0		\n\t"
-		"psubd %%mm7, %%mm1		\n\t"
-		"psubd %%mm7, %%mm4		\n\t"
-		"psubd %%mm7, %%mm5		\n\t"
-		"leal (%%esi, %%esi, 2), %%edi	\n\t"
-		
-		"packssdw %%mm4, %%mm0		\n\t" // EeAa
-		"packssdw %%mm5, %%mm1		\n\t" // FfBb
-		"movq %%mm0, %%mm2		\n\t" // EeAa
-		"punpcklwd %%mm1, %%mm0		\n\t" // BAba
-		"punpckhwd %%mm1, %%mm2		\n\t" // FEfe
-		"movq %%mm0, %%mm1		\n\t" // BAba
-		"punpckldq %%mm6, %%mm0		\n\t" // 00ba
-		"punpckhdq %%mm1, %%mm1		\n\t" // BABA
-		
-		"movq %%mm0, (%0, %%edi)	\n\t"
-		"punpckhdq %%mm2, %%mm0		\n\t" // FE00
-		"punpckldq %%mm1, %%mm2		\n\t" // BAfe
-		"movq %%mm2, 8(%0, %%edi)	\n\t"
-		"movq %%mm0, 16(%0, %%edi)	\n\t"
-		"addl $8, %%esi			\n\t"
-		" jnz 1b			\n\t"
-		"emms				\n\t"
-		:: "r" (s16+1536), "r" (f+256)
-		:"%esi", "%edi", "memory"
-	);
-    return 6*256;
-}
-
-static int a52_resample_2F_2R_LFE_to_6_MMX(float * _f, int16_t * s16){
-    int32_t * f = (int32_t *) _f;
-	asm volatile(
-		"movl $-1024, %%esi		\n\t"
-		"movq "MANGLE(magicF2W)", %%mm7	\n\t"
-//		"pxor %%mm6, %%mm6		\n\t"
-		"1:				\n\t"
-		"movq 1024(%1, %%esi), %%mm0	\n\t"
-		"movq 2048(%1, %%esi), %%mm1	\n\t"
-		"movq 3072(%1, %%esi), %%mm2	\n\t"
-		"movq 4096(%1, %%esi), %%mm3	\n\t"
-		"movq (%1, %%esi), %%mm5	\n\t" 
-		"psubd %%mm7, %%mm0		\n\t"
-		"psubd %%mm7, %%mm1		\n\t"
-		"psubd %%mm7, %%mm2		\n\t"
-		"psubd %%mm7, %%mm3		\n\t"
-		"psubd %%mm7, %%mm5		\n\t"
-		"leal (%%esi, %%esi, 2), %%edi	\n\t"
-		
-		"packssdw %%mm2, %%mm0		\n\t" // CcAa
-		"packssdw %%mm3, %%mm1		\n\t" // DdBb
-		"packssdw %%mm5, %%mm5		\n\t" // FfFf
-		"movq %%mm0, %%mm2		\n\t" // CcAa
-		"punpcklwd %%mm1, %%mm0		\n\t" // BAba
-		"punpckhwd %%mm1, %%mm2		\n\t" // DCdc
-		"pxor %%mm4, %%mm4		\n\t" // 0000
-		"punpcklwd %%mm5, %%mm4		\n\t" // F0f0
-		"movq %%mm0, %%mm1		\n\t" // BAba
-		"movq %%mm4, %%mm3		\n\t" // F0f0
-		"punpckldq %%mm2, %%mm0		\n\t" // dcba
-		"punpckhdq %%mm1, %%mm1		\n\t" // BABA
-		"punpckldq %%mm1, %%mm4		\n\t" // BAf0
-		"punpckhdq %%mm3, %%mm2		\n\t" // F0DC
-		
-		"movq %%mm0, (%0, %%edi)	\n\t"
-		"movq %%mm4, 8(%0, %%edi)	\n\t"
-		"movq %%mm2, 16(%0, %%edi)	\n\t"
-		"addl $8, %%esi			\n\t"
-		" jnz 1b			\n\t"
-		"emms				\n\t"
-		:: "r" (s16+1536), "r" (f+256)
-		:"%esi", "%edi", "memory"
-	);
-    return 6*256;
-}
-
-static int a52_resample_3F_2R_LFE_to_6_MMX(float * _f, int16_t * s16){
-    int32_t * f = (int32_t *) _f;
-	asm volatile(
-		"movl $-1024, %%esi		\n\t"
-		"movq "MANGLE(magicF2W)", %%mm7	\n\t"
-//		"pxor %%mm6, %%mm6		\n\t"
-		"1:				\n\t"
-		"movq 1024(%1, %%esi), %%mm0	\n\t"
-		"movq 3072(%1, %%esi), %%mm1	\n\t"
-		"movq 4096(%1, %%esi), %%mm2	\n\t"
-		"movq 5120(%1, %%esi), %%mm3	\n\t"
-		"movq 2048(%1, %%esi), %%mm4	\n\t"
-		"movq (%1, %%esi), %%mm5	\n\t" 
-		"psubd %%mm7, %%mm0		\n\t"
-		"psubd %%mm7, %%mm1		\n\t"
-		"psubd %%mm7, %%mm2		\n\t"
-		"psubd %%mm7, %%mm3		\n\t"
-		"psubd %%mm7, %%mm4		\n\t"
-		"psubd %%mm7, %%mm5		\n\t"
-		"leal (%%esi, %%esi, 2), %%edi	\n\t"
-		
-		"packssdw %%mm2, %%mm0		\n\t" // CcAa
-		"packssdw %%mm3, %%mm1		\n\t" // DdBb
-		"packssdw %%mm4, %%mm4		\n\t" // EeEe
-		"packssdw %%mm5, %%mm5		\n\t" // FfFf
-		"movq %%mm0, %%mm2		\n\t" // CcAa
-		"punpcklwd %%mm1, %%mm0		\n\t" // BAba
-		"punpckhwd %%mm1, %%mm2		\n\t" // DCdc
-		"punpcklwd %%mm5, %%mm4		\n\t" // FEfe
-		"movq %%mm0, %%mm1		\n\t" // BAba
-		"movq %%mm4, %%mm3		\n\t" // FEfe
-		"punpckldq %%mm2, %%mm0		\n\t" // dcba
-		"punpckhdq %%mm1, %%mm1		\n\t" // BABA
-		"punpckldq %%mm1, %%mm4		\n\t" // BAfe
-		"punpckhdq %%mm3, %%mm2		\n\t" // FEDC
-		
-		"movq %%mm0, (%0, %%edi)	\n\t"
-		"movq %%mm4, 8(%0, %%edi)	\n\t"
-		"movq %%mm2, 16(%0, %%edi)	\n\t"
-		"addl $8, %%esi			\n\t"
-		" jnz 1b			\n\t"
-		"emms				\n\t"
-		:: "r" (s16+1536), "r" (f+256)
-		:"%esi", "%edi", "memory"
-	);
-    return 6*256;
-}
-
-
-static void* a52_resample_MMX(int flags, int ch){
-    switch (flags) {
-    case A52_MONO:
-	if(ch==5) return a52_resample_MONO_to_5_MMX;
-	break;
-    case A52_CHANNEL:
-    case A52_STEREO:
-    case A52_DOLBY:
-	if(ch==2) return a52_resample_STEREO_to_2_MMX;
-	break;
-    case A52_3F:
-	if(ch==5) return a52_resample_3F_to_5_MMX;
-	break;
-    case A52_2F2R:
-	if(ch==4) return a52_resample_2F_2R_to_4_MMX;
-	break;
-    case A52_3F2R:
-	if(ch==5) return a52_resample_3F_2R_to_5_MMX;
-	break;
-    case A52_MONO | A52_LFE:
-	if(ch==6) return a52_resample_MONO_LFE_to_6_MMX;
-	break;
-    case A52_CHANNEL | A52_LFE:
-    case A52_STEREO | A52_LFE:
-    case A52_DOLBY | A52_LFE:
-	if(ch==6) return a52_resample_STEREO_LFE_to_6_MMX;
-	break;
-    case A52_3F | A52_LFE:
-	if(ch==6) return a52_resample_3F_LFE_to_6_MMX;
-	break;
-    case A52_2F2R | A52_LFE:
-	if(ch==6) return a52_resample_2F_2R_LFE_to_6_MMX;
-	break;
-    case A52_3F2R | A52_LFE:
-	if(ch==6) return a52_resample_3F_2R_LFE_to_6_MMX;
-	break;
-    }
-    return NULL;
-}
-
-
diff --git a/ffmpeg.src/libavcodec/liba52/tables.h b/ffmpeg.src/libavcodec/liba52/tables.h
deleted file mode 100644
index b067c63..0000000
--- a/ffmpeg.src/libavcodec/liba52/tables.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * tables.h
- * Copyright (C) 2000-2003 Michel Lespinasse <walken at zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma at ess.engr.uvic.ca>
- *
- * This file is part of a52dec, a free ATSC A-52 stream decoder.
- * See http://liba52.sourceforge.net/ for updates.
- *
- * a52dec 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.
- *
- * a52dec 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-static const int8_t exp_1[128] = {
-    -2,-2,-2,-2,-2,-2,-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,
-     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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-    25,25,25
-};
-static const int8_t exp_2[128] = {
-    -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
-    -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
-    -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
-    -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
-    -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
-    25,25,25
-};
-static const int8_t exp_3[128] = {
-    -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
-    -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
-    -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
-    -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
-    -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
-    25,25,25
-};
-
-#define Q(x) ROUND (32768.0 * x)
-
-#define Q0 Q (-2/3)
-#define Q1 Q (0)
-#define Q2 Q (2/3)
-
-static const quantizer_t q_1_0[32] = {
-    Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
-    Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
-    Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
-    0,  0,  0,  0,  0
-};
-
-static const quantizer_t q_1_1[32] = {
-    Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
-    Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
-    Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
-    0,  0,  0,  0,  0
-};
-
-static const quantizer_t q_1_2[32] = {
-    Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
-    Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
-    Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
-    0,  0,  0,  0,  0
-};
-
-#undef Q0
-#undef Q1
-#undef Q2
-
-#define Q0 Q (-4/5)
-#define Q1 Q (-2/5)
-#define Q2 Q (0)
-#define Q3 Q (2/5)
-#define Q4 Q (4/5)
-
-static const quantizer_t q_2_0[128] = {
-    Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,
-    Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,
-    Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,
-    Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,
-    Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,
-    0,0,0
-};
-
-static const quantizer_t q_2_1[128] = {
-    Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
-    Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
-    Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
-    Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
-    Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
-    0,0,0
-};
-
-static const quantizer_t q_2_2[128] = {
-    Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
-    Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
-    Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
-    Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
-    Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
-    0,0,0
-};
-
-#undef Q0
-#undef Q1
-#undef Q2
-#undef Q3
-#undef Q4
-
-static const quantizer_t q_3[8] = {
-    Q (-6/7), Q (-4/7), Q (-2/7), Q (0), Q (2/7), Q (4/7), Q (6/7), 0
-};
-
-#define Q0 Q (-10/11)
-#define Q1 Q (-8/11)
-#define Q2 Q (-6/11)
-#define Q3 Q (-4/11)
-#define Q4 Q (-2/11)
-#define Q5 Q (0)
-#define Q6 Q (2/11)
-#define Q7 Q (4/11)
-#define Q8 Q (6/11)
-#define Q9 Q (8/11)
-#define QA Q (10/11)
-
-static const quantizer_t q_4_0[128] = {
-    Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
-    Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
-    Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
-    Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3,
-    Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4,
-    Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5,
-    Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6,
-    Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7,
-    Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8,
-    Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9,
-    QA, QA, QA, QA, QA, QA, QA, QA, QA, QA, QA,
-    0,  0,  0,  0,  0,  0,  0
-};
-
-static const quantizer_t q_4_1[128] = {
-    Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
-    Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
-    Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
-    Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
-    Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
-    Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
-    Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
-    Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
-    Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
-    Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
-    Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
-    0,  0,  0,  0,  0,  0,  0
-};
-
-#undef Q0
-#undef Q1
-#undef Q2
-#undef Q3
-#undef Q4
-#undef Q5
-#undef Q6
-#undef Q7
-#undef Q8
-#undef Q9
-#undef QA
-
-static const quantizer_t q_5[16] = {
-    Q (-14/15), Q (-12/15), Q (-10/15), Q (-8/15), Q (-6/15),
-    Q (-4/15), Q (-2/15), Q (0), Q (2/15), Q (4/15),
-    Q (6/15), Q (8/15), Q (10/15), Q (12/15), Q (14/15), 0
-};
-
-#ifndef LIBA52_FIXED
-static const sample_t scale_factor[25] = {
-    0.000030517578125,
-    0.0000152587890625,
-    0.00000762939453125,
-    0.000003814697265625,
-    0.0000019073486328125,
-    0.00000095367431640625,
-    0.000000476837158203125,
-    0.0000002384185791015625,
-    0.00000011920928955078125,
-    0.000000059604644775390625,
-    0.0000000298023223876953125,
-    0.00000001490116119384765625,
-    0.000000007450580596923828125,
-    0.0000000037252902984619140625,
-    0.00000000186264514923095703125,
-    0.000000000931322574615478515625,
-    0.0000000004656612873077392578125,
-    0.00000000023283064365386962890625,
-    0.000000000116415321826934814453125,
-    0.0000000000582076609134674072265625,
-    0.00000000002910383045673370361328125,
-    0.000000000014551915228366851806640625,
-    0.0000000000072759576141834259033203125,
-    0.00000000000363797880709171295166015625,
-    0.000000000001818989403545856475830078125
-};
-#endif
-
-static const uint16_t dither_lut[256] = {
-    0x0000, 0xa011, 0xe033, 0x4022, 0x6077, 0xc066, 0x8044, 0x2055,
-    0xc0ee, 0x60ff, 0x20dd, 0x80cc, 0xa099, 0x0088, 0x40aa, 0xe0bb,
-    0x21cd, 0x81dc, 0xc1fe, 0x61ef, 0x41ba, 0xe1ab, 0xa189, 0x0198,
-    0xe123, 0x4132, 0x0110, 0xa101, 0x8154, 0x2145, 0x6167, 0xc176,
-    0x439a, 0xe38b, 0xa3a9, 0x03b8, 0x23ed, 0x83fc, 0xc3de, 0x63cf,
-    0x8374, 0x2365, 0x6347, 0xc356, 0xe303, 0x4312, 0x0330, 0xa321,
-    0x6257, 0xc246, 0x8264, 0x2275, 0x0220, 0xa231, 0xe213, 0x4202,
-    0xa2b9, 0x02a8, 0x428a, 0xe29b, 0xc2ce, 0x62df, 0x22fd, 0x82ec,
-    0x8734, 0x2725, 0x6707, 0xc716, 0xe743, 0x4752, 0x0770, 0xa761,
-    0x47da, 0xe7cb, 0xa7e9, 0x07f8, 0x27ad, 0x87bc, 0xc79e, 0x678f,
-    0xa6f9, 0x06e8, 0x46ca, 0xe6db, 0xc68e, 0x669f, 0x26bd, 0x86ac,
-    0x6617, 0xc606, 0x8624, 0x2635, 0x0660, 0xa671, 0xe653, 0x4642,
-    0xc4ae, 0x64bf, 0x249d, 0x848c, 0xa4d9, 0x04c8, 0x44ea, 0xe4fb,
-    0x0440, 0xa451, 0xe473, 0x4462, 0x6437, 0xc426, 0x8404, 0x2415,
-    0xe563, 0x4572, 0x0550, 0xa541, 0x8514, 0x2505, 0x6527, 0xc536,
-    0x258d, 0x859c, 0xc5be, 0x65af, 0x45fa, 0xe5eb, 0xa5c9, 0x05d8,
-    0xae79, 0x0e68, 0x4e4a, 0xee5b, 0xce0e, 0x6e1f, 0x2e3d, 0x8e2c,
-    0x6e97, 0xce86, 0x8ea4, 0x2eb5, 0x0ee0, 0xaef1, 0xeed3, 0x4ec2,
-    0x8fb4, 0x2fa5, 0x6f87, 0xcf96, 0xefc3, 0x4fd2, 0x0ff0, 0xafe1,
-    0x4f5a, 0xef4b, 0xaf69, 0x0f78, 0x2f2d, 0x8f3c, 0xcf1e, 0x6f0f,
-    0xede3, 0x4df2, 0x0dd0, 0xadc1, 0x8d94, 0x2d85, 0x6da7, 0xcdb6,
-    0x2d0d, 0x8d1c, 0xcd3e, 0x6d2f, 0x4d7a, 0xed6b, 0xad49, 0x0d58,
-    0xcc2e, 0x6c3f, 0x2c1d, 0x8c0c, 0xac59, 0x0c48, 0x4c6a, 0xec7b,
-    0x0cc0, 0xacd1, 0xecf3, 0x4ce2, 0x6cb7, 0xcca6, 0x8c84, 0x2c95,
-    0x294d, 0x895c, 0xc97e, 0x696f, 0x493a, 0xe92b, 0xa909, 0x0918,
-    0xe9a3, 0x49b2, 0x0990, 0xa981, 0x89d4, 0x29c5, 0x69e7, 0xc9f6,
-    0x0880, 0xa891, 0xe8b3, 0x48a2, 0x68f7, 0xc8e6, 0x88c4, 0x28d5,
-    0xc86e, 0x687f, 0x285d, 0x884c, 0xa819, 0x0808, 0x482a, 0xe83b,
-    0x6ad7, 0xcac6, 0x8ae4, 0x2af5, 0x0aa0, 0xaab1, 0xea93, 0x4a82,
-    0xaa39, 0x0a28, 0x4a0a, 0xea1b, 0xca4e, 0x6a5f, 0x2a7d, 0x8a6c,
-    0x4b1a, 0xeb0b, 0xab29, 0x0b38, 0x2b6d, 0x8b7c, 0xcb5e, 0x6b4f,
-    0x8bf4, 0x2be5, 0x6bc7, 0xcbd6, 0xeb83, 0x4b92, 0x0bb0, 0xaba1
-};
diff --git a/ffmpeg.src/libavcodec/libpostproc/mangle.h b/ffmpeg.src/libavcodec/libpostproc/mangle.h
deleted file mode 100644
index aa09cd6..0000000
--- a/ffmpeg.src/libavcodec/libpostproc/mangle.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* mangle.h - This file has some CPP macros to deal with different symbol
- * mangling across binary formats.
- * (c)2002 by Felix Buenemann <atmosfear at users.sourceforge.net>
- * File licensed under the GPL, see http://www.fsf.org/ for more info.
- */
-
-#ifndef __MANGLE_H
-#define __MANGLE_H
-
-/* Feel free to add more to the list, eg. a.out IMO */
-/* Use rip-relative addressing if compiling PIC code on x86-64. */
-#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__OS2__) || \
-   (defined(__OpenBSD__) && !defined(__ELF__))
-#if defined(ARCH_X86_64) && defined(PIC)
-#define MANGLE(a) "_" #a"(%%rip)"
-#else
-#define MANGLE(a) "_" #a
-#endif
-#else
-#if defined(ARCH_X86_64) && defined(PIC)
-#define MANGLE(a) #a"(%%rip)"
-#else
-#define MANGLE(a) #a
-#endif
-#endif
-
-#endif /* !__MANGLE_H */
-
diff --git a/ffmpeg.src/libavcodec/mdct.c b/ffmpeg.src/libavcodec/mdct.c
deleted file mode 100644
index 6628958..0000000
--- a/ffmpeg.src/libavcodec/mdct.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * MDCT/IMDCT transforms
- * Copyright (c) 2002 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "dsputil.h"
-
-/**
- * @file mdct.c
- * MDCT/IMDCT transforms.
- */
-
-/**
- * init MDCT or IMDCT computation.
- */
-int ff_mdct_init(MDCTContext *s, int nbits, int inverse)
-{
-    int n, n4, i;
-    float alpha;
-
-    memset(s, 0, sizeof(*s));
-    n = 1 << nbits;
-    s->nbits = nbits;
-    s->n = n;
-    n4 = n >> 2;
-    s->tcos = av_malloc(n4 * sizeof(FFTSample));
-    if (!s->tcos)
-        goto fail;
-    s->tsin = av_malloc(n4 * sizeof(FFTSample));
-    if (!s->tsin)
-        goto fail;
-
-    for(i=0;i<n4;i++) {
-        alpha = 2 * M_PI * (i + 1.0 / 8.0) / n;
-        s->tcos[i] = -cos(alpha);
-        s->tsin[i] = -sin(alpha);
-    }
-    if (ff_fft_init(&s->fft, s->nbits - 2, inverse) < 0)
-        goto fail;
-    return 0;
- fail:
-    av_freep(&s->tcos);
-    av_freep(&s->tsin);
-    return -1;
-}
-
-/* complex multiplication: p = a * b */
-#define CMUL(pre, pim, are, aim, bre, bim) \
-{\
-    float _are = (are);\
-    float _aim = (aim);\
-    float _bre = (bre);\
-    float _bim = (bim);\
-    (pre) = _are * _bre - _aim * _bim;\
-    (pim) = _are * _bim + _aim * _bre;\
-}
-
-/**
- * Compute inverse MDCT of size N = 2^nbits
- * @param output N samples
- * @param input N/2 samples
- * @param tmp N/2 samples
- */
-void ff_imdct_calc(MDCTContext *s, FFTSample *output, 
-                   const FFTSample *input, FFTSample *tmp)
-{
-    int k, n8, n4, n2, n, j;
-    const uint16_t *revtab = s->fft.revtab;
-    const FFTSample *tcos = s->tcos;
-    const FFTSample *tsin = s->tsin;
-    const FFTSample *in1, *in2;
-    FFTComplex *z = (FFTComplex *)tmp;
-
-    n = 1 << s->nbits;
-    n2 = n >> 1;
-    n4 = n >> 2;
-    n8 = n >> 3;
-
-    /* pre rotation */
-    in1 = input;
-    in2 = input + n2 - 1;
-    for(k = 0; k < n4; k++) {
-        j=revtab[k];
-        CMUL(z[j].re, z[j].im, *in2, *in1, tcos[k], tsin[k]);
-        in1 += 2;
-        in2 -= 2;
-    }
-    ff_fft_calc(&s->fft, z);
-
-    /* post rotation + reordering */
-    /* XXX: optimize */
-    for(k = 0; k < n4; k++) {
-        CMUL(z[k].re, z[k].im, z[k].re, z[k].im, tcos[k], tsin[k]);
-    }
-    for(k = 0; k < n8; k++) {
-        output[2*k] = -z[n8 + k].im;
-        output[n2-1-2*k] = z[n8 + k].im;
-
-        output[2*k+1] = z[n8-1-k].re;
-        output[n2-1-2*k-1] = -z[n8-1-k].re;
-
-        output[n2 + 2*k]=-z[k+n8].re;
-        output[n-1- 2*k]=-z[k+n8].re;
-
-        output[n2 + 2*k+1]=z[n8-k-1].im;
-        output[n-2 - 2 * k] = z[n8-k-1].im;
-    }
-}
-
-/**
- * Compute MDCT of size N = 2^nbits
- * @param input N samples
- * @param out N/2 samples
- * @param tmp temporary storage of N/2 samples
- */
-void ff_mdct_calc(MDCTContext *s, FFTSample *out, 
-                  const FFTSample *input, FFTSample *tmp)
-{
-    int i, j, n, n8, n4, n2, n3;
-    FFTSample re, im, re1, im1;
-    const uint16_t *revtab = s->fft.revtab;
-    const FFTSample *tcos = s->tcos;
-    const FFTSample *tsin = s->tsin;
-    FFTComplex *x = (FFTComplex *)tmp;
-
-    n = 1 << s->nbits;
-    n2 = n >> 1;
-    n4 = n >> 2;
-    n8 = n >> 3;
-    n3 = 3 * n4;
-
-    /* pre rotation */
-    for(i=0;i<n8;i++) {
-        re = -input[2*i+3*n4] - input[n3-1-2*i];
-        im = -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 = input[2*i] - input[n2-1-2*i];
-        im = -(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]);
-    }
-
-    ff_fft_calc(&s->fft, x);
-  
-    /* post rotation */
-    for(i=0;i<n4;i++) {
-        re = x[i].re;
-        im = x[i].im;
-        CMUL(re1, im1, re, im, -tsin[i], -tcos[i]);
-        out[2*i] = im1;
-        out[n2-1-2*i] = re1;
-    }
-}
-
-void ff_mdct_end(MDCTContext *s)
-{
-    av_freep(&s->tcos);
-    av_freep(&s->tsin);
-    ff_fft_end(&s->fft);
-}
diff --git a/ffmpeg.src/libavcodec/mdec.c b/ffmpeg.src/libavcodec/mdec.c
deleted file mode 100644
index afe122c..0000000
--- a/ffmpeg.src/libavcodec/mdec.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * PSX MDEC codec
- * Copyright (c) 2003 Michael Niedermayer
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * based upon code from Sebastian Jedruszkiewicz <elf at frogger.rules.pl>
- */
- 
-/**
- * @file mdec.c
- * PSX MDEC codec.
- * This is very similar to intra only MPEG1.
- */
- 
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-
-//#undef NDEBUG
-//#include <assert.h>
-
-typedef struct MDECContext{
-    AVCodecContext *avctx;
-    DSPContext dsp;
-    AVFrame picture;
-    PutBitContext pb;
-    GetBitContext gb;
-    ScanTable scantable;
-    int version;
-    int qscale;
-    int last_dc[3];
-    int mb_width;
-    int mb_height;
-    int mb_x, mb_y;
-    DCTELEM __align8 block[6][64];
-    uint16_t __align8 intra_matrix[64];
-    int __align8 q_intra_matrix[64];
-    uint8_t *bitstream_buffer;
-    int bitstream_buffer_size;
-    int block_last_index[6];
-} MDECContext;
-
-//very similar to mpeg1
-static inline int mdec_decode_block_intra(MDECContext *a, DCTELEM *block, int n)
-{
-    int level, diff, i, j, run;
-    int component;
-    RLTable *rl = &rl_mpeg1;
-    uint8_t * const scantable= a->scantable.permutated;
-    const uint16_t *quant_matrix= ff_mpeg1_default_intra_matrix;
-    const int qscale= a->qscale;
-
-    /* DC coef */
-    if(a->version==2){
-        block[0]= 2*get_sbits(&a->gb, 10) + 1024;
-    }else{
-        component = (n <= 3 ? 0 : n - 4 + 1);
-        diff = decode_dc(&a->gb, component);
-        if (diff >= 0xffff)
-            return -1;
-        a->last_dc[component]+= diff;
-        block[0] = a->last_dc[component]<<3;
-    }
-    
-    i = 0;
-    {
-        OPEN_READER(re, &a->gb);    
-        /* now quantify & encode AC coefs */
-        for(;;) {
-            UPDATE_CACHE(re, &a->gb);
-            GET_RL_VLC(level, run, re, &a->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
-            
-            if(level == 127){
-                break;
-            } else if(level != 0) {
-                i += run;
-                j = scantable[i];
-                level= (level*qscale*quant_matrix[j])>>3;
-//                level= (level-1)|1;
-                level = (level ^ SHOW_SBITS(re, &a->gb, 1)) - SHOW_SBITS(re, &a->gb, 1);
-                LAST_SKIP_BITS(re, &a->gb, 1);
-            } else {
-                /* escape */
-                run = SHOW_UBITS(re, &a->gb, 6)+1; LAST_SKIP_BITS(re, &a->gb, 6);
-                UPDATE_CACHE(re, &a->gb);
-                level = SHOW_SBITS(re, &a->gb, 10); SKIP_BITS(re, &a->gb, 10);
-                i += run;
-                j = scantable[i];
-                if(level<0){
-                    level= -level;
-                    level= (level*qscale*quant_matrix[j])>>3;
-                    level= (level-1)|1;
-                    level= -level;
-                }else{
-                    level= (level*qscale*quant_matrix[j])>>3;
-                    level= (level-1)|1;
-                }
-            }
-            if (i > 63){
-                av_log(a->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", a->mb_x, a->mb_y);
-                return -1;
-            }
-
-            block[j] = level;
-        }
-        CLOSE_READER(re, &a->gb);
-    }
-    a->block_last_index[n] = i;
-    return 0;
-}
-
-static inline int decode_mb(MDECContext *a, DCTELEM block[6][64]){
-    int i;
-    const int block_index[6]= {5,4,0,1,2,3};
-
-    a->dsp.clear_blocks(block[0]);
-    
-    for(i=0; i<6; i++){
-        if( mdec_decode_block_intra(a, block[ block_index[i] ], block_index[i]) < 0) 
-            return -1;
-    }
-    return 0;
-}
-
-static inline void idct_put(MDECContext *a, int mb_x, int mb_y){
-    DCTELEM (*block)[64]= a->block;
-    int linesize= a->picture.linesize[0];
-    
-    uint8_t *dest_y  = a->picture.data[0] + (mb_y * 16* linesize              ) + mb_x * 16;
-    uint8_t *dest_cb = a->picture.data[1] + (mb_y * 8 * a->picture.linesize[1]) + mb_x * 8;
-    uint8_t *dest_cr = a->picture.data[2] + (mb_y * 8 * a->picture.linesize[2]) + mb_x * 8;
-
-    a->dsp.idct_put(dest_y                 , linesize, block[0]);
-    a->dsp.idct_put(dest_y              + 8, linesize, block[1]);
-    a->dsp.idct_put(dest_y + 8*linesize    , linesize, block[2]);
-    a->dsp.idct_put(dest_y + 8*linesize + 8, linesize, block[3]);
-
-    if(!(a->avctx->flags&CODEC_FLAG_GRAY)){
-        a->dsp.idct_put(dest_cb, a->picture.linesize[1], block[4]);
-        a->dsp.idct_put(dest_cr, a->picture.linesize[2], block[5]);
-    }
-}
-
-static int decode_frame(AVCodecContext *avctx, 
-                        void *data, int *data_size,
-                        uint8_t *buf, int buf_size)
-{
-    MDECContext * const a = avctx->priv_data;
-    AVFrame *picture = data;
-    AVFrame * const p= (AVFrame*)&a->picture;
-    int i;
-
-    if(p->data[0])
-        avctx->release_buffer(avctx, p);
-
-    p->reference= 0;
-    if(avctx->get_buffer(avctx, p) < 0){
-        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
-        return -1;
-    }
-    p->pict_type= I_TYPE;
-    p->key_frame= 1;
-    a->last_dc[0]=
-    a->last_dc[1]=
-    a->last_dc[2]= 0;
-
-    a->bitstream_buffer= av_fast_realloc(a->bitstream_buffer, &a->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
-    for(i=0; i<buf_size; i+=2){
-        a->bitstream_buffer[i]  = buf[i+1];
-        a->bitstream_buffer[i+1]= buf[i  ];
-    }
-    init_get_bits(&a->gb, a->bitstream_buffer, buf_size*8);
-    
-    /* skip over 4 preamble bytes in stream (typically 0xXX 0xXX 0x00 0x38) */
-    skip_bits(&a->gb, 32);
-
-    a->qscale=  get_bits(&a->gb, 16);
-    a->version= get_bits(&a->gb, 16);
-    
-//    printf("qscale:%d (0x%X), version:%d (0x%X)\n", a->qscale, a->qscale, a->version, a->version);
-    
-    for(a->mb_x=0; a->mb_x<a->mb_width; a->mb_x++){
-        for(a->mb_y=0; a->mb_y<a->mb_height; a->mb_y++){
-            if( decode_mb(a, a->block) <0)
-                return -1;
-             
-            idct_put(a, a->mb_x, a->mb_y);
-        }
-    }
-
-//    p->quality= (32 + a->inv_qscale/2)/a->inv_qscale;
-//    memset(p->qscale_table, p->quality, p->qstride*a->mb_height);
-    
-    *picture= *(AVFrame*)&a->picture;
-    *data_size = sizeof(AVPicture);
-
-    emms_c();
-    
-    return (get_bits_count(&a->gb)+31)/32*4;
-}
-
-static void mdec_common_init(AVCodecContext *avctx){
-    MDECContext * const a = avctx->priv_data;
-
-    dsputil_init(&a->dsp, avctx);
-
-    a->mb_width   = (avctx->coded_width  + 15) / 16;
-    a->mb_height  = (avctx->coded_height + 15) / 16;
-
-    avctx->coded_frame= (AVFrame*)&a->picture;
-    a->avctx= avctx;
-}
-
-static int decode_init(AVCodecContext *avctx){
-    MDECContext * const a = avctx->priv_data;
-    AVFrame *p= (AVFrame*)&a->picture;
- 
-    mdec_common_init(avctx);
-    init_vlcs();
-    ff_init_scantable(a->dsp.idct_permutation, &a->scantable, ff_zigzag_direct);
-/*
-    for(i=0; i<64; i++){
-        int index= ff_zigzag_direct[i];
-        a->intra_matrix[i]= 64*ff_mpeg1_default_intra_matrix[index] / a->inv_qscale;
-    }
-*/
-    p->qstride= a->mb_width;
-    p->qscale_table= av_mallocz( p->qstride * a->mb_height);
-    avctx->pix_fmt= PIX_FMT_YUV420P;
-
-    return 0;
-}
-
-static int decode_end(AVCodecContext *avctx){
-    MDECContext * const a = avctx->priv_data;
-
-    av_freep(&a->bitstream_buffer);
-    av_freep(&a->picture.qscale_table);
-    a->bitstream_buffer_size=0;
-    
-    return 0;
-}
-
-AVCodec mdec_decoder = {
-    "mdec",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MDEC,
-    sizeof(MDECContext),
-    decode_init,
-    NULL,
-    decode_end,
-    decode_frame,
-    CODEC_CAP_DR1,
-};
-
diff --git a/ffmpeg.src/libavcodec/mem.c b/ffmpeg.src/libavcodec/mem.c
deleted file mode 100644
index 462d674..0000000
--- a/ffmpeg.src/libavcodec/mem.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * default memory allocator for libavcodec
- * Copyright (c) 2002 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-/**
- * @file mem.c
- * default memory allocator for libavcodec.
- */
- 
-#include "avcodec.h"
-
-/* here we can use OS dependant allocation functions */
-#undef malloc
-#undef free
-#undef realloc
-
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-
-/* you can redefine av_malloc and av_free in your project to use your
-   memory allocator. You do not need to suppress this file because the
-   linker will do it automatically */
-
-/** 
- * Memory allocation of size byte with alignment suitable for all
- * memory accesses (including vectors if available on the
- * CPU). av_malloc(0) must return a non NULL pointer.
- */
-void *av_malloc(unsigned int size)
-{
-    void *ptr;
-#ifdef MEMALIGN_HACK
-    int diff;
-#endif
-
-    /* lets disallow possible ambiguous cases */
-    if(size > INT_MAX)
-        return NULL;
-    
-#ifdef MEMALIGN_HACK
-    ptr = malloc(size+16+1);
-    diff= ((-(int)ptr - 1)&15) + 1;
-    ptr += diff;
-    ((char*)ptr)[-1]= diff;
-#elif defined (HAVE_MEMALIGN) 
-    ptr = memalign(16,size);
-    /* Why 64? 
-       Indeed, we should align it:
-         on 4 for 386
-         on 16 for 486
-	 on 32 for 586, PPro - k6-III
-	 on 64 for K7 (maybe for P3 too).
-       Because L1 and L2 caches are aligned on those values.
-       But I don't want to code such logic here!
-     */
-     /* Why 16?
-        because some cpus need alignment, for example SSE2 on P4, & most RISC cpus
-        it will just trigger an exception and the unaligned load will be done in the
-        exception handler or it will just segfault (SSE2 on P4)
-        Why not larger? because i didnt see a difference in benchmarks ...
-     */
-     /* benchmarks with p3
-        memalign(64)+1		3071,3051,3032
-        memalign(64)+2		3051,3032,3041
-        memalign(64)+4		2911,2896,2915
-        memalign(64)+8		2545,2554,2550
-        memalign(64)+16		2543,2572,2563
-        memalign(64)+32		2546,2545,2571
-        memalign(64)+64		2570,2533,2558
-        
-        btw, malloc seems to do 8 byte alignment by default here
-     */
-#else
-    ptr = malloc(size);
-#endif
-    return ptr;
-}
-
-/**
- * av_realloc semantics (same as glibc): if ptr is NULL and size > 0,
- * identical to malloc(size). If size is zero, it is identical to
- * free(ptr) and NULL is returned.  
- */
-void *av_realloc(void *ptr, unsigned int size)
-{
-#ifdef MEMALIGN_HACK
-    int diff;
-#endif
-
-    /* lets disallow possible ambiguous cases */
-    if(size > INT_MAX)
-        return NULL;
-
-#ifdef MEMALIGN_HACK
-    //FIXME this isnt aligned correctly though it probably isnt needed
-    if(!ptr) return av_malloc(size);
-    diff= ((char*)ptr)[-1];
-    return realloc(ptr - diff, size + diff) + diff;
-#else
-    return realloc(ptr, size);
-#endif
-}
-
-/* NOTE: ptr = NULL is explicetly allowed */
-void av_free(void *ptr)
-{
-    /* XXX: this test should not be needed on most libcs */
-    if (ptr)
-#ifdef MEMALIGN_HACK
-        free(ptr - ((char*)ptr)[-1]);
-#else
-        free(ptr);
-#endif
-}
-
diff --git a/ffmpeg.src/libavcodec/mjpeg.c b/ffmpeg.src/libavcodec/mjpeg.c
deleted file mode 100644
index 3807807..0000000
--- a/ffmpeg.src/libavcodec/mjpeg.c
+++ /dev/null
@@ -1,2326 +0,0 @@
-/*
- * MJPEG encoder and decoder
- * Copyright (c) 2000, 2001 Fabrice Bellard.
- * Copyright (c) 2003 Alex Beregszaszi
- * Copyright (c) 2003-2004 Michael Niedermayer
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Support for external huffman table, various fixes (AVID workaround),
- * aspecting, new decode_frame mechanism and apple mjpeg-b support
- *                                  by Alex Beregszaszi <alex at naxine.org>
- */
-
-/**
- * @file mjpeg.c
- * MJPEG encoder and decoder.
- */
- 
-//#define DEBUG
-#include <assert.h>
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-
-/* use two quantizer tables (one for luminance and one for chrominance) */
-/* not yet working */
-#undef TWOMATRIXES
-
-typedef struct MJpegContext {
-    uint8_t huff_size_dc_luminance[12]; //FIXME use array [3] instead of lumi / chrom, for easier addressing 
-    uint16_t huff_code_dc_luminance[12];
-    uint8_t huff_size_dc_chrominance[12];
-    uint16_t huff_code_dc_chrominance[12];
-
-    uint8_t huff_size_ac_luminance[256];
-    uint16_t huff_code_ac_luminance[256];
-    uint8_t huff_size_ac_chrominance[256];
-    uint16_t huff_code_ac_chrominance[256];
-} MJpegContext;
-
-/* JPEG marker codes */
-typedef enum {
-    /* start of frame */
-    SOF0  = 0xc0,	/* baseline */
-    SOF1  = 0xc1,	/* extended sequential, huffman */
-    SOF2  = 0xc2,	/* progressive, huffman */
-    SOF3  = 0xc3,	/* lossless, huffman */
-
-    SOF5  = 0xc5,	/* differential sequential, huffman */
-    SOF6  = 0xc6,	/* differential progressive, huffman */
-    SOF7  = 0xc7,	/* differential lossless, huffman */
-    JPG   = 0xc8,	/* reserved for JPEG extension */
-    SOF9  = 0xc9,	/* extended sequential, arithmetic */
-    SOF10 = 0xca,	/* progressive, arithmetic */
-    SOF11 = 0xcb,	/* lossless, arithmetic */
-
-    SOF13 = 0xcd,	/* differential sequential, arithmetic */
-    SOF14 = 0xce,	/* differential progressive, arithmetic */
-    SOF15 = 0xcf,	/* differential lossless, arithmetic */
-
-    DHT   = 0xc4,	/* define huffman tables */
-
-    DAC   = 0xcc,	/* define arithmetic-coding conditioning */
-
-    /* restart with modulo 8 count "m" */
-    RST0  = 0xd0,
-    RST1  = 0xd1,
-    RST2  = 0xd2,
-    RST3  = 0xd3,
-    RST4  = 0xd4,
-    RST5  = 0xd5,
-    RST6  = 0xd6,
-    RST7  = 0xd7,
-
-    SOI   = 0xd8,	/* start of image */
-    EOI   = 0xd9,	/* end of image */
-    SOS   = 0xda,	/* start of scan */
-    DQT   = 0xdb,	/* define quantization tables */
-    DNL   = 0xdc,	/* define number of lines */
-    DRI   = 0xdd,	/* define restart interval */
-    DHP   = 0xde,	/* define hierarchical progression */
-    EXP   = 0xdf,	/* expand reference components */
-
-    APP0  = 0xe0,
-    APP1  = 0xe1,
-    APP2  = 0xe2,
-    APP3  = 0xe3,
-    APP4  = 0xe4,
-    APP5  = 0xe5,
-    APP6  = 0xe6,
-    APP7  = 0xe7,
-    APP8  = 0xe8,
-    APP9  = 0xe9,
-    APP10 = 0xea,
-    APP11 = 0xeb,
-    APP12 = 0xec,
-    APP13 = 0xed,
-    APP14 = 0xee,
-    APP15 = 0xef,
-
-    JPG0  = 0xf0,
-    JPG1  = 0xf1,
-    JPG2  = 0xf2,
-    JPG3  = 0xf3,
-    JPG4  = 0xf4,
-    JPG5  = 0xf5,
-    JPG6  = 0xf6,
-    JPG7  = 0xf7,
-    JPG8  = 0xf8,
-    JPG9  = 0xf9,
-    JPG10 = 0xfa,
-    JPG11 = 0xfb,
-    JPG12 = 0xfc,
-    JPG13 = 0xfd,
-
-    COM   = 0xfe,	/* comment */
-
-    TEM   = 0x01,	/* temporary private use for arithmetic coding */
-
-    /* 0x02 -> 0xbf reserved */
-} JPEG_MARKER;
-
-#if 0
-/* These are the sample quantization tables given in JPEG spec section K.1.
- * The spec says that the values given produce "good" quality, and
- * when divided by 2, "very good" quality.
- */
-static const unsigned char std_luminance_quant_tbl[64] = {
-    16,  11,  10,  16,  24,  40,  51,  61,
-    12,  12,  14,  19,  26,  58,  60,  55,
-    14,  13,  16,  24,  40,  57,  69,  56,
-    14,  17,  22,  29,  51,  87,  80,  62,
-    18,  22,  37,  56,  68, 109, 103,  77,
-    24,  35,  55,  64,  81, 104, 113,  92,
-    49,  64,  78,  87, 103, 121, 120, 101,
-    72,  92,  95,  98, 112, 100, 103,  99
-};
-static const unsigned char std_chrominance_quant_tbl[64] = {
-    17,  18,  24,  47,  99,  99,  99,  99,
-    18,  21,  26,  66,  99,  99,  99,  99,
-    24,  26,  56,  99,  99,  99,  99,  99,
-    47,  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
-};
-#endif
-
-/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
-/* IMPORTANT: these are only valid for 8-bit data precision! */
-static const uint8_t bits_dc_luminance[17] =
-{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
-static const uint8_t val_dc_luminance[] =
-{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
-
-static const uint8_t bits_dc_chrominance[17] =
-{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
-static const uint8_t val_dc_chrominance[] =
-{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
-
-static const uint8_t bits_ac_luminance[17] =
-{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
-static const uint8_t val_ac_luminance[] =
-{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
-  0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
-  0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
-  0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
-  0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
-  0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
-  0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
-  0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
-  0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
-  0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
-  0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
-  0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
-  0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
-  0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
-  0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
-  0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
-  0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
-  0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
-  0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
-  0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
-  0xf9, 0xfa 
-};
-
-static const uint8_t bits_ac_chrominance[17] =
-{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
-
-static const uint8_t val_ac_chrominance[] =
-{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
-  0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
-  0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
-  0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
-  0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
-  0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
-  0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
-  0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
-  0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
-  0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
-  0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
-  0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
-  0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
-  0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
-  0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
-  0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
-  0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
-  0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
-  0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
-  0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
-  0xf9, 0xfa 
-};
-
-/* isn't this function nicer than the one in the libjpeg ? */
-static void 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;
-
-    code = 0;
-    k = 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;
-    }
-}
-
-#ifdef CONFIG_ENCODERS
-int mjpeg_init(MpegEncContext *s)
-{
-    MJpegContext *m;
-    
-    m = av_malloc(sizeof(MJpegContext));
-    if (!m)
-        return -1;
-    
-    s->min_qcoeff=-1023;
-    s->max_qcoeff= 1023;
-
-    /* build all the huffman tables */
-    build_huffman_codes(m->huff_size_dc_luminance,
-                        m->huff_code_dc_luminance,
-                        bits_dc_luminance,
-                        val_dc_luminance);
-    build_huffman_codes(m->huff_size_dc_chrominance,
-                        m->huff_code_dc_chrominance,
-                        bits_dc_chrominance,
-                        val_dc_chrominance);
-    build_huffman_codes(m->huff_size_ac_luminance,
-                        m->huff_code_ac_luminance,
-                        bits_ac_luminance,
-                        val_ac_luminance);
-    build_huffman_codes(m->huff_size_ac_chrominance,
-                        m->huff_code_ac_chrominance,
-                        bits_ac_chrominance,
-                        val_ac_chrominance);
-    
-    s->mjpeg_ctx = m;
-    return 0;
-}
-
-void mjpeg_close(MpegEncContext *s)
-{
-    av_free(s->mjpeg_ctx);
-}
-#endif //CONFIG_ENCODERS
-
-#define PREDICT(ret, topleft, top, left, predictor)\
-    switch(predictor){\
-        case 1: ret= left; break;\
-        case 2: ret= top; break;\
-        case 3: ret= topleft; break;\
-        case 4: ret= left   +   top - topleft; break;\
-        case 5: ret= left   + ((top - topleft)>>1); break;\
-        case 6: ret= top + ((left   - topleft)>>1); break;\
-        default:\
-        case 7: ret= (left + top)>>1; break;\
-    }
-
-#ifdef CONFIG_ENCODERS
-static inline void put_marker(PutBitContext *p, int code)
-{
-    put_bits(p, 8, 0xff);
-    put_bits(p, 8, code);
-}
-
-/* table_class: 0 = DC coef, 1 = AC coefs */
-static int put_huffman_table(MpegEncContext *s, int table_class, int table_id,
-                             const uint8_t *bits_table, const uint8_t *value_table)
-{
-    PutBitContext *p = &s->pb;
-    int n, i;
-
-    put_bits(p, 4, table_class);
-    put_bits(p, 4, table_id);
-
-    n = 0;
-    for(i=1;i<=16;i++) {
-        n += bits_table[i];
-        put_bits(p, 8, bits_table[i]);
-    }
-
-    for(i=0;i<n;i++)
-        put_bits(p, 8, value_table[i]);
-
-    return n + 17;
-}
-
-static void jpeg_table_header(MpegEncContext *s)
-{
-    PutBitContext *p = &s->pb;
-    int i, j, size;
-    uint8_t *ptr;
-
-    /* quant matrixes */
-    put_marker(p, DQT);
-#ifdef TWOMATRIXES
-    put_bits(p, 16, 2 + 2 * (1 + 64));
-#else
-    put_bits(p, 16, 2 + 1 * (1 + 64));
-#endif
-    put_bits(p, 4, 0); /* 8 bit precision */
-    put_bits(p, 4, 0); /* table 0 */
-    for(i=0;i<64;i++) {
-        j = s->intra_scantable.permutated[i];
-        put_bits(p, 8, s->intra_matrix[j]);
-    }
-#ifdef TWOMATRIXES
-    put_bits(p, 4, 0); /* 8 bit precision */
-    put_bits(p, 4, 1); /* table 1 */
-    for(i=0;i<64;i++) {
-        j = s->intra_scantable.permutated[i];
-        put_bits(p, 8, s->chroma_intra_matrix[j]);
-    }
-#endif
-
-    /* huffman table */
-    put_marker(p, DHT);
-    flush_put_bits(p);
-    ptr = pbBufPtr(p);
-    put_bits(p, 16, 0); /* patched later */
-    size = 2;
-    size += put_huffman_table(s, 0, 0, bits_dc_luminance, val_dc_luminance);
-    size += put_huffman_table(s, 0, 1, bits_dc_chrominance, val_dc_chrominance);
-    
-    size += put_huffman_table(s, 1, 0, bits_ac_luminance, val_ac_luminance);
-    size += put_huffman_table(s, 1, 1, bits_ac_chrominance, val_ac_chrominance);
-    ptr[0] = size >> 8;
-    ptr[1] = size;
-}
-
-static void jpeg_put_comments(MpegEncContext *s)
-{
-    PutBitContext *p = &s->pb;
-    int size;
-    uint8_t *ptr;
-
-    if (s->aspect_ratio_info /* && !lossless */)
-    {
-    /* JFIF header */
-    put_marker(p, APP0);
-    put_bits(p, 16, 16);
-    put_string(p, "JFIF", 1); /* this puts the trailing zero-byte too */
-    put_bits(p, 16, 0x0201); /* v 1.02 */
-    put_bits(p, 8, 0); /* units type: 0 - aspect ratio */
-    put_bits(p, 16, s->avctx->sample_aspect_ratio.num);
-    put_bits(p, 16, s->avctx->sample_aspect_ratio.den);
-    put_bits(p, 8, 0); /* thumbnail width */
-    put_bits(p, 8, 0); /* thumbnail height */
-    }
-
-    /* comment */
-    if(!(s->flags & CODEC_FLAG_BITEXACT)){
-        put_marker(p, COM);
-        flush_put_bits(p);
-        ptr = pbBufPtr(p);
-        put_bits(p, 16, 0); /* patched later */
-        put_string(p, LIBAVCODEC_IDENT, 1);
-        size = strlen(LIBAVCODEC_IDENT)+3;
-        ptr[0] = size >> 8;
-        ptr[1] = size;
-    }
-
-    if(  s->avctx->pix_fmt == PIX_FMT_YUV420P 
-       ||s->avctx->pix_fmt == PIX_FMT_YUV422P
-       ||s->avctx->pix_fmt == PIX_FMT_YUV444P){
-        put_marker(p, COM);
-        flush_put_bits(p);
-        ptr = pbBufPtr(p);
-        put_bits(p, 16, 0); /* patched later */
-        put_string(p, "CS=ITU601", 1);
-        size = strlen("CS=ITU601")+3;
-        ptr[0] = size >> 8;
-        ptr[1] = size;
-    }
-}
-
-void mjpeg_picture_header(MpegEncContext *s)
-{
-    const int lossless= s->avctx->codec_id == CODEC_ID_LJPEG;
-
-    put_marker(&s->pb, SOI);
-
-    if (!s->mjpeg_data_only_frames)
-    {
-    jpeg_put_comments(s);    
-
-    if (s->mjpeg_write_tables) jpeg_table_header(s);
-
-    put_marker(&s->pb, lossless ? SOF3 : SOF0);
-
-    put_bits(&s->pb, 16, 17);
-    if(lossless && s->avctx->pix_fmt == PIX_FMT_RGBA32)
-        put_bits(&s->pb, 8, 9); /* 9 bits/component RCT */
-    else
-        put_bits(&s->pb, 8, 8); /* 8 bits/component */
-    put_bits(&s->pb, 16, s->height);
-    put_bits(&s->pb, 16, s->width);
-    put_bits(&s->pb, 8, 3); /* 3 components */
-    
-    /* Y component */
-    put_bits(&s->pb, 8, 1); /* component number */
-    put_bits(&s->pb, 4, s->mjpeg_hsample[0]); /* H factor */
-    put_bits(&s->pb, 4, s->mjpeg_vsample[0]); /* V factor */
-    put_bits(&s->pb, 8, 0); /* select matrix */
-    
-    /* Cb component */
-    put_bits(&s->pb, 8, 2); /* component number */
-    put_bits(&s->pb, 4, s->mjpeg_hsample[1]); /* H factor */
-    put_bits(&s->pb, 4, s->mjpeg_vsample[1]); /* V factor */
-#ifdef TWOMATRIXES
-    put_bits(&s->pb, 8, lossless ? 0 : 1); /* select matrix */
-#else
-    put_bits(&s->pb, 8, 0); /* select matrix */
-#endif
-
-    /* Cr component */
-    put_bits(&s->pb, 8, 3); /* component number */
-    put_bits(&s->pb, 4, s->mjpeg_hsample[2]); /* H factor */
-    put_bits(&s->pb, 4, s->mjpeg_vsample[2]); /* V factor */
-#ifdef TWOMATRIXES
-    put_bits(&s->pb, 8, lossless ? 0 : 1); /* select matrix */
-#else
-    put_bits(&s->pb, 8, 0); /* select matrix */
-#endif
-    }
-
-    /* scan header */
-    put_marker(&s->pb, SOS);
-    put_bits(&s->pb, 16, 12); /* length */
-    put_bits(&s->pb, 8, 3); /* 3 components */
-    
-    /* Y component */
-    put_bits(&s->pb, 8, 1); /* index */
-    put_bits(&s->pb, 4, 0); /* DC huffman table index */
-    put_bits(&s->pb, 4, 0); /* AC huffman table index */
-    
-    /* Cb component */
-    put_bits(&s->pb, 8, 2); /* index */
-    put_bits(&s->pb, 4, 1); /* DC huffman table index */
-    put_bits(&s->pb, 4, lossless ? 0 : 1); /* AC huffman table index */
-    
-    /* Cr component */
-    put_bits(&s->pb, 8, 3); /* index */
-    put_bits(&s->pb, 4, 1); /* DC huffman table index */
-    put_bits(&s->pb, 4, lossless ? 0 : 1); /* AC huffman table index */
-
-    put_bits(&s->pb, 8, lossless ? s->avctx->prediction_method+1 : 0); /* Ss (not used) */
-    put_bits(&s->pb, 8, lossless ? 0 : 63); /* Se (not used) */
-    put_bits(&s->pb, 8, 0); /* Ah/Al (not used) */
-}
-
-static void escape_FF(MpegEncContext *s, int start)
-{
-    int size= put_bits_count(&s->pb) - start*8;
-    int i, ff_count;
-    uint8_t *buf= s->pb.buf + start;
-    int align= (-(size_t)(buf))&3;
-    
-    assert((size&7) == 0);
-    size >>= 3;
-    
-    ff_count=0;
-    for(i=0; i<size && i<align; i++){
-        if(buf[i]==0xFF) ff_count++;
-    }
-    for(; i<size-15; i+=16){
-        int acc, v;
-
-        v= *(uint32_t*)(&buf[i]);
-        acc= (((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
-        v= *(uint32_t*)(&buf[i+4]);
-        acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
-        v= *(uint32_t*)(&buf[i+8]);
-        acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
-        v= *(uint32_t*)(&buf[i+12]);
-        acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
-
-        acc>>=4;
-        acc+= (acc>>16);
-        acc+= (acc>>8);
-        ff_count+= acc&0xFF;
-    }
-    for(; i<size; i++){
-        if(buf[i]==0xFF) ff_count++;
-    }
-
-    if(ff_count==0) return;
-    
-    /* skip put bits */
-    for(i=0; i<ff_count-3; i+=4)
-        put_bits(&s->pb, 32, 0);
-    put_bits(&s->pb, (ff_count-i)*8, 0);
-    flush_put_bits(&s->pb); 
-
-    for(i=size-1; ff_count; i--){
-        int v= buf[i];
-
-        if(v==0xFF){
-//printf("%d %d\n", i, ff_count);
-            buf[i+ff_count]= 0;
-            ff_count--;
-        }
-
-        buf[i+ff_count]= v;
-    }
-}
-
-void ff_mjpeg_stuffing(PutBitContext * pbc)
-{
-    int length;
-    length= (-put_bits_count(pbc))&7;
-    if(length) put_bits(pbc, length, (1<<length)-1);
-}
-
-void mjpeg_picture_trailer(MpegEncContext *s)
-{
-    ff_mjpeg_stuffing(&s->pb);
-    flush_put_bits(&s->pb);
-
-    assert((s->header_bits&7)==0);
-    
-    escape_FF(s, s->header_bits>>3);
-
-    put_marker(&s->pb, EOI);
-}
-
-static inline void mjpeg_encode_dc(MpegEncContext *s, int val,
-				   uint8_t *huff_size, uint16_t *huff_code)
-{
-    int mant, nbits;
-
-    if (val == 0) {
-        put_bits(&s->pb, huff_size[0], huff_code[0]);
-    } else {
-        mant = val;
-        if (val < 0) {
-            val = -val;
-            mant--;
-        }
-        
-        nbits= av_log2_16bit(val) + 1;
-            
-        put_bits(&s->pb, huff_size[nbits], huff_code[nbits]);
-        
-        put_bits(&s->pb, nbits, mant & ((1 << nbits) - 1));
-    }
-}
-
-static void encode_block(MpegEncContext *s, DCTELEM *block, int n)
-{
-    int mant, nbits, code, i, j;
-    int component, dc, run, last_index, val;
-    MJpegContext *m = s->mjpeg_ctx;
-    uint8_t *huff_size_ac;
-    uint16_t *huff_code_ac;
-    
-    /* DC coef */
-    component = (n <= 3 ? 0 : n - 4 + 1);
-    dc = block[0]; /* overflow is impossible */
-    val = dc - s->last_dc[component];
-    if (n < 4) {
-        mjpeg_encode_dc(s, val, m->huff_size_dc_luminance, m->huff_code_dc_luminance);
-        huff_size_ac = m->huff_size_ac_luminance;
-        huff_code_ac = m->huff_code_ac_luminance;
-    } else {
-        mjpeg_encode_dc(s, val, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
-        huff_size_ac = m->huff_size_ac_chrominance;
-        huff_code_ac = m->huff_code_ac_chrominance;
-    }
-    s->last_dc[component] = dc;
-    
-    /* AC coefs */
-    
-    run = 0;
-    last_index = s->block_last_index[n];
-    for(i=1;i<=last_index;i++) {
-        j = s->intra_scantable.permutated[i];
-        val = block[j];
-        if (val == 0) {
-            run++;
-        } else {
-            while (run >= 16) {
-                put_bits(&s->pb, huff_size_ac[0xf0], huff_code_ac[0xf0]);
-                run -= 16;
-            }
-            mant = val;
-            if (val < 0) {
-                val = -val;
-                mant--;
-            }
-            
-            nbits= av_log2(val) + 1;
-            code = (run << 4) | nbits;
-
-            put_bits(&s->pb, huff_size_ac[code], huff_code_ac[code]);
-        
-            put_bits(&s->pb, nbits, mant & ((1 << nbits) - 1));
-            run = 0;
-        }
-    }
-
-    /* output EOB only if not already 64 values */
-    if (last_index < 63 || run != 0)
-        put_bits(&s->pb, huff_size_ac[0], huff_code_ac[0]);
-}
-
-void mjpeg_encode_mb(MpegEncContext *s, 
-                     DCTELEM block[6][64])
-{
-    int i;
-    for(i=0;i<6;i++) {
-        encode_block(s, block[i], i);
-    }
-}
-
-static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
-    MpegEncContext * const s = avctx->priv_data;
-    MJpegContext * const m = s->mjpeg_ctx;
-    AVFrame *pict = data;
-    const int width= s->width;
-    const int height= s->height;
-    AVFrame * const p= (AVFrame*)&s->current_picture;
-    const int predictor= avctx->prediction_method+1;
-
-    init_put_bits(&s->pb, buf, buf_size);
-
-    *p = *pict;
-    p->pict_type= FF_I_TYPE;
-    p->key_frame= 1;
-    
-    mjpeg_picture_header(s);
-
-    s->header_bits= put_bits_count(&s->pb);
-    
-    if(avctx->pix_fmt == PIX_FMT_RGBA32){
-        int x, y, i;
-        const int linesize= p->linesize[0];
-        uint16_t (*buffer)[4]= (void *) s->rd_scratchpad;
-        int left[3], top[3], topleft[3];
-
-        for(i=0; i<3; i++){
-            buffer[0][i]= 1 << (9 - 1);
-        }
-
-        for(y = 0; y < height; y++) {
-            const int modified_predictor= y ? predictor : 1;
-            uint8_t *ptr = p->data[0] + (linesize * y);
-
-            if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < width*3*4){
-                av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
-                return -1;
-            }
-            
-            for(i=0; i<3; i++){
-                top[i]= left[i]= topleft[i]= buffer[0][i];
-            }
-            for(x = 0; x < width; x++) {
-                buffer[x][1] = ptr[4*x+0] - ptr[4*x+1] + 0x100;
-                buffer[x][2] = ptr[4*x+2] - ptr[4*x+1] + 0x100;
-                buffer[x][0] = (ptr[4*x+0] + 2*ptr[4*x+1] + ptr[4*x+2])>>2;
-
-                for(i=0;i<3;i++) {
-                    int pred, diff;
-
-                    PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
-                        
-                    topleft[i]= top[i];
-                    top[i]= buffer[x+1][i];
-                    
-                    left[i]= buffer[x][i];
-
-                    diff= ((left[i] - pred + 0x100)&0x1FF) - 0x100;
-                    
-                    if(i==0)
-                        mjpeg_encode_dc(s, diff, m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
-                    else
-                        mjpeg_encode_dc(s, diff, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
-                }
-            }
-        }
-    }else{
-        int mb_x, mb_y, i;
-        const int mb_width  = (width  + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0];
-        const int mb_height = (height + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0];
-        
-        for(mb_y = 0; mb_y < mb_height; mb_y++) {
-            if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < mb_width * 4 * 3 * s->mjpeg_hsample[0] * s->mjpeg_vsample[0]){
-                av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
-                return -1;
-            }
-            for(mb_x = 0; mb_x < mb_width; mb_x++) {
-                if(mb_x==0 || mb_y==0){
-                    for(i=0;i<3;i++) {
-                        uint8_t *ptr;
-                        int x, y, h, v, linesize;
-                        h = s->mjpeg_hsample[i];
-                        v = s->mjpeg_vsample[i];
-                        linesize= p->linesize[i];
-
-                        for(y=0; y<v; y++){
-                            for(x=0; x<h; x++){
-                                int pred;
-
-                                ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
-                                if(y==0 && mb_y==0){
-                                    if(x==0 && mb_x==0){
-                                        pred= 128;
-                                    }else{
-                                        pred= ptr[-1];
-                                    }
-                                }else{
-                                    if(x==0 && mb_x==0){
-                                        pred= ptr[-linesize];
-                                    }else{
-                                        PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
-                                    }
-                                }
-                                
-                                if(i==0)
-                                    mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
-                                else
-                                    mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
-                            }
-                        }
-                    }
-                }else{
-                    for(i=0;i<3;i++) {
-                        uint8_t *ptr;
-                        int x, y, h, v, linesize;
-                        h = s->mjpeg_hsample[i];
-                        v = s->mjpeg_vsample[i];
-                        linesize= p->linesize[i];
-                             
-                        for(y=0; y<v; y++){
-                            for(x=0; x<h; x++){
-                                int pred;
-
-                                ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
-//printf("%d %d %d %d %8X\n", mb_x, mb_y, x, y, ptr); 
-                                PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
-
-                                if(i==0)
-                                    mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly
-                                else
-                                    mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_chrominance, m->huff_code_dc_chrominance);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    emms_c();
-    
-    mjpeg_picture_trailer(s);
-    s->picture_number++;
-
-    flush_put_bits(&s->pb);
-    return pbBufPtr(&s->pb) - s->pb.buf;
-//    return (put_bits_count(&f->pb)+7)/8;
-}
-
-#endif //CONFIG_ENCODERS
-
-/******************************************/
-/* decoding */
-
-#define MAX_COMPONENTS 4
-
-typedef struct MJpegDecodeContext {
-    AVCodecContext *avctx;
-    GetBitContext gb;
-    int mpeg_enc_ctx_allocated; /* true if decoding context allocated */
-
-    int start_code; /* current start code */
-    int buffer_size;
-    uint8_t *buffer;
-
-    int16_t quant_matrixes[4][64];
-    VLC vlcs[2][4];
-    int qscale[4];      ///< quantizer scale calculated from quant_matrixes
-
-    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 */
-    int lossless;
-    int rgb;
-    int rct;            /* standard rct */  
-    int pegasus_rct;    /* pegasus reversible colorspace transform */  
-    int bits;           /* bits per component */
-
-    int width, height;
-    int mb_width, mb_height;
-    int nb_components;
-    int component_id[MAX_COMPONENTS];
-    int h_count[MAX_COMPONENTS]; /* horizontal and vertical count for each component */
-    int v_count[MAX_COMPONENTS];
-    int comp_index[MAX_COMPONENTS];
-    int dc_index[MAX_COMPONENTS];
-    int ac_index[MAX_COMPONENTS];
-    int nb_blocks[MAX_COMPONENTS];
-    int h_scount[MAX_COMPONENTS];
-    int v_scount[MAX_COMPONENTS];
-    int h_max, v_max; /* maximum h and v counts */
-    int quant_index[4];   /* quant table index for each component */
-    int last_dc[MAX_COMPONENTS]; /* last DEQUANTIZED dc (XXX: am I right to do that ?) */
-    AVFrame picture; /* picture structure */
-    int linesize[MAX_COMPONENTS];                   ///< linesize << interlaced
-    int8_t *qscale_table;
-    DCTELEM block[64] __align8;
-    ScanTable scantable;
-    void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
-
-    int restart_interval;
-    int restart_count;
-
-    int buggy_avid;
-    int cs_itu601;
-    int interlace_polarity;
-
-    int mjpb_skiptosod;
-} MJpegDecodeContext;
-
-static int mjpeg_decode_dht(MJpegDecodeContext *s);
-
-static int build_vlc(VLC *vlc, const uint8_t *bits_table, const uint8_t *val_table, 
-                      int nb_codes, int use_static)
-{
-    uint8_t huff_size[256];
-    uint16_t huff_code[256];
-
-    memset(huff_size, 0, sizeof(huff_size));
-    build_huffman_codes(huff_size, huff_code, bits_table, val_table);
-    
-    return init_vlc(vlc, 9, nb_codes, huff_size, 1, 1, huff_code, 2, 2, use_static);
-}
-
-static int mjpeg_decode_init(AVCodecContext *avctx)
-{
-    MJpegDecodeContext *s = avctx->priv_data;
-    MpegEncContext s2;
-    memset(s, 0, sizeof(MJpegDecodeContext));
-
-    s->avctx = avctx;
-
-    /* ugly way to get the idct & scantable FIXME */
-    memset(&s2, 0, sizeof(MpegEncContext));
-    s2.avctx= avctx;
-//    s2->out_format = FMT_MJPEG;
-    dsputil_init(&s2.dsp, avctx);
-    DCT_common_init(&s2);
-
-    s->scantable= s2.intra_scantable;
-    s->idct_put= s2.dsp.idct_put;
-
-    s->mpeg_enc_ctx_allocated = 0;
-    s->buffer_size = 0;
-    s->buffer = NULL;
-    s->start_code = -1;
-    s->first_picture = 1;
-    s->org_height = avctx->coded_height;
-    
-    build_vlc(&s->vlcs[0][0], bits_dc_luminance, val_dc_luminance, 12, 0);
-    build_vlc(&s->vlcs[0][1], bits_dc_chrominance, val_dc_chrominance, 12, 0);
-    build_vlc(&s->vlcs[1][0], bits_ac_luminance, val_ac_luminance, 251, 0);
-    build_vlc(&s->vlcs[1][1], bits_ac_chrominance, val_ac_chrominance, 251, 0);
-
-    if (avctx->flags & CODEC_FLAG_EXTERN_HUFF)
-    {
-	av_log(avctx, AV_LOG_INFO, "mjpeg: using external huffman table\n");
-	init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8);
-	mjpeg_decode_dht(s);
-	/* should check for error - but dunno */
-    }
-
-    return 0;
-}
-
-
-/**
- * finds the end of the current frame in the bitstream.
- * @return the position of the first byte of the next frame, or -1
- */
-static int find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size){
-    int vop_found, i;
-    uint16_t state;
-    
-    vop_found= pc->frame_start_found;
-    state= pc->state;
-    
-    i=0;
-    if(!vop_found){
-        for(i=0; i<buf_size; i++){
-            state= (state<<8) | buf[i];
-            if(state == 0xFFD8){
-                i++;
-                vop_found=1;
-                break;
-            }
-        }
-    }
-
-    if(vop_found){
-        /* EOF considered as end of frame */
-        if (buf_size == 0)
-            return 0;
-        for(; i<buf_size; i++){
-            state= (state<<8) | buf[i];
-            if(state == 0xFFD8){
-                pc->frame_start_found=0;
-                pc->state=0; 
-                return i-1;
-            }
-        }
-    }
-    pc->frame_start_found= vop_found;
-    pc->state= state;
-    return END_NOT_FOUND;
-}
-
-static int jpeg_parse(AVCodecParserContext *s,
-                           AVCodecContext *avctx,
-                           uint8_t **poutbuf, int *poutbuf_size, 
-                           const uint8_t *buf, int buf_size)
-{
-    ParseContext *pc = s->priv_data;
-    int next;
-    
-    next= find_frame_end(pc, buf, buf_size);
-
-    if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
-        *poutbuf = NULL;
-        *poutbuf_size = 0;
-        return buf_size;
-    }
-
-    *poutbuf = (uint8_t *)buf;
-    *poutbuf_size = buf_size;
-    return next;
-}
-
-/* quantize tables */
-static int mjpeg_decode_dqt(MJpegDecodeContext *s)
-{
-    int len, index, i, j;
-    
-    len = get_bits(&s->gb, 16) - 2;
-
-    while (len >= 65) {
-        /* only 8 bit precision handled */
-        if (get_bits(&s->gb, 4) != 0)
-	{
-	    dprintf("dqt: 16bit precision\n");
-            return -1;
-	}
-        index = get_bits(&s->gb, 4);
-        if (index >= 4)
-            return -1;
-        dprintf("index=%d\n", index);
-        /* read quant table */
-        for(i=0;i<64;i++) {
-            j = s->scantable.permutated[i];
-	    s->quant_matrixes[index][j] = get_bits(&s->gb, 8);
-        }
-
-        //XXX FIXME finetune, and perhaps add dc too
-        s->qscale[index]= FFMAX(
-            s->quant_matrixes[index][s->scantable.permutated[1]],
-            s->quant_matrixes[index][s->scantable.permutated[8]]) >> 1;
-	dprintf("qscale[%d]: %d\n", index, s->qscale[index]);
-        len -= 65;
-    }
-    
-    return 0;
-}
-
-/* decode huffman tables and build VLC decoders */
-static int mjpeg_decode_dht(MJpegDecodeContext *s)
-{
-    int len, index, i, class, n, v, code_max;
-    uint8_t bits_table[17];
-    uint8_t val_table[256];
-    
-    len = get_bits(&s->gb, 16) - 2;
-
-    while (len > 0) {
-        if (len < 17)
-            return -1;
-        class = get_bits(&s->gb, 4);
-        if (class >= 2)
-            return -1;
-        index = get_bits(&s->gb, 4);
-        if (index >= 4)
-            return -1;
-        n = 0;
-        for(i=1;i<=16;i++) {
-            bits_table[i] = get_bits(&s->gb, 8);
-            n += bits_table[i];
-        }
-        len -= 17;
-        if (len < n || n > 256)
-            return -1;
-
-        code_max = 0;
-        for(i=0;i<n;i++) {
-            v = get_bits(&s->gb, 8);
-            if (v > code_max)
-                code_max = v;
-            val_table[i] = v;
-        }
-        len -= n;
-
-        /* build VLC and flush previous vlc if present */
-        free_vlc(&s->vlcs[class][index]);
-        dprintf("class=%d index=%d nb_codes=%d\n",
-               class, index, code_max + 1);
-        if(build_vlc(&s->vlcs[class][index], bits_table, val_table, code_max + 1, 0) < 0){
-            return -1;
-        }
-    }
-    return 0;
-}
-
-static int mjpeg_decode_sof(MJpegDecodeContext *s)
-{
-    int len, nb_components, i, width, height;
-
-    /* XXX: verify len field validity */
-    len = get_bits(&s->gb, 16);
-    s->bits= get_bits(&s->gb, 8);
-    
-    if(s->pegasus_rct) s->bits=9;  
-    if(s->bits==9 && !s->pegasus_rct) s->rct=1;    //FIXME ugly
-
-    if (s->bits != 8 && !s->lossless){
-        av_log(s->avctx, AV_LOG_ERROR, "only 8 bits/component accepted\n");
-        return -1;
-    }
-    height = get_bits(&s->gb, 16);
-    width = get_bits(&s->gb, 16);
-    
-    dprintf("sof0: picture: %dx%d\n", width, height);
-    if(avcodec_check_dimensions(s->avctx, width, height))
-        return -1;
-
-    nb_components = get_bits(&s->gb, 8);
-    if (nb_components <= 0 ||
-        nb_components > MAX_COMPONENTS)
-        return -1;
-    s->nb_components = nb_components;
-    s->h_max = 1;
-    s->v_max = 1;
-    for(i=0;i<nb_components;i++) {
-        /* component id */
-        s->component_id[i] = get_bits(&s->gb, 8) - 1;
-        s->h_count[i] = get_bits(&s->gb, 4);
-        s->v_count[i] = get_bits(&s->gb, 4);
-        /* compute hmax and vmax (only used in interleaved case) */
-        if (s->h_count[i] > s->h_max)
-            s->h_max = s->h_count[i];
-        if (s->v_count[i] > s->v_max)
-            s->v_max = s->v_count[i];
-        s->quant_index[i] = get_bits(&s->gb, 8);
-        if (s->quant_index[i] >= 4)
-            return -1;
-        dprintf("component %d %d:%d id: %d quant:%d\n", i, s->h_count[i],
-	    s->v_count[i], s->component_id[i], s->quant_index[i]);
-    }
-    
-    if(s->v_max==1 && s->h_max==1 && s->lossless==1) s->rgb=1;
-
-    /* if different size, realloc/alloc picture */
-    /* XXX: also check h_count and v_count */
-    if (width != s->width || height != s->height) {
-        av_freep(&s->qscale_table);
-            
-        s->width = width;
-        s->height = height;
-        avcodec_set_dimensions(s->avctx, width, height);
-
-        /* test interlaced mode */
-        if (s->first_picture &&
-            s->org_height != 0 &&
-            s->height < ((s->org_height * 3) / 4)) {
-            s->interlaced = 1;
-//	    s->bottom_field = (s->interlace_polarity) ? 1 : 0;
-            s->bottom_field = 0;
-            s->avctx->height *= 2;
-        }
-
-        s->qscale_table= av_mallocz((s->width+15)/16);
-
-        s->first_picture = 0;
-    }
-    
-    if(s->interlaced && s->bottom_field)
-        return 0;
- 
-    /* XXX: not complete test ! */
-    switch((s->h_count[0] << 4) | s->v_count[0]) {
-    case 0x11:
-        if(s->rgb){
-            s->avctx->pix_fmt = PIX_FMT_RGBA32;
-        }else if(s->nb_components==3)
-            s->avctx->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV444P : PIX_FMT_YUVJ444P;
-        else
-            s->avctx->pix_fmt = PIX_FMT_GRAY8;
-        break;
-    case 0x21:
-        s->avctx->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV422P : PIX_FMT_YUVJ422P;
-        break;
-    default:
-    case 0x22:
-        s->avctx->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV420P : PIX_FMT_YUVJ420P;
-        break;
-    }
-
-    if(s->picture.data[0])
-        s->avctx->release_buffer(s->avctx, &s->picture);
-
-    s->picture.reference= 0;
-    if(s->avctx->get_buffer(s->avctx, &s->picture) < 0){
-        av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
-        return -1;
-    }
-    s->picture.pict_type= I_TYPE;
-    s->picture.key_frame= 1;
-    
-    for(i=0; i<3; i++){
-        s->linesize[i]= s->picture.linesize[i] << s->interlaced;
-    }
-
-//    printf("%d %d %d %d %d %d\n", s->width, s->height, s->linesize[0], s->linesize[1], s->interlaced, s->avctx->height);
-    
-    if (len != (8+(3*nb_components)))
-    {
-	dprintf("decode_sof0: error, len(%d) mismatch\n", len);
-    }
-    
-    return 0;
-}
-
-static inline int mjpeg_decode_dc(MJpegDecodeContext *s, int dc_index)
-{
-    int code;
-    code = get_vlc2(&s->gb, s->vlcs[0][dc_index].table, 9, 2);
-    if (code < 0)
-    {
-	dprintf("mjpeg_decode_dc: bad vlc: %d:%d (%p)\n", 0, dc_index,
-                &s->vlcs[0][dc_index]);
-        return 0xffff;
-    }
-
-    if(code)
-        return get_xbits(&s->gb, code);
-    else
-        return 0;
-}
-
-/* decode block and dequantize */
-static int decode_block(MJpegDecodeContext *s, DCTELEM *block, 
-                        int component, int dc_index, int ac_index, int quant_index)
-{
-    int code, i, j, level, val;
-    VLC *ac_vlc;
-    int16_t *quant_matrix;
-
-    /* DC coef */
-    val = mjpeg_decode_dc(s, dc_index);
-    if (val == 0xffff) {
-        dprintf("error dc\n");
-        return -1;
-    }
-    quant_matrix = s->quant_matrixes[quant_index];
-    val = val * quant_matrix[0] + s->last_dc[component];
-    s->last_dc[component] = val;
-    block[0] = val;
-    /* AC coefs */
-    ac_vlc = &s->vlcs[1][ac_index];
-    i = 1;
-    for(;;) {
-	code = get_vlc2(&s->gb, s->vlcs[1][ac_index].table, 9, 2);
-
-        if (code < 0) {
-            dprintf("error ac\n");
-            return -1;
-        }
-        /* EOB */
-        if (code == 0)
-            break;
-        if (code == 0xf0) {
-            i += 16;
-        } else {
-            level = get_xbits(&s->gb, code & 0xf);
-            i += code >> 4;
-            if (i >= 64) {
-                dprintf("error count: %d\n", i);
-                return -1;
-            }
-            j = s->scantable.permutated[i];
-            block[j] = level * quant_matrix[j];
-            i++;
-            if (i >= 64)
-                break;
-        }
-    }
-    return 0;
-}
-
-static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int predictor, int point_transform){
-    int i, mb_x, mb_y;
-    uint16_t buffer[32768][4];
-    int left[3], top[3], topleft[3];
-    const int linesize= s->linesize[0];
-    const int mask= (1<<s->bits)-1;
-    
-    if((unsigned)s->mb_width > 32768) //dynamic alloc
-        return -1;
-    
-    for(i=0; i<3; i++){
-        buffer[0][i]= 1 << (s->bits + point_transform - 1);
-    }
-    for(mb_y = 0; mb_y < s->mb_height; mb_y++) {
-        const int modified_predictor= mb_y ? predictor : 1;
-        uint8_t *ptr = s->picture.data[0] + (linesize * mb_y);
-
-        if (s->interlaced && s->bottom_field)
-            ptr += linesize >> 1;
-
-        for(i=0; i<3; i++){
-            top[i]= left[i]= topleft[i]= buffer[0][i];
-        }
-        for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
-            if (s->restart_interval && !s->restart_count)
-                s->restart_count = s->restart_interval;
-
-            for(i=0;i<3;i++) {
-                int pred;
-
-                topleft[i]= top[i];
-                top[i]= buffer[mb_x][i];
-
-                PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
-                
-                left[i]= 
-                buffer[mb_x][i]= mask & (pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform));
-            }
-
-            if (s->restart_interval && !--s->restart_count) {
-                align_get_bits(&s->gb);
-                skip_bits(&s->gb, 16); /* skip RSTn */
-            }
-        }
-
-        if(s->rct){
-            for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
-                ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200)>>2);
-                ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
-                ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
-            }
-        }else if(s->pegasus_rct){
-            for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
-                ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2])>>2);
-                ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
-                ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
-            }
-        }else{
-            for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
-                ptr[4*mb_x+0] = buffer[mb_x][0];
-                ptr[4*mb_x+1] = buffer[mb_x][1];
-                ptr[4*mb_x+2] = buffer[mb_x][2];
-            }
-        }
-    }
-    return 0;
-}
-
-static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor, int point_transform){
-    int i, mb_x, mb_y;
-    const int nb_components=3;
-
-    for(mb_y = 0; mb_y < s->mb_height; mb_y++) {
-        for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
-            if (s->restart_interval && !s->restart_count)
-                s->restart_count = s->restart_interval;
-
-            if(mb_x==0 || mb_y==0 || s->interlaced){
-                for(i=0;i<nb_components;i++) {
-                    uint8_t *ptr;
-                    int n, h, v, x, y, c, j, linesize;
-                    n = s->nb_blocks[i];
-                    c = s->comp_index[i];
-                    h = s->h_scount[i];
-                    v = s->v_scount[i];
-                    x = 0;
-                    y = 0;
-                    linesize= s->linesize[c];
-                    
-                    for(j=0; j<n; j++) {
-                        int pred;
-
-                        ptr = s->picture.data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
-                        if(y==0 && mb_y==0){
-                            if(x==0 && mb_x==0){
-                                pred= 128 << point_transform;
-                            }else{
-                                pred= ptr[-1];
-                            }
-                        }else{
-                            if(x==0 && mb_x==0){
-                                pred= ptr[-linesize];
-                            }else{
-                                PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
-                            }
-                        }
-                        
-                        if (s->interlaced && s->bottom_field)
-                            ptr += linesize >> 1;
-                        *ptr= pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform);
-
-                        if (++x == h) {
-                            x = 0;
-                            y++;
-                        }
-                    }
-                }
-            }else{
-                for(i=0;i<nb_components;i++) {
-                    uint8_t *ptr;
-                    int n, h, v, x, y, c, j, linesize;
-                    n = s->nb_blocks[i];
-                    c = s->comp_index[i];
-                    h = s->h_scount[i];
-                    v = s->v_scount[i];
-                    x = 0;
-                    y = 0;
-                    linesize= s->linesize[c];
-                    
-                    for(j=0; j<n; j++) {
-                        int pred;
-
-                        ptr = s->picture.data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
-                        PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
-                        *ptr= pred + (mjpeg_decode_dc(s, s->dc_index[i]) << point_transform);
-                        if (++x == h) {
-                            x = 0;
-                            y++;
-                        }
-                    }
-                }
-            }
-            if (s->restart_interval && !--s->restart_count) {
-                align_get_bits(&s->gb);
-                skip_bits(&s->gb, 16); /* skip RSTn */
-            }
-        }
-    }
-    return 0;
-}
-
-static int mjpeg_decode_scan(MJpegDecodeContext *s){
-    int i, mb_x, mb_y;
-    const int nb_components=3;
-
-    for(mb_y = 0; mb_y < s->mb_height; mb_y++) {
-        for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
-            if (s->restart_interval && !s->restart_count)
-                s->restart_count = s->restart_interval;
-
-            for(i=0;i<nb_components;i++) {
-                uint8_t *ptr;
-                int n, h, v, x, y, c, j;
-                n = s->nb_blocks[i];
-                c = s->comp_index[i];
-                h = s->h_scount[i];
-                v = s->v_scount[i];
-                x = 0;
-                y = 0;
-                for(j=0;j<n;j++) {
-                    memset(s->block, 0, sizeof(s->block));
-                    if (decode_block(s, s->block, i, 
-                                     s->dc_index[i], s->ac_index[i], 
-                                     s->quant_index[c]) < 0) {
-                        dprintf("error y=%d x=%d\n", mb_y, mb_x);
-                        return -1;
-                    }
-//		    dprintf("mb: %d %d processed\n", mb_y, mb_x);
-                    ptr = s->picture.data[c] + 
-                        (((s->linesize[c] * (v * mb_y + y) * 8) + 
-                        (h * mb_x + x) * 8) >> s->avctx->lowres);
-                    if (s->interlaced && s->bottom_field)
-                        ptr += s->linesize[c] >> 1;
-//av_log(NULL, AV_LOG_DEBUG, "%d %d %d %d %d %d %d %d \n", mb_x, mb_y, x, y, c, s->bottom_field, (v * mb_y + y) * 8, (h * mb_x + x) * 8);
-                    s->idct_put(ptr, s->linesize[c], s->block);
-                    if (++x == h) {
-                        x = 0;
-                        y++;
-                    }
-                }
-            }
-            /* (< 1350) buggy workaround for Spectralfan.mov, should be fixed */
-            if (s->restart_interval && (s->restart_interval < 1350) &&
-                !--s->restart_count) {
-                align_get_bits(&s->gb);
-                skip_bits(&s->gb, 16); /* skip RSTn */
-                for (i=0; i<nb_components; i++) /* reset dc */
-                    s->last_dc[i] = 1024;
-            }
-        }
-    }
-    return 0;
-}
-
-static int mjpeg_decode_sos(MJpegDecodeContext *s)
-{
-    int len, nb_components, i, h, v, predictor, point_transform;
-    int vmax, hmax, index, id;
-    const int block_size= s->lossless ? 1 : 8;
-
-    /* XXX: verify len field validity */
-    len = get_bits(&s->gb, 16);
-    nb_components = get_bits(&s->gb, 8);
-    if (len != 6+2*nb_components)
-    {
-	dprintf("decode_sos: invalid len (%d)\n", len);
-	return -1;
-    }
-    /* XXX: only interleaved scan accepted */
-    if (nb_components != s->nb_components)
-    {
-	dprintf("decode_sos: components(%d) mismatch\n", nb_components);
-        return -1;
-    }
-    vmax = 0;
-    hmax = 0;
-    for(i=0;i<nb_components;i++) {
-        id = get_bits(&s->gb, 8) - 1;
-	dprintf("component: %d\n", id);
-        /* find component index */
-        for(index=0;index<s->nb_components;index++)
-            if (id == s->component_id[index])
-                break;
-        if (index == s->nb_components)
-	{
-	    dprintf("decode_sos: index(%d) out of components\n", index);
-            return -1;
-	}
-
-        s->comp_index[i] = index;
-
-        s->nb_blocks[i] = s->h_count[index] * s->v_count[index];
-        s->h_scount[i] = s->h_count[index];
-        s->v_scount[i] = s->v_count[index];
-
-        s->dc_index[i] = get_bits(&s->gb, 4);
-        s->ac_index[i] = get_bits(&s->gb, 4);
-
-	if (s->dc_index[i] <  0 || s->ac_index[i] < 0 ||
-	    s->dc_index[i] >= 4 || s->ac_index[i] >= 4)
-	    goto out_of_range;
-#if 0 //buggy
-	switch(s->start_code)
-	{
-	    case SOF0:
-		if (dc_index[i] > 1 || ac_index[i] > 1)
-		    goto out_of_range;
-		break;
-	    case SOF1:
-	    case SOF2:
-		if (dc_index[i] > 3 || ac_index[i] > 3)
-		    goto out_of_range;
-		break;
-	    case SOF3:
-		if (dc_index[i] > 3 || ac_index[i] != 0)
-		    goto out_of_range;
-		break;	
-	}
-#endif
-    }
-
-    predictor= get_bits(&s->gb, 8); /* lossless predictor or start of spectral (Ss) */
-    skip_bits(&s->gb, 8); /* Se */
-    skip_bits(&s->gb, 4); /* Ah */
-    point_transform= get_bits(&s->gb, 4); /* Al */
-
-    for(i=0;i<nb_components;i++) 
-        s->last_dc[i] = 1024;
-
-    if (nb_components > 1) {
-        /* interleaved stream */
-        s->mb_width  = (s->width  + s->h_max * block_size - 1) / (s->h_max * block_size);
-        s->mb_height = (s->height + s->v_max * block_size - 1) / (s->v_max * block_size);
-    } else {
-        h = s->h_max / s->h_scount[s->comp_index[0]];
-        v = s->v_max / s->v_scount[s->comp_index[0]];
-        s->mb_width  = (s->width  + h * block_size - 1) / (h * block_size);
-        s->mb_height = (s->height + v * block_size - 1) / (v * block_size);
-        s->nb_blocks[0] = 1;
-        s->h_scount[0] = 1;
-        s->v_scount[0] = 1;
-    }
-
-    if(s->avctx->debug & FF_DEBUG_PICT_INFO)
-        av_log(s->avctx, AV_LOG_DEBUG, "%s %s p:%d >>:%d\n", s->lossless ? "lossless" : "sequencial DCT", s->rgb ? "RGB" : "", predictor, point_transform);
-    
-    /* mjpeg-b can have padding bytes between sos and image data, skip them */
-    for (i = s->mjpb_skiptosod; i > 0; i--)
-        skip_bits(&s->gb, 8);
-
-    if(s->lossless){
-            if(s->rgb){
-                if(ljpeg_decode_rgb_scan(s, predictor, point_transform) < 0)
-                    return -1;
-            }else{
-                if(ljpeg_decode_yuv_scan(s, predictor, point_transform) < 0)
-                    return -1;
-            }
-    }else{
-        if(mjpeg_decode_scan(s) < 0)
-            return -1;
-    }
-    emms_c();
-    return 0;
- out_of_range:
-    dprintf("decode_sos: ac/dc index out of range\n");
-    return -1;
-}
-
-static int mjpeg_decode_dri(MJpegDecodeContext *s)
-{
-    if (get_bits(&s->gb, 16) != 4)
-	return -1;
-    s->restart_interval = get_bits(&s->gb, 16);
-    s->restart_count = 0;
-    dprintf("restart interval: %d\n", s->restart_interval);
-
-    return 0;
-}
-
-static int mjpeg_decode_app(MJpegDecodeContext *s)
-{
-    int len, id;
-
-    len = get_bits(&s->gb, 16);
-    if (len < 5)
-	return -1;
-    if(8*len + get_bits_count(&s->gb) > s->gb.size_in_bits)
-        return -1;
-
-    id = (get_bits(&s->gb, 16) << 16) | get_bits(&s->gb, 16);
-    id = be2me_32(id);
-    len -= 6;
-
-    if(s->avctx->debug & FF_DEBUG_STARTCODE){
-        av_log(s->avctx, AV_LOG_DEBUG, "APPx %8X\n", id); 
-    }
-    
-    /* buggy AVID, it puts EOI only at every 10th frame */
-    /* also this fourcc is used by non-avid files too, it holds some
-       informations, but it's always present in AVID creates files */
-    if (id == ff_get_fourcc("AVI1"))
-    {
-	/* structure:
-	    4bytes	AVI1
-	    1bytes	polarity
-	    1bytes	always zero
-	    4bytes	field_size
-	    4bytes	field_size_less_padding
-	*/
-    	s->buggy_avid = 1;
-//	if (s->first_picture)
-//	    printf("mjpeg: workarounding buggy AVID\n");
-	s->interlace_polarity = get_bits(&s->gb, 8);
-#if 0
-	skip_bits(&s->gb, 8);
-	skip_bits(&s->gb, 32);
-	skip_bits(&s->gb, 32);
-	len -= 10;
-#endif
-//	if (s->interlace_polarity)
-//	    printf("mjpeg: interlace polarity: %d\n", s->interlace_polarity);
-	goto out;
-    }
-    
-//    len -= 2;
-    
-    if (id == ff_get_fourcc("JFIF"))
-    {
-	int t_w, t_h, v1, v2;
-	skip_bits(&s->gb, 8); /* the trailing zero-byte */
-	v1= get_bits(&s->gb, 8);
-        v2= get_bits(&s->gb, 8);
-        skip_bits(&s->gb, 8);
-
-        s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 16);
-        s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 16);
-
-        if (s->avctx->debug & FF_DEBUG_PICT_INFO)
-            av_log(s->avctx, AV_LOG_INFO, "mjpeg: JFIF header found (version: %x.%x) SAR=%d/%d\n",
-                v1, v2,
-                s->avctx->sample_aspect_ratio.num,
-                s->avctx->sample_aspect_ratio.den
-            );
-
-	t_w = get_bits(&s->gb, 8);
-	t_h = get_bits(&s->gb, 8);
-	if (t_w && t_h)
-	{
-	    /* skip thumbnail */
-	    if (len-10-(t_w*t_h*3) > 0)
-		len -= t_w*t_h*3;
-	}
-	len -= 10;
-	goto out;
-    }
-    
-    if (id == ff_get_fourcc("Adob") && (get_bits(&s->gb, 8) == 'e'))
-    {
-        if (s->avctx->debug & FF_DEBUG_PICT_INFO)
-            av_log(s->avctx, AV_LOG_INFO, "mjpeg: Adobe header found\n");
-	skip_bits(&s->gb, 16); /* version */
-	skip_bits(&s->gb, 16); /* flags0 */
-	skip_bits(&s->gb, 16); /* flags1 */
-	skip_bits(&s->gb, 8); /* transform */
-	len -= 7;
-	goto out;
-    }
-
-    if (id == ff_get_fourcc("LJIF")){
-        if (s->avctx->debug & FF_DEBUG_PICT_INFO)
-            av_log(s->avctx, AV_LOG_INFO, "Pegasus lossless jpeg header found\n");
-	skip_bits(&s->gb, 16); /* version ? */
-	skip_bits(&s->gb, 16); /* unknwon always 0? */
-	skip_bits(&s->gb, 16); /* unknwon always 0? */
-	skip_bits(&s->gb, 16); /* unknwon always 0? */
-        switch( get_bits(&s->gb, 8)){
-        case 1:
-            s->rgb= 1;
-            s->pegasus_rct=0;
-            break;
-        case 2:
-            s->rgb= 1;
-            s->pegasus_rct=1;
-            break;
-        default:
-            av_log(s->avctx, AV_LOG_ERROR, "unknown colorspace\n");
-        }
-        len -= 9;
-        goto out;
-    }
-    
-    /* Apple MJPEG-A */
-    if ((s->start_code == APP1) && (len > (0x28 - 8)))
-    {
-	id = (get_bits(&s->gb, 16) << 16) | get_bits(&s->gb, 16);
-	id = be2me_32(id);
-	len -= 4;
-	if (id == ff_get_fourcc("mjpg")) /* Apple MJPEG-A */
-	{
-#if 0
-	    skip_bits(&s->gb, 32); /* field size */
-	    skip_bits(&s->gb, 32); /* pad field size */
-	    skip_bits(&s->gb, 32); /* next off */
-	    skip_bits(&s->gb, 32); /* quant off */
-	    skip_bits(&s->gb, 32); /* huff off */
-	    skip_bits(&s->gb, 32); /* image off */
-	    skip_bits(&s->gb, 32); /* scan off */
-	    skip_bits(&s->gb, 32); /* data off */
-#endif
-            if (s->avctx->debug & FF_DEBUG_PICT_INFO)
-		av_log(s->avctx, AV_LOG_INFO, "mjpeg: Apple MJPEG-A header found\n");
-	}
-    }
-
-out:
-    /* slow but needed for extreme adobe jpegs */
-    if (len < 0)
-	av_log(s->avctx, AV_LOG_ERROR, "mjpeg: error, decode_app parser read over the end\n");
-    while(--len > 0)
-	skip_bits(&s->gb, 8);
-
-    return 0;
-}
-
-static int mjpeg_decode_com(MJpegDecodeContext *s)
-{
-    int len = get_bits(&s->gb, 16);
-    if (len >= 2 && 8*len - 16 + get_bits_count(&s->gb) <= s->gb.size_in_bits) {
-	uint8_t *cbuf = av_malloc(len - 1);
-	if (cbuf) {
-	    int i;
-	    for (i = 0; i < len - 2; i++)
-		cbuf[i] = get_bits(&s->gb, 8);
-	    if (i > 0 && cbuf[i-1] == '\n')
-		cbuf[i-1] = 0;
-	    else
-		cbuf[i] = 0;
-
-            if(s->avctx->debug & FF_DEBUG_PICT_INFO)
-                av_log(s->avctx, AV_LOG_INFO, "mjpeg comment: '%s'\n", cbuf);
-
-	    /* buggy avid, it puts EOI only at every 10th frame */
-	    if (!strcmp(cbuf, "AVID"))
-	    {
-		s->buggy_avid = 1;
-		//	if (s->first_picture)
-		//	    printf("mjpeg: workarounding buggy AVID\n");
-	    }
-            else if(!strcmp(cbuf, "CS=ITU601")){
-                s->cs_itu601= 1;
-            }
-
-	    av_free(cbuf);
-	}
-    }
-
-    return 0;
-}
-
-#if 0
-static int valid_marker_list[] =
-{
-        /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f */
-/* 0 */    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-/* 1 */    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-/* 2 */    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-/* 3 */    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-/* 4 */    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-/* 5 */    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-/* 6 */    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-/* 7 */    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-/* 8 */    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-/* 9 */    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-/* a */    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-/* b */    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-/* c */    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-/* d */    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-/* e */    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-/* f */    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
-}
-#endif
-
-/* return the 8 bit start code value and update the search
-   state. Return -1 if no start code found */
-static int find_marker(uint8_t **pbuf_ptr, uint8_t *buf_end)
-{
-    uint8_t *buf_ptr;
-    unsigned int v, v2;
-    int val;
-#ifdef DEBUG
-    int skipped=0;
-#endif
-
-    buf_ptr = *pbuf_ptr;
-    while (buf_ptr < buf_end) {
-        v = *buf_ptr++;
-	v2 = *buf_ptr;
-        if ((v == 0xff) && (v2 >= 0xc0) && (v2 <= 0xfe) && buf_ptr < buf_end) {
-	    val = *buf_ptr++;
-	    goto found;
-        }
-#ifdef DEBUG
-	skipped++;
-#endif
-    }
-    val = -1;
-found:
-#ifdef DEBUG
-    dprintf("find_marker skipped %d bytes\n", skipped);
-#endif
-    *pbuf_ptr = buf_ptr;
-    return val;
-}
-
-static int mjpeg_decode_frame(AVCodecContext *avctx, 
-                              void *data, int *data_size,
-                              uint8_t *buf, int buf_size)
-{
-    MJpegDecodeContext *s = avctx->priv_data;
-    uint8_t *buf_end, *buf_ptr;
-    int start_code;
-    AVFrame *picture = data;
-
-    buf_ptr = buf;
-    buf_end = buf + buf_size;
-    while (buf_ptr < buf_end) {
-        /* find start next marker */
-        start_code = find_marker(&buf_ptr, buf_end);
-	{
-	    /* EOF */
-            if (start_code < 0) {
-		goto the_end;
-            } else {
-                dprintf("marker=%x avail_size_in_buf=%d\n", start_code, buf_end - buf_ptr);
-		
-		if ((buf_end - buf_ptr) > s->buffer_size)
-		{
-		    av_free(s->buffer);
-		    s->buffer_size = buf_end-buf_ptr;
-                    s->buffer = av_malloc(s->buffer_size + FF_INPUT_BUFFER_PADDING_SIZE);
-		    dprintf("buffer too small, expanding to %d bytes\n",
-			s->buffer_size);
-		}
-		
-		/* unescape buffer of SOS */
-		if (start_code == SOS)
-		{
-		    uint8_t *src = buf_ptr;
-		    uint8_t *dst = s->buffer;
-
-		    while (src<buf_end)
-		    {
-			uint8_t x = *(src++);
-
-			*(dst++) = x;
-			if (x == 0xff)
-			{
-                            while(src<buf_end && x == 0xff)
-                                x = *(src++);
-
-			    if (x >= 0xd0 && x <= 0xd7)
-				*(dst++) = x;
-			    else if (x)
-				break;
-			}
-		    }
-		    init_get_bits(&s->gb, s->buffer, (dst - s->buffer)*8);
-		    
-		    dprintf("escaping removed %d bytes\n",
-			(buf_end - buf_ptr) - (dst - s->buffer));
-		}
-		else
-		    init_get_bits(&s->gb, buf_ptr, (buf_end - buf_ptr)*8);
-		
-		s->start_code = start_code;
-                if(s->avctx->debug & FF_DEBUG_STARTCODE){
-                    av_log(s->avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code);
-                }
-
-		/* process markers */
-		if (start_code >= 0xd0 && start_code <= 0xd7) {
-		    dprintf("restart marker: %d\n", start_code&0x0f);
-		    /* APP fields */
-		} else if (start_code >= APP0 && start_code <= APP15) {
-		    mjpeg_decode_app(s);
-		    /* Comment */
-		} else if (start_code == COM){
-		    mjpeg_decode_com(s);
-		}
-
-                switch(start_code) {
-                case SOI:
-		    s->restart_interval = 0;
-		    s->restart_count = 0;
-                    /* nothing to do on SOI */
-                    break;
-                case DQT:
-                    mjpeg_decode_dqt(s);
-                    break;
-                case DHT:
-                    if(mjpeg_decode_dht(s) < 0){
-                        av_log(s->avctx, AV_LOG_ERROR, "huffman table decode error\n");
-                        return -1;
-                    }
-                    break;
-                case SOF0:
-                    s->lossless=0;
-                    if (mjpeg_decode_sof(s) < 0) 
-			return -1;
-                    break;
-                case SOF3:
-                    s->lossless=1;
-                    if (mjpeg_decode_sof(s) < 0) 
-			return -1;
-                    break;
-		case EOI:
-		    if ((s->buggy_avid && !s->interlaced) || s->restart_interval) 
-                        break;
-eoi_parser:
-		    {
-                        if (s->interlaced) {
-                            s->bottom_field ^= 1;
-                            /* if not bottom field, do not output image yet */
-                            if (s->bottom_field)
-                                goto not_the_end;
-                        }
-                        *picture = s->picture;
-                        *data_size = sizeof(AVFrame);
-
-                        if(!s->lossless){
-                            picture->quality= FFMAX(FFMAX(s->qscale[0], s->qscale[1]), s->qscale[2]); 
-                            picture->qstride= 0;
-                            picture->qscale_table= s->qscale_table;
-                            memset(picture->qscale_table, picture->quality, (s->width+15)/16);
-                            if(avctx->debug & FF_DEBUG_QP)
-                                av_log(s->avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality);
-                            picture->quality*= FF_QP2LAMBDA;
-                        }
-                        
-                        goto the_end;
-                    }
-		    break;
-                case SOS:
-                    mjpeg_decode_sos(s);
-		    /* buggy avid puts EOI every 10-20th frame */
-		    /* if restart period is over process EOI */
-		    if ((s->buggy_avid && !s->interlaced) || s->restart_interval)
-			goto eoi_parser;
-                    break;
-		case DRI:
-		    mjpeg_decode_dri(s);
-		    break;
-		case SOF1:
-		case SOF2:
-		case SOF5:
-		case SOF6:
-		case SOF7:
-		case SOF9:
-		case SOF10:
-		case SOF11:
-		case SOF13:
-		case SOF14:
-		case SOF15:
-		case JPG:
-		    av_log(s->avctx, AV_LOG_ERROR, "mjpeg: unsupported coding type (%x)\n", start_code);
-		    break;
-//		default:
-//		    printf("mjpeg: unsupported marker (%x)\n", start_code);
-//		    break;
-                }
-
-not_the_end:
-		/* eof process start code */
-		buf_ptr += (get_bits_count(&s->gb)+7)/8;
-		dprintf("marker parser used %d bytes (%d bits)\n",
-		    (get_bits_count(&s->gb)+7)/8, get_bits_count(&s->gb));
-            }
-        }
-    }
-the_end:
-    dprintf("mjpeg decode frame unused %d bytes\n", buf_end - buf_ptr);
-//    return buf_end - buf_ptr;
-    return buf_ptr - buf;
-}
-
-static int mjpegb_decode_frame(AVCodecContext *avctx, 
-                              void *data, int *data_size,
-                              uint8_t *buf, int buf_size)
-{
-    MJpegDecodeContext *s = avctx->priv_data;
-    uint8_t *buf_end, *buf_ptr;
-    AVFrame *picture = data;
-    GetBitContext hgb; /* for the header */
-    uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs;
-    uint32_t field_size, sod_offs;
-
-    buf_ptr = buf;
-    buf_end = buf + buf_size;
-    
-read_header:
-    /* reset on every SOI */
-    s->restart_interval = 0;
-    s->restart_count = 0;
-    s->mjpb_skiptosod = 0;
-
-    init_get_bits(&hgb, buf_ptr, /*buf_size*/(buf_end - buf_ptr)*8);
-
-    skip_bits(&hgb, 32); /* reserved zeros */
-    
-    if (get_bits_long(&hgb, 32) != be2me_32(ff_get_fourcc("mjpg")))
-    {
-	dprintf("not mjpeg-b (bad fourcc)\n");
-	return 0;
-    }
-
-    field_size = get_bits_long(&hgb, 32); /* field size */
-    dprintf("field size: 0x%x\n", field_size);
-    skip_bits(&hgb, 32); /* padded field size */
-    second_field_offs = get_bits_long(&hgb, 32);
-    dprintf("second field offs: 0x%x\n", second_field_offs);
-    if (second_field_offs)
-	s->interlaced = 1;
-
-    dqt_offs = get_bits_long(&hgb, 32);
-    dprintf("dqt offs: 0x%x\n", dqt_offs);
-    if (dqt_offs)
-    {
-	init_get_bits(&s->gb, buf+dqt_offs, (buf_end - (buf+dqt_offs))*8);
-	s->start_code = DQT;
-	mjpeg_decode_dqt(s);
-    }
-    
-    dht_offs = get_bits_long(&hgb, 32);
-    dprintf("dht offs: 0x%x\n", dht_offs);
-    if (dht_offs)
-    {
-	init_get_bits(&s->gb, buf+dht_offs, (buf_end - (buf+dht_offs))*8);
-	s->start_code = DHT;
-	mjpeg_decode_dht(s);
-    }
-
-    sof_offs = get_bits_long(&hgb, 32);
-    dprintf("sof offs: 0x%x\n", sof_offs);
-    if (sof_offs)
-    {
-	init_get_bits(&s->gb, buf+sof_offs, (buf_end - (buf+sof_offs))*8);
-	s->start_code = SOF0;
-	if (mjpeg_decode_sof(s) < 0)
-	    return -1;
-    }
-
-    sos_offs = get_bits_long(&hgb, 32);
-    dprintf("sos offs: 0x%x\n", sos_offs);
-    sod_offs = get_bits_long(&hgb, 32);
-    dprintf("sod offs: 0x%x\n", sod_offs);
-    if (sos_offs)
-    {
-//	init_get_bits(&s->gb, buf+sos_offs, (buf_end - (buf+sos_offs))*8);
-	init_get_bits(&s->gb, buf+sos_offs, field_size*8);
-	s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16));
-	s->start_code = SOS;
-	mjpeg_decode_sos(s);
-    }
-
-    if (s->interlaced) {
-        s->bottom_field ^= 1;
-        /* if not bottom field, do not output image yet */
-        if (s->bottom_field && second_field_offs)
-	{
-	    buf_ptr = buf + second_field_offs;
-	    second_field_offs = 0;
-	    goto read_header;
-    	}
-    }
-
-    //XXX FIXME factorize, this looks very similar to the EOI code
-
-    *picture= s->picture;
-    *data_size = sizeof(AVFrame);
-    
-    if(!s->lossless){
-        picture->quality= FFMAX(FFMAX(s->qscale[0], s->qscale[1]), s->qscale[2]); 
-        picture->qstride= 0;
-        picture->qscale_table= s->qscale_table;
-        memset(picture->qscale_table, picture->quality, (s->width+15)/16);
-        if(avctx->debug & FF_DEBUG_QP)
-            av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality);
-        picture->quality*= FF_QP2LAMBDA;
-    }
-
-    return buf_ptr - buf;
-}
-
-#include "sp5x.h"
-
-static int sp5x_decode_frame(AVCodecContext *avctx, 
-                              void *data, int *data_size,
-                              uint8_t *buf, int buf_size)
-{
-#if 0
-    MJpegDecodeContext *s = avctx->priv_data;
-#endif
-    const int qscale = 5;
-    uint8_t *buf_ptr, *buf_end, *recoded;
-    int i = 0, j = 0;
-
-    if (!avctx->width || !avctx->height)
-	return -1;
-
-    buf_ptr = buf;
-    buf_end = buf + buf_size;
-
-#if 1
-    recoded = av_mallocz(buf_size + 1024);
-    if (!recoded)
-	return -1;
-
-    /* SOI */
-    recoded[j++] = 0xFF;
-    recoded[j++] = 0xD8;
-
-    memcpy(recoded+j, &sp5x_data_dqt[0], sizeof(sp5x_data_dqt));
-    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));
-    j += sizeof(sp5x_data_dht);
-
-    memcpy(recoded+j, &sp5x_data_sof[0], sizeof(sp5x_data_sof));
-    recoded[j+5] = (avctx->coded_height >> 8) & 0xFF;
-    recoded[j+6] = avctx->coded_height & 0xFF;
-    recoded[j+7] = (avctx->coded_width >> 8) & 0xFF;
-    recoded[j+8] = avctx->coded_width & 0xFF;
-    j += sizeof(sp5x_data_sof);
-
-    memcpy(recoded+j, &sp5x_data_sos[0], sizeof(sp5x_data_sos));
-    j += sizeof(sp5x_data_sos);
-
-    for (i = 14; i < buf_size && j < buf_size+1024-2; i++)
-    {
-	recoded[j++] = buf[i];
-	if (buf[i] == 0xff)
-	    recoded[j++] = 0;
-    }
-
-    /* EOI */
-    recoded[j++] = 0xFF;
-    recoded[j++] = 0xD9;
-
-    i = mjpeg_decode_frame(avctx, data, data_size, recoded, j);
-
-    av_free(recoded);
-
-#else
-    /* SOF */
-    s->bits = 8;
-    s->width  = avctx->coded_width;
-    s->height = avctx->coded_height;
-    s->nb_components = 3;
-    s->component_id[0] = 0;
-    s->h_count[0] = 2;
-    s->v_count[0] = 2;
-    s->quant_index[0] = 0;
-    s->component_id[1] = 1;
-    s->h_count[1] = 1;
-    s->v_count[1] = 1;
-    s->quant_index[1] = 1;
-    s->component_id[2] = 2;
-    s->h_count[2] = 1;
-    s->v_count[2] = 1;
-    s->quant_index[2] = 1;
-    s->h_max = 2;
-    s->v_max = 2;
-    
-    s->qscale_table = av_mallocz((s->width+15)/16);
-    avctx->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV420P : PIX_FMT_YUVJ420;
-    s->interlaced = 0;
-    
-    s->picture.reference = 0;
-    if (avctx->get_buffer(avctx, &s->picture) < 0)
-    {
-        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
-	return -1;
-    }
-
-    s->picture.pict_type = I_TYPE;
-    s->picture.key_frame = 1;
-
-    for (i = 0; i < 3; i++)
-	s->linesize[i] = s->picture.linesize[i] << s->interlaced;
-
-    /* DQT */
-    for (i = 0; i < 64; i++)
-    {
-	j = s->scantable.permutated[i];
-	s->quant_matrixes[0][j] = sp5x_quant_table[(qscale * 2) + i];
-    }
-    s->qscale[0] = FFMAX(
-	s->quant_matrixes[0][s->scantable.permutated[1]],
-	s->quant_matrixes[0][s->scantable.permutated[8]]) >> 1;
-
-    for (i = 0; i < 64; i++)
-    {
-	j = s->scantable.permutated[i];
-	s->quant_matrixes[1][j] = sp5x_quant_table[(qscale * 2) + 1 + i];
-    }
-    s->qscale[1] = FFMAX(
-	s->quant_matrixes[1][s->scantable.permutated[1]],
-	s->quant_matrixes[1][s->scantable.permutated[8]]) >> 1;
-
-    /* DHT */
-
-    /* SOS */
-    s->comp_index[0] = 0;
-    s->nb_blocks[0] = s->h_count[0] * s->v_count[0];
-    s->h_scount[0] = s->h_count[0];
-    s->v_scount[0] = s->v_count[0];
-    s->dc_index[0] = 0;
-    s->ac_index[0] = 0;
-
-    s->comp_index[1] = 1;
-    s->nb_blocks[1] = s->h_count[1] * s->v_count[1];
-    s->h_scount[1] = s->h_count[1];
-    s->v_scount[1] = s->v_count[1];
-    s->dc_index[1] = 1;
-    s->ac_index[1] = 1;
-
-    s->comp_index[2] = 2;
-    s->nb_blocks[2] = s->h_count[2] * s->v_count[2];
-    s->h_scount[2] = s->h_count[2];
-    s->v_scount[2] = s->v_count[2];
-    s->dc_index[2] = 1;
-    s->ac_index[2] = 1;
-    
-    for (i = 0; i < 3; i++)
-	s->last_dc[i] = 1024;
-
-    s->mb_width = (s->width * s->h_max * 8 -1) / (s->h_max * 8);
-    s->mb_height = (s->height * s->v_max * 8 -1) / (s->v_max * 8);
-
-    init_get_bits(&s->gb, buf+14, (buf_size-14)*8);
-    
-    return mjpeg_decode_scan(s);
-#endif
-
-    return i;
-}
-
-static int mjpeg_decode_end(AVCodecContext *avctx)
-{
-    MJpegDecodeContext *s = avctx->priv_data;
-    int i, j;
-
-    av_free(s->buffer);
-    av_free(s->qscale_table);
-    
-    for(i=0;i<2;i++) {
-        for(j=0;j<4;j++)
-            free_vlc(&s->vlcs[i][j]);
-    }
-    return 0;
-}
-
-AVCodec mjpeg_decoder = {
-    "mjpeg",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MJPEG,
-    sizeof(MJpegDecodeContext),
-    mjpeg_decode_init,
-    NULL,
-    mjpeg_decode_end,
-    mjpeg_decode_frame,
-    CODEC_CAP_DR1,
-    NULL
-};
-
-AVCodec mjpegb_decoder = {
-    "mjpegb",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MJPEGB,
-    sizeof(MJpegDecodeContext),
-    mjpeg_decode_init,
-    NULL,
-    mjpeg_decode_end,
-    mjpegb_decode_frame,
-    CODEC_CAP_DR1,
-    NULL
-};
-
-AVCodec sp5x_decoder = {
-    "sp5x",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_SP5X,
-    sizeof(MJpegDecodeContext),
-    mjpeg_decode_init,
-    NULL,
-    mjpeg_decode_end,
-    sp5x_decode_frame,
-    CODEC_CAP_DR1,
-    NULL
-};
-
-#ifdef CONFIG_ENCODERS
-AVCodec ljpeg_encoder = { //FIXME avoid MPV_* lossless jpeg shouldnt need them
-    "ljpeg",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_LJPEG,
-    sizeof(MpegEncContext),
-    MPV_encode_init,
-    encode_picture_lossless,
-    MPV_encode_end,
-};
-#endif
-
-AVCodecParser mjpeg_parser = {
-    { CODEC_ID_MJPEG },
-    sizeof(ParseContext),
-    NULL,
-    jpeg_parse,
-    ff_parse_close,
-};
-
diff --git a/ffmpeg.src/libavcodec/mlib/dsputil_mlib.c b/ffmpeg.src/libavcodec/mlib/dsputil_mlib.c
deleted file mode 100644
index 52a01b3..0000000
--- a/ffmpeg.src/libavcodec/mlib/dsputil_mlib.c
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- * Sun mediaLib optimized DSP utils
- * Copyright (c) 2001 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "../dsputil.h"
-#include "../mpegvideo.h"
-
-#include <mlib_types.h>
-#include <mlib_status.h>
-#include <mlib_sys.h>
-#include <mlib_algebra.h>
-#include <mlib_video.h>
-
-/* misc */
-
-static void get_pixels_mlib(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
-{
-  int i;
-
-  for (i=0;i<8;i++) {
-    mlib_VectorConvert_S16_U8_Mod((mlib_s16 *)block, (mlib_u8 *)pixels, 8);
-
-    pixels += line_size;
-    block += 8;
-  }
-}
-
-static void diff_pixels_mlib(DCTELEM *restrict block, const uint8_t *s1, const uint8_t *s2, int line_size)
-{
-  int i;
-
-  for (i=0;i<8;i++) {
-    mlib_VectorSub_S16_U8_Mod((mlib_s16 *)block, (mlib_u8 *)s1, (mlib_u8 *)s2, 8);
-
-    s1 += line_size;
-    s2 += line_size;
-    block += 8;
-  }
-}
-
-static void add_pixels_clamped_mlib(const DCTELEM *block, uint8_t *pixels, int line_size)
-{
-    mlib_VideoAddBlock_U8_S16(pixels, (mlib_s16 *)block, line_size);
-}
-
-/* put block, width 16 pixel, height 8/16 */
-
-static void put_pixels16_mlib (uint8_t * dest, const uint8_t * ref,
-			       int stride, int height)
-{
-  switch (height) {
-    case 8:
-      mlib_VideoCopyRef_U8_U8_16x8(dest, (uint8_t *)ref, stride);
-    break;
-
-    case 16:
-      mlib_VideoCopyRef_U8_U8_16x16(dest, (uint8_t *)ref, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-static void put_pixels16_x2_mlib (uint8_t * dest, const uint8_t * ref,
-				  int stride, int height)
-{
-  switch (height) {
-    case 8:
-      mlib_VideoInterpX_U8_U8_16x8(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 16:
-      mlib_VideoInterpX_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-static void put_pixels16_y2_mlib (uint8_t * dest, const uint8_t * ref,
-				  int stride, int height)
-{
-  switch (height) {
-    case 8:
-      mlib_VideoInterpY_U8_U8_16x8(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 16:
-      mlib_VideoInterpY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-static void put_pixels16_xy2_mlib(uint8_t * dest, const uint8_t * ref,
-				  int stride, int height)
-{
-  switch (height) {
-    case 8:
-      mlib_VideoInterpXY_U8_U8_16x8(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 16:
-      mlib_VideoInterpXY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-/* put block, width 8 pixel, height 4/8/16 */
-
-static void put_pixels8_mlib (uint8_t * dest, const uint8_t * ref,
-			       int stride, int height)
-{
-  switch (height) {
-    case 4:
-      mlib_VideoCopyRef_U8_U8_8x4(dest, (uint8_t *)ref, stride);
-    break;
-
-    case 8:
-      mlib_VideoCopyRef_U8_U8_8x8(dest, (uint8_t *)ref, stride);
-    break;
-
-    case 16:
-      mlib_VideoCopyRef_U8_U8_8x16(dest, (uint8_t *)ref, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-static void put_pixels8_x2_mlib (uint8_t * dest, const uint8_t * ref,
-				  int stride, int height)
-{
-  switch (height) {
-    case 4:
-      mlib_VideoInterpX_U8_U8_8x4(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 8:
-      mlib_VideoInterpX_U8_U8_8x8(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 16:
-      mlib_VideoInterpX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-static void put_pixels8_y2_mlib (uint8_t * dest, const uint8_t * ref,
-				  int stride, int height)
-{
-  switch (height) {
-    case 4:
-      mlib_VideoInterpY_U8_U8_8x4(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 8:
-      mlib_VideoInterpY_U8_U8_8x8(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 16:
-      mlib_VideoInterpY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-static void put_pixels8_xy2_mlib(uint8_t * dest, const uint8_t * ref,
-				  int stride, int height)
-{
-  switch (height) {
-    case 4:
-      mlib_VideoInterpXY_U8_U8_8x4(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 8:
-      mlib_VideoInterpXY_U8_U8_8x8(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 16:
-      mlib_VideoInterpXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-/* average block, width 16 pixel, height 8/16 */
-
-static void avg_pixels16_mlib (uint8_t * dest, const uint8_t * ref,
-			       int stride, int height)
-{
-  switch (height) {
-    case 8:
-      mlib_VideoCopyRefAve_U8_U8_16x8(dest, (uint8_t *)ref, stride);
-    break;
-
-    case 16:
-      mlib_VideoCopyRefAve_U8_U8_16x16(dest, (uint8_t *)ref, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-static void avg_pixels16_x2_mlib (uint8_t * dest, const uint8_t * ref,
-				  int stride, int height)
-{
-  switch (height) {
-    case 8:
-      mlib_VideoInterpAveX_U8_U8_16x8(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 16:
-      mlib_VideoInterpAveX_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-static void avg_pixels16_y2_mlib (uint8_t * dest, const uint8_t * ref,
-				  int stride, int height)
-{
-  switch (height) {
-    case 8:
-      mlib_VideoInterpAveY_U8_U8_16x8(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 16:
-      mlib_VideoInterpAveY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-static void avg_pixels16_xy2_mlib(uint8_t * dest, const uint8_t * ref,
-				  int stride, int height)
-{
-  switch (height) {
-    case 8:
-      mlib_VideoInterpAveXY_U8_U8_16x8(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 16:
-      mlib_VideoInterpAveXY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-/* average block, width 8 pixel, height 4/8/16 */
-
-static void avg_pixels8_mlib (uint8_t * dest, const uint8_t * ref,
-			       int stride, int height)
-{
-  switch (height) {
-    case 4:
-      mlib_VideoCopyRefAve_U8_U8_8x4(dest, (uint8_t *)ref, stride);
-    break;
-
-    case 8:
-      mlib_VideoCopyRefAve_U8_U8_8x8(dest, (uint8_t *)ref, stride);
-    break;
-
-    case 16:
-      mlib_VideoCopyRefAve_U8_U8_8x16(dest, (uint8_t *)ref, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-static void avg_pixels8_x2_mlib (uint8_t * dest, const uint8_t * ref,
-				  int stride, int height)
-{
-  switch (height) {
-    case 4:
-      mlib_VideoInterpAveX_U8_U8_8x4(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 8:
-      mlib_VideoInterpAveX_U8_U8_8x8(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 16:
-      mlib_VideoInterpAveX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-static void avg_pixels8_y2_mlib (uint8_t * dest, const uint8_t * ref,
-				  int stride, int height)
-{
-  switch (height) {
-    case 4:
-      mlib_VideoInterpAveY_U8_U8_8x4(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 8:
-      mlib_VideoInterpAveY_U8_U8_8x8(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 16:
-      mlib_VideoInterpAveY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-static void avg_pixels8_xy2_mlib(uint8_t * dest, const uint8_t * ref,
-				  int stride, int height)
-{
-  switch (height) {
-    case 4:
-      mlib_VideoInterpAveXY_U8_U8_8x4(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 8:
-      mlib_VideoInterpAveXY_U8_U8_8x8(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    case 16:
-      mlib_VideoInterpAveXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
-    break;
-
-    default:
-      assert(0);
-  }
-}
-
-/* swap byte order of a buffer */
-
-static void bswap_buf_mlib(uint32_t *dst, uint32_t *src, int w)
-{
-  mlib_VectorReverseByteOrder_U32_U32(dst, src, w);
-}
-
-/* transformations */
-
-static void ff_idct_put_mlib(uint8_t *dest, int line_size, DCTELEM *data)
-{
-    int i;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-    mlib_VideoIDCT8x8_S16_S16 (data, data);
-    
-    for(i=0;i<8;i++) {
-        dest[0] = cm[data[0]];
-        dest[1] = cm[data[1]];
-        dest[2] = cm[data[2]];
-        dest[3] = cm[data[3]];
-        dest[4] = cm[data[4]];
-        dest[5] = cm[data[5]];
-        dest[6] = cm[data[6]];
-        dest[7] = cm[data[7]];
-
-        dest += line_size;
-        data += 8;
-    }
-}
-
-static void ff_idct_add_mlib(uint8_t *dest, int line_size, DCTELEM *data)
-{
-    mlib_VideoIDCT8x8_S16_S16 (data, data);
-    mlib_VideoAddBlock_U8_S16(dest, (mlib_s16 *)data, line_size);
-}
-
-static void ff_idct_mlib(DCTELEM *data)
-{
-    mlib_VideoIDCT8x8_S16_S16 (data, data);
-}
-
-static void ff_fdct_mlib(DCTELEM *data)
-{
-    mlib_VideoDCT8x8_S16_S16 (data, data);
-}
-
-void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx)
-{
-    c->get_pixels  = get_pixels_mlib;
-    c->diff_pixels = diff_pixels_mlib;
-    c->add_pixels_clamped = add_pixels_clamped_mlib;
-
-    c->put_pixels_tab[0][0] = put_pixels16_mlib;
-    c->put_pixels_tab[0][1] = put_pixels16_x2_mlib;
-    c->put_pixels_tab[0][2] = put_pixels16_y2_mlib;
-    c->put_pixels_tab[0][3] = put_pixels16_xy2_mlib;
-    c->put_pixels_tab[1][0] = put_pixels8_mlib;
-    c->put_pixels_tab[1][1] = put_pixels8_x2_mlib;
-    c->put_pixels_tab[1][2] = put_pixels8_y2_mlib;
-    c->put_pixels_tab[1][3] = put_pixels8_xy2_mlib;
-
-    c->avg_pixels_tab[0][0] = avg_pixels16_mlib;
-    c->avg_pixels_tab[0][1] = avg_pixels16_x2_mlib;
-    c->avg_pixels_tab[0][2] = avg_pixels16_y2_mlib;
-    c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mlib;
-    c->avg_pixels_tab[1][0] = avg_pixels8_mlib;
-    c->avg_pixels_tab[1][1] = avg_pixels8_x2_mlib;
-    c->avg_pixels_tab[1][2] = avg_pixels8_y2_mlib;
-    c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mlib;
-
-    c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mlib;
-    c->put_no_rnd_pixels_tab[1][0] = put_pixels8_mlib;
-
-    c->bswap_buf = bswap_buf_mlib;
-}
-
-void MPV_common_init_mlib(MpegEncContext *s)
-{
-    if(s->avctx->dct_algo==FF_DCT_AUTO || s->avctx->dct_algo==FF_DCT_MLIB){
-	s->dsp.fdct = ff_fdct_mlib;
-    }
-
-    if(s->avctx->idct_algo==FF_IDCT_AUTO || s->avctx->idct_algo==FF_IDCT_MLIB){
-        s->dsp.idct_put= ff_idct_put_mlib;
-        s->dsp.idct_add= ff_idct_add_mlib;
-        s->dsp.idct    = ff_idct_mlib;
-        s->dsp.idct_permutation_type= FF_NO_IDCT_PERM;
-    }
-}
diff --git a/ffmpeg.src/libavcodec/motion_est.c b/ffmpeg.src/libavcodec/motion_est.c
deleted file mode 100644
index 3426d34..0000000
--- a/ffmpeg.src/libavcodec/motion_est.c
+++ /dev/null
@@ -1,2040 +0,0 @@
-/*
- * Motion estimation 
- * Copyright (c) 2000,2001 Fabrice Bellard.
- * Copyright (c) 2002-2004 Michael Niedermayer
- * 
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * new Motion Estimation (X1/EPZS) by Michael Niedermayer <michaelni at gmx.at>
- */
- 
-/**
- * @file motion_est.c
- * Motion estimation.
- */
- 
-#include <stdlib.h>
-#include <stdio.h>
-#include <limits.h>
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-
-#undef NDEBUG
-#include <assert.h>
-
-#define SQ(a) ((a)*(a))
-
-#define P_LEFT P[1]
-#define P_TOP P[2]
-#define P_TOPRIGHT P[3]
-#define P_MEDIAN P[4]
-#define P_MV1 P[9]
-
-static inline int sad_hpel_motion_search(MpegEncContext * s,
-				  int *mx_ptr, int *my_ptr, int dmin,
-                                  int src_index, int ref_index,
-                                  int size, int h);
-
-static inline int update_map_generation(MotionEstContext *c)
-{
-    c->map_generation+= 1<<(ME_MAP_MV_BITS*2);
-    if(c->map_generation==0){
-        c->map_generation= 1<<(ME_MAP_MV_BITS*2);
-        memset(c->map, 0, sizeof(uint32_t)*ME_MAP_SIZE);
-    }
-    return c->map_generation;
-}
-
-/* shape adaptive search stuff */
-typedef struct Minima{
-    int height;
-    int x, y;
-    int checked;
-}Minima;
-
-static int minima_cmp(const void *a, const void *b){
-    const Minima *da = (const Minima *) a;
-    const Minima *db = (const Minima *) b;
-    
-    return da->height - db->height;
-}
-
-#define FLAG_QPEL   1 //must be 1
-#define FLAG_CHROMA 2
-#define FLAG_DIRECT 4
-
-static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){
-    const int offset[3]= {
-          y*c->  stride + x,
-        ((y*c->uvstride + x)>>1),
-        ((y*c->uvstride + x)>>1),
-    };
-    int i;
-    for(i=0; i<3; i++){
-        c->src[0][i]= src [i] + offset[i];
-        c->ref[0][i]= ref [i] + offset[i];
-    }
-    if(ref_index){
-        for(i=0; i<3; i++){
-            c->ref[ref_index][i]= ref2[i] + offset[i];
-        }
-    }
-}
-
-static int get_flags(MotionEstContext *c, int direct, int chroma){
-    return   ((c->avctx->flags&CODEC_FLAG_QPEL) ? FLAG_QPEL : 0)
-           + (direct ? FLAG_DIRECT : 0) 
-           + (chroma ? FLAG_CHROMA : 0);
-}
-
-static always_inline int cmp(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
-                      const int size, const int h, int ref_index, int src_index,
-                      me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){
-    MotionEstContext * const c= &s->me;
-    const int stride= c->stride;
-    const int uvstride= c->uvstride;
-    const int qpel= flags&FLAG_QPEL;
-    const int chroma= flags&FLAG_CHROMA;
-    const int dxy= subx + (suby<<(1+qpel)); //FIXME log2_subpel?
-    const int hx= subx + (x<<(1+qpel));
-    const int hy= suby + (y<<(1+qpel));
-    uint8_t * const * const ref= c->ref[ref_index];
-    uint8_t * const * const src= c->src[src_index];
-    int d;
-    //FIXME check chroma 4mv, (no crashes ...)
-    if(flags&FLAG_DIRECT){
-        if(x >= c->xmin && hx <= c->xmax<<(qpel+1) && y >= c->ymin && hy <= c->ymax<<(qpel+1)){
-            const int time_pp= s->pp_time;
-            const int time_pb= s->pb_time;
-            const int mask= 2*qpel+1;
-            if(s->mv_type==MV_TYPE_8X8){
-                int i;
-                for(i=0; i<4; i++){
-                    int fx = c->direct_basis_mv[i][0] + hx;
-                    int fy = c->direct_basis_mv[i][1] + hy;
-                    int bx = hx ? fx - c->co_located_mv[i][0] : c->co_located_mv[i][0]*(time_pb - time_pp)/time_pp + ((i &1)<<(qpel+4));
-                    int by = hy ? fy - c->co_located_mv[i][1] : c->co_located_mv[i][1]*(time_pb - time_pp)/time_pp + ((i>>1)<<(qpel+4));
-                    int fxy= (fx&mask) + ((fy&mask)<<(qpel+1));
-                    int bxy= (bx&mask) + ((by&mask)<<(qpel+1));
-        
-                    uint8_t *dst= c->temp + 8*(i&1) + 8*stride*(i>>1);
-                    if(qpel){
-                        c->qpel_put[1][fxy](dst, ref[0] + (fx>>2) + (fy>>2)*stride, stride);
-                        c->qpel_avg[1][bxy](dst, ref[8] + (bx>>2) + (by>>2)*stride, stride);
-                    }else{
-                        c->hpel_put[1][fxy](dst, ref[0] + (fx>>1) + (fy>>1)*stride, stride, 8);
-                        c->hpel_avg[1][bxy](dst, ref[8] + (bx>>1) + (by>>1)*stride, stride, 8);
-                    }
-                }
-            }else{
-                int fx = c->direct_basis_mv[0][0] + hx;
-                int fy = c->direct_basis_mv[0][1] + hy;
-                int bx = hx ? fx - c->co_located_mv[0][0] : (c->co_located_mv[0][0]*(time_pb - time_pp)/time_pp);
-                int by = hy ? fy - c->co_located_mv[0][1] : (c->co_located_mv[0][1]*(time_pb - time_pp)/time_pp);
-                int fxy= (fx&mask) + ((fy&mask)<<(qpel+1));
-                int bxy= (bx&mask) + ((by&mask)<<(qpel+1));
-                
-                if(qpel){
-                    c->qpel_put[1][fxy](c->temp               , ref[0] + (fx>>2) + (fy>>2)*stride               , stride);
-                    c->qpel_put[1][fxy](c->temp + 8           , ref[0] + (fx>>2) + (fy>>2)*stride + 8           , stride);
-                    c->qpel_put[1][fxy](c->temp     + 8*stride, ref[0] + (fx>>2) + (fy>>2)*stride     + 8*stride, stride);
-                    c->qpel_put[1][fxy](c->temp + 8 + 8*stride, ref[0] + (fx>>2) + (fy>>2)*stride + 8 + 8*stride, stride);
-                    c->qpel_avg[1][bxy](c->temp               , ref[8] + (bx>>2) + (by>>2)*stride               , stride);
-                    c->qpel_avg[1][bxy](c->temp + 8           , ref[8] + (bx>>2) + (by>>2)*stride + 8           , stride);
-                    c->qpel_avg[1][bxy](c->temp     + 8*stride, ref[8] + (bx>>2) + (by>>2)*stride     + 8*stride, stride);
-                    c->qpel_avg[1][bxy](c->temp + 8 + 8*stride, ref[8] + (bx>>2) + (by>>2)*stride + 8 + 8*stride, stride);
-                }else{            
-                    assert((fx>>1) + 16*s->mb_x >= -16);
-                    assert((fy>>1) + 16*s->mb_y >= -16);
-                    assert((fx>>1) + 16*s->mb_x <= s->width);
-                    assert((fy>>1) + 16*s->mb_y <= s->height);
-                    assert((bx>>1) + 16*s->mb_x >= -16);
-                    assert((by>>1) + 16*s->mb_y >= -16);
-                    assert((bx>>1) + 16*s->mb_x <= s->width);
-                    assert((by>>1) + 16*s->mb_y <= s->height);
-
-                    c->hpel_put[0][fxy](c->temp, ref[0] + (fx>>1) + (fy>>1)*stride, stride, 16);
-                    c->hpel_avg[0][bxy](c->temp, ref[8] + (bx>>1) + (by>>1)*stride, stride, 16);
-                }
-            }
-            d = cmp_func(s, c->temp, src[0], stride, 16);
-        }else
-            d= 256*256*256*32;
-    }else{
-        int uvdxy;              /* no, it might not be used uninitialized */
-        if(dxy){
-            if(qpel){
-                c->qpel_put[size][dxy](c->temp, ref[0] + x + y*stride, stride); //FIXME prototype (add h)
-                if(chroma){
-                    int cx= hx/2;
-                    int cy= hy/2;
-                    cx= (cx>>1)|(cx&1);
-                    cy= (cy>>1)|(cy&1);
-                    uvdxy= (cx&1) + 2*(cy&1);
-                    //FIXME x/y wrong, but mpeg4 qpel is sick anyway, we should drop as much of it as possible in favor for h264
-                }
-            }else{
-                c->hpel_put[size][dxy](c->temp, ref[0] + x + y*stride, stride, h);
-                if(chroma)
-                    uvdxy= dxy | (x&1) | (2*(y&1));
-            }
-            d = cmp_func(s, c->temp, src[0], stride, h); 
-        }else{
-            d = cmp_func(s, src[0], ref[0] + x + y*stride, stride, h); 
-            if(chroma)
-                uvdxy= (x&1) + 2*(y&1);
-        }
-        if(chroma){
-            uint8_t * const uvtemp= c->temp + 16*stride;
-            c->hpel_put[size+1][uvdxy](uvtemp  , ref[1] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1);
-            c->hpel_put[size+1][uvdxy](uvtemp+8, ref[2] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1);
-            d += chroma_cmp_func(s, uvtemp  , src[1], uvstride, h>>1); 
-            d += chroma_cmp_func(s, uvtemp+8, src[2], uvstride, h>>1); 
-        }
-    }
-#if 0
-    if(full_pel){
-        const int index= (((y)<<ME_MAP_SHIFT) + (x))&(ME_MAP_SIZE-1);
-        score_map[index]= d;
-    }
-
-    d += (c->mv_penalty[hx - c->pred_x] + c->mv_penalty[hy - c->pred_y])*c->penalty_factor;
-#endif
-    return d;
-}
-
-#include "motion_est_template.c"
-
-static int zero_cmp(void *s, uint8_t *a, uint8_t *b, int stride, int h){
-    return 0;
-}
-
-static void zero_hpel(uint8_t *a, const uint8_t *b, int stride, int h){
-}
-
-void ff_init_me(MpegEncContext *s){
-    MotionEstContext * const c= &s->me;
-    c->avctx= s->avctx;
-
-    ff_set_cmp(&s->dsp, s->dsp.me_pre_cmp, c->avctx->me_pre_cmp);
-    ff_set_cmp(&s->dsp, s->dsp.me_cmp, c->avctx->me_cmp);
-    ff_set_cmp(&s->dsp, s->dsp.me_sub_cmp, c->avctx->me_sub_cmp);
-    ff_set_cmp(&s->dsp, s->dsp.mb_cmp, c->avctx->mb_cmp);
-    
-    c->flags    = get_flags(c, 0, c->avctx->me_cmp    &FF_CMP_CHROMA);
-    c->sub_flags= get_flags(c, 0, c->avctx->me_sub_cmp&FF_CMP_CHROMA);
-    c->mb_flags = get_flags(c, 0, c->avctx->mb_cmp    &FF_CMP_CHROMA);
-
-/*FIXME s->no_rounding b_type*/
-    if(s->flags&CODEC_FLAG_QPEL){
-        c->sub_motion_search= qpel_motion_search;
-        c->qpel_avg= s->dsp.avg_qpel_pixels_tab;
-        if(s->no_rounding) c->qpel_put= s->dsp.put_no_rnd_qpel_pixels_tab;
-        else               c->qpel_put= s->dsp.put_qpel_pixels_tab;
-    }else{
-        if(c->avctx->me_sub_cmp&FF_CMP_CHROMA)
-            c->sub_motion_search= hpel_motion_search;
-        else if(   c->avctx->me_sub_cmp == FF_CMP_SAD 
-                && c->avctx->    me_cmp == FF_CMP_SAD 
-                && c->avctx->    mb_cmp == FF_CMP_SAD)
-            c->sub_motion_search= sad_hpel_motion_search; // 2050 vs. 2450 cycles
-        else
-            c->sub_motion_search= hpel_motion_search;
-    }
-    c->hpel_avg= s->dsp.avg_pixels_tab;
-    if(s->no_rounding) c->hpel_put= s->dsp.put_no_rnd_pixels_tab;
-    else               c->hpel_put= s->dsp.put_pixels_tab;
-
-    if(s->linesize){
-        c->stride  = s->linesize; 
-        c->uvstride= s->uvlinesize;
-    }else{
-        c->stride  = 16*s->mb_width + 32;
-        c->uvstride=  8*s->mb_width + 16;
-    }
-
-    // 8x8 fullpel search would need a 4x4 chroma compare, which we dont have yet, and even if we had the motion estimation code doesnt expect it
-    if(s->codec_id != CODEC_ID_SNOW){
-        if((c->avctx->me_cmp&FF_CMP_CHROMA)/* && !s->dsp.me_cmp[2]*/){
-            s->dsp.me_cmp[2]= zero_cmp;
-        }
-        if((c->avctx->me_sub_cmp&FF_CMP_CHROMA) && !s->dsp.me_sub_cmp[2]){
-            s->dsp.me_sub_cmp[2]= zero_cmp;
-        }
-        c->hpel_put[2][0]= c->hpel_put[2][1]=
-        c->hpel_put[2][2]= c->hpel_put[2][3]= zero_hpel;
-    }
-
-    if(s->codec_id == CODEC_ID_H261){
-        c->sub_motion_search= no_sub_motion_search;
-    }
-
-    c->temp= c->scratchpad;
-}
-      
-#if 0
-static int pix_dev(uint8_t * pix, int line_size, int mean)
-{
-    int s, i, j;
-
-    s = 0;
-    for (i = 0; i < 16; i++) {
-	for (j = 0; j < 16; j += 8) {
-	    s += ABS(pix[0]-mean);
-	    s += ABS(pix[1]-mean);
-	    s += ABS(pix[2]-mean);
-	    s += ABS(pix[3]-mean);
-	    s += ABS(pix[4]-mean);
-	    s += ABS(pix[5]-mean);
-	    s += ABS(pix[6]-mean);
-	    s += ABS(pix[7]-mean);
-	    pix += 8;
-	}
-	pix += line_size - 16;
-    }
-    return s;
-}
-#endif
-
-static inline void no_motion_search(MpegEncContext * s,
-				    int *mx_ptr, int *my_ptr)
-{
-    *mx_ptr = 16 * s->mb_x;
-    *my_ptr = 16 * s->mb_y;
-}
-
-#if 0  /* the use of these functions is inside #if 0 */
-static int full_motion_search(MpegEncContext * s,
-                              int *mx_ptr, int *my_ptr, int range,
-                              int xmin, int ymin, int xmax, int ymax, uint8_t *ref_picture)
-{
-    int x1, y1, x2, y2, xx, yy, x, y;
-    int mx, my, dmin, d;
-    uint8_t *pix;
-
-    xx = 16 * s->mb_x;
-    yy = 16 * s->mb_y;
-    x1 = xx - range + 1;	/* we loose one pixel to avoid boundary pb with half pixel pred */
-    if (x1 < xmin)
-	x1 = xmin;
-    x2 = xx + range - 1;
-    if (x2 > xmax)
-	x2 = xmax;
-    y1 = yy - range + 1;
-    if (y1 < ymin)
-	y1 = ymin;
-    y2 = yy + range - 1;
-    if (y2 > ymax)
-	y2 = ymax;
-    pix = s->new_picture.data[0] + (yy * s->linesize) + xx;
-    dmin = 0x7fffffff;
-    mx = 0;
-    my = 0;
-    for (y = y1; y <= y2; y++) {
-	for (x = x1; x <= x2; x++) {
-	    d = s->dsp.pix_abs[0][0](NULL, pix, ref_picture + (y * s->linesize) + x,
-			     s->linesize, 16);
-	    if (d < dmin ||
-		(d == dmin &&
-		 (abs(x - xx) + abs(y - yy)) <
-		 (abs(mx - xx) + abs(my - yy)))) {
-		dmin = d;
-		mx = x;
-		my = y;
-	    }
-	}
-    }
-
-    *mx_ptr = mx;
-    *my_ptr = my;
-
-#if 0
-    if (*mx_ptr < -(2 * range) || *mx_ptr >= (2 * range) ||
-	*my_ptr < -(2 * range) || *my_ptr >= (2 * range)) {
-	fprintf(stderr, "error %d %d\n", *mx_ptr, *my_ptr);
-    }
-#endif
-    return dmin;
-}
-
-
-static int log_motion_search(MpegEncContext * s,
-                             int *mx_ptr, int *my_ptr, int range,
-                             int xmin, int ymin, int xmax, int ymax, uint8_t *ref_picture)
-{
-    int x1, y1, x2, y2, xx, yy, x, y;
-    int mx, my, dmin, d;
-    uint8_t *pix;
-
-    xx = s->mb_x << 4;
-    yy = s->mb_y << 4;
-
-    /* Left limit */
-    x1 = xx - range;
-    if (x1 < xmin)
-	x1 = xmin;
-
-    /* Right limit */
-    x2 = xx + range;
-    if (x2 > xmax)
-	x2 = xmax;
-
-    /* Upper limit */
-    y1 = yy - range;
-    if (y1 < ymin)
-	y1 = ymin;
-
-    /* Lower limit */
-    y2 = yy + range;
-    if (y2 > ymax)
-	y2 = ymax;
-
-    pix = s->new_picture.data[0] + (yy * s->linesize) + xx;
-    dmin = 0x7fffffff;
-    mx = 0;
-    my = 0;
-
-    do {
-	for (y = y1; y <= y2; y += range) {
-	    for (x = x1; x <= x2; x += range) {
-		d = s->dsp.pix_abs[0][0](NULL, pix, ref_picture + (y * s->linesize) + x, s->linesize, 16);
-		if (d < dmin || (d == dmin && (abs(x - xx) + abs(y - yy)) < (abs(mx - xx) + abs(my - yy)))) {
-		    dmin = d;
-		    mx = x;
-		    my = y;
-		}
-	    }
-	}
-
-	range = range >> 1;
-
-	x1 = mx - range;
-	if (x1 < xmin)
-	    x1 = xmin;
-
-	x2 = mx + range;
-	if (x2 > xmax)
-	    x2 = xmax;
-
-	y1 = my - range;
-	if (y1 < ymin)
-	    y1 = ymin;
-
-	y2 = my + range;
-	if (y2 > ymax)
-	    y2 = ymax;
-
-    } while (range >= 1);
-
-#ifdef DEBUG
-    av_log(s->avctx, AV_LOG_DEBUG, "log       - MX: %d\tMY: %d\n", mx, my);
-#endif
-    *mx_ptr = mx;
-    *my_ptr = my;
-    return dmin;
-}
-
-static int phods_motion_search(MpegEncContext * s,
-                               int *mx_ptr, int *my_ptr, int range,
-                               int xmin, int ymin, int xmax, int ymax, uint8_t *ref_picture)
-{
-    int x1, y1, x2, y2, xx, yy, x, y, lastx, d;
-    int mx, my, dminx, dminy;
-    uint8_t *pix;
-
-    xx = s->mb_x << 4;
-    yy = s->mb_y << 4;
-
-    /* Left limit */
-    x1 = xx - range;
-    if (x1 < xmin)
-	x1 = xmin;
-
-    /* Right limit */
-    x2 = xx + range;
-    if (x2 > xmax)
-	x2 = xmax;
-
-    /* Upper limit */
-    y1 = yy - range;
-    if (y1 < ymin)
-	y1 = ymin;
-
-    /* Lower limit */
-    y2 = yy + range;
-    if (y2 > ymax)
-	y2 = ymax;
-
-    pix = s->new_picture.data[0] + (yy * s->linesize) + xx;
-    mx = 0;
-    my = 0;
-
-    x = xx;
-    y = yy;
-    do {
-        dminx = 0x7fffffff;
-        dminy = 0x7fffffff;
-
-	lastx = x;
-	for (x = x1; x <= x2; x += range) {
-	    d = s->dsp.pix_abs[0][0](NULL, pix, ref_picture + (y * s->linesize) + x, s->linesize, 16);
-	    if (d < dminx || (d == dminx && (abs(x - xx) + abs(y - yy)) < (abs(mx - xx) + abs(my - yy)))) {
-		dminx = d;
-		mx = x;
-	    }
-	}
-
-	x = lastx;
-	for (y = y1; y <= y2; y += range) {
-	    d = s->dsp.pix_abs[0][0](NULL, pix, ref_picture + (y * s->linesize) + x, s->linesize, 16);
-	    if (d < dminy || (d == dminy && (abs(x - xx) + abs(y - yy)) < (abs(mx - xx) + abs(my - yy)))) {
-		dminy = d;
-		my = y;
-	    }
-	}
-
-	range = range >> 1;
-
-	x = mx;
-	y = my;
-	x1 = mx - range;
-	if (x1 < xmin)
-	    x1 = xmin;
-
-	x2 = mx + range;
-	if (x2 > xmax)
-	    x2 = xmax;
-
-	y1 = my - range;
-	if (y1 < ymin)
-	    y1 = ymin;
-
-	y2 = my + range;
-	if (y2 > ymax)
-	    y2 = ymax;
-
-    } while (range >= 1);
-
-#ifdef DEBUG
-    av_log(s->avctx, AV_LOG_DEBUG, "phods     - MX: %d\tMY: %d\n", mx, my);
-#endif
-
-    /* half pixel search */
-    *mx_ptr = mx;
-    *my_ptr = my;
-    return dminy;
-}
-#endif /* 0 */
-
-#define Z_THRESHOLD 256
-
-#define CHECK_SAD_HALF_MV(suffix, x, y) \
-{\
-    d= s->dsp.pix_abs[size][(x?1:0)+(y?2:0)](NULL, pix, ptr+((x)>>1), stride, h);\
-    d += (mv_penalty[pen_x + x] + mv_penalty[pen_y + y])*penalty_factor;\
-    COPY3_IF_LT(dminh, d, dx, x, dy, y)\
-}
-
-static inline int sad_hpel_motion_search(MpegEncContext * s,
-				  int *mx_ptr, int *my_ptr, int dmin,
-                                  int src_index, int ref_index,
-                                  int size, int h)
-{
-    MotionEstContext * const c= &s->me;
-    const int penalty_factor= c->sub_penalty_factor;
-    int mx, my, dminh;
-    uint8_t *pix, *ptr;
-    int stride= c->stride;
-    const int flags= c->sub_flags;
-    LOAD_COMMON
-    
-    assert(flags == 0);
-
-    if(c->skip){
-//    printf("S");
-        *mx_ptr = 0;
-        *my_ptr = 0;
-        return dmin;
-    }
-//    printf("N");
-        
-    pix = c->src[src_index][0];
-
-    mx = *mx_ptr;
-    my = *my_ptr;
-    ptr = c->ref[ref_index][0] + (my * stride) + mx;
-    
-    dminh = dmin;
-
-    if (mx > xmin && mx < xmax && 
-        my > ymin && my < ymax) {
-        int dx=0, dy=0;
-        int d, pen_x, pen_y; 
-        const int index= (my<<ME_MAP_SHIFT) + mx;
-        const int t= score_map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)];
-        const int l= score_map[(index- 1               )&(ME_MAP_SIZE-1)];
-        const int r= score_map[(index+ 1               )&(ME_MAP_SIZE-1)];
-        const int b= score_map[(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)];
-        mx<<=1;
-        my<<=1;
-
-        
-        pen_x= pred_x + mx;
-        pen_y= pred_y + my;
-
-        ptr-= stride;
-        if(t<=b){
-            CHECK_SAD_HALF_MV(y2 , 0, -1)
-            if(l<=r){
-                CHECK_SAD_HALF_MV(xy2, -1, -1)
-                if(t+r<=b+l){
-                    CHECK_SAD_HALF_MV(xy2, +1, -1)
-                    ptr+= stride;
-                }else{
-                    ptr+= stride;
-                    CHECK_SAD_HALF_MV(xy2, -1, +1)
-                }
-                CHECK_SAD_HALF_MV(x2 , -1,  0)
-            }else{
-                CHECK_SAD_HALF_MV(xy2, +1, -1)
-                if(t+l<=b+r){
-                    CHECK_SAD_HALF_MV(xy2, -1, -1)
-                    ptr+= stride;
-                }else{
-                    ptr+= stride;
-                    CHECK_SAD_HALF_MV(xy2, +1, +1)
-                }
-                CHECK_SAD_HALF_MV(x2 , +1,  0)
-            }
-        }else{
-            if(l<=r){
-                if(t+l<=b+r){
-                    CHECK_SAD_HALF_MV(xy2, -1, -1)
-                    ptr+= stride;
-                }else{
-                    ptr+= stride;
-                    CHECK_SAD_HALF_MV(xy2, +1, +1)
-                }
-                CHECK_SAD_HALF_MV(x2 , -1,  0)
-                CHECK_SAD_HALF_MV(xy2, -1, +1)
-            }else{
-                if(t+r<=b+l){
-                    CHECK_SAD_HALF_MV(xy2, +1, -1)
-                    ptr+= stride;
-                }else{
-                    ptr+= stride;
-                    CHECK_SAD_HALF_MV(xy2, -1, +1)
-                }
-                CHECK_SAD_HALF_MV(x2 , +1,  0)
-                CHECK_SAD_HALF_MV(xy2, +1, +1)
-            }
-            CHECK_SAD_HALF_MV(y2 ,  0, +1)
-        }
-        mx+=dx;
-        my+=dy;
-
-    }else{
-        mx<<=1;
-        my<<=1;
-    }
-
-    *mx_ptr = mx;
-    *my_ptr = my;
-    return dminh;
-}
-
-static inline void set_p_mv_tables(MpegEncContext * s, int mx, int my, int mv4)
-{
-    const int xy= s->mb_x + s->mb_y*s->mb_stride;
-    
-    s->p_mv_table[xy][0] = mx;
-    s->p_mv_table[xy][1] = my;
-
-    /* has already been set to the 4 MV if 4MV is done */
-    if(mv4){
-        int mot_xy= s->block_index[0];
-
-        s->current_picture.motion_val[0][mot_xy  ][0]= mx;
-        s->current_picture.motion_val[0][mot_xy  ][1]= my;
-        s->current_picture.motion_val[0][mot_xy+1][0]= mx;
-        s->current_picture.motion_val[0][mot_xy+1][1]= my;
-
-        mot_xy += s->b8_stride;
-        s->current_picture.motion_val[0][mot_xy  ][0]= mx;
-        s->current_picture.motion_val[0][mot_xy  ][1]= my;
-        s->current_picture.motion_val[0][mot_xy+1][0]= mx;
-        s->current_picture.motion_val[0][mot_xy+1][1]= my;
-    }
-}
-
-/**
- * get fullpel ME search limits.
- */
-static inline void get_limits(MpegEncContext *s, int x, int y)
-{
-    MotionEstContext * const c= &s->me;
-/*
-    if(c->avctx->me_range) c->range= c->avctx->me_range >> 1;
-    else                   c->range= 16;
-*/
-    if (s->unrestricted_mv) {
-        c->xmin = - x - 16;
-        c->ymin = - y - 16;
-        c->xmax = - x + s->mb_width *16;
-        c->ymax = - y + s->mb_height*16;
-    } else if (s->out_format == FMT_H261){
-        // Search range of H261 is different from other codec standards
-        c->xmin = (x > 15) ? - 15 : 0;
-        c->ymin = (y > 15) ? - 15 : 0;
-        c->xmax = (x < s->mb_width * 16 - 16) ? 15 : 0;              
-        c->ymax = (y < s->mb_height * 16 - 16) ? 15 : 0;
-    } else {
-        c->xmin = - x;
-        c->ymin = - y;
-        c->xmax = - x + s->mb_width *16 - 16;
-        c->ymax = - y + s->mb_height*16 - 16;
-    }
-}
-
-static inline void init_mv4_ref(MotionEstContext *c){
-    const int stride= c->stride;
-
-    c->ref[1][0] = c->ref[0][0] + 8;
-    c->ref[2][0] = c->ref[0][0] + 8*stride;
-    c->ref[3][0] = c->ref[2][0] + 8;
-    c->src[1][0] = c->src[0][0] + 8;
-    c->src[2][0] = c->src[0][0] + 8*stride;
-    c->src[3][0] = c->src[2][0] + 8;
-}
-
-static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
-{
-    MotionEstContext * const c= &s->me;
-    const int size= 1;
-    const int h=8;
-    int block;
-    int P[10][2];
-    int dmin_sum=0, mx4_sum=0, my4_sum=0;
-    int same=1;
-    const int stride= c->stride;
-    uint8_t *mv_penalty= c->current_mv_penalty;
-
-    init_mv4_ref(c);
-    
-    for(block=0; block<4; block++){
-        int mx4, my4;
-        int pred_x4, pred_y4;
-        int dmin4;
-        static const int off[4]= {2, 1, 1, -1};
-        const int mot_stride = s->b8_stride;
-        const int mot_xy = s->block_index[block];
-
-        P_LEFT[0] = s->current_picture.motion_val[0][mot_xy - 1][0];
-        P_LEFT[1] = s->current_picture.motion_val[0][mot_xy - 1][1];
-
-        if(P_LEFT[0]       > (c->xmax<<shift)) P_LEFT[0]       = (c->xmax<<shift);
-
-        /* special case for first line */
-        if (s->first_slice_line && block<2) {
-            c->pred_x= pred_x4= P_LEFT[0];
-            c->pred_y= pred_y4= P_LEFT[1];
-        } else {
-            P_TOP[0]      = s->current_picture.motion_val[0][mot_xy - mot_stride             ][0];
-            P_TOP[1]      = s->current_picture.motion_val[0][mot_xy - mot_stride             ][1];
-            P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + off[block]][0];
-            P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + off[block]][1];
-            if(P_TOP[1]      > (c->ymax<<shift)) P_TOP[1]     = (c->ymax<<shift);
-            if(P_TOPRIGHT[0] < (c->xmin<<shift)) P_TOPRIGHT[0]= (c->xmin<<shift);
-            if(P_TOPRIGHT[0] > (c->xmax<<shift)) P_TOPRIGHT[0]= (c->xmax<<shift);
-            if(P_TOPRIGHT[1] > (c->ymax<<shift)) P_TOPRIGHT[1]= (c->ymax<<shift);
-    
-            P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
-            P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
-
-            c->pred_x= pred_x4 = P_MEDIAN[0];
-            c->pred_y= pred_y4 = P_MEDIAN[1];
-        }
-        P_MV1[0]= mx;
-        P_MV1[1]= my;
-
-        dmin4 = epzs_motion_search4(s, &mx4, &my4, P, block, block, s->p_mv_table, (1<<16)>>shift);
-
-        dmin4= c->sub_motion_search(s, &mx4, &my4, dmin4, block, block, size, h);
-        
-        if(s->dsp.me_sub_cmp[0] != s->dsp.mb_cmp[0]){
-            int dxy;
-            const int offset= ((block&1) + (block>>1)*stride)*8;
-            uint8_t *dest_y = c->scratchpad + offset;
-            if(s->quarter_sample){
-                uint8_t *ref= c->ref[block][0] + (mx4>>2) + (my4>>2)*stride;
-                dxy = ((my4 & 3) << 2) | (mx4 & 3);
-
-                if(s->no_rounding)
-                    s->dsp.put_no_rnd_qpel_pixels_tab[1][dxy](dest_y   , ref    , stride);
-                else
-                    s->dsp.put_qpel_pixels_tab       [1][dxy](dest_y   , ref    , stride);
-            }else{
-                uint8_t *ref= c->ref[block][0] + (mx4>>1) + (my4>>1)*stride;
-                dxy = ((my4 & 1) << 1) | (mx4 & 1);
-
-                if(s->no_rounding)
-                    s->dsp.put_no_rnd_pixels_tab[1][dxy](dest_y    , ref    , stride, h);
-                else
-                    s->dsp.put_pixels_tab       [1][dxy](dest_y    , ref    , stride, h);
-            }
-            dmin_sum+= (mv_penalty[mx4-pred_x4] + mv_penalty[my4-pred_y4])*c->mb_penalty_factor;
-        }else
-            dmin_sum+= dmin4;
-
-        if(s->quarter_sample){
-            mx4_sum+= mx4/2;
-            my4_sum+= my4/2;
-        }else{
-            mx4_sum+= mx4;
-            my4_sum+= my4;
-        }
-            
-        s->current_picture.motion_val[0][ s->block_index[block] ][0]= mx4;
-        s->current_picture.motion_val[0][ s->block_index[block] ][1]= my4;
-
-        if(mx4 != mx || my4 != my) same=0;
-    }
-    
-    if(same)
-        return INT_MAX;
-    
-    if(s->dsp.me_sub_cmp[0] != s->dsp.mb_cmp[0]){
-        dmin_sum += s->dsp.mb_cmp[0](s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*16*stride, c->scratchpad, stride, 16);
-    }
-    
-    if(c->avctx->mb_cmp&FF_CMP_CHROMA){
-        int dxy;
-        int mx, my;
-        int offset;
-
-        mx= ff_h263_round_chroma(mx4_sum);
-        my= ff_h263_round_chroma(my4_sum);
-        dxy = ((my & 1) << 1) | (mx & 1);
-        
-        offset= (s->mb_x*8 + (mx>>1)) + (s->mb_y*8 + (my>>1))*s->uvlinesize;
-       
-        if(s->no_rounding){
-            s->dsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad    , s->last_picture.data[1] + offset, s->uvlinesize, 8);
-            s->dsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad+8  , s->last_picture.data[2] + offset, s->uvlinesize, 8);
-        }else{
-            s->dsp.put_pixels_tab       [1][dxy](c->scratchpad    , s->last_picture.data[1] + offset, s->uvlinesize, 8);
-            s->dsp.put_pixels_tab       [1][dxy](c->scratchpad+8  , s->last_picture.data[2] + offset, s->uvlinesize, 8);
-        }
-
-        dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad  , s->uvlinesize, 8);
-        dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad+8, s->uvlinesize, 8);
-    }
-    
-    c->pred_x= mx;
-    c->pred_y= my;
-
-    switch(c->avctx->mb_cmp&0xFF){
-    /*case FF_CMP_SSE:
-        return dmin_sum+ 32*s->qscale*s->qscale;*/
-    case FF_CMP_RD:
-        return dmin_sum;
-    default:
-        return dmin_sum+ 11*c->mb_penalty_factor;
-    }
-}
-
-static inline void init_interlaced_ref(MpegEncContext *s, int ref_index){
-    MotionEstContext * const c= &s->me;
-
-    c->ref[1+ref_index][0] = c->ref[0+ref_index][0] + s->linesize;
-    c->src[1][0] = c->src[0][0] + s->linesize;
-    if(c->flags & FLAG_CHROMA){
-        c->ref[1+ref_index][1] = c->ref[0+ref_index][1] + s->uvlinesize;
-        c->ref[1+ref_index][2] = c->ref[0+ref_index][2] + s->uvlinesize;
-        c->src[1][1] = c->src[0][1] + s->uvlinesize;
-        c->src[1][2] = c->src[0][2] + s->uvlinesize;
-    }
-}
-
-static int interlaced_search(MpegEncContext *s, int ref_index, 
-                             int16_t (*mv_tables[2][2])[2], uint8_t *field_select_tables[2], int mx, int my, int user_field_select)
-{
-    MotionEstContext * const c= &s->me;
-    const int size=0;
-    const int h=8;
-    int block;
-    int P[10][2];
-    uint8_t * const mv_penalty= c->current_mv_penalty;
-    int same=1;
-    const int stride= 2*s->linesize;
-    int dmin_sum= 0;
-    const int mot_stride= s->mb_stride;
-    const int xy= s->mb_x + s->mb_y*mot_stride;
-    
-    c->ymin>>=1;
-    c->ymax>>=1;
-    c->stride<<=1;
-    c->uvstride<<=1;
-    init_interlaced_ref(s, ref_index);
-    
-    for(block=0; block<2; block++){
-        int field_select;
-        int best_dmin= INT_MAX;
-        int best_field= -1;
-
-        for(field_select=0; field_select<2; field_select++){
-            int dmin, mx_i, my_i;
-            int16_t (*mv_table)[2]= mv_tables[block][field_select];
-            
-            if(user_field_select){
-                if(field_select_tables[block][xy] != field_select)
-                    continue;
-            }
-            
-            P_LEFT[0] = mv_table[xy - 1][0];
-            P_LEFT[1] = mv_table[xy - 1][1];
-            if(P_LEFT[0]       > (c->xmax<<1)) P_LEFT[0]       = (c->xmax<<1);
-            
-            c->pred_x= P_LEFT[0];
-            c->pred_y= P_LEFT[1];
-            
-            if(!s->first_slice_line){
-                P_TOP[0]      = mv_table[xy - mot_stride][0];
-                P_TOP[1]      = mv_table[xy - mot_stride][1];
-                P_TOPRIGHT[0] = mv_table[xy - mot_stride + 1][0];
-                P_TOPRIGHT[1] = mv_table[xy - mot_stride + 1][1];
-                if(P_TOP[1]      > (c->ymax<<1)) P_TOP[1]     = (c->ymax<<1);
-                if(P_TOPRIGHT[0] < (c->xmin<<1)) P_TOPRIGHT[0]= (c->xmin<<1);
-                if(P_TOPRIGHT[0] > (c->xmax<<1)) P_TOPRIGHT[0]= (c->xmax<<1);
-                if(P_TOPRIGHT[1] > (c->ymax<<1)) P_TOPRIGHT[1]= (c->ymax<<1);
-    
-                P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
-                P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
-            }
-            P_MV1[0]= mx; //FIXME not correct if block != field_select
-            P_MV1[1]= my / 2;
-            
-            dmin = epzs_motion_search2(s, &mx_i, &my_i, P, block, field_select+ref_index, mv_table, (1<<16)>>1);
-
-            dmin= c->sub_motion_search(s, &mx_i, &my_i, dmin, block, field_select+ref_index, size, h);
-            
-            mv_table[xy][0]= mx_i;
-            mv_table[xy][1]= my_i;
-            
-            if(s->dsp.me_sub_cmp[0] != s->dsp.mb_cmp[0]){
-                int dxy;
-
-                //FIXME chroma ME
-                uint8_t *ref= c->ref[field_select+ref_index][0] + (mx_i>>1) + (my_i>>1)*stride;
-                dxy = ((my_i & 1) << 1) | (mx_i & 1);
-
-                if(s->no_rounding){
-                    s->dsp.put_no_rnd_pixels_tab[size][dxy](c->scratchpad, ref    , stride, h);
-                }else{
-                    s->dsp.put_pixels_tab       [size][dxy](c->scratchpad, ref    , stride, h);
-                }
-                dmin= s->dsp.mb_cmp[size](s, c->src[block][0], c->scratchpad, stride, h);
-                dmin+= (mv_penalty[mx_i-c->pred_x] + mv_penalty[my_i-c->pred_y] + 1)*c->mb_penalty_factor;
-            }else
-                dmin+= c->mb_penalty_factor; //field_select bits
-                
-            dmin += field_select != block; //slightly prefer same field
-            
-            if(dmin < best_dmin){
-                best_dmin= dmin;
-                best_field= field_select;
-            }
-        }
-        {
-            int16_t (*mv_table)[2]= mv_tables[block][best_field];
-
-            if(mv_table[xy][0] != mx) same=0; //FIXME check if these checks work and are any good at all
-            if(mv_table[xy][1]&1) same=0;
-            if(mv_table[xy][1]*2 != my) same=0; 
-            if(best_field != block) same=0;
-        }
-
-        field_select_tables[block][xy]= best_field;
-        dmin_sum += best_dmin;
-    }
-    
-    c->ymin<<=1;
-    c->ymax<<=1;
-    c->stride>>=1;
-    c->uvstride>>=1;
-
-    if(same)
-        return INT_MAX;
-    
-    switch(c->avctx->mb_cmp&0xFF){
-    /*case FF_CMP_SSE:
-        return dmin_sum+ 32*s->qscale*s->qscale;*/
-    case FF_CMP_RD:
-        return dmin_sum;
-    default:
-        return dmin_sum+ 11*c->mb_penalty_factor;
-    }
-}
-
-static void clip_input_mv(MpegEncContext * s, int16_t *mv, int interlaced){
-    int ymax= s->me.ymax>>interlaced;
-    int ymin= s->me.ymin>>interlaced;
-    
-    if(mv[0] < s->me.xmin) mv[0] = s->me.xmin;
-    if(mv[0] > s->me.xmax) mv[0] = s->me.xmax;
-    if(mv[1] <       ymin) mv[1] =       ymin;
-    if(mv[1] >       ymax) mv[1] =       ymax;
-}
-
-static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int p_type){
-    MotionEstContext * const c= &s->me;
-    Picture *p= s->current_picture_ptr;
-    int mb_xy= mb_x + mb_y*s->mb_stride;
-    int xy= 2*mb_x + 2*mb_y*s->b8_stride;
-    int mb_type= s->current_picture.mb_type[mb_xy];
-    int flags= c->flags;
-    int shift= (flags&FLAG_QPEL) + 1;
-    int mask= (1<<shift)-1;
-    int x, y, i;
-    int d=0;
-    me_cmp_func cmpf= s->dsp.sse[0];
-    me_cmp_func chroma_cmpf= s->dsp.sse[1];
-    
-    if(p_type && USES_LIST(mb_type, 1)){
-        av_log(c->avctx, AV_LOG_ERROR, "backward motion vector in P frame\n");
-        return INT_MAX/2;
-    }
-    assert(IS_INTRA(mb_type) || USES_LIST(mb_type,0) || USES_LIST(mb_type,1));
-    
-    for(i=0; i<4; i++){
-        int xy= s->block_index[i];
-        clip_input_mv(s, p->motion_val[0][xy], !!IS_INTERLACED(mb_type));
-        clip_input_mv(s, p->motion_val[1][xy], !!IS_INTERLACED(mb_type));
-    }
-
-    if(IS_INTERLACED(mb_type)){
-        int xy2= xy  + s->b8_stride;
-        s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTRA;
-        c->stride<<=1;
-        c->uvstride<<=1;
-        
-        if(!(s->flags & CODEC_FLAG_INTERLACED_ME)){
-            av_log(c->avctx, AV_LOG_ERROR, "Interlaced macroblock selected but interlaced motion estimation disabled\n");
-            return INT_MAX/2;
-        }
-
-        if(USES_LIST(mb_type, 0)){
-            int field_select0= p->ref_index[0][xy ];
-            int field_select1= p->ref_index[0][xy2];
-            assert(field_select0==0 ||field_select0==1);
-            assert(field_select1==0 ||field_select1==1);
-            init_interlaced_ref(s, 0);
-
-            if(p_type){
-                s->p_field_select_table[0][mb_xy]= field_select0;
-                s->p_field_select_table[1][mb_xy]= field_select1;
-                *(uint32_t*)s->p_field_mv_table[0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[0][xy ];
-                *(uint32_t*)s->p_field_mv_table[1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[0][xy2];
-                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER_I;
-            }else{
-                s->b_field_select_table[0][0][mb_xy]= field_select0;
-                s->b_field_select_table[0][1][mb_xy]= field_select1;
-                *(uint32_t*)s->b_field_mv_table[0][0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[0][xy ];
-                *(uint32_t*)s->b_field_mv_table[0][1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[0][xy2];
-                s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_FORWARD_I;
-            }
-
-            x= p->motion_val[0][xy ][0]; 
-            y= p->motion_val[0][xy ][1];
-            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0, 0, cmpf, chroma_cmpf, flags);
-            x= p->motion_val[0][xy2][0]; 
-            y= p->motion_val[0][xy2][1];
-            d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1, 1, cmpf, chroma_cmpf, flags);
-        }
-        if(USES_LIST(mb_type, 1)){
-            int field_select0= p->ref_index[1][xy ];
-            int field_select1= p->ref_index[1][xy2];
-            assert(field_select0==0 ||field_select0==1);
-            assert(field_select1==0 ||field_select1==1);
-            init_interlaced_ref(s, 2);
-
-            s->b_field_select_table[1][0][mb_xy]= field_select0;
-            s->b_field_select_table[1][1][mb_xy]= field_select1;
-            *(uint32_t*)s->b_field_mv_table[1][0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[1][xy ];
-            *(uint32_t*)s->b_field_mv_table[1][1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[1][xy2];
-            if(USES_LIST(mb_type, 0)){
-                s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_BIDIR_I;
-            }else{
-                s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_BACKWARD_I;
-            }
-
-            x= p->motion_val[1][xy ][0]; 
-            y= p->motion_val[1][xy ][1];
-            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0+2, 0, cmpf, chroma_cmpf, flags);
-            x= p->motion_val[1][xy2][0]; 
-            y= p->motion_val[1][xy2][1];
-            d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1+2, 1, cmpf, chroma_cmpf, flags);
-            //FIXME bidir scores
-        }
-        c->stride>>=1;
-        c->uvstride>>=1;
-    }else if(IS_8X8(mb_type)){
-        if(!(s->flags & CODEC_FLAG_4MV)){
-            av_log(c->avctx, AV_LOG_ERROR, "4MV macroblock selected but 4MV encoding disabled\n");
-            return INT_MAX/2;
-        }
-        cmpf= s->dsp.sse[1];
-        chroma_cmpf= s->dsp.sse[1];
-        init_mv4_ref(c);
-        for(i=0; i<4; i++){
-            xy= s->block_index[i];
-            x= p->motion_val[0][xy][0]; 
-            y= p->motion_val[0][xy][1];
-            d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 1, 8, i, i, cmpf, chroma_cmpf, flags);
-        }
-        s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER4V;
-    }else{
-        if(USES_LIST(mb_type, 0)){
-            if(p_type){
-                *(uint32_t*)s->p_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy];
-                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER;
-            }else if(USES_LIST(mb_type, 1)){
-                *(uint32_t*)s->b_bidir_forw_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy];
-                *(uint32_t*)s->b_bidir_back_mv_table[mb_xy]= *(uint32_t*)p->motion_val[1][xy];
-                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_BIDIR;
-            }else{
-                *(uint32_t*)s->b_forw_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy];
-                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_FORWARD;
-            }
-            x= p->motion_val[0][xy][0]; 
-            y= p->motion_val[0][xy][1];
-            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 0, 0, cmpf, chroma_cmpf, flags);
-        }else if(USES_LIST(mb_type, 1)){
-            *(uint32_t*)s->b_back_mv_table[mb_xy]= *(uint32_t*)p->motion_val[1][xy];
-            s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_BACKWARD;
-           
-            x= p->motion_val[1][xy][0]; 
-            y= p->motion_val[1][xy][1];
-            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 2, 0, cmpf, chroma_cmpf, flags);
-        }else
-            s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTRA;
-    }
-    return d;
-}
-
-void ff_estimate_p_frame_motion(MpegEncContext * s,
-                                int mb_x, int mb_y)
-{
-    MotionEstContext * const c= &s->me;
-    uint8_t *pix, *ppix;
-    int sum, varc, vard, mx, my, dmin;
-    int P[10][2];
-    const int shift= 1+s->quarter_sample;
-    int mb_type=0;
-    Picture * const pic= &s->current_picture;
-    
-    init_ref(c, s->new_picture.data, s->last_picture.data, NULL, 16*mb_x, 16*mb_y, 0);
-
-    assert(s->quarter_sample==0 || s->quarter_sample==1);
-    assert(s->linesize == c->stride);
-    assert(s->uvlinesize == c->uvstride);
-
-    c->penalty_factor    = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp);
-    c->sub_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_sub_cmp);
-    c->mb_penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->mb_cmp);
-    c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_MV;
-
-    get_limits(s, 16*mb_x, 16*mb_y);
-    c->skip=0;
-
-    /* intra / predictive decision */
-    pix = c->src[0][0];
-    sum = s->dsp.pix_sum(pix, s->linesize);
-    varc = (s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500 + 128)>>8;
-
-    pic->mb_mean[s->mb_stride * mb_y + mb_x] = (sum+128)>>8;
-    pic->mb_var [s->mb_stride * mb_y + mb_x] = varc;
-    c->mb_var_sum_temp += varc;
-
-    if(c->avctx->me_threshold){
-        vard= (check_input_motion(s, mb_x, mb_y, 1)+128)>>8;
-        
-        if(vard<c->avctx->me_threshold){
-            pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = vard;
-            c->mc_mb_var_sum_temp += vard;
-            if (vard <= 64 || vard < varc) { //FIXME
-                c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc);
-            }else{
-                c->scene_change_score+= s->qscale;
-            }
-            return;
-        }
-        if(vard<c->avctx->mb_threshold)
-            mb_type= s->mb_type[mb_x + mb_y*s->mb_stride];
-    }
-
-    switch(s->me_method) {
-    case ME_ZERO:
-    default:
-	no_motion_search(s, &mx, &my);
-        mx-= mb_x*16;
-        my-= mb_y*16;
-        dmin = 0;
-        break;
-#if 0
-    case ME_FULL:
-	dmin = full_motion_search(s, &mx, &my, range, ref_picture);
-        mx-= mb_x*16;
-        my-= mb_y*16;
-        break;
-    case ME_LOG:
-	dmin = log_motion_search(s, &mx, &my, range / 2, ref_picture);
-        mx-= mb_x*16;
-        my-= mb_y*16;
-        break;
-    case ME_PHODS:
-	dmin = phods_motion_search(s, &mx, &my, range / 2, ref_picture);
-        mx-= mb_x*16;
-        my-= mb_y*16;
-        break;
-#endif
-    case ME_X1:
-    case ME_EPZS:
-       {
-            const int mot_stride = s->b8_stride;
-            const int mot_xy = s->block_index[0];
-
-            P_LEFT[0]       = s->current_picture.motion_val[0][mot_xy - 1][0];
-            P_LEFT[1]       = s->current_picture.motion_val[0][mot_xy - 1][1];
-
-            if(P_LEFT[0]       > (c->xmax<<shift)) P_LEFT[0]       = (c->xmax<<shift);
-
-            if(!s->first_slice_line) {
-                P_TOP[0]      = s->current_picture.motion_val[0][mot_xy - mot_stride    ][0];
-                P_TOP[1]      = s->current_picture.motion_val[0][mot_xy - mot_stride    ][1];
-                P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][0];
-                P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][1];
-                if(P_TOP[1]      > (c->ymax<<shift)) P_TOP[1]     = (c->ymax<<shift);
-                if(P_TOPRIGHT[0] < (c->xmin<<shift)) P_TOPRIGHT[0]= (c->xmin<<shift);
-                if(P_TOPRIGHT[1] > (c->ymax<<shift)) P_TOPRIGHT[1]= (c->ymax<<shift);
-        
-                P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
-                P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
-
-                if(s->out_format == FMT_H263){
-                    c->pred_x = P_MEDIAN[0];
-                    c->pred_y = P_MEDIAN[1];
-                }else { /* mpeg1 at least */
-                    c->pred_x= P_LEFT[0];
-                    c->pred_y= P_LEFT[1];
-                }
-            }else{
-                c->pred_x= P_LEFT[0];
-                c->pred_y= P_LEFT[1];
-            }
-
-        }
-        dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, 0, s->p_mv_table, (1<<16)>>shift, 0, 16);       
-
-        break;
-    }
-
-    /* At this point (mx,my) are full-pell and the relative displacement */
-    ppix = c->ref[0][0] + (my * s->linesize) + mx;
-        
-    vard = (s->dsp.sse[0](NULL, pix, ppix, s->linesize, 16)+128)>>8;
-
-    pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = vard;
-//    pic->mb_cmp_score[s->mb_stride * mb_y + mb_x] = dmin; 
-    c->mc_mb_var_sum_temp += vard;
-    
-#if 0
-    printf("varc=%4d avg_var=%4d (sum=%4d) vard=%4d mx=%2d my=%2d\n",
-	   varc, s->avg_mb_var, sum, vard, mx - xx, my - yy);
-#endif
-    if(mb_type){
-        if (vard <= 64 || vard < varc)
-            c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc);
-        else
-            c->scene_change_score+= s->qscale;
-
-        if(mb_type == CANDIDATE_MB_TYPE_INTER){
-            c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
-            set_p_mv_tables(s, mx, my, 1);
-        }else{
-            mx <<=shift;
-            my <<=shift;
-        }
-        if(mb_type == CANDIDATE_MB_TYPE_INTER4V){
-            h263_mv4_search(s, mx, my, shift);
-
-            set_p_mv_tables(s, mx, my, 0);
-        }
-        if(mb_type == CANDIDATE_MB_TYPE_INTER_I){
-            interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 1);
-        }
-    }else if(c->avctx->mb_decision > FF_MB_DECISION_SIMPLE){
-        if (vard <= 64 || vard < varc)
-            c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc);
-        else
-            c->scene_change_score+= s->qscale;
-
-        if (vard*2 + 200 > varc)
-            mb_type|= CANDIDATE_MB_TYPE_INTRA;
-        if (varc*2 + 200 > vard){
-            mb_type|= CANDIDATE_MB_TYPE_INTER;
-            c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
-            if(s->flags&CODEC_FLAG_MV0)
-                if(mx || my)
-                    mb_type |= CANDIDATE_MB_TYPE_SKIPPED; //FIXME check difference
-        }else{
-            mx <<=shift;
-            my <<=shift;
-        }
-        if((s->flags&CODEC_FLAG_4MV)
-           && !c->skip && varc>50 && vard>10){
-            if(h263_mv4_search(s, mx, my, shift) < INT_MAX)
-                mb_type|=CANDIDATE_MB_TYPE_INTER4V;
-
-            set_p_mv_tables(s, mx, my, 0);
-        }else
-            set_p_mv_tables(s, mx, my, 1);
-        if((s->flags&CODEC_FLAG_INTERLACED_ME)
-           && !c->skip){ //FIXME varc/d checks
-            if(interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 0) < INT_MAX)
-                mb_type |= CANDIDATE_MB_TYPE_INTER_I;
-        }
-    }else{
-        int intra_score, i;
-        mb_type= CANDIDATE_MB_TYPE_INTER;
-
-        dmin= c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
-        if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip)
-            dmin= ff_get_mb_score(s, mx, my, 0, 0, 0, 16, 1);
-
-        if((s->flags&CODEC_FLAG_4MV)
-           && !c->skip && varc>50 && vard>10){
-            int dmin4= h263_mv4_search(s, mx, my, shift);
-            if(dmin4 < dmin){
-                mb_type= CANDIDATE_MB_TYPE_INTER4V;
-                dmin=dmin4;
-            }
-        }
-        if((s->flags&CODEC_FLAG_INTERLACED_ME)
-           && !c->skip){ //FIXME varc/d checks
-            int dmin_i= interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 0);
-            if(dmin_i < dmin){
-                mb_type = CANDIDATE_MB_TYPE_INTER_I;
-                dmin= dmin_i;
-            }
-        }
-                
-//        pic->mb_cmp_score[s->mb_stride * mb_y + mb_x] = dmin; 
-        set_p_mv_tables(s, mx, my, mb_type!=CANDIDATE_MB_TYPE_INTER4V);
-
-        /* get intra luma score */
-        if((c->avctx->mb_cmp&0xFF)==FF_CMP_SSE){
-            intra_score= (varc<<8) - 500; //FIXME dont scale it down so we dont have to fix it
-        }else{
-            int mean= (sum+128)>>8;
-            mean*= 0x01010101;
-            
-            for(i=0; i<16; i++){
-                *(uint32_t*)(&c->scratchpad[i*s->linesize+ 0]) = mean;
-                *(uint32_t*)(&c->scratchpad[i*s->linesize+ 4]) = mean;
-                *(uint32_t*)(&c->scratchpad[i*s->linesize+ 8]) = mean;
-                *(uint32_t*)(&c->scratchpad[i*s->linesize+12]) = mean;
-            }
-
-            intra_score= s->dsp.mb_cmp[0](s, c->scratchpad, pix, s->linesize, 16);
-        }
-#if 0 //FIXME
-        /* get chroma score */
-        if(c->avctx->mb_cmp&FF_CMP_CHROMA){
-            for(i=1; i<3; i++){
-                uint8_t *dest_c;
-                int mean;
-                
-                if(s->out_format == FMT_H263){
-                    mean= (s->dc_val[i][mb_x + mb_y*s->b8_stride] + 4)>>3; //FIXME not exact but simple ;)
-                }else{
-                    mean= (s->last_dc[i] + 4)>>3;
-                }
-                dest_c = s->new_picture.data[i] + (mb_y * 8  * (s->uvlinesize)) + mb_x * 8;
-                
-                mean*= 0x01010101;
-                for(i=0; i<8; i++){
-                    *(uint32_t*)(&c->scratchpad[i*s->uvlinesize+ 0]) = mean;
-                    *(uint32_t*)(&c->scratchpad[i*s->uvlinesize+ 4]) = mean;
-                }
-                
-                intra_score+= s->dsp.mb_cmp[1](s, c->scratchpad, dest_c, s->uvlinesize);
-            }                
-        }
-#endif
-        intra_score += c->mb_penalty_factor*16;
-        
-        if(intra_score < dmin){
-            mb_type= CANDIDATE_MB_TYPE_INTRA;
-            s->current_picture.mb_type[mb_y*s->mb_stride + mb_x]= CANDIDATE_MB_TYPE_INTRA; //FIXME cleanup
-        }else
-            s->current_picture.mb_type[mb_y*s->mb_stride + mb_x]= 0;
-        
-        if (vard <= 64 || vard < varc) { //FIXME
-            c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc);
-        }else{
-            c->scene_change_score+= s->qscale;
-        }
-    }
-
-    s->mb_type[mb_y*s->mb_stride + mb_x]= mb_type;
-}
-
-int ff_pre_estimate_p_frame_motion(MpegEncContext * s,
-                                    int mb_x, int mb_y)
-{
-    MotionEstContext * const c= &s->me;
-    int mx, my, dmin;
-    int P[10][2];
-    const int shift= 1+s->quarter_sample;
-    const int xy= mb_x + mb_y*s->mb_stride;
-    init_ref(c, s->new_picture.data, s->last_picture.data, NULL, 16*mb_x, 16*mb_y, 0);
-    
-    assert(s->quarter_sample==0 || s->quarter_sample==1);
-
-    c->pre_penalty_factor    = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_pre_cmp);
-    c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_MV;
-
-    get_limits(s, 16*mb_x, 16*mb_y);
-    c->skip=0;
-
-    P_LEFT[0]       = s->p_mv_table[xy + 1][0];
-    P_LEFT[1]       = s->p_mv_table[xy + 1][1];
-
-    if(P_LEFT[0]       < (c->xmin<<shift)) P_LEFT[0]       = (c->xmin<<shift);
-
-    /* special case for first line */
-    if (s->first_slice_line) {
-        c->pred_x= P_LEFT[0];
-        c->pred_y= P_LEFT[1];
-        P_TOP[0]= P_TOPRIGHT[0]= P_MEDIAN[0]=
-        P_TOP[1]= P_TOPRIGHT[1]= P_MEDIAN[1]= 0; //FIXME 
-    } else {
-        P_TOP[0]      = s->p_mv_table[xy + s->mb_stride    ][0];
-        P_TOP[1]      = s->p_mv_table[xy + s->mb_stride    ][1];
-        P_TOPRIGHT[0] = s->p_mv_table[xy + s->mb_stride - 1][0];
-        P_TOPRIGHT[1] = s->p_mv_table[xy + s->mb_stride - 1][1];
-        if(P_TOP[1]      < (c->ymin<<shift)) P_TOP[1]     = (c->ymin<<shift);
-        if(P_TOPRIGHT[0] > (c->xmax<<shift)) P_TOPRIGHT[0]= (c->xmax<<shift);
-        if(P_TOPRIGHT[1] < (c->ymin<<shift)) P_TOPRIGHT[1]= (c->ymin<<shift);
-    
-        P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
-        P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
-
-        c->pred_x = P_MEDIAN[0];
-        c->pred_y = P_MEDIAN[1];
-    }
-
-    dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, 0, s->p_mv_table, (1<<16)>>shift, 0, 16);       
-
-    s->p_mv_table[xy][0] = mx<<shift;
-    s->p_mv_table[xy][1] = my<<shift;
-    
-    return dmin;
-}
-
-static int ff_estimate_motion_b(MpegEncContext * s,
-                       int mb_x, int mb_y, int16_t (*mv_table)[2], int ref_index, int f_code)
-{
-    MotionEstContext * const c= &s->me;
-    int mx, my, dmin;
-    int P[10][2];
-    const int shift= 1+s->quarter_sample;
-    const int mot_stride = s->mb_stride;
-    const int mot_xy = mb_y*mot_stride + mb_x;
-    uint8_t * const mv_penalty= c->mv_penalty[f_code] + MAX_MV;
-    int mv_scale;
-        
-    c->penalty_factor    = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp);
-    c->sub_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_sub_cmp);
-    c->mb_penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->mb_cmp);
-    c->current_mv_penalty= mv_penalty;
-
-    get_limits(s, 16*mb_x, 16*mb_y);
-
-    switch(s->me_method) {
-    case ME_ZERO:
-    default:
-	no_motion_search(s, &mx, &my);
-        dmin = 0;
-        mx-= mb_x*16;
-        my-= mb_y*16;
-        break;
-#if 0
-    case ME_FULL:
-	dmin = full_motion_search(s, &mx, &my, range, ref_picture);
-        mx-= mb_x*16;
-        my-= mb_y*16;
-        break;
-    case ME_LOG:
-	dmin = log_motion_search(s, &mx, &my, range / 2, ref_picture);
-        mx-= mb_x*16;
-        my-= mb_y*16;
-        break;
-    case ME_PHODS:
-	dmin = phods_motion_search(s, &mx, &my, range / 2, ref_picture);
-        mx-= mb_x*16;
-        my-= mb_y*16;
-        break;
-#endif
-    case ME_X1:
-    case ME_EPZS:
-       {
-            P_LEFT[0]        = mv_table[mot_xy - 1][0];
-            P_LEFT[1]        = mv_table[mot_xy - 1][1];
-
-            if(P_LEFT[0]       > (c->xmax<<shift)) P_LEFT[0]       = (c->xmax<<shift);
-
-            /* special case for first line */
-            if (!s->first_slice_line) {
-                P_TOP[0] = mv_table[mot_xy - mot_stride             ][0];
-                P_TOP[1] = mv_table[mot_xy - mot_stride             ][1];
-                P_TOPRIGHT[0] = mv_table[mot_xy - mot_stride + 1         ][0];
-                P_TOPRIGHT[1] = mv_table[mot_xy - mot_stride + 1         ][1];
-                if(P_TOP[1] > (c->ymax<<shift)) P_TOP[1]= (c->ymax<<shift);
-                if(P_TOPRIGHT[0] < (c->xmin<<shift)) P_TOPRIGHT[0]= (c->xmin<<shift);
-                if(P_TOPRIGHT[1] > (c->ymax<<shift)) P_TOPRIGHT[1]= (c->ymax<<shift);
-        
-                P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
-                P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
-            }
-            c->pred_x= P_LEFT[0];
-            c->pred_y= P_LEFT[1];
-        }
-        
-        if(mv_table == s->b_forw_mv_table){
-            mv_scale= (s->pb_time<<16) / (s->pp_time<<shift);
-        }else{
-            mv_scale= ((s->pb_time - s->pp_time)<<16) / (s->pp_time<<shift);
-        }
-        
-        dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, ref_index, s->p_mv_table, mv_scale, 0, 16);
- 
-        break;
-    }
-    
-    dmin= c->sub_motion_search(s, &mx, &my, dmin, 0, ref_index, 0, 16);
-                                   
-    if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip)
-        dmin= ff_get_mb_score(s, mx, my, 0, ref_index, 0, 16, 1);
-
-//printf("%d %d %d %d//", s->mb_x, s->mb_y, mx, my);
-//    s->mb_type[mb_y*s->mb_width + mb_x]= mb_type;
-    mv_table[mot_xy][0]= mx;
-    mv_table[mot_xy][1]= my;
-
-    return dmin;
-}
-
-static inline int check_bidir_mv(MpegEncContext * s,
-                   int motion_fx, int motion_fy,
-                   int motion_bx, int motion_by,
-                   int pred_fx, int pred_fy,
-                   int pred_bx, int pred_by,
-                   int size, int h)
-{
-    //FIXME optimize?
-    //FIXME better f_code prediction (max mv & distance)
-    //FIXME pointers
-    MotionEstContext * const c= &s->me;
-    uint8_t * const mv_penalty= c->mv_penalty[s->f_code] + MAX_MV; // f_code of the prev frame
-    int stride= c->stride;
-    uint8_t *dest_y = c->scratchpad;
-    uint8_t *ptr;
-    int dxy;
-    int src_x, src_y;
-    int fbmin;
-    uint8_t **src_data= c->src[0];
-    uint8_t **ref_data= c->ref[0];
-    uint8_t **ref2_data= c->ref[2];
-
-    if(s->quarter_sample){
-        dxy = ((motion_fy & 3) << 2) | (motion_fx & 3);
-        src_x = motion_fx >> 2;
-        src_y = motion_fy >> 2;
-
-        ptr = ref_data[0] + (src_y * stride) + src_x;
-        s->dsp.put_qpel_pixels_tab[0][dxy](dest_y    , ptr    , stride);
-
-        dxy = ((motion_by & 3) << 2) | (motion_bx & 3);
-        src_x = motion_bx >> 2;
-        src_y = motion_by >> 2;
-    
-        ptr = ref2_data[0] + (src_y * stride) + src_x;
-        s->dsp.avg_qpel_pixels_tab[size][dxy](dest_y    , ptr    , stride);
-    }else{
-        dxy = ((motion_fy & 1) << 1) | (motion_fx & 1);
-        src_x = motion_fx >> 1;
-        src_y = motion_fy >> 1;
-
-        ptr = ref_data[0] + (src_y * stride) + src_x;
-        s->dsp.put_pixels_tab[size][dxy](dest_y    , ptr    , stride, h);
-
-        dxy = ((motion_by & 1) << 1) | (motion_bx & 1);
-        src_x = motion_bx >> 1;
-        src_y = motion_by >> 1;
-    
-        ptr = ref2_data[0] + (src_y * stride) + src_x;
-        s->dsp.avg_pixels_tab[size][dxy](dest_y    , ptr    , stride, h);
-    }
-
-    fbmin = (mv_penalty[motion_fx-pred_fx] + mv_penalty[motion_fy-pred_fy])*c->mb_penalty_factor
-           +(mv_penalty[motion_bx-pred_bx] + mv_penalty[motion_by-pred_by])*c->mb_penalty_factor
-           + s->dsp.mb_cmp[size](s, src_data[0], dest_y, stride, h); //FIXME new_pic
-           
-    if(c->avctx->mb_cmp&FF_CMP_CHROMA){
-    }
-    //FIXME CHROMA !!!
-           
-    return fbmin;
-}
-
-/* refine the bidir vectors in hq mode and return the score in both lq & hq mode*/
-static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y)
-{
-    const int mot_stride = s->mb_stride;
-    const int xy = mb_y *mot_stride + mb_x;
-    int fbmin;
-    int pred_fx= s->b_bidir_forw_mv_table[xy-1][0];
-    int pred_fy= s->b_bidir_forw_mv_table[xy-1][1];
-    int pred_bx= s->b_bidir_back_mv_table[xy-1][0];
-    int pred_by= s->b_bidir_back_mv_table[xy-1][1];
-    int motion_fx= s->b_bidir_forw_mv_table[xy][0]= s->b_forw_mv_table[xy][0];
-    int motion_fy= s->b_bidir_forw_mv_table[xy][1]= s->b_forw_mv_table[xy][1];
-    int motion_bx= s->b_bidir_back_mv_table[xy][0]= s->b_back_mv_table[xy][0];
-    int motion_by= s->b_bidir_back_mv_table[xy][1]= s->b_back_mv_table[xy][1];
-
-    //FIXME do refinement and add flag
-    
-    fbmin= check_bidir_mv(s, motion_fx, motion_fy,
-                          motion_bx, motion_by,
-                          pred_fx, pred_fy,
-                          pred_bx, pred_by,
-                          0, 16);
-
-   return fbmin;
-}
-
-static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y)
-{
-    MotionEstContext * const c= &s->me;
-    int P[10][2];
-    const int mot_stride = s->mb_stride;
-    const int mot_xy = mb_y*mot_stride + mb_x;
-    const int shift= 1+s->quarter_sample;
-    int dmin, i;
-    const int time_pp= s->pp_time;
-    const int time_pb= s->pb_time;
-    int mx, my, xmin, xmax, ymin, ymax;
-    int16_t (*mv_table)[2]= s->b_direct_mv_table;
-    
-    c->current_mv_penalty= c->mv_penalty[1] + MAX_MV;
-    ymin= xmin=(-32)>>shift;
-    ymax= xmax=   31>>shift;
-
-    if(IS_8X8(s->next_picture.mb_type[mot_xy])){
-        s->mv_type= MV_TYPE_8X8;
-    }else{
-        s->mv_type= MV_TYPE_16X16;
-    }
-
-    for(i=0; i<4; i++){
-        int index= s->block_index[i];
-        int min, max;
-    
-        c->co_located_mv[i][0]= s->next_picture.motion_val[0][index][0];
-        c->co_located_mv[i][1]= s->next_picture.motion_val[0][index][1];
-        c->direct_basis_mv[i][0]= c->co_located_mv[i][0]*time_pb/time_pp + ((i& 1)<<(shift+3));
-        c->direct_basis_mv[i][1]= c->co_located_mv[i][1]*time_pb/time_pp + ((i>>1)<<(shift+3));
-//        c->direct_basis_mv[1][i][0]= c->co_located_mv[i][0]*(time_pb - time_pp)/time_pp + ((i &1)<<(shift+3);
-//        c->direct_basis_mv[1][i][1]= c->co_located_mv[i][1]*(time_pb - time_pp)/time_pp + ((i>>1)<<(shift+3);
-
-        max= FFMAX(c->direct_basis_mv[i][0], c->direct_basis_mv[i][0] - c->co_located_mv[i][0])>>shift;
-        min= FFMIN(c->direct_basis_mv[i][0], c->direct_basis_mv[i][0] - c->co_located_mv[i][0])>>shift;
-        max+= 16*mb_x + 1; // +-1 is for the simpler rounding
-        min+= 16*mb_x - 1;
-        xmax= FFMIN(xmax, s->width - max);
-        xmin= FFMAX(xmin, - 16     - min);
-
-        max= FFMAX(c->direct_basis_mv[i][1], c->direct_basis_mv[i][1] - c->co_located_mv[i][1])>>shift;
-        min= FFMIN(c->direct_basis_mv[i][1], c->direct_basis_mv[i][1] - c->co_located_mv[i][1])>>shift;
-        max+= 16*mb_y + 1; // +-1 is for the simpler rounding
-        min+= 16*mb_y - 1;
-        ymax= FFMIN(ymax, s->height - max);
-        ymin= FFMAX(ymin, - 16      - min);
-        
-        if(s->mv_type == MV_TYPE_16X16) break;
-    }
-    
-    assert(xmax <= 15 && ymax <= 15 && xmin >= -16 && ymin >= -16);
-    
-    if(xmax < 0 || xmin >0 || ymax < 0 || ymin > 0){
-        s->b_direct_mv_table[mot_xy][0]= 0;
-        s->b_direct_mv_table[mot_xy][1]= 0;
-
-        return 256*256*256*64;
-    }
-    
-    c->xmin= xmin;
-    c->ymin= ymin;
-    c->xmax= xmax;
-    c->ymax= ymax;
-    c->flags     |= FLAG_DIRECT;
-    c->sub_flags |= FLAG_DIRECT;
-    c->pred_x=0;
-    c->pred_y=0;
-
-    P_LEFT[0]        = clip(mv_table[mot_xy - 1][0], xmin<<shift, xmax<<shift);
-    P_LEFT[1]        = clip(mv_table[mot_xy - 1][1], ymin<<shift, ymax<<shift);
-
-    /* special case for first line */
-    if (!s->first_slice_line) { //FIXME maybe allow this over thread boundary as its cliped
-        P_TOP[0]      = clip(mv_table[mot_xy - mot_stride             ][0], xmin<<shift, xmax<<shift);
-        P_TOP[1]      = clip(mv_table[mot_xy - mot_stride             ][1], ymin<<shift, ymax<<shift);
-        P_TOPRIGHT[0] = clip(mv_table[mot_xy - mot_stride + 1         ][0], xmin<<shift, xmax<<shift);
-        P_TOPRIGHT[1] = clip(mv_table[mot_xy - mot_stride + 1         ][1], ymin<<shift, ymax<<shift);
-    
-        P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
-        P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
-    }
- 
-    dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, 0, mv_table, 1<<(16-shift), 0, 16);
-    if(c->sub_flags&FLAG_QPEL) 
-        dmin = qpel_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
-    else
-        dmin = hpel_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
-    
-    if(c->avctx->me_sub_cmp != c->avctx->mb_cmp && !c->skip)
-        dmin= ff_get_mb_score(s, mx, my, 0, 0, 0, 16, 1);
-    
-    get_limits(s, 16*mb_x, 16*mb_y); //restore c->?min/max, maybe not needed
-
-    s->b_direct_mv_table[mot_xy][0]= mx;
-    s->b_direct_mv_table[mot_xy][1]= my;
-    c->flags     &= ~FLAG_DIRECT;
-    c->sub_flags &= ~FLAG_DIRECT;
-
-    return dmin;
-}
-
-void ff_estimate_b_frame_motion(MpegEncContext * s,
-                             int mb_x, int mb_y)
-{
-    MotionEstContext * const c= &s->me;
-    const int penalty_factor= c->mb_penalty_factor;
-    int fmin, bmin, dmin, fbmin, bimin, fimin;
-    int type=0;
-    const int xy = mb_y*s->mb_stride + mb_x;
-    init_ref(c, s->new_picture.data, s->last_picture.data, s->next_picture.data, 16*mb_x, 16*mb_y, 2);
-
-    get_limits(s, 16*mb_x, 16*mb_y);
-    
-    c->skip=0;
-    if(c->avctx->me_threshold){
-        int vard= (check_input_motion(s, mb_x, mb_y, 0)+128)>>8;
-        
-        if(vard<c->avctx->me_threshold){
-//            pix = c->src[0][0];
-//            sum = s->dsp.pix_sum(pix, s->linesize);
-//            varc = (s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500 + 128)>>8;
-        
-//            pic->mb_var   [s->mb_stride * mb_y + mb_x] = varc;
-             s->current_picture.mc_mb_var[s->mb_stride * mb_y + mb_x] = vard;
-/*            pic->mb_mean  [s->mb_stride * mb_y + mb_x] = (sum+128)>>8;
-            c->mb_var_sum_temp    += varc;*/
-            c->mc_mb_var_sum_temp += vard;
-/*            if (vard <= 64 || vard < varc) {
-                c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc);
-            }else{
-                c->scene_change_score+= s->qscale;
-            }*/
-            return;
-        }
-        if(vard<c->avctx->mb_threshold){
-            type= s->mb_type[mb_y*s->mb_stride + mb_x];
-            if(type == CANDIDATE_MB_TYPE_DIRECT){
-                direct_search(s, mb_x, mb_y);
-            }
-            if(type == CANDIDATE_MB_TYPE_FORWARD || type == CANDIDATE_MB_TYPE_BIDIR){
-                c->skip=0;
-                ff_estimate_motion_b(s, mb_x, mb_y, s->b_forw_mv_table, 0, s->f_code);
-            }
-            if(type == CANDIDATE_MB_TYPE_BACKWARD || type == CANDIDATE_MB_TYPE_BIDIR){
-                c->skip=0;
-                ff_estimate_motion_b(s, mb_x, mb_y, s->b_back_mv_table, 2, s->b_code);
-            }
-            if(type == CANDIDATE_MB_TYPE_FORWARD_I || type == CANDIDATE_MB_TYPE_BIDIR_I){
-                c->skip=0;
-                c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_MV;
-                interlaced_search(s, 0,
-                                        s->b_field_mv_table[0], s->b_field_select_table[0],
-                                        s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1], 1);
-            }
-            if(type == CANDIDATE_MB_TYPE_BACKWARD_I || type == CANDIDATE_MB_TYPE_BIDIR_I){
-                c->skip=0;
-                c->current_mv_penalty= c->mv_penalty[s->b_code] + MAX_MV;
-                interlaced_search(s, 2,
-                                        s->b_field_mv_table[1], s->b_field_select_table[1],
-                                        s->b_back_mv_table[xy][0], s->b_back_mv_table[xy][1], 1);
-            }
-            return;
-        }
-    }
-
-    if (s->codec_id == CODEC_ID_MPEG4)
-        dmin= direct_search(s, mb_x, mb_y);
-    else
-        dmin= INT_MAX;
-//FIXME penalty stuff for non mpeg4
-    c->skip=0;
-    fmin= ff_estimate_motion_b(s, mb_x, mb_y, s->b_forw_mv_table, 0, s->f_code) + 3*penalty_factor;
-    
-    c->skip=0;
-    bmin= ff_estimate_motion_b(s, mb_x, mb_y, s->b_back_mv_table, 2, s->b_code) + 2*penalty_factor;
-//printf(" %d %d ", s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1]);
-
-    c->skip=0;
-    fbmin= bidir_refine(s, mb_x, mb_y) + penalty_factor;
-//printf("%d %d %d %d\n", dmin, fmin, bmin, fbmin);
-    
-    if(s->flags & CODEC_FLAG_INTERLACED_ME){
-//FIXME mb type penalty
-        c->skip=0;
-        c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_MV;
-        fimin= interlaced_search(s, 0,
-                                 s->b_field_mv_table[0], s->b_field_select_table[0],
-                                 s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1], 0);
-        c->current_mv_penalty= c->mv_penalty[s->b_code] + MAX_MV;
-        bimin= interlaced_search(s, 2,
-                                 s->b_field_mv_table[1], s->b_field_select_table[1],
-                                 s->b_back_mv_table[xy][0], s->b_back_mv_table[xy][1], 0);
-    }else
-        fimin= bimin= INT_MAX;
-
-    {
-        int score= fmin;
-        type = CANDIDATE_MB_TYPE_FORWARD;
-        
-        if (dmin <= score){
-            score = dmin;
-            type = CANDIDATE_MB_TYPE_DIRECT;
-        }
-        if(bmin<score){
-            score=bmin;
-            type= CANDIDATE_MB_TYPE_BACKWARD; 
-        }
-        if(fbmin<score){
-            score=fbmin;
-            type= CANDIDATE_MB_TYPE_BIDIR;
-        }
-        if(fimin<score){
-            score=fimin;
-            type= CANDIDATE_MB_TYPE_FORWARD_I;
-        }
-        if(bimin<score){
-            score=bimin;
-            type= CANDIDATE_MB_TYPE_BACKWARD_I;
-        }
-        
-        score= ((unsigned)(score*score + 128*256))>>16;
-        c->mc_mb_var_sum_temp += score;
-        s->current_picture.mc_mb_var[mb_y*s->mb_stride + mb_x] = score; //FIXME use SSE
-    }
-
-    if(c->avctx->mb_decision > FF_MB_DECISION_SIMPLE){
-        type= CANDIDATE_MB_TYPE_FORWARD | CANDIDATE_MB_TYPE_BACKWARD | CANDIDATE_MB_TYPE_BIDIR | CANDIDATE_MB_TYPE_DIRECT;
-        if(fimin < INT_MAX)
-            type |= CANDIDATE_MB_TYPE_FORWARD_I;
-        if(bimin < INT_MAX)
-            type |= CANDIDATE_MB_TYPE_BACKWARD_I;
-        if(fimin < INT_MAX && bimin < INT_MAX){
-            type |= CANDIDATE_MB_TYPE_BIDIR_I;
-        }
-         //FIXME something smarter
-        if(dmin>256*256*16) type&= ~CANDIDATE_MB_TYPE_DIRECT; //dont try direct mode if its invalid for this MB
-#if 0        
-        if(s->out_format == FMT_MPEG1)
-            type |= CANDIDATE_MB_TYPE_INTRA;
-#endif
-    }
-
-    s->mb_type[mb_y*s->mb_stride + mb_x]= type;
-}
-
-/* find best f_code for ME which do unlimited searches */
-int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type)
-{
-    if(s->me_method>=ME_EPZS){
-        int score[8];
-        int i, y, range= s->avctx->me_range ? s->avctx->me_range : (INT_MAX/2);
-        uint8_t * fcode_tab= s->fcode_tab;
-        int best_fcode=-1;
-        int best_score=-10000000;
-
-        if(s->msmpeg4_version) 
-            range= FFMIN(range, 16);
-        else if(s->codec_id == CODEC_ID_MPEG2VIDEO && s->avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL)
-            range= FFMIN(range, 256);
-
-        for(i=0; i<8; i++) score[i]= s->mb_num*(8-i);
-
-        for(y=0; y<s->mb_height; y++){
-            int x;
-            int xy= y*s->mb_stride;
-            for(x=0; x<s->mb_width; x++){
-                if(s->mb_type[xy] & type){
-                    int mx= mv_table[xy][0];
-                    int my= mv_table[xy][1];
-                    int fcode= FFMAX(fcode_tab[mx + MAX_MV],
-                                     fcode_tab[my + MAX_MV]);
-                    int j;
-                    
-                        if(mx >= range || mx < -range || 
-                           my >= range || my < -range)
-                            continue;
-                    
-                    for(j=0; j<fcode && j<8; j++){
-                        if(s->pict_type==B_TYPE || s->current_picture.mc_mb_var[xy] < s->current_picture.mb_var[xy])
-                            score[j]-= 170;
-                    }
-                }
-                xy++;
-            }
-        }
-        
-        for(i=1; i<8; i++){
-            if(score[i] > best_score){
-                best_score= score[i];
-                best_fcode= i;
-            }
-//            printf("%d %d\n", i, score[i]);
-        }
-
-//    printf("fcode: %d type: %d\n", i, s->pict_type);
-        return best_fcode;
-/*        for(i=0; i<=MAX_FCODE; i++){
-            printf("%d ", mv_num[i]);
-        }
-        printf("\n");*/
-    }else{
-        return 1;
-    }
-}
-
-void ff_fix_long_p_mvs(MpegEncContext * s)
-{
-    MotionEstContext * const c= &s->me;
-    const int f_code= s->f_code;
-    int y, range;
-    assert(s->pict_type==P_TYPE);
-
-    range = (((s->out_format == FMT_MPEG1 || s->msmpeg4_version) ? 8 : 16) << f_code);
-
-    assert(range <= 16 || !s->msmpeg4_version);
-    assert(range <=256 || !(s->codec_id == CODEC_ID_MPEG2VIDEO && s->avctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL));
-    
-    if(c->avctx->me_range && range > c->avctx->me_range) range= c->avctx->me_range;
-    
-//printf("%d no:%d %d//\n", clip, noclip, f_code);
-    if(s->flags&CODEC_FLAG_4MV){
-        const int wrap= s->b8_stride;
-
-        /* clip / convert to intra 8x8 type MVs */
-        for(y=0; y<s->mb_height; y++){
-            int xy= y*2*wrap;
-            int i= y*s->mb_stride;
-            int x;
-
-            for(x=0; x<s->mb_width; x++){
-                if(s->mb_type[i]&CANDIDATE_MB_TYPE_INTER4V){
-                    int block;
-                    for(block=0; block<4; block++){
-                        int off= (block& 1) + (block>>1)*wrap;
-                        int mx= s->current_picture.motion_val[0][ xy + off ][0];
-                        int my= s->current_picture.motion_val[0][ xy + off ][1];
-
-                        if(   mx >=range || mx <-range
-                           || my >=range || my <-range){
-                            s->mb_type[i] &= ~CANDIDATE_MB_TYPE_INTER4V;
-                            s->mb_type[i] |= CANDIDATE_MB_TYPE_INTRA;
-                            s->current_picture.mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
-                        }
-                    }
-                }
-                xy+=2;
-                i++;
-            }
-        }
-    }
-}
-
-/**
- *
- * @param truncate 1 for truncation, 0 for using intra
- */
-void ff_fix_long_mvs(MpegEncContext * s, uint8_t *field_select_table, int field_select, 
-                     int16_t (*mv_table)[2], int f_code, int type, int truncate)
-{
-    MotionEstContext * const c= &s->me;
-    int y, h_range, v_range;
-
-    // RAL: 8 in MPEG-1, 16 in MPEG-4
-    int range = (((s->out_format == FMT_MPEG1 || s->msmpeg4_version) ? 8 : 16) << f_code);
-
-    if(c->avctx->me_range && range > c->avctx->me_range) range= c->avctx->me_range;
-
-    h_range= range;
-    v_range= field_select_table ? range>>1 : range;
-
-    /* clip / convert to intra 16x16 type MVs */
-    for(y=0; y<s->mb_height; y++){
-        int x;
-        int xy= y*s->mb_stride;
-        for(x=0; x<s->mb_width; x++){
-            if (s->mb_type[xy] & type){    // RAL: "type" test added...
-                if(field_select_table==NULL || field_select_table[xy] == field_select){
-                    if(   mv_table[xy][0] >=h_range || mv_table[xy][0] <-h_range
-                       || mv_table[xy][1] >=v_range || mv_table[xy][1] <-v_range){
-
-                        if(truncate){
-                            if     (mv_table[xy][0] > h_range-1) mv_table[xy][0]=  h_range-1;
-                            else if(mv_table[xy][0] < -h_range ) mv_table[xy][0]= -h_range;
-                            if     (mv_table[xy][1] > v_range-1) mv_table[xy][1]=  v_range-1;
-                            else if(mv_table[xy][1] < -v_range ) mv_table[xy][1]= -v_range;
-                        }else{
-                            s->mb_type[xy] &= ~type;
-                            s->mb_type[xy] |= CANDIDATE_MB_TYPE_INTRA;
-                            mv_table[xy][0]=
-                            mv_table[xy][1]= 0;
-                        }
-                    }
-                }
-            }
-            xy++;
-        }
-    }
-}
diff --git a/ffmpeg.src/libavcodec/motion_est_template.c b/ffmpeg.src/libavcodec/motion_est_template.c
deleted file mode 100644
index d8101ec..0000000
--- a/ffmpeg.src/libavcodec/motion_est_template.c
+++ /dev/null
@@ -1,1101 +0,0 @@
-/*
- * Motion estimation 
- * Copyright (c) 2002-2004 Michael Niedermayer
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
- 
-/**
- * @file motion_est_template.c
- * Motion estimation template.
- */
-
-//lets hope gcc will remove the unused vars ...(gcc 3.2.2 seems to do it ...)
-#define LOAD_COMMON\
-    uint32_t attribute_unused * const score_map= c->score_map;\
-    const int attribute_unused xmin= c->xmin;\
-    const int attribute_unused ymin= c->ymin;\
-    const int attribute_unused xmax= c->xmax;\
-    const int attribute_unused ymax= c->ymax;\
-    uint8_t *mv_penalty= c->current_mv_penalty;\
-    const int pred_x= c->pred_x;\
-    const int pred_y= c->pred_y;\
-
-#define CHECK_HALF_MV(dx, dy, x, y)\
-{\
-    const int hx= 2*(x)+(dx);\
-    const int hy= 2*(y)+(dy);\
-    d= cmp(s, x, y, dx, dy, size, h, ref_index, src_index, cmp_sub, chroma_cmp_sub, flags);\
-    d += (mv_penalty[hx - pred_x] + mv_penalty[hy - pred_y])*penalty_factor;\
-    COPY3_IF_LT(dmin, d, bx, hx, by, hy)\
-}
-
-#if 0
-static int hpel_motion_search)(MpegEncContext * s,
-				  int *mx_ptr, int *my_ptr, int dmin,
-                                  uint8_t *ref_data[3], 
-                                  int size)
-{
-    const int xx = 16 * s->mb_x + 8*(n&1);
-    const int yy = 16 * s->mb_y + 8*(n>>1);
-    const int mx = *mx_ptr;
-    const int my = *my_ptr;
-    const int penalty_factor= c->sub_penalty_factor;
-    
-    LOAD_COMMON
-    
- //   INIT;
- //FIXME factorize
-    me_cmp_func cmp, chroma_cmp, cmp_sub, chroma_cmp_sub;
-
-    if(s->no_rounding /*FIXME b_type*/){
-        hpel_put= &s->dsp.put_no_rnd_pixels_tab[size];
-        chroma_hpel_put= &s->dsp.put_no_rnd_pixels_tab[size+1];
-    }else{
-        hpel_put=& s->dsp.put_pixels_tab[size];
-        chroma_hpel_put= &s->dsp.put_pixels_tab[size+1];
-    }
-    cmpf= s->dsp.me_cmp[size];
-    chroma_cmpf= s->dsp.me_cmp[size+1];
-    cmp_sub= s->dsp.me_sub_cmp[size];
-    chroma_cmp_sub= s->dsp.me_sub_cmp[size+1];
-
-    if(c->skip){ //FIXME somehow move up (benchmark)
-        *mx_ptr = 0;
-        *my_ptr = 0;
-        return dmin;
-    }
-        
-    if(c->avctx->me_cmp != c->avctx->me_sub_cmp){
-        CMP_HPEL(dmin, 0, 0, mx, my, size);
-        if(mx || my)
-            dmin += (mv_penalty[2*mx - pred_x] + mv_penalty[2*my - pred_y])*penalty_factor;
-    }
-        
-    if (mx > xmin && mx < xmax && 
-        my > ymin && my < ymax) {
-        int bx=2*mx, by=2*my;
-        int d= dmin;
-        
-        CHECK_HALF_MV(1, 1, mx-1, my-1)
-        CHECK_HALF_MV(0, 1, mx  , my-1)        
-        CHECK_HALF_MV(1, 1, mx  , my-1)
-        CHECK_HALF_MV(1, 0, mx-1, my  )
-        CHECK_HALF_MV(1, 0, mx  , my  )
-        CHECK_HALF_MV(1, 1, mx-1, my  )
-        CHECK_HALF_MV(0, 1, mx  , my  )        
-        CHECK_HALF_MV(1, 1, mx  , my  )
-
-        assert(bx >= xmin*2 || bx <= xmax*2 || by >= ymin*2 || by <= ymax*2);
-
-        *mx_ptr = bx;
-        *my_ptr = by;
-    }else{
-        *mx_ptr =2*mx;
-        *my_ptr =2*my;
-    }
-
-    return dmin;
-}
-
-#else
-static int hpel_motion_search(MpegEncContext * s,
-				  int *mx_ptr, int *my_ptr, int dmin,
-                                  int src_index, int ref_index,
-                                  int size, int h)
-{
-    MotionEstContext * const c= &s->me;
-    const int mx = *mx_ptr;
-    const int my = *my_ptr;   
-    const int penalty_factor= c->sub_penalty_factor;
-    me_cmp_func cmp_sub, chroma_cmp_sub;
-    int bx=2*mx, by=2*my;
-
-    LOAD_COMMON
-    int flags= c->sub_flags;
-    
- //FIXME factorize
-
-    cmp_sub= s->dsp.me_sub_cmp[size];
-    chroma_cmp_sub= s->dsp.me_sub_cmp[size+1];
-
-    if(c->skip){ //FIXME move out of hpel?
-        *mx_ptr = 0;
-        *my_ptr = 0;
-        return dmin;
-    }
-        
-    if(c->avctx->me_cmp != c->avctx->me_sub_cmp){
-        dmin= cmp(s, mx, my, 0, 0, size, h, ref_index, src_index, cmp_sub, chroma_cmp_sub, flags);
-        if(mx || my || size>0)
-            dmin += (mv_penalty[2*mx - pred_x] + mv_penalty[2*my - pred_y])*penalty_factor;
-    }
-        
-    if (mx > xmin && mx < xmax && 
-        my > ymin && my < ymax) {
-        int d= dmin;
-        const int index= (my<<ME_MAP_SHIFT) + mx;
-        const int t= score_map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] 
-                     + (mv_penalty[bx   - pred_x] + mv_penalty[by-2 - pred_y])*c->penalty_factor;
-        const int l= score_map[(index- 1               )&(ME_MAP_SIZE-1)]
-                     + (mv_penalty[bx-2 - pred_x] + mv_penalty[by   - pred_y])*c->penalty_factor;
-        const int r= score_map[(index+ 1               )&(ME_MAP_SIZE-1)]
-                     + (mv_penalty[bx+2 - pred_x] + mv_penalty[by   - pred_y])*c->penalty_factor;
-        const int b= score_map[(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)]
-                     + (mv_penalty[bx   - pred_x] + mv_penalty[by+2 - pred_y])*c->penalty_factor;
-    
-#if 1
-        int key;
-        int map_generation= c->map_generation;
-#ifndef NDEBUG
-        uint32_t *map= c->map;
-#endif
-        key= ((my-1)<<ME_MAP_MV_BITS) + (mx) + map_generation;
-        assert(map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] == key);
-        key= ((my+1)<<ME_MAP_MV_BITS) + (mx) + map_generation;
-        assert(map[(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] == key);
-        key= ((my)<<ME_MAP_MV_BITS) + (mx+1) + map_generation;
-        assert(map[(index+1)&(ME_MAP_SIZE-1)] == key);
-        key= ((my)<<ME_MAP_MV_BITS) + (mx-1) + map_generation;
-        assert(map[(index-1)&(ME_MAP_SIZE-1)] == key);
-#endif                
-        if(t<=b){
-            CHECK_HALF_MV(0, 1, mx  ,my-1)
-            if(l<=r){
-                CHECK_HALF_MV(1, 1, mx-1, my-1)
-                if(t+r<=b+l){
-                    CHECK_HALF_MV(1, 1, mx  , my-1)
-                }else{
-                    CHECK_HALF_MV(1, 1, mx-1, my  )
-                }
-                CHECK_HALF_MV(1, 0, mx-1, my  )
-            }else{
-                CHECK_HALF_MV(1, 1, mx  , my-1)
-                if(t+l<=b+r){
-                    CHECK_HALF_MV(1, 1, mx-1, my-1)
-                }else{
-                    CHECK_HALF_MV(1, 1, mx  , my  )
-                }
-                CHECK_HALF_MV(1, 0, mx  , my  )
-            }
-        }else{
-            if(l<=r){
-                if(t+l<=b+r){
-                    CHECK_HALF_MV(1, 1, mx-1, my-1)
-                }else{
-                    CHECK_HALF_MV(1, 1, mx  , my  )
-                }
-                CHECK_HALF_MV(1, 0, mx-1, my)
-                CHECK_HALF_MV(1, 1, mx-1, my)
-            }else{
-                if(t+r<=b+l){
-                    CHECK_HALF_MV(1, 1, mx  , my-1)
-                }else{
-                    CHECK_HALF_MV(1, 1, mx-1, my)
-                }
-                CHECK_HALF_MV(1, 0, mx  , my)
-                CHECK_HALF_MV(1, 1, mx  , my)
-            }
-            CHECK_HALF_MV(0, 1, mx  , my)
-        }
-        assert(bx >= xmin*2 && bx <= xmax*2 && by >= ymin*2 && by <= ymax*2);
-    }
-
-    *mx_ptr = bx;
-    *my_ptr = by;
-    
-    return dmin;
-}
-#endif
-
-static int no_sub_motion_search(MpegEncContext * s,
-          int *mx_ptr, int *my_ptr, int dmin,
-                                  int src_index, int ref_index,
-                                  int size, int h)
-{
-    (*mx_ptr)<<=1;
-    (*my_ptr)<<=1;
-    return dmin;
-}
-
-int inline ff_get_mb_score(MpegEncContext * s, int mx, int my, int src_index,
-                               int ref_index, int size, int h, int add_rate)
-{
-//    const int check_luma= s->dsp.me_sub_cmp != s->dsp.mb_cmp;
-    MotionEstContext * const c= &s->me;
-    const int penalty_factor= c->mb_penalty_factor;
-    const int flags= c->mb_flags;
-    const int qpel= flags & FLAG_QPEL;
-    const int mask= 1+2*qpel;
-    me_cmp_func cmp_sub, chroma_cmp_sub;
-    int d;
-
-    LOAD_COMMON
-    
- //FIXME factorize
-
-    cmp_sub= s->dsp.mb_cmp[size];
-    chroma_cmp_sub= s->dsp.mb_cmp[size+1];
-    
-//    assert(!c->skip);
-//    assert(c->avctx->me_sub_cmp != c->avctx->mb_cmp);
-
-    d= cmp(s, mx>>(qpel+1), my>>(qpel+1), mx&mask, my&mask, size, h, ref_index, src_index, cmp_sub, chroma_cmp_sub, flags);
-    //FIXME check cbp before adding penalty for (0,0) vector
-    if(add_rate && (mx || my || size>0))
-        d += (mv_penalty[mx - pred_x] + mv_penalty[my - pred_y])*penalty_factor;
-        
-    return d;
-}
-
-#define CHECK_QUARTER_MV(dx, dy, x, y)\
-{\
-    const int hx= 4*(x)+(dx);\
-    const int hy= 4*(y)+(dy);\
-    d= cmp(s, x, y, dx, dy, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);\
-    d += (mv_penalty[hx - pred_x] + mv_penalty[hy - pred_y])*penalty_factor;\
-    COPY3_IF_LT(dmin, d, bx, hx, by, hy)\
-}
-
-static int qpel_motion_search(MpegEncContext * s,
-				  int *mx_ptr, int *my_ptr, int dmin,
-                                  int src_index, int ref_index,                                  
-                                  int size, int h)
-{
-    MotionEstContext * const c= &s->me;
-    const int mx = *mx_ptr;
-    const int my = *my_ptr;   
-    const int penalty_factor= c->sub_penalty_factor;
-    const int map_generation= c->map_generation;
-    const int subpel_quality= c->avctx->me_subpel_quality;
-    uint32_t *map= c->map;
-    me_cmp_func cmpf, chroma_cmpf;
-    me_cmp_func cmp_sub, chroma_cmp_sub;
-
-    LOAD_COMMON
-    int flags= c->sub_flags;
-    
-    cmpf= s->dsp.me_cmp[size];
-    chroma_cmpf= s->dsp.me_cmp[size+1]; //factorize FIXME
- //FIXME factorize
-
-    cmp_sub= s->dsp.me_sub_cmp[size];
-    chroma_cmp_sub= s->dsp.me_sub_cmp[size+1];
-
-    if(c->skip){ //FIXME somehow move up (benchmark)
-        *mx_ptr = 0;
-        *my_ptr = 0;
-        return dmin;
-    }
-        
-    if(c->avctx->me_cmp != c->avctx->me_sub_cmp){
-        dmin= cmp(s, mx, my, 0, 0, size, h, ref_index, src_index, cmp_sub, chroma_cmp_sub, flags);
-        if(mx || my || size>0)
-            dmin += (mv_penalty[4*mx - pred_x] + mv_penalty[4*my - pred_y])*penalty_factor;
-    }
-        
-    if (mx > xmin && mx < xmax && 
-        my > ymin && my < ymax) {
-        int bx=4*mx, by=4*my;
-        int d= dmin;
-        int i, nx, ny;
-        const int index= (my<<ME_MAP_SHIFT) + mx;
-        const int t= score_map[(index-(1<<ME_MAP_SHIFT)  )&(ME_MAP_SIZE-1)];
-        const int l= score_map[(index- 1                 )&(ME_MAP_SIZE-1)];
-        const int r= score_map[(index+ 1                 )&(ME_MAP_SIZE-1)];
-        const int b= score_map[(index+(1<<ME_MAP_SHIFT)  )&(ME_MAP_SIZE-1)];
-        const int c= score_map[(index                    )&(ME_MAP_SIZE-1)];
-        int best[8];
-        int best_pos[8][2];
-        
-        memset(best, 64, sizeof(int)*8);
-#if 1
-        if(s->me.dia_size>=2){        
-            const int tl= score_map[(index-(1<<ME_MAP_SHIFT)-1)&(ME_MAP_SIZE-1)];
-            const int bl= score_map[(index+(1<<ME_MAP_SHIFT)-1)&(ME_MAP_SIZE-1)];
-            const int tr= score_map[(index-(1<<ME_MAP_SHIFT)+1)&(ME_MAP_SIZE-1)];
-            const int br= score_map[(index+(1<<ME_MAP_SHIFT)+1)&(ME_MAP_SIZE-1)];
-
-            for(ny= -3; ny <= 3; ny++){
-                for(nx= -3; nx <= 3; nx++){
-                    //FIXME this could overflow (unlikely though)
-                    const int64_t t2= nx*nx*(tr + tl - 2*t) + 4*nx*(tr-tl) + 32*t;
-                    const int64_t c2= nx*nx*( r +  l - 2*c) + 4*nx*( r- l) + 32*c;
-                    const int64_t b2= nx*nx*(br + bl - 2*b) + 4*nx*(br-bl) + 32*b;
-                    int score= (ny*ny*(b2 + t2 - 2*c2) + 4*ny*(b2 - t2) + 32*c2 + 512)>>10;
-                    int i;
-                    
-                    if((nx&3)==0 && (ny&3)==0) continue;
-                    
-                    score += (mv_penalty[4*mx + nx - pred_x] + mv_penalty[4*my + ny - pred_y])*penalty_factor;
-                    
-//                    if(nx&1) score-=1024*c->penalty_factor;
-//                    if(ny&1) score-=1024*c->penalty_factor;
-                    
-                    for(i=0; i<8; i++){
-                        if(score < best[i]){
-                            memmove(&best[i+1], &best[i], sizeof(int)*(7-i));
-                            memmove(&best_pos[i+1][0], &best_pos[i][0], sizeof(int)*2*(7-i));
-                            best[i]= score;
-                            best_pos[i][0]= nx + 4*mx;
-                            best_pos[i][1]= ny + 4*my;
-                            break;
-                        }
-                    }
-                }
-            }
-        }else{
-            int tl;
-            //FIXME this could overflow (unlikely though)
-            const int cx = 4*(r - l);
-            const int cx2= r + l - 2*c; 
-            const int cy = 4*(b - t);
-            const int cy2= b + t - 2*c;
-            int cxy;
-              
-            if(map[(index-(1<<ME_MAP_SHIFT)-1)&(ME_MAP_SIZE-1)] == (my<<ME_MAP_MV_BITS) + mx + map_generation && 0){ //FIXME
-                tl= score_map[(index-(1<<ME_MAP_SHIFT)-1)&(ME_MAP_SIZE-1)];
-            }else{
-                tl= cmp(s, mx-1, my-1, 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);//FIXME wrong if chroma me is different
-            }
-            
-            cxy= 2*tl + (cx + cy)/4 - (cx2 + cy2) - 2*c; 
-           
-            assert(16*cx2 + 4*cx + 32*c == 32*r);
-            assert(16*cx2 - 4*cx + 32*c == 32*l);
-            assert(16*cy2 + 4*cy + 32*c == 32*b);
-            assert(16*cy2 - 4*cy + 32*c == 32*t);
-            assert(16*cxy + 16*cy2 + 16*cx2 - 4*cy - 4*cx + 32*c == 32*tl);
-            
-            for(ny= -3; ny <= 3; ny++){
-                for(nx= -3; nx <= 3; nx++){
-                    //FIXME this could overflow (unlikely though)
-                    int score= ny*nx*cxy + nx*nx*cx2 + ny*ny*cy2 + nx*cx + ny*cy + 32*c; //FIXME factor
-                    int i;
-                    
-                    if((nx&3)==0 && (ny&3)==0) continue;
-                
-                    score += 32*(mv_penalty[4*mx + nx - pred_x] + mv_penalty[4*my + ny - pred_y])*penalty_factor;
-//                    if(nx&1) score-=32*c->penalty_factor;
-  //                  if(ny&1) score-=32*c->penalty_factor;
-                    
-                    for(i=0; i<8; i++){
-                        if(score < best[i]){
-                            memmove(&best[i+1], &best[i], sizeof(int)*(7-i));
-                            memmove(&best_pos[i+1][0], &best_pos[i][0], sizeof(int)*2*(7-i));
-                            best[i]= score;
-                            best_pos[i][0]= nx + 4*mx;
-                            best_pos[i][1]= ny + 4*my;
-                            break;
-                        }
-                    }
-                }
-            }            
-        }
-        for(i=0; i<subpel_quality; i++){
-            nx= best_pos[i][0];
-            ny= best_pos[i][1];
-            CHECK_QUARTER_MV(nx&3, ny&3, nx>>2, ny>>2)
-        }
-
-#if 0
-            const int tl= score_map[(index-(1<<ME_MAP_SHIFT)-1)&(ME_MAP_SIZE-1)];
-            const int bl= score_map[(index+(1<<ME_MAP_SHIFT)-1)&(ME_MAP_SIZE-1)];
-            const int tr= score_map[(index-(1<<ME_MAP_SHIFT)+1)&(ME_MAP_SIZE-1)];
-            const int br= score_map[(index+(1<<ME_MAP_SHIFT)+1)&(ME_MAP_SIZE-1)];
-//            if(l < r && l < t && l < b && l < tl && l < bl && l < tr && l < br && bl < tl){
-            if(tl<br){
-
-//            nx= FFMAX(4*mx - bx, bx - 4*mx);
-//            ny= FFMAX(4*my - by, by - 4*my);
-            
-            static int stats[7][7], count;
-            count++;
-            stats[4*mx - bx + 3][4*my - by + 3]++;
-            if(256*256*256*64 % count ==0){
-                for(i=0; i<49; i++){
-                    if((i%7)==0) printf("\n");
-                    printf("%6d ", stats[0][i]);
-                }
-                printf("\n");
-            }
-            }
-#endif
-#else
-
-        CHECK_QUARTER_MV(2, 2, mx-1, my-1)
-        CHECK_QUARTER_MV(0, 2, mx  , my-1)        
-        CHECK_QUARTER_MV(2, 2, mx  , my-1)
-        CHECK_QUARTER_MV(2, 0, mx  , my  )
-        CHECK_QUARTER_MV(2, 2, mx  , my  )
-        CHECK_QUARTER_MV(0, 2, mx  , my  )
-        CHECK_QUARTER_MV(2, 2, mx-1, my  )
-        CHECK_QUARTER_MV(2, 0, mx-1, my  )
-        
-        nx= bx;
-        ny= by;
-        
-        for(i=0; i<8; i++){
-            int ox[8]= {0, 1, 1, 1, 0,-1,-1,-1};
-            int oy[8]= {1, 1, 0,-1,-1,-1, 0, 1};
-            CHECK_QUARTER_MV((nx + ox[i])&3, (ny + oy[i])&3, (nx + ox[i])>>2, (ny + oy[i])>>2)
-        }
-#endif
-#if 0
-        //outer ring
-        CHECK_QUARTER_MV(1, 3, mx-1, my-1)
-        CHECK_QUARTER_MV(1, 2, mx-1, my-1)
-        CHECK_QUARTER_MV(1, 1, mx-1, my-1)
-        CHECK_QUARTER_MV(2, 1, mx-1, my-1)
-        CHECK_QUARTER_MV(3, 1, mx-1, my-1)
-        CHECK_QUARTER_MV(0, 1, mx  , my-1)
-        CHECK_QUARTER_MV(1, 1, mx  , my-1)
-        CHECK_QUARTER_MV(2, 1, mx  , my-1)
-        CHECK_QUARTER_MV(3, 1, mx  , my-1)
-        CHECK_QUARTER_MV(3, 2, mx  , my-1)
-        CHECK_QUARTER_MV(3, 3, mx  , my-1)
-        CHECK_QUARTER_MV(3, 0, mx  , my  )
-        CHECK_QUARTER_MV(3, 1, mx  , my  )
-        CHECK_QUARTER_MV(3, 2, mx  , my  )
-        CHECK_QUARTER_MV(3, 3, mx  , my  )
-        CHECK_QUARTER_MV(2, 3, mx  , my  )
-        CHECK_QUARTER_MV(1, 3, mx  , my  )
-        CHECK_QUARTER_MV(0, 3, mx  , my  )
-        CHECK_QUARTER_MV(3, 3, mx-1, my  )
-        CHECK_QUARTER_MV(2, 3, mx-1, my  )
-        CHECK_QUARTER_MV(1, 3, mx-1, my  )
-        CHECK_QUARTER_MV(1, 2, mx-1, my  )
-        CHECK_QUARTER_MV(1, 1, mx-1, my  )
-        CHECK_QUARTER_MV(1, 0, mx-1, my  )
-#endif
-        assert(bx >= xmin*4 && bx <= xmax*4 && by >= ymin*4 && by <= ymax*4);
-
-        *mx_ptr = bx;
-        *my_ptr = by;
-    }else{
-        *mx_ptr =4*mx;
-        *my_ptr =4*my;
-    }
-
-    return dmin;
-}
-
-
-#define CHECK_MV(x,y)\
-{\
-    const int key= ((y)<<ME_MAP_MV_BITS) + (x) + map_generation;\
-    const int index= (((y)<<ME_MAP_SHIFT) + (x))&(ME_MAP_SIZE-1);\
-    assert((x) >= xmin);\
-    assert((x) <= xmax);\
-    assert((y) >= ymin);\
-    assert((y) <= ymax);\
-/*printf("check_mv %d %d\n", x, y);*/\
-    if(map[index]!=key){\
-        d= cmp(s, x, y, 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);\
-        map[index]= key;\
-        score_map[index]= d;\
-        d += (mv_penalty[((x)<<shift)-pred_x] + mv_penalty[((y)<<shift)-pred_y])*penalty_factor;\
-/*printf("score:%d\n", d);*/\
-        COPY3_IF_LT(dmin, d, best[0], x, best[1], y)\
-    }\
-}
-
-#define CHECK_CLIPED_MV(ax,ay)\
-{\
-    const int x= ax;\
-    const int y= ay;\
-    const int x2= FFMAX(xmin, FFMIN(x, xmax));\
-    const int y2= FFMAX(ymin, FFMIN(y, ymax));\
-    CHECK_MV(x2, y2)\
-}
-
-#define CHECK_MV_DIR(x,y,new_dir)\
-{\
-    const int key= ((y)<<ME_MAP_MV_BITS) + (x) + map_generation;\
-    const int index= (((y)<<ME_MAP_SHIFT) + (x))&(ME_MAP_SIZE-1);\
-/*printf("check_mv_dir %d %d %d\n", x, y, new_dir);*/\
-    if(map[index]!=key){\
-        d= cmp(s, x, y, 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);\
-        map[index]= key;\
-        score_map[index]= d;\
-        d += (mv_penalty[((x)<<shift)-pred_x] + mv_penalty[((y)<<shift)-pred_y])*penalty_factor;\
-/*printf("score:%d\n", d);*/\
-        if(d<dmin){\
-            best[0]=x;\
-            best[1]=y;\
-            dmin=d;\
-            next_dir= new_dir;\
-        }\
-    }\
-}
-
-#define check(x,y,S,v)\
-if( (x)<(xmin<<(S)) ) printf("%d %d %d %d %d xmin" #v, xmin, (x), (y), s->mb_x, s->mb_y);\
-if( (x)>(xmax<<(S)) ) printf("%d %d %d %d %d xmax" #v, xmax, (x), (y), s->mb_x, s->mb_y);\
-if( (y)<(ymin<<(S)) ) printf("%d %d %d %d %d ymin" #v, ymin, (x), (y), s->mb_x, s->mb_y);\
-if( (y)>(ymax<<(S)) ) printf("%d %d %d %d %d ymax" #v, ymax, (x), (y), s->mb_x, s->mb_y);\
-
-#define LOAD_COMMON2\
-    uint32_t *map= c->map;\
-    const int qpel= flags&FLAG_QPEL;\
-    const int shift= 1+qpel;\
-
-static always_inline int small_diamond_search(MpegEncContext * s, int *best, int dmin,
-                                       int src_index, int ref_index, int const penalty_factor,
-                                       int size, int h, int flags)
-{
-    MotionEstContext * const c= &s->me;
-    me_cmp_func cmpf, chroma_cmpf;
-    int next_dir=-1;
-    LOAD_COMMON
-    LOAD_COMMON2
-    int map_generation= c->map_generation;
-    
-    cmpf= s->dsp.me_cmp[size];
-    chroma_cmpf= s->dsp.me_cmp[size+1];
-
-    { /* ensure that the best point is in the MAP as h/qpel refinement needs it */
-        const int key= (best[1]<<ME_MAP_MV_BITS) + best[0] + map_generation;
-        const int index= ((best[1]<<ME_MAP_SHIFT) + best[0])&(ME_MAP_SIZE-1);
-        if(map[index]!=key){ //this will be executed only very rarey
-            score_map[index]= cmp(s, best[0], best[1], 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);
-            map[index]= key;
-        }
-    }
-
-    for(;;){
-        int d;
-        const int dir= next_dir;
-        const int x= best[0];
-        const int y= best[1];
-        next_dir=-1;
-
-//printf("%d", dir);
-        if(dir!=2 && x>xmin) CHECK_MV_DIR(x-1, y  , 0)
-        if(dir!=3 && y>ymin) CHECK_MV_DIR(x  , y-1, 1)
-        if(dir!=0 && x<xmax) CHECK_MV_DIR(x+1, y  , 2)
-        if(dir!=1 && y<ymax) CHECK_MV_DIR(x  , y+1, 3)
-
-        if(next_dir==-1){
-            return dmin;
-        }
-    }
-}
-
-static int funny_diamond_search(MpegEncContext * s, int *best, int dmin,
-                                       int src_index, int ref_index, int const penalty_factor,
-                                       int size, int h, int flags)
-{
-    MotionEstContext * const c= &s->me;
-    me_cmp_func cmpf, chroma_cmpf;
-    int dia_size;
-    LOAD_COMMON
-    LOAD_COMMON2
-    int map_generation= c->map_generation;
-    
-    cmpf= s->dsp.me_cmp[size];
-    chroma_cmpf= s->dsp.me_cmp[size+1];
-
-    for(dia_size=1; dia_size<=4; dia_size++){
-        int dir;
-        const int x= best[0];
-        const int y= best[1];
-        
-        if(dia_size&(dia_size-1)) continue;
-
-        if(   x + dia_size > xmax
-           || x - dia_size < xmin
-           || y + dia_size > ymax
-           || y - dia_size < ymin)
-           continue;
-        
-        for(dir= 0; dir<dia_size; dir+=2){
-            int d;
-
-            CHECK_MV(x + dir           , y + dia_size - dir);
-            CHECK_MV(x + dia_size - dir, y - dir           );
-            CHECK_MV(x - dir           , y - dia_size + dir);
-            CHECK_MV(x - dia_size + dir, y + dir           );
-        }
-
-        if(x!=best[0] || y!=best[1])
-            dia_size=0;
-#if 0
-{
-int dx, dy, i;
-static int stats[8*8];
-dx= ABS(x-best[0]);
-dy= ABS(y-best[1]);
-if(dy>dx){
-    dx^=dy; dy^=dx; dx^=dy;
-}
-stats[dy*8 + dx] ++;
-if(256*256*256*64 % (stats[0]+1)==0){
-    for(i=0; i<64; i++){
-        if((i&7)==0) printf("\n");
-        printf("%8d ", stats[i]);
-    }
-    printf("\n");
-}
-}
-#endif
-    }
-    return dmin;    
-}
-
-#define SAB_CHECK_MV(ax,ay)\
-{\
-    const int key= ((ay)<<ME_MAP_MV_BITS) + (ax) + map_generation;\
-    const int index= (((ay)<<ME_MAP_SHIFT) + (ax))&(ME_MAP_SIZE-1);\
-/*printf("sab check %d %d\n", ax, ay);*/\
-    if(map[index]!=key){\
-        d= cmp(s, ax, ay, 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);\
-        map[index]= key;\
-        score_map[index]= d;\
-        d += (mv_penalty[((ax)<<shift)-pred_x] + mv_penalty[((ay)<<shift)-pred_y])*penalty_factor;\
-/*printf("score: %d\n", d);*/\
-        if(d < minima[minima_count-1].height){\
-            int j=0;\
-            \
-            while(d >= minima[j].height) j++;\
-\
-            memmove(&minima [j+1], &minima [j], (minima_count - j - 1)*sizeof(Minima));\
-\
-            minima[j].checked= 0;\
-            minima[j].height= d;\
-            minima[j].x= ax;\
-            minima[j].y= ay;\
-            \
-            i=-1;\
-            continue;\
-        }\
-    }\
-}
-
-#define MAX_SAB_SIZE ME_MAP_SIZE
-static int sab_diamond_search(MpegEncContext * s, int *best, int dmin,
-                                       int src_index, int ref_index, int const penalty_factor,
-                                       int size, int h, int flags)
-{
-    MotionEstContext * const c= &s->me;
-    me_cmp_func cmpf, chroma_cmpf;
-    Minima minima[MAX_SAB_SIZE];
-    const int minima_count= ABS(c->dia_size);
-    int i, j;
-    LOAD_COMMON
-    LOAD_COMMON2
-    int map_generation= c->map_generation;
-    
-    cmpf= s->dsp.me_cmp[size];
-    chroma_cmpf= s->dsp.me_cmp[size+1];
-    
-    for(j=i=0; i<ME_MAP_SIZE; i++){
-        uint32_t key= map[i];
-
-        key += (1<<(ME_MAP_MV_BITS-1)) + (1<<(2*ME_MAP_MV_BITS-1));
-        
-        if((key&((-1)<<(2*ME_MAP_MV_BITS))) != map_generation) continue;
-        
-        assert(j<MAX_SAB_SIZE); //max j = number of predictors
-        
-        minima[j].height= score_map[i];
-        minima[j].x= key & ((1<<ME_MAP_MV_BITS)-1); key>>=ME_MAP_MV_BITS;
-        minima[j].y= key & ((1<<ME_MAP_MV_BITS)-1);
-        minima[j].x-= (1<<(ME_MAP_MV_BITS-1));
-        minima[j].y-= (1<<(ME_MAP_MV_BITS-1));
-        minima[j].checked=0;
-        if(minima[j].x || minima[j].y)
-            minima[j].height+= (mv_penalty[((minima[j].x)<<shift)-pred_x] + mv_penalty[((minima[j].y)<<shift)-pred_y])*penalty_factor;
-        
-        j++;
-    }
-    
-    qsort(minima, j, sizeof(Minima), minima_cmp);
-    
-    for(; j<minima_count; j++){
-        minima[j].height=256*256*256*64;
-        minima[j].checked=0;
-        minima[j].x= minima[j].y=0;
-    }
-    
-    for(i=0; i<minima_count; i++){
-        const int x= minima[i].x;
-        const int y= minima[i].y;
-        int d;
-        
-        if(minima[i].checked) continue;
-        
-        if(   x >= xmax || x <= xmin
-           || y >= ymax || y <= ymin)
-           continue;
-
-        SAB_CHECK_MV(x-1, y)
-        SAB_CHECK_MV(x+1, y)
-        SAB_CHECK_MV(x  , y-1)
-        SAB_CHECK_MV(x  , y+1)
-        
-        minima[i].checked= 1;
-    }
-    
-    best[0]= minima[0].x;
-    best[1]= minima[0].y;
-    dmin= minima[0].height;
-    
-    if(   best[0] < xmax && best[0] > xmin
-       && best[1] < ymax && best[1] > ymin){
-        int d;
-        //ensure that the refernece samples for hpel refinement are in the map
-        CHECK_MV(best[0]-1, best[1])
-        CHECK_MV(best[0]+1, best[1])
-        CHECK_MV(best[0], best[1]-1)
-        CHECK_MV(best[0], best[1]+1)
-    }
-    return dmin;    
-}
-
-static int var_diamond_search(MpegEncContext * s, int *best, int dmin,
-                                       int src_index, int ref_index, int const penalty_factor,
-                                       int size, int h, int flags)
-{
-    MotionEstContext * const c= &s->me;
-    me_cmp_func cmpf, chroma_cmpf;
-    int dia_size;
-    LOAD_COMMON
-    LOAD_COMMON2
-    int map_generation= c->map_generation;
-    
-    cmpf= s->dsp.me_cmp[size];
-    chroma_cmpf= s->dsp.me_cmp[size+1];
-
-    for(dia_size=1; dia_size<=c->dia_size; dia_size++){
-        int dir, start, end;
-        const int x= best[0];
-        const int y= best[1];
-
-        start= FFMAX(0, y + dia_size - ymax);
-        end  = FFMIN(dia_size, xmax - x + 1);
-        for(dir= start; dir<end; dir++){
-            int d;
-
-//check(x + dir,y + dia_size - dir,0, a0)
-            CHECK_MV(x + dir           , y + dia_size - dir);
-        }
-
-        start= FFMAX(0, x + dia_size - xmax);
-        end  = FFMIN(dia_size, y - ymin + 1);
-        for(dir= start; dir<end; dir++){
-            int d;
-
-//check(x + dia_size - dir, y - dir,0, a1)
-            CHECK_MV(x + dia_size - dir, y - dir           );
-        }
-
-        start= FFMAX(0, -y + dia_size + ymin );
-        end  = FFMIN(dia_size, x - xmin + 1);
-        for(dir= start; dir<end; dir++){
-            int d;
-
-//check(x - dir,y - dia_size + dir,0, a2)
-            CHECK_MV(x - dir           , y - dia_size + dir);
-        }
-
-        start= FFMAX(0, -x + dia_size + xmin );
-        end  = FFMIN(dia_size, ymax - y + 1);
-        for(dir= start; dir<end; dir++){
-            int d;
-
-//check(x - dia_size + dir, y + dir,0, a3)
-            CHECK_MV(x - dia_size + dir, y + dir           );
-        }
-
-        if(x!=best[0] || y!=best[1])
-            dia_size=0;
-#if 0
-{
-int dx, dy, i;
-static int stats[8*8];
-dx= ABS(x-best[0]);
-dy= ABS(y-best[1]);
-stats[dy*8 + dx] ++;
-if(256*256*256*64 % (stats[0]+1)==0){
-    for(i=0; i<64; i++){
-        if((i&7)==0) printf("\n");
-        printf("%6d ", stats[i]);
-    }
-    printf("\n");
-}
-}
-#endif
-    }
-    return dmin;    
-}
-
-static always_inline int diamond_search(MpegEncContext * s, int *best, int dmin,
-                                       int src_index, int ref_index, int const penalty_factor,
-                                       int size, int h, int flags){
-    MotionEstContext * const c= &s->me;
-    if(c->dia_size==-1)
-        return funny_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
-    else if(c->dia_size<-1)
-        return   sab_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
-    else if(c->dia_size<2)
-        return small_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
-    else
-        return   var_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
-}
-
-static always_inline int epzs_motion_search_internal(MpegEncContext * s, int *mx_ptr, int *my_ptr,
-                             int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2], 
-                             int ref_mv_scale, int flags, int size, int h)
-{
-    MotionEstContext * const c= &s->me;
-    int best[2]={0, 0};
-    int d, dmin;
-    int map_generation;
-    int penalty_factor;
-    const int ref_mv_stride= s->mb_stride; //pass as arg  FIXME
-    const int ref_mv_xy= s->mb_x + s->mb_y*ref_mv_stride; //add to last_mv beforepassing FIXME
-    me_cmp_func cmpf, chroma_cmpf;
-    
-    LOAD_COMMON
-    LOAD_COMMON2
-    
-    if(c->pre_pass){
-        penalty_factor= c->pre_penalty_factor;
-        cmpf= s->dsp.me_pre_cmp[size];
-        chroma_cmpf= s->dsp.me_pre_cmp[size+1];
-    }else{
-        penalty_factor= c->penalty_factor;
-        cmpf= s->dsp.me_cmp[size];
-        chroma_cmpf= s->dsp.me_cmp[size+1];
-    }
-    
-    map_generation= update_map_generation(c);
-
-    assert(cmpf);
-    dmin= cmp(s, 0, 0, 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);
-    map[0]= map_generation;
-    score_map[0]= dmin;
-
-    /* first line */
-    if (s->first_slice_line) {
-        CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
-        CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, 
-                        (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
-    }else{
-        if(dmin<h*h && ( P_LEFT[0]    |P_LEFT[1]
-                        |P_TOP[0]     |P_TOP[1]
-                        |P_TOPRIGHT[0]|P_TOPRIGHT[1])==0){
-            *mx_ptr= 0;
-            *my_ptr= 0;
-            c->skip=1;
-            return dmin;
-        }
-        CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift)
-        if(dmin>h*h*2){
-            CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, 
-                            (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
-            CHECK_MV(P_LEFT[0]    >>shift, P_LEFT[1]    >>shift)
-            CHECK_MV(P_TOP[0]     >>shift, P_TOP[1]     >>shift)
-            CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
-        }
-    }
-    if(dmin>h*h*4){
-        if(c->pre_pass){
-            CHECK_CLIPED_MV((last_mv[ref_mv_xy-1][0]*ref_mv_scale + (1<<15))>>16, 
-                            (last_mv[ref_mv_xy-1][1]*ref_mv_scale + (1<<15))>>16)
-            if(!s->first_slice_line)
-                CHECK_CLIPED_MV((last_mv[ref_mv_xy-ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16, 
-                                (last_mv[ref_mv_xy-ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
-        }else{
-            CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16, 
-                            (last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
-            if(s->mb_y+1<s->end_mb_y)  //FIXME replace at least with last_slice_line
-                CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16, 
-                                (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
-        }
-    }
-
-    if(c->avctx->last_predictor_count){
-        const int count= c->avctx->last_predictor_count;
-        const int xstart= FFMAX(0, s->mb_x - count);
-        const int ystart= FFMAX(0, s->mb_y - count);
-        const int xend= FFMIN(s->mb_width , s->mb_x + count + 1);
-        const int yend= FFMIN(s->mb_height, s->mb_y + count + 1);
-        int mb_y;
-
-        for(mb_y=ystart; mb_y<yend; mb_y++){
-            int mb_x;
-            for(mb_x=xstart; mb_x<xend; mb_x++){
-                const int xy= mb_x + 1 + (mb_y + 1)*ref_mv_stride;
-                int mx= (last_mv[xy][0]*ref_mv_scale + (1<<15))>>16;
-                int my= (last_mv[xy][1]*ref_mv_scale + (1<<15))>>16;
-
-                if(mx>xmax || mx<xmin || my>ymax || my<ymin) continue;
-                CHECK_MV(mx,my)
-            }
-        }
-    }
-
-//check(best[0],best[1],0, b0)
-    dmin= diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
-
-//check(best[0],best[1],0, b1)
-    *mx_ptr= best[0];
-    *my_ptr= best[1];    
-
-//    printf("%d %d %d \n", best[0], best[1], dmin);
-    return dmin;
-}
-
-//this function is dedicated to the braindamaged gcc
-inline int ff_epzs_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr,
-                             int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2], 
-                             int ref_mv_scale, int size, int h)
-{
-    MotionEstContext * const c= &s->me;
-//FIXME convert other functions in the same way if faster
-    if(c->flags==0 && h==16 && size==0){
-        return epzs_motion_search_internal(s, mx_ptr, my_ptr, P, src_index, ref_index, last_mv, ref_mv_scale, 0, 0, 16);
-//    case FLAG_QPEL:
-//        return epzs_motion_search_internal(s, mx_ptr, my_ptr, P, src_index, ref_index, last_mv, ref_mv_scale, FLAG_QPEL);
-    }else{
-        return epzs_motion_search_internal(s, mx_ptr, my_ptr, P, src_index, ref_index, last_mv, ref_mv_scale, c->flags, size, h);
-    }
-}
-
-static int epzs_motion_search4(MpegEncContext * s,
-                             int *mx_ptr, int *my_ptr, int P[10][2],
-                             int src_index, int ref_index, int16_t (*last_mv)[2], 
-                             int ref_mv_scale)
-{
-    MotionEstContext * const c= &s->me;
-    int best[2]={0, 0};
-    int d, dmin; 
-    int map_generation;
-    const int penalty_factor= c->penalty_factor;
-    const int size=1;
-    const int h=8;
-    const int ref_mv_stride= s->mb_stride;
-    const int ref_mv_xy= s->mb_x + s->mb_y *ref_mv_stride;
-    me_cmp_func cmpf, chroma_cmpf;
-    LOAD_COMMON
-    int flags= c->flags;
-    LOAD_COMMON2
-    
-    cmpf= s->dsp.me_cmp[size];
-    chroma_cmpf= s->dsp.me_cmp[size+1];
-
-    map_generation= update_map_generation(c);
-
-    dmin = 1000000;
-//printf("%d %d %d %d //",xmin, ymin, xmax, ymax); 
-    /* first line */
-    if (s->first_slice_line) {
-	CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
-        CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, 
-                        (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
-        CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
-    }else{
-        CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
-        //FIXME try some early stop
-        if(dmin>64*2){
-            CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift)
-            CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
-            CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift)
-            CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
-            CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, 
-                            (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
-        }
-    }
-    if(dmin>64*4){
-        CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16, 
-                        (last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
-        if(s->mb_y+1<s->end_mb_y)  //FIXME replace at least with last_slice_line
-            CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16, 
-                            (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
-    }
-
-    dmin= diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
-
-    *mx_ptr= best[0];
-    *my_ptr= best[1];    
-
-//    printf("%d %d %d \n", best[0], best[1], dmin);
-    return dmin;
-}
-
-//try to merge with above FIXME (needs PSNR test)
-static int epzs_motion_search2(MpegEncContext * s,
-                             int *mx_ptr, int *my_ptr, int P[10][2],
-                             int src_index, int ref_index, int16_t (*last_mv)[2], 
-                             int ref_mv_scale)
-{
-    MotionEstContext * const c= &s->me;
-    int best[2]={0, 0};
-    int d, dmin; 
-    int map_generation;
-    const int penalty_factor= c->penalty_factor;
-    const int size=0; //FIXME pass as arg
-    const int h=8;
-    const int ref_mv_stride= s->mb_stride;
-    const int ref_mv_xy= s->mb_x + s->mb_y *ref_mv_stride;
-    me_cmp_func cmpf, chroma_cmpf;
-    LOAD_COMMON
-    int flags= c->flags;
-    LOAD_COMMON2
-    
-    cmpf= s->dsp.me_cmp[size];
-    chroma_cmpf= s->dsp.me_cmp[size+1];
-
-    map_generation= update_map_generation(c);
-
-    dmin = 1000000;
-//printf("%d %d %d %d //",xmin, ymin, xmax, ymax); 
-    /* first line */
-    if (s->first_slice_line) {
-	CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
-        CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, 
-                        (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
-        CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
-    }else{
-        CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
-        //FIXME try some early stop
-        if(dmin>64*2){
-            CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift)
-            CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
-            CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift)
-            CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
-            CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, 
-                            (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
-        }
-    }
-    if(dmin>64*4){
-        CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16, 
-                        (last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
-        if(s->mb_y+1<s->end_mb_y)  //FIXME replace at least with last_slice_line
-            CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16, 
-                            (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
-    }
-
-    dmin= diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
-
-    *mx_ptr= best[0];
-    *my_ptr= best[1];    
-
-//    printf("%d %d %d \n", best[0], best[1], dmin);
-    return dmin;
-}
diff --git a/ffmpeg.src/libavcodec/mpeg12.c b/ffmpeg.src/libavcodec/mpeg12.c
deleted file mode 100644
index 94450a0..0000000
--- a/ffmpeg.src/libavcodec/mpeg12.c
+++ /dev/null
@@ -1,3316 +0,0 @@
-/*
- * MPEG1 codec / MPEG2 decoder
- * Copyright (c) 2000,2001 Fabrice Bellard.
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at> 
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-/**
- * @file mpeg12.c
- * MPEG1/2 codec
- */
- 
-//#define DEBUG
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-
-#include "mpeg12data.h"
-
-//#undef NDEBUG
-//#include <assert.h>
-
-
-/* Start codes. */
-#define SEQ_END_CODE		0x000001b7
-#define SEQ_START_CODE		0x000001b3
-#define GOP_START_CODE		0x000001b8
-#define PICTURE_START_CODE	0x00000100
-#define SLICE_MIN_START_CODE	0x00000101
-#define SLICE_MAX_START_CODE	0x000001af
-#define EXT_START_CODE		0x000001b5
-#define USER_START_CODE		0x000001b2
-
-#define DC_VLC_BITS 9
-#define MV_VLC_BITS 9
-#define MBINCR_VLC_BITS 9
-#define MB_PAT_VLC_BITS 9
-#define MB_PTYPE_VLC_BITS 6
-#define MB_BTYPE_VLC_BITS 6
-#define TEX_VLC_BITS 9
-
-#ifdef CONFIG_ENCODERS
-static void mpeg1_encode_block(MpegEncContext *s, 
-                         DCTELEM *block, 
-                         int component);
-static void mpeg1_encode_motion(MpegEncContext *s, int val, int f_or_b_code);    // RAL: f_code parameter added
-#endif //CONFIG_ENCODERS
-static inline int mpeg1_decode_block_inter(MpegEncContext *s, 
-                              DCTELEM *block, 
-                              int n);
-static inline int mpeg1_decode_block_intra(MpegEncContext *s, 
-                              DCTELEM *block, 
-                              int n);
-static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, DCTELEM *block, int n);
-static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, 
-                                        DCTELEM *block, 
-                                        int n);
-static inline int mpeg2_decode_block_intra(MpegEncContext *s, 
-                                    DCTELEM *block, 
-                                    int n);
-static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s, DCTELEM *block, int n);
-static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n);
-static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred);
-static void exchange_uv(MpegEncContext *s);
-
-#ifdef HAVE_XVMC
-extern int XVMC_field_start(MpegEncContext *s, AVCodecContext *avctx);
-extern int XVMC_field_end(MpegEncContext *s);
-extern void XVMC_pack_pblocks(MpegEncContext *s,int cbp);
-extern void XVMC_init_block(MpegEncContext *s);//set s->block
-#endif
-
-const enum PixelFormat pixfmt_yuv_420[]= {PIX_FMT_YUV420P,-1};
-const enum PixelFormat pixfmt_yuv_422[]= {PIX_FMT_YUV422P,-1};
-const enum PixelFormat pixfmt_yuv_444[]= {PIX_FMT_YUV444P,-1};
-const enum PixelFormat pixfmt_xvmc_mpg2_420[] = {
-                                           PIX_FMT_XVMC_MPEG2_IDCT,
-                                           PIX_FMT_XVMC_MPEG2_MC,
-					   -1};
-#ifdef CONFIG_ENCODERS
-static uint8_t (*mv_penalty)[MAX_MV*2+1]= NULL;
-static uint8_t fcode_tab[MAX_MV*2+1];
-
-static uint32_t uni_mpeg1_ac_vlc_bits[64*64*2];
-static uint8_t  uni_mpeg1_ac_vlc_len [64*64*2];
-
-/* simple include everything table for dc, first byte is bits number next 3 are code*/
-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];
-#endif //CONFIG_ENCODERS
-
-static void init_2d_vlc_rl(RLTable *rl, int use_static)
-{
-    int i;
-    
-    init_vlc(&rl->vlc, TEX_VLC_BITS, rl->n + 2, 
-             &rl->table_vlc[0][1], 4, 2,
-             &rl->table_vlc[0][0], 4, 2, use_static);
-
-    if(use_static)    
-        rl->rl_vlc[0]= av_mallocz_static(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
-    else
-        rl->rl_vlc[0]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
-
-    for(i=0; i<rl->vlc.table_size; i++){
-        int code= rl->vlc.table[i][0];
-        int len = rl->vlc.table[i][1];
-        int level, run;
-    
-        if(len==0){ // illegal code
-            run= 65;
-            level= MAX_LEVEL;
-        }else if(len<0){ //more bits needed
-            run= 0;
-            level= code;
-        }else{
-            if(code==rl->n){ //esc
-                run= 65;
-                level= 0;
-            }else if(code==rl->n+1){ //eob
-                run= 0;
-                level= 127;
-            }else{
-                run=   rl->table_run  [code] + 1;
-                level= rl->table_level[code];
-            }
-        }
-        rl->rl_vlc[0][i].len= len;
-        rl->rl_vlc[0][i].level= level;
-        rl->rl_vlc[0][i].run= run;
-    }
-}
-
-#ifdef CONFIG_ENCODERS
-static void init_uni_ac_vlc(RLTable *rl, uint32_t *uni_ac_vlc_bits, uint8_t *uni_ac_vlc_len){
-    int i;
-
-    for(i=0; i<128; i++){
-        int level= i-64;
-        int run;
-        for(run=0; run<64; run++){
-            int len, bits, code;
-            
-            int alevel= ABS(level);
-            int sign= (level>>31)&1;
-
-            if (alevel > rl->max_level[0][run])
-                code= 111; /*rl->n*/
-            else
-                code= rl->index_run[0][run] + alevel - 1;
-
-            if (code < 111 /* rl->n */) {
-	    	/* store the vlc & sign at once */
-                len=   mpeg1_vlc[code][1]+1;
-                bits= (mpeg1_vlc[code][0]<<1) + sign;
-            } else {
-                len=  mpeg1_vlc[111/*rl->n*/][1]+6;
-                bits= mpeg1_vlc[111/*rl->n*/][0]<<6;
-
-                bits|= run;
-                if (alevel < 128) {
-                    bits<<=8; len+=8;
-                    bits|= level & 0xff;
-                } else {
-                    bits<<=16; len+=16;
-                    bits|= level & 0xff;
-                    if (level < 0) {
-                        bits|= 0x8001 + level + 255;
-                    } else {
-                        bits|= level & 0xffff;
-                    }
-                }
-            }
-
-            uni_ac_vlc_bits[UNI_AC_ENC_INDEX(run, i)]= bits;
-            uni_ac_vlc_len [UNI_AC_ENC_INDEX(run, i)]= len;
-        }
-    }
-}
-
-
-static int find_frame_rate_index(MpegEncContext *s){
-    int i;
-    int64_t dmin= INT64_MAX;
-    int64_t d;
-
-    for(i=1;i<14;i++) {
-        int64_t n0= 1001LL/frame_rate_tab[i].den*frame_rate_tab[i].num*s->avctx->time_base.num;
-        int64_t n1= 1001LL*s->avctx->time_base.den;
-        if(s->avctx->strict_std_compliance > FF_COMPLIANCE_INOFFICIAL && i>=9) break;
-
-        d = ABS(n0 - n1);
-        if(d < dmin){
-            dmin=d;
-            s->frame_rate_index= i;
-        }
-    }
-    if(dmin)
-        return -1;
-    else
-        return 0;
-}
-
-static int encode_init(AVCodecContext *avctx)
-{
-    MpegEncContext *s = avctx->priv_data;
-
-    if(MPV_encode_init(avctx) < 0)
-        return -1;
-
-    if(find_frame_rate_index(s) < 0){
-        if(s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL){
-            av_log(avctx, AV_LOG_ERROR, "MPEG1/2 does not support %d/%d fps\n", avctx->time_base.den, avctx->time_base.num);
-            return -1;
-        }else{
-            av_log(avctx, AV_LOG_INFO, "MPEG1/2 does not support %d/%d fps, there may be AV sync issues\n", avctx->time_base.den, avctx->time_base.num);
-        }
-    }
-    
-    return 0;
-}
-
-static void put_header(MpegEncContext *s, int header)
-{
-    align_put_bits(&s->pb);
-    put_bits(&s->pb, 16, header>>16);
-    put_bits(&s->pb, 16, header&0xFFFF);
-}
-
-/* put sequence header if needed */
-static void mpeg1_encode_sequence_header(MpegEncContext *s)
-{
-        unsigned int vbv_buffer_size;
-        unsigned int fps, v;
-        int i;
-        uint64_t time_code;
-        float best_aspect_error= 1E10;
-        float aspect_ratio= av_q2d(s->avctx->sample_aspect_ratio);
-        int constraint_parameter_flag;
-        
-        if(aspect_ratio==0.0) aspect_ratio= 1.0; //pixel aspect 1:1 (VGA)
-        
-        if (s->current_picture.key_frame) {
-            AVRational framerate= frame_rate_tab[s->frame_rate_index];
-
-            /* mpeg1 header repeated every gop */
-            put_header(s, SEQ_START_CODE);
- 
-            put_bits(&s->pb, 12, s->width);
-            put_bits(&s->pb, 12, s->height);
-            
-            for(i=1; i<15; i++){
-                float error= aspect_ratio;
-                if(s->codec_id == CODEC_ID_MPEG1VIDEO || i <=1)
-                    error-= 1.0/mpeg1_aspect[i];
-                else
-                    error-= av_q2d(mpeg2_aspect[i])*s->height/s->width;
-             
-                error= ABS(error);
-                
-                if(error < best_aspect_error){
-                    best_aspect_error= error;
-                    s->aspect_ratio_info= i;
-                }
-            }
-            
-            put_bits(&s->pb, 4, s->aspect_ratio_info);
-            put_bits(&s->pb, 4, s->frame_rate_index);
-            
-            if(s->avctx->rc_max_rate){
-                v = (s->avctx->rc_max_rate + 399) / 400;
-                if (v > 0x3ffff && s->codec_id == CODEC_ID_MPEG1VIDEO)
-                    v = 0x3ffff;
-            }else{
-                v= 0x3FFFF;
-            }
-
-            if(s->avctx->rc_buffer_size)
-                vbv_buffer_size = s->avctx->rc_buffer_size;
-            else
-                /* VBV calculation: Scaled so that a VCD has the proper VBV size of 40 kilobytes */
-                vbv_buffer_size = (( 20 * s->bit_rate) / (1151929 / 2)) * 8 * 1024;
-            vbv_buffer_size= (vbv_buffer_size + 16383) / 16384;
-
-            put_bits(&s->pb, 18, v & 0x3FFFF);
-            put_bits(&s->pb, 1, 1); /* marker */
-            put_bits(&s->pb, 10, vbv_buffer_size & 0x3FF);
-
-            constraint_parameter_flag= 
-                s->width <= 768 && s->height <= 576 && 
-                s->mb_width * s->mb_height <= 396 &&
-                s->mb_width * s->mb_height * framerate.num <= framerate.den*396*25 &&
-                framerate.num <= framerate.den*30 &&
-                s->avctx->me_range && s->avctx->me_range < 128 &&
-                vbv_buffer_size <= 20 &&
-                v <= 1856000/400 &&
-                s->codec_id == CODEC_ID_MPEG1VIDEO;
-                
-            put_bits(&s->pb, 1, constraint_parameter_flag);
-            
-            ff_write_quant_matrix(&s->pb, s->avctx->intra_matrix);
-            ff_write_quant_matrix(&s->pb, s->avctx->inter_matrix);
-
-            if(s->codec_id == CODEC_ID_MPEG2VIDEO){
-                put_header(s, EXT_START_CODE);
-                put_bits(&s->pb, 4, 1); //seq ext
-                put_bits(&s->pb, 1, 0); //esc
-                
-                if(s->avctx->profile == FF_PROFILE_UNKNOWN){
-                    put_bits(&s->pb, 3, 4); //profile
-                }else{
-                    put_bits(&s->pb, 3, s->avctx->profile); //profile
-                }
-
-                if(s->avctx->level == FF_LEVEL_UNKNOWN){
-                    put_bits(&s->pb, 4, 8); //level
-                }else{
-                    put_bits(&s->pb, 4, s->avctx->level); //level
-                }
-
-                put_bits(&s->pb, 1, s->progressive_sequence);
-                put_bits(&s->pb, 2, 1); //chroma format 4:2:0
-                put_bits(&s->pb, 2, 0); //horizontal size ext
-                put_bits(&s->pb, 2, 0); //vertical size ext
-                put_bits(&s->pb, 12, v>>18); //bitrate ext
-                put_bits(&s->pb, 1, 1); //marker
-                put_bits(&s->pb, 8, vbv_buffer_size >>10); //vbv buffer ext
-                put_bits(&s->pb, 1, s->low_delay);
-                put_bits(&s->pb, 2, 0); // frame_rate_ext_n
-                put_bits(&s->pb, 5, 0); // frame_rate_ext_d
-            }
-            
-            put_header(s, GOP_START_CODE);
-            put_bits(&s->pb, 1, 0); /* do drop frame */
-            /* time code : we must convert from the real frame rate to a
-               fake mpeg frame rate in case of low frame rate */
-            fps = (framerate.num + framerate.den/2)/ framerate.den;
-            time_code = s->current_picture_ptr->coded_picture_number;
-
-            s->gop_picture_number = time_code;
-            put_bits(&s->pb, 5, (uint32_t)((time_code / (fps * 3600)) % 24));
-            put_bits(&s->pb, 6, (uint32_t)((time_code / (fps * 60)) % 60));
-            put_bits(&s->pb, 1, 1);
-            put_bits(&s->pb, 6, (uint32_t)((time_code / fps) % 60));
-            put_bits(&s->pb, 6, (uint32_t)((time_code % fps)));
-            put_bits(&s->pb, 1, !!(s->flags & CODEC_FLAG_CLOSED_GOP));
-            put_bits(&s->pb, 1, 0); /* broken link */
-        }
-}
-
-static inline void encode_mb_skip_run(MpegEncContext *s, int run){
-    while (run >= 33) {
-        put_bits(&s->pb, 11, 0x008);
-        run -= 33;
-    }
-    put_bits(&s->pb, mbAddrIncrTable[run][1], 
-             mbAddrIncrTable[run][0]);
-}
-#endif //CONFIG_ENCODERS
-
-static void common_init(MpegEncContext *s)
-{
-
-    s->y_dc_scale_table=
-    s->c_dc_scale_table= mpeg2_dc_scale_table[s->intra_dc_precision];
-
-}
-
-void ff_mpeg1_clean_buffers(MpegEncContext *s){
-    s->last_dc[0] = 1 << (7 + s->intra_dc_precision);
-    s->last_dc[1] = s->last_dc[0];
-    s->last_dc[2] = s->last_dc[0];
-    memset(s->last_mv, 0, sizeof(s->last_mv));
-}
-
-#ifdef CONFIG_ENCODERS
-
-void ff_mpeg1_encode_slice_header(MpegEncContext *s){
-    put_header(s, SLICE_MIN_START_CODE + s->mb_y);
-    put_bits(&s->pb, 5, s->qscale); /* quantizer scale */
-    put_bits(&s->pb, 1, 0); /* slice extra information */
-}
-
-void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
-{
-    mpeg1_encode_sequence_header(s);
-
-    /* mpeg1 picture header */
-    put_header(s, PICTURE_START_CODE);
-    /* temporal reference */
-
-    // RAL: s->picture_number instead of s->fake_picture_number
-    put_bits(&s->pb, 10, (s->picture_number - 
-                          s->gop_picture_number) & 0x3ff); 
-    put_bits(&s->pb, 3, s->pict_type);
-
-    s->vbv_delay_ptr= s->pb.buf + put_bits_count(&s->pb)/8;
-    put_bits(&s->pb, 16, 0xFFFF); /* vbv_delay */
-    
-    // RAL: Forward f_code also needed for B frames
-    if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) {
-        put_bits(&s->pb, 1, 0); /* half pel coordinates */
-        if(s->codec_id == CODEC_ID_MPEG1VIDEO)
-            put_bits(&s->pb, 3, s->f_code); /* forward_f_code */
-        else
-            put_bits(&s->pb, 3, 7); /* forward_f_code */
-    }
-    
-    // RAL: Backward f_code necessary for B frames
-    if (s->pict_type == B_TYPE) {
-        put_bits(&s->pb, 1, 0); /* half pel coordinates */
-        if(s->codec_id == CODEC_ID_MPEG1VIDEO)
-            put_bits(&s->pb, 3, s->b_code); /* backward_f_code */
-        else
-            put_bits(&s->pb, 3, 7); /* backward_f_code */
-    }
-
-    put_bits(&s->pb, 1, 0); /* extra bit picture */
-
-    s->frame_pred_frame_dct = 1;
-    if(s->codec_id == CODEC_ID_MPEG2VIDEO){
-        put_header(s, EXT_START_CODE);
-        put_bits(&s->pb, 4, 8); //pic ext
-        if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) {
-            put_bits(&s->pb, 4, s->f_code);
-            put_bits(&s->pb, 4, s->f_code);
-        }else{
-            put_bits(&s->pb, 8, 255);
-        }
-        if (s->pict_type == B_TYPE) {
-            put_bits(&s->pb, 4, s->b_code);
-            put_bits(&s->pb, 4, s->b_code);
-        }else{
-            put_bits(&s->pb, 8, 255);
-        }
-        put_bits(&s->pb, 2, s->intra_dc_precision);
-        
-        assert(s->picture_structure == PICT_FRAME);
-        put_bits(&s->pb, 2, s->picture_structure);
-        if (s->progressive_sequence) {
-            put_bits(&s->pb, 1, 0); /* no repeat */
-        } else {
-            put_bits(&s->pb, 1, s->current_picture_ptr->top_field_first);
-        }
-        /* XXX: optimize the generation of this flag with entropy
-           measures */
-        s->frame_pred_frame_dct = s->progressive_sequence;
-        
-        put_bits(&s->pb, 1, s->frame_pred_frame_dct);
-        put_bits(&s->pb, 1, s->concealment_motion_vectors);
-        put_bits(&s->pb, 1, s->q_scale_type);
-        put_bits(&s->pb, 1, s->intra_vlc_format);
-        put_bits(&s->pb, 1, s->alternate_scan);
-        put_bits(&s->pb, 1, s->repeat_first_field);
-        s->progressive_frame = s->progressive_sequence;
-        put_bits(&s->pb, 1, s->chroma_420_type=s->progressive_frame);
-        put_bits(&s->pb, 1, s->progressive_frame);
-        put_bits(&s->pb, 1, 0); //composite_display_flag
-    }
-    if(s->flags & CODEC_FLAG_SVCD_SCAN_OFFSET){
-        int i;
-
-        put_header(s, USER_START_CODE);
-        for(i=0; i<sizeof(svcd_scan_offset_placeholder); i++){
-            put_bits(&s->pb, 8, svcd_scan_offset_placeholder[i]);
-        }
-    }
-    
-    s->mb_y=0;
-    ff_mpeg1_encode_slice_header(s);
-}
-
-static inline void put_mb_modes(MpegEncContext *s, int n, int bits, 
-                                int has_mv, int field_motion)
-{
-    put_bits(&s->pb, n, bits);
-    if (!s->frame_pred_frame_dct) {
-        if (has_mv) 
-            put_bits(&s->pb, 2, 2 - field_motion); /* motion_type: frame/field */
-        put_bits(&s->pb, 1, s->interlaced_dct);
-    }
-}
-
-void mpeg1_encode_mb(MpegEncContext *s,
-                     DCTELEM block[6][64],
-                     int motion_x, int motion_y)
-{
-    int i, cbp;
-    const int mb_x = s->mb_x;
-    const int mb_y = s->mb_y;
-    const int first_mb= mb_x == s->resync_mb_x && mb_y == s->resync_mb_y;
-
-    /* compute cbp */
-    cbp = 0;
-    for(i=0;i<6;i++) {
-        if (s->block_last_index[i] >= 0)
-            cbp |= 1 << (5 - i);
-    }
-    
-    if (cbp == 0 && !first_mb && s->mv_type == MV_TYPE_16X16 &&
-        (mb_x != s->mb_width - 1 || (mb_y != s->mb_height - 1 && s->codec_id == CODEC_ID_MPEG1VIDEO)) && 
-        ((s->pict_type == P_TYPE && (motion_x | motion_y) == 0) ||
-        (s->pict_type == B_TYPE && s->mv_dir == s->last_mv_dir && (((s->mv_dir & MV_DIR_FORWARD) ? ((s->mv[0][0][0] - s->last_mv[0][0][0])|(s->mv[0][0][1] - s->last_mv[0][0][1])) : 0) |
-        ((s->mv_dir & MV_DIR_BACKWARD) ? ((s->mv[1][0][0] - s->last_mv[1][0][0])|(s->mv[1][0][1] - s->last_mv[1][0][1])) : 0)) == 0))) {
-        s->mb_skip_run++;
-        s->qscale -= s->dquant;
-        s->skip_count++;
-        s->misc_bits++;
-        s->last_bits++;
-        if(s->pict_type == P_TYPE){
-            s->last_mv[0][1][0]= s->last_mv[0][0][0]= 
-            s->last_mv[0][1][1]= s->last_mv[0][0][1]= 0;
-        }
-    } else {
-        if(first_mb){
-            assert(s->mb_skip_run == 0);
-            encode_mb_skip_run(s, s->mb_x);
-        }else{
-            encode_mb_skip_run(s, s->mb_skip_run);
-        }
-        
-        if (s->pict_type == I_TYPE) {
-            if(s->dquant && cbp){
-                put_mb_modes(s, 2, 1, 0, 0); /* macroblock_type : macroblock_quant = 1 */
-                put_bits(&s->pb, 5, s->qscale);
-            }else{
-                put_mb_modes(s, 1, 1, 0, 0); /* macroblock_type : macroblock_quant = 0 */
-                s->qscale -= s->dquant;
-            }
-            s->misc_bits+= get_bits_diff(s);
-            s->i_count++;
-        } else if (s->mb_intra) {
-            if(s->dquant && cbp){
-                put_mb_modes(s, 6, 0x01, 0, 0);
-                put_bits(&s->pb, 5, s->qscale);
-            }else{
-                put_mb_modes(s, 5, 0x03, 0, 0);
-                s->qscale -= s->dquant;
-            }
-            s->misc_bits+= get_bits_diff(s);
-            s->i_count++;
-            memset(s->last_mv, 0, sizeof(s->last_mv));
-        } else if (s->pict_type == P_TYPE) { 
-            if(s->mv_type == MV_TYPE_16X16){
-                if (cbp != 0) {
-                    if ((motion_x|motion_y) == 0) {
-                        if(s->dquant){
-                            put_mb_modes(s, 5, 1, 0, 0); /* macroblock_pattern & quant */
-                            put_bits(&s->pb, 5, s->qscale);
-                        }else{
-                            put_mb_modes(s, 2, 1, 0, 0); /* macroblock_pattern only */
-                        }
-                        s->misc_bits+= get_bits_diff(s);
-                    } else {
-                        if(s->dquant){
-                            put_mb_modes(s, 5, 2, 1, 0); /* motion + cbp */
-                            put_bits(&s->pb, 5, s->qscale);
-                        }else{
-                            put_mb_modes(s, 1, 1, 1, 0); /* motion + cbp */
-                        }
-                        s->misc_bits+= get_bits_diff(s);
-                        mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code);    // RAL: f_code parameter added
-                        mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code);    // RAL: f_code parameter added
-                        s->mv_bits+= get_bits_diff(s);
-                    }
-                } else {
-                    put_bits(&s->pb, 3, 1); /* motion only */
-                    if (!s->frame_pred_frame_dct)
-                        put_bits(&s->pb, 2, 2); /* motion_type: frame */
-                    s->misc_bits+= get_bits_diff(s);
-                    mpeg1_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code);    // RAL: f_code parameter added
-                    mpeg1_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code);    // RAL: f_code parameter added
-                    s->qscale -= s->dquant;
-                    s->mv_bits+= get_bits_diff(s);
-                }
-                s->last_mv[0][1][0]= s->last_mv[0][0][0]= motion_x;
-                s->last_mv[0][1][1]= s->last_mv[0][0][1]= motion_y;
-            }else{
-                assert(!s->frame_pred_frame_dct && s->mv_type == MV_TYPE_FIELD);
-
-                if (cbp) {
-                    if(s->dquant){
-                        put_mb_modes(s, 5, 2, 1, 1); /* motion + cbp */
-                        put_bits(&s->pb, 5, s->qscale);
-                    }else{
-                        put_mb_modes(s, 1, 1, 1, 1); /* motion + cbp */
-                    }
-                } else {
-                    put_bits(&s->pb, 3, 1); /* motion only */
-                    put_bits(&s->pb, 2, 1); /* motion_type: field */
-                    s->qscale -= s->dquant;
-                }
-                s->misc_bits+= get_bits_diff(s);
-                for(i=0; i<2; i++){
-                    put_bits(&s->pb, 1, s->field_select[0][i]);
-                    mpeg1_encode_motion(s, s->mv[0][i][0] -  s->last_mv[0][i][0]    , s->f_code);
-                    mpeg1_encode_motion(s, s->mv[0][i][1] - (s->last_mv[0][i][1]>>1), s->f_code);
-                    s->last_mv[0][i][0]=   s->mv[0][i][0];
-                    s->last_mv[0][i][1]= 2*s->mv[0][i][1];
-                }
-                s->mv_bits+= get_bits_diff(s);
-            }
-            if(cbp)
-                put_bits(&s->pb, mbPatTable[cbp][1], mbPatTable[cbp][0]);
-            s->f_count++;
-        } else{  
-            static const int mb_type_len[4]={0,3,4,2}; //bak,for,bi
-
-            if(s->mv_type == MV_TYPE_16X16){
-                if (cbp){    // With coded bloc pattern
-                    if (s->dquant) {
-                        if(s->mv_dir == MV_DIR_FORWARD)
-                            put_mb_modes(s, 6, 3, 1, 0);
-                        else
-                            put_mb_modes(s, mb_type_len[s->mv_dir]+3, 2, 1, 0);
-                        put_bits(&s->pb, 5, s->qscale);
-                    } else {
-                        put_mb_modes(s, mb_type_len[s->mv_dir], 3, 1, 0);
-                    }
-                }else{    // No coded bloc pattern
-                    put_bits(&s->pb, mb_type_len[s->mv_dir], 2);
-                    if (!s->frame_pred_frame_dct)
-                        put_bits(&s->pb, 2, 2); /* motion_type: frame */
-                    s->qscale -= s->dquant;
-                }
-                s->misc_bits += get_bits_diff(s);
-                if (s->mv_dir&MV_DIR_FORWARD){
-                    mpeg1_encode_motion(s, s->mv[0][0][0] - s->last_mv[0][0][0], s->f_code); 
-                    mpeg1_encode_motion(s, s->mv[0][0][1] - s->last_mv[0][0][1], s->f_code); 
-                    s->last_mv[0][0][0]=s->last_mv[0][1][0]= s->mv[0][0][0];
-                    s->last_mv[0][0][1]=s->last_mv[0][1][1]= s->mv[0][0][1];
-                    s->f_count++;
-                }
-                if (s->mv_dir&MV_DIR_BACKWARD){
-                    mpeg1_encode_motion(s, s->mv[1][0][0] - s->last_mv[1][0][0], s->b_code); 
-                    mpeg1_encode_motion(s, s->mv[1][0][1] - s->last_mv[1][0][1], s->b_code); 
-                    s->last_mv[1][0][0]=s->last_mv[1][1][0]= s->mv[1][0][0];
-                    s->last_mv[1][0][1]=s->last_mv[1][1][1]= s->mv[1][0][1];
-                    s->b_count++;
-                }
-            }else{
-                assert(s->mv_type == MV_TYPE_FIELD);
-                assert(!s->frame_pred_frame_dct);
-                if (cbp){    // With coded bloc pattern
-                    if (s->dquant) {
-                        if(s->mv_dir == MV_DIR_FORWARD)
-                            put_mb_modes(s, 6, 3, 1, 1);
-                        else
-                            put_mb_modes(s, mb_type_len[s->mv_dir]+3, 2, 1, 1);
-                        put_bits(&s->pb, 5, s->qscale);
-                    } else {
-                        put_mb_modes(s, mb_type_len[s->mv_dir], 3, 1, 1);
-                    }
-                }else{    // No coded bloc pattern
-                    put_bits(&s->pb, mb_type_len[s->mv_dir], 2);
-                    put_bits(&s->pb, 2, 1); /* motion_type: field */
-                    s->qscale -= s->dquant;
-                }
-                s->misc_bits += get_bits_diff(s);
-                if (s->mv_dir&MV_DIR_FORWARD){
-                    for(i=0; i<2; i++){
-                        put_bits(&s->pb, 1, s->field_select[0][i]);
-                        mpeg1_encode_motion(s, s->mv[0][i][0] -  s->last_mv[0][i][0]    , s->f_code);
-                        mpeg1_encode_motion(s, s->mv[0][i][1] - (s->last_mv[0][i][1]>>1), s->f_code);
-                        s->last_mv[0][i][0]=   s->mv[0][i][0];
-                        s->last_mv[0][i][1]= 2*s->mv[0][i][1];
-                    }
-                    s->f_count++;
-                }
-                if (s->mv_dir&MV_DIR_BACKWARD){
-                    for(i=0; i<2; i++){
-                        put_bits(&s->pb, 1, s->field_select[1][i]);
-                        mpeg1_encode_motion(s, s->mv[1][i][0] -  s->last_mv[1][i][0]    , s->b_code);
-                        mpeg1_encode_motion(s, s->mv[1][i][1] - (s->last_mv[1][i][1]>>1), s->b_code);
-                        s->last_mv[1][i][0]=   s->mv[1][i][0];
-                        s->last_mv[1][i][1]= 2*s->mv[1][i][1];
-                    }
-                    s->b_count++;
-                }
-            }
-            s->mv_bits += get_bits_diff(s);
-            if(cbp)
-                put_bits(&s->pb, mbPatTable[cbp][1], mbPatTable[cbp][0]);
-        }
-        for(i=0;i<6;i++) {
-            if (cbp & (1 << (5 - i))) {
-                mpeg1_encode_block(s, block[i], i);
-            }
-        }
-        s->mb_skip_run = 0;
-        if(s->mb_intra)
-            s->i_tex_bits+= get_bits_diff(s);
-        else
-            s->p_tex_bits+= get_bits_diff(s);
-    }
-}
-
-// RAL: Parameter added: f_or_b_code
-static void mpeg1_encode_motion(MpegEncContext *s, int val, int f_or_b_code)
-{
-    int code, bit_size, l, bits, range, sign;
-
-    if (val == 0) {
-        /* zero vector */
-        code = 0;
-        put_bits(&s->pb,
-                 mbMotionVectorTable[0][1], 
-                 mbMotionVectorTable[0][0]); 
-    } else {
-        bit_size = f_or_b_code - 1;
-        range = 1 << bit_size;
-        /* modulo encoding */
-        l= INT_BIT - 5 - bit_size;
-        val= (val<<l)>>l;
-
-        if (val >= 0) {
-            val--;
-            code = (val >> bit_size) + 1;
-            bits = val & (range - 1);
-            sign = 0;
-        } else {
-            val = -val;
-            val--;
-            code = (val >> bit_size) + 1;
-            bits = val & (range - 1);
-            sign = 1;
-        }
-
-        assert(code > 0 && code <= 16);
-
-        put_bits(&s->pb,
-                 mbMotionVectorTable[code][1], 
-                 mbMotionVectorTable[code][0]); 
-
-        put_bits(&s->pb, 1, sign);
-        if (bit_size > 0) {
-            put_bits(&s->pb, bit_size, bits);
-        }
-    }
-}
-
-void ff_mpeg1_encode_init(MpegEncContext *s)
-{
-    static int done=0;
-
-    common_init(s);
-
-    if(!done){
-        int f_code;
-        int mv;
-	int i;
-
-        done=1;
-        init_rl(&rl_mpeg1, 1);
-
-	for(i=0; i<64; i++)
-	{
-		mpeg1_max_level[0][i]= rl_mpeg1.max_level[0][i];
-		mpeg1_index_run[0][i]= rl_mpeg1.index_run[0][i];
-	}
-        
-        init_uni_ac_vlc(&rl_mpeg1, uni_mpeg1_ac_vlc_bits, uni_mpeg1_ac_vlc_len);
-
-	/* build unified dc encoding tables */
-	for(i=-255; i<256; i++)
-	{
-		int adiff, index;
-		int bits, code;
-		int diff=i;
-
-		adiff = ABS(diff);
-		if(diff<0) diff--;
-		index = av_log2(2*adiff);
-
-		bits= vlc_dc_lum_bits[index] + index;
-		code= (vlc_dc_lum_code[index]<<index) + (diff & ((1 << index) - 1));
-		mpeg1_lum_dc_uni[i+255]= bits + (code<<8);
-		
-		bits= vlc_dc_chroma_bits[index] + index;
-		code= (vlc_dc_chroma_code[index]<<index) + (diff & ((1 << index) - 1));
-		mpeg1_chr_dc_uni[i+255]= bits + (code<<8);
-	}
-
-        mv_penalty= av_mallocz( sizeof(uint8_t)*(MAX_FCODE+1)*(2*MAX_MV+1) );
-
-        for(f_code=1; f_code<=MAX_FCODE; f_code++){
-            for(mv=-MAX_MV; mv<=MAX_MV; mv++){
-                int len;
-
-                if(mv==0) len= mbMotionVectorTable[0][1];
-                else{
-                    int val, bit_size, range, code;
-
-                    bit_size = f_code - 1;
-                    range = 1 << bit_size;
-
-                    val=mv;
-                    if (val < 0) 
-                        val = -val;
-                    val--;
-                    code = (val >> bit_size) + 1;
-                    if(code<17){
-                        len= mbMotionVectorTable[code][1] + 1 + bit_size;
-                    }else{
-                        len= mbMotionVectorTable[16][1] + 2 + bit_size;
-                    }
-                }
-
-                mv_penalty[f_code][mv+MAX_MV]= len;
-            }
-        }
-        
-
-        for(f_code=MAX_FCODE; f_code>0; f_code--){
-            for(mv=-(8<<f_code); mv<(8<<f_code); mv++){
-                fcode_tab[mv+MAX_MV]= f_code;
-            }
-        }
-    }
-    s->me.mv_penalty= mv_penalty;
-    s->fcode_tab= fcode_tab;
-    if(s->codec_id == CODEC_ID_MPEG1VIDEO){
-        s->min_qcoeff=-255;
-        s->max_qcoeff= 255;
-    }else{
-        s->min_qcoeff=-2047;
-        s->max_qcoeff= 2047;
-    }
-    s->intra_ac_vlc_length=
-    s->inter_ac_vlc_length=
-    s->intra_ac_vlc_last_length=
-    s->inter_ac_vlc_last_length= uni_mpeg1_ac_vlc_len;
-}
-
-static inline void encode_dc(MpegEncContext *s, int diff, int component)
-{
-  if(((unsigned) (diff+255)) >= 511){
-        int index;
-
-        if(diff<0){
-            index= av_log2_16bit(-2*diff);
-            diff--;
-        }else{
-            index= av_log2_16bit(2*diff);
-        }
-        if (component == 0) {
-            put_bits(
-                &s->pb, 
-                vlc_dc_lum_bits[index] + index,
-                (vlc_dc_lum_code[index]<<index) + (diff & ((1 << index) - 1)));
-        }else{
-            put_bits(
-                &s->pb, 
-                vlc_dc_chroma_bits[index] + index,
-                (vlc_dc_chroma_code[index]<<index) + (diff & ((1 << index) - 1)));
-        }
-  }else{
-    if (component == 0) {
-        put_bits(
-	    &s->pb, 
-	    mpeg1_lum_dc_uni[diff+255]&0xFF,
-	    mpeg1_lum_dc_uni[diff+255]>>8);
-    } else {
-        put_bits(
-            &s->pb, 
-	    mpeg1_chr_dc_uni[diff+255]&0xFF,
-	    mpeg1_chr_dc_uni[diff+255]>>8);
-    }
-  }
-}
-
-static void mpeg1_encode_block(MpegEncContext *s, 
-                               DCTELEM *block, 
-                               int n)
-{
-    int alevel, level, last_non_zero, dc, diff, i, j, run, last_index, sign;
-    int code, component;
-//    RLTable *rl = &rl_mpeg1;
-
-    last_index = s->block_last_index[n];
-
-    /* DC coef */
-    if (s->mb_intra) {
-        component = (n <= 3 ? 0 : n - 4 + 1);
-        dc = block[0]; /* overflow is impossible */
-        diff = dc - s->last_dc[component];
-        encode_dc(s, diff, component);
-        s->last_dc[component] = dc;
-        i = 1;
-/*
-        if (s->intra_vlc_format)
-            rl = &rl_mpeg2;
-        else
-            rl = &rl_mpeg1;
-*/
-    } else {
-        /* encode the first coefficient : needs to be done here because
-           it is handled slightly differently */
-        level = block[0];
-        if (abs(level) == 1) {
-                code = ((uint32_t)level >> 31); /* the sign bit */
-                put_bits(&s->pb, 2, code | 0x02);
-                i = 1;
-        } else {
-            i = 0;
-            last_non_zero = -1;
-            goto next_coef;
-        }
-    }
-
-    /* now quantify & encode AC coefs */
-    last_non_zero = i - 1;
-
-    for(;i<=last_index;i++) {
-        j = s->intra_scantable.permutated[i];
-        level = block[j];
-    next_coef:
-#if 0
-        if (level != 0)
-            dprintf("level[%d]=%d\n", i, level);
-#endif            
-        /* encode using VLC */
-        if (level != 0) {
-            run = i - last_non_zero - 1;
-            
-            alevel= level;
-            MASK_ABS(sign, alevel)
-            sign&=1;
-
-//            code = get_rl_index(rl, 0, run, alevel);
-            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, mpeg1_vlc[code][1]+1, (mpeg1_vlc[code][0]<<1) + sign);
-            } else {
-		/* escape seems to be pretty rare <5% so i dont optimize it */
-                put_bits(&s->pb, mpeg1_vlc[111/*rl->n*/][1], mpeg1_vlc[111/*rl->n*/][0]);
-                /* escape: only clip in this case */
-                put_bits(&s->pb, 6, run);
-                if(s->codec_id == CODEC_ID_MPEG1VIDEO){
-                    if (alevel < 128) {
-                        put_bits(&s->pb, 8, level & 0xff);
-                    } else {
-                        if (level < 0) {
-                            put_bits(&s->pb, 16, 0x8001 + level + 255);
-                        } else {
-                            put_bits(&s->pb, 16, level & 0xffff);
-                        }
-                    }
-                }else{
-                    put_bits(&s->pb, 12, level & 0xfff);
-                }
-            }
-            last_non_zero = i;
-        }
-    }
-    /* end of block */
-    put_bits(&s->pb, 2, 0x2);
-}
-#endif //CONFIG_ENCODERS
-
-/******************************************/
-/* decoding */
-
-static VLC dc_lum_vlc;
-static VLC dc_chroma_vlc;
-static VLC mv_vlc;
-static VLC mbincr_vlc;
-static VLC mb_ptype_vlc;
-static VLC mb_btype_vlc;
-static VLC mb_pat_vlc;
-
-static void init_vlcs(void)
-{
-    static int done = 0;
-
-    if (!done) {
-        done = 1;
-
-        init_vlc(&dc_lum_vlc, DC_VLC_BITS, 12, 
-                 vlc_dc_lum_bits, 1, 1,
-                 vlc_dc_lum_code, 2, 2, 1);
-        init_vlc(&dc_chroma_vlc,  DC_VLC_BITS, 12, 
-                 vlc_dc_chroma_bits, 1, 1,
-                 vlc_dc_chroma_code, 2, 2, 1);
-        init_vlc(&mv_vlc, MV_VLC_BITS, 17, 
-                 &mbMotionVectorTable[0][1], 2, 1,
-                 &mbMotionVectorTable[0][0], 2, 1, 1);
-        init_vlc(&mbincr_vlc, MBINCR_VLC_BITS, 36, 
-                 &mbAddrIncrTable[0][1], 2, 1,
-                 &mbAddrIncrTable[0][0], 2, 1, 1);
-        init_vlc(&mb_pat_vlc, MB_PAT_VLC_BITS, 64,
-                 &mbPatTable[0][1], 2, 1,
-                 &mbPatTable[0][0], 2, 1, 1);
-        
-        init_vlc(&mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7, 
-                 &table_mb_ptype[0][1], 2, 1,
-                 &table_mb_ptype[0][0], 2, 1, 1);
-        init_vlc(&mb_btype_vlc, MB_BTYPE_VLC_BITS, 11, 
-                 &table_mb_btype[0][1], 2, 1,
-                 &table_mb_btype[0][0], 2, 1, 1);
-        init_rl(&rl_mpeg1, 1);
-        init_rl(&rl_mpeg2, 1);
-
-        init_2d_vlc_rl(&rl_mpeg1, 1);
-        init_2d_vlc_rl(&rl_mpeg2, 1);
-    }
-}
-
-static inline int get_dmv(MpegEncContext *s)
-{
-    if(get_bits1(&s->gb)) 
-        return 1 - (get_bits1(&s->gb) << 1);
-    else
-        return 0;
-}
-
-static inline int get_qscale(MpegEncContext *s)
-{
-    int qscale = get_bits(&s->gb, 5);
-    if (s->q_scale_type) {
-        return non_linear_qscale[qscale];
-    } else {
-        return qscale << 1;
-    }
-}
-
-/* motion type (for mpeg2) */
-#define MT_FIELD 1
-#define MT_FRAME 2
-#define MT_16X8  2
-#define MT_DMV   3
-
-static int mpeg_decode_mb(MpegEncContext *s,
-                          DCTELEM block[12][64])
-{
-    int i, j, k, cbp, val, mb_type, motion_type;
-    const int mb_block_count = 4 + (1<< s->chroma_format);
-
-    dprintf("decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
-
-    assert(s->mb_skipped==0);
-
-    if (s->mb_skip_run-- != 0) {
-        if(s->pict_type == I_TYPE){
-            av_log(s->avctx, AV_LOG_ERROR, "skipped MB in I frame at %d %d\n", s->mb_x, s->mb_y);
-            return -1;
-        }
-    
-        /* skip mb */
-        s->mb_intra = 0;
-        for(i=0;i<12;i++)
-            s->block_last_index[i] = -1;
-        if(s->picture_structure == PICT_FRAME)
-            s->mv_type = MV_TYPE_16X16;
-        else
-            s->mv_type = MV_TYPE_FIELD;
-        if (s->pict_type == P_TYPE) {
-            /* if P type, zero motion vector is implied */
-            s->mv_dir = MV_DIR_FORWARD;
-            s->mv[0][0][0] = s->mv[0][0][1] = 0;
-            s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0;
-            s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0;
-            s->field_select[0][0]= s->picture_structure - 1;
-            s->mb_skipped = 1;
-            s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
-        } else {
-            int mb_type;
-            
-            if(s->mb_x)
-                mb_type= s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1];
-            else
-                mb_type= s->current_picture.mb_type[ s->mb_width + (s->mb_y-1)*s->mb_stride - 1]; // FIXME not sure if this is allowed in mpeg at all, 
-            if(IS_INTRA(mb_type))
-                return -1;
-            
-            /* if B type, reuse previous vectors and directions */
-            s->mv[0][0][0] = s->last_mv[0][0][0];
-            s->mv[0][0][1] = s->last_mv[0][0][1];
-            s->mv[1][0][0] = s->last_mv[1][0][0];
-            s->mv[1][0][1] = s->last_mv[1][0][1];
-
-            s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= 
-                mb_type | MB_TYPE_SKIP;
-//            assert(s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]&(MB_TYPE_16x16|MB_TYPE_16x8));
-
-            if((s->mv[0][0][0]|s->mv[0][0][1]|s->mv[1][0][0]|s->mv[1][0][1])==0) 
-                s->mb_skipped = 1;
-        }
-
-        return 0;
-    }
-
-    switch(s->pict_type) {
-    default:
-    case I_TYPE:
-        if (get_bits1(&s->gb) == 0) {
-            if (get_bits1(&s->gb) == 0){
-                av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in I Frame at %d %d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-            mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
-        } else {
-            mb_type = MB_TYPE_INTRA;
-        }
-        break;
-    case P_TYPE:
-        mb_type = get_vlc2(&s->gb, mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
-        if (mb_type < 0){
-            av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in P Frame at %d %d\n", s->mb_x, s->mb_y);
-            return -1;
-        }
-        mb_type = ptype2mb_type[ mb_type ];
-        break;
-    case B_TYPE:
-        mb_type = get_vlc2(&s->gb, mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);
-        if (mb_type < 0){
-            av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in B Frame at %d %d\n", s->mb_x, s->mb_y);
-            return -1;
-        }
-        mb_type = btype2mb_type[ mb_type ];
-        break;
-    }
-    dprintf("mb_type=%x\n", mb_type);
-//    motion_type = 0; /* avoid warning */
-    if (IS_INTRA(mb_type)) {
-        s->dsp.clear_blocks(s->block[0]);
-    
-        if(!s->chroma_y_shift){
-            s->dsp.clear_blocks(s->block[6]);
-        }
-    
-        /* compute dct type */
-        if (s->picture_structure == PICT_FRAME && //FIXME add a interlaced_dct coded var?
-            !s->frame_pred_frame_dct) {
-            s->interlaced_dct = get_bits1(&s->gb);
-        }
-
-        if (IS_QUANT(mb_type))
-            s->qscale = get_qscale(s);
-        
-        if (s->concealment_motion_vectors) {
-            /* just parse them */
-            if (s->picture_structure != PICT_FRAME) 
-                skip_bits1(&s->gb); /* field select */
-            
-            s->mv[0][0][0]= s->last_mv[0][0][0]= s->last_mv[0][1][0] = 
-                mpeg_decode_motion(s, s->mpeg_f_code[0][0], s->last_mv[0][0][0]);
-            s->mv[0][0][1]= s->last_mv[0][0][1]= s->last_mv[0][1][1] = 
-                mpeg_decode_motion(s, s->mpeg_f_code[0][1], s->last_mv[0][0][1]);
-
-            skip_bits1(&s->gb); /* marker */
-        }else
-            memset(s->last_mv, 0, sizeof(s->last_mv)); /* reset mv prediction */
-        s->mb_intra = 1;
-#ifdef HAVE_XVMC
-        //one 1 we memcpy blocks in xvmcvideo
-        if(s->avctx->xvmc_acceleration > 1){
-            XVMC_pack_pblocks(s,-1);//inter are always full blocks
-            if(s->swap_uv){
-                exchange_uv(s);
-            }
-        }
-#endif
-
-        if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
-            if(s->flags2 & CODEC_FLAG2_FAST){
-                for(i=0;i<6;i++) {
-                    mpeg2_fast_decode_block_intra(s, s->pblocks[i], i);
-                }
-            }else{
-                for(i=0;i<mb_block_count;i++) {
-                    if (mpeg2_decode_block_intra(s, s->pblocks[i], i) < 0)
-                        return -1;
-                }
-            }
-        } else {
-            for(i=0;i<6;i++) {
-                if (mpeg1_decode_block_intra(s, s->pblocks[i], i) < 0)
-                    return -1;
-            }
-        }
-    } else {
-        if (mb_type & MB_TYPE_ZERO_MV){
-            assert(mb_type & MB_TYPE_CBP);
-
-            /* compute dct type */
-            if (s->picture_structure == PICT_FRAME && //FIXME add a interlaced_dct coded var?
-                !s->frame_pred_frame_dct) {
-                s->interlaced_dct = get_bits1(&s->gb);
-            }
-
-            if (IS_QUANT(mb_type))
-                s->qscale = get_qscale(s);
-
-            s->mv_dir = MV_DIR_FORWARD;
-            if(s->picture_structure == PICT_FRAME)
-                s->mv_type = MV_TYPE_16X16;
-            else{
-                s->mv_type = MV_TYPE_FIELD;
-                mb_type |= MB_TYPE_INTERLACED;
-                s->field_select[0][0]= s->picture_structure - 1;
-            }
-            s->last_mv[0][0][0] = 0;
-            s->last_mv[0][0][1] = 0;
-            s->last_mv[0][1][0] = 0;
-            s->last_mv[0][1][1] = 0;
-            s->mv[0][0][0] = 0;
-            s->mv[0][0][1] = 0;
-        }else{
-            assert(mb_type & MB_TYPE_L0L1);
-//FIXME decide if MBs in field pictures are MB_TYPE_INTERLACED
-            /* get additionnal motion vector type */
-            if (s->frame_pred_frame_dct) 
-                motion_type = MT_FRAME;
-            else{
-                motion_type = get_bits(&s->gb, 2);
-            }
-
-            /* compute dct type */
-            if (s->picture_structure == PICT_FRAME && //FIXME add a interlaced_dct coded var?
-                !s->frame_pred_frame_dct && HAS_CBP(mb_type)) {
-                s->interlaced_dct = get_bits1(&s->gb);
-            }
-
-            if (IS_QUANT(mb_type))
-                s->qscale = get_qscale(s);
-
-            /* motion vectors */
-            s->mv_dir = 0;
-            for(i=0;i<2;i++) {
-                if (USES_LIST(mb_type, i)) {
-                    s->mv_dir |= (MV_DIR_FORWARD >> i);
-                    dprintf("motion_type=%d\n", motion_type);
-                    switch(motion_type) {
-                    case MT_FRAME: /* or MT_16X8 */
-                        if (s->picture_structure == PICT_FRAME) {
-                            /* MT_FRAME */
-                            mb_type |= MB_TYPE_16x16; 
-                            s->mv_type = MV_TYPE_16X16;
-                            s->mv[i][0][0]= s->last_mv[i][0][0]= s->last_mv[i][1][0] = 
-                                mpeg_decode_motion(s, s->mpeg_f_code[i][0], s->last_mv[i][0][0]);
-                            s->mv[i][0][1]= s->last_mv[i][0][1]= s->last_mv[i][1][1] = 
-                                mpeg_decode_motion(s, s->mpeg_f_code[i][1], s->last_mv[i][0][1]);
-                            /* full_pel: only for mpeg1 */
-                            if (s->full_pel[i]){
-                                s->mv[i][0][0] <<= 1;
-                                s->mv[i][0][1] <<= 1;
-                            }
-                        } else {
-                            /* MT_16X8 */
-                            mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED; 
-                            s->mv_type = MV_TYPE_16X8;
-                            for(j=0;j<2;j++) {
-                                s->field_select[i][j] = get_bits1(&s->gb);
-                                for(k=0;k<2;k++) {
-                                    val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
-                                                             s->last_mv[i][j][k]);
-                                    s->last_mv[i][j][k] = val;
-                                    s->mv[i][j][k] = val;
-                                }
-                            }
-                        }
-                        break;
-                    case MT_FIELD:
-                        s->mv_type = MV_TYPE_FIELD;
-                        if (s->picture_structure == PICT_FRAME) {
-                            mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED; 
-                            for(j=0;j<2;j++) {
-                                s->field_select[i][j] = get_bits1(&s->gb);
-                                val = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
-                                                         s->last_mv[i][j][0]);
-                                s->last_mv[i][j][0] = val;
-                                s->mv[i][j][0] = val;
-                                dprintf("fmx=%d\n", val);
-                                val = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
-                                                         s->last_mv[i][j][1] >> 1);
-                                s->last_mv[i][j][1] = val << 1;
-                                s->mv[i][j][1] = val;
-                                dprintf("fmy=%d\n", val);
-                            }
-                        } else {
-                            mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED; 
-                            s->field_select[i][0] = get_bits1(&s->gb);
-                            for(k=0;k<2;k++) {
-                                val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
-                                                         s->last_mv[i][0][k]);
-                                s->last_mv[i][0][k] = val;
-                                s->last_mv[i][1][k] = val;
-                                s->mv[i][0][k] = val;
-                            }
-                        }
-                        break;
-                    case MT_DMV:
-                        {
-                            int dmx, dmy, mx, my, m;
-
-                            mx = mpeg_decode_motion(s, s->mpeg_f_code[i][0], 
-                                                    s->last_mv[i][0][0]);
-                            s->last_mv[i][0][0] = mx;
-                            s->last_mv[i][1][0] = mx;
-                            dmx = get_dmv(s);
-                            my = mpeg_decode_motion(s, s->mpeg_f_code[i][1], 
-                                                    s->last_mv[i][0][1] >> 1);
-                            dmy = get_dmv(s);
-                            s->mv_type = MV_TYPE_DMV;
-
-
-                            s->last_mv[i][0][1] = my<<1;
-                            s->last_mv[i][1][1] = my<<1;
-
-                            s->mv[i][0][0] = mx;
-                            s->mv[i][0][1] = my;
-                            s->mv[i][1][0] = mx;//not used
-                            s->mv[i][1][1] = my;//not used
-
-                            if (s->picture_structure == PICT_FRAME) {
-                                mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED; 
-
-                                //m = 1 + 2 * s->top_field_first;
-                                m = s->top_field_first ? 1 : 3;
-
-                                /* top -> top pred */
-                                s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
-                                s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
-                                m = 4 - m;
-                                s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
-                                s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1;
-                            } else {
-                                mb_type |= MB_TYPE_16x16;
-
-                                s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx;
-                                s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy;
-                                if(s->picture_structure == PICT_TOP_FIELD)
-                                    s->mv[i][2][1]--;
-                                else 
-                                    s->mv[i][2][1]++;
-                            }
-                        }
-                        break;
-                    default:
-                        av_log(s->avctx, AV_LOG_ERROR, "00 motion_type at %d %d\n", s->mb_x, s->mb_y);
-                        return -1;
-                    }
-                }
-            }
-        }
-        
-        s->mb_intra = 0;
-        if (HAS_CBP(mb_type)) {
-            s->dsp.clear_blocks(s->block[0]);
-        
-            if(!s->chroma_y_shift){
-                s->dsp.clear_blocks(s->block[6]);
-            }
-
-            cbp = get_vlc2(&s->gb, mb_pat_vlc.table, MB_PAT_VLC_BITS, 1);
-            if (cbp < 0 || ((cbp == 0) && (s->chroma_format < 2)) ){
-                av_log(s->avctx, AV_LOG_ERROR, "invalid cbp at %d %d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-            if(mb_block_count > 6){
-	         cbp<<= mb_block_count-6;
-		 cbp |= get_bits(&s->gb, mb_block_count-6);
-            }
-
-#ifdef HAVE_XVMC
-            //on 1 we memcpy blocks in xvmcvideo
-            if(s->avctx->xvmc_acceleration > 1){
-                XVMC_pack_pblocks(s,cbp);
-                if(s->swap_uv){
-                    exchange_uv(s);
-                }
-            }    
-#endif
-
-            if (s->codec_id == CODEC_ID_MPEG2VIDEO) {
-                if(s->flags2 & CODEC_FLAG2_FAST){
-                    for(i=0;i<6;i++) {
-                        if(cbp & 32) {
-                            mpeg2_fast_decode_block_non_intra(s, s->pblocks[i], i);
-                        } else {
-                            s->block_last_index[i] = -1;
-                        }
-                        cbp+=cbp;
-                    }
-                }else{
-                    cbp<<= 12-mb_block_count;
-    
-                    for(i=0;i<mb_block_count;i++) {
-                        if ( cbp & (1<<11) ) {
-                            if (mpeg2_decode_block_non_intra(s, s->pblocks[i], i) < 0)
-                                return -1;
-                        } else {
-                            s->block_last_index[i] = -1;
-                        }
-                        cbp+=cbp;
-                    }
-                }
-            } else {
-                if(s->flags2 & CODEC_FLAG2_FAST){
-                    for(i=0;i<6;i++) {
-                        if (cbp & 32) {
-                            mpeg1_fast_decode_block_inter(s, s->pblocks[i], i);
-                        } else {
-                            s->block_last_index[i] = -1;
-                        }
-                        cbp+=cbp;
-                    }
-                }else{
-                    for(i=0;i<6;i++) {
-                        if (cbp & 32) {
-                            if (mpeg1_decode_block_inter(s, s->pblocks[i], i) < 0)
-                                return -1;
-                        } else {
-                            s->block_last_index[i] = -1;
-                        }
-                        cbp+=cbp;
-                    }
-                }
-            }
-        }else{
-            for(i=0;i<6;i++)
-                s->block_last_index[i] = -1;
-        }
-    }
-
-    s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= mb_type;
-
-    return 0;
-}
-
-/* as h263, but only 17 codes */
-static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
-{
-    int code, sign, val, l, shift;
-
-    code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2);
-    if (code == 0) {
-        return pred;
-    }
-    if (code < 0) {
-        return 0xffff;
-    }
-
-    sign = get_bits1(&s->gb);
-    shift = fcode - 1;
-    val = code;
-    if (shift) {
-        val = (val - 1) << shift;
-        val |= get_bits(&s->gb, shift);
-        val++;
-    }
-    if (sign)
-        val = -val;
-    val += pred;
-    
-    /* modulo decoding */
-    l= INT_BIT - 5 - shift;
-    val = (val<<l)>>l;
-    return val;
-}
-
-static inline int decode_dc(GetBitContext *gb, int component)
-{
-    int code, diff;
-
-    if (component == 0) {
-        code = get_vlc2(gb, dc_lum_vlc.table, DC_VLC_BITS, 2);
-    } else {
-        code = get_vlc2(gb, dc_chroma_vlc.table, DC_VLC_BITS, 2);
-    }
-    if (code < 0){
-        av_log(NULL, AV_LOG_ERROR, "invalid dc code at\n");
-        return 0xffff;
-    }
-    if (code == 0) {
-        diff = 0;
-    } else {
-        diff = get_xbits(gb, code);
-    }
-    return diff;
-}
-
-static inline int mpeg1_decode_block_intra(MpegEncContext *s, 
-                               DCTELEM *block, 
-                               int n)
-{
-    int level, dc, diff, i, j, run;
-    int component;
-    RLTable *rl = &rl_mpeg1;
-    uint8_t * const scantable= s->intra_scantable.permutated;
-    const uint16_t *quant_matrix= s->intra_matrix;
-    const int qscale= s->qscale;
-
-    /* DC coef */
-    component = (n <= 3 ? 0 : n - 4 + 1);
-    diff = decode_dc(&s->gb, component);
-    if (diff >= 0xffff)
-        return -1;
-    dc = s->last_dc[component];
-    dc += diff;
-    s->last_dc[component] = dc;
-    block[0] = dc<<3;
-    dprintf("dc=%d diff=%d\n", dc, diff);
-    i = 0;
-    {
-        OPEN_READER(re, &s->gb);    
-        /* now quantify & encode AC coefs */
-        for(;;) {
-            UPDATE_CACHE(re, &s->gb);
-            GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
-            
-            if(level == 127){
-                break;
-            } else if(level != 0) {
-                i += run;
-                j = scantable[i];
-                level= (level*qscale*quant_matrix[j])>>4;
-                level= (level-1)|1;
-                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
-                LAST_SKIP_BITS(re, &s->gb, 1);
-            } else {
-                /* escape */
-                run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re, &s->gb, 6);
-                UPDATE_CACHE(re, &s->gb);
-                level = SHOW_SBITS(re, &s->gb, 8); SKIP_BITS(re, &s->gb, 8);
-                if (level == -128) {
-                    level = SHOW_UBITS(re, &s->gb, 8) - 256; LAST_SKIP_BITS(re, &s->gb, 8);
-                } else if (level == 0) {
-                    level = SHOW_UBITS(re, &s->gb, 8)      ; LAST_SKIP_BITS(re, &s->gb, 8);
-                }
-                i += run;
-                j = scantable[i];
-                if(level<0){
-                    level= -level;
-                    level= (level*qscale*quant_matrix[j])>>4;
-                    level= (level-1)|1;
-                    level= -level;
-                }else{
-                    level= (level*qscale*quant_matrix[j])>>4;
-                    level= (level-1)|1;
-                }
-            }
-            if (i > 63){
-                av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-
-            block[j] = level;
-        }
-        CLOSE_READER(re, &s->gb);
-    }
-    s->block_last_index[n] = i;
-   return 0;
-}
-
-static inline int mpeg1_decode_block_inter(MpegEncContext *s, 
-                               DCTELEM *block, 
-                               int n)
-{
-    int level, i, j, run;
-    RLTable *rl = &rl_mpeg1;
-    uint8_t * const scantable= s->intra_scantable.permutated;
-    const uint16_t *quant_matrix= s->inter_matrix;
-    const int qscale= s->qscale;
-
-    {
-        OPEN_READER(re, &s->gb);
-        i = -1;
-        /* special case for the first coef. no need to add a second vlc table */
-        UPDATE_CACHE(re, &s->gb);
-        if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
-            level= (3*qscale*quant_matrix[0])>>5;
-            level= (level-1)|1;
-            if(GET_CACHE(re, &s->gb)&0x40000000)
-                level= -level;
-            block[0] = level;
-            i++;
-            SKIP_BITS(re, &s->gb, 2);
-            if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
-                goto end;
-        }
-
-        /* now quantify & encode AC coefs */
-        for(;;) {
-            GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
-            
-            if(level != 0) {
-                i += run;
-                j = scantable[i];
-                level= ((level*2+1)*qscale*quant_matrix[j])>>5;
-                level= (level-1)|1;
-                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
-                SKIP_BITS(re, &s->gb, 1);
-            } else {
-                /* escape */
-                run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re, &s->gb, 6);
-                UPDATE_CACHE(re, &s->gb);
-                level = SHOW_SBITS(re, &s->gb, 8); SKIP_BITS(re, &s->gb, 8);
-                if (level == -128) {
-                    level = SHOW_UBITS(re, &s->gb, 8) - 256; SKIP_BITS(re, &s->gb, 8);
-                } else if (level == 0) {
-                    level = SHOW_UBITS(re, &s->gb, 8)      ; SKIP_BITS(re, &s->gb, 8);
-                }
-                i += run;
-                j = scantable[i];
-                if(level<0){
-                    level= -level;
-                    level= ((level*2+1)*qscale*quant_matrix[j])>>5;
-                    level= (level-1)|1;
-                    level= -level;
-                }else{
-                    level= ((level*2+1)*qscale*quant_matrix[j])>>5;
-                    level= (level-1)|1;
-                }
-            }
-            if (i > 63){
-                av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-
-            block[j] = level;
-            if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
-                break;
-            UPDATE_CACHE(re, &s->gb);
-        }
-end:
-        LAST_SKIP_BITS(re, &s->gb, 2);
-        CLOSE_READER(re, &s->gb);
-    }
-    s->block_last_index[n] = i;
-    return 0;
-}
-
-static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s, DCTELEM *block, int n)
-{
-    int level, i, j, run;
-    RLTable *rl = &rl_mpeg1;
-    uint8_t * const scantable= s->intra_scantable.permutated;
-    const int qscale= s->qscale;
-
-    {
-        OPEN_READER(re, &s->gb);
-        i = -1;
-        /* special case for the first coef. no need to add a second vlc table */
-        UPDATE_CACHE(re, &s->gb);
-        if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
-            level= (3*qscale)>>1;
-            level= (level-1)|1;
-            if(GET_CACHE(re, &s->gb)&0x40000000)
-                level= -level;
-            block[0] = level;
-            i++;
-            SKIP_BITS(re, &s->gb, 2);
-            if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
-                goto end;
-        }
-
-        /* now quantify & encode AC coefs */
-        for(;;) {
-            GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
-            
-            if(level != 0) {
-                i += run;
-                j = scantable[i];
-                level= ((level*2+1)*qscale)>>1;
-                level= (level-1)|1;
-                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
-                SKIP_BITS(re, &s->gb, 1);
-            } else {
-                /* escape */
-                run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re, &s->gb, 6);
-                UPDATE_CACHE(re, &s->gb);
-                level = SHOW_SBITS(re, &s->gb, 8); SKIP_BITS(re, &s->gb, 8);
-                if (level == -128) {
-                    level = SHOW_UBITS(re, &s->gb, 8) - 256; SKIP_BITS(re, &s->gb, 8);
-                } else if (level == 0) {
-                    level = SHOW_UBITS(re, &s->gb, 8)      ; SKIP_BITS(re, &s->gb, 8);
-                }
-                i += run;
-                j = scantable[i];
-                if(level<0){
-                    level= -level;
-                    level= ((level*2+1)*qscale)>>1;
-                    level= (level-1)|1;
-                    level= -level;
-                }else{
-                    level= ((level*2+1)*qscale)>>1;
-                    level= (level-1)|1;
-                }
-            }
-
-            block[j] = level;
-            if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
-                break;
-            UPDATE_CACHE(re, &s->gb);
-        }
-end:
-        LAST_SKIP_BITS(re, &s->gb, 2);
-        CLOSE_READER(re, &s->gb);
-    }
-    s->block_last_index[n] = i;
-    return 0;
-}
-
-
-static inline int mpeg2_decode_block_non_intra(MpegEncContext *s, 
-                               DCTELEM *block, 
-                               int n)
-{
-    int level, i, j, run;
-    RLTable *rl = &rl_mpeg1;
-    uint8_t * const scantable= s->intra_scantable.permutated;
-    const uint16_t *quant_matrix;
-    const int qscale= s->qscale;
-    int mismatch;
-
-    mismatch = 1;
-
-    {
-        OPEN_READER(re, &s->gb);
-        i = -1;
-        if (n < 4)
-            quant_matrix = s->inter_matrix;
-        else
-            quant_matrix = s->chroma_inter_matrix;
-
-        /* special case for the first coef. no need to add a second vlc table */
-        UPDATE_CACHE(re, &s->gb);
-        if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
-            level= (3*qscale*quant_matrix[0])>>5;
-            if(GET_CACHE(re, &s->gb)&0x40000000)
-                level= -level;
-            block[0] = level;
-            mismatch ^= level;
-            i++;
-            SKIP_BITS(re, &s->gb, 2);
-            if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
-                goto end;
-        }
-
-        /* now quantify & encode AC coefs */
-        for(;;) {
-            GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
-            
-            if(level != 0) {
-                i += run;
-                j = scantable[i];
-                level= ((level*2+1)*qscale*quant_matrix[j])>>5;
-                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
-                SKIP_BITS(re, &s->gb, 1);
-            } else {
-                /* escape */
-                run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re, &s->gb, 6);
-                UPDATE_CACHE(re, &s->gb);
-                level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
-
-                i += run;
-                j = scantable[i];
-                if(level<0){
-                    level= ((-level*2+1)*qscale*quant_matrix[j])>>5;
-                    level= -level;
-                }else{
-                    level= ((level*2+1)*qscale*quant_matrix[j])>>5;
-                }
-            }
-            if (i > 63){
-                av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-            
-            mismatch ^= level;
-            block[j] = level;
-            if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
-                break;
-            UPDATE_CACHE(re, &s->gb);
-        }
-end:
-        LAST_SKIP_BITS(re, &s->gb, 2);
-        CLOSE_READER(re, &s->gb);
-    }
-    block[63] ^= (mismatch & 1);
-    
-    s->block_last_index[n] = i;
-    return 0;
-}
-
-static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s, 
-                               DCTELEM *block, 
-                               int n)
-{
-    int level, i, j, run;
-    RLTable *rl = &rl_mpeg1;
-    uint8_t * const scantable= s->intra_scantable.permutated;
-    const int qscale= s->qscale;
-    OPEN_READER(re, &s->gb);
-    i = -1;
-
-    /* special case for the first coef. no need to add a second vlc table */
-    UPDATE_CACHE(re, &s->gb);
-    if (((int32_t)GET_CACHE(re, &s->gb)) < 0) {
-        level= (3*qscale)>>1;
-        if(GET_CACHE(re, &s->gb)&0x40000000)
-            level= -level;
-        block[0] = level;
-        i++;
-        SKIP_BITS(re, &s->gb, 2);
-        if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
-            goto end;
-    }
-
-    /* now quantify & encode AC coefs */
-    for(;;) {
-        GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
-        
-        if(level != 0) {
-            i += run;
-            j = scantable[i];
-            level= ((level*2+1)*qscale)>>1;
-            level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
-            SKIP_BITS(re, &s->gb, 1);
-        } else {
-            /* escape */
-            run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re, &s->gb, 6);
-            UPDATE_CACHE(re, &s->gb);
-            level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
-
-            i += run;
-            j = scantable[i];
-            if(level<0){
-                level= ((-level*2+1)*qscale)>>1;
-                level= -level;
-            }else{
-                level= ((level*2+1)*qscale)>>1;
-            }
-        }
-        
-        block[j] = level;
-        if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
-            break;
-        UPDATE_CACHE(re, &s->gb);
-    }
-end:
-    LAST_SKIP_BITS(re, &s->gb, 2);    
-    CLOSE_READER(re, &s->gb);
-    s->block_last_index[n] = i;
-    return 0;
-}
-
-
-static inline int mpeg2_decode_block_intra(MpegEncContext *s, 
-                               DCTELEM *block, 
-                               int n)
-{
-    int level, dc, diff, i, j, run;
-    int component;
-    RLTable *rl;
-    uint8_t * const scantable= s->intra_scantable.permutated;
-    const uint16_t *quant_matrix;
-    const int qscale= s->qscale;
-    int mismatch;
-
-    /* DC coef */
-    if (n < 4){
-        quant_matrix = s->intra_matrix;
-        component = 0; 
-    }else{
-        quant_matrix = s->chroma_intra_matrix;
-        component = (n&1) + 1;
-    }
-    diff = decode_dc(&s->gb, component);
-    if (diff >= 0xffff)
-        return -1;
-    dc = s->last_dc[component];
-    dc += diff;
-    s->last_dc[component] = dc;
-    block[0] = dc << (3 - s->intra_dc_precision);
-    dprintf("dc=%d\n", block[0]);
-    mismatch = block[0] ^ 1;
-    i = 0;
-    if (s->intra_vlc_format)
-        rl = &rl_mpeg2;
-    else
-        rl = &rl_mpeg1;
-
-    {
-        OPEN_READER(re, &s->gb);    
-        /* now quantify & encode AC coefs */
-        for(;;) {
-            UPDATE_CACHE(re, &s->gb);
-            GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
-            
-            if(level == 127){
-                break;
-            } else if(level != 0) {
-                i += run;
-                j = scantable[i];
-                level= (level*qscale*quant_matrix[j])>>4;
-                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
-                LAST_SKIP_BITS(re, &s->gb, 1);
-            } else {
-                /* escape */
-                run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re, &s->gb, 6);
-                UPDATE_CACHE(re, &s->gb);
-                level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
-                i += run;
-                j = scantable[i];
-                if(level<0){
-                    level= (-level*qscale*quant_matrix[j])>>4;
-                    level= -level;
-                }else{
-                    level= (level*qscale*quant_matrix[j])>>4;
-                }
-            }
-            if (i > 63){
-                av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
-                return -1;
-            }
-            
-            mismatch^= level;
-            block[j] = level;
-        }
-        CLOSE_READER(re, &s->gb);
-    }
-    block[63]^= mismatch&1;
-    
-    s->block_last_index[n] = i;
-    return 0;
-}
-
-static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s, 
-                               DCTELEM *block, 
-                               int n)
-{
-    int level, dc, diff, j, run;
-    int component;
-    RLTable *rl;
-    uint8_t * scantable= s->intra_scantable.permutated;
-    const uint16_t *quant_matrix;
-    const int qscale= s->qscale;
-
-    /* DC coef */
-    if (n < 4){
-        quant_matrix = s->intra_matrix;
-        component = 0; 
-    }else{
-        quant_matrix = s->chroma_intra_matrix;
-        component = (n&1) + 1;
-    }
-    diff = decode_dc(&s->gb, component);
-    if (diff >= 0xffff)
-        return -1;
-    dc = s->last_dc[component];
-    dc += diff;
-    s->last_dc[component] = dc;
-    block[0] = dc << (3 - s->intra_dc_precision);
-    if (s->intra_vlc_format)
-        rl = &rl_mpeg2;
-    else
-        rl = &rl_mpeg1;
-
-    {
-        OPEN_READER(re, &s->gb);    
-        /* now quantify & encode AC coefs */
-        for(;;) {
-            UPDATE_CACHE(re, &s->gb);
-            GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
-            
-            if(level == 127){
-                break;
-            } else if(level != 0) {
-                scantable += run;
-                j = *scantable;
-                level= (level*qscale*quant_matrix[j])>>4;
-                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
-                LAST_SKIP_BITS(re, &s->gb, 1);
-            } else {
-                /* escape */
-                run = SHOW_UBITS(re, &s->gb, 6)+1; LAST_SKIP_BITS(re, &s->gb, 6);
-                UPDATE_CACHE(re, &s->gb);
-                level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
-                scantable += run;
-                j = *scantable;
-                if(level<0){
-                    level= (-level*qscale*quant_matrix[j])>>4;
-                    level= -level;
-                }else{
-                    level= (level*qscale*quant_matrix[j])>>4;
-                }
-            }
-            
-            block[j] = level;
-        }
-        CLOSE_READER(re, &s->gb);
-    }
-    
-    s->block_last_index[n] = scantable - s->intra_scantable.permutated;
-    return 0;
-}
-
-typedef struct Mpeg1Context {
-    MpegEncContext mpeg_enc_ctx;
-    int mpeg_enc_ctx_allocated; /* true if decoding context allocated */
-    int repeat_field; /* true if we must repeat the field */
-    AVPanScan pan_scan; /** some temporary storage for the panscan */
-    int slice_count;
-    int swap_uv;//indicate VCR2
-    int save_aspect_info;
-    AVRational frame_rate_ext;       ///< MPEG-2 specific framerate modificator
-
-} Mpeg1Context;
-
-static int mpeg_decode_init(AVCodecContext *avctx)
-{
-    Mpeg1Context *s = avctx->priv_data;
-    MpegEncContext *s2 = &s->mpeg_enc_ctx;
-    int i;
-    
-    //we need some parmutation to store
-    //matrixes, until MPV_common_init()
-    //set the real permutatuon 
-    for(i=0;i<64;i++)
-       s2->dsp.idct_permutation[i]=i;
-
-    MPV_decode_defaults(s2);
-    
-    s->mpeg_enc_ctx.avctx= avctx;
-    s->mpeg_enc_ctx.flags= avctx->flags;
-    s->mpeg_enc_ctx.flags2= avctx->flags2;
-    common_init(&s->mpeg_enc_ctx);
-    init_vlcs();
-
-    s->mpeg_enc_ctx_allocated = 0;
-    s->mpeg_enc_ctx.picture_number = 0;
-    s->repeat_field = 0;
-    s->mpeg_enc_ctx.codec_id= avctx->codec->id;
-    return 0;
-}
-
-static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm, 
-                                     const uint8_t *new_perm){
-    uint16_t temp_matrix[64];
-    int i;
-
-    memcpy(temp_matrix,matrix,64*sizeof(uint16_t));
-    
-    for(i=0;i<64;i++){
-        matrix[new_perm[i]] = temp_matrix[old_perm[i]];
-    }      
-}
-
-//Call this function when we know all parameters
-//it may be called in different places for mpeg1 and mpeg2
-static int mpeg_decode_postinit(AVCodecContext *avctx){
-    Mpeg1Context *s1 = avctx->priv_data;
-    MpegEncContext *s = &s1->mpeg_enc_ctx;
-    uint8_t old_permutation[64];
-
-    if (
-    	(s1->mpeg_enc_ctx_allocated == 0)|| 
-        avctx->coded_width  != s->width ||
-        avctx->coded_height != s->height||
-        s1->save_aspect_info != s->aspect_ratio_info||
-        0)
-    {
-    
-        if (s1->mpeg_enc_ctx_allocated) {
-            ParseContext pc= s->parse_context;
-            s->parse_context.buffer=0;
-            MPV_common_end(s);
-            s->parse_context= pc;
-        }
-
-	if( (s->width == 0 )||(s->height == 0))
-	    return -2;
-
-        avcodec_set_dimensions(avctx, s->width, s->height);
-        avctx->bit_rate = s->bit_rate;
-        s1->save_aspect_info = s->aspect_ratio_info;
-
-     //low_delay may be forced, in this case we will have B frames
-     //that behave like P frames
-        avctx->has_b_frames = !(s->low_delay);
-
-        if(avctx->sub_id==1){//s->codec_id==avctx->codec_id==CODEC_ID
-            //mpeg1 fps
-            avctx->time_base.den     = frame_rate_tab[s->frame_rate_index].num;
-            avctx->time_base.num= frame_rate_tab[s->frame_rate_index].den;
-            //mpeg1 aspect
-            avctx->sample_aspect_ratio= av_d2q(
-                    1.0/mpeg1_aspect[s->aspect_ratio_info], 255);
-
-        }else{//mpeg2
-        //mpeg2 fps
-            av_reduce(
-                &s->avctx->time_base.den, 
-                &s->avctx->time_base.num, 
-                frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num,
-                frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
-                1<<30);
-        //mpeg2 aspect
-            if(s->aspect_ratio_info > 1){
-                if( (s1->pan_scan.width == 0 )||(s1->pan_scan.height == 0) ){
-                    s->avctx->sample_aspect_ratio= 
-                        av_div_q(
-                         mpeg2_aspect[s->aspect_ratio_info], 
-                         (AVRational){s->width, s->height}
-                         );
-                }else{
-                    s->avctx->sample_aspect_ratio= 
-                        av_div_q(
-                         mpeg2_aspect[s->aspect_ratio_info], 
-                         (AVRational){s1->pan_scan.width, s1->pan_scan.height}
-                        );
-        	}
-            }else{
-                s->avctx->sample_aspect_ratio= 
-                    mpeg2_aspect[s->aspect_ratio_info];
-            }
-        }//mpeg2
-
-        if(avctx->xvmc_acceleration){
-            avctx->pix_fmt = avctx->get_format(avctx,pixfmt_xvmc_mpg2_420);
-        }else{
-            if(s->chroma_format <  2){
-                avctx->pix_fmt = avctx->get_format(avctx,pixfmt_yuv_420);
-            }else
-            if(s->chroma_format == 2){
-                avctx->pix_fmt = avctx->get_format(avctx,pixfmt_yuv_422);
-            }else
-            if(s->chroma_format >  2){
-                avctx->pix_fmt = avctx->get_format(avctx,pixfmt_yuv_444);
-            }
-        }
-        //until then pix_fmt may be changed right after codec init
-        if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT )
-            if( avctx->idct_algo == FF_IDCT_AUTO )
-                avctx->idct_algo = FF_IDCT_SIMPLE;
-
-        //quantization matrixes may need reordering 
-        //if dct permutation is changed
-        memcpy(old_permutation,s->dsp.idct_permutation,64*sizeof(uint8_t));
-
-        if (MPV_common_init(s) < 0)
-            return -2;
-
-        quant_matrix_rebuild(s->intra_matrix,       old_permutation,s->dsp.idct_permutation);
-        quant_matrix_rebuild(s->inter_matrix,       old_permutation,s->dsp.idct_permutation);
-        quant_matrix_rebuild(s->chroma_intra_matrix,old_permutation,s->dsp.idct_permutation);
-        quant_matrix_rebuild(s->chroma_inter_matrix,old_permutation,s->dsp.idct_permutation);
-
-        s1->mpeg_enc_ctx_allocated = 1;
-    }
-    return 0;
-}
-
-/* return the 8 bit start code value and update the search
-   state. Return -1 if no start code found */
-static int find_start_code(const uint8_t **pbuf_ptr, const uint8_t *buf_end)
-{
-    const uint8_t *buf_ptr= *pbuf_ptr;
-
-    buf_ptr++; //gurantees that -1 is within the array
-    buf_end -= 2; // gurantees that +2 is within the array
-
-    while (buf_ptr < buf_end) {
-        if(*buf_ptr==0){
-            while(buf_ptr < buf_end && buf_ptr[1]==0)
-                buf_ptr++;
-
-            if(buf_ptr[-1] == 0 && buf_ptr[1] == 1){
-                *pbuf_ptr = buf_ptr+3;
-                return buf_ptr[2] + 0x100;
-            }
-        }
-        buf_ptr += 2;
-    }
-    buf_end += 2; //undo the hack above
-    
-    *pbuf_ptr = buf_end;
-    return -1;
-}
-
-static int mpeg1_decode_picture(AVCodecContext *avctx, 
-                                const uint8_t *buf, int buf_size)
-{
-    Mpeg1Context *s1 = avctx->priv_data;
-    MpegEncContext *s = &s1->mpeg_enc_ctx;
-    int ref, f_code, vbv_delay;
-
-    if(mpeg_decode_postinit(s->avctx) < 0) 
-       return -2;
-
-    init_get_bits(&s->gb, buf, buf_size*8);
-
-    ref = get_bits(&s->gb, 10); /* temporal ref */
-    s->pict_type = get_bits(&s->gb, 3);
-    if(s->pict_type == 0 || s->pict_type > 3)
-        return -1;
-
-    vbv_delay= get_bits(&s->gb, 16);
-    if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) {
-        s->full_pel[0] = get_bits1(&s->gb);
-        f_code = get_bits(&s->gb, 3);
-        if (f_code == 0 && avctx->error_resilience >= FF_ER_COMPLIANT)
-            return -1;
-        s->mpeg_f_code[0][0] = f_code;
-        s->mpeg_f_code[0][1] = f_code;
-    }
-    if (s->pict_type == B_TYPE) {
-        s->full_pel[1] = get_bits1(&s->gb);
-        f_code = get_bits(&s->gb, 3);
-        if (f_code == 0 && avctx->error_resilience >= FF_ER_COMPLIANT)
-            return -1;
-        s->mpeg_f_code[1][0] = f_code;
-        s->mpeg_f_code[1][1] = f_code;
-    }
-    s->current_picture.pict_type= s->pict_type;
-    s->current_picture.key_frame= s->pict_type == I_TYPE;
-    
-    if(avctx->debug & FF_DEBUG_PICT_INFO)
-        av_log(avctx, AV_LOG_DEBUG, "vbv_delay %d, ref %d type:%d\n", vbv_delay, ref, s->pict_type);
-    
-    s->y_dc_scale = 8;
-    s->c_dc_scale = 8;
-    s->first_slice = 1;
-    return 0;
-}
-
-static void mpeg_decode_sequence_extension(Mpeg1Context *s1)
-{
-    MpegEncContext *s= &s1->mpeg_enc_ctx;
-    int horiz_size_ext, vert_size_ext;
-    int bit_rate_ext;
-
-    skip_bits(&s->gb, 1); /* profil and level esc*/
-    s->avctx->profile= get_bits(&s->gb, 3);
-    s->avctx->level= get_bits(&s->gb, 4);
-    s->progressive_sequence = get_bits1(&s->gb); /* progressive_sequence */
-    s->chroma_format = get_bits(&s->gb, 2); /* chroma_format 1=420, 2=422, 3=444 */
-    horiz_size_ext = get_bits(&s->gb, 2);
-    vert_size_ext = get_bits(&s->gb, 2);
-    s->width |= (horiz_size_ext << 12);
-    s->height |= (vert_size_ext << 12);
-    bit_rate_ext = get_bits(&s->gb, 12);  /* XXX: handle it */
-    s->bit_rate += (bit_rate_ext << 18) * 400;
-    skip_bits1(&s->gb); /* marker */
-    s->avctx->rc_buffer_size += get_bits(&s->gb, 8)*1024*16<<10;
-
-    s->low_delay = get_bits1(&s->gb);
-    if(s->flags & CODEC_FLAG_LOW_DELAY) s->low_delay=1;
-
-    s1->frame_rate_ext.num = get_bits(&s->gb, 2)+1;
-    s1->frame_rate_ext.den = get_bits(&s->gb, 5)+1;
-
-    dprintf("sequence extension\n");
-    s->codec_id= s->avctx->codec_id= CODEC_ID_MPEG2VIDEO;
-    s->avctx->sub_id = 2; /* indicates mpeg2 found */
-
-    if(s->avctx->debug & FF_DEBUG_PICT_INFO)
-        av_log(s->avctx, AV_LOG_DEBUG, "profile: %d, level: %d vbv buffer: %d, bitrate:%d\n", 
-               s->avctx->profile, s->avctx->level, s->avctx->rc_buffer_size, s->bit_rate);
-
-}
-
-static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1)
-{
-    MpegEncContext *s= &s1->mpeg_enc_ctx;
-    int color_description, w, h;
-
-    skip_bits(&s->gb, 3); /* video format */
-    color_description= get_bits1(&s->gb);
-    if(color_description){
-        skip_bits(&s->gb, 8); /* color primaries */
-        skip_bits(&s->gb, 8); /* transfer_characteristics */
-        skip_bits(&s->gb, 8); /* matrix_coefficients */
-    }
-    w= get_bits(&s->gb, 14);
-    skip_bits(&s->gb, 1); //marker
-    h= get_bits(&s->gb, 14);
-    skip_bits(&s->gb, 1); //marker
-    
-    s1->pan_scan.width= 16*w;
-    s1->pan_scan.height=16*h;
-        
-    if(s->avctx->debug & FF_DEBUG_PICT_INFO)
-        av_log(s->avctx, AV_LOG_DEBUG, "sde w:%d, h:%d\n", w, h);
-}
-
-static void mpeg_decode_picture_display_extension(Mpeg1Context *s1)
-{
-    MpegEncContext *s= &s1->mpeg_enc_ctx;
-    int i,nofco;
-
-    nofco = 1;
-    if(s->progressive_sequence){
-        if(s->repeat_first_field){
-	    nofco++;
-	    if(s->top_field_first)
-	        nofco++;	
-	}
-    }else{
-        if(s->picture_structure == PICT_FRAME){
-            nofco++;
-	    if(s->repeat_first_field)
-	        nofco++;
-	}
-    }
-    for(i=0; i<nofco; i++){
-        s1->pan_scan.position[i][0]= get_sbits(&s->gb, 16);
-        skip_bits(&s->gb, 1); //marker
-        s1->pan_scan.position[i][1]= get_sbits(&s->gb, 16);
-        skip_bits(&s->gb, 1); //marker
-    }
-   
-    if(s->avctx->debug & FF_DEBUG_PICT_INFO)
-        av_log(s->avctx, AV_LOG_DEBUG, "pde (%d,%d) (%d,%d) (%d,%d)\n", 
-            s1->pan_scan.position[0][0], s1->pan_scan.position[0][1], 
-            s1->pan_scan.position[1][0], s1->pan_scan.position[1][1], 
-            s1->pan_scan.position[2][0], s1->pan_scan.position[2][1]
-        );
-}
-
-static void mpeg_decode_quant_matrix_extension(MpegEncContext *s)
-{
-    int i, v, j;
-
-    dprintf("matrix extension\n");
-
-    if (get_bits1(&s->gb)) {
-        for(i=0;i<64;i++) {
-            v = get_bits(&s->gb, 8);
-            j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
-            s->intra_matrix[j] = v;
-            s->chroma_intra_matrix[j] = v;
-        }
-    }
-    if (get_bits1(&s->gb)) {
-        for(i=0;i<64;i++) {
-            v = get_bits(&s->gb, 8);
-            j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
-            s->inter_matrix[j] = v;
-            s->chroma_inter_matrix[j] = v;
-        }
-    }
-    if (get_bits1(&s->gb)) {
-        for(i=0;i<64;i++) {
-            v = get_bits(&s->gb, 8);
-            j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
-            s->chroma_intra_matrix[j] = v;
-        }
-    }
-    if (get_bits1(&s->gb)) {
-        for(i=0;i<64;i++) {
-            v = get_bits(&s->gb, 8);
-            j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
-            s->chroma_inter_matrix[j] = v;
-        }
-    }
-}
-
-static void mpeg_decode_picture_coding_extension(MpegEncContext *s)
-{
-    s->full_pel[0] = s->full_pel[1] = 0;
-    s->mpeg_f_code[0][0] = get_bits(&s->gb, 4);
-    s->mpeg_f_code[0][1] = get_bits(&s->gb, 4);
-    s->mpeg_f_code[1][0] = get_bits(&s->gb, 4);
-    s->mpeg_f_code[1][1] = get_bits(&s->gb, 4);
-    s->intra_dc_precision = get_bits(&s->gb, 2);
-    s->picture_structure = get_bits(&s->gb, 2);
-    s->top_field_first = get_bits1(&s->gb);
-    s->frame_pred_frame_dct = get_bits1(&s->gb);
-    s->concealment_motion_vectors = get_bits1(&s->gb);
-    s->q_scale_type = get_bits1(&s->gb);
-    s->intra_vlc_format = get_bits1(&s->gb);
-    s->alternate_scan = get_bits1(&s->gb);
-    s->repeat_first_field = get_bits1(&s->gb);
-    s->chroma_420_type = get_bits1(&s->gb);
-    s->progressive_frame = get_bits1(&s->gb);
-
-    if(s->picture_structure == PICT_FRAME)
-        s->first_field=0;
-    else{
-        s->first_field ^= 1;
-        memset(s->mbskip_table, 0, s->mb_stride*s->mb_height);
-    }
-    
-    if(s->alternate_scan){
-        ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable  , ff_alternate_vertical_scan);
-        ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable  , ff_alternate_vertical_scan);
-    }else{
-        ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable  , ff_zigzag_direct);
-        ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable  , ff_zigzag_direct);
-    }
-    
-    /* composite display not parsed */
-    dprintf("intra_dc_precision=%d\n", s->intra_dc_precision);
-    dprintf("picture_structure=%d\n", s->picture_structure);
-    dprintf("top field first=%d\n", s->top_field_first);
-    dprintf("repeat first field=%d\n", s->repeat_first_field);
-    dprintf("conceal=%d\n", s->concealment_motion_vectors);
-    dprintf("intra_vlc_format=%d\n", s->intra_vlc_format);
-    dprintf("alternate_scan=%d\n", s->alternate_scan);
-    dprintf("frame_pred_frame_dct=%d\n", s->frame_pred_frame_dct);
-    dprintf("progressive_frame=%d\n", s->progressive_frame);
-}
-
-static void mpeg_decode_extension(AVCodecContext *avctx, 
-                                  const uint8_t *buf, int buf_size)
-{
-    Mpeg1Context *s1 = avctx->priv_data;
-    MpegEncContext *s = &s1->mpeg_enc_ctx;
-    int ext_type;
-
-    init_get_bits(&s->gb, buf, buf_size*8);
-    
-    ext_type = get_bits(&s->gb, 4);
-    switch(ext_type) {
-    case 0x1:
-        mpeg_decode_sequence_extension(s1);
-        break;
-    case 0x2:
-        mpeg_decode_sequence_display_extension(s1);
-        break;
-    case 0x3:
-        mpeg_decode_quant_matrix_extension(s);
-        break;
-    case 0x7:
-        mpeg_decode_picture_display_extension(s1);
-        break;
-    case 0x8:
-        mpeg_decode_picture_coding_extension(s);
-        break;
-    }
-}
-
-static void exchange_uv(MpegEncContext *s){
-    short * tmp = s->pblocks[4];
-    s->pblocks[4] = s->pblocks[5];
-    s->pblocks[5] = tmp;
-}
-
-static int mpeg_field_start(MpegEncContext *s){
-    AVCodecContext *avctx= s->avctx;
-    Mpeg1Context *s1 = (Mpeg1Context*)s;
-
-    /* start frame decoding */
-    if(s->first_field || s->picture_structure==PICT_FRAME){
-        if(MPV_frame_start(s, avctx) < 0)
-            return -1;
-
-        ff_er_frame_start(s);
-
-        /* first check if we must repeat the frame */
-        s->current_picture_ptr->repeat_pict = 0;
-        if (s->repeat_first_field) {
-            if (s->progressive_sequence) {
-                if (s->top_field_first)
-                    s->current_picture_ptr->repeat_pict = 4;
-                else
-                    s->current_picture_ptr->repeat_pict = 2;
-            } else if (s->progressive_frame) {
-                s->current_picture_ptr->repeat_pict = 1;
-            }
-        }         
-
-        *s->current_picture_ptr->pan_scan= s1->pan_scan;
-    }else{ //second field
-            int i;
-            
-            if(!s->current_picture_ptr){
-                av_log(s->avctx, AV_LOG_ERROR, "first field missing\n");
-                return -1;
-            }
-            
-            for(i=0; i<4; i++){
-                s->current_picture.data[i] = s->current_picture_ptr->data[i];
-                if(s->picture_structure == PICT_BOTTOM_FIELD){
-                    s->current_picture.data[i] += s->current_picture_ptr->linesize[i];
-                } 
-            }
-    }
-#ifdef HAVE_XVMC
-// MPV_frame_start will call this function too,
-// but we need to call it on every field
-    if(s->avctx->xvmc_acceleration)
-         XVMC_field_start(s,avctx);
-#endif
-
-    return 0;
-}
-
-#define DECODE_SLICE_ERROR -1
-#define DECODE_SLICE_OK 0
-
-/**
- * decodes a slice. MpegEncContext.mb_y must be set to the MB row from the startcode
- * @return DECODE_SLICE_ERROR if the slice is damaged<br>
- *         DECODE_SLICE_OK if this slice is ok<br>
- */
-static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
-                             const uint8_t **buf, int buf_size)
-{
-    MpegEncContext *s = &s1->mpeg_enc_ctx;
-    AVCodecContext *avctx= s->avctx;
-    int ret;
-    const int field_pic= s->picture_structure != PICT_FRAME;
-    const int lowres= s->avctx->lowres;
-
-    s->resync_mb_x=
-    s->resync_mb_y= -1;
-
-    if (mb_y<<field_pic >= s->mb_height){
-        av_log(s->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", mb_y, s->mb_height);
-        return -1;
-    }
-    
-    init_get_bits(&s->gb, *buf, buf_size*8);
-
-    ff_mpeg1_clean_buffers(s);
-    s->interlaced_dct = 0;
-
-    s->qscale = get_qscale(s);
-
-    if(s->qscale == 0){
-        av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n");
-        return -1;
-    }
-    
-    /* extra slice info */
-    while (get_bits1(&s->gb) != 0) {
-        skip_bits(&s->gb, 8);
-    }
-    
-    s->mb_x=0;
-
-    for(;;) {
-        int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);
-        if (code < 0){
-            av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n");
-            return -1;
-        }
-        if (code >= 33) {
-            if (code == 33) {
-                s->mb_x += 33;
-            }
-            /* otherwise, stuffing, nothing to do */
-        } else {
-            s->mb_x += code;
-            break;
-        }
-    }
-
-    s->resync_mb_x= s->mb_x;
-    s->resync_mb_y= s->mb_y= mb_y;
-    s->mb_skip_run= 0;
-    ff_init_block_index(s);
-
-    if (s->mb_y==0 && s->mb_x==0 && (s->first_field || s->picture_structure==PICT_FRAME)) {
-        if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-             av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", 
-                 s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1],
-                 s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")), 
-                 s->progressive_sequence ? "ps" :"", s->progressive_frame ? "pf" : "", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"", 
-                 s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors,
-                 s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :"");
-        }
-    }    
-    
-    for(;;) {
-#ifdef HAVE_XVMC
-        //one 1 we memcpy blocks in xvmcvideo
-        if(s->avctx->xvmc_acceleration > 1)
-            XVMC_init_block(s);//set s->block
-#endif
-
-        ret = mpeg_decode_mb(s, s->block);
-        s->chroma_qscale= s->qscale;
-
-        dprintf("ret=%d\n", ret);
-        if (ret < 0)
-            return -1;
-
-        if(s->current_picture.motion_val[0] && !s->encoding){ //note motion_val is normally NULL unless we want to extract the MVs
-            const int wrap = field_pic ? 2*s->b8_stride : s->b8_stride;
-            int xy = s->mb_x*2 + s->mb_y*2*wrap;
-            int motion_x, motion_y, dir, i;
-            if(field_pic && !s->first_field)
-                xy += wrap/2;
-
-            for(i=0; i<2; i++){
-                for(dir=0; dir<2; dir++){
-                    if (s->mb_intra || (dir==1 && s->pict_type != B_TYPE)) {
-                        motion_x = motion_y = 0;
-                    }else if (s->mv_type == MV_TYPE_16X16 || (s->mv_type == MV_TYPE_FIELD && field_pic)){
-                        motion_x = s->mv[dir][0][0];
-                        motion_y = s->mv[dir][0][1];
-                    } else /*if ((s->mv_type == MV_TYPE_FIELD) || (s->mv_type == MV_TYPE_16X8))*/ {
-                        motion_x = s->mv[dir][i][0];
-                        motion_y = s->mv[dir][i][1];
-                    }
-
-                    s->current_picture.motion_val[dir][xy    ][0] = motion_x;
-                    s->current_picture.motion_val[dir][xy    ][1] = motion_y;
-                    s->current_picture.motion_val[dir][xy + 1][0] = motion_x;
-                    s->current_picture.motion_val[dir][xy + 1][1] = motion_y;
-                    s->current_picture.ref_index [dir][xy    ]=
-                    s->current_picture.ref_index [dir][xy + 1]= s->field_select[dir][i];
-                    assert(s->field_select[dir][i]==0 || s->field_select[dir][i]==1);
-                }
-                xy += wrap;
-            }
-        }
-
-        s->dest[0] += 16 >> lowres;
-        s->dest[1] += 16 >> (s->chroma_x_shift + lowres);
-        s->dest[2] += 16 >> (s->chroma_x_shift + lowres);
-
-        MPV_decode_mb(s, s->block);
-        
-        if (++s->mb_x >= s->mb_width) {
-            const int mb_size= 16>>s->avctx->lowres;
-
-            ff_draw_horiz_band(s, mb_size*s->mb_y, mb_size);
-
-            s->mb_x = 0;
-            s->mb_y++;
-
-            if(s->mb_y<<field_pic >= s->mb_height){
-                int left= s->gb.size_in_bits - get_bits_count(&s->gb);
-
-                if(left < 0 || (left && show_bits(&s->gb, FFMIN(left, 23)))
-                   || (avctx->error_resilience >= FF_ER_AGGRESSIVE && left>8)){
-                    av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d\n", left);
-                    return -1;
-                }else
-                    goto eos;
-            }
-            
-            ff_init_block_index(s);
-        }
-
-        /* skip mb handling */
-        if (s->mb_skip_run == -1) {
-            /* read again increment */
-            s->mb_skip_run = 0;
-            for(;;) {
-                int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);
-                if (code < 0){
-                    av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n");
-                    return -1;
-                }
-                if (code >= 33) {
-                    if (code == 33) {
-                        s->mb_skip_run += 33;
-                    }else if(code == 35){
-                        if(s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0){
-                            av_log(s->avctx, AV_LOG_ERROR, "slice mismatch\n");
-                            return -1;
-                        }
-                        goto eos; /* end of slice */
-                    }
-                    /* otherwise, stuffing, nothing to do */
-                } else {
-                    s->mb_skip_run += code;
-                    break;
-                }
-            }
-        }
-    }
-eos: // end of slice
-    *buf += get_bits_count(&s->gb)/8 - 1;
-//printf("y %d %d %d %d\n", s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y);
-    return 0;
-}
-
-static int slice_decode_thread(AVCodecContext *c, void *arg){
-    MpegEncContext *s= arg;
-    const uint8_t *buf= s->gb.buffer;
-    int mb_y= s->start_mb_y;
-
-    s->error_count= 3*(s->end_mb_y - s->start_mb_y)*s->mb_width;
-
-    for(;;){
-        int start_code, ret;
-
-        ret= mpeg_decode_slice((Mpeg1Context*)s, mb_y, &buf, s->gb.buffer_end - buf);
-        emms_c();
-//av_log(c, AV_LOG_DEBUG, "ret:%d resync:%d/%d mb:%d/%d ts:%d/%d ec:%d\n", 
-//ret, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, s->start_mb_y, s->end_mb_y, s->error_count);
-        if(ret < 0){
-            if(s->resync_mb_x>=0 && s->resync_mb_y>=0)
-                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
-        }else{
-            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);
-        }
-        
-        if(s->mb_y == s->end_mb_y)
-            return 0;
-        
-        start_code = find_start_code(&buf, s->gb.buffer_end);
-        mb_y= start_code - SLICE_MIN_START_CODE;
-        if(mb_y < 0 || mb_y >= s->end_mb_y)
-            return -1;
-    }
-    
-    return 0; //not reached
-}
-
-/**
- * handles slice ends.
- * @return 1 if it seems to be the last slice of 
- */
-static int slice_end(AVCodecContext *avctx, AVFrame *pict)
-{
-    Mpeg1Context *s1 = avctx->priv_data;
-    MpegEncContext *s = &s1->mpeg_enc_ctx;
-       
-    if (!s1->mpeg_enc_ctx_allocated || !s->current_picture_ptr)
-        return 0;
-
-#ifdef HAVE_XVMC
-    if(s->avctx->xvmc_acceleration)
-        XVMC_field_end(s);
-#endif
-    /* end of slice reached */
-    if (/*s->mb_y<<field_pic == s->mb_height &&*/ !s->first_field) {
-        /* end of image */
-
-        s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_MPEG2;
-
-        ff_er_frame_end(s);
-
-        MPV_frame_end(s);
-
-        if (s->pict_type == B_TYPE || s->low_delay) {
-            *pict= *(AVFrame*)s->current_picture_ptr;
-            ff_print_debug_info(s, pict);
-        } else {
-            s->picture_number++;
-            /* latency of 1 frame for I and P frames */
-            /* XXX: use another variable than picture_number */
-            if (s->last_picture_ptr != NULL) {
-                *pict= *(AVFrame*)s->last_picture_ptr;
-                 ff_print_debug_info(s, pict);
-            }
-        }
-
-        return 1;
-    } else {
-        return 0;
-    }
-}
-
-static int mpeg1_decode_sequence(AVCodecContext *avctx, 
-                                 const uint8_t *buf, int buf_size)
-{
-    Mpeg1Context *s1 = avctx->priv_data;
-    MpegEncContext *s = &s1->mpeg_enc_ctx;
-    int width,height;
-    int i, v, j;
-
-    init_get_bits(&s->gb, buf, buf_size*8);
-
-    width = get_bits(&s->gb, 12);
-    height = get_bits(&s->gb, 12);
-    if (width <= 0 || height <= 0 ||
-        (width % 2) != 0 || (height % 2) != 0)
-        return -1;
-    s->aspect_ratio_info= get_bits(&s->gb, 4);
-    if (s->aspect_ratio_info == 0)
-        return -1;
-    s->frame_rate_index = get_bits(&s->gb, 4);
-    if (s->frame_rate_index == 0 || s->frame_rate_index > 13)
-        return -1;
-    s->bit_rate = get_bits(&s->gb, 18) * 400;
-    if (get_bits1(&s->gb) == 0) /* marker */
-        return -1;
-    s->width = width;
-    s->height = height;
-
-    s->avctx->rc_buffer_size= get_bits(&s->gb, 10) * 1024*16;
-    skip_bits(&s->gb, 1);
-
-    /* get matrix */
-    if (get_bits1(&s->gb)) {
-        for(i=0;i<64;i++) {
-            v = get_bits(&s->gb, 8);
-            if(v==0){
-                av_log(s->avctx, AV_LOG_ERROR, "intra matrix damaged\n");
-                return -1;
-            }
-            j = s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
-            s->intra_matrix[j] = v;
-            s->chroma_intra_matrix[j] = v;
-        }
-#ifdef DEBUG
-        dprintf("intra matrix present\n");
-        for(i=0;i<64;i++)
-            dprintf(" %d", s->intra_matrix[s->dsp.idct_permutation[i]]);
-        printf("\n");
-#endif
-    } else {
-        for(i=0;i<64;i++) {
-            j = s->dsp.idct_permutation[i];
-            v = ff_mpeg1_default_intra_matrix[i];
-            s->intra_matrix[j] = v;
-            s->chroma_intra_matrix[j] = v;
-        }
-    }
-    if (get_bits1(&s->gb)) {
-        for(i=0;i<64;i++) {
-            v = get_bits(&s->gb, 8);
-            if(v==0){
-                av_log(s->avctx, AV_LOG_ERROR, "inter matrix damaged\n");
-                return -1;
-            }
-            j = s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
-            s->inter_matrix[j] = v;
-            s->chroma_inter_matrix[j] = v;
-        }
-#ifdef DEBUG
-        dprintf("non intra matrix present\n");
-        for(i=0;i<64;i++)
-            dprintf(" %d", s->inter_matrix[s->dsp.idct_permutation[i]]);
-        printf("\n");
-#endif
-    } else {
-        for(i=0;i<64;i++) {
-            int j= s->dsp.idct_permutation[i];
-            v = ff_mpeg1_default_non_intra_matrix[i];
-            s->inter_matrix[j] = v;
-            s->chroma_inter_matrix[j] = v;
-        }
-    }
-    
-    if(show_bits(&s->gb, 23) != 0){
-        av_log(s->avctx, AV_LOG_ERROR, "sequence header damaged\n");
-        return -1;
-    }
-
-    /* we set mpeg2 parameters so that it emulates mpeg1 */
-    s->progressive_sequence = 1;
-    s->progressive_frame = 1;
-    s->picture_structure = PICT_FRAME;
-    s->frame_pred_frame_dct = 1;
-    s->chroma_format = 1;
-    s->codec_id= s->avctx->codec_id= CODEC_ID_MPEG1VIDEO;
-    avctx->sub_id = 1; /* indicates mpeg1 */
-    s->out_format = FMT_MPEG1;
-    s->swap_uv = 0;//AFAIK VCR2 don't have SEQ_HEADER
-    if(s->flags & CODEC_FLAG_LOW_DELAY) s->low_delay=1;
-    
-    if(s->avctx->debug & FF_DEBUG_PICT_INFO)
-        av_log(s->avctx, AV_LOG_DEBUG, "vbv buffer: %d, bitrate:%d\n", 
-               s->avctx->rc_buffer_size, s->bit_rate);
-    
-    return 0;
-}
-
-static int vcr2_init_sequence(AVCodecContext *avctx)
-{
-    Mpeg1Context *s1 = avctx->priv_data;
-    MpegEncContext *s = &s1->mpeg_enc_ctx;
-    int i, v;
-
-    /* start new mpeg1 context decoding */
-    s->out_format = FMT_MPEG1;
-    if (s1->mpeg_enc_ctx_allocated) {
-        MPV_common_end(s);
-    }
-    s->width  = avctx->coded_width;
-    s->height = avctx->coded_height;
-    avctx->has_b_frames= 0; //true?
-    s->low_delay= 1;
-
-    if(avctx->xvmc_acceleration){
-        avctx->pix_fmt = avctx->get_format(avctx,pixfmt_xvmc_mpg2_420);
-    }else{
-        avctx->pix_fmt = avctx->get_format(avctx,pixfmt_yuv_420);
-    }
-
-    if( avctx->pix_fmt == PIX_FMT_XVMC_MPEG2_IDCT )
-        if( avctx->idct_algo == FF_IDCT_AUTO )
-            avctx->idct_algo = FF_IDCT_SIMPLE;
-    
-    if (MPV_common_init(s) < 0)
-        return -1;
-    exchange_uv(s);//common init reset pblocks, so we swap them here
-    s->swap_uv = 1;// in case of xvmc we need to swap uv for each MB 
-    s1->mpeg_enc_ctx_allocated = 1;
-
-    for(i=0;i<64;i++) {
-        int j= s->dsp.idct_permutation[i];
-        v = ff_mpeg1_default_intra_matrix[i];
-        s->intra_matrix[j] = v;
-        s->chroma_intra_matrix[j] = v;
-
-        v = ff_mpeg1_default_non_intra_matrix[i];
-        s->inter_matrix[j] = v;
-        s->chroma_inter_matrix[j] = v;
-    }
-
-    s->progressive_sequence = 1;
-    s->progressive_frame = 1;
-    s->picture_structure = PICT_FRAME;
-    s->frame_pred_frame_dct = 1;
-    s->chroma_format = 1;
-    s->codec_id= s->avctx->codec_id= CODEC_ID_MPEG2VIDEO;
-    avctx->sub_id = 2; /* indicates mpeg2 */
-    return 0;
-}
-
-
-static void mpeg_decode_user_data(AVCodecContext *avctx, 
-                                  const uint8_t *buf, int buf_size)
-{
-    const uint8_t *p;
-    int len, flags;
-    p = buf;
-    len = buf_size;
-
-    /* we parse the DTG active format information */
-    if (len >= 5 &&
-        p[0] == 'D' && p[1] == 'T' && p[2] == 'G' && p[3] == '1') {
-        flags = p[4];
-        p += 5;
-        len -= 5;
-        if (flags & 0x80) {
-            /* skip event id */
-            if (len < 2)
-                return;
-            p += 2;
-            len -= 2;
-        }
-        if (flags & 0x40) {
-            if (len < 1)
-                return;
-            avctx->dtg_active_format = p[0] & 0x0f;
-        }
-    }
-}
-
-static void mpeg_decode_gop(AVCodecContext *avctx, 
-                            const uint8_t *buf, int buf_size){
-    Mpeg1Context *s1 = avctx->priv_data;
-    MpegEncContext *s = &s1->mpeg_enc_ctx;
-
-    int drop_frame_flag;
-    int time_code_hours, time_code_minutes;
-    int time_code_seconds, time_code_pictures;
-    int broken_link;
-
-    init_get_bits(&s->gb, buf, buf_size*8);
-
-    drop_frame_flag = get_bits1(&s->gb);
-    
-    time_code_hours=get_bits(&s->gb,5);
-    time_code_minutes = get_bits(&s->gb,6);
-    skip_bits1(&s->gb);//marker bit
-    time_code_seconds = get_bits(&s->gb,6);
-    time_code_pictures = get_bits(&s->gb,6);
-
-    /*broken_link indicate that after editing the
-      reference frames of the first B-Frames after GOP I-Frame
-      are missing (open gop)*/
-    broken_link = get_bits1(&s->gb);
-
-    if(s->avctx->debug & FF_DEBUG_PICT_INFO)
-        av_log(s->avctx, AV_LOG_DEBUG, "GOP (%2d:%02d:%02d.[%02d]) broken_link=%d\n",
-	    time_code_hours, time_code_minutes, time_code_seconds,
-	    time_code_pictures, broken_link);
-}
-/**
- * finds the end of the current frame in the bitstream.
- * @return the position of the first byte of the next frame, or -1
- */
-int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size)
-{
-    int i;
-    uint32_t state;
-    
-    state= pc->state;
-    
-    i=0;
-    if(!pc->frame_start_found){
-        for(i=0; i<buf_size; i++){
-            state= (state<<8) | buf[i];
-            if(state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE){
-                i++;
-                pc->frame_start_found=1;
-                break;
-            }
-        }
-    }
-    
-    if(pc->frame_start_found){
-        /* EOF considered as end of frame */
-        if (buf_size == 0)
-            return 0;
-        for(; i<buf_size; i++){
-            state= (state<<8) | buf[i];
-            if((state&0xFFFFFF00) == 0x100){
-                if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){
-                    pc->frame_start_found=0;
-                    pc->state=-1; 
-                    return i-3;
-                }
-            }
-        }
-    }        
-    pc->state= state;
-    return END_NOT_FOUND;
-}
-
-/* handle buffering and image synchronisation */
-static int mpeg_decode_frame(AVCodecContext *avctx, 
-                             void *data, int *data_size,
-                             uint8_t *buf, int buf_size)
-{
-    Mpeg1Context *s = avctx->priv_data;
-    const uint8_t *buf_end;
-    const uint8_t *buf_ptr;
-    int ret, start_code, input_size;
-    AVFrame *picture = data;
-    MpegEncContext *s2 = &s->mpeg_enc_ctx;
-    dprintf("fill_buffer\n");
-
-    if (buf_size == 0) {
-	/* special case for last picture */
-	if (s2->low_delay==0 && s2->next_picture_ptr) {
-	    *picture= *(AVFrame*)s2->next_picture_ptr;
-	    s2->next_picture_ptr= NULL;
-
-	    *data_size = sizeof(AVFrame);
-	}
-        return 0;
-    }
-
-    if(s2->flags&CODEC_FLAG_TRUNCATED){
-        int next= ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size);
-        
-        if( ff_combine_frame(&s2->parse_context, next, &buf, &buf_size) < 0 )
-            return buf_size;
-    }    
-    
-    buf_ptr = buf;
-    buf_end = buf + buf_size;
-
-#if 0    
-    if (s->repeat_field % 2 == 1) { 
-        s->repeat_field++;
-        //fprintf(stderr,"\nRepeating last frame: %d -> %d! pict: %d %d", avctx->frame_number-1, avctx->frame_number,
-        //        s2->picture_number, s->repeat_field);
-        if (avctx->flags & CODEC_FLAG_REPEAT_FIELD) {
-            *data_size = sizeof(AVPicture);
-            goto the_end;
-        }
-    }
-#endif
-
-    if(s->mpeg_enc_ctx_allocated==0 && avctx->codec_tag == ff_get_fourcc("VCR2"))
-        vcr2_init_sequence(avctx);
-    
-    s->slice_count= 0;
-        
-    for(;;) {
-        /* find start next code */
-        start_code = find_start_code(&buf_ptr, buf_end);
-        if (start_code < 0){
-            if(s2->pict_type != B_TYPE || avctx->skip_frame <= AVDISCARD_DEFAULT){
-                if(avctx->thread_count > 1){
-                    int i;
-
-                    avctx->execute(avctx, slice_decode_thread,  (void**)&(s2->thread_context[0]), NULL, s->slice_count);
-                    for(i=0; i<s->slice_count; i++)
-                        s2->error_count += s2->thread_context[i]->error_count;
-                }
-                if (slice_end(avctx, picture)) {
-                    if(s2->last_picture_ptr || s2->low_delay) //FIXME merge with the stuff in mpeg_decode_slice
-                        *data_size = sizeof(AVPicture);
-                }
-            }
-            return FFMAX(0, buf_ptr - buf - s2->parse_context.last_index);
-        }
-        
-        input_size = buf_end - buf_ptr;
-
-        if(avctx->debug & FF_DEBUG_STARTCODE){
-            av_log(avctx, AV_LOG_DEBUG, "%3X at %zd left %d\n", start_code, buf_ptr-buf, input_size);
-        }
-
-                /* prepare data for next start code */
-                switch(start_code) {
-                case SEQ_START_CODE:
-                    mpeg1_decode_sequence(avctx, buf_ptr, 
-					  input_size);
-                    break;
-                            
-                case PICTURE_START_CODE:
-                    /* we have a complete image : we try to decompress it */
-                    mpeg1_decode_picture(avctx, 
-					 buf_ptr, input_size);
-                    break;
-                case EXT_START_CODE:
-                    mpeg_decode_extension(avctx,
-                                          buf_ptr, input_size);
-                    break;
-                case USER_START_CODE:
-                    mpeg_decode_user_data(avctx, 
-                                          buf_ptr, input_size);
-                    break;
-                case GOP_START_CODE:
-                    s2->first_field=0;
-                    mpeg_decode_gop(avctx, 
-                                          buf_ptr, input_size);
-                    break;
-                default:
-                    if (start_code >= SLICE_MIN_START_CODE &&
-                        start_code <= SLICE_MAX_START_CODE) {
-                        int mb_y= start_code - SLICE_MIN_START_CODE;
-                        
-                        if(s2->last_picture_ptr==NULL){
-                        /* skip b frames if we dont have reference frames */
-                            if(s2->pict_type==B_TYPE) break;
-                        /* skip P frames if we dont have reference frame no valid header */
-                            if(s2->pict_type==P_TYPE && !s2->first_slice) break;
-                        }
-                        /* skip b frames if we are in a hurry */
-                        if(avctx->hurry_up && s2->pict_type==B_TYPE) break;
-                        if(  (avctx->skip_frame >= AVDISCARD_NONREF && s2->pict_type==B_TYPE)
-                           ||(avctx->skip_frame >= AVDISCARD_NONKEY && s2->pict_type!=I_TYPE)
-                           || avctx->skip_frame >= AVDISCARD_ALL)
-                            break;
-                        /* skip everything if we are in a hurry>=5 */
-                        if(avctx->hurry_up>=5) break;
-                        
-                        if (!s->mpeg_enc_ctx_allocated) break;
-
-                        if(s2->codec_id == CODEC_ID_MPEG2VIDEO){
-                            if(mb_y < avctx->skip_top || mb_y >= s2->mb_height - avctx->skip_bottom)
-                                break;
-                        }
-                        
-                        if(s2->first_slice){
-                            s2->first_slice=0;
-                            if(mpeg_field_start(s2) < 0)
-                                return -1;
-                        }
-                        
-                        if(avctx->thread_count > 1){
-                            int threshold= (s2->mb_height*s->slice_count + avctx->thread_count/2) / avctx->thread_count;
-                            if(threshold <= mb_y){
-                                MpegEncContext *thread_context= s2->thread_context[s->slice_count];
-                                
-                                thread_context->start_mb_y= mb_y;
-                                thread_context->end_mb_y  = s2->mb_height;
-                                if(s->slice_count){
-                                    s2->thread_context[s->slice_count-1]->end_mb_y= mb_y;
-                                    ff_update_duplicate_context(thread_context, s2);
-                                }
-                                init_get_bits(&thread_context->gb, buf_ptr, input_size*8);
-                                s->slice_count++;
-                            }
-                            buf_ptr += 2; //FIXME add minimum num of bytes per slice
-                        }else{
-                            ret = mpeg_decode_slice(s, mb_y, &buf_ptr, input_size);
-                            emms_c();
-
-                            if(ret < 0){
-                                if(s2->resync_mb_x>=0 && s2->resync_mb_y>=0)
-                                    ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
-                            }else{
-                                ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x-1, s2->mb_y, AC_END|DC_END|MV_END);
-                            }
-                        }
-                    }
-                    break;
-                }
-    }
-}
-
-static int mpeg_decode_end(AVCodecContext *avctx)
-{
-    Mpeg1Context *s = avctx->priv_data;
-
-    if (s->mpeg_enc_ctx_allocated)
-        MPV_common_end(&s->mpeg_enc_ctx);
-    return 0;
-}
-
-AVCodec mpeg1video_decoder = {
-    "mpeg1video",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MPEG1VIDEO,
-    sizeof(Mpeg1Context),
-    mpeg_decode_init,
-    NULL,
-    mpeg_decode_end,
-    mpeg_decode_frame,
-    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
-    .flush= ff_mpeg_flush,
-};
-
-AVCodec mpeg2video_decoder = {
-    "mpeg2video",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MPEG2VIDEO,
-    sizeof(Mpeg1Context),
-    mpeg_decode_init,
-    NULL,
-    mpeg_decode_end,
-    mpeg_decode_frame,
-    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
-    .flush= ff_mpeg_flush,
-};
-
-//legacy decoder
-AVCodec mpegvideo_decoder = {
-    "mpegvideo",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MPEG2VIDEO,
-    sizeof(Mpeg1Context),
-    mpeg_decode_init,
-    NULL,
-    mpeg_decode_end,
-    mpeg_decode_frame,
-    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
-    .flush= ff_mpeg_flush,
-};
-
-#ifdef CONFIG_ENCODERS
-
-AVCodec mpeg1video_encoder = {
-    "mpeg1video",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MPEG1VIDEO,
-    sizeof(MpegEncContext),
-    encode_init,
-    MPV_encode_picture,
-    MPV_encode_end,
-    .supported_framerates= frame_rate_tab+1,
-    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-    .capabilities= CODEC_CAP_DELAY,
-};
-
-AVCodec mpeg2video_encoder = {
-    "mpeg2video",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MPEG2VIDEO,
-    sizeof(MpegEncContext),
-    encode_init,
-    MPV_encode_picture,
-    MPV_encode_end,
-    .supported_framerates= frame_rate_tab+1,
-    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-    .capabilities= CODEC_CAP_DELAY,
-};
-#endif
-
-#ifdef HAVE_XVMC
-static int mpeg_mc_decode_init(AVCodecContext *avctx){
-    Mpeg1Context *s;
-
-    if( avctx->thread_count > 1) 
-        return -1;
-    if( !(avctx->slice_flags & SLICE_FLAG_CODED_ORDER) )
-        return -1;
-    if( !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD) ){
-        dprintf("mpeg12.c: XvMC decoder will work better if SLICE_FLAG_ALLOW_FIELD is set\n");
-    }
-    mpeg_decode_init(avctx);
-    s = avctx->priv_data;
-
-    avctx->pix_fmt = PIX_FMT_XVMC_MPEG2_IDCT;
-    avctx->xvmc_acceleration = 2;//2 - the blocks are packed!
-
-    return 0;
-}
-
-AVCodec mpeg_xvmc_decoder = {
-    "mpegvideo_xvmc",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_MPEG2VIDEO_XVMC,
-    sizeof(Mpeg1Context),
-    mpeg_mc_decode_init,
-    NULL,
-    mpeg_decode_end,
-    mpeg_decode_frame,
-    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED| CODEC_CAP_HWACCEL | CODEC_CAP_DELAY,
-    .flush= ff_mpeg_flush,
-};
-
-#endif
-
-/* this is ugly i know, but the alternative is too make 
-   hundreds of vars global and prefix them with ff_mpeg1_
-   which is far uglier. */
-#include "mdec.c"  
diff --git a/ffmpeg.src/libavcodec/mpeg12data.h b/ffmpeg.src/libavcodec/mpeg12data.h
deleted file mode 100644
index d9c0900..0000000
--- a/ffmpeg.src/libavcodec/mpeg12data.h
+++ /dev/null
@@ -1,447 +0,0 @@
-/**
- * @file mpeg12data.h
- * MPEG1/2 tables.
- */
-
-const int16_t ff_mpeg1_default_intra_matrix[64] = {
-	8, 16, 19, 22, 26, 27, 29, 34,
-	16, 16, 22, 24, 27, 29, 34, 37,
-	19, 22, 26, 27, 29, 34, 34, 38,
-	22, 22, 26, 27, 29, 34, 37, 40,
-	22, 26, 27, 29, 32, 35, 40, 48,
-	26, 27, 29, 32, 35, 40, 48, 58,
-	26, 27, 29, 34, 38, 46, 56, 69,
-	27, 29, 35, 38, 46, 56, 69, 83
-};
-
-const int16_t ff_mpeg1_default_non_intra_matrix[64] = {
-    16, 16, 16, 16, 16, 16, 16, 16,
-    16, 16, 16, 16, 16, 16, 16, 16,
-    16, 16, 16, 16, 16, 16, 16, 16,
-    16, 16, 16, 16, 16, 16, 16, 16,
-    16, 16, 16, 16, 16, 16, 16, 16,
-    16, 16, 16, 16, 16, 16, 16, 16,
-    16, 16, 16, 16, 16, 16, 16, 16,
-    16, 16, 16, 16, 16, 16, 16, 16,
-};
-
-static const uint16_t vlc_dc_lum_code[12] = {
-    0x4, 0x0, 0x1, 0x5, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x1ff,
-};
-static const unsigned char vlc_dc_lum_bits[12] = {
-    3, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 9,
-};
-
-const uint16_t vlc_dc_chroma_code[12] = {
-    0x0, 0x1, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x3fe, 0x3ff,
-};
-const unsigned char vlc_dc_chroma_bits[12] = {
-    2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10,
-};
-
-static const uint16_t mpeg1_vlc[113][2] = {
- { 0x3, 2 }, { 0x4, 4 }, { 0x5, 5 }, { 0x6, 7 },
- { 0x26, 8 }, { 0x21, 8 }, { 0xa, 10 }, { 0x1d, 12 },
- { 0x18, 12 }, { 0x13, 12 }, { 0x10, 12 }, { 0x1a, 13 },
- { 0x19, 13 }, { 0x18, 13 }, { 0x17, 13 }, { 0x1f, 14 },
- { 0x1e, 14 }, { 0x1d, 14 }, { 0x1c, 14 }, { 0x1b, 14 },
- { 0x1a, 14 }, { 0x19, 14 }, { 0x18, 14 }, { 0x17, 14 },
- { 0x16, 14 }, { 0x15, 14 }, { 0x14, 14 }, { 0x13, 14 },
- { 0x12, 14 }, { 0x11, 14 }, { 0x10, 14 }, { 0x18, 15 },
- { 0x17, 15 }, { 0x16, 15 }, { 0x15, 15 }, { 0x14, 15 },
- { 0x13, 15 }, { 0x12, 15 }, { 0x11, 15 }, { 0x10, 15 },
- { 0x3, 3 }, { 0x6, 6 }, { 0x25, 8 }, { 0xc, 10 },
- { 0x1b, 12 }, { 0x16, 13 }, { 0x15, 13 }, { 0x1f, 15 },
- { 0x1e, 15 }, { 0x1d, 15 }, { 0x1c, 15 }, { 0x1b, 15 },
- { 0x1a, 15 }, { 0x19, 15 }, { 0x13, 16 }, { 0x12, 16 },
- { 0x11, 16 }, { 0x10, 16 }, { 0x5, 4 }, { 0x4, 7 },
- { 0xb, 10 }, { 0x14, 12 }, { 0x14, 13 }, { 0x7, 5 },
- { 0x24, 8 }, { 0x1c, 12 }, { 0x13, 13 }, { 0x6, 5 },
- { 0xf, 10 }, { 0x12, 12 }, { 0x7, 6 }, { 0x9, 10 },
- { 0x12, 13 }, { 0x5, 6 }, { 0x1e, 12 }, { 0x14, 16 },
- { 0x4, 6 }, { 0x15, 12 }, { 0x7, 7 }, { 0x11, 12 },
- { 0x5, 7 }, { 0x11, 13 }, { 0x27, 8 }, { 0x10, 13 },
- { 0x23, 8 }, { 0x1a, 16 }, { 0x22, 8 }, { 0x19, 16 },
- { 0x20, 8 }, { 0x18, 16 }, { 0xe, 10 }, { 0x17, 16 },
- { 0xd, 10 }, { 0x16, 16 }, { 0x8, 10 }, { 0x15, 16 },
- { 0x1f, 12 }, { 0x1a, 12 }, { 0x19, 12 }, { 0x17, 12 },
- { 0x16, 12 }, { 0x1f, 13 }, { 0x1e, 13 }, { 0x1d, 13 },
- { 0x1c, 13 }, { 0x1b, 13 }, { 0x1f, 16 }, { 0x1e, 16 },
- { 0x1d, 16 }, { 0x1c, 16 }, { 0x1b, 16 },
- { 0x1, 6 }, /* escape */
- { 0x2, 2 }, /* EOB */
-};
-
-static const uint16_t mpeg2_vlc[113][2] = {
-  {0x02, 2}, {0x06, 3}, {0x07, 4}, {0x1c, 5},
-  {0x1d, 5}, {0x05, 6}, {0x04, 6}, {0x7b, 7},
-  {0x7c, 7}, {0x23, 8}, {0x22, 8}, {0xfa, 8},
-  {0xfb, 8}, {0xfe, 8}, {0xff, 8}, {0x1f,14},
-  {0x1e,14}, {0x1d,14}, {0x1c,14}, {0x1b,14},
-  {0x1a,14}, {0x19,14}, {0x18,14}, {0x17,14},
-  {0x16,14}, {0x15,14}, {0x14,14}, {0x13,14},
-  {0x12,14}, {0x11,14}, {0x10,14}, {0x18,15},
-  {0x17,15}, {0x16,15}, {0x15,15}, {0x14,15},
-  {0x13,15}, {0x12,15}, {0x11,15}, {0x10,15},
-  {0x02, 3}, {0x06, 5}, {0x79, 7}, {0x27, 8},
-  {0x20, 8}, {0x16,13}, {0x15,13}, {0x1f,15},
-  {0x1e,15}, {0x1d,15}, {0x1c,15}, {0x1b,15},
-  {0x1a,15}, {0x19,15}, {0x13,16}, {0x12,16},
-  {0x11,16}, {0x10,16}, {0x05, 5}, {0x07, 7}, 
-  {0xfc, 8}, {0x0c,10}, {0x14,13}, {0x07, 5}, 
-  {0x26, 8}, {0x1c,12}, {0x13,13}, {0x06, 6}, 
-  {0xfd, 8}, {0x12,12}, {0x07, 6}, {0x04, 9}, 
-  {0x12,13}, {0x06, 7}, {0x1e,12}, {0x14,16}, 
-  {0x04, 7}, {0x15,12}, {0x05, 7}, {0x11,12}, 
-  {0x78, 7}, {0x11,13}, {0x7a, 7}, {0x10,13}, 
-  {0x21, 8}, {0x1a,16}, {0x25, 8}, {0x19,16}, 
-  {0x24, 8}, {0x18,16}, {0x05, 9}, {0x17,16}, 
-  {0x07, 9}, {0x16,16}, {0x0d,10}, {0x15,16}, 
-  {0x1f,12}, {0x1a,12}, {0x19,12}, {0x17,12}, 
-  {0x16,12}, {0x1f,13}, {0x1e,13}, {0x1d,13}, 
-  {0x1c,13}, {0x1b,13}, {0x1f,16}, {0x1e,16}, 
-  {0x1d,16}, {0x1c,16}, {0x1b,16}, 
-  {0x01,6}, /* escape */
-  {0x06,4}, /* EOB */
-};
-
-static const int8_t mpeg1_level[111] = {
-  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, 32,
- 33, 34, 35, 36, 37, 38, 39, 40,
-  1,  2,  3,  4,  5,  6,  7,  8,
-  9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18,  1,  2,  3,  4,  5,  1,
-  2,  3,  4,  1,  2,  3,  1,  2,
-  3,  1,  2,  3,  1,  2,  1,  2,
-  1,  2,  1,  2,  1,  2,  1,  2,
-  1,  2,  1,  2,  1,  2,  1,  2,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,
-};
-
-static const int8_t mpeg1_run[111] = {
-  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,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  2,  2,  2,  2,  2,  3,
-  3,  3,  3,  4,  4,  4,  5,  5,
-  5,  6,  6,  6,  7,  7,  8,  8,
-  9,  9, 10, 10, 11, 11, 12, 12,
- 13, 13, 14, 14, 15, 15, 16, 16,
- 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31,
-};
-
-static RLTable rl_mpeg1 = {
-    111,
-    111,
-    mpeg1_vlc,
-    mpeg1_run,
-    mpeg1_level,
-};
-
-static RLTable rl_mpeg2 = {
-    111,
-    111,
-    mpeg2_vlc,
-    mpeg1_run,
-    mpeg1_level,
-};
-
-static const uint8_t mbAddrIncrTable[36][2] = {
-    {0x1, 1},
-    {0x3, 3},
-    {0x2, 3},
-    {0x3, 4},
-    {0x2, 4},
-    {0x3, 5},
-    {0x2, 5},
-    {0x7, 7},
-    {0x6, 7},
-    {0xb, 8},
-    {0xa, 8},
-    {0x9, 8},
-    {0x8, 8},
-    {0x7, 8},
-    {0x6, 8},
-    {0x17, 10},
-    {0x16, 10},
-    {0x15, 10},
-    {0x14, 10},
-    {0x13, 10},
-    {0x12, 10},
-    {0x23, 11},
-    {0x22, 11},
-    {0x21, 11},
-    {0x20, 11},
-    {0x1f, 11},
-    {0x1e, 11},
-    {0x1d, 11},
-    {0x1c, 11},
-    {0x1b, 11},
-    {0x1a, 11},
-    {0x19, 11},
-    {0x18, 11},
-    {0x8, 11}, /* escape */
-    {0xf, 11}, /* stuffing */
-    {0x0, 8}, /* end (and 15 more 0 bits should follow) */
-};
-
-static const uint8_t mbPatTable[64][2] = {
-    {0x1, 9},
-    {0xb, 5},
-    {0x9, 5},
-    {0xd, 6},
-    {0xd, 4},
-    {0x17, 7},
-    {0x13, 7},
-    {0x1f, 8},
-    {0xc, 4},
-    {0x16, 7},
-    {0x12, 7},
-    {0x1e, 8},
-    {0x13, 5},
-    {0x1b, 8},
-    {0x17, 8},
-    {0x13, 8},
-    {0xb, 4},
-    {0x15, 7},
-    {0x11, 7},
-    {0x1d, 8},
-    {0x11, 5},
-    {0x19, 8},
-    {0x15, 8},
-    {0x11, 8},
-    {0xf, 6},
-    {0xf, 8},
-    {0xd, 8},
-    {0x3, 9},
-    {0xf, 5},
-    {0xb, 8},
-    {0x7, 8},
-    {0x7, 9},
-    {0xa, 4},
-    {0x14, 7},
-    {0x10, 7},
-    {0x1c, 8},
-    {0xe, 6},
-    {0xe, 8},
-    {0xc, 8},
-    {0x2, 9},
-    {0x10, 5},
-    {0x18, 8},
-    {0x14, 8},
-    {0x10, 8},
-    {0xe, 5},
-    {0xa, 8},
-    {0x6, 8},
-    {0x6, 9},
-    {0x12, 5},
-    {0x1a, 8},
-    {0x16, 8},
-    {0x12, 8},
-    {0xd, 5},
-    {0x9, 8},
-    {0x5, 8},
-    {0x5, 9},
-    {0xc, 5},
-    {0x8, 8},
-    {0x4, 8},
-    {0x4, 9},
-    {0x7, 3},
-    {0xa, 5},
-    {0x8, 5},
-    {0xc, 6}
-};
-
-#define MB_TYPE_ZERO_MV   0x20000000
-#define IS_ZERO_MV(a)   ((a)&MB_TYPE_ZERO_MV)
-
-static const uint8_t table_mb_ptype[7][2] = {
-    { 3, 5 }, // 0x01 MB_INTRA
-    { 1, 2 }, // 0x02 MB_PAT
-    { 1, 3 }, // 0x08 MB_FOR
-    { 1, 1 }, // 0x0A MB_FOR|MB_PAT
-    { 1, 6 }, // 0x11 MB_QUANT|MB_INTRA
-    { 1, 5 }, // 0x12 MB_QUANT|MB_PAT
-    { 2, 5 }, // 0x1A MB_QUANT|MB_FOR|MB_PAT
-};
-
-static const uint32_t ptype2mb_type[7] = {
-                    MB_TYPE_INTRA,
-                    MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
-                    MB_TYPE_L0,
-                    MB_TYPE_L0 | MB_TYPE_CBP,
-    MB_TYPE_QUANT | MB_TYPE_INTRA,
-    MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
-    MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP,
-};
-
-static const uint8_t table_mb_btype[11][2] = {
-    { 3, 5 }, // 0x01 MB_INTRA
-    { 2, 3 }, // 0x04 MB_BACK
-    { 3, 3 }, // 0x06 MB_BACK|MB_PAT
-    { 2, 4 }, // 0x08 MB_FOR
-    { 3, 4 }, // 0x0A MB_FOR|MB_PAT
-    { 2, 2 }, // 0x0C MB_FOR|MB_BACK
-    { 3, 2 }, // 0x0E MB_FOR|MB_BACK|MB_PAT
-    { 1, 6 }, // 0x11 MB_QUANT|MB_INTRA
-    { 2, 6 }, // 0x16 MB_QUANT|MB_BACK|MB_PAT
-    { 3, 6 }, // 0x1A MB_QUANT|MB_FOR|MB_PAT
-    { 2, 5 }, // 0x1E MB_QUANT|MB_FOR|MB_BACK|MB_PAT
-};
-
-static const uint32_t btype2mb_type[11] = {
-                    MB_TYPE_INTRA,
-                    MB_TYPE_L1,
-                    MB_TYPE_L1   | MB_TYPE_CBP,
-                    MB_TYPE_L0,
-                    MB_TYPE_L0   | MB_TYPE_CBP,
-                    MB_TYPE_L0L1,
-                    MB_TYPE_L0L1 | MB_TYPE_CBP,
-    MB_TYPE_QUANT | MB_TYPE_INTRA,
-    MB_TYPE_QUANT | MB_TYPE_L1   | MB_TYPE_CBP,
-    MB_TYPE_QUANT | MB_TYPE_L0   | MB_TYPE_CBP,
-    MB_TYPE_QUANT | MB_TYPE_L0L1 | MB_TYPE_CBP,
-};
-
-static const uint8_t mbMotionVectorTable[17][2] = {
-{ 0x1, 1 },
-{ 0x1, 2 },
-{ 0x1, 3 },
-{ 0x1, 4 },
-{ 0x3, 6 },
-{ 0x5, 7 },
-{ 0x4, 7 },
-{ 0x3, 7 },
-{ 0xb, 9 },
-{ 0xa, 9 },
-{ 0x9, 9 },
-{ 0x11, 10 },
-{ 0x10, 10 },
-{ 0xf, 10 },
-{ 0xe, 10 },
-{ 0xd, 10 },
-{ 0xc, 10 },
-};
-
-static const AVRational frame_rate_tab[] = {
-    {    0,    0},
-    {24000, 1001},
-    {   24,    1},
-    {   25,    1},
-    {30000, 1001},
-    {   30,    1},
-    {   50,    1},
-    {60000, 1001},
-    {   60,    1},
-  // Xing's 15fps: (9)
-    {   15,    1},
-  // libmpeg3's "Unofficial economy rates": (10-13)
-    {    5,    1},
-    {   10,    1},
-    {   12,    1},
-    {   15,    1},
-    {    0,    0},
-};
-
-static const uint8_t non_linear_qscale[32] = {
-    0, 1, 2, 3, 4, 5, 6, 7,
-    8,10,12,14,16,18,20,22,
-    24,28,32,36,40,44,48,52,
-    56,64,72,80,88,96,104,112,
-};
-
-const uint8_t ff_mpeg1_dc_scale_table[128]={
-//  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
-    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-};
-
-const static uint8_t mpeg2_dc_scale_table1[128]={
-//  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
-    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-};
-
-static const uint8_t mpeg2_dc_scale_table2[128]={ 
-//  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
-    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-
-static const uint8_t mpeg2_dc_scale_table3[128]={ 
-//  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
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    1, 1, 1, 1, 1, 1, 1, 1, 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 uint8_t *mpeg2_dc_scale_table[4]={
-    ff_mpeg1_dc_scale_table,
-    mpeg2_dc_scale_table1,
-    mpeg2_dc_scale_table2,
-    mpeg2_dc_scale_table3,    
-};
-
-static const float mpeg1_aspect[16]={
-    0.0000,
-    1.0000,
-    0.6735,
-    0.7031,
-    
-    0.7615,
-    0.8055,
-    0.8437,
-    0.8935,
-
-    0.9157,
-    0.9815,
-    1.0255,
-    1.0695,
-
-    1.0950,
-    1.1575,
-    1.2015,
-};
-
-static const AVRational mpeg2_aspect[16]={
-    {0,1},
-    {1,1},
-    {4,3},
-    {16,9},
-    {221,100},
-    {0,1},
-    {0,1},
-    {0,1},
-    {0,1},
-    {0,1},
-    {0,1},
-    {0,1},
-    {0,1},
-    {0,1},
-    {0,1},
-    {0,1},
-};
-
-static const uint8_t svcd_scan_offset_placeholder[14]={
-    0x10, 0x0E,
-    0x00, 0x80, 0x81,
-    0x00, 0x80, 0x81,
-    0xff, 0xff, 0xff,
-    0xff, 0xff, 0xff,
-};
diff --git a/ffmpeg.src/libavcodec/mpeg4data.h b/ffmpeg.src/libavcodec/mpeg4data.h
deleted file mode 100644
index 0ceef90..0000000
--- a/ffmpeg.src/libavcodec/mpeg4data.h
+++ /dev/null
@@ -1,401 +0,0 @@
-/**
- * @file mpeg4data.h
- * mpeg4 tables.
- */
-
-// shapes
-#define RECT_SHAPE       0
-#define BIN_SHAPE        1
-#define BIN_ONLY_SHAPE   2
-#define GRAY_SHAPE       3
-
-#define SIMPLE_VO_TYPE             1
-#define CORE_VO_TYPE               3
-#define MAIN_VO_TYPE               4
-#define NBIT_VO_TYPE               5
-#define ARTS_VO_TYPE               10
-#define ACE_VO_TYPE                12
-#define ADV_SIMPLE_VO_TYPE         17
-
-// aspect_ratio_info
-#define EXTENDED_PAR 15
-
-//vol_sprite_usage / sprite_enable
-#define STATIC_SPRITE 1
-#define GMC_SPRITE 2
-
-#define MOTION_MARKER 0x1F001
-#define DC_MARKER     0x6B001
-
-static const int mb_type_b_map[4]= {
-    MB_TYPE_DIRECT2 | MB_TYPE_L0L1,
-    MB_TYPE_L0L1 | MB_TYPE_16x16,
-    MB_TYPE_L1 | MB_TYPE_16x16,
-    MB_TYPE_L0 | MB_TYPE_16x16,
-};
-
-#define VOS_STARTCODE        0x1B0
-#define USER_DATA_STARTCODE  0x1B2
-#define GOP_STARTCODE        0x1B3
-#define VISUAL_OBJ_STARTCODE 0x1B5
-#define VOP_STARTCODE        0x1B6
-
-/* dc encoding for mpeg4 */
-const uint8_t DCtab_lum[13][2] =
-{
-    {3,3}, {3,2}, {2,2}, {2,3}, {1,3}, {1,4}, {1,5}, {1,6}, {1,7},
-    {1,8}, {1,9}, {1,10}, {1,11},
-}; 
-
-const uint8_t DCtab_chrom[13][2] =
-{
-    {3,2}, {2,2}, {1,2}, {1,3}, {1,4}, {1,5}, {1,6}, {1,7}, {1,8},
-    {1,9}, {1,10}, {1,11}, {1,12},
-}; 
-
-const uint16_t intra_vlc[103][2] = {
-{ 0x2, 2 },
-{ 0x6, 3 },{ 0xf, 4 },{ 0xd, 5 },{ 0xc, 5 },
-{ 0x15, 6 },{ 0x13, 6 },{ 0x12, 6 },{ 0x17, 7 },
-{ 0x1f, 8 },{ 0x1e, 8 },{ 0x1d, 8 },{ 0x25, 9 },
-{ 0x24, 9 },{ 0x23, 9 },{ 0x21, 9 },{ 0x21, 10 },
-{ 0x20, 10 },{ 0xf, 10 },{ 0xe, 10 },{ 0x7, 11 },
-{ 0x6, 11 },{ 0x20, 11 },{ 0x21, 11 },{ 0x50, 12 },
-{ 0x51, 12 },{ 0x52, 12 },{ 0xe, 4 },{ 0x14, 6 },
-{ 0x16, 7 },{ 0x1c, 8 },{ 0x20, 9 },{ 0x1f, 9 },
-{ 0xd, 10 },{ 0x22, 11 },{ 0x53, 12 },{ 0x55, 12 },
-{ 0xb, 5 },{ 0x15, 7 },{ 0x1e, 9 },{ 0xc, 10 },
-{ 0x56, 12 },{ 0x11, 6 },{ 0x1b, 8 },{ 0x1d, 9 },
-{ 0xb, 10 },{ 0x10, 6 },{ 0x22, 9 },{ 0xa, 10 },
-{ 0xd, 6 },{ 0x1c, 9 },{ 0x8, 10 },{ 0x12, 7 },
-{ 0x1b, 9 },{ 0x54, 12 },{ 0x14, 7 },{ 0x1a, 9 },
-{ 0x57, 12 },{ 0x19, 8 },{ 0x9, 10 },{ 0x18, 8 },
-{ 0x23, 11 },{ 0x17, 8 },{ 0x19, 9 },{ 0x18, 9 },
-{ 0x7, 10 },{ 0x58, 12 },{ 0x7, 4 },{ 0xc, 6 },
-{ 0x16, 8 },{ 0x17, 9 },{ 0x6, 10 },{ 0x5, 11 },
-{ 0x4, 11 },{ 0x59, 12 },{ 0xf, 6 },{ 0x16, 9 },
-{ 0x5, 10 },{ 0xe, 6 },{ 0x4, 10 },{ 0x11, 7 },
-{ 0x24, 11 },{ 0x10, 7 },{ 0x25, 11 },{ 0x13, 7 },
-{ 0x5a, 12 },{ 0x15, 8 },{ 0x5b, 12 },{ 0x14, 8 },
-{ 0x13, 8 },{ 0x1a, 8 },{ 0x15, 9 },{ 0x14, 9 },
-{ 0x13, 9 },{ 0x12, 9 },{ 0x11, 9 },{ 0x26, 11 },
-{ 0x27, 11 },{ 0x5c, 12 },{ 0x5d, 12 },{ 0x5e, 12 },
-{ 0x5f, 12 },{ 0x3, 7 },
-};
-
-const int8_t intra_level[102] = {
-  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,  1,  2,  3,  4,  5,
-  6,  7,  8,  9, 10,  1,  2,  3,
-  4,  5,  1,  2,  3,  4,  1,  2,
-  3,  1,  2,  3,  1,  2,  3,  1,
-  2,  3,  1,  2,  1,  2,  1,  1,
-  1,  1,  1,  1,  2,  3,  4,  5,
-  6,  7,  8,  1,  2,  3,  1,  2,
-  1,  2,  1,  2,  1,  2,  1,  2,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,
-};
-
-const int8_t intra_run[102] = {
-  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,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  2,  2,  2,
-  2,  2,  3,  3,  3,  3,  4,  4,
-  4,  5,  5,  5,  6,  6,  6,  7,
-  7,  7,  8,  8,  9,  9, 10, 11,
- 12, 13, 14,  0,  0,  0,  0,  0,
-  0,  0,  0,  1,  1,  1,  2,  2,
-  3,  3,  4,  4,  5,  5,  6,  6,
-  7,  8,  9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20,
-};
-
-static RLTable rl_intra = {
-    102,
-    67,
-    intra_vlc,
-    intra_run,
-    intra_level,
-};
-
-static const uint16_t inter_rvlc[170][2]={ //note this is identical to the intra rvlc except that its reordered
-{0x0006,  3},{0x0001,  4},{0x0004,  5},{0x001C,  7},
-{0x003C,  8},{0x003D,  8},{0x007C,  9},{0x00FC, 10},
-{0x00FD, 10},{0x01FC, 11},{0x01FD, 11},{0x03FC, 12},
-{0x07FC, 13},{0x07FD, 13},{0x0BFC, 13},{0x0BFD, 13},
-{0x0FFC, 14},{0x0FFD, 14},{0x1FFC, 15},{0x0007,  3},
-{0x000C,  6},{0x005C,  8},{0x007D,  9},{0x017C, 10},
-{0x02FC, 11},{0x03FD, 12},{0x0DFC, 13},{0x17FC, 14},
-{0x17FD, 14},{0x000A,  4},{0x001D,  7},{0x00BC,  9},
-{0x02FD, 11},{0x05FC, 12},{0x1BFC, 14},{0x1BFD, 14},
-{0x0005,  5},{0x005D,  8},{0x017D, 10},{0x05FD, 12},
-{0x0DFD, 13},{0x1DFC, 14},{0x1FFD, 15},{0x0008,  5},
-{0x006C,  8},{0x037C, 11},{0x0EFC, 13},{0x2FFC, 15},
-{0x0009,  5},{0x00BD,  9},{0x037D, 11},{0x0EFD, 13},
-{0x000D,  6},{0x01BC, 10},{0x06FC, 12},{0x1DFD, 14},
-{0x0014,  6},{0x01BD, 10},{0x06FD, 12},{0x2FFD, 15},
-{0x0015,  6},{0x01DC, 10},{0x0F7C, 13},{0x002C,  7},
-{0x01DD, 10},{0x1EFC, 14},{0x002D,  7},{0x03BC, 11},
-{0x0034,  7},{0x077C, 12},{0x006D,  8},{0x0F7D, 13},
-{0x0074,  8},{0x1EFD, 14},{0x0075,  8},{0x1F7C, 14},
-{0x00DC,  9},{0x1F7D, 14},{0x00DD,  9},{0x1FBC, 14},
-{0x00EC,  9},{0x37FC, 15},{0x01EC, 10},{0x01ED, 10},
-{0x01F4, 10},{0x03BD, 11},{0x03DC, 11},{0x03DD, 11},
-{0x03EC, 11},{0x03ED, 11},{0x03F4, 11},{0x077D, 12},
-{0x07BC, 12},{0x07BD, 12},{0x0FBC, 13},{0x0FBD, 13},
-{0x0FDC, 13},{0x0FDD, 13},{0x1FBD, 14},{0x1FDC, 14},
-{0x1FDD, 14},{0x37FD, 15},{0x3BFC, 15},
-{0x000B,  4},{0x0078,  8},{0x03F5, 11},{0x0FEC, 13},
-{0x1FEC, 14},{0x0012,  5},{0x00ED,  9},{0x07DC, 12},
-{0x1FED, 14},{0x3BFD, 15},{0x0013,  5},{0x03F8, 11},
-{0x3DFC, 15},{0x0018,  6},{0x07DD, 12},{0x0019,  6},
-{0x07EC, 12},{0x0022,  6},{0x0FED, 13},{0x0023,  6},
-{0x0FF4, 13},{0x0035,  7},{0x0FF5, 13},{0x0038,  7},
-{0x0FF8, 13},{0x0039,  7},{0x0FF9, 13},{0x0042,  7},
-{0x1FF4, 14},{0x0043,  7},{0x1FF5, 14},{0x0079,  8},
-{0x1FF8, 14},{0x0082,  8},{0x3DFD, 15},{0x0083,  8},
-{0x00F4,  9},{0x00F5,  9},{0x00F8,  9},{0x00F9,  9},
-{0x0102,  9},{0x0103,  9},{0x01F5, 10},{0x01F8, 10},
-{0x01F9, 10},{0x0202, 10},{0x0203, 10},{0x03F9, 11},
-{0x0402, 11},{0x0403, 11},{0x07ED, 12},{0x07F4, 12},
-{0x07F5, 12},{0x07F8, 12},{0x07F9, 12},{0x0802, 12},
-{0x0803, 12},{0x1002, 13},{0x1003, 13},{0x1FF9, 14},
-{0x2002, 14},{0x2003, 14},{0x3EFC, 15},{0x3EFD, 15},
-{0x3F7C, 15},{0x3F7D, 15},{0x0000, 4}
-};
-
-static const uint8_t inter_rvlc_run[169]={
- 0,  0,  0,  0,  0,  0,  0,  0, 
- 0,  0,  0,  0,  0,  0,  0,  0, 
- 0,  0,  0,  1,  1,  1,  1,  1, 
- 1,  1,  1,  1,  1,  2,  2,  2, 
- 2,  2,  2,  2,  3,  3,  3,  3, 
- 3,  3,  3,  4,  4,  4,  4,  4, 
- 5,  5,  5,  5,  6,  6,  6,  6, 
- 7,  7,  7,  7,  8,  8,  8,  9, 
- 9,  9, 10, 10, 11, 11, 12, 12, 
-13, 13, 14, 14, 15, 15, 16, 16, 
-17, 17, 18, 19, 20, 21, 22, 23, 
-24, 25, 26, 27, 28, 29, 30, 31, 
-32, 33, 34, 35, 36, 37, 38, 
- 0,  0,  0,  0,  0,  1,  1,  1, 
- 1,  1,  2,  2,  2,  3,  3,  4, 
- 4,  5,  5,  6,  6,  7,  7,  8, 
- 8,  9,  9, 10, 10, 11, 11, 12, 
-12, 13, 13, 14, 15, 16, 17, 18, 
-19, 20, 21, 22, 23, 24, 25, 26, 
-27, 28, 29, 30, 31, 32, 33, 34, 
-35, 36, 37, 38, 39, 40, 41, 42, 
-43, 44,  
-};
-
-static const uint8_t inter_rvlc_level[169]={
- 1,  2,  3,  4,  5,  6,  7,  8, 
- 9, 10, 11, 12, 13, 14, 15, 16, 
-17, 18, 19,  1,  2,  3,  4,  5, 
- 6,  7,  8,  9, 10,  1,  2,  3, 
- 4,  5,  6,  7,  1,  2,  3,  4, 
- 5,  6,  7,  1,  2,  3,  4,  5, 
- 1,  2,  3,  4,  1,  2,  3,  4, 
- 1,  2,  3,  4,  1,  2,  3,  1, 
- 2,  3,  1,  2,  1,  2,  1,  2, 
- 1,  2,  1,  2,  1,  2,  1,  2, 
- 1,  2,  1,  1,  1,  1,  1,  1, 
- 1,  1,  1,  1,  1,  1,  1,  1, 
- 1,  1,  1,  1,  1,  1,  1, 
- 1,  2,  3,  4,  5,  1,  2,  3, 
- 4,  5,  1,  2,  3,  1,  2,  1, 
- 2,  1,  2,  1,  2,  1,  2,  1, 
- 2,  1,  2,  1,  2,  1,  2,  1, 
- 2,  1,  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, 
-};
-
-static RLTable rvlc_rl_inter = {
-    169,
-    103,
-    inter_rvlc,
-    inter_rvlc_run,
-    inter_rvlc_level,
-};
-
-static const uint16_t intra_rvlc[170][2]={
-{0x0006,  3},{0x0007,  3},{0x000A,  4},{0x0009,  5},
-{0x0014,  6},{0x0015,  6},{0x0034,  7},{0x0074,  8},
-{0x0075,  8},{0x00DD,  9},{0x00EC,  9},{0x01EC, 10},
-{0x01ED, 10},{0x01F4, 10},{0x03EC, 11},{0x03ED, 11},
-{0x03F4, 11},{0x077D, 12},{0x07BC, 12},{0x0FBD, 13},
-{0x0FDC, 13},{0x07BD, 12},{0x0FDD, 13},{0x1FBD, 14},
-{0x1FDC, 14},{0x1FDD, 14},{0x1FFC, 15},{0x0001,  4},
-{0x0008,  5},{0x002D,  7},{0x006C,  8},{0x006D,  8},
-{0x00DC,  9},{0x01DD, 10},{0x03DC, 11},{0x03DD, 11},
-{0x077C, 12},{0x0FBC, 13},{0x1F7D, 14},{0x1FBC, 14},
-{0x0004,  5},{0x002C,  7},{0x00BC,  9},{0x01DC, 10},
-{0x03BC, 11},{0x03BD, 11},{0x0EFD, 13},{0x0F7C, 13},
-{0x0F7D, 13},{0x1EFD, 14},{0x1F7C, 14},{0x0005,  5},
-{0x005C,  8},{0x00BD,  9},{0x037D, 11},{0x06FC, 12},
-{0x0EFC, 13},{0x1DFD, 14},{0x1EFC, 14},{0x1FFD, 15},
-{0x000C,  6},{0x005D,  8},{0x01BD, 10},{0x03FD, 12},
-{0x06FD, 12},{0x1BFD, 14},{0x000D,  6},{0x007D,  9},
-{0x02FC, 11},{0x05FC, 12},{0x1BFC, 14},{0x1DFC, 14},
-{0x001C,  7},{0x017C, 10},{0x02FD, 11},{0x05FD, 12},
-{0x2FFC, 15},{0x001D,  7},{0x017D, 10},{0x037C, 11},
-{0x0DFD, 13},{0x2FFD, 15},{0x003C,  8},{0x01BC, 10},
-{0x0BFD, 13},{0x17FD, 14},{0x003D,  8},{0x01FD, 11},
-{0x0DFC, 13},{0x37FC, 15},{0x007C,  9},{0x03FC, 12},
-{0x00FC, 10},{0x0BFC, 13},{0x00FD, 10},{0x37FD, 15},
-{0x01FC, 11},{0x07FC, 13},{0x07FD, 13},{0x0FFC, 14},
-{0x0FFD, 14},{0x17FC, 14},{0x3BFC, 15},
-{0x000B,  4},{0x0078,  8},{0x03F5, 11},{0x0FEC, 13},
-{0x1FEC, 14},{0x0012,  5},{0x00ED,  9},{0x07DC, 12},
-{0x1FED, 14},{0x3BFD, 15},{0x0013,  5},{0x03F8, 11},
-{0x3DFC, 15},{0x0018,  6},{0x07DD, 12},{0x0019,  6},
-{0x07EC, 12},{0x0022,  6},{0x0FED, 13},{0x0023,  6},
-{0x0FF4, 13},{0x0035,  7},{0x0FF5, 13},{0x0038,  7},
-{0x0FF8, 13},{0x0039,  7},{0x0FF9, 13},{0x0042,  7},
-{0x1FF4, 14},{0x0043,  7},{0x1FF5, 14},{0x0079,  8},
-{0x1FF8, 14},{0x0082,  8},{0x3DFD, 15},{0x0083,  8},
-{0x00F4,  9},{0x00F5,  9},{0x00F8,  9},{0x00F9,  9},
-{0x0102,  9},{0x0103,  9},{0x01F5, 10},{0x01F8, 10},
-{0x01F9, 10},{0x0202, 10},{0x0203, 10},{0x03F9, 11},
-{0x0402, 11},{0x0403, 11},{0x07ED, 12},{0x07F4, 12},
-{0x07F5, 12},{0x07F8, 12},{0x07F9, 12},{0x0802, 12},
-{0x0803, 12},{0x1002, 13},{0x1003, 13},{0x1FF9, 14},
-{0x2002, 14},{0x2003, 14},{0x3EFC, 15},{0x3EFD, 15},
-{0x3F7C, 15},{0x3F7D, 15},{0x0000,  4}
-};
-
-static const uint8_t intra_rvlc_run[169]={
- 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,  1,  1,  1,  1, 
- 1,  1,  1,  1,  1,  1,  1,  1, 
- 2,  2,  2,  2,  2,  2,  2,  2, 
- 2,  2,  2,  3,  3,  3,  3,  3, 
- 3,  3,  3,  3,  4,  4,  4,  4, 
- 4,  4,  5,  5,  5,  5,  5,  5, 
- 6,  6,  6,  6,  6,  7,  7,  7, 
- 7,  7,  8,  8,  8,  8,  9,  9, 
- 9,  9, 10, 10, 11, 11, 12, 12, 
-13, 14, 15, 16, 17, 18, 19, 
- 0,  0,  0,  0,  0,  1,  1,  1, 
- 1,  1,  2,  2,  2,  3,  3,  4, 
- 4,  5,  5,  6,  6,  7,  7,  8, 
- 8,  9,  9, 10, 10, 11, 11, 12, 
-12, 13, 13, 14, 15, 16, 17, 18, 
-19, 20, 21, 22, 23, 24, 25, 26, 
-27, 28, 29, 30, 31, 32, 33, 34, 
-35, 36, 37, 38, 39, 40, 41, 42, 
-43, 44, 
-};
-
-static const uint8_t intra_rvlc_level[169]={
- 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,  1,  2,  3,  4,  5, 
- 6,  7,  8,  9, 10, 11, 12, 13, 
- 1,  2,  3,  4,  5,  6,  7,  8, 
- 9, 10, 11,  1,  2,  3,  4,  5, 
- 6,  7,  8,  9,  1,  2,  3,  4, 
- 5,  6,  1,  2,  3,  4,  5,  6, 
- 1,  2,  3,  4,  5,  1,  2,  3, 
- 4,  5,  1,  2,  3,  4,  1,  2, 
- 3,  4,  1,  2,  1,  2,  1,  2, 
- 1,  1,  1,  1,  1,  1,  1,  
- 1,  2,  3,  4,  5,  1,  2,  3, 
- 4,  5,  1,  2,  3,  1,  2,  1, 
- 2,  1,  2,  1,  2,  1,  2,  1, 
- 2,  1,  2,  1,  2,  1,  2,  1, 
- 2,  1,  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, 
-};
-
-static RLTable rvlc_rl_intra = {
-    169,
-    103,
-    intra_rvlc,
-    intra_rvlc_run,
-    intra_rvlc_level,
-};
-
-static const uint16_t sprite_trajectory_tab[15][2] = {
- {0x00, 2}, {0x02, 3},  {0x03, 3},  {0x04, 3}, {0x05, 3}, {0x06, 3},
- {0x0E, 4}, {0x1E, 5},  {0x3E, 6},  {0x7E, 7}, {0xFE, 8}, 
- {0x1FE, 9},{0x3FE, 10},{0x7FE, 11},{0xFFE, 12},
-};
-
-static const uint8_t mb_type_b_tab[4][2] = {
- {1, 1}, {1, 2}, {1, 3}, {1, 4},
-};
-
-static const AVRational pixel_aspect[16]={
- {0, 1},
- {1, 1},
- {12, 11},
- {10, 11},
- {16, 11},
- {40, 33},
- {0, 1},
- {0, 1},
- {0, 1},
- {0, 1},
- {0, 1},
- {0, 1},
- {0, 1},
- {0, 1},
- {0, 1},
- {0, 1},
-};
-
-/* these matrixes will be permuted for the idct */
-const int16_t ff_mpeg4_default_intra_matrix[64] = {
-  8, 17, 18, 19, 21, 23, 25, 27,
- 17, 18, 19, 21, 23, 25, 27, 28,
- 20, 21, 22, 23, 24, 26, 28, 30,
- 21, 22, 23, 24, 26, 28, 30, 32,
- 22, 23, 24, 26, 28, 30, 32, 35,
- 23, 24, 26, 28, 30, 32, 35, 38,
- 25, 26, 28, 30, 32, 35, 38, 41,
- 27, 28, 30, 32, 35, 38, 41, 45, 
-};
-
-const int16_t ff_mpeg4_default_non_intra_matrix[64] = {
- 16, 17, 18, 19, 20, 21, 22, 23,
- 17, 18, 19, 20, 21, 22, 23, 24,
- 18, 19, 20, 21, 22, 23, 24, 25,
- 19, 20, 21, 22, 23, 24, 26, 27,
- 20, 21, 22, 23, 25, 26, 27, 28,
- 21, 22, 23, 24, 26, 27, 28, 30,
- 22, 23, 24, 26, 27, 28, 30, 31,
- 23, 24, 25, 27, 28, 30, 31, 33,
-};
-
-const uint8_t ff_mpeg4_y_dc_scale_table[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, 8, 8, 8, 8,10,12,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,34,36,38,40,42,44,46
-};
-const uint8_t ff_mpeg4_c_dc_scale_table[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, 8, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,20,21,22,23,24,25
-};
-
-const uint16_t ff_mpeg4_resync_prefix[8]={
-    0x7F00, 0x7E00, 0x7C00, 0x7800, 0x7000, 0x6000, 0x4000, 0x0000
-};
-
-static const uint8_t mpeg4_dc_threshold[8]={
-    99, 13, 15, 17, 19, 21, 23, 0
-};
diff --git a/ffmpeg.src/libavcodec/mpegaudio.c b/ffmpeg.src/libavcodec/mpegaudio.c
deleted file mode 100644
index 190aa15..0000000
--- a/ffmpeg.src/libavcodec/mpegaudio.c
+++ /dev/null
@@ -1,801 +0,0 @@
-/*
- * The simplest mpeg audio layer 2 encoder
- * Copyright (c) 2000, 2001 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-/**
- * @file mpegaudio.c
- * The simplest mpeg audio layer 2 encoder.
- */
- 
-#include "avcodec.h"
-#include "bitstream.h"
-#include "mpegaudio.h"
-
-/* currently, cannot change these constants (need to modify
-   quantization stage) */
-#define FRAC_BITS 15
-#define WFRAC_BITS  14
-#define MUL(a,b) (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS)
-#define FIX(a)   ((int)((a) * (1 << FRAC_BITS)))
-
-#define SAMPLES_BUF_SIZE 4096
-
-typedef struct MpegAudioContext {
-    PutBitContext pb;
-    int nb_channels;
-    int freq, bit_rate;
-    int lsf;           /* 1 if mpeg2 low bitrate selected */
-    int bitrate_index; /* bit rate */
-    int freq_index;
-    int frame_size; /* frame size, in bits, without padding */
-    int64_t nb_samples; /* total number of samples encoded */
-    /* padding computation */
-    int frame_frac, frame_frac_incr, do_padding;
-    short samples_buf[MPA_MAX_CHANNELS][SAMPLES_BUF_SIZE]; /* buffer for filter */
-    int samples_offset[MPA_MAX_CHANNELS];       /* offset in samples_buf */
-    int sb_samples[MPA_MAX_CHANNELS][3][12][SBLIMIT];
-    unsigned char scale_factors[MPA_MAX_CHANNELS][SBLIMIT][3]; /* scale factors */
-    /* code to group 3 scale factors */
-    unsigned char scale_code[MPA_MAX_CHANNELS][SBLIMIT];       
-    int sblimit; /* number of used subbands */
-    const unsigned char *alloc_table;
-} MpegAudioContext;
-
-/* define it to use floats in quantization (I don't like floats !) */
-//#define USE_FLOATS
-
-#include "mpegaudiotab.h"
-
-static int MPA_encode_init(AVCodecContext *avctx)
-{
-    MpegAudioContext *s = avctx->priv_data;
-    int freq = avctx->sample_rate;
-    int bitrate = avctx->bit_rate;
-    int channels = avctx->channels;
-    int i, v, table;
-    float a;
-
-    if (channels > 2)
-        return -1;
-    bitrate = bitrate / 1000;
-    s->nb_channels = channels;
-    s->freq = freq;
-    s->bit_rate = bitrate * 1000;
-    avctx->frame_size = MPA_FRAME_SIZE;
-
-    /* encoding freq */
-    s->lsf = 0;
-    for(i=0;i<3;i++) {
-        if (mpa_freq_tab[i] == freq) 
-            break;
-        if ((mpa_freq_tab[i] / 2) == freq) {
-            s->lsf = 1;
-            break;
-        }
-    }
-    if (i == 3){
-        av_log(avctx, AV_LOG_ERROR, "Sampling rate %d is not allowed in mp2\n", freq);
-        return -1;
-    }
-    s->freq_index = i;
-
-    /* encoding bitrate & frequency */
-    for(i=0;i<15;i++) {
-        if (mpa_bitrate_tab[s->lsf][1][i] == bitrate) 
-            break;
-    }
-    if (i == 15){
-        av_log(avctx, AV_LOG_ERROR, "bitrate %d is not allowed in mp2\n", bitrate);
-        return -1;
-    }
-    s->bitrate_index = i;
-
-    /* compute total header size & pad bit */
-    
-    a = (float)(bitrate * 1000 * MPA_FRAME_SIZE) / (freq * 8.0);
-    s->frame_size = ((int)a) * 8;
-
-    /* frame fractional size to compute padding */
-    s->frame_frac = 0;
-    s->frame_frac_incr = (int)((a - floor(a)) * 65536.0);
-    
-    /* select the right allocation table */
-    table = l2_select_table(bitrate, s->nb_channels, freq, s->lsf);
-
-    /* number of used subbands */
-    s->sblimit = sblimit_table[table];
-    s->alloc_table = alloc_tables[table];
-
-#ifdef DEBUG
-    av_log(avctx, AV_LOG_DEBUG, "%d kb/s, %d Hz, frame_size=%d bits, table=%d, padincr=%x\n", 
-           bitrate, freq, s->frame_size, table, s->frame_frac_incr);
-#endif
-
-    for(i=0;i<s->nb_channels;i++)
-        s->samples_offset[i] = 0;
-
-    for(i=0;i<257;i++) {
-        int v;
-        v = mpa_enwindow[i];
-#if WFRAC_BITS != 16
-        v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);
-#endif
-        filter_bank[i] = v;
-        if ((i & 63) != 0)
-            v = -v;
-        if (i != 0)
-            filter_bank[512 - i] = v;
-    }
-
-    for(i=0;i<64;i++) {
-        v = (int)(pow(2.0, (3 - i) / 3.0) * (1 << 20));
-        if (v <= 0)
-            v = 1;
-        scale_factor_table[i] = v;
-#ifdef USE_FLOATS
-        scale_factor_inv_table[i] = pow(2.0, -(3 - i) / 3.0) / (float)(1 << 20);
-#else
-#define P 15
-        scale_factor_shift[i] = 21 - P - (i / 3);
-        scale_factor_mult[i] = (1 << P) * pow(2.0, (i % 3) / 3.0);
-#endif
-    }
-    for(i=0;i<128;i++) {
-        v = i - 64;
-        if (v <= -3)
-            v = 0;
-        else if (v < 0)
-            v = 1;
-        else if (v == 0)
-            v = 2;
-        else if (v < 3)
-            v = 3;
-        else 
-            v = 4;
-        scale_diff_table[i] = v;
-    }
-
-    for(i=0;i<17;i++) {
-        v = quant_bits[i];
-        if (v < 0) 
-            v = -v;
-        else
-            v = v * 3;
-        total_quant_bits[i] = 12 * v;
-    }
-
-    avctx->coded_frame= avcodec_alloc_frame();
-    avctx->coded_frame->key_frame= 1;
-
-    return 0;
-}
-
-/* 32 point floating point IDCT without 1/sqrt(2) coef zero scaling */
-static void idct32(int *out, int *tab)
-{
-    int i, j;
-    int *t, *t1, xr;
-    const int *xp = costab32;
-
-    for(j=31;j>=3;j-=2) tab[j] += tab[j - 2];
-    
-    t = tab + 30;
-    t1 = tab + 2;
-    do {
-        t[0] += t[-4];
-        t[1] += t[1 - 4];
-        t -= 4;
-    } while (t != t1);
-
-    t = tab + 28;
-    t1 = tab + 4;
-    do {
-        t[0] += t[-8];
-        t[1] += t[1-8];
-        t[2] += t[2-8];
-        t[3] += t[3-8];
-        t -= 8;
-    } while (t != t1);
-    
-    t = tab;
-    t1 = tab + 32;
-    do {
-        t[ 3] = -t[ 3];    
-        t[ 6] = -t[ 6];    
-        
-        t[11] = -t[11];    
-        t[12] = -t[12];    
-        t[13] = -t[13];    
-        t[15] = -t[15]; 
-        t += 16;
-    } while (t != t1);
-
-    
-    t = tab;
-    t1 = tab + 8;
-    do {
-        int x1, x2, x3, x4;
-        
-        x3 = MUL(t[16], FIX(SQRT2*0.5));
-        x4 = t[0] - x3;
-        x3 = t[0] + x3;
-        
-        x2 = MUL(-(t[24] + t[8]), FIX(SQRT2*0.5));
-        x1 = MUL((t[8] - x2), xp[0]);
-        x2 = MUL((t[8] + x2), xp[1]);
-
-        t[ 0] = x3 + x1;
-        t[ 8] = x4 - x2;
-        t[16] = x4 + x2;
-        t[24] = x3 - x1;
-        t++;
-    } while (t != t1);
-
-    xp += 2;
-    t = tab;
-    t1 = tab + 4;
-    do {
-        xr = MUL(t[28],xp[0]);
-        t[28] = (t[0] - xr);
-        t[0] = (t[0] + xr);
-
-        xr = MUL(t[4],xp[1]);
-        t[ 4] = (t[24] - xr);
-        t[24] = (t[24] + xr);
-        
-        xr = MUL(t[20],xp[2]);
-        t[20] = (t[8] - xr);
-        t[ 8] = (t[8] + xr);
-            
-        xr = MUL(t[12],xp[3]);
-        t[12] = (t[16] - xr);
-        t[16] = (t[16] + xr);
-        t++;
-    } while (t != t1);
-    xp += 4;
-
-    for (i = 0; i < 4; i++) {
-        xr = MUL(tab[30-i*4],xp[0]);
-        tab[30-i*4] = (tab[i*4] - xr);
-        tab[   i*4] = (tab[i*4] + xr);
-        
-        xr = MUL(tab[ 2+i*4],xp[1]);
-        tab[ 2+i*4] = (tab[28-i*4] - xr);
-        tab[28-i*4] = (tab[28-i*4] + xr);
-        
-        xr = MUL(tab[31-i*4],xp[0]);
-        tab[31-i*4] = (tab[1+i*4] - xr);
-        tab[ 1+i*4] = (tab[1+i*4] + xr);
-        
-        xr = MUL(tab[ 3+i*4],xp[1]);
-        tab[ 3+i*4] = (tab[29-i*4] - xr);
-        tab[29-i*4] = (tab[29-i*4] + xr);
-        
-        xp += 2;
-    }
-
-    t = tab + 30;
-    t1 = tab + 1;
-    do {
-        xr = MUL(t1[0], *xp);
-        t1[0] = (t[0] - xr);
-        t[0] = (t[0] + xr);
-        t -= 2;
-        t1 += 2;
-        xp++;
-    } while (t >= tab);
-
-    for(i=0;i<32;i++) {
-        out[i] = tab[bitinv32[i]];
-    }
-}
-
-#define WSHIFT (WFRAC_BITS + 15 - FRAC_BITS)
-
-static void filter(MpegAudioContext *s, int ch, short *samples, int incr)
-{
-    short *p, *q;
-    int sum, offset, i, j;
-    int tmp[64];
-    int tmp1[32];
-    int *out;
-
-    //    print_pow1(samples, 1152);
-
-    offset = s->samples_offset[ch];
-    out = &s->sb_samples[ch][0][0][0];
-    for(j=0;j<36;j++) {
-        /* 32 samples at once */
-        for(i=0;i<32;i++) {
-            s->samples_buf[ch][offset + (31 - i)] = samples[0];
-            samples += incr;
-        }
-
-        /* filter */
-        p = s->samples_buf[ch] + offset;
-        q = filter_bank;
-        /* maxsum = 23169 */
-        for(i=0;i<64;i++) {
-            sum = p[0*64] * q[0*64];
-            sum += p[1*64] * q[1*64];
-            sum += p[2*64] * q[2*64];
-            sum += p[3*64] * q[3*64];
-            sum += p[4*64] * q[4*64];
-            sum += p[5*64] * q[5*64];
-            sum += p[6*64] * q[6*64];
-            sum += p[7*64] * q[7*64];
-            tmp[i] = sum;
-            p++;
-            q++;
-        }
-        tmp1[0] = tmp[16] >> WSHIFT;
-        for( i=1; i<=16; i++ ) tmp1[i] = (tmp[i+16]+tmp[16-i]) >> WSHIFT;
-        for( i=17; i<=31; i++ ) tmp1[i] = (tmp[i+16]-tmp[80-i]) >> WSHIFT;
-
-        idct32(out, tmp1);
-
-        /* advance of 32 samples */
-        offset -= 32;
-        out += 32;
-        /* handle the wrap around */
-        if (offset < 0) {
-            memmove(s->samples_buf[ch] + SAMPLES_BUF_SIZE - (512 - 32), 
-                    s->samples_buf[ch], (512 - 32) * 2);
-            offset = SAMPLES_BUF_SIZE - 512;
-        }
-    }
-    s->samples_offset[ch] = offset;
-
-    //    print_pow(s->sb_samples, 1152);
-}
-
-static void compute_scale_factors(unsigned char scale_code[SBLIMIT],
-                                  unsigned char scale_factors[SBLIMIT][3], 
-                                  int sb_samples[3][12][SBLIMIT],
-                                  int sblimit)
-{
-    int *p, vmax, v, n, i, j, k, code;
-    int index, d1, d2;
-    unsigned char *sf = &scale_factors[0][0];
-    
-    for(j=0;j<sblimit;j++) {
-        for(i=0;i<3;i++) {
-            /* find the max absolute value */
-            p = &sb_samples[i][0][j];
-            vmax = abs(*p);
-            for(k=1;k<12;k++) {
-                p += SBLIMIT;
-                v = abs(*p);
-                if (v > vmax)
-                    vmax = v;
-            }
-            /* compute the scale factor index using log 2 computations */
-            if (vmax > 0) {
-                n = av_log2(vmax);
-                /* n is the position of the MSB of vmax. now 
-                   use at most 2 compares to find the index */
-                index = (21 - n) * 3 - 3;
-                if (index >= 0) {
-                    while (vmax <= scale_factor_table[index+1])
-                        index++;
-                } else {
-                    index = 0; /* very unlikely case of overflow */
-                }
-            } else {
-                index = 62; /* value 63 is not allowed */
-            }
-
-#if 0
-            printf("%2d:%d in=%x %x %d\n", 
-                   j, i, vmax, scale_factor_table[index], index);
-#endif
-            /* store the scale factor */
-            assert(index >=0 && index <= 63);
-            sf[i] = index;
-        }
-
-        /* compute the transmission factor : look if the scale factors
-           are close enough to each other */
-        d1 = scale_diff_table[sf[0] - sf[1] + 64];
-        d2 = scale_diff_table[sf[1] - sf[2] + 64];
-        
-        /* handle the 25 cases */
-        switch(d1 * 5 + d2) {
-        case 0*5+0:
-        case 0*5+4:
-        case 3*5+4:
-        case 4*5+0:
-        case 4*5+4:
-            code = 0;
-            break;
-        case 0*5+1:
-        case 0*5+2:
-        case 4*5+1:
-        case 4*5+2:
-            code = 3;
-            sf[2] = sf[1];
-            break;
-        case 0*5+3:
-        case 4*5+3:
-            code = 3;
-            sf[1] = sf[2];
-            break;
-        case 1*5+0:
-        case 1*5+4:
-        case 2*5+4:
-            code = 1;
-            sf[1] = sf[0];
-            break;
-        case 1*5+1:
-        case 1*5+2:
-        case 2*5+0:
-        case 2*5+1:
-        case 2*5+2:
-            code = 2;
-            sf[1] = sf[2] = sf[0];
-            break;
-        case 2*5+3:
-        case 3*5+3:
-            code = 2;
-            sf[0] = sf[1] = sf[2];
-            break;
-        case 3*5+0:
-        case 3*5+1:
-        case 3*5+2:
-            code = 2;
-            sf[0] = sf[2] = sf[1];
-            break;
-        case 1*5+3:
-            code = 2;
-            if (sf[0] > sf[2])
-              sf[0] = sf[2];
-            sf[1] = sf[2] = sf[0];
-            break;
-        default:
-            assert(0); //cant happen
-            code = 0;           /* kill warning */
-        }
-        
-#if 0
-        printf("%d: %2d %2d %2d %d %d -> %d\n", j, 
-               sf[0], sf[1], sf[2], d1, d2, code);
-#endif
-        scale_code[j] = code;
-        sf += 3;
-    }
-}
-
-/* The most important function : psycho acoustic module. In this
-   encoder there is basically none, so this is the worst you can do,
-   but also this is the simpler. */
-static void psycho_acoustic_model(MpegAudioContext *s, short smr[SBLIMIT])
-{
-    int i;
-
-    for(i=0;i<s->sblimit;i++) {
-        smr[i] = (int)(fixed_smr[i] * 10);
-    }
-}
-
-
-#define SB_NOTALLOCATED  0
-#define SB_ALLOCATED     1
-#define SB_NOMORE        2
-
-/* Try to maximize the smr while using a number of bits inferior to
-   the frame size. I tried to make the code simpler, faster and
-   smaller than other encoders :-) */
-static void compute_bit_allocation(MpegAudioContext *s, 
-                                   short smr1[MPA_MAX_CHANNELS][SBLIMIT],
-                                   unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT],
-                                   int *padding)
-{
-    int i, ch, b, max_smr, max_ch, max_sb, current_frame_size, max_frame_size;
-    int incr;
-    short smr[MPA_MAX_CHANNELS][SBLIMIT];
-    unsigned char subband_status[MPA_MAX_CHANNELS][SBLIMIT];
-    const unsigned char *alloc;
-
-    memcpy(smr, smr1, s->nb_channels * sizeof(short) * SBLIMIT);
-    memset(subband_status, SB_NOTALLOCATED, s->nb_channels * SBLIMIT);
-    memset(bit_alloc, 0, s->nb_channels * SBLIMIT);
-    
-    /* compute frame size and padding */
-    max_frame_size = s->frame_size;
-    s->frame_frac += s->frame_frac_incr;
-    if (s->frame_frac >= 65536) {
-        s->frame_frac -= 65536;
-        s->do_padding = 1;
-        max_frame_size += 8;
-    } else {
-        s->do_padding = 0;
-    }
-
-    /* compute the header + bit alloc size */
-    current_frame_size = 32;
-    alloc = s->alloc_table;
-    for(i=0;i<s->sblimit;i++) {
-        incr = alloc[0];
-        current_frame_size += incr * s->nb_channels;
-        alloc += 1 << incr;
-    }
-    for(;;) {
-        /* look for the subband with the largest signal to mask ratio */
-        max_sb = -1;
-        max_ch = -1;
-        max_smr = 0x80000000;
-        for(ch=0;ch<s->nb_channels;ch++) {
-            for(i=0;i<s->sblimit;i++) {
-                if (smr[ch][i] > max_smr && subband_status[ch][i] != SB_NOMORE) {
-                    max_smr = smr[ch][i];
-                    max_sb = i;
-                    max_ch = ch;
-                }
-            }
-        }
-#if 0
-        printf("current=%d max=%d max_sb=%d alloc=%d\n", 
-               current_frame_size, max_frame_size, max_sb,
-               bit_alloc[max_sb]);
-#endif        
-        if (max_sb < 0)
-            break;
-        
-        /* find alloc table entry (XXX: not optimal, should use
-           pointer table) */
-        alloc = s->alloc_table;
-        for(i=0;i<max_sb;i++) {
-            alloc += 1 << alloc[0];
-        }
-
-        if (subband_status[max_ch][max_sb] == SB_NOTALLOCATED) {
-            /* nothing was coded for this band: add the necessary bits */
-            incr = 2 + nb_scale_factors[s->scale_code[max_ch][max_sb]] * 6;
-            incr += total_quant_bits[alloc[1]];
-        } else {
-            /* increments bit allocation */
-            b = bit_alloc[max_ch][max_sb];
-            incr = total_quant_bits[alloc[b + 1]] - 
-                total_quant_bits[alloc[b]];
-        }
-
-        if (current_frame_size + incr <= max_frame_size) {
-            /* can increase size */
-            b = ++bit_alloc[max_ch][max_sb];
-            current_frame_size += incr;
-            /* decrease smr by the resolution we added */
-            smr[max_ch][max_sb] = smr1[max_ch][max_sb] - quant_snr[alloc[b]];
-            /* max allocation size reached ? */
-            if (b == ((1 << alloc[0]) - 1))
-                subband_status[max_ch][max_sb] = SB_NOMORE;
-            else
-                subband_status[max_ch][max_sb] = SB_ALLOCATED;
-        } else {
-            /* cannot increase the size of this subband */
-            subband_status[max_ch][max_sb] = SB_NOMORE;
-        }
-    }
-    *padding = max_frame_size - current_frame_size;
-    assert(*padding >= 0);
-
-#if 0
-    for(i=0;i<s->sblimit;i++) {
-        printf("%d ", bit_alloc[i]);
-    }
-    printf("\n");
-#endif
-}
-
-/*
- * Output the mpeg audio layer 2 frame. Note how the code is small
- * compared to other encoders :-)
- */
-static void encode_frame(MpegAudioContext *s,
-                         unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT],
-                         int padding)
-{
-    int i, j, k, l, bit_alloc_bits, b, ch;
-    unsigned char *sf;
-    int q[3];
-    PutBitContext *p = &s->pb;
-
-    /* header */
-
-    put_bits(p, 12, 0xfff);
-    put_bits(p, 1, 1 - s->lsf); /* 1 = mpeg1 ID, 0 = mpeg2 lsf ID */
-    put_bits(p, 2, 4-2);  /* layer 2 */
-    put_bits(p, 1, 1); /* no error protection */
-    put_bits(p, 4, s->bitrate_index);
-    put_bits(p, 2, s->freq_index);
-    put_bits(p, 1, s->do_padding); /* use padding */
-    put_bits(p, 1, 0);             /* private_bit */
-    put_bits(p, 2, s->nb_channels == 2 ? MPA_STEREO : MPA_MONO);
-    put_bits(p, 2, 0); /* mode_ext */
-    put_bits(p, 1, 0); /* no copyright */
-    put_bits(p, 1, 1); /* original */
-    put_bits(p, 2, 0); /* no emphasis */
-
-    /* bit allocation */
-    j = 0;
-    for(i=0;i<s->sblimit;i++) {
-        bit_alloc_bits = s->alloc_table[j];
-        for(ch=0;ch<s->nb_channels;ch++) {
-            put_bits(p, bit_alloc_bits, bit_alloc[ch][i]);
-        }
-        j += 1 << bit_alloc_bits;
-    }
-    
-    /* scale codes */
-    for(i=0;i<s->sblimit;i++) {
-        for(ch=0;ch<s->nb_channels;ch++) {
-            if (bit_alloc[ch][i]) 
-                put_bits(p, 2, s->scale_code[ch][i]);
-        }
-    }
-
-    /* scale factors */
-    for(i=0;i<s->sblimit;i++) {
-        for(ch=0;ch<s->nb_channels;ch++) {
-            if (bit_alloc[ch][i]) {
-                sf = &s->scale_factors[ch][i][0];
-                switch(s->scale_code[ch][i]) {
-                case 0:
-                    put_bits(p, 6, sf[0]);
-                    put_bits(p, 6, sf[1]);
-                    put_bits(p, 6, sf[2]);
-                    break;
-                case 3:
-                case 1:
-                    put_bits(p, 6, sf[0]);
-                    put_bits(p, 6, sf[2]);
-                    break;
-                case 2:
-                    put_bits(p, 6, sf[0]);
-                    break;
-                }
-            }
-        }
-    }
-    
-    /* quantization & write sub band samples */
-
-    for(k=0;k<3;k++) {
-        for(l=0;l<12;l+=3) {
-            j = 0;
-            for(i=0;i<s->sblimit;i++) {
-                bit_alloc_bits = s->alloc_table[j];
-                for(ch=0;ch<s->nb_channels;ch++) {
-                    b = bit_alloc[ch][i];
-                    if (b) {
-                        int qindex, steps, m, sample, bits;
-                        /* we encode 3 sub band samples of the same sub band at a time */
-                        qindex = s->alloc_table[j+b];
-                        steps = quant_steps[qindex];
-                        for(m=0;m<3;m++) {
-                            sample = s->sb_samples[ch][k][l + m][i];
-                            /* divide by scale factor */
-#ifdef USE_FLOATS
-                            {
-                                float a;
-                                a = (float)sample * scale_factor_inv_table[s->scale_factors[ch][i][k]];
-                                q[m] = (int)((a + 1.0) * steps * 0.5);
-                            }
-#else
-                            {
-                                int q1, e, shift, mult;
-                                e = s->scale_factors[ch][i][k];
-                                shift = scale_factor_shift[e];
-                                mult = scale_factor_mult[e];
-                                
-                                /* normalize to P bits */
-                                if (shift < 0)
-                                    q1 = sample << (-shift);
-                                else
-                                    q1 = sample >> shift;
-                                q1 = (q1 * mult) >> P;
-                                q[m] = ((q1 + (1 << P)) * steps) >> (P + 1);
-                            }
-#endif
-                            if (q[m] >= steps)
-                                q[m] = steps - 1;
-                            assert(q[m] >= 0 && q[m] < steps);
-                        }
-                        bits = quant_bits[qindex];
-                        if (bits < 0) {
-                            /* group the 3 values to save bits */
-                            put_bits(p, -bits, 
-                                     q[0] + steps * (q[1] + steps * q[2]));
-#if 0
-                            printf("%d: gr1 %d\n", 
-                                   i, q[0] + steps * (q[1] + steps * q[2]));
-#endif
-                        } else {
-#if 0
-                            printf("%d: gr3 %d %d %d\n", 
-                                   i, q[0], q[1], q[2]);
-#endif                               
-                            put_bits(p, bits, q[0]);
-                            put_bits(p, bits, q[1]);
-                            put_bits(p, bits, q[2]);
-                        }
-                    }
-                }
-                /* next subband in alloc table */
-                j += 1 << bit_alloc_bits; 
-            }
-        }
-    }
-
-    /* padding */
-    for(i=0;i<padding;i++)
-        put_bits(p, 1, 0);
-
-    /* flush */
-    flush_put_bits(p);
-}
-
-static int MPA_encode_frame(AVCodecContext *avctx,
-			    unsigned char *frame, int buf_size, void *data)
-{
-    MpegAudioContext *s = avctx->priv_data;
-    short *samples = data;
-    short smr[MPA_MAX_CHANNELS][SBLIMIT];
-    unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT];
-    int padding, i;
-
-    for(i=0;i<s->nb_channels;i++) {
-        filter(s, i, samples + i, s->nb_channels);
-    }
-
-    for(i=0;i<s->nb_channels;i++) {
-        compute_scale_factors(s->scale_code[i], s->scale_factors[i], 
-                              s->sb_samples[i], s->sblimit);
-    }
-    for(i=0;i<s->nb_channels;i++) {
-        psycho_acoustic_model(s, smr[i]);
-    }
-    compute_bit_allocation(s, smr, bit_alloc, &padding);
-
-    init_put_bits(&s->pb, frame, MPA_MAX_CODED_FRAME_SIZE);
-
-    encode_frame(s, bit_alloc, padding);
-    
-    s->nb_samples += MPA_FRAME_SIZE;
-    return pbBufPtr(&s->pb) - s->pb.buf;
-}
-
-static int MPA_encode_close(AVCodecContext *avctx)
-{
-    av_freep(&avctx->coded_frame);
-    return 0;
-}
-
-#ifdef CONFIG_MP2_ENCODER
-AVCodec mp2_encoder = {
-    "mp2",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_MP2,
-    sizeof(MpegAudioContext),
-    MPA_encode_init,
-    MPA_encode_frame,
-    MPA_encode_close,
-    NULL,
-};
-#endif // CONFIG_MP2_ENCODER
-
-#undef FIX
diff --git a/ffmpeg.src/libavcodec/mpegaudio.h b/ffmpeg.src/libavcodec/mpegaudio.h
deleted file mode 100644
index 072c41b..0000000
--- a/ffmpeg.src/libavcodec/mpegaudio.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * @file mpegaudio.h
- * mpeg audio declarations for both encoder and decoder.
- */
-
-/* max frame size, in samples */
-#define MPA_FRAME_SIZE 1152 
-
-/* max compressed frame size */
-#define MPA_MAX_CODED_FRAME_SIZE 1792
-
-#define MPA_MAX_CHANNELS 2
-
-#define SBLIMIT 32 /* number of subbands */
-
-#define MPA_STEREO  0
-#define MPA_JSTEREO 1
-#define MPA_DUAL    2
-#define MPA_MONO    3
-
-/* header + layer + bitrate + freq + lsf/mpeg25 */
-#define SAME_HEADER_MASK \
-   (0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19))
-
-int l2_select_table(int bitrate, int nb_channels, int freq, int lsf);
-int mpa_decode_header(AVCodecContext *avctx, uint32_t head);
-
-extern const uint16_t mpa_bitrate_tab[2][3][15];
-extern const uint16_t mpa_freq_tab[3];
-extern const unsigned char *alloc_tables[5];
-extern const double enwindow[512];
-extern const int sblimit_table[5];
-extern const int quant_steps[17];
-extern const int quant_bits[17];
-extern const int32_t mpa_enwindow[257];
-
-/* fast header check for resync */
-static inline int ff_mpa_check_header(uint32_t header){
-    /* header */
-    if ((header & 0xffe00000) != 0xffe00000)
-        return -1;
-    /* layer check */
-    if ((header & (3<<17)) == 0)
-        return -1;
-    /* bit rate */
-    if ((header & (0xf<<12)) == 0xf<<12)
-        return -1;
-    /* frequency */
-    if ((header & (3<<10)) == 3<<10)
-        return -1;
-    return 0;
-}
diff --git a/ffmpeg.src/libavcodec/mpegaudiodec.c b/ffmpeg.src/libavcodec/mpegaudiodec.c
deleted file mode 100644
index 708d355..0000000
--- a/ffmpeg.src/libavcodec/mpegaudiodec.c
+++ /dev/null
@@ -1,2911 +0,0 @@
-/*
- * MPEG Audio decoder
- * Copyright (c) 2001, 2002 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file mpegaudiodec.c
- * MPEG Audio decoder.
- */ 
-
-//#define DEBUG
-#include "avcodec.h"
-#include "bitstream.h"
-#include "mpegaudio.h"
-#include "dsputil.h"
-
-/*
- * TODO:
- *  - in low precision mode, use more 16 bit multiplies in synth filter
- *  - test lsf / mpeg25 extensively.
- */
-
-/* define USE_HIGHPRECISION to have a bit exact (but slower) mpeg
-   audio decoder */
-#ifdef CONFIG_MPEGAUDIO_HP
-#define USE_HIGHPRECISION
-#endif
-
-#ifdef USE_HIGHPRECISION
-#define FRAC_BITS   23   /* fractional bits for sb_samples and dct */
-#define WFRAC_BITS  16   /* fractional bits for window */
-#else
-#define FRAC_BITS   15   /* fractional bits for sb_samples and dct */
-#define WFRAC_BITS  14   /* fractional bits for window */
-#endif
-
-#if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT)
-typedef int32_t OUT_INT;
-#define OUT_MAX INT32_MAX
-#define OUT_MIN INT32_MIN
-#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 31)
-#else
-typedef int16_t OUT_INT;
-#define OUT_MAX INT16_MAX
-#define OUT_MIN INT16_MIN
-#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15)
-#endif
-
-#define FRAC_ONE    (1 << FRAC_BITS)
-
-#define MULL(a,b) (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS)
-#define MUL64(a,b) ((int64_t)(a) * (int64_t)(b))
-#define FIX(a)   ((int)((a) * FRAC_ONE))
-/* WARNING: only correct for posititive numbers */
-#define FIXR(a)   ((int)((a) * FRAC_ONE + 0.5))
-#define FRAC_RND(a) (((a) + (FRAC_ONE/2)) >> FRAC_BITS)
-
-#define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5))
-//#define MULH(a,b) (((int64_t)(a) * (int64_t)(b))>>32) //gcc 3.4 creates an incredibly bloated mess out of this
-static always_inline int MULH(int a, int b){
-    return ((int64_t)(a) * (int64_t)(b))>>32;
-}
-
-#if FRAC_BITS <= 15
-typedef int16_t MPA_INT;
-#else
-typedef int32_t MPA_INT;
-#endif
-
-/****************/
-
-#define HEADER_SIZE 4
-#define BACKSTEP_SIZE 512
-
-struct GranuleDef;
-
-typedef struct MPADecodeContext {
-    uint8_t inbuf1[2][MPA_MAX_CODED_FRAME_SIZE + BACKSTEP_SIZE];	/* input buffer */
-    int inbuf_index;
-    uint8_t *inbuf_ptr, *inbuf;
-    int frame_size;
-    int free_format_frame_size; /* frame size in case of free format
-                                   (zero if currently unknown) */
-    /* next header (used in free format parsing) */
-    uint32_t free_format_next_header; 
-    int error_protection;
-    int layer;
-    int sample_rate;
-    int sample_rate_index; /* between 0 and 8 */
-    int bit_rate;
-    int old_frame_size;
-    GetBitContext gb;
-    int nb_channels;
-    int mode;
-    int mode_ext;
-    int lsf;
-    MPA_INT synth_buf[MPA_MAX_CHANNELS][512 * 2] __attribute__((aligned(16)));
-    int synth_buf_offset[MPA_MAX_CHANNELS];
-    int32_t sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT] __attribute__((aligned(16)));
-    int32_t mdct_buf[MPA_MAX_CHANNELS][SBLIMIT * 18]; /* previous samples, for layer 3 MDCT */
-#ifdef DEBUG
-    int frame_count;
-#endif
-    void (*compute_antialias)(struct MPADecodeContext *s, struct GranuleDef *g);
-    int adu_mode; ///< 0 for standard mp3, 1 for adu formatted mp3
-    unsigned int dither_state;
-} MPADecodeContext;
-
-/**
- * Context for MP3On4 decoder
- */
-typedef struct MP3On4DecodeContext {
-    int frames;   ///< number of mp3 frames per block (number of mp3 decoder instances)
-    int chan_cfg; ///< channel config number
-    MPADecodeContext *mp3decctx[5]; ///< MPADecodeContext for every decoder instance
-} MP3On4DecodeContext;
-
-/* layer 3 "granule" */
-typedef struct GranuleDef {
-    uint8_t scfsi;
-    int part2_3_length;
-    int big_values;
-    int global_gain;
-    int scalefac_compress;
-    uint8_t block_type;
-    uint8_t switch_point;
-    int table_select[3];
-    int subblock_gain[3];
-    uint8_t scalefac_scale;
-    uint8_t count1table_select;
-    int region_size[3]; /* number of huffman codes in each region */
-    int preflag;
-    int short_start, long_end; /* long/short band indexes */
-    uint8_t scale_factors[40];
-    int32_t sb_hybrid[SBLIMIT * 18]; /* 576 samples */
-} GranuleDef;
-
-#define MODE_EXT_MS_STEREO 2
-#define MODE_EXT_I_STEREO  1
-
-/* layer 3 huffman tables */
-typedef struct HuffTable {
-    int xsize;
-    const uint8_t *bits;
-    const uint16_t *codes;
-} HuffTable;
-
-#include "mpegaudiodectab.h"
-
-static void compute_antialias_integer(MPADecodeContext *s, GranuleDef *g);
-static void compute_antialias_float(MPADecodeContext *s, GranuleDef *g);
-
-/* vlc structure for decoding layer 3 huffman tables */
-static VLC huff_vlc[16]; 
-static uint8_t *huff_code_table[16];
-static VLC huff_quad_vlc[2];
-/* computed from band_size_long */
-static uint16_t band_index_long[9][23];
-/* XXX: free when all decoders are closed */
-#define TABLE_4_3_SIZE (8191 + 16)*4
-static int8_t  *table_4_3_exp;
-static uint32_t *table_4_3_value;
-/* intensity stereo coef table */
-static int32_t is_table[2][16];
-static int32_t is_table_lsf[2][2][16];
-static int32_t csa_table[8][4];
-static float csa_table_float[8][4];
-static int32_t mdct_win[8][36];
-
-/* lower 2 bits: modulo 3, higher bits: shift */
-static uint16_t scale_factor_modshift[64];
-/* [i][j]:  2^(-j/3) * FRAC_ONE * 2^(i+2) / (2^(i+2) - 1) */
-static int32_t scale_factor_mult[15][3];
-/* mult table for layer 2 group quantization */
-
-#define SCALE_GEN(v) \
-{ FIXR(1.0 * (v)), FIXR(0.7937005259 * (v)), FIXR(0.6299605249 * (v)) }
-
-static const int32_t scale_factor_mult2[3][3] = {
-    SCALE_GEN(4.0 / 3.0), /* 3 steps */
-    SCALE_GEN(4.0 / 5.0), /* 5 steps */
-    SCALE_GEN(4.0 / 9.0), /* 9 steps */
-};
-
-void ff_mpa_synth_init(MPA_INT *window);
-static MPA_INT window[512] __attribute__((aligned(16)));
-    
-/* layer 1 unscaling */
-/* n = number of bits of the mantissa minus 1 */
-static inline int l1_unscale(int n, int mant, int scale_factor)
-{
-    int shift, mod;
-    int64_t val;
-
-    shift = scale_factor_modshift[scale_factor];
-    mod = shift & 3;
-    shift >>= 2;
-    val = MUL64(mant + (-1 << n) + 1, scale_factor_mult[n-1][mod]);
-    shift += n;
-    /* NOTE: at this point, 1 <= shift >= 21 + 15 */
-    return (int)((val + (1LL << (shift - 1))) >> shift);
-}
-
-static inline int l2_unscale_group(int steps, int mant, int scale_factor)
-{
-    int shift, mod, val;
-
-    shift = scale_factor_modshift[scale_factor];
-    mod = shift & 3;
-    shift >>= 2;
-
-    val = (mant - (steps >> 1)) * scale_factor_mult2[steps >> 2][mod];
-    /* NOTE: at this point, 0 <= shift <= 21 */
-    if (shift > 0)
-        val = (val + (1 << (shift - 1))) >> shift;
-    return val;
-}
-
-/* compute value^(4/3) * 2^(exponent/4). It normalized to FRAC_BITS */
-static inline int l3_unscale(int value, int exponent)
-{
-    unsigned int m;
-    int e;
-
-    e = table_4_3_exp  [4*value + (exponent&3)];
-    m = table_4_3_value[4*value + (exponent&3)];
-    e -= (exponent >> 2);
-    assert(e>=1);
-    if (e > 31)
-        return 0;
-    m = (m + (1 << (e-1))) >> e;
-
-    return m;
-}
-
-/* all integer n^(4/3) computation code */
-#define DEV_ORDER 13
-
-#define POW_FRAC_BITS 24
-#define POW_FRAC_ONE    (1 << POW_FRAC_BITS)
-#define POW_FIX(a)   ((int)((a) * POW_FRAC_ONE))
-#define POW_MULL(a,b) (((int64_t)(a) * (int64_t)(b)) >> POW_FRAC_BITS)
-
-static int dev_4_3_coefs[DEV_ORDER];
-
-#if 0 /* unused */
-static int pow_mult3[3] = {
-    POW_FIX(1.0),
-    POW_FIX(1.25992104989487316476),
-    POW_FIX(1.58740105196819947474),
-};
-#endif
-
-static void int_pow_init(void)
-{
-    int i, a;
-
-    a = POW_FIX(1.0);
-    for(i=0;i<DEV_ORDER;i++) {
-        a = POW_MULL(a, POW_FIX(4.0 / 3.0) - i * POW_FIX(1.0)) / (i + 1);
-        dev_4_3_coefs[i] = a;
-    }
-}
-
-#if 0 /* unused, remove? */
-/* return the mantissa and the binary exponent */
-static int int_pow(int i, int *exp_ptr)
-{
-    int e, er, eq, j;
-    int a, a1;
-    
-    /* renormalize */
-    a = i;
-    e = POW_FRAC_BITS;
-    while (a < (1 << (POW_FRAC_BITS - 1))) {
-        a = a << 1;
-        e--;
-    }
-    a -= (1 << POW_FRAC_BITS);
-    a1 = 0;
-    for(j = DEV_ORDER - 1; j >= 0; j--)
-        a1 = POW_MULL(a, dev_4_3_coefs[j] + a1);
-    a = (1 << POW_FRAC_BITS) + a1;
-    /* exponent compute (exact) */
-    e = e * 4;
-    er = e % 3;
-    eq = e / 3;
-    a = POW_MULL(a, pow_mult3[er]);
-    while (a >= 2 * POW_FRAC_ONE) {
-        a = a >> 1;
-        eq++;
-    }
-    /* convert to float */
-    while (a < POW_FRAC_ONE) {
-        a = a << 1;
-        eq--;
-    }
-    /* now POW_FRAC_ONE <= a < 2 * POW_FRAC_ONE */
-#if POW_FRAC_BITS > FRAC_BITS
-    a = (a + (1 << (POW_FRAC_BITS - FRAC_BITS - 1))) >> (POW_FRAC_BITS - FRAC_BITS);
-    /* correct overflow */
-    if (a >= 2 * (1 << FRAC_BITS)) {
-        a = a >> 1;
-        eq++;
-    }
-#endif
-    *exp_ptr = eq;
-    return a;
-}
-#endif
-
-static int decode_init(AVCodecContext * avctx)
-{
-    MPADecodeContext *s = avctx->priv_data;
-    static int init=0;
-    int i, j, k;
-
-#if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT)
-    avctx->sample_fmt= SAMPLE_FMT_S32;
-#else
-    avctx->sample_fmt= SAMPLE_FMT_S16;
-#endif    
-    
-    if(avctx->antialias_algo != FF_AA_FLOAT)
-        s->compute_antialias= compute_antialias_integer;
-    else
-        s->compute_antialias= compute_antialias_float;
-
-    if (!init && !avctx->parse_only) {
-        /* scale factors table for layer 1/2 */
-        for(i=0;i<64;i++) {
-            int shift, mod;
-            /* 1.0 (i = 3) is normalized to 2 ^ FRAC_BITS */
-            shift = (i / 3);
-            mod = i % 3;
-            scale_factor_modshift[i] = mod | (shift << 2);
-        }
-
-        /* scale factor multiply for layer 1 */
-        for(i=0;i<15;i++) {
-            int n, norm;
-            n = i + 2;
-            norm = ((int64_t_C(1) << n) * FRAC_ONE) / ((1 << n) - 1);
-            scale_factor_mult[i][0] = MULL(FIXR(1.0 * 2.0), norm);
-            scale_factor_mult[i][1] = MULL(FIXR(0.7937005259 * 2.0), norm);
-            scale_factor_mult[i][2] = MULL(FIXR(0.6299605249 * 2.0), norm);
-            dprintf("%d: norm=%x s=%x %x %x\n",
-                    i, norm, 
-                    scale_factor_mult[i][0],
-                    scale_factor_mult[i][1],
-                    scale_factor_mult[i][2]);
-        }
-        
-	ff_mpa_synth_init(window);
-        
-        /* huffman decode tables */
-        huff_code_table[0] = NULL;
-        for(i=1;i<16;i++) {
-            const HuffTable *h = &mpa_huff_tables[i];
-	    int xsize, x, y;
-            unsigned int n;
-            uint8_t *code_table;
-
-            xsize = h->xsize;
-            n = xsize * xsize;
-            /* XXX: fail test */
-            init_vlc(&huff_vlc[i], 8, n, 
-                     h->bits, 1, 1, h->codes, 2, 2, 1);
-            
-            code_table = av_mallocz(n);
-            j = 0;
-            for(x=0;x<xsize;x++) {
-                for(y=0;y<xsize;y++)
-                    code_table[j++] = (x << 4) | y;
-            }
-            huff_code_table[i] = code_table;
-        }
-        for(i=0;i<2;i++) {
-            init_vlc(&huff_quad_vlc[i], i == 0 ? 7 : 4, 16, 
-                     mpa_quad_bits[i], 1, 1, mpa_quad_codes[i], 1, 1, 1);
-        }
-
-        for(i=0;i<9;i++) {
-            k = 0;
-            for(j=0;j<22;j++) {
-                band_index_long[i][j] = k;
-                k += band_size_long[i][j];
-            }
-            band_index_long[i][22] = k;
-        }
-
-	/* compute n ^ (4/3) and store it in mantissa/exp format */
-	table_4_3_exp= av_mallocz_static(TABLE_4_3_SIZE * sizeof(table_4_3_exp[0]));
-        if(!table_4_3_exp)
-	    return -1;
-	table_4_3_value= av_mallocz_static(TABLE_4_3_SIZE * sizeof(table_4_3_value[0]));
-        if(!table_4_3_value)
-            return -1;
-        
-        int_pow_init();
-        for(i=1;i<TABLE_4_3_SIZE;i++) {
-            double f, fm;
-            int e, m;
-            f = pow((double)(i/4), 4.0 / 3.0) * pow(2, (i&3)*0.25);
-            fm = frexp(f, &e);
-            m = (uint32_t)(fm*(1LL<<31) + 0.5);
-            e+= FRAC_BITS - 31 + 5;
-
-            /* normalized to FRAC_BITS */
-            table_4_3_value[i] = m;
-//            av_log(NULL, AV_LOG_DEBUG, "%d %d %f\n", i, m, pow((double)i, 4.0 / 3.0));
-            table_4_3_exp[i] = -e;
-        }
-        
-        for(i=0;i<7;i++) {
-            float f;
-            int v;
-            if (i != 6) {
-                f = tan((double)i * M_PI / 12.0);
-                v = FIXR(f / (1.0 + f));
-            } else {
-                v = FIXR(1.0);
-            }
-            is_table[0][i] = v;
-            is_table[1][6 - i] = v;
-        }
-        /* invalid values */
-        for(i=7;i<16;i++)
-            is_table[0][i] = is_table[1][i] = 0.0;
-
-        for(i=0;i<16;i++) {
-            double f;
-            int e, k;
-
-            for(j=0;j<2;j++) {
-                e = -(j + 1) * ((i + 1) >> 1);
-                f = pow(2.0, e / 4.0);
-                k = i & 1;
-                is_table_lsf[j][k ^ 1][i] = FIXR(f);
-                is_table_lsf[j][k][i] = FIXR(1.0);
-                dprintf("is_table_lsf %d %d: %x %x\n", 
-                        i, j, is_table_lsf[j][0][i], is_table_lsf[j][1][i]);
-            }
-        }
-
-        for(i=0;i<8;i++) {
-            float ci, cs, ca;
-            ci = ci_table[i];
-            cs = 1.0 / sqrt(1.0 + ci * ci);
-            ca = cs * ci;
-            csa_table[i][0] = FIXHR(cs/4);
-            csa_table[i][1] = FIXHR(ca/4);
-            csa_table[i][2] = FIXHR(ca/4) + FIXHR(cs/4);
-            csa_table[i][3] = FIXHR(ca/4) - FIXHR(cs/4); 
-            csa_table_float[i][0] = cs;
-            csa_table_float[i][1] = ca;
-            csa_table_float[i][2] = ca + cs;
-            csa_table_float[i][3] = ca - cs; 
-//            printf("%d %d %d %d\n", FIX(cs), FIX(cs-1), FIX(ca), FIX(cs)-FIX(ca));
-//            av_log(NULL, AV_LOG_DEBUG,"%f %f %f %f\n", cs, ca, ca+cs, ca-cs);
-        }
-
-        /* compute mdct windows */
-        for(i=0;i<36;i++) {
-            for(j=0; j<4; j++){
-                double d;
-                
-                if(j==2 && i%3 != 1)
-                    continue;
-                
-                d= sin(M_PI * (i + 0.5) / 36.0);
-                if(j==1){
-                    if     (i>=30) d= 0;
-                    else if(i>=24) d= sin(M_PI * (i - 18 + 0.5) / 12.0);
-                    else if(i>=18) d= 1;
-                }else if(j==3){
-                    if     (i<  6) d= 0;
-                    else if(i< 12) d= sin(M_PI * (i -  6 + 0.5) / 12.0);
-                    else if(i< 18) d= 1;
-                }
-                //merge last stage of imdct into the window coefficients
-                d*= 0.5 / cos(M_PI*(2*i + 19)/72);
-
-                if(j==2)
-                    mdct_win[j][i/3] = FIXHR((d / (1<<5)));
-                else
-                    mdct_win[j][i  ] = FIXHR((d / (1<<5)));
-//                av_log(NULL, AV_LOG_DEBUG, "%2d %d %f\n", i,j,d / (1<<5));
-            }
-        }
-
-        /* NOTE: we do frequency inversion adter the MDCT by changing
-           the sign of the right window coefs */
-        for(j=0;j<4;j++) {
-            for(i=0;i<36;i+=2) {
-                mdct_win[j + 4][i] = mdct_win[j][i];
-                mdct_win[j + 4][i + 1] = -mdct_win[j][i + 1];
-            }
-        }
-
-#if defined(DEBUG)
-        for(j=0;j<8;j++) {
-            printf("win%d=\n", j);
-            for(i=0;i<36;i++)
-                printf("%f, ", (double)mdct_win[j][i] / FRAC_ONE);
-            printf("\n");
-        }
-#endif
-        init = 1;
-    }
-
-    s->inbuf_index = 0;
-    s->inbuf = &s->inbuf1[s->inbuf_index][BACKSTEP_SIZE];
-    s->inbuf_ptr = s->inbuf;
-#ifdef DEBUG
-    s->frame_count = 0;
-#endif
-    if (avctx->codec_id == CODEC_ID_MP3ADU)
-        s->adu_mode = 1;
-    return 0;
-}
-
-/* tab[i][j] = 1.0 / (2.0 * cos(pi*(2*k+1) / 2^(6 - j))) */
-
-/* cos(i*pi/64) */
-
-#define COS0_0  FIXR(0.50060299823519630134)
-#define COS0_1  FIXR(0.50547095989754365998)
-#define COS0_2  FIXR(0.51544730992262454697)
-#define COS0_3  FIXR(0.53104259108978417447)
-#define COS0_4  FIXR(0.55310389603444452782)
-#define COS0_5  FIXR(0.58293496820613387367)
-#define COS0_6  FIXR(0.62250412303566481615)
-#define COS0_7  FIXR(0.67480834145500574602)
-#define COS0_8  FIXR(0.74453627100229844977)
-#define COS0_9  FIXR(0.83934964541552703873)
-#define COS0_10 FIXR(0.97256823786196069369)
-#define COS0_11 FIXR(1.16943993343288495515)
-#define COS0_12 FIXR(1.48416461631416627724)
-#define COS0_13 FIXR(2.05778100995341155085)
-#define COS0_14 FIXR(3.40760841846871878570)
-#define COS0_15 FIXR(10.19000812354805681150)
-
-#define COS1_0 FIXR(0.50241928618815570551)
-#define COS1_1 FIXR(0.52249861493968888062)
-#define COS1_2 FIXR(0.56694403481635770368)
-#define COS1_3 FIXR(0.64682178335999012954)
-#define COS1_4 FIXR(0.78815462345125022473)
-#define COS1_5 FIXR(1.06067768599034747134)
-#define COS1_6 FIXR(1.72244709823833392782)
-#define COS1_7 FIXR(5.10114861868916385802)
-
-#define COS2_0 FIXR(0.50979557910415916894)
-#define COS2_1 FIXR(0.60134488693504528054)
-#define COS2_2 FIXR(0.89997622313641570463)
-#define COS2_3 FIXR(2.56291544774150617881)
-
-#define COS3_0 FIXR(0.54119610014619698439)
-#define COS3_1 FIXR(1.30656296487637652785)
-
-#define COS4_0 FIXR(0.70710678118654752439)
-
-/* butterfly operator */
-#define BF(a, b, c)\
-{\
-    tmp0 = tab[a] + tab[b];\
-    tmp1 = tab[a] - tab[b];\
-    tab[a] = tmp0;\
-    tab[b] = MULL(tmp1, c);\
-}
-
-#define BF1(a, b, c, d)\
-{\
-    BF(a, b, COS4_0);\
-    BF(c, d, -COS4_0);\
-    tab[c] += tab[d];\
-}
-
-#define BF2(a, b, c, d)\
-{\
-    BF(a, b, COS4_0);\
-    BF(c, d, -COS4_0);\
-    tab[c] += tab[d];\
-    tab[a] += tab[c];\
-    tab[c] += tab[b];\
-    tab[b] += tab[d];\
-}
-
-#define ADD(a, b) tab[a] += tab[b]
-
-/* DCT32 without 1/sqrt(2) coef zero scaling. */
-static void dct32(int32_t *out, int32_t *tab)
-{
-    int tmp0, tmp1;
-
-    /* pass 1 */
-    BF(0, 31, COS0_0);
-    BF(1, 30, COS0_1);
-    BF(2, 29, COS0_2);
-    BF(3, 28, COS0_3);
-    BF(4, 27, COS0_4);
-    BF(5, 26, COS0_5);
-    BF(6, 25, COS0_6);
-    BF(7, 24, COS0_7);
-    BF(8, 23, COS0_8);
-    BF(9, 22, COS0_9);
-    BF(10, 21, COS0_10);
-    BF(11, 20, COS0_11);
-    BF(12, 19, COS0_12);
-    BF(13, 18, COS0_13);
-    BF(14, 17, COS0_14);
-    BF(15, 16, COS0_15);
-
-    /* pass 2 */
-    BF(0, 15, COS1_0);
-    BF(1, 14, COS1_1);
-    BF(2, 13, COS1_2);
-    BF(3, 12, COS1_3);
-    BF(4, 11, COS1_4);
-    BF(5, 10, COS1_5);
-    BF(6,  9, COS1_6);
-    BF(7,  8, COS1_7);
-    
-    BF(16, 31, -COS1_0);
-    BF(17, 30, -COS1_1);
-    BF(18, 29, -COS1_2);
-    BF(19, 28, -COS1_3);
-    BF(20, 27, -COS1_4);
-    BF(21, 26, -COS1_5);
-    BF(22, 25, -COS1_6);
-    BF(23, 24, -COS1_7);
-    
-    /* pass 3 */
-    BF(0, 7, COS2_0);
-    BF(1, 6, COS2_1);
-    BF(2, 5, COS2_2);
-    BF(3, 4, COS2_3);
-    
-    BF(8, 15, -COS2_0);
-    BF(9, 14, -COS2_1);
-    BF(10, 13, -COS2_2);
-    BF(11, 12, -COS2_3);
-    
-    BF(16, 23, COS2_0);
-    BF(17, 22, COS2_1);
-    BF(18, 21, COS2_2);
-    BF(19, 20, COS2_3);
-    
-    BF(24, 31, -COS2_0);
-    BF(25, 30, -COS2_1);
-    BF(26, 29, -COS2_2);
-    BF(27, 28, -COS2_3);
-
-    /* pass 4 */
-    BF(0, 3, COS3_0);
-    BF(1, 2, COS3_1);
-    
-    BF(4, 7, -COS3_0);
-    BF(5, 6, -COS3_1);
-    
-    BF(8, 11, COS3_0);
-    BF(9, 10, COS3_1);
-    
-    BF(12, 15, -COS3_0);
-    BF(13, 14, -COS3_1);
-    
-    BF(16, 19, COS3_0);
-    BF(17, 18, COS3_1);
-    
-    BF(20, 23, -COS3_0);
-    BF(21, 22, -COS3_1);
-    
-    BF(24, 27, COS3_0);
-    BF(25, 26, COS3_1);
-    
-    BF(28, 31, -COS3_0);
-    BF(29, 30, -COS3_1);
-    
-    /* pass 5 */
-    BF1(0, 1, 2, 3);
-    BF2(4, 5, 6, 7);
-    BF1(8, 9, 10, 11);
-    BF2(12, 13, 14, 15);
-    BF1(16, 17, 18, 19);
-    BF2(20, 21, 22, 23);
-    BF1(24, 25, 26, 27);
-    BF2(28, 29, 30, 31);
-    
-    /* pass 6 */
-    
-    ADD( 8, 12);
-    ADD(12, 10);
-    ADD(10, 14);
-    ADD(14,  9);
-    ADD( 9, 13);
-    ADD(13, 11);
-    ADD(11, 15);
-
-    out[ 0] = tab[0];
-    out[16] = tab[1];
-    out[ 8] = tab[2];
-    out[24] = tab[3];
-    out[ 4] = tab[4];
-    out[20] = tab[5];
-    out[12] = tab[6];
-    out[28] = tab[7];
-    out[ 2] = tab[8];
-    out[18] = tab[9];
-    out[10] = tab[10];
-    out[26] = tab[11];
-    out[ 6] = tab[12];
-    out[22] = tab[13];
-    out[14] = tab[14];
-    out[30] = tab[15];
-    
-    ADD(24, 28);
-    ADD(28, 26);
-    ADD(26, 30);
-    ADD(30, 25);
-    ADD(25, 29);
-    ADD(29, 27);
-    ADD(27, 31);
-
-    out[ 1] = tab[16] + tab[24];
-    out[17] = tab[17] + tab[25];
-    out[ 9] = tab[18] + tab[26];
-    out[25] = tab[19] + tab[27];
-    out[ 5] = tab[20] + tab[28];
-    out[21] = tab[21] + tab[29];
-    out[13] = tab[22] + tab[30];
-    out[29] = tab[23] + tab[31];
-    out[ 3] = tab[24] + tab[20];
-    out[19] = tab[25] + tab[21];
-    out[11] = tab[26] + tab[22];
-    out[27] = tab[27] + tab[23];
-    out[ 7] = tab[28] + tab[18];
-    out[23] = tab[29] + tab[19];
-    out[15] = tab[30] + tab[17];
-    out[31] = tab[31];
-}
-
-#if FRAC_BITS <= 15
-
-static inline int round_sample(int *sum)
-{
-    int sum1;
-    sum1 = (*sum) >> OUT_SHIFT;
-    *sum &= (1<<OUT_SHIFT)-1;
-    if (sum1 < OUT_MIN)
-        sum1 = OUT_MIN;
-    else if (sum1 > OUT_MAX)
-        sum1 = OUT_MAX;
-    return sum1;
-}
-
-#if defined(ARCH_POWERPC_405)
-
-/* signed 16x16 -> 32 multiply add accumulate */
-#define MACS(rt, ra, rb) \
-    asm ("maclhw %0, %2, %3" : "=r" (rt) : "0" (rt), "r" (ra), "r" (rb));
-
-/* signed 16x16 -> 32 multiply */
-#define MULS(ra, rb) \
-    ({ int __rt; asm ("mullhw %0, %1, %2" : "=r" (__rt) : "r" (ra), "r" (rb)); __rt; })
-
-#else
-
-/* signed 16x16 -> 32 multiply add accumulate */
-#define MACS(rt, ra, rb) rt += (ra) * (rb)
-
-/* signed 16x16 -> 32 multiply */
-#define MULS(ra, rb) ((ra) * (rb))
-
-#endif
-
-#else
-
-static inline int round_sample(int64_t *sum) 
-{
-    int sum1;
-    sum1 = (int)((*sum) >> OUT_SHIFT);
-    *sum &= (1<<OUT_SHIFT)-1;
-    if (sum1 < OUT_MIN)
-        sum1 = OUT_MIN;
-    else if (sum1 > OUT_MAX)
-        sum1 = OUT_MAX;
-    return sum1;
-}
-
-#define MULS(ra, rb) MUL64(ra, rb)
-
-#endif
-
-#define SUM8(sum, op, w, p) \
-{                                               \
-    sum op MULS((w)[0 * 64], p[0 * 64]);\
-    sum op MULS((w)[1 * 64], p[1 * 64]);\
-    sum op MULS((w)[2 * 64], p[2 * 64]);\
-    sum op MULS((w)[3 * 64], p[3 * 64]);\
-    sum op MULS((w)[4 * 64], p[4 * 64]);\
-    sum op MULS((w)[5 * 64], p[5 * 64]);\
-    sum op MULS((w)[6 * 64], p[6 * 64]);\
-    sum op MULS((w)[7 * 64], p[7 * 64]);\
-}
-
-#define SUM8P2(sum1, op1, sum2, op2, w1, w2, p) \
-{                                               \
-    int tmp;\
-    tmp = p[0 * 64];\
-    sum1 op1 MULS((w1)[0 * 64], tmp);\
-    sum2 op2 MULS((w2)[0 * 64], tmp);\
-    tmp = p[1 * 64];\
-    sum1 op1 MULS((w1)[1 * 64], tmp);\
-    sum2 op2 MULS((w2)[1 * 64], tmp);\
-    tmp = p[2 * 64];\
-    sum1 op1 MULS((w1)[2 * 64], tmp);\
-    sum2 op2 MULS((w2)[2 * 64], tmp);\
-    tmp = p[3 * 64];\
-    sum1 op1 MULS((w1)[3 * 64], tmp);\
-    sum2 op2 MULS((w2)[3 * 64], tmp);\
-    tmp = p[4 * 64];\
-    sum1 op1 MULS((w1)[4 * 64], tmp);\
-    sum2 op2 MULS((w2)[4 * 64], tmp);\
-    tmp = p[5 * 64];\
-    sum1 op1 MULS((w1)[5 * 64], tmp);\
-    sum2 op2 MULS((w2)[5 * 64], tmp);\
-    tmp = p[6 * 64];\
-    sum1 op1 MULS((w1)[6 * 64], tmp);\
-    sum2 op2 MULS((w2)[6 * 64], tmp);\
-    tmp = p[7 * 64];\
-    sum1 op1 MULS((w1)[7 * 64], tmp);\
-    sum2 op2 MULS((w2)[7 * 64], tmp);\
-}
-
-void ff_mpa_synth_init(MPA_INT *window)
-{
-    int i;
-
-    /* max = 18760, max sum over all 16 coefs : 44736 */
-    for(i=0;i<257;i++) {
-        int v;
-        v = mpa_enwindow[i];
-#if WFRAC_BITS < 16
-        v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);
-#endif
-        window[i] = v;
-        if ((i & 63) != 0)
-            v = -v;
-        if (i != 0)
-            window[512 - i] = v;
-    }	
-}
-
-/* 32 sub band synthesis filter. Input: 32 sub band samples, Output:
-   32 samples. */
-/* XXX: optimize by avoiding ring buffer usage */
-void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
-			 MPA_INT *window, int *dither_state,
-                         OUT_INT *samples, int incr, 
-                         int32_t sb_samples[SBLIMIT])
-{
-    int32_t tmp[32];
-    register MPA_INT *synth_buf;
-    register const MPA_INT *w, *w2, *p;
-    int j, offset, v;
-    OUT_INT *samples2;
-#if FRAC_BITS <= 15
-    int sum, sum2;
-#else
-    int64_t sum, sum2;
-#endif
-
-    dct32(tmp, sb_samples);
-    
-    offset = *synth_buf_offset;
-    synth_buf = synth_buf_ptr + offset;
-
-    for(j=0;j<32;j++) {
-        v = tmp[j];
-#if FRAC_BITS <= 15
-        /* NOTE: can cause a loss in precision if very high amplitude
-           sound */
-        if (v > 32767)
-            v = 32767;
-        else if (v < -32768)
-            v = -32768;
-#endif
-        synth_buf[j] = v;
-    }
-    /* copy to avoid wrap */
-    memcpy(synth_buf + 512, synth_buf, 32 * sizeof(MPA_INT));
-
-    samples2 = samples + 31 * incr;
-    w = window;
-    w2 = window + 31;
-
-    sum = *dither_state;
-    p = synth_buf + 16;
-    SUM8(sum, +=, w, p);
-    p = synth_buf + 48;
-    SUM8(sum, -=, w + 32, p);
-    *samples = round_sample(&sum);
-    samples += incr;
-    w++;
-
-    /* we calculate two samples at the same time to avoid one memory
-       access per two sample */
-    for(j=1;j<16;j++) {
-        sum2 = 0;
-        p = synth_buf + 16 + j;
-        SUM8P2(sum, +=, sum2, -=, w, w2, p);
-        p = synth_buf + 48 - j;
-        SUM8P2(sum, -=, sum2, -=, w + 32, w2 + 32, p);
-
-        *samples = round_sample(&sum);
-        samples += incr;
-        sum += sum2;
-        *samples2 = round_sample(&sum);
-        samples2 -= incr;
-        w++;
-        w2--;
-    }
-    
-    p = synth_buf + 32;
-    SUM8(sum, -=, w + 32, p);
-    *samples = round_sample(&sum);
-    *dither_state= sum;
-
-    offset = (offset - 32) & 511;
-    *synth_buf_offset = offset;
-}
-
-#define C3 FIXHR(0.86602540378443864676/2)
-
-/* 0.5 / cos(pi*(2*i+1)/36) */
-static const int icos36[9] = {
-    FIXR(0.50190991877167369479),
-    FIXR(0.51763809020504152469), //0
-    FIXR(0.55168895948124587824),
-    FIXR(0.61038729438072803416),
-    FIXR(0.70710678118654752439), //1
-    FIXR(0.87172339781054900991),
-    FIXR(1.18310079157624925896),
-    FIXR(1.93185165257813657349), //2
-    FIXR(5.73685662283492756461),
-};
-
-/* 12 points IMDCT. We compute it "by hand" by factorizing obvious
-   cases. */
-static void imdct12(int *out, int *in)
-{
-    int in0, in1, in2, in3, in4, in5, t1, t2;
-
-    in0= in[0*3];
-    in1= in[1*3] + in[0*3];
-    in2= in[2*3] + in[1*3];
-    in3= in[3*3] + in[2*3];
-    in4= in[4*3] + in[3*3];
-    in5= in[5*3] + in[4*3];
-    in5 += in3;
-    in3 += in1;
-
-    in2= MULH(2*in2, C3);
-    in3= MULH(2*in3, C3);
-    
-    t1 = in0 - in4;
-    t2 = MULL(in1 - in5, icos36[4]);
-
-    out[ 7]= 
-    out[10]= t1 + t2;
-    out[ 1]=
-    out[ 4]= t1 - t2;
-
-    in0 += in4>>1;
-    in4 = in0 + in2;
-    in1 += in5>>1;
-    in5 = MULL(in1 + in3, icos36[1]);    
-    out[ 8]= 
-    out[ 9]= in4 + in5;
-    out[ 2]=
-    out[ 3]= in4 - in5;
-    
-    in0 -= in2;
-    in1 = MULL(in1 - in3, icos36[7]);
-    out[ 0]=
-    out[ 5]= in0 - in1;
-    out[ 6]=
-    out[11]= in0 + in1;    
-}
-
-/* cos(pi*i/18) */
-#define C1 FIXHR(0.98480775301220805936/2)
-#define C2 FIXHR(0.93969262078590838405/2)
-#define C3 FIXHR(0.86602540378443864676/2)
-#define C4 FIXHR(0.76604444311897803520/2)
-#define C5 FIXHR(0.64278760968653932632/2)
-#define C6 FIXHR(0.5/2)
-#define C7 FIXHR(0.34202014332566873304/2)
-#define C8 FIXHR(0.17364817766693034885/2)
-
-
-/* using Lee like decomposition followed by hand coded 9 points DCT */
-static void imdct36(int *out, int *buf, int *in, int *win)
-{
-    int i, j, t0, t1, t2, t3, s0, s1, s2, s3;
-    int tmp[18], *tmp1, *in1;
-
-    for(i=17;i>=1;i--)
-        in[i] += in[i-1];
-    for(i=17;i>=3;i-=2)
-        in[i] += in[i-2];
-
-    for(j=0;j<2;j++) {
-        tmp1 = tmp + j;
-        in1 = in + j;
-#if 0
-//more accurate but slower
-        int64_t t0, t1, t2, t3;
-        t2 = in1[2*4] + in1[2*8] - in1[2*2];
-        
-        t3 = (in1[2*0] + (int64_t)(in1[2*6]>>1))<<32;
-        t1 = in1[2*0] - in1[2*6];
-        tmp1[ 6] = t1 - (t2>>1);
-        tmp1[16] = t1 + t2;
-
-        t0 = MUL64(2*(in1[2*2] + in1[2*4]),    C2);
-        t1 = MUL64(   in1[2*4] - in1[2*8] , -2*C8);
-        t2 = MUL64(2*(in1[2*2] + in1[2*8]),   -C4);
-        
-        tmp1[10] = (t3 - t0 - t2) >> 32;
-        tmp1[ 2] = (t3 + t0 + t1) >> 32;
-        tmp1[14] = (t3 + t2 - t1) >> 32;
-        
-        tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3);
-        t2 = MUL64(2*(in1[2*1] + in1[2*5]),    C1);
-        t3 = MUL64(   in1[2*5] - in1[2*7] , -2*C7);
-        t0 = MUL64(2*in1[2*3], C3);
-
-        t1 = MUL64(2*(in1[2*1] + in1[2*7]),   -C5);
-
-        tmp1[ 0] = (t2 + t3 + t0) >> 32;
-        tmp1[12] = (t2 + t1 - t0) >> 32;
-        tmp1[ 8] = (t3 - t1 - t0) >> 32;
-#else
-        t2 = in1[2*4] + in1[2*8] - in1[2*2];
-        
-        t3 = in1[2*0] + (in1[2*6]>>1);
-        t1 = in1[2*0] - in1[2*6];
-        tmp1[ 6] = t1 - (t2>>1);
-        tmp1[16] = t1 + t2;
-
-        t0 = MULH(2*(in1[2*2] + in1[2*4]),    C2);
-        t1 = MULH(   in1[2*4] - in1[2*8] , -2*C8);
-        t2 = MULH(2*(in1[2*2] + in1[2*8]),   -C4);
-        
-        tmp1[10] = t3 - t0 - t2;
-        tmp1[ 2] = t3 + t0 + t1;
-        tmp1[14] = t3 + t2 - t1;
-        
-        tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3);
-        t2 = MULH(2*(in1[2*1] + in1[2*5]),    C1);
-        t3 = MULH(   in1[2*5] - in1[2*7] , -2*C7);
-        t0 = MULH(2*in1[2*3], C3);
-
-        t1 = MULH(2*(in1[2*1] + in1[2*7]),   -C5);
-
-        tmp1[ 0] = t2 + t3 + t0;
-        tmp1[12] = t2 + t1 - t0;
-        tmp1[ 8] = t3 - t1 - t0;
-#endif
-    }
-
-    i = 0;
-    for(j=0;j<4;j++) {
-        t0 = tmp[i];
-        t1 = tmp[i + 2];
-        s0 = t1 + t0;
-        s2 = t1 - t0;
-
-        t2 = tmp[i + 1];
-        t3 = tmp[i + 3];
-        s1 = MULL(t3 + t2, icos36[j]);
-        s3 = MULL(t3 - t2, icos36[8 - j]);
-        
-        t0 = s0 + s1;
-        t1 = s0 - s1;
-        out[(9 + j)*SBLIMIT] =  MULH(t1, win[9 + j]) + buf[9 + j];
-        out[(8 - j)*SBLIMIT] =  MULH(t1, win[8 - j]) + buf[8 - j];
-        buf[9 + j] = MULH(t0, win[18 + 9 + j]);
-        buf[8 - j] = MULH(t0, win[18 + 8 - j]);
-        
-        t0 = s2 + s3;
-        t1 = s2 - s3;
-        out[(9 + 8 - j)*SBLIMIT] =  MULH(t1, win[9 + 8 - j]) + buf[9 + 8 - j];
-        out[(        j)*SBLIMIT] =  MULH(t1, win[        j]) + buf[        j];
-        buf[9 + 8 - j] = MULH(t0, win[18 + 9 + 8 - j]);
-        buf[      + j] = MULH(t0, win[18         + j]);
-        i += 4;
-    }
-
-    s0 = tmp[16];
-    s1 = MULL(tmp[17], icos36[4]);
-    t0 = s0 + s1;
-    t1 = s0 - s1;
-    out[(9 + 4)*SBLIMIT] =  MULH(t1, win[9 + 4]) + buf[9 + 4];
-    out[(8 - 4)*SBLIMIT] =  MULH(t1, win[8 - 4]) + buf[8 - 4];
-    buf[9 + 4] = MULH(t0, win[18 + 9 + 4]);
-    buf[8 - 4] = MULH(t0, win[18 + 8 - 4]);
-}
-
-/* header decoding. MUST check the header before because no
-   consistency check is done there. Return 1 if free format found and
-   that the frame size must be computed externally */
-static int decode_header(MPADecodeContext *s, uint32_t header)
-{
-    int sample_rate, frame_size, mpeg25, padding;
-    int sample_rate_index, bitrate_index;
-    if (header & (1<<20)) {
-        s->lsf = (header & (1<<19)) ? 0 : 1;
-        mpeg25 = 0;
-    } else {
-        s->lsf = 1;
-        mpeg25 = 1;
-    }
-    
-    s->layer = 4 - ((header >> 17) & 3);
-    /* extract frequency */
-    sample_rate_index = (header >> 10) & 3;
-    sample_rate = mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25);
-    sample_rate_index += 3 * (s->lsf + mpeg25);
-    s->sample_rate_index = sample_rate_index;
-    s->error_protection = ((header >> 16) & 1) ^ 1;
-    s->sample_rate = sample_rate;
-
-    bitrate_index = (header >> 12) & 0xf;
-    padding = (header >> 9) & 1;
-    //extension = (header >> 8) & 1;
-    s->mode = (header >> 6) & 3;
-    s->mode_ext = (header >> 4) & 3;
-    //copyright = (header >> 3) & 1;
-    //original = (header >> 2) & 1;
-    //emphasis = header & 3;
-
-    if (s->mode == MPA_MONO)
-        s->nb_channels = 1;
-    else
-        s->nb_channels = 2;
-    
-    if (bitrate_index != 0) {
-        frame_size = mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index];
-        s->bit_rate = frame_size * 1000;
-        switch(s->layer) {
-        case 1:
-            frame_size = (frame_size * 12000) / sample_rate;
-            frame_size = (frame_size + padding) * 4;
-            break;
-        case 2:
-            frame_size = (frame_size * 144000) / sample_rate;
-            frame_size += padding;
-            break;
-        default:
-        case 3:
-            frame_size = (frame_size * 144000) / (sample_rate << s->lsf);
-            frame_size += padding;
-            break;
-        }
-        s->frame_size = frame_size;
-    } else {
-        /* if no frame size computed, signal it */
-        if (!s->free_format_frame_size)
-            return 1;
-        /* free format: compute bitrate and real frame size from the
-           frame size we extracted by reading the bitstream */
-        s->frame_size = s->free_format_frame_size;
-        switch(s->layer) {
-        case 1:
-            s->frame_size += padding  * 4;
-            s->bit_rate = (s->frame_size * sample_rate) / 48000;
-            break;
-        case 2:
-            s->frame_size += padding;
-            s->bit_rate = (s->frame_size * sample_rate) / 144000;
-            break;
-        default:
-        case 3:
-            s->frame_size += padding;
-            s->bit_rate = (s->frame_size * (sample_rate << s->lsf)) / 144000;
-            break;
-        }
-    }
-    
-#if defined(DEBUG)
-    printf("layer%d, %d Hz, %d kbits/s, ",
-           s->layer, s->sample_rate, s->bit_rate);
-    if (s->nb_channels == 2) {
-        if (s->layer == 3) {
-            if (s->mode_ext & MODE_EXT_MS_STEREO)
-                printf("ms-");
-            if (s->mode_ext & MODE_EXT_I_STEREO)
-                printf("i-");
-        }
-        printf("stereo");
-    } else {
-        printf("mono");
-    }
-    printf("\n");
-#endif
-    return 0;
-}
-
-/* useful helper to get mpeg audio stream infos. Return -1 if error in
-   header, otherwise the coded frame size in bytes */
-int mpa_decode_header(AVCodecContext *avctx, uint32_t head)
-{
-    MPADecodeContext s1, *s = &s1;
-    memset( s, 0, sizeof(MPADecodeContext) );
-
-    if (ff_mpa_check_header(head) != 0)
-        return -1;
-
-    if (decode_header(s, head) != 0) {
-        return -1;
-    }
-
-    switch(s->layer) {
-    case 1:
-        avctx->frame_size = 384;
-        break;
-    case 2:
-        avctx->frame_size = 1152;
-        break;
-    default:
-    case 3:
-        if (s->lsf)
-            avctx->frame_size = 576;
-        else
-            avctx->frame_size = 1152;
-        break;
-    }
-
-    avctx->sample_rate = s->sample_rate;
-    avctx->channels = s->nb_channels;
-    avctx->bit_rate = s->bit_rate;
-    avctx->sub_id = s->layer;
-    return s->frame_size;
-}
-
-/* return the number of decoded frames */
-static int mp_decode_layer1(MPADecodeContext *s)
-{
-    int bound, i, v, n, ch, j, mant;
-    uint8_t allocation[MPA_MAX_CHANNELS][SBLIMIT];
-    uint8_t scale_factors[MPA_MAX_CHANNELS][SBLIMIT];
-
-    if (s->mode == MPA_JSTEREO) 
-        bound = (s->mode_ext + 1) * 4;
-    else
-        bound = SBLIMIT;
-
-    /* allocation bits */
-    for(i=0;i<bound;i++) {
-        for(ch=0;ch<s->nb_channels;ch++) {
-            allocation[ch][i] = get_bits(&s->gb, 4);
-        }
-    }
-    for(i=bound;i<SBLIMIT;i++) {
-        allocation[0][i] = get_bits(&s->gb, 4);
-    }
-
-    /* scale factors */
-    for(i=0;i<bound;i++) {
-        for(ch=0;ch<s->nb_channels;ch++) {
-            if (allocation[ch][i])
-                scale_factors[ch][i] = get_bits(&s->gb, 6);
-        }
-    }
-    for(i=bound;i<SBLIMIT;i++) {
-        if (allocation[0][i]) {
-            scale_factors[0][i] = get_bits(&s->gb, 6);
-            scale_factors[1][i] = get_bits(&s->gb, 6);
-        }
-    }
-    
-    /* compute samples */
-    for(j=0;j<12;j++) {
-        for(i=0;i<bound;i++) {
-            for(ch=0;ch<s->nb_channels;ch++) {
-                n = allocation[ch][i];
-                if (n) {
-                    mant = get_bits(&s->gb, n + 1);
-                    v = l1_unscale(n, mant, scale_factors[ch][i]);
-                } else {
-                    v = 0;
-                }
-                s->sb_samples[ch][j][i] = v;
-            }
-        }
-        for(i=bound;i<SBLIMIT;i++) {
-            n = allocation[0][i];
-            if (n) {
-                mant = get_bits(&s->gb, n + 1);
-                v = l1_unscale(n, mant, scale_factors[0][i]);
-                s->sb_samples[0][j][i] = v;
-                v = l1_unscale(n, mant, scale_factors[1][i]);
-                s->sb_samples[1][j][i] = v;
-            } else {
-                s->sb_samples[0][j][i] = 0;
-                s->sb_samples[1][j][i] = 0;
-            }
-        }
-    }
-    return 12;
-}
-
-/* bitrate is in kb/s */
-int l2_select_table(int bitrate, int nb_channels, int freq, int lsf)
-{
-    int ch_bitrate, table;
-    
-    ch_bitrate = bitrate / nb_channels;
-    if (!lsf) {
-        if ((freq == 48000 && ch_bitrate >= 56) ||
-            (ch_bitrate >= 56 && ch_bitrate <= 80)) 
-            table = 0;
-        else if (freq != 48000 && ch_bitrate >= 96) 
-            table = 1;
-        else if (freq != 32000 && ch_bitrate <= 48) 
-            table = 2;
-        else 
-            table = 3;
-    } else {
-        table = 4;
-    }
-    return table;
-}
-
-static int mp_decode_layer2(MPADecodeContext *s)
-{
-    int sblimit; /* number of used subbands */
-    const unsigned char *alloc_table;
-    int table, bit_alloc_bits, i, j, ch, bound, v;
-    unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT];
-    unsigned char scale_code[MPA_MAX_CHANNELS][SBLIMIT];
-    unsigned char scale_factors[MPA_MAX_CHANNELS][SBLIMIT][3], *sf;
-    int scale, qindex, bits, steps, k, l, m, b;
-
-    /* select decoding table */
-    table = l2_select_table(s->bit_rate / 1000, s->nb_channels, 
-                            s->sample_rate, s->lsf);
-    sblimit = sblimit_table[table];
-    alloc_table = alloc_tables[table];
-
-    if (s->mode == MPA_JSTEREO) 
-        bound = (s->mode_ext + 1) * 4;
-    else
-        bound = sblimit;
-
-    dprintf("bound=%d sblimit=%d\n", bound, sblimit);
-
-    /* sanity check */
-    if( bound > sblimit ) bound = sblimit;
-
-    /* parse bit allocation */
-    j = 0;
-    for(i=0;i<bound;i++) {
-        bit_alloc_bits = alloc_table[j];
-        for(ch=0;ch<s->nb_channels;ch++) {
-            bit_alloc[ch][i] = get_bits(&s->gb, bit_alloc_bits);
-        }
-        j += 1 << bit_alloc_bits;
-    }
-    for(i=bound;i<sblimit;i++) {
-        bit_alloc_bits = alloc_table[j];
-        v = get_bits(&s->gb, bit_alloc_bits);
-        bit_alloc[0][i] = v;
-        bit_alloc[1][i] = v;
-        j += 1 << bit_alloc_bits;
-    }
-
-#ifdef DEBUG
-    {
-        for(ch=0;ch<s->nb_channels;ch++) {
-            for(i=0;i<sblimit;i++)
-                printf(" %d", bit_alloc[ch][i]);
-            printf("\n");
-        }
-    }
-#endif
-
-    /* scale codes */
-    for(i=0;i<sblimit;i++) {
-        for(ch=0;ch<s->nb_channels;ch++) {
-            if (bit_alloc[ch][i]) 
-                scale_code[ch][i] = get_bits(&s->gb, 2);
-        }
-    }
-    
-    /* scale factors */
-    for(i=0;i<sblimit;i++) {
-        for(ch=0;ch<s->nb_channels;ch++) {
-            if (bit_alloc[ch][i]) {
-                sf = scale_factors[ch][i];
-                switch(scale_code[ch][i]) {
-                default:
-                case 0:
-                    sf[0] = get_bits(&s->gb, 6);
-                    sf[1] = get_bits(&s->gb, 6);
-                    sf[2] = get_bits(&s->gb, 6);
-                    break;
-                case 2:
-                    sf[0] = get_bits(&s->gb, 6);
-                    sf[1] = sf[0];
-                    sf[2] = sf[0];
-                    break;
-                case 1:
-                    sf[0] = get_bits(&s->gb, 6);
-                    sf[2] = get_bits(&s->gb, 6);
-                    sf[1] = sf[0];
-                    break;
-                case 3:
-                    sf[0] = get_bits(&s->gb, 6);
-                    sf[2] = get_bits(&s->gb, 6);
-                    sf[1] = sf[2];
-                    break;
-                }
-            }
-        }
-    }
-
-#ifdef DEBUG
-    for(ch=0;ch<s->nb_channels;ch++) {
-        for(i=0;i<sblimit;i++) {
-            if (bit_alloc[ch][i]) {
-                sf = scale_factors[ch][i];
-                printf(" %d %d %d", sf[0], sf[1], sf[2]);
-            } else {
-                printf(" -");
-            }
-        }
-        printf("\n");
-    }
-#endif
-
-    /* samples */
-    for(k=0;k<3;k++) {
-        for(l=0;l<12;l+=3) {
-            j = 0;
-            for(i=0;i<bound;i++) {
-                bit_alloc_bits = alloc_table[j];
-                for(ch=0;ch<s->nb_channels;ch++) {
-                    b = bit_alloc[ch][i];
-                    if (b) {
-                        scale = scale_factors[ch][i][k];
-                        qindex = alloc_table[j+b];
-                        bits = quant_bits[qindex];
-                        if (bits < 0) {
-                            /* 3 values at the same time */
-                            v = get_bits(&s->gb, -bits);
-                            steps = quant_steps[qindex];
-                            s->sb_samples[ch][k * 12 + l + 0][i] = 
-                                l2_unscale_group(steps, v % steps, scale);
-                            v = v / steps;
-                            s->sb_samples[ch][k * 12 + l + 1][i] = 
-                                l2_unscale_group(steps, v % steps, scale);
-                            v = v / steps;
-                            s->sb_samples[ch][k * 12 + l + 2][i] = 
-                                l2_unscale_group(steps, v, scale);
-                        } else {
-                            for(m=0;m<3;m++) {
-                                v = get_bits(&s->gb, bits);
-                                v = l1_unscale(bits - 1, v, scale);
-                                s->sb_samples[ch][k * 12 + l + m][i] = v;
-                            }
-                        }
-                    } else {
-                        s->sb_samples[ch][k * 12 + l + 0][i] = 0;
-                        s->sb_samples[ch][k * 12 + l + 1][i] = 0;
-                        s->sb_samples[ch][k * 12 + l + 2][i] = 0;
-                    }
-                }
-                /* next subband in alloc table */
-                j += 1 << bit_alloc_bits; 
-            }
-            /* XXX: find a way to avoid this duplication of code */
-            for(i=bound;i<sblimit;i++) {
-                bit_alloc_bits = alloc_table[j];
-                b = bit_alloc[0][i];
-                if (b) {
-                    int mant, scale0, scale1;
-                    scale0 = scale_factors[0][i][k];
-                    scale1 = scale_factors[1][i][k];
-                    qindex = alloc_table[j+b];
-                    bits = quant_bits[qindex];
-                    if (bits < 0) {
-                        /* 3 values at the same time */
-                        v = get_bits(&s->gb, -bits);
-                        steps = quant_steps[qindex];
-                        mant = v % steps;
-                        v = v / steps;
-                        s->sb_samples[0][k * 12 + l + 0][i] = 
-                            l2_unscale_group(steps, mant, scale0);
-                        s->sb_samples[1][k * 12 + l + 0][i] = 
-                            l2_unscale_group(steps, mant, scale1);
-                        mant = v % steps;
-                        v = v / steps;
-                        s->sb_samples[0][k * 12 + l + 1][i] = 
-                            l2_unscale_group(steps, mant, scale0);
-                        s->sb_samples[1][k * 12 + l + 1][i] = 
-                            l2_unscale_group(steps, mant, scale1);
-                        s->sb_samples[0][k * 12 + l + 2][i] = 
-                            l2_unscale_group(steps, v, scale0);
-                        s->sb_samples[1][k * 12 + l + 2][i] = 
-                            l2_unscale_group(steps, v, scale1);
-                    } else {
-                        for(m=0;m<3;m++) {
-                            mant = get_bits(&s->gb, bits);
-                            s->sb_samples[0][k * 12 + l + m][i] = 
-                                l1_unscale(bits - 1, mant, scale0);
-                            s->sb_samples[1][k * 12 + l + m][i] = 
-                                l1_unscale(bits - 1, mant, scale1);
-                        }
-                    }
-                } else {
-                    s->sb_samples[0][k * 12 + l + 0][i] = 0;
-                    s->sb_samples[0][k * 12 + l + 1][i] = 0;
-                    s->sb_samples[0][k * 12 + l + 2][i] = 0;
-                    s->sb_samples[1][k * 12 + l + 0][i] = 0;
-                    s->sb_samples[1][k * 12 + l + 1][i] = 0;
-                    s->sb_samples[1][k * 12 + l + 2][i] = 0;
-                }
-                /* next subband in alloc table */
-                j += 1 << bit_alloc_bits; 
-            }
-            /* fill remaining samples to zero */
-            for(i=sblimit;i<SBLIMIT;i++) {
-                for(ch=0;ch<s->nb_channels;ch++) {
-                    s->sb_samples[ch][k * 12 + l + 0][i] = 0;
-                    s->sb_samples[ch][k * 12 + l + 1][i] = 0;
-                    s->sb_samples[ch][k * 12 + l + 2][i] = 0;
-                }
-            }
-        }
-    }
-    return 3 * 12;
-}
-
-/*
- * Seek back in the stream for backstep bytes (at most 511 bytes)
- */
-static void seek_to_maindata(MPADecodeContext *s, unsigned int backstep)
-{
-    uint8_t *ptr;
-
-    /* compute current position in stream */
-    ptr = (uint8_t *)(s->gb.buffer + (get_bits_count(&s->gb)>>3));
-
-    /* copy old data before current one */
-    ptr -= backstep;
-    memcpy(ptr, s->inbuf1[s->inbuf_index ^ 1] + 
-           BACKSTEP_SIZE + s->old_frame_size - backstep, backstep);
-    /* init get bits again */
-    init_get_bits(&s->gb, ptr, (s->frame_size + backstep)*8);
-
-    /* prepare next buffer */
-    s->inbuf_index ^= 1;
-    s->inbuf = &s->inbuf1[s->inbuf_index][BACKSTEP_SIZE];
-    s->old_frame_size = s->frame_size;
-}
-
-static inline void lsf_sf_expand(int *slen,
-                                 int sf, int n1, int n2, int n3)
-{
-    if (n3) {
-        slen[3] = sf % n3;
-        sf /= n3;
-    } else {
-        slen[3] = 0;
-    }
-    if (n2) {
-        slen[2] = sf % n2;
-        sf /= n2;
-    } else {
-        slen[2] = 0;
-    }
-    slen[1] = sf % n1;
-    sf /= n1;
-    slen[0] = sf;
-}
-
-static void exponents_from_scale_factors(MPADecodeContext *s, 
-                                         GranuleDef *g,
-                                         int16_t *exponents)
-{
-    const uint8_t *bstab, *pretab;
-    int len, i, j, k, l, v0, shift, gain, gains[3];
-    int16_t *exp_ptr;
-
-    exp_ptr = exponents;
-    gain = g->global_gain - 210;
-    shift = g->scalefac_scale + 1;
-
-    bstab = band_size_long[s->sample_rate_index];
-    pretab = mpa_pretab[g->preflag];
-    for(i=0;i<g->long_end;i++) {
-        v0 = gain - ((g->scale_factors[i] + pretab[i]) << shift);
-        len = bstab[i];
-        for(j=len;j>0;j--)
-            *exp_ptr++ = v0;
-    }
-
-    if (g->short_start < 13) {
-        bstab = band_size_short[s->sample_rate_index];
-        gains[0] = gain - (g->subblock_gain[0] << 3);
-        gains[1] = gain - (g->subblock_gain[1] << 3);
-        gains[2] = gain - (g->subblock_gain[2] << 3);
-        k = g->long_end;
-        for(i=g->short_start;i<13;i++) {
-            len = bstab[i];
-            for(l=0;l<3;l++) {
-                v0 = gains[l] - (g->scale_factors[k++] << shift);
-                for(j=len;j>0;j--)
-                *exp_ptr++ = v0;
-            }
-        }
-    }
-}
-
-/* handle n = 0 too */
-static inline int get_bitsz(GetBitContext *s, int n)
-{
-    if (n == 0)
-        return 0;
-    else
-        return get_bits(s, n);
-}
-
-static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
-                          int16_t *exponents, int end_pos)
-{
-    int s_index;
-    int linbits, code, x, y, l, v, i, j, k, pos;
-    GetBitContext last_gb;
-    VLC *vlc;
-    uint8_t *code_table;
-
-    /* low frequencies (called big values) */
-    s_index = 0;
-    for(i=0;i<3;i++) {
-        j = g->region_size[i];
-        if (j == 0)
-            continue;
-        /* select vlc table */
-        k = g->table_select[i];
-        l = mpa_huff_data[k][0];
-        linbits = mpa_huff_data[k][1];
-        vlc = &huff_vlc[l];
-        code_table = huff_code_table[l];
-
-        /* read huffcode and compute each couple */
-        for(;j>0;j--) {
-            if (get_bits_count(&s->gb) >= end_pos)
-                break;
-            if (code_table) {
-                code = get_vlc(&s->gb, vlc);
-                if (code < 0)
-                    return -1;
-                y = code_table[code];
-                x = y >> 4;
-                y = y & 0x0f;
-            } else {
-                x = 0;
-                y = 0;
-            }
-            dprintf("region=%d n=%d x=%d y=%d exp=%d\n", 
-                    i, g->region_size[i] - j, x, y, exponents[s_index]);
-            if (x) {
-                if (x == 15)
-                    x += get_bitsz(&s->gb, linbits);
-                v = l3_unscale(x, exponents[s_index]);
-                if (get_bits1(&s->gb))
-                    v = -v;
-            } else {
-                v = 0;
-            }
-            g->sb_hybrid[s_index++] = v;
-            if (y) {
-                if (y == 15)
-                    y += get_bitsz(&s->gb, linbits);
-                v = l3_unscale(y, exponents[s_index]);
-                if (get_bits1(&s->gb))
-                    v = -v;
-            } else {
-                v = 0;
-            }
-            g->sb_hybrid[s_index++] = v;
-        }
-    }
-            
-    /* high frequencies */
-    vlc = &huff_quad_vlc[g->count1table_select];
-    last_gb.buffer = NULL;
-    while (s_index <= 572) {
-        pos = get_bits_count(&s->gb);
-        if (pos >= end_pos) {
-            if (pos > end_pos && last_gb.buffer != NULL) {
-                /* some encoders generate an incorrect size for this
-                   part. We must go back into the data */
-                s_index -= 4;
-                s->gb = last_gb;
-            }
-            break;
-        }
-        last_gb= s->gb;
-
-        code = get_vlc(&s->gb, vlc);
-        dprintf("t=%d code=%d\n", g->count1table_select, code);
-        if (code < 0)
-            return -1;
-        for(i=0;i<4;i++) {
-            if (code & (8 >> i)) {
-                /* non zero value. Could use a hand coded function for
-                   'one' value */
-                v = l3_unscale(1, exponents[s_index]);
-                if(get_bits1(&s->gb))
-                    v = -v;
-            } else {
-                v = 0;
-            }
-            g->sb_hybrid[s_index++] = v;
-        }
-    }
-    while (s_index < 576)
-        g->sb_hybrid[s_index++] = 0;
-    return 0;
-}
-
-/* Reorder short blocks from bitstream order to interleaved order. It
-   would be faster to do it in parsing, but the code would be far more
-   complicated */
-static void reorder_block(MPADecodeContext *s, GranuleDef *g)
-{
-    int i, j, k, len;
-    int32_t *ptr, *dst, *ptr1;
-    int32_t tmp[576];
-
-    if (g->block_type != 2)
-        return;
-
-    if (g->switch_point) {
-        if (s->sample_rate_index != 8) {
-            ptr = g->sb_hybrid + 36;
-        } else {
-            ptr = g->sb_hybrid + 48;
-        }
-    } else {
-        ptr = g->sb_hybrid;
-    }
-    
-    for(i=g->short_start;i<13;i++) {
-        len = band_size_short[s->sample_rate_index][i];
-        ptr1 = ptr;
-        for(k=0;k<3;k++) {
-            dst = tmp + k;
-            for(j=len;j>0;j--) {
-                *dst = *ptr++;
-                dst += 3;
-            }
-        }
-        memcpy(ptr1, tmp, len * 3 * sizeof(int32_t));
-    }
-}
-
-#define ISQRT2 FIXR(0.70710678118654752440)
-
-static void compute_stereo(MPADecodeContext *s,
-                           GranuleDef *g0, GranuleDef *g1)
-{
-    int i, j, k, l;
-    int32_t v1, v2;
-    int sf_max, tmp0, tmp1, sf, len, non_zero_found;
-    int32_t (*is_tab)[16];
-    int32_t *tab0, *tab1;
-    int non_zero_found_short[3];
-
-    /* intensity stereo */
-    if (s->mode_ext & MODE_EXT_I_STEREO) {
-        if (!s->lsf) {
-            is_tab = is_table;
-            sf_max = 7;
-        } else {
-            is_tab = is_table_lsf[g1->scalefac_compress & 1];
-            sf_max = 16;
-        }
-            
-        tab0 = g0->sb_hybrid + 576;
-        tab1 = g1->sb_hybrid + 576;
-
-        non_zero_found_short[0] = 0;
-        non_zero_found_short[1] = 0;
-        non_zero_found_short[2] = 0;
-        k = (13 - g1->short_start) * 3 + g1->long_end - 3;
-        for(i = 12;i >= g1->short_start;i--) {
-            /* for last band, use previous scale factor */
-            if (i != 11)
-                k -= 3;
-            len = band_size_short[s->sample_rate_index][i];
-            for(l=2;l>=0;l--) {
-                tab0 -= len;
-                tab1 -= len;
-                if (!non_zero_found_short[l]) {
-                    /* test if non zero band. if so, stop doing i-stereo */
-                    for(j=0;j<len;j++) {
-                        if (tab1[j] != 0) {
-                            non_zero_found_short[l] = 1;
-                            goto found1;
-                        }
-                    }
-                    sf = g1->scale_factors[k + l];
-                    if (sf >= sf_max)
-                        goto found1;
-
-                    v1 = is_tab[0][sf];
-                    v2 = is_tab[1][sf];
-                    for(j=0;j<len;j++) {
-                        tmp0 = tab0[j];
-                        tab0[j] = MULL(tmp0, v1);
-                        tab1[j] = MULL(tmp0, v2);
-                    }
-                } else {
-                found1:
-                    if (s->mode_ext & MODE_EXT_MS_STEREO) {
-                        /* lower part of the spectrum : do ms stereo
-                           if enabled */
-                        for(j=0;j<len;j++) {
-                            tmp0 = tab0[j];
-                            tmp1 = tab1[j];
-                            tab0[j] = MULL(tmp0 + tmp1, ISQRT2);
-                            tab1[j] = MULL(tmp0 - tmp1, ISQRT2);
-                        }
-                    }
-                }
-            }
-        }
-
-        non_zero_found = non_zero_found_short[0] | 
-            non_zero_found_short[1] | 
-            non_zero_found_short[2];
-
-        for(i = g1->long_end - 1;i >= 0;i--) {
-            len = band_size_long[s->sample_rate_index][i];
-            tab0 -= len;
-            tab1 -= len;
-            /* test if non zero band. if so, stop doing i-stereo */
-            if (!non_zero_found) {
-                for(j=0;j<len;j++) {
-                    if (tab1[j] != 0) {
-                        non_zero_found = 1;
-                        goto found2;
-                    }
-                }
-                /* for last band, use previous scale factor */
-                k = (i == 21) ? 20 : i;
-                sf = g1->scale_factors[k];
-                if (sf >= sf_max)
-                    goto found2;
-                v1 = is_tab[0][sf];
-                v2 = is_tab[1][sf];
-                for(j=0;j<len;j++) {
-                    tmp0 = tab0[j];
-                    tab0[j] = MULL(tmp0, v1);
-                    tab1[j] = MULL(tmp0, v2);
-                }
-            } else {
-            found2:
-                if (s->mode_ext & MODE_EXT_MS_STEREO) {
-                    /* lower part of the spectrum : do ms stereo
-                       if enabled */
-                    for(j=0;j<len;j++) {
-                        tmp0 = tab0[j];
-                        tmp1 = tab1[j];
-                        tab0[j] = MULL(tmp0 + tmp1, ISQRT2);
-                        tab1[j] = MULL(tmp0 - tmp1, ISQRT2);
-                    }
-                }
-            }
-        }
-    } else if (s->mode_ext & MODE_EXT_MS_STEREO) {
-        /* ms stereo ONLY */
-        /* NOTE: the 1/sqrt(2) normalization factor is included in the
-           global gain */
-        tab0 = g0->sb_hybrid;
-        tab1 = g1->sb_hybrid;
-        for(i=0;i<576;i++) {
-            tmp0 = tab0[i];
-            tmp1 = tab1[i];
-            tab0[i] = tmp0 + tmp1;
-            tab1[i] = tmp0 - tmp1;
-        }
-    }
-}
-
-static void compute_antialias_integer(MPADecodeContext *s,
-                              GranuleDef *g)
-{
-    int32_t *ptr, *csa;
-    int n, i;
-
-    /* we antialias only "long" bands */
-    if (g->block_type == 2) {
-        if (!g->switch_point)
-            return;
-        /* XXX: check this for 8000Hz case */
-        n = 1;
-    } else {
-        n = SBLIMIT - 1;
-    }
-    
-    ptr = g->sb_hybrid + 18;
-    for(i = n;i > 0;i--) {
-        int tmp0, tmp1, tmp2;
-        csa = &csa_table[0][0];
-#define INT_AA(j) \
-            tmp0 = ptr[-1-j];\
-            tmp1 = ptr[   j];\
-            tmp2= MULH(tmp0 + tmp1, csa[0+4*j]);\
-            ptr[-1-j] = 4*(tmp2 - MULH(tmp1, csa[2+4*j]));\
-            ptr[   j] = 4*(tmp2 + MULH(tmp0, csa[3+4*j]));
-
-        INT_AA(0)
-        INT_AA(1)
-        INT_AA(2)
-        INT_AA(3)
-        INT_AA(4)
-        INT_AA(5)
-        INT_AA(6)
-        INT_AA(7)
-            
-        ptr += 18;       
-    }
-}
-
-static void compute_antialias_float(MPADecodeContext *s,
-                              GranuleDef *g)
-{
-    int32_t *ptr;
-    int n, i;
-
-    /* we antialias only "long" bands */
-    if (g->block_type == 2) {
-        if (!g->switch_point)
-            return;
-        /* XXX: check this for 8000Hz case */
-        n = 1;
-    } else {
-        n = SBLIMIT - 1;
-    }
-    
-    ptr = g->sb_hybrid + 18;
-    for(i = n;i > 0;i--) {
-        float tmp0, tmp1;
-        float *csa = &csa_table_float[0][0];       
-#define FLOAT_AA(j)\
-        tmp0= ptr[-1-j];\
-        tmp1= ptr[   j];\
-        ptr[-1-j] = lrintf(tmp0 * csa[0+4*j] - tmp1 * csa[1+4*j]);\
-        ptr[   j] = lrintf(tmp0 * csa[1+4*j] + tmp1 * csa[0+4*j]);
-        
-        FLOAT_AA(0)
-        FLOAT_AA(1)
-        FLOAT_AA(2)
-        FLOAT_AA(3)
-        FLOAT_AA(4)
-        FLOAT_AA(5)
-        FLOAT_AA(6)
-        FLOAT_AA(7)
-
-        ptr += 18;       
-    }
-}
-
-static void compute_imdct(MPADecodeContext *s,
-                          GranuleDef *g, 
-                          int32_t *sb_samples,
-                          int32_t *mdct_buf)
-{
-    int32_t *ptr, *win, *win1, *buf, *out_ptr, *ptr1;
-    int32_t out2[12];
-    int i, j, mdct_long_end, v, sblimit;
-
-    /* find last non zero block */
-    ptr = g->sb_hybrid + 576;
-    ptr1 = g->sb_hybrid + 2 * 18;
-    while (ptr >= ptr1) {
-        ptr -= 6;
-        v = ptr[0] | ptr[1] | ptr[2] | ptr[3] | ptr[4] | ptr[5];
-        if (v != 0)
-            break;
-    }
-    sblimit = ((ptr - g->sb_hybrid) / 18) + 1;
-
-    if (g->block_type == 2) {
-        /* XXX: check for 8000 Hz */
-        if (g->switch_point)
-            mdct_long_end = 2;
-        else
-            mdct_long_end = 0;
-    } else {
-        mdct_long_end = sblimit;
-    }
-
-    buf = mdct_buf;
-    ptr = g->sb_hybrid;
-    for(j=0;j<mdct_long_end;j++) {
-        /* apply window & overlap with previous buffer */
-        out_ptr = sb_samples + j;
-        /* select window */
-        if (g->switch_point && j < 2)
-            win1 = mdct_win[0];
-        else
-            win1 = mdct_win[g->block_type];
-        /* select frequency inversion */
-        win = win1 + ((4 * 36) & -(j & 1));
-        imdct36(out_ptr, buf, ptr, win);
-        out_ptr += 18*SBLIMIT;
-        ptr += 18;
-        buf += 18;
-    }
-    for(j=mdct_long_end;j<sblimit;j++) {
-        /* select frequency inversion */
-        win = mdct_win[2] + ((4 * 36) & -(j & 1));
-        out_ptr = sb_samples + j;
-        
-        for(i=0; i<6; i++){
-            *out_ptr = buf[i];
-            out_ptr += SBLIMIT;
-        }
-        imdct12(out2, ptr + 0);
-        for(i=0;i<6;i++) {
-            *out_ptr = MULH(out2[i], win[i]) + buf[i + 6*1];
-            buf[i + 6*2] = MULH(out2[i + 6], win[i + 6]);
-            out_ptr += SBLIMIT;
-        }
-        imdct12(out2, ptr + 1);
-        for(i=0;i<6;i++) {
-            *out_ptr = MULH(out2[i], win[i]) + buf[i + 6*2];
-            buf[i + 6*0] = MULH(out2[i + 6], win[i + 6]);
-            out_ptr += SBLIMIT;
-        }
-        imdct12(out2, ptr + 2);
-        for(i=0;i<6;i++) {
-            buf[i + 6*0] = MULH(out2[i], win[i]) + buf[i + 6*0];
-            buf[i + 6*1] = MULH(out2[i + 6], win[i + 6]);
-            buf[i + 6*2] = 0;
-        }
-        ptr += 18;
-        buf += 18;
-    }
-    /* zero bands */
-    for(j=sblimit;j<SBLIMIT;j++) {
-        /* overlap */
-        out_ptr = sb_samples + j;
-        for(i=0;i<18;i++) {
-            *out_ptr = buf[i];
-            buf[i] = 0;
-            out_ptr += SBLIMIT;
-        }
-        buf += 18;
-    }
-}
-
-#if defined(DEBUG)
-void sample_dump(int fnum, int32_t *tab, int n)
-{
-    static FILE *files[16], *f;
-    char buf[512];
-    int i;
-    int32_t v;
-    
-    f = files[fnum];
-    if (!f) {
-        snprintf(buf, sizeof(buf), "/tmp/out%d.%s.pcm", 
-                fnum, 
-#ifdef USE_HIGHPRECISION
-                "hp"
-#else
-                "lp"
-#endif
-                );
-        f = fopen(buf, "w");
-        if (!f)
-            return;
-        files[fnum] = f;
-    }
-    
-    if (fnum == 0) {
-        static int pos = 0;
-        av_log(NULL, AV_LOG_DEBUG, "pos=%d\n", pos);
-        for(i=0;i<n;i++) {
-            av_log(NULL, AV_LOG_DEBUG, " %0.4f", (double)tab[i] / FRAC_ONE);
-            if ((i % 18) == 17)
-                av_log(NULL, AV_LOG_DEBUG, "\n");
-        }
-        pos += n;
-    }
-    for(i=0;i<n;i++) {
-        /* normalize to 23 frac bits */
-        v = tab[i] << (23 - FRAC_BITS);
-        fwrite(&v, 1, sizeof(int32_t), f);
-    }
-}
-#endif
-
-
-/* main layer3 decoding function */
-static int mp_decode_layer3(MPADecodeContext *s)
-{
-    int nb_granules, main_data_begin, private_bits;
-    int gr, ch, blocksplit_flag, i, j, k, n, bits_pos, bits_left;
-    GranuleDef granules[2][2], *g;
-    int16_t exponents[576];
-
-    /* read side info */
-    if (s->lsf) {
-        main_data_begin = get_bits(&s->gb, 8);
-        if (s->nb_channels == 2)
-            private_bits = get_bits(&s->gb, 2);
-        else
-            private_bits = get_bits(&s->gb, 1);
-        nb_granules = 1;
-    } else {
-        main_data_begin = get_bits(&s->gb, 9);
-        if (s->nb_channels == 2)
-            private_bits = get_bits(&s->gb, 3);
-        else
-            private_bits = get_bits(&s->gb, 5);
-        nb_granules = 2;
-        for(ch=0;ch<s->nb_channels;ch++) {
-            granules[ch][0].scfsi = 0; /* all scale factors are transmitted */
-            granules[ch][1].scfsi = get_bits(&s->gb, 4);
-        }
-    }
-    
-    for(gr=0;gr<nb_granules;gr++) {
-        for(ch=0;ch<s->nb_channels;ch++) {
-            dprintf("gr=%d ch=%d: side_info\n", gr, ch);
-            g = &granules[ch][gr];
-            g->part2_3_length = get_bits(&s->gb, 12);
-            g->big_values = get_bits(&s->gb, 9);
-            g->global_gain = get_bits(&s->gb, 8);
-            /* if MS stereo only is selected, we precompute the
-               1/sqrt(2) renormalization factor */
-            if ((s->mode_ext & (MODE_EXT_MS_STEREO | MODE_EXT_I_STEREO)) == 
-                MODE_EXT_MS_STEREO)
-                g->global_gain -= 2;
-            if (s->lsf)
-                g->scalefac_compress = get_bits(&s->gb, 9);
-            else
-                g->scalefac_compress = get_bits(&s->gb, 4);
-            blocksplit_flag = get_bits(&s->gb, 1);
-            if (blocksplit_flag) {
-                g->block_type = get_bits(&s->gb, 2);
-                if (g->block_type == 0)
-                    return -1;
-                g->switch_point = get_bits(&s->gb, 1);
-                for(i=0;i<2;i++)
-                    g->table_select[i] = get_bits(&s->gb, 5);
-                for(i=0;i<3;i++) 
-                    g->subblock_gain[i] = get_bits(&s->gb, 3);
-                /* compute huffman coded region sizes */
-                if (g->block_type == 2)
-                    g->region_size[0] = (36 / 2);
-                else {
-                    if (s->sample_rate_index <= 2) 
-                        g->region_size[0] = (36 / 2);
-                    else if (s->sample_rate_index != 8) 
-                        g->region_size[0] = (54 / 2);
-                    else
-                        g->region_size[0] = (108 / 2);
-                }
-                g->region_size[1] = (576 / 2);
-            } else {
-                int region_address1, region_address2, l;
-                g->block_type = 0;
-                g->switch_point = 0;
-                for(i=0;i<3;i++)
-                    g->table_select[i] = get_bits(&s->gb, 5);
-                /* compute huffman coded region sizes */
-                region_address1 = get_bits(&s->gb, 4);
-                region_address2 = get_bits(&s->gb, 3);
-                dprintf("region1=%d region2=%d\n", 
-                        region_address1, region_address2);
-                g->region_size[0] = 
-                    band_index_long[s->sample_rate_index][region_address1 + 1] >> 1;
-                l = region_address1 + region_address2 + 2;
-                /* should not overflow */
-                if (l > 22)
-                    l = 22;
-                g->region_size[1] = 
-                    band_index_long[s->sample_rate_index][l] >> 1;
-            }
-            /* convert region offsets to region sizes and truncate
-               size to big_values */
-            g->region_size[2] = (576 / 2);
-            j = 0;
-            for(i=0;i<3;i++) {
-                k = g->region_size[i];
-                if (k > g->big_values)
-                    k = g->big_values;
-                g->region_size[i] = k - j;
-                j = k;
-            }
-
-            /* compute band indexes */
-            if (g->block_type == 2) {
-                if (g->switch_point) {
-                    /* if switched mode, we handle the 36 first samples as
-                       long blocks.  For 8000Hz, we handle the 48 first
-                       exponents as long blocks (XXX: check this!) */
-                    if (s->sample_rate_index <= 2)
-                        g->long_end = 8;
-                    else if (s->sample_rate_index != 8)
-                        g->long_end = 6;
-                    else
-                        g->long_end = 4; /* 8000 Hz */
-                    
-                    if (s->sample_rate_index != 8)
-                        g->short_start = 3;
-                    else
-                        g->short_start = 2; 
-                } else {
-                    g->long_end = 0;
-                    g->short_start = 0;
-                }
-            } else {
-                g->short_start = 13;
-                g->long_end = 22;
-            }
-            
-            g->preflag = 0;
-            if (!s->lsf)
-                g->preflag = get_bits(&s->gb, 1);
-            g->scalefac_scale = get_bits(&s->gb, 1);
-            g->count1table_select = get_bits(&s->gb, 1);
-            dprintf("block_type=%d switch_point=%d\n",
-                    g->block_type, g->switch_point);
-        }
-    }
-
-  if (!s->adu_mode) {
-    /* now we get bits from the main_data_begin offset */
-    dprintf("seekback: %d\n", main_data_begin);
-    seek_to_maindata(s, main_data_begin);
-  }
-
-    for(gr=0;gr<nb_granules;gr++) {
-        for(ch=0;ch<s->nb_channels;ch++) {
-            g = &granules[ch][gr];
-            
-            bits_pos = get_bits_count(&s->gb);
-            
-            if (!s->lsf) {
-                uint8_t *sc;
-                int slen, slen1, slen2;
-
-                /* MPEG1 scale factors */
-                slen1 = slen_table[0][g->scalefac_compress];
-                slen2 = slen_table[1][g->scalefac_compress];
-                dprintf("slen1=%d slen2=%d\n", slen1, slen2);
-                if (g->block_type == 2) {
-                    n = g->switch_point ? 17 : 18;
-                    j = 0;
-                    for(i=0;i<n;i++)
-                        g->scale_factors[j++] = get_bitsz(&s->gb, slen1);
-                    for(i=0;i<18;i++)
-                        g->scale_factors[j++] = get_bitsz(&s->gb, slen2);
-                    for(i=0;i<3;i++)
-                        g->scale_factors[j++] = 0;
-                } else {
-                    sc = granules[ch][0].scale_factors;
-                    j = 0;
-                    for(k=0;k<4;k++) {
-                        n = (k == 0 ? 6 : 5);
-                        if ((g->scfsi & (0x8 >> k)) == 0) {
-                            slen = (k < 2) ? slen1 : slen2;
-                            for(i=0;i<n;i++)
-                                g->scale_factors[j++] = get_bitsz(&s->gb, slen);
-                        } else {
-                            /* simply copy from last granule */
-                            for(i=0;i<n;i++) {
-                                g->scale_factors[j] = sc[j];
-                                j++;
-                            }
-                        }
-                    }
-                    g->scale_factors[j++] = 0;
-                }
-#if defined(DEBUG)
-                {
-                    printf("scfsi=%x gr=%d ch=%d scale_factors:\n", 
-                           g->scfsi, gr, ch);
-                    for(i=0;i<j;i++)
-                        printf(" %d", g->scale_factors[i]);
-                    printf("\n");
-                }
-#endif
-            } else {
-                int tindex, tindex2, slen[4], sl, sf;
-
-                /* LSF scale factors */
-                if (g->block_type == 2) {
-                    tindex = g->switch_point ? 2 : 1;
-                } else {
-                    tindex = 0;
-                }
-                sf = g->scalefac_compress;
-                if ((s->mode_ext & MODE_EXT_I_STEREO) && ch == 1) {
-                    /* intensity stereo case */
-                    sf >>= 1;
-                    if (sf < 180) {
-                        lsf_sf_expand(slen, sf, 6, 6, 0);
-                        tindex2 = 3;
-                    } else if (sf < 244) {
-                        lsf_sf_expand(slen, sf - 180, 4, 4, 0);
-                        tindex2 = 4;
-                    } else {
-                        lsf_sf_expand(slen, sf - 244, 3, 0, 0);
-                        tindex2 = 5;
-                    }
-                } else {
-                    /* normal case */
-                    if (sf < 400) {
-                        lsf_sf_expand(slen, sf, 5, 4, 4);
-                        tindex2 = 0;
-                    } else if (sf < 500) {
-                        lsf_sf_expand(slen, sf - 400, 5, 4, 0);
-                        tindex2 = 1;
-                    } else {
-                        lsf_sf_expand(slen, sf - 500, 3, 0, 0);
-                        tindex2 = 2;
-                        g->preflag = 1;
-                    }
-                }
-
-                j = 0;
-                for(k=0;k<4;k++) {
-                    n = lsf_nsf_table[tindex2][tindex][k];
-                    sl = slen[k];
-                    for(i=0;i<n;i++)
-                        g->scale_factors[j++] = get_bitsz(&s->gb, sl);
-                }
-                /* XXX: should compute exact size */
-                for(;j<40;j++)
-                    g->scale_factors[j] = 0;
-#if defined(DEBUG)
-                {
-                    printf("gr=%d ch=%d scale_factors:\n", 
-                           gr, ch);
-                    for(i=0;i<40;i++)
-                        printf(" %d", g->scale_factors[i]);
-                    printf("\n");
-                }
-#endif
-            }
-
-            exponents_from_scale_factors(s, g, exponents);
-
-            /* read Huffman coded residue */
-            if (huffman_decode(s, g, exponents,
-                               bits_pos + g->part2_3_length) < 0)
-                return -1;
-#if defined(DEBUG)
-            sample_dump(0, g->sb_hybrid, 576);
-#endif
-
-            /* skip extension bits */
-            bits_left = g->part2_3_length - (get_bits_count(&s->gb) - bits_pos);
-            if (bits_left < 0) {
-                dprintf("bits_left=%d\n", bits_left);
-                return -1;
-            }
-            while (bits_left >= 16) {
-                skip_bits(&s->gb, 16);
-                bits_left -= 16;
-            }
-            if (bits_left > 0)
-                skip_bits(&s->gb, bits_left);
-        } /* ch */
-
-        if (s->nb_channels == 2)
-            compute_stereo(s, &granules[0][gr], &granules[1][gr]);
-
-        for(ch=0;ch<s->nb_channels;ch++) {
-            g = &granules[ch][gr];
-
-            reorder_block(s, g);
-#if defined(DEBUG)
-            sample_dump(0, g->sb_hybrid, 576);
-#endif
-            s->compute_antialias(s, g);
-#if defined(DEBUG)
-            sample_dump(1, g->sb_hybrid, 576);
-#endif
-            compute_imdct(s, g, &s->sb_samples[ch][18 * gr][0], s->mdct_buf[ch]); 
-#if defined(DEBUG)
-            sample_dump(2, &s->sb_samples[ch][18 * gr][0], 576);
-#endif
-        }
-    } /* gr */
-    return nb_granules * 18;
-}
-
-static int mp_decode_frame(MPADecodeContext *s, 
-                           OUT_INT *samples)
-{
-    int i, nb_frames, ch;
-    OUT_INT *samples_ptr;
-
-    init_get_bits(&s->gb, s->inbuf + HEADER_SIZE, 
-                  (s->inbuf_ptr - s->inbuf - HEADER_SIZE)*8);
-    
-    /* skip error protection field */
-    if (s->error_protection)
-        get_bits(&s->gb, 16);
-
-    dprintf("frame %d:\n", s->frame_count);
-    switch(s->layer) {
-    case 1:
-        nb_frames = mp_decode_layer1(s);
-        break;
-    case 2:
-        nb_frames = mp_decode_layer2(s);
-        break;
-    case 3:
-    default:
-        nb_frames = mp_decode_layer3(s);
-        break;
-    }
-#if defined(DEBUG)
-    for(i=0;i<nb_frames;i++) {
-        for(ch=0;ch<s->nb_channels;ch++) {
-            int j;
-            printf("%d-%d:", i, ch);
-            for(j=0;j<SBLIMIT;j++)
-                printf(" %0.6f", (double)s->sb_samples[ch][i][j] / FRAC_ONE);
-            printf("\n");
-        }
-    }
-#endif
-    /* apply the synthesis filter */
-    for(ch=0;ch<s->nb_channels;ch++) {
-        samples_ptr = samples + ch;
-        for(i=0;i<nb_frames;i++) {
-            ff_mpa_synth_filter(s->synth_buf[ch], &(s->synth_buf_offset[ch]),
-			 window, &s->dither_state,
-			 samples_ptr, s->nb_channels,
-                         s->sb_samples[ch][i]);
-            samples_ptr += 32 * s->nb_channels;
-        }
-    }
-#ifdef DEBUG
-    s->frame_count++;        
-#endif
-    return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels;
-}
-
-static int decode_frame(AVCodecContext * avctx,
-			void *data, int *data_size,
-			uint8_t * buf, int buf_size)
-{
-    MPADecodeContext *s = avctx->priv_data;
-    uint32_t header;
-    uint8_t *buf_ptr;
-    int len, out_size;
-    OUT_INT *out_samples = data;
-
-    buf_ptr = buf;
-    while (buf_size > 0) {
-	len = s->inbuf_ptr - s->inbuf;
-	if (s->frame_size == 0) {
-            /* special case for next header for first frame in free
-               format case (XXX: find a simpler method) */
-            if (s->free_format_next_header != 0) {
-                s->inbuf[0] = s->free_format_next_header >> 24;
-                s->inbuf[1] = s->free_format_next_header >> 16;
-                s->inbuf[2] = s->free_format_next_header >> 8;
-                s->inbuf[3] = s->free_format_next_header;
-                s->inbuf_ptr = s->inbuf + 4;
-                s->free_format_next_header = 0;
-                goto got_header;
-            }
-	    /* no header seen : find one. We need at least HEADER_SIZE
-               bytes to parse it */
-	    len = HEADER_SIZE - len;
-	    if (len > buf_size)
-		len = buf_size;
-	    if (len > 0) {
-		memcpy(s->inbuf_ptr, buf_ptr, len);
-		buf_ptr += len;
-		buf_size -= len;
-		s->inbuf_ptr += len;
-	    }
-	    if ((s->inbuf_ptr - s->inbuf) >= HEADER_SIZE) {
-            got_header:
-		header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
-		    (s->inbuf[2] << 8) | s->inbuf[3];
-
-		if (ff_mpa_check_header(header) < 0) {
-		    /* no sync found : move by one byte (inefficient, but simple!) */
-		    memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
-		    s->inbuf_ptr--;
-                    dprintf("skip %x\n", header);
-                    /* reset free format frame size to give a chance
-                       to get a new bitrate */
-                    s->free_format_frame_size = 0;
-		} else {
-		    if (decode_header(s, header) == 1) {
-                        /* free format: prepare to compute frame size */
-			s->frame_size = -1;
-                    }
-                    /* update codec info */
-                    avctx->sample_rate = s->sample_rate;
-                    avctx->channels = s->nb_channels;
-                    avctx->bit_rate = s->bit_rate;
-                    avctx->sub_id = s->layer;
-                    switch(s->layer) {
-                    case 1:
-                        avctx->frame_size = 384;
-                        break;
-                    case 2:
-                        avctx->frame_size = 1152;
-                        break;
-                    case 3:
-                        if (s->lsf)
-                            avctx->frame_size = 576;
-                        else
-                            avctx->frame_size = 1152;
-                        break;
-                    }
-		}
-	    }
-        } else if (s->frame_size == -1) {
-            /* free format : find next sync to compute frame size */
-	    len = MPA_MAX_CODED_FRAME_SIZE - len;
-	    if (len > buf_size)
-		len = buf_size;
-            if (len == 0) {
-		/* frame too long: resync */
-                s->frame_size = 0;
-		memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
-		s->inbuf_ptr--;
-            } else {
-                uint8_t *p, *pend;
-                uint32_t header1;
-                int padding;
-
-                memcpy(s->inbuf_ptr, buf_ptr, len);
-                /* check for header */
-                p = s->inbuf_ptr - 3;
-                pend = s->inbuf_ptr + len - 4;
-                while (p <= pend) {
-                    header = (p[0] << 24) | (p[1] << 16) |
-                        (p[2] << 8) | p[3];
-                    header1 = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
-                        (s->inbuf[2] << 8) | s->inbuf[3];
-                    /* check with high probability that we have a
-                       valid header */
-                    if ((header & SAME_HEADER_MASK) ==
-                        (header1 & SAME_HEADER_MASK)) {
-                        /* header found: update pointers */
-                        len = (p + 4) - s->inbuf_ptr;
-                        buf_ptr += len;
-                        buf_size -= len;
-                        s->inbuf_ptr = p;
-                        /* compute frame size */
-                        s->free_format_next_header = header;
-                        s->free_format_frame_size = s->inbuf_ptr - s->inbuf;
-                        padding = (header1 >> 9) & 1;
-                        if (s->layer == 1)
-                            s->free_format_frame_size -= padding * 4;
-                        else
-                            s->free_format_frame_size -= padding;
-                        dprintf("free frame size=%d padding=%d\n", 
-                                s->free_format_frame_size, padding);
-                        decode_header(s, header1);
-                        goto next_data;
-                    }
-                    p++;
-                }
-                /* not found: simply increase pointers */
-                buf_ptr += len;
-                s->inbuf_ptr += len;
-                buf_size -= len;
-            }
-	} else if (len < s->frame_size) {
-            if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)
-                s->frame_size = MPA_MAX_CODED_FRAME_SIZE;
-	    len = s->frame_size - len;
-	    if (len > buf_size)
-		len = buf_size;
-	    memcpy(s->inbuf_ptr, buf_ptr, len);
-	    buf_ptr += len;
-	    s->inbuf_ptr += len;
-	    buf_size -= len;
-	}
-    next_data:
-        if (s->frame_size > 0 && 
-            (s->inbuf_ptr - s->inbuf) >= s->frame_size) {
-            if (avctx->parse_only) {
-                /* simply return the frame data */
-                *(uint8_t **)data = s->inbuf;
-                out_size = s->inbuf_ptr - s->inbuf;
-            } else {
-                out_size = mp_decode_frame(s, out_samples);
-            }
-	    s->inbuf_ptr = s->inbuf;
-	    s->frame_size = 0;
-            if(out_size>=0)
-	        *data_size = out_size;
-            else
-                av_log(avctx, AV_LOG_DEBUG, "Error while decoding mpeg audio frame\n"); //FIXME return -1 / but also return the number of bytes consumed
-	    break;
-	}
-    }
-    return buf_ptr - buf;
-}
-
-
-static int decode_frame_adu(AVCodecContext * avctx,
-			void *data, int *data_size,
-			uint8_t * buf, int buf_size)
-{
-    MPADecodeContext *s = avctx->priv_data;
-    uint32_t header;
-    int len, out_size;
-    OUT_INT *out_samples = data;
-
-    len = buf_size;
-
-    // Discard too short frames
-    if (buf_size < HEADER_SIZE) {
-        *data_size = 0;
-        return buf_size;
-    }
-
-
-    if (len > MPA_MAX_CODED_FRAME_SIZE)
-        len = MPA_MAX_CODED_FRAME_SIZE;
-
-    memcpy(s->inbuf, buf, len);
-    s->inbuf_ptr = s->inbuf + len;
-
-    // Get header and restore sync word
-    header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
-              (s->inbuf[2] << 8) | s->inbuf[3] | 0xffe00000;
-
-    if (ff_mpa_check_header(header) < 0) { // Bad header, discard frame
-        *data_size = 0;
-        return buf_size;
-    }
-
-    decode_header(s, header);
-    /* update codec info */
-    avctx->sample_rate = s->sample_rate;
-    avctx->channels = s->nb_channels;
-    avctx->bit_rate = s->bit_rate;
-    avctx->sub_id = s->layer;
-
-    avctx->frame_size=s->frame_size = len;
-
-    if (avctx->parse_only) {
-        /* simply return the frame data */
-        *(uint8_t **)data = s->inbuf;
-        out_size = s->inbuf_ptr - s->inbuf;
-    } else {
-        out_size = mp_decode_frame(s, out_samples);
-    }
-
-    *data_size = out_size;
-    return buf_size;
-}
-
-
-/* Next 3 arrays are indexed by channel config number (passed via codecdata) */
-static int mp3Frames[16] = {0,1,1,2,3,3,4,5,2};   /* number of mp3 decoder instances */
-static int mp3Channels[16] = {0,1,2,3,4,5,6,8,4}; /* total output channels */
-/* offsets into output buffer, assume output order is FL FR BL BR C LFE */
-static int chan_offset[9][5] = {
-    {0},
-    {0},            // C
-    {0},            // FLR
-    {2,0},          // C FLR
-    {2,0,3},        // C FLR BS
-    {4,0,2},        // C FLR BLRS
-    {4,0,2,5},      // C FLR BLRS LFE
-    {4,0,2,6,5},    // C FLR BLRS BLR LFE
-    {0,2}           // FLR BLRS
-};
-
-
-static int decode_init_mp3on4(AVCodecContext * avctx)
-{
-    MP3On4DecodeContext *s = avctx->priv_data;
-    int i;
-
-    if ((avctx->extradata_size < 2) || (avctx->extradata == NULL)) {
-        av_log(avctx, AV_LOG_ERROR, "Codec extradata missing or too short.\n");
-        return -1;
-    }
-
-    s->chan_cfg = (((unsigned char *)avctx->extradata)[1] >> 3) & 0x0f;
-    s->frames = mp3Frames[s->chan_cfg];
-    if(!s->frames) {
-        av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n");
-        return -1;
-    }
-    avctx->channels = mp3Channels[s->chan_cfg];
-
-    /* Init the first mp3 decoder in standard way, so that all tables get builded
-     * We replace avctx->priv_data with the context of the first decoder so that
-     * decode_init() does not have to be changed.
-     * Other decoders will be inited here copying data from the first context
-     */
-    // Allocate zeroed memory for the first decoder context
-    s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext));
-    // Put decoder context in place to make init_decode() happy
-    avctx->priv_data = s->mp3decctx[0];
-    decode_init(avctx);
-    // Restore mp3on4 context pointer
-    avctx->priv_data = s;
-    s->mp3decctx[0]->adu_mode = 1; // Set adu mode
-
-    /* Create a separate codec/context for each frame (first is already ok).
-     * Each frame is 1 or 2 channels - up to 5 frames allowed
-     */
-    for (i = 1; i < s->frames; i++) {
-        s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext));
-        s->mp3decctx[i]->compute_antialias = s->mp3decctx[0]->compute_antialias;
-        s->mp3decctx[i]->inbuf = &s->mp3decctx[i]->inbuf1[0][BACKSTEP_SIZE];
-        s->mp3decctx[i]->inbuf_ptr = s->mp3decctx[i]->inbuf;
-        s->mp3decctx[i]->adu_mode = 1;
-    }
-
-    return 0;
-}
-
-
-static int decode_close_mp3on4(AVCodecContext * avctx)
-{
-    MP3On4DecodeContext *s = avctx->priv_data;
-    int i;
-
-    for (i = 0; i < s->frames; i++)
-        if (s->mp3decctx[i])
-            av_free(s->mp3decctx[i]);
-
-    return 0;
-}
-
-
-static int decode_frame_mp3on4(AVCodecContext * avctx,
-			void *data, int *data_size,
-			uint8_t * buf, int buf_size)
-{
-    MP3On4DecodeContext *s = avctx->priv_data;
-    MPADecodeContext *m;
-    int len, out_size = 0;
-    uint32_t header;
-    OUT_INT *out_samples = data;
-    OUT_INT decoded_buf[MPA_FRAME_SIZE * MPA_MAX_CHANNELS];
-    OUT_INT *outptr, *bp;
-    int fsize;
-    unsigned char *start2 = buf, *start;
-    int fr, i, j, n;
-    int off = avctx->channels;
-    int *coff = chan_offset[s->chan_cfg];
-
-    len = buf_size;
-
-    // Discard too short frames
-    if (buf_size < HEADER_SIZE) {
-        *data_size = 0;
-        return buf_size;
-    }
-
-    // If only one decoder interleave is not needed
-    outptr = s->frames == 1 ? out_samples : decoded_buf;
-
-    for (fr = 0; fr < s->frames; fr++) {
-        start = start2;
-        fsize = (start[0] << 4) | (start[1] >> 4);
-        start2 += fsize;
-        if (fsize > len)
-            fsize = len;
-        len -= fsize;
-        if (fsize > MPA_MAX_CODED_FRAME_SIZE)
-            fsize = MPA_MAX_CODED_FRAME_SIZE;
-        m = s->mp3decctx[fr];
-        assert (m != NULL);
-        /* copy original to new */
-        m->inbuf_ptr = m->inbuf + fsize;
-        memcpy(m->inbuf, start, fsize);
-
-        // Get header
-        header = (m->inbuf[0] << 24) | (m->inbuf[1] << 16) |
-                  (m->inbuf[2] << 8) | m->inbuf[3] | 0xfff00000;
-
-        if (ff_mpa_check_header(header) < 0) { // Bad header, discard block
-            *data_size = 0;
-            return buf_size;
-        }
-
-        decode_header(m, header);
-        mp_decode_frame(m, decoded_buf);
-
-        n = MPA_FRAME_SIZE * m->nb_channels;
-        out_size += n * sizeof(OUT_INT);
-        if(s->frames > 1) {
-            /* interleave output data */
-            bp = out_samples + coff[fr];
-            if(m->nb_channels == 1) {
-                for(j = 0; j < n; j++) {
-                    *bp = decoded_buf[j];
-                    bp += off;
-                }
-            } else {
-                for(j = 0; j < n; j++) {
-                    bp[0] = decoded_buf[j++];
-                    bp[1] = decoded_buf[j];
-                    bp += off;
-                }
-            }
-        }
-    }
-
-    /* update codec info */
-    avctx->sample_rate = s->mp3decctx[0]->sample_rate;
-    avctx->frame_size= buf_size;
-    avctx->bit_rate = 0;
-    for (i = 0; i < s->frames; i++)
-        avctx->bit_rate += s->mp3decctx[i]->bit_rate;
-
-    *data_size = out_size;
-    return buf_size;
-}
-
-
-AVCodec mp2_decoder =
-{
-    "mp2",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_MP2,
-    sizeof(MPADecodeContext),
-    decode_init,
-    NULL,
-    NULL,
-    decode_frame,
-    CODEC_CAP_PARSE_ONLY,
-};
-
-AVCodec mp3_decoder =
-{
-    "mp3",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_MP3,
-    sizeof(MPADecodeContext),
-    decode_init,
-    NULL,
-    NULL,
-    decode_frame,
-    CODEC_CAP_PARSE_ONLY,
-};
-
-AVCodec mp3adu_decoder =
-{
-    "mp3adu",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_MP3ADU,
-    sizeof(MPADecodeContext),
-    decode_init,
-    NULL,
-    NULL,
-    decode_frame_adu,
-    CODEC_CAP_PARSE_ONLY,
-};
-
-AVCodec mp3on4_decoder =
-{
-    "mp3on4",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_MP3ON4,
-    sizeof(MP3On4DecodeContext),
-    decode_init_mp3on4,
-    NULL,
-    decode_close_mp3on4,
-    decode_frame_mp3on4,
-    0
-};
diff --git a/ffmpeg.src/libavcodec/mpegaudiodectab.h b/ffmpeg.src/libavcodec/mpegaudiodectab.h
deleted file mode 100644
index a60edb6..0000000
--- a/ffmpeg.src/libavcodec/mpegaudiodectab.h
+++ /dev/null
@@ -1,774 +0,0 @@
-/**
- * @file mpegaudiodectab.h
- * mpeg audio layer decoder tables. 
- */
-
-const uint16_t mpa_bitrate_tab[2][3][15] = {
-    { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 },
-      {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 },
-      {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } },
-    { {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256},
-      {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160},
-      {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}
-    }
-};
-
-const uint16_t mpa_freq_tab[3] = { 44100, 48000, 32000 };
-
-/*******************************************************/
-/* half mpeg encoding window (full precision) */
-const int32_t mpa_enwindow[257] = {
-     0,    -1,    -1,    -1,    -1,    -1,    -1,    -2,
-    -2,    -2,    -2,    -3,    -3,    -4,    -4,    -5,
-    -5,    -6,    -7,    -7,    -8,    -9,   -10,   -11,
-   -13,   -14,   -16,   -17,   -19,   -21,   -24,   -26,
-   -29,   -31,   -35,   -38,   -41,   -45,   -49,   -53,
-   -58,   -63,   -68,   -73,   -79,   -85,   -91,   -97,
-  -104,  -111,  -117,  -125,  -132,  -139,  -147,  -154,
-  -161,  -169,  -176,  -183,  -190,  -196,  -202,  -208,
-   213,   218,   222,   225,   227,   228,   228,   227,
-   224,   221,   215,   208,   200,   189,   177,   163,
-   146,   127,   106,    83,    57,    29,    -2,   -36,
-   -72,  -111,  -153,  -197,  -244,  -294,  -347,  -401,
-  -459,  -519,  -581,  -645,  -711,  -779,  -848,  -919,
-  -991, -1064, -1137, -1210, -1283, -1356, -1428, -1498,
- -1567, -1634, -1698, -1759, -1817, -1870, -1919, -1962,
- -2001, -2032, -2057, -2075, -2085, -2087, -2080, -2063,
-  2037,  2000,  1952,  1893,  1822,  1739,  1644,  1535,
-  1414,  1280,  1131,   970,   794,   605,   402,   185,
-   -45,  -288,  -545,  -814, -1095, -1388, -1692, -2006,
- -2330, -2663, -3004, -3351, -3705, -4063, -4425, -4788,
- -5153, -5517, -5879, -6237, -6589, -6935, -7271, -7597,
- -7910, -8209, -8491, -8755, -8998, -9219, -9416, -9585,
- -9727, -9838, -9916, -9959, -9966, -9935, -9863, -9750,
- -9592, -9389, -9139, -8840, -8492, -8092, -7640, -7134,
-  6574,  5959,  5288,  4561,  3776,  2935,  2037,  1082,
-    70,  -998, -2122, -3300, -4533, -5818, -7154, -8540,
- -9975,-11455,-12980,-14548,-16155,-17799,-19478,-21189,
--22929,-24694,-26482,-28289,-30112,-31947,-33791,-35640,
--37489,-39336,-41176,-43006,-44821,-46617,-48390,-50137,
--51853,-53534,-55178,-56778,-58333,-59838,-61289,-62684,
--64019,-65290,-66494,-67629,-68692,-69679,-70590,-71420,
--72169,-72835,-73415,-73908,-74313,-74630,-74856,-74992,
- 75038,
-};
-
-/*******************************************************/
-/* layer 2 tables */
-
-const int sblimit_table[5] = { 27 , 30 , 8, 12 , 30 };
-
-const int quant_steps[17] = {
-    3,     5,    7,    9,    15,
-    31,    63,  127,  255,   511,
-    1023,  2047, 4095, 8191, 16383,
-    32767, 65535
-};
-
-/* we use a negative value if grouped */
-const int quant_bits[17] = {
-    -5,  -7,  3, -10, 4, 
-     5,  6,  7,  8,  9,
-    10, 11, 12, 13, 14,
-    15, 16 
-};
-
-/* encoding tables which give the quantization index. Note how it is
-   possible to store them efficiently ! */
-static const unsigned char alloc_table_0[] = {
- 4,  0,  2,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 
- 4,  0,  2,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 
- 4,  0,  2,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 2,  0,  1, 16, 
- 2,  0,  1, 16, 
- 2,  0,  1, 16, 
- 2,  0,  1, 16, 
-};
-
-static const unsigned char alloc_table_1[] = {
- 4,  0,  2,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 
- 4,  0,  2,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 
- 4,  0,  2,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 3,  0,  1,  2,  3,  4,  5, 16, 
- 2,  0,  1, 16, 
- 2,  0,  1, 16, 
- 2,  0,  1, 16, 
- 2,  0,  1, 16, 
- 2,  0,  1, 16, 
- 2,  0,  1, 16, 
- 2,  0,  1, 16, 
-};
-
-static const unsigned char alloc_table_2[] = {
- 4,  0,  1,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 
- 4,  0,  1,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
-};
-
-static const unsigned char alloc_table_3[] = {
- 4,  0,  1,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 
- 4,  0,  1,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
-};
-
-static const unsigned char alloc_table_4[] = {
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 3,  0,  1,  3,  4,  5,  6,  7, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
- 2,  0,  1,  3, 
-};
-
-const unsigned char *alloc_tables[5] = 
-{ alloc_table_0, alloc_table_1, alloc_table_2, alloc_table_3, alloc_table_4, };
-
-/*******************************************************/
-/* layer 3 tables */
-
-/* layer3 scale factor size */
-static const uint8_t slen_table[2][16] = {
-    { 0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 },
-    { 0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3 },
-};
-
-/* number of lsf scale factors for a given size */
-static const uint8_t lsf_nsf_table[6][3][4] = {
-    { {  6,  5,  5, 5 }, {  9,  9,  9, 9 }, {  6,  9,  9, 9 } },
-    { {  6,  5,  7, 3 }, {  9,  9, 12, 6 }, {  6,  9, 12, 6 } },
-    { { 11, 10,  0, 0 }, { 18, 18,  0, 0 }, { 15, 18,  0, 0 } },
-    { {  7,  7,  7, 0 }, { 12, 12, 12, 0 }, {  6, 15, 12, 0 } }, 
-    { {  6,  6,  6, 3 }, { 12,  9,  9, 6 }, {  6, 12,  9, 6 } },
-    { {  8,  8,  5, 0 }, { 15, 12,  9, 0 }, {  6, 18,  9, 0 } },
-};
-
-/* mpegaudio layer 3 huffman tables */
-
-const uint16_t mpa_huffcodes_1[4] = {
- 0x0001, 0x0001, 0x0001, 0x0000,
-};
-
-const uint8_t mpa_huffbits_1[4] = {
-  1,  3,  2,  3,
-};
-
-const uint16_t mpa_huffcodes_2[9] = {
- 0x0001, 0x0002, 0x0001, 0x0003, 0x0001, 0x0001, 0x0003, 0x0002,
- 0x0000,
-};
-
-const uint8_t mpa_huffbits_2[9] = {
-  1,  3,  6,  3,  3,  5,  5,  5,
-  6,
-};
-
-const uint16_t mpa_huffcodes_3[9] = {
- 0x0003, 0x0002, 0x0001, 0x0001, 0x0001, 0x0001, 0x0003, 0x0002,
- 0x0000,
-};
-
-const uint8_t mpa_huffbits_3[9] = {
-  2,  2,  6,  3,  2,  5,  5,  5,
-  6,
-};
-
-const uint16_t mpa_huffcodes_5[16] = {
- 0x0001, 0x0002, 0x0006, 0x0005, 0x0003, 0x0001, 0x0004, 0x0004,
- 0x0007, 0x0005, 0x0007, 0x0001, 0x0006, 0x0001, 0x0001, 0x0000,
-};
-
-const uint8_t mpa_huffbits_5[16] = {
-  1,  3,  6,  7,  3,  3,  6,  7,
-  6,  6,  7,  8,  7,  6,  7,  8,
-};
-
-const uint16_t mpa_huffcodes_6[16] = {
- 0x0007, 0x0003, 0x0005, 0x0001, 0x0006, 0x0002, 0x0003, 0x0002,
- 0x0005, 0x0004, 0x0004, 0x0001, 0x0003, 0x0003, 0x0002, 0x0000,
-};
-
-const uint8_t mpa_huffbits_6[16] = {
-  3,  3,  5,  7,  3,  2,  4,  5,
-  4,  4,  5,  6,  6,  5,  6,  7,
-};
-
-const uint16_t mpa_huffcodes_7[36] = {
- 0x0001, 0x0002, 0x000a, 0x0013, 0x0010, 0x000a, 0x0003, 0x0003,
- 0x0007, 0x000a, 0x0005, 0x0003, 0x000b, 0x0004, 0x000d, 0x0011,
- 0x0008, 0x0004, 0x000c, 0x000b, 0x0012, 0x000f, 0x000b, 0x0002,
- 0x0007, 0x0006, 0x0009, 0x000e, 0x0003, 0x0001, 0x0006, 0x0004,
- 0x0005, 0x0003, 0x0002, 0x0000,
-};
-
-const uint8_t mpa_huffbits_7[36] = {
-  1,  3,  6,  8,  8,  9,  3,  4,
-  6,  7,  7,  8,  6,  5,  7,  8,
-  8,  9,  7,  7,  8,  9,  9,  9,
-  7,  7,  8,  9,  9, 10,  8,  8,
-  9, 10, 10, 10,
-};
-
-const uint16_t mpa_huffcodes_8[36] = {
- 0x0003, 0x0004, 0x0006, 0x0012, 0x000c, 0x0005, 0x0005, 0x0001,
- 0x0002, 0x0010, 0x0009, 0x0003, 0x0007, 0x0003, 0x0005, 0x000e,
- 0x0007, 0x0003, 0x0013, 0x0011, 0x000f, 0x000d, 0x000a, 0x0004,
- 0x000d, 0x0005, 0x0008, 0x000b, 0x0005, 0x0001, 0x000c, 0x0004,
- 0x0004, 0x0001, 0x0001, 0x0000,
-};
-
-const uint8_t mpa_huffbits_8[36] = {
-  2,  3,  6,  8,  8,  9,  3,  2,
-  4,  8,  8,  8,  6,  4,  6,  8,
-  8,  9,  8,  8,  8,  9,  9, 10,
-  8,  7,  8,  9, 10, 10,  9,  8,
-  9,  9, 11, 11,
-};
-
-const uint16_t mpa_huffcodes_9[36] = {
- 0x0007, 0x0005, 0x0009, 0x000e, 0x000f, 0x0007, 0x0006, 0x0004,
- 0x0005, 0x0005, 0x0006, 0x0007, 0x0007, 0x0006, 0x0008, 0x0008,
- 0x0008, 0x0005, 0x000f, 0x0006, 0x0009, 0x000a, 0x0005, 0x0001,
- 0x000b, 0x0007, 0x0009, 0x0006, 0x0004, 0x0001, 0x000e, 0x0004,
- 0x0006, 0x0002, 0x0006, 0x0000,
-};
-
-const uint8_t mpa_huffbits_9[36] = {
-  3,  3,  5,  6,  8,  9,  3,  3,
-  4,  5,  6,  8,  4,  4,  5,  6,
-  7,  8,  6,  5,  6,  7,  7,  8,
-  7,  6,  7,  7,  8,  9,  8,  7,
-  8,  8,  9,  9,
-};
-
-const uint16_t mpa_huffcodes_10[64] = {
- 0x0001, 0x0002, 0x000a, 0x0017, 0x0023, 0x001e, 0x000c, 0x0011,
- 0x0003, 0x0003, 0x0008, 0x000c, 0x0012, 0x0015, 0x000c, 0x0007,
- 0x000b, 0x0009, 0x000f, 0x0015, 0x0020, 0x0028, 0x0013, 0x0006,
- 0x000e, 0x000d, 0x0016, 0x0022, 0x002e, 0x0017, 0x0012, 0x0007,
- 0x0014, 0x0013, 0x0021, 0x002f, 0x001b, 0x0016, 0x0009, 0x0003,
- 0x001f, 0x0016, 0x0029, 0x001a, 0x0015, 0x0014, 0x0005, 0x0003,
- 0x000e, 0x000d, 0x000a, 0x000b, 0x0010, 0x0006, 0x0005, 0x0001,
- 0x0009, 0x0008, 0x0007, 0x0008, 0x0004, 0x0004, 0x0002, 0x0000,
-};
-
-const uint8_t mpa_huffbits_10[64] = {
-  1,  3,  6,  8,  9,  9,  9, 10,
-  3,  4,  6,  7,  8,  9,  8,  8,
-  6,  6,  7,  8,  9, 10,  9,  9,
-  7,  7,  8,  9, 10, 10,  9, 10,
-  8,  8,  9, 10, 10, 10, 10, 10,
-  9,  9, 10, 10, 11, 11, 10, 11,
-  8,  8,  9, 10, 10, 10, 11, 11,
-  9,  8,  9, 10, 10, 11, 11, 11,
-};
-
-const uint16_t mpa_huffcodes_11[64] = {
- 0x0003, 0x0004, 0x000a, 0x0018, 0x0022, 0x0021, 0x0015, 0x000f,
- 0x0005, 0x0003, 0x0004, 0x000a, 0x0020, 0x0011, 0x000b, 0x000a,
- 0x000b, 0x0007, 0x000d, 0x0012, 0x001e, 0x001f, 0x0014, 0x0005,
- 0x0019, 0x000b, 0x0013, 0x003b, 0x001b, 0x0012, 0x000c, 0x0005,
- 0x0023, 0x0021, 0x001f, 0x003a, 0x001e, 0x0010, 0x0007, 0x0005,
- 0x001c, 0x001a, 0x0020, 0x0013, 0x0011, 0x000f, 0x0008, 0x000e,
- 0x000e, 0x000c, 0x0009, 0x000d, 0x000e, 0x0009, 0x0004, 0x0001,
- 0x000b, 0x0004, 0x0006, 0x0006, 0x0006, 0x0003, 0x0002, 0x0000,
-};
-
-const uint8_t mpa_huffbits_11[64] = {
-  2,  3,  5,  7,  8,  9,  8,  9,
-  3,  3,  4,  6,  8,  8,  7,  8,
-  5,  5,  6,  7,  8,  9,  8,  8,
-  7,  6,  7,  9,  8, 10,  8,  9,
-  8,  8,  8,  9,  9, 10,  9, 10,
-  8,  8,  9, 10, 10, 11, 10, 11,
-  8,  7,  7,  8,  9, 10, 10, 10,
-  8,  7,  8,  9, 10, 10, 10, 10,
-};
-
-const uint16_t mpa_huffcodes_12[64] = {
- 0x0009, 0x0006, 0x0010, 0x0021, 0x0029, 0x0027, 0x0026, 0x001a,
- 0x0007, 0x0005, 0x0006, 0x0009, 0x0017, 0x0010, 0x001a, 0x000b,
- 0x0011, 0x0007, 0x000b, 0x000e, 0x0015, 0x001e, 0x000a, 0x0007,
- 0x0011, 0x000a, 0x000f, 0x000c, 0x0012, 0x001c, 0x000e, 0x0005,
- 0x0020, 0x000d, 0x0016, 0x0013, 0x0012, 0x0010, 0x0009, 0x0005,
- 0x0028, 0x0011, 0x001f, 0x001d, 0x0011, 0x000d, 0x0004, 0x0002,
- 0x001b, 0x000c, 0x000b, 0x000f, 0x000a, 0x0007, 0x0004, 0x0001,
- 0x001b, 0x000c, 0x0008, 0x000c, 0x0006, 0x0003, 0x0001, 0x0000,
-};
-
-const uint8_t mpa_huffbits_12[64] = {
-  4,  3,  5,  7,  8,  9,  9,  9,
-  3,  3,  4,  5,  7,  7,  8,  8,
-  5,  4,  5,  6,  7,  8,  7,  8,
-  6,  5,  6,  6,  7,  8,  8,  8,
-  7,  6,  7,  7,  8,  8,  8,  9,
-  8,  7,  8,  8,  8,  9,  8,  9,
-  8,  7,  7,  8,  8,  9,  9, 10,
-  9,  8,  8,  9,  9,  9,  9, 10,
-};
-
-const uint16_t mpa_huffcodes_13[256] = {
- 0x0001, 0x0005, 0x000e, 0x0015, 0x0022, 0x0033, 0x002e, 0x0047,
- 0x002a, 0x0034, 0x0044, 0x0034, 0x0043, 0x002c, 0x002b, 0x0013,
- 0x0003, 0x0004, 0x000c, 0x0013, 0x001f, 0x001a, 0x002c, 0x0021,
- 0x001f, 0x0018, 0x0020, 0x0018, 0x001f, 0x0023, 0x0016, 0x000e,
- 0x000f, 0x000d, 0x0017, 0x0024, 0x003b, 0x0031, 0x004d, 0x0041,
- 0x001d, 0x0028, 0x001e, 0x0028, 0x001b, 0x0021, 0x002a, 0x0010,
- 0x0016, 0x0014, 0x0025, 0x003d, 0x0038, 0x004f, 0x0049, 0x0040,
- 0x002b, 0x004c, 0x0038, 0x0025, 0x001a, 0x001f, 0x0019, 0x000e,
- 0x0023, 0x0010, 0x003c, 0x0039, 0x0061, 0x004b, 0x0072, 0x005b,
- 0x0036, 0x0049, 0x0037, 0x0029, 0x0030, 0x0035, 0x0017, 0x0018,
- 0x003a, 0x001b, 0x0032, 0x0060, 0x004c, 0x0046, 0x005d, 0x0054,
- 0x004d, 0x003a, 0x004f, 0x001d, 0x004a, 0x0031, 0x0029, 0x0011,
- 0x002f, 0x002d, 0x004e, 0x004a, 0x0073, 0x005e, 0x005a, 0x004f,
- 0x0045, 0x0053, 0x0047, 0x0032, 0x003b, 0x0026, 0x0024, 0x000f,
- 0x0048, 0x0022, 0x0038, 0x005f, 0x005c, 0x0055, 0x005b, 0x005a,
- 0x0056, 0x0049, 0x004d, 0x0041, 0x0033, 0x002c, 0x002b, 0x002a,
- 0x002b, 0x0014, 0x001e, 0x002c, 0x0037, 0x004e, 0x0048, 0x0057,
- 0x004e, 0x003d, 0x002e, 0x0036, 0x0025, 0x001e, 0x0014, 0x0010,
- 0x0035, 0x0019, 0x0029, 0x0025, 0x002c, 0x003b, 0x0036, 0x0051,
- 0x0042, 0x004c, 0x0039, 0x0036, 0x0025, 0x0012, 0x0027, 0x000b,
- 0x0023, 0x0021, 0x001f, 0x0039, 0x002a, 0x0052, 0x0048, 0x0050,
- 0x002f, 0x003a, 0x0037, 0x0015, 0x0016, 0x001a, 0x0026, 0x0016,
- 0x0035, 0x0019, 0x0017, 0x0026, 0x0046, 0x003c, 0x0033, 0x0024,
- 0x0037, 0x001a, 0x0022, 0x0017, 0x001b, 0x000e, 0x0009, 0x0007,
- 0x0022, 0x0020, 0x001c, 0x0027, 0x0031, 0x004b, 0x001e, 0x0034,
- 0x0030, 0x0028, 0x0034, 0x001c, 0x0012, 0x0011, 0x0009, 0x0005,
- 0x002d, 0x0015, 0x0022, 0x0040, 0x0038, 0x0032, 0x0031, 0x002d,
- 0x001f, 0x0013, 0x000c, 0x000f, 0x000a, 0x0007, 0x0006, 0x0003,
- 0x0030, 0x0017, 0x0014, 0x0027, 0x0024, 0x0023, 0x0035, 0x0015,
- 0x0010, 0x0017, 0x000d, 0x000a, 0x0006, 0x0001, 0x0004, 0x0002,
- 0x0010, 0x000f, 0x0011, 0x001b, 0x0019, 0x0014, 0x001d, 0x000b,
- 0x0011, 0x000c, 0x0010, 0x0008, 0x0001, 0x0001, 0x0000, 0x0001,
-};
-
-const uint8_t mpa_huffbits_13[256] = {
-  1,  4,  6,  7,  8,  9,  9, 10,
-  9, 10, 11, 11, 12, 12, 13, 13,
-  3,  4,  6,  7,  8,  8,  9,  9,
-  9,  9, 10, 10, 11, 12, 12, 12,
-  6,  6,  7,  8,  9,  9, 10, 10,
-  9, 10, 10, 11, 11, 12, 13, 13,
-  7,  7,  8,  9,  9, 10, 10, 10,
- 10, 11, 11, 11, 11, 12, 13, 13,
-  8,  7,  9,  9, 10, 10, 11, 11,
- 10, 11, 11, 12, 12, 13, 13, 14,
-  9,  8,  9, 10, 10, 10, 11, 11,
- 11, 11, 12, 11, 13, 13, 14, 14,
-  9,  9, 10, 10, 11, 11, 11, 11,
- 11, 12, 12, 12, 13, 13, 14, 14,
- 10,  9, 10, 11, 11, 11, 12, 12,
- 12, 12, 13, 13, 13, 14, 16, 16,
-  9,  8,  9, 10, 10, 11, 11, 12,
- 12, 12, 12, 13, 13, 14, 15, 15,
- 10,  9, 10, 10, 11, 11, 11, 13,
- 12, 13, 13, 14, 14, 14, 16, 15,
- 10, 10, 10, 11, 11, 12, 12, 13,
- 12, 13, 14, 13, 14, 15, 16, 17,
- 11, 10, 10, 11, 12, 12, 12, 12,
- 13, 13, 13, 14, 15, 15, 15, 16,
- 11, 11, 11, 12, 12, 13, 12, 13,
- 14, 14, 15, 15, 15, 16, 16, 16,
- 12, 11, 12, 13, 13, 13, 14, 14,
- 14, 14, 14, 15, 16, 15, 16, 16,
- 13, 12, 12, 13, 13, 13, 15, 14,
- 14, 17, 15, 15, 15, 17, 16, 16,
- 12, 12, 13, 14, 14, 14, 15, 14,
- 15, 15, 16, 16, 19, 18, 19, 16,
-};
-
-const uint16_t mpa_huffcodes_15[256] = {
- 0x0007, 0x000c, 0x0012, 0x0035, 0x002f, 0x004c, 0x007c, 0x006c,
- 0x0059, 0x007b, 0x006c, 0x0077, 0x006b, 0x0051, 0x007a, 0x003f,
- 0x000d, 0x0005, 0x0010, 0x001b, 0x002e, 0x0024, 0x003d, 0x0033,
- 0x002a, 0x0046, 0x0034, 0x0053, 0x0041, 0x0029, 0x003b, 0x0024,
- 0x0013, 0x0011, 0x000f, 0x0018, 0x0029, 0x0022, 0x003b, 0x0030,
- 0x0028, 0x0040, 0x0032, 0x004e, 0x003e, 0x0050, 0x0038, 0x0021,
- 0x001d, 0x001c, 0x0019, 0x002b, 0x0027, 0x003f, 0x0037, 0x005d,
- 0x004c, 0x003b, 0x005d, 0x0048, 0x0036, 0x004b, 0x0032, 0x001d,
- 0x0034, 0x0016, 0x002a, 0x0028, 0x0043, 0x0039, 0x005f, 0x004f,
- 0x0048, 0x0039, 0x0059, 0x0045, 0x0031, 0x0042, 0x002e, 0x001b,
- 0x004d, 0x0025, 0x0023, 0x0042, 0x003a, 0x0034, 0x005b, 0x004a,
- 0x003e, 0x0030, 0x004f, 0x003f, 0x005a, 0x003e, 0x0028, 0x0026,
- 0x007d, 0x0020, 0x003c, 0x0038, 0x0032, 0x005c, 0x004e, 0x0041,
- 0x0037, 0x0057, 0x0047, 0x0033, 0x0049, 0x0033, 0x0046, 0x001e,
- 0x006d, 0x0035, 0x0031, 0x005e, 0x0058, 0x004b, 0x0042, 0x007a,
- 0x005b, 0x0049, 0x0038, 0x002a, 0x0040, 0x002c, 0x0015, 0x0019,
- 0x005a, 0x002b, 0x0029, 0x004d, 0x0049, 0x003f, 0x0038, 0x005c,
- 0x004d, 0x0042, 0x002f, 0x0043, 0x0030, 0x0035, 0x0024, 0x0014,
- 0x0047, 0x0022, 0x0043, 0x003c, 0x003a, 0x0031, 0x0058, 0x004c,
- 0x0043, 0x006a, 0x0047, 0x0036, 0x0026, 0x0027, 0x0017, 0x000f,
- 0x006d, 0x0035, 0x0033, 0x002f, 0x005a, 0x0052, 0x003a, 0x0039,
- 0x0030, 0x0048, 0x0039, 0x0029, 0x0017, 0x001b, 0x003e, 0x0009,
- 0x0056, 0x002a, 0x0028, 0x0025, 0x0046, 0x0040, 0x0034, 0x002b,
- 0x0046, 0x0037, 0x002a, 0x0019, 0x001d, 0x0012, 0x000b, 0x000b,
- 0x0076, 0x0044, 0x001e, 0x0037, 0x0032, 0x002e, 0x004a, 0x0041,
- 0x0031, 0x0027, 0x0018, 0x0010, 0x0016, 0x000d, 0x000e, 0x0007,
- 0x005b, 0x002c, 0x0027, 0x0026, 0x0022, 0x003f, 0x0034, 0x002d,
- 0x001f, 0x0034, 0x001c, 0x0013, 0x000e, 0x0008, 0x0009, 0x0003,
- 0x007b, 0x003c, 0x003a, 0x0035, 0x002f, 0x002b, 0x0020, 0x0016,
- 0x0025, 0x0018, 0x0011, 0x000c, 0x000f, 0x000a, 0x0002, 0x0001,
- 0x0047, 0x0025, 0x0022, 0x001e, 0x001c, 0x0014, 0x0011, 0x001a,
- 0x0015, 0x0010, 0x000a, 0x0006, 0x0008, 0x0006, 0x0002, 0x0000,
-};
-
-const uint8_t mpa_huffbits_15[256] = {
-  3,  4,  5,  7,  7,  8,  9,  9,
-  9, 10, 10, 11, 11, 11, 12, 13,
-  4,  3,  5,  6,  7,  7,  8,  8,
-  8,  9,  9, 10, 10, 10, 11, 11,
-  5,  5,  5,  6,  7,  7,  8,  8,
-  8,  9,  9, 10, 10, 11, 11, 11,
-  6,  6,  6,  7,  7,  8,  8,  9,
-  9,  9, 10, 10, 10, 11, 11, 11,
-  7,  6,  7,  7,  8,  8,  9,  9,
-  9,  9, 10, 10, 10, 11, 11, 11,
-  8,  7,  7,  8,  8,  8,  9,  9,
-  9,  9, 10, 10, 11, 11, 11, 12,
-  9,  7,  8,  8,  8,  9,  9,  9,
-  9, 10, 10, 10, 11, 11, 12, 12,
-  9,  8,  8,  9,  9,  9,  9, 10,
- 10, 10, 10, 10, 11, 11, 11, 12,
-  9,  8,  8,  9,  9,  9,  9, 10,
- 10, 10, 10, 11, 11, 12, 12, 12,
-  9,  8,  9,  9,  9,  9, 10, 10,
- 10, 11, 11, 11, 11, 12, 12, 12,
- 10,  9,  9,  9, 10, 10, 10, 10,
- 10, 11, 11, 11, 11, 12, 13, 12,
- 10,  9,  9,  9, 10, 10, 10, 10,
- 11, 11, 11, 11, 12, 12, 12, 13,
- 11, 10,  9, 10, 10, 10, 11, 11,
- 11, 11, 11, 11, 12, 12, 13, 13,
- 11, 10, 10, 10, 10, 11, 11, 11,
- 11, 12, 12, 12, 12, 12, 13, 13,
- 12, 11, 11, 11, 11, 11, 11, 11,
- 12, 12, 12, 12, 13, 13, 12, 13,
- 12, 11, 11, 11, 11, 11, 11, 12,
- 12, 12, 12, 12, 13, 13, 13, 13,
-};
-
-const uint16_t mpa_huffcodes_16[256] = {
- 0x0001, 0x0005, 0x000e, 0x002c, 0x004a, 0x003f, 0x006e, 0x005d,
- 0x00ac, 0x0095, 0x008a, 0x00f2, 0x00e1, 0x00c3, 0x0178, 0x0011,
- 0x0003, 0x0004, 0x000c, 0x0014, 0x0023, 0x003e, 0x0035, 0x002f,
- 0x0053, 0x004b, 0x0044, 0x0077, 0x00c9, 0x006b, 0x00cf, 0x0009,
- 0x000f, 0x000d, 0x0017, 0x0026, 0x0043, 0x003a, 0x0067, 0x005a,
- 0x00a1, 0x0048, 0x007f, 0x0075, 0x006e, 0x00d1, 0x00ce, 0x0010,
- 0x002d, 0x0015, 0x0027, 0x0045, 0x0040, 0x0072, 0x0063, 0x0057,
- 0x009e, 0x008c, 0x00fc, 0x00d4, 0x00c7, 0x0183, 0x016d, 0x001a,
- 0x004b, 0x0024, 0x0044, 0x0041, 0x0073, 0x0065, 0x00b3, 0x00a4,
- 0x009b, 0x0108, 0x00f6, 0x00e2, 0x018b, 0x017e, 0x016a, 0x0009,
- 0x0042, 0x001e, 0x003b, 0x0038, 0x0066, 0x00b9, 0x00ad, 0x0109,
- 0x008e, 0x00fd, 0x00e8, 0x0190, 0x0184, 0x017a, 0x01bd, 0x0010,
- 0x006f, 0x0036, 0x0034, 0x0064, 0x00b8, 0x00b2, 0x00a0, 0x0085,
- 0x0101, 0x00f4, 0x00e4, 0x00d9, 0x0181, 0x016e, 0x02cb, 0x000a,
- 0x0062, 0x0030, 0x005b, 0x0058, 0x00a5, 0x009d, 0x0094, 0x0105,
- 0x00f8, 0x0197, 0x018d, 0x0174, 0x017c, 0x0379, 0x0374, 0x0008,
- 0x0055, 0x0054, 0x0051, 0x009f, 0x009c, 0x008f, 0x0104, 0x00f9,
- 0x01ab, 0x0191, 0x0188, 0x017f, 0x02d7, 0x02c9, 0x02c4, 0x0007,
- 0x009a, 0x004c, 0x0049, 0x008d, 0x0083, 0x0100, 0x00f5, 0x01aa,
- 0x0196, 0x018a, 0x0180, 0x02df, 0x0167, 0x02c6, 0x0160, 0x000b,
- 0x008b, 0x0081, 0x0043, 0x007d, 0x00f7, 0x00e9, 0x00e5, 0x00db,
- 0x0189, 0x02e7, 0x02e1, 0x02d0, 0x0375, 0x0372, 0x01b7, 0x0004,
- 0x00f3, 0x0078, 0x0076, 0x0073, 0x00e3, 0x00df, 0x018c, 0x02ea,
- 0x02e6, 0x02e0, 0x02d1, 0x02c8, 0x02c2, 0x00df, 0x01b4, 0x0006,
- 0x00ca, 0x00e0, 0x00de, 0x00da, 0x00d8, 0x0185, 0x0182, 0x017d,
- 0x016c, 0x0378, 0x01bb, 0x02c3, 0x01b8, 0x01b5, 0x06c0, 0x0004,
- 0x02eb, 0x00d3, 0x00d2, 0x00d0, 0x0172, 0x017b, 0x02de, 0x02d3,
- 0x02ca, 0x06c7, 0x0373, 0x036d, 0x036c, 0x0d83, 0x0361, 0x0002,
- 0x0179, 0x0171, 0x0066, 0x00bb, 0x02d6, 0x02d2, 0x0166, 0x02c7,
- 0x02c5, 0x0362, 0x06c6, 0x0367, 0x0d82, 0x0366, 0x01b2, 0x0000,
- 0x000c, 0x000a, 0x0007, 0x000b, 0x000a, 0x0011, 0x000b, 0x0009,
- 0x000d, 0x000c, 0x000a, 0x0007, 0x0005, 0x0003, 0x0001, 0x0003,
-};
-
-const uint8_t mpa_huffbits_16[256] = {
-  1,  4,  6,  8,  9,  9, 10, 10,
- 11, 11, 11, 12, 12, 12, 13,  9,
-  3,  4,  6,  7,  8,  9,  9,  9,
- 10, 10, 10, 11, 12, 11, 12,  8,
-  6,  6,  7,  8,  9,  9, 10, 10,
- 11, 10, 11, 11, 11, 12, 12,  9,
-  8,  7,  8,  9,  9, 10, 10, 10,
- 11, 11, 12, 12, 12, 13, 13, 10,
-  9,  8,  9,  9, 10, 10, 11, 11,
- 11, 12, 12, 12, 13, 13, 13,  9,
-  9,  8,  9,  9, 10, 11, 11, 12,
- 11, 12, 12, 13, 13, 13, 14, 10,
- 10,  9,  9, 10, 11, 11, 11, 11,
- 12, 12, 12, 12, 13, 13, 14, 10,
- 10,  9, 10, 10, 11, 11, 11, 12,
- 12, 13, 13, 13, 13, 15, 15, 10,
- 10, 10, 10, 11, 11, 11, 12, 12,
- 13, 13, 13, 13, 14, 14, 14, 10,
- 11, 10, 10, 11, 11, 12, 12, 13,
- 13, 13, 13, 14, 13, 14, 13, 11,
- 11, 11, 10, 11, 12, 12, 12, 12,
- 13, 14, 14, 14, 15, 15, 14, 10,
- 12, 11, 11, 11, 12, 12, 13, 14,
- 14, 14, 14, 14, 14, 13, 14, 11,
- 12, 12, 12, 12, 12, 13, 13, 13,
- 13, 15, 14, 14, 14, 14, 16, 11,
- 14, 12, 12, 12, 13, 13, 14, 14,
- 14, 16, 15, 15, 15, 17, 15, 11,
- 13, 13, 11, 12, 14, 14, 13, 14,
- 14, 15, 16, 15, 17, 15, 14, 11,
-  9,  8,  8,  9,  9, 10, 10, 10,
- 11, 11, 11, 11, 11, 11, 11,  8,
-};
-
-const uint16_t mpa_huffcodes_24[256] = {
- 0x000f, 0x000d, 0x002e, 0x0050, 0x0092, 0x0106, 0x00f8, 0x01b2,
- 0x01aa, 0x029d, 0x028d, 0x0289, 0x026d, 0x0205, 0x0408, 0x0058,
- 0x000e, 0x000c, 0x0015, 0x0026, 0x0047, 0x0082, 0x007a, 0x00d8,
- 0x00d1, 0x00c6, 0x0147, 0x0159, 0x013f, 0x0129, 0x0117, 0x002a,
- 0x002f, 0x0016, 0x0029, 0x004a, 0x0044, 0x0080, 0x0078, 0x00dd,
- 0x00cf, 0x00c2, 0x00b6, 0x0154, 0x013b, 0x0127, 0x021d, 0x0012,
- 0x0051, 0x0027, 0x004b, 0x0046, 0x0086, 0x007d, 0x0074, 0x00dc,
- 0x00cc, 0x00be, 0x00b2, 0x0145, 0x0137, 0x0125, 0x010f, 0x0010,
- 0x0093, 0x0048, 0x0045, 0x0087, 0x007f, 0x0076, 0x0070, 0x00d2,
- 0x00c8, 0x00bc, 0x0160, 0x0143, 0x0132, 0x011d, 0x021c, 0x000e,
- 0x0107, 0x0042, 0x0081, 0x007e, 0x0077, 0x0072, 0x00d6, 0x00ca,
- 0x00c0, 0x00b4, 0x0155, 0x013d, 0x012d, 0x0119, 0x0106, 0x000c,
- 0x00f9, 0x007b, 0x0079, 0x0075, 0x0071, 0x00d7, 0x00ce, 0x00c3,
- 0x00b9, 0x015b, 0x014a, 0x0134, 0x0123, 0x0110, 0x0208, 0x000a,
- 0x01b3, 0x0073, 0x006f, 0x006d, 0x00d3, 0x00cb, 0x00c4, 0x00bb,
- 0x0161, 0x014c, 0x0139, 0x012a, 0x011b, 0x0213, 0x017d, 0x0011,
- 0x01ab, 0x00d4, 0x00d0, 0x00cd, 0x00c9, 0x00c1, 0x00ba, 0x00b1,
- 0x00a9, 0x0140, 0x012f, 0x011e, 0x010c, 0x0202, 0x0179, 0x0010,
- 0x014f, 0x00c7, 0x00c5, 0x00bf, 0x00bd, 0x00b5, 0x00ae, 0x014d,
- 0x0141, 0x0131, 0x0121, 0x0113, 0x0209, 0x017b, 0x0173, 0x000b,
- 0x029c, 0x00b8, 0x00b7, 0x00b3, 0x00af, 0x0158, 0x014b, 0x013a,
- 0x0130, 0x0122, 0x0115, 0x0212, 0x017f, 0x0175, 0x016e, 0x000a,
- 0x028c, 0x015a, 0x00ab, 0x00a8, 0x00a4, 0x013e, 0x0135, 0x012b,
- 0x011f, 0x0114, 0x0107, 0x0201, 0x0177, 0x0170, 0x016a, 0x0006,
- 0x0288, 0x0142, 0x013c, 0x0138, 0x0133, 0x012e, 0x0124, 0x011c,
- 0x010d, 0x0105, 0x0200, 0x0178, 0x0172, 0x016c, 0x0167, 0x0004,
- 0x026c, 0x012c, 0x0128, 0x0126, 0x0120, 0x011a, 0x0111, 0x010a,
- 0x0203, 0x017c, 0x0176, 0x0171, 0x016d, 0x0169, 0x0165, 0x0002,
- 0x0409, 0x0118, 0x0116, 0x0112, 0x010b, 0x0108, 0x0103, 0x017e,
- 0x017a, 0x0174, 0x016f, 0x016b, 0x0168, 0x0166, 0x0164, 0x0000,
- 0x002b, 0x0014, 0x0013, 0x0011, 0x000f, 0x000d, 0x000b, 0x0009,
- 0x0007, 0x0006, 0x0004, 0x0007, 0x0005, 0x0003, 0x0001, 0x0003,
-};
-
-const uint8_t mpa_huffbits_24[256] = {
-  4,  4,  6,  7,  8,  9,  9, 10,
- 10, 11, 11, 11, 11, 11, 12,  9,
-  4,  4,  5,  6,  7,  8,  8,  9,
-  9,  9, 10, 10, 10, 10, 10,  8,
-  6,  5,  6,  7,  7,  8,  8,  9,
-  9,  9,  9, 10, 10, 10, 11,  7,
-  7,  6,  7,  7,  8,  8,  8,  9,
-  9,  9,  9, 10, 10, 10, 10,  7,
-  8,  7,  7,  8,  8,  8,  8,  9,
-  9,  9, 10, 10, 10, 10, 11,  7,
-  9,  7,  8,  8,  8,  8,  9,  9,
-  9,  9, 10, 10, 10, 10, 10,  7,
-  9,  8,  8,  8,  8,  9,  9,  9,
-  9, 10, 10, 10, 10, 10, 11,  7,
- 10,  8,  8,  8,  9,  9,  9,  9,
- 10, 10, 10, 10, 10, 11, 11,  8,
- 10,  9,  9,  9,  9,  9,  9,  9,
-  9, 10, 10, 10, 10, 11, 11,  8,
- 10,  9,  9,  9,  9,  9,  9, 10,
- 10, 10, 10, 10, 11, 11, 11,  8,
- 11,  9,  9,  9,  9, 10, 10, 10,
- 10, 10, 10, 11, 11, 11, 11,  8,
- 11, 10,  9,  9,  9, 10, 10, 10,
- 10, 10, 10, 11, 11, 11, 11,  8,
- 11, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 11, 11, 11, 11, 11,  8,
- 11, 10, 10, 10, 10, 10, 10, 10,
- 11, 11, 11, 11, 11, 11, 11,  8,
- 12, 10, 10, 10, 10, 10, 10, 11,
- 11, 11, 11, 11, 11, 11, 11,  8,
-  8,  7,  7,  7,  7,  7,  7,  7,
-  7,  7,  7,  8,  8,  8,  8,  4,
-};
-
-const HuffTable mpa_huff_tables[16] = {
-{ 1, NULL, NULL },
-{ 2, mpa_huffbits_1, mpa_huffcodes_1 },
-{ 3, mpa_huffbits_2, mpa_huffcodes_2 },
-{ 3, mpa_huffbits_3, mpa_huffcodes_3 },
-{ 4, mpa_huffbits_5, mpa_huffcodes_5 },
-{ 4, mpa_huffbits_6, mpa_huffcodes_6 },
-{ 6, mpa_huffbits_7, mpa_huffcodes_7 },
-{ 6, mpa_huffbits_8, mpa_huffcodes_8 },
-{ 6, mpa_huffbits_9, mpa_huffcodes_9 },
-{ 8, mpa_huffbits_10, mpa_huffcodes_10 },
-{ 8, mpa_huffbits_11, mpa_huffcodes_11 },
-{ 8, mpa_huffbits_12, mpa_huffcodes_12 },
-{ 16, mpa_huffbits_13, mpa_huffcodes_13 },
-{ 16, mpa_huffbits_15, mpa_huffcodes_15 },
-{ 16, mpa_huffbits_16, mpa_huffcodes_16 },
-{ 16, mpa_huffbits_24, mpa_huffcodes_24 },
-};
-
-const uint8_t mpa_huff_data[32][2] = {
-{ 0, 0 },
-{ 1, 0 },
-{ 2, 0 },
-{ 3, 0 },
-{ 0, 0 },
-{ 4, 0 },
-{ 5, 0 },
-{ 6, 0 },
-{ 7, 0 },
-{ 8, 0 },
-{ 9, 0 },
-{ 10, 0 },
-{ 11, 0 },
-{ 12, 0 },
-{ 0, 0 },
-{ 13, 0 },
-{ 14, 1 },
-{ 14, 2 },
-{ 14, 3 },
-{ 14, 4 },
-{ 14, 6 },
-{ 14, 8 },
-{ 14, 10 },
-{ 14, 13 },
-{ 15, 4 },
-{ 15, 5 },
-{ 15, 6 },
-{ 15, 7 },
-{ 15, 8 },
-{ 15, 9 },
-{ 15, 11 },
-{ 15, 13 },
-};
-
-
-/* huffman tables for quadrules */
-static const uint8_t mpa_quad_codes[2][16] = {
-    {  1,  5,  4,  5,  6,  5,  4,  4, 7,  3,  6,  0,  7,  2,  3,  1, },
-    { 15, 14, 13, 12, 11, 10,  9,  8, 7,  6,  5,  4,  3,  2,  1,  0, },
-};
-
-static const uint8_t mpa_quad_bits[2][16] = {
-    { 1, 4, 4, 5, 4, 6, 5, 6, 4, 5, 5, 6, 5, 6, 6, 6, },
-    { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, },
-};
-
-/* band size tables */
-const uint8_t band_size_long[9][22] = {
-{ 4, 4, 4, 4, 4, 4, 6, 6, 8, 8, 10,
-  12, 16, 20, 24, 28, 34, 42, 50, 54, 76, 158, }, /* 44100 */
-{ 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 10,
-  12, 16, 18, 22, 28, 34, 40, 46, 54, 54, 192, }, /* 48000 */
-{ 4, 4, 4, 4, 4, 4, 6, 6, 8, 10, 12,
-  16, 20, 24, 30, 38, 46, 56, 68, 84, 102, 26, }, /* 32000 */
-{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16,
-  20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 22050 */
-{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16,
-  18, 22, 26, 32, 38, 46, 52, 64, 70, 76, 36, }, /* 24000 */
-{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16,
-  20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 16000 */
-{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16,
-  20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 11025 */
-{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16,
-  20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 12000 */
-{ 12, 12, 12, 12, 12, 12, 16, 20, 24, 28, 32,
-  40, 48, 56, 64, 76, 90, 2, 2, 2, 2, 2, }, /* 8000 */
-};
-
-const uint8_t band_size_short[9][13] = {
-{ 4, 4, 4, 4, 6, 8, 10, 12, 14, 18, 22, 30, 56, }, /* 44100 */
-{ 4, 4, 4, 4, 6, 6, 10, 12, 14, 16, 20, 26, 66, }, /* 48000 */
-{ 4, 4, 4, 4, 6, 8, 12, 16, 20, 26, 34, 42, 12, }, /* 32000 */
-{ 4, 4, 4, 6, 6, 8, 10, 14, 18, 26, 32, 42, 18, }, /* 22050 */
-{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 32, 44, 12, }, /* 24000 */
-{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18, }, /* 16000 */
-{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18, }, /* 11025 */
-{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18, }, /* 12000 */
-{ 8, 8, 8, 12, 16, 20, 24, 28, 36, 2, 2, 2, 26, }, /* 8000 */
-};
-
-const uint8_t mpa_pretab[2][22] = {
-    { 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, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0 },
-};
-
-/* table for alias reduction (XXX: store it as integer !) */
-const float ci_table[8] = {
-    -0.6, -0.535, -0.33, -0.185, -0.095, -0.041, -0.0142, -0.0037,
-};
diff --git a/ffmpeg.src/libavcodec/mpegaudiotab.h b/ffmpeg.src/libavcodec/mpegaudiotab.h
deleted file mode 100644
index d2c13ed..0000000
--- a/ffmpeg.src/libavcodec/mpegaudiotab.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * mpeg audio layer 2 tables. Most of them come from the mpeg audio
- * specification.
- * 
- * Copyright (c) 2000, 2001 Fabrice Bellard.
- *
- * The licence of this code is contained in file LICENCE found in the
- * same archive 
- */
-
-/**
- * @file mpegaudiotab.h
- * mpeg audio layer 2 tables. 
- * Most of them come from the mpeg audio specification.
- */
- 
-#define SQRT2 1.41421356237309514547
-
-static const int costab32[30] = {
-    FIX(0.54119610014619701222),
-    FIX(1.3065629648763763537),
-    
-    FIX(0.50979557910415917998),
-    FIX(2.5629154477415054814),
-    FIX(0.89997622313641556513),
-    FIX(0.60134488693504528634),
-    
-    FIX(0.5024192861881556782),
-    FIX(5.1011486186891552563),
-    FIX(0.78815462345125020249),
-    FIX(0.64682178335999007679),
-    FIX(0.56694403481635768927),
-    FIX(1.0606776859903470633),
-    FIX(1.7224470982383341955),
-    FIX(0.52249861493968885462),
-    
-    FIX(10.19000812354803287),
-    FIX(0.674808341455005678),
-    FIX(1.1694399334328846596),
-    FIX(0.53104259108978413284),
-    FIX(2.0577810099534108446),
-    FIX(0.58293496820613388554),
-    FIX(0.83934964541552681272),
-    FIX(0.50547095989754364798),
-    FIX(3.4076084184687189804),
-    FIX(0.62250412303566482475),
-    FIX(0.97256823786196078263),
-    FIX(0.51544730992262455249),
-    FIX(1.4841646163141661852),
-    FIX(0.5531038960344445421),
-    FIX(0.74453627100229857749),
-    FIX(0.5006029982351962726),
-};
-
-static const int bitinv32[32] = {
-    0,  16,  8, 24,  4,  20,  12,  28,
-    2,  18, 10, 26,  6,  22,  14,  30,
-    1,  17,  9, 25,  5,  21,  13,  29,
-    3,  19, 11, 27,  7,  23,  15,  31
-};
-
-
-static int16_t filter_bank[512];
-
-static int scale_factor_table[64];
-#ifdef USE_FLOATS
-static float scale_factor_inv_table[64];
-#else
-static int8_t scale_factor_shift[64];
-static unsigned short scale_factor_mult[64];
-#endif
-static unsigned char scale_diff_table[128];
-
-/* total number of bits per allocation group */
-static unsigned short total_quant_bits[17];
-
-/* signal to noise ratio of each quantification step (could be
-   computed from quant_steps[]). The values are dB multiplied by 10 
-*/
-static const unsigned short quant_snr[17] = { 
-     70, 110, 160, 208,
-    253, 316, 378, 439,
-    499, 559, 620, 680, 
-    740, 800, 861, 920, 
-    980
-};
-
-/* fixed psycho acoustic model. Values of SNR taken from the 'toolame'
-   project */
-static const float fixed_smr[SBLIMIT] =  {
-    30, 17, 16, 10, 3, 12, 8, 2.5,
-    5, 5, 6, 6, 5, 6, 10, 6,
-    -4, -10, -21, -30, -42, -55, -68, -75,
-    -75, -75, -75, -75, -91, -107, -110, -108
-};
-
-static const unsigned char nb_scale_factors[4] = { 3, 2, 1, 2 };
-
diff --git a/ffmpeg.src/libavcodec/mpegvideo.c b/ffmpeg.src/libavcodec/mpegvideo.c
deleted file mode 100644
index 26878a8..0000000
--- a/ffmpeg.src/libavcodec/mpegvideo.c
+++ /dev/null
@@ -1,6565 +0,0 @@
-/*
- * The simplest mpeg encoder (well, it was the simplest!)
- * Copyright (c) 2000,2001 Fabrice Bellard.
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * 4MV & hq & b-frame encoding stuff by Michael Niedermayer <michaelni at gmx.at>
- */
- 
-/**
- * @file mpegvideo.c
- * The simplest mpeg encoder (well, it was the simplest!).
- */ 
- 
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-#include "faandct.h"
-#include <limits.h>
-
-#ifdef USE_FASTMEMCPY
-#include "fastmemcpy.h"
-#endif
-
-//#undef NDEBUG
-//#include <assert.h>
-
-#ifdef CONFIG_ENCODERS
-static void encode_picture(MpegEncContext *s, int picture_number);
-#endif //CONFIG_ENCODERS
-static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s, 
-                                   DCTELEM *block, int n, int qscale);
-static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s, 
-                                   DCTELEM *block, int n, int qscale);
-static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s,
-                                   DCTELEM *block, int n, int qscale);
-static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s,
-                                   DCTELEM *block, int n, int qscale);
-static void dct_unquantize_h263_intra_c(MpegEncContext *s, 
-                                  DCTELEM *block, int n, int qscale);
-static void dct_unquantize_h263_inter_c(MpegEncContext *s, 
-                                  DCTELEM *block, int n, int qscale);
-static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w);
-#ifdef CONFIG_ENCODERS
-static int dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
-static int dct_quantize_trellis_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow);
-static int dct_quantize_refine(MpegEncContext *s, DCTELEM *block, int16_t *weight, DCTELEM *orig, int n, int qscale);
-static int sse_mb(MpegEncContext *s);
-static void  denoise_dct_c(MpegEncContext *s, DCTELEM *block);
-#endif //CONFIG_ENCODERS
-
-#ifdef HAVE_XVMC
-extern int  XVMC_field_start(MpegEncContext*s, AVCodecContext *avctx);
-extern void XVMC_field_end(MpegEncContext *s);
-extern void XVMC_decode_mb(MpegEncContext *s);
-#endif
-
-void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w)= draw_edges_c;
-
-
-/* enable all paranoid tests for rounding, overflows, etc... */
-//#define PARANOID
-
-//#define DEBUG
-
-
-/* for jpeg fast DCT */
-#define CONST_BITS 14
-
-static const uint16_t aanscales[64] = {
-    /* precomputed values scaled up by 14 bits */
-    16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
-    22725, 31521, 29692, 26722, 22725, 17855, 12299,  6270,
-    21407, 29692, 27969, 25172, 21407, 16819, 11585,  5906,
-    19266, 26722, 25172, 22654, 19266, 15137, 10426,  5315,
-    16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
-    12873, 17855, 16819, 15137, 12873, 10114,  6967,  3552,
-    8867 , 12299, 11585, 10426,  8867,  6967,  4799,  2446,
-    4520 ,  6270,  5906,  5315,  4520,  3552,  2446,  1247
-};
-
-static const uint8_t h263_chroma_roundtab[16] = {
-//  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
-    0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
-};
-
-static const uint8_t ff_default_chroma_qscale_table[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, 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
-};
-
-#ifdef CONFIG_ENCODERS
-static uint8_t (*default_mv_penalty)[MAX_MV*2+1]=NULL;
-static uint8_t default_fcode_tab[MAX_MV*2+1];
-
-enum PixelFormat ff_yuv420p_list[2]= {PIX_FMT_YUV420P, -1};
-
-static void convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64],
-                           const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra)
-{
-    int qscale;
-    int shift=0;
-
-    for(qscale=qmin; qscale<=qmax; qscale++){
-        int i;
-        if (dsp->fdct == ff_jpeg_fdct_islow 
-#ifdef FAAN_POSTSCALE
-            || dsp->fdct == ff_faandct
-#endif
-            ) {
-            for(i=0;i<64;i++) {
-                const int j= dsp->idct_permutation[i];
-                /* 16 <= qscale * quant_matrix[i] <= 7905 */
-                /* 19952         <= aanscales[i] * qscale * quant_matrix[i]           <= 249205026 */
-                /* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */
-                /* 3444240       >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */
-                
-                qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) / 
-                                (qscale * quant_matrix[j]));
-            }
-        } else if (dsp->fdct == fdct_ifast
-#ifndef FAAN_POSTSCALE
-                   || dsp->fdct == ff_faandct
-#endif
-                   ) {
-            for(i=0;i<64;i++) {
-                const int j= dsp->idct_permutation[i];
-                /* 16 <= qscale * quant_matrix[i] <= 7905 */
-                /* 19952         <= aanscales[i] * qscale * quant_matrix[i]           <= 249205026 */
-                /* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */
-                /* 3444240       >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */
-                
-                qmat[qscale][i] = (int)((uint64_t_C(1) << (QMAT_SHIFT + 14)) / 
-                                (aanscales[i] * qscale * quant_matrix[j]));
-            }
-        } else {
-            for(i=0;i<64;i++) {
-                const int j= dsp->idct_permutation[i];
-                /* We can safely suppose that 16 <= quant_matrix[i] <= 255
-                   So 16           <= qscale * quant_matrix[i]             <= 7905
-                   so (1<<19) / 16 >= (1<<19) / (qscale * quant_matrix[i]) >= (1<<19) / 7905
-                   so 32768        >= (1<<19) / (qscale * quant_matrix[i]) >= 67
-                */
-                qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j]));
-//                qmat  [qscale][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[i]);
-                qmat16[qscale][0][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[j]);
-
-                if(qmat16[qscale][0][i]==0 || qmat16[qscale][0][i]==128*256) qmat16[qscale][0][i]=128*256-1;
-                qmat16[qscale][1][i]= ROUNDED_DIV(bias<<(16-QUANT_BIAS_SHIFT), qmat16[qscale][0][i]);
-            }
-        }
-        
-        for(i=intra; i<64; i++){
-            int64_t max= 8191;
-            if (dsp->fdct == fdct_ifast
-#ifndef FAAN_POSTSCALE
-                   || dsp->fdct == ff_faandct
-#endif
-                   ) {
-                max= (8191LL*aanscales[i]) >> 14;
-            }
-            while(((max * qmat[qscale][i]) >> shift) > INT_MAX){ 
-                shift++;
-            }
-        }
-    }
-    if(shift){
-        av_log(NULL, AV_LOG_INFO, "Warning, QMAT_SHIFT is larger then %d, overflows possible\n", QMAT_SHIFT - shift);
-    }
-}
-
-static inline void update_qscale(MpegEncContext *s){
-    s->qscale= (s->lambda*139 + FF_LAMBDA_SCALE*64) >> (FF_LAMBDA_SHIFT + 7);
-    s->qscale= clip(s->qscale, s->avctx->qmin, s->avctx->qmax);
-    
-    s->lambda2= (s->lambda*s->lambda + FF_LAMBDA_SCALE/2) >> FF_LAMBDA_SHIFT;
-}
-#endif //CONFIG_ENCODERS
-
-void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable){
-    int i;
-    int end;
-    
-    st->scantable= src_scantable;
-
-    for(i=0; i<64; i++){
-        int j;
-        j = src_scantable[i];
-        st->permutated[i] = permutation[j];
-#ifdef ARCH_POWERPC
-        st->inverse[j] = i;
-#endif
-    }
-    
-    end=-1;
-    for(i=0; i<64; i++){
-        int j;
-        j = st->permutated[i];
-        if(j>end) end=j;
-        st->raster_end[i]= end;
-    }
-}
-
-#ifdef CONFIG_ENCODERS
-void ff_write_quant_matrix(PutBitContext *pb, int16_t *matrix){
-    int i;
-
-    if(matrix){
-        put_bits(pb, 1, 1);
-        for(i=0;i<64;i++) {
-            put_bits(pb, 8, matrix[ ff_zigzag_direct[i] ]);
-        }
-    }else
-        put_bits(pb, 1, 0);
-}
-#endif //CONFIG_ENCODERS
-
-/* init common dct for both encoder and decoder */
-int DCT_common_init(MpegEncContext *s)
-{
-    s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_c;
-    s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_c;
-    s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c;
-    s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_c;
-    s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_c;
-    s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_c;
-
-#ifdef CONFIG_ENCODERS
-    s->dct_quantize= dct_quantize_c;
-    s->denoise_dct= denoise_dct_c;
-#endif //CONFIG_ENCODERS
-        
-#ifdef HAVE_MMX
-    MPV_common_init_mmx(s);
-#endif
-#ifdef ARCH_ALPHA
-    MPV_common_init_axp(s);
-#endif
-#ifdef HAVE_MLIB
-    MPV_common_init_mlib(s);
-#endif
-#ifdef HAVE_MMI
-    MPV_common_init_mmi(s);
-#endif
-#ifdef ARCH_ARMV4L
-    MPV_common_init_armv4l(s);
-#endif
-#ifdef ARCH_POWERPC
-    MPV_common_init_ppc(s);
-#endif
-
-#ifdef CONFIG_ENCODERS
-    s->fast_dct_quantize= s->dct_quantize;
-
-    if(s->flags&CODEC_FLAG_TRELLIS_QUANT){
-        s->dct_quantize= dct_quantize_trellis_c; //move before MPV_common_init_*
-    }
-
-#endif //CONFIG_ENCODERS
-
-    /* load & permutate scantables
-       note: only wmv uses different ones 
-    */
-    if(s->alternate_scan){
-        ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable  , ff_alternate_vertical_scan);
-        ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable  , ff_alternate_vertical_scan);
-    }else{
-        ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable  , ff_zigzag_direct);
-        ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable  , ff_zigzag_direct);
-    }
-    ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
-    ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
-
-    return 0;
-}
-
-static void copy_picture(Picture *dst, Picture *src){
-    *dst = *src;
-    dst->type= FF_BUFFER_TYPE_COPY;
-}
-
-static void copy_picture_attributes(MpegEncContext *s, AVFrame *dst, AVFrame *src){
-    int i;
-
-    dst->pict_type              = src->pict_type;
-    dst->quality                = src->quality;
-    dst->coded_picture_number   = src->coded_picture_number;
-    dst->display_picture_number = src->display_picture_number;
-//    dst->reference              = src->reference;
-    dst->pts                    = src->pts;
-    dst->interlaced_frame       = src->interlaced_frame;
-    dst->top_field_first        = src->top_field_first;
-
-    if(s->avctx->me_threshold){
-        if(!src->motion_val[0])
-            av_log(s->avctx, AV_LOG_ERROR, "AVFrame.motion_val not set!\n");
-        if(!src->mb_type)
-            av_log(s->avctx, AV_LOG_ERROR, "AVFrame.mb_type not set!\n");
-        if(!src->ref_index[0])
-            av_log(s->avctx, AV_LOG_ERROR, "AVFrame.ref_index not set!\n");
-        if(src->motion_subsample_log2 != dst->motion_subsample_log2)
-            av_log(s->avctx, AV_LOG_ERROR, "AVFrame.motion_subsample_log2 doesn't match! (%d!=%d)\n",
-            src->motion_subsample_log2, dst->motion_subsample_log2);
-
-        memcpy(dst->mb_type, src->mb_type, s->mb_stride * s->mb_height * sizeof(dst->mb_type[0]));
-        
-        for(i=0; i<2; i++){
-            int stride= ((16*s->mb_width )>>src->motion_subsample_log2) + 1;
-            int height= ((16*s->mb_height)>>src->motion_subsample_log2);
-
-            if(src->motion_val[i] && src->motion_val[i] != dst->motion_val[i]){
-                memcpy(dst->motion_val[i], src->motion_val[i], 2*stride*height*sizeof(int16_t));
-            }
-            if(src->ref_index[i] && src->ref_index[i] != dst->ref_index[i]){
-                memcpy(dst->ref_index[i], src->ref_index[i], s->b8_stride*2*s->mb_height*sizeof(int8_t));
-            }
-        }
-    }
-}
-
-/**
- * allocates a Picture
- * The pixels are allocated/set by calling get_buffer() if shared=0
- */
-static int alloc_picture(MpegEncContext *s, Picture *pic, int shared){
-    const int big_mb_num= s->mb_stride*(s->mb_height+1) + 1; //the +1 is needed so memset(,,stride*height) doesnt sig11
-    const int mb_array_size= s->mb_stride*s->mb_height;
-    const int b8_array_size= s->b8_stride*s->mb_height*2;
-    const int b4_array_size= s->b4_stride*s->mb_height*4;
-    int i;
-    
-    if(shared){
-        assert(pic->data[0]);
-        assert(pic->type == 0 || pic->type == FF_BUFFER_TYPE_SHARED);
-        pic->type= FF_BUFFER_TYPE_SHARED;
-    }else{
-        int r;
-        
-        assert(!pic->data[0]);
-        
-        r= s->avctx->get_buffer(s->avctx, (AVFrame*)pic);
-        
-        if(r<0 || !pic->age || !pic->type || !pic->data[0]){
-	    av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]);
-            return -1;
-        }
-
-        if(s->linesize && (s->linesize != pic->linesize[0] || s->uvlinesize != pic->linesize[1])){
-            av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n");
-            return -1;
-        }
-
-        if(pic->linesize[1] != pic->linesize[2]){
-            av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (uv stride mismatch)\n");
-            return -1;
-        }
-
-        s->linesize  = pic->linesize[0];
-        s->uvlinesize= pic->linesize[1];
-    }
-    
-    if(pic->qscale_table==NULL){
-        if (s->encoding) {        
-            CHECKED_ALLOCZ(pic->mb_var   , mb_array_size * sizeof(int16_t))
-            CHECKED_ALLOCZ(pic->mc_mb_var, mb_array_size * sizeof(int16_t))
-            CHECKED_ALLOCZ(pic->mb_mean  , mb_array_size * sizeof(int8_t))
-        }
-
-        CHECKED_ALLOCZ(pic->mbskip_table , mb_array_size * sizeof(uint8_t)+2) //the +2 is for the slice end check
-        CHECKED_ALLOCZ(pic->qscale_table , mb_array_size * sizeof(uint8_t))
-        CHECKED_ALLOCZ(pic->mb_type_base , big_mb_num    * sizeof(uint32_t))
-        pic->mb_type= pic->mb_type_base + s->mb_stride+1;
-        if(s->out_format == FMT_H264){
-            for(i=0; i<2; i++){
-                CHECKED_ALLOCZ(pic->motion_val_base[i], 2 * (b4_array_size+4)  * sizeof(int16_t))
-                pic->motion_val[i]= pic->motion_val_base[i]+4;
-                CHECKED_ALLOCZ(pic->ref_index[i], b8_array_size * sizeof(uint8_t))
-            }
-            pic->motion_subsample_log2= 2;
-        }else if(s->out_format == FMT_H263 || s->encoding || (s->avctx->debug&FF_DEBUG_MV) || (s->avctx->debug_mv)){
-            for(i=0; i<2; i++){
-                CHECKED_ALLOCZ(pic->motion_val_base[i], 2 * (b8_array_size+4) * sizeof(int16_t))
-                pic->motion_val[i]= pic->motion_val_base[i]+4;
-                CHECKED_ALLOCZ(pic->ref_index[i], b8_array_size * sizeof(uint8_t))
-            }
-            pic->motion_subsample_log2= 3;
-        }
-        if(s->avctx->debug&FF_DEBUG_DCT_COEFF) {
-            CHECKED_ALLOCZ(pic->dct_coeff, 64 * mb_array_size * sizeof(DCTELEM)*6)
-        }
-        pic->qstride= s->mb_stride;
-        CHECKED_ALLOCZ(pic->pan_scan , 1 * sizeof(AVPanScan))
-    }
-
-    //it might be nicer if the application would keep track of these but it would require a API change
-    memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1);
-    s->prev_pict_types[0]= s->pict_type;
-    if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == B_TYPE)
-        pic->age= INT_MAX; // skipped MBs in b frames are quite rare in mpeg1/2 and its a bit tricky to skip them anyway
-    
-    return 0;
-fail: //for the CHECKED_ALLOCZ macro
-    return -1;
-}
-
-/**
- * deallocates a picture
- */
-static void free_picture(MpegEncContext *s, Picture *pic){
-    int i;
-
-    if(pic->data[0] && pic->type!=FF_BUFFER_TYPE_SHARED){
-        s->avctx->release_buffer(s->avctx, (AVFrame*)pic);
-    }
-
-    av_freep(&pic->mb_var);
-    av_freep(&pic->mc_mb_var);
-    av_freep(&pic->mb_mean);
-    av_freep(&pic->mbskip_table);
-    av_freep(&pic->qscale_table);
-    av_freep(&pic->mb_type_base);
-    av_freep(&pic->dct_coeff);
-    av_freep(&pic->pan_scan);
-    pic->mb_type= NULL;
-    for(i=0; i<2; i++){
-        av_freep(&pic->motion_val_base[i]);
-        av_freep(&pic->ref_index[i]);
-    }
-    
-    if(pic->type == FF_BUFFER_TYPE_SHARED){
-        for(i=0; i<4; i++){
-            pic->base[i]=
-            pic->data[i]= NULL;
-        }
-        pic->type= 0;        
-    }
-}
-
-static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){
-    int i;
-
-    // edge emu needs blocksize + filter length - 1 (=17x17 for halfpel / 21x21 for h264) 
-    CHECKED_ALLOCZ(s->allocated_edge_emu_buffer, (s->width+64)*2*17*2); //(width + edge + align)*interlaced*MBsize*tolerance
-    s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*17;
-
-     //FIXME should be linesize instead of s->width*2 but that isnt known before get_buffer()
-    CHECKED_ALLOCZ(s->me.scratchpad,  (s->width+64)*4*16*2*sizeof(uint8_t)) 
-    s->rd_scratchpad=   s->me.scratchpad;
-    s->b_scratchpad=    s->me.scratchpad;
-    s->obmc_scratchpad= s->me.scratchpad + 16;
-    if (s->encoding) {
-        CHECKED_ALLOCZ(s->me.map      , ME_MAP_SIZE*sizeof(uint32_t))
-        CHECKED_ALLOCZ(s->me.score_map, ME_MAP_SIZE*sizeof(uint32_t))
-        if(s->avctx->noise_reduction){
-            CHECKED_ALLOCZ(s->dct_error_sum, 2 * 64 * sizeof(int))
-        }
-    }   
-    CHECKED_ALLOCZ(s->blocks, 64*12*2 * sizeof(DCTELEM))
-    s->block= s->blocks[0];
-
-    for(i=0;i<12;i++){
-        s->pblocks[i] = (short *)(&s->block[i]);
-    }
-    return 0;
-fail:
-    return -1; //free() through MPV_common_end()
-}
-
-static void free_duplicate_context(MpegEncContext *s){
-    if(s==NULL) return;
-
-    av_freep(&s->allocated_edge_emu_buffer); s->edge_emu_buffer= NULL;
-    av_freep(&s->me.scratchpad);
-    s->rd_scratchpad=   
-    s->b_scratchpad=    
-    s->obmc_scratchpad= NULL;
-    
-    av_freep(&s->dct_error_sum);
-    av_freep(&s->me.map);
-    av_freep(&s->me.score_map);
-    av_freep(&s->blocks);
-    s->block= NULL;
-}
-
-static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src){
-#define COPY(a) bak->a= src->a
-    COPY(allocated_edge_emu_buffer);
-    COPY(edge_emu_buffer);
-    COPY(me.scratchpad);
-    COPY(rd_scratchpad);
-    COPY(b_scratchpad);
-    COPY(obmc_scratchpad);
-    COPY(me.map);
-    COPY(me.score_map);
-    COPY(blocks);
-    COPY(block);
-    COPY(start_mb_y);
-    COPY(end_mb_y);
-    COPY(me.map_generation);
-    COPY(pb);
-    COPY(dct_error_sum);
-    COPY(dct_count[0]);
-    COPY(dct_count[1]);
-#undef COPY
-}
-
-void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src){
-    MpegEncContext bak;
-    int i;
-    //FIXME copy only needed parts
-//START_TIMER
-    backup_duplicate_context(&bak, dst);
-    memcpy(dst, src, sizeof(MpegEncContext));
-    backup_duplicate_context(dst, &bak);
-    for(i=0;i<12;i++){
-        dst->pblocks[i] = (short *)(&dst->block[i]);
-    }
-//STOP_TIMER("update_duplicate_context") //about 10k cycles / 0.01 sec for 1000frames on 1ghz with 2 threads
-}
-
-static void update_duplicate_context_after_me(MpegEncContext *dst, MpegEncContext *src){
-#define COPY(a) dst->a= src->a
-    COPY(pict_type);
-    COPY(current_picture);
-    COPY(f_code);
-    COPY(b_code);
-    COPY(qscale);
-    COPY(lambda);
-    COPY(lambda2);
-    COPY(picture_in_gop_number);
-    COPY(gop_picture_number);
-    COPY(frame_pred_frame_dct); //FIXME don't set in encode_header
-    COPY(progressive_frame); //FIXME don't set in encode_header
-    COPY(partitioned_frame); //FIXME don't set in encode_header
-#undef COPY
-}
-
-/**
- * sets the given MpegEncContext to common defaults (same for encoding and decoding).
- * the changed fields will not depend upon the prior state of the MpegEncContext.
- */
-static void MPV_common_defaults(MpegEncContext *s){
-    s->y_dc_scale_table=
-    s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
-    s->chroma_qscale_table= ff_default_chroma_qscale_table;
-    s->progressive_frame= 1;
-    s->progressive_sequence= 1;
-    s->picture_structure= PICT_FRAME;
-
-    s->coded_picture_number = 0;
-    s->picture_number = 0;
-    s->input_picture_number = 0;
-
-    s->picture_in_gop_number = 0;
-
-    s->f_code = 1;
-    s->b_code = 1;
-}
-
-/**
- * sets the given MpegEncContext to defaults for decoding.
- * the changed fields will not depend upon the prior state of the MpegEncContext.
- */
-void MPV_decode_defaults(MpegEncContext *s){
-    MPV_common_defaults(s);
-}
-
-/**
- * sets the given MpegEncContext to defaults for encoding.
- * the changed fields will not depend upon the prior state of the MpegEncContext.
- */
-
-#ifdef CONFIG_ENCODERS
-static void MPV_encode_defaults(MpegEncContext *s){
-    static int done=0;
-    
-    MPV_common_defaults(s);
-    
-    if(!done){
-        int i;
-        done=1;
-
-        default_mv_penalty= av_mallocz( sizeof(uint8_t)*(MAX_FCODE+1)*(2*MAX_MV+1) );
-        memset(default_fcode_tab , 0, sizeof(uint8_t)*(2*MAX_MV+1));
-
-        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;
-}
-#endif //CONFIG_ENCODERS
-
-/** 
- * init common structure for both encoder and decoder.
- * this assumes that some variables like width/height are already set
- */
-int MPV_common_init(MpegEncContext *s)
-{
-    int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;
-
-    if(s->avctx->thread_count > MAX_THREADS || (16*s->avctx->thread_count > s->height && s->height)){
-        av_log(s->avctx, AV_LOG_ERROR, "too many threads\n");
-        return -1;
-    }
-
-    if((s->width || s->height) && avcodec_check_dimensions(s->avctx, s->width, s->height))
-        return -1;
-
-    dsputil_init(&s->dsp, s->avctx);
-    DCT_common_init(s);
-
-    s->flags= s->avctx->flags;
-    s->flags2= s->avctx->flags2;
-
-    s->mb_width  = (s->width  + 15) / 16;
-    s->mb_height = (s->height + 15) / 16;
-    s->mb_stride = s->mb_width + 1;
-    s->b8_stride = s->mb_width*2 + 1;
-    s->b4_stride = s->mb_width*4 + 1;
-    mb_array_size= s->mb_height * s->mb_stride;
-    mv_table_size= (s->mb_height+2) * s->mb_stride + 1;
-
-    /* set chroma shifts */
-    avcodec_get_chroma_sub_sample(s->avctx->pix_fmt,&(s->chroma_x_shift),
-                                                    &(s->chroma_y_shift) );
-
-    /* set default edge pos, will be overriden in decode_header if needed */
-    s->h_edge_pos= s->mb_width*16;
-    s->v_edge_pos= s->mb_height*16;
-
-    s->mb_num = s->mb_width * s->mb_height;
-    
-    s->block_wrap[0]=
-    s->block_wrap[1]=
-    s->block_wrap[2]=
-    s->block_wrap[3]= s->b8_stride;
-    s->block_wrap[4]=
-    s->block_wrap[5]= s->mb_stride;
- 
-    y_size = s->b8_stride * (2 * s->mb_height + 1);
-    c_size = s->mb_stride * (s->mb_height + 1);
-    yc_size = y_size + 2 * c_size;
-    
-    /* convert fourcc to upper case */
-    s->avctx->codec_tag=   toupper( s->avctx->codec_tag     &0xFF)          
-                        + (toupper((s->avctx->codec_tag>>8 )&0xFF)<<8 )
-                        + (toupper((s->avctx->codec_tag>>16)&0xFF)<<16) 
-                        + (toupper((s->avctx->codec_tag>>24)&0xFF)<<24);
-
-    s->avctx->stream_codec_tag=   toupper( s->avctx->stream_codec_tag     &0xFF)          
-                               + (toupper((s->avctx->stream_codec_tag>>8 )&0xFF)<<8 )
-                               + (toupper((s->avctx->stream_codec_tag>>16)&0xFF)<<16) 
-                               + (toupper((s->avctx->stream_codec_tag>>24)&0xFF)<<24);
-
-    s->avctx->coded_frame= (AVFrame*)&s->current_picture;
-
-    CHECKED_ALLOCZ(s->mb_index2xy, (s->mb_num+1)*sizeof(int)) //error ressilience code looks cleaner with this
-    for(y=0; y<s->mb_height; y++){
-        for(x=0; x<s->mb_width; x++){
-            s->mb_index2xy[ x + y*s->mb_width ] = x + y*s->mb_stride;
-        }
-    }
-    s->mb_index2xy[ s->mb_height*s->mb_width ] = (s->mb_height-1)*s->mb_stride + s->mb_width; //FIXME really needed?
-    
-    if (s->encoding) {
-        /* Allocate MV tables */
-        CHECKED_ALLOCZ(s->p_mv_table_base            , mv_table_size * 2 * sizeof(int16_t))
-        CHECKED_ALLOCZ(s->b_forw_mv_table_base       , mv_table_size * 2 * sizeof(int16_t))
-        CHECKED_ALLOCZ(s->b_back_mv_table_base       , mv_table_size * 2 * sizeof(int16_t))
-        CHECKED_ALLOCZ(s->b_bidir_forw_mv_table_base , mv_table_size * 2 * sizeof(int16_t))
-        CHECKED_ALLOCZ(s->b_bidir_back_mv_table_base , mv_table_size * 2 * sizeof(int16_t))
-        CHECKED_ALLOCZ(s->b_direct_mv_table_base     , mv_table_size * 2 * sizeof(int16_t))
-        s->p_mv_table           = s->p_mv_table_base            + s->mb_stride + 1;
-        s->b_forw_mv_table      = s->b_forw_mv_table_base       + s->mb_stride + 1;
-        s->b_back_mv_table      = s->b_back_mv_table_base       + s->mb_stride + 1;
-        s->b_bidir_forw_mv_table= s->b_bidir_forw_mv_table_base + s->mb_stride + 1;
-        s->b_bidir_back_mv_table= s->b_bidir_back_mv_table_base + s->mb_stride + 1;
-        s->b_direct_mv_table    = s->b_direct_mv_table_base     + s->mb_stride + 1;
-
-        if(s->msmpeg4_version){
-            CHECKED_ALLOCZ(s->ac_stats, 2*2*(MAX_LEVEL+1)*(MAX_RUN+1)*2*sizeof(int));
-        }
-        CHECKED_ALLOCZ(s->avctx->stats_out, 256);
-
-        /* Allocate MB type table */
-        CHECKED_ALLOCZ(s->mb_type  , mb_array_size * sizeof(uint16_t)) //needed for encoding
-        
-        CHECKED_ALLOCZ(s->lambda_table, mb_array_size * sizeof(int))
-        
-        CHECKED_ALLOCZ(s->q_intra_matrix, 64*32 * sizeof(int))
-        CHECKED_ALLOCZ(s->q_inter_matrix, 64*32 * sizeof(int))
-        CHECKED_ALLOCZ(s->q_intra_matrix16, 64*32*2 * sizeof(uint16_t))
-        CHECKED_ALLOCZ(s->q_inter_matrix16, 64*32*2 * sizeof(uint16_t))
-        CHECKED_ALLOCZ(s->input_picture, MAX_PICTURE_COUNT * sizeof(Picture*))
-        CHECKED_ALLOCZ(s->reordered_input_picture, MAX_PICTURE_COUNT * sizeof(Picture*))
-        
-        if(s->avctx->noise_reduction){
-            CHECKED_ALLOCZ(s->dct_offset, 2 * 64 * sizeof(uint16_t))
-        }
-    }
-    CHECKED_ALLOCZ(s->picture, MAX_PICTURE_COUNT * sizeof(Picture))
-
-    CHECKED_ALLOCZ(s->error_status_table, mb_array_size*sizeof(uint8_t))
-    
-    if(s->codec_id==CODEC_ID_MPEG4 || (s->flags & CODEC_FLAG_INTERLACED_ME)){
-        /* interlaced direct mode decoding tables */
-            for(i=0; i<2; i++){
-                int j, k;
-                for(j=0; j<2; j++){
-                    for(k=0; k<2; k++){
-                        CHECKED_ALLOCZ(s->b_field_mv_table_base[i][j][k]     , mv_table_size * 2 * sizeof(int16_t))
-                        s->b_field_mv_table[i][j][k]    = s->b_field_mv_table_base[i][j][k]     + s->mb_stride + 1;
-                    }
-                    CHECKED_ALLOCZ(s->b_field_select_table[i][j]     , mb_array_size * 2 * sizeof(uint8_t))
-                    CHECKED_ALLOCZ(s->p_field_mv_table_base[i][j]     , mv_table_size * 2 * sizeof(int16_t))
-                    s->p_field_mv_table[i][j]    = s->p_field_mv_table_base[i][j]     + s->mb_stride + 1;
-                }
-                CHECKED_ALLOCZ(s->p_field_select_table[i]      , mb_array_size * 2 * sizeof(uint8_t))
-            }
-    }
-    if (s->out_format == FMT_H263) {
-        /* ac values */
-        CHECKED_ALLOCZ(s->ac_val_base, yc_size * sizeof(int16_t) * 16);
-        s->ac_val[0] = s->ac_val_base + s->b8_stride + 1;
-        s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1;
-        s->ac_val[2] = s->ac_val[1] + c_size;
-        
-        /* cbp values */
-        CHECKED_ALLOCZ(s->coded_block_base, y_size);
-        s->coded_block= s->coded_block_base + s->b8_stride + 1;
-        
-        /* cbp, ac_pred, pred_dir */
-        CHECKED_ALLOCZ(s->cbp_table  , mb_array_size * sizeof(uint8_t))
-        CHECKED_ALLOCZ(s->pred_dir_table, mb_array_size * sizeof(uint8_t))
-    }
-    
-    if (s->h263_pred || s->h263_plus || !s->encoding) {
-        /* dc values */
-        //MN: we need these for error resilience of intra-frames
-        CHECKED_ALLOCZ(s->dc_val_base, yc_size * sizeof(int16_t));
-        s->dc_val[0] = s->dc_val_base + s->b8_stride + 1;
-        s->dc_val[1] = s->dc_val_base + y_size + s->mb_stride + 1;
-        s->dc_val[2] = s->dc_val[1] + c_size;
-        for(i=0;i<yc_size;i++)
-            s->dc_val_base[i] = 1024;
-    }
-
-    /* which mb is a intra block */
-    CHECKED_ALLOCZ(s->mbintra_table, mb_array_size);
-    memset(s->mbintra_table, 1, mb_array_size);
-    
-    /* init macroblock skip table */
-    CHECKED_ALLOCZ(s->mbskip_table, mb_array_size+2);
-    //Note the +1 is for a quicker mpeg4 slice_end detection
-    CHECKED_ALLOCZ(s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE);
-    
-    s->parse_context.state= -1;
-    if((s->avctx->debug&(FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) || (s->avctx->debug_mv)){
-       s->visualization_buffer[0] = av_malloc((s->mb_width*16 + 2*EDGE_WIDTH) * s->mb_height*16 + 2*EDGE_WIDTH);
-       s->visualization_buffer[1] = av_malloc((s->mb_width*8 + EDGE_WIDTH) * s->mb_height*8 + EDGE_WIDTH);
-       s->visualization_buffer[2] = av_malloc((s->mb_width*8 + EDGE_WIDTH) * s->mb_height*8 + EDGE_WIDTH);
-    }
-
-    s->context_initialized = 1;
-
-    s->thread_context[0]= s;
-    for(i=1; i<s->avctx->thread_count; i++){
-        s->thread_context[i]= av_malloc(sizeof(MpegEncContext));
-        memcpy(s->thread_context[i], s, sizeof(MpegEncContext));
-    }
-
-    for(i=0; i<s->avctx->thread_count; i++){
-        if(init_duplicate_context(s->thread_context[i], s) < 0)
-           goto fail;
-        s->thread_context[i]->start_mb_y= (s->mb_height*(i  ) + s->avctx->thread_count/2) / s->avctx->thread_count;
-        s->thread_context[i]->end_mb_y  = (s->mb_height*(i+1) + s->avctx->thread_count/2) / s->avctx->thread_count;
-    }
-
-    return 0;
- fail:
-    MPV_common_end(s);
-    return -1;
-}
-
-/* init common structure for both encoder and decoder */
-void MPV_common_end(MpegEncContext *s)
-{
-    int i, j, k;
-
-    for(i=0; i<s->avctx->thread_count; i++){
-        free_duplicate_context(s->thread_context[i]);
-    }
-    for(i=1; i<s->avctx->thread_count; i++){
-        av_freep(&s->thread_context[i]);
-    }
-
-    av_freep(&s->parse_context.buffer);
-    s->parse_context.buffer_size=0;
-
-    av_freep(&s->mb_type);
-    av_freep(&s->p_mv_table_base);
-    av_freep(&s->b_forw_mv_table_base);
-    av_freep(&s->b_back_mv_table_base);
-    av_freep(&s->b_bidir_forw_mv_table_base);
-    av_freep(&s->b_bidir_back_mv_table_base);
-    av_freep(&s->b_direct_mv_table_base);
-    s->p_mv_table= NULL;
-    s->b_forw_mv_table= NULL;
-    s->b_back_mv_table= NULL;
-    s->b_bidir_forw_mv_table= NULL;
-    s->b_bidir_back_mv_table= NULL;
-    s->b_direct_mv_table= NULL;
-    for(i=0; i<2; i++){
-        for(j=0; j<2; j++){
-            for(k=0; k<2; k++){
-                av_freep(&s->b_field_mv_table_base[i][j][k]);
-                s->b_field_mv_table[i][j][k]=NULL;
-            }
-            av_freep(&s->b_field_select_table[i][j]);
-            av_freep(&s->p_field_mv_table_base[i][j]);
-            s->p_field_mv_table[i][j]=NULL;
-        }
-        av_freep(&s->p_field_select_table[i]);
-    }
-    
-    av_freep(&s->dc_val_base);
-    av_freep(&s->ac_val_base);
-    av_freep(&s->coded_block_base);
-    av_freep(&s->mbintra_table);
-    av_freep(&s->cbp_table);
-    av_freep(&s->pred_dir_table);
-    
-    av_freep(&s->mbskip_table);
-    av_freep(&s->prev_pict_types);
-    av_freep(&s->bitstream_buffer);
-    s->allocated_bitstream_buffer_size=0;
-
-    av_freep(&s->avctx->stats_out);
-    av_freep(&s->ac_stats);
-    av_freep(&s->error_status_table);
-    av_freep(&s->mb_index2xy);
-    av_freep(&s->lambda_table);
-    av_freep(&s->q_intra_matrix);
-    av_freep(&s->q_inter_matrix);
-    av_freep(&s->q_intra_matrix16);
-    av_freep(&s->q_inter_matrix16);
-    av_freep(&s->input_picture);
-    av_freep(&s->reordered_input_picture);
-    av_freep(&s->dct_offset);
-
-    if(s->picture){
-        for(i=0; i<MAX_PICTURE_COUNT; i++){
-            free_picture(s, &s->picture[i]);
-        }
-    }
-    av_freep(&s->picture);
-    s->context_initialized = 0;
-    s->last_picture_ptr=
-    s->next_picture_ptr=
-    s->current_picture_ptr= NULL;
-    s->linesize= s->uvlinesize= 0;
-
-    for(i=0; i<3; i++)
-        av_freep(&s->visualization_buffer[i]);
-
-    avcodec_default_free_buffers(s->avctx);
-}
-
-#ifdef CONFIG_ENCODERS
-
-/* init video encoder */
-int MPV_encode_init(AVCodecContext *avctx)
-{
-    MpegEncContext *s = avctx->priv_data;
-    int i;
-    int chroma_h_shift, chroma_v_shift;
-    
-    MPV_encode_defaults(s);
-
-    if(avctx->pix_fmt != PIX_FMT_YUVJ420P && avctx->pix_fmt != PIX_FMT_YUV420P){
-        av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n");
-        return -1;
-    }
-
-    if(avctx->codec_id == CODEC_ID_MJPEG || avctx->codec_id == CODEC_ID_LJPEG){
-        if(avctx->strict_std_compliance>FF_COMPLIANCE_INOFFICIAL && avctx->pix_fmt != PIX_FMT_YUVJ420P){
-            av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n");
-            return -1;
-        }
-    }else{
-        if(avctx->strict_std_compliance>FF_COMPLIANCE_INOFFICIAL && avctx->pix_fmt != PIX_FMT_YUV420P){
-            av_log(avctx, AV_LOG_ERROR, "colorspace not supported\n");
-            return -1;
-        }
-    }
-
-    s->bit_rate = avctx->bit_rate;
-    s->width = avctx->width;
-    s->height = avctx->height;
-    if(avctx->gop_size > 600){
-	av_log(avctx, AV_LOG_ERROR, "Warning keyframe interval too large! reducing it ...\n");
-        avctx->gop_size=600;
-    }
-    s->gop_size = avctx->gop_size;
-    s->avctx = avctx;
-    s->flags= avctx->flags;
-    s->flags2= avctx->flags2;
-    s->max_b_frames= avctx->max_b_frames;
-    s->codec_id= avctx->codec->id;
-    s->luma_elim_threshold  = avctx->luma_elim_threshold;
-    s->chroma_elim_threshold= avctx->chroma_elim_threshold;
-    s->strict_std_compliance= avctx->strict_std_compliance;
-    s->data_partitioning= avctx->flags & CODEC_FLAG_PART;
-    s->quarter_sample= (avctx->flags & CODEC_FLAG_QPEL)!=0;
-    s->mpeg_quant= avctx->mpeg_quant;
-    s->rtp_mode= !!avctx->rtp_payload_size;
-    s->intra_dc_precision= avctx->intra_dc_precision;
-    s->user_specified_pts = AV_NOPTS_VALUE;
-
-    if (s->gop_size <= 1) {
-        s->intra_only = 1;
-        s->gop_size = 12;
-    } else {
-        s->intra_only = 0;
-    }
-
-    s->me_method = avctx->me_method;
-
-    /* Fixed QSCALE */
-    s->fixed_qscale = !!(avctx->flags & CODEC_FLAG_QSCALE);
-    
-    s->adaptive_quant= (   s->avctx->lumi_masking
-                        || s->avctx->dark_masking
-                        || s->avctx->temporal_cplx_masking 
-                        || s->avctx->spatial_cplx_masking
-                        || s->avctx->p_masking
-                        || s->avctx->border_masking
-                        || (s->flags&CODEC_FLAG_QP_RD))
-                       && !s->fixed_qscale;
-    
-    s->obmc= !!(s->flags & CODEC_FLAG_OBMC);
-    s->loop_filter= !!(s->flags & CODEC_FLAG_LOOP_FILTER);
-    s->alternate_scan= !!(s->flags & CODEC_FLAG_ALT_SCAN);
-
-    if(avctx->rc_max_rate && !avctx->rc_buffer_size){
-        av_log(avctx, AV_LOG_ERROR, "a vbv buffer size is needed, for encoding with a maximum bitrate\n");
-        return -1;
-    }    
-
-    if(avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate){
-        av_log(avctx, AV_LOG_INFO, "Warning min_rate > 0 but min_rate != max_rate isn't recommended!\n");
-    }
-    
-    if(avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate){
-        av_log(avctx, AV_LOG_INFO, "bitrate below min bitrate\n");
-        return -1;
-    }
-    
-    if(avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate){
-        av_log(avctx, AV_LOG_INFO, "bitrate above max bitrate\n");
-        return -1;
-    }
-        
-    if(   s->avctx->rc_max_rate && s->avctx->rc_min_rate == s->avctx->rc_max_rate 
-       && (s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO)
-       && 90000LL * (avctx->rc_buffer_size-1) > s->avctx->rc_max_rate*0xFFFFLL){
-        
-        av_log(avctx, AV_LOG_INFO, "Warning vbv_delay will be set to 0xFFFF (=VBR) as the specified vbv buffer is too large for the given bitrate!\n");
-    }
-       
-    if((s->flags & CODEC_FLAG_4MV) && s->codec_id != CODEC_ID_MPEG4 
-       && s->codec_id != CODEC_ID_H263 && s->codec_id != CODEC_ID_H263P && s->codec_id != CODEC_ID_FLV1){
-        av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n");
-        return -1;
-    }
-        
-    if(s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE){
-        av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with simple mb decision\n");
-        return -1;
-    }
-    
-    if(s->obmc && s->codec_id != CODEC_ID_H263 && s->codec_id != CODEC_ID_H263P){
-        av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with H263(+)\n");
-        return -1;
-    }
-    
-    if(s->quarter_sample && s->codec_id != CODEC_ID_MPEG4){
-        av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n");
-        return -1;
-    }
-
-    if(s->data_partitioning && s->codec_id != CODEC_ID_MPEG4){
-        av_log(avctx, AV_LOG_ERROR, "data partitioning not supported by codec\n");
-        return -1;
-    }
-    
-    if(s->max_b_frames && s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO){
-        av_log(avctx, AV_LOG_ERROR, "b frames not supported by codec\n");
-        return -1;
-    }
-
-    if((s->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME|CODEC_FLAG_ALT_SCAN)) 
-       && s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG2VIDEO){
-        av_log(avctx, AV_LOG_ERROR, "interlacing not supported by codec\n");
-        return -1;
-    }
-        
-    if(s->mpeg_quant && s->codec_id != CODEC_ID_MPEG4){ //FIXME mpeg2 uses that too
-        av_log(avctx, AV_LOG_ERROR, "mpeg2 style quantization not supported by codec\n");
-        return -1;
-    }
-        
-    if((s->flags & CODEC_FLAG_CBP_RD) && !(s->flags & CODEC_FLAG_TRELLIS_QUANT)){
-        av_log(avctx, AV_LOG_ERROR, "CBP RD needs trellis quant\n");
-        return -1;
-    }
-
-    if((s->flags & CODEC_FLAG_QP_RD) && s->avctx->mb_decision != FF_MB_DECISION_RD){
-        av_log(avctx, AV_LOG_ERROR, "QP RD needs mbd=2\n");
-        return -1;
-    }
-    
-    if(s->avctx->scenechange_threshold < 1000000000 && (s->flags & CODEC_FLAG_CLOSED_GOP)){
-        av_log(avctx, AV_LOG_ERROR, "closed gop with scene change detection arent supported yet\n");
-        return -1;
-    }
-    
-    if(s->avctx->thread_count > 1 && s->codec_id != CODEC_ID_MPEG4 
-       && s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO 
-       && (s->codec_id != CODEC_ID_H263P || !(s->flags & CODEC_FLAG_H263P_SLICE_STRUCT))){
-        av_log(avctx, AV_LOG_ERROR, "multi threaded encoding not supported by codec\n");
-        return -1;
-    }
-    
-    if(s->avctx->thread_count > 1)
-        s->rtp_mode= 1;
-
-    if(!avctx->time_base.den || !avctx->time_base.num){
-        av_log(avctx, AV_LOG_ERROR, "framerate not set\n");
-        return -1;
-    }
-    
-    i= (INT_MAX/2+128)>>8;
-    if(avctx->me_threshold >= i){
-        av_log(avctx, AV_LOG_ERROR, "me_threshold too large, max is %d\n", i - 1);
-        return -1;
-    }
-    if(avctx->mb_threshold >= i){
-        av_log(avctx, AV_LOG_ERROR, "mb_threshold too large, max is %d\n", i - 1);
-        return -1;
-    }
-        
-    if(avctx->b_frame_strategy && (avctx->flags&CODEC_FLAG_PASS2)){
-        av_log(avctx, AV_LOG_ERROR, "b_frame_strategy must be 0 on the second pass");
-        return -1;
-    }
-
-    i= ff_gcd(avctx->time_base.den, avctx->time_base.num);
-    if(i > 1){
-        av_log(avctx, AV_LOG_INFO, "removing common factors from framerate\n");
-        avctx->time_base.den /= i;
-        avctx->time_base.num /= i;
-//        return -1;
-    }
-    
-    if(s->codec_id==CODEC_ID_MJPEG){
-        s->intra_quant_bias= 1<<(QUANT_BIAS_SHIFT-1); //(a + x/2)/x
-        s->inter_quant_bias= 0;
-    }else if(s->mpeg_quant || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO){
-        s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3); //(a + x*3/8)/x
-        s->inter_quant_bias= 0;
-    }else{
-        s->intra_quant_bias=0;
-        s->inter_quant_bias=-(1<<(QUANT_BIAS_SHIFT-2)); //(a - x/4)/x
-    }
-    
-    if(avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS)
-        s->intra_quant_bias= avctx->intra_quant_bias;
-    if(avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS)
-        s->inter_quant_bias= avctx->inter_quant_bias;
-        
-    avcodec_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift);
-
-    if(avctx->codec_id == CODEC_ID_MPEG4 && s->avctx->time_base.den > (1<<16)-1){
-        av_log(avctx, AV_LOG_ERROR, "timebase not supported by mpeg 4 standard\n");
-        return -1;        
-    }
-    s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
-
-    switch(avctx->codec->id) {
-//     case CODEC_ID_MPEG1VIDEO:
-//         s->out_format = FMT_MPEG1;
-//         s->low_delay= 0; //s->max_b_frames ? 0 : 1;
-//         avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
-//         break;
-    case CODEC_ID_MPEG2VIDEO:
-        s->out_format = FMT_MPEG1;
-        s->low_delay= 0; //s->max_b_frames ? 0 : 1;
-        avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
-        s->rtp_mode= 1;
-        break;
-//     case CODEC_ID_LJPEG:
-//     case CODEC_ID_MJPEG:
-//         s->out_format = FMT_MJPEG;
-//         s->intra_only = 1; /* force intra only for jpeg */
-//         s->mjpeg_write_tables = 1; /* write all tables */
-// 	s->mjpeg_data_only_frames = 0; /* write all the needed headers */
-//         s->mjpeg_vsample[0] = 1<<chroma_v_shift;
-//         s->mjpeg_vsample[1] = 1;
-//         s->mjpeg_vsample[2] = 1; 
-//         s->mjpeg_hsample[0] = 1<<chroma_h_shift;
-//         s->mjpeg_hsample[1] = 1; 
-//         s->mjpeg_hsample[2] = 1; 
-//         if (mjpeg_init(s) < 0)
-//             return -1;
-//         avctx->delay=0;
-//         s->low_delay=1;
-//         break;
-//     case CODEC_ID_H261:
-//         s->out_format = FMT_H261;
-//         avctx->delay=0;
-//         s->low_delay=1;
-//         break;
-//     case CODEC_ID_H263:
-//         if (h263_get_picture_format(s->width, s->height) == 7) {
-//             av_log(avctx, AV_LOG_INFO, "Input picture size isn't suitable for h263 codec! try h263+\n");
-//             return -1;
-//         }
-//         s->out_format = FMT_H263;
-// 	s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
-//         avctx->delay=0;
-//         s->low_delay=1;
-//         break;
-//     case CODEC_ID_H263P:
-//         s->out_format = FMT_H263;
-//         s->h263_plus = 1;
-// 	/* Fx */
-//         s->umvplus = (avctx->flags & CODEC_FLAG_H263P_UMV) ? 1:0;
-// 	s->h263_aic= (avctx->flags & CODEC_FLAG_H263P_AIC) ? 1:0;
-// 	s->modified_quant= s->h263_aic;
-// 	s->alt_inter_vlc= (avctx->flags & CODEC_FLAG_H263P_AIV) ? 1:0;
-// 	s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
-// 	s->loop_filter= (avctx->flags & CODEC_FLAG_LOOP_FILTER) ? 1:0;
-// 	s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus;
-//         s->h263_slice_structured= (s->flags & CODEC_FLAG_H263P_SLICE_STRUCT) ? 1:0;
-// 
-// 	/* /Fx */
-//         /* These are just to be sure */
-//         avctx->delay=0;
-//         s->low_delay=1;
-//         break;
-//     case CODEC_ID_FLV1:
-//         s->out_format = FMT_H263;
-//         s->h263_flv = 2; /* format = 1; 11-bit codes */
-//         s->unrestricted_mv = 1;
-//         s->rtp_mode=0; /* don't allow GOB */
-//         avctx->delay=0;
-//         s->low_delay=1;
-//         break;
-//     case CODEC_ID_RV10:
-//         s->out_format = FMT_H263;
-//         avctx->delay=0;
-//         s->low_delay=1;
-//         break;
-//     case CODEC_ID_RV20:
-//         s->out_format = FMT_H263;
-//         avctx->delay=0;
-//         s->low_delay=1;
-//         s->modified_quant=1;
-//         s->h263_aic=1;
-//         s->h263_plus=1;
-//         s->loop_filter=1;
-//         s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus;
-//         break;
-//     case CODEC_ID_MPEG4:
-//         s->out_format = FMT_H263;
-//         s->h263_pred = 1;
-//         s->unrestricted_mv = 1;
-//         s->low_delay= s->max_b_frames ? 0 : 1;
-//         avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
-//         break;
-//     case CODEC_ID_MSMPEG4V1:
-//         s->out_format = FMT_H263;
-//         s->h263_msmpeg4 = 1;
-//         s->h263_pred = 1;
-//         s->unrestricted_mv = 1;
-//         s->msmpeg4_version= 1;
-//         avctx->delay=0;
-//         s->low_delay=1;
-//         break;
-//     case CODEC_ID_MSMPEG4V2:
-//         s->out_format = FMT_H263;
-//         s->h263_msmpeg4 = 1;
-//         s->h263_pred = 1;
-//         s->unrestricted_mv = 1;
-//         s->msmpeg4_version= 2;
-//         avctx->delay=0;
-//         s->low_delay=1;
-//         break;
-//     case CODEC_ID_MSMPEG4V3:
-//         s->out_format = FMT_H263;
-//         s->h263_msmpeg4 = 1;
-//         s->h263_pred = 1;
-//         s->unrestricted_mv = 1;
-//         s->msmpeg4_version= 3;
-//         s->flipflop_rounding=1;
-//         avctx->delay=0;
-//         s->low_delay=1;
-//         break;
-//     case CODEC_ID_WMV1:
-//         s->out_format = FMT_H263;
-//         s->h263_msmpeg4 = 1;
-//         s->h263_pred = 1;
-//         s->unrestricted_mv = 1;
-//         s->msmpeg4_version= 4;
-//         s->flipflop_rounding=1;
-//         avctx->delay=0;
-//         s->low_delay=1;
-//         break;
-//     case CODEC_ID_WMV2:
-//         s->out_format = FMT_H263;
-//         s->h263_msmpeg4 = 1;
-//         s->h263_pred = 1;
-//         s->unrestricted_mv = 1;
-//         s->msmpeg4_version= 5;
-//         s->flipflop_rounding=1;
-//         avctx->delay=0;
-//         s->low_delay=1;
-//         break;
-    default:
-        return -1;
-    }
-    
-    avctx->has_b_frames= !s->low_delay;
-
-    s->encoding = 1;
-
-    /* init */
-    if (MPV_common_init(s) < 0)
-        return -1;
-
-    if(s->modified_quant)
-        s->chroma_qscale_table= ff_h263_chroma_qscale_table;
-    s->progressive_frame= 
-    s->progressive_sequence= !(avctx->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME));
-    s->quant_precision=5;
-    
-    ff_set_cmp(&s->dsp, s->dsp.ildct_cmp, s->avctx->ildct_cmp);
-    ff_set_cmp(&s->dsp, s->dsp.frame_skip_cmp, s->avctx->frame_skip_cmp);
-    
-#ifdef CONFIG_H261_ENCODER
-    if (s->out_format == FMT_H261)
-        ff_h261_encode_init(s);
-#endif
-    if (s->out_format == FMT_H263)
-        h263_encode_init(s);
-    if(s->msmpeg4_version)
-        ff_msmpeg4_encode_init(s);
-    if (s->out_format == FMT_MPEG1)
-        ff_mpeg1_encode_init(s);
-
-    /* init q matrix */
-    for(i=0;i<64;i++) {
-        int j= s->dsp.idct_permutation[i];
-//         if(s->codec_id==CODEC_ID_MPEG4 && s->mpeg_quant){
-//             s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i];
-//             s->inter_matrix[j] = ff_mpeg4_default_non_intra_matrix[i];
-//         }else if(s->out_format == FMT_H263 || s->out_format == FMT_H261){
-//             s->intra_matrix[j] =
-//             s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];
-//         }else
-        { /* mpeg1/2 */
-            s->intra_matrix[j] = ff_mpeg1_default_intra_matrix[i];
-            s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i];
-        }
-        if(s->avctx->intra_matrix)
-            s->intra_matrix[j] = s->avctx->intra_matrix[i];
-        if(s->avctx->inter_matrix)
-            s->inter_matrix[j] = s->avctx->inter_matrix[i];
-    }
-
-    /* precompute matrix */
-    /* for mjpeg, we do include qscale in the matrix */
-    if (s->out_format != FMT_MJPEG) {
-        convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16, 
-                       s->intra_matrix, s->intra_quant_bias, avctx->qmin, 31, 1);
-        convert_matrix(&s->dsp, s->q_inter_matrix, s->q_inter_matrix16, 
-                       s->inter_matrix, s->inter_quant_bias, avctx->qmin, 31, 0);
-    }
-
-    if(ff_rate_control_init(s) < 0)
-        return -1;
-    
-    return 0;
-}
-
-int MPV_encode_end(AVCodecContext *avctx)
-{
-    MpegEncContext *s = avctx->priv_data;
-
-#ifdef STATS
-    print_stats();
-#endif
-
-    ff_rate_control_uninit(s);
-
-    MPV_common_end(s);
-    if (s->out_format == FMT_MJPEG)
-        mjpeg_close(s);
-
-    av_freep(&avctx->extradata);
-      
-    return 0;
-}
-
-#endif //CONFIG_ENCODERS
-
-void init_rl(RLTable *rl, int use_static)
-{
-    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 table is static, we can quit if rl->max_level[0] is not NULL */
-    if(use_static && rl->max_level[0])
-        return;
-
-    /* compute max_level[], max_run[] and index_run[] */
-    for(last=0;last<2;last++) {
-        if (last == 0) {
-            start = 0;
-            end = rl->last;
-        } else {
-            start = rl->last;
-            end = rl->n;
-        }
-
-        memset(max_level, 0, MAX_RUN + 1);
-        memset(max_run, 0, MAX_LEVEL + 1);
-        memset(index_run, rl->n, MAX_RUN + 1);
-        for(i=start;i<end;i++) {
-            run = rl->table_run[i];
-            level = rl->table_level[i];
-            if (index_run[run] == rl->n)
-                index_run[run] = i;
-            if (level > max_level[run])
-                max_level[run] = level;
-            if (run > max_run[level])
-                max_run[level] = run;
-        }
-        if(use_static)
-            rl->max_level[last] = av_mallocz_static(MAX_RUN + 1);
-        else
-            rl->max_level[last] = av_malloc(MAX_RUN + 1);
-        memcpy(rl->max_level[last], max_level, MAX_RUN + 1);
-        if(use_static)
-            rl->max_run[last] = av_mallocz_static(MAX_LEVEL + 1);
-        else
-            rl->max_run[last] = av_malloc(MAX_LEVEL + 1);
-        memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1);
-        if(use_static)
-            rl->index_run[last] = av_mallocz_static(MAX_RUN + 1);
-        else
-            rl->index_run[last] = av_malloc(MAX_RUN + 1);
-        memcpy(rl->index_run[last], index_run, MAX_RUN + 1);
-    }
-}
-
-/* draw the edges of width 'w' of an image of size width, height */
-//FIXME check that this is ok for mpeg4 interlaced
-static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w)
-{
-    uint8_t *ptr, *last_line;
-    int i;
-
-    last_line = buf + (height - 1) * wrap;
-    for(i=0;i<w;i++) {
-        /* top and bottom */
-        memcpy(buf - (i + 1) * wrap, buf, width);
-        memcpy(last_line + (i + 1) * wrap, last_line, width);
-    }
-    /* left and right */
-    ptr = buf;
-    for(i=0;i<height;i++) {
-        memset(ptr - w, ptr[0], w);
-        memset(ptr + width, ptr[width-1], w);
-        ptr += wrap;
-    }
-    /* corners */
-    for(i=0;i<w;i++) {
-        memset(buf - (i + 1) * wrap - w, buf[0], w); /* top left */
-        memset(buf - (i + 1) * wrap + width, buf[width-1], w); /* top right */
-        memset(last_line + (i + 1) * wrap - w, last_line[0], w); /* top left */
-        memset(last_line + (i + 1) * wrap + width, last_line[width-1], w); /* top right */
-    }
-}
-
-int ff_find_unused_picture(MpegEncContext *s, int shared){
-    int i;
-    
-    if(shared){
-        for(i=0; i<MAX_PICTURE_COUNT; i++){
-            if(s->picture[i].data[0]==NULL && s->picture[i].type==0) return i;
-        }
-    }else{
-        for(i=0; i<MAX_PICTURE_COUNT; i++){
-            if(s->picture[i].data[0]==NULL && s->picture[i].type!=0) return i; //FIXME
-        }
-        for(i=0; i<MAX_PICTURE_COUNT; i++){
-            if(s->picture[i].data[0]==NULL) return i;
-        }
-    }
-
-    assert(0);
-    return -1;
-}
-
-static void update_noise_reduction(MpegEncContext *s){
-    int intra, i;
-
-    for(intra=0; intra<2; intra++){
-        if(s->dct_count[intra] > (1<<16)){
-            for(i=0; i<64; i++){
-                s->dct_error_sum[intra][i] >>=1;
-            }
-            s->dct_count[intra] >>= 1;
-        }
-        
-        for(i=0; i<64; i++){
-            s->dct_offset[intra][i]= (s->avctx->noise_reduction * s->dct_count[intra] + s->dct_error_sum[intra][i]/2) / (s->dct_error_sum[intra][i]+1);
-        }
-    }
-}
-
-/**
- * generic function for encode/decode called after coding/decoding the header and before a frame is coded/decoded
- */
-int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
-{
-    int i;
-    AVFrame *pic;
-    s->mb_skipped = 0;
-
-    assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3);
-
-    /* mark&release old frames */
-    if (s->pict_type != B_TYPE && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->data[0]) {
-        avctx->release_buffer(avctx, (AVFrame*)s->last_picture_ptr);
-
-        /* release forgotten pictures */
-        /* if(mpeg124/h263) */
-        if(!s->encoding){
-            for(i=0; i<MAX_PICTURE_COUNT; i++){
-                if(s->picture[i].data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].reference){
-                    av_log(avctx, AV_LOG_ERROR, "releasing zombie picture\n");
-                    avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);                
-                }
-            }
-        }
-    }
-alloc:
-    if(!s->encoding){
-        /* release non reference frames */
-        for(i=0; i<MAX_PICTURE_COUNT; i++){
-            if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
-                s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]);
-            }
-        }
-
-        if(s->current_picture_ptr && s->current_picture_ptr->data[0]==NULL)
-            pic= (AVFrame*)s->current_picture_ptr; //we allready have a unused image (maybe it was set before reading the header)
-        else{
-            i= ff_find_unused_picture(s, 0);
-            pic= (AVFrame*)&s->picture[i];
-        }
-
-        pic->reference= (s->pict_type != B_TYPE || s->codec_id == CODEC_ID_H264)
-                        && !s->dropable ? 3 : 0;
-
-        pic->coded_picture_number= s->coded_picture_number++;
-        
-        if( alloc_picture(s, (Picture*)pic, 0) < 0)
-            return -1;
-
-        s->current_picture_ptr= (Picture*)pic;
-        s->current_picture_ptr->top_field_first= s->top_field_first; //FIXME use only the vars from current_pic
-        s->current_picture_ptr->interlaced_frame= !s->progressive_frame && !s->progressive_sequence;
-    }
-
-    s->current_picture_ptr->pict_type= s->pict_type;
-//    if(s->flags && CODEC_FLAG_QSCALE) 
-  //      s->current_picture_ptr->quality= s->new_picture_ptr->quality;
-    s->current_picture_ptr->key_frame= s->pict_type == I_TYPE;
-
-    copy_picture(&s->current_picture, s->current_picture_ptr);
-  
-  if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){
-    if (s->pict_type != B_TYPE) {
-        s->last_picture_ptr= s->next_picture_ptr;
-        if(!s->dropable)
-            s->next_picture_ptr= s->current_picture_ptr;
-    }
-/*    av_log(s->avctx, AV_LOG_DEBUG, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n", s->last_picture_ptr, s->next_picture_ptr,s->current_picture_ptr,
-        s->last_picture_ptr    ? s->last_picture_ptr->data[0] : NULL, 
-        s->next_picture_ptr    ? s->next_picture_ptr->data[0] : NULL, 
-        s->current_picture_ptr ? s->current_picture_ptr->data[0] : NULL,
-        s->pict_type, s->dropable);*/
-    
-    if(s->last_picture_ptr) copy_picture(&s->last_picture, s->last_picture_ptr);
-    if(s->next_picture_ptr) copy_picture(&s->next_picture, s->next_picture_ptr);
-    
-    if(s->pict_type != I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL)){
-        av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n");
-        assert(s->pict_type != B_TYPE); //these should have been dropped if we don't have a reference
-        goto alloc;
-    }
-
-    assert(s->pict_type == I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0]));
-
-    if(s->picture_structure!=PICT_FRAME){
-        int i;
-        for(i=0; i<4; i++){
-            if(s->picture_structure == PICT_BOTTOM_FIELD){
-                 s->current_picture.data[i] += s->current_picture.linesize[i];
-            } 
-            s->current_picture.linesize[i] *= 2;
-            s->last_picture.linesize[i] *=2;
-            s->next_picture.linesize[i] *=2;
-        }
-    }
-  }
-   
-    s->hurry_up= s->avctx->hurry_up;
-    s->error_resilience= avctx->error_resilience;
-
-    /* set dequantizer, we can't do it during init as it might change for mpeg4
-       and we can't do it in the header decode as init isnt called for mpeg4 there yet */
-    if(s->mpeg_quant || s->codec_id == CODEC_ID_MPEG2VIDEO){
-        s->dct_unquantize_intra = s->dct_unquantize_mpeg2_intra;
-        s->dct_unquantize_inter = s->dct_unquantize_mpeg2_inter;
-//     }else if(s->out_format == FMT_H263 || s->out_format == FMT_H261){
-//         s->dct_unquantize_intra = s->dct_unquantize_h263_intra;
-//         s->dct_unquantize_inter = s->dct_unquantize_h263_inter;
-//     }else{
-//         s->dct_unquantize_intra = s->dct_unquantize_mpeg1_intra;
-//         s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter;
-    }
-
-    if(s->dct_error_sum){
-        assert(s->avctx->noise_reduction && s->encoding);
-
-        update_noise_reduction(s);
-    }
-        
-#ifdef HAVE_XVMC
-    if(s->avctx->xvmc_acceleration)
-        return XVMC_field_start(s, avctx);
-#endif
-    return 0;
-}
-
-/* generic function for encode/decode called after a frame has been coded/decoded */
-void MPV_frame_end(MpegEncContext *s)
-{
-    int i;
-    /* draw edge for correct motion prediction if outside */
-#ifdef HAVE_XVMC
-//just to make sure that all data is rendered.
-    if(s->avctx->xvmc_acceleration){
-        XVMC_field_end(s);
-    }else
-#endif
-    if(s->unrestricted_mv && s->current_picture.reference && !s->intra_only && !(s->flags&CODEC_FLAG_EMU_EDGE)) {
-            draw_edges(s->current_picture.data[0], s->linesize  , s->h_edge_pos   , s->v_edge_pos   , EDGE_WIDTH  );
-            draw_edges(s->current_picture.data[1], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2);
-            draw_edges(s->current_picture.data[2], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2);
-    }
-    emms_c();
-    
-    s->last_pict_type    = s->pict_type;
-    if(s->pict_type!=B_TYPE){
-        s->last_non_b_pict_type= s->pict_type;
-    }
-#if 0
-        /* copy back current_picture variables */
-    for(i=0; i<MAX_PICTURE_COUNT; i++){
-        if(s->picture[i].data[0] == s->current_picture.data[0]){
-            s->picture[i]= s->current_picture;
-            break;
-        }    
-    }
-    assert(i<MAX_PICTURE_COUNT);
-#endif    
-
-    if(s->encoding){
-        /* release non-reference frames */
-        for(i=0; i<MAX_PICTURE_COUNT; i++){
-            if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
-                s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]);
-            }
-        }
-    }
-    // clear copies, to avoid confusion
-#if 0
-    memset(&s->last_picture, 0, sizeof(Picture));
-    memset(&s->next_picture, 0, sizeof(Picture));
-    memset(&s->current_picture, 0, sizeof(Picture));
-#endif
-    s->avctx->coded_frame= (AVFrame*)s->current_picture_ptr;
-}
-
-/**
- * draws an line from (ex, ey) -> (sx, sy).
- * @param w width of the image
- * @param h height of the image
- * @param stride stride/linesize of the image
- * @param color color of the arrow
- */
-static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){
-    int t, x, y, fr, f;
-    
-    sx= clip(sx, 0, w-1);
-    sy= clip(sy, 0, h-1);
-    ex= clip(ex, 0, w-1);
-    ey= clip(ey, 0, h-1);
-    
-    buf[sy*stride + sx]+= color;
-    
-    if(ABS(ex - sx) > ABS(ey - sy)){
-        if(sx > ex){
-            t=sx; sx=ex; ex=t;
-            t=sy; sy=ey; ey=t;
-        }
-        buf+= sx + sy*stride;
-        ex-= sx;
-        f= ((ey-sy)<<16)/ex;
-        for(x= 0; x <= ex; x++){
-            y = (x*f)>>16;
-            fr= (x*f)&0xFFFF;
-            buf[ y   *stride + x]+= (color*(0x10000-fr))>>16;
-            buf[(y+1)*stride + x]+= (color*         fr )>>16;
-        }
-    }else{
-        if(sy > ey){
-            t=sx; sx=ex; ex=t;
-            t=sy; sy=ey; ey=t;
-        }
-        buf+= sx + sy*stride;
-        ey-= sy;
-        if(ey) f= ((ex-sx)<<16)/ey;
-        else   f= 0;
-        for(y= 0; y <= ey; y++){
-            x = (y*f)>>16;
-            fr= (y*f)&0xFFFF;
-            buf[y*stride + x  ]+= (color*(0x10000-fr))>>16;;
-            buf[y*stride + x+1]+= (color*         fr )>>16;;
-        }
-    }
-}
-
-/**
- * draws an arrow from (ex, ey) -> (sx, sy).
- * @param w width of the image
- * @param h height of the image
- * @param stride stride/linesize of the image
- * @param color color of the arrow
- */
-static void draw_arrow(uint8_t *buf, int sx, int sy, int ex, int ey, int w, int h, int stride, int color){ 
-    int dx,dy;
-
-    sx= clip(sx, -100, w+100);
-    sy= clip(sy, -100, h+100);
-    ex= clip(ex, -100, w+100);
-    ey= clip(ey, -100, h+100);
-    
-    dx= ex - sx;
-    dy= ey - sy;
-    
-    if(dx*dx + dy*dy > 3*3){
-        int rx=  dx + dy;
-        int ry= -dx + dy;
-        int length= ff_sqrt((rx*rx + ry*ry)<<8);
-        
-        //FIXME subpixel accuracy
-        rx= ROUNDED_DIV(rx*3<<4, length);
-        ry= ROUNDED_DIV(ry*3<<4, length);
-        
-        draw_line(buf, sx, sy, sx + rx, sy + ry, w, h, stride, color);
-        draw_line(buf, sx, sy, sx - ry, sy + rx, w, h, stride, color);
-    }
-    draw_line(buf, sx, sy, ex, ey, w, h, stride, color);
-}
-
-/**
- * prints debuging info for the given picture.
- */
-void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){
-
-    if(!pict || !pict->mb_type) return;
-
-    if(s->avctx->debug&(FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)){
-        int x,y;
-        
-        av_log(s->avctx,AV_LOG_DEBUG,"New frame, type: ");
-        switch (pict->pict_type) {
-            case FF_I_TYPE: av_log(s->avctx,AV_LOG_DEBUG,"I\n"); break;
-            case FF_P_TYPE: av_log(s->avctx,AV_LOG_DEBUG,"P\n"); break;
-            case FF_B_TYPE: av_log(s->avctx,AV_LOG_DEBUG,"B\n"); break;
-            case FF_S_TYPE: av_log(s->avctx,AV_LOG_DEBUG,"S\n"); break;
-            case FF_SI_TYPE: av_log(s->avctx,AV_LOG_DEBUG,"SI\n"); break;
-            case FF_SP_TYPE: av_log(s->avctx,AV_LOG_DEBUG,"SP\n"); break;            
-        }
-        for(y=0; y<s->mb_height; y++){
-            for(x=0; x<s->mb_width; x++){
-                if(s->avctx->debug&FF_DEBUG_SKIP){
-                    int count= s->mbskip_table[x + y*s->mb_stride];
-                    if(count>9) count=9;
-                    av_log(s->avctx, AV_LOG_DEBUG, "%1d", count);
-                }
-                if(s->avctx->debug&FF_DEBUG_QP){
-                    av_log(s->avctx, AV_LOG_DEBUG, "%2d", pict->qscale_table[x + y*s->mb_stride]);
-                }
-                if(s->avctx->debug&FF_DEBUG_MB_TYPE){
-                    int mb_type= pict->mb_type[x + y*s->mb_stride];
-                    //Type & MV direction
-                    if(IS_PCM(mb_type))
-                        av_log(s->avctx, AV_LOG_DEBUG, "P");
-                    else if(IS_INTRA(mb_type) && IS_ACPRED(mb_type))
-                        av_log(s->avctx, AV_LOG_DEBUG, "A");
-                    else if(IS_INTRA4x4(mb_type))
-                        av_log(s->avctx, AV_LOG_DEBUG, "i");
-                    else if(IS_INTRA16x16(mb_type))
-                        av_log(s->avctx, AV_LOG_DEBUG, "I");
-                    else if(IS_DIRECT(mb_type) && IS_SKIP(mb_type))
-                        av_log(s->avctx, AV_LOG_DEBUG, "d");
-                    else if(IS_DIRECT(mb_type))
-                        av_log(s->avctx, AV_LOG_DEBUG, "D");
-                    else if(IS_GMC(mb_type) && IS_SKIP(mb_type))
-                        av_log(s->avctx, AV_LOG_DEBUG, "g");
-                    else if(IS_GMC(mb_type))
-                        av_log(s->avctx, AV_LOG_DEBUG, "G");
-                    else if(IS_SKIP(mb_type))
-                        av_log(s->avctx, AV_LOG_DEBUG, "S");
-                    else if(!USES_LIST(mb_type, 1))
-                        av_log(s->avctx, AV_LOG_DEBUG, ">");
-                    else if(!USES_LIST(mb_type, 0))
-                        av_log(s->avctx, AV_LOG_DEBUG, "<");
-                    else{
-                        assert(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
-                        av_log(s->avctx, AV_LOG_DEBUG, "X");
-                    }
-                    
-                    //segmentation
-                    if(IS_8X8(mb_type))
-                        av_log(s->avctx, AV_LOG_DEBUG, "+");
-                    else if(IS_16X8(mb_type))
-                        av_log(s->avctx, AV_LOG_DEBUG, "-");
-                    else if(IS_8X16(mb_type))
-                        av_log(s->avctx, AV_LOG_DEBUG, "|");
-                    else if(IS_INTRA(mb_type) || IS_16X16(mb_type))
-                        av_log(s->avctx, AV_LOG_DEBUG, " ");
-                    else
-                        av_log(s->avctx, AV_LOG_DEBUG, "?");
-                    
-                        
-                    if(IS_INTERLACED(mb_type) && s->codec_id == CODEC_ID_H264)
-                        av_log(s->avctx, AV_LOG_DEBUG, "=");
-                    else
-                        av_log(s->avctx, AV_LOG_DEBUG, " ");
-                }
-//                av_log(s->avctx, AV_LOG_DEBUG, " ");
-            }
-            av_log(s->avctx, AV_LOG_DEBUG, "\n");
-        }
-    }
-
-    if((s->avctx->debug&(FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) || (s->avctx->debug_mv)){
-        const int shift= 1 + s->quarter_sample;
-        int mb_y;
-        uint8_t *ptr;
-        int i;
-        int h_chroma_shift, v_chroma_shift;
-        const int width = s->avctx->width;
-        const int height= s->avctx->height;
-        const int mv_sample_log2= 4 - pict->motion_subsample_log2;
-        const int mv_stride= (s->mb_width << mv_sample_log2) + 1;
-        s->low_delay=0; //needed to see the vectors without trashing the buffers
-
-        avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift, &v_chroma_shift);
-        for(i=0; i<3; i++){
-            memcpy(s->visualization_buffer[i], pict->data[i], (i==0) ? pict->linesize[i]*height:pict->linesize[i]*height >> v_chroma_shift);
-            pict->data[i]= s->visualization_buffer[i];
-        }
-        pict->type= FF_BUFFER_TYPE_COPY;
-        ptr= pict->data[0];
-
-        for(mb_y=0; mb_y<s->mb_height; mb_y++){
-            int mb_x;
-            for(mb_x=0; mb_x<s->mb_width; mb_x++){
-                const int mb_index= mb_x + mb_y*s->mb_stride;
-                if((s->avctx->debug_mv) && pict->motion_val){
-                  int type;
-                  for(type=0; type<3; type++){
-                    int direction = 0;
-                    switch (type) {
-                      case 0: if ((!(s->avctx->debug_mv&FF_DEBUG_VIS_MV_P_FOR)) || (pict->pict_type!=FF_P_TYPE))
-                                continue;
-                              direction = 0;
-                              break;
-                      case 1: if ((!(s->avctx->debug_mv&FF_DEBUG_VIS_MV_B_FOR)) || (pict->pict_type!=FF_B_TYPE))
-                                continue;
-                              direction = 0;
-                              break;
-                      case 2: if ((!(s->avctx->debug_mv&FF_DEBUG_VIS_MV_B_BACK)) || (pict->pict_type!=FF_B_TYPE))
-                                continue;
-                              direction = 1;
-                              break;
-                    }
-                    if(!USES_LIST(pict->mb_type[mb_index], direction))
-                        continue;
-
-                    if(IS_8X8(pict->mb_type[mb_index])){
-                      int i;
-                      for(i=0; i<4; i++){
-                        int sx= mb_x*16 + 4 + 8*(i&1);
-                        int sy= mb_y*16 + 4 + 8*(i>>1);
-                        int xy= (mb_x*2 + (i&1) + (mb_y*2 + (i>>1))*mv_stride) << (mv_sample_log2-1);
-                        int mx= (pict->motion_val[direction][xy][0]>>shift) + sx;
-                        int my= (pict->motion_val[direction][xy][1]>>shift) + sy;
-                        draw_arrow(ptr, sx, sy, mx, my, width, height, s->linesize, 100);
-                      }
-                    }else if(IS_16X8(pict->mb_type[mb_index])){
-                      int i;
-                      for(i=0; i<2; i++){
-                        int sx=mb_x*16 + 8;
-                        int sy=mb_y*16 + 4 + 8*i;
-                        int xy= (mb_x*2 + (mb_y*2 + i)*mv_stride) << (mv_sample_log2-1);
-                        int mx=(pict->motion_val[direction][xy][0]>>shift);
-                        int my=(pict->motion_val[direction][xy][1]>>shift);
-                        
-                        if(IS_INTERLACED(pict->mb_type[mb_index]))
-                            my*=2;
-                        
-                        draw_arrow(ptr, sx, sy, mx+sx, my+sy, width, height, s->linesize, 100);
-                      }
-                    }else if(IS_8X16(pict->mb_type[mb_index])){
-                      int i;
-                      for(i=0; i<2; i++){
-                        int sx=mb_x*16 + 4 + 8*i;
-                        int sy=mb_y*16 + 8;
-                        int xy= (mb_x*2 + i + mb_y*2*mv_stride) << (mv_sample_log2-1);
-                        int mx=(pict->motion_val[direction][xy][0]>>shift);
-                        int my=(pict->motion_val[direction][xy][1]>>shift);
-                        
-                        if(IS_INTERLACED(pict->mb_type[mb_index]))
-                            my*=2;
-                        
-                        draw_arrow(ptr, sx, sy, mx+sx, my+sy, width, height, s->linesize, 100);
-                      }
-                    }else{
-                      int sx= mb_x*16 + 8;
-                      int sy= mb_y*16 + 8;
-                      int xy= (mb_x + mb_y*mv_stride) << mv_sample_log2;
-                      int mx= (pict->motion_val[direction][xy][0]>>shift) + sx;
-                      int my= (pict->motion_val[direction][xy][1]>>shift) + sy;
-                      draw_arrow(ptr, sx, sy, mx, my, width, height, s->linesize, 100);
-                    }
-                  }                  
-                }
-                if((s->avctx->debug&FF_DEBUG_VIS_QP) && pict->motion_val){
-                    uint64_t c= (pict->qscale_table[mb_index]*128/31) * 0x0101010101010101ULL;
-                    int y;
-                    for(y=0; y<8; y++){
-                        *(uint64_t*)(pict->data[1] + 8*mb_x + (8*mb_y + y)*pict->linesize[1])= c;
-                        *(uint64_t*)(pict->data[2] + 8*mb_x + (8*mb_y + y)*pict->linesize[2])= c;
-                    }
-                }
-                if((s->avctx->debug&FF_DEBUG_VIS_MB_TYPE) && pict->motion_val){
-                    int mb_type= pict->mb_type[mb_index];
-                    uint64_t u,v;
-                    int y;
-#define COLOR(theta, r)\
-u= (int)(128 + r*cos(theta*3.141592/180));\
-v= (int)(128 + r*sin(theta*3.141592/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{
-                        assert(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
-                        COLOR(300,48)
-                    }
-
-                    u*= 0x0101010101010101ULL;
-                    v*= 0x0101010101010101ULL;
-                    for(y=0; y<8; y++){
-                        *(uint64_t*)(pict->data[1] + 8*mb_x + (8*mb_y + y)*pict->linesize[1])= u;
-                        *(uint64_t*)(pict->data[2] + 8*mb_x + (8*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*)&pict->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) && s->codec_id == CODEC_ID_H264){
-                        // hmm
-                    }
-                }
-                s->mbskip_table[mb_index]=0;
-            }
-        }
-    }
-}
-
-#ifdef CONFIG_ENCODERS
-
-static int get_sae(uint8_t *src, int ref, int stride){
-    int x,y;
-    int acc=0;
-    
-    for(y=0; y<16; y++){
-        for(x=0; x<16; x++){
-            acc+= ABS(src[x+y*stride] - ref);
-        }
-    }
-    
-    return acc;
-}
-
-static int get_intra_count(MpegEncContext *s, uint8_t *src, uint8_t *ref, int stride){
-    int x, y, w, h;
-    int acc=0;
-    
-    w= s->width &~15;
-    h= s->height&~15;
-    
-    for(y=0; y<h; y+=16){
-        for(x=0; x<w; x+=16){
-            int offset= x + y*stride;
-            int sad = s->dsp.sad[0](NULL, src + offset, ref + offset, stride, 16);
-            int mean= (s->dsp.pix_sum(src + offset, stride) + 128)>>8;
-            int sae = get_sae(src + offset, mean, stride);
-            
-            acc+= sae + 500 < sad;
-        }
-    }
-    return acc;
-}
-
-
-static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){
-    AVFrame *pic=NULL;
-    int64_t pts;
-    int i;
-    const int encoding_delay= s->max_b_frames;
-    int direct=1;
-    
-    if(pic_arg){
-        pts= pic_arg->pts;
-        pic_arg->display_picture_number= s->input_picture_number++;
-
-        if(pts != AV_NOPTS_VALUE){ 
-            if(s->user_specified_pts != AV_NOPTS_VALUE){
-                int64_t time= pts;
-                int64_t last= s->user_specified_pts;
-            
-                if(time <= last){            
-                    av_log(s->avctx, AV_LOG_ERROR, "Error, Invalid timestamp=%Ld, last=%Ld\n", pts, s->user_specified_pts);
-                    return -1;
-                }
-            }
-            s->user_specified_pts= pts;
-        }else{
-            if(s->user_specified_pts != AV_NOPTS_VALUE){
-                s->user_specified_pts= 
-                pts= s->user_specified_pts + 1;
-                av_log(s->avctx, AV_LOG_INFO, "Warning: AVFrame.pts=? trying to guess (%Ld)\n", pts);
-            }else{
-                pts= pic_arg->display_picture_number;
-            }
-        }
-    }
-
-  if(pic_arg){
-    if(encoding_delay && !(s->flags&CODEC_FLAG_INPUT_PRESERVED)) direct=0;
-    if(pic_arg->linesize[0] != s->linesize) direct=0;
-    if(pic_arg->linesize[1] != s->uvlinesize) direct=0;
-    if(pic_arg->linesize[2] != s->uvlinesize) direct=0;
-  
-//    av_log(AV_LOG_DEBUG, "%d %d %d %d\n",pic_arg->linesize[0], pic_arg->linesize[1], s->linesize, s->uvlinesize);
-    
-    if(direct){
-        i= ff_find_unused_picture(s, 1);
-
-        pic= (AVFrame*)&s->picture[i];
-        pic->reference= 3;
-    
-        for(i=0; i<4; i++){
-            pic->data[i]= pic_arg->data[i];
-            pic->linesize[i]= pic_arg->linesize[i];
-        }
-        alloc_picture(s, (Picture*)pic, 1);
-    }else{
-        int offset= 16;
-        i= ff_find_unused_picture(s, 0);
-
-        pic= (AVFrame*)&s->picture[i];
-        pic->reference= 3;
-
-        alloc_picture(s, (Picture*)pic, 0);
-
-        if(   pic->data[0] + offset == pic_arg->data[0] 
-           && pic->data[1] + offset == pic_arg->data[1]
-           && pic->data[2] + offset == pic_arg->data[2]){
-       // empty
-        }else{
-            int h_chroma_shift, v_chroma_shift;
-            avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift, &v_chroma_shift);
-        
-            for(i=0; i<3; i++){
-                int src_stride= pic_arg->linesize[i];
-                int dst_stride= i ? s->uvlinesize : s->linesize;
-                int h_shift= i ? h_chroma_shift : 0;
-                int v_shift= i ? v_chroma_shift : 0;
-                int w= s->width >>h_shift;
-                int h= s->height>>v_shift;
-                uint8_t *src= pic_arg->data[i];
-                uint8_t *dst= pic->data[i] + offset;
-            
-                if(src_stride==dst_stride)
-                    memcpy(dst, src, src_stride*h);
-                else{
-                    while(h--){
-                        memcpy(dst, src, w);
-                        dst += dst_stride;
-                        src += src_stride;
-                    }
-                }
-            }
-        }
-    }
-    copy_picture_attributes(s, pic, pic_arg);
-    pic->pts= pts; //we set this here to avoid modifiying pic_arg
-  }
-  
-    /* shift buffer entries */
-    for(i=1; i<MAX_PICTURE_COUNT /*s->encoding_delay+1*/; i++)
-        s->input_picture[i-1]= s->input_picture[i];
-        
-    s->input_picture[encoding_delay]= (Picture*)pic;
-
-    return 0;
-}
-
-static int skip_check(MpegEncContext *s, Picture *p, Picture *ref){
-    int x, y, plane;
-    int score=0;
-    int64_t score64=0;
-
-    for(plane=0; plane<3; plane++){
-        const int stride= p->linesize[plane];
-        const int bw= plane ? 1 : 2;
-        for(y=0; y<s->mb_height*bw; y++){
-            for(x=0; x<s->mb_width*bw; x++){
-                int v= s->dsp.frame_skip_cmp[1](s, p->data[plane] + 8*(x + y*stride), ref->data[plane] + 8*(x + y*stride), stride, 8);
-                
-                switch(s->avctx->frame_skip_exp){
-                    case 0: score= FFMAX(score, v); break;
-                    case 1: score+= ABS(v);break;
-                    case 2: score+= v*v;break;
-                    case 3: score64+= ABS(v*v*(int64_t)v);break;
-                    case 4: score64+= v*v*(int64_t)(v*v);break;
-                }
-            }
-        }
-    }
-    
-    if(score) score64= score;
-
-    if(score64 < s->avctx->frame_skip_threshold)
-        return 1;
-    if(score64 < ((s->avctx->frame_skip_factor * (int64_t)s->lambda)>>8))
-        return 1;
-    return 0;
-}
-
-static void select_input_picture(MpegEncContext *s){
-    int i;
-
-    for(i=1; i<MAX_PICTURE_COUNT; i++)
-        s->reordered_input_picture[i-1]= s->reordered_input_picture[i];
-    s->reordered_input_picture[MAX_PICTURE_COUNT-1]= NULL;
-
-    /* set next picture type & ordering */
-    if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){
-        if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){
-            s->reordered_input_picture[0]= s->input_picture[0];
-            s->reordered_input_picture[0]->pict_type= I_TYPE;
-            s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++;
-        }else{
-            int b_frames;
-
-            if(s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor){
-                if(skip_check(s, s->input_picture[0], s->next_picture_ptr)){
-//av_log(NULL, AV_LOG_DEBUG, "skip %p %Ld\n", s->input_picture[0]->data[0], s->input_picture[0]->pts);
-                
-                    if(s->input_picture[0]->type == FF_BUFFER_TYPE_SHARED){
-                        for(i=0; i<4; i++)
-                            s->input_picture[0]->data[i]= NULL;
-                        s->input_picture[0]->type= 0;            
-                    }else{
-                        assert(   s->input_picture[0]->type==FF_BUFFER_TYPE_USER 
-                               || s->input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL);
-            
-                        s->avctx->release_buffer(s->avctx, (AVFrame*)s->input_picture[0]);
-                    }
-
-                    goto no_output_pic;
-                }
-            }
-
-            if(s->flags&CODEC_FLAG_PASS2){
-                for(i=0; i<s->max_b_frames+1; i++){
-                    int pict_num= s->input_picture[0]->display_picture_number + i;
-
-                    if(pict_num >= s->rc_context.num_entries) 
-                        break;
-                    if(!s->input_picture[i]){
-                        s->rc_context.entry[pict_num-1].new_pict_type = P_TYPE;
-                        break;
-                    }
-
-                    s->input_picture[i]->pict_type= 
-                        s->rc_context.entry[pict_num].new_pict_type;
-                }
-            }
-
-            if(s->avctx->b_frame_strategy==0){
-                b_frames= s->max_b_frames;
-                while(b_frames && !s->input_picture[b_frames]) b_frames--;
-            }else if(s->avctx->b_frame_strategy==1){
-                for(i=1; i<s->max_b_frames+1; i++){
-                    if(s->input_picture[i] && s->input_picture[i]->b_frame_score==0){
-                        s->input_picture[i]->b_frame_score= 
-                            get_intra_count(s, s->input_picture[i  ]->data[0], 
-                                               s->input_picture[i-1]->data[0], s->linesize) + 1;
-                    }
-                }
-                for(i=0; i<s->max_b_frames+1; i++){
-                    if(s->input_picture[i]==NULL || s->input_picture[i]->b_frame_score - 1 > s->mb_num/40) break;
-                }
-                                
-                b_frames= FFMAX(0, i-1);
-                
-                /* reset scores */
-                for(i=0; i<b_frames+1; i++){
-                    s->input_picture[i]->b_frame_score=0;
-                }
-            }else{
-                av_log(s->avctx, AV_LOG_ERROR, "illegal b frame strategy\n");
-                b_frames=0;
-            }
-
-            emms_c();
-//static int b_count=0;
-//b_count+= b_frames;
-//av_log(s->avctx, AV_LOG_DEBUG, "b_frames: %d\n", b_count);
-
-            for(i= b_frames - 1; i>=0; i--){
-                int type= s->input_picture[i]->pict_type;
-                if(type && type != B_TYPE)
-                    b_frames= i;
-            }
-            if(s->input_picture[b_frames]->pict_type == B_TYPE && b_frames == s->max_b_frames){
-                av_log(s->avctx, AV_LOG_ERROR, "warning, too many b frames in a row\n");
-            }
-
-            if(s->picture_in_gop_number + b_frames >= s->gop_size){
-              if((s->flags2 & CODEC_FLAG2_STRICT_GOP) && s->gop_size > s->picture_in_gop_number){
-                    b_frames= s->gop_size - s->picture_in_gop_number - 1;
-              }else{
-                if(s->flags & CODEC_FLAG_CLOSED_GOP)
-                    b_frames=0;
-                s->input_picture[b_frames]->pict_type= I_TYPE;
-              }
-            }
-            
-            if(   (s->flags & CODEC_FLAG_CLOSED_GOP)
-               && b_frames
-               && s->input_picture[b_frames]->pict_type== I_TYPE)
-                b_frames--;
-
-            s->reordered_input_picture[0]= s->input_picture[b_frames];
-            if(s->reordered_input_picture[0]->pict_type != I_TYPE)
-                s->reordered_input_picture[0]->pict_type= P_TYPE;
-            s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++;
-            for(i=0; i<b_frames; i++){
-                s->reordered_input_picture[i+1]= s->input_picture[i];
-                s->reordered_input_picture[i+1]->pict_type= B_TYPE;
-                s->reordered_input_picture[i+1]->coded_picture_number= s->coded_picture_number++;
-            }
-        }
-    }
-no_output_pic:
-    if(s->reordered_input_picture[0]){
-        s->reordered_input_picture[0]->reference= s->reordered_input_picture[0]->pict_type!=B_TYPE ? 3 : 0;
-
-        copy_picture(&s->new_picture, s->reordered_input_picture[0]);
-
-        if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED){
-            // input is a shared pix, so we can't modifiy it -> alloc a new one & ensure that the shared one is reuseable
-        
-            int i= ff_find_unused_picture(s, 0);
-            Picture *pic= &s->picture[i];
-
-            /* mark us unused / free shared pic */
-            for(i=0; i<4; i++)
-                s->reordered_input_picture[0]->data[i]= NULL;
-            s->reordered_input_picture[0]->type= 0;
-            
-            pic->reference              = s->reordered_input_picture[0]->reference;
-            
-            alloc_picture(s, pic, 0);
-
-            copy_picture_attributes(s, (AVFrame*)pic, (AVFrame*)s->reordered_input_picture[0]);
-
-            s->current_picture_ptr= pic;
-        }else{
-            // input is not a shared pix -> reuse buffer for current_pix
-
-            assert(   s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_USER 
-                   || s->reordered_input_picture[0]->type==FF_BUFFER_TYPE_INTERNAL);
-            
-            s->current_picture_ptr= s->reordered_input_picture[0];
-            for(i=0; i<4; i++){
-                s->new_picture.data[i]+=16;
-            }
-        }
-        copy_picture(&s->current_picture, s->current_picture_ptr);
-    
-        s->picture_number= s->new_picture.display_picture_number;
-//printf("dpn:%d\n", s->picture_number);
-    }else{
-       memset(&s->new_picture, 0, sizeof(Picture));
-    }
-}
-
-int MPV_encode_picture(AVCodecContext *avctx,
-                       unsigned char *buf, int buf_size, void *data)
-{
-    MpegEncContext *s = avctx->priv_data;
-    AVFrame *pic_arg = data;
-    int i, stuffing_count;
-
-    if(avctx->pix_fmt != PIX_FMT_YUV420P && avctx->pix_fmt != PIX_FMT_YUVJ420P){
-        av_log(avctx, AV_LOG_ERROR, "this codec supports only YUV420P\n");
-        return -1;
-    }
-    
-    for(i=0; i<avctx->thread_count; i++){
-        int start_y= s->thread_context[i]->start_mb_y;
-        int   end_y= s->thread_context[i]->  end_mb_y;
-        int h= s->mb_height;
-        uint8_t *start= buf + (size_t)(((int64_t) buf_size)*start_y/h);
-        uint8_t *end  = buf + (size_t)(((int64_t) buf_size)*  end_y/h);
-
-        init_put_bits(&s->thread_context[i]->pb, start, end - start);
-    }
-
-    s->picture_in_gop_number++;
-
-    if(load_input_picture(s, pic_arg) < 0)
-        return -1;
-    
-    select_input_picture(s);
-    
-    /* output? */
-    if(s->new_picture.data[0]){
-        s->pict_type= s->new_picture.pict_type;
-//emms_c();
-//printf("qs:%f %f %d\n", s->new_picture.quality, s->current_picture.quality, s->qscale);
-        MPV_frame_start(s, avctx);
-
-        encode_picture(s, s->picture_number);
-        
-        avctx->real_pict_num  = s->picture_number;
-        avctx->header_bits = s->header_bits;
-        avctx->mv_bits     = s->mv_bits;
-        avctx->misc_bits   = s->misc_bits;
-        avctx->i_tex_bits  = s->i_tex_bits;
-        avctx->p_tex_bits  = s->p_tex_bits;
-        avctx->i_count     = s->i_count;
-        avctx->p_count     = s->mb_num - s->i_count - s->skip_count; //FIXME f/b_count in avctx
-        avctx->skip_count  = s->skip_count;
-
-        MPV_frame_end(s);
-
-        if (s->out_format == FMT_MJPEG)
-            mjpeg_picture_trailer(s);
-        
-        if(s->flags&CODEC_FLAG_PASS1)
-            ff_write_pass1_stats(s);
-
-        for(i=0; i<4; i++){
-            avctx->error[i] += s->current_picture_ptr->error[i];
-        }
-
-        if(s->flags&CODEC_FLAG_PASS1)
-            assert(avctx->header_bits + avctx->mv_bits + avctx->misc_bits + avctx->i_tex_bits + avctx->p_tex_bits == put_bits_count(&s->pb));
-        flush_put_bits(&s->pb);
-        s->frame_bits  = put_bits_count(&s->pb);
-
-        stuffing_count= ff_vbv_update(s, s->frame_bits);
-        if(stuffing_count){
-            if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < stuffing_count + 50){
-                av_log(s->avctx, AV_LOG_ERROR, "stuffing too large\n");
-                return -1;
-            }
-
-            switch(s->codec_id){
-            case CODEC_ID_MPEG1VIDEO:
-            case CODEC_ID_MPEG2VIDEO:
-                while(stuffing_count--){
-                    put_bits(&s->pb, 8, 0);
-                }
-            break;
-//             case CODEC_ID_MPEG4:
-//                 put_bits(&s->pb, 16, 0);
-//                 put_bits(&s->pb, 16, 0x1C3);
-//                 stuffing_count -= 4;
-//                 while(stuffing_count--){
-//                     put_bits(&s->pb, 8, 0xFF);
-//                 }
-//             break;
-            default:
-                av_log(s->avctx, AV_LOG_ERROR, "vbv buffer overflow\n");
-            }
-            flush_put_bits(&s->pb);
-            s->frame_bits  = put_bits_count(&s->pb);
-        }
-
-        /* update mpeg1/2 vbv_delay for CBR */    
-        if(s->avctx->rc_max_rate && s->avctx->rc_min_rate == s->avctx->rc_max_rate && s->out_format == FMT_MPEG1
-           && 90000LL * (avctx->rc_buffer_size-1) <= s->avctx->rc_max_rate*0xFFFFLL){
-            int vbv_delay;
-
-            assert(s->repeat_first_field==0);
-            
-            vbv_delay= lrintf(90000 * s->rc_context.buffer_index / s->avctx->rc_max_rate);
-            assert(vbv_delay < 0xFFFF);
-
-            s->vbv_delay_ptr[0] &= 0xF8;
-            s->vbv_delay_ptr[0] |= vbv_delay>>13;
-            s->vbv_delay_ptr[1]  = vbv_delay>>5;
-            s->vbv_delay_ptr[2] &= 0x07;
-            s->vbv_delay_ptr[2] |= vbv_delay<<3;
-        }
-        s->total_bits += s->frame_bits;
-        avctx->frame_bits  = s->frame_bits;
-    }else{
-        assert((pbBufPtr(&s->pb) == s->pb.buf));
-        s->frame_bits=0;
-    }
-    assert((s->frame_bits&7)==0);
-    
-    return s->frame_bits/8;
-}
-
-#endif //CONFIG_ENCODERS
-
-static inline void gmc1_motion(MpegEncContext *s,
-                               uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
-                               uint8_t **ref_picture)
-{
-    uint8_t *ptr;
-    int offset, src_x, src_y, linesize, uvlinesize;
-    int motion_x, motion_y;
-    int emu=0;
-
-    motion_x= s->sprite_offset[0][0];
-    motion_y= s->sprite_offset[0][1];
-    src_x = s->mb_x * 16 + (motion_x >> (s->sprite_warping_accuracy+1));
-    src_y = s->mb_y * 16 + (motion_y >> (s->sprite_warping_accuracy+1));
-    motion_x<<=(3-s->sprite_warping_accuracy);
-    motion_y<<=(3-s->sprite_warping_accuracy);
-    src_x = clip(src_x, -16, s->width);
-    if (src_x == s->width)
-        motion_x =0;
-    src_y = clip(src_y, -16, s->height);
-    if (src_y == s->height)
-        motion_y =0;
-
-    linesize = s->linesize;
-    uvlinesize = s->uvlinesize;
-    
-    ptr = ref_picture[0] + (src_y * linesize) + src_x;
-
-    if(s->flags&CODEC_FLAG_EMU_EDGE){
-        if(   (unsigned)src_x >= s->h_edge_pos - 17
-           || (unsigned)src_y >= s->v_edge_pos - 17){
-            ff_emulated_edge_mc(s->edge_emu_buffer, ptr, linesize, 17, 17, src_x, src_y, s->h_edge_pos, s->v_edge_pos);
-            ptr= s->edge_emu_buffer;
-        }
-    }
-    
-    if((motion_x|motion_y)&7){
-        s->dsp.gmc1(dest_y  , ptr  , linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding);
-        s->dsp.gmc1(dest_y+8, ptr+8, linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding);
-    }else{
-        int dxy;
-        
-        dxy= ((motion_x>>3)&1) | ((motion_y>>2)&2);
-        if (s->no_rounding){
-	    s->dsp.put_no_rnd_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);
-        }else{
-            s->dsp.put_pixels_tab       [0][dxy](dest_y, ptr, linesize, 16);
-        }
-    }
-    
-    if(s->flags&CODEC_FLAG_GRAY) return;
-
-    motion_x= s->sprite_offset[1][0];
-    motion_y= s->sprite_offset[1][1];
-    src_x = s->mb_x * 8 + (motion_x >> (s->sprite_warping_accuracy+1));
-    src_y = s->mb_y * 8 + (motion_y >> (s->sprite_warping_accuracy+1));
-    motion_x<<=(3-s->sprite_warping_accuracy);
-    motion_y<<=(3-s->sprite_warping_accuracy);
-    src_x = clip(src_x, -8, s->width>>1);
-    if (src_x == s->width>>1)
-        motion_x =0;
-    src_y = clip(src_y, -8, s->height>>1);
-    if (src_y == s->height>>1)
-        motion_y =0;
-
-    offset = (src_y * uvlinesize) + src_x;
-    ptr = ref_picture[1] + offset;
-    if(s->flags&CODEC_FLAG_EMU_EDGE){
-        if(   (unsigned)src_x >= (s->h_edge_pos>>1) - 9
-           || (unsigned)src_y >= (s->v_edge_pos>>1) - 9){
-            ff_emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
-            ptr= s->edge_emu_buffer;
-            emu=1;
-        }
-    }
-    s->dsp.gmc1(dest_cb, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);
-    
-    ptr = ref_picture[2] + offset;
-    if(emu){
-        ff_emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
-        ptr= s->edge_emu_buffer;
-    }
-    s->dsp.gmc1(dest_cr, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);
-    
-    return;
-}
-
-static inline void gmc_motion(MpegEncContext *s,
-                               uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
-                               uint8_t **ref_picture)
-{
-    uint8_t *ptr;
-    int linesize, uvlinesize;
-    const int a= s->sprite_warping_accuracy;
-    int ox, oy;
-
-    linesize = s->linesize;
-    uvlinesize = s->uvlinesize;
-
-    ptr = ref_picture[0];
-
-    ox= s->sprite_offset[0][0] + s->sprite_delta[0][0]*s->mb_x*16 + s->sprite_delta[0][1]*s->mb_y*16;
-    oy= s->sprite_offset[0][1] + s->sprite_delta[1][0]*s->mb_x*16 + s->sprite_delta[1][1]*s->mb_y*16;
-
-    s->dsp.gmc(dest_y, ptr, linesize, 16,
-           ox, 
-           oy, 
-           s->sprite_delta[0][0], s->sprite_delta[0][1],
-           s->sprite_delta[1][0], s->sprite_delta[1][1], 
-           a+1, (1<<(2*a+1)) - s->no_rounding,
-           s->h_edge_pos, s->v_edge_pos);
-    s->dsp.gmc(dest_y+8, ptr, linesize, 16,
-           ox + s->sprite_delta[0][0]*8, 
-           oy + s->sprite_delta[1][0]*8, 
-           s->sprite_delta[0][0], s->sprite_delta[0][1],
-           s->sprite_delta[1][0], s->sprite_delta[1][1], 
-           a+1, (1<<(2*a+1)) - s->no_rounding,
-           s->h_edge_pos, s->v_edge_pos);
-
-    if(s->flags&CODEC_FLAG_GRAY) return;
-
-    ox= s->sprite_offset[1][0] + s->sprite_delta[0][0]*s->mb_x*8 + s->sprite_delta[0][1]*s->mb_y*8;
-    oy= s->sprite_offset[1][1] + s->sprite_delta[1][0]*s->mb_x*8 + s->sprite_delta[1][1]*s->mb_y*8;
-
-    ptr = ref_picture[1];
-    s->dsp.gmc(dest_cb, ptr, uvlinesize, 8,
-           ox, 
-           oy, 
-           s->sprite_delta[0][0], s->sprite_delta[0][1],
-           s->sprite_delta[1][0], s->sprite_delta[1][1], 
-           a+1, (1<<(2*a+1)) - s->no_rounding,
-           s->h_edge_pos>>1, s->v_edge_pos>>1);
-    
-    ptr = ref_picture[2];
-    s->dsp.gmc(dest_cr, ptr, uvlinesize, 8,
-           ox, 
-           oy, 
-           s->sprite_delta[0][0], s->sprite_delta[0][1],
-           s->sprite_delta[1][0], s->sprite_delta[1][1], 
-           a+1, (1<<(2*a+1)) - s->no_rounding,
-           s->h_edge_pos>>1, s->v_edge_pos>>1);
-}
-
-/**
- * Copies a rectangular area of samples to a temporary buffer and replicates the boarder samples.
- * @param buf destination buffer
- * @param src source buffer
- * @param linesize number of bytes between 2 vertically adjacent samples in both the source and destination buffers
- * @param block_w width of block
- * @param block_h height of block
- * @param src_x x coordinate of the top left sample of the block in the source buffer
- * @param src_y y coordinate of the top left sample of the block in the source buffer
- * @param w width of the source buffer
- * @param h height of the source buffer
- */
-void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize, int block_w, int block_h, 
-                                    int src_x, int src_y, int w, int h){
-    int x, y;
-    int start_y, start_x, end_y, end_x;
-
-    if(src_y>= h){
-        src+= (h-1-src_y)*linesize;
-        src_y=h-1;
-    }else if(src_y<=-block_h){
-        src+= (1-block_h-src_y)*linesize;
-        src_y=1-block_h;
-    }
-    if(src_x>= w){
-        src+= (w-1-src_x);
-        src_x=w-1;
-    }else if(src_x<=-block_w){
-        src+= (1-block_w-src_x);
-        src_x=1-block_w;
-    }
-
-    start_y= FFMAX(0, -src_y);
-    start_x= FFMAX(0, -src_x);
-    end_y= FFMIN(block_h, h-src_y);
-    end_x= FFMIN(block_w, w-src_x);
-
-    // copy existing part
-    for(y=start_y; y<end_y; y++){
-        for(x=start_x; x<end_x; x++){
-            buf[x + y*linesize]= src[x + y*linesize];
-        }
-    }
-
-    //top
-    for(y=0; y<start_y; y++){
-        for(x=start_x; x<end_x; x++){
-            buf[x + y*linesize]= buf[x + start_y*linesize];
-        }
-    }
-
-    //bottom
-    for(y=end_y; y<block_h; y++){
-        for(x=start_x; x<end_x; x++){
-            buf[x + y*linesize]= buf[x + (end_y-1)*linesize];
-        }
-    }
-                                    
-    for(y=0; y<block_h; y++){
-       //left
-        for(x=0; x<start_x; x++){
-            buf[x + y*linesize]= buf[start_x + y*linesize];
-        }
-       
-       //right
-        for(x=end_x; x<block_w; x++){
-            buf[x + y*linesize]= buf[end_x - 1 + y*linesize];
-        }
-    }
-}
-
-static inline int hpel_motion(MpegEncContext *s, 
-                                  uint8_t *dest, uint8_t *src,
-                                  int field_based, int field_select,
-                                  int src_x, int src_y,
-                                  int width, int height, int stride,
-                                  int h_edge_pos, int v_edge_pos,
-                                  int w, int h, op_pixels_func *pix_op,
-                                  int motion_x, int motion_y)
-{
-    int dxy;
-    int emu=0;
-
-    dxy = ((motion_y & 1) << 1) | (motion_x & 1);
-    src_x += motion_x >> 1;
-    src_y += motion_y >> 1;
-                
-    /* WARNING: do no forget half pels */
-    src_x = clip(src_x, -16, width); //FIXME unneeded for emu?
-    if (src_x == width)
-        dxy &= ~1;
-    src_y = clip(src_y, -16, height);
-    if (src_y == height)
-        dxy &= ~2;
-    src += src_y * stride + src_x;
-
-    if(s->unrestricted_mv && (s->flags&CODEC_FLAG_EMU_EDGE)){
-        if(   (unsigned)src_x > h_edge_pos - (motion_x&1) - w
-           || (unsigned)src_y > v_edge_pos - (motion_y&1) - h){
-            ff_emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, w+1, (h+1)<<field_based,
-                             src_x, src_y<<field_based, h_edge_pos, s->v_edge_pos);
-            src= s->edge_emu_buffer;
-            emu=1;
-        }
-    }
-    if(field_select)
-        src += s->linesize;
-    pix_op[dxy](dest, src, stride, h);
-    return emu;
-}
-
-static inline int hpel_motion_lowres(MpegEncContext *s, 
-                                  uint8_t *dest, uint8_t *src,
-                                  int field_based, int field_select,
-                                  int src_x, int src_y,
-                                  int width, int height, int stride,
-                                  int h_edge_pos, int v_edge_pos,
-                                  int w, int h, h264_chroma_mc_func *pix_op,
-                                  int motion_x, int motion_y)
-{
-    const int lowres= s->avctx->lowres;
-    const int s_mask= (2<<lowres)-1;
-    int emu=0;
-    int sx, sy;
-
-    if(s->quarter_sample){
-        motion_x/=2;
-        motion_y/=2;
-    }
-
-    sx= motion_x & s_mask;
-    sy= motion_y & s_mask;
-    src_x += motion_x >> (lowres+1);
-    src_y += motion_y >> (lowres+1);
-                
-    src += src_y * stride + src_x;
-
-    if(   (unsigned)src_x > h_edge_pos                 - (!!sx) - w
-       || (unsigned)src_y >(v_edge_pos >> field_based) - (!!sy) - h){
-        ff_emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, w+1, (h+1)<<field_based,
-                            src_x, src_y<<field_based, h_edge_pos, v_edge_pos);
-        src= s->edge_emu_buffer;
-        emu=1;
-    }
-
-    sx <<= 2 - lowres;
-    sy <<= 2 - lowres;
-    if(field_select)
-        src += s->linesize;
-    pix_op[lowres](dest, src, stride, h, sx, sy);
-    return emu;
-}
-
-/* apply one mpeg motion vector to the three components */
-static always_inline void mpeg_motion(MpegEncContext *s,
-                               uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
-                               int field_based, int bottom_field, int field_select,
-                               uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
-                               int motion_x, int motion_y, int h)
-{
-    uint8_t *ptr_y, *ptr_cb, *ptr_cr;
-    int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y, v_edge_pos, uvlinesize, linesize;
-    
-#if 0    
-if(s->quarter_sample)
-{
-    motion_x>>=1;
-    motion_y>>=1;
-}
-#endif
-
-    v_edge_pos = s->v_edge_pos >> field_based;
-    linesize   = s->current_picture.linesize[0] << field_based;
-    uvlinesize = s->current_picture.linesize[1] << field_based;
-
-    dxy = ((motion_y & 1) << 1) | (motion_x & 1);
-    src_x = s->mb_x* 16               + (motion_x >> 1);
-    src_y =(s->mb_y<<(4-field_based)) + (motion_y >> 1);
-
-    if (s->out_format == FMT_H263) {
-        if((s->workaround_bugs & FF_BUG_HPEL_CHROMA) && field_based){
-            mx = (motion_x>>1)|(motion_x&1);
-            my = motion_y >>1;
-            uvdxy = ((my & 1) << 1) | (mx & 1);
-            uvsrc_x = s->mb_x* 8               + (mx >> 1);
-            uvsrc_y = (s->mb_y<<(3-field_based)) + (my >> 1);
-        }else{
-            uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
-            uvsrc_x = src_x>>1;
-            uvsrc_y = src_y>>1;
-        }
-    }else if(s->out_format == FMT_H261){//even chroma mv's are full pel in H261
-        mx = motion_x / 4;
-        my = motion_y / 4;
-        uvdxy = 0;
-        uvsrc_x = s->mb_x*8 + mx;
-        uvsrc_y = s->mb_y*8 + my;
-    } else {
-        if(s->chroma_y_shift){
-            mx = motion_x / 2;
-            my = motion_y / 2;
-            uvdxy = ((my & 1) << 1) | (mx & 1);
-            uvsrc_x = s->mb_x* 8               + (mx >> 1);
-            uvsrc_y = (s->mb_y<<(3-field_based)) + (my >> 1);
-        } else {
-            if(s->chroma_x_shift){
-            //Chroma422
-                mx = motion_x / 2;
-                uvdxy = ((motion_y & 1) << 1) | (mx & 1);
-                uvsrc_x = s->mb_x* 8           + (mx >> 1);
-                uvsrc_y = src_y;
-            } else {
-            //Chroma444
-                uvdxy = dxy;
-                uvsrc_x = src_x;
-                uvsrc_y = src_y;
-            }
-        }
-    }
-
-    ptr_y  = ref_picture[0] + src_y * linesize + src_x;
-    ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
-    ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
-
-    if(   (unsigned)src_x > s->h_edge_pos - (motion_x&1) - 16
-       || (unsigned)src_y >    v_edge_pos - (motion_y&1) - h){
-            if(s->codec_id == CODEC_ID_MPEG2VIDEO ||
-               s->codec_id == CODEC_ID_MPEG1VIDEO){
-                av_log(s->avctx,AV_LOG_DEBUG,"MPEG motion vector out of boundary\n");
-                return ;
-            }
-            ff_emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize, 17, 17+field_based,
-                             src_x, src_y<<field_based, s->h_edge_pos, s->v_edge_pos);
-            ptr_y = s->edge_emu_buffer;
-            if(!(s->flags&CODEC_FLAG_GRAY)){
-                uint8_t *uvbuf= s->edge_emu_buffer+18*s->linesize;
-                ff_emulated_edge_mc(uvbuf  , ptr_cb, s->uvlinesize, 9, 9+field_based, 
-                                 uvsrc_x, uvsrc_y<<field_based, s->h_edge_pos>>1, s->v_edge_pos>>1);
-                ff_emulated_edge_mc(uvbuf+16, ptr_cr, s->uvlinesize, 9, 9+field_based, 
-                                 uvsrc_x, uvsrc_y<<field_based, s->h_edge_pos>>1, s->v_edge_pos>>1);
-                ptr_cb= uvbuf;
-                ptr_cr= uvbuf+16;
-            }
-    }
-
-    if(bottom_field){ //FIXME use this for field pix too instead of the obnoxious hack which changes picture.data
-        dest_y += s->linesize;
-        dest_cb+= s->uvlinesize;
-        dest_cr+= s->uvlinesize;
-    }
-
-    if(field_select){
-        ptr_y += s->linesize;
-        ptr_cb+= s->uvlinesize;
-        ptr_cr+= s->uvlinesize;
-    }
-
-    pix_op[0][dxy](dest_y, ptr_y, linesize, h);
-    
-    if(!(s->flags&CODEC_FLAG_GRAY)){
-        pix_op[s->chroma_x_shift][uvdxy](dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift);
-        pix_op[s->chroma_x_shift][uvdxy](dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift);
-    }
-#if defined(CONFIG_H261_ENCODER) || defined(CONFIG_H261_DECODER)
-    if(s->out_format == FMT_H261){
-        ff_h261_loop_filter(s);
-    }
-#endif
-}
-
-/* apply one mpeg motion vector to the three components */
-static always_inline void mpeg_motion_lowres(MpegEncContext *s,
-                               uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
-                               int field_based, int bottom_field, int field_select,
-                               uint8_t **ref_picture, h264_chroma_mc_func *pix_op,
-                               int motion_x, int motion_y, int h)
-{
-    uint8_t *ptr_y, *ptr_cb, *ptr_cr;
-    int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, uvlinesize, linesize, sx, sy, uvsx, uvsy;
-    const int lowres= s->avctx->lowres;
-    const int block_s= 8>>lowres;
-    const int s_mask= (2<<lowres)-1;
-    const int h_edge_pos = s->h_edge_pos >> lowres;
-    const int v_edge_pos = s->v_edge_pos >> lowres;
-    linesize   = s->current_picture.linesize[0] << field_based;
-    uvlinesize = s->current_picture.linesize[1] << field_based;
-
-    if(s->quarter_sample){ //FIXME obviously not perfect but qpel wont work in lowres anyway
-        motion_x/=2;
-        motion_y/=2;
-    }
-    
-    if(field_based){
-        motion_y += (bottom_field - field_select)*((1<<lowres)-1);
-    }
-
-    sx= motion_x & s_mask;
-    sy= motion_y & s_mask;
-    src_x = s->mb_x*2*block_s               + (motion_x >> (lowres+1));
-    src_y =(s->mb_y*2*block_s>>field_based) + (motion_y >> (lowres+1));
-    
-    if (s->out_format == FMT_H263) {
-        uvsx = ((motion_x>>1) & s_mask) | (sx&1);
-        uvsy = ((motion_y>>1) & s_mask) | (sy&1);
-        uvsrc_x = src_x>>1;
-        uvsrc_y = src_y>>1;
-    }else if(s->out_format == FMT_H261){//even chroma mv's are full pel in H261
-        mx = motion_x / 4;
-        my = motion_y / 4;
-        uvsx = (2*mx) & s_mask;
-        uvsy = (2*my) & s_mask;
-        uvsrc_x = s->mb_x*block_s               + (mx >> lowres);
-        uvsrc_y = s->mb_y*block_s               + (my >> lowres);
-    } else {
-        mx = motion_x / 2;
-        my = motion_y / 2;
-        uvsx = mx & s_mask;
-        uvsy = my & s_mask;
-        uvsrc_x = s->mb_x*block_s               + (mx >> (lowres+1));
-        uvsrc_y =(s->mb_y*block_s>>field_based) + (my >> (lowres+1));
-    }
-
-    ptr_y  = ref_picture[0] + src_y * linesize + src_x;
-    ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
-    ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
-
-    if(   (unsigned)src_x > h_edge_pos                 - (!!sx) - 2*block_s
-       || (unsigned)src_y >(v_edge_pos >> field_based) - (!!sy) - h){
-            ff_emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize, 17, 17+field_based,
-                             src_x, src_y<<field_based, h_edge_pos, v_edge_pos);
-            ptr_y = s->edge_emu_buffer;
-            if(!(s->flags&CODEC_FLAG_GRAY)){
-                uint8_t *uvbuf= s->edge_emu_buffer+18*s->linesize;
-                ff_emulated_edge_mc(uvbuf  , ptr_cb, s->uvlinesize, 9, 9+field_based, 
-                                 uvsrc_x, uvsrc_y<<field_based, h_edge_pos>>1, v_edge_pos>>1);
-                ff_emulated_edge_mc(uvbuf+16, ptr_cr, s->uvlinesize, 9, 9+field_based, 
-                                 uvsrc_x, uvsrc_y<<field_based, h_edge_pos>>1, v_edge_pos>>1);
-                ptr_cb= uvbuf;
-                ptr_cr= uvbuf+16;
-            }
-    }
-
-    if(bottom_field){ //FIXME use this for field pix too instead of the obnoxious hack which changes picture.data
-        dest_y += s->linesize;
-        dest_cb+= s->uvlinesize;
-        dest_cr+= s->uvlinesize;
-    }
-
-    if(field_select){
-        ptr_y += s->linesize;
-        ptr_cb+= s->uvlinesize;
-        ptr_cr+= s->uvlinesize;
-    }
-
-    sx <<= 2 - lowres;
-    sy <<= 2 - lowres;
-    pix_op[lowres-1](dest_y, ptr_y, linesize, h, sx, sy);
-    
-    if(!(s->flags&CODEC_FLAG_GRAY)){
-        uvsx <<= 2 - lowres;
-        uvsy <<= 2 - lowres;
-        pix_op[lowres](dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy);
-        pix_op[lowres](dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy);
-    }
-    //FIXME h261 lowres loop filter
-}
-
-//FIXME move to dsputil, avg variant, 16x16 version
-static inline void put_obmc(uint8_t *dst, uint8_t *src[5], int stride){
-    int x;
-    uint8_t * const top   = src[1];
-    uint8_t * const left  = src[2];
-    uint8_t * const mid   = src[0];
-    uint8_t * const right = src[3];
-    uint8_t * const bottom= src[4];
-#define OBMC_FILTER(x, t, l, m, r, b)\
-    dst[x]= (t*top[x] + l*left[x] + m*mid[x] + r*right[x] + b*bottom[x] + 4)>>3
-#define OBMC_FILTER4(x, t, l, m, r, b)\
-    OBMC_FILTER(x         , t, l, m, r, b);\
-    OBMC_FILTER(x+1       , t, l, m, r, b);\
-    OBMC_FILTER(x  +stride, t, l, m, r, b);\
-    OBMC_FILTER(x+1+stride, t, l, m, r, b);
-    
-    x=0;
-    OBMC_FILTER (x  , 2, 2, 4, 0, 0);
-    OBMC_FILTER (x+1, 2, 1, 5, 0, 0);
-    OBMC_FILTER4(x+2, 2, 1, 5, 0, 0);
-    OBMC_FILTER4(x+4, 2, 0, 5, 1, 0);
-    OBMC_FILTER (x+6, 2, 0, 5, 1, 0);
-    OBMC_FILTER (x+7, 2, 0, 4, 2, 0);
-    x+= stride;
-    OBMC_FILTER (x  , 1, 2, 5, 0, 0);
-    OBMC_FILTER (x+1, 1, 2, 5, 0, 0);
-    OBMC_FILTER (x+6, 1, 0, 5, 2, 0);
-    OBMC_FILTER (x+7, 1, 0, 5, 2, 0);
-    x+= stride;
-    OBMC_FILTER4(x  , 1, 2, 5, 0, 0);
-    OBMC_FILTER4(x+2, 1, 1, 6, 0, 0);
-    OBMC_FILTER4(x+4, 1, 0, 6, 1, 0);
-    OBMC_FILTER4(x+6, 1, 0, 5, 2, 0);
-    x+= 2*stride;
-    OBMC_FILTER4(x  , 0, 2, 5, 0, 1);
-    OBMC_FILTER4(x+2, 0, 1, 6, 0, 1);
-    OBMC_FILTER4(x+4, 0, 0, 6, 1, 1);
-    OBMC_FILTER4(x+6, 0, 0, 5, 2, 1);
-    x+= 2*stride;
-    OBMC_FILTER (x  , 0, 2, 5, 0, 1);
-    OBMC_FILTER (x+1, 0, 2, 5, 0, 1);
-    OBMC_FILTER4(x+2, 0, 1, 5, 0, 2);
-    OBMC_FILTER4(x+4, 0, 0, 5, 1, 2);
-    OBMC_FILTER (x+6, 0, 0, 5, 2, 1);
-    OBMC_FILTER (x+7, 0, 0, 5, 2, 1);
-    x+= stride;
-    OBMC_FILTER (x  , 0, 2, 4, 0, 2);
-    OBMC_FILTER (x+1, 0, 1, 5, 0, 2);
-    OBMC_FILTER (x+6, 0, 0, 5, 1, 2);
-    OBMC_FILTER (x+7, 0, 0, 4, 2, 2);
-}
-
-/* obmc for 1 8x8 luma block */
-static inline void obmc_motion(MpegEncContext *s,
-                               uint8_t *dest, uint8_t *src,
-                               int src_x, int src_y,
-                               op_pixels_func *pix_op,
-                               int16_t mv[5][2]/* mid top left right bottom*/)
-#define MID    0
-{
-    int i;
-    uint8_t *ptr[5];
-    
-    assert(s->quarter_sample==0);
-    
-    for(i=0; i<5; i++){
-        if(i && mv[i][0]==mv[MID][0] && mv[i][1]==mv[MID][1]){
-            ptr[i]= ptr[MID];
-        }else{
-            ptr[i]= s->obmc_scratchpad + 8*(i&1) + s->linesize*8*(i>>1);
-            hpel_motion(s, ptr[i], src, 0, 0,
-                        src_x, src_y,
-                        s->width, s->height, s->linesize,
-                        s->h_edge_pos, s->v_edge_pos,
-                        8, 8, pix_op,
-                        mv[i][0], mv[i][1]);
-        }
-    }
-
-    put_obmc(dest, ptr, s->linesize);                
-}
-
-static inline void qpel_motion(MpegEncContext *s,
-                               uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
-                               int field_based, int bottom_field, int field_select,
-                               uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
-                               qpel_mc_func (*qpix_op)[16],
-                               int motion_x, int motion_y, int h)
-{
-    uint8_t *ptr_y, *ptr_cb, *ptr_cr;
-    int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y, v_edge_pos, linesize, uvlinesize;
-
-    dxy = ((motion_y & 3) << 2) | (motion_x & 3);
-    src_x = s->mb_x *  16                 + (motion_x >> 2);
-    src_y = s->mb_y * (16 >> field_based) + (motion_y >> 2);
-
-    v_edge_pos = s->v_edge_pos >> field_based;
-    linesize = s->linesize << field_based;
-    uvlinesize = s->uvlinesize << field_based;
-    
-    if(field_based){
-        mx= motion_x/2;
-        my= motion_y>>1;
-    }else if(s->workaround_bugs&FF_BUG_QPEL_CHROMA2){
-        static const int rtab[8]= {0,0,1,1,0,0,0,1};
-        mx= (motion_x>>1) + rtab[motion_x&7];
-        my= (motion_y>>1) + rtab[motion_y&7];
-    }else if(s->workaround_bugs&FF_BUG_QPEL_CHROMA){
-        mx= (motion_x>>1)|(motion_x&1);
-        my= (motion_y>>1)|(motion_y&1);
-    }else{
-        mx= motion_x/2;
-        my= motion_y/2;
-    }
-    mx= (mx>>1)|(mx&1);
-    my= (my>>1)|(my&1);
-
-    uvdxy= (mx&1) | ((my&1)<<1);
-    mx>>=1;
-    my>>=1;
-
-    uvsrc_x = s->mb_x *  8                 + mx;
-    uvsrc_y = s->mb_y * (8 >> field_based) + my;
-
-    ptr_y  = ref_picture[0] +   src_y *   linesize +   src_x;
-    ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
-    ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
-
-    if(   (unsigned)src_x > s->h_edge_pos - (motion_x&3) - 16 
-       || (unsigned)src_y >    v_edge_pos - (motion_y&3) - h  ){
-        ff_emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize, 17, 17+field_based, 
-                         src_x, src_y<<field_based, s->h_edge_pos, s->v_edge_pos);
-        ptr_y= s->edge_emu_buffer;
-        if(!(s->flags&CODEC_FLAG_GRAY)){
-            uint8_t *uvbuf= s->edge_emu_buffer + 18*s->linesize;
-            ff_emulated_edge_mc(uvbuf, ptr_cb, s->uvlinesize, 9, 9 + field_based, 
-                             uvsrc_x, uvsrc_y<<field_based, s->h_edge_pos>>1, s->v_edge_pos>>1);
-            ff_emulated_edge_mc(uvbuf + 16, ptr_cr, s->uvlinesize, 9, 9 + field_based, 
-                             uvsrc_x, uvsrc_y<<field_based, s->h_edge_pos>>1, s->v_edge_pos>>1);
-            ptr_cb= uvbuf;
-            ptr_cr= uvbuf + 16;
-        }
-    }
-
-    if(!field_based)
-        qpix_op[0][dxy](dest_y, ptr_y, linesize);
-    else{
-        if(bottom_field){
-            dest_y += s->linesize;
-            dest_cb+= s->uvlinesize;
-            dest_cr+= s->uvlinesize;
-        }
-
-        if(field_select){
-            ptr_y  += s->linesize;
-            ptr_cb += s->uvlinesize;
-            ptr_cr += s->uvlinesize;
-        }
-        //damn interlaced mode
-        //FIXME boundary mirroring is not exactly correct here
-        qpix_op[1][dxy](dest_y  , ptr_y  , linesize);
-        qpix_op[1][dxy](dest_y+8, ptr_y+8, linesize);
-    }
-    if(!(s->flags&CODEC_FLAG_GRAY)){
-        pix_op[1][uvdxy](dest_cr, ptr_cr, uvlinesize, h >> 1);
-        pix_op[1][uvdxy](dest_cb, ptr_cb, uvlinesize, h >> 1);
-    }
-}
-
-inline int ff_h263_round_chroma(int x){
-    if (x >= 0)
-        return  (h263_chroma_roundtab[x & 0xf] + ((x >> 3) & ~1));
-    else {
-        x = -x;
-        return -(h263_chroma_roundtab[x & 0xf] + ((x >> 3) & ~1));
-    }
-}
-
-/**
- * h263 chorma 4mv motion compensation.
- */
-static inline void chroma_4mv_motion(MpegEncContext *s,
-                                     uint8_t *dest_cb, uint8_t *dest_cr,
-                                     uint8_t **ref_picture,
-                                     op_pixels_func *pix_op,
-                                     int mx, int my){
-    int dxy, emu=0, src_x, src_y, offset;
-    uint8_t *ptr;
-    
-    /* In case of 8X8, we construct a single chroma motion vector
-       with a special rounding */
-    mx= ff_h263_round_chroma(mx);
-    my= ff_h263_round_chroma(my);
-    
-    dxy = ((my & 1) << 1) | (mx & 1);
-    mx >>= 1;
-    my >>= 1;
-
-    src_x = s->mb_x * 8 + mx;
-    src_y = s->mb_y * 8 + my;
-    src_x = clip(src_x, -8, s->width/2);
-    if (src_x == s->width/2)
-        dxy &= ~1;
-    src_y = clip(src_y, -8, s->height/2);
-    if (src_y == s->height/2)
-        dxy &= ~2;
-    
-    offset = (src_y * (s->uvlinesize)) + src_x;
-    ptr = ref_picture[1] + offset;
-    if(s->flags&CODEC_FLAG_EMU_EDGE){
-        if(   (unsigned)src_x > (s->h_edge_pos>>1) - (dxy &1) - 8
-           || (unsigned)src_y > (s->v_edge_pos>>1) - (dxy>>1) - 8){
-            ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
-            ptr= s->edge_emu_buffer;
-            emu=1;
-        }
-    }
-    pix_op[dxy](dest_cb, ptr, s->uvlinesize, 8);
-
-    ptr = ref_picture[2] + offset;
-    if(emu){
-        ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
-        ptr= s->edge_emu_buffer;
-    }
-    pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8);
-}
-
-static inline void chroma_4mv_motion_lowres(MpegEncContext *s,
-                                     uint8_t *dest_cb, uint8_t *dest_cr,
-                                     uint8_t **ref_picture,
-                                     h264_chroma_mc_func *pix_op,
-                                     int mx, int my){
-    const int lowres= s->avctx->lowres;
-    const int block_s= 8>>lowres;
-    const int s_mask= (2<<lowres)-1;
-    const int h_edge_pos = s->h_edge_pos >> (lowres+1);
-    const int v_edge_pos = s->v_edge_pos >> (lowres+1);
-    int emu=0, src_x, src_y, offset, sx, sy;
-    uint8_t *ptr;
-    
-    if(s->quarter_sample){
-        mx/=2;
-        my/=2;
-    }
-
-    /* In case of 8X8, we construct a single chroma motion vector
-       with a special rounding */
-    mx= ff_h263_round_chroma(mx);
-    my= ff_h263_round_chroma(my);
-    
-    sx= mx & s_mask;
-    sy= my & s_mask;
-    src_x = s->mb_x*block_s + (mx >> (lowres+1));
-    src_y = s->mb_y*block_s + (my >> (lowres+1));
-    
-    offset = src_y * s->uvlinesize + src_x;
-    ptr = ref_picture[1] + offset;
-    if(s->flags&CODEC_FLAG_EMU_EDGE){
-        if(   (unsigned)src_x > h_edge_pos - (!!sx) - block_s
-           || (unsigned)src_y > v_edge_pos - (!!sy) - block_s){
-            ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos);
-            ptr= s->edge_emu_buffer;
-            emu=1;
-        }
-    }     
-    sx <<= 2 - lowres;
-    sy <<= 2 - lowres;
-    pix_op[lowres](dest_cb, ptr, s->uvlinesize, block_s, sx, sy);
-          
-    ptr = ref_picture[2] + offset;
-    if(emu){
-        ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos);
-        ptr= s->edge_emu_buffer;
-    }
-    pix_op[lowres](dest_cr, ptr, s->uvlinesize, block_s, sx, sy);
-}
-
-/**
- * motion compensation of a single macroblock
- * @param s context
- * @param dest_y luma destination pointer
- * @param dest_cb chroma cb/u destination pointer
- * @param dest_cr chroma cr/v destination pointer
- * @param dir direction (0->forward, 1->backward)
- * @param ref_picture array[3] of pointers to the 3 planes of the reference picture
- * @param pic_op halfpel motion compensation function (average or put normally)
- * @param pic_op qpel motion compensation function (average or put normally)
- * the motion vectors are taken from s->mv and the MV type from s->mv_type
- */
-static inline void MPV_motion(MpegEncContext *s, 
-                              uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
-                              int dir, uint8_t **ref_picture, 
-                              op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16])
-{
-    int dxy, mx, my, src_x, src_y, motion_x, motion_y;
-    int mb_x, mb_y, i;
-    uint8_t *ptr, *dest;
-
-    mb_x = s->mb_x;
-    mb_y = s->mb_y;
-
-    if(s->obmc && s->pict_type != B_TYPE){
-        int16_t mv_cache[4][4][2];
-        const int xy= s->mb_x + s->mb_y*s->mb_stride;
-        const int mot_stride= s->b8_stride;
-        const int mot_xy= mb_x*2 + mb_y*2*mot_stride;
-
-        assert(!s->mb_skipped);
-                
-        memcpy(mv_cache[1][1], s->current_picture.motion_val[0][mot_xy           ], sizeof(int16_t)*4);
-        memcpy(mv_cache[2][1], s->current_picture.motion_val[0][mot_xy+mot_stride], sizeof(int16_t)*4);
-        memcpy(mv_cache[3][1], s->current_picture.motion_val[0][mot_xy+mot_stride], sizeof(int16_t)*4);
-
-        if(mb_y==0 || IS_INTRA(s->current_picture.mb_type[xy-s->mb_stride])){
-            memcpy(mv_cache[0][1], mv_cache[1][1], sizeof(int16_t)*4);
-        }else{
-            memcpy(mv_cache[0][1], s->current_picture.motion_val[0][mot_xy-mot_stride], sizeof(int16_t)*4);
-        }
-
-        if(mb_x==0 || IS_INTRA(s->current_picture.mb_type[xy-1])){
-            *(int32_t*)mv_cache[1][0]= *(int32_t*)mv_cache[1][1];
-            *(int32_t*)mv_cache[2][0]= *(int32_t*)mv_cache[2][1];
-        }else{
-            *(int32_t*)mv_cache[1][0]= *(int32_t*)s->current_picture.motion_val[0][mot_xy-1];
-            *(int32_t*)mv_cache[2][0]= *(int32_t*)s->current_picture.motion_val[0][mot_xy-1+mot_stride];
-        }
-
-        if(mb_x+1>=s->mb_width || IS_INTRA(s->current_picture.mb_type[xy+1])){
-            *(int32_t*)mv_cache[1][3]= *(int32_t*)mv_cache[1][2];
-            *(int32_t*)mv_cache[2][3]= *(int32_t*)mv_cache[2][2];
-        }else{
-            *(int32_t*)mv_cache[1][3]= *(int32_t*)s->current_picture.motion_val[0][mot_xy+2];
-            *(int32_t*)mv_cache[2][3]= *(int32_t*)s->current_picture.motion_val[0][mot_xy+2+mot_stride];
-        }
-        
-        mx = 0;
-        my = 0;
-        for(i=0;i<4;i++) {
-            const int x= (i&1)+1;
-            const int y= (i>>1)+1;
-            int16_t mv[5][2]= {
-                {mv_cache[y][x  ][0], mv_cache[y][x  ][1]},
-                {mv_cache[y-1][x][0], mv_cache[y-1][x][1]},
-                {mv_cache[y][x-1][0], mv_cache[y][x-1][1]},
-                {mv_cache[y][x+1][0], mv_cache[y][x+1][1]},
-                {mv_cache[y+1][x][0], mv_cache[y+1][x][1]}};
-            //FIXME cleanup
-            obmc_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
-                        ref_picture[0],
-                        mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
-                        pix_op[1],
-                        mv);
-
-            mx += mv[0][0];
-            my += mv[0][1];
-        }
-        if(!(s->flags&CODEC_FLAG_GRAY))
-            chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my);
-
-        return;
-    }
-   
-    switch(s->mv_type) {
-    case MV_TYPE_16X16:
-        if(s->mcsel){
-            if(s->real_sprite_warping_points==1){
-                gmc1_motion(s, dest_y, dest_cb, dest_cr,
-                            ref_picture);
-            }else{
-                gmc_motion(s, dest_y, dest_cb, dest_cr,
-                            ref_picture);
-            }
-        }else if(s->quarter_sample){
-            qpel_motion(s, dest_y, dest_cb, dest_cr, 
-                        0, 0, 0,
-                        ref_picture, pix_op, qpix_op,
-                        s->mv[dir][0][0], s->mv[dir][0][1], 16);
-        }else if(s->mspel){
-            ff_mspel_motion(s, dest_y, dest_cb, dest_cr,
-                        ref_picture, pix_op,
-                        s->mv[dir][0][0], s->mv[dir][0][1], 16);
-        }else
-        {
-            mpeg_motion(s, dest_y, dest_cb, dest_cr, 
-                        0, 0, 0,
-                        ref_picture, pix_op,
-                        s->mv[dir][0][0], s->mv[dir][0][1], 16);
-        }           
-        break;
-    case MV_TYPE_8X8:
-        mx = 0;
-        my = 0;
-        if(s->quarter_sample){
-            for(i=0;i<4;i++) {
-                motion_x = s->mv[dir][i][0];
-                motion_y = s->mv[dir][i][1];
-
-                dxy = ((motion_y & 3) << 2) | (motion_x & 3);
-                src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8;
-                src_y = mb_y * 16 + (motion_y >> 2) + (i >>1) * 8;
-                    
-                /* WARNING: do no forget half pels */
-                src_x = clip(src_x, -16, s->width);
-                if (src_x == s->width)
-                    dxy &= ~3;
-                src_y = clip(src_y, -16, s->height);
-                if (src_y == s->height)
-                    dxy &= ~12;
-                    
-                ptr = ref_picture[0] + (src_y * s->linesize) + (src_x);
-                if(s->flags&CODEC_FLAG_EMU_EDGE){
-                    if(   (unsigned)src_x > s->h_edge_pos - (motion_x&3) - 8 
-                       || (unsigned)src_y > s->v_edge_pos - (motion_y&3) - 8 ){
-                        ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->linesize, 9, 9, src_x, src_y, s->h_edge_pos, s->v_edge_pos);
-                        ptr= s->edge_emu_buffer;
-                    }
-                }
-                dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize;
-                qpix_op[1][dxy](dest, ptr, s->linesize);
-
-                mx += s->mv[dir][i][0]/2;
-                my += s->mv[dir][i][1]/2;
-            }
-        }else{
-            for(i=0;i<4;i++) {
-                hpel_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
-                            ref_picture[0], 0, 0,
-                            mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
-                            s->width, s->height, s->linesize,
-                            s->h_edge_pos, s->v_edge_pos,
-                            8, 8, pix_op[1],
-                            s->mv[dir][i][0], s->mv[dir][i][1]);
-
-                mx += s->mv[dir][i][0];
-                my += s->mv[dir][i][1];
-            }
-        }
-
-        if(!(s->flags&CODEC_FLAG_GRAY))
-            chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my);
-        break;
-    case MV_TYPE_FIELD:
-        if (s->picture_structure == PICT_FRAME) {
-            if(s->quarter_sample){
-                for(i=0; i<2; i++){
-                    qpel_motion(s, dest_y, dest_cb, dest_cr,
-                                1, i, s->field_select[dir][i],
-                                ref_picture, pix_op, qpix_op,
-                                s->mv[dir][i][0], s->mv[dir][i][1], 8);
-                }
-            }else{
-                /* top field */       
-                mpeg_motion(s, dest_y, dest_cb, dest_cr,
-                            1, 0, s->field_select[dir][0],
-                            ref_picture, pix_op,
-                            s->mv[dir][0][0], s->mv[dir][0][1], 8);
-                /* bottom field */
-                mpeg_motion(s, dest_y, dest_cb, dest_cr,
-                            1, 1, s->field_select[dir][1],
-                            ref_picture, pix_op,
-                            s->mv[dir][1][0], s->mv[dir][1][1], 8);
-            }
-        } else {
-            if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != B_TYPE && !s->first_field){
-                ref_picture= s->current_picture_ptr->data;
-            } 
-
-            mpeg_motion(s, dest_y, dest_cb, dest_cr,
-                        0, 0, s->field_select[dir][0],
-                        ref_picture, pix_op,
-                        s->mv[dir][0][0], s->mv[dir][0][1], 16);
-        }
-        break;
-    case MV_TYPE_16X8:
-        for(i=0; i<2; i++){
-            uint8_t ** ref2picture;
-
-            if(s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == B_TYPE || s->first_field){
-                ref2picture= ref_picture;
-            }else{
-                ref2picture= s->current_picture_ptr->data;
-            } 
-
-            mpeg_motion(s, dest_y, dest_cb, dest_cr, 
-                        0, 0, s->field_select[dir][i],
-                        ref2picture, pix_op,
-                        s->mv[dir][i][0], s->mv[dir][i][1] + 16*i, 8);
-                
-            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(s, dest_y, dest_cb, dest_cr,
-                                1, j, j^i,
-                                ref_picture, pix_op,
-                                s->mv[dir][2*i + j][0], s->mv[dir][2*i + j][1], 8);
-                }
-                pix_op = s->dsp.avg_pixels_tab; 
-            }
-        }else{
-            for(i=0; i<2; i++){
-                mpeg_motion(s, dest_y, dest_cb, dest_cr, 
-                            0, 0, s->picture_structure != i+1,
-                            ref_picture, pix_op,
-                            s->mv[dir][2*i][0],s->mv[dir][2*i][1],16);
-
-                // after put we make avg of the same block
-                pix_op=s->dsp.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->data;    
-                }
-            }
-        }
-    break;
-    default: assert(0);
-    }
-}
-
-/**
- * motion compensation of a single macroblock
- * @param s context
- * @param dest_y luma destination pointer
- * @param dest_cb chroma cb/u destination pointer
- * @param dest_cr chroma cr/v destination pointer
- * @param dir direction (0->forward, 1->backward)
- * @param ref_picture array[3] of pointers to the 3 planes of the reference picture
- * @param pic_op halfpel motion compensation function (average or put normally)
- * the motion vectors are taken from s->mv and the MV type from s->mv_type
- */
-static inline void MPV_motion_lowres(MpegEncContext *s, 
-                              uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
-                              int dir, uint8_t **ref_picture, 
-                              h264_chroma_mc_func *pix_op)
-{
-    int mx, my;
-    int mb_x, mb_y, i;
-    const int lowres= s->avctx->lowres;
-    const int block_s= 8>>lowres;    
-
-    mb_x = s->mb_x;
-    mb_y = s->mb_y;
-
-    switch(s->mv_type) {
-    case MV_TYPE_16X16:
-        mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, 
-                    0, 0, 0,
-                    ref_picture, pix_op,
-                    s->mv[dir][0][0], s->mv[dir][0][1], 2*block_s);
-        break;
-    case MV_TYPE_8X8:
-        mx = 0;
-        my = 0;
-            for(i=0;i<4;i++) {
-                hpel_motion_lowres(s, dest_y + ((i & 1) + (i >> 1) * s->linesize)*block_s,
-                            ref_picture[0], 0, 0,
-                            (2*mb_x + (i & 1))*block_s, (2*mb_y + (i >>1))*block_s,
-                            s->width, s->height, s->linesize,
-                            s->h_edge_pos >> lowres, s->v_edge_pos >> lowres,
-                            block_s, block_s, pix_op,
-                            s->mv[dir][i][0], s->mv[dir][i][1]);
-
-                mx += s->mv[dir][i][0];
-                my += s->mv[dir][i][1];
-            }
-
-        if(!(s->flags&CODEC_FLAG_GRAY))
-            chroma_4mv_motion_lowres(s, dest_cb, dest_cr, ref_picture, pix_op, mx, my);
-        break;
-    case MV_TYPE_FIELD:
-        if (s->picture_structure == PICT_FRAME) {
-            /* top field */       
-            mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
-                        1, 0, s->field_select[dir][0],
-                        ref_picture, pix_op,
-                        s->mv[dir][0][0], s->mv[dir][0][1], block_s);
-            /* bottom field */
-            mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
-                        1, 1, s->field_select[dir][1],
-                        ref_picture, pix_op,
-                        s->mv[dir][1][0], s->mv[dir][1][1], block_s);
-        } else {
-            if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != B_TYPE && !s->first_field){
-                ref_picture= s->current_picture_ptr->data;
-            } 
-
-            mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
-                        0, 0, s->field_select[dir][0],
-                        ref_picture, pix_op,
-                        s->mv[dir][0][0], s->mv[dir][0][1], 2*block_s);
-        }
-        break;
-    case MV_TYPE_16X8:
-        for(i=0; i<2; i++){
-            uint8_t ** ref2picture;
-
-            if(s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == B_TYPE || s->first_field){
-                ref2picture= ref_picture;
-            }else{
-                ref2picture= s->current_picture_ptr->data;
-            } 
-
-            mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, 
-                        0, 0, s->field_select[dir][i],
-                        ref2picture, pix_op,
-                        s->mv[dir][i][0], s->mv[dir][i][1] + 2*block_s*i, block_s);
-                
-            dest_y += 2*block_s*s->linesize;
-            dest_cb+= (2*block_s>>s->chroma_y_shift)*s->uvlinesize;
-            dest_cr+= (2*block_s>>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_lowres(s, dest_y, dest_cb, dest_cr,
-                                1, j, j^i,
-                                ref_picture, pix_op,
-                                s->mv[dir][2*i + j][0], s->mv[dir][2*i + j][1], block_s);
-                }
-                pix_op = s->dsp.avg_h264_chroma_pixels_tab;
-            }
-        }else{
-            for(i=0; i<2; i++){
-                mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, 
-                            0, 0, s->picture_structure != i+1,
-                            ref_picture, pix_op,
-                            s->mv[dir][2*i][0],s->mv[dir][2*i][1],2*block_s);
-
-                // after put we make avg of the same block
-                pix_op = s->dsp.avg_h264_chroma_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->data;    
-                }
-            }
-        }
-    break;
-    default: assert(0);
-    }
-}
-
-/* put block[] to dest[] */
-static inline void put_dct(MpegEncContext *s, 
-                           DCTELEM *block, int i, uint8_t *dest, int line_size, int qscale)
-{
-    s->dct_unquantize_intra(s, block, i, qscale);
-    s->dsp.idct_put (dest, line_size, block);
-}
-
-/* add block[] to dest[] */
-static inline void add_dct(MpegEncContext *s, 
-                           DCTELEM *block, int i, uint8_t *dest, int line_size)
-{
-    if (s->block_last_index[i] >= 0) {
-        s->dsp.idct_add (dest, line_size, block);
-    }
-}
-
-static inline void add_dequant_dct(MpegEncContext *s, 
-                           DCTELEM *block, int i, uint8_t *dest, int line_size, int qscale)
-{
-    if (s->block_last_index[i] >= 0) {
-        s->dct_unquantize_inter(s, block, i, qscale);
-
-        s->dsp.idct_add (dest, line_size, block);
-    }
-}
-
-/**
- * cleans dc, ac, coded_block for the current non intra MB
- */
-void ff_clean_intra_table_entries(MpegEncContext *s)
-{
-    int wrap = s->b8_stride;
-    int xy = s->block_index[0];
-    
-    s->dc_val[0][xy           ] = 
-    s->dc_val[0][xy + 1       ] = 
-    s->dc_val[0][xy     + wrap] =
-    s->dc_val[0][xy + 1 + wrap] = 1024;
-    /* ac pred */
-    memset(s->ac_val[0][xy       ], 0, 32 * sizeof(int16_t));
-    memset(s->ac_val[0][xy + wrap], 0, 32 * sizeof(int16_t));
-    if (s->msmpeg4_version>=3) {
-        s->coded_block[xy           ] =
-        s->coded_block[xy + 1       ] =
-        s->coded_block[xy     + wrap] =
-        s->coded_block[xy + 1 + wrap] = 0;
-    }
-    /* chroma */
-    wrap = s->mb_stride;
-    xy = s->mb_x + s->mb_y * wrap;
-    s->dc_val[1][xy] =
-    s->dc_val[2][xy] = 1024;
-    /* ac pred */
-    memset(s->ac_val[1][xy], 0, 16 * sizeof(int16_t));
-    memset(s->ac_val[2][xy], 0, 16 * sizeof(int16_t));
-    
-    s->mbintra_table[xy]= 0;
-}
-
-/* generic function called after a macroblock has been parsed by the
-   decoder or after it has been encoded by the encoder.
-
-   Important variables used:
-   s->mb_intra : true if intra macroblock
-   s->mv_dir   : motion vector direction
-   s->mv_type  : motion vector type
-   s->mv       : motion vector
-   s->interlaced_dct : true if interlaced dct used (mpeg2)
- */
-static always_inline void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], int lowres_flag)
-{
-    int mb_x, mb_y;
-    const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
-#ifdef HAVE_XVMC
-    if(s->avctx->xvmc_acceleration){
-        XVMC_decode_mb(s);//xvmc uses pblocks
-        return;
-    }
-#endif
-
-    mb_x = s->mb_x;
-    mb_y = s->mb_y;
-
-    if(s->avctx->debug&FF_DEBUG_DCT_COEFF) {
-       /* save DCT coefficients */
-       int i,j;
-       DCTELEM *dct = &s->current_picture.dct_coeff[mb_xy*64*6];
-       for(i=0; i<6; i++)
-           for(j=0; j<64; j++)
-               *dct++ = block[i][s->dsp.idct_permutation[j]];
-    }
-
-    s->current_picture.qscale_table[mb_xy]= s->qscale;
-
-    /* update DC predictors for P macroblocks */
-    if (!s->mb_intra) {
-        if (s->h263_pred || s->h263_aic) {
-            if(s->mbintra_table[mb_xy])
-                ff_clean_intra_table_entries(s);
-        } else {
-            s->last_dc[0] =
-            s->last_dc[1] =
-            s->last_dc[2] = 128 << s->intra_dc_precision;
-        }
-    }
-    else if (s->h263_pred || s->h263_aic)
-        s->mbintra_table[mb_xy]=1;
-
-    if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==B_TYPE))) { //FIXME precalc
-        uint8_t *dest_y, *dest_cb, *dest_cr;
-        int dct_linesize, dct_offset;
-        op_pixels_func (*op_pix)[4];
-        qpel_mc_func (*op_qpix)[16];
-        const int linesize= s->current_picture.linesize[0]; //not s->linesize as this would be wrong for field pics
-        const int uvlinesize= s->current_picture.linesize[1];
-        const int readable= s->pict_type != B_TYPE || s->encoding || s->avctx->draw_horiz_band || lowres_flag;
-        const int block_size= lowres_flag ? 8>>s->avctx->lowres : 8;
-
-        /* avoid copy if macroblock skipped in last frame too */
-        /* skip only during decoding as we might trash the buffers during encoding a bit */
-        if(!s->encoding){
-            uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
-            const int age= s->current_picture.age;
-
-            assert(age);
-
-            if (s->mb_skipped) {
-                s->mb_skipped= 0;
-                assert(s->pict_type!=I_TYPE);
- 
-                (*mbskip_ptr) ++; /* indicate that this time we skipped it */
-                if(*mbskip_ptr >99) *mbskip_ptr= 99;
-
-                /* if previous was skipped too, then nothing to do !  */
-                if (*mbskip_ptr >= age && s->current_picture.reference){
-                    return;
-                }
-            } else if(!s->current_picture.reference){
-                (*mbskip_ptr) ++; /* increase counter so the age can be compared cleanly */
-                if(*mbskip_ptr >99) *mbskip_ptr= 99;
-            } else{
-                *mbskip_ptr = 0; /* not skipped */
-            }
-        }
-        
-        dct_linesize = linesize << s->interlaced_dct;
-        dct_offset =(s->interlaced_dct)? linesize : linesize*block_size;
-        
-        if(readable){
-            dest_y=  s->dest[0];
-            dest_cb= s->dest[1];
-            dest_cr= s->dest[2];
-        }else{
-            dest_y = s->b_scratchpad;
-            dest_cb= s->b_scratchpad+16*linesize;
-            dest_cr= s->b_scratchpad+32*linesize;
-        }
-
-        if (!s->mb_intra) {
-            /* motion handling */
-            /* decoding or more than one mb_type (MC was already done otherwise) */
-            if(!s->encoding){
-                if(lowres_flag){
-                    h264_chroma_mc_func *op_pix = s->dsp.put_h264_chroma_pixels_tab;
-
-                    if (s->mv_dir & MV_DIR_FORWARD) {
-                        MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix);
-                        op_pix = s->dsp.avg_h264_chroma_pixels_tab;
-                    }
-                    if (s->mv_dir & MV_DIR_BACKWARD) {
-                        MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix);
-                    }
-                }else{
-                    if ((!s->no_rounding) || s->pict_type==B_TYPE){                
-                        op_pix = s->dsp.put_pixels_tab;
-                        op_qpix= s->dsp.put_qpel_pixels_tab;
-                    }else{
-                        op_pix = s->dsp.put_no_rnd_pixels_tab;
-                        op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab;
-                    }
-                    if (s->mv_dir & MV_DIR_FORWARD) {
-                        MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix, op_qpix);
-                        op_pix = s->dsp.avg_pixels_tab;
-                        op_qpix= s->dsp.avg_qpel_pixels_tab;
-                    }
-                    if (s->mv_dir & MV_DIR_BACKWARD) {
-                        MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix, op_qpix);
-                    }
-                }
-            }
-
-            /* skip dequant / idct if we are really late ;) */
-            if(s->hurry_up>1) goto skip_idct;
-            if(s->avctx->skip_idct){
-                if(  (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == B_TYPE)
-                   ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != I_TYPE)
-                   || s->avctx->skip_idct >= AVDISCARD_ALL)
-                    goto skip_idct;
-            }
-
-            /* add dct residue */
-            if(s->encoding || !(   s->h263_msmpeg4 || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO
-                                || (s->codec_id==CODEC_ID_MPEG4 && !s->mpeg_quant))){
-                add_dequant_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
-                add_dequant_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
-                add_dequant_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
-                add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
-
-                if(!(s->flags&CODEC_FLAG_GRAY)){
-                    add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
-                    add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
-                }
-            } 
-	    else if(s->codec_id != CODEC_ID_WMV2){
-                add_dct(s, block[0], 0, dest_y                          , dct_linesize);
-                add_dct(s, block[1], 1, dest_y              + block_size, dct_linesize);
-                add_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize);
-                add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
-
-                if(!(s->flags&CODEC_FLAG_GRAY)){
-                    if(s->chroma_y_shift){//Chroma420
-                        add_dct(s, block[4], 4, dest_cb, uvlinesize);
-                        add_dct(s, block[5], 5, dest_cr, uvlinesize);
-                    }else{
-                        //chroma422
-                        dct_linesize = uvlinesize << s->interlaced_dct;
-                        dct_offset =(s->interlaced_dct)? uvlinesize : uvlinesize*8;
-
-                        add_dct(s, block[4], 4, dest_cb, dct_linesize);
-                        add_dct(s, block[5], 5, dest_cr, dct_linesize);
-                        add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
-                        add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
-                        if(!s->chroma_x_shift){//Chroma444
-                            add_dct(s, block[8], 8, dest_cb+8, dct_linesize);
-                            add_dct(s, block[9], 9, dest_cr+8, dct_linesize);
-                            add_dct(s, block[10], 10, dest_cb+8+dct_offset, dct_linesize);
-                            add_dct(s, block[11], 11, dest_cr+8+dct_offset, dct_linesize);
-                        }
-                    }
-                }//fi gray
-            }
-//             else{
-//                 ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr);
-//             }
-        } else {
-            /* dct only in intra block */
-            if(s->encoding || !(s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO)){
-                put_dct(s, block[0], 0, dest_y                          , dct_linesize, s->qscale);
-                put_dct(s, block[1], 1, dest_y              + block_size, dct_linesize, s->qscale);
-                put_dct(s, block[2], 2, dest_y + dct_offset             , dct_linesize, s->qscale);
-                put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
-
-                if(!(s->flags&CODEC_FLAG_GRAY)){
-                    put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
-                    put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
-                }
-            }else{
-                s->dsp.idct_put(dest_y                          , dct_linesize, block[0]);
-                s->dsp.idct_put(dest_y              + block_size, dct_linesize, block[1]);
-                s->dsp.idct_put(dest_y + dct_offset             , dct_linesize, block[2]);
-                s->dsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
-
-                if(!(s->flags&CODEC_FLAG_GRAY)){
-                    if(s->chroma_y_shift){
-                        s->dsp.idct_put(dest_cb, uvlinesize, block[4]);
-                        s->dsp.idct_put(dest_cr, uvlinesize, block[5]);
-                    }else{
-
-                        dct_linesize = uvlinesize << s->interlaced_dct;
-                        dct_offset =(s->interlaced_dct)? uvlinesize : uvlinesize*8;
-
-                        s->dsp.idct_put(dest_cb,              dct_linesize, block[4]);
-                        s->dsp.idct_put(dest_cr,              dct_linesize, block[5]);
-                        s->dsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
-                        s->dsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
-                        if(!s->chroma_x_shift){//Chroma444
-                            s->dsp.idct_put(dest_cb + 8,              dct_linesize, block[8]);
-                            s->dsp.idct_put(dest_cr + 8,              dct_linesize, block[9]);
-                            s->dsp.idct_put(dest_cb + 8 + dct_offset, dct_linesize, block[10]);
-                            s->dsp.idct_put(dest_cr + 8 + dct_offset, dct_linesize, block[11]);
-                        }
-                    }
-                }//gray
-            }
-        }
-skip_idct:
-        if(!readable){
-            s->dsp.put_pixels_tab[0][0](s->dest[0], dest_y ,   linesize,16);
-            s->dsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[1], dest_cb, uvlinesize,16 >> s->chroma_y_shift);
-            s->dsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[2], dest_cr, uvlinesize,16 >> s->chroma_y_shift);
-        }
-    }
-}
-
-void MPV_decode_mb(MpegEncContext *s, DCTELEM block[12][64]){
-    if(s->avctx->lowres) MPV_decode_mb_internal(s, block, 1);
-    else                  MPV_decode_mb_internal(s, block, 0);
-}
-
-#ifdef CONFIG_ENCODERS
-
-static inline void dct_single_coeff_elimination(MpegEncContext *s, int n, int threshold)
-{
-    static const char tab[64]=
-        {3,2,2,1,1,1,1,1,
-         1,1,1,1,1,1,1,1,
-         1,1,1,1,1,1,1,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};
-    int score=0;
-    int run=0;
-    int i;
-    DCTELEM *block= s->block[n];
-    const int last_index= s->block_last_index[n];
-    int skip_dc;
-
-    if(threshold<0){
-        skip_dc=0;
-        threshold= -threshold;
-    }else
-        skip_dc=1;
-
-    /* are all which we could set to zero are allready zero? */
-    if(last_index<=skip_dc - 1) return;
-
-    for(i=0; i<=last_index; i++){
-        const int j = s->intra_scantable.permutated[i];
-        const int level = ABS(block[j]);
-        if(level==1){
-            if(skip_dc && i==0) continue;
-            score+= tab[run];
-            run=0;
-        }else if(level>1){
-            return;
-        }else{
-            run++;
-        }
-    }
-    if(score >= threshold) return;
-    for(i=skip_dc; i<=last_index; i++){
-        const int j = s->intra_scantable.permutated[i];
-        block[j]=0;
-    }
-    if(block[0]) s->block_last_index[n]= 0;
-    else         s->block_last_index[n]= -1;
-}
-
-static inline void clip_coeffs(MpegEncContext *s, DCTELEM *block, int last_index)
-{
-    int i;
-    const int maxlevel= s->max_qcoeff;
-    const int minlevel= s->min_qcoeff;
-    int overflow=0;
-    
-    if(s->mb_intra){
-        i=1; //skip clipping of intra dc
-    }else
-        i=0;
-    
-    for(;i<=last_index; i++){
-        const int j= s->intra_scantable.permutated[i];
-        int level = block[j];
-       
-        if     (level>maxlevel){
-            level=maxlevel;
-            overflow++;
-        }else if(level<minlevel){
-            level=minlevel;
-            overflow++;
-        }
-        
-        block[j]= level;
-    }
-    
-    if(overflow && s->avctx->mb_decision == FF_MB_DECISION_SIMPLE)
-        av_log(s->avctx, AV_LOG_INFO, "warning, clipping %d dct coefficients to %d..%d\n", overflow, minlevel, maxlevel);
-}
-
-#endif //CONFIG_ENCODERS
-
-/**
- *
- * @param h is the normal height, this will be reduced automatically if needed for the last row
- */
-void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
-    if (s->avctx->draw_horiz_band) {
-        AVFrame *src;
-        int offset[4];
-        
-        if(s->picture_structure != PICT_FRAME){
-            h <<= 1;
-            y <<= 1;
-            if(s->first_field  && !(s->avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)) return;
-        }
-
-        h= FFMIN(h, s->avctx->height - y);
-
-        if(s->pict_type==B_TYPE || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER)) 
-            src= (AVFrame*)s->current_picture_ptr;
-        else if(s->last_picture_ptr)
-            src= (AVFrame*)s->last_picture_ptr;
-        else
-            return;
-            
-        if(s->pict_type==B_TYPE && s->picture_structure == PICT_FRAME && s->out_format != FMT_H264){
-            offset[0]=
-            offset[1]=
-            offset[2]=
-            offset[3]= 0;
-        }else{
-            offset[0]= y * s->linesize;;
-            offset[1]= 
-            offset[2]= (y >> s->chroma_y_shift) * s->uvlinesize;
-            offset[3]= 0;
-        }
-
-        emms_c();
-
-        s->avctx->draw_horiz_band(s->avctx, src, offset,
-                                  y, s->picture_structure, h);
-    }
-}
-
-void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename
-    const int linesize= s->current_picture.linesize[0]; //not s->linesize as this would be wrong for field pics
-    const int uvlinesize= s->current_picture.linesize[1];
-    const int mb_size= 4 - s->avctx->lowres;
-        
-    s->block_index[0]= s->b8_stride*(s->mb_y*2    ) - 2 + s->mb_x*2;
-    s->block_index[1]= s->b8_stride*(s->mb_y*2    ) - 1 + s->mb_x*2;
-    s->block_index[2]= s->b8_stride*(s->mb_y*2 + 1) - 2 + s->mb_x*2;
-    s->block_index[3]= s->b8_stride*(s->mb_y*2 + 1) - 1 + s->mb_x*2;
-    s->block_index[4]= s->mb_stride*(s->mb_y + 1)                + s->b8_stride*s->mb_height*2 + s->mb_x - 1;
-    s->block_index[5]= s->mb_stride*(s->mb_y + s->mb_height + 2) + s->b8_stride*s->mb_height*2 + s->mb_x - 1;
-    //block_index is not used by mpeg2, so it is not affected by chroma_format
-
-    s->dest[0] = s->current_picture.data[0] + ((s->mb_x - 1) << mb_size);
-    s->dest[1] = s->current_picture.data[1] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
-    s->dest[2] = s->current_picture.data[2] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
-
-    if(!(s->pict_type==B_TYPE && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME))
-    {
-        s->dest[0] += s->mb_y *   linesize << mb_size;
-        s->dest[1] += s->mb_y * uvlinesize << (mb_size - s->chroma_y_shift);
-        s->dest[2] += s->mb_y * uvlinesize << (mb_size - s->chroma_y_shift);
-    }
-}
-
-#ifdef CONFIG_ENCODERS
-
-static void get_vissual_weight(int16_t *weight, uint8_t *ptr, int stride){
-    int x, y;
-//FIXME optimize
-    for(y=0; y<8; y++){
-        for(x=0; x<8; x++){
-            int x2, y2;
-            int sum=0;
-            int sqr=0;
-            int count=0;
-
-            for(y2= FFMAX(y-1, 0); y2 < FFMIN(8, y+2); y2++){
-                for(x2= FFMAX(x-1, 0); x2 < FFMIN(8, x+2); x2++){
-                    int v= ptr[x2 + y2*stride];
-                    sum += v;
-                    sqr += v*v;
-                    count++;
-                }
-            }
-            weight[x + 8*y]= (36*ff_sqrt(count*sqr - sum*sum)) / count;
-        }
-    }
-}
-
-static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
-{
-    int16_t weight[6][64];
-    DCTELEM orig[6][64];
-    const int mb_x= s->mb_x;
-    const int mb_y= s->mb_y;
-    int i;
-    int skip_dct[6];
-    int dct_offset   = s->linesize*8; //default for progressive frames
-    uint8_t *ptr_y, *ptr_cb, *ptr_cr;
-    int wrap_y, wrap_c;
-    
-    for(i=0; i<6; i++) skip_dct[i]=0;
-    
-    if(s->adaptive_quant){
-        const int last_qp= s->qscale;
-        const int mb_xy= mb_x + mb_y*s->mb_stride;
-
-        s->lambda= s->lambda_table[mb_xy];
-        update_qscale(s);
-    
-        if(!(s->flags&CODEC_FLAG_QP_RD)){
-            s->dquant= s->qscale - last_qp;
-
-            if(s->out_format==FMT_H263){
-                s->dquant= clip(s->dquant, -2, 2); //FIXME RD
-            
-//                 if(s->codec_id==CODEC_ID_MPEG4){        
-//                     if(!s->mb_intra){
-//                         if(s->pict_type == B_TYPE){
-//                             if(s->dquant&1) 
-//                                 s->dquant= (s->dquant/2)*2;
-//                             if(s->mv_dir&MV_DIRECT)
-//                                 s->dquant= 0;
-//                         }
-//                         if(s->mv_type==MV_TYPE_8X8)
-//                             s->dquant=0;
-//                     }
-//                 }
-            }
-        }
-        ff_set_qscale(s, last_qp + s->dquant);
-    }else if(s->flags&CODEC_FLAG_QP_RD)
-        ff_set_qscale(s, s->qscale + s->dquant);
-
-    wrap_y = s->linesize;
-    wrap_c = s->uvlinesize;
-    ptr_y = s->new_picture.data[0] + (mb_y * 16 * wrap_y) + mb_x * 16;
-    ptr_cb = s->new_picture.data[1] + (mb_y * 8 * wrap_c) + mb_x * 8;
-    ptr_cr = s->new_picture.data[2] + (mb_y * 8 * wrap_c) + mb_x * 8;
-
-    if(mb_x*16+16 > s->width || mb_y*16+16 > s->height){
-        uint8_t *ebuf= s->edge_emu_buffer + 32;
-        ff_emulated_edge_mc(ebuf            , ptr_y , wrap_y,16,16,mb_x*16,mb_y*16, s->width   , s->height);
-        ptr_y= ebuf;
-        ff_emulated_edge_mc(ebuf+18*wrap_y  , ptr_cb, wrap_c, 8, 8, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
-        ptr_cb= ebuf+18*wrap_y;
-        ff_emulated_edge_mc(ebuf+18*wrap_y+8, ptr_cr, wrap_c, 8, 8, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
-        ptr_cr= ebuf+18*wrap_y+8;
-    }
-
-    if (s->mb_intra) {
-        if(s->flags&CODEC_FLAG_INTERLACED_DCT){
-            int progressive_score, interlaced_score;
-
-            s->interlaced_dct=0;
-            progressive_score= s->dsp.ildct_cmp[4](s, ptr_y           , NULL, wrap_y, 8) 
-                              +s->dsp.ildct_cmp[4](s, ptr_y + wrap_y*8, NULL, wrap_y, 8) - 400;
-
-            if(progressive_score > 0){
-                interlaced_score = s->dsp.ildct_cmp[4](s, ptr_y           , NULL, wrap_y*2, 8) 
-                                  +s->dsp.ildct_cmp[4](s, ptr_y + wrap_y  , NULL, wrap_y*2, 8);
-                if(progressive_score > interlaced_score){
-                    s->interlaced_dct=1;
-            
-                    dct_offset= wrap_y;
-                    wrap_y<<=1;
-                }
-            }
-        }
-        
-	s->dsp.get_pixels(s->block[0], ptr_y                 , wrap_y);
-        s->dsp.get_pixels(s->block[1], ptr_y              + 8, wrap_y);
-        s->dsp.get_pixels(s->block[2], ptr_y + dct_offset    , wrap_y);
-        s->dsp.get_pixels(s->block[3], ptr_y + dct_offset + 8, wrap_y);
-
-        if(s->flags&CODEC_FLAG_GRAY){
-            skip_dct[4]= 1;
-            skip_dct[5]= 1;
-        }else{
-	    s->dsp.get_pixels(s->block[4], ptr_cb, wrap_c);
-            s->dsp.get_pixels(s->block[5], ptr_cr, wrap_c);
-        }
-    }else{
-        op_pixels_func (*op_pix)[4];
-        qpel_mc_func (*op_qpix)[16];
-        uint8_t *dest_y, *dest_cb, *dest_cr;
-
-        dest_y  = s->dest[0];
-        dest_cb = s->dest[1];
-        dest_cr = s->dest[2];
-
-        if ((!s->no_rounding) || s->pict_type==B_TYPE){
-	    op_pix = s->dsp.put_pixels_tab;
-            op_qpix= s->dsp.put_qpel_pixels_tab;
-        }else{
-            op_pix = s->dsp.put_no_rnd_pixels_tab;
-            op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab;
-        }
-
-        if (s->mv_dir & MV_DIR_FORWARD) {
-            MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix, op_qpix);
-            op_pix = s->dsp.avg_pixels_tab;
-            op_qpix= s->dsp.avg_qpel_pixels_tab;
-        }
-        if (s->mv_dir & MV_DIR_BACKWARD) {
-            MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix, op_qpix);
-        }
-
-        if(s->flags&CODEC_FLAG_INTERLACED_DCT){
-            int progressive_score, interlaced_score;
-
-            s->interlaced_dct=0;
-            progressive_score= s->dsp.ildct_cmp[0](s, dest_y           , ptr_y           , wrap_y, 8) 
-                              +s->dsp.ildct_cmp[0](s, dest_y + wrap_y*8, ptr_y + wrap_y*8, wrap_y, 8) - 400;
-            
-            if(s->avctx->ildct_cmp == FF_CMP_VSSE) progressive_score -= 400;
-
-            if(progressive_score>0){
-                interlaced_score = s->dsp.ildct_cmp[0](s, dest_y           , ptr_y           , wrap_y*2, 8) 
-                                  +s->dsp.ildct_cmp[0](s, dest_y + wrap_y  , ptr_y + wrap_y  , wrap_y*2, 8);
-            
-                if(progressive_score > interlaced_score){
-                    s->interlaced_dct=1;
-            
-                    dct_offset= wrap_y;
-                    wrap_y<<=1;
-                }
-            }
-        }
-        
-	s->dsp.diff_pixels(s->block[0], ptr_y                 , dest_y                 , wrap_y);
-        s->dsp.diff_pixels(s->block[1], ptr_y              + 8, dest_y              + 8, wrap_y);
-        s->dsp.diff_pixels(s->block[2], ptr_y + dct_offset    , dest_y + dct_offset    , wrap_y);
-        s->dsp.diff_pixels(s->block[3], ptr_y + dct_offset + 8, dest_y + dct_offset + 8, wrap_y);
-        
-        if(s->flags&CODEC_FLAG_GRAY){
-            skip_dct[4]= 1;
-            skip_dct[5]= 1;
-        }else{
-            s->dsp.diff_pixels(s->block[4], ptr_cb, dest_cb, wrap_c);
-            s->dsp.diff_pixels(s->block[5], ptr_cr, dest_cr, wrap_c);
-        }
-        /* pre quantization */         
-        if(s->current_picture.mc_mb_var[s->mb_stride*mb_y+ mb_x]<2*s->qscale*s->qscale){
-            //FIXME optimize
-	    if(s->dsp.sad[1](NULL, ptr_y               , dest_y               , wrap_y, 8) < 20*s->qscale) skip_dct[0]= 1;
-            if(s->dsp.sad[1](NULL, ptr_y            + 8, dest_y            + 8, wrap_y, 8) < 20*s->qscale) skip_dct[1]= 1;
-            if(s->dsp.sad[1](NULL, ptr_y +dct_offset   , dest_y +dct_offset   , wrap_y, 8) < 20*s->qscale) skip_dct[2]= 1;
-            if(s->dsp.sad[1](NULL, ptr_y +dct_offset+ 8, dest_y +dct_offset+ 8, wrap_y, 8) < 20*s->qscale) skip_dct[3]= 1;
-            if(s->dsp.sad[1](NULL, ptr_cb              , dest_cb              , wrap_c, 8) < 20*s->qscale) skip_dct[4]= 1;
-            if(s->dsp.sad[1](NULL, ptr_cr              , dest_cr              , wrap_c, 8) < 20*s->qscale) skip_dct[5]= 1;
-        }
-    }
-
-    if(s->avctx->quantizer_noise_shaping){
-        if(!skip_dct[0]) get_vissual_weight(weight[0], ptr_y                 , wrap_y);
-        if(!skip_dct[1]) get_vissual_weight(weight[1], ptr_y              + 8, wrap_y);
-        if(!skip_dct[2]) get_vissual_weight(weight[2], ptr_y + dct_offset    , wrap_y);
-        if(!skip_dct[3]) get_vissual_weight(weight[3], ptr_y + dct_offset + 8, wrap_y);
-        if(!skip_dct[4]) get_vissual_weight(weight[4], ptr_cb                , wrap_c);
-        if(!skip_dct[5]) get_vissual_weight(weight[5], ptr_cr                , wrap_c);
-        memcpy(orig[0], s->block[0], sizeof(DCTELEM)*64*6);
-    }
-            
-    /* DCT & quantize */
-    assert(s->out_format!=FMT_MJPEG || s->qscale==8);
-    {
-        for(i=0;i<6;i++) {
-            if(!skip_dct[i]){
-                int overflow;
-                s->block_last_index[i] = s->dct_quantize(s, s->block[i], i, s->qscale, &overflow);
-            // FIXME we could decide to change to quantizer instead of clipping
-            // JS: I don't think that would be a good idea it could lower quality instead
-            //     of improve it. Just INTRADC clipping deserves changes in quantizer
-                if (overflow) clip_coeffs(s, s->block[i], s->block_last_index[i]);
-            }else
-                s->block_last_index[i]= -1;
-        }
-        if(s->avctx->quantizer_noise_shaping){
-            for(i=0;i<6;i++) {
-                if(!skip_dct[i]){
-                    s->block_last_index[i] = dct_quantize_refine(s, s->block[i], weight[i], orig[i], i, s->qscale);
-                }
-            }
-        }
-        
-        if(s->luma_elim_threshold && !s->mb_intra)
-            for(i=0; i<4; i++)
-                dct_single_coeff_elimination(s, i, s->luma_elim_threshold);
-        if(s->chroma_elim_threshold && !s->mb_intra)
-            for(i=4; i<6; i++)
-                dct_single_coeff_elimination(s, i, s->chroma_elim_threshold);
-
-        if(s->flags & CODEC_FLAG_CBP_RD){
-            for(i=0;i<6;i++) {
-                if(s->block_last_index[i] == -1)
-                    s->coded_score[i]= INT_MAX/256;
-            }
-        }
-    }
-
-    if((s->flags&CODEC_FLAG_GRAY) && s->mb_intra){
-        s->block_last_index[4]=
-        s->block_last_index[5]= 0;
-        s->block[4][0]=
-        s->block[5][0]= (1024 + s->c_dc_scale/2)/ s->c_dc_scale;
-    }
-
-    //non c quantize code returns incorrect block_last_index FIXME
-    if(s->alternate_scan && s->dct_quantize != dct_quantize_c){
-        for(i=0; i<6; i++){
-            int j;
-            if(s->block_last_index[i]>0){
-                for(j=63; j>0; j--){
-                    if(s->block[i][ s->intra_scantable.permutated[j] ]) break;
-                }
-                s->block_last_index[i]= j;
-            }
-        }
-    }
-
-    /* huffman encode */
-    switch(s->codec_id){ //FIXME funct ptr could be slightly faster
-    case CODEC_ID_MPEG1VIDEO:
-    case CODEC_ID_MPEG2VIDEO:
-        mpeg1_encode_mb(s, s->block, motion_x, motion_y); break;
-//     case CODEC_ID_MPEG4:
-//         mpeg4_encode_mb(s, s->block, motion_x, motion_y); break;
-//     case CODEC_ID_MSMPEG4V2:
-//     case CODEC_ID_MSMPEG4V3:
-//     case CODEC_ID_WMV1:
-//         msmpeg4_encode_mb(s, s->block, motion_x, motion_y); break;
-//     case CODEC_ID_WMV2:
-//          ff_wmv2_encode_mb(s, s->block, motion_x, motion_y); break;
-// #ifdef CONFIG_H261_ENCODER
-//     case CODEC_ID_H261:
-//         ff_h261_encode_mb(s, s->block, motion_x, motion_y); break;
-// #endif
-//     case CODEC_ID_H263:
-//     case CODEC_ID_H263P:
-//     case CODEC_ID_FLV1:
-//     case CODEC_ID_RV10:
-//     case CODEC_ID_RV20:
-//         h263_encode_mb(s, s->block, motion_x, motion_y); break;
-//     case CODEC_ID_MJPEG:
-//         mjpeg_encode_mb(s, s->block); break;
-    default:
-        assert(0);
-    }
-}
-
-#endif //CONFIG_ENCODERS
-
-void ff_mpeg_flush(AVCodecContext *avctx){
-    int i;
-    MpegEncContext *s = avctx->priv_data;
-    
-    if(s==NULL || s->picture==NULL) 
-        return;
-    
-    for(i=0; i<MAX_PICTURE_COUNT; i++){
-       if(s->picture[i].data[0] && (   s->picture[i].type == FF_BUFFER_TYPE_INTERNAL
-                                    || s->picture[i].type == FF_BUFFER_TYPE_USER))
-        avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);
-    }
-    s->current_picture_ptr = s->last_picture_ptr = s->next_picture_ptr = NULL;
-    
-    s->mb_x= s->mb_y= 0;
-    
-    s->parse_context.state= -1;
-    s->parse_context.frame_start_found= 0;
-    s->parse_context.overread= 0;
-    s->parse_context.overread_index= 0;
-    s->parse_context.index= 0;
-    s->parse_context.last_index= 0;
-    s->bitstream_buffer_size=0;
-}
-
-#ifdef CONFIG_ENCODERS
-void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length)
-{
-    const uint16_t *srcw= (uint16_t*)src;
-    int words= length>>4;
-    int bits= length&15;
-    int i;
-
-    if(length==0) return;
-    
-    if(words < 16){
-        for(i=0; i<words; i++) put_bits(pb, 16, be2me_16(srcw[i]));
-    }else if(put_bits_count(pb)&7){
-        for(i=0; i<words; i++) put_bits(pb, 16, be2me_16(srcw[i]));
-    }else{
-        for(i=0; put_bits_count(pb)&31; i++)
-            put_bits(pb, 8, src[i]);
-        flush_put_bits(pb);
-        memcpy(pbBufPtr(pb), src+i, 2*words-i);
-        skip_put_bytes(pb, 2*words-i);
-    }
-        
-    put_bits(pb, bits, be2me_16(srcw[words])>>(16-bits));
-}
-
-static inline void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type){
-    int i;
-
-    memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster then a loop?
-
-    /* mpeg1 */
-    d->mb_skip_run= s->mb_skip_run;
-    for(i=0; i<3; i++)
-        d->last_dc[i]= s->last_dc[i];
-    
-    /* statistics */
-    d->mv_bits= s->mv_bits;
-    d->i_tex_bits= s->i_tex_bits;
-    d->p_tex_bits= s->p_tex_bits;
-    d->i_count= s->i_count;
-    d->f_count= s->f_count;
-    d->b_count= s->b_count;
-    d->skip_count= s->skip_count;
-    d->misc_bits= s->misc_bits;
-    d->last_bits= 0;
-
-    d->mb_skipped= 0;
-    d->qscale= s->qscale;
-    d->dquant= s->dquant;
-}
-
-static inline void copy_context_after_encode(MpegEncContext *d, MpegEncContext *s, int type){
-    int i;
-
-    memcpy(d->mv, s->mv, 2*4*2*sizeof(int)); 
-    memcpy(d->last_mv, s->last_mv, 2*2*2*sizeof(int)); //FIXME is memcpy faster then a loop?
-    
-    /* mpeg1 */
-    d->mb_skip_run= s->mb_skip_run;
-    for(i=0; i<3; i++)
-        d->last_dc[i]= s->last_dc[i];
-    
-    /* statistics */
-    d->mv_bits= s->mv_bits;
-    d->i_tex_bits= s->i_tex_bits;
-    d->p_tex_bits= s->p_tex_bits;
-    d->i_count= s->i_count;
-    d->f_count= s->f_count;
-    d->b_count= s->b_count;
-    d->skip_count= s->skip_count;
-    d->misc_bits= s->misc_bits;
-
-    d->mb_intra= s->mb_intra;
-    d->mb_skipped= s->mb_skipped;
-    d->mv_type= s->mv_type;
-    d->mv_dir= s->mv_dir;
-    d->pb= s->pb;
-    if(s->data_partitioning){
-        d->pb2= s->pb2;
-        d->tex_pb= s->tex_pb;
-    }
-    d->block= s->block;
-    for(i=0; i<6; i++)
-        d->block_last_index[i]= s->block_last_index[i];
-    d->interlaced_dct= s->interlaced_dct;
-    d->qscale= s->qscale;
-}
-
-static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegEncContext *best, int type, 
-                           PutBitContext pb[2], PutBitContext pb2[2], PutBitContext tex_pb[2],
-                           int *dmin, int *next_block, int motion_x, int motion_y)
-{
-    int score;
-    uint8_t *dest_backup[3];
-    
-    copy_context_before_encode(s, backup, type);
-
-    s->block= s->blocks[*next_block];
-    s->pb= pb[*next_block];
-    if(s->data_partitioning){
-        s->pb2   = pb2   [*next_block];
-        s->tex_pb= tex_pb[*next_block];
-    }
-    
-    if(*next_block){
-        memcpy(dest_backup, s->dest, sizeof(s->dest));
-        s->dest[0] = s->rd_scratchpad;
-        s->dest[1] = s->rd_scratchpad + 16*s->linesize;
-        s->dest[2] = s->rd_scratchpad + 16*s->linesize + 8;
-        assert(s->linesize >= 32); //FIXME
-    }
-
-    encode_mb(s, motion_x, motion_y);
-    
-    score= put_bits_count(&s->pb);
-    if(s->data_partitioning){
-        score+= put_bits_count(&s->pb2);
-        score+= put_bits_count(&s->tex_pb);
-    }
-   
-    if(s->avctx->mb_decision == FF_MB_DECISION_RD){
-        MPV_decode_mb(s, s->block);
-
-        score *= s->lambda2;
-        score += sse_mb(s) << FF_LAMBDA_SHIFT;
-    }
-    
-    if(*next_block){
-        memcpy(s->dest, dest_backup, sizeof(s->dest));
-    }
-
-    if(score<*dmin){
-        *dmin= score;
-        *next_block^=1;
-
-        copy_context_after_encode(best, s, type);
-    }
-}
-                
-static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, int stride){
-    uint32_t *sq = squareTbl + 256;
-    int acc=0;
-    int x,y;
-    
-    if(w==16 && h==16) 
-        return s->dsp.sse[0](NULL, src1, src2, stride, 16);
-    else if(w==8 && h==8)
-        return s->dsp.sse[1](NULL, src1, src2, stride, 8);
-    
-    for(y=0; y<h; y++){
-        for(x=0; x<w; x++){
-            acc+= sq[src1[x + y*stride] - src2[x + y*stride]];
-        } 
-    }
-    
-    assert(acc>=0);
-    
-    return acc;
-}
-
-static int sse_mb(MpegEncContext *s){
-    int w= 16;
-    int h= 16;
-
-    if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16;
-    if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
-
-    if(w==16 && h==16)
-      if(s->avctx->mb_cmp == FF_CMP_NSSE){
-        return  s->dsp.nsse[0](s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
-               +s->dsp.nsse[1](s, s->new_picture.data[1] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
-               +s->dsp.nsse[1](s, s->new_picture.data[2] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
-      }else{
-        return  s->dsp.sse[0](NULL, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], s->linesize, 16)
-               +s->dsp.sse[1](NULL, s->new_picture.data[1] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[1], s->uvlinesize, 8)
-               +s->dsp.sse[1](NULL, s->new_picture.data[2] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[2], s->uvlinesize, 8);
-      }
-    else
-        return  sse(s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16, s->dest[0], w, h, s->linesize)
-               +sse(s, s->new_picture.data[1] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[1], w>>1, h>>1, s->uvlinesize)
-               +sse(s, s->new_picture.data[2] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,s->dest[2], w>>1, h>>1, s->uvlinesize);
-}
-
-static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){
-    MpegEncContext *s= arg;
-
-    
-    s->me.pre_pass=1;
-    s->me.dia_size= s->avctx->pre_dia_size;
-    s->first_slice_line=1;
-    for(s->mb_y= s->end_mb_y-1; s->mb_y >= s->start_mb_y; s->mb_y--) {
-        for(s->mb_x=s->mb_width-1; s->mb_x >=0 ;s->mb_x--) {
-            ff_pre_estimate_p_frame_motion(s, s->mb_x, s->mb_y);
-        }
-        s->first_slice_line=0;
-    }
-    
-    s->me.pre_pass=0;
-    
-    return 0;
-}
-
-static int estimate_motion_thread(AVCodecContext *c, void *arg){
-    MpegEncContext *s= arg;
-
-    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++) {
-        s->mb_x=0; //for block init below
-        ff_init_block_index(s);
-        for(s->mb_x=0; s->mb_x < s->mb_width; s->mb_x++) {
-            s->block_index[0]+=2;
-            s->block_index[1]+=2;
-            s->block_index[2]+=2;
-            s->block_index[3]+=2;
-            
-            /* compute motion vector & mb_type and store in context */
-            if(s->pict_type==B_TYPE)
-                ff_estimate_b_frame_motion(s, s->mb_x, s->mb_y);
-            else
-                ff_estimate_p_frame_motion(s, s->mb_x, s->mb_y);
-        }
-        s->first_slice_line=0;
-    }
-    return 0;
-}
-
-static int mb_var_thread(AVCodecContext *c, void *arg){
-    MpegEncContext *s= arg;
-    int mb_x, mb_y;
-
-    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;
-            int yy = mb_y * 16;
-            uint8_t *pix = s->new_picture.data[0] + (yy * s->linesize) + xx;
-            int varc;
-            int sum = s->dsp.pix_sum(pix, s->linesize);
-    
-            varc = (s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500 + 128)>>8;
-
-            s->current_picture.mb_var [s->mb_stride * mb_y + mb_x] = varc;
-            s->current_picture.mb_mean[s->mb_stride * mb_y + mb_x] = (sum+128)>>8;
-            s->me.mb_var_sum_temp    += varc;
-        }
-    }
-    return 0;
-}
-
-static void write_slice_end(MpegEncContext *s){
-//     if(s->codec_id==CODEC_ID_MPEG4){
-//         if(s->partitioned_frame){
-//             ff_mpeg4_merge_partitions(s);
-//         }
-//     
-//         ff_mpeg4_stuffing(&s->pb);
-//     }else if(s->out_format == FMT_MJPEG){
-//         ff_mjpeg_stuffing(&s->pb);
-//     }
-
-    align_put_bits(&s->pb);
-    flush_put_bits(&s->pb);
-    
-    if((s->flags&CODEC_FLAG_PASS1) && !s->partitioned_frame)
-        s->misc_bits+= get_bits_diff(s);
-}
-
-static int encode_thread(AVCodecContext *c, void *arg){
-    MpegEncContext *s= arg;
-    int mb_x, mb_y, pdif = 0;
-    int i, j;
-    MpegEncContext best_s, backup_s;
-    uint8_t bit_buf[2][MAX_MB_BYTES];
-    uint8_t bit_buf2[2][MAX_MB_BYTES];
-    uint8_t bit_buf_tex[2][MAX_MB_BYTES];
-    PutBitContext pb[2], pb2[2], tex_pb[2];
-//printf("%d->%d\n", s->resync_mb_y, s->end_mb_y);
-
-    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);
-        init_put_bits(&tex_pb[i], bit_buf_tex[i], MAX_MB_BYTES);
-    }
-
-    s->last_bits= put_bits_count(&s->pb);
-    s->mv_bits=0;
-    s->misc_bits=0;
-    s->i_tex_bits=0;
-    s->p_tex_bits=0;
-    s->i_count=0;
-    s->f_count=0;
-    s->b_count=0;
-    s->skip_count=0;
-
-    for(i=0; i<3; i++){
-        /* init last dc values */
-        /* note: quant matrix value (8) is implied here */
-        s->last_dc[i] = 128 << s->intra_dc_precision;
-        
-        s->current_picture_ptr->error[i] = 0;
-    }
-    s->mb_skip_run = 0;
-    memset(s->last_mv, 0, sizeof(s->last_mv));
-     
-    s->last_mv_dir = 0;
-
-//     switch(s->codec_id){
-//     case CODEC_ID_H263:
-//     case CODEC_ID_H263P:
-//     case CODEC_ID_FLV1:
-//         s->gob_index = ff_h263_get_gob_height(s);
-//         break;
-//     case CODEC_ID_MPEG4:
-//         if(s->partitioned_frame)
-//             ff_mpeg4_init_partitions(s);
-//         break;
-//     }
-
-    s->resync_mb_x=0;
-    s->resync_mb_y=0; 
-    s->first_slice_line = 1;
-    s->ptr_lastgob = s->pb.buf;
-    for(mb_y= s->start_mb_y; mb_y < s->end_mb_y; mb_y++) {
-//    printf("row %d at %X\n", s->mb_y, (int)s);
-        s->mb_x=0;
-        s->mb_y= mb_y;
-
-        ff_set_qscale(s, s->qscale);
-        ff_init_block_index(s);
-        
-        for(mb_x=0; mb_x < s->mb_width; mb_x++) {
-            int xy= mb_y*s->mb_stride + mb_x; // removed const, H261 needs to adjust this
-            int mb_type= s->mb_type[xy];
-//            int d;
-            int dmin= INT_MAX;
-            int dir;
-
-            if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < MAX_MB_BYTES){
-                av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
-                return -1;
-            }
-            if(s->data_partitioning){
-                if(   s->pb2   .buf_end - s->pb2   .buf - (put_bits_count(&s->    pb2)>>3) < MAX_MB_BYTES
-                   || s->tex_pb.buf_end - s->tex_pb.buf - (put_bits_count(&s->tex_pb )>>3) < MAX_MB_BYTES){
-                    av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
-                    return -1;
-                }
-            }
-
-            s->mb_x = mb_x;
-            s->mb_y = mb_y;  // moved into loop, can get changed by H.261
-            ff_update_block_index(s);
-
-#ifdef CONFIG_H261_ENCODER
-//             if(s->codec_id == CODEC_ID_H261){
-//                 ff_h261_reorder_mb_index(s);
-//                 xy= s->mb_y*s->mb_stride + s->mb_x;
-//                 mb_type= s->mb_type[xy];
-//             }
-#endif
-
-            /* write gob / video packet header  */
-            if(s->rtp_mode){
-                int current_packet_size, is_gob_start;
-                
-                current_packet_size= ((put_bits_count(&s->pb)+7)>>3) - (s->ptr_lastgob - s->pb.buf);
-                
-                is_gob_start= s->avctx->rtp_payload_size && current_packet_size >= s->avctx->rtp_payload_size && mb_y + mb_x>0; 
-                
-                if(s->start_mb_y == mb_y && mb_y > 0 && mb_x==0) is_gob_start=1;
-                
-                switch(s->codec_id){
-//                 case CODEC_ID_H263:
-//                 case CODEC_ID_H263P:
-//                     if(!s->h263_slice_structured)
-//                         if(s->mb_x || s->mb_y%s->gob_index) is_gob_start=0;
-//                     break;
-                case CODEC_ID_MPEG2VIDEO:
-                    if(s->mb_x==0 && s->mb_y!=0) is_gob_start=1;
-                case CODEC_ID_MPEG1VIDEO:
-                    if(s->mb_skip_run) is_gob_start=0;
-                    break;
-                }
-
-                if(is_gob_start){
-                    if(s->start_mb_y != mb_y || mb_x!=0){
-                        write_slice_end(s);
-
-//                         if(s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame){
-//                             ff_mpeg4_init_partitions(s);
-//                         }
-                    }
-                
-                    assert((put_bits_count(&s->pb)&7) == 0);
-                    current_packet_size= pbBufPtr(&s->pb) - s->ptr_lastgob;
-                    
-                    if(s->avctx->error_rate && s->resync_mb_x + s->resync_mb_y > 0){
-                        int r= put_bits_count(&s->pb)/8 + s->picture_number + 16 + s->mb_x + s->mb_y;
-                        int d= 100 / s->avctx->error_rate;
-                        if(r % d == 0){
-                            current_packet_size=0;
-#ifndef ALT_BITSTREAM_WRITER
-                            s->pb.buf_ptr= s->ptr_lastgob;
-#endif
-                            assert(pbBufPtr(&s->pb) == s->ptr_lastgob);
-                        }
-                    }
-
-                    if (s->avctx->rtp_callback){
-                        int number_mb = (mb_y - s->resync_mb_y)*s->mb_width + mb_x - s->resync_mb_x;
-                        s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, current_packet_size, number_mb);
-                    }
-                    
-                    switch(s->codec_id){
-//                     case CODEC_ID_MPEG4:
-//                         ff_mpeg4_encode_video_packet_header(s);
-//                         ff_mpeg4_clean_buffers(s);
-//                     break;
-                    case CODEC_ID_MPEG1VIDEO:
-                    case CODEC_ID_MPEG2VIDEO:
-                        ff_mpeg1_encode_slice_header(s);
-                        ff_mpeg1_clean_buffers(s);
-                    break;
-//                     case CODEC_ID_H263:
-//                     case CODEC_ID_H263P:
-//                         h263_encode_gob_header(s, mb_y);                       
-//                     break;
-                    }
-
-                    if(s->flags&CODEC_FLAG_PASS1){
-                        int bits= put_bits_count(&s->pb);
-                        s->misc_bits+= bits - s->last_bits;
-                        s->last_bits= bits;
-                    }
-    
-                    s->ptr_lastgob += current_packet_size;
-                    s->first_slice_line=1;
-                    s->resync_mb_x=mb_x;
-                    s->resync_mb_y=mb_y;
-                }
-            }
-
-            if(  (s->resync_mb_x   == s->mb_x)
-               && s->resync_mb_y+1 == s->mb_y){
-                s->first_slice_line=0; 
-            }
-
-            s->mb_skipped=0;
-            s->dquant=0; //only for QP_RD
-
-            if(mb_type & (mb_type-1) || (s->flags & CODEC_FLAG_QP_RD)){ // more than 1 MB type possible or CODEC_FLAG_QP_RD
-                int next_block=0;
-                int pb_bits_count, pb2_bits_count, tex_pb_bits_count;
-
-                copy_context_before_encode(&backup_s, s, -1);
-                backup_s.pb= s->pb;
-                best_s.data_partitioning= s->data_partitioning;
-                best_s.partitioned_frame= s->partitioned_frame;
-                if(s->data_partitioning){
-                    backup_s.pb2= s->pb2;
-                    backup_s.tex_pb= s->tex_pb;
-                }
-
-                if(mb_type&CANDIDATE_MB_TYPE_INTER){
-                    s->mv_dir = MV_DIR_FORWARD;
-                    s->mv_type = MV_TYPE_16X16;
-                    s->mb_intra= 0;
-                    s->mv[0][0][0] = s->p_mv_table[xy][0];
-                    s->mv[0][0][1] = s->p_mv_table[xy][1];
-                    encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER, pb, pb2, tex_pb, 
-                                 &dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
-                }
-                if(mb_type&CANDIDATE_MB_TYPE_INTER_I){ 
-                    s->mv_dir = MV_DIR_FORWARD;
-                    s->mv_type = MV_TYPE_FIELD;
-                    s->mb_intra= 0;
-                    for(i=0; i<2; i++){
-                        j= s->field_select[0][i] = s->p_field_select_table[i][xy];
-                        s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0];
-                        s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1];
-                    }
-                    encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER_I, pb, pb2, tex_pb, 
-                                 &dmin, &next_block, 0, 0);
-                }
-                if(mb_type&CANDIDATE_MB_TYPE_SKIPPED){
-                    s->mv_dir = MV_DIR_FORWARD;
-                    s->mv_type = MV_TYPE_16X16;
-                    s->mb_intra= 0;
-                    s->mv[0][0][0] = 0;
-                    s->mv[0][0][1] = 0;
-                    encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_SKIPPED, pb, pb2, tex_pb, 
-                                 &dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
-                }
-                if(mb_type&CANDIDATE_MB_TYPE_INTER4V){                 
-                    s->mv_dir = MV_DIR_FORWARD;
-                    s->mv_type = MV_TYPE_8X8;
-                    s->mb_intra= 0;
-                    for(i=0; i<4; i++){
-                        s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0];
-                        s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1];
-                    }
-                    encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER4V, pb, pb2, tex_pb, 
-                                 &dmin, &next_block, 0, 0);
-                }
-                if(mb_type&CANDIDATE_MB_TYPE_FORWARD){
-                    s->mv_dir = MV_DIR_FORWARD;
-                    s->mv_type = MV_TYPE_16X16;
-                    s->mb_intra= 0;
-                    s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
-                    s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
-                    encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD, pb, pb2, tex_pb, 
-                                 &dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
-                }
-                if(mb_type&CANDIDATE_MB_TYPE_BACKWARD){
-                    s->mv_dir = MV_DIR_BACKWARD;
-                    s->mv_type = MV_TYPE_16X16;
-                    s->mb_intra= 0;
-                    s->mv[1][0][0] = s->b_back_mv_table[xy][0];
-                    s->mv[1][0][1] = s->b_back_mv_table[xy][1];
-                    encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD, pb, pb2, tex_pb, 
-                                 &dmin, &next_block, s->mv[1][0][0], s->mv[1][0][1]);
-                }
-                if(mb_type&CANDIDATE_MB_TYPE_BIDIR){
-                    s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
-                    s->mv_type = MV_TYPE_16X16;
-                    s->mb_intra= 0;
-                    s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
-                    s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
-                    s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
-                    s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
-                    encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR, pb, pb2, tex_pb, 
-                                 &dmin, &next_block, 0, 0);
-                }
-                if(mb_type&CANDIDATE_MB_TYPE_DIRECT){
-                    int mx= s->b_direct_mv_table[xy][0];
-                    int my= s->b_direct_mv_table[xy][1];
-                    
-                    s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
-                    s->mb_intra= 0;
-                    ff_mpeg4_set_direct_mv(s, mx, my);
-                    encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb, 
-                                 &dmin, &next_block, mx, my);
-                }
-                if(mb_type&CANDIDATE_MB_TYPE_FORWARD_I){ 
-                    s->mv_dir = MV_DIR_FORWARD;
-                    s->mv_type = MV_TYPE_FIELD;
-                    s->mb_intra= 0;
-                    for(i=0; i<2; i++){
-                        j= s->field_select[0][i] = s->b_field_select_table[0][i][xy];
-                        s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0];
-                        s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1];
-                    }
-                    encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_FORWARD_I, pb, pb2, tex_pb, 
-                                 &dmin, &next_block, 0, 0);
-                }
-                if(mb_type&CANDIDATE_MB_TYPE_BACKWARD_I){ 
-                    s->mv_dir = MV_DIR_BACKWARD;
-                    s->mv_type = MV_TYPE_FIELD;
-                    s->mb_intra= 0;
-                    for(i=0; i<2; i++){
-                        j= s->field_select[1][i] = s->b_field_select_table[1][i][xy];
-                        s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0];
-                        s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1];
-                    }
-                    encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BACKWARD_I, pb, pb2, tex_pb, 
-                                 &dmin, &next_block, 0, 0);
-                }
-                if(mb_type&CANDIDATE_MB_TYPE_BIDIR_I){ 
-                    s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
-                    s->mv_type = MV_TYPE_FIELD;
-                    s->mb_intra= 0;
-                    for(dir=0; dir<2; dir++){
-                        for(i=0; i<2; i++){
-                            j= s->field_select[dir][i] = s->b_field_select_table[dir][i][xy];
-                            s->mv[dir][i][0] = s->b_field_mv_table[dir][i][j][xy][0];
-                            s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1];
-                        }
-                    }
-                    encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_BIDIR_I, pb, pb2, tex_pb, 
-                                 &dmin, &next_block, 0, 0);
-                }
-                if(mb_type&CANDIDATE_MB_TYPE_INTRA){
-                    s->mv_dir = 0;
-                    s->mv_type = MV_TYPE_16X16;
-                    s->mb_intra= 1;
-                    s->mv[0][0][0] = 0;
-                    s->mv[0][0][1] = 0;
-                    encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTRA, pb, pb2, tex_pb, 
-                                 &dmin, &next_block, 0, 0);
-                    if(s->h263_pred || s->h263_aic){
-                        if(best_s.mb_intra)
-                            s->mbintra_table[mb_x + mb_y*s->mb_stride]=1;
-                        else
-                            ff_clean_intra_table_entries(s); //old mode?
-                    }
-                }
-
-                if(s->flags & CODEC_FLAG_QP_RD){
-                    if(best_s.mv_type==MV_TYPE_16X16 && !(best_s.mv_dir&MV_DIRECT)){
-                        const int last_qp= backup_s.qscale;
-                        int dquant, dir, qp, dc[6];
-                        DCTELEM ac[6][16];
-                        const int mvdir= (best_s.mv_dir&MV_DIR_BACKWARD) ? 1 : 0;
-                        
-                        assert(backup_s.dquant == 0);
-
-                        //FIXME intra
-                        s->mv_dir= best_s.mv_dir;
-                        s->mv_type = MV_TYPE_16X16;
-                        s->mb_intra= best_s.mb_intra;
-                        s->mv[0][0][0] = best_s.mv[0][0][0];
-                        s->mv[0][0][1] = best_s.mv[0][0][1];
-                        s->mv[1][0][0] = best_s.mv[1][0][0];
-                        s->mv[1][0][1] = best_s.mv[1][0][1];
-                        
-                        dir= s->pict_type == B_TYPE ? 2 : 1;
-                        if(last_qp + dir > s->avctx->qmax) dir= -dir;
-                        for(dquant= dir; dquant<=2 && dquant>=-2; dquant += dir){
-                            qp= last_qp + dquant;
-                            if(qp < s->avctx->qmin || qp > s->avctx->qmax)
-                                break;
-                            backup_s.dquant= dquant;
-                            if(s->mb_intra && s->dc_val[0]){
-                                for(i=0; i<6; i++){
-                                    dc[i]= s->dc_val[0][ s->block_index[i] ];
-                                    memcpy(ac[i], s->ac_val[0][s->block_index[i]], sizeof(DCTELEM)*16);
-                                }
-                            }
-
-                            encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER /* wrong but unused */, pb, pb2, tex_pb, 
-                                         &dmin, &next_block, s->mv[mvdir][0][0], s->mv[mvdir][0][1]);
-                            if(best_s.qscale != qp){
-                                if(s->mb_intra && s->dc_val[0]){
-                                    for(i=0; i<6; i++){
-                                        s->dc_val[0][ s->block_index[i] ]= dc[i];
-                                        memcpy(s->ac_val[0][s->block_index[i]], ac[i], sizeof(DCTELEM)*16);
-                                    }
-                                }
-                                if(dir > 0 && dquant==dir){
-                                    dquant= 0;
-                                    dir= -dir;
-                                }else
-                                    break;
-                            }
-                        }
-                        qp= best_s.qscale;
-                        s->current_picture.qscale_table[xy]= qp;
-                    }
-                }
-
-                copy_context_after_encode(s, &best_s, -1);
-                
-                pb_bits_count= put_bits_count(&s->pb);
-                flush_put_bits(&s->pb);
-                ff_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count);
-                s->pb= backup_s.pb;
-                
-                if(s->data_partitioning){
-                    pb2_bits_count= put_bits_count(&s->pb2);
-                    flush_put_bits(&s->pb2);
-                    ff_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count);
-                    s->pb2= backup_s.pb2;
-                    
-                    tex_pb_bits_count= put_bits_count(&s->tex_pb);
-                    flush_put_bits(&s->tex_pb);
-                    ff_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count);
-                    s->tex_pb= backup_s.tex_pb;
-                }
-                s->last_bits= put_bits_count(&s->pb);
-               
-                if (s->out_format == FMT_H263 && s->pict_type!=B_TYPE)
-                    ff_h263_update_motion_val(s);
-        
-                if(next_block==0){ //FIXME 16 vs linesize16
-                    s->dsp.put_pixels_tab[0][0](s->dest[0], s->rd_scratchpad                     , s->linesize  ,16);
-                    s->dsp.put_pixels_tab[1][0](s->dest[1], s->rd_scratchpad + 16*s->linesize    , s->uvlinesize, 8);
-                    s->dsp.put_pixels_tab[1][0](s->dest[2], s->rd_scratchpad + 16*s->linesize + 8, s->uvlinesize, 8);
-                }
-
-                if(s->avctx->mb_decision == FF_MB_DECISION_BITS)
-                    MPV_decode_mb(s, s->block);
-            } else {
-                int motion_x, motion_y;
-                s->mv_type=MV_TYPE_16X16;
-                // only one MB-Type possible
-                
-                switch(mb_type){
-                case CANDIDATE_MB_TYPE_INTRA:
-                    s->mv_dir = 0;
-                    s->mb_intra= 1;
-                    motion_x= s->mv[0][0][0] = 0;
-                    motion_y= s->mv[0][0][1] = 0;
-                    break;
-                case CANDIDATE_MB_TYPE_INTER:
-                    s->mv_dir = MV_DIR_FORWARD;
-                    s->mb_intra= 0;
-                    motion_x= s->mv[0][0][0] = s->p_mv_table[xy][0];
-                    motion_y= s->mv[0][0][1] = s->p_mv_table[xy][1];
-                    break;
-                case CANDIDATE_MB_TYPE_INTER_I:
-                    s->mv_dir = MV_DIR_FORWARD;
-                    s->mv_type = MV_TYPE_FIELD;
-                    s->mb_intra= 0;
-                    for(i=0; i<2; i++){
-                        j= s->field_select[0][i] = s->p_field_select_table[i][xy];
-                        s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0];
-                        s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1];
-                    }
-                    motion_x = motion_y = 0;
-                    break;
-                case CANDIDATE_MB_TYPE_INTER4V:
-                    s->mv_dir = MV_DIR_FORWARD;
-                    s->mv_type = MV_TYPE_8X8;
-                    s->mb_intra= 0;
-                    for(i=0; i<4; i++){
-                        s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0];
-                        s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1];
-                    }
-                    motion_x= motion_y= 0;
-                    break;
-                case CANDIDATE_MB_TYPE_DIRECT:
-                    s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
-                    s->mb_intra= 0;
-                    motion_x=s->b_direct_mv_table[xy][0];
-                    motion_y=s->b_direct_mv_table[xy][1];
-                    ff_mpeg4_set_direct_mv(s, motion_x, motion_y);
-                    break;
-                case CANDIDATE_MB_TYPE_BIDIR:
-                    s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
-                    s->mb_intra= 0;
-                    motion_x=0;
-                    motion_y=0;
-                    s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
-                    s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
-                    s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
-                    s->mv[1][0][1] = s->b_bidir_back_mv_table[xy][1];
-                    break;
-                case CANDIDATE_MB_TYPE_BACKWARD:
-                    s->mv_dir = MV_DIR_BACKWARD;
-                    s->mb_intra= 0;
-                    motion_x= s->mv[1][0][0] = s->b_back_mv_table[xy][0];
-                    motion_y= s->mv[1][0][1] = s->b_back_mv_table[xy][1];
-                    break;
-                case CANDIDATE_MB_TYPE_FORWARD:
-                    s->mv_dir = MV_DIR_FORWARD;
-                    s->mb_intra= 0;
-                    motion_x= s->mv[0][0][0] = s->b_forw_mv_table[xy][0];
-                    motion_y= s->mv[0][0][1] = s->b_forw_mv_table[xy][1];
-//                    printf(" %d %d ", motion_x, motion_y);
-                    break;
-                case CANDIDATE_MB_TYPE_FORWARD_I:
-                    s->mv_dir = MV_DIR_FORWARD;
-                    s->mv_type = MV_TYPE_FIELD;
-                    s->mb_intra= 0;
-                    for(i=0; i<2; i++){
-                        j= s->field_select[0][i] = s->b_field_select_table[0][i][xy];
-                        s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0];
-                        s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1];
-                    }
-                    motion_x=motion_y=0;
-                    break;
-                case CANDIDATE_MB_TYPE_BACKWARD_I:
-                    s->mv_dir = MV_DIR_BACKWARD;
-                    s->mv_type = MV_TYPE_FIELD;
-                    s->mb_intra= 0;
-                    for(i=0; i<2; i++){
-                        j= s->field_select[1][i] = s->b_field_select_table[1][i][xy];
-                        s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0];
-                        s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1];
-                    }
-                    motion_x=motion_y=0;
-                    break;
-                case CANDIDATE_MB_TYPE_BIDIR_I:
-                    s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
-                    s->mv_type = MV_TYPE_FIELD;
-                    s->mb_intra= 0;
-                    for(dir=0; dir<2; dir++){
-                        for(i=0; i<2; i++){
-                            j= s->field_select[dir][i] = s->b_field_select_table[dir][i][xy];
-                            s->mv[dir][i][0] = s->b_field_mv_table[dir][i][j][xy][0];
-                            s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1];
-                        }
-                    }
-                    motion_x=motion_y=0;
-                    break;
-                default:
-                    motion_x=motion_y=0; //gcc warning fix
-                    av_log(s->avctx, AV_LOG_ERROR, "illegal MB type\n");
-                }
-
-                encode_mb(s, motion_x, motion_y);
-
-                // RAL: Update last macroblock type
-                s->last_mv_dir = s->mv_dir;
-            
-                if (s->out_format == FMT_H263 && s->pict_type!=B_TYPE)
-                    ff_h263_update_motion_val(s);
-		
-                MPV_decode_mb(s, s->block);
-            }
-
-            /* clean the MV table in IPS frames for direct mode in B frames */
-            if(s->mb_intra /* && I,P,S_TYPE */){
-                s->p_mv_table[xy][0]=0;
-                s->p_mv_table[xy][1]=0;
-            }
-            
-            if(s->flags&CODEC_FLAG_PSNR){
-                int w= 16;
-                int h= 16;
-
-                if(s->mb_x*16 + 16 > s->width ) w= s->width - s->mb_x*16;
-                if(s->mb_y*16 + 16 > s->height) h= s->height- s->mb_y*16;
-
-                s->current_picture_ptr->error[0] += sse(
-                    s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*s->linesize*16,
-                    s->dest[0], w, h, s->linesize);
-                s->current_picture_ptr->error[1] += sse(
-                    s, s->new_picture.data[1] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,
-                    s->dest[1], w>>1, h>>1, s->uvlinesize);
-                s->current_picture_ptr->error[2] += sse(
-                    s, s->new_picture    .data[2] + s->mb_x*8  + s->mb_y*s->uvlinesize*8,
-                    s->dest[2], w>>1, h>>1, s->uvlinesize);
-            }
-            if(s->loop_filter){
-                if(s->out_format == FMT_H263)
-                    ff_h263_loop_filter(s);
-            }
-//printf("MB %d %d bits\n", s->mb_x+s->mb_y*s->mb_stride, put_bits_count(&s->pb));
-        }
-    }
-
-    //not beautiful here but we must write it before flushing so it has to be here
-    if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == I_TYPE)
-        msmpeg4_encode_ext_header(s);
-
-    write_slice_end(s);
-
-    /* Send the last GOB if RTP */    
-    if (s->avctx->rtp_callback) {
-        int number_mb = (mb_y - s->resync_mb_y)*s->mb_width - s->resync_mb_x;
-        pdif = pbBufPtr(&s->pb) - s->ptr_lastgob;
-        /* Call the RTP callback to send the last GOB */
-        emms_c();
-        s->avctx->rtp_callback(s->avctx, s->ptr_lastgob, pdif, number_mb);
-    }
-
-    return 0;
-}
-
-#define MERGE(field) dst->field += src->field; src->field=0
-static void merge_context_after_me(MpegEncContext *dst, MpegEncContext *src){
-    MERGE(me.scene_change_score);
-    MERGE(me.mc_mb_var_sum_temp);
-    MERGE(me.mb_var_sum_temp);
-}
-
-static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src){
-    int i;
-
-    MERGE(dct_count[0]); //note, the other dct vars are not part of the context
-    MERGE(dct_count[1]);
-    MERGE(mv_bits);
-    MERGE(i_tex_bits);
-    MERGE(p_tex_bits);
-    MERGE(i_count);
-    MERGE(f_count);
-    MERGE(b_count);
-    MERGE(skip_count);
-    MERGE(misc_bits);
-    MERGE(error_count);
-    MERGE(padding_bug_score);
-
-    if(dst->avctx->noise_reduction){
-        for(i=0; i<64; i++){
-            MERGE(dct_error_sum[0][i]);
-            MERGE(dct_error_sum[1][i]);
-        }
-    }
-    
-    assert(put_bits_count(&src->pb) % 8 ==0);
-    assert(put_bits_count(&dst->pb) % 8 ==0);
-    ff_copy_bits(&dst->pb, src->pb.buf, put_bits_count(&src->pb));
-    flush_put_bits(&dst->pb);
-}
-
-static void encode_picture(MpegEncContext *s, int picture_number)
-{
-    int i;
-    int bits;
-
-    s->picture_number = picture_number;
-    
-    /* Reset the average MB variance */
-    s->me.mb_var_sum_temp    =
-    s->me.mc_mb_var_sum_temp = 0;
-
-    /* we need to initialize some time vars before we can encode b-frames */
-    // RAL: Condition added for MPEG1VIDEO
-    if (s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO || (s->h263_pred && !s->h263_msmpeg4))
-        ff_set_mpeg4_time(s, s->picture_number);  //FIXME rename and use has_b_frames or similar
-        
-    s->me.scene_change_score=0;
-    
-//    s->lambda= s->current_picture_ptr->quality; //FIXME qscale / ... stuff for ME ratedistoration
-    
-    if(s->pict_type==I_TYPE){
-        if(s->msmpeg4_version >= 3) s->no_rounding=1;
-        else                        s->no_rounding=0;
-    }else if(s->pict_type!=B_TYPE){
-        if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4)
-            s->no_rounding ^= 1;          
-    }
-    
-    s->mb_intra=0; //for the rate distortion & bit compare functions
-    for(i=1; i<s->avctx->thread_count; i++){
-        ff_update_duplicate_context(s->thread_context[i], s);
-    }
-
-    ff_init_me(s);
-
-    /* Estimate motion for every MB */
-    if(s->pict_type != I_TYPE){
-        s->lambda = (s->lambda * s->avctx->me_penalty_compensation + 128)>>8;
-        s->lambda2= (s->lambda2* s->avctx->me_penalty_compensation + 128)>>8;
-        if(s->pict_type != B_TYPE && s->avctx->me_threshold==0){
-            if((s->avctx->pre_me && s->last_non_b_pict_type==I_TYPE) || s->avctx->pre_me==2){
-                s->avctx->execute(s->avctx, pre_estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count);
-            }
-        }
-
-        s->avctx->execute(s->avctx, estimate_motion_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count);
-    }else /* if(s->pict_type == I_TYPE) */{
-        /* I-Frame */
-        for(i=0; i<s->mb_stride*s->mb_height; i++)
-            s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
-        
-        if(!s->fixed_qscale){
-            /* finding spatial complexity for I-frame rate control */
-            s->avctx->execute(s->avctx, mb_var_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count);
-        }
-    }
-    for(i=1; i<s->avctx->thread_count; i++){
-        merge_context_after_me(s, s->thread_context[i]);
-    }
-    s->current_picture.mc_mb_var_sum= s->current_picture_ptr->mc_mb_var_sum= s->me.mc_mb_var_sum_temp;
-    s->current_picture.   mb_var_sum= s->current_picture_ptr->   mb_var_sum= s->me.   mb_var_sum_temp;
-    emms_c();
-
-    if(s->me.scene_change_score > s->avctx->scenechange_threshold && s->pict_type == P_TYPE){
-        s->pict_type= I_TYPE;
-        for(i=0; i<s->mb_stride*s->mb_height; i++)
-            s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
-//printf("Scene change detected, encoding as I Frame %d %d\n", s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum);
-    }
-
-    if(!s->umvplus){
-        if(s->pict_type==P_TYPE || s->pict_type==S_TYPE) {
-            s->f_code= ff_get_best_fcode(s, s->p_mv_table, CANDIDATE_MB_TYPE_INTER);
-
-            if(s->flags & CODEC_FLAG_INTERLACED_ME){
-                int a,b;
-                a= ff_get_best_fcode(s, s->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I); //FIXME field_select
-                b= ff_get_best_fcode(s, s->p_field_mv_table[1][1], CANDIDATE_MB_TYPE_INTER_I);
-                s->f_code= FFMAX(s->f_code, FFMAX(a,b));
-            }
-                    
-            ff_fix_long_p_mvs(s);
-            ff_fix_long_mvs(s, NULL, 0, s->p_mv_table, s->f_code, CANDIDATE_MB_TYPE_INTER, 0);
-            if(s->flags & CODEC_FLAG_INTERLACED_ME){
-                int j;
-                for(i=0; i<2; i++){
-                    for(j=0; j<2; j++)
-                        ff_fix_long_mvs(s, s->p_field_select_table[i], j, 
-                                        s->p_field_mv_table[i][j], s->f_code, CANDIDATE_MB_TYPE_INTER_I, 0);
-                }
-            }
-        }
-
-        if(s->pict_type==B_TYPE){
-            int a, b;
-
-            a = ff_get_best_fcode(s, s->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD);
-            b = ff_get_best_fcode(s, s->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR);
-            s->f_code = FFMAX(a, b);
-
-            a = ff_get_best_fcode(s, s->b_back_mv_table, CANDIDATE_MB_TYPE_BACKWARD);
-            b = ff_get_best_fcode(s, s->b_bidir_back_mv_table, CANDIDATE_MB_TYPE_BIDIR);
-            s->b_code = FFMAX(a, b);
-
-            ff_fix_long_mvs(s, NULL, 0, s->b_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_FORWARD, 1);
-            ff_fix_long_mvs(s, NULL, 0, s->b_back_mv_table, s->b_code, CANDIDATE_MB_TYPE_BACKWARD, 1);
-            ff_fix_long_mvs(s, NULL, 0, s->b_bidir_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_BIDIR, 1);
-            ff_fix_long_mvs(s, NULL, 0, s->b_bidir_back_mv_table, s->b_code, CANDIDATE_MB_TYPE_BIDIR, 1);
-            if(s->flags & CODEC_FLAG_INTERLACED_ME){
-                int dir, j;
-                for(dir=0; dir<2; dir++){
-                    for(i=0; i<2; i++){
-                        for(j=0; j<2; j++){
-                            int type= dir ? (CANDIDATE_MB_TYPE_BACKWARD_I|CANDIDATE_MB_TYPE_BIDIR_I) 
-                                          : (CANDIDATE_MB_TYPE_FORWARD_I |CANDIDATE_MB_TYPE_BIDIR_I);
-                            ff_fix_long_mvs(s, s->b_field_select_table[dir][i], j, 
-                                            s->b_field_mv_table[dir][i][j], dir ? s->b_code : s->f_code, type, 1);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    if (!s->fixed_qscale) 
-        s->current_picture.quality = ff_rate_estimate_qscale(s); //FIXME pic_ptr
-
-    if(s->adaptive_quant){
-        switch(s->codec_id){
-//         case CODEC_ID_MPEG4:
-//             ff_clean_mpeg4_qscales(s);
-//             break;
-//         case CODEC_ID_H263:
-//         case CODEC_ID_H263P:
-//         case CODEC_ID_FLV1:
-//             ff_clean_h263_qscales(s);
-//             break;
-        }
-
-        s->lambda= s->lambda_table[0];
-        //FIXME broken
-    }else
-        s->lambda= s->current_picture.quality;
-//printf("%d %d\n", s->avctx->global_quality, s->current_picture.quality);
-    update_qscale(s);
-    
-    if(s->qscale < 3 && s->max_qcoeff<=128 && s->pict_type==I_TYPE && !(s->flags & CODEC_FLAG_QSCALE)) 
-        s->qscale= 3; //reduce clipping problems
-        
-    if (s->out_format == FMT_MJPEG) {
-        /* for mjpeg, we do include qscale in the matrix */
-        s->intra_matrix[0] = ff_mpeg1_default_intra_matrix[0];
-        for(i=1;i<64;i++){
-            int j= s->dsp.idct_permutation[i];
-
-            s->intra_matrix[j] = clip_uint8((ff_mpeg1_default_intra_matrix[i] * s->qscale) >> 3) & 0xFF;
-        }
-        convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16, 
-                       s->intra_matrix, s->intra_quant_bias, 8, 8, 1);
-        s->qscale= 8;
-    }
-    
-    //FIXME var duplication
-    s->current_picture_ptr->key_frame=
-    s->current_picture.key_frame= s->pict_type == I_TYPE; //FIXME pic_ptr
-    s->current_picture_ptr->pict_type=
-    s->current_picture.pict_type= s->pict_type;
-
-    if(s->current_picture.key_frame)
-        s->picture_in_gop_number=0;
-
-    s->last_bits= put_bits_count(&s->pb);
-    switch(s->out_format) {
-//     case FMT_MJPEG:
-//         mjpeg_picture_header(s);
-//         break;
-// #ifdef CONFIG_H261_ENCODER
-//     case FMT_H261:
-//         ff_h261_encode_picture_header(s, picture_number);
-//         break;
-// #endif
-//     case FMT_H263:
-//         if (s->codec_id == CODEC_ID_WMV2) 
-//             ff_wmv2_encode_picture_header(s, picture_number);
-//         else if (s->h263_msmpeg4) 
-//             msmpeg4_encode_picture_header(s, picture_number);
-//         else if (s->h263_pred)
-//             mpeg4_encode_picture_header(s, picture_number);
-// #ifdef CONFIG_RV10_ENCODER
-//         else if (s->codec_id == CODEC_ID_RV10) 
-//             rv10_encode_picture_header(s, picture_number);
-// #endif
-// #ifdef CONFIG_RV20_ENCODER
-//         else if (s->codec_id == CODEC_ID_RV20) 
-//             rv20_encode_picture_header(s, picture_number);
-// #endif
-//         else if (s->codec_id == CODEC_ID_FLV1)
-//             ff_flv_encode_picture_header(s, picture_number);
-//         else
-//             h263_encode_picture_header(s, picture_number);
-//         break;
-    case FMT_MPEG1:
-        mpeg1_encode_picture_header(s, picture_number);
-        break;
-//     case FMT_H264:
-//         break;
-    default:
-        assert(0);
-    }
-    bits= put_bits_count(&s->pb);
-    s->header_bits= bits - s->last_bits;
-        
-    for(i=1; i<s->avctx->thread_count; i++){
-        update_duplicate_context_after_me(s->thread_context[i], s);
-    }
-    s->avctx->execute(s->avctx, encode_thread, (void**)&(s->thread_context[0]), NULL, s->avctx->thread_count);
-    for(i=1; i<s->avctx->thread_count; i++){
-        merge_context_after_encode(s, s->thread_context[i]);
-    }
-    emms_c();
-}
-
-#endif //CONFIG_ENCODERS
-
-static void  denoise_dct_c(MpegEncContext *s, DCTELEM *block){
-    const int intra= s->mb_intra;
-    int i;
-
-    s->dct_count[intra]++;
-
-    for(i=0; i<64; i++){
-        int level= block[i];
-
-        if(level){
-            if(level>0){
-                s->dct_error_sum[intra][i] += level;
-                level -= s->dct_offset[intra][i];
-                if(level<0) level=0;
-            }else{
-                s->dct_error_sum[intra][i] -= level;
-                level += s->dct_offset[intra][i];
-                if(level>0) level=0;
-            }
-            block[i]= level;
-        }
-    }
-}
-
-#ifdef CONFIG_ENCODERS
-
-static int dct_quantize_trellis_c(MpegEncContext *s, 
-                        DCTELEM *block, int n,
-                        int qscale, int *overflow){
-    const int *qmat;
-    const uint8_t *scantable= s->intra_scantable.scantable;
-    const uint8_t *perm_scantable= s->intra_scantable.permutated;
-    int max=0;
-    unsigned int threshold1, threshold2;
-    int bias=0;
-    int run_tab[65];
-    int level_tab[65];
-    int score_tab[65];
-    int survivor[65];
-    int survivor_count;
-    int last_run=0;
-    int last_level=0;
-    int last_score= 0;
-    int last_i;
-    int coeff[2][64];
-    int coeff_count[64];
-    int qmul, qadd, start_i, last_non_zero, i, dc;
-    const int esc_length= s->ac_esc_length;
-    uint8_t * length;
-    uint8_t * last_length;
-    const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
-        
-    s->dsp.fdct (block);
-    
-    if(s->dct_error_sum)
-        s->denoise_dct(s, block);
-    qmul= qscale*16;
-    qadd= ((qscale-1)|1)*8;
-
-    if (s->mb_intra) {
-        int q;
-        if (!s->h263_aic) {
-            if (n < 4)
-                q = s->y_dc_scale;
-            else
-                q = s->c_dc_scale;
-            q = q << 3;
-        } else{
-            /* For AIC we skip quant/dequant of INTRADC */
-            q = 1 << 3;
-            qadd=0;
-        }
-            
-        /* note: block[0] is assumed to be positive */
-        block[0] = (block[0] + (q >> 1)) / q;
-        start_i = 1;
-        last_non_zero = 0;
-        qmat = s->q_intra_matrix[qscale];
-        if(s->mpeg_quant || s->out_format == FMT_MPEG1)
-            bias= 1<<(QMAT_SHIFT-1);
-        length     = s->intra_ac_vlc_length;
-        last_length= s->intra_ac_vlc_last_length;
-    } else {
-        start_i = 0;
-        last_non_zero = -1;
-        qmat = s->q_inter_matrix[qscale];
-        length     = s->inter_ac_vlc_length;
-        last_length= s->inter_ac_vlc_last_length;
-    }
-    last_i= start_i;
-
-    threshold1= (1<<QMAT_SHIFT) - bias - 1;
-    threshold2= (threshold1<<1);
-
-    for(i=63; i>=start_i; i--) {
-        const int j = scantable[i];
-        int level = block[j] * qmat[j];
-
-        if(((unsigned)(level+threshold1))>threshold2){
-            last_non_zero = i;
-            break;
-        }
-    }
-
-    for(i=start_i; i<=last_non_zero; i++) {
-        const int j = scantable[i];
-        int level = block[j] * qmat[j];
-
-//        if(   bias+level >= (1<<(QMAT_SHIFT - 3))
-//           || bias-level >= (1<<(QMAT_SHIFT - 3))){
-        if(((unsigned)(level+threshold1))>threshold2){
-            if(level>0){
-                level= (bias + level)>>QMAT_SHIFT;
-                coeff[0][i]= level;
-                coeff[1][i]= level-1;
-//                coeff[2][k]= level-2;
-            }else{
-                level= (bias - level)>>QMAT_SHIFT;
-                coeff[0][i]= -level;
-                coeff[1][i]= -level+1;
-//                coeff[2][k]= -level+2;
-            }
-            coeff_count[i]= FFMIN(level, 2);
-            assert(coeff_count[i]);
-            max |=level;
-        }else{
-            coeff[0][i]= (level>>31)|1;
-            coeff_count[i]= 1;
-        }
-    }
-    
-    *overflow= s->max_qcoeff < max; //overflow might have happened
-    
-    if(last_non_zero < start_i){
-        memset(block + start_i, 0, (64-start_i)*sizeof(DCTELEM));
-        return last_non_zero;
-    }
-
-    score_tab[start_i]= 0;
-    survivor[0]= start_i;
-    survivor_count= 1;
-    
-    for(i=start_i; i<=last_non_zero; i++){
-        int level_index, j;
-        const int dct_coeff= ABS(block[ scantable[i] ]);
-        const int zero_distoration= dct_coeff*dct_coeff;
-        int best_score=256*256*256*120;
-        for(level_index=0; level_index < coeff_count[i]; level_index++){
-            int distoration;
-            int level= coeff[level_index][i];
-            const int alevel= ABS(level);
-            int unquant_coeff;
-            
-            assert(level);
-
-            if(s->out_format == FMT_H263){
-                unquant_coeff= alevel*qmul + qadd;
-            }else{ //MPEG1
-                j= s->dsp.idct_permutation[ scantable[i] ]; //FIXME optimize
-                if(s->mb_intra){
-                        unquant_coeff = (int)(  alevel  * qscale * s->intra_matrix[j]) >> 3;
-                        unquant_coeff =   (unquant_coeff - 1) | 1;
-                }else{
-                        unquant_coeff = (((  alevel  << 1) + 1) * qscale * ((int) s->inter_matrix[j])) >> 4;
-                        unquant_coeff =   (unquant_coeff - 1) | 1;
-                }
-                unquant_coeff<<= 3;
-            }
-
-            distoration= (unquant_coeff - dct_coeff) * (unquant_coeff - dct_coeff) - zero_distoration;
-            level+=64;
-            if((level&(~127)) == 0){
-                for(j=survivor_count-1; j>=0; j--){
-                    int run= i - survivor[j];
-                    int score= distoration + length[UNI_AC_ENC_INDEX(run, level)]*lambda;
-                    score += score_tab[i-run];
-                    
-                    if(score < best_score){
-                        best_score= score;
-                        run_tab[i+1]= run;
-                        level_tab[i+1]= level-64;
-                    }
-                }
-
-                if(s->out_format == FMT_H263){
-                    for(j=survivor_count-1; j>=0; j--){
-                        int run= i - survivor[j];
-                        int score= distoration + last_length[UNI_AC_ENC_INDEX(run, level)]*lambda;
-                        score += score_tab[i-run];
-                        if(score < last_score){
-                            last_score= score;
-                            last_run= run;
-                            last_level= level-64;
-                            last_i= i+1;
-                        }
-                    }
-                }
-            }else{
-                distoration += esc_length*lambda;
-                for(j=survivor_count-1; j>=0; j--){
-                    int run= i - survivor[j];
-                    int score= distoration + score_tab[i-run];
-                    
-                    if(score < best_score){
-                        best_score= score;
-                        run_tab[i+1]= run;
-                        level_tab[i+1]= level-64;
-                    }
-                }
-
-                if(s->out_format == FMT_H263){
-                  for(j=survivor_count-1; j>=0; j--){
-                        int run= i - survivor[j];
-                        int score= distoration + score_tab[i-run];
-                        if(score < last_score){
-                            last_score= score;
-                            last_run= run;
-                            last_level= level-64;
-                            last_i= i+1;
-                        }
-                    }
-                }
-            }
-        }
-        
-        score_tab[i+1]= best_score;
-
-        //Note: there is a vlc code in mpeg4 which is 1 bit shorter then another one with a shorter run and the same level
-        if(last_non_zero <= 27){
-            for(; survivor_count; survivor_count--){
-                if(score_tab[ survivor[survivor_count-1] ] <= best_score)
-                    break;
-            }
-        }else{
-            for(; survivor_count; survivor_count--){
-                if(score_tab[ survivor[survivor_count-1] ] <= best_score + lambda)
-                    break;
-            }
-        }
-
-        survivor[ survivor_count++ ]= i+1;
-    }
-
-    if(s->out_format != FMT_H263){
-        last_score= 256*256*256*120;
-        for(i= survivor[0]; i<=last_non_zero + 1; i++){
-            int score= score_tab[i];
-            if(i) score += lambda*2; //FIXME exacter?
-
-            if(score < last_score){
-                last_score= score;
-                last_i= i;
-                last_level= level_tab[i];
-                last_run= run_tab[i];
-            }
-        }
-    }
-
-    s->coded_score[n] = last_score;
-    
-    dc= ABS(block[0]);
-    last_non_zero= last_i - 1;
-    memset(block + start_i, 0, (64-start_i)*sizeof(DCTELEM));
-    
-    if(last_non_zero < start_i)
-        return last_non_zero;
-
-    if(last_non_zero == 0 && start_i == 0){
-        int best_level= 0;
-        int best_score= dc * dc;
-        
-        for(i=0; i<coeff_count[0]; i++){
-            int level= coeff[i][0];
-            int alevel= ABS(level);
-            int unquant_coeff, score, distortion;
-
-            if(s->out_format == FMT_H263){
-                    unquant_coeff= (alevel*qmul + qadd)>>3;
-            }else{ //MPEG1
-                    unquant_coeff = (((  alevel  << 1) + 1) * qscale * ((int) s->inter_matrix[0])) >> 4;
-                    unquant_coeff =   (unquant_coeff - 1) | 1;
-            }
-            unquant_coeff = (unquant_coeff + 4) >> 3;
-            unquant_coeff<<= 3 + 3;
-
-            distortion= (unquant_coeff - dc) * (unquant_coeff - dc);
-            level+=64;
-            if((level&(~127)) == 0) score= distortion + last_length[UNI_AC_ENC_INDEX(0, level)]*lambda;
-            else                    score= distortion + esc_length*lambda;
-
-            if(score < best_score){
-                best_score= score;
-                best_level= level - 64;
-            }
-        }
-        block[0]= best_level;
-        s->coded_score[n] = best_score - dc*dc;
-        if(best_level == 0) return -1;
-        else                return last_non_zero;
-    }
-
-    i= last_i;
-    assert(last_level);
-
-    block[ perm_scantable[last_non_zero] ]= last_level;
-    i -= last_run + 1;
-    
-    for(; i>start_i; i -= run_tab[i] + 1){
-        block[ perm_scantable[i-1] ]= level_tab[i];
-    }
-
-    return last_non_zero;
-}
-
-//#define REFINE_STATS 1
-static int16_t basis[64][64];
-
-static void build_basis(uint8_t *perm){
-    int i, j, x, y;
-    emms_c();
-    for(i=0; i<8; i++){
-        for(j=0; j<8; j++){
-            for(y=0; y<8; y++){
-                for(x=0; x<8; x++){
-                    double s= 0.25*(1<<BASIS_SHIFT);
-                    int index= 8*i + j;
-                    int perm_index= perm[index];
-                    if(i==0) s*= sqrt(0.5);
-                    if(j==0) s*= sqrt(0.5);
-                    basis[perm_index][8*x + y]= lrintf(s * cos((M_PI/8.0)*i*(x+0.5)) * cos((M_PI/8.0)*j*(y+0.5)));
-                }
-            }
-        }
-    }
-}
-
-static int dct_quantize_refine(MpegEncContext *s, //FIXME breaks denoise?
-                        DCTELEM *block, int16_t *weight, DCTELEM *orig,
-                        int n, int qscale){
-    int16_t rem[64];
-    DCTELEM d1[64] __align16;
-    const int *qmat;
-    const uint8_t *scantable= s->intra_scantable.scantable;
-    const uint8_t *perm_scantable= s->intra_scantable.permutated;
-//    unsigned int threshold1, threshold2;
-//    int bias=0;
-    int run_tab[65];
-    int prev_run=0;
-    int prev_level=0;
-    int qmul, qadd, start_i, last_non_zero, i, dc;
-    uint8_t * length;
-    uint8_t * last_length;
-    int lambda;
-    int rle_index, run, q, sum;
-#ifdef REFINE_STATS
-static int count=0;
-static int after_last=0;
-static int to_zero=0;
-static int from_zero=0;
-static int raise=0;
-static int lower=0;
-static int messed_sign=0;
-#endif
-
-    if(basis[0][0] == 0)
-        build_basis(s->dsp.idct_permutation);
-    
-    qmul= qscale*2;
-    qadd= (qscale-1)|1;
-    if (s->mb_intra) {
-        if (!s->h263_aic) {
-            if (n < 4)
-                q = s->y_dc_scale;
-            else
-                q = s->c_dc_scale;
-        } else{
-            /* For AIC we skip quant/dequant of INTRADC */
-            q = 1;
-            qadd=0;
-        }
-        q <<= RECON_SHIFT-3;
-        /* note: block[0] is assumed to be positive */
-        dc= block[0]*q;
-//        block[0] = (block[0] + (q >> 1)) / q;
-        start_i = 1;
-        qmat = s->q_intra_matrix[qscale];
-//        if(s->mpeg_quant || s->out_format == FMT_MPEG1)
-//            bias= 1<<(QMAT_SHIFT-1);
-        length     = s->intra_ac_vlc_length;
-        last_length= s->intra_ac_vlc_last_length;
-    } else {
-        dc= 0;
-        start_i = 0;
-        qmat = s->q_inter_matrix[qscale];
-        length     = s->inter_ac_vlc_length;
-        last_length= s->inter_ac_vlc_last_length;
-    }
-    last_non_zero = s->block_last_index[n];
-
-#ifdef REFINE_STATS
-{START_TIMER
-#endif
-    dc += (1<<(RECON_SHIFT-1));
-    for(i=0; i<64; i++){
-        rem[i]= dc - (orig[i]<<RECON_SHIFT); //FIXME  use orig dirrectly instead of copying to rem[]
-    }
-#ifdef REFINE_STATS
-STOP_TIMER("memset rem[]")}
-#endif
-    sum=0;
-    for(i=0; i<64; i++){
-        int one= 36;
-        int qns=4;
-        int w;
-
-        w= ABS(weight[i]) + qns*one;
-        w= 15 + (48*qns*one + w/2)/w; // 16 .. 63
-
-        weight[i] = w;
-//        w=weight[i] = (63*qns + (w/2)) / w;
-         
-        assert(w>0);
-        assert(w<(1<<6));
-        sum += w*w;
-    }
-    lambda= sum*(uint64_t)s->lambda2 >> (FF_LAMBDA_SHIFT - 6 + 6 + 6 + 6);
-#ifdef REFINE_STATS
-{START_TIMER
-#endif
-    run=0;
-    rle_index=0;
-    for(i=start_i; i<=last_non_zero; i++){
-        int j= perm_scantable[i];
-        const int level= block[j];
-        int coeff;
-        
-        if(level){
-            if(level<0) coeff= qmul*level - qadd;
-            else        coeff= qmul*level + qadd;
-            run_tab[rle_index++]=run;
-            run=0;
-
-            s->dsp.add_8x8basis(rem, basis[j], coeff);
-        }else{
-            run++;
-        }
-    }
-#ifdef REFINE_STATS
-if(last_non_zero>0){
-STOP_TIMER("init rem[]")
-}
-}
-
-{START_TIMER
-#endif
-    for(;;){
-        int best_score=s->dsp.try_8x8basis(rem, weight, basis[0], 0);
-        int best_coeff=0;
-        int best_change=0;
-        int run2, best_unquant_change=0, analyze_gradient;
-#ifdef REFINE_STATS
-{START_TIMER
-#endif
-        analyze_gradient = last_non_zero > 2 || s->avctx->quantizer_noise_shaping >= 3;
-
-        if(analyze_gradient){
-#ifdef REFINE_STATS
-{START_TIMER
-#endif
-            for(i=0; i<64; i++){
-                int w= weight[i];
-            
-                d1[i] = (rem[i]*w*w + (1<<(RECON_SHIFT+12-1)))>>(RECON_SHIFT+12);
-            }
-#ifdef REFINE_STATS
-STOP_TIMER("rem*w*w")}
-{START_TIMER
-#endif
-            s->dsp.fdct(d1);
-#ifdef REFINE_STATS
-STOP_TIMER("dct")}
-#endif
-        }
-
-        if(start_i){
-            const int level= block[0];
-            int change, old_coeff;
-
-            assert(s->mb_intra);
-            
-            old_coeff= q*level;
-            
-            for(change=-1; change<=1; change+=2){
-                int new_level= level + change;
-                int score, new_coeff;
-                
-                new_coeff= q*new_level;
-                if(new_coeff >= 2048 || new_coeff < 0)
-                    continue;
-
-                score= s->dsp.try_8x8basis(rem, weight, basis[0], new_coeff - old_coeff);
-                if(score<best_score){
-                    best_score= score;
-                    best_coeff= 0;
-                    best_change= change;
-                    best_unquant_change= new_coeff - old_coeff;
-                }
-            }
-        }
-        
-        run=0;
-        rle_index=0;
-        run2= run_tab[rle_index++];
-        prev_level=0;
-        prev_run=0;
-
-        for(i=start_i; i<64; i++){
-            int j= perm_scantable[i];
-            const int level= block[j];
-            int change, old_coeff;
-
-            if(s->avctx->quantizer_noise_shaping < 3 && i > last_non_zero + 1)
-                break;
-
-            if(level){
-                if(level<0) old_coeff= qmul*level - qadd;
-                else        old_coeff= qmul*level + qadd;
-                run2= run_tab[rle_index++]; //FIXME ! maybe after last
-            }else{
-                old_coeff=0;
-                run2--;
-                assert(run2>=0 || i >= last_non_zero );
-            }
-            
-            for(change=-1; change<=1; change+=2){
-                int new_level= level + change;
-                int score, new_coeff, unquant_change;
-                
-                score=0;
-                if(s->avctx->quantizer_noise_shaping < 2 && ABS(new_level) > ABS(level))
-                   continue;
-
-                if(new_level){
-                    if(new_level<0) new_coeff= qmul*new_level - qadd;
-                    else            new_coeff= qmul*new_level + qadd;
-                    if(new_coeff >= 2048 || new_coeff <= -2048)
-                        continue;
-                    //FIXME check for overflow
-                    
-                    if(level){
-                        if(level < 63 && level > -63){
-                            if(i < last_non_zero)
-                                score +=   length[UNI_AC_ENC_INDEX(run, new_level+64)]
-                                         - length[UNI_AC_ENC_INDEX(run, level+64)];
-                            else
-                                score +=   last_length[UNI_AC_ENC_INDEX(run, new_level+64)]
-                                         - last_length[UNI_AC_ENC_INDEX(run, level+64)];
-                        }
-                    }else{
-                        assert(ABS(new_level)==1);
-                        
-                        if(analyze_gradient){
-                            int g= d1[ scantable[i] ];
-                            if(g && (g^new_level) >= 0)
-                                continue;
-                        }
-
-                        if(i < last_non_zero){
-                            int next_i= i + run2 + 1;
-                            int next_level= block[ perm_scantable[next_i] ] + 64;
-                            
-                            if(next_level&(~127))
-                                next_level= 0;
-
-                            if(next_i < last_non_zero)
-                                score +=   length[UNI_AC_ENC_INDEX(run, 65)]
-                                         + length[UNI_AC_ENC_INDEX(run2, next_level)]
-                                         - length[UNI_AC_ENC_INDEX(run + run2 + 1, next_level)];
-                            else
-                                score +=  length[UNI_AC_ENC_INDEX(run, 65)]
-                                        + last_length[UNI_AC_ENC_INDEX(run2, next_level)]
-                                        - last_length[UNI_AC_ENC_INDEX(run + run2 + 1, next_level)];
-                        }else{
-                            score += last_length[UNI_AC_ENC_INDEX(run, 65)];
-                            if(prev_level){
-                                score +=  length[UNI_AC_ENC_INDEX(prev_run, prev_level)]
-                                        - last_length[UNI_AC_ENC_INDEX(prev_run, prev_level)];
-                            }
-                        }
-                    }
-                }else{
-                    new_coeff=0;
-                    assert(ABS(level)==1);
-
-                    if(i < last_non_zero){
-                        int next_i= i + run2 + 1;
-                        int next_level= block[ perm_scantable[next_i] ] + 64;
-                            
-                        if(next_level&(~127))
-                            next_level= 0;
-
-                        if(next_i < last_non_zero)
-                            score +=   length[UNI_AC_ENC_INDEX(run + run2 + 1, next_level)]
-                                     - length[UNI_AC_ENC_INDEX(run2, next_level)]
-                                     - length[UNI_AC_ENC_INDEX(run, 65)];
-                        else
-                            score +=   last_length[UNI_AC_ENC_INDEX(run + run2 + 1, next_level)]
-                                     - last_length[UNI_AC_ENC_INDEX(run2, next_level)]
-                                     - length[UNI_AC_ENC_INDEX(run, 65)];
-                    }else{
-                        score += -last_length[UNI_AC_ENC_INDEX(run, 65)];
-                        if(prev_level){
-                            score +=  last_length[UNI_AC_ENC_INDEX(prev_run, prev_level)]
-                                    - length[UNI_AC_ENC_INDEX(prev_run, prev_level)];
-                        }
-                    }
-                }
-                
-                score *= lambda;
-
-                unquant_change= new_coeff - old_coeff;
-                assert((score < 100*lambda && score > -100*lambda) || lambda==0);
-                
-                score+= s->dsp.try_8x8basis(rem, weight, basis[j], unquant_change);
-                if(score<best_score){
-                    best_score= score;
-                    best_coeff= i;
-                    best_change= change;
-                    best_unquant_change= unquant_change;
-                }
-            }
-            if(level){
-                prev_level= level + 64;
-                if(prev_level&(~127))
-                    prev_level= 0;
-                prev_run= run;
-                run=0;
-            }else{
-                run++;
-            }
-        }
-#ifdef REFINE_STATS
-STOP_TIMER("iterative step")}
-#endif
-
-        if(best_change){
-            int j= perm_scantable[ best_coeff ];
-            
-            block[j] += best_change;
-            
-            if(best_coeff > last_non_zero){
-                last_non_zero= best_coeff;
-                assert(block[j]);
-#ifdef REFINE_STATS
-after_last++;
-#endif
-            }else{
-#ifdef REFINE_STATS
-if(block[j]){
-    if(block[j] - best_change){
-        if(ABS(block[j]) > ABS(block[j] - best_change)){
-            raise++;
-        }else{
-            lower++;
-        }
-    }else{
-        from_zero++;
-    }
-}else{
-    to_zero++;
-}
-#endif
-                for(; last_non_zero>=start_i; last_non_zero--){
-                    if(block[perm_scantable[last_non_zero]])
-                        break;
-                }
-            }
-#ifdef REFINE_STATS
-count++;
-if(256*256*256*64 % count == 0){
-    printf("after_last:%d to_zero:%d from_zero:%d raise:%d lower:%d sign:%d xyp:%d/%d/%d\n", after_last, to_zero, from_zero, raise, lower, messed_sign, s->mb_x, s->mb_y, s->picture_number);
-}
-#endif
-            run=0;
-            rle_index=0;
-            for(i=start_i; i<=last_non_zero; i++){
-                int j= perm_scantable[i];
-                const int level= block[j];
-        
-                 if(level){
-                     run_tab[rle_index++]=run;
-                     run=0;
-                 }else{
-                     run++;
-                 }
-            }
-            
-            s->dsp.add_8x8basis(rem, basis[j], best_unquant_change);
-        }else{
-            break;
-        }
-    }
-#ifdef REFINE_STATS
-if(last_non_zero>0){
-STOP_TIMER("iterative search")
-}
-}
-#endif
-
-    return last_non_zero;
-}
-
-static int dct_quantize_c(MpegEncContext *s, 
-                        DCTELEM *block, int n,
-                        int qscale, int *overflow)
-{
-    int i, j, level, last_non_zero, q, start_i;
-    const int *qmat;
-    const uint8_t *scantable= s->intra_scantable.scantable;
-    int bias;
-    int max=0;
-    unsigned int threshold1, threshold2;
-
-    s->dsp.fdct (block);
-
-    if(s->dct_error_sum)
-        s->denoise_dct(s, block);
-
-    if (s->mb_intra) {
-        if (!s->h263_aic) {
-            if (n < 4)
-                q = s->y_dc_scale;
-            else
-                q = s->c_dc_scale;
-            q = q << 3;
-        } else
-            /* For AIC we skip quant/dequant of INTRADC */
-            q = 1 << 3;
-            
-        /* note: block[0] is assumed to be positive */
-        block[0] = (block[0] + (q >> 1)) / q;
-        start_i = 1;
-        last_non_zero = 0;
-        qmat = s->q_intra_matrix[qscale];
-        bias= s->intra_quant_bias<<(QMAT_SHIFT - QUANT_BIAS_SHIFT);
-    } else {
-        start_i = 0;
-        last_non_zero = -1;
-        qmat = s->q_inter_matrix[qscale];
-        bias= s->inter_quant_bias<<(QMAT_SHIFT - QUANT_BIAS_SHIFT);
-    }
-    threshold1= (1<<QMAT_SHIFT) - bias - 1;
-    threshold2= (threshold1<<1);
-    for(i=63;i>=start_i;i--) {
-        j = scantable[i];
-        level = block[j] * qmat[j];
-
-        if(((unsigned)(level+threshold1))>threshold2){
-            last_non_zero = i;
-            break;
-        }else{
-            block[j]=0;
-        }
-    }
-    for(i=start_i; i<=last_non_zero; i++) {
-        j = scantable[i];
-        level = block[j] * qmat[j];
-
-//        if(   bias+level >= (1<<QMAT_SHIFT)
-//           || bias-level >= (1<<QMAT_SHIFT)){
-        if(((unsigned)(level+threshold1))>threshold2){
-            if(level>0){
-                level= (bias + level)>>QMAT_SHIFT;
-                block[j]= level;
-            }else{
-                level= (bias - level)>>QMAT_SHIFT;
-                block[j]= -level;
-            }
-            max |=level;
-        }else{
-            block[j]=0;
-        }
-    }
-    *overflow= s->max_qcoeff < max; //overflow might have happened
-    
-    /* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */
-    if (s->dsp.idct_permutation_type != FF_NO_IDCT_PERM)
-	ff_block_permute(block, s->dsp.idct_permutation, scantable, last_non_zero);
-
-    return last_non_zero;
-}
-
-#endif //CONFIG_ENCODERS
-
-static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s, 
-                                   DCTELEM *block, int n, int qscale)
-{
-    int i, level, nCoeffs;
-    const uint16_t *quant_matrix;
-
-    nCoeffs= s->block_last_index[n];
-    
-    if (n < 4) 
-        block[0] = block[0] * s->y_dc_scale;
-    else
-        block[0] = block[0] * s->c_dc_scale;
-    /* XXX: only mpeg1 */
-    quant_matrix = s->intra_matrix;
-    for(i=1;i<=nCoeffs;i++) {
-        int j= s->intra_scantable.permutated[i];
-        level = block[j];
-        if (level) {
-            if (level < 0) {
-                level = -level;
-                level = (int)(level * qscale * quant_matrix[j]) >> 3;
-                level = (level - 1) | 1;
-                level = -level;
-            } else {
-                level = (int)(level * qscale * quant_matrix[j]) >> 3;
-                level = (level - 1) | 1;
-            }
-            block[j] = level;
-        }
-    }
-}
-
-static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s, 
-                                   DCTELEM *block, int n, int qscale)
-{
-    int i, level, nCoeffs;
-    const uint16_t *quant_matrix;
-
-    nCoeffs= s->block_last_index[n];
-    
-    quant_matrix = s->inter_matrix;
-    for(i=0; i<=nCoeffs; i++) {
-        int j= s->intra_scantable.permutated[i];
-        level = block[j];
-        if (level) {
-            if (level < 0) {
-                level = -level;
-                level = (((level << 1) + 1) * qscale *
-                         ((int) (quant_matrix[j]))) >> 4;
-                level = (level - 1) | 1;
-                level = -level;
-            } else {
-                level = (((level << 1) + 1) * qscale *
-                         ((int) (quant_matrix[j]))) >> 4;
-                level = (level - 1) | 1;
-            }
-            block[j] = level;
-        }
-    }
-}
-
-static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s, 
-                                   DCTELEM *block, int n, int qscale)
-{
-    int i, level, nCoeffs;
-    const uint16_t *quant_matrix;
-
-    if(s->alternate_scan) nCoeffs= 63;
-    else nCoeffs= s->block_last_index[n];
-    
-    if (n < 4) 
-        block[0] = block[0] * s->y_dc_scale;
-    else
-        block[0] = block[0] * s->c_dc_scale;
-    quant_matrix = s->intra_matrix;
-    for(i=1;i<=nCoeffs;i++) {
-        int j= s->intra_scantable.permutated[i];
-        level = block[j];
-        if (level) {
-            if (level < 0) {
-                level = -level;
-                level = (int)(level * qscale * quant_matrix[j]) >> 3;
-                level = -level;
-            } else {
-                level = (int)(level * qscale * quant_matrix[j]) >> 3;
-            }
-            block[j] = level;
-        }
-    }
-}
-
-static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s, 
-                                   DCTELEM *block, int n, int qscale)
-{
-    int i, level, nCoeffs;
-    const uint16_t *quant_matrix;
-    int sum=-1;
-
-    if(s->alternate_scan) nCoeffs= 63;
-    else nCoeffs= s->block_last_index[n];
-    
-    quant_matrix = s->inter_matrix;
-    for(i=0; i<=nCoeffs; i++) {
-        int j= s->intra_scantable.permutated[i];
-        level = block[j];
-        if (level) {
-            if (level < 0) {
-                level = -level;
-                level = (((level << 1) + 1) * qscale *
-                         ((int) (quant_matrix[j]))) >> 4;
-                level = -level;
-            } else {
-                level = (((level << 1) + 1) * qscale *
-                         ((int) (quant_matrix[j]))) >> 4;
-            }
-            block[j] = level;
-            sum+=level;
-        }
-    }
-    block[63]^=sum&1;
-}
-
-static void dct_unquantize_h263_intra_c(MpegEncContext *s, 
-                                  DCTELEM *block, int n, int qscale)
-{
-    int i, level, qmul, qadd;
-    int nCoeffs;
-    
-    assert(s->block_last_index[n]>=0);
-    
-    qmul = qscale << 1;
-    
-    if (!s->h263_aic) {
-        if (n < 4) 
-            block[0] = block[0] * s->y_dc_scale;
-        else
-            block[0] = block[0] * s->c_dc_scale;
-        qadd = (qscale - 1) | 1;
-    }else{
-        qadd = 0;
-    }
-    if(s->ac_pred)
-        nCoeffs=63;
-    else
-        nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
-
-    for(i=1; i<=nCoeffs; i++) {
-        level = block[i];
-        if (level) {
-            if (level < 0) {
-                level = level * qmul - qadd;
-            } else {
-                level = level * qmul + qadd;
-            }
-            block[i] = level;
-        }
-    }
-}
-
-static void dct_unquantize_h263_inter_c(MpegEncContext *s, 
-                                  DCTELEM *block, int n, int qscale)
-{
-    int i, level, qmul, qadd;
-    int nCoeffs;
-    
-    assert(s->block_last_index[n]>=0);
-    
-    qadd = (qscale - 1) | 1;
-    qmul = qscale << 1;
-    
-    nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
-
-    for(i=0; i<=nCoeffs; i++) {
-        level = block[i];
-        if (level) {
-            if (level < 0) {
-                level = level * qmul - qadd;
-            } else {
-                level = level * qmul + qadd;
-            }
-            block[i] = level;
-        }
-    }
-}
-
-#ifdef CONFIG_ENCODERS
-// AVCodec h263_encoder = {
-//     "h263",
-//     CODEC_TYPE_VIDEO,
-//     CODEC_ID_H263,
-//     sizeof(MpegEncContext),
-//     MPV_encode_init,
-//     MPV_encode_picture,
-//     MPV_encode_end,
-//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-// };
-// 
-// AVCodec h263p_encoder = {
-//     "h263p",
-//     CODEC_TYPE_VIDEO,
-//     CODEC_ID_H263P,
-//     sizeof(MpegEncContext),
-//     MPV_encode_init,
-//     MPV_encode_picture,
-//     MPV_encode_end,
-//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-// };
-// 
-// AVCodec flv_encoder = {
-//     "flv",
-//     CODEC_TYPE_VIDEO,
-//     CODEC_ID_FLV1,
-//     sizeof(MpegEncContext),
-//     MPV_encode_init,
-//     MPV_encode_picture,
-//     MPV_encode_end,
-//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-// };
-// 
-// AVCodec rv10_encoder = {
-//     "rv10",
-//     CODEC_TYPE_VIDEO,
-//     CODEC_ID_RV10,
-//     sizeof(MpegEncContext),
-//     MPV_encode_init,
-//     MPV_encode_picture,
-//     MPV_encode_end,
-//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-// };
-// 
-// AVCodec rv20_encoder = {
-//     "rv20",
-//     CODEC_TYPE_VIDEO,
-//     CODEC_ID_RV20,
-//     sizeof(MpegEncContext),
-//     MPV_encode_init,
-//     MPV_encode_picture,
-//     MPV_encode_end,
-//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-// };
-// 
-// AVCodec mpeg4_encoder = {
-//     "mpeg4",
-//     CODEC_TYPE_VIDEO,
-//     CODEC_ID_MPEG4,
-//     sizeof(MpegEncContext),
-//     MPV_encode_init,
-//     MPV_encode_picture,
-//     MPV_encode_end,
-//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-//     .capabilities= CODEC_CAP_DELAY,
-// };
-// 
-// AVCodec msmpeg4v1_encoder = {
-//     "msmpeg4v1",
-//     CODEC_TYPE_VIDEO,
-//     CODEC_ID_MSMPEG4V1,
-//     sizeof(MpegEncContext),
-//     MPV_encode_init,
-//     MPV_encode_picture,
-//     MPV_encode_end,
-//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-// };
-// 
-// AVCodec msmpeg4v2_encoder = {
-//     "msmpeg4v2",
-//     CODEC_TYPE_VIDEO,
-//     CODEC_ID_MSMPEG4V2,
-//     sizeof(MpegEncContext),
-//     MPV_encode_init,
-//     MPV_encode_picture,
-//     MPV_encode_end,
-//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-// };
-// 
-// AVCodec msmpeg4v3_encoder = {
-//     "msmpeg4",
-//     CODEC_TYPE_VIDEO,
-//     CODEC_ID_MSMPEG4V3,
-//     sizeof(MpegEncContext),
-//     MPV_encode_init,
-//     MPV_encode_picture,
-//     MPV_encode_end,
-//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-// };
-// 
-// AVCodec wmv1_encoder = {
-//     "wmv1",
-//     CODEC_TYPE_VIDEO,
-//     CODEC_ID_WMV1,
-//     sizeof(MpegEncContext),
-//     MPV_encode_init,
-//     MPV_encode_picture,
-//     MPV_encode_end,
-//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
-// };
-// 
-// AVCodec mjpeg_encoder = {
-//     "mjpeg",
-//     CODEC_TYPE_VIDEO,
-//     CODEC_ID_MJPEG,
-//     sizeof(MpegEncContext),
-//     MPV_encode_init,
-//     MPV_encode_picture,
-//     MPV_encode_end,
-//     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUVJ420P, -1},
-// };
-
-#endif //CONFIG_ENCODERS
diff --git a/ffmpeg.src/libavcodec/mpegvideo.h b/ffmpeg.src/libavcodec/mpegvideo.h
deleted file mode 100644
index 9e02fdc..0000000
--- a/ffmpeg.src/libavcodec/mpegvideo.h
+++ /dev/null
@@ -1,985 +0,0 @@
-/*
- * Generic DCT based hybrid video encoder
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
- * Copyright (c) 2002-2004 Michael Niedermayer
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file mpegvideo.h
- * mpegvideo header.
- */
- 
-#ifndef AVCODEC_MPEGVIDEO_H
-#define AVCODEC_MPEGVIDEO_H
-
-#include "dsputil.h"
-#include "bitstream.h"
-
-#define FRAME_SKIPPED 100 ///< return value for header parsers if frame is not coded
-
-enum OutputFormat {
-    FMT_MPEG1,
-    FMT_H261,
-    FMT_H263,
-    FMT_MJPEG, 
-    FMT_H264,
-};
-
-#define EDGE_WIDTH 16
-
-#define MPEG_BUF_SIZE (16 * 1024)
-
-#define QMAT_SHIFT_MMX 16
-#define QMAT_SHIFT 22
-
-#define MAX_FCODE 7
-#define MAX_MV 2048
-
-#define MAX_THREADS 8
-
-#define MAX_PICTURE_COUNT 32
-
-#define ME_MAP_SIZE 64
-#define ME_MAP_SHIFT 3
-#define ME_MAP_MV_BITS 11
-
-/* run length table */
-#define MAX_RUN    64
-#define MAX_LEVEL  64
-
-#define I_TYPE FF_I_TYPE  ///< Intra
-#define P_TYPE FF_P_TYPE  ///< Predicted
-#define B_TYPE FF_B_TYPE  ///< Bi-dir predicted
-#define S_TYPE FF_S_TYPE  ///< S(GMC)-VOP MPEG4
-#define SI_TYPE FF_SI_TYPE  ///< Switching Intra
-#define SP_TYPE FF_SP_TYPE  ///< Switching Predicted
-
-#define MAX_MB_BYTES (30*16*16*3/8 + 120)
-
-typedef struct Predictor{
-    double coeff;
-    double count;
-    double decay;
-} Predictor;
-
-typedef struct RateControlEntry{
-    int pict_type;
-    float qscale;
-    int mv_bits;
-    int i_tex_bits;
-    int p_tex_bits;
-    int misc_bits;
-    uint64_t expected_bits;
-    int new_pict_type;
-    float new_qscale;
-    int mc_mb_var_sum;
-    int mb_var_sum;
-    int i_count;
-    int f_code;
-    int b_code;
-}RateControlEntry;
-
-/**
- * rate control context.
- */
-typedef struct RateControlContext{
-    FILE *stats_file;
-    int num_entries;              ///< number of RateControlEntries 
-    RateControlEntry *entry;
-    double buffer_index;          ///< amount of bits in the video/audio buffer 
-    Predictor pred[5];
-    double short_term_qsum;       ///< sum of recent qscales 
-    double short_term_qcount;     ///< count of recent qscales 
-    double pass1_rc_eq_output_sum;///< sum of the output of the rc equation, this is used for normalization  
-    double pass1_wanted_bits;     ///< bits which should have been outputed by the pass1 code (including complexity init) 
-    double last_qscale;
-    double last_qscale_for[5];    ///< last qscale for a specific pict type, used for max_diff & ipb factor stuff 
-    int last_mc_mb_var_sum;
-    int last_mb_var_sum;
-    uint64_t i_cplx_sum[5];
-    uint64_t p_cplx_sum[5];
-    uint64_t mv_bits_sum[5];
-    uint64_t qscale_sum[5];
-    int frame_count[5];
-    int last_non_b_pict_type;
-}RateControlContext;
-
-/**
- * Scantable.
- */
-typedef struct ScanTable{
-    const uint8_t *scantable;
-    uint8_t permutated[64];
-    uint8_t raster_end[64];
-#ifdef ARCH_POWERPC
-		/** Used by dct_quantise_alitvec to find last-non-zero */
-    uint8_t __align8 inverse[64];
-#endif
-} ScanTable;
-
-/**
- * Picture.
- */
-typedef struct Picture{
-    FF_COMMON_FRAME
-
-    /**
-     * halfpel luma planes.
-     */
-    uint8_t *interpolated[3];
-    int16_t (*motion_val_base[2])[2];
-    uint32_t *mb_type_base;
-#define MB_TYPE_INTRA MB_TYPE_INTRA4x4 //default mb_type if theres just one type
-#define IS_INTRA4x4(a)   ((a)&MB_TYPE_INTRA4x4)
-#define IS_INTRA16x16(a) ((a)&MB_TYPE_INTRA16x16)
-#define IS_PCM(a)        ((a)&MB_TYPE_INTRA_PCM)
-#define IS_INTRA(a)      ((a)&7)
-#define IS_INTER(a)      ((a)&(MB_TYPE_16x16|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8))
-#define IS_SKIP(a)       ((a)&MB_TYPE_SKIP)
-#define IS_INTRA_PCM(a)  ((a)&MB_TYPE_INTRA_PCM)
-#define IS_INTERLACED(a) ((a)&MB_TYPE_INTERLACED)
-#define IS_DIRECT(a)     ((a)&MB_TYPE_DIRECT2)
-#define IS_GMC(a)        ((a)&MB_TYPE_GMC)
-#define IS_16X16(a)      ((a)&MB_TYPE_16x16)
-#define IS_16X8(a)       ((a)&MB_TYPE_16x8)
-#define IS_8X16(a)       ((a)&MB_TYPE_8x16)
-#define IS_8X8(a)        ((a)&MB_TYPE_8x8)
-#define IS_SUB_8X8(a)    ((a)&MB_TYPE_16x16) //note reused
-#define IS_SUB_8X4(a)    ((a)&MB_TYPE_16x8)  //note reused
-#define IS_SUB_4X8(a)    ((a)&MB_TYPE_8x16)  //note reused
-#define IS_SUB_4X4(a)    ((a)&MB_TYPE_8x8)   //note reused
-#define IS_ACPRED(a)     ((a)&MB_TYPE_ACPRED)
-#define IS_QUANT(a)      ((a)&MB_TYPE_QUANT)
-#define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0<<((part)+2*(list))))
-#define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0|MB_TYPE_P1L0)<<(2*(list)))) ///< does this mb use listX, note doesnt work if subMBs
-#define HAS_CBP(a)        ((a)&MB_TYPE_CBP)
-
-    int field_poc[2];           ///< h264 top/bottom POC
-    int poc;                    ///< h264 frame POC
-    int frame_num;              ///< h264 frame_num
-    int pic_id;                 ///< h264 pic_num or long_term_pic_idx
-    int long_ref;               ///< 1->long term reference 0->short term reference
-    int ref_poc[2][16];         ///< h264 POCs of the frames used as reference
-    int ref_count[2];           ///< number of entries in ref_poc
-
-    int mb_var_sum;             ///< sum of MB variance for current frame 
-    int mc_mb_var_sum;          ///< motion compensated MB variance for current frame 
-    uint16_t *mb_var;           ///< Table for MB variances 
-    uint16_t *mc_mb_var;        ///< Table for motion compensated MB variances 
-    uint8_t *mb_mean;           ///< Table for MB luminance 
-    int32_t *mb_cmp_score;	///< Table for MB cmp scores, for mb decision FIXME remove
-    int b_frame_score;          /* */
-} Picture;
-
-typedef struct ParseContext{
-    uint8_t *buffer;
-    int index;
-    int last_index;
-    int buffer_size;
-    uint32_t state;             ///< contains the last few bytes in MSB order
-    int frame_start_found;
-    int overread;               ///< the number of bytes which where irreversibly read from the next frame
-    int overread_index;         ///< the index into ParseContext.buffer of the overreaded bytes
-} ParseContext;
-
-struct MpegEncContext;
-
-/**
- * Motion estimation context.
- */
-typedef struct MotionEstContext{
-    AVCodecContext *avctx;
-    int skip;                          ///< set if ME is skipped for the current MB 
-    int co_located_mv[4][2];           ///< mv from last p frame for direct mode ME 
-    int direct_basis_mv[4][2];
-    uint8_t *scratchpad;               ///< data area for the me algo, so that the ME doesnt need to malloc/free 
-    uint8_t *best_mb;
-    uint8_t *temp_mb[2];
-    uint8_t *temp;
-    int best_bits;
-    uint32_t *map;                     ///< map to avoid duplicate evaluations 
-    uint32_t *score_map;               ///< map to store the scores 
-    int map_generation;  
-    int pre_penalty_factor;
-    int penalty_factor;
-    int sub_penalty_factor;
-    int mb_penalty_factor;
-    int flags;
-    int sub_flags;
-    int mb_flags;
-    int pre_pass;                      ///< = 1 for the pre pass 
-    int dia_size;
-    int xmin;
-    int xmax;
-    int ymin;
-    int ymax;
-    int pred_x;
-    int pred_y;
-    uint8_t *src[4][4];
-    uint8_t *ref[4][4];
-    int stride;
-    int uvstride;
-    /* temp variables for picture complexity calculation */
-    int mc_mb_var_sum_temp;
-    int mb_var_sum_temp;
-    int scene_change_score;
-/*    cmp, chroma_cmp;*/
-    op_pixels_func (*hpel_put)[4];
-    op_pixels_func (*hpel_avg)[4];
-    qpel_mc_func (*qpel_put)[16];
-    qpel_mc_func (*qpel_avg)[16];
-    uint8_t (*mv_penalty)[MAX_MV*2+1];  ///< amount of bits 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,
-                                  int size, int h);
-}MotionEstContext;
-
-/**
- * MpegEncContext.
- */
-typedef struct MpegEncContext {
-    struct AVCodecContext *avctx;
-    /* the following parameters must be initialized before encoding */
-    int width, height;///< picture size. must be a multiple of 16 
-    int gop_size;
-    int intra_only;   ///< if true, only intra pictures are generated 
-    int bit_rate;     ///< wanted bit rate 
-    enum OutputFormat out_format; ///< output format 
-    int h263_pred;    ///< use mpeg4/h263 ac/dc predictions 
-
-/* the following codec id fields are deprecated in favor of codec_id */
-    int h263_plus;    ///< h263 plus headers 
-    int h263_msmpeg4; ///< generate MSMPEG4 compatible stream (deprecated, use msmpeg4_version instead)
-    int h263_flv;     ///< use flv h263 header 
-    
-    enum CodecID codec_id;     /* see CODEC_ID_xxx */
-    int fixed_qscale; ///< fixed qscale if non zero 
-    int encoding;     ///< true if we are encoding (vs decoding) 
-    int flags;        ///< AVCodecContext.flags (HQ, MV4, ...) 
-    int flags2;       ///< AVCodecContext.flags2
-    int max_b_frames; ///< max number of b-frames for encoding 
-    int luma_elim_threshold;
-    int chroma_elim_threshold;
-    int strict_std_compliance; ///< strictly follow the std (MPEG4, ...) 
-    int workaround_bugs;       ///< workaround bugs in encoders which cannot be detected automatically 
-    /* the following fields are managed internally by the encoder */
-
-    /** bit output */
-    PutBitContext pb;
-
-    /* sequence parameters */
-    int context_initialized;
-    int input_picture_number;  ///< used to set pic->display_picture_number, shouldnt be used for/by anything else
-    int coded_picture_number;  ///< used to set pic->coded_picture_number, shouldnt be used for/by anything else
-    int picture_number;       //FIXME remove, unclear definition
-    int picture_in_gop_number; ///< 0-> first pic in gop, ... 
-    int b_frames_since_non_b;  ///< used for encoding, relative to not yet reordered input 
-    int64_t user_specified_pts;///< last non zero pts from AVFrame which was passed into avcodec_encode_video()
-    int mb_width, mb_height;   ///< number of MBs horizontally & vertically 
-    int mb_stride;             ///< mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11
-    int b8_stride;             ///< 2*mb_width+1 used for some 8x8 block arrays to allow simple addressing
-    int b4_stride;             ///< 4*mb_width+1 used for some 4x4 block arrays to allow simple addressing
-    int h_edge_pos, v_edge_pos;///< horizontal / vertical position of the right/bottom edge (pixel replication)
-    int mb_num;                ///< number of MBs of a picture 
-    int linesize;              ///< line size, in bytes, may be different from width 
-    int uvlinesize;            ///< line size, for chroma in bytes, may be different from width 
-    Picture *picture;          ///< main picture buffer 
-    Picture **input_picture;   ///< next pictures on display order for encoding
-    Picture **reordered_input_picture; ///< pointer to the next pictures in codedorder for encoding
-    
-    int start_mb_y;            ///< start mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y)
-    int end_mb_y;              ///< end   mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y)
-    struct MpegEncContext *thread_context[MAX_THREADS];
-    
-    /** 
-     * copy of the previous picture structure.
-     * note, linesize & data, might not match the previous picture (for field pictures)
-     */
-    Picture last_picture;       
-    
-    /** 
-     * copy of the next picture structure.
-     * note, linesize & data, might not match the next picture (for field pictures)
-     */
-    Picture next_picture;
-    
-    /** 
-     * copy of the source picture structure for encoding.
-     * note, linesize & data, might not match the source picture (for field pictures)
-     */
-    Picture new_picture;
-    
-    /** 
-     * copy of the current picture structure.
-     * note, linesize & data, might not match the current picture (for field pictures)
-     */
-    Picture current_picture;    ///< buffer to store the decompressed current picture 
-    
-    Picture *last_picture_ptr;     ///< pointer to the previous picture.
-    Picture *next_picture_ptr;     ///< pointer to the next picture (for bidir pred) 
-    Picture *current_picture_ptr;  ///< pointer to the current picture
-    uint8_t *visualization_buffer[3]; //< temporary buffer vor MV visualization
-    int last_dc[3];                ///< last DC values for MPEG1 
-    int16_t *dc_val_base;
-    int16_t *dc_val[3];            ///< used for mpeg4 DC prediction, all 3 arrays must be continuous 
-    int16_t dc_cache[4*5];
-    int y_dc_scale, c_dc_scale;
-    const uint8_t *y_dc_scale_table;     ///< qscale -> y_dc_scale table 
-    const uint8_t *c_dc_scale_table;     ///< qscale -> c_dc_scale table 
-    const uint8_t *chroma_qscale_table;  ///< qscale -> chroma_qscale (h263)
-    uint8_t *coded_block_base;
-    uint8_t *coded_block;          ///< used for coded block pattern prediction (msmpeg4v3, wmv1)
-    int16_t (*ac_val_base)[16];
-    int16_t (*ac_val[3])[16];      ///< used for for mpeg4 AC prediction, all 3 arrays must be continuous 
-    int ac_pred;
-    uint8_t *prev_pict_types;     ///< previous picture types in bitstream order, used for mb skip 
-#define PREV_PICT_TYPES_BUFFER_SIZE 256
-    int mb_skipped;                ///< MUST BE SET only during DECODING 
-    uint8_t *mbskip_table;        /**< used to avoid copy if macroblock skipped (for black regions for example) 
-                                   and used for b-frame encoding & decoding (contains skip table of next P Frame) */
-    uint8_t *mbintra_table;       ///< used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding 
-    uint8_t *cbp_table;           ///< used to store cbp, ac_pred for partitioned decoding 
-    uint8_t *pred_dir_table;      ///< used to store pred_dir for partitioned decoding 
-    uint8_t *allocated_edge_emu_buffer;
-    uint8_t *edge_emu_buffer;     ///< points into the middle of allocated_edge_emu_buffer
-    uint8_t *rd_scratchpad;       ///< scratchpad for rate distortion mb decision
-    uint8_t *obmc_scratchpad;
-    uint8_t *b_scratchpad;        ///< scratchpad used for writing into write only buffers
-
-    int qscale;                 ///< QP 
-    int chroma_qscale;          ///< chroma QP 
-    int lambda;                 ///< lagrange multipler used in rate distortion
-    int lambda2;                ///< (lambda*lambda) >> FF_LAMBDA_SHIFT 
-    int *lambda_table;
-    int adaptive_quant;         ///< use adaptive quantization 
-    int dquant;                 ///< qscale difference to prev qscale  
-    int pict_type;              ///< I_TYPE, P_TYPE, B_TYPE, ... 
-    int last_pict_type; //FIXME removes
-    int last_non_b_pict_type;   ///< used for mpeg4 gmc b-frames & ratecontrol 
-    int dropable;
-    int frame_rate_index;
-
-    /* motion compensation */
-    int unrestricted_mv;        ///< mv can point outside of the coded picture 
-    int h263_long_vectors;      ///< use horrible h263v1 long vector mode 
-    int decode;                 ///< if 0 then decoding will be skipped (for encoding b frames for example)
-
-    DSPContext dsp;             ///< pointers for accelerated dsp functions
-    int f_code;                 ///< forward MV resolution 
-    int b_code;                 ///< backward MV resolution for B Frames (mpeg4) 
-    int16_t (*p_mv_table_base)[2];
-    int16_t (*b_forw_mv_table_base)[2];
-    int16_t (*b_back_mv_table_base)[2];
-    int16_t (*b_bidir_forw_mv_table_base)[2]; 
-    int16_t (*b_bidir_back_mv_table_base)[2]; 
-    int16_t (*b_direct_mv_table_base)[2];
-    int16_t (*p_field_mv_table_base[2][2])[2];
-    int16_t (*b_field_mv_table_base[2][2][2])[2];
-    int16_t (*p_mv_table)[2];            ///< MV table (1MV per MB) p-frame encoding 
-    int16_t (*b_forw_mv_table)[2];       ///< MV table (1MV per MB) forward mode b-frame encoding 
-    int16_t (*b_back_mv_table)[2];       ///< MV table (1MV per MB) backward mode b-frame encoding 
-    int16_t (*b_bidir_forw_mv_table)[2]; ///< MV table (1MV per MB) bidir mode b-frame encoding 
-    int16_t (*b_bidir_back_mv_table)[2]; ///< MV table (1MV per MB) bidir mode b-frame encoding 
-    int16_t (*b_direct_mv_table)[2];     ///< MV table (1MV per MB) direct mode b-frame encoding 
-    int16_t (*p_field_mv_table[2][2])[2];   ///< MV table (2MV per MB) interlaced p-frame encoding
-    int16_t (*b_field_mv_table[2][2][2])[2];///< MV table (4MV per MB) interlaced b-frame encoding
-    uint8_t (*p_field_select_table[2]);
-    uint8_t (*b_field_select_table[2][2]);
-    int me_method;                       ///< ME algorithm 
-    int mv_dir;
-#define MV_DIR_BACKWARD  1
-#define MV_DIR_FORWARD   2
-#define MV_DIRECT        4 ///< bidirectional mode where the difference equals the MV of the last P/S/I-Frame (mpeg4)
-    int mv_type;
-#define MV_TYPE_16X16       0   ///< 1 vector for the whole mb 
-#define MV_TYPE_8X8         1   ///< 4 vectors (h263, mpeg4 4MV) 
-#define MV_TYPE_16X8        2   ///< 2 vectors, one per 16x8 block  
-#define MV_TYPE_FIELD       3   ///< 2 vectors, one per field  
-#define MV_TYPE_DMV         4   ///< 2 vectors, special mpeg2 Dual Prime Vectors 
-    /**motion vectors for a macroblock 
-       first coordinate : 0 = forward 1 = backward
-       second "         : depend on type
-       third  "         : 0 = x, 1 = y
-    */
-    int mv[2][4][2];
-    int field_select[2][2];
-    int last_mv[2][2][2];             ///< last MV, used for MV prediction in MPEG1 & B-frame MPEG4 
-    uint8_t *fcode_tab;               ///< smallest fcode needed for each MV 
-    
-    MotionEstContext me;
-
-    int no_rounding;  /**< apply no rounding to motion compensation (MPEG4, msmpeg4, ...) 
-                        for b-frames rounding mode is allways 0 */
-
-    int hurry_up;     /**< when set to 1 during decoding, b frames will be skipped
-                         when set to 2 idct/dequant will be skipped too */
-                        
-    /* macroblock layer */
-    int mb_x, mb_y;
-    int mb_skip_run;
-    int mb_intra;
-    uint16_t *mb_type;           ///< Table for candidate MB types for encoding
-#define CANDIDATE_MB_TYPE_INTRA    0x01
-#define CANDIDATE_MB_TYPE_INTER    0x02
-#define CANDIDATE_MB_TYPE_INTER4V  0x04
-#define CANDIDATE_MB_TYPE_SKIPPED   0x08
-//#define MB_TYPE_GMC      0x10
-
-#define CANDIDATE_MB_TYPE_DIRECT   0x10
-#define CANDIDATE_MB_TYPE_FORWARD  0x20
-#define CANDIDATE_MB_TYPE_BACKWARD 0x40
-#define CANDIDATE_MB_TYPE_BIDIR    0x80
-
-#define CANDIDATE_MB_TYPE_INTER_I    0x100
-#define CANDIDATE_MB_TYPE_FORWARD_I  0x200
-#define CANDIDATE_MB_TYPE_BACKWARD_I 0x400
-#define CANDIDATE_MB_TYPE_BIDIR_I    0x800
-
-    int block_index[6]; ///< index to current MB in block based arrays with edges
-    int block_wrap[6];
-    uint8_t *dest[3];
-    
-    int *mb_index2xy;        ///< mb_index -> mb_x + mb_y*mb_stride
-
-    /** matrix transmitted in the bitstream */
-    uint16_t intra_matrix[64];
-    uint16_t chroma_intra_matrix[64];
-    uint16_t inter_matrix[64];
-    uint16_t chroma_inter_matrix[64];
-#define QUANT_BIAS_SHIFT 8
-    int intra_quant_bias;    ///< bias for the quantizer 
-    int inter_quant_bias;    ///< bias for the quantizer 
-    int min_qcoeff;          ///< minimum encodable coefficient 
-    int max_qcoeff;          ///< maximum encodable coefficient 
-    int ac_esc_length;       ///< num of bits needed to encode the longest esc 
-    uint8_t *intra_ac_vlc_length;
-    uint8_t *intra_ac_vlc_last_length;
-    uint8_t *inter_ac_vlc_length;
-    uint8_t *inter_ac_vlc_last_length;
-    uint8_t *luma_dc_vlc_length;
-    uint8_t *chroma_dc_vlc_length;
-#define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level))
-
-    int coded_score[6];
-
-    /** precomputed matrix (combine qscale and DCT renorm) */
-    int (*q_intra_matrix)[64];
-    int (*q_inter_matrix)[64];
-    /** identical to the above but for MMX & these are not permutated, second 64 entries are bias*/
-    uint16_t (*q_intra_matrix16)[2][64];
-    uint16_t (*q_inter_matrix16)[2][64];
-    int block_last_index[12];  ///< last non zero coefficient in block
-    /* scantables */
-    ScanTable __align8 intra_scantable;
-    ScanTable intra_h_scantable;
-    ScanTable intra_v_scantable;
-    ScanTable inter_scantable; ///< if inter == intra then intra should be used to reduce tha cache usage
-    
-    /* noise reduction */
-    int (*dct_error_sum)[64];
-    int dct_count[2];
-    uint16_t (*dct_offset)[64];
-
-    void *opaque;              ///< private data for the user
-
-    /* bit rate control */
-    int64_t wanted_bits;
-    int64_t total_bits;
-    int frame_bits;                ///< bits used for the current frame 
-    RateControlContext rc_context; ///< contains stuff only accessed in ratecontrol.c
-
-    /* statistics, used for 2-pass encoding */
-    int mv_bits;
-    int header_bits;
-    int i_tex_bits;
-    int p_tex_bits;
-    int i_count;
-    int f_count;
-    int b_count;
-    int skip_count;
-    int misc_bits; ///< cbp, mb_type
-    int last_bits; ///< temp var used for calculating the above vars
-    
-    /* error concealment / resync */
-    int error_count;
-    uint8_t *error_status_table;       ///< table of the error status of each MB  
-#define VP_START            1          ///< current MB is the first after a resync marker 
-#define AC_ERROR            2
-#define DC_ERROR            4
-#define MV_ERROR            8
-#define AC_END              16
-#define DC_END              32
-#define MV_END              64
-//FIXME some prefix?
-    
-    int resync_mb_x;                 ///< x position of last resync marker 
-    int resync_mb_y;                 ///< y position of last resync marker 
-    GetBitContext last_resync_gb;    ///< used to search for the next resync marker 
-    int mb_num_left;                 ///< number of MBs left in this video packet (for partitioned Slices only)
-    int next_p_frame_damaged;        ///< set if the next p frame is damaged, to avoid showing trashed b frames 
-    int error_resilience;
-    
-    ParseContext parse_context;
-
-    /* H.263 specific */
-    int gob_index;
-    int obmc;                       ///< overlapped block motion compensation
-        
-    /* H.263+ specific */
-    int umvplus;                    ///< == H263+ && unrestricted_mv 
-    int h263_aic;                   ///< Advanded INTRA Coding (AIC) 
-    int h263_aic_dir;               ///< AIC direction: 0 = left, 1 = top
-    int h263_slice_structured;
-    int alt_inter_vlc;              ///< alternative inter vlc
-    int modified_quant;
-    int loop_filter;    
-    int custom_pcf;
-    
-    /* mpeg4 specific */
-    int time_increment_bits;        ///< number of bits to represent the fractional part of time 
-    int last_time_base;
-    int time_base;                  ///< time in seconds of last I,P,S Frame 
-    int64_t time;                   ///< time of current frame  
-    int64_t last_non_b_time;
-    uint16_t pp_time;               ///< time distance between the last 2 p,s,i frames 
-    uint16_t pb_time;               ///< time distance between the last b and p,s,i frame 
-    uint16_t pp_field_time;
-    uint16_t pb_field_time;         ///< like above, just for interlaced 
-    int shape;
-    int vol_sprite_usage;
-    int sprite_width;
-    int sprite_height;
-    int sprite_left;
-    int sprite_top;
-    int sprite_brightness_change;
-    int num_sprite_warping_points;
-    int real_sprite_warping_points;
-    int sprite_offset[2][2];         ///< sprite offset[isChroma][isMVY] 
-    int sprite_delta[2][2];          ///< sprite_delta [isY][isMVY]  
-    int sprite_shift[2];             ///< sprite shift [isChroma] 
-    int mcsel;
-    int quant_precision;
-    int quarter_sample;              ///< 1->qpel, 0->half pel ME/MC  
-    int scalability;
-    int hierachy_type;
-    int enhancement_type;
-    int new_pred;
-    int reduced_res_vop;
-    int aspect_ratio_info; //FIXME remove
-    int sprite_warping_accuracy;
-    int low_latency_sprite;
-    int data_partitioning;           ///< data partitioning flag from header 
-    int partitioned_frame;           ///< is current frame partitioned 
-    int rvlc;                        ///< reversible vlc 
-    int resync_marker;               ///< could this stream contain resync markers
-    int low_delay;                   ///< no reordering needed / has no b-frames 
-    int vo_type;
-    int vol_control_parameters;      ///< does the stream contain the low_delay flag, used to workaround buggy encoders 
-    int intra_dc_threshold;          ///< QP above whch the ac VLC should be used for intra dc 
-    PutBitContext tex_pb;            ///< used for data partitioned VOPs 
-    PutBitContext pb2;               ///< used for data partitioned VOPs 
-    int mpeg_quant;
-    int t_frame;                       ///< time distance of first I -> B, used for interlaced b frames 
-    int padding_bug_score;             ///< used to detect the VERY common padding bug in MPEG4 
-
-    /* divx specific, used to workaround (many) bugs in divx5 */
-    int divx_version;
-    int divx_build;
-    int divx_packed;
-    uint8_t *bitstream_buffer; //Divx 5.01 puts several frames in a single one, this is used to reorder them
-    int bitstream_buffer_size;
-    int allocated_bitstream_buffer_size;
-    
-    int xvid_build;
-    
-    /* lavc specific stuff, used to workaround bugs in libavcodec */
-    int lavc_build;
-    
-    /* RV10 specific */
-    int rv10_version; ///< RV10 version: 0 or 3 
-    int rv10_first_dc_coded[3];
-    
-    /* MJPEG specific */
-    struct MJpegContext *mjpeg_ctx;
-    int mjpeg_vsample[3];       ///< vertical sampling factors, default = {2, 1, 1} 
-    int mjpeg_hsample[3];       ///< horizontal sampling factors, default = {2, 1, 1} 
-    int mjpeg_write_tables;     ///< do we want to have quantisation- and huffmantables in the jpeg file ? 
-    int mjpeg_data_only_frames; ///< frames only with SOI, SOS and EOI markers 
-
-    /* MSMPEG4 specific */
-    int mv_table_index;
-    int rl_table_index;
-    int rl_chroma_table_index;
-    int dc_table_index;
-    int use_skip_mb_code;
-    int slice_height;      ///< in macroblocks 
-    int first_slice_line;  ///< used in mpeg4 too to handle resync markers 
-    int flipflop_rounding;
-    int msmpeg4_version;   ///< 0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8
-    int per_mb_rl_table;
-    int esc3_level_length;
-    int esc3_run_length;
-    /** [mb_intra][isChroma][level][run][last] */
-    int (*ac_stats)[2][MAX_LEVEL+1][MAX_RUN+1][2];
-    int inter_intra_pred;
-    int mspel;
-
-    /* decompression specific */
-    GetBitContext gb;
-
-    /* Mpeg1 specific */
-    int gop_picture_number;  ///< index of the first picture of a GOP based on fake_pic_num & mpeg1 specific 
-    int last_mv_dir;         ///< last mv_dir, used for b frame encoding 
-    int broken_link;         ///< no_output_of_prior_pics_flag
-    uint8_t *vbv_delay_ptr;  ///< pointer to vbv_delay in the bitstream 
-    
-    /* MPEG2 specific - I wish I had not to support this mess. */
-    int progressive_sequence;
-    int mpeg_f_code[2][2];
-    int picture_structure;
-/* picture type */
-#define PICT_TOP_FIELD     1
-#define PICT_BOTTOM_FIELD  2
-#define PICT_FRAME         3
-
-    int intra_dc_precision;
-    int frame_pred_frame_dct;
-    int top_field_first;
-    int concealment_motion_vectors;
-    int q_scale_type;
-    int intra_vlc_format;
-    int alternate_scan;
-    int repeat_first_field;
-    int chroma_420_type;
-    int chroma_format;
-#define CHROMA_420 1
-#define CHROMA_422 2
-#define CHROMA_444 3
-    int chroma_x_shift;//depend on pix_format, that depend on chroma_format
-    int chroma_y_shift;
-
-    int progressive_frame;
-    int full_pel[2];
-    int interlaced_dct;
-    int first_slice;
-    int first_field;         ///< is 1 for the first field of a field picture 0 otherwise
-
-    /* RTP specific */
-    int rtp_mode;
-    
-    uint8_t *ptr_lastgob;
-    int swap_uv;//vcr2 codec is mpeg2 varint with UV swaped
-    short * pblocks[12];
-    
-    DCTELEM (*block)[64]; ///< points to one of the following blocks 
-    DCTELEM (*blocks)[6][64]; // for HQ mode we need to keep the best block
-    int (*decode_mb)(struct MpegEncContext *s, DCTELEM block[6][64]); // used by some codecs to avoid a switch()
-#define SLICE_OK         0
-#define SLICE_ERROR     -1
-#define SLICE_END       -2 ///<end marker found
-#define SLICE_NOEND     -3 ///<no end marker or error found but mb count exceeded
-    
-    void (*dct_unquantize_mpeg1_intra)(struct MpegEncContext *s, 
-                           DCTELEM *block/*align 16*/, int n, int qscale);
-    void (*dct_unquantize_mpeg1_inter)(struct MpegEncContext *s, 
-                           DCTELEM *block/*align 16*/, int n, int qscale);
-    void (*dct_unquantize_mpeg2_intra)(struct MpegEncContext *s, 
-                           DCTELEM *block/*align 16*/, int n, int qscale);
-    void (*dct_unquantize_mpeg2_inter)(struct MpegEncContext *s, 
-                           DCTELEM *block/*align 16*/, int n, int qscale);
-    void (*dct_unquantize_h263_intra)(struct MpegEncContext *s, 
-                           DCTELEM *block/*align 16*/, int n, int qscale);
-    void (*dct_unquantize_h263_inter)(struct MpegEncContext *s, 
-                           DCTELEM *block/*align 16*/, int n, int qscale);
-    void (*dct_unquantize_h261_intra)(struct MpegEncContext *s, 
-                           DCTELEM *block/*align 16*/, int n, int qscale);
-    void (*dct_unquantize_h261_inter)(struct MpegEncContext *s, 
-                           DCTELEM *block/*align 16*/, int n, int qscale);
-    void (*dct_unquantize_intra)(struct MpegEncContext *s, // unquantizer to use (mpeg4 can use both)
-                           DCTELEM *block/*align 16*/, int n, int qscale);
-    void (*dct_unquantize_inter)(struct MpegEncContext *s, // unquantizer to use (mpeg4 can use both)
-                           DCTELEM *block/*align 16*/, int n, int qscale);
-    int (*dct_quantize)(struct MpegEncContext *s, DCTELEM *block/*align 16*/, int n, int qscale, int *overflow);
-    int (*fast_dct_quantize)(struct MpegEncContext *s, DCTELEM *block/*align 16*/, int n, int qscale, int *overflow);
-    void (*denoise_dct)(struct MpegEncContext *s, DCTELEM *block);
-} MpegEncContext;
-
-
-int DCT_common_init(MpegEncContext *s);
-void MPV_decode_defaults(MpegEncContext *s);
-int MPV_common_init(MpegEncContext *s);
-void MPV_common_end(MpegEncContext *s);
-void MPV_decode_mb(MpegEncContext *s, DCTELEM block[12][64]);
-int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx);
-void MPV_frame_end(MpegEncContext *s);
-int MPV_encode_init(AVCodecContext *avctx);
-int MPV_encode_end(AVCodecContext *avctx);
-int MPV_encode_picture(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data);
-#ifdef HAVE_MMX
-void MPV_common_init_mmx(MpegEncContext *s);
-#endif
-#ifdef ARCH_ALPHA
-void MPV_common_init_axp(MpegEncContext *s);
-#endif
-#ifdef HAVE_MLIB
-void MPV_common_init_mlib(MpegEncContext *s);
-#endif
-#ifdef HAVE_MMI
-void MPV_common_init_mmi(MpegEncContext *s);
-#endif
-#ifdef ARCH_ARMV4L
-void MPV_common_init_armv4l(MpegEncContext *s);
-#endif
-#ifdef ARCH_POWERPC
-void MPV_common_init_ppc(MpegEncContext *s);
-#endif
-extern void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w);
-void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length);
-void ff_clean_intra_table_entries(MpegEncContext *s);
-void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable);
-void ff_draw_horiz_band(MpegEncContext *s, int y, int h);
-void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize, int block_w, int block_h, 
-                                    int src_x, int src_y, int w, int h);
-#define END_NOT_FOUND -100
-int ff_combine_frame(ParseContext *pc, int next, uint8_t **buf, int *buf_size);
-void ff_parse_close(AVCodecParserContext *s);
-void ff_mpeg_flush(AVCodecContext *avctx);
-void ff_print_debug_info(MpegEncContext *s, AVFrame *pict);
-void ff_write_quant_matrix(PutBitContext *pb, int16_t *matrix);
-int ff_find_unused_picture(MpegEncContext *s, int shared);
-void ff_denoise_dct(MpegEncContext *s, DCTELEM *block);
-void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src);
-
-void ff_er_frame_start(MpegEncContext *s);
-void ff_er_frame_end(MpegEncContext *s);
-void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int endy, int status);
-
-
-extern enum PixelFormat ff_yuv420p_list[2];
-
-void ff_init_block_index(MpegEncContext *s);
-
-static inline void ff_update_block_index(MpegEncContext *s){
-    const int block_size= 8>>s->avctx->lowres;
-
-    s->block_index[0]+=2;
-    s->block_index[1]+=2;
-    s->block_index[2]+=2;
-    s->block_index[3]+=2;
-    s->block_index[4]++;
-    s->block_index[5]++;
-    s->dest[0]+= 2*block_size;
-    s->dest[1]+= block_size;
-    s->dest[2]+= block_size;
-}
-
-static inline int get_bits_diff(MpegEncContext *s){
-    const int bits= put_bits_count(&s->pb);
-    const int last= s->last_bits;
-
-    s->last_bits = bits;
-
-    return bits - last;
-}
-
-/* motion_est.c */
-void ff_estimate_p_frame_motion(MpegEncContext * s,
-                             int mb_x, int mb_y);
-void ff_estimate_b_frame_motion(MpegEncContext * s,
-                             int mb_x, int mb_y);
-int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type);
-void ff_fix_long_p_mvs(MpegEncContext * s);
-void ff_fix_long_mvs(MpegEncContext * s, uint8_t *field_select_table, int field_select,
-                     int16_t (*mv_table)[2], int f_code, int type, int truncate);
-void ff_init_me(MpegEncContext *s);
-int ff_pre_estimate_p_frame_motion(MpegEncContext * s, int mb_x, int mb_y);
-inline int ff_epzs_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr,
-                             int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2], 
-                             int ref_mv_scale, int size, int h);                             
-int inline ff_get_mb_score(MpegEncContext * s, int mx, int my, int src_index,
-                               int ref_index, int size, int h, int add_rate);
-
-/* mpeg12.c */
-extern const int16_t ff_mpeg1_default_intra_matrix[64];
-extern const int16_t ff_mpeg1_default_non_intra_matrix[64];
-extern const uint8_t ff_mpeg1_dc_scale_table[128];
-
-void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number);
-void mpeg1_encode_mb(MpegEncContext *s,
-                     DCTELEM block[6][64],
-                     int motion_x, int motion_y);
-void ff_mpeg1_encode_init(MpegEncContext *s);
-void ff_mpeg1_encode_slice_header(MpegEncContext *s);
-void ff_mpeg1_clean_buffers(MpegEncContext *s);
-int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size);
-
-
-/** RLTable. */
-typedef struct RLTable {
-    int n;                         ///< number of entries of table_vlc minus 1 
-    int last;                      ///< number of values for last = 0 
-    const uint16_t (*table_vlc)[2];
-    const int8_t *table_run;
-    const int8_t *table_level;
-    uint8_t *index_run[2];         ///< encoding only 
-    int8_t *max_level[2];          ///< encoding & decoding 
-    int8_t *max_run[2];            ///< encoding & decoding 
-    VLC vlc;                       ///< decoding only deprected FIXME remove
-    RL_VLC_ELEM *rl_vlc[32];       ///< decoding only 
-} RLTable;
-
-void init_rl(RLTable *rl, int use_static);
-void init_vlc_rl(RLTable *rl, int use_static);
-
-static inline int get_rl_index(const RLTable *rl, int last, int run, int level)
-{
-    int index;
-    index = rl->index_run[last][run];
-    if (index >= rl->n)
-        return rl->n;
-    if (level > rl->max_level[last][run])
-        return rl->n;
-    return index + level - 1;
-}
-
-extern const uint8_t ff_mpeg4_y_dc_scale_table[32];
-extern const uint8_t ff_mpeg4_c_dc_scale_table[32];
-extern const uint8_t ff_aic_dc_scale_table[32];
-extern const int16_t ff_mpeg4_default_intra_matrix[64];
-extern const int16_t ff_mpeg4_default_non_intra_matrix[64];
-extern const uint8_t ff_h263_chroma_qscale_table[32];
-extern const uint8_t ff_h263_loop_filter_strength[32];
-
-/* h261.c */
-void ff_h261_loop_filter(MpegEncContext *s);
-void ff_h261_reorder_mb_index(MpegEncContext* s);
-void ff_h261_encode_mb(MpegEncContext *s,
-                    DCTELEM block[6][64],
-                    int motion_x, int motion_y);
-void ff_h261_encode_picture_header(MpegEncContext * s, int picture_number);
-void ff_h261_encode_init(MpegEncContext *s);
-
-
-/* h263.c, h263dec.c */
-int ff_h263_decode_init(AVCodecContext *avctx);
-int ff_h263_decode_frame(AVCodecContext *avctx, 
-                             void *data, int *data_size,
-                             uint8_t *buf, int buf_size);
-int ff_h263_decode_end(AVCodecContext *avctx);
-void h263_encode_mb(MpegEncContext *s, 
-                    DCTELEM block[6][64],
-                    int motion_x, int motion_y);
-void mpeg4_encode_mb(MpegEncContext *s, 
-                    DCTELEM block[6][64],
-                    int motion_x, int motion_y);
-void h263_encode_picture_header(MpegEncContext *s, int picture_number);
-void ff_flv_encode_picture_header(MpegEncContext *s, int picture_number);
-void h263_encode_gob_header(MpegEncContext * s, int mb_line);
-int16_t *h263_pred_motion(MpegEncContext * s, int block, int dir,
-                        int *px, int *py);
-void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n, 
-                   int dir);
-void ff_set_mpeg4_time(MpegEncContext * s, int picture_number);
-void mpeg4_encode_picture_header(MpegEncContext *s, int picture_number);
-void h263_encode_init(MpegEncContext *s);
-void h263_decode_init_vlc(MpegEncContext *s);
-int h263_decode_picture_header(MpegEncContext *s);
-int ff_h263_decode_gob_header(MpegEncContext *s);
-int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb);
-void ff_h263_update_motion_val(MpegEncContext * s);
-void ff_h263_loop_filter(MpegEncContext * s);
-void ff_set_qscale(MpegEncContext * s, int qscale);
-int ff_h263_decode_mba(MpegEncContext *s);
-void ff_h263_encode_mba(MpegEncContext *s);
-
-int intel_h263_decode_picture_header(MpegEncContext *s);
-int flv_h263_decode_picture_header(MpegEncContext *s);
-int ff_h263_decode_mb(MpegEncContext *s,
-                      DCTELEM block[6][64]);
-int ff_mpeg4_decode_mb(MpegEncContext *s,
-                      DCTELEM block[6][64]);
-int h263_get_picture_format(int width, int height);
-void ff_mpeg4_encode_video_packet_header(MpegEncContext *s);
-void ff_mpeg4_clean_buffers(MpegEncContext *s);
-void ff_mpeg4_stuffing(PutBitContext * pbc);
-void ff_mpeg4_init_partitions(MpegEncContext *s);
-void ff_mpeg4_merge_partitions(MpegEncContext *s);
-void ff_clean_mpeg4_qscales(MpegEncContext *s);
-void ff_clean_h263_qscales(MpegEncContext *s);
-int ff_mpeg4_decode_partitions(MpegEncContext *s);
-int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s);
-int ff_h263_resync(MpegEncContext *s);
-int ff_h263_get_gob_height(MpegEncContext *s);
-int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my);
-int ff_h263_round_chroma(int x);
-void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code);
-int ff_mpeg4_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size);
-
-
-/* rv10.c */
-void rv10_encode_picture_header(MpegEncContext *s, int picture_number);
-int rv_decode_dc(MpegEncContext *s, int n);
-void rv20_encode_picture_header(MpegEncContext *s, int picture_number);
-
-
-/* msmpeg4.c */
-void msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number);
-void msmpeg4_encode_ext_header(MpegEncContext * s);
-void msmpeg4_encode_mb(MpegEncContext * s, 
-                       DCTELEM block[6][64],
-                       int motion_x, int motion_y);
-int msmpeg4_decode_picture_header(MpegEncContext * s);
-int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size);
-int ff_msmpeg4_decode_init(MpegEncContext *s);
-void ff_msmpeg4_encode_init(MpegEncContext *s);
-int ff_wmv2_decode_picture_header(MpegEncContext * s);
-int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s);
-void ff_wmv2_add_mb(MpegEncContext *s, DCTELEM block[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr);
-void ff_mspel_motion(MpegEncContext *s,
-                               uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
-                               uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
-                               int motion_x, int motion_y, int h);
-int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number);
-void ff_wmv2_encode_mb(MpegEncContext * s, 
-                       DCTELEM block[6][64],
-                       int motion_x, int motion_y);
-
-/* mjpeg.c */
-int mjpeg_init(MpegEncContext *s);
-void mjpeg_close(MpegEncContext *s);
-void mjpeg_encode_mb(MpegEncContext *s, 
-                     DCTELEM block[6][64]);
-void mjpeg_picture_header(MpegEncContext *s);
-void mjpeg_picture_trailer(MpegEncContext *s);
-void ff_mjpeg_stuffing(PutBitContext * pbc);
-
-
-/* rate control */
-int ff_rate_control_init(MpegEncContext *s);
-float ff_rate_estimate_qscale(MpegEncContext *s);
-void ff_write_pass1_stats(MpegEncContext *s);
-void ff_rate_control_uninit(MpegEncContext *s);
-double ff_eval(char *s, double *const_value, const char **const_name,
-               double (**func1)(void *, double), const char **func1_name,
-               double (**func2)(void *, double, double), char **func2_name,
-               void *opaque);
-int ff_vbv_update(MpegEncContext *s, int frame_size);
-
-
-#endif /* AVCODEC_MPEGVIDEO_H */
diff --git a/ffmpeg.src/libavcodec/msmpeg4.c b/ffmpeg.src/libavcodec/msmpeg4.c
deleted file mode 100644
index 81f1479..0000000
--- a/ffmpeg.src/libavcodec/msmpeg4.c
+++ /dev/null
@@ -1,2012 +0,0 @@
-/*
- * MSMPEG4 backend for ffmpeg encoder and decoder
- * Copyright (c) 2001 Fabrice Bellard.
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * msmpeg4v1 & v2 stuff by Michael Niedermayer <michaelni at gmx.at>
- */
-
-/**
- * @file msmpeg4.c
- * MSMPEG4 backend for ffmpeg encoder and decoder.
- */
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-
-/*
- * You can also call this codec : MPEG4 with a twist ! 
- *
- * TODO: 
- *        - (encoding) select best mv table (two choices)
- *        - (encoding) select best vlc/dc table 
- */
-//#define DEBUG
-
-#define DC_VLC_BITS 9
-#define CBPY_VLC_BITS 6
-#define INTER_INTRA_VLC_BITS 3
-#define V1_INTRA_CBPC_VLC_BITS 6
-#define V1_INTER_CBPC_VLC_BITS 6
-#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 MB_NON_INTRA_VLC_BITS 9
-#define MB_INTRA_VLC_BITS 9
-
-#define II_BITRATE 128*1024
-#define MBAC_BITRATE 50*1024
-
-#define DEFAULT_INTER_INDEX 3
-
-static uint32_t v2_dc_lum_table[512][2];
-static uint32_t v2_dc_chroma_table[512][2];
-
-static inline void msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n);
-static inline int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
-                                       int n, int coded, const uint8_t *scantable);
-static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr);
-static int msmpeg4_decode_motion(MpegEncContext * s, 
-                                 int *mx_ptr, int *my_ptr);
-static void msmpeg4v2_encode_motion(MpegEncContext * s, int val);
-static void init_h263_dc_for_msmpeg4(void);
-static inline void msmpeg4_memsetw(short *tab, int val, int n);
-#ifdef CONFIG_ENCODERS
-static int get_size_of_code(MpegEncContext * s, RLTable *rl, int last, int run, int level, int intra);
-#endif //CONFIG_ENCODERS
-static int msmpeg4v12_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
-static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
-static int wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
-
-/* vc9 externs */
-extern uint8_t wmv3_dc_scale_table[32];
-
-#ifdef DEBUG
-int intra_count = 0;
-int frame_count = 0;
-#endif
-
-#include "msmpeg4data.h"
-
-#ifdef CONFIG_ENCODERS //strangely gcc includes this even if its not references
-static uint8_t rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2];
-#endif //CONFIG_ENCODERS
-
-#ifdef STATS
-
-const char *st_names[ST_NB] = {
-    "unknown",
-    "dc",
-    "intra_ac",
-    "inter_ac",
-    "intra_mb",
-    "inter_mb",
-    "mv",
-};
-
-int st_current_index = 0;
-unsigned int st_bit_counts[ST_NB];
-unsigned int st_out_bit_counts[ST_NB];
-
-#define set_stat(var) st_current_index = var;
-
-void print_stats(void)
-{
-    unsigned int total;
-    int i;
-
-    printf("Input:\n");
-    total = 0;
-    for(i=0;i<ST_NB;i++)
-        total += st_bit_counts[i];
-    if (total == 0)
-        total = 1;
-    for(i=0;i<ST_NB;i++) {
-        printf("%-10s : %10.1f %5.1f%%\n", 
-               st_names[i], 
-               (double)st_bit_counts[i] / 8.0, 
-               (double)st_bit_counts[i] * 100.0 / total);
-    }
-    printf("%-10s : %10.1f %5.1f%%\n",
-           "total", 
-           (double)total / 8.0, 
-           100.0);
-
-    printf("Output:\n");
-    total = 0;
-    for(i=0;i<ST_NB;i++)
-        total += st_out_bit_counts[i];
-    if (total == 0)
-        total = 1;
-    for(i=0;i<ST_NB;i++) {
-        printf("%-10s : %10.1f %5.1f%%\n", 
-               st_names[i], 
-               (double)st_out_bit_counts[i] / 8.0, 
-               (double)st_out_bit_counts[i] * 100.0 / total);
-    }
-    printf("%-10s : %10.1f %5.1f%%\n",
-           "total", 
-           (double)total / 8.0, 
-           100.0);
-}
-
-#else
-
-#define set_stat(var)
-
-#endif
-
-static void common_init(MpegEncContext * s)
-{
-    static int inited=0;
-    
-    switch(s->msmpeg4_version){
-    case 1:
-    case 2:
-        s->y_dc_scale_table=
-        s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
-        break;
-    case 3:
-        if(s->workaround_bugs){
-            s->y_dc_scale_table= old_ff_y_dc_scale_table;
-            s->c_dc_scale_table= old_ff_c_dc_scale_table;
-        } else{
-            s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table;
-            s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;
-        }
-        break;
-    case 4:
-    case 5:
-        s->y_dc_scale_table= wmv1_y_dc_scale_table;
-        s->c_dc_scale_table= wmv1_c_dc_scale_table;
-        break;
-#if defined(CONFIG_WMV3_DECODER)||defined(CONFIG_VC9_DECODER)
-    case 6:
-        s->y_dc_scale_table= wmv3_dc_scale_table;
-        s->c_dc_scale_table= wmv3_dc_scale_table;
-        break;
-#endif
-
-    }
-
-    
-    if(s->msmpeg4_version>=4){
-        ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable  , wmv1_scantable[1]);
-        ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, wmv1_scantable[2]);
-        ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, wmv1_scantable[3]);
-        ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable  , wmv1_scantable[0]);
-    }
-    //Note the default tables are set in common_init in mpegvideo.c
-    
-    if(!inited){
-        inited=1;
-
-        init_h263_dc_for_msmpeg4();
-    }
-}
-
-#ifdef CONFIG_ENCODERS
-
-/* build the table which associate a (x,y) motion vector to a vlc */
-static void init_mv_table(MVTable *tab)
-{
-    int i, x, y;
-
-    tab->table_mv_index = av_malloc(sizeof(uint16_t) * 4096);
-    /* mark all entries as not used */
-    for(i=0;i<4096;i++)
-        tab->table_mv_index[i] = tab->n;
-    
-    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;
-    }
-}
-
-static void code012(PutBitContext *pb, int n)
-{
-    if (n == 0) {
-        put_bits(pb, 1, 0);
-    } else {
-        put_bits(pb, 1, 1);
-        put_bits(pb, 1, (n >= 2));
-    }
-}
-
-void ff_msmpeg4_encode_init(MpegEncContext *s)
-{
-    static int init_done=0;
-    int i;
-
-    common_init(s);
-    if(s->msmpeg4_version>=4){
-        s->min_qcoeff= -255;
-        s->max_qcoeff=  255;
-    }
-
-    if (!init_done) {
-        /* init various encoding tables */
-        init_done = 1;
-        init_mv_table(&mv_tables[0]);
-        init_mv_table(&mv_tables[1]);
-        for(i=0;i<NB_RL_TABLES;i++)
-            init_rl(&rl_table[i], 1);
-
-        for(i=0; i<NB_RL_TABLES; i++){
-            int level;
-            for(level=0; level<=MAX_LEVEL; level++){
-                int run;
-                for(run=0; run<=MAX_RUN; run++){
-                    int last;
-                    for(last=0; last<2; last++){
-                        rl_length[i][level][run][last]= get_size_of_code(s, &rl_table[  i], last, run, level, 0);
-                    }
-                }
-            }
-        }
-    }
-}
-
-static int get_size_of_code(MpegEncContext * s, RLTable *rl, int last, int run, int level, int intra){
-    int size=0;
-    int code;
-    int run_diff= intra ? 0 : 1;
-    
-    code = get_rl_index(rl, last, run, level);
-    size+= rl->table_vlc[code][1];
-    if (code == rl->n) {
-        int level1, run1;
-
-        level1 = level - rl->max_level[last][run];
-        if (level1 < 1) 
-            goto esc2;
-        code = get_rl_index(rl, last, run, level1);
-        if (code == rl->n) {
-            esc2:
-            size++;
-            if (level > MAX_LEVEL)
-                goto esc3;
-            run1 = run - rl->max_run[last][level] - run_diff;
-            if (run1 < 0)
-                goto esc3;
-            code = get_rl_index(rl, last, run1, level);
-            if (code == rl->n) {
-            esc3:
-                /* third escape */
-                size+=1+1+6+8;
-            } else {
-                /* second escape */
-                size+= 1+1+ rl->table_vlc[code][1];
-            }
-        } else {
-            /* first escape */
-            size+= 1+1+ rl->table_vlc[code][1];
-        }
-    } else {
-        size++;
-    }
-    return size;
-}
-
-static void find_best_tables(MpegEncContext * s)
-{
-    int i;
-    int best       =-1, best_size       =9999999;
-    int chroma_best=-1, best_chroma_size=9999999;
-
-    for(i=0; i<3; i++){
-        int level;
-        int chroma_size=0;
-        int size=0;
-
-        if(i>0){// ;)
-            size++; 
-            chroma_size++;
-        }
-        for(level=0; level<=MAX_LEVEL; level++){
-            int run;
-            for(run=0; run<=MAX_RUN; run++){
-                int last;
-                const int last_size= size + chroma_size;
-                for(last=0; last<2; last++){
-                    int inter_count       = s->ac_stats[0][0][level][run][last] + s->ac_stats[0][1][level][run][last];
-                    int intra_luma_count  = s->ac_stats[1][0][level][run][last];
-                    int intra_chroma_count= s->ac_stats[1][1][level][run][last];
-                    
-                    if(s->pict_type==I_TYPE){
-                        size       += intra_luma_count  *rl_length[i  ][level][run][last];
-                        chroma_size+= intra_chroma_count*rl_length[i+3][level][run][last];
-                    }else{
-                        size+=        intra_luma_count  *rl_length[i  ][level][run][last]
-                                     +intra_chroma_count*rl_length[i+3][level][run][last]
-                                     +inter_count       *rl_length[i+3][level][run][last];
-                    }                   
-                }
-                if(last_size == size+chroma_size) break;
-            }
-        }
-        if(size<best_size){
-            best_size= size;
-            best= i;
-        }
-        if(chroma_size<best_chroma_size){
-            best_chroma_size= chroma_size;
-            chroma_best= i;
-        }
-    }
-
-//    printf("type:%d, best:%d, qp:%d, var:%d, mcvar:%d, size:%d //\n", 
-//           s->pict_type, best, s->qscale, s->mb_var_sum, s->mc_mb_var_sum, best_size);
-           
-    if(s->pict_type==P_TYPE) chroma_best= best;
-
-    memset(s->ac_stats, 0, sizeof(int)*(MAX_LEVEL+1)*(MAX_RUN+1)*2*2*2);
-
-    s->rl_table_index       =        best;
-    s->rl_chroma_table_index= chroma_best;
-    
-    if(s->pict_type != s->last_non_b_pict_type){
-        s->rl_table_index= 2;
-        if(s->pict_type==I_TYPE)
-            s->rl_chroma_table_index= 1;
-        else
-            s->rl_chroma_table_index= 2;
-    }
-
-}
-
-/* write MSMPEG4 compatible frame header */
-void msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
-{
-    find_best_tables(s);
-
-    align_put_bits(&s->pb);
-    put_bits(&s->pb, 2, s->pict_type - 1);
-
-    put_bits(&s->pb, 5, s->qscale);
-    if(s->msmpeg4_version<=2){
-        s->rl_table_index = 2;
-        s->rl_chroma_table_index = 2;
-    }
-
-    s->dc_table_index = 1;
-    s->mv_table_index = 1; /* only if P frame */
-    s->use_skip_mb_code = 1; /* only if P frame */
-    s->per_mb_rl_table = 0;
-    if(s->msmpeg4_version==4)
-        s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE && s->pict_type==P_TYPE);
-//printf("%d %d %d %d %d\n", s->pict_type, s->bit_rate, s->inter_intra_pred, s->width, s->height);
-
-    if (s->pict_type == I_TYPE) {
-        s->slice_height= s->mb_height/1;
-        put_bits(&s->pb, 5, 0x16 + s->mb_height/s->slice_height);
-        
-        if(s->msmpeg4_version==4){
-            msmpeg4_encode_ext_header(s);
-            if(s->bit_rate>MBAC_BITRATE)
-                put_bits(&s->pb, 1, s->per_mb_rl_table);
-        }
-
-        if(s->msmpeg4_version>2){
-            if(!s->per_mb_rl_table){
-                code012(&s->pb, s->rl_chroma_table_index);
-                code012(&s->pb, s->rl_table_index);
-            }
-
-            put_bits(&s->pb, 1, s->dc_table_index);
-        }
-    } else {
-        put_bits(&s->pb, 1, s->use_skip_mb_code);
-        
-        if(s->msmpeg4_version==4 && s->bit_rate>MBAC_BITRATE)
-            put_bits(&s->pb, 1, s->per_mb_rl_table);
-
-        if(s->msmpeg4_version>2){
-            if(!s->per_mb_rl_table)
-                code012(&s->pb, s->rl_table_index);
-
-            put_bits(&s->pb, 1, s->dc_table_index);
-
-            put_bits(&s->pb, 1, s->mv_table_index);
-        }
-    }
-
-    s->esc3_level_length= 0;
-    s->esc3_run_length= 0;
-
-#ifdef DEBUG
-    intra_count = 0;
-    printf("*****frame %d:\n", frame_count++);
-#endif
-}
-
-void msmpeg4_encode_ext_header(MpegEncContext * s)
-{
-        put_bits(&s->pb, 5, s->avctx->time_base.den / s->avctx->time_base.num); //yes 29.97 -> 29
-
-        put_bits(&s->pb, 11, FFMIN(s->bit_rate/1024, 2047));
-
-        if(s->msmpeg4_version>=3)
-            put_bits(&s->pb, 1, s->flipflop_rounding);
-        else
-            assert(s->flipflop_rounding==0);
-}
-
-#endif //CONFIG_ENCODERS
-
-/* predict coded block */
-static inline int coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr)
-{
-    int xy, wrap, pred, a, b, c;
-
-    xy = s->block_index[n];
-    wrap = s->b8_stride;
-
-    /* B C
-     * A X 
-     */
-    a = s->coded_block[xy - 1       ];
-    b = s->coded_block[xy - 1 - wrap];
-    c = s->coded_block[xy     - wrap];
-    
-    if (b == c) {
-        pred = a;
-    } else {
-        pred = c;
-    }
-    
-    /* store value */
-    *coded_block_ptr = &s->coded_block[xy];
-
-    return pred;
-}
-
-#ifdef CONFIG_ENCODERS
-
-static void msmpeg4_encode_motion(MpegEncContext * s, 
-                                  int mx, int my)
-{
-    int code;
-    MVTable *mv;
-
-    /* modulo encoding */
-    /* WARNING : you cannot reach all the MVs even with the modulo
-       encoding. This is a somewhat strange compromise they took !!!  */
-    if (mx <= -64)
-        mx += 64;
-    else if (mx >= 64)
-        mx -= 64;
-    if (my <= -64)
-        my += 64;
-    else if (my >= 64)
-        my -= 64;
-    
-    mx += 32;
-    my += 32;
-#if 0
-    if ((unsigned)mx >= 64 ||
-        (unsigned)my >= 64) 
-        fprintf(stderr, "error mx=%d my=%d\n", mx, my);
-#endif
-    mv = &mv_tables[s->mv_table_index];
-
-    code = mv->table_mv_index[(mx << 6) | my];
-    set_stat(ST_MV);
-    put_bits(&s->pb, 
-             mv->table_mv_bits[code], 
-             mv->table_mv_code[code]);
-    if (code == mv->n) {
-        /* escape : code litterally */
-        put_bits(&s->pb, 6, mx);
-        put_bits(&s->pb, 6, my);
-    }
-}
-
-static inline void handle_slices(MpegEncContext *s){
-    if (s->mb_x == 0) {
-        if (s->slice_height && (s->mb_y % s->slice_height) == 0) {
-            if(s->msmpeg4_version < 4){
-                ff_mpeg4_clean_buffers(s);
-            }
-            s->first_slice_line = 1;
-        } else {
-            s->first_slice_line = 0; 
-        }
-    }
-}
-
-void msmpeg4_encode_mb(MpegEncContext * s, 
-                       DCTELEM block[6][64],
-                       int motion_x, int motion_y)
-{
-    int cbp, coded_cbp, i;
-    int pred_x, pred_y;
-    uint8_t *coded_block;
-
-    handle_slices(s);
-    
-    if (!s->mb_intra) {
-	/* compute cbp */
-        set_stat(ST_INTER_MB);
-	cbp = 0;
-	for (i = 0; i < 6; i++) {
-	    if (s->block_last_index[i] >= 0)
-		cbp |= 1 << (5 - i);
-	}
-	if (s->use_skip_mb_code && (cbp | motion_x | motion_y) == 0) {
-	    /* skip macroblock */
-	    put_bits(&s->pb, 1, 1);
-            s->last_bits++;
-	    s->misc_bits++;
-            s->skip_count++;
-
-	    return;
-	}
-        if (s->use_skip_mb_code)
-            put_bits(&s->pb, 1, 0);	/* mb coded */
-        
-        if(s->msmpeg4_version<=2){
-            put_bits(&s->pb, 
-                     v2_mb_type[cbp&3][1], 
-                     v2_mb_type[cbp&3][0]);
-            if((cbp&3) != 3) coded_cbp= cbp ^ 0x3C;
-            else             coded_cbp= cbp;
-
-            put_bits(&s->pb, 
-                     cbpy_tab[coded_cbp>>2][1], 
-                     cbpy_tab[coded_cbp>>2][0]);
-
-            s->misc_bits += get_bits_diff(s);
-
-            h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
-            msmpeg4v2_encode_motion(s, motion_x - pred_x);
-            msmpeg4v2_encode_motion(s, motion_y - pred_y);
-        }else{
-            put_bits(&s->pb, 
-                     table_mb_non_intra[cbp + 64][1], 
-                     table_mb_non_intra[cbp + 64][0]);
-
-            s->misc_bits += get_bits_diff(s);
-
-            /* motion vector */
-            h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
-            msmpeg4_encode_motion(s, motion_x - pred_x, 
-                                  motion_y - pred_y);
-        }
-
-        s->mv_bits += get_bits_diff(s);
-
-        for (i = 0; i < 6; i++) {
-            msmpeg4_encode_block(s, block[i], i);
-        }
-        s->p_tex_bits += get_bits_diff(s);
-    } else {
-	/* compute cbp */
-	cbp = 0;
-        coded_cbp = 0;
-	for (i = 0; i < 6; i++) {
-            int val, pred;
-            val = (s->block_last_index[i] >= 1);
-            cbp |= val << (5 - i);
-            if (i < 4) {
-                /* predict value for close blocks only for luma */
-                pred = coded_block_pred(s, i, &coded_block);
-                *coded_block = val;
-                val = val ^ pred;
-            }
-            coded_cbp |= val << (5 - i);
-	}
-#if 0
-        if (coded_cbp)
-            printf("cbp=%x %x\n", cbp, coded_cbp);
-#endif
-
-        if(s->msmpeg4_version<=2){
-            if (s->pict_type == I_TYPE) {
-                put_bits(&s->pb, 
-                         v2_intra_cbpc[cbp&3][1], v2_intra_cbpc[cbp&3][0]);
-            } else {
-                if (s->use_skip_mb_code)
-                    put_bits(&s->pb, 1, 0);	/* mb coded */
-                put_bits(&s->pb, 
-                         v2_mb_type[(cbp&3) + 4][1], 
-                         v2_mb_type[(cbp&3) + 4][0]);
-            }
-            put_bits(&s->pb, 1, 0);	/* no AC prediction yet */
-            put_bits(&s->pb, 
-                     cbpy_tab[cbp>>2][1], 
-                     cbpy_tab[cbp>>2][0]);
-        }else{
-            if (s->pict_type == I_TYPE) {
-                set_stat(ST_INTRA_MB);
-                put_bits(&s->pb, 
-                         ff_msmp4_mb_i_table[coded_cbp][1], ff_msmp4_mb_i_table[coded_cbp][0]);
-            } else {
-                if (s->use_skip_mb_code)
-                    put_bits(&s->pb, 1, 0);	/* mb coded */
-                put_bits(&s->pb, 
-                         table_mb_non_intra[cbp][1], 
-                         table_mb_non_intra[cbp][0]);
-            }
-            set_stat(ST_INTRA_MB);
-            put_bits(&s->pb, 1, 0);	/* no AC prediction yet */
-            if(s->inter_intra_pred){
-                s->h263_aic_dir=0;
-                put_bits(&s->pb, table_inter_intra[s->h263_aic_dir][1], table_inter_intra[s->h263_aic_dir][0]);
-            }
-        }
-        s->misc_bits += get_bits_diff(s);
-
-        for (i = 0; i < 6; i++) {
-            msmpeg4_encode_block(s, block[i], i);
-        }
-        s->i_tex_bits += get_bits_diff(s);
-        s->i_count++;
-    }
-}
-
-#endif //CONFIG_ENCODERS
-
-static inline int msmpeg4v1_pred_dc(MpegEncContext * s, int n, 
-                                    int32_t **dc_val_ptr)
-{
-    int i;
-
-    if (n < 4) {
-        i= 0;
-    } else {
-        i= n-3;
-    }
-    
-    *dc_val_ptr= &s->last_dc[i];
-    return s->last_dc[i]; 
-}
-
-static int get_dc(uint8_t *src, int stride, int scale)
-{
-    int y;
-    int sum=0;
-    for(y=0; y<8; y++){
-        int x;
-        for(x=0; x<8; x++){
-            sum+=src[x + y*stride];
-        }
-    }
-    return FASTDIV((sum + (scale>>1)), scale);
-}
-
-/* dir = 0: left, dir = 1: top prediction */
-static inline int msmpeg4_pred_dc(MpegEncContext * s, int n, 
-                             uint16_t **dc_val_ptr, int *dir_ptr)
-{
-    int a, b, c, wrap, pred, scale;
-    int16_t *dc_val;
-
-    /* find prediction */
-    if (n < 4) {
-	scale = s->y_dc_scale;
-    } else {
-	scale = s->c_dc_scale;
-    }
-    
-    wrap = s->block_wrap[n];
-    dc_val= s->dc_val[0] + s->block_index[n];
-
-    /* B C
-     * A X 
-     */
-    a = dc_val[ - 1];
-    b = dc_val[ - 1 - wrap];
-    c = dc_val[ - wrap];
-    
-    if(s->first_slice_line && (n&2)==0 && s->msmpeg4_version<4){
-        b=c=1024;
-    }
-
-    /* XXX: the following solution consumes divisions, but it does not
-       necessitate to modify mpegvideo.c. The problem comes from the
-       fact they decided to store the quantized DC (which would lead
-       to problems if Q could vary !) */
-#if (defined(ARCH_X86) || defined(ARCH_X86_64)) && !defined PIC
-    asm volatile(
-        "movl %3, %%eax		\n\t"
-	"shrl $1, %%eax		\n\t"
-	"addl %%eax, %2		\n\t"
-	"addl %%eax, %1		\n\t"
-	"addl %0, %%eax		\n\t"
-	"mull %4		\n\t"
-	"movl %%edx, %0		\n\t"
-	"movl %1, %%eax		\n\t"
-	"mull %4		\n\t"
-	"movl %%edx, %1		\n\t"
-	"movl %2, %%eax		\n\t"
-	"mull %4		\n\t"
-	"movl %%edx, %2		\n\t"
-	: "+b" (a), "+c" (b), "+D" (c)
-	: "g" (scale), "S" (inverse[scale])
-	: "%eax", "%edx"
-    );
-#else
-    /* #elif defined (ARCH_ALPHA) */
-    /* Divisions are extremely costly on Alpha; optimize the most
-       common case. But they are costly everywhere...
-     */
-    if (scale == 8) {
-	a = (a + (8 >> 1)) / 8;
-	b = (b + (8 >> 1)) / 8;
-	c = (c + (8 >> 1)) / 8;
-    } else {
-	a = FASTDIV((a + (scale >> 1)), scale);
-	b = FASTDIV((b + (scale >> 1)), scale);
-	c = FASTDIV((c + (scale >> 1)), scale);
-    }
-#endif
-    /* XXX: WARNING: they did not choose the same test as MPEG4. This
-       is very important ! */
-    if(s->msmpeg4_version>3){
-        if(s->inter_intra_pred){
-            uint8_t *dest;
-            int wrap;
-            
-            if(n==1){
-                pred=a;
-                *dir_ptr = 0;
-            }else if(n==2){
-                pred=c;
-                *dir_ptr = 1;
-            }else if(n==3){
-                if (abs(a - b) < abs(b - c)) {
-                    pred = c;
-                    *dir_ptr = 1;
-                } else {
-                    pred = a;
-                    *dir_ptr = 0;
-                }
-            }else{
-                if(n<4){
-                    wrap= s->linesize;
-                    dest= s->current_picture.data[0] + (((n>>1) + 2*s->mb_y) * 8*  wrap ) + ((n&1) + 2*s->mb_x) * 8;
-                }else{
-                    wrap= s->uvlinesize;
-                    dest= s->current_picture.data[n-3] + (s->mb_y * 8 * wrap) + s->mb_x * 8;
-                }
-                if(s->mb_x==0) a= (1024 + (scale>>1))/scale;
-                else           a= get_dc(dest-8, wrap, scale*8);
-                if(s->mb_y==0) c= (1024 + (scale>>1))/scale;
-                else           c= get_dc(dest-8*wrap, wrap, scale*8);
-                
-                if (s->h263_aic_dir==0) {
-                    pred= a;
-                    *dir_ptr = 0;
-                }else if (s->h263_aic_dir==1) {
-                    if(n==0){
-                        pred= c;
-                        *dir_ptr = 1;
-                    }else{
-                        pred= a;
-                        *dir_ptr = 0;
-                    }
-                }else if (s->h263_aic_dir==2) {
-                    if(n==0){
-                        pred= a;
-                        *dir_ptr = 0;
-                    }else{
-                        pred= c;
-                        *dir_ptr = 1;
-                    }
-                } else {
-                    pred= c;
-                    *dir_ptr = 1;
-                }
-            }
-        }else{
-            if (abs(a - b) < abs(b - c)) {
-                pred = c;
-                *dir_ptr = 1;
-            } else {
-                pred = a;
-                *dir_ptr = 0;
-            }
-        }
-    }else{
-        if (abs(a - b) <= abs(b - c)) {
-            pred = c;
-            *dir_ptr = 1;
-        } else {
-            pred = a;
-            *dir_ptr = 0;
-        }
-    }
-
-    /* update predictor */
-    *dc_val_ptr = &dc_val[0];
-    return pred;
-}
-
-#define DC_MAX 119
-
-static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr)
-{
-    int sign, code;
-    int pred;
-
-    if(s->msmpeg4_version==1){
-        int32_t *dc_val;
-        pred = msmpeg4v1_pred_dc(s, n, &dc_val);
-        
-        /* update predictor */
-        *dc_val= level;
-    }else{
-        uint16_t *dc_val;
-        pred = msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
-
-        /* update predictor */
-        if (n < 4) {
-            *dc_val = level * s->y_dc_scale;
-        } else {
-            *dc_val = level * s->c_dc_scale;
-        }
-    }
-
-    /* do the prediction */
-    level -= pred;
-
-    if(s->msmpeg4_version<=2){
-        if (n < 4) {
-            put_bits(&s->pb, 
-                     v2_dc_lum_table[level+256][1],
-                     v2_dc_lum_table[level+256][0]);
-        }else{
-            put_bits(&s->pb, 
-                     v2_dc_chroma_table[level+256][1],
-                     v2_dc_chroma_table[level+256][0]);
-        }
-    }else{
-        sign = 0;
-        if (level < 0) {
-            level = -level;
-            sign = 1;
-        }
-        code = level;
-        if (code > DC_MAX) 
-            code = DC_MAX;
-
-        if (s->dc_table_index == 0) {
-            if (n < 4) {
-                put_bits(&s->pb, ff_table0_dc_lum[code][1], ff_table0_dc_lum[code][0]);
-            } else {
-                put_bits(&s->pb, ff_table0_dc_chroma[code][1], ff_table0_dc_chroma[code][0]);
-            }
-        } else {
-            if (n < 4) {
-                put_bits(&s->pb, ff_table1_dc_lum[code][1], ff_table1_dc_lum[code][0]);
-            } else {
-                put_bits(&s->pb, ff_table1_dc_chroma[code][1], ff_table1_dc_chroma[code][0]);
-            }
-        }
-            
-        if (code == DC_MAX)
-            put_bits(&s->pb, 8, level);
-            
-        if (level != 0) {
-            put_bits(&s->pb, 1, sign);
-        }
-    }
-}
-
-/* Encoding of a block. Very similar to MPEG4 except for a different
-   escape coding (same as H263) and more vlc tables.
- */
-static inline void msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n)
-{
-    int level, run, last, i, j, last_index;
-    int last_non_zero, sign, slevel;
-    int code, run_diff, dc_pred_dir;
-    const RLTable *rl;
-    const uint8_t *scantable;
-
-    if (s->mb_intra) {
-        set_stat(ST_DC);
-        msmpeg4_encode_dc(s, block[0], n, &dc_pred_dir);
-        i = 1;
-        if (n < 4) {
-            rl = &rl_table[s->rl_table_index];
-        } else {
-            rl = &rl_table[3 + s->rl_chroma_table_index];
-        }
-        run_diff = 0;
-        scantable= s->intra_scantable.permutated;
-        set_stat(ST_INTRA_AC);
-    } else {
-        i = 0;
-        rl = &rl_table[3 + s->rl_table_index];
-        if(s->msmpeg4_version<=2)
-            run_diff = 0;
-        else
-            run_diff = 1;
-        scantable= s->inter_scantable.permutated;
-        set_stat(ST_INTER_AC);
-    }
-
-    /* recalculate block_last_index for M$ wmv1 */
-    if(s->msmpeg4_version>=4 && s->block_last_index[n]>0){
-        for(last_index=63; last_index>=0; last_index--){
-            if(block[scantable[last_index]]) break;
-        }
-        s->block_last_index[n]= last_index;
-    }else
-        last_index = s->block_last_index[n];
-    /* AC coefs */
-    last_non_zero = i - 1;
-    for (; i <= last_index; i++) {
-	j = scantable[i];
-	level = block[j];
-	if (level) {
-	    run = i - last_non_zero - 1;
-	    last = (i == last_index);
-	    sign = 0;
-	    slevel = level;
-	    if (level < 0) {
-		sign = 1;
-		level = -level;
-	    }
-
-            if(level<=MAX_LEVEL && run<=MAX_RUN){
-                s->ac_stats[s->mb_intra][n>3][level][run][last]++;
-            }
-#if 0
-else
-    s->ac_stats[s->mb_intra][n>3][40][63][0]++; //esc3 like
-#endif
-            code = get_rl_index(rl, last, run, level);
-            put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
-            if (code == rl->n) {
-                int level1, run1;
-
-                level1 = level - rl->max_level[last][run];
-                if (level1 < 1) 
-                    goto esc2;
-                code = get_rl_index(rl, last, run, level1);
-                if (code == rl->n) {
-                esc2:
-                    put_bits(&s->pb, 1, 0);
-                    if (level > MAX_LEVEL)
-                        goto esc3;
-                    run1 = run - rl->max_run[last][level] - run_diff;
-                    if (run1 < 0)
-                        goto esc3;
-                    code = get_rl_index(rl, last, run1, level);
-                    if (code == rl->n) {
-                    esc3:
-                        /* third escape */
-                        put_bits(&s->pb, 1, 0);
-                        put_bits(&s->pb, 1, last);
-                        if(s->msmpeg4_version>=4){
-                            if(s->esc3_level_length==0){
-                                s->esc3_level_length=8;
-                                s->esc3_run_length= 6;
-                                if(s->qscale<8)
-                                    put_bits(&s->pb, 6, 3);
-                                else
-                                    put_bits(&s->pb, 8, 3);
-                            }
-                            put_bits(&s->pb, s->esc3_run_length, run);
-                            put_bits(&s->pb, 1, sign);
-                            put_bits(&s->pb, s->esc3_level_length, level);
-                        }else{
-                            put_bits(&s->pb, 6, run);
-                            put_bits(&s->pb, 8, slevel & 0xff);
-                        }
-                    } else {
-                        /* second escape */
-                        put_bits(&s->pb, 1, 1);
-                        put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
-                        put_bits(&s->pb, 1, sign);
-                    }
-                } else {
-                    /* first escape */
-                    put_bits(&s->pb, 1, 1);
-                    put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]);
-                    put_bits(&s->pb, 1, sign);
-                }
-            } else {
-                put_bits(&s->pb, 1, sign);
-            }
-	    last_non_zero = i;
-	}
-    }
-}
-
-/****************************************/
-/* decoding stuff */
-
-static VLC mb_non_intra_vlc[4];
-VLC ff_msmp4_mb_i_vlc;
-VLC ff_msmp4_dc_luma_vlc[2];
-VLC ff_msmp4_dc_chroma_vlc[2];
-static VLC v2_dc_lum_vlc;
-static VLC v2_dc_chroma_vlc;
-static VLC cbpy_vlc;
-static VLC v2_intra_cbpc_vlc;
-static VLC v2_mb_type_vlc;
-static VLC v2_mv_vlc;
-static VLC v1_intra_cbpc_vlc;
-static VLC v1_inter_cbpc_vlc;
-static VLC inter_intra_vlc;
-
-/* this table is practically identical to the one from h263 except that its inverted */
-static void init_h263_dc_for_msmpeg4(void)
-{
-        int level, uni_code, uni_len;
-
-        for(level=-256; level<256; level++){
-            int size, v, l;
-            /* find number of bits */
-            size = 0;
-            v = abs(level);
-            while (v) {
-                v >>= 1;
-		    size++;
-            }
-
-            if (level < 0)
-                l= (-level) ^ ((1 << size) - 1);
-            else
-                l= level;
-
-            /* luminance h263 */
-            uni_code= DCtab_lum[size][0];
-            uni_len = DCtab_lum[size][1];
-            uni_code ^= (1<<uni_len)-1; //M$ doesnt like compatibility
-
-            if (size > 0) {
-                uni_code<<=size; uni_code|=l;
-                uni_len+=size;
-                if (size > 8){
-                    uni_code<<=1; uni_code|=1;
-                    uni_len++;
-                }
-            }
-            v2_dc_lum_table[level+256][0]= uni_code;
-            v2_dc_lum_table[level+256][1]= uni_len;
-
-            /* chrominance h263 */
-            uni_code= DCtab_chrom[size][0];
-            uni_len = DCtab_chrom[size][1];
-            uni_code ^= (1<<uni_len)-1; //M$ doesnt like compatibility
-            
-            if (size > 0) {
-                uni_code<<=size; uni_code|=l;
-                uni_len+=size;
-                if (size > 8){
-                    uni_code<<=1; uni_code|=1;
-                    uni_len++;
-                }
-            }
-            v2_dc_chroma_table[level+256][0]= uni_code;
-            v2_dc_chroma_table[level+256][1]= uni_len;
-
-        }
-}
-
-/* init all vlc decoding tables */
-int ff_msmpeg4_decode_init(MpegEncContext *s)
-{
-    static int done = 0;
-    int i;
-    MVTable *mv;
-
-    common_init(s);
-
-    if (!done) {
-        done = 1;
-
-        for(i=0;i<NB_RL_TABLES;i++) {
-            init_rl(&rl_table[i], 1);
-            init_vlc_rl(&rl_table[i], 1);
-        }
-        for(i=0;i<2;i++) {
-            mv = &mv_tables[i];
-            init_vlc(&mv->vlc, MV_VLC_BITS, mv->n + 1, 
-                     mv->table_mv_bits, 1, 1,
-                     mv->table_mv_code, 2, 2, 1);
-        }
-
-        init_vlc(&ff_msmp4_dc_luma_vlc[0], DC_VLC_BITS, 120, 
-                 &ff_table0_dc_lum[0][1], 8, 4,
-                 &ff_table0_dc_lum[0][0], 8, 4, 1);
-        init_vlc(&ff_msmp4_dc_chroma_vlc[0], DC_VLC_BITS, 120, 
-                 &ff_table0_dc_chroma[0][1], 8, 4,
-                 &ff_table0_dc_chroma[0][0], 8, 4, 1);
-        init_vlc(&ff_msmp4_dc_luma_vlc[1], DC_VLC_BITS, 120, 
-                 &ff_table1_dc_lum[0][1], 8, 4,
-                 &ff_table1_dc_lum[0][0], 8, 4, 1);
-        init_vlc(&ff_msmp4_dc_chroma_vlc[1], DC_VLC_BITS, 120, 
-                 &ff_table1_dc_chroma[0][1], 8, 4,
-                 &ff_table1_dc_chroma[0][0], 8, 4, 1);
-    
-        init_vlc(&v2_dc_lum_vlc, DC_VLC_BITS, 512, 
-                 &v2_dc_lum_table[0][1], 8, 4,
-                 &v2_dc_lum_table[0][0], 8, 4, 1);
-        init_vlc(&v2_dc_chroma_vlc, DC_VLC_BITS, 512, 
-                 &v2_dc_chroma_table[0][1], 8, 4,
-                 &v2_dc_chroma_table[0][0], 8, 4, 1);
-    
-        init_vlc(&cbpy_vlc, CBPY_VLC_BITS, 16,
-                 &cbpy_tab[0][1], 2, 1,
-                 &cbpy_tab[0][0], 2, 1, 1);
-        init_vlc(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,
-                 &v2_intra_cbpc[0][1], 2, 1,
-                 &v2_intra_cbpc[0][0], 2, 1, 1);
-        init_vlc(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8,
-                 &v2_mb_type[0][1], 2, 1,
-                 &v2_mb_type[0][0], 2, 1, 1);
-        init_vlc(&v2_mv_vlc, V2_MV_VLC_BITS, 33,
-                 &mvtab[0][1], 2, 1,
-                 &mvtab[0][0], 2, 1, 1);
-
-        for(i=0; i<4; i++){
-            init_vlc(&mb_non_intra_vlc[i], MB_NON_INTRA_VLC_BITS, 128, 
-                     &wmv2_inter_table[i][0][1], 8, 4,
-                     &wmv2_inter_table[i][0][0], 8, 4, 1); //FIXME name?
-        }
-        
-        init_vlc(&ff_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64, 
-                 &ff_msmp4_mb_i_table[0][1], 4, 2,
-                 &ff_msmp4_mb_i_table[0][0], 4, 2, 1);
-        
-        init_vlc(&v1_intra_cbpc_vlc, V1_INTRA_CBPC_VLC_BITS, 8, 
-                 intra_MCBPC_bits, 1, 1,
-                 intra_MCBPC_code, 1, 1, 1);
-        init_vlc(&v1_inter_cbpc_vlc, V1_INTER_CBPC_VLC_BITS, 25, 
-                 inter_MCBPC_bits, 1, 1,
-                 inter_MCBPC_code, 1, 1, 1);
-        
-        init_vlc(&inter_intra_vlc, INTER_INTRA_VLC_BITS, 4, 
-                 &table_inter_intra[0][1], 2, 1,
-                 &table_inter_intra[0][0], 2, 1, 1);
-    }
-    
-    switch(s->msmpeg4_version){
-    case 1:
-    case 2:
-        s->decode_mb= msmpeg4v12_decode_mb;
-        break;
-    case 3:
-    case 4:
-        s->decode_mb= msmpeg4v34_decode_mb;
-        break;
-    case 5:
-        s->decode_mb= wmv2_decode_mb;
-    case 6:
-        //FIXME + TODO VC9 decode mb
-        break;
-    }
-    
-    s->slice_height= s->mb_height; //to avoid 1/0 if the first frame isnt a keyframe
-    
-    return 0;
-}
-
-int msmpeg4_decode_picture_header(MpegEncContext * s)
-{
-    int code;
-
-#if 0
-{
-int i;
-for(i=0; i<s->gb.size_in_bits; i++)
-    printf("%d", get_bits1(&s->gb));
-//    get_bits1(&s->gb);
-printf("END\n");
-return -1;
-}
-#endif
-
-    if(s->msmpeg4_version==1){
-        int start_code, num;
-        start_code = (get_bits(&s->gb, 16)<<16) | get_bits(&s->gb, 16);
-        if(start_code!=0x00000100){
-            av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n");
-            return -1;
-        }
-
-        num= get_bits(&s->gb, 5); // frame number */
-    }
-
-    s->pict_type = get_bits(&s->gb, 2) + 1;
-    if (s->pict_type != I_TYPE &&
-        s->pict_type != P_TYPE){
-        av_log(s->avctx, AV_LOG_ERROR, "invalid picture type\n");
-        return -1;
-    }
-#if 0
-{
-    static int had_i=0;
-    if(s->pict_type == I_TYPE) had_i=1;
-    if(!had_i) return -1;
-}
-#endif
-    s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
-    if(s->qscale==0){
-        av_log(s->avctx, AV_LOG_ERROR, "invalid qscale\n");
-        return -1;
-    }
-
-    if (s->pict_type == I_TYPE) {
-        code = get_bits(&s->gb, 5); 
-        if(s->msmpeg4_version==1){
-            if(code==0 || code>s->mb_height){
-                av_log(s->avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
-                return -1;
-            }
-
-            s->slice_height = code;
-        }else{
-            /* 0x17: one slice, 0x18: two slices, ... */
-            if (code < 0x17){
-                av_log(s->avctx, AV_LOG_ERROR, "error, slice code was %X\n", code);
-                return -1;
-            }
-
-            s->slice_height = s->mb_height / (code - 0x16);
-        }
-
-        switch(s->msmpeg4_version){
-        case 1:
-        case 2:
-            s->rl_chroma_table_index = 2;
-            s->rl_table_index = 2;
-
-            s->dc_table_index = 0; //not used
-            break;
-        case 3:
-            s->rl_chroma_table_index = decode012(&s->gb);
-            s->rl_table_index = decode012(&s->gb);
-
-            s->dc_table_index = get_bits1(&s->gb);
-            break;
-        case 4:
-            msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8);
-
-            if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
-            else                           s->per_mb_rl_table= 0;
-            
-            if(!s->per_mb_rl_table){
-                s->rl_chroma_table_index = decode012(&s->gb);
-                s->rl_table_index = decode012(&s->gb);
-            }
-
-            s->dc_table_index = get_bits1(&s->gb);
-            s->inter_intra_pred= 0;
-            break;
-        }
-        s->no_rounding = 1;
-        if(s->avctx->debug&FF_DEBUG_PICT_INFO)
-	    av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d slice:%d   \n", 
-		s->qscale,
-		s->rl_chroma_table_index,
-		s->rl_table_index, 
-		s->dc_table_index,
-                s->per_mb_rl_table,
-                s->slice_height);
-    } else {
-        switch(s->msmpeg4_version){
-        case 1:
-        case 2:
-            if(s->msmpeg4_version==1)
-                s->use_skip_mb_code = 1;
-            else
-                s->use_skip_mb_code = get_bits1(&s->gb);
-            s->rl_table_index = 2;
-            s->rl_chroma_table_index = s->rl_table_index;
-            s->dc_table_index = 0; //not used
-            s->mv_table_index = 0;
-            break;
-        case 3:
-            s->use_skip_mb_code = get_bits1(&s->gb);
-            s->rl_table_index = decode012(&s->gb);
-            s->rl_chroma_table_index = s->rl_table_index;
-
-            s->dc_table_index = get_bits1(&s->gb);
-
-            s->mv_table_index = get_bits1(&s->gb);
-            break;
-        case 4:
-            s->use_skip_mb_code = get_bits1(&s->gb);
-
-            if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
-            else                           s->per_mb_rl_table= 0;
-
-            if(!s->per_mb_rl_table){
-                s->rl_table_index = decode012(&s->gb);
-                s->rl_chroma_table_index = s->rl_table_index;
-            }
-
-            s->dc_table_index = get_bits1(&s->gb);
-
-            s->mv_table_index = get_bits1(&s->gb);
-            s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
-            break;
-        }
-        
-        if(s->avctx->debug&FF_DEBUG_PICT_INFO)
-	    av_log(s->avctx, AV_LOG_DEBUG, "skip:%d rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d   \n", 
-		s->use_skip_mb_code, 
-		s->rl_table_index, 
-		s->rl_chroma_table_index, 
-		s->dc_table_index,
-		s->mv_table_index,
-                s->per_mb_rl_table,
-                s->qscale);
-
-	if(s->flipflop_rounding){
-	    s->no_rounding ^= 1;
-	}else{
-	    s->no_rounding = 0;
-	}
-    }
-//printf("%d %d %d %d %d\n", s->pict_type, s->bit_rate, s->inter_intra_pred, s->width, s->height);
-
-    s->esc3_level_length= 0;
-    s->esc3_run_length= 0;
-
-#ifdef DEBUG
-    printf("*****frame %d:\n", frame_count++);
-#endif
-    return 0;
-}
-
-int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size)
-{
-    int left= buf_size*8 - get_bits_count(&s->gb);
-    int length= s->msmpeg4_version>=3 ? 17 : 16;
-    /* the alt_bitstream reader could read over the end so we need to check it */
-    if(left>=length && left<length+8)
-    {
-        int fps;
-
-        fps= get_bits(&s->gb, 5);
-        s->bit_rate= get_bits(&s->gb, 11)*1024;
-        if(s->msmpeg4_version>=3)
-            s->flipflop_rounding= get_bits1(&s->gb);
-        else
-            s->flipflop_rounding= 0;
-
-//        printf("fps:%2d bps:%2d roundingType:%1d\n", fps, s->bit_rate/1024, s->flipflop_rounding);
-    }
-    else if(left<length+8)
-    {
-        s->flipflop_rounding= 0;
-        if(s->msmpeg4_version != 2)
-            av_log(s->avctx, AV_LOG_ERROR, "ext header missing, %d left\n", left);
-    }
-    else
-    {
-        av_log(s->avctx, AV_LOG_ERROR, "I frame too long, ignoring ext header\n");
-    }
-
-    return 0;
-}
-
-static inline void msmpeg4_memsetw(short *tab, int val, int n)
-{
-    int i;
-    for(i=0;i<n;i++)
-        tab[i] = val;
-}
-
-static void msmpeg4v2_encode_motion(MpegEncContext * s, int val)
-{
-    int range, bit_size, sign, code, bits;
-
-    if (val == 0) {
-        /* zero vector */
-        code = 0;
-        put_bits(&s->pb, mvtab[code][1], mvtab[code][0]);
-    } else {
-        bit_size = s->f_code - 1;
-        range = 1 << bit_size;
-        if (val <= -64)
-            val += 64;
-        else if (val >= 64)
-            val -= 64;
-
-        if (val >= 0) {
-            sign = 0;
-        } else {
-            val = -val;
-            sign = 1;
-        }
-        val--;
-        code = (val >> bit_size) + 1;
-        bits = val & (range - 1);
-
-        put_bits(&s->pb, mvtab[code][1] + 1, (mvtab[code][0] << 1) | sign); 
-        if (bit_size > 0) {
-            put_bits(&s->pb, bit_size, bits);
-        }
-    }
-}
-
-/* this is identical to h263 except that its range is multiplied by 2 */
-static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code)
-{
-    int code, val, sign, shift;
-
-    code = get_vlc2(&s->gb, v2_mv_vlc.table, V2_MV_VLC_BITS, 2);
-//     printf("MV code %d at %d %d pred: %d\n", code, s->mb_x,s->mb_y, pred);
-    if (code < 0)
-        return 0xffff;
-
-    if (code == 0)
-        return pred;
-    sign = get_bits1(&s->gb);
-    shift = f_code - 1;
-    val = code;
-    if (shift) {
-        val = (val - 1) << shift;
-        val |= get_bits(&s->gb, shift);
-        val++;
-    }
-    if (sign)
-        val = -val;
-
-    val += pred;
-    if (val <= -64)
-        val += 64;
-    else if (val >= 64)
-        val -= 64;
-
-    return val;
-}
-
-static int msmpeg4v12_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
-{
-    int cbp, code, i;
-    
-    if (s->pict_type == P_TYPE) {
-        if (s->use_skip_mb_code) {
-            if (get_bits1(&s->gb)) {
-                /* skip mb */
-                s->mb_intra = 0;
-                for(i=0;i<6;i++)
-                    s->block_last_index[i] = -1;
-                s->mv_dir = MV_DIR_FORWARD;
-                s->mv_type = MV_TYPE_16X16;
-                s->mv[0][0][0] = 0;
-                s->mv[0][0][1] = 0;
-                s->mb_skipped = 1;
-                return 0;
-            }
-        }
-
-        if(s->msmpeg4_version==2)
-            code = get_vlc2(&s->gb, v2_mb_type_vlc.table, V2_MB_TYPE_VLC_BITS, 1);
-        else
-            code = get_vlc2(&s->gb, v1_inter_cbpc_vlc.table, V1_INTER_CBPC_VLC_BITS, 3);
-        if(code<0 || code>7){
-            av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", code, s->mb_x, s->mb_y);
-            return -1;
-        }
-
-        s->mb_intra = code >>2;
-    
-        cbp = code & 0x3;
-    } else {
-        s->mb_intra = 1;
-        if(s->msmpeg4_version==2)
-            cbp= get_vlc2(&s->gb, v2_intra_cbpc_vlc.table, V2_INTRA_CBPC_VLC_BITS, 1);
-        else
-            cbp= get_vlc2(&s->gb, v1_intra_cbpc_vlc.table, V1_INTRA_CBPC_VLC_BITS, 1);
-        if(cbp<0 || cbp>3){
-            av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
-            return -1;
-        }
-    }
-
-    if (!s->mb_intra) {
-        int mx, my, cbpy;
-        
-        cbpy= get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
-        if(cbpy<0){
-            av_log(s->avctx, AV_LOG_ERROR, "cbpy %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
-            return -1;
-        }
-
-        cbp|= cbpy<<2;
-        if(s->msmpeg4_version==1 || (cbp&3) != 3) cbp^= 0x3C;
-        
-        h263_pred_motion(s, 0, 0, &mx, &my);
-        mx= msmpeg4v2_decode_motion(s, mx, 1);
-        my= msmpeg4v2_decode_motion(s, my, 1);
-        
-        s->mv_dir = MV_DIR_FORWARD;
-        s->mv_type = MV_TYPE_16X16;
-        s->mv[0][0][0] = mx;
-        s->mv[0][0][1] = my;
-    } else {
-        if(s->msmpeg4_version==2){
-            s->ac_pred = get_bits1(&s->gb);
-            cbp|= get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; //FIXME check errors
-        } else{
-            s->ac_pred = 0;
-            cbp|= get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; //FIXME check errors
-            if(s->pict_type==P_TYPE) cbp^=0x3C;
-        }
-    }
-
-    s->dsp.clear_blocks(s->block[0]);
-    for (i = 0; i < 6; i++) {
-        if (msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
-	{
-             av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
-             return -1;
-	}
-    }
-    return 0;
-}
-
-static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
-{
-    int cbp, code, i;
-    uint8_t *coded_val;
-    uint32_t * const mb_type_ptr= &s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ];
-
-    if (s->pict_type == P_TYPE) {
-        set_stat(ST_INTER_MB);
-        if (s->use_skip_mb_code) {
-            if (get_bits1(&s->gb)) {
-                /* skip mb */
-                s->mb_intra = 0;
-                for(i=0;i<6;i++)
-                    s->block_last_index[i] = -1;
-                s->mv_dir = MV_DIR_FORWARD;
-                s->mv_type = MV_TYPE_16X16;
-                s->mv[0][0][0] = 0;
-                s->mv[0][0][1] = 0;
-                s->mb_skipped = 1;
-                *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
-
-                return 0;
-            }
-        }
-        
-        code = get_vlc2(&s->gb, 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;
-            
-        cbp = code & 0x3f;
-    } else {
-        set_stat(ST_INTRA_MB);
-        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++) {
-            int val = ((code >> (5 - i)) & 1);
-            if (i < 4) {
-                int pred = coded_block_pred(s, i, &coded_val);
-                val = val ^ pred;
-                *coded_val = val;
-            }
-            cbp |= val << (5 - i);
-        }
-    }
-
-    if (!s->mb_intra) {
-        int mx, my;
-//printf("P at %d %d\n", s->mb_x, s->mb_y);
-        if(s->per_mb_rl_table && cbp){
-            s->rl_table_index = decode012(&s->gb);
-            s->rl_chroma_table_index = s->rl_table_index;
-        }
-        set_stat(ST_MV);
-        h263_pred_motion(s, 0, 0, &mx, &my);
-        if (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;
-        s->mv[0][0][1] = my;
-        *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
-    } else {
-//printf("I at %d %d %d %06X\n", s->mb_x, s->mb_y, ((cbp&3)? 1 : 0) +((cbp&0x3C)? 2 : 0), show_bits(&s->gb, 24));
-        set_stat(ST_INTRA_MB);
-        s->ac_pred = get_bits1(&s->gb);
-        *mb_type_ptr = MB_TYPE_INTRA;
-        if(s->inter_intra_pred){
-            s->h263_aic_dir= get_vlc2(&s->gb, inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1);
-//            printf("%d%d %d %d/", s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
-        }
-        if(s->per_mb_rl_table && cbp){
-            s->rl_table_index = decode012(&s->gb);
-            s->rl_chroma_table_index = s->rl_table_index;
-        }
-    }
-
-    s->dsp.clear_blocks(s->block[0]);
-    for (i = 0; i < 6; i++) {
-        if (msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
-	{
-	    av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
-	    return -1;
-	}
-    }
-    
-    return 0;
-}
-//#define ERROR_DETAILS
-static inline int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
-                              int n, int coded, const uint8_t *scan_table)
-{
-    int level, i, last, run, run_diff;
-    int dc_pred_dir;
-    RLTable *rl;
-    RL_VLC_ELEM *rl_vlc;
-    int qmul, qadd;
-
-    if (s->mb_intra) {
-        qmul=1;
-        qadd=0;
-
-	/* DC coef */
-        set_stat(ST_DC);
-        level = msmpeg4_decode_dc(s, n, &dc_pred_dir);
-        
-        if (level < 0){
-            av_log(s->avctx, AV_LOG_ERROR, "dc overflow- block: %d qscale: %d//\n", n, s->qscale);
-            if(s->inter_intra_pred) level=0;
-            else                    return -1;
-        }
-        if (n < 4) {
-            rl = &rl_table[s->rl_table_index];
-            if(level > 256*s->y_dc_scale){
-                av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ L qscale: %d//\n", s->qscale);
-                if(!s->inter_intra_pred) return -1;
-            }
-        } else {
-            rl = &rl_table[3 + s->rl_chroma_table_index];
-            if(level > 256*s->c_dc_scale){
-                av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ C qscale: %d//\n", s->qscale);
-                if(!s->inter_intra_pred) return -1;
-            }
-        }
-        block[0] = level;
-
-        run_diff = 0;
-        i = 0;
-        if (!coded) {
-            goto not_coded;
-        }
-        if (s->ac_pred) {
-            if (dc_pred_dir == 0) 
-                scan_table = s->intra_v_scantable.permutated; /* left */
-            else
-                scan_table = s->intra_h_scantable.permutated; /* top */
-        } else {
-            scan_table = s->intra_scantable.permutated;
-        }
-        set_stat(ST_INTRA_AC);
-        rl_vlc= rl->rl_vlc[0];
-    } else {
-        qmul = s->qscale << 1;
-        qadd = (s->qscale - 1) | 1;
-        i = -1;
-        rl = &rl_table[3 + s->rl_table_index];
-
-        if(s->msmpeg4_version==2)
-            run_diff = 0;
-        else
-            run_diff = 1;
-
-        if (!coded) {
-            s->block_last_index[n] = i;
-            return 0;
-        }
-        if(!scan_table)
-            scan_table = s->inter_scantable.permutated;
-        set_stat(ST_INTER_AC);
-        rl_vlc= rl->rl_vlc[s->qscale];
-    }
-  {
-    OPEN_READER(re, &s->gb);
-    for(;;) {
-        UPDATE_CACHE(re, &s->gb);
-        GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
-        if (level==0) {
-            int cache;
-            cache= GET_CACHE(re, &s->gb);
-            /* escape */
-            if (s->msmpeg4_version==1 || (cache&0x80000000)==0) {
-                if (s->msmpeg4_version==1 || (cache&0x40000000)==0) {
-                    /* third escape */
-                    if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2);
-                    UPDATE_CACHE(re, &s->gb);
-                    if(s->msmpeg4_version<=3){
-                        last=  SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
-                        run=   SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
-                        level= SHOW_SBITS(re, &s->gb, 8); LAST_SKIP_CACHE(re, &s->gb, 8);
-                        SKIP_COUNTER(re, &s->gb, 1+6+8);
-                    }else{                        
-                        int sign;
-                        last=  SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
-                        if(!s->esc3_level_length){
-                            int ll;
-                            //printf("ESC-3 %X at %d %d\n", show_bits(&s->gb, 24), s->mb_x, s->mb_y);
-                            if(s->qscale<8){
-                                ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3);
-                                if(ll==0){
-                                    if(SHOW_UBITS(re, &s->gb, 1)) av_log(s->avctx, AV_LOG_ERROR, "cool a new vlc code ,contact the ffmpeg developers and upload the file\n");
-                                    SKIP_BITS(re, &s->gb, 1);
-                                    ll=8;
-                                }
-                            }else{
-                                ll=2;
-                                while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){
-                                    ll++;
-                                    SKIP_BITS(re, &s->gb, 1);
-                                }
-                                if(ll<8) SKIP_BITS(re, &s->gb, 1);
-                            }
-
-                            s->esc3_level_length= ll;
-                            s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2);
-//printf("level length:%d, run length: %d\n", ll, s->esc3_run_length);
-                            UPDATE_CACHE(re, &s->gb);
-                        }
-                        run=   SHOW_UBITS(re, &s->gb, s->esc3_run_length); 
-                        SKIP_BITS(re, &s->gb, s->esc3_run_length);
-                        
-                        sign=  SHOW_UBITS(re, &s->gb, 1); 
-                        SKIP_BITS(re, &s->gb, 1);
-                        
-                        level= SHOW_UBITS(re, &s->gb, s->esc3_level_length); 
-                        SKIP_BITS(re, &s->gb, s->esc3_level_length);
-                        if(sign) level= -level;
-                    }
-//printf("level: %d, run: %d at %d %d\n", level, run, s->mb_x, s->mb_y);
-#if 0 // waste of time / this will detect very few errors
-                    {
-                        const int abs_level= ABS(level);
-                        const int run1= run - rl->max_run[last][abs_level] - run_diff;
-                        if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
-                            if(abs_level <= rl->max_level[last][run]){
-                                fprintf(stderr, "illegal 3. esc, vlc encoding possible\n");
-                                return DECODING_AC_LOST;
-                            }
-                            if(abs_level <= rl->max_level[last][run]*2){
-                                fprintf(stderr, "illegal 3. esc, esc 1 encoding possible\n");
-                                return DECODING_AC_LOST;
-                            }
-                            if(run1>=0 && abs_level <= rl->max_level[last][run1]){
-                                fprintf(stderr, "illegal 3. esc, esc 2 encoding possible\n");
-                                return DECODING_AC_LOST;
-                            }
-                        }
-                    }
-#endif
-		    //level = level * qmul + (level>0) * qadd - (level<=0) * qadd ;
-		    if (level>0) level= level * qmul + qadd;
-                    else         level= level * qmul - qadd;
-#if 0 // waste of time too :(
-                    if(level>2048 || level<-2048){
-                        fprintf(stderr, "|level| overflow in 3. esc\n");
-                        return DECODING_AC_LOST;
-                    }
-#endif
-                    i+= run + 1;
-                    if(last) i+=192;
-#ifdef ERROR_DETAILS
-                if(run==66)
-                    av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC3 level=%d\n", level);
-                else if((i>62 && i<192) || i>192+63)
-                    av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC3 i=%d run=%d level=%d\n", i, run, level);
-#endif
-                } else {
-                    /* second escape */
-#if MIN_CACHE_BITS < 23
-                    LAST_SKIP_BITS(re, &s->gb, 2);
-                    UPDATE_CACHE(re, &s->gb);
-#else
-                    SKIP_BITS(re, &s->gb, 2);
-#endif
-                    GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
-                    i+= run + rl->max_run[run>>7][level/qmul] + run_diff; //FIXME opt indexing
-                    level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
-                    LAST_SKIP_BITS(re, &s->gb, 1);
-#ifdef ERROR_DETAILS
-                if(run==66)
-                    av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC2 level=%d\n", level);
-                else if((i>62 && i<192) || i>192+63)
-                    av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC2 i=%d run=%d level=%d\n", i, run, level);
-#endif
-                }
-            } else {
-                /* first escape */
-#if MIN_CACHE_BITS < 22
-                LAST_SKIP_BITS(re, &s->gb, 1);
-                UPDATE_CACHE(re, &s->gb);
-#else
-                SKIP_BITS(re, &s->gb, 1);
-#endif
-                GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
-                i+= run;
-                level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
-                level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
-                LAST_SKIP_BITS(re, &s->gb, 1);
-#ifdef ERROR_DETAILS
-                if(run==66)
-                    av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC1 level=%d\n", level);
-                else if((i>62 && i<192) || i>192+63)
-                    av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC1 i=%d run=%d level=%d\n", i, run, level);
-#endif
-            }
-        } else {
-            i+= run;
-            level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
-            LAST_SKIP_BITS(re, &s->gb, 1);
-#ifdef ERROR_DETAILS
-                if(run==66)
-                    av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code level=%d\n", level);
-                else if((i>62 && i<192) || i>192+63)
-                    av_log(s->avctx, AV_LOG_ERROR, "run overflow i=%d run=%d level=%d\n", i, run, level);
-#endif
-        }
-        if (i > 62){
-            i-= 192;
-            if(i&(~63)){
-                const int left= s->gb.size_in_bits - get_bits_count(&s->gb);
-                if(((i+192 == 64 && level/qmul==-1) || s->error_resilience<=1) && left>=0){
-                    av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
-                    break;
-                }else{
-                    av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
-                    return -1;
-                }
-            }
-
-            block[scan_table[i]] = level;
-            break;
-        }
-
-        block[scan_table[i]] = level;
-    }
-    CLOSE_READER(re, &s->gb);
-  }
- not_coded:
-    if (s->mb_intra) {
-        mpeg4_pred_ac(s, block, n, dc_pred_dir);
-        if (s->ac_pred) {
-            i = 63; /* XXX: not optimal */
-        }
-    }
-    if(s->msmpeg4_version>=4 && i>0) i=63; //FIXME/XXX optimize
-    s->block_last_index[n] = i;
-    
-    return 0;
-}
-
-static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
-{
-    int level, pred;
-
-    if(s->msmpeg4_version<=2){
-        if (n < 4) {
-            level = get_vlc2(&s->gb, v2_dc_lum_vlc.table, DC_VLC_BITS, 3);
-        } else {
-            level = get_vlc2(&s->gb, v2_dc_chroma_vlc.table, DC_VLC_BITS, 3);
-        }
-        if (level < 0) 
-            return -1;
-        level-=256;
-    }else{  //FIXME optimize use unified tables & index
-        if (n < 4) {
-            level = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
-        } 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");
-            return -1;
-        }
-
-        if (level == DC_MAX) {
-            level = get_bits(&s->gb, 8);
-            if (get_bits1(&s->gb))
-                level = -level;
-        } else if (level != 0) {
-            if (get_bits1(&s->gb))
-                level = -level;
-        }
-    }
-
-    if(s->msmpeg4_version==1){
-        int32_t *dc_val;
-        pred = msmpeg4v1_pred_dc(s, n, &dc_val);
-        level += pred;
-        
-        /* update predictor */
-        *dc_val= level;
-    }else{
-        uint16_t *dc_val;
-        pred = msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
-        level += pred;
-
-        /* update predictor */
-        if (n < 4) {
-            *dc_val = level * s->y_dc_scale;
-        } else {
-            *dc_val = level * s->c_dc_scale;
-        }
-    }
-
-    return level;
-}
-
-static int msmpeg4_decode_motion(MpegEncContext * s, 
-                                 int *mx_ptr, int *my_ptr)
-{
-    MVTable *mv;
-    int code, mx, my;
-
-    mv = &mv_tables[s->mv_table_index];
-
-    code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2);
-    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) {
-//printf("MV ESC %X at %d %d\n", show_bits(&s->gb, 24), s->mb_x, s->mb_y);
-        mx = get_bits(&s->gb, 6);
-        my = get_bits(&s->gb, 6);
-    } else {
-        mx = mv->table_mvx[code];
-        my = mv->table_mvy[code];
-    }
-
-    mx += *mx_ptr - 32;
-    my += *my_ptr - 32;
-    /* WARNING : they do not do exactly modulo encoding */
-    if (mx <= -64)
-        mx += 64;
-    else if (mx >= 64)
-        mx -= 64;
-
-    if (my <= -64)
-        my += 64;
-    else if (my >= 64)
-        my -= 64;
-    *mx_ptr = mx;
-    *my_ptr = my;
-    return 0;
-}
-
-/* cleanest way to support it
- * there is too much shared between versions so that we cant have 1 file per version & 1 common
- * as allmost everything would be in the common file 
- */
-#include "wmv2.c"
diff --git a/ffmpeg.src/libavcodec/msmpeg4data.h b/ffmpeg.src/libavcodec/msmpeg4data.h
deleted file mode 100644
index 3b69406..0000000
--- a/ffmpeg.src/libavcodec/msmpeg4data.h
+++ /dev/null
@@ -1,2004 +0,0 @@
-/**
- * @file msmpeg4data.h
- * MSMPEG4 data tables. 
- */
-
-/* intra picture macro block coded block pattern */
-const uint16_t ff_msmp4_mb_i_table[64][2] = {
-{ 0x1, 1 },{ 0x17, 6 },{ 0x9, 5 },{ 0x5, 5 },
-{ 0x6, 5 },{ 0x47, 9 },{ 0x20, 7 },{ 0x10, 7 },
-{ 0x2, 5 },{ 0x7c, 9 },{ 0x3a, 7 },{ 0x1d, 7 },
-{ 0x2, 6 },{ 0xec, 9 },{ 0x77, 8 },{ 0x0, 8 },
-{ 0x3, 5 },{ 0xb7, 9 },{ 0x2c, 7 },{ 0x13, 7 },
-{ 0x1, 6 },{ 0x168, 10 },{ 0x46, 8 },{ 0x3f, 8 },
-{ 0x1e, 6 },{ 0x712, 13 },{ 0xb5, 9 },{ 0x42, 8 },
-{ 0x22, 7 },{ 0x1c5, 11 },{ 0x11e, 10 },{ 0x87, 9 },
-{ 0x6, 4 },{ 0x3, 9 },{ 0x1e, 7 },{ 0x1c, 6 },
-{ 0x12, 7 },{ 0x388, 12 },{ 0x44, 9 },{ 0x70, 9 },
-{ 0x1f, 6 },{ 0x23e, 11 },{ 0x39, 8 },{ 0x8e, 9 },
-{ 0x1, 7 },{ 0x1c6, 11 },{ 0xb6, 9 },{ 0x45, 9 },
-{ 0x14, 6 },{ 0x23f, 11 },{ 0x7d, 9 },{ 0x18, 9 },
-{ 0x7, 7 },{ 0x1c7, 11 },{ 0x86, 9 },{ 0x19, 9 },
-{ 0x15, 6 },{ 0x1db, 10 },{ 0x2, 9 },{ 0x46, 9 },
-{ 0xd, 8 },{ 0x713, 13 },{ 0x1da, 10 },{ 0x169, 10 },
-};
-
-/* non intra picture macro block coded block pattern + mb type */
-static const uint32_t table_mb_non_intra[128][2] = {
-{ 0x40, 7 },{ 0x13c9, 13 },{ 0x9fd, 12 },{ 0x1fc, 15 },
-{ 0x9fc, 12 },{ 0xa83, 18 },{ 0x12d34, 17 },{ 0x83bc, 16 },
-{ 0x83a, 12 },{ 0x7f8, 17 },{ 0x3fd, 16 },{ 0x3ff, 16 },
-{ 0x79, 13 },{ 0xa82, 18 },{ 0x969d, 16 },{ 0x2a4, 16 },
-{ 0x978, 12 },{ 0x543, 17 },{ 0x41df, 15 },{ 0x7f9, 17 },
-{ 0x12f3, 13 },{ 0x25a6b, 18 },{ 0x25ef9, 18 },{ 0x3fa, 16 },
-{ 0x20ee, 14 },{ 0x969ab, 20 },{ 0x969c, 16 },{ 0x25ef8, 18 },
-{ 0x12d2, 13 },{ 0xa85, 18 },{ 0x969e, 16 },{ 0x4bc8, 15 },
-{ 0x3d, 12 },{ 0x12f7f, 17 },{ 0x2a2, 16 },{ 0x969f, 16 },
-{ 0x25ee, 14 },{ 0x12d355, 21 },{ 0x12f7d, 17 },{ 0x12f7e, 17 },
-{ 0x9e5, 12 },{ 0xa81, 18 },{ 0x4b4d4, 19 },{ 0x83bd, 16 },
-{ 0x78, 13 },{ 0x969b, 16 },{ 0x3fe, 16 },{ 0x2a5, 16 },
-{ 0x7e, 13 },{ 0xa80, 18 },{ 0x2a3, 16 },{ 0x3fb, 16 },
-{ 0x1076, 13 },{ 0xa84, 18 },{ 0x153, 15 },{ 0x4bc9, 15 },
-{ 0x55, 13 },{ 0x12d354, 21 },{ 0x4bde, 15 },{ 0x25e5, 14 },
-{ 0x25b, 10 },{ 0x4b4c, 15 },{ 0x96b, 12 },{ 0x96a, 12 },
-{ 0x1, 2 },{ 0x0, 7 },{ 0x26, 6 },{ 0x12b, 9 },
-{ 0x7, 3 },{ 0x20f, 10 },{ 0x4, 9 },{ 0x28, 12 },
-{ 0x6, 3 },{ 0x20a, 10 },{ 0x128, 9 },{ 0x2b, 12 },
-{ 0x11, 5 },{ 0x1b, 11 },{ 0x13a, 9 },{ 0x4ff, 11 },
-{ 0x3, 4 },{ 0x277, 10 },{ 0x106, 9 },{ 0x839, 12 },
-{ 0xb, 4 },{ 0x27b, 10 },{ 0x12c, 9 },{ 0x4bf, 11 },
-{ 0x9, 6 },{ 0x35, 12 },{ 0x27e, 10 },{ 0x13c8, 13 },
-{ 0x1, 6 },{ 0x4aa, 11 },{ 0x208, 10 },{ 0x29, 12 },
-{ 0x1, 4 },{ 0x254, 10 },{ 0x12e, 9 },{ 0x838, 12 },
-{ 0x24, 6 },{ 0x4f3, 11 },{ 0x276, 10 },{ 0x12f6, 13 },
-{ 0x1, 5 },{ 0x27a, 10 },{ 0x13e, 9 },{ 0x3e, 12 },
-{ 0x8, 6 },{ 0x413, 11 },{ 0xc, 10 },{ 0x4be, 11 },
-{ 0x14, 5 },{ 0x412, 11 },{ 0x253, 10 },{ 0x97a, 12 },
-{ 0x21, 6 },{ 0x4ab, 11 },{ 0x20b, 10 },{ 0x34, 12 },
-{ 0x15, 5 },{ 0x278, 10 },{ 0x252, 10 },{ 0x968, 12 },
-{ 0x5, 5 },{ 0xb, 10 },{ 0x9c, 8 },{ 0xe, 10 },
-};
-
-/* dc table 0 */
-
-const uint32_t ff_table0_dc_lum[120][2] = {
-{ 0x1, 1 },{ 0x1, 2 },{ 0x1, 4 },{ 0x1, 5 },
-{ 0x5, 5 },{ 0x7, 5 },{ 0x8, 6 },{ 0xc, 6 },
-{ 0x0, 7 },{ 0x2, 7 },{ 0x12, 7 },{ 0x1a, 7 },
-{ 0x3, 8 },{ 0x7, 8 },{ 0x27, 8 },{ 0x37, 8 },
-{ 0x5, 9 },{ 0x4c, 9 },{ 0x6c, 9 },{ 0x6d, 9 },
-{ 0x8, 10 },{ 0x19, 10 },{ 0x9b, 10 },{ 0x1b, 10 },
-{ 0x9a, 10 },{ 0x13, 11 },{ 0x34, 11 },{ 0x35, 11 },
-{ 0x61, 12 },{ 0x48, 13 },{ 0xc4, 13 },{ 0x4a, 13 },
-{ 0xc6, 13 },{ 0xc7, 13 },{ 0x92, 14 },{ 0x18b, 14 },
-{ 0x93, 14 },{ 0x183, 14 },{ 0x182, 14 },{ 0x96, 14 },
-{ 0x97, 14 },{ 0x180, 14 },{ 0x314, 15 },{ 0x315, 15 },
-{ 0x605, 16 },{ 0x604, 16 },{ 0x606, 16 },{ 0xc0e, 17 },
-{ 0x303cd, 23 },{ 0x303c9, 23 },{ 0x303c8, 23 },{ 0x303ca, 23 },
-{ 0x303cb, 23 },{ 0x303cc, 23 },{ 0x303ce, 23 },{ 0x303cf, 23 },
-{ 0x303d0, 23 },{ 0x303d1, 23 },{ 0x303d2, 23 },{ 0x303d3, 23 },
-{ 0x303d4, 23 },{ 0x303d5, 23 },{ 0x303d6, 23 },{ 0x303d7, 23 },
-{ 0x303d8, 23 },{ 0x303d9, 23 },{ 0x303da, 23 },{ 0x303db, 23 },
-{ 0x303dc, 23 },{ 0x303dd, 23 },{ 0x303de, 23 },{ 0x303df, 23 },
-{ 0x303e0, 23 },{ 0x303e1, 23 },{ 0x303e2, 23 },{ 0x303e3, 23 },
-{ 0x303e4, 23 },{ 0x303e5, 23 },{ 0x303e6, 23 },{ 0x303e7, 23 },
-{ 0x303e8, 23 },{ 0x303e9, 23 },{ 0x303ea, 23 },{ 0x303eb, 23 },
-{ 0x303ec, 23 },{ 0x303ed, 23 },{ 0x303ee, 23 },{ 0x303ef, 23 },
-{ 0x303f0, 23 },{ 0x303f1, 23 },{ 0x303f2, 23 },{ 0x303f3, 23 },
-{ 0x303f4, 23 },{ 0x303f5, 23 },{ 0x303f6, 23 },{ 0x303f7, 23 },
-{ 0x303f8, 23 },{ 0x303f9, 23 },{ 0x303fa, 23 },{ 0x303fb, 23 },
-{ 0x303fc, 23 },{ 0x303fd, 23 },{ 0x303fe, 23 },{ 0x303ff, 23 },
-{ 0x60780, 24 },{ 0x60781, 24 },{ 0x60782, 24 },{ 0x60783, 24 },
-{ 0x60784, 24 },{ 0x60785, 24 },{ 0x60786, 24 },{ 0x60787, 24 },
-{ 0x60788, 24 },{ 0x60789, 24 },{ 0x6078a, 24 },{ 0x6078b, 24 },
-{ 0x6078c, 24 },{ 0x6078d, 24 },{ 0x6078e, 24 },{ 0x6078f, 24 },
-};
-
-const uint32_t ff_table0_dc_chroma[120][2] = {
-{ 0x0, 2 },{ 0x1, 2 },{ 0x5, 3 },{ 0x9, 4 },
-{ 0xd, 4 },{ 0x11, 5 },{ 0x1d, 5 },{ 0x1f, 5 },
-{ 0x21, 6 },{ 0x31, 6 },{ 0x38, 6 },{ 0x33, 6 },
-{ 0x39, 6 },{ 0x3d, 6 },{ 0x61, 7 },{ 0x79, 7 },
-{ 0x80, 8 },{ 0xc8, 8 },{ 0xca, 8 },{ 0xf0, 8 },
-{ 0x81, 8 },{ 0xc0, 8 },{ 0xc9, 8 },{ 0x107, 9 },
-{ 0x106, 9 },{ 0x196, 9 },{ 0x183, 9 },{ 0x1e3, 9 },
-{ 0x1e2, 9 },{ 0x20a, 10 },{ 0x20b, 10 },{ 0x609, 11 },
-{ 0x412, 11 },{ 0x413, 11 },{ 0x60b, 11 },{ 0x411, 11 },
-{ 0x60a, 11 },{ 0x65f, 11 },{ 0x410, 11 },{ 0x65d, 11 },
-{ 0x65e, 11 },{ 0xcb8, 12 },{ 0xc10, 12 },{ 0xcb9, 12 },
-{ 0x1823, 13 },{ 0x3045, 14 },{ 0x6089, 15 },{ 0xc110, 16 },
-{ 0x304448, 22 },{ 0x304449, 22 },{ 0x30444a, 22 },{ 0x30444b, 22 },
-{ 0x30444c, 22 },{ 0x30444d, 22 },{ 0x30444e, 22 },{ 0x30444f, 22 },
-{ 0x304450, 22 },{ 0x304451, 22 },{ 0x304452, 22 },{ 0x304453, 22 },
-{ 0x304454, 22 },{ 0x304455, 22 },{ 0x304456, 22 },{ 0x304457, 22 },
-{ 0x304458, 22 },{ 0x304459, 22 },{ 0x30445a, 22 },{ 0x30445b, 22 },
-{ 0x30445c, 22 },{ 0x30445d, 22 },{ 0x30445e, 22 },{ 0x30445f, 22 },
-{ 0x304460, 22 },{ 0x304461, 22 },{ 0x304462, 22 },{ 0x304463, 22 },
-{ 0x304464, 22 },{ 0x304465, 22 },{ 0x304466, 22 },{ 0x304467, 22 },
-{ 0x304468, 22 },{ 0x304469, 22 },{ 0x30446a, 22 },{ 0x30446b, 22 },
-{ 0x30446c, 22 },{ 0x30446d, 22 },{ 0x30446e, 22 },{ 0x30446f, 22 },
-{ 0x304470, 22 },{ 0x304471, 22 },{ 0x304472, 22 },{ 0x304473, 22 },
-{ 0x304474, 22 },{ 0x304475, 22 },{ 0x304476, 22 },{ 0x304477, 22 },
-{ 0x304478, 22 },{ 0x304479, 22 },{ 0x30447a, 22 },{ 0x30447b, 22 },
-{ 0x30447c, 22 },{ 0x30447d, 22 },{ 0x30447e, 22 },{ 0x30447f, 22 },
-{ 0x608880, 23 },{ 0x608881, 23 },{ 0x608882, 23 },{ 0x608883, 23 },
-{ 0x608884, 23 },{ 0x608885, 23 },{ 0x608886, 23 },{ 0x608887, 23 },
-{ 0x608888, 23 },{ 0x608889, 23 },{ 0x60888a, 23 },{ 0x60888b, 23 },
-{ 0x60888c, 23 },{ 0x60888d, 23 },{ 0x60888e, 23 },{ 0x60888f, 23 },
-};
-
-/* dc table 1 */
-
-const uint32_t ff_table1_dc_lum[120][2] = {
-{ 0x2, 2 },{ 0x3, 2 },{ 0x3, 3 },{ 0x2, 4 },
-{ 0x5, 4 },{ 0x1, 5 },{ 0x3, 5 },{ 0x8, 5 },
-{ 0x0, 6 },{ 0x5, 6 },{ 0xd, 6 },{ 0xf, 6 },
-{ 0x13, 6 },{ 0x8, 7 },{ 0x18, 7 },{ 0x1c, 7 },
-{ 0x24, 7 },{ 0x4, 8 },{ 0x6, 8 },{ 0x12, 8 },
-{ 0x32, 8 },{ 0x3b, 8 },{ 0x4a, 8 },{ 0x4b, 8 },
-{ 0xb, 9 },{ 0x26, 9 },{ 0x27, 9 },{ 0x66, 9 },
-{ 0x74, 9 },{ 0x75, 9 },{ 0x14, 10 },{ 0x1c, 10 },
-{ 0x1f, 10 },{ 0x1d, 10 },{ 0x2b, 11 },{ 0x3d, 11 },
-{ 0x19d, 11 },{ 0x19f, 11 },{ 0x54, 12 },{ 0x339, 12 },
-{ 0x338, 12 },{ 0x33d, 12 },{ 0xab, 13 },{ 0xf1, 13 },
-{ 0x678, 13 },{ 0xf2, 13 },{ 0x1e0, 14 },{ 0x1e1, 14 },
-{ 0x154, 14 },{ 0xcf2, 14 },{ 0x3cc, 15 },{ 0x2ab, 15 },
-{ 0x19e7, 15 },{ 0x3ce, 15 },{ 0x19e6, 15 },{ 0x554, 16 },
-{ 0x79f, 16 },{ 0x555, 16 },{ 0xf3d, 17 },{ 0xf37, 17 },
-{ 0xf3c, 17 },{ 0xf35, 17 },{ 0x1e6d, 18 },{ 0x1e68, 18 },
-{ 0x3cd8, 19 },{ 0x3cd3, 19 },{ 0x3cd9, 19 },{ 0x79a4, 20 },
-{ 0xf34ba, 25 },{ 0xf34b4, 25 },{ 0xf34b5, 25 },{ 0xf34b6, 25 },
-{ 0xf34b7, 25 },{ 0xf34b8, 25 },{ 0xf34b9, 25 },{ 0xf34bb, 25 },
-{ 0xf34bc, 25 },{ 0xf34bd, 25 },{ 0xf34be, 25 },{ 0xf34bf, 25 },
-{ 0x1e6940, 26 },{ 0x1e6941, 26 },{ 0x1e6942, 26 },{ 0x1e6943, 26 },
-{ 0x1e6944, 26 },{ 0x1e6945, 26 },{ 0x1e6946, 26 },{ 0x1e6947, 26 },
-{ 0x1e6948, 26 },{ 0x1e6949, 26 },{ 0x1e694a, 26 },{ 0x1e694b, 26 },
-{ 0x1e694c, 26 },{ 0x1e694d, 26 },{ 0x1e694e, 26 },{ 0x1e694f, 26 },
-{ 0x1e6950, 26 },{ 0x1e6951, 26 },{ 0x1e6952, 26 },{ 0x1e6953, 26 },
-{ 0x1e6954, 26 },{ 0x1e6955, 26 },{ 0x1e6956, 26 },{ 0x1e6957, 26 },
-{ 0x1e6958, 26 },{ 0x1e6959, 26 },{ 0x1e695a, 26 },{ 0x1e695b, 26 },
-{ 0x1e695c, 26 },{ 0x1e695d, 26 },{ 0x1e695e, 26 },{ 0x1e695f, 26 },
-{ 0x1e6960, 26 },{ 0x1e6961, 26 },{ 0x1e6962, 26 },{ 0x1e6963, 26 },
-{ 0x1e6964, 26 },{ 0x1e6965, 26 },{ 0x1e6966, 26 },{ 0x1e6967, 26 },
-};
-
-const uint32_t ff_table1_dc_chroma[120][2] = {
-{ 0x0, 2 },{ 0x1, 2 },{ 0x4, 3 },{ 0x7, 3 },
-{ 0xb, 4 },{ 0xd, 4 },{ 0x15, 5 },{ 0x28, 6 },
-{ 0x30, 6 },{ 0x32, 6 },{ 0x52, 7 },{ 0x62, 7 },
-{ 0x66, 7 },{ 0xa6, 8 },{ 0xc6, 8 },{ 0xcf, 8 },
-{ 0x14f, 9 },{ 0x18e, 9 },{ 0x19c, 9 },{ 0x29d, 10 },
-{ 0x33a, 10 },{ 0x538, 11 },{ 0x63c, 11 },{ 0x63e, 11 },
-{ 0x63f, 11 },{ 0x676, 11 },{ 0xa73, 12 },{ 0xc7a, 12 },
-{ 0xcef, 12 },{ 0x14e5, 13 },{ 0x19dd, 13 },{ 0x29c8, 14 },
-{ 0x29c9, 14 },{ 0x63dd, 15 },{ 0x33b8, 14 },{ 0x33b9, 14 },
-{ 0xc7b6, 16 },{ 0x63d8, 15 },{ 0x63df, 15 },{ 0xc7b3, 16 },
-{ 0xc7b4, 16 },{ 0xc7b5, 16 },{ 0x63de, 15 },{ 0xc7b7, 16 },
-{ 0xc7b8, 16 },{ 0xc7b9, 16 },{ 0x18f65, 17 },{ 0x31ec8, 18 },
-{ 0xc7b248, 24 },{ 0xc7b249, 24 },{ 0xc7b24a, 24 },{ 0xc7b24b, 24 },
-{ 0xc7b24c, 24 },{ 0xc7b24d, 24 },{ 0xc7b24e, 24 },{ 0xc7b24f, 24 },
-{ 0xc7b250, 24 },{ 0xc7b251, 24 },{ 0xc7b252, 24 },{ 0xc7b253, 24 },
-{ 0xc7b254, 24 },{ 0xc7b255, 24 },{ 0xc7b256, 24 },{ 0xc7b257, 24 },
-{ 0xc7b258, 24 },{ 0xc7b259, 24 },{ 0xc7b25a, 24 },{ 0xc7b25b, 24 },
-{ 0xc7b25c, 24 },{ 0xc7b25d, 24 },{ 0xc7b25e, 24 },{ 0xc7b25f, 24 },
-{ 0xc7b260, 24 },{ 0xc7b261, 24 },{ 0xc7b262, 24 },{ 0xc7b263, 24 },
-{ 0xc7b264, 24 },{ 0xc7b265, 24 },{ 0xc7b266, 24 },{ 0xc7b267, 24 },
-{ 0xc7b268, 24 },{ 0xc7b269, 24 },{ 0xc7b26a, 24 },{ 0xc7b26b, 24 },
-{ 0xc7b26c, 24 },{ 0xc7b26d, 24 },{ 0xc7b26e, 24 },{ 0xc7b26f, 24 },
-{ 0xc7b270, 24 },{ 0xc7b271, 24 },{ 0xc7b272, 24 },{ 0xc7b273, 24 },
-{ 0xc7b274, 24 },{ 0xc7b275, 24 },{ 0xc7b276, 24 },{ 0xc7b277, 24 },
-{ 0xc7b278, 24 },{ 0xc7b279, 24 },{ 0xc7b27a, 24 },{ 0xc7b27b, 24 },
-{ 0xc7b27c, 24 },{ 0xc7b27d, 24 },{ 0xc7b27e, 24 },{ 0xc7b27f, 24 },
-{ 0x18f6480, 25 },{ 0x18f6481, 25 },{ 0x18f6482, 25 },{ 0x18f6483, 25 },
-{ 0x18f6484, 25 },{ 0x18f6485, 25 },{ 0x18f6486, 25 },{ 0x18f6487, 25 },
-{ 0x18f6488, 25 },{ 0x18f6489, 25 },{ 0x18f648a, 25 },{ 0x18f648b, 25 },
-{ 0x18f648c, 25 },{ 0x18f648d, 25 },{ 0x18f648e, 25 },{ 0x18f648f, 25 },
-};
-
-/* vlc table 0, for intra luma */
-
-static const uint16_t table0_vlc[133][2] = {
-{ 0x1, 2 },{ 0x6, 3 },{ 0xf, 4 },{ 0x16, 5 },
-{ 0x20, 6 },{ 0x18, 7 },{ 0x8, 8 },{ 0x9a, 8 },
-{ 0x56, 9 },{ 0x13e, 9 },{ 0xf0, 10 },{ 0x3a5, 10 },
-{ 0x77, 11 },{ 0x1ef, 11 },{ 0x9a, 12 },{ 0x5d, 13 },
-{ 0x1, 4 },{ 0x11, 5 },{ 0x2, 7 },{ 0xb, 8 },
-{ 0x12, 9 },{ 0x1d6, 9 },{ 0x27e, 10 },{ 0x191, 11 },
-{ 0xea, 12 },{ 0x3dc, 12 },{ 0x13b, 13 },{ 0x4, 5 },
-{ 0x14, 7 },{ 0x9e, 8 },{ 0x9, 10 },{ 0x1ac, 11 },
-{ 0x1e2, 11 },{ 0x3ca, 12 },{ 0x5f, 13 },{ 0x17, 5 },
-{ 0x4e, 7 },{ 0x5e, 9 },{ 0xf3, 10 },{ 0x1ad, 11 },
-{ 0xec, 12 },{ 0x5f0, 13 },{ 0xe, 6 },{ 0xe1, 8 },
-{ 0x3a4, 10 },{ 0x9c, 12 },{ 0x13d, 13 },{ 0x3b, 6 },
-{ 0x1c, 9 },{ 0x14, 11 },{ 0x9be, 12 },{ 0x6, 7 },
-{ 0x7a, 9 },{ 0x190, 11 },{ 0x137, 13 },{ 0x1b, 7 },
-{ 0x8, 10 },{ 0x75c, 11 },{ 0x71, 7 },{ 0xd7, 10 },
-{ 0x9bf, 12 },{ 0x7, 8 },{ 0xaf, 10 },{ 0x4cc, 11 },
-{ 0x34, 8 },{ 0x265, 10 },{ 0x9f, 12 },{ 0xe0, 8 },
-{ 0x16, 11 },{ 0x327, 12 },{ 0x15, 9 },{ 0x17d, 11 },
-{ 0xebb, 12 },{ 0x14, 9 },{ 0xf6, 10 },{ 0x1e4, 11 },
-{ 0xcb, 10 },{ 0x99d, 12 },{ 0xca, 10 },{ 0x2fc, 12 },
-{ 0x17f, 11 },{ 0x4cd, 11 },{ 0x2fd, 12 },{ 0x4fe, 11 },
-{ 0x13a, 13 },{ 0xa, 4 },{ 0x42, 7 },{ 0x1d3, 9 },
-{ 0x4dd, 11 },{ 0x12, 5 },{ 0xe8, 8 },{ 0x4c, 11 },
-{ 0x136, 13 },{ 0x39, 6 },{ 0x264, 10 },{ 0xeba, 12 },
-{ 0x0, 7 },{ 0xae, 10 },{ 0x99c, 12 },{ 0x1f, 7 },
-{ 0x4de, 11 },{ 0x43, 7 },{ 0x4dc, 11 },{ 0x3, 8 },
-{ 0x3cb, 12 },{ 0x6, 8 },{ 0x99e, 12 },{ 0x2a, 8 },
-{ 0x5f1, 13 },{ 0xf, 8 },{ 0x9fe, 12 },{ 0x33, 8 },
-{ 0x9ff, 12 },{ 0x98, 8 },{ 0x99f, 12 },{ 0xea, 8 },
-{ 0x13c, 13 },{ 0x2e, 8 },{ 0x192, 11 },{ 0x136, 9 },
-{ 0x6a, 9 },{ 0x15, 11 },{ 0x3af, 10 },{ 0x1e3, 11 },
-{ 0x74, 11 },{ 0xeb, 12 },{ 0x2f9, 12 },{ 0x5c, 13 },
-{ 0xed, 12 },{ 0x3dd, 12 },{ 0x326, 12 },{ 0x5e, 13 },
-{ 0x16, 7 },
-};
-
-static const int8_t table0_level[132] = {
-  1,  2,  3,  4,  5,  6,  7,  8,
-  9, 10, 11, 12, 13, 14, 15, 16,
-  1,  2,  3,  4,  5,  6,  7,  8,
-  9, 10, 11,  1,  2,  3,  4,  5,
-  6,  7,  8,  1,  2,  3,  4,  5,
-  6,  7,  1,  2,  3,  4,  5,  1,
-  2,  3,  4,  1,  2,  3,  4,  1,
-  2,  3,  1,  2,  3,  1,  2,  3,
-  1,  2,  3,  1,  2,  3,  1,  2,
-  3,  1,  2,  3,  1,  2,  1,  2,
-  1,  1,  1,  1,  1,  1,  2,  3,
-  4,  1,  2,  3,  4,  1,  2,  3,
-  1,  2,  3,  1,  2,  1,  2,  1,
-  2,  1,  2,  1,  2,  1,  2,  1,
-  2,  1,  2,  1,  2,  1,  2,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,
-};
-
-static const int8_t table0_run[132] = {
-  0,  0,  0,  0,  0,  0,  0,  0,
-  0,  0,  0,  0,  0,  0,  0,  0,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  2,  2,  2,  2,  2,
-  2,  2,  2,  3,  3,  3,  3,  3,
-  3,  3,  4,  4,  4,  4,  4,  5,
-  5,  5,  5,  6,  6,  6,  6,  7,
-  7,  7,  8,  8,  8,  9,  9,  9,
- 10, 10, 10, 11, 11, 11, 12, 12,
- 12, 13, 13, 13, 14, 14, 15, 15,
- 16, 17, 18, 19, 20,  0,  0,  0,
-  0,  1,  1,  1,  1,  2,  2,  2,
-  3,  3,  3,  4,  4,  5,  5,  6,
-  6,  7,  7,  8,  8,  9,  9, 10,
- 10, 11, 11, 12, 12, 13, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, 26,
-};
-
-/* vlc table 1, for intra chroma and P macro blocks */
-
-static const uint16_t table1_vlc[149][2] = {
-{ 0x4, 3 },{ 0x14, 5 },{ 0x17, 7 },{ 0x7f, 8 },
-{ 0x154, 9 },{ 0x1f2, 10 },{ 0xbf, 11 },{ 0x65, 12 },
-{ 0xaaa, 12 },{ 0x630, 13 },{ 0x1597, 13 },{ 0x3b7, 14 },
-{ 0x2b22, 14 },{ 0xbe6, 15 },{ 0xb, 4 },{ 0x37, 7 },
-{ 0x62, 9 },{ 0x7, 11 },{ 0x166, 12 },{ 0xce, 13 },
-{ 0x1590, 13 },{ 0x5f6, 14 },{ 0xbe7, 15 },{ 0x7, 5 },
-{ 0x6d, 8 },{ 0x3, 11 },{ 0x31f, 12 },{ 0x5f2, 14 },
-{ 0x2, 6 },{ 0x61, 9 },{ 0x55, 12 },{ 0x1df, 14 },
-{ 0x1a, 6 },{ 0x1e, 10 },{ 0xac9, 12 },{ 0x2b23, 14 },
-{ 0x1e, 6 },{ 0x1f, 10 },{ 0xac3, 12 },{ 0x2b2b, 14 },
-{ 0x6, 7 },{ 0x4, 11 },{ 0x2f8, 13 },{ 0x19, 7 },
-{ 0x6, 11 },{ 0x63d, 13 },{ 0x57, 7 },{ 0x182, 11 },
-{ 0x2aa2, 14 },{ 0x4, 8 },{ 0x180, 11 },{ 0x59c, 14 },
-{ 0x7d, 8 },{ 0x164, 12 },{ 0x76d, 15 },{ 0x2, 9 },
-{ 0x18d, 11 },{ 0x1581, 13 },{ 0xad, 8 },{ 0x60, 12 },
-{ 0xc67, 14 },{ 0x1c, 9 },{ 0xee, 13 },{ 0x3, 9 },
-{ 0x2cf, 13 },{ 0xd9, 9 },{ 0x1580, 13 },{ 0x2, 11 },
-{ 0x183, 11 },{ 0x57, 12 },{ 0x61, 12 },{ 0x31, 11 },
-{ 0x66, 12 },{ 0x631, 13 },{ 0x632, 13 },{ 0xac, 13 },
-{ 0x31d, 12 },{ 0x76, 12 },{ 0x3a, 11 },{ 0x165, 12 },
-{ 0xc66, 14 },{ 0x3, 2 },{ 0x54, 7 },{ 0x2ab, 10 },
-{ 0x16, 13 },{ 0x5f7, 14 },{ 0x5, 4 },{ 0xf8, 9 },
-{ 0xaa9, 12 },{ 0x5f, 15 },{ 0x4, 4 },{ 0x1c, 10 },
-{ 0x1550, 13 },{ 0x4, 5 },{ 0x77, 11 },{ 0x76c, 15 },
-{ 0xe, 5 },{ 0xa, 12 },{ 0xc, 5 },{ 0x562, 11 },
-{ 0x4, 6 },{ 0x31c, 12 },{ 0x6, 6 },{ 0xc8, 13 },
-{ 0xd, 6 },{ 0x1da, 13 },{ 0x7, 6 },{ 0xc9, 13 },
-{ 0x1, 7 },{ 0x2e, 14 },{ 0x14, 7 },{ 0x1596, 13 },
-{ 0xa, 7 },{ 0xac2, 12 },{ 0x16, 7 },{ 0x15b, 14 },
-{ 0x15, 7 },{ 0x15a, 14 },{ 0xf, 8 },{ 0x5e, 15 },
-{ 0x7e, 8 },{ 0xab, 8 },{ 0x2d, 9 },{ 0xd8, 9 },
-{ 0xb, 9 },{ 0x14, 10 },{ 0x2b3, 10 },{ 0x1f3, 10 },
-{ 0x3a, 10 },{ 0x0, 10 },{ 0x58, 10 },{ 0x2e, 9 },
-{ 0x5e, 10 },{ 0x563, 11 },{ 0xec, 12 },{ 0x54, 12 },
-{ 0xac1, 12 },{ 0x1556, 13 },{ 0x2fa, 13 },{ 0x181, 11 },
-{ 0x1557, 13 },{ 0x59d, 14 },{ 0x2aa3, 14 },{ 0x2b2a, 14 },
-{ 0x1de, 14 },{ 0x63c, 13 },{ 0xcf, 13 },{ 0x1594, 13 },
-{ 0xd, 9 },
-};
-
-static const int8_t table1_level[148] = {
-  1,  2,  3,  4,  5,  6,  7,  8,
-  9, 10, 11, 12, 13, 14,  1,  2,
-  3,  4,  5,  6,  7,  8,  9,  1,
-  2,  3,  4,  5,  1,  2,  3,  4,
-  1,  2,  3,  4,  1,  2,  3,  4,
-  1,  2,  3,  1,  2,  3,  1,  2,
-  3,  1,  2,  3,  1,  2,  3,  1,
-  2,  3,  1,  2,  3,  1,  2,  1,
-  2,  1,  2,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  2,  3,  4,  5,  1,  2,
-  3,  4,  1,  2,  3,  1,  2,  3,
-  1,  2,  1,  2,  1,  2,  1,  2,
-  1,  2,  1,  2,  1,  2,  1,  2,
-  1,  2,  1,  2,  1,  2,  1,  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,
-};
-
-static const int8_t table1_run[148] = {
-  0,  0,  0,  0,  0,  0,  0,  0,
-  0,  0,  0,  0,  0,  0,  1,  1,
-  1,  1,  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,  7,  7,  7,  8,  8,
-  8,  9,  9,  9, 10, 10, 10, 11,
- 11, 11, 12, 12, 12, 13, 13, 14,
- 14, 15, 15, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 27, 28,
- 29,  0,  0,  0,  0,  0,  1,  1,
-  1,  1,  2,  2,  2,  3,  3,  3,
-  4,  4,  5,  5,  6,  6,  7,  7,
-  8,  8,  9,  9, 10, 10, 11, 11,
- 12, 12, 13, 13, 14, 14, 15, 15,
- 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43,
-};
-
-/* third vlc table */
-
-static const uint16_t table2_vlc[186][2] = {
-{ 0x1, 2 },{ 0x5, 3 },{ 0xd, 4 },{ 0x12, 5 },
-{ 0xe, 6 },{ 0x15, 7 },{ 0x13, 8 },{ 0x3f, 8 },
-{ 0x4b, 9 },{ 0x11f, 9 },{ 0xb8, 10 },{ 0x3e3, 10 },
-{ 0x172, 11 },{ 0x24d, 12 },{ 0x3da, 12 },{ 0x2dd, 13 },
-{ 0x1f55, 13 },{ 0x5b9, 14 },{ 0x3eae, 14 },{ 0x0, 4 },
-{ 0x10, 5 },{ 0x8, 7 },{ 0x20, 8 },{ 0x29, 9 },
-{ 0x1f4, 9 },{ 0x233, 10 },{ 0x1e0, 11 },{ 0x12a, 12 },
-{ 0x3dd, 12 },{ 0x50a, 13 },{ 0x1f29, 13 },{ 0xa42, 14 },
-{ 0x1272, 15 },{ 0x1737, 15 },{ 0x3, 5 },{ 0x11, 7 },
-{ 0xc4, 8 },{ 0x4b, 10 },{ 0xb4, 11 },{ 0x7d4, 11 },
-{ 0x345, 12 },{ 0x2d7, 13 },{ 0x7bf, 13 },{ 0x938, 14 },
-{ 0xbbb, 14 },{ 0x95e, 15 },{ 0x13, 5 },{ 0x78, 7 },
-{ 0x69, 9 },{ 0x232, 10 },{ 0x461, 11 },{ 0x3ec, 12 },
-{ 0x520, 13 },{ 0x1f2a, 13 },{ 0x3e50, 14 },{ 0x3e51, 14 },
-{ 0x1486, 15 },{ 0xc, 6 },{ 0x24, 9 },{ 0x94, 11 },
-{ 0x8c0, 12 },{ 0xf09, 14 },{ 0x1ef0, 15 },{ 0x3d, 6 },
-{ 0x53, 9 },{ 0x1a0, 11 },{ 0x2d6, 13 },{ 0xf08, 14 },
-{ 0x13, 7 },{ 0x7c, 9 },{ 0x7c1, 11 },{ 0x4ac, 14 },
-{ 0x1b, 7 },{ 0xa0, 10 },{ 0x344, 12 },{ 0xf79, 14 },
-{ 0x79, 7 },{ 0x3e1, 10 },{ 0x2d4, 13 },{ 0x2306, 14 },
-{ 0x21, 8 },{ 0x23c, 10 },{ 0xfae, 12 },{ 0x23de, 14 },
-{ 0x35, 8 },{ 0x175, 11 },{ 0x7b3, 13 },{ 0xc5, 8 },
-{ 0x174, 11 },{ 0x785, 13 },{ 0x48, 9 },{ 0x1a3, 11 },
-{ 0x49e, 13 },{ 0x2c, 9 },{ 0xfa, 10 },{ 0x7d6, 11 },
-{ 0x92, 10 },{ 0x5cc, 13 },{ 0x1ef1, 15 },{ 0xa3, 10 },
-{ 0x3ed, 12 },{ 0x93e, 14 },{ 0x1e2, 11 },{ 0x1273, 15 },
-{ 0x7c4, 11 },{ 0x1487, 15 },{ 0x291, 12 },{ 0x293, 12 },
-{ 0xf8a, 12 },{ 0x509, 13 },{ 0x508, 13 },{ 0x78d, 13 },
-{ 0x7be, 13 },{ 0x78c, 13 },{ 0x4ae, 14 },{ 0xbba, 14 },
-{ 0x2307, 14 },{ 0xb9a, 14 },{ 0x1736, 15 },{ 0xe, 4 },
-{ 0x45, 7 },{ 0x1f3, 9 },{ 0x47a, 11 },{ 0x5dc, 13 },
-{ 0x23df, 14 },{ 0x19, 5 },{ 0x28, 9 },{ 0x176, 11 },
-{ 0x49d, 13 },{ 0x23dd, 14 },{ 0x30, 6 },{ 0xa2, 10 },
-{ 0x2ef, 12 },{ 0x5b8, 14 },{ 0x3f, 6 },{ 0xa5, 10 },
-{ 0x3db, 12 },{ 0x93f, 14 },{ 0x44, 7 },{ 0x7cb, 11 },
-{ 0x95f, 15 },{ 0x63, 7 },{ 0x3c3, 12 },{ 0x15, 8 },
-{ 0x8f6, 12 },{ 0x17, 8 },{ 0x498, 13 },{ 0x2c, 8 },
-{ 0x7b2, 13 },{ 0x2f, 8 },{ 0x1f54, 13 },{ 0x8d, 8 },
-{ 0x7bd, 13 },{ 0x8e, 8 },{ 0x1182, 13 },{ 0xfb, 8 },
-{ 0x50b, 13 },{ 0x2d, 8 },{ 0x7c0, 11 },{ 0x79, 9 },
-{ 0x1f5f, 13 },{ 0x7a, 9 },{ 0x1f56, 13 },{ 0x231, 10 },
-{ 0x3e4, 10 },{ 0x1a1, 11 },{ 0x143, 11 },{ 0x1f7, 11 },
-{ 0x16f, 12 },{ 0x292, 12 },{ 0x2e7, 12 },{ 0x16c, 12 },
-{ 0x16d, 12 },{ 0x3dc, 12 },{ 0xf8b, 12 },{ 0x499, 13 },
-{ 0x3d8, 12 },{ 0x78e, 13 },{ 0x2d5, 13 },{ 0x1f5e, 13 },
-{ 0x1f2b, 13 },{ 0x78f, 13 },{ 0x4ad, 14 },{ 0x3eaf, 14 },
-{ 0x23dc, 14 },{ 0x4a, 9 },
-};
-
-static const int8_t table2_level[185] = {
-  1,  2,  3,  4,  5,  6,  7,  8,
-  9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19,  1,  2,  3,  4,  5,
-  6,  7,  8,  9, 10, 11, 12, 13,
- 14, 15,  1,  2,  3,  4,  5,  6,
-  7,  8,  9, 10, 11, 12,  1,  2,
-  3,  4,  5,  6,  7,  8,  9, 10,
- 11,  1,  2,  3,  4,  5,  6,  1,
-  2,  3,  4,  5,  1,  2,  3,  4,
-  1,  2,  3,  4,  1,  2,  3,  4,
-  1,  2,  3,  4,  1,  2,  3,  1,
-  2,  3,  1,  2,  3,  1,  2,  3,
-  1,  2,  3,  1,  2,  3,  1,  2,
-  1,  2,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  2,  3,  4,  5,  6,  1,  2,  3,
-  4,  5,  1,  2,  3,  4,  1,  2,
-  3,  4,  1,  2,  3,  1,  2,  1,
-  2,  1,  2,  1,  2,  1,  2,  1,
-  2,  1,  2,  1,  2,  1,  2,  1,
-  2,  1,  2,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,
-};
-
-static const int8_t table2_run[185] = {
-  0,  0,  0,  0,  0,  0,  0,  0,
-  0,  0,  0,  0,  0,  0,  0,  0,
-  0,  0,  0,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  2,  2,  2,  2,  2,  2,
-  2,  2,  2,  2,  2,  2,  3,  3,
-  3,  3,  3,  3,  3,  3,  3,  3,
-  3,  4,  4,  4,  4,  4,  4,  5,
-  5,  5,  5,  5,  6,  6,  6,  6,
-  7,  7,  7,  7,  8,  8,  8,  8,
-  9,  9,  9,  9, 10, 10, 10, 11,
- 11, 11, 12, 12, 12, 13, 13, 13,
- 14, 14, 14, 15, 15, 15, 16, 16,
- 17, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30,  0,
-  0,  0,  0,  0,  0,  1,  1,  1,
-  1,  1,  2,  2,  2,  2,  3,  3,
-  3,  3,  4,  4,  4,  5,  5,  6,
-  6,  7,  7,  8,  8,  9,  9, 10,
- 10, 11, 11, 12, 12, 13, 13, 14,
- 14, 15, 15, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 27, 28,
- 29, 30, 31, 32, 33, 34, 35, 36,
- 37,
-};
-
-/* second non intra vlc table */
-static const uint16_t table4_vlc[169][2] = {
-{ 0x0, 3 },{ 0x3, 4 },{ 0xb, 5 },{ 0x14, 6 },
-{ 0x3f, 6 },{ 0x5d, 7 },{ 0xa2, 8 },{ 0xac, 9 },
-{ 0x16e, 9 },{ 0x20a, 10 },{ 0x2e2, 10 },{ 0x432, 11 },
-{ 0x5c9, 11 },{ 0x827, 12 },{ 0xb54, 12 },{ 0x4e6, 13 },
-{ 0x105f, 13 },{ 0x172a, 13 },{ 0x20b2, 14 },{ 0x2d4e, 14 },
-{ 0x39f0, 14 },{ 0x4175, 15 },{ 0x5a9e, 15 },{ 0x4, 4 },
-{ 0x1e, 5 },{ 0x42, 7 },{ 0xb6, 8 },{ 0x173, 9 },
-{ 0x395, 10 },{ 0x72e, 11 },{ 0xb94, 12 },{ 0x16a4, 13 },
-{ 0x20b3, 14 },{ 0x2e45, 14 },{ 0x5, 5 },{ 0x40, 7 },
-{ 0x49, 9 },{ 0x28f, 10 },{ 0x5cb, 11 },{ 0x48a, 13 },
-{ 0x9dd, 14 },{ 0x73e2, 15 },{ 0x18, 5 },{ 0x25, 8 },
-{ 0x8a, 10 },{ 0x51b, 11 },{ 0xe5f, 12 },{ 0x9c9, 14 },
-{ 0x139c, 15 },{ 0x29, 6 },{ 0x4f, 9 },{ 0x412, 11 },
-{ 0x48d, 13 },{ 0x2e41, 14 },{ 0x38, 6 },{ 0x10e, 9 },
-{ 0x5a8, 11 },{ 0x105c, 13 },{ 0x39f2, 14 },{ 0x58, 7 },
-{ 0x21f, 10 },{ 0xe7e, 12 },{ 0x39ff, 14 },{ 0x23, 8 },
-{ 0x2e3, 10 },{ 0x4e5, 13 },{ 0x2e40, 14 },{ 0xa1, 8 },
-{ 0x5be, 11 },{ 0x9c8, 14 },{ 0x83, 8 },{ 0x13a, 11 },
-{ 0x1721, 13 },{ 0x44, 9 },{ 0x276, 12 },{ 0x39f6, 14 },
-{ 0x8b, 10 },{ 0x4ef, 13 },{ 0x5a9b, 15 },{ 0x208, 10 },
-{ 0x1cfe, 13 },{ 0x399, 10 },{ 0x1cb4, 13 },{ 0x39e, 10 },
-{ 0x39f3, 14 },{ 0x5ab, 11 },{ 0x73e3, 15 },{ 0x737, 11 },
-{ 0x5a9f, 15 },{ 0x82d, 12 },{ 0xe69, 12 },{ 0xe68, 12 },
-{ 0x433, 11 },{ 0xb7b, 12 },{ 0x2df8, 14 },{ 0x2e56, 14 },
-{ 0x2e57, 14 },{ 0x39f7, 14 },{ 0x51a5, 15 },{ 0x3, 3 },
-{ 0x2a, 6 },{ 0xe4, 8 },{ 0x28e, 10 },{ 0x735, 11 },
-{ 0x1058, 13 },{ 0x1cfa, 13 },{ 0x2df9, 14 },{ 0x4174, 15 },
-{ 0x9, 4 },{ 0x54, 8 },{ 0x398, 10 },{ 0x48b, 13 },
-{ 0x139d, 15 },{ 0xd, 4 },{ 0xad, 9 },{ 0x826, 12 },
-{ 0x2d4c, 14 },{ 0x11, 5 },{ 0x16b, 9 },{ 0xb7f, 12 },
-{ 0x51a4, 15 },{ 0x19, 5 },{ 0x21b, 10 },{ 0x16fd, 13 },
-{ 0x1d, 5 },{ 0x394, 10 },{ 0x28d3, 14 },{ 0x2b, 6 },
-{ 0x5bc, 11 },{ 0x5a9a, 15 },{ 0x2f, 6 },{ 0x247, 12 },
-{ 0x10, 7 },{ 0xa35, 12 },{ 0x3e, 6 },{ 0xb7a, 12 },
-{ 0x59, 7 },{ 0x105e, 13 },{ 0x26, 8 },{ 0x9cf, 14 },
-{ 0x55, 8 },{ 0x1cb5, 13 },{ 0x57, 8 },{ 0xe5b, 12 },
-{ 0xa0, 8 },{ 0x1468, 13 },{ 0x170, 9 },{ 0x90, 10 },
-{ 0x1ce, 9 },{ 0x21a, 10 },{ 0x218, 10 },{ 0x168, 9 },
-{ 0x21e, 10 },{ 0x244, 12 },{ 0x736, 11 },{ 0x138, 11 },
-{ 0x519, 11 },{ 0xe5e, 12 },{ 0x72c, 11 },{ 0xb55, 12 },
-{ 0x9dc, 14 },{ 0x20bb, 14 },{ 0x48c, 13 },{ 0x1723, 13 },
-{ 0x2e44, 14 },{ 0x16a5, 13 },{ 0x518, 11 },{ 0x39fe, 14 },
-{ 0x169, 9 },
-};
-
-static const int8_t table4_level[168] = {
-  1,  2,  3,  4,  5,  6,  7,  8,
-  9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23,  1,
-  2,  3,  4,  5,  6,  7,  8,  9,
- 10, 11,  1,  2,  3,  4,  5,  6,
-  7,  8,  1,  2,  3,  4,  5,  6,
-  7,  1,  2,  3,  4,  5,  1,  2,
-  3,  4,  5,  1,  2,  3,  4,  1,
-  2,  3,  4,  1,  2,  3,  1,  2,
-  3,  1,  2,  3,  1,  2,  3,  1,
-  2,  1,  2,  1,  2,  1,  2,  1,
-  2,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  2,  3,  4,  5,
-  6,  7,  8,  9,  1,  2,  3,  4,
-  5,  1,  2,  3,  4,  1,  2,  3,
-  4,  1,  2,  3,  1,  2,  3,  1,
-  2,  3,  1,  2,  1,  2,  1,  2,
-  1,  2,  1,  2,  1,  2,  1,  2,
-  1,  2,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-};
-
-static const int8_t table4_run[168] = {
-  0,  0,  0,  0,  0,  0,  0,  0,
-  0,  0,  0,  0,  0,  0,  0,  0,
-  0,  0,  0,  0,  0,  0,  0,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  2,  2,  2,  2,  2,  2,
-  2,  2,  3,  3,  3,  3,  3,  3,
-  3,  4,  4,  4,  4,  4,  5,  5,
-  5,  5,  5,  6,  6,  6,  6,  7,
-  7,  7,  7,  8,  8,  8,  9,  9,
-  9, 10, 10, 10, 11, 11, 11, 12,
- 12, 13, 13, 14, 14, 15, 15, 16,
- 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26,  0,  0,  0,  0,  0,
-  0,  0,  0,  0,  1,  1,  1,  1,
-  1,  2,  2,  2,  2,  3,  3,  3,
-  3,  4,  4,  4,  5,  5,  5,  6,
-  6,  6,  7,  7,  8,  8,  9,  9,
- 10, 10, 11, 11, 12, 12, 13, 13,
- 14, 14, 15, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 27, 28,
- 29, 30, 31, 32, 33, 34, 35, 36,
-};
-
-extern const uint16_t inter_vlc[103][2];
-extern const int8_t inter_level[102];
-extern const int8_t inter_run[102];
-
-extern const uint16_t intra_vlc[103][2];
-extern const int8_t intra_level[102];
-extern const int8_t intra_run[102];
-
-extern const uint8_t DCtab_lum[13][2];
-extern const uint8_t DCtab_chrom[13][2];
-
-extern const uint8_t cbpy_tab[16][2];
-extern const uint8_t mvtab[33][2];
-
-extern const uint8_t intra_MCBPC_code[8];
-extern const uint8_t intra_MCBPC_bits[8];
-
-extern const uint8_t inter_MCBPC_code[25];
-extern const uint8_t inter_MCBPC_bits[25];
-
-#define NB_RL_TABLES  6
-
-static RLTable rl_table[NB_RL_TABLES] = {
-    /* intra luminance tables */
-    {
-        132,
-        85,
-        table0_vlc,
-        table0_run,
-        table0_level,
-    },
-    {
-        185,
-        119,
-        table2_vlc,
-        table2_run,
-        table2_level,
-    },
-    {
-        102,
-        67,
-        intra_vlc,
-        intra_run,
-        intra_level,
-    },
-    /* intra chrominance / non intra tables */
-    {
-        148,
-        81,
-        table1_vlc,
-        table1_run,
-        table1_level,
-    },
-    {
-        168,
-        99,
-        table4_vlc,
-        table4_run,
-        table4_level,
-    },
-    {
-        102,
-        58,
-        inter_vlc,
-        inter_run,
-        inter_level,
-    },
-};
-
-/* motion vector table 0 */
-
-static const uint16_t table0_mv_code[1100] = {
- 0x0001, 0x0003, 0x0005, 0x0007, 0x0003, 0x0008, 0x000c, 0x0001,
- 0x0002, 0x001b, 0x0006, 0x000b, 0x0015, 0x0002, 0x000e, 0x000f,
- 0x0014, 0x0020, 0x0022, 0x0025, 0x0027, 0x0029, 0x002d, 0x004b,
- 0x004d, 0x0003, 0x0022, 0x0023, 0x0025, 0x0027, 0x0042, 0x0048,
- 0x0049, 0x0050, 0x005c, 0x0091, 0x009f, 0x000e, 0x0043, 0x004c,
- 0x0054, 0x0056, 0x008c, 0x0098, 0x009a, 0x009b, 0x00b1, 0x00b2,
- 0x0120, 0x0121, 0x0126, 0x0133, 0x0139, 0x01a1, 0x01a4, 0x01a5,
- 0x01a6, 0x01a7, 0x01ae, 0x01af, 0x000b, 0x0019, 0x0085, 0x0090,
- 0x009b, 0x00aa, 0x00af, 0x010c, 0x010e, 0x011c, 0x011e, 0x0133,
- 0x0144, 0x0160, 0x0174, 0x0175, 0x0177, 0x0178, 0x0249, 0x024b,
- 0x0252, 0x0261, 0x0265, 0x0270, 0x0352, 0x0353, 0x0355, 0x0359,
- 0x0010, 0x0011, 0x0013, 0x0034, 0x0035, 0x0036, 0x0037, 0x003d,
- 0x003e, 0x0109, 0x0126, 0x0156, 0x021a, 0x021e, 0x023a, 0x023e,
- 0x028e, 0x028f, 0x02cf, 0x0491, 0x0494, 0x049f, 0x04a0, 0x04a3,
- 0x04a6, 0x04a7, 0x04ad, 0x04ae, 0x04c0, 0x04c4, 0x04c6, 0x04c8,
- 0x04c9, 0x04f5, 0x04f6, 0x04f7, 0x0680, 0x0682, 0x0683, 0x0688,
- 0x0689, 0x068d, 0x068e, 0x068f, 0x06a2, 0x06a3, 0x06a9, 0x06b0,
- 0x06b1, 0x06b4, 0x06b5, 0x0024, 0x0060, 0x0063, 0x0078, 0x0079,
- 0x0211, 0x0244, 0x0245, 0x0247, 0x0248, 0x0249, 0x024a, 0x024b,
- 0x026b, 0x02af, 0x02b8, 0x02bb, 0x0436, 0x0476, 0x0477, 0x047e,
- 0x04c8, 0x04c9, 0x04ca, 0x0514, 0x0586, 0x0587, 0x0598, 0x059d,
- 0x05d9, 0x05da, 0x0920, 0x0921, 0x093b, 0x093c, 0x093d, 0x0942,
- 0x0943, 0x0944, 0x0945, 0x0959, 0x095e, 0x095f, 0x0982, 0x0983,
- 0x098e, 0x098f, 0x09c4, 0x09e7, 0x09e8, 0x09e9, 0x0d02, 0x0d17,
- 0x0d18, 0x0d19, 0x0d41, 0x0d42, 0x0d43, 0x0d50, 0x0d5f, 0x0d6d,
- 0x0d6e, 0x0d6f, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
- 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x041e, 0x041f, 0x0420, 0x0421,
- 0x048c, 0x048d, 0x04d3, 0x04d4, 0x04d5, 0x055c, 0x055d, 0x0572,
- 0x0573, 0x0574, 0x0575, 0x08de, 0x08df, 0x08fe, 0x08ff, 0x0996,
- 0x0a36, 0x0a37, 0x0b08, 0x0b09, 0x0b0a, 0x0b0b, 0x0b32, 0x0b33,
- 0x0b34, 0x0b35, 0x0b36, 0x0b37, 0x0b38, 0x0b39, 0x0bb0, 0x0bf7,
- 0x0bf8, 0x0bf9, 0x0bfa, 0x0bfb, 0x0bfc, 0x0bfd, 0x0bfe, 0x0bff,
- 0x1254, 0x1255, 0x1256, 0x1257, 0x1270, 0x1271, 0x1272, 0x1273,
- 0x1274, 0x1275, 0x12ab, 0x12ac, 0x12ad, 0x12ae, 0x12af, 0x12b0,
- 0x12b1, 0x1315, 0x1316, 0x1317, 0x13bf, 0x13c0, 0x13c1, 0x13c2,
- 0x13c3, 0x13c4, 0x13c5, 0x13c6, 0x13c7, 0x13c8, 0x13c9, 0x13ca,
- 0x13cb, 0x13cc, 0x13cd, 0x1a06, 0x1a07, 0x1a28, 0x1a29, 0x1a2a,
- 0x1a2b, 0x1a2c, 0x1a2d, 0x1a80, 0x1abb, 0x1abc, 0x1abd, 0x1ad8,
- 0x1ad9, 0x0094, 0x0095, 0x0096, 0x0097, 0x00a0, 0x00a1, 0x00a2,
- 0x00a3, 0x0831, 0x0832, 0x0833, 0x0834, 0x0835, 0x0836, 0x0837,
- 0x0838, 0x0839, 0x083a, 0x083b, 0x0939, 0x093a, 0x093b, 0x093c,
- 0x093d, 0x093e, 0x093f, 0x09a0, 0x09a1, 0x09a2, 0x09a3, 0x09a4,
- 0x09a5, 0x11ac, 0x11ad, 0x11ae, 0x11af, 0x11b0, 0x11b1, 0x11b2,
- 0x11b3, 0x11b4, 0x11b5, 0x11b6, 0x11b7, 0x11b8, 0x11b9, 0x11ba,
- 0x11bb, 0x132f, 0x1454, 0x1455, 0x1456, 0x1457, 0x1458, 0x1459,
- 0x145a, 0x145b, 0x145c, 0x145d, 0x145e, 0x145f, 0x1460, 0x1461,
- 0x1462, 0x1463, 0x1464, 0x1465, 0x1466, 0x1467, 0x1468, 0x1469,
- 0x146a, 0x146b, 0x17de, 0x17df, 0x17e0, 0x17e1, 0x17e2, 0x17e3,
- 0x17e4, 0x17e5, 0x17e6, 0x17e7, 0x17e8, 0x17e9, 0x17ea, 0x17eb,
- 0x17ec, 0x17ed, 0x2540, 0x2541, 0x2542, 0x2543, 0x2544, 0x2545,
- 0x2546, 0x2547, 0x2548, 0x2549, 0x254a, 0x254b, 0x254c, 0x254d,
- 0x254e, 0x254f, 0x2550, 0x2551, 0x2552, 0x2553, 0x2554, 0x2555,
- 0x2628, 0x2766, 0x2767, 0x2768, 0x2769, 0x276a, 0x276b, 0x276c,
- 0x276d, 0x276e, 0x276f, 0x2770, 0x2771, 0x2772, 0x2773, 0x2774,
- 0x2775, 0x2776, 0x2777, 0x2778, 0x2779, 0x277a, 0x277b, 0x277c,
- 0x277d, 0x3503, 0x3544, 0x3545, 0x3546, 0x3547, 0x3560, 0x3561,
- 0x3562, 0x3563, 0x3564, 0x3565, 0x3566, 0x3567, 0x3568, 0x3569,
- 0x356a, 0x356b, 0x356c, 0x356d, 0x356e, 0x356f, 0x3570, 0x3571,
- 0x3572, 0x3573, 0x3574, 0x3575, 0x03f0, 0x103d, 0x103e, 0x103f,
- 0x1040, 0x1041, 0x1042, 0x1043, 0x1044, 0x1045, 0x1046, 0x1047,
- 0x1048, 0x1049, 0x104a, 0x104b, 0x104c, 0x104d, 0x104e, 0x104f,
- 0x1050, 0x1051, 0x1052, 0x1053, 0x1054, 0x1055, 0x1056, 0x1057,
- 0x1058, 0x1059, 0x105a, 0x105b, 0x105c, 0x105d, 0x105e, 0x105f,
- 0x1060, 0x1061, 0x1270, 0x1271, 0x21b8, 0x21b9, 0x21ba, 0x21bb,
- 0x21bc, 0x21bd, 0x21be, 0x21bf, 0x21f0, 0x21f1, 0x21f2, 0x21f3,
- 0x21f4, 0x21f5, 0x21f6, 0x21f7, 0x21f8, 0x21f9, 0x21fa, 0x21fb,
- 0x21fc, 0x21fd, 0x21fe, 0x21ff, 0x2340, 0x2341, 0x2342, 0x2343,
- 0x2344, 0x2345, 0x2346, 0x2347, 0x2348, 0x2349, 0x234a, 0x234b,
- 0x234c, 0x234d, 0x234e, 0x234f, 0x2350, 0x2351, 0x2352, 0x2353,
- 0x2354, 0x2355, 0x2356, 0x2357, 0x265c, 0x2f88, 0x2f89, 0x2f8a,
- 0x2f8b, 0x2f8c, 0x2f8d, 0x2f8e, 0x2f8f, 0x2f90, 0x2f91, 0x2f92,
- 0x2f93, 0x2f94, 0x2f95, 0x2f96, 0x2f97, 0x2f98, 0x2f99, 0x2f9a,
- 0x2f9b, 0x2f9c, 0x2f9d, 0x2f9e, 0x2f9f, 0x2fa0, 0x2fa1, 0x2fa2,
- 0x2fa3, 0x2fa4, 0x2fa5, 0x2fa6, 0x2fa7, 0x2fa8, 0x2fa9, 0x2faa,
- 0x2fab, 0x2fac, 0x2fad, 0x2fae, 0x2faf, 0x2fb0, 0x2fb1, 0x2fb2,
- 0x2fb3, 0x2fb4, 0x2fb5, 0x2fb6, 0x2fb7, 0x2fb8, 0x2fb9, 0x2fba,
- 0x2fbb, 0x4c52, 0x4c53, 0x4e28, 0x4e29, 0x4e2a, 0x4e2b, 0x4e2c,
- 0x4e2d, 0x4e2e, 0x4e2f, 0x4e30, 0x4e31, 0x4e32, 0x4e33, 0x4e34,
- 0x4e35, 0x4e36, 0x4e37, 0x4e38, 0x4e39, 0x4e3a, 0x4e3b, 0x4e3c,
- 0x4e3d, 0x4e3e, 0x4e3f, 0x4e80, 0x4e81, 0x4e82, 0x4e83, 0x4e84,
- 0x4e85, 0x4e86, 0x4e87, 0x4e88, 0x4e89, 0x4e8a, 0x4e8b, 0x4e8c,
- 0x4e8d, 0x4e8e, 0x4e8f, 0x4e90, 0x4e91, 0x4e92, 0x4e93, 0x4e94,
- 0x4e95, 0x4e96, 0x4e97, 0x4e98, 0x4e99, 0x4e9a, 0x4e9b, 0x4e9c,
- 0x4e9d, 0x4e9e, 0x4e9f, 0x4ea0, 0x4ea1, 0x4ea2, 0x4ea3, 0x4ea4,
- 0x4ea5, 0x4ea6, 0x4ea7, 0x4ea8, 0x4ea9, 0x4eaa, 0x4eab, 0x4eac,
- 0x4ead, 0x4eae, 0x4eaf, 0x4eb0, 0x4eb1, 0x4eb2, 0x4eb3, 0x4eb4,
- 0x4eb5, 0x4eb6, 0x4eb7, 0x4eb8, 0x4eb9, 0x4eba, 0x4ebb, 0x4ebc,
- 0x4ebd, 0x4ebe, 0x4ebf, 0x4ec0, 0x4ec1, 0x4ec2, 0x4ec3, 0x4ec4,
- 0x4ec5, 0x4ec6, 0x4ec7, 0x4ec8, 0x4ec9, 0x4eca, 0x4ecb, 0x6a04,
- 0x6a05, 0x07e2, 0x07e3, 0x07e4, 0x07e5, 0x07e6, 0x07e7, 0x07e8,
- 0x07e9, 0x07ea, 0x07eb, 0x07ec, 0x07ed, 0x07ee, 0x07ef, 0x07f0,
- 0x07f1, 0x07f2, 0x07f3, 0x07f4, 0x07f5, 0x07f6, 0x07f7, 0x07f8,
- 0x07f9, 0x07fa, 0x07fb, 0x07fc, 0x07fd, 0x07fe, 0x07ff, 0x2000,
- 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008,
- 0x2009, 0x200a, 0x200b, 0x200c, 0x200d, 0x200e, 0x200f, 0x2010,
- 0x2011, 0x2012, 0x2013, 0x2014, 0x2015, 0x2016, 0x2017, 0x2018,
- 0x2019, 0x201a, 0x201b, 0x201c, 0x201d, 0x201e, 0x201f, 0x2020,
- 0x2021, 0x2022, 0x2023, 0x2024, 0x2025, 0x2026, 0x2027, 0x2028,
- 0x2029, 0x202a, 0x202b, 0x202c, 0x202d, 0x202e, 0x202f, 0x2030,
- 0x2031, 0x2032, 0x2033, 0x2034, 0x2035, 0x2036, 0x2037, 0x2038,
- 0x2039, 0x203a, 0x203b, 0x203c, 0x203d, 0x203e, 0x203f, 0x2040,
- 0x2041, 0x2042, 0x2043, 0x2044, 0x2045, 0x2046, 0x2047, 0x2048,
- 0x2049, 0x204a, 0x204b, 0x204c, 0x204d, 0x204e, 0x204f, 0x2050,
- 0x2051, 0x2052, 0x2053, 0x2054, 0x2055, 0x2056, 0x2057, 0x2058,
- 0x2059, 0x205a, 0x205b, 0x205c, 0x205d, 0x205e, 0x205f, 0x2060,
- 0x2061, 0x2062, 0x2063, 0x2064, 0x2065, 0x2066, 0x2067, 0x2068,
- 0x2069, 0x206a, 0x206b, 0x206c, 0x206d, 0x206e, 0x206f, 0x2070,
- 0x2071, 0x2072, 0x2073, 0x2074, 0x2075, 0x2076, 0x2077, 0x2078,
- 0x2079, 0x4cba, 0x4cbb, 0x5d88, 0x5d89, 0x5d8a, 0x5d8b, 0x5d8c,
- 0x5d8d, 0x5d8e, 0x5d8f, 0x5db0, 0x5db1, 0x5db2, 0x5db3, 0x5db4,
- 0x5db5, 0x5db6, 0x5db7, 0x5db8, 0x5db9, 0x5dba, 0x5dbb, 0x5dbc,
- 0x5dbd, 0x5dbe, 0x5dbf, 0x5e40, 0x5e41, 0x5e42, 0x5e43, 0x5e44,
- 0x5e45, 0x5e46, 0x5e47, 0x5e48, 0x5e49, 0x5e4a, 0x5e4b, 0x5e4c,
- 0x5e4d, 0x5e4e, 0x5e4f, 0x5e50, 0x5e51, 0x5e52, 0x5e53, 0x5e54,
- 0x5e55, 0x5e56, 0x5e57, 0x5e58, 0x5e59, 0x5e5a, 0x5e5b, 0x5e5c,
- 0x5e5d, 0x5e5e, 0x5e5f, 0x5e60, 0x5e61, 0x5e62, 0x5e63, 0x5e64,
- 0x5e65, 0x5e66, 0x5e67, 0x5e68, 0x5e69, 0x5e6a, 0x5e6b, 0x5e6c,
- 0x5e6d, 0x5e6e, 0x5e6f, 0x5e70, 0x5e71, 0x5e72, 0x5e73, 0x5e74,
- 0x5e75, 0x5e76, 0x5e77, 0x5e78, 0x5e79, 0x5e7a, 0x5e7b, 0x5e7c,
- 0x5e7d, 0x5e7e, 0x5e7f, 0x5e80, 0x5e81, 0x5e82, 0x5e83, 0x5e84,
- 0x5e85, 0x5e86, 0x5e87, 0x5e88, 0x5e89, 0x5e8a, 0x5e8b, 0x5e8c,
- 0x5e8d, 0x5e8e, 0x5e8f, 0x5e90, 0x5e91, 0x5e92, 0x5e93, 0x5e94,
- 0x5e95, 0x5e96, 0x5e97, 0x5e98, 0x5e99, 0x5e9a, 0x5e9b, 0x5e9c,
- 0x5e9d, 0x5e9e, 0x5e9f, 0x5ea0, 0x5ea1, 0x5ea2, 0x5ea3, 0x5ea4,
- 0x5ea5, 0x5ea6, 0x5ea7, 0x5ea8, 0x5ea9, 0x5eaa, 0x5eab, 0x5eac,
- 0x5ead, 0x5eae, 0x5eaf, 0x5eb0, 0x5eb1, 0x5eb2, 0x5eb3, 0x5eb4,
- 0x5eb5, 0x5eb6, 0x5eb7, 0x5eb8, 0x5eb9, 0x5eba, 0x5ebb, 0x5ebc,
- 0x5ebd, 0x5ebe, 0x5ebf, 0x5ec0, 0x5ec1, 0x5ec2, 0x5ec3, 0x5ec4,
- 0x5ec5, 0x5ec6, 0x5ec7, 0x5ec8, 0x5ec9, 0x5eca, 0x5ecb, 0x5ecc,
- 0x5ecd, 0x5ece, 0x5ecf, 0x5ed0, 0x5ed1, 0x5ed2, 0x5ed3, 0x5ed4,
- 0x5ed5, 0x5ed6, 0x5ed7, 0x5ed8, 0x5ed9, 0x5eda, 0x5edb, 0x5edc,
- 0x5edd, 0x5ede, 0x5edf, 0x5ee0, 0x5ee1, 0x5ee2, 0x5ee3, 0x5ee4,
- 0x5ee5, 0x5ee6, 0x5ee7, 0x5ee8, 0x5ee9, 0x5eea, 0x5eeb, 0x5eec,
- 0x5eed, 0x5eee, 0x5eef, 0x5ef0, 0x5ef1, 0x5ef2, 0x5ef3, 0x5ef4,
- 0x5ef5, 0x5ef6, 0x5ef7, 0x5ef8, 0x5ef9, 0x5efa, 0x5efb, 0x5efc,
- 0x5efd, 0x5efe, 0x5eff, 0x5f00, 0x5f01, 0x5f02, 0x5f03, 0x5f04,
- 0x5f05, 0x5f06, 0x5f07, 0x5f08, 0x5f09, 0x5f0a, 0x5f0b, 0x5f0c,
- 0x5f0d, 0x5f0e, 0x5f0f, 0x0000,
-};
-
-static const uint8_t table0_mv_bits[1100] = {
-  1,  4,  4,  4,  5,  5,  5,  6,
-  6,  6,  7,  7,  7,  8,  8,  8,
-  8,  8,  8,  8,  8,  8,  8,  8,
-  8,  9,  9,  9,  9,  9,  9,  9,
-  9,  9,  9,  9,  9, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 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, 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, 14, 14,
- 14, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17,  8,
-};
-
-static const uint8_t table0_mvx[1099] = {
- 32, 32, 31, 32, 33, 31, 33, 31,
- 33, 32, 34, 32, 30, 32, 31, 34,
- 35, 32, 34, 33, 29, 33, 30, 30,
- 31, 31, 35, 29, 33, 35, 33, 34,
- 31, 29, 30, 34, 30, 36, 28, 32,
- 34, 37, 30, 27, 32, 25, 39, 32,
- 34, 32, 35, 35, 35, 31, 35, 29,
- 32, 29, 30, 29, 37, 27, 36, 38,
- 37, 33, 32, 31, 29, 31, 28, 36,
- 33, 30, 34, 33, 33, 28, 27, 25,
- 31, 26, 39, 32, 32, 31, 33, 39,
- 31, 38, 28, 36, 21, 23, 43, 36,
- 34, 41, 30, 25, 28, 31, 30, 34,
- 38, 35, 61, 34, 28, 30, 37, 37,
- 35, 27, 36,  3, 59, 38, 37, 32,
- 31, 29, 26, 33, 37, 33, 27, 27,
- 35, 34, 34, 40, 42, 33, 32, 29,
-  4,  5, 28, 24, 25, 35, 39, 38,
- 32, 23, 27, 32, 30, 35, 26, 34,
- 60, 36, 29, 22, 26, 41,  7, 30,
- 38, 30, 36, 29, 30, 41, 26, 25,
- 32, 34, 24, 39,  1, 25, 39, 32,
- 28, 29, 32, 38, 26, 36, 28, 63,
- 28, 39, 23, 21, 26, 35, 31, 35,
- 57, 31, 29, 29, 28, 30, 27, 35,
-  2, 38, 40, 34, 37, 29, 38, 43,
- 26, 32, 33, 42, 24, 40, 28, 32,
- 32, 32, 36, 32, 43, 25, 21, 31,
- 30, 31, 41, 29, 33, 37, 26, 37,
- 27, 59, 23, 33, 35, 31, 31, 37,
- 38, 39, 32, 23, 32, 27, 37, 36,
- 31, 40, 25, 27, 38, 31, 36, 28,
- 31, 36, 25, 45,  3, 34, 38, 39,
- 40, 38, 30, 32, 19, 24, 25, 26,
- 45, 20, 24, 33, 33, 31, 41, 34,
- 39, 47, 40, 58, 59, 41, 33,  3,
- 17, 61, 42, 30, 26, 29, 36, 61,
- 33, 37, 62, 28, 25, 38, 25, 38,
- 17, 23, 34, 33, 21, 33, 49, 27,
- 32, 23, 27, 22, 24, 22, 39, 43,
- 27, 37,  6, 42, 47, 26, 30, 31,
- 41, 39, 33, 22, 45, 36, 32, 45,
- 19, 22, 30,  5,  5, 17, 29, 22,
- 31, 31, 43, 37, 27, 32, 32, 32,
- 33, 34, 43, 35, 29, 26, 22, 32,
- 19, 32, 25, 31, 41, 49, 28, 34,
- 28, 39, 34, 19, 37, 38, 29, 21,
- 36, 42, 24, 48, 16, 28, 49, 22,
- 34, 31, 38, 39, 44, 11, 35, 30,
- 33, 33, 23, 28, 33, 46, 15, 13,
- 24, 41, 24, 34, 34, 30, 26, 24,
- 14, 60, 21, 29, 39, 23, 35, 37,
- 63, 45, 33, 34, 47, 41, 22, 42,
- 35, 35, 23, 32, 35, 43, 32,  7,
- 31, 41, 20, 31, 16, 13, 63, 25,
- 30, 32, 35, 30, 30, 31, 42, 47,
- 39, 38, 40, 40, 51, 55, 56, 18,
- 21, 39, 39, 33, 17, 41, 23, 24,
- 43, 25, 31, 20, 19, 45,  1, 34,
- 31, 22, 35, 15, 46, 46, 35, 31,
- 28, 29, 29, 23, 41, 27, 14, 53,
- 53, 27, 24, 32, 57, 32, 17, 42,
- 37, 29, 33,  1, 25, 32, 32, 63,
- 26, 40, 44, 36, 31, 39, 20, 20,
- 44, 23, 33, 34, 35, 33, 33, 28,
- 41, 23, 41, 41, 29, 25, 26, 49,
- 29, 24, 37, 49, 50, 51, 51, 26,
- 39, 25, 26, 15, 39, 18, 42, 17,
-  4, 31, 32, 32, 60,  1, 42, 32,
-  0, 12, 19, 35, 21, 41, 17, 26,
- 20, 45, 46, 32, 37, 22, 47, 29,
- 31, 27, 29, 30, 21, 33, 35, 18,
- 25, 33, 50, 51, 42,  2, 15, 51,
- 53, 33, 25, 29, 55, 37, 38, 33,
- 38, 59, 38, 33, 39, 13, 32, 40,
- 61, 61, 32,  9, 44,  3, 31, 29,
- 25, 31, 27, 23,  9, 25,  9, 29,
- 20, 30, 30, 42, 18, 28, 25, 28,
- 28, 21, 29, 43, 29, 43, 26, 44,
- 44, 21, 38, 21, 24, 45, 45, 35,
- 39, 22, 35, 36, 34, 34, 45, 34,
- 29, 31, 46, 25, 46, 16, 17, 31,
- 20, 32, 47, 47, 47, 32, 49, 49,
- 49, 31,  1, 27, 28, 39, 39, 21,
- 36, 23, 51,  2, 40, 51, 32, 53,
- 24, 30, 24, 30, 21, 40, 57, 57,
- 31, 41, 58, 32, 12,  4, 32, 34,
- 59, 31, 32, 13,  9, 35, 26, 35,
- 37, 61, 37, 63, 26, 29, 41, 38,
- 23, 20, 41, 26, 41, 42, 42, 42,
- 26, 26, 26, 26,  1, 26, 37, 37,
- 37, 23, 34, 42, 27, 43, 34, 27,
- 31, 24, 33, 16,  3, 31, 24, 33,
- 24,  4, 44, 44, 11, 44, 31, 13,
- 13, 44, 45, 13, 25, 22, 38, 26,
- 38, 38, 39, 32, 30, 39, 30, 22,
- 32, 26, 30, 47, 47, 47, 19, 47,
- 30, 31, 35,  8, 23, 47, 47, 27,
- 35, 47, 31, 48, 35, 19, 36, 49,
- 49, 33, 31, 39, 27, 39, 49, 49,
- 50, 50, 50, 39, 31, 51, 51, 39,
- 28, 33, 33, 21, 40, 31, 52, 53,
- 40, 53,  9, 33, 31, 53, 54, 54,
- 54, 55, 55, 34, 15, 56, 25, 56,
- 21, 21, 40, 40, 25, 40, 58, 36,
-  5, 41, 41, 12, 60, 41, 41, 37,
- 22, 61, 18, 29, 29, 30, 61, 30,
- 61, 62, 62, 30, 30, 63, 18, 13,
- 30, 23, 19, 20, 20, 41, 13,  2,
-  5,  5,  1,  5, 32,  6, 32, 35,
- 20, 35, 27, 35, 35, 36, 36, 13,
- 36, 41, 41, 41,  3, 30, 42, 27,
- 20, 30, 27, 28, 30, 21, 33, 33,
- 14, 24, 30, 42, 24, 33, 25, 42,
- 43, 14, 43, 43, 14, 43,  7, 36,
- 37, 37, 37, 37,  7, 14, 25, 43,
- 43, 44, 15, 37,  7,  7,  3,  1,
-  8, 15, 15,  8, 44, 44, 44, 45,
- 45, 45, 45,  8,  8, 45, 21, 45,
- 28, 28, 28, 21, 28, 28, 22, 37,
- 46, 46, 37,  8, 29, 37, 29, 22,
- 46, 37, 22, 29, 47, 47, 38, 38,
- 16, 38, 38, 33, 38, 22, 47, 47,
- 29, 25, 16,  0, 48,  1, 34, 48,
- 48, 34, 25, 26, 26, 49, 49, 26,
-  1, 49,  4, 26,  4, 49,  1,  9,
- 49, 49, 49, 10, 49, 17, 38, 17,
- 17, 50, 38, 50, 50, 22, 38, 51,
- 38, 38, 51, 39, 39, 18, 22, 39,
- 51, 22, 52, 52, 52, 39, 53, 53,
- 10, 23, 18, 29, 10, 53, 29, 54,
- 11, 54, 11, 11, 55,  1, 18, 55,
- 55, 55, 55, 55, 55, 29, 34, 18,
- 29, 56, 56, 34, 57, 34, 34, 29,
- 29, 57, 57, 35, 35, 35, 35, 35,
- 39, 35, 59, 59, 18, 59, 39, 30,
- 18, 40, 60, 60, 61, 30, 18, 61,
- 61, 19, 19,
-};
-
-static const uint8_t table0_mvy[1099] = {
- 32, 31, 32, 33, 32, 31, 31, 33,
- 33, 34, 32, 30, 32, 35, 34, 31,
- 32, 29, 33, 30, 32, 34, 33, 31,
- 30, 35, 31, 31, 29, 33, 35, 30,
- 29, 33, 34, 34, 30, 32, 32, 36,
- 29, 32, 35, 32, 28, 32, 32, 27,
- 35, 37, 34, 29, 30, 36, 35, 34,
- 25, 30, 29, 35, 33, 31, 31, 32,
- 31, 28, 39, 28, 29, 37, 31, 33,
- 27, 36, 28, 36, 37, 33, 33, 31,
- 27, 32, 31, 38, 26, 25, 25, 33,
- 39, 31, 34, 30, 32, 32, 32, 34,
- 36, 32, 28, 33, 30, 38, 37, 27,
- 33, 28, 32, 37, 35, 38, 29, 34,
- 27, 29, 29, 32, 32, 34, 35,  3,
- 26, 36, 31, 38, 30, 26, 35, 34,
- 37, 26, 25, 32, 32, 39, 23, 37,
- 32, 32, 29, 32, 29, 36, 29, 30,
- 41, 31, 30, 21, 39, 25, 34, 38,
- 32, 35, 39, 32, 33, 33, 32, 27,
- 29, 25, 28, 27, 26, 31, 30, 35,
- 24, 24, 31, 34, 32, 30, 35, 40,
- 28, 38,  5, 35, 29, 36, 36, 32,
- 38, 30, 33, 31, 35, 26, 23, 38,
- 32, 41, 28, 25, 37, 40, 37, 39,
- 32, 36, 33, 39, 25, 26, 28, 31,
- 28, 42, 23, 31, 33, 31, 39,  1,
- 59, 22, 27,  4, 33, 34, 33, 24,
- 41,  3, 35, 41, 41, 28, 36, 36,
- 28, 33, 35, 21, 23, 21, 22, 37,
- 27, 27, 43, 29, 60, 39, 27, 25,
- 59, 34, 27, 27, 26, 40, 37, 27,
- 61, 26, 39, 33, 31, 22, 37, 25,
- 30, 25, 24, 61, 31, 34, 25, 38,
- 32, 32, 30,  3, 61, 43, 29, 23,
- 28, 32, 28, 32, 31, 34,  5, 33,
- 32, 33, 33, 42, 37, 23, 38, 31,
- 40, 26, 32, 26, 37, 38, 36, 24,
- 29, 30, 20, 22, 29, 24, 32, 41,
-  2, 34, 25, 33, 29, 31, 39, 35,
- 36, 24, 32, 30, 33, 27, 44, 60,
- 30, 36, 19, 34, 31, 24, 16, 35,
- 32, 38, 21, 33, 31, 31, 21, 35,
-  5, 17, 29, 38, 38, 18, 58, 19,
- 43, 41, 30, 41, 43, 39, 29,  7,
- 29, 17, 28, 19, 28, 31, 25, 19,
- 40, 26, 21, 33, 39, 23, 40, 30,
- 39, 34, 35, 32, 32, 24, 33, 30,
- 40, 47, 39, 37, 32, 33, 24, 23,
- 45, 47, 27, 23, 42, 32, 32, 33,
- 36, 37, 37, 17, 18, 22, 40, 38,
- 32, 31, 35, 24, 17, 25, 17, 23,
- 33, 34, 51, 42, 31, 36, 36, 29,
- 21, 22, 37, 44, 43, 25, 47, 33,
- 45, 27, 31, 58, 31, 32, 31, 38,
- 43, 20, 47, 45, 54,  1, 26, 34,
- 38, 14, 22, 24, 33, 34, 32, 32,
- 37, 21, 23, 49, 35, 23, 28, 39,
- 39, 23, 55, 33, 30, 30, 63, 16,
- 42, 28, 13, 33, 33, 35, 19, 46,
- 43, 17, 19, 36, 39, 24, 31, 32,
- 33, 26, 28, 62, 33, 63, 33, 39,
- 19, 49, 17, 31, 43, 13, 15, 29,
- 25, 35, 33, 23, 49, 41, 28, 29,
- 34, 38,  7, 61, 11, 50, 13, 41,
- 19, 47, 25, 26, 15, 42, 41, 29,
- 45, 27, 17, 35, 32, 29, 32, 24,
- 13, 26, 26, 31, 24, 33, 28, 30,
- 31, 11, 45, 46, 33, 33, 35, 57,
- 32, 32, 35, 45, 34, 11, 37, 42,
- 39, 37, 31, 49, 21, 27, 29, 47,
- 53, 40, 51, 16, 26,  1, 40, 30,
- 41, 44, 34, 25, 27, 31, 35, 35,
- 31, 15, 49,  1, 35, 40,  5, 58,
- 21, 29, 22, 59, 45, 31,  9, 26,
-  9, 29, 11, 32, 30,  3, 13, 20,
- 18, 20, 11,  3, 29, 40, 31, 53,
- 30, 17, 20, 37, 31, 42, 47, 47,
- 54, 38,  9, 34, 13, 37, 21, 25,
- 27, 43, 42, 45, 40, 25, 27, 46,
- 22, 25, 53, 20,  2, 14, 39, 15,
- 22, 44, 34, 21, 38, 33, 27, 48,
- 34, 52, 35, 47, 49, 54,  2, 13,
- 23, 52, 29, 45, 22, 49, 54, 21,
- 40, 42, 31, 30, 29, 34,  0, 25,
- 23, 51, 24, 59, 28, 38, 29, 31,
-  2, 13, 31,  8, 31, 33, 12, 45,
- 41,  7, 14, 30, 25, 18, 43, 20,
- 43, 35, 44,  1, 49, 42, 42, 18,
- 41, 38, 41, 44, 53, 11, 20, 25,
- 45, 46, 47, 48, 39, 52, 46, 49,
- 63, 55, 44, 38, 13, 13, 57, 22,
- 51, 16, 12, 28, 35, 57, 25, 20,
- 26, 28, 28, 29, 32, 31, 62, 34,
- 35, 35, 19, 49, 48, 39, 40, 18,
- 43, 46, 11,  6, 48, 19, 49, 41,
- 10, 23, 58, 17, 21, 23, 34, 30,
- 60,  0, 44, 34, 26, 37, 46, 43,
- 49, 59,  4, 34, 59, 37, 22, 25,
- 28, 46,  6, 40, 59, 42, 36, 61,
- 28, 30, 31, 43, 10, 22, 23, 47,
- 20, 52, 55, 36, 25, 16,  1, 11,
- 27, 29,  5, 63, 18, 41, 31, 34,
- 38,  1,  5, 13, 28, 31, 17, 38,
- 39, 41, 36, 37, 22, 39, 33, 43,
- 43, 15, 17, 49, 30, 21, 22, 20,
- 10, 17, 25, 54, 57,  3, 34,  8,
- 36, 25, 31, 14, 15, 19, 29, 25,
- 18, 39, 53, 22, 27, 20, 29, 33,
- 41, 42, 35, 62, 50, 29, 53, 50,
- 35, 55, 42, 61, 63,  4,  7, 42,
- 21, 46, 47, 49, 27, 46, 17, 55,
- 41, 50, 63,  4, 56, 18,  8, 10,
- 18, 51, 63, 36, 55, 18,  5, 55,
-  9, 29, 17, 21, 30, 27,  1, 59,
-  7, 11, 12, 15,  5, 42, 24, 41,
- 43,  7, 27, 22, 25, 31, 30, 37,
- 22, 39, 53, 29, 36, 37, 48,  0,
-  5, 13, 17, 31, 32, 26, 46, 28,
- 44, 45, 46, 53, 49, 51,  3, 41,
-  3, 22, 42, 33,  5, 45,  7, 22,
- 40, 53, 24, 14, 25, 27, 10, 12,
- 34, 16, 17, 53, 20, 26, 39, 45,
- 18, 45, 35, 33, 31, 49,  4, 39,
- 42, 11, 51,  5, 13, 26, 27, 17,
- 52, 30,  0, 22, 12, 34, 62, 36,
- 38, 41, 47, 30, 63, 38, 41, 43,
- 59, 33, 45, 37, 38, 40, 47, 24,
- 48, 49, 30,  1, 10, 22, 49, 15,
- 39, 59, 31, 32, 33, 18, 13, 15,
- 31, 21, 27, 44, 42, 39, 46, 17,
- 26, 32, 30, 31,  0, 30, 34,  9,
- 12, 13, 25, 31, 32, 55, 43, 35,
- 61, 33, 35, 46, 25, 47, 48, 62,
- 63, 38, 61,  1,  2,  5,  7,  9,
- 46, 10, 34, 35, 36, 55, 51,  7,
- 40, 23, 34, 37,  5, 13, 42, 18,
- 25, 27, 28,
-};
-
-/* motion vector table 1 */
-static const uint16_t table1_mv_code[1100] = {
- 0x0000, 0x0007, 0x0009, 0x000f, 0x000a, 0x0011, 0x001a, 0x001c,
- 0x0011, 0x0031, 0x0025, 0x002d, 0x002f, 0x006f, 0x0075, 0x0041,
- 0x004c, 0x004e, 0x005c, 0x0060, 0x0062, 0x0066, 0x0068, 0x0069,
- 0x006b, 0x00a6, 0x00c1, 0x00cb, 0x00cc, 0x00ce, 0x00da, 0x00e8,
- 0x00ee, 0x0087, 0x0090, 0x009e, 0x009f, 0x00ba, 0x00ca, 0x00d8,
- 0x00db, 0x00df, 0x0104, 0x0109, 0x010c, 0x0143, 0x0145, 0x014a,
- 0x0156, 0x015c, 0x01b3, 0x01d3, 0x01da, 0x0103, 0x0109, 0x010b,
- 0x0122, 0x0127, 0x0134, 0x0161, 0x0164, 0x0176, 0x0184, 0x018d,
- 0x018e, 0x018f, 0x0190, 0x0193, 0x0196, 0x019d, 0x019e, 0x019f,
- 0x01a9, 0x01b2, 0x01b4, 0x01ba, 0x01bb, 0x01bc, 0x0201, 0x0202,
- 0x0205, 0x0207, 0x020d, 0x0210, 0x0211, 0x0215, 0x021b, 0x021f,
- 0x0281, 0x0285, 0x0290, 0x029c, 0x029d, 0x02a2, 0x02a7, 0x02a8,
- 0x02aa, 0x02b0, 0x02b1, 0x02b4, 0x02bc, 0x02bf, 0x0320, 0x0326,
- 0x0327, 0x0329, 0x032a, 0x0336, 0x0360, 0x0362, 0x0363, 0x0372,
- 0x03b2, 0x03bc, 0x03bd, 0x0203, 0x0205, 0x021a, 0x0249, 0x024a,
- 0x024c, 0x02c7, 0x02ca, 0x02ce, 0x02ef, 0x030d, 0x0322, 0x0325,
- 0x0338, 0x0373, 0x037a, 0x0409, 0x0415, 0x0416, 0x0418, 0x0428,
- 0x042d, 0x042f, 0x0434, 0x0508, 0x0509, 0x0510, 0x0511, 0x051c,
- 0x051e, 0x0524, 0x0541, 0x0543, 0x0546, 0x0547, 0x054d, 0x0557,
- 0x055f, 0x056a, 0x056c, 0x056d, 0x056f, 0x0576, 0x0577, 0x057a,
- 0x057b, 0x057c, 0x057d, 0x0600, 0x0601, 0x0603, 0x0614, 0x0616,
- 0x0617, 0x061c, 0x061f, 0x0642, 0x0648, 0x0649, 0x064a, 0x064b,
- 0x0657, 0x0668, 0x0669, 0x066b, 0x066e, 0x067f, 0x06c2, 0x06c8,
- 0x06cb, 0x06de, 0x06df, 0x06e2, 0x06e3, 0x06ef, 0x0748, 0x074b,
- 0x076e, 0x076f, 0x077c, 0x0409, 0x0423, 0x0428, 0x0429, 0x042a,
- 0x042b, 0x0432, 0x0433, 0x0496, 0x049a, 0x04d5, 0x04db, 0x0581,
- 0x0582, 0x058b, 0x058c, 0x058d, 0x0598, 0x0599, 0x059a, 0x059e,
- 0x05dd, 0x0619, 0x0632, 0x0633, 0x0648, 0x0672, 0x06a1, 0x06a2,
- 0x06a3, 0x06af, 0x06e2, 0x06e3, 0x06e4, 0x0800, 0x0801, 0x0802,
- 0x0803, 0x081a, 0x081b, 0x0829, 0x082f, 0x0832, 0x083e, 0x083f,
- 0x0852, 0x0853, 0x0858, 0x086b, 0x0877, 0x0878, 0x0879, 0x087a,
- 0x087b, 0x0a00, 0x0a01, 0x0a0d, 0x0a0e, 0x0a0f, 0x0a24, 0x0a37,
- 0x0a3a, 0x0a3b, 0x0a3e, 0x0a46, 0x0a47, 0x0a4a, 0x0a4b, 0x0a5f,
- 0x0a79, 0x0a7a, 0x0a7b, 0x0a80, 0x0a81, 0x0a84, 0x0a85, 0x0a99,
- 0x0aa5, 0x0aa6, 0x0ab8, 0x0aba, 0x0abb, 0x0abc, 0x0abd, 0x0ac8,
- 0x0ace, 0x0acf, 0x0ad7, 0x0adc, 0x0aeb, 0x0c04, 0x0c25, 0x0c26,
- 0x0c27, 0x0c2a, 0x0c2b, 0x0c3a, 0x0c3b, 0x0c3c, 0x0c3d, 0x0ca0,
- 0x0cad, 0x0cd4, 0x0cd5, 0x0cfc, 0x0cfd, 0x0d86, 0x0d92, 0x0d93,
- 0x0d94, 0x0d95, 0x0db0, 0x0db8, 0x0db9, 0x0dba, 0x0dbb, 0x0dc0,
- 0x0dc2, 0x0dc3, 0x0dda, 0x0ddb, 0x0ddc, 0x0ddd, 0x0e92, 0x0e93,
- 0x0e94, 0x0e95, 0x0ec7, 0x0ecc, 0x0ece, 0x0ecf, 0x0ed8, 0x0ed9,
- 0x0eda, 0x0edb, 0x0808, 0x0809, 0x080a, 0x0810, 0x0811, 0x0844,
- 0x0845, 0x0861, 0x0862, 0x0863, 0x086c, 0x0922, 0x0923, 0x092e,
- 0x092f, 0x0936, 0x0937, 0x09b1, 0x09b2, 0x09b3, 0x09b4, 0x09b5,
- 0x09b8, 0x09b9, 0x09ba, 0x09bb, 0x09bc, 0x09bd, 0x09be, 0x09bf,
- 0x0b00, 0x0b15, 0x0b2c, 0x0b2d, 0x0b2e, 0x0b2f, 0x0b36, 0x0bb9,
- 0x0c28, 0x0c2a, 0x0c2b, 0x0c2c, 0x0c2d, 0x0c2e, 0x0c2f, 0x0c30,
- 0x0c31, 0x0c38, 0x0c60, 0x0c61, 0x0c62, 0x0c63, 0x0c8d, 0x0c8e,
- 0x0c8f, 0x0c92, 0x0cbe, 0x0cbf, 0x0ce6, 0x0ce7, 0x0d40, 0x0d41,
- 0x0d57, 0x0d58, 0x0d59, 0x0d5a, 0x0d5b, 0x0d5c, 0x0d5d, 0x0d98,
- 0x0d99, 0x0d9a, 0x0d9b, 0x0d9c, 0x0d9d, 0x0dad, 0x0dae, 0x0daf,
- 0x0dc0, 0x0dc1, 0x0dc2, 0x0dc3, 0x0dca, 0x0dcb, 0x0dec, 0x0ded,
- 0x0dee, 0x0def, 0x1018, 0x1022, 0x1023, 0x1030, 0x1031, 0x1032,
- 0x1033, 0x1050, 0x1051, 0x105c, 0x1074, 0x1075, 0x1076, 0x1077,
- 0x1078, 0x1079, 0x107a, 0x107b, 0x10b2, 0x10b3, 0x10b8, 0x10b9,
- 0x10ba, 0x10bb, 0x10d4, 0x10ea, 0x10eb, 0x10ec, 0x10ed, 0x1404,
- 0x1405, 0x1406, 0x1407, 0x1410, 0x1411, 0x1412, 0x1413, 0x1414,
- 0x1415, 0x1416, 0x1417, 0x1418, 0x1419, 0x1466, 0x1467, 0x1468,
- 0x1469, 0x146a, 0x146b, 0x146c, 0x146d, 0x147e, 0x147f, 0x1488,
- 0x1489, 0x148a, 0x148b, 0x14b6, 0x14b7, 0x14b8, 0x14b9, 0x14ba,
- 0x14bb, 0x14bc, 0x14bd, 0x14f0, 0x14f1, 0x14f8, 0x14f9, 0x14fa,
- 0x14fb, 0x14fc, 0x14fd, 0x14fe, 0x14ff, 0x152a, 0x152b, 0x152c,
- 0x152d, 0x152e, 0x152f, 0x1530, 0x1531, 0x1548, 0x1549, 0x154e,
- 0x154f, 0x1558, 0x1559, 0x155a, 0x155b, 0x1572, 0x159a, 0x159b,
- 0x15ac, 0x15ba, 0x15bb, 0x15d0, 0x15d1, 0x15d2, 0x15d3, 0x15d4,
- 0x15d5, 0x181d, 0x181e, 0x181f, 0x1840, 0x1841, 0x1842, 0x1843,
- 0x1844, 0x1845, 0x1846, 0x1847, 0x1848, 0x1849, 0x1861, 0x1862,
- 0x1863, 0x1864, 0x1865, 0x1866, 0x1867, 0x1868, 0x1869, 0x186a,
- 0x186b, 0x186c, 0x186d, 0x186e, 0x191b, 0x191c, 0x191d, 0x191e,
- 0x191f, 0x1942, 0x1943, 0x1944, 0x1945, 0x1946, 0x1947, 0x1958,
- 0x1959, 0x19ed, 0x19ee, 0x19ef, 0x19f0, 0x19f1, 0x19f2, 0x19f3,
- 0x19f4, 0x19f5, 0x19f6, 0x19f7, 0x1b0e, 0x1b0f, 0x1b62, 0x1b63,
- 0x1b64, 0x1b65, 0x1b66, 0x1b67, 0x1b68, 0x1b69, 0x1b6a, 0x1b6b,
- 0x1b6c, 0x1b6d, 0x1b6e, 0x1b6f, 0x1b82, 0x1ba8, 0x1ba9, 0x1baa,
- 0x1bab, 0x1bac, 0x1bad, 0x1bae, 0x1baf, 0x1bb0, 0x1bb1, 0x1bb2,
- 0x1bb3, 0x1d80, 0x1d81, 0x1d82, 0x1d83, 0x1d84, 0x1d85, 0x1d86,
- 0x1d87, 0x1d88, 0x1d89, 0x1d8a, 0x1d8b, 0x1d8c, 0x1d8d, 0x1007,
- 0x1008, 0x1009, 0x100a, 0x100b, 0x100c, 0x100d, 0x100e, 0x100f,
- 0x1016, 0x1080, 0x1081, 0x1082, 0x1083, 0x1084, 0x1085, 0x1086,
- 0x1087, 0x10c0, 0x123a, 0x123b, 0x123c, 0x123d, 0x123e, 0x123f,
- 0x1240, 0x1241, 0x1242, 0x1243, 0x1350, 0x1352, 0x1353, 0x1358,
- 0x1359, 0x135a, 0x135b, 0x135c, 0x135d, 0x135e, 0x135f, 0x1360,
- 0x1361, 0x1602, 0x1603, 0x160c, 0x160d, 0x160e, 0x160f, 0x1620,
- 0x1621, 0x1622, 0x1623, 0x1624, 0x1625, 0x1626, 0x1627, 0x1628,
- 0x1629, 0x166e, 0x166f, 0x167c, 0x167d, 0x167e, 0x167f, 0x1770,
- 0x1771, 0x1852, 0x1853, 0x1872, 0x1873, 0x1874, 0x1875, 0x1876,
- 0x1877, 0x1878, 0x1879, 0x187a, 0x187b, 0x187c, 0x187d, 0x187e,
- 0x187f, 0x1918, 0x1919, 0x1926, 0x1927, 0x1970, 0x1971, 0x1972,
- 0x1973, 0x1974, 0x1975, 0x1976, 0x1977, 0x1978, 0x1979, 0x197a,
- 0x197b, 0x1aa0, 0x1aa1, 0x1aa2, 0x1aa3, 0x1aa4, 0x1aa5, 0x1aa6,
- 0x1aa7, 0x1aa8, 0x1aa9, 0x1aaa, 0x1aab, 0x1aac, 0x1aad, 0x1b3c,
- 0x1b3d, 0x1b3e, 0x1b3f, 0x1b50, 0x1b51, 0x1b52, 0x1b53, 0x1b54,
- 0x1b55, 0x1b56, 0x1b57, 0x1b58, 0x1b59, 0x2032, 0x2033, 0x2034,
- 0x2035, 0x2036, 0x2037, 0x2038, 0x2039, 0x203a, 0x203b, 0x203c,
- 0x203d, 0x203e, 0x203f, 0x2040, 0x2041, 0x2042, 0x2043, 0x20ba,
- 0x20bb, 0x20cc, 0x20cd, 0x20ce, 0x20cf, 0x20e0, 0x20e1, 0x20e2,
- 0x20e3, 0x20e4, 0x20e5, 0x20e6, 0x20e7, 0x21aa, 0x21ab, 0x21c0,
- 0x21c1, 0x21c2, 0x21c3, 0x21c4, 0x21c5, 0x21c6, 0x21c7, 0x21c8,
- 0x21c9, 0x21ca, 0x21cb, 0x21cc, 0x21cd, 0x21ce, 0x21cf, 0x21d0,
- 0x21d1, 0x21d2, 0x21d3, 0x2894, 0x2895, 0x2896, 0x2897, 0x2898,
- 0x2899, 0x289a, 0x289b, 0x289c, 0x289d, 0x289e, 0x289f, 0x28c0,
- 0x28c1, 0x28c2, 0x28c3, 0x28c4, 0x28c5, 0x28c6, 0x28c7, 0x28c8,
- 0x28c9, 0x28ca, 0x28cb, 0x2930, 0x2931, 0x2932, 0x2933, 0x2934,
- 0x2935, 0x2936, 0x2937, 0x2938, 0x2939, 0x293a, 0x293b, 0x293c,
- 0x293d, 0x293e, 0x293f, 0x2960, 0x2961, 0x2962, 0x2963, 0x2964,
- 0x2965, 0x2966, 0x2967, 0x2968, 0x2969, 0x296a, 0x296b, 0x2a40,
- 0x2a41, 0x2a42, 0x2a43, 0x2a44, 0x2a45, 0x2a46, 0x2a47, 0x2a48,
- 0x2a49, 0x2a4a, 0x2a4b, 0x2a4c, 0x2a4d, 0x2a4e, 0x2a4f, 0x2a50,
- 0x2a51, 0x2a52, 0x2a53, 0x2ae6, 0x2ae7, 0x2b24, 0x2b25, 0x2b26,
- 0x2b27, 0x2b28, 0x2b29, 0x2b2a, 0x2b2b, 0x2b2c, 0x2b2d, 0x2b2e,
- 0x2b2f, 0x2b30, 0x2b31, 0x2b32, 0x2b33, 0x2b5a, 0x2b5b, 0x3014,
- 0x3015, 0x3016, 0x3017, 0x3020, 0x3021, 0x3022, 0x3023, 0x3024,
- 0x3025, 0x3026, 0x3027, 0x3028, 0x3029, 0x302a, 0x302b, 0x302c,
- 0x302d, 0x302e, 0x302f, 0x3030, 0x3031, 0x3032, 0x3033, 0x3034,
- 0x3035, 0x3036, 0x3037, 0x3038, 0x3039, 0x30c0, 0x30c1, 0x30de,
- 0x30df, 0x3218, 0x3219, 0x321a, 0x321b, 0x321c, 0x321d, 0x321e,
- 0x321f, 0x3220, 0x3221, 0x3222, 0x3223, 0x3224, 0x3225, 0x3226,
- 0x3227, 0x3228, 0x3229, 0x322a, 0x322b, 0x322c, 0x322d, 0x322e,
- 0x322f, 0x3230, 0x3231, 0x3232, 0x3233, 0x3234, 0x3235, 0x3378,
- 0x3379, 0x337a, 0x337b, 0x337c, 0x337d, 0x337e, 0x337f, 0x33c0,
- 0x33c1, 0x33c2, 0x33c3, 0x33c4, 0x33c5, 0x33c6, 0x33c7, 0x33c8,
- 0x33c9, 0x33ca, 0x33cb, 0x33cc, 0x33cd, 0x33ce, 0x33cf, 0x33d0,
- 0x33d1, 0x33d2, 0x33d3, 0x33d4, 0x33d5, 0x33d6, 0x33d7, 0x33d8,
- 0x33d9, 0x3706, 0x3707, 0x3730, 0x3731, 0x3732, 0x3733, 0x3734,
- 0x3735, 0x3736, 0x3737, 0x3738, 0x3739, 0x373a, 0x373b, 0x373c,
- 0x373d, 0x373e, 0x373f, 0x3740, 0x3741, 0x3742, 0x3743, 0x3744,
- 0x3745, 0x3746, 0x3747, 0x3748, 0x3749, 0x374a, 0x374b, 0x374c,
- 0x374d, 0x374e, 0x374f, 0x3b34, 0x3b35, 0x3b36, 0x3b37, 0x3be8,
- 0x3be9, 0x3bea, 0x3beb, 0x3bec, 0x3bed, 0x3bee, 0x3bef, 0x3bf0,
- 0x3bf1, 0x3bf2, 0x3bf3, 0x3bf4, 0x3bf5, 0x3bf6, 0x3bf7, 0x3bf8,
- 0x3bf9, 0x3bfa, 0x3bfb, 0x3bfc, 0x3bfd, 0x3bfe, 0x3bff, 0x2000,
- 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008,
- 0x2009, 0x200a, 0x200b, 0x200c, 0x200d, 0x202e, 0x202f, 0x2182,
- 0x2183, 0x21b4, 0x21b5, 0x21b6, 0x21b7, 0x21b8, 0x21b9, 0x21ba,
- 0x21bb, 0x21bc, 0x21bd, 0x21be, 0x21bf, 0x2460, 0x2461, 0x2462,
- 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, 0x2468, 0x2469, 0x246a,
- 0x246b, 0x246c, 0x246d, 0x246e, 0x246f, 0x2470, 0x2471, 0x2472,
- 0x2473, 0x26a2, 0x26a3, 0x000b,
-};
-
-static const uint8_t table1_mv_bits[1100] = {
-  2,  4,  4,  4,  5,  5,  5,  5,
-  6,  6,  7,  7,  7,  7,  7,  8,
-  8,  8,  8,  8,  8,  8,  8,  8,
-  8,  8,  8,  8,  8,  8,  8,  8,
-  8,  9,  9,  9,  9,  9,  9,  9,
-  9,  9,  9,  9,  9,  9,  9,  9,
-  9,  9,  9,  9,  9, 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, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 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, 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, 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, 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, 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, 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, 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, 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, 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, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15,  4,
-};
-
-static const uint8_t table1_mvx[1099] = {
- 32, 31, 32, 31, 33, 32, 33, 33,
- 31, 34, 30, 32, 32, 34, 35, 32,
- 34, 33, 29, 30, 30, 32, 31, 31,
- 33, 35, 35, 33, 31, 29, 29, 33,
- 34, 30, 31, 28, 36, 30, 34, 32,
- 32, 37, 32, 32, 25, 27, 39, 32,
- 32, 32, 38, 35, 36, 32, 37, 61,
- 26, 32, 34, 35,  3, 35, 27, 28,
- 29, 34, 28, 37, 31, 36, 32, 27,
- 31, 30, 29, 39, 33, 29, 33, 35,
- 25, 25, 29, 33, 31, 31, 31, 33,
- 32, 30, 32, 32, 41, 39, 33, 36,
- 32, 28, 34, 36, 38, 24, 60, 31,
- 23, 28, 32, 33, 59, 32, 40, 30,
-  5, 34, 32, 38, 32, 30, 43,  4,
- 32, 32, 42, 31, 31, 32, 26, 38,
- 26, 22, 21, 37, 61, 63, 37, 31,
- 32, 33,  2,  1, 23, 33, 41, 27,
- 35, 30, 38, 23, 33,  3, 28, 34,
- 34, 27, 41, 29, 39, 35, 36, 29,
- 32, 27, 30, 32, 24, 61, 37, 26,
- 59, 25, 35, 27, 36, 37, 30, 31,
- 34, 40,  3, 28, 34, 39, 32, 31,
- 32, 30, 24, 28, 35, 36, 26, 32,
- 31, 33, 29, 33, 39, 25, 30, 24,
- 35, 59, 29, 34, 25, 30, 21, 35,
- 43, 40, 32, 29,  5, 28, 31, 62,
- 33, 33, 25, 31, 21, 31, 43, 31,
- 34, 33, 20, 40, 39, 31, 31, 57,
- 38, 32, 42, 33, 32, 31, 32, 29,
- 30, 44,  5, 31, 22, 34, 36, 17,
- 38, 58, 38, 35, 32, 60, 35, 24,
- 32, 38, 16, 45, 42, 32, 31, 29,
-  4, 30, 17, 40, 46, 48, 63, 32,
- 42, 19, 41, 22, 28, 36, 45, 33,
- 33, 32, 29,  7, 41, 42, 18, 33,
- 33, 32, 22, 37,  1, 26, 22, 23,
- 49, 28, 26, 27, 32, 33, 27, 23,
- 28, 36, 15,  6, 34, 27, 31, 26,
- 23,  2, 33, 32, 34, 41, 28, 32,
- 41,  0, 36, 38, 34, 31, 47, 32,
- 17, 31, 39, 33, 37, 51, 30, 47,
- 32, 50, 32, 19, 63, 30, 25, 27,
- 33, 62, 24, 31, 27, 30, 37, 31,
- 45, 32, 39, 20, 46, 47, 35, 19,
- 34,  1, 49, 21, 21, 14, 51, 26,
- 23, 31, 36, 35, 58, 29, 29, 21,
- 20, 42, 13, 28, 12, 40, 31, 33,
- 39, 60, 32, 44, 33, 31, 28, 37,
- 29, 32, 30, 49, 43, 28, 39, 25,
- 32, 48,  2, 15, 20, 25, 31, 28,
- 21, 24, 25, 15, 31, 17, 37, 43,
- 18, 32, 33, 24, 33, 36, 13, 33,
- 31, 39, 11, 31, 33, 32, 39, 37,
- 32, 32, 29, 17, 44, 46, 36, 35,
- 26, 37, 58, 32, 34, 38,  8, 38,
- 38, 22, 29, 25, 16, 35, 32, 35,
- 33, 43, 18, 46, 38, 50, 33, 18,
- 53, 60, 13, 32, 36, 33, 51, 36,
- 43, 45, 27, 42, 29, 24, 30, 25,
- 31, 52, 31, 35, 38,  9, 22, 34,
-  4, 17, 28, 55, 42, 25, 17, 20,
- 47, 34, 33, 16, 40, 25, 16, 30,
- 53, 29, 10, 11, 14, 26, 33,  4,
- 35, 44, 26, 16, 31, 26, 34, 38,
- 29, 31, 30, 24, 22, 61, 32,  9,
- 45, 34, 31, 19,  9, 31, 46, 31,
- 35, 54, 29, 57, 30, 50,  3, 31,
- 63, 34, 47, 41, 51, 18, 31, 14,
- 37, 38, 31, 24, 32, 31, 50, 33,
- 31, 54, 27,  9, 33, 23, 19, 32,
- 29, 29, 33, 28, 47, 49, 30, 47,
- 33, 27, 25, 54, 44, 45, 50, 58,
- 51, 48, 33, 59, 33, 34, 57, 13,
- 26, 33, 13, 48, 30, 11,  7, 56,
- 34, 55, 26,  0, 26, 35,  1, 51,
- 33, 53, 31, 45, 12, 29, 29, 51,
- 31, 48,  2,  6, 34, 30, 28, 33,
- 60, 40, 27, 46, 31,  9, 35, 29,
- 31, 39, 55, 46, 19, 37, 62, 34,
- 30, 16, 19, 49, 41, 41, 39, 37,
- 14,  5, 13, 35, 55, 30, 40, 40,
- 42,  8, 20, 25, 45, 35, 33, 36,
- 54, 38, 27, 37, 62, 40, 15, 59,
- 49, 31, 29, 34, 34, 39, 24, 29,
- 25, 29, 21, 29, 10, 61, 33, 49,
- 35, 34,  3, 38, 39, 29,  7, 41,
-  1, 35,  4, 23, 15, 23, 11, 37,
- 28, 35, 30, 30, 24,  1, 43, 56,
-  8, 34, 42, 24, 45, 30, 20, 23,
-  8, 38, 22, 33, 17, 52, 34, 22,
- 53, 43, 44,  1, 27, 31, 41, 43,
- 41, 30, 31, 36, 30,  5, 55, 31,
- 33, 30, 40, 23, 15, 29, 34, 34,
- 59, 34, 30, 11, 13, 38,  5,  0,
- 30, 42,  5, 30, 29, 34, 10, 44,
- 30, 63, 35, 12,  3, 26, 15, 17,
- 25, 34, 43, 39, 34, 56, 29, 23,
- 30, 12, 30, 10, 35,  9, 24, 58,
- 10, 12, 54, 33, 37, 20, 41, 35,
- 29, 18, 61, 30, 40, 24, 39, 53,
- 62, 26, 29, 33, 34, 53, 49, 21,
- 27, 11, 63, 20, 26, 23,  7, 13,
-  6, 47, 29, 30,  9, 51, 22, 34,
- 21, 25, 33, 56, 57, 30, 38, 51,
- 51, 38, 63, 28, 40, 35, 33, 18,
- 33, 33, 24, 58, 58, 34, 49, 29,
- 43,  4,  1,  4, 42, 35, 35, 30,
- 17,  5, 56, 61, 25, 37, 36, 55,
- 28, 35, 29, 50, 48, 52,  2, 42,
- 34, 40, 46, 46, 43, 35, 29, 48,
- 20, 29, 31, 41,  7, 30, 35, 19,
- 14, 21,  8, 39, 39, 40, 46, 55,
- 34,  6, 30, 34, 37, 25, 37, 33,
- 22, 44, 52, 17, 35, 29, 36, 35,
- 40, 37, 28, 30, 50, 14, 28, 55,
-  6, 23, 19, 14, 30,  3, 30, 28,
- 28, 61, 61, 47, 45, 48, 40, 40,
- 34, 34, 25, 30, 29, 35,  4, 26,
- 53, 50, 26, 41, 27, 59, 27, 38,
- 39,  3, 50, 43, 47, 23, 33, 55,
- 35, 21, 23, 35, 61, 33, 46, 52,
- 35, 34, 24, 30, 43, 16, 37, 21,
-  2, 24, 45, 34, 30, 55, 55,  1,
- 29, 29, 26, 28, 25, 31, 36, 22,
- 17, 30, 52,  2, 44, 44, 57, 26,
- 62, 41, 39, 57, 26, 46, 49, 11,
- 16, 19,  5, 59, 38, 39, 58, 38,
- 25, 49, 50, 22, 28, 59,  9, 59,
-  7, 28, 55, 17,  4, 35, 50, 21,
- 29, 44, 47, 18, 24, 19, 25, 42,
- 35,  3, 51, 35, 16, 35, 30, 63,
- 57, 39, 39, 25, 35, 38,  9, 16,
- 36, 45, 31, 60, 14, 34, 42, 24,
-  0, 37, 18, 61, 57, 37, 28, 53,
- 20, 46, 14, 47, 38, 38, 38,  9,
- 34, 39, 43, 17, 39, 59,  5, 27,
-  0, 12, 27,
-};
-
-static const uint8_t table1_mvy[1099] = {
- 32, 32, 31, 31, 32, 33, 31, 33,
- 33, 32, 32, 30, 34, 31, 32, 29,
- 33, 30, 32, 33, 31, 35, 34, 30,
- 34, 31, 33, 29, 29, 31, 33, 35,
- 30, 30, 35, 32, 32, 34, 34, 28,
- 25, 32, 36, 27, 32, 32, 32, 37,
- 39,  3, 32, 30, 31, 26, 31, 32,
- 32, 38, 29, 29, 32, 34, 31, 31,
- 34, 35, 33, 33, 28, 33,  1, 33,
- 27, 29, 30, 31, 28, 29, 37, 35,
- 31, 33, 35, 27, 36, 37, 25, 25,
- 61, 35,  4,  5, 32, 33, 36, 30,
- 23, 30, 28, 34, 31, 32, 32, 39,
- 32, 34, 21, 39, 32, 59, 32, 28,
- 32, 36, 60, 33, 24, 36, 32, 32,
- 41,  2, 32, 38, 26, 22, 33, 30,
- 31, 32, 32, 30, 31, 32, 29,  3,
- 40, 38, 32, 32, 33, 26, 31, 34,
- 28, 38, 34, 31,  3, 31, 35, 38,
- 27, 35, 33, 28, 29, 27, 29, 27,
- 43, 29, 37, 63, 31, 33, 34, 30,
- 31, 30, 37, 30, 35, 35, 26, 41,
- 37, 31, 33, 28, 26, 30, 42, 24,
-  7, 27, 33, 29, 36, 28, 34, 57,
- 23, 41, 36, 23, 35, 34, 25, 30,
- 25, 33, 25, 25, 29, 24, 33, 39,
- 33, 33,  0, 37, 31, 36, 21, 32,
- 61, 24, 35, 61, 31,  5, 31, 59,
- 39, 21, 32, 30, 34, 22, 40, 32,
- 29, 16, 31,  5, 62,  2, 20, 39,
- 39, 32, 33,  1, 31, 24, 36, 32,
- 36, 32, 28, 26,  6, 31, 38, 34,
- 58, 35, 32, 33, 33, 17, 43, 26,
- 31, 40, 31, 34, 32, 32, 31, 19,
- 30, 32, 29, 33, 38, 38, 32, 59,
- 40, 18, 38, 32, 35, 34, 32, 17,
-  1, 15, 30, 28, 31, 28, 34, 29,
- 32, 27, 35, 27, 49, 22, 37, 34,
- 37, 26, 32, 32, 22, 28, 45, 29,
- 30, 31, 43, 46, 41, 30, 26, 13,
- 34, 32, 27, 38, 42, 42, 33, 47,
- 33, 60, 27, 42, 25, 32, 22, 32,
- 48, 32, 45, 33, 33, 41, 27, 25,
- 19, 31, 35, 19, 36, 42, 27, 17,
- 31, 44, 28, 33, 33, 31, 23, 31,
- 40, 33, 31, 34, 30, 32, 33, 36,
- 35, 47, 37, 41, 31, 23, 41, 29,
- 30, 35, 32, 25, 32, 28, 58,  2,
- 37, 33, 14, 33, 49, 20, 39, 36,
- 21,  9, 23, 33, 35, 24, 39, 37,
- 11, 33, 30, 31, 31, 28, 51, 40,
- 35, 29, 25, 33, 46, 35, 37, 30,
- 30,  8, 63, 28, 15, 40, 33, 45,
- 49, 25, 32,  4, 47, 51, 36, 39,
- 53, 10, 24, 29, 30, 31, 25, 40,
- 38, 38, 33, 56, 23, 27, 32, 37,
- 26, 29, 43, 36, 33, 24, 55, 43,
-  9, 29, 34, 34, 24, 33, 18, 33,
- 33, 30, 31, 50, 24, 60, 30, 39,
- 34, 30, 39, 28, 22, 38,  2, 26,
- 63, 32, 57, 21, 39, 33, 28, 18,
- 30, 34, 22, 33, 29, 41, 30, 34,
- 35, 21, 13, 34, 35, 39, 30, 46,
- 32, 42, 32, 31, 33, 26, 11, 33,
- 22, 31, 25, 31, 53, 27, 43, 25,
- 40, 50, 21, 36, 38, 30, 12, 31,
- 34, 20, 15, 29, 32, 62, 30, 13,
- 17, 32, 19, 31, 20, 31, 30,  7,
-  1, 17, 34, 37, 31, 31, 44, 34,
- 26, 40, 16, 37, 52, 48, 30, 20,
- 18, 33, 38, 29,  7, 25, 30, 54,
- 45, 47, 46, 41, 29, 29, 16, 30,
- 14, 26, 38, 34, 34, 29, 34, 30,
- 29, 30, 57, 30,  4, 46, 33, 29,
- 39, 44, 30, 31, 50, 33, 31, 32,
- 19, 32, 40, 31, 37, 47,  1, 35,
- 16, 31,  0, 35, 33,  1, 17, 34,
-  9, 34, 33, 31, 49, 43, 42, 51,
- 34, 29, 23, 29, 14, 30, 45, 49,
- 11, 24, 31, 28, 35, 41, 30, 44,
- 18, 29, 34, 35, 36, 25, 26, 21,
- 31, 30, 34, 19, 34, 44, 36, 38,
- 25, 31, 28, 23, 37,  3, 55, 41,
- 30, 22, 41, 24, 33, 26, 35, 35,
- 30, 55, 51, 47, 48, 38, 24, 15,
- 21, 50, 25, 46, 30, 29, 10, 34,
- 42, 45, 29, 42, 22,  3, 33, 27,
- 34,  1, 34, 28, 34, 36, 35, 23,
- 23, 13, 58,  3, 26, 63, 25, 31,
- 34, 61, 38, 39, 25, 61, 29, 37,
- 30, 41, 26, 48, 28, 33, 50, 35,
- 30, 37, 29, 29, 40,  6, 39, 28,
- 28, 19,  8, 22, 45, 34, 35, 10,
- 58, 17, 37, 39, 30, 18, 54, 14,
- 29, 16, 59, 30, 35, 23, 35, 30,
- 47, 36, 29, 55, 20, 12, 31, 35,
- 14, 29, 18, 34, 34, 24, 29, 26,
- 22,  2, 27, 23,  8, 30, 55, 38,
- 60, 31,  4, 34, 49, 34, 27, 34,
- 33, 30, 31, 54, 42, 35, 38, 46,
- 44, 26, 27,  9, 39, 25, 21, 29,
- 28, 42, 13,  0,  5, 34, 37, 28,
- 24, 29, 63, 26, 22, 27, 29, 25,
- 33, 25, 61,  0, 35, 25, 36, 15,
- 27, 40, 53, 33,  3, 10, 16, 37,
- 38, 18, 30, 46, 27,  9,  6, 29,
- 62,  8, 42, 28, 29,  3, 25, 16,
- 26, 29, 35, 28, 27, 51, 61, 48,
- 37,  9, 34,  7, 49, 45, 20, 29,
- 21,  5,  5, 29, 28, 34, 29, 24,
- 10, 24, 35, 36, 38, 55, 11, 36,
- 38, 53, 54, 26, 30, 49, 20, 27,
- 30, 39, 33, 41, 49, 22, 38, 38,
-  4, 30,  8,  9,  3, 24, 22, 50,
- 37, 36, 31, 27,  2,  9, 42, 63,
- 25, 19, 44,  1, 28, 28, 48, 30,
- 34, 41, 41, 38, 12, 27, 15,  0,
- 16, 34, 35, 38, 28, 29, 40, 42,
- 51, 52, 45, 54, 59, 59, 42, 44,
- 37, 26, 46, 24, 15, 39, 22, 46,
- 19, 35, 38, 17, 37, 23, 52, 55,
- 50, 37, 26, 11, 37, 12, 24, 30,
- 16, 13, 22, 13, 36, 35, 40, 41,
- 34, 41, 26, 53, 51,  5, 21, 30,
-  2, 63, 41, 20,  1, 56, 21, 24,
- 25,  5, 28, 35, 26, 28, 30, 18,
- 29, 23, 40, 34, 20, 42, 39, 34,
- 28, 61, 38, 27, 62,  9, 36, 17,
-  9, 49, 24, 25, 54, 34, 39, 37,
-  3,  1, 25, 38, 38, 44, 35, 36,
- 12, 60, 36, 38, 40, 25, 43, 39,
- 53, 28, 39, 57, 46, 10, 52, 27,
- 35, 42, 45, 59, 15, 60, 38, 24,
- 23, 39, 12, 29, 24,  0, 20, 16,
- 28, 43, 35, 28,  1, 49,  4, 21,
- 42, 39, 29,  3, 44, 21, 53, 55,
- 11,  5,  3, 39, 53, 28, 25, 19,
- 34, 28, 21,
-};
-
-/* 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;
-    const uint8_t *table_mvy;
-    uint16_t *table_mv_index; /* encoding: convert mv to index in table_mv */
-    VLC vlc;                /* decoding: vlc */
-} MVTable;
-
-static MVTable mv_tables[2] = {
-    {
-        1099,
-        table0_mv_code,
-        table0_mv_bits,
-        table0_mvx,
-        table0_mvy,
-    },
-    {
-        1099,
-        table1_mv_code,
-        table1_mv_bits,
-        table1_mvx,
-        table1_mvy,
-    }
-};
-
-static const uint8_t v2_mb_type[8][2] = {
- {1, 1}, {0   , 2}, {3   , 3}, {9   , 5},
- {5, 4}, {0x21, 7}, {0x20, 7}, {0x11, 6},
-};
-
-static const uint8_t v2_intra_cbpc[4][2] = {
- {1, 1}, {0, 3}, {1, 3}, {1, 2},
-};
-
-static const uint8_t wmv1_y_dc_scale_table[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, 8, 8, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21
-};
-static const uint8_t wmv1_c_dc_scale_table[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, 8, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22
-};
-
-static const uint8_t old_ff_y_dc_scale_table[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, 8, 8, 8, 8,10,12,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39
-};
-static const uint8_t old_ff_c_dc_scale_table[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, 8, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22
-};
-
-
-#define WMV1_SCANTABLE_COUNT 4
-
-static const uint8_t wmv1_scantable00[64]= {
-0x00, 0x08, 0x01, 0x02, 0x09, 0x10, 0x18, 0x11, 
-0x0A, 0x03, 0x04, 0x0B, 0x12, 0x19, 0x20, 0x28, 
-0x30, 0x38, 0x29, 0x21, 0x1A, 0x13, 0x0C, 0x05, 
-0x06, 0x0D, 0x14, 0x1B, 0x22, 0x31, 0x39, 0x3A, 
-0x32, 0x2A, 0x23, 0x1C, 0x15, 0x0E, 0x07, 0x0F, 
-0x16, 0x1D, 0x24, 0x2B, 0x33, 0x3B, 0x3C, 0x34, 
-0x2C, 0x25, 0x1E, 0x17, 0x1F, 0x26, 0x2D, 0x35, 
-0x3D, 0x3E, 0x36, 0x2E, 0x27, 0x2F, 0x37, 0x3F, 
-};
-static const uint8_t wmv1_scantable01[64]= {
-0x00, 0x08, 0x01, 0x02, 0x09, 0x10, 0x18, 0x11, 
-0x0A, 0x03, 0x04, 0x0B, 0x12, 0x19, 0x20, 0x28, 
-0x21, 0x30, 0x1A, 0x13, 0x0C, 0x05, 0x06, 0x0D, 
-0x14, 0x1B, 0x22, 0x29, 0x38, 0x31, 0x39, 0x2A, 
-0x23, 0x1C, 0x15, 0x0E, 0x07, 0x0F, 0x16, 0x1D, 
-0x24, 0x2B, 0x32, 0x3A, 0x33, 0x3B, 0x2C, 0x25, 
-0x1E, 0x17, 0x1F, 0x26, 0x2D, 0x34, 0x3C, 0x35, 
-0x3D, 0x2E, 0x27, 0x2F, 0x36, 0x3E, 0x37, 0x3F, 
-};
-static const uint8_t wmv1_scantable02[64]= {
-0x00, 0x01, 0x08, 0x02, 0x03, 0x09, 0x10, 0x18, 
-0x11, 0x0A, 0x04, 0x05, 0x0B, 0x12, 0x19, 0x20, 
-0x28, 0x30, 0x21, 0x1A, 0x13, 0x0C, 0x06, 0x07, 
-0x0D, 0x14, 0x1B, 0x22, 0x29, 0x38, 0x31, 0x39, 
-0x2A, 0x23, 0x1C, 0x15, 0x0E, 0x0F, 0x16, 0x1D, 
-0x24, 0x2B, 0x32, 0x3A, 0x33, 0x2C, 0x25, 0x1E, 
-0x17, 0x1F, 0x26, 0x2D, 0x34, 0x3B, 0x3C, 0x35, 
-0x2E, 0x27, 0x2F, 0x36, 0x3D, 0x3E, 0x37, 0x3F, 
-};
-static const uint8_t wmv1_scantable03[64]= {
-0x00, 0x08, 0x10, 0x01, 0x18, 0x20, 0x28, 0x09, 
-0x02, 0x03, 0x0A, 0x11, 0x19, 0x30, 0x38, 0x29, 
-0x21, 0x1A, 0x12, 0x0B, 0x04, 0x05, 0x0C, 0x13, 
-0x1B, 0x22, 0x31, 0x39, 0x32, 0x2A, 0x23, 0x1C, 
-0x14, 0x0D, 0x06, 0x07, 0x0E, 0x15, 0x1D, 0x24, 
-0x2B, 0x33, 0x3A, 0x3B, 0x34, 0x2C, 0x25, 0x1E, 
-0x16, 0x0F, 0x17, 0x1F, 0x26, 0x2D, 0x3C, 0x35, 
-0x2E, 0x27, 0x2F, 0x36, 0x3D, 0x3E, 0x37, 0x3F, 
-};
-
-static const uint8_t *wmv1_scantable[WMV1_SCANTABLE_COUNT+1]={
-    wmv1_scantable00,
-    wmv1_scantable01,
-    wmv1_scantable02,
-    wmv1_scantable03,
-};
-
-static const uint8_t table_inter_intra[4][2]={
-    {0,1} /*Luma-Left Chroma-Left*/,
-    {2,2} /*Luma-Top  Chroma-Left*/,
-    {6,3} /*luma-Left Chroma-Top */,
-    {7,3} /*luma-Top  Chroma-Top */
-};
-
-#define WMV2_INTER_CBP_TABLE_COUNT 4
-
-static const uint32_t table_mb_non_intra2[128][2] = {
-{0x0000A7, 14}, {0x01B2B8, 18}, {0x01B28E, 18}, {0x036575, 19}, 
-{0x006CAC, 16}, {0x000A69, 18}, {0x002934, 20}, {0x00526B, 21}, 
-{0x006CA1, 16}, {0x01B2B9, 18}, {0x0029AD, 20}, {0x029353, 24}, 
-{0x006CA7, 16}, {0x006CAB, 16}, {0x01B2BB, 18}, {0x00029B, 16}, 
-{0x00D944, 17}, {0x000A6A, 18}, {0x0149A8, 23}, {0x03651F, 19}, 
-{0x006CAF, 16}, {0x000A4C, 18}, {0x03651E, 19}, {0x000A48, 18}, 
-{0x00299C, 20}, {0x00299F, 20}, {0x029352, 24}, {0x0029AC, 20}, 
-{0x000296, 16}, {0x00D946, 17}, {0x000A68, 18}, {0x000298, 16}, 
-{0x000527, 17}, {0x00D94D, 17}, {0x0014D7, 19}, {0x036574, 19}, 
-{0x000A5C, 18}, {0x01B299, 18}, {0x00299D, 20}, {0x00299E, 20}, 
-{0x000525, 17}, {0x000A66, 18}, {0x00A4D5, 22}, {0x00149B, 19}, 
-{0x000295, 16}, {0x006CAD, 16}, {0x000A49, 18}, {0x000521, 17}, 
-{0x006CAA, 16}, {0x00D945, 17}, {0x01B298, 18}, {0x00052F, 17}, 
-{0x003654, 15}, {0x006CA0, 16}, {0x000532, 17}, {0x000291, 16}, 
-{0x003652, 15}, {0x000520, 17}, {0x000A5D, 18}, {0x000294, 16}, 
-{0x00009B, 11}, {0x0006E2, 12}, {0x000028, 12}, {0x0001B0, 10}, 
-{0x000001,  3}, {0x000010,  8}, {0x00002F,  6}, {0x00004C, 10}, 
-{0x00000D,  4}, {0x000000, 10}, {0x000006,  9}, {0x000134, 12}, 
-{0x00000C,  4}, {0x000007, 10}, {0x000007,  9}, {0x0006E1, 12}, 
-{0x00000E,  5}, {0x0000DA,  9}, {0x000022,  9}, {0x000364, 11}, 
-{0x00000F,  4}, {0x000006, 10}, {0x00000F,  9}, {0x000135, 12}, 
-{0x000014,  5}, {0x0000DD,  9}, {0x000004,  9}, {0x000015, 11}, 
-{0x00001A,  6}, {0x0001B3, 10}, {0x000005, 10}, {0x0006E3, 12}, 
-{0x00000C,  5}, {0x0000B9,  8}, {0x000004,  8}, {0x0000DB,  9}, 
-{0x00000E,  4}, {0x00000B, 10}, {0x000023,  9}, {0x0006CB, 12}, 
-{0x000005,  6}, {0x0001B1, 10}, {0x000001, 10}, {0x0006E0, 12}, 
-{0x000011,  5}, {0x0000DF,  9}, {0x00000E,  9}, {0x000373, 11}, 
-{0x000003,  5}, {0x0000B8,  8}, {0x000006,  8}, {0x000175,  9}, 
-{0x000015,  5}, {0x000174,  9}, {0x000027,  9}, {0x000372, 11}, 
-{0x000010,  5}, {0x0000BB,  8}, {0x000005,  8}, {0x0000DE,  9}, 
-{0x00000F,  5}, {0x000001,  9}, {0x000012,  8}, {0x000004, 10}, 
-{0x000002,  3}, {0x000016,  5}, {0x000009,  4}, {0x000001,  5}, 
-};
-
-static const uint32_t table_mb_non_intra3[128][2] = {
-{0x0002A1, 10}, {0x005740, 15}, {0x01A0BF, 18}, {0x015D19, 17}, 
-{0x001514, 13}, {0x00461E, 15}, {0x015176, 17}, {0x015177, 17}, 
-{0x0011AD, 13}, {0x00682E, 16}, {0x0682F9, 20}, {0x03417D, 19}, 
-{0x001A36, 14}, {0x002A2D, 14}, {0x00D05E, 17}, {0x006824, 16}, 
-{0x001515, 13}, {0x00545C, 15}, {0x0230E9, 18}, {0x011AFA, 17}, 
-{0x0015D7, 13}, {0x005747, 15}, {0x008D79, 16}, {0x006825, 16}, 
-{0x002BA2, 14}, {0x00A8BA, 16}, {0x0235F6, 18}, {0x015D18, 17}, 
-{0x0011AE, 13}, {0x00346F, 15}, {0x008C3B, 16}, {0x00346E, 15}, 
-{0x000D1A, 13}, {0x00461F, 15}, {0x0682F8, 20}, {0x011875, 17}, 
-{0x002BA1, 14}, {0x008D61, 16}, {0x0235F7, 18}, {0x0230E8, 18}, 
-{0x001513, 13}, {0x008D7B, 16}, {0x011AF4, 17}, {0x011AF5, 17}, 
-{0x001185, 13}, {0x0046BF, 15}, {0x008D60, 16}, {0x008D7C, 16}, 
-{0x001512, 13}, {0x00461C, 15}, {0x00AE8D, 16}, {0x008D78, 16}, 
-{0x000D0E, 13}, {0x003413, 15}, {0x0046B1, 15}, {0x003416, 15}, 
-{0x000AEA, 12}, {0x002A2C, 14}, {0x005741, 15}, {0x002A2F, 14}, 
-{0x000158,  9}, {0x0008D2, 12}, {0x00054C, 11}, {0x000686, 12}, 
-{0x000000,  2}, {0x000069,  8}, {0x00006B,  8}, {0x00068C, 12}, 
-{0x000007,  3}, {0x00015E,  9}, {0x0002A3, 10}, {0x000AE9, 12}, 
-{0x000006,  3}, {0x000231, 10}, {0x0002B8, 10}, {0x001A08, 14}, 
-{0x000010,  5}, {0x0001A9, 10}, {0x000342, 11}, {0x000A88, 12}, 
-{0x000004,  4}, {0x0001A2, 10}, {0x0002A4, 10}, {0x001184, 13}, 
-{0x000012,  5}, {0x000232, 10}, {0x0002B2, 10}, {0x000680, 12}, 
-{0x00001B,  6}, {0x00046A, 11}, {0x00068E, 12}, {0x002359, 14}, 
-{0x000016,  5}, {0x00015F,  9}, {0x0002A0, 10}, {0x00054D, 11}, 
-{0x000005,  4}, {0x000233, 10}, {0x0002B9, 10}, {0x0015D6, 13}, 
-{0x000022,  6}, {0x000468, 11}, {0x000683, 12}, {0x001A0A, 14}, 
-{0x000013,  5}, {0x000236, 10}, {0x0002BB, 10}, {0x001186, 13}, 
-{0x000017,  5}, {0x0001AB, 10}, {0x0002A7, 10}, {0x0008D3, 12}, 
-{0x000014,  5}, {0x000237, 10}, {0x000460, 11}, {0x000D0F, 13}, 
-{0x000019,  6}, {0x0001AA, 10}, {0x0002B3, 10}, {0x000681, 12}, 
-{0x000018,  6}, {0x0001A8, 10}, {0x0002A5, 10}, {0x00068F, 12}, 
-{0x000007,  4}, {0x000055,  7}, {0x000047,  7}, {0x0000AD,  8}, 
-};
-
-static const uint32_t table_mb_non_intra4[128][2] = {
-{0x0000D4,  8}, {0x0021C5, 14}, {0x00F18A, 16}, {0x00D5BC, 16}, 
-{0x000879, 12}, {0x00354D, 14}, {0x010E3F, 17}, {0x010F54, 17}, 
-{0x000866, 12}, {0x00356E, 14}, {0x010F55, 17}, {0x010E3E, 17}, 
-{0x0010CE, 13}, {0x003C84, 14}, {0x00D5BD, 16}, {0x00F18B, 16}, 
-{0x000868, 12}, {0x00438C, 15}, {0x0087AB, 16}, {0x00790B, 15}, 
-{0x000F10, 12}, {0x00433D, 15}, {0x006AD3, 15}, {0x00790A, 15}, 
-{0x001AA7, 13}, {0x0043D4, 15}, {0x00871E, 16}, {0x006ADF, 15}, 
-{0x000D7C, 12}, {0x003C94, 14}, {0x00438D, 15}, {0x006AD2, 15}, 
-{0x0006BC, 11}, {0x0021E9, 14}, {0x006ADA, 15}, {0x006A99, 15}, 
-{0x0010F7, 13}, {0x004389, 15}, {0x006ADB, 15}, {0x0078C4, 15}, 
-{0x000D56, 12}, {0x0035F7, 14}, {0x00438E, 15}, {0x006A98, 15}, 
-{0x000D52, 12}, {0x003C95, 14}, {0x004388, 15}, {0x00433C, 15}, 
-{0x000D54, 12}, {0x001E4B, 13}, {0x003C63, 14}, {0x003C83, 14}, 
-{0x000861, 12}, {0x0021EB, 14}, {0x00356C, 14}, {0x0035F6, 14}, 
-{0x000863, 12}, {0x00219F, 14}, {0x003568, 14}, {0x003C82, 14}, 
-{0x0001AE,  9}, {0x0010C0, 13}, {0x000F11, 12}, {0x001AFA, 13}, 
-{0x000000,  1}, {0x0000F0,  8}, {0x0001AD,  9}, {0x0010C1, 13}, 
-{0x00000A,  4}, {0x0003C5, 10}, {0x000789, 11}, {0x001AB5, 13}, 
-{0x000009,  4}, {0x000435, 11}, {0x000793, 11}, {0x001E40, 13}, 
-{0x00001D,  5}, {0x0003CB, 10}, {0x000878, 12}, {0x001AAF, 13}, 
-{0x00000B,  4}, {0x0003C7, 10}, {0x000791, 11}, {0x001AAB, 13}, 
-{0x00001F,  5}, {0x000436, 11}, {0x0006BF, 11}, {0x000F19, 12}, 
-{0x00003D,  6}, {0x000D51, 12}, {0x0010C4, 13}, {0x0021E8, 14}, 
-{0x000036,  6}, {0x000437, 11}, {0x0006AF, 11}, {0x0010C5, 13}, 
-{0x00000C,  4}, {0x000432, 11}, {0x000794, 11}, {0x001E30, 13}, 
-{0x000042,  7}, {0x000870, 12}, {0x000F24, 12}, {0x001E43, 13}, 
-{0x000020,  6}, {0x00043E, 11}, {0x000795, 11}, {0x001AAA, 13}, 
-{0x000037,  6}, {0x0006AC, 11}, {0x0006AE, 11}, {0x0010F6, 13}, 
-{0x000034,  6}, {0x00043A, 11}, {0x000D50, 12}, {0x001AAE, 13}, 
-{0x000039,  6}, {0x00043F, 11}, {0x00078D, 11}, {0x0010D2, 13}, 
-{0x000038,  6}, {0x00043B, 11}, {0x0006BD, 11}, {0x0010D3, 13}, 
-{0x000011,  5}, {0x0001AC,  9}, {0x0000F3,  8}, {0x000439, 11}, 
-};
-
-static const uint32_t (*wmv2_inter_table[WMV2_INTER_CBP_TABLE_COUNT])[2]={
-    table_mb_non_intra2,
-    table_mb_non_intra3,
-    table_mb_non_intra4,
-    table_mb_non_intra,
-};
-
-static const uint8_t wmv2_scantableA[64]={
-0x00, 0x01, 0x02, 0x08, 0x03, 0x09, 0x0A, 0x10,
-0x04, 0x0B, 0x11, 0x18, 0x12, 0x0C, 0x05, 0x13,
-0x19, 0x0D, 0x14, 0x1A, 0x1B, 0x06, 0x15, 0x1C,
-0x0E, 0x16, 0x1D, 0x07, 0x1E, 0x0F, 0x17, 0x1F,
-};
-
-static const uint8_t wmv2_scantableB[64]={
-0x00, 0x08, 0x01, 0x10, 0x09, 0x18, 0x11, 0x02,
-0x20, 0x0A, 0x19, 0x28, 0x12, 0x30, 0x21, 0x1A, 
-0x38, 0x29, 0x22, 0x03, 0x31, 0x39, 0x0B, 0x2A, 
-0x13, 0x32, 0x1B, 0x3A, 0x23, 0x2B, 0x33, 0x3B,
-};
diff --git a/ffmpeg.src/libavcodec/opt.c b/ffmpeg.src/libavcodec/opt.c
deleted file mode 100644
index 8934c23..0000000
--- a/ffmpeg.src/libavcodec/opt.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * AVOptions
- * Copyright (c) 2005 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
- 
-/**
- * @file opt.c
- * AVOptions
- * @author Michael Niedermayer <michaelni at gmx.at>
- */
- 
-#include "avcodec.h"
-#include "opt.h"
- 
-static double av_parse_num(const char *name, char **tail){
-    double d;
-    d= strtod(name, tail);
-    if(*tail>name && (**tail=='/' || **tail==':'))
-        d/=strtod((*tail)+1, tail);
-    return d;
-}
-
-//FIXME order them and do a bin search
-static AVOption *find_opt(void *v, const char *name, const char *unit){
-    AVClass *c= *(AVClass**)v; //FIXME silly way of storing AVClass
-    AVOption *o= c->option;
-    
-    for(;o && o->name; o++){
-        if(!strcmp(o->name, name) && (!unit || !strcmp(o->unit, unit)) )
-            return o;
-    }
-    return NULL;
-}
-
-AVOption *av_next_option(void *obj, AVOption *last){
-    if(last && last[1].name) return ++last;
-    else if(last)            return NULL;
-    else                     return (*(AVClass**)obj)->option;
-}
-
-static AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum){
-    AVOption *o= find_opt(obj, name, NULL);
-    void *dst;
-    if(!o || o->offset<=0) 
-        return NULL;
-    
-    if(o->max*den < num*intnum || o->min*den > num*intnum)
-        return NULL;
-        
-    dst= ((uint8_t*)obj) + o->offset;
-
-    switch(o->type){
-    case FF_OPT_TYPE_FLAGS:   
-    case FF_OPT_TYPE_INT:   *(int       *)dst= lrintf(num/den)*intnum; break;
-    case FF_OPT_TYPE_INT64: *(int64_t   *)dst= lrintf(num/den)*intnum; break;
-    case FF_OPT_TYPE_FLOAT: *(float     *)dst= num*intnum/den;         break;
-    case FF_OPT_TYPE_DOUBLE:*(double    *)dst= num*intnum/den;         break;
-    case FF_OPT_TYPE_RATIONAL:
-        if((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, den};
-        else                *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24);
-    default:
-        return NULL;
-    }
-    return o;
-}
-
-static AVOption *set_all_opt(void *v, const char *unit, double d){
-    AVClass *c= *(AVClass**)v; //FIXME silly way of storing AVClass
-    AVOption *o= c->option;
-    AVOption *ret=NULL;
-    
-    for(;o && o->name; o++){
-        if(o->type != FF_OPT_TYPE_CONST && o->unit && !strcmp(o->unit, unit)){
-            double tmp= d;
-            if(o->type == FF_OPT_TYPE_FLAGS)
-                tmp= av_get_int(v, o->name, NULL) | (int64_t)d;
-
-            av_set_number(v, o->name, tmp, 1, 1);
-            ret= o;
-        }
-    }
-    return ret;
-}
-
-//FIXME use eval.c maybe?
-AVOption *av_set_string(void *obj, const char *name, const char *val){
-    AVOption *o= find_opt(obj, name, NULL);
-    if(o && o->offset==0 && o->type == FF_OPT_TYPE_CONST && o->unit){
-        return set_all_opt(obj, o->unit, o->default_val);
-    }
-    if(!o || !val || o->offset<=0) 
-        return NULL;
-    if(o->type != FF_OPT_TYPE_STRING){
-        for(;;){
-            int i;
-            char buf[256], *tail;
-            int cmd=0;
-            double d;
-
-            if(*val == '+' || *val == '-')
-                cmd= *(val++);
-            
-            for(i=0; i<sizeof(buf)-1 && val[i] && val[i]!='+' && val[i]!='-'; i++)
-                buf[i]= val[i];
-            buf[i]=0;
-            val+= i;
-            
-            d= av_parse_num(buf, &tail);
-            if(tail <= buf){
-                AVOption *o_named= find_opt(obj, buf, o->unit);
-                if(o_named && o_named->type == FF_OPT_TYPE_CONST) 
-                    d= o_named->default_val;
-                else if(!strcmp(buf, "default")) d= o->default_val;
-                else if(!strcmp(buf, "max"    )) d= o->max;
-                else if(!strcmp(buf, "min"    )) d= o->min;
-                else return NULL;
-            }
-            if(o->type == FF_OPT_TYPE_FLAGS){
-                if     (cmd=='+') d= av_get_int(obj, name, NULL) | (int64_t)d;
-                else if(cmd=='-') d= av_get_int(obj, name, NULL) &~(int64_t)d;
-            }else if(cmd=='-')
-                d= -d;
-
-            av_set_number(obj, name, d, 1, 1);
-            if(!*val)
-                return o;
-        }
-        return NULL;
-    }
-    
-    memcpy(((uint8_t*)obj) + o->offset, val, sizeof(val));
-    return o;
-}
-
-AVOption *av_set_double(void *obj, const char *name, double n){
-    return av_set_number(obj, name, n, 1, 1);
-}
-
-AVOption *av_set_q(void *obj, const char *name, AVRational n){
-    return av_set_number(obj, name, n.num, n.den, 1);
-}
-
-AVOption *av_set_int(void *obj, const char *name, int64_t n){
-    return av_set_number(obj, name, 1, 1, n);
-}
-
-/**
- * 
- * @param buf a buffer which is used for returning non string values as strings, can be NULL
- * @param buf_len allocated length in bytes of buf
- */
-const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *buf, int buf_len){
-    AVOption *o= find_opt(obj, name, NULL);
-    void *dst;
-    if(!o || o->offset<=0)
-        return NULL;
-    if(o->type != FF_OPT_TYPE_STRING && (!buf || !buf_len))
-        return NULL;
-
-    dst= ((uint8_t*)obj) + o->offset;
-    if(o_out) *o_out= o;
-    
-    if(o->type == FF_OPT_TYPE_STRING)
-        return dst;
-    
-    switch(o->type){
-    case FF_OPT_TYPE_FLAGS:     snprintf(buf, buf_len, "0x%08X",*(int    *)dst);break;
-    case FF_OPT_TYPE_INT:       snprintf(buf, buf_len, "%d" , *(int    *)dst);break;
-    case FF_OPT_TYPE_INT64:     snprintf(buf, buf_len, "%Ld", *(int64_t*)dst);break;
-    case FF_OPT_TYPE_FLOAT:     snprintf(buf, buf_len, "%f" , *(float  *)dst);break;
-    case FF_OPT_TYPE_DOUBLE:    snprintf(buf, buf_len, "%f" , *(double *)dst);break;
-    case FF_OPT_TYPE_RATIONAL:  snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
-    default: return NULL;
-    }
-    return buf;
-}
-
-static int av_get_number(void *obj, const char *name, AVOption **o_out, double *num, int *den, int64_t *intnum){
-    AVOption *o= find_opt(obj, name, NULL);
-    void *dst;
-    if(!o || o->offset<=0)
-        goto error;
-
-    dst= ((uint8_t*)obj) + o->offset;
-
-    if(o_out) *o_out= o;
-
-    switch(o->type){
-    case FF_OPT_TYPE_FLAGS:   
-    case FF_OPT_TYPE_INT:       *intnum= *(int    *)dst;return 0;
-    case FF_OPT_TYPE_INT64:     *intnum= *(int64_t*)dst;return 0;
-    case FF_OPT_TYPE_FLOAT:     *num=    *(float  *)dst;return 0;
-    case FF_OPT_TYPE_DOUBLE:    *num=    *(double *)dst;return 0;
-    case FF_OPT_TYPE_RATIONAL:  *intnum= ((AVRational*)dst)->num; 
-                                *den   = ((AVRational*)dst)->den;
-                                                        return 0;
-    }
-error:
-    *den=*intnum=0;
-    return -1;
-}
-
-double av_get_double(void *obj, const char *name, AVOption **o_out){
-    int64_t intnum=1;
-    double num=1;
-    int den=1;
-
-    av_get_number(obj, name, o_out, &num, &den, &intnum);
-    return num*intnum/den;
-}
-
-AVRational av_get_q(void *obj, const char *name, AVOption **o_out){
-    int64_t intnum=1;
-    double num=1;
-    int den=1;
-
-    av_get_number(obj, name, o_out, &num, &den, &intnum);
-    if(num == 1.0 && (int)intnum == intnum)
-        return (AVRational){intnum, den};
-    else
-        return av_d2q(num*intnum/den, 1<<24);
-}
-
-int64_t av_get_int(void *obj, const char *name, AVOption **o_out){
-    int64_t intnum=1;
-    double num=1;
-    int den=1;
-
-    av_get_number(obj, name, o_out, &num, &den, &intnum);
-    return num*intnum/den;
-}
-
-int av_opt_show(void *obj, void *av_log_obj){
-    AVOption *opt=NULL;
-    
-    if(!obj)
-        return -1;
-
-    av_log(av_log_obj, AV_LOG_INFO, "%s AVOptions:\n", (*(AVClass**)obj)->class_name);
-
-    while((opt= av_next_option(obj, opt))){
-        if(!(opt->flags & (AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM)))
-            continue;
-            
-        av_log(av_log_obj, AV_LOG_INFO, "-%-17s ", opt->name);
-        av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.');
-        av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.');
-        av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_VIDEO_PARAM   ) ? 'V' : '.');
-        av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_AUDIO_PARAM   ) ? 'A' : '.');
-        av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.');
-        
-        av_log(av_log_obj, AV_LOG_INFO, " %s\n", opt->help);
-    }
-    return 0;
-}
diff --git a/ffmpeg.src/libavcodec/opt.h b/ffmpeg.src/libavcodec/opt.h
deleted file mode 100644
index c84db00..0000000
--- a/ffmpeg.src/libavcodec/opt.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef AVOPT_H
-#define AVOPT_H
-
-/**
- * @file opt.h
- * AVOptions
- */
-
-enum AVOptionType{
-    FF_OPT_TYPE_FLAGS,
-    FF_OPT_TYPE_INT,
-    FF_OPT_TYPE_INT64,
-    FF_OPT_TYPE_DOUBLE,
-    FF_OPT_TYPE_FLOAT,
-    FF_OPT_TYPE_STRING,
-    FF_OPT_TYPE_RATIONAL,
-    FF_OPT_TYPE_CONST=128,
-};
-
-/**
- * AVOption.
- */
-typedef struct AVOption {
-    const char *name;
-
-    /**
-     * short English text help.
-     * @fixme what about other languages
-     */
-    const char *help;
-    int offset;             ///< offset to context structure where the parsed value should be stored 
-    enum AVOptionType type;
-    
-    double default_val;
-    double min;
-    double max;
-    
-    int flags;
-#define AV_OPT_FLAG_ENCODING_PARAM  1   ///< a generic parameter which can be set by the user for muxing or encoding
-#define AV_OPT_FLAG_DECODING_PARAM  2   ///< a generic parameter which can be set by the user for demuxing or decoding
-#define AV_OPT_FLAG_METADATA        4   ///< some data extracted or inserted into the file like title, comment, ...
-#define AV_OPT_FLAG_AUDIO_PARAM     8
-#define AV_OPT_FLAG_VIDEO_PARAM     16
-#define AV_OPT_FLAG_SUBTITLE_PARAM  32
-//FIXME think about enc-audio, ... style flags
-    const char *unit;
-} AVOption;
-
-
-AVOption *av_set_string(void *obj, const char *name, const char *val);
-AVOption *av_set_double(void *obj, const char *name, double n);
-AVOption *av_set_q(void *obj, const char *name, AVRational n);
-AVOption *av_set_int(void *obj, const char *name, int64_t n);
-double av_get_double(void *obj, const char *name, AVOption **o_out);
-AVRational av_get_q(void *obj, const char *name, AVOption **o_out);
-int64_t av_get_int(void *obj, const char *name, AVOption **o_out);
-const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *buf, int buf_len);
-AVOption *av_next_option(void *obj, AVOption *last);
-int av_opt_show(void *obj, void *av_log_obj);
-
-#endif
diff --git a/ffmpeg.src/libavcodec/parser.c b/ffmpeg.src/libavcodec/parser.c
deleted file mode 100644
index 06cb7d1..0000000
--- a/ffmpeg.src/libavcodec/parser.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/*
- * Audio and Video frame extraction
- * Copyright (c) 2003 Fabrice Bellard.
- * Copyright (c) 2003 Michael Niedermayer.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avcodec.h"
-#include "mpegvideo.h"
-#include "mpegaudio.h"
-
-AVCodecParser *av_first_parser = NULL;
-
-void av_register_codec_parser(AVCodecParser *parser)
-{
-    parser->next = av_first_parser;
-    av_first_parser = parser;
-}
-
-AVCodecParserContext *av_parser_init(int codec_id)
-{
-    AVCodecParserContext *s;
-    AVCodecParser *parser;
-    int ret;
-    
-    if(codec_id == CODEC_ID_NONE)
-        return NULL;
-
-    for(parser = av_first_parser; parser != NULL; parser = parser->next) {
-        if (parser->codec_ids[0] == codec_id ||
-            parser->codec_ids[1] == codec_id ||
-            parser->codec_ids[2] == codec_id ||
-            parser->codec_ids[3] == codec_id ||
-            parser->codec_ids[4] == codec_id)
-            goto found;
-    }
-    return NULL;
- found:
-    s = av_mallocz(sizeof(AVCodecParserContext));
-    if (!s)
-        return NULL;
-    s->parser = parser;
-    s->priv_data = av_mallocz(parser->priv_data_size);
-    if (!s->priv_data) {
-        av_free(s);
-        return NULL;
-    }
-    if (parser->parser_init) {
-        ret = parser->parser_init(s);
-        if (ret != 0) {
-            av_free(s->priv_data);
-            av_free(s);
-            return NULL;
-        }
-    }
-    s->fetch_timestamp=1;
-    return s;
-}
-
-/* NOTE: buf_size == 0 is used to signal EOF so that the last frame
-   can be returned if necessary */
-int av_parser_parse(AVCodecParserContext *s, 
-                    AVCodecContext *avctx,
-                    uint8_t **poutbuf, int *poutbuf_size, 
-                    const uint8_t *buf, int buf_size,
-                    int64_t pts, int64_t dts)
-{
-    int index, i, k;
-    uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE];
-    
-    if (buf_size == 0) {
-        /* padding is always necessary even if EOF, so we add it here */
-        memset(dummy_buf, 0, sizeof(dummy_buf));
-        buf = dummy_buf;
-    } else {
-        /* add a new packet descriptor */
-        k = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1);
-        s->cur_frame_start_index = k;
-        s->cur_frame_offset[k] = s->cur_offset;
-        s->cur_frame_pts[k] = pts;
-        s->cur_frame_dts[k] = dts;
-
-        /* fill first PTS/DTS */
-        if (s->fetch_timestamp){
-            s->fetch_timestamp=0;
-            s->last_pts = pts;
-            s->last_dts = dts;
-            s->cur_frame_pts[k] =
-            s->cur_frame_dts[k] = AV_NOPTS_VALUE;
-        }
-    }
-
-    /* WARNING: the returned index can be negative */
-    index = s->parser->parser_parse(s, avctx, poutbuf, poutbuf_size, buf, buf_size);
-//av_log(NULL, AV_LOG_DEBUG, "parser: in:%lld, %lld, out:%lld, %lld, in:%d out:%d id:%d\n", pts, dts, s->last_pts, s->last_dts, buf_size, *poutbuf_size, avctx->codec_id);
-    /* update the file pointer */
-    if (*poutbuf_size) {
-        /* fill the data for the current frame */
-        s->frame_offset = s->last_frame_offset;
-        s->pts = s->last_pts;
-        s->dts = s->last_dts;
-        
-        /* offset of the next frame */
-        s->last_frame_offset = s->cur_offset + index;
-        /* find the packet in which the new frame starts. It
-           is tricky because of MPEG video start codes
-           which can begin in one packet and finish in
-           another packet. In the worst case, an MPEG
-           video start code could be in 4 different
-           packets. */
-        k = s->cur_frame_start_index;
-        for(i = 0; i < AV_PARSER_PTS_NB; i++) {
-            if (s->last_frame_offset >= s->cur_frame_offset[k])
-                break;
-            k = (k - 1) & (AV_PARSER_PTS_NB - 1);
-        }
-
-        s->last_pts = s->cur_frame_pts[k];
-        s->last_dts = s->cur_frame_dts[k];
-        
-        /* some parsers tell us the packet size even before seeing the first byte of the next packet,
-           so the next pts/dts is in the next chunk */
-        if(index == buf_size){
-            s->fetch_timestamp=1;
-        }
-    }
-    if (index < 0)
-        index = 0;
-    s->cur_offset += index;
-    return index;
-}
-
-/**
- *
- * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed
- */
-int av_parser_change(AVCodecParserContext *s,
-                     AVCodecContext *avctx,
-                     uint8_t **poutbuf, int *poutbuf_size, 
-                     const uint8_t *buf, int buf_size, int keyframe){
-   
-    if(s && s->parser->split){
-        if((avctx->flags & CODEC_FLAG_GLOBAL_HEADER) || (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)){
-            int i= s->parser->split(avctx, buf, buf_size);
-            buf += i;
-            buf_size -= i;
-        }
-    }
-
-    /* cast to avoid warning about discarding qualifiers */
-    *poutbuf= (uint8_t *) buf;
-    *poutbuf_size= buf_size;
-    if(avctx->extradata){
-        if(  (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER))
-            /*||(s->pict_type != I_TYPE && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_NOKEY))*/
-            /*||(? && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_BEGIN)*/){
-            int size= buf_size + avctx->extradata_size;
-            *poutbuf_size= size;
-            *poutbuf= av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
-            
-            memcpy(*poutbuf, avctx->extradata, avctx->extradata_size);
-            memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
-            return 1;
-        }
-    }
-
-    return 0;
-}
-
-void av_parser_close(AVCodecParserContext *s)
-{
-    if (s->parser->parser_close)
-        s->parser->parser_close(s);
-    av_free(s->priv_data);
-    av_free(s);
-}
-
-/*****************************************************/
-
-//#define END_NOT_FOUND (-100)
-
-#define PICTURE_START_CODE	0x00000100
-#define SEQ_START_CODE		0x000001b3
-#define EXT_START_CODE		0x000001b5
-#define SLICE_MIN_START_CODE	0x00000101
-#define SLICE_MAX_START_CODE	0x000001af
-
-typedef struct ParseContext1{
-    ParseContext pc;
-/* XXX/FIXME PC1 vs. PC */
-    /* MPEG2 specific */
-    int frame_rate;
-    int progressive_sequence;
-    int width, height;
-
-    /* XXX: suppress that, needed by MPEG4 */
-    MpegEncContext *enc;
-    int first_picture;
-} ParseContext1;
-
-/**
- * combines the (truncated) bitstream to a complete frame
- * @returns -1 if no complete frame could be created
- */
-int ff_combine_frame(ParseContext *pc, int next, uint8_t **buf, int *buf_size)
-{
-#if 0
-    if(pc->overread){
-        printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index);
-        printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
-    }
-#endif
-
-    /* copy overreaded bytes from last frame into buffer */
-    for(; pc->overread>0; pc->overread--){
-        pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
-    }
-
-    /* flush remaining if EOF */
-    if(!*buf_size && next == END_NOT_FOUND){
-        next= 0;
-    }
-
-    pc->last_index= pc->index;
-
-    /* copy into buffer end return */
-    if(next == END_NOT_FOUND){
-        pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
-
-        memcpy(&pc->buffer[pc->index], *buf, *buf_size);
-        pc->index += *buf_size;
-        return -1;
-    }
-
-    *buf_size=
-    pc->overread_index= pc->index + next;
-    
-    /* append to buffer */
-    if(pc->index){
-        pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
-
-        memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE );
-        pc->index = 0;
-        *buf= pc->buffer;
-    }
-
-    /* store overread bytes */
-    for(;next < 0; next++){
-        pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next];
-        pc->overread++;
-    }
-
-#if 0
-    if(pc->overread){
-        printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index);
-        printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
-    }
-#endif
-
-    return 0;
-}
-
-static int find_start_code(const uint8_t **pbuf_ptr, const uint8_t *buf_end)
-{
-    const uint8_t *buf_ptr;
-    unsigned int state=0xFFFFFFFF, v;
-    int val;
-
-    buf_ptr = *pbuf_ptr;
-    while (buf_ptr < buf_end) {
-        v = *buf_ptr++;
-        if (state == 0x000001) {
-            state = ((state << 8) | v) & 0xffffff;
-            val = state;
-            goto found;
-        }
-        state = ((state << 8) | v) & 0xffffff;
-    }
-    val = -1;
- found:
-    *pbuf_ptr = buf_ptr;
-    return val;
-}
-
-/* XXX: merge with libavcodec ? */
-#define MPEG1_FRAME_RATE_BASE 1001
-
-static const int frame_rate_tab[16] = {
-        0,        
-    24000,
-    24024,
-    25025,
-    30000,
-    30030,
-    50050,
-    60000,
-    60060,
-  // Xing's 15fps: (9)
-    15015,
-  // libmpeg3's "Unofficial economy rates": (10-13)
-     5005,
-    10010,
-    12012,
-    15015,
-  // random, just to avoid segfault !never encode these
-    25025,
-    25025,
-};
-
-//FIXME move into mpeg12.c
-static void mpegvideo_extract_headers(AVCodecParserContext *s, 
-                                      AVCodecContext *avctx,
-                                      const uint8_t *buf, int buf_size)
-{
-    ParseContext1 *pc = s->priv_data;
-    const uint8_t *buf_end;
-    int32_t start_code;
-    int frame_rate_index, ext_type, bytes_left;
-    int frame_rate_ext_n, frame_rate_ext_d;
-    int picture_structure, top_field_first, repeat_first_field, progressive_frame;
-    int horiz_size_ext, vert_size_ext, bit_rate_ext;
-//FIXME replace the crap with get_bits()
-    s->repeat_pict = 0;
-    buf_end = buf + buf_size;
-    while (buf < buf_end) {
-        start_code = find_start_code(&buf, buf_end);
-        bytes_left = buf_end - buf;
-        switch(start_code) {
-        case PICTURE_START_CODE:
-            if (bytes_left >= 2) {
-                s->pict_type = (buf[1] >> 3) & 7;
-            }
-            break;
-        case SEQ_START_CODE:
-            if (bytes_left >= 7) {
-                pc->width  = (buf[0] << 4) | (buf[1] >> 4);
-                pc->height = ((buf[1] & 0x0f) << 8) | buf[2];
-                avcodec_set_dimensions(avctx, pc->width, pc->height);
-                frame_rate_index = buf[3] & 0xf;
-                pc->frame_rate = avctx->time_base.den = frame_rate_tab[frame_rate_index];
-                avctx->time_base.num = MPEG1_FRAME_RATE_BASE;
-                avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400;
-                avctx->codec_id = CODEC_ID_MPEG1VIDEO;
-                avctx->sub_id = 1;
-            }
-            break;
-        case EXT_START_CODE:
-            if (bytes_left >= 1) {
-                ext_type = (buf[0] >> 4);
-                switch(ext_type) {
-                case 0x1: /* sequence extension */
-                    if (bytes_left >= 6) {
-                        horiz_size_ext = ((buf[1] & 1) << 1) | (buf[2] >> 7);
-                        vert_size_ext = (buf[2] >> 5) & 3;
-                        bit_rate_ext = ((buf[2] & 0x1F)<<7) | (buf[3]>>1);
-                        frame_rate_ext_n = (buf[5] >> 5) & 3;
-                        frame_rate_ext_d = (buf[5] & 0x1f);
-                        pc->progressive_sequence = buf[1] & (1 << 3);
-                        avctx->has_b_frames= !(buf[5] >> 7);
-
-                        pc->width  |=(horiz_size_ext << 12);
-                        pc->height |=( vert_size_ext << 12);
-                        avctx->bit_rate += (bit_rate_ext << 18) * 400;
-                        avcodec_set_dimensions(avctx, pc->width, pc->height);
-                        avctx->time_base.den = pc->frame_rate * (frame_rate_ext_n + 1);
-                        avctx->time_base.num = MPEG1_FRAME_RATE_BASE * (frame_rate_ext_d + 1);
-                        avctx->codec_id = CODEC_ID_MPEG2VIDEO;
-                        avctx->sub_id = 2; /* forces MPEG2 */
-                    }
-                    break;
-                case 0x8: /* picture coding extension */
-                    if (bytes_left >= 5) {
-                        picture_structure = buf[2]&3;
-                        top_field_first = buf[3] & (1 << 7);
-                        repeat_first_field = buf[3] & (1 << 1);
-                        progressive_frame = buf[4] & (1 << 7);
-                    
-                        /* check if we must repeat the frame */
-                        if (repeat_first_field) {
-                            if (pc->progressive_sequence) {
-                                if (top_field_first)
-                                    s->repeat_pict = 4;
-                                else
-                                    s->repeat_pict = 2;
-                            } else if (progressive_frame) {
-                                s->repeat_pict = 1;
-                            }
-                        }
-                        
-                        /* the packet only represents half a frame 
-                           XXX,FIXME maybe find a different solution */
-                        if(picture_structure != 3)
-                            s->repeat_pict = -1;
-                    }
-                    break;
-                }
-            }
-            break;
-        case -1:
-            goto the_end;
-        default:
-            /* we stop parsing when we encounter a slice. It ensures
-               that this function takes a negligible amount of time */
-            if (start_code >= SLICE_MIN_START_CODE && 
-                start_code <= SLICE_MAX_START_CODE)
-                goto the_end;
-            break;
-        }
-    }
- the_end: ;
-}
-
-static int mpegvideo_parse(AVCodecParserContext *s,
-                           AVCodecContext *avctx,
-                           uint8_t **poutbuf, int *poutbuf_size, 
-                           const uint8_t *buf, int buf_size)
-{
-    ParseContext1 *pc1 = s->priv_data;
-    ParseContext *pc= &pc1->pc;
-    int next;
-   
-    if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
-        next= buf_size;
-    }else{
-        next= ff_mpeg1_find_frame_end(pc, buf, buf_size);
-        
-        if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
-            *poutbuf = NULL;
-            *poutbuf_size = 0;
-            return buf_size;
-        }
-       
-    }
-    /* we have a full frame : we just parse the first few MPEG headers
-       to have the full timing information. The time take by this
-       function should be negligible for uncorrupted streams */
-    mpegvideo_extract_headers(s, avctx, buf, buf_size);
-#if 0
-    printf("pict_type=%d frame_rate=%0.3f repeat_pict=%d\n", 
-           s->pict_type, (double)avctx->time_base.den / avctx->time_base.num, s->repeat_pict);
-#endif
-
-    *poutbuf = (uint8_t *)buf;
-    *poutbuf_size = buf_size;
-    return next;
-}
-
-static int mpegvideo_split(AVCodecContext *avctx,
-                           const uint8_t *buf, int buf_size)
-{
-    int i;
-    uint32_t state= -1;
-    
-    for(i=0; i<buf_size; i++){
-        state= (state<<8) | buf[i];
-        if(state != 0x1B3 && state != 0x1B5 && state < 0x200 && state >= 0x100)
-            return i-3;
-    }
-    return 0;
-}
-
-void ff_parse_close(AVCodecParserContext *s)
-{
-    ParseContext *pc = s->priv_data;
-
-    av_free(pc->buffer);
-}
-
-static void parse1_close(AVCodecParserContext *s)
-{
-    ParseContext1 *pc1 = s->priv_data;
-
-    av_free(pc1->pc.buffer);
-    av_free(pc1->enc);
-}
-
-/*************************/
-
-/* used by parser */
-/* XXX: make it use less memory */
-static int av_mpeg4_decode_header(AVCodecParserContext *s1, 
-                                  AVCodecContext *avctx,
-                                  const uint8_t *buf, int buf_size)
-{
-    ParseContext1 *pc = s1->priv_data;
-    MpegEncContext *s = pc->enc;
-    GetBitContext gb1, *gb = &gb1;
-    int ret;
-
-    s->avctx = avctx;
-    s->current_picture_ptr = &s->current_picture;
-
-    if (avctx->extradata_size && pc->first_picture){
-        init_get_bits(gb, avctx->extradata, avctx->extradata_size*8);
-        ret = ff_mpeg4_decode_picture_header(s, gb);
-    }
-
-    init_get_bits(gb, buf, 8 * buf_size);
-    ret = ff_mpeg4_decode_picture_header(s, gb);
-    if (s->width) {
-        avcodec_set_dimensions(avctx, s->width, s->height);
-    }
-    s1->pict_type= s->pict_type;
-    pc->first_picture = 0;
-    return ret;
-}
-
-static int mpeg4video_parse_init(AVCodecParserContext *s)
-{
-    ParseContext1 *pc = s->priv_data;
-
-    pc->enc = av_mallocz(sizeof(MpegEncContext));
-    if (!pc->enc)
-        return -1;
-    pc->first_picture = 1;
-    return 0;
-}
-
-static int mpeg4video_parse(AVCodecParserContext *s,
-                           AVCodecContext *avctx,
-                           uint8_t **poutbuf, int *poutbuf_size, 
-                           const uint8_t *buf, int buf_size)
-{
-    ParseContext *pc = s->priv_data;
-    int next;
-    
-    if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
-        next= buf_size;
-    }else{
-        next= ff_mpeg4_find_frame_end(pc, buf, buf_size);
-    
-        if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
-            *poutbuf = NULL;
-            *poutbuf_size = 0;
-            return buf_size;
-        }
-    }
-    av_mpeg4_decode_header(s, avctx, buf, buf_size);
-
-    *poutbuf = (uint8_t *)buf;
-    *poutbuf_size = buf_size;
-    return next;
-}
-
-static int mpeg4video_split(AVCodecContext *avctx,
-                           const uint8_t *buf, int buf_size)
-{
-    int i;
-    uint32_t state= -1;
-    
-    for(i=0; i<buf_size; i++){
-        state= (state<<8) | buf[i];
-        if(state == 0x1B3 || state == 0x1B6)
-            return i-3;
-    }
-    return 0;
-}
-
-/*************************/
-
-typedef struct MpegAudioParseContext {
-    uint8_t inbuf[MPA_MAX_CODED_FRAME_SIZE];	/* input buffer */
-    uint8_t *inbuf_ptr;
-    int frame_size;
-    int free_format_frame_size;
-    int free_format_next_header;
-    uint32_t header;
-    int header_count;
-} MpegAudioParseContext;
-
-#define MPA_HEADER_SIZE 4
-
-/* header + layer + bitrate + freq + lsf/mpeg25 */
-#undef SAME_HEADER_MASK /* mpegaudio.h defines different version */
-#define SAME_HEADER_MASK \
-   (0xffe00000 | (3 << 17) | (3 << 10) | (3 << 19))
-
-static int mpegaudio_parse_init(AVCodecParserContext *s1)
-{
-    MpegAudioParseContext *s = s1->priv_data;
-    s->inbuf_ptr = s->inbuf;
-    return 0;
-}
-
-static int mpegaudio_parse(AVCodecParserContext *s1,
-                           AVCodecContext *avctx,
-                           uint8_t **poutbuf, int *poutbuf_size, 
-                           const uint8_t *buf, int buf_size)
-{
-    MpegAudioParseContext *s = s1->priv_data;
-    int len, ret, sr;
-    uint32_t header;
-    const uint8_t *buf_ptr;
-
-    *poutbuf = NULL;
-    *poutbuf_size = 0;
-    buf_ptr = buf;
-    while (buf_size > 0) {
-	len = s->inbuf_ptr - s->inbuf;
-	if (s->frame_size == 0) {
-            /* special case for next header for first frame in free
-               format case (XXX: find a simpler method) */
-            if (s->free_format_next_header != 0) {
-                s->inbuf[0] = s->free_format_next_header >> 24;
-                s->inbuf[1] = s->free_format_next_header >> 16;
-                s->inbuf[2] = s->free_format_next_header >> 8;
-                s->inbuf[3] = s->free_format_next_header;
-                s->inbuf_ptr = s->inbuf + 4;
-                s->free_format_next_header = 0;
-                goto got_header;
-            }
-	    /* no header seen : find one. We need at least MPA_HEADER_SIZE
-               bytes to parse it */
-	    len = MPA_HEADER_SIZE - len;
-	    if (len > buf_size)
-		len = buf_size;
-	    if (len > 0) {
-		memcpy(s->inbuf_ptr, buf_ptr, len);
-		buf_ptr += len;
-		buf_size -= len;
-		s->inbuf_ptr += len;
-	    }
-	    if ((s->inbuf_ptr - s->inbuf) >= MPA_HEADER_SIZE) {
-            got_header:
-                sr= avctx->sample_rate;
-		header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
-		    (s->inbuf[2] << 8) | s->inbuf[3];
-
-                ret = mpa_decode_header(avctx, header);
-                if (ret < 0) {
-                    s->header_count= -2;
-		    /* no sync found : move by one byte (inefficient, but simple!) */
-		    memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
-		    s->inbuf_ptr--;
-                    dprintf("skip %x\n", header);
-                    /* reset free format frame size to give a chance
-                       to get a new bitrate */
-                    s->free_format_frame_size = 0;
-		} else {
-                    if((header&SAME_HEADER_MASK) != (s->header&SAME_HEADER_MASK) && s->header)
-                        s->header_count= -3;
-                    s->header= header;
-                    s->header_count++;
-                    s->frame_size = ret;
-                    
-#if 0
-                    /* free format: prepare to compute frame size */
-		    if (decode_header(s, header) == 1) {
-			s->frame_size = -1;
-                    }
-#endif
-		}
-                if(s->header_count <= 0)
-                    avctx->sample_rate= sr; //FIXME ugly
-	    }
-        } else 
-#if 0
-        if (s->frame_size == -1) {
-            /* free format : find next sync to compute frame size */
-	    len = MPA_MAX_CODED_FRAME_SIZE - len;
-	    if (len > buf_size)
-		len = buf_size;
-            if (len == 0) {
-		/* frame too long: resync */
-                s->frame_size = 0;
-		memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
-		s->inbuf_ptr--;
-            } else {
-                uint8_t *p, *pend;
-                uint32_t header1;
-                int padding;
-
-                memcpy(s->inbuf_ptr, buf_ptr, len);
-                /* check for header */
-                p = s->inbuf_ptr - 3;
-                pend = s->inbuf_ptr + len - 4;
-                while (p <= pend) {
-                    header = (p[0] << 24) | (p[1] << 16) |
-                        (p[2] << 8) | p[3];
-                    header1 = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
-                        (s->inbuf[2] << 8) | s->inbuf[3];
-                    /* check with high probability that we have a
-                       valid header */
-                    if ((header & SAME_HEADER_MASK) ==
-                        (header1 & SAME_HEADER_MASK)) {
-                        /* header found: update pointers */
-                        len = (p + 4) - s->inbuf_ptr;
-                        buf_ptr += len;
-                        buf_size -= len;
-                        s->inbuf_ptr = p;
-                        /* compute frame size */
-                        s->free_format_next_header = header;
-                        s->free_format_frame_size = s->inbuf_ptr - s->inbuf;
-                        padding = (header1 >> 9) & 1;
-                        if (s->layer == 1)
-                            s->free_format_frame_size -= padding * 4;
-                        else
-                            s->free_format_frame_size -= padding;
-                        dprintf("free frame size=%d padding=%d\n", 
-                                s->free_format_frame_size, padding);
-                        decode_header(s, header1);
-                        goto next_data;
-                    }
-                    p++;
-                }
-                /* not found: simply increase pointers */
-                buf_ptr += len;
-                s->inbuf_ptr += len;
-                buf_size -= len;
-            }
-	} else 
-#endif
-        if (len < s->frame_size) {
-            if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)
-                s->frame_size = MPA_MAX_CODED_FRAME_SIZE;
-	    len = s->frame_size - len;
-	    if (len > buf_size)
-		len = buf_size;
-	    memcpy(s->inbuf_ptr, buf_ptr, len);
-	    buf_ptr += len;
-	    s->inbuf_ptr += len;
-	    buf_size -= len;
-	}
-        //    next_data:
-        if (s->frame_size > 0 && 
-            (s->inbuf_ptr - s->inbuf) >= s->frame_size) {
-            if(s->header_count > 0){
-                *poutbuf = s->inbuf;
-                *poutbuf_size = s->inbuf_ptr - s->inbuf;
-            }
-	    s->inbuf_ptr = s->inbuf;
-	    s->frame_size = 0;
-	    break;
-	}
-    }
-    return buf_ptr - buf;
-}
-
-#ifdef CONFIG_AC3
-#ifdef CONFIG_A52BIN
-extern int ff_a52_syncinfo (AVCodecContext * avctx, const uint8_t * buf,
-                       int * flags, int * sample_rate, int * bit_rate);
-#else
-extern int a52_syncinfo (const uint8_t * buf, int * flags,
-                         int * sample_rate, int * bit_rate);
-#endif
-
-typedef struct AC3ParseContext {
-    uint8_t inbuf[4096]; /* input buffer */
-    uint8_t *inbuf_ptr;
-    int frame_size;
-    int flags;
-} AC3ParseContext;
-
-#define AC3_HEADER_SIZE 7
-#define A52_LFE 16
-
-static int ac3_parse_init(AVCodecParserContext *s1)
-{
-    AC3ParseContext *s = s1->priv_data;
-    s->inbuf_ptr = s->inbuf;
-    return 0;
-}
-
-static int ac3_parse(AVCodecParserContext *s1,
-                     AVCodecContext *avctx,
-                     uint8_t **poutbuf, int *poutbuf_size, 
-                     const uint8_t *buf, int buf_size)
-{
-    AC3ParseContext *s = s1->priv_data;
-    const uint8_t *buf_ptr;
-    int len, sample_rate, bit_rate;
-    static const int ac3_channels[8] = {
-	2, 1, 2, 3, 3, 4, 4, 5
-    };
-
-    *poutbuf = NULL;
-    *poutbuf_size = 0;
-
-    buf_ptr = buf;
-    while (buf_size > 0) {
-        len = s->inbuf_ptr - s->inbuf;
-        if (s->frame_size == 0) {
-            /* no header seen : find one. We need at least 7 bytes to parse it */
-            len = AC3_HEADER_SIZE - len;
-            if (len > buf_size)
-                len = buf_size;
-            memcpy(s->inbuf_ptr, buf_ptr, len);
-            buf_ptr += len;
-            s->inbuf_ptr += len;
-            buf_size -= len;
-            if ((s->inbuf_ptr - s->inbuf) == AC3_HEADER_SIZE) {
-#ifdef CONFIG_A52BIN
-                len = ff_a52_syncinfo(avctx, s->inbuf, &s->flags, &sample_rate, &bit_rate);
-#else
-                len = a52_syncinfo(s->inbuf, &s->flags, &sample_rate, &bit_rate);
-#endif
-                if (len == 0) {
-                    /* no sync found : move by one byte (inefficient, but simple!) */
-                    memmove(s->inbuf, s->inbuf + 1, AC3_HEADER_SIZE - 1);
-                    s->inbuf_ptr--;
-                } else {
-		    s->frame_size = len;
-                    /* update codec info */
-                    avctx->sample_rate = sample_rate;
-                    /* set channels,except if the user explicitly requests 1 or 2 channels, XXX/FIXME this is a bit ugly */
-                    if(avctx->channels!=1 && avctx->channels!=2){
-                        avctx->channels = ac3_channels[s->flags & 7];
-                        if (s->flags & A52_LFE)
-                            avctx->channels++;
-                    }
-		    avctx->bit_rate = bit_rate;
-                    avctx->frame_size = 6 * 256;
-                }
-            }
-        } else if (len < s->frame_size) {
-            len = s->frame_size - len;
-            if (len > buf_size)
-                len = buf_size;
-
-            memcpy(s->inbuf_ptr, buf_ptr, len);
-            buf_ptr += len;
-            s->inbuf_ptr += len;
-            buf_size -= len;
-        } else {
-            *poutbuf = s->inbuf;
-            *poutbuf_size = s->frame_size;
-            s->inbuf_ptr = s->inbuf;
-            s->frame_size = 0;
-            break;
-        }
-    }
-    return buf_ptr - buf;
-}
-#endif
-
-AVCodecParser mpegvideo_parser = {
-    { CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO },
-    sizeof(ParseContext1),
-    NULL,
-    mpegvideo_parse,
-    parse1_close,
-    mpegvideo_split,
-};
-
-AVCodecParser mpeg4video_parser = {
-    { CODEC_ID_MPEG4 },
-    sizeof(ParseContext1),
-    mpeg4video_parse_init,
-    mpeg4video_parse,
-    parse1_close,
-    mpeg4video_split,
-};
-
-AVCodecParser mpegaudio_parser = {
-    { CODEC_ID_MP2, CODEC_ID_MP3 },
-    sizeof(MpegAudioParseContext),
-    mpegaudio_parse_init,
-    mpegaudio_parse,
-    NULL,
-};
-
-#ifdef CONFIG_AC3
-AVCodecParser ac3_parser = {
-    { CODEC_ID_AC3 },
-    sizeof(AC3ParseContext),
-    ac3_parse_init,
-    ac3_parse,
-    NULL,
-};
-#endif
diff --git a/ffmpeg.src/libavcodec/pcm.c b/ffmpeg.src/libavcodec/pcm.c
deleted file mode 100644
index e3a81a5..0000000
--- a/ffmpeg.src/libavcodec/pcm.c
+++ /dev/null
@@ -1,546 +0,0 @@
-/*
- * PCM codecs
- * Copyright (c) 2001 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-/**
- * @file pcm.c
- * PCM codecs
- */
- 
-#include "avcodec.h"
-#include "bitstream.h" // for ff_reverse
-
-/* from g711.c by SUN microsystems (unrestricted use) */
-
-#define	SIGN_BIT	(0x80)		/* Sign bit for a A-law byte. */
-#define	QUANT_MASK	(0xf)		/* Quantization field mask. */
-#define	NSEGS		(8)		/* Number of A-law segments. */
-#define	SEG_SHIFT	(4)		/* Left shift for segment number. */
-#define	SEG_MASK	(0x70)		/* Segment field mask. */
-
-#define	BIAS		(0x84)		/* Bias for linear code. */
-
-/*
- * alaw2linear() - Convert an A-law value to 16-bit linear PCM
- *
- */
-static int alaw2linear(unsigned char	a_val)
-{
-	int		t;
-	int		seg;
-
-	a_val ^= 0x55;
-
-	t = a_val & QUANT_MASK;
-	seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT;
-	if(seg) t= (t + t + 1 + 32) << (seg + 2);
-	else    t= (t + t + 1     ) << 3;
-
-	return ((a_val & SIGN_BIT) ? t : -t);
-}
-
-static int ulaw2linear(unsigned char	u_val)
-{
-	int		t;
-
-	/* Complement to obtain normal u-law value. */
-	u_val = ~u_val;
-
-	/*
-	 * Extract and bias the quantization bits. Then
-	 * shift up by the segment number and subtract out the bias.
-	 */
-	t = ((u_val & QUANT_MASK) << 3) + BIAS;
-	t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT;
-
-	return ((u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS));
-}
-
-/* 16384 entries per table */
-static uint8_t *linear_to_alaw = NULL;
-static int linear_to_alaw_ref = 0;
-
-static uint8_t *linear_to_ulaw = NULL;
-static int linear_to_ulaw_ref = 0;
-
-static void build_xlaw_table(uint8_t *linear_to_xlaw, 
-                             int (*xlaw2linear)(unsigned char),
-                             int mask) 
-{
-    int i, j, v, v1, v2;
-
-    j = 0;
-    for(i=0;i<128;i++) {
-        if (i != 127) {
-            v1 = xlaw2linear(i ^ mask);
-            v2 = xlaw2linear((i + 1) ^ mask);
-            v = (v1 + v2 + 4) >> 3;
-        } else {
-            v = 8192;
-        }
-        for(;j<v;j++) {
-            linear_to_xlaw[8192 + j] = (i ^ mask);
-            if (j > 0)
-                linear_to_xlaw[8192 - j] = (i ^ (mask ^ 0x80));
-        }
-    }
-    linear_to_xlaw[0] = linear_to_xlaw[1];
-}
-
-static int pcm_encode_init(AVCodecContext *avctx)
-{
-    avctx->frame_size = 1;
-    switch(avctx->codec->id) {
-    case CODEC_ID_PCM_ALAW:
-        if (linear_to_alaw_ref == 0) {
-            linear_to_alaw = av_malloc(16384);
-            if (!linear_to_alaw)
-                return -1;
-            build_xlaw_table(linear_to_alaw, alaw2linear, 0xd5);
-        }
-        linear_to_alaw_ref++;
-        break;
-    case CODEC_ID_PCM_MULAW:
-        if (linear_to_ulaw_ref == 0) {
-            linear_to_ulaw = av_malloc(16384);
-            if (!linear_to_ulaw)
-                return -1;
-            build_xlaw_table(linear_to_ulaw, ulaw2linear, 0xff);
-        }
-        linear_to_ulaw_ref++;
-        break;
-    default:
-        break;
-    }
-    
-    switch(avctx->codec->id) {
-    case CODEC_ID_PCM_S32LE:
-    case CODEC_ID_PCM_S32BE:
-    case CODEC_ID_PCM_U32LE:
-    case CODEC_ID_PCM_U32BE:
-        avctx->block_align = 4 * avctx->channels;
-        break;
-    case CODEC_ID_PCM_S24LE:
-    case CODEC_ID_PCM_S24BE:
-    case CODEC_ID_PCM_U24LE:
-    case CODEC_ID_PCM_U24BE:
-    case CODEC_ID_PCM_S24DAUD:
-        avctx->block_align = 3 * avctx->channels;
-        break;
-    case CODEC_ID_PCM_S16LE:
-    case CODEC_ID_PCM_S16BE:
-    case CODEC_ID_PCM_U16LE:
-    case CODEC_ID_PCM_U16BE:
-        avctx->block_align = 2 * avctx->channels;
-        break;
-    case CODEC_ID_PCM_S8:
-    case CODEC_ID_PCM_U8:
-    case CODEC_ID_PCM_MULAW:
-    case CODEC_ID_PCM_ALAW:
-        avctx->block_align = avctx->channels;
-        break;
-    default:
-        break;
-    }
-
-    avctx->coded_frame= avcodec_alloc_frame();
-    avctx->coded_frame->key_frame= 1;
-    
-    return 0;
-}
-
-static int pcm_encode_close(AVCodecContext *avctx)
-{
-    av_freep(&avctx->coded_frame);
-
-    switch(avctx->codec->id) {
-    case CODEC_ID_PCM_ALAW:
-        if (--linear_to_alaw_ref == 0)
-            av_free(linear_to_alaw);
-        break;
-    case CODEC_ID_PCM_MULAW:
-        if (--linear_to_ulaw_ref == 0)
-            av_free(linear_to_ulaw);
-        break;
-    default:
-        /* nothing to free */
-        break;
-    }
-    return 0;
-}
-
-/**
- * \brief convert samples from 16 bit
- * \param bps byte per sample for the destination format, must be >= 2
- * \param le 0 for big-, 1 for little-endian
- * \param us 0 for signed, 1 for unsigned output
- * \param samples input samples
- * \param dst output samples
- * \param n number of samples in samples buffer.
- */
-static inline void encode_from16(int bps, int le, int us,
-                               short **samples, uint8_t **dst, int n) {
-    if (bps > 2)
-        memset(*dst, 0, n * bps);
-    if (le) *dst += bps - 2;
-    for(;n>0;n--) {
-        register int v = *(*samples)++;
-        if (us) v += 0x8000;
-        (*dst)[le] = v >> 8;
-        (*dst)[1 - le] = v;
-        *dst += bps;
-    }
-    if (le) *dst -= bps - 2;
-}
-
-static int pcm_encode_frame(AVCodecContext *avctx,
-			    unsigned char *frame, int buf_size, void *data)
-{
-    int n, sample_size, v;
-    short *samples;
-    unsigned char *dst;
-
-    switch(avctx->codec->id) {
-    case CODEC_ID_PCM_S32LE:
-    case CODEC_ID_PCM_S32BE:
-    case CODEC_ID_PCM_U32LE:
-    case CODEC_ID_PCM_U32BE:
-        sample_size = 4;
-        break;
-    case CODEC_ID_PCM_S24LE:
-    case CODEC_ID_PCM_S24BE:
-    case CODEC_ID_PCM_U24LE:
-    case CODEC_ID_PCM_U24BE:
-    case CODEC_ID_PCM_S24DAUD:
-        sample_size = 3;
-        break;
-    case CODEC_ID_PCM_S16LE:
-    case CODEC_ID_PCM_S16BE:
-    case CODEC_ID_PCM_U16LE:
-    case CODEC_ID_PCM_U16BE:
-        sample_size = 2;
-        break;
-    default:
-        sample_size = 1;
-        break;
-    }
-    n = buf_size / sample_size;
-    samples = data;
-    dst = frame;
-
-    switch(avctx->codec->id) {
-    case CODEC_ID_PCM_S32LE:
-        encode_from16(4, 1, 0, &samples, &dst, n);
-        break;
-    case CODEC_ID_PCM_S32BE:
-        encode_from16(4, 0, 0, &samples, &dst, n);
-        break;
-    case CODEC_ID_PCM_U32LE:
-        encode_from16(4, 1, 1, &samples, &dst, n);
-        break;
-    case CODEC_ID_PCM_U32BE:
-        encode_from16(4, 0, 1, &samples, &dst, n);
-        break;
-    case CODEC_ID_PCM_S24LE:
-        encode_from16(3, 1, 0, &samples, &dst, n);
-        break;
-    case CODEC_ID_PCM_S24BE:
-        encode_from16(3, 0, 0, &samples, &dst, n);
-        break;
-    case CODEC_ID_PCM_U24LE:
-        encode_from16(3, 1, 1, &samples, &dst, n);
-        break;
-    case CODEC_ID_PCM_U24BE:
-        encode_from16(3, 0, 1, &samples, &dst, n);
-        break;
-    case CODEC_ID_PCM_S24DAUD:
-        for(;n>0;n--) {
-            uint32_t tmp = ff_reverse[*samples >> 8] +
-                           (ff_reverse[*samples & 0xff] << 8);
-            tmp <<= 4; // sync flags would go here
-            dst[2] = tmp & 0xff;
-            tmp >>= 8;
-            dst[1] = tmp & 0xff;
-            dst[0] = tmp >> 8;
-            samples++;
-            dst += 3;
-        }
-        break;
-    case CODEC_ID_PCM_S16LE:
-        for(;n>0;n--) {
-            v = *samples++;
-            dst[0] = v & 0xff;
-            dst[1] = v >> 8;
-            dst += 2;
-        }
-        break;
-    case CODEC_ID_PCM_S16BE:
-        for(;n>0;n--) {
-            v = *samples++;
-            dst[0] = v >> 8;
-            dst[1] = v;
-            dst += 2;
-        }
-        break;
-    case CODEC_ID_PCM_U16LE:
-        for(;n>0;n--) {
-            v = *samples++;
-            v += 0x8000;
-            dst[0] = v & 0xff;
-            dst[1] = v >> 8;
-            dst += 2;
-        }
-        break;
-    case CODEC_ID_PCM_U16BE:
-        for(;n>0;n--) {
-            v = *samples++;
-            v += 0x8000;
-            dst[0] = v >> 8;
-            dst[1] = v;
-            dst += 2;
-        }
-        break;
-    case CODEC_ID_PCM_S8:
-        for(;n>0;n--) {
-            v = *samples++;
-            dst[0] = v >> 8;
-            dst++;
-        }
-        break;
-    case CODEC_ID_PCM_U8:
-        for(;n>0;n--) {
-            v = *samples++;
-            dst[0] = (v >> 8) + 128;
-            dst++;
-        }
-        break;
-    case CODEC_ID_PCM_ALAW:
-        for(;n>0;n--) {
-            v = *samples++;
-            dst[0] = linear_to_alaw[(v + 32768) >> 2];
-            dst++;
-        }
-        break;
-    case CODEC_ID_PCM_MULAW:
-        for(;n>0;n--) {
-            v = *samples++;
-            dst[0] = linear_to_ulaw[(v + 32768) >> 2];
-            dst++;
-        }
-        break;
-    default:
-        return -1;
-    }
-    //avctx->frame_size = (dst - frame) / (sample_size * avctx->channels);
-
-    return dst - frame;
-}
-
-typedef struct PCMDecode {
-    short table[256];
-} PCMDecode;
-
-static int pcm_decode_init(AVCodecContext * avctx)
-{
-    PCMDecode *s = avctx->priv_data;
-    int i;
-
-    switch(avctx->codec->id) {
-    case CODEC_ID_PCM_ALAW:
-        for(i=0;i<256;i++)
-            s->table[i] = alaw2linear(i);
-        break;
-    case CODEC_ID_PCM_MULAW:
-        for(i=0;i<256;i++)
-            s->table[i] = ulaw2linear(i);
-        break;
-    default:
-        break;
-    }
-    return 0;
-}
-
-/**
- * \brief convert samples to 16 bit
- * \param bps byte per sample for the source format, must be >= 2
- * \param le 0 for big-, 1 for little-endian
- * \param us 0 for signed, 1 for unsigned input
- * \param src input samples
- * \param samples output samples
- * \param src_len number of bytes in src
- */
-static inline void decode_to16(int bps, int le, int us,
-                               uint8_t **src, short **samples, int src_len)
-{
-    register int n = src_len / bps;
-    if (le) *src += bps - 2;
-    for(;n>0;n--) {
-        *(*samples)++ = ((*src)[le] << 8 | (*src)[1 - le]) - (us?0x8000:0);
-        *src += bps;
-    }
-    if (le) *src -= bps - 2;
-}
-
-static int pcm_decode_frame(AVCodecContext *avctx,
-			    void *data, int *data_size,
-			    uint8_t *buf, int buf_size)
-{
-    PCMDecode *s = avctx->priv_data;
-    int n;
-    short *samples;
-    uint8_t *src;
-
-    samples = data;
-    src = buf;
-
-    if(buf_size > AVCODEC_MAX_AUDIO_FRAME_SIZE/2)
-        buf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE/2;
-
-    switch(avctx->codec->id) {
-    case CODEC_ID_PCM_S32LE:
-        decode_to16(4, 1, 0, &src, &samples, buf_size);
-        break;
-    case CODEC_ID_PCM_S32BE:
-        decode_to16(4, 0, 0, &src, &samples, buf_size);
-        break;
-    case CODEC_ID_PCM_U32LE:
-        decode_to16(4, 1, 1, &src, &samples, buf_size);
-        break;
-    case CODEC_ID_PCM_U32BE:
-        decode_to16(4, 0, 1, &src, &samples, buf_size);
-        break;
-    case CODEC_ID_PCM_S24LE:
-        decode_to16(3, 1, 0, &src, &samples, buf_size);
-        break;
-    case CODEC_ID_PCM_S24BE:
-        decode_to16(3, 0, 0, &src, &samples, buf_size);
-        break;
-    case CODEC_ID_PCM_U24LE:
-        decode_to16(3, 1, 1, &src, &samples, buf_size);
-        break;
-    case CODEC_ID_PCM_U24BE:
-        decode_to16(3, 0, 1, &src, &samples, buf_size);
-        break;
-    case CODEC_ID_PCM_S24DAUD:
-        n = buf_size / 3;
-        for(;n>0;n--) {
-          uint32_t v = src[0] << 16 | src[1] << 8 | src[2];
-          v >>= 4; // sync flags are here
-          *samples++ = ff_reverse[(v >> 8) & 0xff] +
-                       (ff_reverse[v & 0xff] << 8);
-          src += 3;
-        }
-        break;
-    case CODEC_ID_PCM_S16LE:
-        n = buf_size >> 1;
-        for(;n>0;n--) {
-            *samples++ = src[0] | (src[1] << 8);
-            src += 2;
-        }
-        break;
-    case CODEC_ID_PCM_S16BE:
-        n = buf_size >> 1;
-        for(;n>0;n--) {
-            *samples++ = (src[0] << 8) | src[1];
-            src += 2;
-        }
-        break;
-    case CODEC_ID_PCM_U16LE:
-        n = buf_size >> 1;
-        for(;n>0;n--) {
-            *samples++ = (src[0] | (src[1] << 8)) - 0x8000;
-            src += 2;
-        }
-        break;
-    case CODEC_ID_PCM_U16BE:
-        n = buf_size >> 1;
-        for(;n>0;n--) {
-            *samples++ = ((src[0] << 8) | src[1]) - 0x8000;
-            src += 2;
-        }
-        break;
-    case CODEC_ID_PCM_S8:
-        n = buf_size;
-        for(;n>0;n--) {
-            *samples++ = src[0] << 8;
-            src++;
-        }
-        break;
-    case CODEC_ID_PCM_U8:
-        n = buf_size;
-        for(;n>0;n--) {
-            *samples++ = ((int)src[0] - 128) << 8;
-            src++;
-        }
-        break;
-    case CODEC_ID_PCM_ALAW:
-    case CODEC_ID_PCM_MULAW:
-        n = buf_size;
-        for(;n>0;n--) {
-            *samples++ = s->table[src[0]];
-            src++;
-        }
-        break;
-    default:
-        return -1;
-    }
-    *data_size = (uint8_t *)samples - (uint8_t *)data;
-    return src - buf;
-}
-
-#define PCM_CODEC(id, name)                     \
-AVCodec name ## _encoder = {                    \
-    #name,                                      \
-    CODEC_TYPE_AUDIO,                           \
-    id,                                         \
-    0,                                          \
-    pcm_encode_init,				\
-    pcm_encode_frame,				\
-    pcm_encode_close,				\
-    NULL,                                       \
-};                                              \
-AVCodec name ## _decoder = {                    \
-    #name,                                      \
-    CODEC_TYPE_AUDIO,                           \
-    id,                                         \
-    sizeof(PCMDecode),                          \
-    pcm_decode_init,				\
-    NULL,                                       \
-    NULL,                                       \
-    pcm_decode_frame,                           \
-}
-
-PCM_CODEC(CODEC_ID_PCM_S32LE, pcm_s32le);
-PCM_CODEC(CODEC_ID_PCM_S32BE, pcm_s32be);
-PCM_CODEC(CODEC_ID_PCM_U32LE, pcm_u32le);
-PCM_CODEC(CODEC_ID_PCM_U32BE, pcm_u32be);
-PCM_CODEC(CODEC_ID_PCM_S24LE, pcm_s24le);
-PCM_CODEC(CODEC_ID_PCM_S24BE, pcm_s24be);
-PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le);
-PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be);
-PCM_CODEC(CODEC_ID_PCM_S24DAUD, pcm_s24daud);
-PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
-PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
-PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
-PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
-PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
-PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
-PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
-PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
-
-#undef PCM_CODEC
diff --git a/ffmpeg.src/libavcodec/pnm.c b/ffmpeg.src/libavcodec/pnm.c
deleted file mode 100644
index 1df6184..0000000
--- a/ffmpeg.src/libavcodec/pnm.c
+++ /dev/null
@@ -1,594 +0,0 @@
-/*
- * PNM image format
- * Copyright (c) 2002, 2003 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avcodec.h"
-#include "mpegvideo.h" //only for ParseContext
-
-typedef struct PNMContext {
-    uint8_t *bytestream;
-    uint8_t *bytestream_start;
-    uint8_t *bytestream_end;
-    AVFrame picture;
-} PNMContext;
-
-static inline int pnm_space(int c)  
-{
-    return (c == ' ' || c == '\n' || c == '\r' || c == '\t');
-}
-
-static void pnm_get(PNMContext *sc, char *str, int buf_size) 
-{
-    char *s;
-    int c;
-    
-    /* skip spaces and comments */
-    for(;;) {
-        c = *sc->bytestream++;
-        if (c == '#')  {
-            do  {
-                c = *sc->bytestream++;
-            } while (c != '\n' && sc->bytestream < sc->bytestream_end);
-        } else if (!pnm_space(c)) {
-            break;
-        }
-    }
-    
-    s = str;
-    while (sc->bytestream < sc->bytestream_end && !pnm_space(c)) {
-        if ((s - str)  < buf_size - 1)
-            *s++ = c;
-        c = *sc->bytestream++;
-    }
-    *s = '\0';
-}
-
-static int common_init(AVCodecContext *avctx){
-    PNMContext *s = avctx->priv_data;
-
-    avcodec_get_frame_defaults((AVFrame*)&s->picture);
-    avctx->coded_frame= (AVFrame*)&s->picture;
-
-    return 0;
-}
-
-static int pnm_decode_header(AVCodecContext *avctx, PNMContext * const s){
-    char buf1[32], tuple_type[32];
-    int h, w, depth, maxval;;
-
-    pnm_get(s, buf1, sizeof(buf1));
-    if (!strcmp(buf1, "P4")) {
-        avctx->pix_fmt = PIX_FMT_MONOWHITE;
-    } else if (!strcmp(buf1, "P5")) {
-        if (avctx->codec_id == CODEC_ID_PGMYUV) 
-            avctx->pix_fmt = PIX_FMT_YUV420P;
-        else
-            avctx->pix_fmt = PIX_FMT_GRAY8;
-    } else if (!strcmp(buf1, "P6")) {
-        avctx->pix_fmt = PIX_FMT_RGB24;
-    } else if (!strcmp(buf1, "P7")) {
-        w = -1;
-        h = -1;
-        maxval = -1;
-        depth = -1;
-        tuple_type[0] = '\0';
-        for(;;) {
-            pnm_get(s, buf1, sizeof(buf1));
-            if (!strcmp(buf1, "WIDTH")) {
-                pnm_get(s, buf1, sizeof(buf1));
-                w = strtol(buf1, NULL, 10);
-            } else if (!strcmp(buf1, "HEIGHT")) {
-                pnm_get(s, buf1, sizeof(buf1));
-                h = strtol(buf1, NULL, 10);
-            } else if (!strcmp(buf1, "DEPTH")) {
-                pnm_get(s, buf1, sizeof(buf1));
-                depth = strtol(buf1, NULL, 10);
-            } else if (!strcmp(buf1, "MAXVAL")) {
-                pnm_get(s, buf1, sizeof(buf1));
-                maxval = strtol(buf1, NULL, 10);
-            } else if (!strcmp(buf1, "TUPLETYPE")) {
-                pnm_get(s, tuple_type, sizeof(tuple_type));
-            } else if (!strcmp(buf1, "ENDHDR")) {
-                break;
-            } else {
-                return -1;
-            }
-        }
-        /* check that all tags are present */
-        if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0' || avcodec_check_dimensions(avctx, w, h))
-            return -1;
-                   
-        avctx->width = w;
-        avctx->height = h;
-        if (depth == 1) {
-            if (maxval == 1)
-                avctx->pix_fmt = PIX_FMT_MONOWHITE;
-            else 
-                avctx->pix_fmt = PIX_FMT_GRAY8;
-        } else if (depth == 3) {
-            avctx->pix_fmt = PIX_FMT_RGB24;
-        } else if (depth == 4) {
-            avctx->pix_fmt = PIX_FMT_RGBA32;
-        } else {
-            return -1;
-        }
-        return 0;
-    } else {
-        return -1;
-    }
-    pnm_get(s, buf1, sizeof(buf1));
-    avctx->width = atoi(buf1);
-    if (avctx->width <= 0)
-        return -1;
-    pnm_get(s, buf1, sizeof(buf1));
-    avctx->height = atoi(buf1);
-    if(avcodec_check_dimensions(avctx, avctx->width, avctx->height))
-        return -1;
-    if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
-        pnm_get(s, buf1, sizeof(buf1));
-    }
-
-    /* more check if YUV420 */
-    if (avctx->pix_fmt == PIX_FMT_YUV420P) {
-        if ((avctx->width & 1) != 0)
-            return -1;
-        h = (avctx->height * 2);
-        if ((h % 3) != 0)
-            return -1;
-        h /= 3;
-        avctx->height = h;
-    }
-    return 0;
-}
-
-static int pnm_decode_frame(AVCodecContext *avctx, 
-                        void *data, int *data_size,
-                        uint8_t *buf, int buf_size)
-{
-    PNMContext * const s = avctx->priv_data;
-    AVFrame *picture = data;
-    AVFrame * const p= (AVFrame*)&s->picture;
-    int i, n, linesize, h;
-    unsigned char *ptr;
-
-    s->bytestream_start=
-    s->bytestream= buf;
-    s->bytestream_end= buf + buf_size;
-    
-    if(pnm_decode_header(avctx, s) < 0)
-        return -1;
-    
-    if(p->data[0])
-        avctx->release_buffer(avctx, p);
-
-    p->reference= 0;
-    if(avctx->get_buffer(avctx, p) < 0){
-        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
-        return -1;
-    }
-    p->pict_type= FF_I_TYPE;
-    p->key_frame= 1;
-    
-    switch(avctx->pix_fmt) {
-    default:
-        return -1;
-    case PIX_FMT_RGB24:
-        n = avctx->width * 3;
-        goto do_read;
-    case PIX_FMT_GRAY8:
-        n = avctx->width;
-        goto do_read;
-    case PIX_FMT_MONOWHITE:
-    case PIX_FMT_MONOBLACK:
-        n = (avctx->width + 7) >> 3;
-    do_read:
-        ptr = p->data[0];
-        linesize = p->linesize[0];
-        if(s->bytestream + n*avctx->height > s->bytestream_end)
-            return -1;
-        for(i = 0; i < avctx->height; i++) {
-            memcpy(ptr, s->bytestream, n);
-            s->bytestream += n;
-            ptr += linesize;
-        }
-        break;
-    case PIX_FMT_YUV420P:
-        {
-            unsigned char *ptr1, *ptr2;
-
-            n = avctx->width;
-            ptr = p->data[0];
-            linesize = p->linesize[0];
-            if(s->bytestream + n*avctx->height*3/2 > s->bytestream_end)
-                return -1;
-            for(i = 0; i < avctx->height; i++) {
-                memcpy(ptr, s->bytestream, n);
-                s->bytestream += n;
-                ptr += linesize;
-            }
-            ptr1 = p->data[1];
-            ptr2 = p->data[2];
-            n >>= 1;
-            h = avctx->height >> 1;
-            for(i = 0; i < h; i++) {
-                memcpy(ptr1, s->bytestream, n);
-                s->bytestream += n;
-                memcpy(ptr2, s->bytestream, n);
-                s->bytestream += n;
-                ptr1 += p->linesize[1];
-                ptr2 += p->linesize[2];
-            }
-        }
-        break;
-    case PIX_FMT_RGBA32:
-        ptr = p->data[0];
-        linesize = p->linesize[0];
-        if(s->bytestream + avctx->width*avctx->height*4 > s->bytestream_end)
-            return -1;
-        for(i = 0; i < avctx->height; i++) {
-            int j, r, g, b, a;
-
-            for(j = 0;j < avctx->width; j++) {
-                r = *s->bytestream++;
-                g = *s->bytestream++;
-                b = *s->bytestream++;
-                a = *s->bytestream++;
-                ((uint32_t *)ptr)[j] = (a << 24) | (r << 16) | (g << 8) | b;
-            }
-            ptr += linesize;
-        }
-        break;
-    }
-    *picture= *(AVFrame*)&s->picture;
-    *data_size = sizeof(AVPicture);
-
-    return s->bytestream - s->bytestream_start;
-}
-
-static int pnm_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int buf_size, void *data){
-    PNMContext *s = avctx->priv_data;
-    AVFrame *pict = data;
-    AVFrame * const p= (AVFrame*)&s->picture;
-    int i, h, h1, c, n, linesize;
-    uint8_t *ptr, *ptr1, *ptr2;
-
-    if(buf_size < avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height) + 200){
-        av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
-        return -1;
-    }
-
-    *p = *pict;
-    p->pict_type= FF_I_TYPE;
-    p->key_frame= 1;
-    
-    s->bytestream_start=
-    s->bytestream= outbuf;
-    s->bytestream_end= outbuf+buf_size;
-
-    h = avctx->height;
-    h1 = h;
-    switch(avctx->pix_fmt) {
-    case PIX_FMT_MONOWHITE:
-        c = '4';
-        n = (avctx->width + 7) >> 3;
-        break;
-    case PIX_FMT_GRAY8:
-        c = '5';
-        n = avctx->width;
-        break;
-    case PIX_FMT_RGB24:
-        c = '6';
-        n = avctx->width * 3;
-        break;
-    case PIX_FMT_YUV420P:
-        c = '5';
-        n = avctx->width;
-        h1 = (h * 3) / 2;
-        break;
-    default:
-        return -1;
-    }
-    snprintf(s->bytestream, s->bytestream_end - s->bytestream, 
-             "P%c\n%d %d\n",
-             c, avctx->width, h1);
-    s->bytestream += strlen(s->bytestream);
-    if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
-        snprintf(s->bytestream, s->bytestream_end - s->bytestream, 
-                 "%d\n", 255);
-        s->bytestream += strlen(s->bytestream);
-    }
-
-    ptr = p->data[0];
-    linesize = p->linesize[0];
-    for(i=0;i<h;i++) {
-        memcpy(s->bytestream, ptr, n);
-        s->bytestream += n;
-        ptr += linesize;
-    }
-    
-    if (avctx->pix_fmt == PIX_FMT_YUV420P) {
-        h >>= 1;
-        n >>= 1;
-        ptr1 = p->data[1];
-        ptr2 = p->data[2];
-        for(i=0;i<h;i++) {
-            memcpy(s->bytestream, ptr1, n);
-            s->bytestream += n;
-            memcpy(s->bytestream, ptr2, n);
-            s->bytestream += n;
-                ptr1 += p->linesize[1];
-                ptr2 += p->linesize[2];
-        }
-    }
-    return s->bytestream - s->bytestream_start;
-}
-
-static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int buf_size, void *data){
-    PNMContext *s = avctx->priv_data;
-    AVFrame *pict = data;
-    AVFrame * const p= (AVFrame*)&s->picture;
-    int i, h, w, n, linesize, depth, maxval;
-    const char *tuple_type;
-    uint8_t *ptr;
-
-    if(buf_size < avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height) + 200){
-        av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
-        return -1;
-    }
-
-    *p = *pict;
-    p->pict_type= FF_I_TYPE;
-    p->key_frame= 1;
-    
-    s->bytestream_start=
-    s->bytestream= outbuf;
-    s->bytestream_end= outbuf+buf_size;
-
-    h = avctx->height;
-    w = avctx->width;
-    switch(avctx->pix_fmt) {
-    case PIX_FMT_MONOWHITE:
-        n = (w + 7) >> 3;
-        depth = 1;
-        maxval = 1;
-        tuple_type = "BLACKANDWHITE";
-        break;
-    case PIX_FMT_GRAY8:
-        n = w;
-        depth = 1;
-        maxval = 255;
-        tuple_type = "GRAYSCALE";
-        break;
-    case PIX_FMT_RGB24:
-        n = w * 3;
-        depth = 3;
-        maxval = 255;
-        tuple_type = "RGB";
-        break;
-    case PIX_FMT_RGBA32:
-        n = w * 4;
-        depth = 4;
-        maxval = 255;
-        tuple_type = "RGB_ALPHA";
-        break;
-    default:
-        return -1;
-    }
-    snprintf(s->bytestream, s->bytestream_end - s->bytestream, 
-             "P7\nWIDTH %d\nHEIGHT %d\nDEPTH %d\nMAXVAL %d\nTUPLETYPE %s\nENDHDR\n",
-             w, h, depth, maxval, tuple_type);
-    s->bytestream += strlen(s->bytestream);
-    
-    ptr = p->data[0];
-    linesize = p->linesize[0];
-    
-    if (avctx->pix_fmt == PIX_FMT_RGBA32) {
-        int j;
-        unsigned int v;
-
-        for(i=0;i<h;i++) {
-            for(j=0;j<w;j++) {
-                v = ((uint32_t *)ptr)[j];
-                *s->bytestream++ = v >> 16;
-                *s->bytestream++ = v >> 8;
-                *s->bytestream++ = v;
-                *s->bytestream++ = v >> 24;
-            }
-            ptr += linesize;
-        }
-    } else {
-        for(i=0;i<h;i++) {
-            memcpy(s->bytestream, ptr, n);
-            s->bytestream += n;
-            ptr += linesize;
-        }
-    }
-    return s->bytestream - s->bytestream_start;
-}
-
-#if 0
-static int pnm_probe(AVProbeData *pd)
-{
-    const char *p = pd->buf;
-    if (pd->buf_size >= 8 &&
-        p[0] == 'P' &&
-        p[1] >= '4' && p[1] <= '6' &&
-        pnm_space(p[2]) )
-        return AVPROBE_SCORE_MAX - 1; /* to permit pgmyuv probe */
-    else
-        return 0;
-}
-
-static int pgmyuv_probe(AVProbeData *pd)
-{
-    if (match_ext(pd->filename, "pgmyuv"))
-        return AVPROBE_SCORE_MAX;
-    else
-        return 0;
-}
-
-static int pam_probe(AVProbeData *pd)
-{
-    const char *p = pd->buf;
-    if (pd->buf_size >= 8 &&
-        p[0] == 'P' &&
-        p[1] == '7' &&
-        p[2] == '\n')
-        return AVPROBE_SCORE_MAX;
-    else
-        return 0;
-}
-#endif
-
-static int pnm_parse(AVCodecParserContext *s,
-                           AVCodecContext *avctx,
-                           uint8_t **poutbuf, int *poutbuf_size, 
-                           const uint8_t *buf, int buf_size)
-{
-    ParseContext *pc = s->priv_data;
-    PNMContext pnmctx;
-    int next;
-
-    for(; pc->overread>0; pc->overread--){
-        pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
-    }
-retry:
-    if(pc->index){
-        pnmctx.bytestream_start=
-        pnmctx.bytestream= pc->buffer;
-        pnmctx.bytestream_end= pc->buffer + pc->index;
-    }else{
-        pnmctx.bytestream_start=
-        pnmctx.bytestream= (uint8_t *) buf; /* casts avoid warnings */
-        pnmctx.bytestream_end= (uint8_t *) buf + buf_size;
-    }
-    if(pnm_decode_header(avctx, &pnmctx) < 0){
-        if(pnmctx.bytestream < pnmctx.bytestream_end){
-            if(pc->index){
-                pc->index=0;
-            }else{
-                buf++;
-                buf_size--;
-            }
-            goto retry;
-        }
-#if 0
-        if(pc->index && pc->index*2 + FF_INPUT_BUFFER_PADDING_SIZE < pc->buffer_size && buf_size > pc->index){
-            memcpy(pc->buffer + pc->index, buf, pc->index);
-            pc->index += pc->index;
-            buf += pc->index;
-            buf_size -= pc->index;
-            goto retry;
-        }
-#endif
-        next= END_NOT_FOUND;
-    }else{
-        next= pnmctx.bytestream - pnmctx.bytestream_start 
-            + avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
-        if(pnmctx.bytestream_start!=buf)
-            next-= pc->index;
-        if(next > buf_size)
-            next= END_NOT_FOUND;
-    }
-    
-    if(ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size)<0){
-        *poutbuf = NULL;
-        *poutbuf_size = 0;
-        return buf_size;
-    }
-    *poutbuf = (uint8_t *)buf;
-    *poutbuf_size = buf_size;
-    return next;
-}
-
-AVCodecParser pnm_parser = {
-    { CODEC_ID_PGM, CODEC_ID_PGMYUV, CODEC_ID_PPM, CODEC_ID_PBM, CODEC_ID_PAM},
-    sizeof(ParseContext),
-    NULL,
-    pnm_parse,
-    ff_parse_close,
-};
-
-#ifdef CONFIG_PGM_ENCODER
-AVCodec pgm_encoder = {
-    "pgm",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_PGM,
-    sizeof(PNMContext),
-    common_init,
-    pnm_encode_frame,
-    NULL, //encode_end,
-    pnm_decode_frame,
-    .pix_fmts= (enum PixelFormat[]){PIX_FMT_GRAY8, -1}, 
-};
-#endif // CONFIG_PGM_ENCODER
-
-#ifdef CONFIG_PGMYUV_ENCODER
-AVCodec pgmyuv_encoder = {
-    "pgmyuv",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_PGMYUV,
-    sizeof(PNMContext),
-    common_init,
-    pnm_encode_frame,
-    NULL, //encode_end,
-    pnm_decode_frame,
-    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1}, 
-};
-#endif // CONFIG_PGMYUV_ENCODER
-
-#ifdef CONFIG_PPM_ENCODER
-AVCodec ppm_encoder = {
-    "ppm",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_PPM,
-    sizeof(PNMContext),
-    common_init,
-    pnm_encode_frame,
-    NULL, //encode_end,
-    pnm_decode_frame,
-    .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, -1}, 
-};
-#endif // CONFIG_PPM_ENCODER
-
-#ifdef CONFIG_PBM_ENCODER
-AVCodec pbm_encoder = {
-    "pbm",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_PBM,
-    sizeof(PNMContext),
-    common_init,
-    pnm_encode_frame,
-    NULL, //encode_end,
-    pnm_decode_frame,
-    .pix_fmts= (enum PixelFormat[]){PIX_FMT_MONOWHITE, -1}, 
-};
-#endif // CONFIG_PBM_ENCODER
-
-#ifdef CONFIG_PAM_ENCODER
-AVCodec pam_encoder = {
-    "pam",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_PAM,
-    sizeof(PNMContext),
-    common_init,
-    pam_encode_frame,
-    NULL, //encode_end,
-    pnm_decode_frame,
-    .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGBA32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, -1}, 
-};
-#endif // CONFIG_PAM_ENCODER
diff --git a/ffmpeg.src/libavcodec/ppc/dsputil_altivec.c b/ffmpeg.src/libavcodec/ppc/dsputil_altivec.c
deleted file mode 100644
index 57b687d..0000000
--- a/ffmpeg.src/libavcodec/ppc/dsputil_altivec.c
+++ /dev/null
@@ -1,1775 +0,0 @@
-/*
- * Copyright (c) 2002 Brian Foley
- * Copyright (c) 2002 Dieter Shirley
- * Copyright (c) 2003-2004 Romain Dolbeau <romain at dolbeau.org>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-#include "../dsputil.h"
-
-#include "gcc_fixes.h"
-
-#include "dsputil_altivec.h"
-
-#ifdef CONFIG_DARWIN
-#include <sys/sysctl.h>
-#else /* CONFIG_DARWIN */
-#ifdef __AMIGAOS4__
-#include <exec/exec.h>
-#include <interfaces/exec.h>
-#include <proto/exec.h>
-#else /* __AMIGAOS4__ */
-#include <signal.h>
-#include <setjmp.h>
-
-static sigjmp_buf jmpbuf;
-static volatile sig_atomic_t canjump = 0;
-
-static void sigill_handler (int sig)
-{
-    if (!canjump) {
-        signal (sig, SIG_DFL);
-        raise (sig);
-    }
-    
-    canjump = 0;
-    siglongjmp (jmpbuf, 1);
-}
-#endif /* CONFIG_DARWIN */
-#endif /* __AMIGAOS4__ */
-
-int sad16_x2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int i;
-    int s __attribute__((aligned(16)));
-    const_vector unsigned char zero = (const_vector unsigned char)vec_splat_u8(0);
-    vector unsigned char *tv;
-    vector unsigned char pix1v, pix2v, pix2iv, avgv, t5;
-    vector unsigned int sad;
-    vector signed int sumdiffs;
-
-    s = 0;
-    sad = (vector unsigned int)vec_splat_u32(0);
-    for(i=0;i<h;i++) {
-        /*
-           Read unaligned pixels into our vectors. The vectors are as follows:
-           pix1v: pix1[0]-pix1[15]
-           pix2v: pix2[0]-pix2[15]	pix2iv: pix2[1]-pix2[16]
-        */
-        tv = (vector unsigned char *) pix1;
-        pix1v = vec_perm(tv[0], tv[1], vec_lvsl(0, pix1));
-        
-        tv = (vector unsigned char *) &pix2[0];
-        pix2v = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix2[0]));
-
-        tv = (vector unsigned char *) &pix2[1];
-        pix2iv = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix2[1]));
-
-        /* Calculate the average vector */
-        avgv = vec_avg(pix2v, pix2iv);
-
-        /* Calculate a sum of abs differences vector */
-        t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));
-
-        /* Add each 4 pixel group together and put 4 results into sad */
-        sad = vec_sum4s(t5, sad);
-        
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    /* Sum up the four partial sums, and put the result into s */
-    sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
-    sumdiffs = vec_splat(sumdiffs, 3);
-    vec_ste(sumdiffs, 0, &s);
-
-    return s;
-}
-
-int sad16_y2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int i;
-    int s __attribute__((aligned(16)));
-    const_vector unsigned char zero = (const_vector unsigned char)vec_splat_u8(0);
-    vector unsigned char *tv;
-    vector unsigned char pix1v, pix2v, pix3v, avgv, t5;
-    vector unsigned int sad;
-    vector signed int sumdiffs;
-    uint8_t *pix3 = pix2 + line_size;
-
-    s = 0;
-    sad = (vector unsigned int)vec_splat_u32(0);
-
-    /*
-       Due to the fact that pix3 = pix2 + line_size, the pix3 of one
-       iteration becomes pix2 in the next iteration. We can use this
-       fact to avoid a potentially expensive unaligned read, each
-       time around the loop.
-       Read unaligned pixels into our vectors. The vectors are as follows:
-       pix2v: pix2[0]-pix2[15]
-       Split the pixel vectors into shorts
-    */
-    tv = (vector unsigned char *) &pix2[0];
-    pix2v = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix2[0]));
-    
-    for(i=0;i<h;i++) {
-        /*
-           Read unaligned pixels into our vectors. The vectors are as follows:
-           pix1v: pix1[0]-pix1[15]
-           pix3v: pix3[0]-pix3[15]
-        */
-        tv = (vector unsigned char *) pix1;
-        pix1v = vec_perm(tv[0], tv[1], vec_lvsl(0, pix1));
-
-        tv = (vector unsigned char *) &pix3[0];
-        pix3v = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix3[0]));
-
-        /* Calculate the average vector */
-        avgv = vec_avg(pix2v, pix3v);
-
-        /* Calculate a sum of abs differences vector */
-        t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));
-
-        /* Add each 4 pixel group together and put 4 results into sad */
-        sad = vec_sum4s(t5, sad);
-        
-        pix1 += line_size;
-        pix2v = pix3v;
-        pix3 += line_size;
-        
-    }
-    
-    /* Sum up the four partial sums, and put the result into s */
-    sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
-    sumdiffs = vec_splat(sumdiffs, 3);
-    vec_ste(sumdiffs, 0, &s);
-    return s;    
-}
-
-int sad16_xy2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int i;
-    int s __attribute__((aligned(16)));
-    uint8_t *pix3 = pix2 + line_size;
-    const_vector unsigned char zero = (const_vector unsigned char)vec_splat_u8(0);
-    const_vector unsigned short two = (const_vector unsigned short)vec_splat_u16(2);
-    vector unsigned char *tv, avgv, t5;
-    vector unsigned char pix1v, pix2v, pix3v, pix2iv, pix3iv;
-    vector unsigned short pix2lv, pix2hv, pix2ilv, pix2ihv;
-    vector unsigned short pix3lv, pix3hv, pix3ilv, pix3ihv;
-    vector unsigned short avghv, avglv;
-    vector unsigned short t1, t2, t3, t4;
-    vector unsigned int sad;
-    vector signed int sumdiffs;
-
-    sad = (vector unsigned int)vec_splat_u32(0);
-    
-    s = 0;
-
-    /*
-       Due to the fact that pix3 = pix2 + line_size, the pix3 of one
-       iteration becomes pix2 in the next iteration. We can use this
-       fact to avoid a potentially expensive unaligned read, as well
-       as some splitting, and vector addition each time around the loop.
-       Read unaligned pixels into our vectors. The vectors are as follows:
-       pix2v: pix2[0]-pix2[15]	pix2iv: pix2[1]-pix2[16]
-       Split the pixel vectors into shorts
-    */
-    tv = (vector unsigned char *) &pix2[0];
-    pix2v = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix2[0]));
-
-    tv = (vector unsigned char *) &pix2[1];
-    pix2iv = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix2[1]));
-
-    pix2hv = (vector unsigned short) vec_mergeh(zero, pix2v);
-    pix2lv = (vector unsigned short) vec_mergel(zero, pix2v);
-    pix2ihv = (vector unsigned short) vec_mergeh(zero, pix2iv);
-    pix2ilv = (vector unsigned short) vec_mergel(zero, pix2iv);
-    t1 = vec_add(pix2hv, pix2ihv);
-    t2 = vec_add(pix2lv, pix2ilv);
-    
-    for(i=0;i<h;i++) {
-        /*
-           Read unaligned pixels into our vectors. The vectors are as follows:
-           pix1v: pix1[0]-pix1[15]
-           pix3v: pix3[0]-pix3[15]	pix3iv: pix3[1]-pix3[16]
-        */
-        tv = (vector unsigned char *) pix1;
-        pix1v = vec_perm(tv[0], tv[1], vec_lvsl(0, pix1));
-
-        tv = (vector unsigned char *) &pix3[0];
-        pix3v = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix3[0]));
-
-        tv = (vector unsigned char *) &pix3[1];
-        pix3iv = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix3[1]));
-
-        /*
-          Note that Altivec does have vec_avg, but this works on vector pairs
-          and rounds up. We could do avg(avg(a,b),avg(c,d)), but the rounding
-          would mean that, for example, avg(3,0,0,1) = 2, when it should be 1.
-          Instead, we have to split the pixel vectors into vectors of shorts,
-          and do the averaging by hand.
-        */
-
-        /* Split the pixel vectors into shorts */
-        pix3hv = (vector unsigned short) vec_mergeh(zero, pix3v);
-        pix3lv = (vector unsigned short) vec_mergel(zero, pix3v);
-        pix3ihv = (vector unsigned short) vec_mergeh(zero, pix3iv);
-        pix3ilv = (vector unsigned short) vec_mergel(zero, pix3iv);
-
-        /* Do the averaging on them */
-        t3 = vec_add(pix3hv, pix3ihv);
-        t4 = vec_add(pix3lv, pix3ilv);
-
-        avghv = vec_sr(vec_add(vec_add(t1, t3), two), two);
-        avglv = vec_sr(vec_add(vec_add(t2, t4), two), two);
-
-        /* Pack the shorts back into a result */
-        avgv = vec_pack(avghv, avglv);
-
-        /* Calculate a sum of abs differences vector */
-        t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));
-
-        /* Add each 4 pixel group together and put 4 results into sad */
-        sad = vec_sum4s(t5, sad);
-
-        pix1 += line_size;
-        pix3 += line_size;
-        /* Transfer the calculated values for pix3 into pix2 */
-        t1 = t3;
-        t2 = t4;
-    }
-    /* Sum up the four partial sums, and put the result into s */
-    sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
-    sumdiffs = vec_splat(sumdiffs, 3);
-    vec_ste(sumdiffs, 0, &s);
-
-    return s;
-}
-
-int sad16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int i;
-    int s __attribute__((aligned(16)));
-    const_vector unsigned int zero = (const_vector unsigned int)vec_splat_u32(0);
-    vector unsigned char perm1, perm2, *pix1v, *pix2v;
-    vector unsigned char t1, t2, t3,t4, t5;
-    vector unsigned int sad;
-    vector signed int sumdiffs;
-    
-    sad = (vector unsigned int)vec_splat_u32(0);
-
-
-    for(i=0;i<h;i++) {
-	/* Read potentially unaligned pixels into t1 and t2 */
-        perm1 = vec_lvsl(0, pix1);
-        pix1v = (vector unsigned char *) pix1;
-        perm2 = vec_lvsl(0, pix2);
-        pix2v = (vector unsigned char *) pix2;
-        t1 = vec_perm(pix1v[0], pix1v[1], perm1);
-        t2 = vec_perm(pix2v[0], pix2v[1], perm2);
-       
-	/* Calculate a sum of abs differences vector */ 
-        t3 = vec_max(t1, t2);
-        t4 = vec_min(t1, t2);
-        t5 = vec_sub(t3, t4);
-	
-	/* Add each 4 pixel group together and put 4 results into sad */
-        sad = vec_sum4s(t5, sad);
-
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-
-    /* Sum up the four partial sums, and put the result into s */
-    sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
-    sumdiffs = vec_splat(sumdiffs, 3);
-    vec_ste(sumdiffs, 0, &s);
-    
-    return s;
-}
-
-int sad8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int i;
-    int s __attribute__((aligned(16)));
-    const_vector unsigned int zero = (const_vector unsigned int)vec_splat_u32(0);
-    vector unsigned char perm1, perm2, permclear, *pix1v, *pix2v;
-    vector unsigned char t1, t2, t3,t4, t5;
-    vector unsigned int sad;
-    vector signed int sumdiffs;
-
-    sad = (vector unsigned int)vec_splat_u32(0);
-
-    permclear = (vector unsigned char)AVV(255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0);
-
-    for(i=0;i<h;i++) {
-	/* Read potentially unaligned pixels into t1 and t2
-	   Since we're reading 16 pixels, and actually only want 8,
-	   mask out the last 8 pixels. The 0s don't change the sum. */
-        perm1 = vec_lvsl(0, pix1);
-        pix1v = (vector unsigned char *) pix1;
-        perm2 = vec_lvsl(0, pix2);
-        pix2v = (vector unsigned char *) pix2;
-        t1 = vec_and(vec_perm(pix1v[0], pix1v[1], perm1), permclear);
-        t2 = vec_and(vec_perm(pix2v[0], pix2v[1], perm2), permclear);
-
-	/* Calculate a sum of abs differences vector */ 
-        t3 = vec_max(t1, t2);
-        t4 = vec_min(t1, t2);
-        t5 = vec_sub(t3, t4);
-
-	/* Add each 4 pixel group together and put 4 results into sad */
-        sad = vec_sum4s(t5, sad);
-
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-
-    /* Sum up the four partial sums, and put the result into s */
-    sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
-    sumdiffs = vec_splat(sumdiffs, 3);
-    vec_ste(sumdiffs, 0, &s);
-
-    return s;
-}
-
-int pix_norm1_altivec(uint8_t *pix, int line_size)
-{
-    int i;
-    int s __attribute__((aligned(16)));
-    const_vector unsigned int zero = (const_vector unsigned int)vec_splat_u32(0);
-    vector unsigned char *tv;
-    vector unsigned char pixv;
-    vector unsigned int sv;
-    vector signed int sum;
-    
-    sv = (vector unsigned int)vec_splat_u32(0);
-    
-    s = 0;
-    for (i = 0; i < 16; i++) {
-        /* Read in the potentially unaligned pixels */
-        tv = (vector unsigned char *) pix;
-        pixv = vec_perm(tv[0], tv[1], vec_lvsl(0, pix));
-
-        /* Square the values, and add them to our sum */
-        sv = vec_msum(pixv, pixv, sv);
-
-        pix += line_size;
-    }
-    /* Sum up the four partial sums, and put the result into s */
-    sum = vec_sums((vector signed int) sv, (vector signed int) zero);
-    sum = vec_splat(sum, 3);
-    vec_ste(sum, 0, &s);
-
-    return s;
-}
-
-/**
- * Sum of Squared Errors for a 8x8 block.
- * AltiVec-enhanced.
- * It's the sad8_altivec code above w/ squaring added.
- */
-int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int i;
-    int s __attribute__((aligned(16)));
-    const_vector unsigned int zero = (const_vector unsigned int)vec_splat_u32(0);
-    vector unsigned char perm1, perm2, permclear, *pix1v, *pix2v;
-    vector unsigned char t1, t2, t3,t4, t5;
-    vector unsigned int sum;
-    vector signed int sumsqr;
-    
-    sum = (vector unsigned int)vec_splat_u32(0);
-
-    permclear = (vector unsigned char)AVV(255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0);
-
-    
-    for(i=0;i<h;i++) {
-	/* Read potentially unaligned pixels into t1 and t2
-	   Since we're reading 16 pixels, and actually only want 8,
-	   mask out the last 8 pixels. The 0s don't change the sum. */
-        perm1 = vec_lvsl(0, pix1);
-        pix1v = (vector unsigned char *) pix1;
-        perm2 = vec_lvsl(0, pix2);
-        pix2v = (vector unsigned char *) pix2;
-        t1 = vec_and(vec_perm(pix1v[0], pix1v[1], perm1), permclear);
-        t2 = vec_and(vec_perm(pix2v[0], pix2v[1], perm2), permclear);
-
-        /*
-          Since we want to use unsigned chars, we can take advantage
-          of the fact that abs(a-b)^2 = (a-b)^2.
-        */
-        
-	/* Calculate abs differences vector */ 
-        t3 = vec_max(t1, t2);
-        t4 = vec_min(t1, t2);
-        t5 = vec_sub(t3, t4);
-        
-        /* Square the values and add them to our sum */
-        sum = vec_msum(t5, t5, sum);
-        
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    
-    /* Sum up the four partial sums, and put the result into s */
-    sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero);
-    sumsqr = vec_splat(sumsqr, 3);
-    vec_ste(sumsqr, 0, &s);
-    
-    return s;
-}
-
-/**
- * Sum of Squared Errors for a 16x16 block.
- * AltiVec-enhanced.
- * It's the sad16_altivec code above w/ squaring added.
- */
-int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int i;
-    int s __attribute__((aligned(16)));
-    const_vector unsigned int zero = (const_vector unsigned int)vec_splat_u32(0);
-    vector unsigned char perm1, perm2, *pix1v, *pix2v;
-    vector unsigned char t1, t2, t3,t4, t5;
-    vector unsigned int sum;
-    vector signed int sumsqr;
-    
-    sum = (vector unsigned int)vec_splat_u32(0);
-    
-    for(i=0;i<h;i++) {
-	/* Read potentially unaligned pixels into t1 and t2 */
-        perm1 = vec_lvsl(0, pix1);
-        pix1v = (vector unsigned char *) pix1;
-        perm2 = vec_lvsl(0, pix2);
-        pix2v = (vector unsigned char *) pix2;
-        t1 = vec_perm(pix1v[0], pix1v[1], perm1);
-        t2 = vec_perm(pix2v[0], pix2v[1], perm2);
-
-        /*
-          Since we want to use unsigned chars, we can take advantage
-          of the fact that abs(a-b)^2 = (a-b)^2.
-        */
-        
-	/* Calculate abs differences vector */ 
-        t3 = vec_max(t1, t2);
-        t4 = vec_min(t1, t2);
-        t5 = vec_sub(t3, t4);
-        
-        /* Square the values and add them to our sum */
-        sum = vec_msum(t5, t5, sum);
-        
-        pix1 += line_size;
-        pix2 += line_size;
-    }
-    
-    /* Sum up the four partial sums, and put the result into s */
-    sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero);
-    sumsqr = vec_splat(sumsqr, 3);
-    vec_ste(sumsqr, 0, &s);
-    
-    return s;
-}
-
-int pix_sum_altivec(uint8_t * pix, int line_size)
-{
-    const_vector unsigned int zero = (const_vector unsigned int)vec_splat_u32(0);
-    vector unsigned char perm, *pixv;
-    vector unsigned char t1;
-    vector unsigned int sad;
-    vector signed int sumdiffs;
-
-    int i;
-    int s __attribute__((aligned(16)));
-    
-    sad = (vector unsigned int)vec_splat_u32(0);
-    
-    for (i = 0; i < 16; i++) {
-	/* Read the potentially unaligned 16 pixels into t1 */
-        perm = vec_lvsl(0, pix);
-        pixv = (vector unsigned char *) pix;
-        t1 = vec_perm(pixv[0], pixv[1], perm);
-
-	/* Add each 4 pixel group together and put 4 results into sad */
-        sad = vec_sum4s(t1, sad);
-        
-        pix += line_size;
-    }
-    
-    /* Sum up the four partial sums, and put the result into s */
-    sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
-    sumdiffs = vec_splat(sumdiffs, 3);
-    vec_ste(sumdiffs, 0, &s);
-    
-    return s;
-}
-
-void get_pixels_altivec(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
-{
-    int i;
-    vector unsigned char perm, bytes, *pixv;
-    const_vector unsigned char zero = (const_vector unsigned char)vec_splat_u8(0);
-    vector signed short shorts;
-
-    for(i=0;i<8;i++)
-    {
-        // Read potentially unaligned pixels.
-        // We're reading 16 pixels, and actually only want 8,
-        // but we simply ignore the extras.
-        perm = vec_lvsl(0, pixels);
-        pixv = (vector unsigned char *) pixels;
-        bytes = vec_perm(pixv[0], pixv[1], perm);
-
-        // convert the bytes into shorts
-        shorts = (vector signed short)vec_mergeh(zero, bytes);
-
-        // save the data to the block, we assume the block is 16-byte aligned
-        vec_st(shorts, i*16, (vector signed short*)block);
-
-        pixels += line_size;
-    }
-}
-
-void diff_pixels_altivec(DCTELEM *restrict block, const uint8_t *s1,
-        const uint8_t *s2, int stride)
-{
-    int i;
-    vector unsigned char perm, bytes, *pixv;
-    const_vector unsigned char zero = (const_vector unsigned char)vec_splat_u8(0);
-    vector signed short shorts1, shorts2;
-
-    for(i=0;i<4;i++)
-    {
-        // Read potentially unaligned pixels
-        // We're reading 16 pixels, and actually only want 8,
-        // but we simply ignore the extras.
-        perm = vec_lvsl(0, s1);
-        pixv = (vector unsigned char *) s1;
-        bytes = vec_perm(pixv[0], pixv[1], perm);
-
-        // convert the bytes into shorts
-        shorts1 = (vector signed short)vec_mergeh(zero, bytes);
-
-        // Do the same for the second block of pixels
-        perm = vec_lvsl(0, s2);
-        pixv = (vector unsigned char *) s2;
-        bytes = vec_perm(pixv[0], pixv[1], perm);
-
-        // convert the bytes into shorts
-        shorts2 = (vector signed short)vec_mergeh(zero, bytes);
-
-        // Do the subtraction
-        shorts1 = vec_sub(shorts1, shorts2);
-
-        // save the data to the block, we assume the block is 16-byte aligned
-        vec_st(shorts1, 0, (vector signed short*)block);
-
-        s1 += stride;
-        s2 += stride;
-        block += 8;
-
-
-        // The code below is a copy of the code above... This is a manual
-        // unroll.
-
-        // Read potentially unaligned pixels
-        // We're reading 16 pixels, and actually only want 8,
-        // but we simply ignore the extras.
-        perm = vec_lvsl(0, s1);
-        pixv = (vector unsigned char *) s1;
-        bytes = vec_perm(pixv[0], pixv[1], perm);
-
-        // convert the bytes into shorts
-        shorts1 = (vector signed short)vec_mergeh(zero, bytes);
-
-        // Do the same for the second block of pixels
-        perm = vec_lvsl(0, s2);
-        pixv = (vector unsigned char *) s2;
-        bytes = vec_perm(pixv[0], pixv[1], perm);
-
-        // convert the bytes into shorts
-        shorts2 = (vector signed short)vec_mergeh(zero, bytes);
-
-        // Do the subtraction
-        shorts1 = vec_sub(shorts1, shorts2);
-
-        // save the data to the block, we assume the block is 16-byte aligned
-        vec_st(shorts1, 0, (vector signed short*)block);
-
-        s1 += stride;
-        s2 += stride;
-        block += 8;
-    }
-}
-
-void add_bytes_altivec(uint8_t *dst, uint8_t *src, int w) {
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-    int i;
-    for(i=0; i+7<w; i++){
-        dst[i+0] += src[i+0];
-        dst[i+1] += src[i+1];
-        dst[i+2] += src[i+2];
-        dst[i+3] += src[i+3];
-        dst[i+4] += src[i+4];
-        dst[i+5] += src[i+5];
-        dst[i+6] += src[i+6];
-        dst[i+7] += src[i+7];
-    }
-    for(; i<w; i++)
-        dst[i+0] += src[i+0];
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-    register int i;
-    register vector unsigned char vdst, vsrc;
-    
-    /* dst and src are 16 bytes-aligned (guaranteed) */
-    for(i = 0 ; (i + 15) < w ; i++)
-    {
-      vdst = vec_ld(i << 4, (unsigned char*)dst);
-      vsrc = vec_ld(i << 4, (unsigned char*)src);
-      vdst = vec_add(vsrc, vdst);
-      vec_st(vdst, i << 4, (unsigned char*)dst);
-    }
-    /* if w is not a multiple of 16 */
-    for (; (i < w) ; i++)
-    {
-      dst[i] = src[i];
-    }
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-}
-
-/* next one assumes that ((line_size % 16) == 0) */
-void put_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-POWERPC_PERF_DECLARE(altivec_put_pixels16_num, 1);
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-    int i;
-
-POWERPC_PERF_START_COUNT(altivec_put_pixels16_num, 1);
-
-    for(i=0; i<h; i++) {
-      *((uint32_t*)(block)) = LD32(pixels);
-      *((uint32_t*)(block+4)) = LD32(pixels+4);
-      *((uint32_t*)(block+8)) = LD32(pixels+8);
-      *((uint32_t*)(block+12)) = LD32(pixels+12);
-      pixels+=line_size;
-      block +=line_size;
-    }
-
-POWERPC_PERF_STOP_COUNT(altivec_put_pixels16_num, 1);
-
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-    register vector unsigned char pixelsv1, pixelsv2;
-    register vector unsigned char pixelsv1B, pixelsv2B;
-    register vector unsigned char pixelsv1C, pixelsv2C;
-    register vector unsigned char pixelsv1D, pixelsv2D;
-
-    register vector unsigned char perm = vec_lvsl(0, pixels);
-    int i;
-    register int line_size_2 = line_size << 1;
-    register int line_size_3 = line_size + line_size_2;
-    register int line_size_4 = line_size << 2;
-
-POWERPC_PERF_START_COUNT(altivec_put_pixels16_num, 1);
-// hand-unrolling the loop by 4 gains about 15%
-// mininum execution time goes from 74 to 60 cycles
-// it's faster than -funroll-loops, but using
-// -funroll-loops w/ this is bad - 74 cycles again.
-// all this is on a 7450, tuning for the 7450
-#if 0
-    for(i=0; i<h; i++) {
-      pixelsv1 = vec_ld(0, (unsigned char*)pixels);
-      pixelsv2 = vec_ld(16, (unsigned char*)pixels);
-      vec_st(vec_perm(pixelsv1, pixelsv2, perm),
-             0, (unsigned char*)block);
-      pixels+=line_size;
-      block +=line_size;
-    }
-#else
-    for(i=0; i<h; i+=4) {
-      pixelsv1 = vec_ld(0, (unsigned char*)pixels);
-      pixelsv2 = vec_ld(16, (unsigned char*)pixels);
-      pixelsv1B = vec_ld(line_size, (unsigned char*)pixels);
-      pixelsv2B = vec_ld(16 + line_size, (unsigned char*)pixels);
-      pixelsv1C = vec_ld(line_size_2, (unsigned char*)pixels);
-      pixelsv2C = vec_ld(16 + line_size_2, (unsigned char*)pixels);
-      pixelsv1D = vec_ld(line_size_3, (unsigned char*)pixels);
-      pixelsv2D = vec_ld(16 + line_size_3, (unsigned char*)pixels);
-      vec_st(vec_perm(pixelsv1, pixelsv2, perm),
-             0, (unsigned char*)block);
-      vec_st(vec_perm(pixelsv1B, pixelsv2B, perm),
-             line_size, (unsigned char*)block);
-      vec_st(vec_perm(pixelsv1C, pixelsv2C, perm),
-             line_size_2, (unsigned char*)block);
-      vec_st(vec_perm(pixelsv1D, pixelsv2D, perm),
-             line_size_3, (unsigned char*)block);
-      pixels+=line_size_4;
-      block +=line_size_4;
-    }
-#endif
-POWERPC_PERF_STOP_COUNT(altivec_put_pixels16_num, 1);
-
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-}
-
-/* next one assumes that ((line_size % 16) == 0) */
-#define op_avg(a,b)  a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEUL)>>1) )
-void avg_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-POWERPC_PERF_DECLARE(altivec_avg_pixels16_num, 1);
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-    int i;
-
-POWERPC_PERF_START_COUNT(altivec_avg_pixels16_num, 1);
-
-    for(i=0; i<h; i++) {
-      op_avg(*((uint32_t*)(block)),LD32(pixels));
-      op_avg(*((uint32_t*)(block+4)),LD32(pixels+4));
-      op_avg(*((uint32_t*)(block+8)),LD32(pixels+8));
-      op_avg(*((uint32_t*)(block+12)),LD32(pixels+12));
-      pixels+=line_size;
-      block +=line_size;
-    }
-
-POWERPC_PERF_STOP_COUNT(altivec_avg_pixels16_num, 1);
-
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-    register vector unsigned char pixelsv1, pixelsv2, pixelsv, blockv;
-    register vector unsigned char perm = vec_lvsl(0, pixels);
-    int i;
-
-POWERPC_PERF_START_COUNT(altivec_avg_pixels16_num, 1);
-
-    for(i=0; i<h; i++) {
-      pixelsv1 = vec_ld(0, (unsigned char*)pixels);
-      pixelsv2 = vec_ld(16, (unsigned char*)pixels);
-      blockv = vec_ld(0, block);
-      pixelsv = vec_perm(pixelsv1, pixelsv2, perm);
-      blockv = vec_avg(blockv,pixelsv);
-      vec_st(blockv, 0, (unsigned char*)block);
-      pixels+=line_size;
-      block +=line_size;
-    }
-
-POWERPC_PERF_STOP_COUNT(altivec_avg_pixels16_num, 1);
-
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-}
-
-/* next one assumes that ((line_size % 8) == 0) */
-void avg_pixels8_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h)
-{
-POWERPC_PERF_DECLARE(altivec_avg_pixels8_num, 1);
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-    int i;
-POWERPC_PERF_START_COUNT(altivec_avg_pixels8_num, 1);
-    for (i = 0; i < h; i++) {
-        *((uint32_t *) (block)) =
-            (((*((uint32_t *) (block))) |
-              ((((const struct unaligned_32 *) (pixels))->l))) -
-             ((((*((uint32_t *) (block))) ^
-                ((((const struct unaligned_32 *) (pixels))->
-                  l))) & 0xFEFEFEFEUL) >> 1));
-        *((uint32_t *) (block + 4)) =
-            (((*((uint32_t *) (block + 4))) |
-              ((((const struct unaligned_32 *) (pixels + 4))->l))) -
-             ((((*((uint32_t *) (block + 4))) ^
-                ((((const struct unaligned_32 *) (pixels +
-                                                  4))->
-                  l))) & 0xFEFEFEFEUL) >> 1));
-        pixels += line_size;
-        block += line_size;
-    }
-POWERPC_PERF_STOP_COUNT(altivec_avg_pixels8_num, 1);
-
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-    register vector unsigned char pixelsv1, pixelsv2, pixelsv, blockv;
-    int i;
-
-POWERPC_PERF_START_COUNT(altivec_avg_pixels8_num, 1);
- 
-   for (i = 0; i < h; i++) {
-     /*
-       block is 8 bytes-aligned, so we're either in the
-       left block (16 bytes-aligned) or in the right block (not)
-     */
-     int rightside = ((unsigned long)block & 0x0000000F);
-     
-     blockv = vec_ld(0, block);
-     pixelsv1 = vec_ld(0, (unsigned char*)pixels);
-     pixelsv2 = vec_ld(16, (unsigned char*)pixels);
-     pixelsv = vec_perm(pixelsv1, pixelsv2, vec_lvsl(0, pixels));
-     
-     if (rightside)
-     {
-       pixelsv = vec_perm(blockv, pixelsv, vcprm(0,1,s0,s1));
-     }
-     else
-     {
-       pixelsv = vec_perm(blockv, pixelsv, vcprm(s0,s1,2,3));
-     }
-     
-     blockv = vec_avg(blockv, pixelsv);
-
-     vec_st(blockv, 0, block);
-     
-     pixels += line_size;
-     block += line_size;
-   }
-   
-POWERPC_PERF_STOP_COUNT(altivec_avg_pixels8_num, 1);
- 
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-}
-
-/* next one assumes that ((line_size % 8) == 0) */
-void put_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-POWERPC_PERF_DECLARE(altivec_put_pixels8_xy2_num, 1);
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-    int j;
-POWERPC_PERF_START_COUNT(altivec_put_pixels8_xy2_num, 1);
-    for (j = 0; j < 2; j++) {
-      int i;
-      const uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
-      const uint32_t b =
-        (((const struct unaligned_32 *) (pixels + 1))->l);
-      uint32_t l0 =
-        (a & 0x03030303UL) + (b & 0x03030303UL) + 0x02020202UL;
-      uint32_t h0 =
-        ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-      uint32_t l1, h1;
-      pixels += line_size;
-      for (i = 0; i < h; i += 2) {
-        uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
-        uint32_t b = (((const struct unaligned_32 *) (pixels + 1))->l);
-        l1 = (a & 0x03030303UL) + (b & 0x03030303UL);
-        h1 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-        *((uint32_t *) block) =
-          h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL);
-        pixels += line_size;
-        block += line_size;
-        a = (((const struct unaligned_32 *) (pixels))->l);
-        b = (((const struct unaligned_32 *) (pixels + 1))->l);
-        l0 = (a & 0x03030303UL) + (b & 0x03030303UL) + 0x02020202UL;
-        h0 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-        *((uint32_t *) block) =
-          h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL);
-        pixels += line_size;
-        block += line_size;
-      } pixels += 4 - line_size * (h + 1);
-      block += 4 - line_size * h;
-    }
-
-POWERPC_PERF_STOP_COUNT(altivec_put_pixels8_xy2_num, 1);
-
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-   register int i;
-   register vector unsigned char
-     pixelsv1, pixelsv2,
-     pixelsavg;
-   register vector unsigned char
-     blockv, temp1, temp2;
-   register vector unsigned short
-     pixelssum1, pixelssum2, temp3;
-   register const_vector unsigned char vczero = (const_vector unsigned char)vec_splat_u8(0);
-   register const_vector unsigned short vctwo = (const_vector unsigned short)vec_splat_u16(2);
-   
-   temp1 = vec_ld(0, pixels);
-   temp2 = vec_ld(16, pixels);
-   pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels));
-   if ((((unsigned long)pixels) & 0x0000000F) ==  0x0000000F)
-   {
-     pixelsv2 = temp2;
-   }
-   else
-   {
-     pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels));
-   }
-   pixelsv1 = vec_mergeh(vczero, pixelsv1);
-   pixelsv2 = vec_mergeh(vczero, pixelsv2);
-   pixelssum1 = vec_add((vector unsigned short)pixelsv1,
-                        (vector unsigned short)pixelsv2);
-   pixelssum1 = vec_add(pixelssum1, vctwo);
-   
-POWERPC_PERF_START_COUNT(altivec_put_pixels8_xy2_num, 1); 
-   for (i = 0; i < h ; i++) {
-     int rightside = ((unsigned long)block & 0x0000000F);
-     blockv = vec_ld(0, block);
-
-     temp1 = vec_ld(line_size, pixels);
-     temp2 = vec_ld(line_size + 16, pixels);
-     pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(line_size, pixels));
-     if (((((unsigned long)pixels) + line_size) & 0x0000000F) ==  0x0000000F)
-     {
-       pixelsv2 = temp2;
-     }
-     else
-     {
-       pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels));
-     }
-
-     pixelsv1 = vec_mergeh(vczero, pixelsv1);
-     pixelsv2 = vec_mergeh(vczero, pixelsv2);
-     pixelssum2 = vec_add((vector unsigned short)pixelsv1,
-                          (vector unsigned short)pixelsv2);
-     temp3 = vec_add(pixelssum1, pixelssum2);
-     temp3 = vec_sra(temp3, vctwo);
-     pixelssum1 = vec_add(pixelssum2, vctwo);
-     pixelsavg = vec_packsu(temp3, (vector unsigned short) vczero);
-     
-     if (rightside)
-     {
-       blockv = vec_perm(blockv, pixelsavg, vcprm(0, 1, s0, s1));
-     }
-     else
-     {
-       blockv = vec_perm(blockv, pixelsavg, vcprm(s0, s1, 2, 3));
-     }
-     
-     vec_st(blockv, 0, block);
-     
-     block += line_size;
-     pixels += line_size;
-   }
-   
-POWERPC_PERF_STOP_COUNT(altivec_put_pixels8_xy2_num, 1);
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-}
-
-/* next one assumes that ((line_size % 8) == 0) */
-void put_no_rnd_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-POWERPC_PERF_DECLARE(altivec_put_no_rnd_pixels8_xy2_num, 1);
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-    int j;
-POWERPC_PERF_START_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
-    for (j = 0; j < 2; j++) {
-      int i;
-      const uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
-      const uint32_t b =
-        (((const struct unaligned_32 *) (pixels + 1))->l);
-      uint32_t l0 =
-        (a & 0x03030303UL) + (b & 0x03030303UL) + 0x01010101UL;
-      uint32_t h0 =
-        ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-      uint32_t l1, h1;
-      pixels += line_size;
-      for (i = 0; i < h; i += 2) {
-        uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
-        uint32_t b = (((const struct unaligned_32 *) (pixels + 1))->l);
-        l1 = (a & 0x03030303UL) + (b & 0x03030303UL);
-        h1 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-        *((uint32_t *) block) =
-          h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL);
-        pixels += line_size;
-        block += line_size;
-        a = (((const struct unaligned_32 *) (pixels))->l);
-        b = (((const struct unaligned_32 *) (pixels + 1))->l);
-        l0 = (a & 0x03030303UL) + (b & 0x03030303UL) + 0x01010101UL;
-        h0 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-        *((uint32_t *) block) =
-          h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL);
-        pixels += line_size;
-        block += line_size;
-      } pixels += 4 - line_size * (h + 1);
-      block += 4 - line_size * h;
-    }
-    
-POWERPC_PERF_STOP_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
-
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-   register int i;
-   register vector unsigned char
-     pixelsv1, pixelsv2,
-     pixelsavg;
-   register vector unsigned char
-     blockv, temp1, temp2;
-   register vector unsigned short
-     pixelssum1, pixelssum2, temp3;
-   register const_vector unsigned char vczero = (const_vector unsigned char)vec_splat_u8(0);
-   register const_vector unsigned short vcone = (const_vector unsigned short)vec_splat_u16(1);
-   register const_vector unsigned short vctwo = (const_vector unsigned short)vec_splat_u16(2);
-   
-   temp1 = vec_ld(0, pixels);
-   temp2 = vec_ld(16, pixels);
-   pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels));
-   if ((((unsigned long)pixels) & 0x0000000F) ==  0x0000000F)
-   {
-     pixelsv2 = temp2;
-   }
-   else
-   {
-     pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels));
-   }
-   pixelsv1 = vec_mergeh(vczero, pixelsv1);
-   pixelsv2 = vec_mergeh(vczero, pixelsv2);
-   pixelssum1 = vec_add((vector unsigned short)pixelsv1,
-                        (vector unsigned short)pixelsv2);
-   pixelssum1 = vec_add(pixelssum1, vcone);
-   
-POWERPC_PERF_START_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1); 
-   for (i = 0; i < h ; i++) {
-     int rightside = ((unsigned long)block & 0x0000000F);
-     blockv = vec_ld(0, block);
-
-     temp1 = vec_ld(line_size, pixels);
-     temp2 = vec_ld(line_size + 16, pixels);
-     pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(line_size, pixels));
-     if (((((unsigned long)pixels) + line_size) & 0x0000000F) ==  0x0000000F)
-     {
-       pixelsv2 = temp2;
-     }
-     else
-     {
-       pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels));
-     }
-
-     pixelsv1 = vec_mergeh(vczero, pixelsv1);
-     pixelsv2 = vec_mergeh(vczero, pixelsv2);
-     pixelssum2 = vec_add((vector unsigned short)pixelsv1,
-                          (vector unsigned short)pixelsv2);
-     temp3 = vec_add(pixelssum1, pixelssum2);
-     temp3 = vec_sra(temp3, vctwo);
-     pixelssum1 = vec_add(pixelssum2, vcone);
-     pixelsavg = vec_packsu(temp3, (vector unsigned short) vczero);
-     
-     if (rightside)
-     {
-       blockv = vec_perm(blockv, pixelsavg, vcprm(0, 1, s0, s1));
-     }
-     else
-     {
-       blockv = vec_perm(blockv, pixelsavg, vcprm(s0, s1, 2, 3));
-     }
-     
-     vec_st(blockv, 0, block);
-     
-     block += line_size;
-     pixels += line_size;
-   }
-   
-POWERPC_PERF_STOP_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-}
-
-/* next one assumes that ((line_size % 16) == 0) */
-void put_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h)
-{
-POWERPC_PERF_DECLARE(altivec_put_pixels16_xy2_num, 1);
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-    int j;
-POWERPC_PERF_START_COUNT(altivec_put_pixels16_xy2_num, 1);
-      for (j = 0; j < 4; j++) {
-      int i;
-      const uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
-      const uint32_t b =
-        (((const struct unaligned_32 *) (pixels + 1))->l);
-      uint32_t l0 =
-        (a & 0x03030303UL) + (b & 0x03030303UL) + 0x02020202UL;
-      uint32_t h0 =
-        ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-      uint32_t l1, h1;
-      pixels += line_size;
-      for (i = 0; i < h; i += 2) {
-        uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
-        uint32_t b = (((const struct unaligned_32 *) (pixels + 1))->l);
-        l1 = (a & 0x03030303UL) + (b & 0x03030303UL);
-        h1 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-        *((uint32_t *) block) =
-          h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL);
-        pixels += line_size;
-        block += line_size;
-        a = (((const struct unaligned_32 *) (pixels))->l);
-        b = (((const struct unaligned_32 *) (pixels + 1))->l);
-        l0 = (a & 0x03030303UL) + (b & 0x03030303UL) + 0x02020202UL;
-        h0 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-        *((uint32_t *) block) =
-          h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL);
-        pixels += line_size;
-        block += line_size;
-      } pixels += 4 - line_size * (h + 1);
-      block += 4 - line_size * h;
-    }
-
-POWERPC_PERF_STOP_COUNT(altivec_put_pixels16_xy2_num, 1);
-
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-   register int i;
-   register vector unsigned char
-     pixelsv1, pixelsv2, pixelsv3, pixelsv4;
-   register vector unsigned char
-     blockv, temp1, temp2;
-   register vector unsigned short
-     pixelssum1, pixelssum2, temp3,
-     pixelssum3, pixelssum4, temp4;
-   register const_vector unsigned char vczero = (const_vector unsigned char)vec_splat_u8(0);
-   register const_vector unsigned short vctwo = (const_vector unsigned short)vec_splat_u16(2);
-
-POWERPC_PERF_START_COUNT(altivec_put_pixels16_xy2_num, 1);
- 
-   temp1 = vec_ld(0, pixels);
-   temp2 = vec_ld(16, pixels);
-   pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels));
-   if ((((unsigned long)pixels) & 0x0000000F) ==  0x0000000F)
-   {
-     pixelsv2 = temp2;
-   }
-   else
-   {
-     pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels));
-   }
-   pixelsv3 = vec_mergel(vczero, pixelsv1);
-   pixelsv4 = vec_mergel(vczero, pixelsv2);
-   pixelsv1 = vec_mergeh(vczero, pixelsv1);
-   pixelsv2 = vec_mergeh(vczero, pixelsv2);
-   pixelssum3 = vec_add((vector unsigned short)pixelsv3,
-                        (vector unsigned short)pixelsv4);
-   pixelssum3 = vec_add(pixelssum3, vctwo);
-   pixelssum1 = vec_add((vector unsigned short)pixelsv1,
-                        (vector unsigned short)pixelsv2);
-   pixelssum1 = vec_add(pixelssum1, vctwo);
-   
-   for (i = 0; i < h ; i++) {
-     blockv = vec_ld(0, block);
-
-     temp1 = vec_ld(line_size, pixels);
-     temp2 = vec_ld(line_size + 16, pixels);
-     pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(line_size, pixels));
-     if (((((unsigned long)pixels) + line_size) & 0x0000000F) ==  0x0000000F)
-     {
-       pixelsv2 = temp2;
-     }
-     else
-     {
-       pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels));
-     }
-
-     pixelsv3 = vec_mergel(vczero, pixelsv1);
-     pixelsv4 = vec_mergel(vczero, pixelsv2);
-     pixelsv1 = vec_mergeh(vczero, pixelsv1);
-     pixelsv2 = vec_mergeh(vczero, pixelsv2);
-     
-     pixelssum4 = vec_add((vector unsigned short)pixelsv3,
-                          (vector unsigned short)pixelsv4);
-     pixelssum2 = vec_add((vector unsigned short)pixelsv1,
-                          (vector unsigned short)pixelsv2);
-     temp4 = vec_add(pixelssum3, pixelssum4);
-     temp4 = vec_sra(temp4, vctwo);
-     temp3 = vec_add(pixelssum1, pixelssum2);
-     temp3 = vec_sra(temp3, vctwo);
-
-     pixelssum3 = vec_add(pixelssum4, vctwo);
-     pixelssum1 = vec_add(pixelssum2, vctwo);
-
-     blockv = vec_packsu(temp3, temp4);
-     
-     vec_st(blockv, 0, block);
-     
-     block += line_size;
-     pixels += line_size;
-   }
-   
-POWERPC_PERF_STOP_COUNT(altivec_put_pixels16_xy2_num, 1);
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-}
-
-/* next one assumes that ((line_size % 16) == 0) */
-void put_no_rnd_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h)
-{
-POWERPC_PERF_DECLARE(altivec_put_no_rnd_pixels16_xy2_num, 1);
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-    int j;
-POWERPC_PERF_START_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
-      for (j = 0; j < 4; j++) {
-      int i;
-      const uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
-      const uint32_t b =
-        (((const struct unaligned_32 *) (pixels + 1))->l);
-      uint32_t l0 =
-        (a & 0x03030303UL) + (b & 0x03030303UL) + 0x01010101UL;
-      uint32_t h0 =
-        ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-      uint32_t l1, h1;
-      pixels += line_size;
-      for (i = 0; i < h; i += 2) {
-        uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
-        uint32_t b = (((const struct unaligned_32 *) (pixels + 1))->l);
-        l1 = (a & 0x03030303UL) + (b & 0x03030303UL);
-        h1 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-        *((uint32_t *) block) =
-          h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL);
-        pixels += line_size;
-        block += line_size;
-        a = (((const struct unaligned_32 *) (pixels))->l);
-        b = (((const struct unaligned_32 *) (pixels + 1))->l);
-        l0 = (a & 0x03030303UL) + (b & 0x03030303UL) + 0x01010101UL;
-        h0 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-        *((uint32_t *) block) =
-          h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL);
-        pixels += line_size;
-        block += line_size;
-      } pixels += 4 - line_size * (h + 1);
-      block += 4 - line_size * h;
-    }
-
-POWERPC_PERF_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
-
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-   register int i;
-   register vector unsigned char
-     pixelsv1, pixelsv2, pixelsv3, pixelsv4;
-   register vector unsigned char
-     blockv, temp1, temp2;
-   register vector unsigned short
-     pixelssum1, pixelssum2, temp3,
-     pixelssum3, pixelssum4, temp4;
-   register const_vector unsigned char vczero = (const_vector unsigned char)vec_splat_u8(0);
-   register const_vector unsigned short vcone = (const_vector unsigned short)vec_splat_u16(1);
-   register const_vector unsigned short vctwo = (const_vector unsigned short)vec_splat_u16(2);
-
-POWERPC_PERF_START_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
- 
-   temp1 = vec_ld(0, pixels);
-   temp2 = vec_ld(16, pixels);
-   pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels));
-   if ((((unsigned long)pixels) & 0x0000000F) ==  0x0000000F)
-   {
-     pixelsv2 = temp2;
-   }
-   else
-   {
-     pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels));
-   }
-   pixelsv3 = vec_mergel(vczero, pixelsv1);
-   pixelsv4 = vec_mergel(vczero, pixelsv2);
-   pixelsv1 = vec_mergeh(vczero, pixelsv1);
-   pixelsv2 = vec_mergeh(vczero, pixelsv2);
-   pixelssum3 = vec_add((vector unsigned short)pixelsv3,
-                        (vector unsigned short)pixelsv4);
-   pixelssum3 = vec_add(pixelssum3, vcone);
-   pixelssum1 = vec_add((vector unsigned short)pixelsv1,
-                        (vector unsigned short)pixelsv2);
-   pixelssum1 = vec_add(pixelssum1, vcone);
-   
-   for (i = 0; i < h ; i++) {
-     blockv = vec_ld(0, block);
-
-     temp1 = vec_ld(line_size, pixels);
-     temp2 = vec_ld(line_size + 16, pixels);
-     pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(line_size, pixels));
-     if (((((unsigned long)pixels) + line_size) & 0x0000000F) ==  0x0000000F)
-     {
-       pixelsv2 = temp2;
-     }
-     else
-     {
-       pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels));
-     }
-
-     pixelsv3 = vec_mergel(vczero, pixelsv1);
-     pixelsv4 = vec_mergel(vczero, pixelsv2);
-     pixelsv1 = vec_mergeh(vczero, pixelsv1);
-     pixelsv2 = vec_mergeh(vczero, pixelsv2);
-     
-     pixelssum4 = vec_add((vector unsigned short)pixelsv3,
-                          (vector unsigned short)pixelsv4);
-     pixelssum2 = vec_add((vector unsigned short)pixelsv1,
-                          (vector unsigned short)pixelsv2);
-     temp4 = vec_add(pixelssum3, pixelssum4);
-     temp4 = vec_sra(temp4, vctwo);
-     temp3 = vec_add(pixelssum1, pixelssum2);
-     temp3 = vec_sra(temp3, vctwo);
-
-     pixelssum3 = vec_add(pixelssum4, vcone);
-     pixelssum1 = vec_add(pixelssum2, vcone);
-
-     blockv = vec_packsu(temp3, temp4);
-     
-     vec_st(blockv, 0, block);
-     
-     block += line_size;
-     pixels += line_size;
-   }
-   
-POWERPC_PERF_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-}
-
-#ifdef CONFIG_DARWIN
-int hadamard8_diff8x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){
-POWERPC_PERF_DECLARE(altivec_hadamard8_diff8x8_num, 1);
-  int sum;
-POWERPC_PERF_START_COUNT(altivec_hadamard8_diff8x8_num, 1);
-  register const_vector unsigned char vzero = (const_vector unsigned char)vec_splat_u8(0);
-  register vector signed short temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
-  {
-    register const_vector signed short vprod1 = (const_vector signed short)AVV( 1,-1, 1,-1, 1,-1, 1,-1);
-    register const_vector signed short vprod2 = (const_vector signed short)AVV( 1, 1,-1,-1, 1, 1,-1,-1);
-    register const_vector signed short vprod3 = (const_vector signed short)AVV( 1, 1, 1, 1,-1,-1,-1,-1);
-    register const_vector unsigned char perm1 = (const_vector unsigned char)
-      AVV(0x02, 0x03, 0x00, 0x01,
-       0x06, 0x07, 0x04, 0x05,
-       0x0A, 0x0B, 0x08, 0x09,
-       0x0E, 0x0F, 0x0C, 0x0D);
-    register const_vector unsigned char perm2 = (const_vector unsigned char)
-      AVV(0x04, 0x05, 0x06, 0x07,
-       0x00, 0x01, 0x02, 0x03,
-       0x0C, 0x0D, 0x0E, 0x0F,
-       0x08, 0x09, 0x0A, 0x0B);
-    register const_vector unsigned char perm3 = (const_vector unsigned char)
-      AVV(0x08, 0x09, 0x0A, 0x0B,
-       0x0C, 0x0D, 0x0E, 0x0F,
-       0x00, 0x01, 0x02, 0x03,
-       0x04, 0x05, 0x06, 0x07);
-
-#define ONEITERBUTTERFLY(i, res)					\
-    {									\
-      register vector unsigned char src1, src2, srcO;		       	\
-      register vector unsigned char dst1, dst2, dstO;		       	\
-      src1 = vec_ld(stride * i, src);					\
-      if ((((stride * i) + (unsigned long)src) & 0x0000000F) > 8)	\
-	src2 = vec_ld((stride * i) + 16, src);				\
-      srcO = vec_perm(src1, src2, vec_lvsl(stride * i, src));		\
-      dst1 = vec_ld(stride * i, dst);					\
-      if ((((stride * i) + (unsigned long)dst) & 0x0000000F) > 8)	\
-	dst2 = vec_ld((stride * i) + 16, dst);				\
-      dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst));		\
-      /* promote the unsigned chars to signed shorts */			\
-      /* we're in the 8x8 function, we only care for the first 8 */	\
-      register vector signed short srcV =			       	\
-	(vector signed short)vec_mergeh((vector signed char)vzero, (vector signed char)srcO); \
-      register vector signed short dstV =			       	\
-	(vector signed short)vec_mergeh((vector signed char)vzero, (vector signed char)dstO); \
-      /* substractions inside the first butterfly */			\
-      register vector signed short but0 = vec_sub(srcV, dstV);	       	\
-      register vector signed short op1 = vec_perm(but0, but0, perm1);  	\
-      register vector signed short but1 = vec_mladd(but0, vprod1, op1);	\
-      register vector signed short op2 = vec_perm(but1, but1, perm2);  	\
-      register vector signed short but2 = vec_mladd(but1, vprod2, op2);	\
-      register vector signed short op3 = vec_perm(but2, but2, perm3);  	\
-      res = vec_mladd(but2, vprod3, op3);				\
-    }
-    ONEITERBUTTERFLY(0, temp0);
-    ONEITERBUTTERFLY(1, temp1);
-    ONEITERBUTTERFLY(2, temp2);
-    ONEITERBUTTERFLY(3, temp3);
-    ONEITERBUTTERFLY(4, temp4);
-    ONEITERBUTTERFLY(5, temp5);
-    ONEITERBUTTERFLY(6, temp6);
-    ONEITERBUTTERFLY(7, temp7);
-  }
-#undef ONEITERBUTTERFLY
-  {
-    register vector signed int vsum;
-    register vector signed short line0 = vec_add(temp0, temp1);
-    register vector signed short line1 = vec_sub(temp0, temp1);
-    register vector signed short line2 = vec_add(temp2, temp3);
-    register vector signed short line3 = vec_sub(temp2, temp3);
-    register vector signed short line4 = vec_add(temp4, temp5);
-    register vector signed short line5 = vec_sub(temp4, temp5);
-    register vector signed short line6 = vec_add(temp6, temp7);
-    register vector signed short line7 = vec_sub(temp6, temp7);
-    
-    register vector signed short line0B = vec_add(line0, line2);
-    register vector signed short line2B = vec_sub(line0, line2);
-    register vector signed short line1B = vec_add(line1, line3);
-    register vector signed short line3B = vec_sub(line1, line3);
-    register vector signed short line4B = vec_add(line4, line6);
-    register vector signed short line6B = vec_sub(line4, line6);
-    register vector signed short line5B = vec_add(line5, line7);
-    register vector signed short line7B = vec_sub(line5, line7);
-    
-    register vector signed short line0C = vec_add(line0B, line4B);
-    register vector signed short line4C = vec_sub(line0B, line4B);
-    register vector signed short line1C = vec_add(line1B, line5B);
-    register vector signed short line5C = vec_sub(line1B, line5B);
-    register vector signed short line2C = vec_add(line2B, line6B);
-    register vector signed short line6C = vec_sub(line2B, line6B);
-    register vector signed short line3C = vec_add(line3B, line7B);
-    register vector signed short line7C = vec_sub(line3B, line7B);
-    
-    vsum = vec_sum4s(vec_abs(line0C), vec_splat_s32(0));
-    vsum = vec_sum4s(vec_abs(line1C), vsum);
-    vsum = vec_sum4s(vec_abs(line2C), vsum);
-    vsum = vec_sum4s(vec_abs(line3C), vsum);
-    vsum = vec_sum4s(vec_abs(line4C), vsum);
-    vsum = vec_sum4s(vec_abs(line5C), vsum);
-    vsum = vec_sum4s(vec_abs(line6C), vsum);
-    vsum = vec_sum4s(vec_abs(line7C), vsum);
-    vsum = vec_sums(vsum, (vector signed int)vzero);
-    vsum = vec_splat(vsum, 3);
-    vec_ste(vsum, 0, &sum);
-  }
-POWERPC_PERF_STOP_COUNT(altivec_hadamard8_diff8x8_num, 1);
-  return sum;
-}
-
-/*
-  16x8 works with 16 elements ; it allows to avoid replicating
-  loads, and give the compiler more rooms for scheduling.
-  It's only used from inside hadamard8_diff16_altivec.
-  
-  Unfortunately, it seems gcc-3.3 is a bit dumb, and
-  the compiled code has a LOT of spill code, it seems
-  gcc (unlike xlc) cannot keep everything in registers
-  by itself. The following code include hand-made
-  registers allocation. It's not clean, but on
-  a 7450 the resulting code is much faster (best case
-  fall from 700+ cycles to 550).
-  
-  xlc doesn't add spill code, but it doesn't know how to
-  schedule for the 7450, and its code isn't much faster than
-  gcc-3.3 on the 7450 (but uses 25% less instructions...)
-  
-  On the 970, the hand-made RA is still a win (arount 690
-  vs. around 780), but xlc goes to around 660 on the
-  regular C code...
-*/
-
-static int hadamard8_diff16x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h) {
-  int sum;
-  register vector signed short
-    temp0 asm ("v0"),
-    temp1 asm ("v1"),
-    temp2 asm ("v2"),
-    temp3 asm ("v3"),
-    temp4 asm ("v4"),
-    temp5 asm ("v5"),
-    temp6 asm ("v6"),
-    temp7 asm ("v7");
-  register vector signed short
-    temp0S asm ("v8"),
-    temp1S asm ("v9"),
-    temp2S asm ("v10"),
-    temp3S asm ("v11"),
-    temp4S asm ("v12"),
-    temp5S asm ("v13"),
-    temp6S asm ("v14"),
-    temp7S asm ("v15");
-  register const_vector unsigned char vzero asm ("v31")= (const_vector unsigned char)vec_splat_u8(0);
-  {
-    register const_vector signed short vprod1 asm ("v16")= (const_vector signed short)AVV( 1,-1, 1,-1, 1,-1, 1,-1);
-    register const_vector signed short vprod2 asm ("v17")= (const_vector signed short)AVV( 1, 1,-1,-1, 1, 1,-1,-1);
-    register const_vector signed short vprod3 asm ("v18")= (const_vector signed short)AVV( 1, 1, 1, 1,-1,-1,-1,-1);
-    register const_vector unsigned char perm1 asm ("v19")= (const_vector unsigned char)
-      AVV(0x02, 0x03, 0x00, 0x01,
-       0x06, 0x07, 0x04, 0x05,
-       0x0A, 0x0B, 0x08, 0x09,
-       0x0E, 0x0F, 0x0C, 0x0D);
-    register const_vector unsigned char perm2 asm ("v20")= (const_vector unsigned char)
-      AVV(0x04, 0x05, 0x06, 0x07,
-       0x00, 0x01, 0x02, 0x03,
-       0x0C, 0x0D, 0x0E, 0x0F,
-       0x08, 0x09, 0x0A, 0x0B);
-    register const_vector unsigned char perm3 asm ("v21")= (const_vector unsigned char)
-      AVV(0x08, 0x09, 0x0A, 0x0B,
-       0x0C, 0x0D, 0x0E, 0x0F,
-       0x00, 0x01, 0x02, 0x03,
-       0x04, 0x05, 0x06, 0x07);
-
-#define ONEITERBUTTERFLY(i, res1, res2)					\
-    {									\
-      register vector unsigned char src1 asm ("v22"), src2 asm ("v23"); \
-      register vector unsigned char dst1 asm ("v24"), dst2 asm ("v25"); \
-      src1 = vec_ld(stride * i, src);					\
-      src2 = vec_ld((stride * i) + 16, src);				\
-      register vector unsigned char srcO asm ("v22") = vec_perm(src1, src2, vec_lvsl(stride * i, src)); \
-      dst1 = vec_ld(stride * i, dst);					\
-      dst2 = vec_ld((stride * i) + 16, dst);				\
-      register vector unsigned char dstO asm ("v23") = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \
-      /* promote the unsigned chars to signed shorts */			\
-      register vector signed short srcV asm ("v24") =                   \
-	(vector signed short)vec_mergeh((vector signed char)vzero, (vector signed char)srcO); \
-      register vector signed short dstV asm ("v25") =                   \
-	(vector signed short)vec_mergeh((vector signed char)vzero, (vector signed char)dstO); \
-      register vector signed short srcW asm ("v26") =                   \
-	(vector signed short)vec_mergel((vector signed char)vzero, (vector signed char)srcO); \
-      register vector signed short dstW asm ("v27") =                   \
-	(vector signed short)vec_mergel((vector signed char)vzero, (vector signed char)dstO); \
-      /* substractions inside the first butterfly */			\
-      register vector signed short but0 asm ("v28") = vec_sub(srcV, dstV); \
-      register vector signed short but0S asm ("v29") = vec_sub(srcW, dstW); \
-      register vector signed short op1 asm ("v30") = vec_perm(but0, but0, perm1); \
-      register vector signed short but1 asm ("v22") = vec_mladd(but0, vprod1, op1); \
-      register vector signed short op1S asm ("v23") = vec_perm(but0S, but0S, perm1); \
-      register vector signed short but1S asm ("v24") = vec_mladd(but0S, vprod1, op1S); \
-      register vector signed short op2 asm ("v25") = vec_perm(but1, but1, perm2); \
-      register vector signed short but2 asm ("v26") = vec_mladd(but1, vprod2, op2); \
-      register vector signed short op2S asm ("v27") = vec_perm(but1S, but1S, perm2); \
-      register vector signed short but2S asm ("v28") = vec_mladd(but1S, vprod2, op2S); \
-      register vector signed short op3 asm ("v29") = vec_perm(but2, but2, perm3); \
-      res1 = vec_mladd(but2, vprod3, op3);				\
-      register vector signed short op3S asm ("v30") = vec_perm(but2S, but2S, perm3); \
-      res2 = vec_mladd(but2S, vprod3, op3S);				\
-    }
-    ONEITERBUTTERFLY(0, temp0, temp0S);
-    ONEITERBUTTERFLY(1, temp1, temp1S);
-    ONEITERBUTTERFLY(2, temp2, temp2S);
-    ONEITERBUTTERFLY(3, temp3, temp3S);
-    ONEITERBUTTERFLY(4, temp4, temp4S);
-    ONEITERBUTTERFLY(5, temp5, temp5S);
-    ONEITERBUTTERFLY(6, temp6, temp6S);
-    ONEITERBUTTERFLY(7, temp7, temp7S);
-  }
-#undef ONEITERBUTTERFLY
-  {
-    register vector signed int vsum;
-    register vector signed short line0 = vec_add(temp0, temp1);
-    register vector signed short line1 = vec_sub(temp0, temp1);
-    register vector signed short line2 = vec_add(temp2, temp3);
-    register vector signed short line3 = vec_sub(temp2, temp3);
-    register vector signed short line4 = vec_add(temp4, temp5);
-    register vector signed short line5 = vec_sub(temp4, temp5);
-    register vector signed short line6 = vec_add(temp6, temp7);
-    register vector signed short line7 = vec_sub(temp6, temp7);
-      
-    register vector signed short line0B = vec_add(line0, line2);
-    register vector signed short line2B = vec_sub(line0, line2);
-    register vector signed short line1B = vec_add(line1, line3);
-    register vector signed short line3B = vec_sub(line1, line3);
-    register vector signed short line4B = vec_add(line4, line6);
-    register vector signed short line6B = vec_sub(line4, line6);
-    register vector signed short line5B = vec_add(line5, line7);
-    register vector signed short line7B = vec_sub(line5, line7);
-      
-    register vector signed short line0C = vec_add(line0B, line4B);
-    register vector signed short line4C = vec_sub(line0B, line4B);
-    register vector signed short line1C = vec_add(line1B, line5B);
-    register vector signed short line5C = vec_sub(line1B, line5B);
-    register vector signed short line2C = vec_add(line2B, line6B);
-    register vector signed short line6C = vec_sub(line2B, line6B);
-    register vector signed short line3C = vec_add(line3B, line7B);
-    register vector signed short line7C = vec_sub(line3B, line7B);
-      
-    vsum = vec_sum4s(vec_abs(line0C), vec_splat_s32(0));
-    vsum = vec_sum4s(vec_abs(line1C), vsum);
-    vsum = vec_sum4s(vec_abs(line2C), vsum);
-    vsum = vec_sum4s(vec_abs(line3C), vsum);
-    vsum = vec_sum4s(vec_abs(line4C), vsum);
-    vsum = vec_sum4s(vec_abs(line5C), vsum);
-    vsum = vec_sum4s(vec_abs(line6C), vsum);
-    vsum = vec_sum4s(vec_abs(line7C), vsum);
-
-    register vector signed short line0S = vec_add(temp0S, temp1S);
-    register vector signed short line1S = vec_sub(temp0S, temp1S);
-    register vector signed short line2S = vec_add(temp2S, temp3S);
-    register vector signed short line3S = vec_sub(temp2S, temp3S);
-    register vector signed short line4S = vec_add(temp4S, temp5S);
-    register vector signed short line5S = vec_sub(temp4S, temp5S);
-    register vector signed short line6S = vec_add(temp6S, temp7S);
-    register vector signed short line7S = vec_sub(temp6S, temp7S);
-
-    register vector signed short line0BS = vec_add(line0S, line2S);
-    register vector signed short line2BS = vec_sub(line0S, line2S);
-    register vector signed short line1BS = vec_add(line1S, line3S);
-    register vector signed short line3BS = vec_sub(line1S, line3S);
-    register vector signed short line4BS = vec_add(line4S, line6S);
-    register vector signed short line6BS = vec_sub(line4S, line6S);
-    register vector signed short line5BS = vec_add(line5S, line7S);
-    register vector signed short line7BS = vec_sub(line5S, line7S);
-
-    register vector signed short line0CS = vec_add(line0BS, line4BS);
-    register vector signed short line4CS = vec_sub(line0BS, line4BS);
-    register vector signed short line1CS = vec_add(line1BS, line5BS);
-    register vector signed short line5CS = vec_sub(line1BS, line5BS);
-    register vector signed short line2CS = vec_add(line2BS, line6BS);
-    register vector signed short line6CS = vec_sub(line2BS, line6BS);
-    register vector signed short line3CS = vec_add(line3BS, line7BS);
-    register vector signed short line7CS = vec_sub(line3BS, line7BS);
-
-    vsum = vec_sum4s(vec_abs(line0CS), vsum);
-    vsum = vec_sum4s(vec_abs(line1CS), vsum);
-    vsum = vec_sum4s(vec_abs(line2CS), vsum);
-    vsum = vec_sum4s(vec_abs(line3CS), vsum);
-    vsum = vec_sum4s(vec_abs(line4CS), vsum);
-    vsum = vec_sum4s(vec_abs(line5CS), vsum);
-    vsum = vec_sum4s(vec_abs(line6CS), vsum);
-    vsum = vec_sum4s(vec_abs(line7CS), vsum);
-    vsum = vec_sums(vsum, (vector signed int)vzero);
-    vsum = vec_splat(vsum, 3);
-    vec_ste(vsum, 0, &sum);
-  }
-  return sum;
-}
-
-int hadamard8_diff16_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){
-POWERPC_PERF_DECLARE(altivec_hadamard8_diff16_num, 1);
-  int score;
-POWERPC_PERF_START_COUNT(altivec_hadamard8_diff16_num, 1);
-  score = hadamard8_diff16x8_altivec(s, dst, src, stride, 8);
-  if (h==16) {
-    dst += 8*stride;
-    src += 8*stride;
-    score += hadamard8_diff16x8_altivec(s, dst, src, stride, 8);
-  }
-POWERPC_PERF_STOP_COUNT(altivec_hadamard8_diff16_num, 1);
-  return score;
-}
-#endif //CONFIG_DARWIN
-
-int has_altivec(void)
-{
-#ifdef __AMIGAOS4__
-	ULONG result = 0;
-	extern struct ExecIFace *IExec;
-
-	IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE);
-	if (result == VECTORTYPE_ALTIVEC) return 1;
-	return 0;
-#else /* __AMIGAOS4__ */
-
-#ifdef CONFIG_DARWIN
-    int sels[2] = {CTL_HW, HW_VECTORUNIT};
-    int has_vu = 0;
-    size_t len = sizeof(has_vu);
-    int err;
-
-    err = sysctl(sels, 2, &has_vu, &len, NULL, 0);
-
-    if (err == 0) return (has_vu != 0);
-#else /* CONFIG_DARWIN */
-/* no Darwin, do it the brute-force way */
-/* this is borrowed from the libmpeg2 library */
-    {
-      signal (SIGILL, sigill_handler);
-      if (sigsetjmp (jmpbuf, 1)) {
-        signal (SIGILL, SIG_DFL);
-      } else {
-        canjump = 1;
-        
-        asm volatile ("mtspr 256, %0\n\t"
-                      "vand %%v0, %%v0, %%v0"
-                      :
-                      : "r" (-1));
-        
-        signal (SIGILL, SIG_DFL);
-        return 1;
-      }
-    }
-#endif /* CONFIG_DARWIN */
-    return 0;
-#endif /* __AMIGAOS4__ */
-}
-
-/* next one assumes that ((line_size % 8) == 0) */
-void avg_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-POWERPC_PERF_DECLARE(altivec_avg_pixels8_xy2_num, 1);
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-
-    int j;
-POWERPC_PERF_START_COUNT(altivec_avg_pixels8_xy2_num, 1);
- for (j = 0; j < 2; j++) {
-   int             i;
-   const uint32_t  a = (((const struct unaligned_32 *) (pixels))->l);
-   const uint32_t  b = (((const struct unaligned_32 *) (pixels + 1))->l);
-   uint32_t        l0 = (a & 0x03030303UL) + (b & 0x03030303UL) + 0x02020202UL;
-   uint32_t        h0 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-   uint32_t        l1, h1;
-   pixels += line_size;
-   for (i = 0; i < h; i += 2) {
-     uint32_t        a = (((const struct unaligned_32 *) (pixels))->l);
-     uint32_t        b = (((const struct unaligned_32 *) (pixels + 1))->l);
-     l1 = (a & 0x03030303UL) + (b & 0x03030303UL);
-     h1 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-     *((uint32_t *) block) = rnd_avg32(*((uint32_t *) block), h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL));
-     pixels += line_size;
-     block += line_size;
-     a = (((const struct unaligned_32 *) (pixels))->l);
-     b = (((const struct unaligned_32 *) (pixels + 1))->l);
-     l0 = (a & 0x03030303UL) + (b & 0x03030303UL) + 0x02020202UL;
-     h0 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
-     *((uint32_t *) block) = rnd_avg32(*((uint32_t *) block), h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL));
-     pixels += line_size;
-     block += line_size;
-   } pixels += 4 - line_size * (h + 1);
-   block += 4 - line_size * h;
- }
-POWERPC_PERF_STOP_COUNT(altivec_avg_pixels8_xy2_num, 1);
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-   register int i;
-   register vector unsigned char
-     pixelsv1, pixelsv2,
-     pixelsavg;
-   register vector unsigned char
-     blockv, temp1, temp2, blocktemp;
-   register vector unsigned short
-     pixelssum1, pixelssum2, temp3;
-   register const_vector unsigned char vczero = (const_vector unsigned char)vec_splat_u8(0);
-   register const_vector unsigned short vctwo = (const_vector unsigned short)vec_splat_u16(2);
-   
-   temp1 = vec_ld(0, pixels);
-   temp2 = vec_ld(16, pixels);
-   pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels));
-   if ((((unsigned long)pixels) & 0x0000000F) ==  0x0000000F)
-   {
-     pixelsv2 = temp2;
-   }
-   else
-   {
-     pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels));
-   }
-   pixelsv1 = vec_mergeh(vczero, pixelsv1);
-   pixelsv2 = vec_mergeh(vczero, pixelsv2);
-   pixelssum1 = vec_add((vector unsigned short)pixelsv1,
-                        (vector unsigned short)pixelsv2);
-   pixelssum1 = vec_add(pixelssum1, vctwo);
-   
-POWERPC_PERF_START_COUNT(altivec_avg_pixels8_xy2_num, 1); 
-   for (i = 0; i < h ; i++) {
-     int rightside = ((unsigned long)block & 0x0000000F);
-     blockv = vec_ld(0, block);
-
-     temp1 = vec_ld(line_size, pixels);
-     temp2 = vec_ld(line_size + 16, pixels);
-     pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(line_size, pixels));
-     if (((((unsigned long)pixels) + line_size) & 0x0000000F) ==  0x0000000F)
-     {
-       pixelsv2 = temp2;
-     }
-     else
-     {
-       pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels));
-     }
-
-     pixelsv1 = vec_mergeh(vczero, pixelsv1);
-     pixelsv2 = vec_mergeh(vczero, pixelsv2);
-     pixelssum2 = vec_add((vector unsigned short)pixelsv1,
-                          (vector unsigned short)pixelsv2);
-     temp3 = vec_add(pixelssum1, pixelssum2);
-     temp3 = vec_sra(temp3, vctwo);
-     pixelssum1 = vec_add(pixelssum2, vctwo);
-     pixelsavg = vec_packsu(temp3, (vector unsigned short) vczero);
-     
-     if (rightside)
-     {
-       blocktemp = vec_perm(blockv, pixelsavg, vcprm(0, 1, s0, s1));
-     }
-     else
-     {
-       blocktemp = vec_perm(blockv, pixelsavg, vcprm(s0, s1, 2, 3));
-     }
-     
-     blockv = vec_avg(blocktemp, blockv);
-     vec_st(blockv, 0, block);
-     
-     block += line_size;
-     pixels += line_size;
-   }
-   
-POWERPC_PERF_STOP_COUNT(altivec_avg_pixels8_xy2_num, 1);
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-}
diff --git a/ffmpeg.src/libavcodec/ppc/dsputil_altivec.h b/ffmpeg.src/libavcodec/ppc/dsputil_altivec.h
deleted file mode 100644
index 88f06c3..0000000
--- a/ffmpeg.src/libavcodec/ppc/dsputil_altivec.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2002 Brian Foley
- * Copyright (c) 2002 Dieter Shirley
- * Copyright (c) 2003-2004 Romain Dolbeau <romain at dolbeau.org>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _DSPUTIL_ALTIVEC_
-#define _DSPUTIL_ALTIVEC_
-
-#include "dsputil_ppc.h"
-
-#ifdef HAVE_ALTIVEC
-
-extern int sad16_x2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
-extern int sad16_y2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
-extern int sad16_xy2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
-extern int sad16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
-extern int sad8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
-extern int pix_norm1_altivec(uint8_t *pix, int line_size);
-extern int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
-extern int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
-extern int pix_sum_altivec(uint8_t * pix, int line_size);
-extern void diff_pixels_altivec(DCTELEM* block, const uint8_t* s1, const uint8_t* s2, int stride);
-extern void get_pixels_altivec(DCTELEM* block, const uint8_t * pixels, int line_size);
-
-extern void add_bytes_altivec(uint8_t *dst, uint8_t *src, int w);
-extern void put_pixels_clamped_altivec(const DCTELEM *block, uint8_t *restrict pixels, int line_size);
-extern void put_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-extern void avg_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-extern void avg_pixels8_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h);
-extern void put_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-extern void put_no_rnd_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-extern void put_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h);
-extern void put_no_rnd_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h);
-extern int hadamard8_diff8x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h);
-extern int hadamard8_diff16_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h);
-extern void avg_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-
-extern void gmc1_altivec(uint8_t *dst, uint8_t *src, int stride, int h, int x16, int y16, int rounder);
-
-extern int has_altivec(void);
-
-// used to build registers permutation vectors (vcprm)
-// the 's' are for words in the _s_econd vector
-#define WORD_0 0x00,0x01,0x02,0x03
-#define WORD_1 0x04,0x05,0x06,0x07
-#define WORD_2 0x08,0x09,0x0a,0x0b
-#define WORD_3 0x0c,0x0d,0x0e,0x0f
-#define WORD_s0 0x10,0x11,0x12,0x13
-#define WORD_s1 0x14,0x15,0x16,0x17
-#define WORD_s2 0x18,0x19,0x1a,0x1b
-#define WORD_s3 0x1c,0x1d,0x1e,0x1f
-
-#ifdef CONFIG_DARWIN
-#define vcprm(a,b,c,d) (const vector unsigned char)(WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d)
-#else
-#define vcprm(a,b,c,d) (const vector unsigned char){WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d}
-#endif
-
-// vcprmle is used to keep the same index as in the SSE version.
-// it's the same as vcprm, with the index inversed
-// ('le' is Little Endian)
-#define vcprmle(a,b,c,d) vcprm(d,c,b,a)
-
-// used to build inverse/identity vectors (vcii)
-// n is _n_egative, p is _p_ositive
-#define FLOAT_n -1.
-#define FLOAT_p 1.
-
-
-#ifdef CONFIG_DARWIN
-#define vcii(a,b,c,d) (const vector float)(FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d)
-#else
-#define vcii(a,b,c,d) (const vector float){FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d}
-#endif
-
-#else /* HAVE_ALTIVEC */
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-#error "I can't use ALTIVEC_USE_REFERENCE_C_CODE if I don't use HAVE_ALTIVEC"
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-#endif /* HAVE_ALTIVEC */
-
-#endif /* _DSPUTIL_ALTIVEC_ */
diff --git a/ffmpeg.src/libavcodec/ppc/dsputil_h264_altivec.c b/ffmpeg.src/libavcodec/ppc/dsputil_h264_altivec.c
deleted file mode 100644
index 1891e19..0000000
--- a/ffmpeg.src/libavcodec/ppc/dsputil_h264_altivec.c
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (c) 2004 Romain Dolbeau <romain at dolbeau.org>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-#include "../dsputil.h"
-
-#include "gcc_fixes.h"
-
-#include "dsputil_altivec.h"
-
-#define PUT_OP_U8_ALTIVEC(d, s, dst) d = s
-#define AVG_OP_U8_ALTIVEC(d, s, dst) d = vec_avg(dst, s)
-
-#define OP_U8_ALTIVEC                          PUT_OP_U8_ALTIVEC
-#define PREFIX_h264_chroma_mc8_altivec         put_h264_chroma_mc8_altivec
-#define PREFIX_h264_chroma_mc8_num             altivec_put_h264_chroma_mc8_num
-#define PREFIX_h264_qpel16_h_lowpass_altivec   put_h264_qpel16_h_lowpass_altivec
-#define PREFIX_h264_qpel16_h_lowpass_num       altivec_put_h264_qpel16_h_lowpass_num
-#define PREFIX_h264_qpel16_v_lowpass_altivec   put_h264_qpel16_v_lowpass_altivec
-#define PREFIX_h264_qpel16_v_lowpass_num       altivec_put_h264_qpel16_v_lowpass_num
-#define PREFIX_h264_qpel16_hv_lowpass_altivec  put_h264_qpel16_hv_lowpass_altivec
-#define PREFIX_h264_qpel16_hv_lowpass_num      altivec_put_h264_qpel16_hv_lowpass_num
-#include "dsputil_h264_template_altivec.c"
-#undef OP_U8_ALTIVEC
-#undef PREFIX_h264_chroma_mc8_altivec
-#undef PREFIX_h264_chroma_mc8_num
-#undef PREFIX_h264_qpel16_h_lowpass_altivec
-#undef PREFIX_h264_qpel16_h_lowpass_num
-#undef PREFIX_h264_qpel16_v_lowpass_altivec
-#undef PREFIX_h264_qpel16_v_lowpass_num
-#undef PREFIX_h264_qpel16_hv_lowpass_altivec
-#undef PREFIX_h264_qpel16_hv_lowpass_num
-
-#define OP_U8_ALTIVEC                          AVG_OP_U8_ALTIVEC
-#define PREFIX_h264_chroma_mc8_altivec         avg_h264_chroma_mc8_altivec
-#define PREFIX_h264_chroma_mc8_num             altivec_avg_h264_chroma_mc8_num
-#define PREFIX_h264_qpel16_h_lowpass_altivec   avg_h264_qpel16_h_lowpass_altivec
-#define PREFIX_h264_qpel16_h_lowpass_num       altivec_avg_h264_qpel16_h_lowpass_num
-#define PREFIX_h264_qpel16_v_lowpass_altivec   avg_h264_qpel16_v_lowpass_altivec
-#define PREFIX_h264_qpel16_v_lowpass_num       altivec_avg_h264_qpel16_v_lowpass_num
-#define PREFIX_h264_qpel16_hv_lowpass_altivec  avg_h264_qpel16_hv_lowpass_altivec
-#define PREFIX_h264_qpel16_hv_lowpass_num      altivec_avg_h264_qpel16_hv_lowpass_num
-#include "dsputil_h264_template_altivec.c"
-#undef OP_U8_ALTIVEC
-#undef PREFIX_h264_chroma_mc8_altivec
-#undef PREFIX_h264_chroma_mc8_num
-#undef PREFIX_h264_qpel16_h_lowpass_altivec
-#undef PREFIX_h264_qpel16_h_lowpass_num
-#undef PREFIX_h264_qpel16_v_lowpass_altivec
-#undef PREFIX_h264_qpel16_v_lowpass_num
-#undef PREFIX_h264_qpel16_hv_lowpass_altivec
-#undef PREFIX_h264_qpel16_hv_lowpass_num
-
-#define H264_MC(OPNAME, SIZE, CODETYPE) \
-static void OPNAME ## h264_qpel ## SIZE ## _mc00_ ## CODETYPE (uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## pixels ## SIZE ## _ ## CODETYPE(dst, src, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc10_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){ \
-    uint64_t temp[SIZE*SIZE/8] __align16;\
-    uint8_t * const half= (uint8_t*)temp;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(half, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, src, half, stride, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc20_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc30_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/8] __align16;\
-    uint8_t * const half= (uint8_t*)temp;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(half, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, src+1, half, stride, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc01_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/8] __align16;\
-    uint8_t * const half= (uint8_t*)temp;\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(half, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, src, half, stride, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc02_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc03_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/8] __align16;\
-    uint8_t * const half= (uint8_t*)temp;\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(half, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, src+stride, half, stride, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc11_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/4] __align16;\
-    uint8_t * const halfH= (uint8_t*)temp;\
-    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(halfH, src, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(halfV, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfH, halfV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc31_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/4] __align16;\
-    uint8_t * const halfH= (uint8_t*)temp;\
-    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(halfH, src, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(halfV, src+1, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfH, halfV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc13_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/4] __align16;\
-    uint8_t * const halfH= (uint8_t*)temp;\
-    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(halfH, src + stride, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(halfV, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfH, halfV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc33_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*SIZE/4] __align16;\
-    uint8_t * const halfH= (uint8_t*)temp;\
-    uint8_t * const halfV= ((uint8_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(halfH, src + stride, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(halfV, src+1, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfH, halfV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc22_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*(SIZE+8)/4] __align16;\
-    int16_t * const tmp= (int16_t*)temp;\
-    OPNAME ## h264_qpel ## SIZE ## _hv_lowpass_ ## CODETYPE(dst, tmp, src, stride, SIZE, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc21_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4] __align16;\
-    uint8_t * const halfH= (uint8_t*)temp;\
-    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\
-    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(halfH, src, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _hv_lowpass_ ## CODETYPE(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfH, halfHV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc23_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4] __align16;\
-    uint8_t * const halfH= (uint8_t*)temp;\
-    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\
-    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _h_lowpass_ ## CODETYPE(halfH, src + stride, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _hv_lowpass_ ## CODETYPE(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfH, halfHV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc12_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4] __align16;\
-    uint8_t * const halfV= (uint8_t*)temp;\
-    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\
-    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(halfV, src, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _hv_lowpass_ ## CODETYPE(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfV, halfHV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## CODETYPE(uint8_t *dst, uint8_t *src, int stride){\
-    uint64_t temp[SIZE*(SIZE+8)/4 + SIZE*SIZE/4] __align16;\
-    uint8_t * const halfV= (uint8_t*)temp;\
-    uint8_t * const halfHV= ((uint8_t*)temp) + SIZE*SIZE;\
-    int16_t * const tmp= ((int16_t*)temp) + SIZE*SIZE;\
-    put_h264_qpel ## SIZE ## _v_lowpass_ ## CODETYPE(halfV, src+1, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _hv_lowpass_ ## CODETYPE(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_ ## CODETYPE(dst, halfV, halfHV, stride, SIZE, SIZE);\
-}\
-
-
-/* from dsputil.c */
-static inline void put_pixels8_l2(uint8_t * dst, const uint8_t * src1, const uint8_t * src2, int dst_stride, int src_stride1, int src_stride2, int h) {
-	int             i;
-	for (i = 0; i < h; i++) {
-		uint32_t        a, b;
-		a = (((const struct unaligned_32 *) (&src1[i * src_stride1]))->l);
-		b = (((const struct unaligned_32 *) (&src2[i * src_stride2]))->l);
-		*((uint32_t *) & dst[i * dst_stride]) = rnd_avg32(a, b);
-		a = (((const struct unaligned_32 *) (&src1[i * src_stride1 + 4]))->l);
-		b = (((const struct unaligned_32 *) (&src2[i * src_stride2 + 4]))->l);
-		*((uint32_t *) & dst[i * dst_stride + 4]) = rnd_avg32(a, b);
-	}
-} static inline void avg_pixels8_l2(uint8_t * dst, const uint8_t * src1, const uint8_t * src2, int dst_stride, int src_stride1, int src_stride2, int h) {
-	int             i;
-	for (i = 0; i < h; i++) {
-		uint32_t        a, b;
-		a = (((const struct unaligned_32 *) (&src1[i * src_stride1]))->l);
-		b = (((const struct unaligned_32 *) (&src2[i * src_stride2]))->l);
-		*((uint32_t *) & dst[i * dst_stride]) = rnd_avg32(*((uint32_t *) & dst[i * dst_stride]), rnd_avg32(a, b));
-		a = (((const struct unaligned_32 *) (&src1[i * src_stride1 + 4]))->l);
-		b = (((const struct unaligned_32 *) (&src2[i * src_stride2 + 4]))->l);
-		*((uint32_t *) & dst[i * dst_stride + 4]) = rnd_avg32(*((uint32_t *) & dst[i * dst_stride + 4]), rnd_avg32(a, b));
-	}
-} static inline void put_pixels16_l2(uint8_t * dst, const uint8_t * src1, const uint8_t * src2, int dst_stride, int src_stride1, int src_stride2, int h) {
-	put_pixels8_l2(dst, src1, src2, dst_stride, src_stride1, src_stride2, h);
-	put_pixels8_l2(dst + 8, src1 + 8, src2 + 8, dst_stride, src_stride1, src_stride2, h);
-} static inline void avg_pixels16_l2(uint8_t * dst, const uint8_t * src1, const uint8_t * src2, int dst_stride, int src_stride1, int src_stride2, int h) {
-	avg_pixels8_l2(dst, src1, src2, dst_stride, src_stride1, src_stride2, h);
-	avg_pixels8_l2(dst + 8, src1 + 8, src2 + 8, dst_stride, src_stride1, src_stride2, h);
-}
-
-/* UNIMPLEMENTED YET !! */
-#define put_pixels16_l2_altivec(d,s1,s2,ds,s1s,h) put_pixels16_l2(d,s1,s2,ds,s1s,16,h)
-#define avg_pixels16_l2_altivec(d,s1,s2,ds,s1s,h) avg_pixels16_l2(d,s1,s2,ds,s1s,16,h)
-
-H264_MC(put_, 16, altivec)
-     H264_MC(avg_, 16, altivec)
-
-void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx) {
-    
-#ifdef HAVE_ALTIVEC
-  if (has_altivec()) {
-    c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_altivec;
-    c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_altivec;
-
-#define dspfunc(PFX, IDX, NUM) \
-    c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_altivec; \
-    c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_altivec; \
-    c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_altivec; \
-    c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_altivec; \
-    c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_altivec; \
-    c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_altivec; \
-    c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_altivec; \
-    c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_altivec; \
-    c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_altivec; \
-    c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_altivec; \
-    c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_altivec; \
-    c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_altivec; \
-    c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_altivec; \
-    c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_altivec; \
-    c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_altivec; \
-    c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_altivec
-    
-    dspfunc(put_h264_qpel, 0, 16);
-    dspfunc(avg_h264_qpel, 0, 16);
-#undef dspfunc
-    
-  } else
-#endif /* HAVE_ALTIVEC */
-  {
-    // Non-AltiVec PPC optimisations
-    
-    // ... pending ...
-  }
-}
diff --git a/ffmpeg.src/libavcodec/ppc/dsputil_h264_template_altivec.c b/ffmpeg.src/libavcodec/ppc/dsputil_h264_template_altivec.c
deleted file mode 100644
index cb0fa95..0000000
--- a/ffmpeg.src/libavcodec/ppc/dsputil_h264_template_altivec.c
+++ /dev/null
@@ -1,639 +0,0 @@
-/*
- * Copyright (c) 2004 Romain Dolbeau <romain at dolbeau.org>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/* this code assume that stride % 16 == 0 */
-void PREFIX_h264_chroma_mc8_altivec(uint8_t * dst, uint8_t * src, int stride, int h, int x, int y) {
-  POWERPC_PERF_DECLARE(PREFIX_h264_chroma_mc8_num, 1);
-  POWERPC_PERF_START_COUNT(PREFIX_h264_chroma_mc8_num, 1);
-    signed int ABCD[4] __attribute__((aligned(16)));
-    register int i;
-    ABCD[0] = ((8 - x) * (8 - y));
-    ABCD[1] = ((x) * (8 - y));
-    ABCD[2] = ((8 - x) * (y));
-    ABCD[3] = ((x) * (y));
-    const vector signed int vABCD = vec_ld(0, ABCD);
-    const vector signed short vA = vec_splat((vector signed short)vABCD, 1);
-    const vector signed short vB = vec_splat((vector signed short)vABCD, 3);
-    const vector signed short vC = vec_splat((vector signed short)vABCD, 5);
-    const vector signed short vD = vec_splat((vector signed short)vABCD, 7);
-    const vector signed int vzero = vec_splat_s32(0);
-    const vector signed short v32ss = (const vector signed short)AVV(32);
-    const vector unsigned short v6us = vec_splat_u16(6);
-
-    vector unsigned char fperm;
-
-    if (((unsigned long)dst) % 16 == 0) {
-      fperm = (vector unsigned char)AVV(0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
-                                        0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F);
-    } else {
-      fperm = (vector unsigned char)AVV(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-                                        0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F);
-    }
-
-    register int loadSecond = (((unsigned long)src) % 16) <= 7 ? 0 : 1;
-    register int reallyBadAlign = (((unsigned long)src) % 16) == 15 ? 1 : 0;
-    
-    vector unsigned char vsrcAuc;
-    vector unsigned char vsrcBuc;
-    vector unsigned char vsrcperm0;
-    vector unsigned char vsrcperm1;
-    vsrcAuc = vec_ld(0, src);
-    if (loadSecond)
-      vsrcBuc = vec_ld(16, src);
-    vsrcperm0 = vec_lvsl(0, src);
-    vsrcperm1 = vec_lvsl(1, src);
-    
-    vector unsigned char vsrc0uc;
-    vector unsigned char vsrc1uc;
-    vsrc0uc = vec_perm(vsrcAuc, vsrcBuc, vsrcperm0);
-    if (reallyBadAlign)
-      vsrc1uc = vsrcBuc;
-    else
-      vsrc1uc = vec_perm(vsrcAuc, vsrcBuc, vsrcperm1);
-    
-    vector signed short vsrc0ssH = (vector signed short)vec_mergeh((vector unsigned char)vzero, (vector unsigned char)vsrc0uc);
-    vector signed short vsrc1ssH = (vector signed short)vec_mergeh((vector unsigned char)vzero, (vector unsigned char)vsrc1uc);
-
-    if (!loadSecond) {// -> !reallyBadAlign
-      for (i = 0 ; i < h ; i++) {
-        vector unsigned char vsrcCuc;
-        vsrcCuc = vec_ld(stride + 0, src);
-        
-        vector unsigned char vsrc2uc;
-        vector unsigned char vsrc3uc;
-        vsrc2uc = vec_perm(vsrcCuc, vsrcCuc, vsrcperm0);
-        vsrc3uc = vec_perm(vsrcCuc, vsrcCuc, vsrcperm1);
-        
-        vector signed short vsrc2ssH = (vector signed short)vec_mergeh((vector unsigned char)vzero, (vector unsigned char)vsrc2uc);
-        vector signed short vsrc3ssH = (vector signed short)vec_mergeh((vector unsigned char)vzero, (vector unsigned char)vsrc3uc);
-        
-        vector signed short psum;
-        
-        psum = vec_mladd(vA, vsrc0ssH, vec_splat_s16(0));
-        psum = vec_mladd(vB, vsrc1ssH, psum);
-        psum = vec_mladd(vC, vsrc2ssH, psum);
-        psum = vec_mladd(vD, vsrc3ssH, psum);
-        psum = vec_add(v32ss, psum);
-        psum = vec_sra(psum, v6us);
-        
-        vector unsigned char vdst = vec_ld(0, dst);
-        vector unsigned char ppsum = (vector unsigned char)vec_packsu(psum, psum);
-        
-        vector unsigned char vfdst = vec_perm(vdst, ppsum, fperm);
-        vector unsigned char fsum;
-        
-        OP_U8_ALTIVEC(fsum, vfdst, vdst);
-
-        vec_st(fsum, 0, dst);
-        
-        vsrc0ssH = vsrc2ssH;
-        vsrc1ssH = vsrc3ssH;
-        
-        dst += stride;
-        src += stride;
-      }
-    } else {
-      for (i = 0 ; i < h ; i++) {
-        vector unsigned char vsrcCuc;
-        vector unsigned char vsrcDuc;
-        vsrcCuc = vec_ld(stride + 0, src);
-        vsrcDuc = vec_ld(stride + 16, src);
-        
-        vector unsigned char vsrc2uc;
-        vector unsigned char vsrc3uc;
-        vsrc2uc = vec_perm(vsrcCuc, vsrcDuc, vsrcperm0);
-        if (reallyBadAlign)
-          vsrc3uc = vsrcDuc;
-        else
-          vsrc3uc = vec_perm(vsrcCuc, vsrcDuc, vsrcperm1);
-        
-        vector signed short vsrc2ssH = (vector signed short)vec_mergeh((vector unsigned char)vzero, (vector unsigned char)vsrc2uc);
-        vector signed short vsrc3ssH = (vector signed short)vec_mergeh((vector unsigned char)vzero, (vector unsigned char)vsrc3uc);
-        
-        vector signed short psum;
-      
-        psum = vec_mladd(vA, vsrc0ssH, vec_splat_s16(0));
-        psum = vec_mladd(vB, vsrc1ssH, psum);
-        psum = vec_mladd(vC, vsrc2ssH, psum);
-        psum = vec_mladd(vD, vsrc3ssH, psum);
-        psum = vec_add(v32ss, psum);
-        psum = vec_sr(psum, v6us);
-        
-        vector unsigned char vdst = vec_ld(0, dst);
-        vector unsigned char ppsum = (vector unsigned char)vec_pack(psum, psum); 
-        
-        vector unsigned char vfdst = vec_perm(vdst, ppsum, fperm);
-        vector unsigned char fsum;
-        
-        OP_U8_ALTIVEC(fsum, vfdst, vdst);
-
-        vec_st(fsum, 0, dst);
-        
-        vsrc0ssH = vsrc2ssH;
-        vsrc1ssH = vsrc3ssH;
-        
-        dst += stride;
-        src += stride;
-      }
-    }
-    POWERPC_PERF_STOP_COUNT(PREFIX_h264_chroma_mc8_num, 1);
-}
-
-/* this code assume stride % 16 == 0 */
-static void PREFIX_h264_qpel16_h_lowpass_altivec(uint8_t * dst, uint8_t * src, int dstStride, int srcStride) {
-  POWERPC_PERF_DECLARE(PREFIX_h264_qpel16_h_lowpass_num, 1);
-  POWERPC_PERF_START_COUNT(PREFIX_h264_qpel16_h_lowpass_num, 1);
-  register int i;
-  
-  const vector signed int vzero = vec_splat_s32(0);
-  const vector unsigned char permM2 = vec_lvsl(-2, src);
-  const vector unsigned char permM1 = vec_lvsl(-1, src);
-  const vector unsigned char permP0 = vec_lvsl(+0, src);
-  const vector unsigned char permP1 = vec_lvsl(+1, src);
-  const vector unsigned char permP2 = vec_lvsl(+2, src);
-  const vector unsigned char permP3 = vec_lvsl(+3, src);
-  const vector signed short v20ss = (const vector signed short)AVV(20);
-  const vector unsigned short v5us = vec_splat_u16(5);
-  const vector signed short v5ss = vec_splat_s16(5);
-  const vector signed short v16ss = (const vector signed short)AVV(16);
-  const vector unsigned char dstperm = vec_lvsr(0, dst);
-  const vector unsigned char neg1 = (const vector unsigned char)vec_splat_s8(-1);
-  const vector unsigned char dstmask = vec_perm((const vector unsigned char)vzero, neg1, dstperm);
-
-  register int align = ((((unsigned long)src) - 2) % 16);
-
-  for (i = 0 ; i < 16 ; i ++) {
-    vector unsigned char srcM2, srcM1, srcP0, srcP1, srcP2, srcP3;
-    vector unsigned char srcR1 = vec_ld(-2, src);
-    vector unsigned char srcR2 = vec_ld(14, src);
-
-    switch (align) {
-    default: {
-      srcM2 = vec_perm(srcR1, srcR2, permM2);
-      srcM1 = vec_perm(srcR1, srcR2, permM1);
-      srcP0 = vec_perm(srcR1, srcR2, permP0);
-      srcP1 = vec_perm(srcR1, srcR2, permP1);
-      srcP2 = vec_perm(srcR1, srcR2, permP2);
-      srcP3 = vec_perm(srcR1, srcR2, permP3);
-    } break;
-    case 11: {
-      srcM2 = vec_perm(srcR1, srcR2, permM2);
-      srcM1 = vec_perm(srcR1, srcR2, permM1);
-      srcP0 = vec_perm(srcR1, srcR2, permP0);
-      srcP1 = vec_perm(srcR1, srcR2, permP1);
-      srcP2 = vec_perm(srcR1, srcR2, permP2);
-      srcP3 = srcR2;
-    } break;
-    case 12: {
-      vector unsigned char srcR3 = vec_ld(30, src);
-      srcM2 = vec_perm(srcR1, srcR2, permM2);
-      srcM1 = vec_perm(srcR1, srcR2, permM1);
-      srcP0 = vec_perm(srcR1, srcR2, permP0);
-      srcP1 = vec_perm(srcR1, srcR2, permP1);
-      srcP2 = srcR2;
-      srcP3 = vec_perm(srcR2, srcR3, permP3);
-    } break;
-    case 13: {
-      vector unsigned char srcR3 = vec_ld(30, src);
-      srcM2 = vec_perm(srcR1, srcR2, permM2);
-      srcM1 = vec_perm(srcR1, srcR2, permM1);
-      srcP0 = vec_perm(srcR1, srcR2, permP0);
-      srcP1 = srcR2;
-      srcP2 = vec_perm(srcR2, srcR3, permP2);
-      srcP3 = vec_perm(srcR2, srcR3, permP3);
-    } break;
-    case 14: {
-      vector unsigned char srcR3 = vec_ld(30, src);
-      srcM2 = vec_perm(srcR1, srcR2, permM2);
-      srcM1 = vec_perm(srcR1, srcR2, permM1);
-      srcP0 = srcR2;
-      srcP1 = vec_perm(srcR2, srcR3, permP1);
-      srcP2 = vec_perm(srcR2, srcR3, permP2);
-      srcP3 = vec_perm(srcR2, srcR3, permP3);
-    } break;
-    case 15: {
-      vector unsigned char srcR3 = vec_ld(30, src);
-      srcM2 = vec_perm(srcR1, srcR2, permM2);
-      srcM1 = srcR2;
-      srcP0 = vec_perm(srcR2, srcR3, permP0);
-      srcP1 = vec_perm(srcR2, srcR3, permP1);
-      srcP2 = vec_perm(srcR2, srcR3, permP2);
-      srcP3 = vec_perm(srcR2, srcR3, permP3);
-    } break;
-    }
-
-    const vector signed short srcP0A = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcP0);
-    const vector signed short srcP0B = (vector signed short)vec_mergel((vector unsigned char)vzero, srcP0);
-    const vector signed short srcP1A = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcP1);
-    const vector signed short srcP1B = (vector signed short)vec_mergel((vector unsigned char)vzero, srcP1);
-
-    const vector signed short srcP2A = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcP2);
-    const vector signed short srcP2B = (vector signed short)vec_mergel((vector unsigned char)vzero, srcP2);
-    const vector signed short srcP3A = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcP3);
-    const vector signed short srcP3B = (vector signed short)vec_mergel((vector unsigned char)vzero, srcP3);
-
-    const vector signed short srcM1A = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcM1);
-    const vector signed short srcM1B = (vector signed short)vec_mergel((vector unsigned char)vzero, srcM1);
-    const vector signed short srcM2A = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcM2);
-    const vector signed short srcM2B = (vector signed short)vec_mergel((vector unsigned char)vzero, srcM2);
-
-    const vector signed short sum1A = vec_adds(srcP0A, srcP1A);
-    const vector signed short sum1B = vec_adds(srcP0B, srcP1B);
-    const vector signed short sum2A = vec_adds(srcM1A, srcP2A);
-    const vector signed short sum2B = vec_adds(srcM1B, srcP2B);
-    const vector signed short sum3A = vec_adds(srcM2A, srcP3A);
-    const vector signed short sum3B = vec_adds(srcM2B, srcP3B);
-    
-    const vector signed short pp1A = vec_mladd(sum1A, v20ss, v16ss);
-    const vector signed short pp1B = vec_mladd(sum1B, v20ss, v16ss);
-
-    const vector signed short pp2A = vec_mladd(sum2A, v5ss, (vector signed short)vzero);
-    const vector signed short pp2B = vec_mladd(sum2B, v5ss, (vector signed short)vzero);
-    
-    const vector signed short pp3A = vec_add(sum3A, pp1A);
-    const vector signed short pp3B = vec_add(sum3B, pp1B);
-
-    const vector signed short psumA = vec_sub(pp3A, pp2A);
-    const vector signed short psumB = vec_sub(pp3B, pp2B);
-
-    const vector signed short sumA = vec_sra(psumA, v5us);
-    const vector signed short sumB = vec_sra(psumB, v5us);
-
-    const vector unsigned char sum = vec_packsu(sumA, sumB);
-
-    const vector unsigned char dst1 = vec_ld(0, dst);
-    const vector unsigned char dst2 = vec_ld(16, dst);
-    const vector unsigned char vdst = vec_perm(dst1, dst2, vec_lvsl(0, dst));
-
-    vector unsigned char fsum;
-    OP_U8_ALTIVEC(fsum, sum, vdst);
-
-    const vector unsigned char rsum = vec_perm(fsum, fsum, dstperm);
-    const vector unsigned char fdst1 = vec_sel(dst1, rsum, dstmask);
-    const vector unsigned char fdst2 = vec_sel(rsum, dst2, dstmask);
-
-    vec_st(fdst1, 0, dst);
-    vec_st(fdst2, 16, dst);
-
-    src += srcStride;
-    dst += dstStride;
-  }
-POWERPC_PERF_STOP_COUNT(PREFIX_h264_qpel16_h_lowpass_num, 1);
-}
-
-/* this code assume stride % 16 == 0 */
-static void PREFIX_h264_qpel16_v_lowpass_altivec(uint8_t * dst, uint8_t * src, int dstStride, int srcStride) {
-  POWERPC_PERF_DECLARE(PREFIX_h264_qpel16_v_lowpass_num, 1);
-  POWERPC_PERF_START_COUNT(PREFIX_h264_qpel16_v_lowpass_num, 1);
-  
-  register int i;
-
-  const vector signed int vzero = vec_splat_s32(0);
-  const vector unsigned char perm = vec_lvsl(0, src);
-  const vector signed short v20ss = (const vector signed short)AVV(20);
-  const vector unsigned short v5us = vec_splat_u16(5);
-  const vector signed short v5ss = vec_splat_s16(5);
-  const vector signed short v16ss = (const vector signed short)AVV(16);
-  const vector unsigned char dstperm = vec_lvsr(0, dst);
-  const vector unsigned char neg1 = (const vector unsigned char)vec_splat_s8(-1);
-  const vector unsigned char dstmask = vec_perm((const vector unsigned char)vzero, neg1, dstperm);
-  
-  uint8_t *srcbis = src - (srcStride * 2);
-
-  const vector unsigned char srcM2a = vec_ld(0, srcbis);
-  const vector unsigned char srcM2b = vec_ld(16, srcbis);
-  const vector unsigned char srcM2 = vec_perm(srcM2a, srcM2b, perm);
-  srcbis += srcStride;
-  const vector unsigned char srcM1a = vec_ld(0, srcbis);
-  const vector unsigned char srcM1b = vec_ld(16, srcbis);
-  const vector unsigned char srcM1 = vec_perm(srcM1a, srcM1b, perm);
-  srcbis += srcStride;
-  const vector unsigned char srcP0a = vec_ld(0, srcbis);
-  const vector unsigned char srcP0b = vec_ld(16, srcbis);
-  const vector unsigned char srcP0 = vec_perm(srcP0a, srcP0b, perm);
-  srcbis += srcStride;
-  const vector unsigned char srcP1a = vec_ld(0, srcbis);
-  const vector unsigned char srcP1b = vec_ld(16, srcbis);
-  const vector unsigned char srcP1 = vec_perm(srcP1a, srcP1b, perm);
-  srcbis += srcStride;
-  const vector unsigned char srcP2a = vec_ld(0, srcbis);
-  const vector unsigned char srcP2b = vec_ld(16, srcbis);
-  const vector unsigned char srcP2 = vec_perm(srcP2a, srcP2b, perm);
-  srcbis += srcStride;
-
-  vector signed short srcM2ssA = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcM2);
-  vector signed short srcM2ssB = (vector signed short)vec_mergel((vector unsigned char)vzero, srcM2);
-  vector signed short srcM1ssA = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcM1);
-  vector signed short srcM1ssB = (vector signed short)vec_mergel((vector unsigned char)vzero, srcM1);
-  vector signed short srcP0ssA = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcP0);
-  vector signed short srcP0ssB = (vector signed short)vec_mergel((vector unsigned char)vzero, srcP0);
-  vector signed short srcP1ssA = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcP1);
-  vector signed short srcP1ssB = (vector signed short)vec_mergel((vector unsigned char)vzero, srcP1);
-  vector signed short srcP2ssA = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcP2);
-  vector signed short srcP2ssB = (vector signed short)vec_mergel((vector unsigned char)vzero, srcP2);
-
-  for (i = 0 ; i < 16 ; i++) {
-    const vector unsigned char srcP3a = vec_ld(0, srcbis);
-    const vector unsigned char srcP3b = vec_ld(16, srcbis);
-    const vector unsigned char srcP3 = vec_perm(srcP3a, srcP3b, perm);
-    const vector signed short srcP3ssA = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcP3);
-    const vector signed short srcP3ssB = (vector signed short)vec_mergel((vector unsigned char)vzero, srcP3);
-    srcbis += srcStride;
-
-    const vector signed short sum1A = vec_adds(srcP0ssA, srcP1ssA);
-    const vector signed short sum1B = vec_adds(srcP0ssB, srcP1ssB);
-    const vector signed short sum2A = vec_adds(srcM1ssA, srcP2ssA);
-    const vector signed short sum2B = vec_adds(srcM1ssB, srcP2ssB);
-    const vector signed short sum3A = vec_adds(srcM2ssA, srcP3ssA);
-    const vector signed short sum3B = vec_adds(srcM2ssB, srcP3ssB);
-
-    srcM2ssA = srcM1ssA;
-    srcM2ssB = srcM1ssB;
-    srcM1ssA = srcP0ssA;
-    srcM1ssB = srcP0ssB;
-    srcP0ssA = srcP1ssA;
-    srcP0ssB = srcP1ssB;
-    srcP1ssA = srcP2ssA;
-    srcP1ssB = srcP2ssB;
-    srcP2ssA = srcP3ssA;
-    srcP2ssB = srcP3ssB;
-    
-    const vector signed short pp1A = vec_mladd(sum1A, v20ss, v16ss);
-    const vector signed short pp1B = vec_mladd(sum1B, v20ss, v16ss);
-
-    const vector signed short pp2A = vec_mladd(sum2A, v5ss, (vector signed short)vzero);
-    const vector signed short pp2B = vec_mladd(sum2B, v5ss, (vector signed short)vzero);
-    
-    const vector signed short pp3A = vec_add(sum3A, pp1A);
-    const vector signed short pp3B = vec_add(sum3B, pp1B);
-
-    const vector signed short psumA = vec_sub(pp3A, pp2A);
-    const vector signed short psumB = vec_sub(pp3B, pp2B);
-
-    const vector signed short sumA = vec_sra(psumA, v5us);
-    const vector signed short sumB = vec_sra(psumB, v5us);
-
-    const vector unsigned char sum = vec_packsu(sumA, sumB);
-
-    const vector unsigned char dst1 = vec_ld(0, dst);
-    const vector unsigned char dst2 = vec_ld(16, dst);
-    const vector unsigned char vdst = vec_perm(dst1, dst2, vec_lvsl(0, dst));
-
-    vector unsigned char fsum;
-    OP_U8_ALTIVEC(fsum, sum, vdst);
-
-    const vector unsigned char rsum = vec_perm(fsum, fsum, dstperm);
-    const vector unsigned char fdst1 = vec_sel(dst1, rsum, dstmask);
-    const vector unsigned char fdst2 = vec_sel(rsum, dst2, dstmask);
-
-    vec_st(fdst1, 0, dst);
-    vec_st(fdst2, 16, dst);
-
-    dst += dstStride;
-  }
-  POWERPC_PERF_STOP_COUNT(PREFIX_h264_qpel16_v_lowpass_num, 1);
-}
-
-/* this code assume stride % 16 == 0 *and* tmp is properly aligned */
-static void PREFIX_h264_qpel16_hv_lowpass_altivec(uint8_t * dst, int16_t * tmp, uint8_t * src, int dstStride, int tmpStride, int srcStride) {
-  POWERPC_PERF_DECLARE(PREFIX_h264_qpel16_hv_lowpass_num, 1);
-  POWERPC_PERF_START_COUNT(PREFIX_h264_qpel16_hv_lowpass_num, 1);
-  register int i;
-  const vector signed int vzero = vec_splat_s32(0);
-  const vector unsigned char permM2 = vec_lvsl(-2, src);
-  const vector unsigned char permM1 = vec_lvsl(-1, src);
-  const vector unsigned char permP0 = vec_lvsl(+0, src);
-  const vector unsigned char permP1 = vec_lvsl(+1, src);
-  const vector unsigned char permP2 = vec_lvsl(+2, src);
-  const vector unsigned char permP3 = vec_lvsl(+3, src);
-  const vector signed short v20ss = (const vector signed short)AVV(20);
-  const vector unsigned int v10ui = vec_splat_u32(10);
-  const vector signed short v5ss = vec_splat_s16(5);
-  const vector signed short v1ss = vec_splat_s16(1);
-  const vector signed int v512si = (const vector signed int)AVV(512);
-  const vector unsigned int v16ui = (const vector unsigned int)AVV(16);
-
-  register int align = ((((unsigned long)src) - 2) % 16);
-
-  src -= (2 * srcStride);
-
-  for (i = 0 ; i < 21 ; i ++) {
-    vector unsigned char srcM2, srcM1, srcP0, srcP1, srcP2, srcP3;
-    vector unsigned char srcR1 = vec_ld(-2, src);
-    vector unsigned char srcR2 = vec_ld(14, src);
-
-    switch (align) {
-    default: {
-      srcM2 = vec_perm(srcR1, srcR2, permM2);
-      srcM1 = vec_perm(srcR1, srcR2, permM1);
-      srcP0 = vec_perm(srcR1, srcR2, permP0);
-      srcP1 = vec_perm(srcR1, srcR2, permP1);
-      srcP2 = vec_perm(srcR1, srcR2, permP2);
-      srcP3 = vec_perm(srcR1, srcR2, permP3);
-    } break;
-    case 11: {
-      srcM2 = vec_perm(srcR1, srcR2, permM2);
-      srcM1 = vec_perm(srcR1, srcR2, permM1);
-      srcP0 = vec_perm(srcR1, srcR2, permP0);
-      srcP1 = vec_perm(srcR1, srcR2, permP1);
-      srcP2 = vec_perm(srcR1, srcR2, permP2);
-      srcP3 = srcR2;
-    } break;
-    case 12: {
-      vector unsigned char srcR3 = vec_ld(30, src);
-      srcM2 = vec_perm(srcR1, srcR2, permM2);
-      srcM1 = vec_perm(srcR1, srcR2, permM1);
-      srcP0 = vec_perm(srcR1, srcR2, permP0);
-      srcP1 = vec_perm(srcR1, srcR2, permP1);
-      srcP2 = srcR2;
-      srcP3 = vec_perm(srcR2, srcR3, permP3);
-    } break;
-    case 13: {
-      vector unsigned char srcR3 = vec_ld(30, src);
-      srcM2 = vec_perm(srcR1, srcR2, permM2);
-      srcM1 = vec_perm(srcR1, srcR2, permM1);
-      srcP0 = vec_perm(srcR1, srcR2, permP0);
-      srcP1 = srcR2;
-      srcP2 = vec_perm(srcR2, srcR3, permP2);
-      srcP3 = vec_perm(srcR2, srcR3, permP3);
-    } break;
-    case 14: {
-      vector unsigned char srcR3 = vec_ld(30, src);
-      srcM2 = vec_perm(srcR1, srcR2, permM2);
-      srcM1 = vec_perm(srcR1, srcR2, permM1);
-      srcP0 = srcR2;
-      srcP1 = vec_perm(srcR2, srcR3, permP1);
-      srcP2 = vec_perm(srcR2, srcR3, permP2);
-      srcP3 = vec_perm(srcR2, srcR3, permP3);
-    } break;
-    case 15: {
-      vector unsigned char srcR3 = vec_ld(30, src);
-      srcM2 = vec_perm(srcR1, srcR2, permM2);
-      srcM1 = srcR2;
-      srcP0 = vec_perm(srcR2, srcR3, permP0);
-      srcP1 = vec_perm(srcR2, srcR3, permP1);
-      srcP2 = vec_perm(srcR2, srcR3, permP2);
-      srcP3 = vec_perm(srcR2, srcR3, permP3);
-    } break;
-    }
-
-    const vector signed short srcP0A = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcP0);
-    const vector signed short srcP0B = (vector signed short)vec_mergel((vector unsigned char)vzero, srcP0);
-    const vector signed short srcP1A = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcP1);
-    const vector signed short srcP1B = (vector signed short)vec_mergel((vector unsigned char)vzero, srcP1);
-
-    const vector signed short srcP2A = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcP2);
-    const vector signed short srcP2B = (vector signed short)vec_mergel((vector unsigned char)vzero, srcP2);
-    const vector signed short srcP3A = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcP3);
-    const vector signed short srcP3B = (vector signed short)vec_mergel((vector unsigned char)vzero, srcP3);
-
-    const vector signed short srcM1A = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcM1);
-    const vector signed short srcM1B = (vector signed short)vec_mergel((vector unsigned char)vzero, srcM1);
-    const vector signed short srcM2A = (vector signed short)vec_mergeh((vector unsigned char)vzero, srcM2);
-    const vector signed short srcM2B = (vector signed short)vec_mergel((vector unsigned char)vzero, srcM2);
-
-    const vector signed short sum1A = vec_adds(srcP0A, srcP1A);
-    const vector signed short sum1B = vec_adds(srcP0B, srcP1B);
-    const vector signed short sum2A = vec_adds(srcM1A, srcP2A);
-    const vector signed short sum2B = vec_adds(srcM1B, srcP2B);
-    const vector signed short sum3A = vec_adds(srcM2A, srcP3A);
-    const vector signed short sum3B = vec_adds(srcM2B, srcP3B);
-    
-    const vector signed short pp1A = vec_mladd(sum1A, v20ss, sum3A);
-    const vector signed short pp1B = vec_mladd(sum1B, v20ss, sum3B);
-
-    const vector signed short pp2A = vec_mladd(sum2A, v5ss, (vector signed short)vzero);
-    const vector signed short pp2B = vec_mladd(sum2B, v5ss, (vector signed short)vzero);
-
-    const vector signed short psumA = vec_sub(pp1A, pp2A);
-    const vector signed short psumB = vec_sub(pp1B, pp2B);
-
-    vec_st(psumA, 0, tmp);
-    vec_st(psumB, 16, tmp);
-    
-    src += srcStride;
-    tmp += tmpStride; /* int16_t*, and stride is 16, so it's OK here */
-  }
-  
-  const vector unsigned char dstperm = vec_lvsr(0, dst);
-  const vector unsigned char neg1 = (const vector unsigned char)vec_splat_s8(-1);
-  const vector unsigned char dstmask = vec_perm((const vector unsigned char)vzero, neg1, dstperm);
-  const vector unsigned char mperm = (const vector unsigned char)
-    AVV(0x00, 0x08, 0x01, 0x09, 0x02, 0x0A, 0x03, 0x0B,
-        0x04, 0x0C, 0x05, 0x0D, 0x06, 0x0E, 0x07, 0x0F);
-  
-  int16_t *tmpbis = tmp - (tmpStride * 21);
-
-  vector signed short tmpM2ssA = vec_ld(0, tmpbis);
-  vector signed short tmpM2ssB = vec_ld(16, tmpbis);
-  tmpbis += tmpStride;
-  vector signed short tmpM1ssA = vec_ld(0, tmpbis);
-  vector signed short tmpM1ssB = vec_ld(16, tmpbis);
-  tmpbis += tmpStride;
-  vector signed short tmpP0ssA = vec_ld(0, tmpbis);
-  vector signed short tmpP0ssB = vec_ld(16, tmpbis);
-  tmpbis += tmpStride;
-  vector signed short tmpP1ssA = vec_ld(0, tmpbis);
-  vector signed short tmpP1ssB = vec_ld(16, tmpbis);
-  tmpbis += tmpStride;
-  vector signed short tmpP2ssA = vec_ld(0, tmpbis);
-  vector signed short tmpP2ssB = vec_ld(16, tmpbis);
-  tmpbis += tmpStride;
-
-  for (i = 0 ; i < 16 ; i++) {
-    const vector signed short tmpP3ssA = vec_ld(0, tmpbis);
-    const vector signed short tmpP3ssB = vec_ld(16, tmpbis);
-    tmpbis += tmpStride;
-
-    const vector signed short sum1A = vec_adds(tmpP0ssA, tmpP1ssA);
-    const vector signed short sum1B = vec_adds(tmpP0ssB, tmpP1ssB);
-    const vector signed short sum2A = vec_adds(tmpM1ssA, tmpP2ssA);
-    const vector signed short sum2B = vec_adds(tmpM1ssB, tmpP2ssB);
-    const vector signed short sum3A = vec_adds(tmpM2ssA, tmpP3ssA);
-    const vector signed short sum3B = vec_adds(tmpM2ssB, tmpP3ssB);
-
-    tmpM2ssA = tmpM1ssA;
-    tmpM2ssB = tmpM1ssB;
-    tmpM1ssA = tmpP0ssA;
-    tmpM1ssB = tmpP0ssB;
-    tmpP0ssA = tmpP1ssA;
-    tmpP0ssB = tmpP1ssB;
-    tmpP1ssA = tmpP2ssA;
-    tmpP1ssB = tmpP2ssB;
-    tmpP2ssA = tmpP3ssA;
-    tmpP2ssB = tmpP3ssB;
-
-    const vector signed int pp1Ae = vec_mule(sum1A, v20ss);
-    const vector signed int pp1Ao = vec_mulo(sum1A, v20ss);
-    const vector signed int pp1Be = vec_mule(sum1B, v20ss);
-    const vector signed int pp1Bo = vec_mulo(sum1B, v20ss);
-
-    const vector signed int pp2Ae = vec_mule(sum2A, v5ss);
-    const vector signed int pp2Ao = vec_mulo(sum2A, v5ss);
-    const vector signed int pp2Be = vec_mule(sum2B, v5ss);
-    const vector signed int pp2Bo = vec_mulo(sum2B, v5ss);
-
-    const vector signed int pp3Ae = vec_sra((vector signed int)sum3A, v16ui);
-    const vector signed int pp3Ao = vec_mulo(sum3A, v1ss);
-    const vector signed int pp3Be = vec_sra((vector signed int)sum3B, v16ui);
-    const vector signed int pp3Bo = vec_mulo(sum3B, v1ss);
-
-    const vector signed int pp1cAe = vec_add(pp1Ae, v512si);
-    const vector signed int pp1cAo = vec_add(pp1Ao, v512si);
-    const vector signed int pp1cBe = vec_add(pp1Be, v512si);
-    const vector signed int pp1cBo = vec_add(pp1Bo, v512si);
-
-    const vector signed int pp32Ae = vec_sub(pp3Ae, pp2Ae);
-    const vector signed int pp32Ao = vec_sub(pp3Ao, pp2Ao);
-    const vector signed int pp32Be = vec_sub(pp3Be, pp2Be);
-    const vector signed int pp32Bo = vec_sub(pp3Bo, pp2Bo);
-
-    const vector signed int sumAe = vec_add(pp1cAe, pp32Ae);
-    const vector signed int sumAo = vec_add(pp1cAo, pp32Ao);
-    const vector signed int sumBe = vec_add(pp1cBe, pp32Be);
-    const vector signed int sumBo = vec_add(pp1cBo, pp32Bo);
-    
-    const vector signed int ssumAe = vec_sra(sumAe, v10ui);
-    const vector signed int ssumAo = vec_sra(sumAo, v10ui);
-    const vector signed int ssumBe = vec_sra(sumBe, v10ui);
-    const vector signed int ssumBo = vec_sra(sumBo, v10ui);
-
-    const vector signed short ssume = vec_packs(ssumAe, ssumBe);
-    const vector signed short ssumo = vec_packs(ssumAo, ssumBo);
-
-    const vector unsigned char sumv = vec_packsu(ssume, ssumo);
-    const vector unsigned char sum = vec_perm(sumv, sumv, mperm);
-
-    const vector unsigned char dst1 = vec_ld(0, dst);
-    const vector unsigned char dst2 = vec_ld(16, dst);
-    const vector unsigned char vdst = vec_perm(dst1, dst2, vec_lvsl(0, dst));
-
-    vector unsigned char fsum;
-    OP_U8_ALTIVEC(fsum, sum, vdst);
-
-    const vector unsigned char rsum = vec_perm(fsum, fsum, dstperm);
-    const vector unsigned char fdst1 = vec_sel(dst1, rsum, dstmask);
-    const vector unsigned char fdst2 = vec_sel(rsum, dst2, dstmask);
-
-    vec_st(fdst1, 0, dst);
-    vec_st(fdst2, 16, dst);
-
-    dst += dstStride;
-  }
-  POWERPC_PERF_STOP_COUNT(PREFIX_h264_qpel16_hv_lowpass_num, 1);
-}
diff --git a/ffmpeg.src/libavcodec/ppc/dsputil_ppc.c b/ffmpeg.src/libavcodec/ppc/dsputil_ppc.c
deleted file mode 100644
index 776f423..0000000
--- a/ffmpeg.src/libavcodec/ppc/dsputil_ppc.c
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Copyright (c) 2002 Brian Foley
- * Copyright (c) 2002 Dieter Shirley
- * Copyright (c) 2003-2004 Romain Dolbeau <romain at dolbeau.org>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "../dsputil.h"
-
-#include "dsputil_ppc.h"
-
-#ifdef HAVE_ALTIVEC
-#include "dsputil_altivec.h"
-#endif
-
-extern void fdct_altivec(int16_t *block);
-extern void idct_put_altivec(uint8_t *dest, int line_size, int16_t *block);
-extern void idct_add_altivec(uint8_t *dest, int line_size, int16_t *block);
-
-int mm_flags = 0;
-
-int mm_support(void)
-{
-    int result = 0;
-#ifdef HAVE_ALTIVEC
-    if (has_altivec()) {
-        result |= MM_ALTIVEC;
-    }
-#endif /* result */
-    return result;
-}
-
-#ifdef POWERPC_PERFORMANCE_REPORT
-unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total];
-/* list below must match enum in dsputil_ppc.h */
-static unsigned char* perfname[] = {
-  "ff_fft_calc_altivec",
-  "gmc1_altivec",
-  "dct_unquantize_h263_altivec",
-  "fdct_altivec",
-  "idct_add_altivec",
-  "idct_put_altivec",
-  "put_pixels16_altivec",
-  "avg_pixels16_altivec",
-  "avg_pixels8_altivec",
-  "put_pixels8_xy2_altivec",
-  "put_no_rnd_pixels8_xy2_altivec",
-  "put_pixels16_xy2_altivec",
-  "put_no_rnd_pixels16_xy2_altivec",
-  "hadamard8_diff8x8_altivec",
-  "hadamard8_diff16_altivec",
-  "avg_pixels8_xy2_altivec",
-  "clear_blocks_dcbz32_ppc",
-  "clear_blocks_dcbz128_ppc",
-  "put_h264_chroma_mc8_altivec",
-  "avg_h264_chroma_mc8_altivec",
-  "put_h264_qpel16_h_lowpass_altivec",
-  "avg_h264_qpel16_h_lowpass_altivec",
-  "put_h264_qpel16_v_lowpass_altivec",
-  "avg_h264_qpel16_v_lowpass_altivec",
-  "put_h264_qpel16_hv_lowpass_altivec",
-  "avg_h264_qpel16_hv_lowpass_altivec",
-  ""
-};
-#include <stdio.h>
-#endif
-
-#ifdef POWERPC_PERFORMANCE_REPORT
-void powerpc_display_perf_report(void)
-{
-  int i, j;
-  av_log(NULL, AV_LOG_INFO, "PowerPC performance report\n Values are from the PMC registers, and represent whatever the registers are set to record.\n");
-  for(i = 0 ; i < powerpc_perf_total ; i++)
-  {
-    for (j = 0; j < POWERPC_NUM_PMC_ENABLED ; j++)
-      {
-	if (perfdata[j][i][powerpc_data_num] != (unsigned long long)0)
-	  av_log(NULL, AV_LOG_INFO,
-		  " Function \"%s\" (pmc%d):\n\tmin: %llu\n\tmax: %llu\n\tavg: %1.2lf (%llu)\n",
-		  perfname[i],
-		  j+1,
-		  perfdata[j][i][powerpc_data_min],
-		  perfdata[j][i][powerpc_data_max],
-		  (double)perfdata[j][i][powerpc_data_sum] /
-		  (double)perfdata[j][i][powerpc_data_num],
-		  perfdata[j][i][powerpc_data_num]);
-      }
-  }
-}
-#endif /* POWERPC_PERFORMANCE_REPORT */
-
-/* ***** WARNING ***** WARNING ***** WARNING ***** */
-/*
-  clear_blocks_dcbz32_ppc will not work properly
-  on PowerPC processors with a cache line size
-  not equal to 32 bytes.
-  Fortunately all processor used by Apple up to
-  at least the 7450 (aka second generation G4)
-  use 32 bytes cache line.
-  This is due to the use of the 'dcbz' instruction.
-  It simply clear to zero a single cache line,
-  so you need to know the cache line size to use it !
-  It's absurd, but it's fast...
-
-  update 24/06/2003 : Apple released yesterday the G5,
-  with a PPC970. cache line size : 128 bytes. Oups.
-  The semantic of dcbz was changed, it always clear
-  32 bytes. so the function below will work, but will
-  be slow. So I fixed check_dcbz_effect to use dcbzl,
-  which is defined to clear a cache line (as dcbz before).
-  So we still can distinguish, and use dcbz (32 bytes)
-  or dcbzl (one cache line) as required.
-
-  see <http://developer.apple.com/technotes/tn/tn2087.html>
-  and <http://developer.apple.com/technotes/tn/tn2086.html>
-*/
-void clear_blocks_dcbz32_ppc(DCTELEM *blocks)
-{
-POWERPC_PERF_DECLARE(powerpc_clear_blocks_dcbz32, 1);
-    register int misal = ((unsigned long)blocks & 0x00000010);
-    register int i = 0;
-POWERPC_PERF_START_COUNT(powerpc_clear_blocks_dcbz32, 1);
-#if 1
-    if (misal) {
-      ((unsigned long*)blocks)[0] = 0L;
-      ((unsigned long*)blocks)[1] = 0L;
-      ((unsigned long*)blocks)[2] = 0L;
-      ((unsigned long*)blocks)[3] = 0L;
-      i += 16;
-    }
-    for ( ; i < sizeof(DCTELEM)*6*64-31 ; i += 32) {
-#ifndef __MWERKS__
-      asm volatile("dcbz %0,%1" : : "b" (blocks), "r" (i) : "memory");
-#else
-      __dcbz( blocks, i );
-#endif
-    }
-    if (misal) {
-      ((unsigned long*)blocks)[188] = 0L;
-      ((unsigned long*)blocks)[189] = 0L;
-      ((unsigned long*)blocks)[190] = 0L;
-      ((unsigned long*)blocks)[191] = 0L;
-      i += 16;
-    }
-#else
-    memset(blocks, 0, sizeof(DCTELEM)*6*64);
-#endif
-POWERPC_PERF_STOP_COUNT(powerpc_clear_blocks_dcbz32, 1);
-}
-
-/* same as above, when dcbzl clear a whole 128B cache line
-   i.e. the PPC970 aka G5 */
-#ifndef NO_DCBZL
-void clear_blocks_dcbz128_ppc(DCTELEM *blocks)
-{
-POWERPC_PERF_DECLARE(powerpc_clear_blocks_dcbz128, 1);
-    register int misal = ((unsigned long)blocks & 0x0000007f);
-    register int i = 0;
-POWERPC_PERF_START_COUNT(powerpc_clear_blocks_dcbz128, 1);
-#if 1
- if (misal) {
-   // we could probably also optimize this case,
-   // but there's not much point as the machines
-   // aren't available yet (2003-06-26)
-      memset(blocks, 0, sizeof(DCTELEM)*6*64);
-    }
-    else
-      for ( ; i < sizeof(DCTELEM)*6*64 ; i += 128) {
-	asm volatile("dcbzl %0,%1" : : "b" (blocks), "r" (i) : "memory");
-      }
-#else
-    memset(blocks, 0, sizeof(DCTELEM)*6*64);
-#endif
-POWERPC_PERF_STOP_COUNT(powerpc_clear_blocks_dcbz128, 1);
-}
-#else
-void clear_blocks_dcbz128_ppc(DCTELEM *blocks)
-{
-  memset(blocks, 0, sizeof(DCTELEM)*6*64);
-}
-#endif
-
-#ifndef NO_DCBZL
-/* check dcbz report how many bytes are set to 0 by dcbz */
-/* update 24/06/2003 : replace dcbz by dcbzl to get
-   the intended effect (Apple "fixed" dcbz)
-   unfortunately this cannot be used unless the assembler
-   knows about dcbzl ... */
-long check_dcbzl_effect(void)
-{
-  register char *fakedata = (char*)av_malloc(1024);
-  register char *fakedata_middle;
-  register long zero = 0;
-  register long i = 0;
-  long count = 0;
-
-  if (!fakedata)
-  {
-    return 0L;
-  }
-
-  fakedata_middle = (fakedata + 512);
-
-  memset(fakedata, 0xFF, 1024);
-
-  /* below the constraint "b" seems to mean "Address base register"
-     in gcc-3.3 / RS/6000 speaks. seems to avoid using r0, so.... */
-  asm volatile("dcbzl %0, %1" : : "b" (fakedata_middle), "r" (zero));
-
-  for (i = 0; i < 1024 ; i ++)
-  {
-    if (fakedata[i] == (char)0)
-      count++;
-  }
-
-  av_free(fakedata);
-  
-  return count;
-}
-#else
-long check_dcbzl_effect(void)
-{
-  return 0;
-}
-#endif
-
-
-void dsputil_h264_init_ppc(DSPContext* c, AVCodecContext *avctx);
-
-void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx)
-{
-    // Common optimizations whether Altivec is available or not
-
-  switch (check_dcbzl_effect()) {
-  case 32:
-    c->clear_blocks = clear_blocks_dcbz32_ppc;
-    break;
-  case 128:
-    c->clear_blocks = clear_blocks_dcbz128_ppc;
-    break;
-  default:
-    break;
-  }
-
-#ifdef HAVE_ALTIVEC
-  dsputil_h264_init_ppc(c, avctx);
-  
-    if (has_altivec()) {
-        mm_flags |= MM_ALTIVEC;
-        
-        // Altivec specific optimisations
-        c->pix_abs[0][1] = sad16_x2_altivec;
-        c->pix_abs[0][2] = sad16_y2_altivec;
-        c->pix_abs[0][3] = sad16_xy2_altivec;
-        c->pix_abs[0][0] = sad16_altivec;
-        c->pix_abs[1][0] = sad8_altivec;
-        c->sad[0]= sad16_altivec;
-        c->sad[1]= sad8_altivec;
-        c->pix_norm1 = pix_norm1_altivec;
-        c->sse[1]= sse8_altivec;
-        c->sse[0]= sse16_altivec;
-        c->pix_sum = pix_sum_altivec;
-        c->diff_pixels = diff_pixels_altivec;
-        c->get_pixels = get_pixels_altivec;
-// next one disabled as it's untested.
-#if 0
-        c->add_bytes= add_bytes_altivec;
-#endif /* 0 */
-        c->put_pixels_tab[0][0] = put_pixels16_altivec;
-        /* the two functions do the same thing, so use the same code */
-        c->put_no_rnd_pixels_tab[0][0] = put_pixels16_altivec;
-        c->avg_pixels_tab[0][0] = avg_pixels16_altivec;
-        c->avg_pixels_tab[1][0] = avg_pixels8_altivec;
-	c->avg_pixels_tab[1][3] = avg_pixels8_xy2_altivec;
-        c->put_pixels_tab[1][3] = put_pixels8_xy2_altivec;
-        c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels8_xy2_altivec;
-        c->put_pixels_tab[0][3] = put_pixels16_xy2_altivec;
-        c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_altivec;
-        
-	c->gmc1 = gmc1_altivec;
-
-#ifdef CONFIG_DARWIN // ATM gcc-3.3 and gcc-3.4 fail to compile these in linux...
-	c->hadamard8_diff[0] = hadamard8_diff16_altivec;
-	c->hadamard8_diff[1] = hadamard8_diff8x8_altivec;
-#endif
-
-#ifdef CONFIG_ENCODERS
-	if (avctx->dct_algo == FF_DCT_AUTO ||
-	    avctx->dct_algo == FF_DCT_ALTIVEC)
-	{
-	    c->fdct = fdct_altivec;
-	}
-#endif //CONFIG_ENCODERS
-
-      if (avctx->lowres==0)
-      {
-        if ((avctx->idct_algo == FF_IDCT_AUTO) ||
-                (avctx->idct_algo == FF_IDCT_ALTIVEC))
-        {
-            c->idct_put = idct_put_altivec;
-            c->idct_add = idct_add_altivec;
-#ifndef ALTIVEC_USE_REFERENCE_C_CODE
-            c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-            c->idct_permutation_type = FF_NO_IDCT_PERM;
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-        }
-      }
-        
-#ifdef POWERPC_PERFORMANCE_REPORT
-        {
-          int i, j;
-          for (i = 0 ; i < powerpc_perf_total ; i++)
-          {
-	    for (j = 0; j < POWERPC_NUM_PMC_ENABLED ; j++)
-	      {
-		perfdata[j][i][powerpc_data_min] = 0xFFFFFFFFFFFFFFFFULL;
-		perfdata[j][i][powerpc_data_max] = 0x0000000000000000ULL;
-		perfdata[j][i][powerpc_data_sum] = 0x0000000000000000ULL;
-		perfdata[j][i][powerpc_data_num] = 0x0000000000000000ULL;
-	      }
-	  }
-        }
-#endif /* POWERPC_PERFORMANCE_REPORT */
-    } else
-#endif /* HAVE_ALTIVEC */
-    {
-        // Non-AltiVec PPC optimisations
-
-        // ... pending ...
-    }
-}
diff --git a/ffmpeg.src/libavcodec/ppc/dsputil_ppc.h b/ffmpeg.src/libavcodec/ppc/dsputil_ppc.h
deleted file mode 100644
index 7e01677..0000000
--- a/ffmpeg.src/libavcodec/ppc/dsputil_ppc.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2003-2004 Romain Dolbeau <romain at dolbeau.org>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _DSPUTIL_PPC_
-#define _DSPUTIL_PPC_
-
-#ifdef CONFIG_DARWIN
-/* The Apple assembler shipped w/ gcc-3.3 knows about DCBZL, previous assemblers don't
-   We assume here that the Darwin GCC is from Apple.... */
-#if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
-#define NO_DCBZL
-#endif
-#else /* CONFIG_DARWIN */
-/* I don't think any non-Apple assembler knows about DCBZL */
-#define NO_DCBZL
-#endif /* CONFIG_DARWIN */
-
-#ifdef POWERPC_PERFORMANCE_REPORT
-void powerpc_display_perf_report(void);
-/* the 604* have 2, the G3* have 4, the G4s have 6,
-   and the G5 are completely different (they MUST use
-   POWERPC_MODE_64BITS, and let's hope all future 64 bis PPC
-   will use the same PMCs... */
-#define POWERPC_NUM_PMC_ENABLED 6
-/* if you add to the enum below, also add to the perfname array
-   in dsputil_ppc.c */
-enum powerpc_perf_index {
-  altivec_fft_num = 0,
-  altivec_gmc1_num,
-  altivec_dct_unquantize_h263_num,
-  altivec_fdct,
-  altivec_idct_add_num,
-  altivec_idct_put_num,
-  altivec_put_pixels16_num,
-  altivec_avg_pixels16_num,
-  altivec_avg_pixels8_num,
-  altivec_put_pixels8_xy2_num,
-  altivec_put_no_rnd_pixels8_xy2_num,
-  altivec_put_pixels16_xy2_num,
-  altivec_put_no_rnd_pixels16_xy2_num,
-  altivec_hadamard8_diff8x8_num,
-  altivec_hadamard8_diff16_num,
-  altivec_avg_pixels8_xy2_num,
-  powerpc_clear_blocks_dcbz32,
-  powerpc_clear_blocks_dcbz128,
-  altivec_put_h264_chroma_mc8_num,
-  altivec_avg_h264_chroma_mc8_num,
-  altivec_put_h264_qpel16_h_lowpass_num,
-  altivec_avg_h264_qpel16_h_lowpass_num,
-  altivec_put_h264_qpel16_v_lowpass_num,
-  altivec_avg_h264_qpel16_v_lowpass_num,
-  altivec_put_h264_qpel16_hv_lowpass_num,
-  altivec_avg_h264_qpel16_hv_lowpass_num,
-  powerpc_perf_total
-};
-enum powerpc_data_index {
-  powerpc_data_min = 0,
-  powerpc_data_max,
-  powerpc_data_sum,
-  powerpc_data_num,
-  powerpc_data_total
-};
-extern unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total];
-
-#ifndef POWERPC_MODE_64BITS
-#define POWERP_PMC_DATATYPE unsigned long
-#define POWERPC_GET_PMC1(a) asm volatile("mfspr %0, 937" : "=r" (a))
-#define POWERPC_GET_PMC2(a) asm volatile("mfspr %0, 938" : "=r" (a))
-#if (POWERPC_NUM_PMC_ENABLED > 2)
-#define POWERPC_GET_PMC3(a) asm volatile("mfspr %0, 941" : "=r" (a))
-#define POWERPC_GET_PMC4(a) asm volatile("mfspr %0, 942" : "=r" (a))
-#else
-#define POWERPC_GET_PMC3(a) do {} while (0)
-#define POWERPC_GET_PMC4(a) do {} while (0)
-#endif
-#if (POWERPC_NUM_PMC_ENABLED > 4)
-#define POWERPC_GET_PMC5(a) asm volatile("mfspr %0, 929" : "=r" (a))
-#define POWERPC_GET_PMC6(a) asm volatile("mfspr %0, 930" : "=r" (a))
-#else
-#define POWERPC_GET_PMC5(a) do {} while (0)
-#define POWERPC_GET_PMC6(a) do {} while (0)
-#endif
-#else /* POWERPC_MODE_64BITS */
-#define POWERP_PMC_DATATYPE unsigned long long
-#define POWERPC_GET_PMC1(a) asm volatile("mfspr %0, 771" : "=r" (a))
-#define POWERPC_GET_PMC2(a) asm volatile("mfspr %0, 772" : "=r" (a))
-#if (POWERPC_NUM_PMC_ENABLED > 2)
-#define POWERPC_GET_PMC3(a) asm volatile("mfspr %0, 773" : "=r" (a))
-#define POWERPC_GET_PMC4(a) asm volatile("mfspr %0, 774" : "=r" (a))
-#else
-#define POWERPC_GET_PMC3(a) do {} while (0)
-#define POWERPC_GET_PMC4(a) do {} while (0)
-#endif
-#if (POWERPC_NUM_PMC_ENABLED > 4)
-#define POWERPC_GET_PMC5(a) asm volatile("mfspr %0, 775" : "=r" (a))
-#define POWERPC_GET_PMC6(a) asm volatile("mfspr %0, 776" : "=r" (a))
-#else
-#define POWERPC_GET_PMC5(a) do {} while (0)
-#define POWERPC_GET_PMC6(a) do {} while (0)
-#endif
-#endif /* POWERPC_MODE_64BITS */
-#define POWERPC_PERF_DECLARE(a, cond)				\
-  POWERP_PMC_DATATYPE						\
-    pmc_start[POWERPC_NUM_PMC_ENABLED],				\
-    pmc_stop[POWERPC_NUM_PMC_ENABLED],				\
-    pmc_loop_index;
-#define POWERPC_PERF_START_COUNT(a, cond) do { \
-  POWERPC_GET_PMC6(pmc_start[5]); \
-  POWERPC_GET_PMC5(pmc_start[4]); \
-  POWERPC_GET_PMC4(pmc_start[3]); \
-  POWERPC_GET_PMC3(pmc_start[2]); \
-  POWERPC_GET_PMC2(pmc_start[1]); \
-  POWERPC_GET_PMC1(pmc_start[0]); \
-  } while (0)
-#define POWERPC_PERF_STOP_COUNT(a, cond) do { \
-  POWERPC_GET_PMC1(pmc_stop[0]); \
-  POWERPC_GET_PMC2(pmc_stop[1]); \
-  POWERPC_GET_PMC3(pmc_stop[2]); \
-  POWERPC_GET_PMC4(pmc_stop[3]); \
-  POWERPC_GET_PMC5(pmc_stop[4]); \
-  POWERPC_GET_PMC6(pmc_stop[5]); \
-  if (cond)                       \
-  {                               \
-    for(pmc_loop_index = 0;       \
-        pmc_loop_index < POWERPC_NUM_PMC_ENABLED; \
-        pmc_loop_index++)         \
-    {                             \
-      if (pmc_stop[pmc_loop_index] >= pmc_start[pmc_loop_index])  \
-	{							  \
-        POWERP_PMC_DATATYPE diff =				  \
-          pmc_stop[pmc_loop_index] - pmc_start[pmc_loop_index];   \
-        if (diff < perfdata[pmc_loop_index][a][powerpc_data_min]) \
-          perfdata[pmc_loop_index][a][powerpc_data_min] = diff;   \
-        if (diff > perfdata[pmc_loop_index][a][powerpc_data_max]) \
-          perfdata[pmc_loop_index][a][powerpc_data_max] = diff;   \
-        perfdata[pmc_loop_index][a][powerpc_data_sum] += diff;    \
-        perfdata[pmc_loop_index][a][powerpc_data_num] ++;         \
-      }                           \
-    }                             \
-  }                               \
-} while (0)
-#else /* POWERPC_PERFORMANCE_REPORT */
-// those are needed to avoid empty statements.
-#define POWERPC_PERF_DECLARE(a, cond)        int altivec_placeholder __attribute__ ((unused))
-#define POWERPC_PERF_START_COUNT(a, cond)    do {} while (0)
-#define POWERPC_PERF_STOP_COUNT(a, cond)     do {} while (0)
-#endif /* POWERPC_PERFORMANCE_REPORT */
-
-#endif /*  _DSPUTIL_PPC_ */
diff --git a/ffmpeg.src/libavcodec/ppc/fdct_altivec.c b/ffmpeg.src/libavcodec/ppc/fdct_altivec.c
deleted file mode 100644
index b38b909..0000000
--- a/ffmpeg.src/libavcodec/ppc/fdct_altivec.c
+++ /dev/null
@@ -1,498 +0,0 @@
-/* ffmpeg/libavcodec/ppc/fdct_altivec.c, this file is part of the
- * AltiVec optimized library for the FFMPEG Multimedia System
- * Copyright (C) 2003  James Klicman <james at klicman.org>
- *
- * This library 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.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include "common.h"
-#include "../dsputil.h"
-#include "dsputil_altivec.h"
-#include "gcc_fixes.h"
-
-
-#define vs16(v) ((vector signed short)(v))
-#define vs32(v) ((vector signed int)(v))
-#define vu8(v)  ((vector unsigned char)(v))
-#define vu16(v) ((vector unsigned short)(v))
-#define vu32(v) ((vector unsigned int)(v))
-
-
-#define C1     0.98078525066375732421875000 /* cos(1*PI/16) */
-#define C2     0.92387950420379638671875000 /* cos(2*PI/16) */
-#define C3     0.83146959543228149414062500 /* cos(3*PI/16) */
-#define C4     0.70710676908493041992187500 /* cos(4*PI/16) */
-#define C5     0.55557024478912353515625000 /* cos(5*PI/16) */
-#define C6     0.38268342614173889160156250 /* cos(6*PI/16) */
-#define C7     0.19509032368659973144531250 /* cos(7*PI/16) */
-#define SQRT_2 1.41421353816986083984375000 /* sqrt(2)      */
-
-
-#define W0 -(2 * C2)
-#define W1 (2 * C6)
-#define W2 (SQRT_2 * C6)
-#define W3 (SQRT_2 * C3)
-#define W4 (SQRT_2 * (-C1 + C3 + C5 - C7))
-#define W5 (SQRT_2 * ( C1 + C3 - C5 + C7))
-#define W6 (SQRT_2 * ( C1 + C3 + C5 - C7))
-#define W7 (SQRT_2 * ( C1 + C3 - C5 - C7))
-#define W8 (SQRT_2 * ( C7 - C3))
-#define W9 (SQRT_2 * (-C1 - C3))
-#define WA (SQRT_2 * (-C3 - C5))
-#define WB (SQRT_2 * ( C5 - C3))
-
-
-static vector float fdctconsts[3] = {
-    (vector float)AVV( W0, W1, W2, W3 ),
-    (vector float)AVV( W4, W5, W6, W7 ),
-    (vector float)AVV( W8, W9, WA, WB )
-};
-
-#define LD_W0 vec_splat(cnsts0, 0)
-#define LD_W1 vec_splat(cnsts0, 1)
-#define LD_W2 vec_splat(cnsts0, 2)
-#define LD_W3 vec_splat(cnsts0, 3)
-#define LD_W4 vec_splat(cnsts1, 0)
-#define LD_W5 vec_splat(cnsts1, 1)
-#define LD_W6 vec_splat(cnsts1, 2)
-#define LD_W7 vec_splat(cnsts1, 3)
-#define LD_W8 vec_splat(cnsts2, 0)
-#define LD_W9 vec_splat(cnsts2, 1)
-#define LD_WA vec_splat(cnsts2, 2)
-#define LD_WB vec_splat(cnsts2, 3)
-
-
-#define FDCTROW(b0,b1,b2,b3,b4,b5,b6,b7) /* {{{ */                  \
-    x0 = vec_add(b0, b7);               /* x0 = b0 + b7; */         \
-    x7 = vec_sub(b0, b7);               /* x7 = b0 - b7; */         \
-    x1 = vec_add(b1, b6);               /* x1 = b1 + b6; */         \
-    x6 = vec_sub(b1, b6);               /* x6 = b1 - b6; */         \
-    x2 = vec_add(b2, b5);               /* x2 = b2 + b5; */         \
-    x5 = vec_sub(b2, b5);               /* x5 = b2 - b5; */         \
-    x3 = vec_add(b3, b4);               /* x3 = b3 + b4; */         \
-    x4 = vec_sub(b3, b4);               /* x4 = b3 - b4; */         \
-                                                                    \
-    b7 = vec_add(x0, x3);               /* b7 = x0 + x3; */         \
-    b1 = vec_add(x1, x2);               /* b1 = x1 + x2; */         \
-    b0 = vec_add(b7, b1);               /* b0 = b7 + b1; */         \
-    b4 = vec_sub(b7, b1);               /* b4 = b7 - b1; */         \
-                                                                    \
-    b2 = vec_sub(x0, x3);               /* b2 = x0 - x3; */         \
-    b6 = vec_sub(x1, x2);               /* b6 = x1 - x2; */         \
-    b5 = vec_add(b6, b2);               /* b5 = b6 + b2; */         \
-    cnst = LD_W2;                                                   \
-    b5 = vec_madd(cnst, b5, mzero);     /* b5 = b5 * W2; */         \
-    cnst = LD_W1;                                                   \
-    b2 = vec_madd(cnst, b2, b5);        /* b2 = b5 + b2 * W1; */    \
-    cnst = LD_W0;                                                   \
-    b6 = vec_madd(cnst, b6, b5);        /* b6 = b5 + b6 * W0; */    \
-                                                                    \
-    x0 = vec_add(x4, x7);               /* x0 = x4 + x7; */         \
-    x1 = vec_add(x5, x6);               /* x1 = x5 + x6; */         \
-    x2 = vec_add(x4, x6);               /* x2 = x4 + x6; */         \
-    x3 = vec_add(x5, x7);               /* x3 = x5 + x7; */         \
-    x8 = vec_add(x2, x3);               /* x8 = x2 + x3; */         \
-    cnst = LD_W3;                                                   \
-    x8 = vec_madd(cnst, x8, mzero);     /* x8 = x8 * W3; */         \
-                                                                    \
-    cnst = LD_W8;                                                   \
-    x0 = vec_madd(cnst, x0, mzero);     /* x0 *= W8; */             \
-    cnst = LD_W9;                                                   \
-    x1 = vec_madd(cnst, x1, mzero);     /* x1 *= W9; */             \
-    cnst = LD_WA;                                                   \
-    x2 = vec_madd(cnst, x2, x8);        /* x2 = x2 * WA + x8; */    \
-    cnst = LD_WB;                                                   \
-    x3 = vec_madd(cnst, x3, x8);        /* x3 = x3 * WB + x8; */    \
-                                                                    \
-    cnst = LD_W4;                                                   \
-    b7 = vec_madd(cnst, x4, x0);        /* b7 = x4 * W4 + x0; */    \
-    cnst = LD_W5;                                                   \
-    b5 = vec_madd(cnst, x5, x1);        /* b5 = x5 * W5 + x1; */    \
-    cnst = LD_W6;                                                   \
-    b3 = vec_madd(cnst, x6, x1);        /* b3 = x6 * W6 + x1; */    \
-    cnst = LD_W7;                                                   \
-    b1 = vec_madd(cnst, x7, x0);        /* b1 = x7 * W7 + x0; */    \
-                                                                    \
-    b7 = vec_add(b7, x2);               /* b7 = b7 + x2; */         \
-    b5 = vec_add(b5, x3);               /* b5 = b5 + x3; */         \
-    b3 = vec_add(b3, x2);               /* b3 = b3 + x2; */         \
-    b1 = vec_add(b1, x3);               /* b1 = b1 + x3; */         \
-    /* }}} */
-
-#define FDCTCOL(b0,b1,b2,b3,b4,b5,b6,b7) /* {{{ */                  \
-    x0 = vec_add(b0, b7);               /* x0 = b0 + b7; */         \
-    x7 = vec_sub(b0, b7);               /* x7 = b0 - b7; */         \
-    x1 = vec_add(b1, b6);               /* x1 = b1 + b6; */         \
-    x6 = vec_sub(b1, b6);               /* x6 = b1 - b6; */         \
-    x2 = vec_add(b2, b5);               /* x2 = b2 + b5; */         \
-    x5 = vec_sub(b2, b5);               /* x5 = b2 - b5; */         \
-    x3 = vec_add(b3, b4);               /* x3 = b3 + b4; */         \
-    x4 = vec_sub(b3, b4);               /* x4 = b3 - b4; */         \
-                                                                    \
-    b7 = vec_add(x0, x3);               /* b7 = x0 + x3; */         \
-    b1 = vec_add(x1, x2);               /* b1 = x1 + x2; */         \
-    b0 = vec_add(b7, b1);               /* b0 = b7 + b1; */         \
-    b4 = vec_sub(b7, b1);               /* b4 = b7 - b1; */         \
-                                                                    \
-    b2 = vec_sub(x0, x3);               /* b2 = x0 - x3; */         \
-    b6 = vec_sub(x1, x2);               /* b6 = x1 - x2; */         \
-    b5 = vec_add(b6, b2);               /* b5 = b6 + b2; */         \
-    cnst = LD_W2;                                                   \
-    b5 = vec_madd(cnst, b5, mzero);     /* b5 = b5 * W2; */         \
-    cnst = LD_W1;                                                   \
-    b2 = vec_madd(cnst, b2, b5);        /* b2 = b5 + b2 * W1; */    \
-    cnst = LD_W0;                                                   \
-    b6 = vec_madd(cnst, b6, b5);        /* b6 = b5 + b6 * W0; */    \
-                                                                    \
-    x0 = vec_add(x4, x7);               /* x0 = x4 + x7; */         \
-    x1 = vec_add(x5, x6);               /* x1 = x5 + x6; */         \
-    x2 = vec_add(x4, x6);               /* x2 = x4 + x6; */         \
-    x3 = vec_add(x5, x7);               /* x3 = x5 + x7; */         \
-    x8 = vec_add(x2, x3);               /* x8 = x2 + x3; */         \
-    cnst = LD_W3;                                                   \
-    x8 = vec_madd(cnst, x8, mzero);     /* x8 = x8 * W3; */         \
-                                                                    \
-    cnst = LD_W8;                                                   \
-    x0 = vec_madd(cnst, x0, mzero);     /* x0 *= W8; */             \
-    cnst = LD_W9;                                                   \
-    x1 = vec_madd(cnst, x1, mzero);     /* x1 *= W9; */             \
-    cnst = LD_WA;                                                   \
-    x2 = vec_madd(cnst, x2, x8);        /* x2 = x2 * WA + x8; */    \
-    cnst = LD_WB;                                                   \
-    x3 = vec_madd(cnst, x3, x8);        /* x3 = x3 * WB + x8; */    \
-                                                                    \
-    cnst = LD_W4;                                                   \
-    b7 = vec_madd(cnst, x4, x0);        /* b7 = x4 * W4 + x0; */    \
-    cnst = LD_W5;                                                   \
-    b5 = vec_madd(cnst, x5, x1);        /* b5 = x5 * W5 + x1; */    \
-    cnst = LD_W6;                                                   \
-    b3 = vec_madd(cnst, x6, x1);        /* b3 = x6 * W6 + x1; */    \
-    cnst = LD_W7;                                                   \
-    b1 = vec_madd(cnst, x7, x0);        /* b1 = x7 * W7 + x0; */    \
-                                                                    \
-    b7 = vec_add(b7, x2);               /* b7 += x2; */             \
-    b5 = vec_add(b5, x3);               /* b5 += x3; */             \
-    b3 = vec_add(b3, x2);               /* b3 += x2; */             \
-    b1 = vec_add(b1, x3);               /* b1 += x3; */             \
-    /* }}} */
-
-
-
-/* two dimensional discrete cosine transform */
-
-void fdct_altivec(int16_t *block)
-{
-POWERPC_PERF_DECLARE(altivec_fdct, 1);
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-POWERPC_PERF_START_COUNT(altivec_fdct, 1);
-    void ff_jpeg_fdct_islow(int16_t *block);
-    ff_jpeg_fdct_islow(block);
-POWERPC_PERF_STOP_COUNT(altivec_fdct, 1);
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-    vector signed short *bp;
-    vector float *cp;
-    vector float b00, b10, b20, b30, b40, b50, b60, b70;
-    vector float b01, b11, b21, b31, b41, b51, b61, b71;
-    vector float mzero, cnst, cnsts0, cnsts1, cnsts2;
-    vector float x0, x1, x2, x3, x4, x5, x6, x7, x8;
-
-    POWERPC_PERF_START_COUNT(altivec_fdct, 1);
-
-
-    /* setup constants {{{ */
-    /* mzero = -0.0 */
-    mzero = ((vector float)vec_splat_u32(-1));
-    mzero = ((vector float)vec_sl(vu32(mzero), vu32(mzero)));
-    cp = fdctconsts;
-    cnsts0 = vec_ld(0, cp); cp++;
-    cnsts1 = vec_ld(0, cp); cp++;
-    cnsts2 = vec_ld(0, cp);
-    /* }}} */
-
-
-    /* 8x8 matrix transpose (vector short[8]) {{{ */
-#define MERGE_S16(hl,a,b) vec_merge##hl(vs16(a), vs16(b))
-
-    bp = (vector signed short*)block;
-    b00 = ((vector float)vec_ld(0,    bp));
-    b40 = ((vector float)vec_ld(16*4, bp));
-    b01 = ((vector float)MERGE_S16(h, b00, b40));
-    b11 = ((vector float)MERGE_S16(l, b00, b40));
-    bp++;
-    b10 = ((vector float)vec_ld(0,    bp));
-    b50 = ((vector float)vec_ld(16*4, bp));
-    b21 = ((vector float)MERGE_S16(h, b10, b50));
-    b31 = ((vector float)MERGE_S16(l, b10, b50));
-    bp++;
-    b20 = ((vector float)vec_ld(0,    bp));
-    b60 = ((vector float)vec_ld(16*4, bp));
-    b41 = ((vector float)MERGE_S16(h, b20, b60));
-    b51 = ((vector float)MERGE_S16(l, b20, b60));
-    bp++;
-    b30 = ((vector float)vec_ld(0,    bp));
-    b70 = ((vector float)vec_ld(16*4, bp));
-    b61 = ((vector float)MERGE_S16(h, b30, b70));
-    b71 = ((vector float)MERGE_S16(l, b30, b70));
-
-    x0 = ((vector float)MERGE_S16(h, b01, b41));
-    x1 = ((vector float)MERGE_S16(l, b01, b41));
-    x2 = ((vector float)MERGE_S16(h, b11, b51));
-    x3 = ((vector float)MERGE_S16(l, b11, b51));
-    x4 = ((vector float)MERGE_S16(h, b21, b61));
-    x5 = ((vector float)MERGE_S16(l, b21, b61));
-    x6 = ((vector float)MERGE_S16(h, b31, b71));
-    x7 = ((vector float)MERGE_S16(l, b31, b71));
-
-    b00 = ((vector float)MERGE_S16(h, x0, x4));
-    b10 = ((vector float)MERGE_S16(l, x0, x4));
-    b20 = ((vector float)MERGE_S16(h, x1, x5));
-    b30 = ((vector float)MERGE_S16(l, x1, x5));
-    b40 = ((vector float)MERGE_S16(h, x2, x6));
-    b50 = ((vector float)MERGE_S16(l, x2, x6));
-    b60 = ((vector float)MERGE_S16(h, x3, x7));
-    b70 = ((vector float)MERGE_S16(l, x3, x7));
-
-#undef MERGE_S16
-    /* }}} */
-
-
-/* Some of the initial calculations can be done as vector short before
- * conversion to vector float.  The following code section takes advantage
- * of this.
- */
-#if 1
-    /* fdct rows {{{ */
-    x0 = ((vector float)vec_add(vs16(b00), vs16(b70)));
-    x7 = ((vector float)vec_sub(vs16(b00), vs16(b70)));
-    x1 = ((vector float)vec_add(vs16(b10), vs16(b60)));
-    x6 = ((vector float)vec_sub(vs16(b10), vs16(b60)));
-    x2 = ((vector float)vec_add(vs16(b20), vs16(b50)));
-    x5 = ((vector float)vec_sub(vs16(b20), vs16(b50)));
-    x3 = ((vector float)vec_add(vs16(b30), vs16(b40)));
-    x4 = ((vector float)vec_sub(vs16(b30), vs16(b40)));
-
-    b70 = ((vector float)vec_add(vs16(x0), vs16(x3)));
-    b10 = ((vector float)vec_add(vs16(x1), vs16(x2)));
-
-    b00 = ((vector float)vec_add(vs16(b70), vs16(b10)));
-    b40 = ((vector float)vec_sub(vs16(b70), vs16(b10)));
-
-#define CTF0(n) \
-    b##n##1 = ((vector float)vec_unpackl(vs16(b##n##0))); \
-    b##n##0 = ((vector float)vec_unpackh(vs16(b##n##0))); \
-    b##n##1 = vec_ctf(vs32(b##n##1), 0); \
-    b##n##0 = vec_ctf(vs32(b##n##0), 0);
-
-    CTF0(0);
-    CTF0(4);
-
-    b20 = ((vector float)vec_sub(vs16(x0), vs16(x3)));
-    b60 = ((vector float)vec_sub(vs16(x1), vs16(x2)));
-
-    CTF0(2);
-    CTF0(6);
-
-#undef CTF0
-
-    x0 = vec_add(b60, b20);
-    x1 = vec_add(b61, b21);
-
-    cnst = LD_W2;
-    x0 = vec_madd(cnst, x0, mzero);
-    x1 = vec_madd(cnst, x1, mzero);
-    cnst = LD_W1;
-    b20 = vec_madd(cnst, b20, x0);
-    b21 = vec_madd(cnst, b21, x1);
-    cnst = LD_W0;
-    b60 = vec_madd(cnst, b60, x0);
-    b61 = vec_madd(cnst, b61, x1);
-
-#define CTFX(x,b) \
-    b##0 = ((vector float)vec_unpackh(vs16(x))); \
-    b##1 = ((vector float)vec_unpackl(vs16(x))); \
-    b##0 = vec_ctf(vs32(b##0), 0); \
-    b##1 = vec_ctf(vs32(b##1), 0); \
-
-    CTFX(x4, b7);
-    CTFX(x5, b5);
-    CTFX(x6, b3);
-    CTFX(x7, b1);
-
-#undef CTFX
-
-
-    x0 = vec_add(b70, b10);
-    x1 = vec_add(b50, b30);
-    x2 = vec_add(b70, b30);
-    x3 = vec_add(b50, b10);
-    x8 = vec_add(x2, x3);
-    cnst = LD_W3;
-    x8 = vec_madd(cnst, x8, mzero);
-
-    cnst = LD_W8;
-    x0 = vec_madd(cnst, x0, mzero);
-    cnst = LD_W9;
-    x1 = vec_madd(cnst, x1, mzero);
-    cnst = LD_WA;
-    x2 = vec_madd(cnst, x2, x8);
-    cnst = LD_WB;
-    x3 = vec_madd(cnst, x3, x8);
-
-    cnst = LD_W4;
-    b70 = vec_madd(cnst, b70, x0);
-    cnst = LD_W5;
-    b50 = vec_madd(cnst, b50, x1);
-    cnst = LD_W6;
-    b30 = vec_madd(cnst, b30, x1);
-    cnst = LD_W7;
-    b10 = vec_madd(cnst, b10, x0);
-
-    b70 = vec_add(b70, x2);
-    b50 = vec_add(b50, x3);
-    b30 = vec_add(b30, x2);
-    b10 = vec_add(b10, x3);
-
-
-    x0 = vec_add(b71, b11);
-    x1 = vec_add(b51, b31);
-    x2 = vec_add(b71, b31);
-    x3 = vec_add(b51, b11);
-    x8 = vec_add(x2, x3);
-    cnst = LD_W3;
-    x8 = vec_madd(cnst, x8, mzero);
-
-    cnst = LD_W8;
-    x0 = vec_madd(cnst, x0, mzero);
-    cnst = LD_W9;
-    x1 = vec_madd(cnst, x1, mzero);
-    cnst = LD_WA;
-    x2 = vec_madd(cnst, x2, x8);
-    cnst = LD_WB;
-    x3 = vec_madd(cnst, x3, x8);
-
-    cnst = LD_W4;
-    b71 = vec_madd(cnst, b71, x0);
-    cnst = LD_W5;
-    b51 = vec_madd(cnst, b51, x1);
-    cnst = LD_W6;
-    b31 = vec_madd(cnst, b31, x1);
-    cnst = LD_W7;
-    b11 = vec_madd(cnst, b11, x0);
-
-    b71 = vec_add(b71, x2);
-    b51 = vec_add(b51, x3);
-    b31 = vec_add(b31, x2);
-    b11 = vec_add(b11, x3);
-    /* }}} */
-#else
-    /* convert to float {{{ */
-#define CTF(n) \
-    vs32(b##n##1) = vec_unpackl(vs16(b##n##0)); \
-    vs32(b##n##0) = vec_unpackh(vs16(b##n##0)); \
-    b##n##1 = vec_ctf(vs32(b##n##1), 0); \
-    b##n##0 = vec_ctf(vs32(b##n##0), 0); \
-
-    CTF(0);
-    CTF(1);
-    CTF(2);
-    CTF(3);
-    CTF(4);
-    CTF(5);
-    CTF(6);
-    CTF(7);
-
-#undef CTF
-    /* }}} */
-
-    FDCTROW(b00, b10, b20, b30, b40, b50, b60, b70);
-    FDCTROW(b01, b11, b21, b31, b41, b51, b61, b71);
-#endif
-
-
-    /* 8x8 matrix transpose (vector float[8][2]) {{{ */
-    x0 = vec_mergel(b00, b20);
-    x1 = vec_mergeh(b00, b20);
-    x2 = vec_mergel(b10, b30);
-    x3 = vec_mergeh(b10, b30);
-
-    b00 = vec_mergeh(x1, x3);
-    b10 = vec_mergel(x1, x3);
-    b20 = vec_mergeh(x0, x2);
-    b30 = vec_mergel(x0, x2);
-
-    x4 = vec_mergel(b41, b61);
-    x5 = vec_mergeh(b41, b61);
-    x6 = vec_mergel(b51, b71);
-    x7 = vec_mergeh(b51, b71);
-
-    b41 = vec_mergeh(x5, x7);
-    b51 = vec_mergel(x5, x7);
-    b61 = vec_mergeh(x4, x6);
-    b71 = vec_mergel(x4, x6);
-
-    x0 = vec_mergel(b01, b21);
-    x1 = vec_mergeh(b01, b21);
-    x2 = vec_mergel(b11, b31);
-    x3 = vec_mergeh(b11, b31);
-
-    x4 = vec_mergel(b40, b60);
-    x5 = vec_mergeh(b40, b60);
-    x6 = vec_mergel(b50, b70);
-    x7 = vec_mergeh(b50, b70);
-
-    b40 = vec_mergeh(x1, x3);
-    b50 = vec_mergel(x1, x3);
-    b60 = vec_mergeh(x0, x2);
-    b70 = vec_mergel(x0, x2);
-
-    b01 = vec_mergeh(x5, x7);
-    b11 = vec_mergel(x5, x7);
-    b21 = vec_mergeh(x4, x6);
-    b31 = vec_mergel(x4, x6);
-    /* }}} */
-
-
-    FDCTCOL(b00, b10, b20, b30, b40, b50, b60, b70);
-    FDCTCOL(b01, b11, b21, b31, b41, b51, b61, b71);
-
-
-    /* round, convert back to short {{{ */
-#define CTS(n) \
-    b##n##0 = vec_round(b##n##0); \
-    b##n##1 = vec_round(b##n##1); \
-    b##n##0 = ((vector float)vec_cts(b##n##0, 0)); \
-    b##n##1 = ((vector float)vec_cts(b##n##1, 0)); \
-    b##n##0 = ((vector float)vec_pack(vs32(b##n##0), vs32(b##n##1))); \
-    vec_st(vs16(b##n##0), 0, bp);
-
-    bp = (vector signed short*)block;
-    CTS(0); bp++;
-    CTS(1); bp++;
-    CTS(2); bp++;
-    CTS(3); bp++;
-    CTS(4); bp++;
-    CTS(5); bp++;
-    CTS(6); bp++;
-    CTS(7);
-
-#undef CTS
-    /* }}} */
-
-POWERPC_PERF_STOP_COUNT(altivec_fdct, 1);
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-}
-
-/* vim:set foldmethod=marker foldlevel=0: */
diff --git a/ffmpeg.src/libavcodec/ppc/fft_altivec.c b/ffmpeg.src/libavcodec/ppc/fft_altivec.c
deleted file mode 100644
index 29d85e8..0000000
--- a/ffmpeg.src/libavcodec/ppc/fft_altivec.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * FFT/IFFT transforms
- * AltiVec-enabled
- * Copyright (c) 2003 Romain Dolbeau <romain at dolbeau.org>
- * Based on code Copyright (c) 2002 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "../dsputil.h"
-
-#include "gcc_fixes.h"
-
-#include "dsputil_altivec.h"
-
-/*
-  those three macros are from libavcodec/fft.c
-  and are required for the reference C code
-*/
-/* butter fly op */
-#define BF(pre, pim, qre, qim, pre1, pim1, qre1, qim1) \
-{\
-  FFTSample ax, ay, bx, by;\
-  bx=pre1;\
-  by=pim1;\
-  ax=qre1;\
-  ay=qim1;\
-  pre = (bx + ax);\
-  pim = (by + ay);\
-  qre = (bx - ax);\
-  qim = (by - ay);\
-}
-#define MUL16(a,b) ((a) * (b))
-#define CMUL(pre, pim, are, aim, bre, bim) \
-{\
-   pre = (MUL16(are, bre) - MUL16(aim, bim));\
-   pim = (MUL16(are, bim) + MUL16(bre, aim));\
-}
-
-
-/**
- * Do a complex FFT with the parameters defined in ff_fft_init(). The
- * input data must be permuted before with s->revtab table. No
- * 1.0/sqrt(n) normalization is done.
- * AltiVec-enabled
- * This code assumes that the 'z' pointer is 16 bytes-aligned
- * It also assumes all FFTComplex are 8 bytes-aligned pair of float
- * The code is exactly the same as the SSE version, except
- * that successive MUL + ADD/SUB have been merged into
- * fused multiply-add ('vec_madd' in altivec)
- */
-void ff_fft_calc_altivec(FFTContext *s, FFTComplex *z)
-{
-POWERPC_PERF_DECLARE(altivec_fft_num, s->nbits >= 6);
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-    int ln = s->nbits;
-    int	j, np, np2;
-    int	nblocks, nloops;
-    register FFTComplex *p, *q;
-    FFTComplex *exptab = s->exptab;
-    int l;
-    FFTSample tmp_re, tmp_im;
-    
-POWERPC_PERF_START_COUNT(altivec_fft_num, s->nbits >= 6);
- 
-    np = 1 << ln;
-
-    /* pass 0 */
-
-    p=&z[0];
-    j=(np >> 1);
-    do {
-        BF(p[0].re, p[0].im, p[1].re, p[1].im, 
-           p[0].re, p[0].im, p[1].re, p[1].im);
-        p+=2;
-    } while (--j != 0);
-
-    /* pass 1 */
-
-    
-    p=&z[0];
-    j=np >> 2;
-    if (s->inverse) {
-        do {
-            BF(p[0].re, p[0].im, p[2].re, p[2].im, 
-               p[0].re, p[0].im, p[2].re, p[2].im);
-            BF(p[1].re, p[1].im, p[3].re, p[3].im, 
-               p[1].re, p[1].im, -p[3].im, p[3].re);
-            p+=4;
-        } while (--j != 0);
-    } else {
-        do {
-            BF(p[0].re, p[0].im, p[2].re, p[2].im, 
-               p[0].re, p[0].im, p[2].re, p[2].im);
-            BF(p[1].re, p[1].im, p[3].re, p[3].im, 
-               p[1].re, p[1].im, p[3].im, -p[3].re);
-            p+=4;
-        } while (--j != 0);
-    }
-    /* pass 2 .. ln-1 */
-
-    nblocks = np >> 3;
-    nloops = 1 << 2;
-    np2 = np >> 1;
-    do {
-        p = z;
-        q = z + nloops;
-        for (j = 0; j < nblocks; ++j) {
-            BF(p->re, p->im, q->re, q->im,
-               p->re, p->im, q->re, q->im);
-            
-            p++;
-            q++;
-            for(l = nblocks; l < np2; l += nblocks) {
-                CMUL(tmp_re, tmp_im, exptab[l].re, exptab[l].im, q->re, q->im);
-                BF(p->re, p->im, q->re, q->im,
-                   p->re, p->im, tmp_re, tmp_im);
-                p++;
-                q++;
-            }
-
-            p += nloops;
-            q += nloops;
-        }
-        nblocks = nblocks >> 1;
-        nloops = nloops << 1;
-    } while (nblocks != 0);
-
-POWERPC_PERF_STOP_COUNT(altivec_fft_num, s->nbits >= 6);
-
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-#ifdef CONFIG_DARWIN
-    register const vector float vczero = (const vector float)(0.);
-#else
-    register const vector float vczero = (const vector float){0.,0.,0.,0.};
-#endif
-    
-    int ln = s->nbits;
-    int	j, np, np2;
-    int	nblocks, nloops;
-    register FFTComplex *p, *q;
-    FFTComplex *cptr, *cptr1;
-    int k;
-
-POWERPC_PERF_START_COUNT(altivec_fft_num, s->nbits >= 6);
-
-    np = 1 << ln;
-
-    {
-        vector float *r, a, b, a1, c1, c2;
-
-        r = (vector float *)&z[0];
-
-        c1 = vcii(p,p,n,n);
-        
-        if (s->inverse)
-            {
-                c2 = vcii(p,p,n,p);
-            }
-        else
-            {
-                c2 = vcii(p,p,p,n);
-            }
-        
-        j = (np >> 2);
-        do {
-            a = vec_ld(0, r);
-            a1 = vec_ld(sizeof(vector float), r);
-            
-            b = vec_perm(a,a,vcprmle(1,0,3,2));
-            a = vec_madd(a,c1,b);
-            /* do the pass 0 butterfly */
-            
-            b = vec_perm(a1,a1,vcprmle(1,0,3,2));
-            b = vec_madd(a1,c1,b);
-            /* do the pass 0 butterfly */
-            
-            /* multiply third by -i */
-            b = vec_perm(b,b,vcprmle(2,3,1,0));
-            
-            /* do the pass 1 butterfly */
-            vec_st(vec_madd(b,c2,a), 0, r);
-            vec_st(vec_nmsub(b,c2,a), sizeof(vector float), r);
-            
-            r += 2;
-        } while (--j != 0);
-    }
-    /* pass 2 .. ln-1 */
-
-    nblocks = np >> 3;
-    nloops = 1 << 2;
-    np2 = np >> 1;
-
-    cptr1 = s->exptab1;
-    do {
-        p = z;
-        q = z + nloops;
-        j = nblocks;
-        do {
-            cptr = cptr1;
-            k = nloops >> 1;
-            do {
-                vector float a,b,c,t1;
-
-                a = vec_ld(0, (float*)p);
-                b = vec_ld(0, (float*)q);
-                
-                /* complex mul */
-                c = vec_ld(0, (float*)cptr);
-                /*  cre*re cim*re */
-                t1 = vec_madd(c, vec_perm(b,b,vcprmle(2,2,0,0)),vczero);
-                c = vec_ld(sizeof(vector float), (float*)cptr);
-                /*  -cim*im cre*im */
-                b = vec_madd(c, vec_perm(b,b,vcprmle(3,3,1,1)),t1);
-                
-                /* butterfly */
-                vec_st(vec_add(a,b), 0, (float*)p);
-                vec_st(vec_sub(a,b), 0, (float*)q);
-                
-                p += 2;
-                q += 2;
-                cptr += 4;
-            } while (--k);
-            
-            p += nloops;
-            q += nloops;
-        } while (--j);
-        cptr1 += nloops * 2;
-        nblocks = nblocks >> 1;
-        nloops = nloops << 1;
-    } while (nblocks != 0);
-
-POWERPC_PERF_STOP_COUNT(altivec_fft_num, s->nbits >= 6);
-
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-}
diff --git a/ffmpeg.src/libavcodec/ppc/gcc_fixes.h b/ffmpeg.src/libavcodec/ppc/gcc_fixes.h
deleted file mode 100644
index 13d4ff1..0000000
--- a/ffmpeg.src/libavcodec/ppc/gcc_fixes.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * gcc fixes for altivec.
- * Used to workaround broken gcc (FSF gcc-3 pre gcc-3.3) 
- * and to stay somewhat compatible with Darwin.
- */
-
-#ifndef _GCC_FIXES_
-#define _GCC_FIXES_
-
-#ifdef HAVE_ALTIVEC_H
-#include <altivec.h>
-#endif
-
-#ifdef CONFIG_DARWIN
-# ifndef __MWERKS__
-#  define AVV(x...) (x)
-# else
-#  define AVV
-# endif
-#else
-#define AVV(x...) {x}
-#if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)  
-
-/* This code was provided to me by Bartosch Pixa
- * as a separate header file (broken_mergel.h).
- * thanks to lu_zero for the workaround.
- *
- * See this mail for more information:
- * http://gcc.gnu.org/ml/gcc/2003-04/msg00967.html
- */
-
-static inline vector signed char ff_vmrglb (vector signed char const A,
-					  vector signed char const B)
-{
-    static const vector unsigned char lowbyte = {
-	0x08, 0x18, 0x09, 0x19, 0x0a, 0x1a, 0x0b,  0x1b,
-	0x0c, 0x1c, 0x0d, 0x1d, 0x0e, 0x1e, 0x0f, 0x1f
-    };
-    return vec_perm (A, B, lowbyte);
-}
-
-static inline vector signed short ff_vmrglh (vector signed short const A,
-					  vector signed short const B)
-{
-    static const vector unsigned char lowhalf = {
-    	0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b,
-	0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f
-    };
-    return vec_perm (A, B, lowhalf);
-}
-
-static inline vector signed int ff_vmrglw (vector signed int const A,
-					  vector signed int const B)
-{
-    static const vector unsigned char lowword = {
-    	0x08, 0x09, 0x0a, 0x0b, 0x18, 0x19, 0x1a, 0x1b,
-	0x0c, 0x0d, 0x0e, 0x0f, 0x1c, 0x1d, 0x1e, 0x1f
-    };
-    return vec_perm (A, B, lowword);
-}
-/*#define ff_vmrglb ff_vmrglb 
-#define ff_vmrglh ff_vmrglh 
-#define ff_vmrglw ff_vmrglw 
-*/
-#undef vec_mergel
-
-#define vec_mergel(a1, a2) \
-__ch (__bin_args_eq (vector signed char, (a1), vector signed char, (a2)), \
-      ((vector signed char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
-__ch (__bin_args_eq (vector unsigned char, (a1), vector unsigned char, (a2)), \
-      ((vector unsigned char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
-__ch (__bin_args_eq (vector signed short, (a1), vector signed short, (a2)), \
-      ((vector signed short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
-__ch (__bin_args_eq (vector unsigned short, (a1), vector unsigned short, (a2)), \
-      ((vector unsigned short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
-__ch (__bin_args_eq (vector float, (a1), vector float, (a2)), \
-      ((vector float) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
-__ch (__bin_args_eq (vector signed int, (a1), vector signed int, (a2)), \
-      ((vector signed int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
-__ch (__bin_args_eq (vector unsigned int, (a1), vector unsigned int, (a2)), \
-      ((vector unsigned int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
-    __altivec_link_error_invalid_argument ())))))))
-
-#endif
-
-#endif /* CONFIG_DARWIN */
-
-#ifndef __MWERKS__
-#define const_vector const vector
-#else
-#define const_vector vector
-#endif
-
-#endif /* _GCC_FIXES_ */
diff --git a/ffmpeg.src/libavcodec/ppc/gmc_altivec.c b/ffmpeg.src/libavcodec/ppc/gmc_altivec.c
deleted file mode 100644
index 3448216..0000000
--- a/ffmpeg.src/libavcodec/ppc/gmc_altivec.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * GMC (Global Motion Compensation)
- * AltiVec-enabled
- * Copyright (c) 2003 Romain Dolbeau <romain at dolbeau.org>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "../dsputil.h"
-
-#include "gcc_fixes.h"
-
-#include "dsputil_altivec.h"
-
-/*
-  altivec-enhanced gmc1. ATM this code assume stride is a multiple of 8,
-  to preserve proper dst alignement.
-*/
-#define GMC1_PERF_COND (h==8)
-void gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */, int stride, int h, int x16, int y16, int rounder)
-{
-POWERPC_PERF_DECLARE(altivec_gmc1_num, GMC1_PERF_COND);
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-    const int A=(16-x16)*(16-y16);
-    const int B=(   x16)*(16-y16);
-    const int C=(16-x16)*(   y16);
-    const int D=(   x16)*(   y16);
-    int i;
-
-POWERPC_PERF_START_COUNT(altivec_gmc1_num, GMC1_PERF_COND);
-    
-    for(i=0; i<h; i++)
-    {
-        dst[0]= (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + rounder)>>8;
-        dst[1]= (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + rounder)>>8;
-        dst[2]= (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + rounder)>>8;
-        dst[3]= (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + rounder)>>8;
-        dst[4]= (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + rounder)>>8;
-        dst[5]= (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + rounder)>>8;
-        dst[6]= (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + rounder)>>8;
-        dst[7]= (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + rounder)>>8;
-        dst+= stride;
-        src+= stride;
-    }
-
-POWERPC_PERF_STOP_COUNT(altivec_gmc1_num, GMC1_PERF_COND);
-
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-    const unsigned short __attribute__ ((aligned(16))) rounder_a[8] =
-      {rounder, rounder, rounder, rounder,
-       rounder, rounder, rounder, rounder};
-    const unsigned short __attribute__ ((aligned(16))) ABCD[8] =
-      {
-        (16-x16)*(16-y16), /* A */
-        (   x16)*(16-y16), /* B */
-        (16-x16)*(   y16), /* C */
-        (   x16)*(   y16), /* D */
-        0, 0, 0, 0         /* padding */
-      };
-    register const_vector unsigned char vczero = (const_vector unsigned char)vec_splat_u8(0);
-    register const_vector unsigned short vcsr8 = (const_vector unsigned short)vec_splat_u16(8);
-    register vector unsigned char dstv, dstv2, src_0, src_1, srcvA, srcvB, srcvC, srcvD;
-    register vector unsigned short Av, Bv, Cv, Dv, rounderV, tempA, tempB, tempC, tempD;
-    int i;
-    unsigned long dst_odd = (unsigned long)dst & 0x0000000F;
-    unsigned long src_really_odd = (unsigned long)src & 0x0000000F;
-
-
-POWERPC_PERF_START_COUNT(altivec_gmc1_num, GMC1_PERF_COND);
-
-    tempA = vec_ld(0, (unsigned short*)ABCD);
-    Av = vec_splat(tempA, 0);
-    Bv = vec_splat(tempA, 1);
-    Cv = vec_splat(tempA, 2);
-    Dv = vec_splat(tempA, 3);
-
-    rounderV = vec_ld(0, (unsigned short*)rounder_a);
-    
-    // we'll be able to pick-up our 9 char elements
-    // at src from those 32 bytes
-    // we load the first batch here, as inside the loop
-    // we can re-use 'src+stride' from one iteration
-    // as the 'src' of the next.
-    src_0 = vec_ld(0, src);
-    src_1 = vec_ld(16, src);
-    srcvA = vec_perm(src_0, src_1, vec_lvsl(0, src));
-    
-    if (src_really_odd != 0x0000000F)
-    { // if src & 0xF == 0xF, then (src+1) is properly aligned on the second vector.
-      srcvB = vec_perm(src_0, src_1, vec_lvsl(1, src));
-    }
-    else
-    {
-      srcvB = src_1;
-    }
-    srcvA = vec_mergeh(vczero, srcvA);
-    srcvB = vec_mergeh(vczero, srcvB);
-    
-    for(i=0; i<h; i++)
-    {
-      dst_odd = (unsigned long)dst & 0x0000000F;
-      src_really_odd = (((unsigned long)src) + stride) & 0x0000000F;
-      
-      dstv = vec_ld(0, dst);
-      
-      // we we'll be able to pick-up our 9 char elements
-      // at src + stride from those 32 bytes
-      // then reuse the resulting 2 vectors srvcC and srcvD
-      // as the next srcvA and srcvB
-      src_0 = vec_ld(stride + 0, src);
-      src_1 = vec_ld(stride + 16, src);
-      srcvC = vec_perm(src_0, src_1, vec_lvsl(stride + 0, src));
-      
-      if (src_really_odd != 0x0000000F)
-      { // if src & 0xF == 0xF, then (src+1) is properly aligned on the second vector.
-        srcvD = vec_perm(src_0, src_1, vec_lvsl(stride + 1, src));
-      }
-      else
-      {
-        srcvD = src_1;
-      }
-      
-      srcvC = vec_mergeh(vczero, srcvC);
-      srcvD = vec_mergeh(vczero, srcvD);
-      
-
-      // OK, now we (finally) do the math :-)
-      // those four instructions replaces 32 int muls & 32 int adds.
-      // isn't AltiVec nice ?
-      tempA = vec_mladd((vector unsigned short)srcvA, Av, rounderV);
-      tempB = vec_mladd((vector unsigned short)srcvB, Bv, tempA);
-      tempC = vec_mladd((vector unsigned short)srcvC, Cv, tempB);
-      tempD = vec_mladd((vector unsigned short)srcvD, Dv, tempC);
-      
-      srcvA = srcvC;
-      srcvB = srcvD;
-      
-      tempD = vec_sr(tempD, vcsr8);
-      
-      dstv2 = vec_pack(tempD, (vector unsigned short)vczero);
-      
-      if (dst_odd)
-      {
-        dstv2 = vec_perm(dstv, dstv2, vcprm(0,1,s0,s1));
-      }
-      else
-      {
-        dstv2 = vec_perm(dstv, dstv2, vcprm(s0,s1,2,3));
-      }
-      
-      vec_st(dstv2, 0, dst);
-      
-      dst += stride;
-      src += stride;
-    }
-
-POWERPC_PERF_STOP_COUNT(altivec_gmc1_num, GMC1_PERF_COND);
-
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-}
diff --git a/ffmpeg.src/libavcodec/ppc/idct_altivec.c b/ffmpeg.src/libavcodec/ppc/idct_altivec.c
deleted file mode 100644
index 3445ada..0000000
--- a/ffmpeg.src/libavcodec/ppc/idct_altivec.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright (c) 2001 Michel Lespinasse
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-/*
- * NOTE: This code is based on GPL code from the libmpeg2 project.  The
- * author, Michel Lespinasses, has given explicit permission to release
- * under LGPL as part of ffmpeg.
- *
- */
-
-/*
- * FFMpeg integration by Dieter Shirley
- *
- * This file is a direct copy of the altivec idct module from the libmpeg2
- * project.  I've deleted all of the libmpeg2 specific code, renamed the functions and
- * re-ordered the function parameters.  The only change to the IDCT function
- * itself was to factor out the partial transposition, and to perform a full
- * transpose at the end of the function.
- */
-
-
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <string.h>
-#include "../dsputil.h"
-
-#include "gcc_fixes.h"
-
-#include "dsputil_altivec.h"
-
-#define vector_s16_t vector signed short
-#define const_vector_s16_t const_vector signed short
-#define vector_u16_t vector unsigned short
-#define vector_s8_t vector signed char
-#define vector_u8_t vector unsigned char
-#define vector_s32_t vector signed int
-#define vector_u32_t vector unsigned int
-
-#define IDCT_HALF					\
-    /* 1st stage */					\
-    t1 = vec_mradds (a1, vx7, vx1 );			\
-    t8 = vec_mradds (a1, vx1, vec_subs (zero, vx7));	\
-    t7 = vec_mradds (a2, vx5, vx3);			\
-    t3 = vec_mradds (ma2, vx3, vx5);			\
-							\
-    /* 2nd stage */					\
-    t5 = vec_adds (vx0, vx4);				\
-    t0 = vec_subs (vx0, vx4);				\
-    t2 = vec_mradds (a0, vx6, vx2);			\
-    t4 = vec_mradds (a0, vx2, vec_subs (zero, vx6));	\
-    t6 = vec_adds (t8, t3);				\
-    t3 = vec_subs (t8, t3);				\
-    t8 = vec_subs (t1, t7);				\
-    t1 = vec_adds (t1, t7);				\
-							\
-    /* 3rd stage */					\
-    t7 = vec_adds (t5, t2);				\
-    t2 = vec_subs (t5, t2);				\
-    t5 = vec_adds (t0, t4);				\
-    t0 = vec_subs (t0, t4);				\
-    t4 = vec_subs (t8, t3);				\
-    t3 = vec_adds (t8, t3);				\
-							\
-    /* 4th stage */					\
-    vy0 = vec_adds (t7, t1);				\
-    vy7 = vec_subs (t7, t1);				\
-    vy1 = vec_mradds (c4, t3, t5);			\
-    vy6 = vec_mradds (mc4, t3, t5);			\
-    vy2 = vec_mradds (c4, t4, t0);			\
-    vy5 = vec_mradds (mc4, t4, t0);			\
-    vy3 = vec_adds (t2, t6);				\
-    vy4 = vec_subs (t2, t6);
-
-	
-#define IDCT								\
-    vector_s16_t vx0, vx1, vx2, vx3, vx4, vx5, vx6, vx7;		\
-    vector_s16_t vy0, vy1, vy2, vy3, vy4, vy5, vy6, vy7;		\
-    vector_s16_t a0, a1, a2, ma2, c4, mc4, zero, bias;			\
-    vector_s16_t t0, t1, t2, t3, t4, t5, t6, t7, t8;			\
-    vector_u16_t shift;							\
-									\
-    c4 = vec_splat (constants[0], 0);					\
-    a0 = vec_splat (constants[0], 1);					\
-    a1 = vec_splat (constants[0], 2);					\
-    a2 = vec_splat (constants[0], 3);					\
-    mc4 = vec_splat (constants[0], 4);					\
-    ma2 = vec_splat (constants[0], 5);					\
-    bias = (vector_s16_t)vec_splat ((vector_s32_t)constants[0], 3);	\
-									\
-    zero = vec_splat_s16 (0);						\
-    shift = vec_splat_u16 (4);						\
-									\
-    vx0 = vec_mradds (vec_sl (block[0], shift), constants[1], zero);	\
-    vx1 = vec_mradds (vec_sl (block[1], shift), constants[2], zero);	\
-    vx2 = vec_mradds (vec_sl (block[2], shift), constants[3], zero);	\
-    vx3 = vec_mradds (vec_sl (block[3], shift), constants[4], zero);	\
-    vx4 = vec_mradds (vec_sl (block[4], shift), constants[1], zero);	\
-    vx5 = vec_mradds (vec_sl (block[5], shift), constants[4], zero);	\
-    vx6 = vec_mradds (vec_sl (block[6], shift), constants[3], zero);	\
-    vx7 = vec_mradds (vec_sl (block[7], shift), constants[2], zero);	\
-									\
-    IDCT_HALF								\
-									\
-    vx0 = vec_mergeh (vy0, vy4);					\
-    vx1 = vec_mergel (vy0, vy4);					\
-    vx2 = vec_mergeh (vy1, vy5);					\
-    vx3 = vec_mergel (vy1, vy5);					\
-    vx4 = vec_mergeh (vy2, vy6);					\
-    vx5 = vec_mergel (vy2, vy6);					\
-    vx6 = vec_mergeh (vy3, vy7);					\
-    vx7 = vec_mergel (vy3, vy7);					\
-									\
-    vy0 = vec_mergeh (vx0, vx4);					\
-    vy1 = vec_mergel (vx0, vx4);					\
-    vy2 = vec_mergeh (vx1, vx5);					\
-    vy3 = vec_mergel (vx1, vx5);					\
-    vy4 = vec_mergeh (vx2, vx6);					\
-    vy5 = vec_mergel (vx2, vx6);					\
-    vy6 = vec_mergeh (vx3, vx7);					\
-    vy7 = vec_mergel (vx3, vx7);					\
-									\
-    vx0 = vec_adds (vec_mergeh (vy0, vy4), bias);			\
-    vx1 = vec_mergel (vy0, vy4);					\
-    vx2 = vec_mergeh (vy1, vy5);					\
-    vx3 = vec_mergel (vy1, vy5);					\
-    vx4 = vec_mergeh (vy2, vy6);					\
-    vx5 = vec_mergel (vy2, vy6);					\
-    vx6 = vec_mergeh (vy3, vy7);					\
-    vx7 = vec_mergel (vy3, vy7);					\
-									\
-    IDCT_HALF								\
-									\
-    shift = vec_splat_u16 (6);						\
-    vx0 = vec_sra (vy0, shift);						\
-    vx1 = vec_sra (vy1, shift);						\
-    vx2 = vec_sra (vy2, shift);						\
-    vx3 = vec_sra (vy3, shift);						\
-    vx4 = vec_sra (vy4, shift);						\
-    vx5 = vec_sra (vy5, shift);						\
-    vx6 = vec_sra (vy6, shift);						\
-    vx7 = vec_sra (vy7, shift);
-
-
-static const_vector_s16_t constants[5] = {
-    (vector_s16_t) AVV(23170, 13573, 6518, 21895, -23170, -21895, 32, 31),
-    (vector_s16_t) AVV(16384, 22725, 21407, 19266, 16384, 19266, 21407, 22725),
-    (vector_s16_t) AVV(22725, 31521, 29692, 26722, 22725, 26722, 29692, 31521),
-    (vector_s16_t) AVV(21407, 29692, 27969, 25172, 21407, 25172, 27969, 29692),
-    (vector_s16_t) AVV(19266, 26722, 25172, 22654, 19266, 22654, 25172, 26722)
-};
-
-void idct_put_altivec(uint8_t* dest, int stride, vector_s16_t* block)
-{
-POWERPC_PERF_DECLARE(altivec_idct_put_num, 1);
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-POWERPC_PERF_START_COUNT(altivec_idct_put_num, 1);
-    void simple_idct_put(uint8_t *dest, int line_size, int16_t *block);
-    simple_idct_put(dest, stride, (int16_t*)block);
-POWERPC_PERF_STOP_COUNT(altivec_idct_put_num, 1);
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-    vector_u8_t tmp;
-
-#ifdef POWERPC_PERFORMANCE_REPORT
-POWERPC_PERF_START_COUNT(altivec_idct_put_num, 1);
-#endif
-    IDCT
-
-#define COPY(dest,src)						\
-    tmp = vec_packsu (src, src);				\
-    vec_ste ((vector_u32_t)tmp, 0, (unsigned int *)dest);	\
-    vec_ste ((vector_u32_t)tmp, 4, (unsigned int *)dest);
-
-    COPY (dest, vx0)	dest += stride;
-    COPY (dest, vx1)	dest += stride;
-    COPY (dest, vx2)	dest += stride;
-    COPY (dest, vx3)	dest += stride;
-    COPY (dest, vx4)	dest += stride;
-    COPY (dest, vx5)	dest += stride;
-    COPY (dest, vx6)	dest += stride;
-    COPY (dest, vx7)
-
-POWERPC_PERF_STOP_COUNT(altivec_idct_put_num, 1);
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-}
-
-void idct_add_altivec(uint8_t* dest, int stride, vector_s16_t* block)
-{
-POWERPC_PERF_DECLARE(altivec_idct_add_num, 1);
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-POWERPC_PERF_START_COUNT(altivec_idct_add_num, 1);
-    void simple_idct_add(uint8_t *dest, int line_size, int16_t *block);
-    simple_idct_add(dest, stride, (int16_t*)block);
-POWERPC_PERF_STOP_COUNT(altivec_idct_add_num, 1);
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-    vector_u8_t tmp;
-    vector_s16_t tmp2, tmp3;
-    vector_u8_t perm0;
-    vector_u8_t perm1;
-    vector_u8_t p0, p1, p;
-
-#ifdef POWERPC_PERFORMANCE_REPORT
-POWERPC_PERF_START_COUNT(altivec_idct_add_num, 1);
-#endif
-
-    IDCT
-
-    p0 = vec_lvsl (0, dest);
-    p1 = vec_lvsl (stride, dest);
-    p = vec_splat_u8 (-1);
-    perm0 = vec_mergeh (p, p0);
-    perm1 = vec_mergeh (p, p1);
-
-#define ADD(dest,src,perm)						\
-    /* *(uint64_t *)&tmp = *(uint64_t *)dest; */			\
-    tmp = vec_ld (0, dest);						\
-    tmp2 = (vector_s16_t)vec_perm (tmp, (vector_u8_t)zero, perm);	\
-    tmp3 = vec_adds (tmp2, src);					\
-    tmp = vec_packsu (tmp3, tmp3);					\
-    vec_ste ((vector_u32_t)tmp, 0, (unsigned int *)dest);		\
-    vec_ste ((vector_u32_t)tmp, 4, (unsigned int *)dest);
-
-    ADD (dest, vx0, perm0)	dest += stride;
-    ADD (dest, vx1, perm1)	dest += stride;
-    ADD (dest, vx2, perm0)	dest += stride;
-    ADD (dest, vx3, perm1)	dest += stride;
-    ADD (dest, vx4, perm0)	dest += stride;
-    ADD (dest, vx5, perm1)	dest += stride;
-    ADD (dest, vx6, perm0)	dest += stride;
-    ADD (dest, vx7, perm1)
-
-POWERPC_PERF_STOP_COUNT(altivec_idct_add_num, 1);
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-}
-
diff --git a/ffmpeg.src/libavcodec/ppc/mpegvideo_altivec.c b/ffmpeg.src/libavcodec/ppc/mpegvideo_altivec.c
deleted file mode 100644
index 91e744a..0000000
--- a/ffmpeg.src/libavcodec/ppc/mpegvideo_altivec.c
+++ /dev/null
@@ -1,649 +0,0 @@
-/*
- * Copyright (c) 2002 Dieter Shirley
- *
- * dct_unquantize_h263_altivec:
- * Copyright (c) 2003 Romain Dolbeau <romain at dolbeau.org>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "../dsputil.h"
-#include "../mpegvideo.h"
-
-#include "gcc_fixes.h"
- 
-#include "dsputil_altivec.h"
-
-// Swaps two variables (used for altivec registers)
-#define SWAP(a,b) \
-do { \
-    __typeof__(a) swap_temp=a; \
-    a=b; \
-    b=swap_temp; \
-} while (0)
-
-// transposes a matrix consisting of four vectors with four elements each
-#define TRANSPOSE4(a,b,c,d) \
-do { \
-  __typeof__(a) _trans_ach = vec_mergeh(a, c); \
-  __typeof__(a) _trans_acl = vec_mergel(a, c); \
-  __typeof__(a) _trans_bdh = vec_mergeh(b, d); \
-  __typeof__(a) _trans_bdl = vec_mergel(b, d); \
- \
-  a = vec_mergeh(_trans_ach, _trans_bdh); \
-  b = vec_mergel(_trans_ach, _trans_bdh); \
-  c = vec_mergeh(_trans_acl, _trans_bdl); \
-  d = vec_mergel(_trans_acl, _trans_bdl); \
-} while (0)
-
-#define TRANSPOSE8(a,b,c,d,e,f,g,h) \
-do { \
-    __typeof__(a)  _A1, _B1, _C1, _D1, _E1, _F1, _G1, _H1; \
-    __typeof__(a)  _A2, _B2, _C2, _D2, _E2, _F2, _G2, _H2; \
- \
-    _A1 = vec_mergeh (a, e); \
-    _B1 = vec_mergel (a, e); \
-    _C1 = vec_mergeh (b, f); \
-    _D1 = vec_mergel (b, f); \
-    _E1 = vec_mergeh (c, g); \
-    _F1 = vec_mergel (c, g); \
-    _G1 = vec_mergeh (d, h); \
-    _H1 = vec_mergel (d, h); \
- \
-    _A2 = vec_mergeh (_A1, _E1); \
-    _B2 = vec_mergel (_A1, _E1); \
-    _C2 = vec_mergeh (_B1, _F1); \
-    _D2 = vec_mergel (_B1, _F1); \
-    _E2 = vec_mergeh (_C1, _G1); \
-    _F2 = vec_mergel (_C1, _G1); \
-    _G2 = vec_mergeh (_D1, _H1); \
-    _H2 = vec_mergel (_D1, _H1); \
- \
-    a = vec_mergeh (_A2, _E2); \
-    b = vec_mergel (_A2, _E2); \
-    c = vec_mergeh (_B2, _F2); \
-    d = vec_mergel (_B2, _F2); \
-    e = vec_mergeh (_C2, _G2); \
-    f = vec_mergel (_C2, _G2); \
-    g = vec_mergeh (_D2, _H2); \
-    h = vec_mergel (_D2, _H2); \
-} while (0)
-
-
-// Loads a four-byte value (int or float) from the target address
-// into every element in the target vector.  Only works if the
-// target address is four-byte aligned (which should be always).
-#define LOAD4(vec, address) \
-{ \
-    __typeof__(vec)* _load_addr = (__typeof__(vec)*)(address); \
-    vector unsigned char _perm_vec = vec_lvsl(0,(address)); \
-    vec = vec_ld(0, _load_addr); \
-    vec = vec_perm(vec, vec, _perm_vec); \
-    vec = vec_splat(vec, 0); \
-}
-
-
-#ifdef CONFIG_DARWIN
-#define FOUROF(a) (a)
-#else
-// slower, for dumb non-apple GCC
-#define FOUROF(a) {a,a,a,a}
-#endif
-int dct_quantize_altivec(MpegEncContext* s, 
-                        DCTELEM* data, int n,
-                        int qscale, int* overflow)
-{
-    int lastNonZero;
-    vector float row0, row1, row2, row3, row4, row5, row6, row7;
-    vector float alt0, alt1, alt2, alt3, alt4, alt5, alt6, alt7;
-    const_vector float zero = (const_vector float)FOUROF(0.);
-    // used after quantise step
-    int oldBaseValue = 0;
-
-    // Load the data into the row/alt vectors
-    {
-        vector signed short data0, data1, data2, data3, data4, data5, data6, data7;
-
-        data0 = vec_ld(0, data);
-        data1 = vec_ld(16, data);
-        data2 = vec_ld(32, data);
-        data3 = vec_ld(48, data);
-        data4 = vec_ld(64, data);
-        data5 = vec_ld(80, data);
-        data6 = vec_ld(96, data);
-        data7 = vec_ld(112, data);
-
-        // Transpose the data before we start
-        TRANSPOSE8(data0, data1, data2, data3, data4, data5, data6, data7);
-
-        // load the data into floating point vectors.  We load
-        // the high half of each row into the main row vectors
-        // and the low half into the alt vectors.
-        row0 = vec_ctf(vec_unpackh(data0), 0);
-        alt0 = vec_ctf(vec_unpackl(data0), 0);
-        row1 = vec_ctf(vec_unpackh(data1), 0);
-        alt1 = vec_ctf(vec_unpackl(data1), 0);
-        row2 = vec_ctf(vec_unpackh(data2), 0);
-        alt2 = vec_ctf(vec_unpackl(data2), 0);
-        row3 = vec_ctf(vec_unpackh(data3), 0);
-        alt3 = vec_ctf(vec_unpackl(data3), 0);
-        row4 = vec_ctf(vec_unpackh(data4), 0);
-        alt4 = vec_ctf(vec_unpackl(data4), 0);
-        row5 = vec_ctf(vec_unpackh(data5), 0);
-        alt5 = vec_ctf(vec_unpackl(data5), 0);
-        row6 = vec_ctf(vec_unpackh(data6), 0);
-        alt6 = vec_ctf(vec_unpackl(data6), 0);
-        row7 = vec_ctf(vec_unpackh(data7), 0);
-        alt7 = vec_ctf(vec_unpackl(data7), 0);
-    }
-
-    // The following block could exist as a separate an altivec dct
-		// function.  However, if we put it inline, the DCT data can remain
-		// in the vector local variables, as floats, which we'll use during the
-		// quantize step...
-    {
-        const vector float vec_0_298631336 = (vector float)FOUROF(0.298631336f);
-        const vector float vec_0_390180644 = (vector float)FOUROF(-0.390180644f);
-        const vector float vec_0_541196100 = (vector float)FOUROF(0.541196100f);
-        const vector float vec_0_765366865 = (vector float)FOUROF(0.765366865f);
-        const vector float vec_0_899976223 = (vector float)FOUROF(-0.899976223f);
-        const vector float vec_1_175875602 = (vector float)FOUROF(1.175875602f);
-        const vector float vec_1_501321110 = (vector float)FOUROF(1.501321110f);
-        const vector float vec_1_847759065 = (vector float)FOUROF(-1.847759065f);
-        const vector float vec_1_961570560 = (vector float)FOUROF(-1.961570560f);
-        const vector float vec_2_053119869 = (vector float)FOUROF(2.053119869f);
-        const vector float vec_2_562915447 = (vector float)FOUROF(-2.562915447f);
-        const vector float vec_3_072711026 = (vector float)FOUROF(3.072711026f);
-
-
-        int whichPass, whichHalf;
-
-        for(whichPass = 1; whichPass<=2; whichPass++)
-        {
-            for(whichHalf = 1; whichHalf<=2; whichHalf++)
-            {
-                vector float tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
-                vector float tmp10, tmp11, tmp12, tmp13;
-                vector float z1, z2, z3, z4, z5;
-
-                tmp0 = vec_add(row0, row7); // tmp0 = dataptr[0] + dataptr[7];
-                tmp7 = vec_sub(row0, row7); // tmp7 = dataptr[0] - dataptr[7];
-                tmp3 = vec_add(row3, row4); // tmp3 = dataptr[3] + dataptr[4];
-                tmp4 = vec_sub(row3, row4); // tmp4 = dataptr[3] - dataptr[4];
-                tmp1 = vec_add(row1, row6); // tmp1 = dataptr[1] + dataptr[6];
-                tmp6 = vec_sub(row1, row6); // tmp6 = dataptr[1] - dataptr[6];
-                tmp2 = vec_add(row2, row5); // tmp2 = dataptr[2] + dataptr[5];
-                tmp5 = vec_sub(row2, row5); // tmp5 = dataptr[2] - dataptr[5];
-
-                tmp10 = vec_add(tmp0, tmp3); // tmp10 = tmp0 + tmp3;
-                tmp13 = vec_sub(tmp0, tmp3); // tmp13 = tmp0 - tmp3;
-                tmp11 = vec_add(tmp1, tmp2); // tmp11 = tmp1 + tmp2;
-                tmp12 = vec_sub(tmp1, tmp2); // tmp12 = tmp1 - tmp2;
-
-
-                // dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS);
-                row0 = vec_add(tmp10, tmp11);
-
-                // dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);
-                row4 = vec_sub(tmp10, tmp11);
-
-
-                // z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);
-                z1 = vec_madd(vec_add(tmp12, tmp13), vec_0_541196100, (vector float)zero);
-
-                // dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865),
-                //		   CONST_BITS-PASS1_BITS);
-                row2 = vec_madd(tmp13, vec_0_765366865, z1);
-
-                // dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065),
-                //		   CONST_BITS-PASS1_BITS);
-                row6 = vec_madd(tmp12, vec_1_847759065, z1);
-
-                z1 = vec_add(tmp4, tmp7); // z1 = tmp4 + tmp7;
-                z2 = vec_add(tmp5, tmp6); // z2 = tmp5 + tmp6;
-                z3 = vec_add(tmp4, tmp6); // z3 = tmp4 + tmp6;
-                z4 = vec_add(tmp5, tmp7); // z4 = tmp5 + tmp7;
-
-                // z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
-                z5 = vec_madd(vec_add(z3, z4), vec_1_175875602, (vector float)zero);
-
-                // z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
-                z3 = vec_madd(z3, vec_1_961570560, z5);
-
-                // z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
-                z4 = vec_madd(z4, vec_0_390180644, z5);
-
-                // The following adds are rolled into the multiplies above
-                // z3 = vec_add(z3, z5);  // z3 += z5;
-                // z4 = vec_add(z4, z5);  // z4 += z5;
-
-                // z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
-                // Wow!  It's actually more effecient to roll this multiply
-                // into the adds below, even thought the multiply gets done twice!
-                // z2 = vec_madd(z2, vec_2_562915447, (vector float)zero);
-
-                // z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
-                // Same with this one...
-                // z1 = vec_madd(z1, vec_0_899976223, (vector float)zero);
-
-                // tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
-                // dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS);
-                row7 = vec_madd(tmp4, vec_0_298631336, vec_madd(z1, vec_0_899976223, z3));
-
-                // tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
-                // dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS);
-                row5 = vec_madd(tmp5, vec_2_053119869, vec_madd(z2, vec_2_562915447, z4));
-
-                // tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
-                // dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS);
-                row3 = vec_madd(tmp6, vec_3_072711026, vec_madd(z2, vec_2_562915447, z3));
-
-                // tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
-                // dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS);
-                row1 = vec_madd(z1, vec_0_899976223, vec_madd(tmp7, vec_1_501321110, z4));
-
-                // Swap the row values with the alts.  If this is the first half,
-                // this sets up the low values to be acted on in the second half.
-                // If this is the second half, it puts the high values back in
-                // the row values where they are expected to be when we're done.
-                SWAP(row0, alt0);
-                SWAP(row1, alt1);
-                SWAP(row2, alt2);
-                SWAP(row3, alt3);
-                SWAP(row4, alt4);
-                SWAP(row5, alt5);
-                SWAP(row6, alt6);
-                SWAP(row7, alt7);
-            }
-
-            if (whichPass == 1)
-            {
-                // transpose the data for the second pass
-                 
-                // First, block transpose the upper right with lower left.
-                SWAP(row4, alt0);
-                SWAP(row5, alt1);
-                SWAP(row6, alt2);
-                SWAP(row7, alt3);
-
-                // Now, transpose each block of four
-                TRANSPOSE4(row0, row1, row2, row3);
-                TRANSPOSE4(row4, row5, row6, row7);
-                TRANSPOSE4(alt0, alt1, alt2, alt3);
-                TRANSPOSE4(alt4, alt5, alt6, alt7);
-            }
-        }
-    }
-
-    // perform the quantise step, using the floating point data
-    // still in the row/alt registers
-    {
-        const int* biasAddr;
-        const vector signed int* qmat;
-        vector float bias, negBias;
-
-        if (s->mb_intra)
-        {
-            vector signed int baseVector;
-
-            // We must cache element 0 in the intra case
-            // (it needs special handling).
-            baseVector = vec_cts(vec_splat(row0, 0), 0);
-            vec_ste(baseVector, 0, &oldBaseValue);
-
-            qmat = (vector signed int*)s->q_intra_matrix[qscale];
-            biasAddr = &(s->intra_quant_bias);
-        }
-        else
-        {
-            qmat = (vector signed int*)s->q_inter_matrix[qscale];
-            biasAddr = &(s->inter_quant_bias);
-        }
-
-        // Load the bias vector (We add 0.5 to the bias so that we're
-				// rounding when we convert to int, instead of flooring.)
-        {
-            vector signed int biasInt;
-            const vector float negOneFloat = (vector float)FOUROF(-1.0f);
-            LOAD4(biasInt, biasAddr);
-            bias = vec_ctf(biasInt, QUANT_BIAS_SHIFT);
-            negBias = vec_madd(bias, negOneFloat, zero);
-        }
-
-        {
-            vector float q0, q1, q2, q3, q4, q5, q6, q7;
-
-            q0 = vec_ctf(qmat[0], QMAT_SHIFT);
-            q1 = vec_ctf(qmat[2], QMAT_SHIFT);
-            q2 = vec_ctf(qmat[4], QMAT_SHIFT);
-            q3 = vec_ctf(qmat[6], QMAT_SHIFT);
-            q4 = vec_ctf(qmat[8], QMAT_SHIFT);
-            q5 = vec_ctf(qmat[10], QMAT_SHIFT);
-            q6 = vec_ctf(qmat[12], QMAT_SHIFT);
-            q7 = vec_ctf(qmat[14], QMAT_SHIFT);
-
-            row0 = vec_sel(vec_madd(row0, q0, negBias), vec_madd(row0, q0, bias),
-                    vec_cmpgt(row0, zero));
-            row1 = vec_sel(vec_madd(row1, q1, negBias), vec_madd(row1, q1, bias),
-                    vec_cmpgt(row1, zero));
-            row2 = vec_sel(vec_madd(row2, q2, negBias), vec_madd(row2, q2, bias),
-                    vec_cmpgt(row2, zero));
-            row3 = vec_sel(vec_madd(row3, q3, negBias), vec_madd(row3, q3, bias),
-                    vec_cmpgt(row3, zero));
-            row4 = vec_sel(vec_madd(row4, q4, negBias), vec_madd(row4, q4, bias),
-                    vec_cmpgt(row4, zero));
-            row5 = vec_sel(vec_madd(row5, q5, negBias), vec_madd(row5, q5, bias),
-                    vec_cmpgt(row5, zero));
-            row6 = vec_sel(vec_madd(row6, q6, negBias), vec_madd(row6, q6, bias),
-                    vec_cmpgt(row6, zero));
-            row7 = vec_sel(vec_madd(row7, q7, negBias), vec_madd(row7, q7, bias),
-                    vec_cmpgt(row7, zero));
-
-            q0 = vec_ctf(qmat[1], QMAT_SHIFT);
-            q1 = vec_ctf(qmat[3], QMAT_SHIFT);
-            q2 = vec_ctf(qmat[5], QMAT_SHIFT);
-            q3 = vec_ctf(qmat[7], QMAT_SHIFT);
-            q4 = vec_ctf(qmat[9], QMAT_SHIFT);
-            q5 = vec_ctf(qmat[11], QMAT_SHIFT);
-            q6 = vec_ctf(qmat[13], QMAT_SHIFT);
-            q7 = vec_ctf(qmat[15], QMAT_SHIFT);
-
-            alt0 = vec_sel(vec_madd(alt0, q0, negBias), vec_madd(alt0, q0, bias),
-                    vec_cmpgt(alt0, zero));
-            alt1 = vec_sel(vec_madd(alt1, q1, negBias), vec_madd(alt1, q1, bias),
-                    vec_cmpgt(alt1, zero));
-            alt2 = vec_sel(vec_madd(alt2, q2, negBias), vec_madd(alt2, q2, bias),
-                    vec_cmpgt(alt2, zero));
-            alt3 = vec_sel(vec_madd(alt3, q3, negBias), vec_madd(alt3, q3, bias),
-                    vec_cmpgt(alt3, zero));
-            alt4 = vec_sel(vec_madd(alt4, q4, negBias), vec_madd(alt4, q4, bias),
-                    vec_cmpgt(alt4, zero));
-            alt5 = vec_sel(vec_madd(alt5, q5, negBias), vec_madd(alt5, q5, bias),
-                    vec_cmpgt(alt5, zero));
-            alt6 = vec_sel(vec_madd(alt6, q6, negBias), vec_madd(alt6, q6, bias),
-                    vec_cmpgt(alt6, zero));
-            alt7 = vec_sel(vec_madd(alt7, q7, negBias), vec_madd(alt7, q7, bias),
-                    vec_cmpgt(alt7, zero));
-        }
-
- 
-    }
-
-    // Store the data back into the original block
-    {
-        vector signed short data0, data1, data2, data3, data4, data5, data6, data7;
-
-        data0 = vec_pack(vec_cts(row0, 0), vec_cts(alt0, 0));
-        data1 = vec_pack(vec_cts(row1, 0), vec_cts(alt1, 0));
-        data2 = vec_pack(vec_cts(row2, 0), vec_cts(alt2, 0));
-        data3 = vec_pack(vec_cts(row3, 0), vec_cts(alt3, 0));
-        data4 = vec_pack(vec_cts(row4, 0), vec_cts(alt4, 0));
-        data5 = vec_pack(vec_cts(row5, 0), vec_cts(alt5, 0));
-        data6 = vec_pack(vec_cts(row6, 0), vec_cts(alt6, 0));
-        data7 = vec_pack(vec_cts(row7, 0), vec_cts(alt7, 0));
-
-        {
-            // Clamp for overflow
-            vector signed int max_q_int, min_q_int;
-            vector signed short max_q, min_q;
-
-            LOAD4(max_q_int, &(s->max_qcoeff));
-            LOAD4(min_q_int, &(s->min_qcoeff));
-
-            max_q = vec_pack(max_q_int, max_q_int);
-            min_q = vec_pack(min_q_int, min_q_int);
-
-            data0 = vec_max(vec_min(data0, max_q), min_q);
-            data1 = vec_max(vec_min(data1, max_q), min_q);
-            data2 = vec_max(vec_min(data2, max_q), min_q);
-            data4 = vec_max(vec_min(data4, max_q), min_q);
-            data5 = vec_max(vec_min(data5, max_q), min_q);
-            data6 = vec_max(vec_min(data6, max_q), min_q);
-            data7 = vec_max(vec_min(data7, max_q), min_q);
-        }
-
-        {
-        vector bool char zero_01, zero_23, zero_45, zero_67;
-        vector signed char scanIndices_01, scanIndices_23, scanIndices_45, scanIndices_67;
-        vector signed char negOne = vec_splat_s8(-1);
-        vector signed char* scanPtr =
-                (vector signed char*)(s->intra_scantable.inverse);
-        signed char lastNonZeroChar;
-
-        // Determine the largest non-zero index.
-        zero_01 = vec_pack(vec_cmpeq(data0, (vector signed short)zero),
-                vec_cmpeq(data1, (vector signed short)zero));
-        zero_23 = vec_pack(vec_cmpeq(data2, (vector signed short)zero),
-                vec_cmpeq(data3, (vector signed short)zero));
-        zero_45 = vec_pack(vec_cmpeq(data4, (vector signed short)zero),
-                vec_cmpeq(data5, (vector signed short)zero));
-        zero_67 = vec_pack(vec_cmpeq(data6, (vector signed short)zero),
-                vec_cmpeq(data7, (vector signed short)zero));
-
-        // 64 biggest values
-        scanIndices_01 = vec_sel(scanPtr[0], negOne, zero_01);
-        scanIndices_23 = vec_sel(scanPtr[1], negOne, zero_23);
-        scanIndices_45 = vec_sel(scanPtr[2], negOne, zero_45);
-        scanIndices_67 = vec_sel(scanPtr[3], negOne, zero_67);
-
-        // 32 largest values
-        scanIndices_01 = vec_max(scanIndices_01, scanIndices_23);
-        scanIndices_45 = vec_max(scanIndices_45, scanIndices_67);
-
-        // 16 largest values
-        scanIndices_01 = vec_max(scanIndices_01, scanIndices_45);
-
-        // 8 largest values
-        scanIndices_01 = vec_max(vec_mergeh(scanIndices_01, negOne),
-                vec_mergel(scanIndices_01, negOne));
-
-        // 4 largest values
-        scanIndices_01 = vec_max(vec_mergeh(scanIndices_01, negOne),
-                vec_mergel(scanIndices_01, negOne));
-
-        // 2 largest values
-        scanIndices_01 = vec_max(vec_mergeh(scanIndices_01, negOne),
-                vec_mergel(scanIndices_01, negOne));
-
-        // largest value
-        scanIndices_01 = vec_max(vec_mergeh(scanIndices_01, negOne),
-                vec_mergel(scanIndices_01, negOne));
-
-        scanIndices_01 = vec_splat(scanIndices_01, 0);
-
-
-        vec_ste(scanIndices_01, 0, &lastNonZeroChar);
-
-        lastNonZero = lastNonZeroChar;
-        
-        // While the data is still in vectors we check for the transpose IDCT permute
-        // and handle it using the vector unit if we can.  This is the permute used
-        // by the altivec idct, so it is common when using the altivec dct.
-
-        if ((lastNonZero > 0) && (s->dsp.idct_permutation_type == FF_TRANSPOSE_IDCT_PERM))
-        {
-            TRANSPOSE8(data0, data1, data2, data3, data4, data5, data6, data7);
-        }
-
-        vec_st(data0, 0, data);
-        vec_st(data1, 16, data);
-        vec_st(data2, 32, data);
-        vec_st(data3, 48, data);
-        vec_st(data4, 64, data);
-        vec_st(data5, 80, data);
-        vec_st(data6, 96, data);
-        vec_st(data7, 112, data);
-        }
-    }
-
-    // special handling of block[0]
-    if (s->mb_intra)
-    {
-        if (!s->h263_aic)
-        {
-            if (n < 4)
-                oldBaseValue /= s->y_dc_scale;
-            else
-                oldBaseValue /= s->c_dc_scale;
-        }
-
-        // Divide by 8, rounding the result
-        data[0] = (oldBaseValue + 4) >> 3;
-    }
-
-    // We handled the tranpose permutation above and we don't
-    // need to permute the "no" permutation case.
-    if ((lastNonZero > 0) &&
-        (s->dsp.idct_permutation_type != FF_TRANSPOSE_IDCT_PERM) &&
-        (s->dsp.idct_permutation_type != FF_NO_IDCT_PERM))
-    {
-        ff_block_permute(data, s->dsp.idct_permutation,
-                s->intra_scantable.scantable, lastNonZero);
-    }
-
-    return lastNonZero;
-}
-#undef FOUROF
-
-/*
-  AltiVec version of dct_unquantize_h263
-  this code assumes `block' is 16 bytes-aligned
-*/
-void dct_unquantize_h263_altivec(MpegEncContext *s, 
-                                 DCTELEM *block, int n, int qscale)
-{
-POWERPC_PERF_DECLARE(altivec_dct_unquantize_h263_num, 1);
-    int i, level, qmul, qadd;
-    int nCoeffs;
-    
-    assert(s->block_last_index[n]>=0);
-
-POWERPC_PERF_START_COUNT(altivec_dct_unquantize_h263_num, 1);
-    
-    qadd = (qscale - 1) | 1;
-    qmul = qscale << 1;
-    
-    if (s->mb_intra) {
-        if (!s->h263_aic) {
-            if (n < 4) 
-                block[0] = block[0] * s->y_dc_scale;
-            else
-                block[0] = block[0] * s->c_dc_scale;
-        }else
-            qadd = 0;
-        i = 1;
-        nCoeffs= 63; //does not allways use zigzag table 
-    } else {
-        i = 0;
-        nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
-    }
-
-#ifdef ALTIVEC_USE_REFERENCE_C_CODE
-    for(;i<=nCoeffs;i++) {
-        level = block[i];
-        if (level) {
-            if (level < 0) {
-                level = level * qmul - qadd;
-            } else {
-                level = level * qmul + qadd;
-            }
-            block[i] = level;
-        }
-    }
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-    {
-      register const_vector signed short vczero = (const_vector signed short)vec_splat_s16(0);
-      short __attribute__ ((aligned(16))) qmul8[] =
-          {
-            qmul, qmul, qmul, qmul,
-            qmul, qmul, qmul, qmul
-          };
-      short __attribute__ ((aligned(16))) qadd8[] =
-          {
-            qadd, qadd, qadd, qadd,
-            qadd, qadd, qadd, qadd
-          };
-      short __attribute__ ((aligned(16))) nqadd8[] =
-          {
-            -qadd, -qadd, -qadd, -qadd,
-            -qadd, -qadd, -qadd, -qadd
-          };
-      register vector signed short blockv, qmulv, qaddv, nqaddv, temp1;
-      register vector bool short blockv_null, blockv_neg;
-      register short backup_0 = block[0];
-      register int j = 0;
-      
-      qmulv = vec_ld(0, qmul8);
-      qaddv = vec_ld(0, qadd8);
-      nqaddv = vec_ld(0, nqadd8);
-
-#if 0 // block *is* 16 bytes-aligned, it seems.
-      // first make sure block[j] is 16 bytes-aligned
-      for(j = 0; (j <= nCoeffs) && ((((unsigned long)block) + (j << 1)) & 0x0000000F) ; j++) {
-        level = block[j];
-        if (level) {
-          if (level < 0) {
-                level = level * qmul - qadd;
-            } else {
-                level = level * qmul + qadd;
-            }
-            block[j] = level;
-        }
-      }
-#endif
-      
-      // vectorize all the 16 bytes-aligned blocks
-      // of 8 elements
-      for(; (j + 7) <= nCoeffs ; j+=8)
-      {
-        blockv = vec_ld(j << 1, block);
-        blockv_neg = vec_cmplt(blockv, vczero);
-        blockv_null = vec_cmpeq(blockv, vczero);
-        // choose between +qadd or -qadd as the third operand
-        temp1 = vec_sel(qaddv, nqaddv, blockv_neg);
-        // multiply & add (block{i,i+7} * qmul [+-] qadd)
-        temp1 = vec_mladd(blockv, qmulv, temp1);
-        // put 0 where block[{i,i+7} used to have 0
-        blockv = vec_sel(temp1, blockv, blockv_null);
-        vec_st(blockv, j << 1, block);
-      }
-
-      // if nCoeffs isn't a multiple of 8, finish the job
-      // using good old scalar units.
-      // (we could do it using a truncated vector,
-      // but I'm not sure it's worth the hassle)
-      for(; j <= nCoeffs ; j++) {
-        level = block[j];
-        if (level) {
-          if (level < 0) {
-                level = level * qmul - qadd;
-            } else {
-                level = level * qmul + qadd;
-            }
-            block[j] = level;
-        }
-      }
-      
-      if (i == 1)
-      { // cheat. this avoid special-casing the first iteration
-        block[0] = backup_0;
-      }
-    }
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-
-POWERPC_PERF_STOP_COUNT(altivec_dct_unquantize_h263_num, nCoeffs == 63);
-}
diff --git a/ffmpeg.src/libavcodec/ppc/mpegvideo_ppc.c b/ffmpeg.src/libavcodec/ppc/mpegvideo_ppc.c
deleted file mode 100644
index 832bace..0000000
--- a/ffmpeg.src/libavcodec/ppc/mpegvideo_ppc.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2002 Dieter Shirley
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-#include "../dsputil.h"
-#include "../mpegvideo.h"
-#include <time.h>
-
-#ifdef HAVE_ALTIVEC
-#include "dsputil_altivec.h"
-#endif
-
-extern int dct_quantize_altivec(MpegEncContext *s,  
-        DCTELEM *block, int n,
-        int qscale, int *overflow);
-extern void dct_unquantize_h263_altivec(MpegEncContext *s,
-                                        DCTELEM *block, int n, int qscale);
-
-extern void idct_put_altivec(uint8_t *dest, int line_size, int16_t *block);
-extern void idct_add_altivec(uint8_t *dest, int line_size, int16_t *block);
-
-
-void MPV_common_init_ppc(MpegEncContext *s)
-{
-#ifdef HAVE_ALTIVEC
-    if (has_altivec())
-    {
-      if (s->avctx->lowres==0)
-      {
-        if ((s->avctx->idct_algo == FF_IDCT_AUTO) ||
-                (s->avctx->idct_algo == FF_IDCT_ALTIVEC))
-        {
-            s->dsp.idct_put = idct_put_altivec;
-            s->dsp.idct_add = idct_add_altivec;
-#ifndef ALTIVEC_USE_REFERENCE_C_CODE
-            s->dsp.idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
-#else /* ALTIVEC_USE_REFERENCE_C_CODE */
-            s->dsp.idct_permutation_type = FF_NO_IDCT_PERM;
-#endif /* ALTIVEC_USE_REFERENCE_C_CODE */
-        }
-      }
-
-        // Test to make sure that the dct required alignments are met.
-        if ((((long)(s->q_intra_matrix) & 0x0f) != 0) ||
-                (((long)(s->q_inter_matrix) & 0x0f) != 0))
-        {
-            av_log(s->avctx, AV_LOG_INFO, "Internal Error: q-matrix blocks must be 16-byte aligned "
-                    "to use Altivec DCT. Reverting to non-altivec version.\n");
-            return;
-        }
-
-        if (((long)(s->intra_scantable.inverse) & 0x0f) != 0)
-        {
-            av_log(s->avctx, AV_LOG_INFO, "Internal Error: scan table blocks must be 16-byte aligned "
-                    "to use Altivec DCT. Reverting to non-altivec version.\n");
-            return;
-        }
-
-
-        if ((s->avctx->dct_algo == FF_DCT_AUTO) ||
-                (s->avctx->dct_algo == FF_DCT_ALTIVEC))
-        {
-#if 0 /* seems to cause trouble under some circumstances */
-            s->dct_quantize = dct_quantize_altivec;
-#endif
-            s->dct_unquantize_h263_intra = dct_unquantize_h263_altivec;
-            s->dct_unquantize_h263_inter = dct_unquantize_h263_altivec;
-        }
-    } else
-#endif
-    {
-        /* Non-AltiVec PPC optimisations here */
-    }
-}
-
diff --git a/ffmpeg.src/libavcodec/ps2/dsputil_mmi.c b/ffmpeg.src/libavcodec/ps2/dsputil_mmi.c
deleted file mode 100644
index 8d1bf4b..0000000
--- a/ffmpeg.src/libavcodec/ps2/dsputil_mmi.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * MMI optimized DSP utils
- * Copyright (c) 2000, 2001 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * MMI optimization by Leon van Stuivenberg
- * clear_blocks_mmi() by BroadQ
- */
-
-#include "../dsputil.h"
-#include "mmi.h"
-
-void ff_mmi_idct_put(uint8_t *dest, int line_size, DCTELEM *block);
-void ff_mmi_idct_add(uint8_t *dest, int line_size, DCTELEM *block);
-void ff_mmi_idct(DCTELEM *block);
-
-static void clear_blocks_mmi(DCTELEM * blocks)
-{
-        asm volatile(
-        ".set noreorder    \n"
-        "addiu $9, %0, 768 \n"
-        "nop               \n"
-        "1:                \n"
-        "sq $0, 0(%0)      \n"
-        "move $8, %0       \n"
-        "addi %0, %0, 64   \n"
-        "sq $0, 16($8)     \n"
-        "slt $10, %0, $9   \n"
-        "sq $0, 32($8)     \n"
-        "bnez $10, 1b      \n"
-        "sq $0, 48($8)     \n"
-        ".set reorder      \n"
-        : "+r" (blocks) ::  "$8", "$9", "memory" );
-}
-
-
-static void get_pixels_mmi(DCTELEM *block, const uint8_t *pixels, int line_size)
-{
-        asm volatile(
-        ".set   push            \n\t"
-        ".set   mips3           \n\t"
-        "ld     $8, 0(%0)       \n\t"
-        "add    %0, %0, %2      \n\t"
-        "ld     $9, 0(%0)       \n\t"
-        "add    %0, %0, %2      \n\t"
-        "ld     $10, 0(%0)      \n\t"
-        "pextlb $8, $0, $8      \n\t"
-        "sq     $8, 0(%1)       \n\t"
-        "add    %0, %0, %2      \n\t"
-        "ld     $8, 0(%0)       \n\t"
-        "pextlb $9, $0, $9      \n\t"
-        "sq     $9, 16(%1)      \n\t"
-        "add    %0, %0, %2      \n\t"
-        "ld     $9, 0(%0)       \n\t"
-        "pextlb $10, $0, $10    \n\t"
-        "sq     $10, 32(%1)     \n\t"
-        "add    %0, %0, %2      \n\t"
-        "ld     $10, 0(%0)      \n\t"
-        "pextlb $8, $0, $8      \n\t"
-        "sq     $8, 48(%1)      \n\t"
-        "add    %0, %0, %2      \n\t"
-        "ld     $8, 0(%0)       \n\t"
-        "pextlb $9, $0, $9      \n\t"
-        "sq     $9, 64(%1)      \n\t"
-        "add    %0, %0, %2      \n\t"
-        "ld     $9, 0(%0)       \n\t"
-        "pextlb $10, $0, $10    \n\t"
-        "sq     $10, 80(%1)     \n\t"
-        "pextlb $8, $0, $8      \n\t"
-	"sq     $8, 96(%1)      \n\t"
-        "pextlb $9, $0, $9      \n\t"
-        "sq     $9, 112(%1)     \n\t"
-        ".set   pop             \n\t"
-        : "+r" (pixels) : "r" (block), "r" (line_size) : "$8", "$9", "$10", "memory" );
-}
-
-
-static void put_pixels8_mmi(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-        asm volatile(
-        ".set   push            \n\t"
-        ".set   mips3           \n\t"
-        "1:                     \n\t"
-        "ldr    $8, 0(%1)       \n\t"
-        "addiu  %2, %2, -1      \n\t"
-        "ldl    $8, 7(%1)       \n\t"
-        "add    %1, %1, %3      \n\t"
-        "sd     $8, 0(%0)       \n\t"
-        "add    %0, %0, %3      \n\t"
-        "bgtz   %2, 1b          \n\t"
-        ".set   pop             \n\t"
-        : "+r" (block), "+r" (pixels), "+r" (h) : "r" (line_size)
-        : "$8", "memory" );
-}
-
-
-static void put_pixels16_mmi(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-{
-        asm volatile (
-        ".set   push            \n\t"
-        ".set   mips3           \n\t"
-	"1:                     \n\t"
-        "ldr    $8, 0(%1)       \n\t"
-        "add    $11, %1, %3     \n\t"
-        "ldl    $8, 7(%1)       \n\t"
-        "add    $10, %0, %3     \n\t"
-        "ldr    $9, 8(%1)       \n\t"
-        "ldl    $9, 15(%1)      \n\t"
-        "ldr    $12, 0($11)     \n\t"
-        "add    %1, $11, %3     \n\t"
-        "ldl    $12, 7($11)     \n\t"
-        "pcpyld $8, $9, $8      \n\t"
-        "sq     $8, 0(%0)       \n\t"
-        "ldr    $13, 8($11)     \n\t"
-        "addiu  %2, %2, -2      \n\t"
-        "ldl    $13, 15($11)    \n\t"
-        "add    %0, $10, %3     \n\t"
-        "pcpyld $12, $13, $12   \n\t"
-        "sq     $12, 0($10)     \n\t"
-        "bgtz   %2, 1b          \n\t"
-        ".set   pop             \n\t"
-        : "+r" (block), "+r" (pixels), "+r" (h) : "r" (line_size)
-	: "$8", "$9", "$10", "$11", "$12", "$13", "memory" );
-}
-
-
-void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx)
-{
-    const int idct_algo= avctx->idct_algo;
-
-    c->clear_blocks = clear_blocks_mmi;
-
-    c->put_pixels_tab[1][0] = put_pixels8_mmi;
-    c->put_no_rnd_pixels_tab[1][0] = put_pixels8_mmi;
-
-    c->put_pixels_tab[0][0] = put_pixels16_mmi;
-    c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mmi;
-
-    c->get_pixels = get_pixels_mmi;
-       
-    if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_PS2){
-        c->idct_put= ff_mmi_idct_put;
-        c->idct_add= ff_mmi_idct_add;
-        c->idct    = ff_mmi_idct;
-        c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
-    }
-}
-
diff --git a/ffmpeg.src/libavcodec/ps2/idct_mmi.c b/ffmpeg.src/libavcodec/ps2/idct_mmi.c
deleted file mode 100644
index 1d2c7e9..0000000
--- a/ffmpeg.src/libavcodec/ps2/idct_mmi.c
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
-  Originally provided by Intel at AP-922
-  http://developer.intel.com/vtune/cbts/strmsimd/922down.htm
-  (See more app notes at http://developer.intel.com/vtune/cbts/strmsimd/appnotes.htm)
-  but in a limited edition.
-
-  column code adapted from peter gubanov
-  Copyright (c) 2000-2001 Peter Gubanov <peter at elecard.net.ru>
-  http://www.elecard.com/peter/idct.shtml
-  Rounding trick Copyright (c) 2000 Michel Lespinasse <walken at zoy.org>
-
-  MMI port by Leon van Stuivenberg
-*/  
-#include "../common.h"
-#include "../dsputil.h"
-#include "mmi.h"
-
-#define BITS_INV_ACC	5	// 4 or 5 for IEEE
-#define SHIFT_INV_ROW	(16 - BITS_INV_ACC)
-#define SHIFT_INV_COL   (1 + BITS_INV_ACC)
-
-#define TG1	6518
-#define TG2	13573
-#define TG3	21895
-#define CS4	23170
-
-#define ROUNDER_0	0
-#define ROUNDER_1	16
-
-#define TAB_i_04	(32+0)
-#define TAB_i_17	(32+64)
-#define TAB_i_26	(32+128)
-#define TAB_i_35	(32+192)
-
-#define TG_1_16		(32+256+0)
-#define TG_2_16		(32+256+16)
-#define TG_3_16		(32+256+32)
-#define COS_4_16	(32+256+48)
-
-#define CLIPMAX		(32+256+64+0)
-
-static short consttable[] align16 = {
-/* rounder 0*/	// assume SHIFT_INV_ROW == 11
- 0x3ff, 1, 0x3ff, 1, 0x3ff, 1, 0x3ff, 1,
-/* rounder 1*/
- 0x3ff, 0, 0x3ff, 0, 0x3ff, 0, 0x3ff, 0,
-/* row 0/4*/
- 16384,  21407, -16384, -21407,  22725,  19266, -22725, -12873, 
-  8867,  16384,   8867,  16384,   4520,  12873,  -4520,  19266, 
- 16384,  -8867,  16384,  -8867,  12873, -22725,  19266, -22725, 
- 21407, -16384, -21407,  16384,  19266,   4520, -12873,   4520, 
-/* row 1/7*/
- 22725,  29692, -22725, -29692,  31521,  26722, -31521, -17855, 
- 12299,  22725,  12299,  22725,   6270,  17855,  -6270,  26722, 
- 22725, -12299,  22725, -12299,  17855, -31521,  26722, -31521, 
- 29692, -22725, -29692,  22725,  26722,   6270, -17855,   6270, 
-/* row 2/6*/
- 21407,  27969, -21407, -27969,  29692,  25172, -29692, -16819, 
- 11585,  21407,  11585,  21407,   5906,  16819,  -5906,  25172, 
- 21407, -11585,  21407, -11585,  16819, -29692,  25172, -29692, 
- 27969, -21407, -27969,  21407,  25172,   5906, -16819,   5906, 
-/*row 3/5*/
- 19266,  25172, -19266, -25172,  26722,  22654, -26722, -15137, 
- 10426,  19266,  10426,  19266,   5315,  15137,  -5315,  22654, 
- 19266, -10426,  19266, -10426,  15137, -26722,  22654, -26722, 
- 25172, -19266, -25172,  19266,  22654,   5315, -15137,   5315,
-/*column constants*/
- TG1, TG1, TG1, TG1, TG1, TG1, TG1, TG1,
- TG2, TG2, TG2, TG2, TG2, TG2, TG2, TG2,
- TG3, TG3, TG3, TG3, TG3, TG3, TG3, TG3,
- CS4, CS4, CS4, CS4, CS4, CS4, CS4, CS4,
-/* clamp */
- 255, 255, 255, 255, 255, 255, 255, 255
-};
-
-
-#define DCT_8_INV_ROW1(blk, rowoff, taboff, rnd, outreg) { \
-	lq(blk, rowoff, $16);	/* r16 = x7  x5  x3  x1  x6  x4  x2  x0 */ \
-	/*slot*/ \
-	lq($24, 0+taboff, $17);	/* r17 = w */ \
-	/*delay slot $16*/ \
-	lq($24, 16+taboff, $18);/* r18 = w */ \
-	prevh($16, $2);		/* r2  = x1  x3  x5  x7  x0  x2  x4  x6 */ \
-	lq($24, 32+taboff, $19);/* r19 = w */ \
-	phmadh($17, $16, $17);	/* r17 = b1"b0'a1"a0' */ \
-	lq($24, 48+taboff, $20);/* r20 = w */ \
-	phmadh($18, $2, $18);	/* r18 = b1'b0"a1'a0" */ \
-	phmadh($19, $16, $19);	/* r19 = b3"b2'a3"a2' */ \
-	phmadh($20, $2, $20);	/* r20 = b3'b2"a3'a2" */ \
-	paddw($17, $18, $17);	/* r17 = (b1)(b0)(a1)(a0) */ \
-	paddw($19, $20, $19);	/* r19 = (b3)(b2)(a3)(a2) */ \
-	pcpyld($19, $17, $18);	/* r18 = (a3)(a2)(a1)(a0) */ \
-	pcpyud($17, $19, $20);	/* r20 = (b3)(b2)(b1)(b0) */ \
-	paddw($18, rnd, $18);	/* r18 = (a3)(a2)(a1)(a0) */\
-	paddw($18, $20, $17);	/* r17 = ()()()(a0+b0) */ \
-	psubw($18, $20, $20);	/* r20 = ()()()(a0-b0) */ \
-	psraw($17, SHIFT_INV_ROW, $17); /* r17 = (y3 y2 y1 y0) */ \
-	psraw($20, SHIFT_INV_ROW, $20);	/* r20 = (y4 y5 y6 y7) */ \
-	ppach($20, $17, outreg);/* out = y4 y5 y6 y7 y3 y2 y1 y0  Note order */ \
-\
-	prevh(outreg, $2);	\
-	pcpyud($2, $2, $2);	\
-	pcpyld($2, outreg, outreg);	\
-}
-
-
-#define DCT_8_INV_COL8() \
-\
-	lq($24, TG_3_16, $2);	/* r2  = tn3 */	\
-\
-	pmulth($11, $2, $17);	/* r17 = x3 * tn3 (6420) */ \
-	psraw($17, 15, $17);	\
-	pmfhl_uw($3);		/* r3  = 7531 */	\
-	psraw($3, 15, $3);	\
-	pinteh($3, $17, $17);	/* r17 = x3 * tn3 */ \
-	psubh($17, $13, $17);	/* r17 = tm35 */	\
-\
-	pmulth($13, $2, $18);	/* r18 = x5 * tn3 (6420) */ \
-	psraw($18, 15, $18);	\
-	pmfhl_uw($3);		/* r3  = 7531 */	\
-	psraw($3, 15, $3);	\
-	pinteh($3, $18, $18);	/* r18 = x5 * tn3 */ \
-	paddh($18, $11, $18);	/* r18 = tp35 */	\
-\
-	lq($24, TG_1_16, $2);	/* r2  = tn1 */	\
-\
-	pmulth($15, $2, $19);	/* r19 = x7 * tn1 (6420) */ \
-	psraw($19, 15, $19);	\
-	pmfhl_uw($3);		/* r3  = 7531 */	\
-	psraw($3, 15, $3);	\
-	pinteh($3, $19, $19);	/* r19 = x7 * tn1 */ \
-	paddh($19, $9, $19);	/* r19 = tp17 */	\
-\
-	pmulth($9, $2, $20);	/* r20 = x1 * tn1 (6420) */ \
-	psraw($20, 15, $20);	\
-	pmfhl_uw($3);		/* r3  = 7531 */	\
-	psraw($3, 15, $3);	\
-	pinteh($3, $20, $20);	/* r20 = x1 * tn1 */ \
-	psubh($20, $15, $20);	/* r20 = tm17 */	\
-\
-	psubh($19, $18, $3);	/* r3  = t1 */	\
-	paddh($20, $17, $16);	/* r16 = t2 */	\
-	psubh($20, $17, $23);	/* r23 = b3 */	\
-	paddh($19, $18, $20);	/* r20 = b0 */	\
-\
-	lq($24, COS_4_16, $2);	/* r2  = cs4 */	\
-\
-	paddh($3, $16, $21);	/* r21 = t1+t2 */	\
-	psubh($3, $16, $22);	/* r22 = t1-t2 */	\
-\
-	pmulth($21, $2, $21);	/* r21 = cs4 * (t1+t2) 6420 */ \
-	psraw($21, 15, $21);	\
-	pmfhl_uw($3);		/* r3  = 7531 */	\
-	psraw($3, 15, $3);	\
-	pinteh($3, $21, $21);	/* r21 = b1 */	\
-\
-	pmulth($22, $2, $22);	/* r22 = cs4 * (t1-t2) 6420 */ \
-	psraw($22, 15, $22);	\
-	pmfhl_uw($3);		/* r3  = 7531 */	\
-	psraw($3, 15, $3);	\
-	pinteh($3, $22, $22);	/* r22 = b2 */	\
-\
-	lq($24, TG_2_16, $2);	/* r2  = tn2 */	\
-\
-	pmulth($10, $2, $17);	/* r17 = x2 * tn2 (6420) */ \
-	psraw($17, 15, $17);	\
-	pmfhl_uw($3);		/* r3  = 7531 */	\
-	psraw($3, 15, $3);	\
-	pinteh($3, $17, $17);	/* r17 = x3 * tn3 */ \
-	psubh($17, $14, $17);	/* r17 = tm26 */	\
-\
-	pmulth($14, $2, $18);	/* r18 = x6 * tn2 (6420) */ \
-	psraw($18, 15, $18);	\
-	pmfhl_uw($3);		/* r3  = 7531 */	\
-	psraw($3, 15, $3);	\
-	pinteh($3, $18, $18);	/* r18 = x6 * tn2 */ \
-	paddh($18, $10, $18);	/* r18 = tp26 */	\
-\
-	paddh($8, $12, $2);	/* r2  = tp04 */	\
-	psubh($8, $12, $3);	/* r3  = tm04 */	\
-\
-	paddh($2, $18, $16);	/* r16 = a0 */			\
-	psubh($2, $18, $19);	/* r19 = a3 */			\
-	psubh($3, $17, $18);	/* r18 = a2 */			\
-	paddh($3, $17, $17);	/* r17 = a1 */
-
-
-#define DCT_8_INV_COL8_STORE(blk) \
-\
-	paddh($16, $20, $2);	/* y0  a0+b0 */		\
-	psubh($16, $20, $16);	/* y7  a0-b0 */		\
-	psrah($2, SHIFT_INV_COL, $2);		\
-	psrah($16, SHIFT_INV_COL, $16);		\
-	sq($2, 0, blk); 			\
-	sq($16, 112, blk); 			\
-\
-	paddh($17, $21, $3);	/* y1  a1+b1 */		\
-	psubh($17, $21, $17);	/* y6  a1-b1 */		\
-	psrah($3, SHIFT_INV_COL, $3);		\
-	psrah($17, SHIFT_INV_COL, $17);		\
-	sq($3, 16, blk);			\
-	sq($17, 96, blk);			\
-\
-	paddh($18, $22, $2);	/* y2  a2+b2 */	\
-	psubh($18, $22, $18);	/* y5  a2-b2 */	\
-	psrah($2, SHIFT_INV_COL, $2);	\
-	psrah($18, SHIFT_INV_COL, $18);	\
-	sq($2, 32, blk);			\
-	sq($18, 80, blk);			\
-\
-	paddh($19, $23, $3);	/* y3  a3+b3 */	\
-	psubh($19, $23, $19);	/* y4  a3-b3 */	\
-	psrah($3, SHIFT_INV_COL, $3);	\
-	psrah($19, SHIFT_INV_COL, $19);	\
-	sq($3, 48, blk);			\
-	sq($19, 64, blk);
-
-
-
-#define DCT_8_INV_COL8_PMS() \
-	paddh($16, $20, $2);	/* y0  a0+b0 */		\
-	psubh($16, $20, $20);	/* y7  a0-b0 */		\
-	psrah($2, SHIFT_INV_COL, $16);		\
-	psrah($20, SHIFT_INV_COL, $20);		\
-\
-	paddh($17, $21, $3);	/* y1  a1+b1 */		\
-	psubh($17, $21, $21);	/* y6  a1-b1 */		\
-	psrah($3, SHIFT_INV_COL, $17);		\
-	psrah($21, SHIFT_INV_COL, $21);		\
-\
-	paddh($18, $22, $2);	/* y2  a2+b2 */	\
-	psubh($18, $22, $22);	/* y5  a2-b2 */	\
-	psrah($2, SHIFT_INV_COL, $18);	\
-	psrah($22, SHIFT_INV_COL, $22);	\
-\
-	paddh($19, $23, $3);	/* y3  a3+b3 */	\
-	psubh($19, $23, $23);	/* y4  a3-b3 */	\
-	psrah($3, SHIFT_INV_COL, $19);	\
-	psrah($23, SHIFT_INV_COL, $23);
-
-#define PUT(rs) \
-	pminh(rs, $11, $2);	\
-    	pmaxh($2, $0, $2);	\
-	ppacb($0, $2, $2); \
-	sd3(2, 0, 4); \
-	__asm__ __volatile__ ("add $4, $5, $4");
-
-#define DCT_8_INV_COL8_PUT() \
-    	PUT($16);		\
-    	PUT($17);		\
-    	PUT($18);		\
-    	PUT($19);		\
-    	PUT($23);		\
-    	PUT($22);		\
-    	PUT($21);		\
-    	PUT($20);
-
-#define ADD(rs) \
-    ld3(4, 0, 2); \
-    pextlb($0, $2, $2); \
-    paddh($2, rs, $2); \
-    pminh($2, $11, $2);	\
-    pmaxh($2, $0, $2);	\
-    ppacb($0, $2, $2); \
-    sd3(2, 0, 4); \
-    __asm__ __volatile__ ("add $4, $5, $4");
-
-/*fixme: schedule*/
-#define DCT_8_INV_COL8_ADD() \
-    	ADD($16);		\
-    	ADD($17);		\
-    	ADD($18);		\
-    	ADD($19);		\
-    	ADD($23);		\
-    	ADD($22);		\
-    	ADD($21);		\
-    	ADD($20);
-
-
-void ff_mmi_idct(int16_t * block)
-{
-    /* $4 = block */
-    __asm__ __volatile__("la $24, %0"::"m"(consttable[0]));
-    lq($24, ROUNDER_0, $8);
-    lq($24, ROUNDER_1, $7);
-    DCT_8_INV_ROW1($4, 0, TAB_i_04, $8, $8);
-    DCT_8_INV_ROW1($4, 16, TAB_i_17, $7, $9);
-    DCT_8_INV_ROW1($4, 32, TAB_i_26, $7, $10);
-    DCT_8_INV_ROW1($4, 48, TAB_i_35, $7, $11);
-    DCT_8_INV_ROW1($4, 64, TAB_i_04, $7, $12);
-    DCT_8_INV_ROW1($4, 80, TAB_i_35, $7, $13);
-    DCT_8_INV_ROW1($4, 96, TAB_i_26, $7, $14);
-    DCT_8_INV_ROW1($4, 112, TAB_i_17, $7, $15);
-    DCT_8_INV_COL8();
-    DCT_8_INV_COL8_STORE($4);
- 
-    //let savedtemp regs be saved
-    __asm__ __volatile__(" ":::"$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23");
-}
-
-
-void ff_mmi_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    /* $4 = dest, $5 = line_size, $6 = block */
-    __asm__ __volatile__("la $24, %0"::"m"(consttable[0]));
-    lq($24, ROUNDER_0, $8);
-    lq($24, ROUNDER_1, $7);
-    DCT_8_INV_ROW1($6, 0, TAB_i_04, $8, $8);
-    DCT_8_INV_ROW1($6, 16, TAB_i_17, $7, $9);
-    DCT_8_INV_ROW1($6, 32, TAB_i_26, $7, $10);
-    DCT_8_INV_ROW1($6, 48, TAB_i_35, $7, $11);
-    DCT_8_INV_ROW1($6, 64, TAB_i_04, $7, $12);
-    DCT_8_INV_ROW1($6, 80, TAB_i_35, $7, $13);
-    DCT_8_INV_ROW1($6, 96, TAB_i_26, $7, $14);
-    DCT_8_INV_ROW1($6, 112, TAB_i_17, $7, $15);
-    DCT_8_INV_COL8();
-    lq($24, CLIPMAX, $11);
-    DCT_8_INV_COL8_PMS();
-    DCT_8_INV_COL8_PUT();
-
-    //let savedtemp regs be saved
-    __asm__ __volatile__(" ":::"$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23");
-}
-
-
-void ff_mmi_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    /* $4 = dest, $5 = line_size, $6 = block */
-    __asm__ __volatile__("la $24, %0"::"m"(consttable[0]));
-    lq($24, ROUNDER_0, $8);
-    lq($24, ROUNDER_1, $7);
-    DCT_8_INV_ROW1($6, 0, TAB_i_04, $8, $8);
-    DCT_8_INV_ROW1($6, 16, TAB_i_17, $7, $9);
-    DCT_8_INV_ROW1($6, 32, TAB_i_26, $7, $10);
-    DCT_8_INV_ROW1($6, 48, TAB_i_35, $7, $11);
-    DCT_8_INV_ROW1($6, 64, TAB_i_04, $7, $12);
-    DCT_8_INV_ROW1($6, 80, TAB_i_35, $7, $13);
-    DCT_8_INV_ROW1($6, 96, TAB_i_26, $7, $14);
-    DCT_8_INV_ROW1($6, 112, TAB_i_17, $7, $15);
-    DCT_8_INV_COL8();
-    lq($24, CLIPMAX, $11);
-    DCT_8_INV_COL8_PMS();
-    DCT_8_INV_COL8_ADD();
-
-    //let savedtemp regs be saved
-    __asm__ __volatile__(" ":::"$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23");
-}
-
diff --git a/ffmpeg.src/libavcodec/ps2/mmi.h b/ffmpeg.src/libavcodec/ps2/mmi.h
deleted file mode 100644
index de9af1d..0000000
--- a/ffmpeg.src/libavcodec/ps2/mmi.h
+++ /dev/null
@@ -1,152 +0,0 @@
-#ifndef __mmi_H
-#define __mmi_H
-
-#define align16 __attribute__ ((aligned (16)))
-
-/*
-#define r0 $zero
-#define r1 $at	//assembler!
-#define r2 $v0	//return
-#define r3 $v1	//return
-#define r4 $a0	//arg
-#define r5 $a1	//arg
-#define r6 $a2	//arg
-#define r7 $a3	//arg
-#define r8 $t0	//temp
-#define r9 $t1	//temp
-#define r10 $t2	//temp
-#define r11 $t3	//temp
-#define r12 $t4	//temp
-#define r13 $t5	//temp
-#define r14 $t6	//temp
-#define r15 $t7	//temp
-#define r16 $s0	//saved temp
-#define r17 $s1	//saved temp
-#define r18 $s2	//saved temp
-#define r19 $s3	//saved temp
-#define r20 $s4	//saved temp
-#define r21 $s5	//saved temp
-#define r22 $s6	//saved temp
-#define r23 $s7	//saved temp
-#define r24 $t8	//temp
-#define r25 $t9	//temp
-#define r26 $k0	//kernel
-#define r27 $k1	//kernel
-#define r28 $gp	//global ptr
-#define r29 $sp //stack ptr
-#define r30 $fp //frame ptr
-#define r31 $ra //return addr
-*/
-
-
-#define	lq(base, off, reg)	\
-	__asm__ __volatile__ ("lq " #reg ", %0("#base ")" : : "i" (off) )
-
-#define	lq2(mem, reg)	\
-	__asm__ __volatile__ ("lq " #reg ", %0" : : "r" (mem))
-
-#define	sq(reg, off, base)	\
-	__asm__ __volatile__ ("sq " #reg ", %0("#base ")" : : "i" (off) )
-
-/*
-#define	ld(base, off, reg)	\
-	__asm__ __volatile__ ("ld " #reg ", " #off "("#base ")")
-*/
-
-#define	ld3(base, off, reg)	\
-	__asm__ __volatile__ (".word %0" : : "i" ( 0xdc000000 | (base<<21) | (reg<<16) | (off)))
-
-#define	ldr3(base, off, reg)	\
-	__asm__ __volatile__ (".word %0" : : "i" ( 0x6c000000 | (base<<21) | (reg<<16) | (off)))
-
-#define	ldl3(base, off, reg)	\
-	__asm__ __volatile__ (".word %0" : : "i" ( 0x68000000 | (base<<21) | (reg<<16) | (off)))
-
-/*
-#define	sd(reg, off, base)	\
-	__asm__ __volatile__ ("sd " #reg ", " #off "("#base ")")
-*/
-//seems assembler has bug encoding mnemonic 'sd', so DIY
-#define	sd3(reg, off, base)	\
-	__asm__ __volatile__ (".word %0" : : "i" ( 0xfc000000 | (base<<21) | (reg<<16) | (off)))
-
-#define	sw(reg, off, base)	\
-	__asm__ __volatile__ ("sw " #reg ", " #off "("#base ")")
-
-#define	sq2(reg, mem)	\
-	__asm__ __volatile__ ("sq " #reg ", %0" : : "m" (*(mem)))
-
-#define	pinth(rs, rt, rd) \
-	__asm__ __volatile__ ("pinth  " #rd ", " #rs ", " #rt )
-
-#define	phmadh(rs, rt, rd) \
-	__asm__ __volatile__ ("phmadh " #rd ", " #rs ", " #rt )
-
-#define	pcpyud(rs, rt, rd) \
-	__asm__ __volatile__ ("pcpyud " #rd ", " #rs ", " #rt )
-
-#define	pcpyld(rs, rt, rd) \
-	__asm__ __volatile__ ("pcpyld " #rd ", " #rs ", " #rt )
-
-#define	pcpyh(rt, rd) \
-	__asm__ __volatile__ ("pcpyh  " #rd ", " #rt )
-
-#define	paddw(rs, rt, rd) \
-	__asm__ __volatile__ ("paddw  " #rd ", " #rs ", " #rt )
-
-#define	pextlw(rs, rt, rd) \
-	__asm__ __volatile__ ("pextlw " #rd ", " #rs ", " #rt )
-
-#define	pextuw(rs, rt, rd) \
-	__asm__ __volatile__ ("pextuw " #rd ", " #rs ", " #rt )
-
-#define	pextlh(rs, rt, rd) \
-	__asm__ __volatile__ ("pextlh " #rd ", " #rs ", " #rt )
-
-#define	pextuh(rs, rt, rd) \
-	__asm__ __volatile__ ("pextuh " #rd ", " #rs ", " #rt )
-
-#define	psubw(rs, rt, rd) \
-	__asm__ __volatile__ ("psubw  " #rd ", " #rs ", " #rt )
-
-#define	psraw(rt, sa, rd) \
-	__asm__ __volatile__ ("psraw  " #rd ", " #rt ", %0" : : "i"(sa) )
-
-#define	ppach(rs, rt, rd) \
-	__asm__ __volatile__ ("ppach  " #rd ", " #rs ", " #rt )
-
-#define	ppacb(rs, rt, rd) \
-	__asm__ __volatile__ ("ppacb  " #rd ", " #rs ", " #rt )
-
-#define	prevh(rt, rd) \
-	__asm__ __volatile__ ("prevh  " #rd ", " #rt )
-
-#define	pmulth(rs, rt, rd) \
-	__asm__ __volatile__ ("pmulth " #rd ", " #rs ", " #rt )
-
-#define	pmaxh(rs, rt, rd) \
-	__asm__ __volatile__ ("pmaxh " #rd ", " #rs ", " #rt )
-
-#define	pminh(rs, rt, rd) \
-	__asm__ __volatile__ ("pminh " #rd ", " #rs ", " #rt )
-
-#define	pinteh(rs, rt, rd) \
-	__asm__ __volatile__ ("pinteh  " #rd ", " #rs ", " #rt )
-
-#define	paddh(rs, rt, rd) \
-	__asm__ __volatile__ ("paddh  " #rd ", " #rs ", " #rt )
-
-#define	psubh(rs, rt, rd) \
-	__asm__ __volatile__ ("psubh  " #rd ", " #rs ", " #rt )
-
-#define	psrah(rt, sa, rd) \
-	__asm__ __volatile__ ("psrah  " #rd ", " #rt ", %0" : : "i"(sa) )
-
-#define	pmfhl_uw(rd) \
-	__asm__ __volatile__ ("pmfhl.uw  " #rd)
-
-#define	pextlb(rs, rt, rd) \
-	__asm__ __volatile__ ("pextlb  " #rd ", " #rs ", " #rt )
-
-#endif
-
diff --git a/ffmpeg.src/libavcodec/ps2/mpegvideo_mmi.c b/ffmpeg.src/libavcodec/ps2/mpegvideo_mmi.c
deleted file mode 100644
index 2d706b8..0000000
--- a/ffmpeg.src/libavcodec/ps2/mpegvideo_mmi.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2000,2001 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * MMI optimization by Leon van Stuivenberg
- */
- 
-#include "../dsputil.h"
-#include "../mpegvideo.h"
-#include "../avcodec.h"
-
-static void dct_unquantize_h263_mmi(MpegEncContext *s, 
-                                  DCTELEM *block, int n, int qscale)
-{
-    int level=0, qmul, qadd;
-    int nCoeffs;
-    
-    assert(s->block_last_index[n]>=0);
-    
-    qadd = (qscale - 1) | 1;
-    qmul = qscale << 1;
-    
-    if (s->mb_intra) {
-        if (!s->h263_aic) {
-            if (n < 4) 
-                level = block[0] * s->y_dc_scale;
-            else
-                level = block[0] * s->c_dc_scale;
-        }else {
-            qadd = 0;
-	    level = block[0];
-        }
-        nCoeffs= 63; //does not allways use zigzag table 
-    } else {
-        nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
-    }
-
-    asm volatile(
-        "add    $14, $0, %3	\n\t"
-        "pcpyld $8, %0, %0	\n\t"	
-        "pcpyh  $8, $8		\n\t"   //r8 = qmul
-        "pcpyld $9, %1, %1	\n\t"	
-        "pcpyh  $9, $9		\n\t"   //r9 = qadd
-        ".p2align 2             \n\t"
-        "1:			\n\t"
-        "lq     $10, 0($14)	\n\t"   //r10 = level
-        "addi   $14, $14, 16	\n\t"	//block+=8
-        "addi   %2, %2, -8	\n\t"
-        "pcgth  $11, $0, $10	\n\t"   //r11 = level < 0 ? -1 : 0
-        "pcgth  $12, $10, $0	\n\t"   //r12 = level > 0 ? -1 : 0
-        "por    $12, $11, $12	\n\t"
-        "pmulth $10, $10, $8	\n\t"	
-        "paddh  $13, $9, $11	\n\t"
-        "pxor   $13, $13, $11   \n\t"   //r13 = level < 0 ? -qadd : qadd
-        "pmfhl.uw $11		\n\t"
-        "pinteh $10, $11, $10	\n\t"   //r10 = level * qmul
-        "paddh  $10, $10, $13	\n\t"
-        "pand   $10, $10, $12   \n\t"
-        "sq     $10, -16($14)	\n\t"
-        "bgez   %2, 1b		\n\t"
-	:: "r"(qmul), "r" (qadd), "r" (nCoeffs), "r" (block) : "$8", "$9", "$10", "$11", "$12", "$13", "$14", "memory" );
-
-    if(s->mb_intra)
-        block[0]= level;
-}
-
-
-void MPV_common_init_mmi(MpegEncContext *s)
-{
-    s->dct_unquantize_h263_intra = 
-    s->dct_unquantize_h263_inter = dct_unquantize_h263_mmi;
-}
-
-
diff --git a/ffmpeg.src/libavcodec/rangecoder.c b/ffmpeg.src/libavcodec/rangecoder.c
deleted file mode 100644
index 730d5a8..0000000
--- a/ffmpeg.src/libavcodec/rangecoder.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Range coder
- * Copyright (c) 2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
- 
-/**
- * @file rangecoder.c
- * Range coder.
- * based upon
- *    "Range encoding: an algorithm for removing redundancy from a digitised
- *                     message.
- *     G. N. N. Martin                  Presented in March 1979 to the Video &
- *                                      Data Recording Conference,
- *     IBM UK Scientific Center         held in Southampton July 24-27 1979."
- *
- */
-
-#include <string.h>
-
-#include "avcodec.h"
-#include "common.h"
-#include "rangecoder.h"
-
-
-void ff_init_range_encoder(RangeCoder *c, uint8_t *buf, int buf_size){
-    c->bytestream_start= 
-    c->bytestream= buf;
-    c->bytestream_end= buf + buf_size;
-
-    c->low= 0;
-    c->range= 0xFF00;
-    c->outstanding_count= 0;
-    c->outstanding_byte= -1;
-}
-
-void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf, int buf_size){
-    /* cast to avoid compiler warning */
-    ff_init_range_encoder(c, (uint8_t *) buf, buf_size);
-
-    c->low =(*c->bytestream++)<<8;
-    c->low+= *c->bytestream++;
-}
-
-void ff_build_rac_states(RangeCoder *c, int factor, int max_p){
-    const int64_t one= 1LL<<32;
-    int64_t p;
-    int last_p8, p8, i;
-
-    memset(c->zero_state, 0, sizeof(c->zero_state));
-    memset(c-> one_state, 0, sizeof(c-> one_state));
-
-#if 0
-    for(i=1; i<256; i++){
-        if(c->one_state[i]) 
-            continue;
-        
-        p= (i*one + 128) >> 8;
-        last_p8= i;
-        for(;;){
-            p+= ((one-p)*factor + one/2) >> 32;
-            p8= (256*p + one/2) >> 32; //FIXME try without the one
-            if(p8 <= last_p8) p8= last_p8+1;
-            if(p8 > max_p) p8= max_p;
-            if(p8 < last_p8)
-                break;
-            c->one_state[last_p8]=     p8;
-            if(p8 == last_p8)
-                break;
-            last_p8= p8;
-        }
-    }
-#endif
-#if 1
-    last_p8= 0;
-    p= one/2;
-    for(i=0; i<128; i++){
-        p8= (256*p + one/2) >> 32; //FIXME try without the one
-        if(p8 <= last_p8) p8= last_p8+1;
-        if(last_p8 && last_p8<256 && p8<=max_p)
-            c->one_state[last_p8]= p8;
-        
-        p+= ((one-p)*factor + one/2) >> 32;
-        last_p8= p8;
-    }
-#endif
-    for(i=256-max_p; i<=max_p; i++){
-        if(c->one_state[i]) 
-            continue;
-
-        p= (i*one + 128) >> 8;
-        p+= ((one-p)*factor + one/2) >> 32;
-        p8= (256*p + one/2) >> 32; //FIXME try without the one
-        if(p8 <= i) p8= i+1;
-        if(p8 > max_p) p8= max_p;
-        c->one_state[    i]=     p8;
-    }
-    
-    for(i=0; i<256; i++)
-        c->zero_state[i]= 256-c->one_state[256-i];
-#if 0
-    for(i=0; i<256; i++)
-        av_log(NULL, AV_LOG_DEBUG, "%3d %3d\n", i, c->one_state[i]);
-#endif
-}
-
-/**
- *
- * @return the number of bytes written
- */
-int ff_rac_terminate(RangeCoder *c){
-    c->range=0xFF;
-    c->low +=0xFF;
-    renorm_encoder(c);
-    c->range=0xFF;
-    renorm_encoder(c);
-
-    assert(c->low   == 0);
-    assert(c->range >= 0x100);
-
-    return c->bytestream - c->bytestream_start;
-}
-
-#if 0 //selftest
-#define SIZE 10240
-int main(){
-    RangeCoder c;
-    uint8_t b[9*SIZE];
-    uint8_t r[9*SIZE];
-    int i;
-    uint8_t state[10]= {0};
-    
-    ff_init_range_encoder(&c, b, SIZE);
-    ff_build_rac_states(&c, 0.05*(1LL<<32), 128+64+32+16);
-    
-    memset(state, 128, sizeof(state));
-
-    for(i=0; i<SIZE; i++){
-        r[i]= random()%7;
-    }
-    
-  
-    for(i=0; i<SIZE; i++){
-START_TIMER
-        put_rac(&c, state, r[i]&1);
-STOP_TIMER("put_rac")
-    }
-
-    ff_put_rac_terminate(&c);
-    
-    ff_init_range_decoder(&c, b, SIZE);
-    
-    memset(state, 128, sizeof(state));
-    
-    for(i=0; i<SIZE; i++){
-START_TIMER
-        if( (r[i]&1) != get_rac(&c, state) )
-            av_log(NULL, AV_LOG_DEBUG, "rac failure at %d\n", i);
-STOP_TIMER("get_rac")
-    }
-    
-    return 0;
-}
-
-#endif
diff --git a/ffmpeg.src/libavcodec/rangecoder.h b/ffmpeg.src/libavcodec/rangecoder.h
deleted file mode 100644
index 6fd7b43..0000000
--- a/ffmpeg.src/libavcodec/rangecoder.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Range coder
- * Copyright (c) 2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
- 
-/**
- * @file rangecoder.h
- * Range coder.
- */
-
-typedef struct RangeCoder{
-    int low;
-    int range;
-    int outstanding_count;
-    int outstanding_byte;
-    uint8_t zero_state[256];
-    uint8_t  one_state[256];
-    uint8_t *bytestream_start;
-    uint8_t *bytestream;
-    uint8_t *bytestream_end;
-}RangeCoder;
-
-void ff_init_range_encoder(RangeCoder *c, uint8_t *buf, int buf_size);
-void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf, int buf_size);
-int ff_rac_terminate(RangeCoder *c);
-void ff_build_rac_states(RangeCoder *c, int factor, int max_p);
-
-static inline void renorm_encoder(RangeCoder *c){
-    //FIXME optimize
-    while(c->range < 0x100){
-        if(c->outstanding_byte < 0){
-            c->outstanding_byte= c->low>>8;
-        }else if(c->low <= 0xFF00){
-            *c->bytestream++ = c->outstanding_byte;
-            for(;c->outstanding_count; c->outstanding_count--)
-                *c->bytestream++ = 0xFF;
-            c->outstanding_byte= c->low>>8;
-        }else if(c->low >= 0x10000){
-            *c->bytestream++ = c->outstanding_byte + 1;
-            for(;c->outstanding_count; c->outstanding_count--)
-                *c->bytestream++ = 0x00;
-            c->outstanding_byte= (c->low>>8) & 0xFF;
-        }else{
-            c->outstanding_count++;
-        }
-        
-        c->low = (c->low & 0xFF)<<8;
-        c->range <<= 8;
-    }
-}
-
-static inline void put_rac(RangeCoder *c, uint8_t * const state, int bit){
-    int range1= (c->range * (*state)) >> 8;
-
-    assert(*state);
-    assert(range1 < c->range);
-    assert(range1 > 0);
-    if(!bit){
-        c->range -= range1;
-        *state= c->zero_state[*state];
-    }else{
-        c->low += c->range - range1;
-        c->range = range1;
-        *state= c->one_state[*state];
-    }
-    
-    renorm_encoder(c);
-}
-
-static inline void refill(RangeCoder *c){
-    if(c->range < 0x100){
-        c->range <<= 8;
-        c->low <<= 8;
-        if(c->bytestream < c->bytestream_end)
-            c->low+= c->bytestream[0];
-        c->bytestream++;
-    }
-}
-
-static inline int get_rac(RangeCoder *c, uint8_t * const state){
-    int range1= (c->range * (*state)) >> 8;
-    int attribute_unused one_mask;
-    
-    c->range -= range1;
-#if 1
-    if(c->low < c->range){
-        *state= c->zero_state[*state];
-        refill(c);
-        return 0;
-    }else{
-        c->low -= c->range;
-        *state= c->one_state[*state];
-        c->range = range1;
-        refill(c);
-        return 1;
-    }
-#else
-    one_mask= (c->range - c->low-1)>>31;
-    
-    c->low -= c->range & one_mask;
-    c->range += (range1 - c->range) & one_mask;
-    
-    *state= c->zero_state[(*state) + (256&one_mask)];
-    
-    refill(c);
-
-    return one_mask&1;
-#endif
-}
-
diff --git a/ffmpeg.src/libavcodec/ratecontrol.c b/ffmpeg.src/libavcodec/ratecontrol.c
deleted file mode 100644
index 0fc9caa..0000000
--- a/ffmpeg.src/libavcodec/ratecontrol.c
+++ /dev/null
@@ -1,886 +0,0 @@
-/*
- * Rate control for video encoders
- *
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file ratecontrol.c
- * Rate control for video encoders.
- */ 
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-
-#undef NDEBUG // allways check asserts, the speed effect is far too small to disable them
-#include <assert.h>
-
-#ifndef M_E
-#define M_E 2.718281828
-#endif
-
-static int init_pass2(MpegEncContext *s);
-static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_factor, int frame_num);
-
-void ff_write_pass1_stats(MpegEncContext *s){
-    snprintf(s->avctx->stats_out, 256, "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d;\n",
-            s->current_picture_ptr->display_picture_number, s->current_picture_ptr->coded_picture_number, s->pict_type, 
-            s->current_picture.quality, s->i_tex_bits, s->p_tex_bits, s->mv_bits, s->misc_bits, 
-            s->f_code, s->b_code, s->current_picture.mc_mb_var_sum, s->current_picture.mb_var_sum, s->i_count);
-}
-
-int ff_rate_control_init(MpegEncContext *s)
-{
-    RateControlContext *rcc= &s->rc_context;
-    int i;
-    emms_c();
-
-    for(i=0; i<5; i++){
-        rcc->pred[i].coeff= FF_QP2LAMBDA * 7.0;
-        rcc->pred[i].count= 1.0;
-    
-        rcc->pred[i].decay= 0.4;
-        rcc->i_cplx_sum [i]=
-        rcc->p_cplx_sum [i]=
-        rcc->mv_bits_sum[i]=
-        rcc->qscale_sum [i]=
-        rcc->frame_count[i]= 1; // 1 is better cuz of 1/0 and such
-        rcc->last_qscale_for[i]=FF_QP2LAMBDA * 5;
-    }
-    rcc->buffer_index= s->avctx->rc_initial_buffer_occupancy;
-
-    if(s->flags&CODEC_FLAG_PASS2){
-        int i;
-        char *p;
-
-        /* find number of pics */
-        p= s->avctx->stats_in;
-        for(i=-1; p; i++){
-            p= strchr(p+1, ';');
-        }
-        i+= s->max_b_frames;
-        if(i<=0 || i>=INT_MAX / sizeof(RateControlEntry))
-            return -1;
-        rcc->entry = (RateControlEntry*)av_mallocz(i*sizeof(RateControlEntry));
-        rcc->num_entries= i;
-        
-        /* init all to skipped p frames (with b frames we might have a not encoded frame at the end FIXME) */
-        for(i=0; i<rcc->num_entries; i++){
-            RateControlEntry *rce= &rcc->entry[i];
-            rce->pict_type= rce->new_pict_type=P_TYPE;
-            rce->qscale= rce->new_qscale=FF_QP2LAMBDA * 2;
-            rce->misc_bits= s->mb_num + 10;
-            rce->mb_var_sum= s->mb_num*100;
-        }        
-        
-        /* read stats */
-        p= s->avctx->stats_in;
-        for(i=0; i<rcc->num_entries - s->max_b_frames; i++){
-            RateControlEntry *rce;
-            int picture_number;
-            int e;
-            char *next;
-
-            next= strchr(p, ';');
-            if(next){
-                (*next)=0; //sscanf in unbelieavle slow on looong strings //FIXME copy / dont write
-                next++;
-            }
-            e= sscanf(p, " in:%d ", &picture_number);
-
-            assert(picture_number >= 0);
-            assert(picture_number < rcc->num_entries);
-            rce= &rcc->entry[picture_number];
-
-            e+=sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d",
-                   &rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits, &rce->mv_bits, &rce->misc_bits, 
-                   &rce->f_code, &rce->b_code, &rce->mc_mb_var_sum, &rce->mb_var_sum, &rce->i_count);
-            if(e!=12){
-                av_log(s->avctx, AV_LOG_ERROR, "statistics are damaged at line %d, parser out=%d\n", i, e);
-                return -1;
-            }
-            p= next;
-        }
-        
-        if(init_pass2(s) < 0) return -1;
-    }
-     
-    if(!(s->flags&CODEC_FLAG_PASS2)){
-
-        rcc->short_term_qsum=0.001;
-        rcc->short_term_qcount=0.001;
-    
-        rcc->pass1_rc_eq_output_sum= 0.001;
-        rcc->pass1_wanted_bits=0.001;
-        
-        /* init stuff with the user specified complexity */
-        if(s->avctx->rc_initial_cplx){
-            for(i=0; i<60*30; i++){
-                double bits= s->avctx->rc_initial_cplx * (i/10000.0 + 1.0)*s->mb_num;
-                RateControlEntry rce;
-                double q;
-                
-                if     (i%((s->gop_size+3)/4)==0) rce.pict_type= I_TYPE;
-                else if(i%(s->max_b_frames+1))    rce.pict_type= B_TYPE;
-                else                              rce.pict_type= P_TYPE;
-
-                rce.new_pict_type= rce.pict_type;
-                rce.mc_mb_var_sum= bits*s->mb_num/100000;
-                rce.mb_var_sum   = s->mb_num;
-                rce.qscale   = FF_QP2LAMBDA * 2;
-                rce.f_code   = 2;
-                rce.b_code   = 1;
-                rce.misc_bits= 1;
-
-                if(s->pict_type== I_TYPE){
-                    rce.i_count   = s->mb_num;
-                    rce.i_tex_bits= bits;
-                    rce.p_tex_bits= 0;
-                    rce.mv_bits= 0;
-                }else{
-                    rce.i_count   = 0; //FIXME we do know this approx
-                    rce.i_tex_bits= 0;
-                    rce.p_tex_bits= bits*0.9;
-                    rce.mv_bits= bits*0.1;
-                }
-                rcc->i_cplx_sum [rce.pict_type] += rce.i_tex_bits*rce.qscale;
-                rcc->p_cplx_sum [rce.pict_type] += rce.p_tex_bits*rce.qscale;
-                rcc->mv_bits_sum[rce.pict_type] += rce.mv_bits;
-                rcc->frame_count[rce.pict_type] ++;
-
-                bits= rce.i_tex_bits + rce.p_tex_bits;
-
-                q= get_qscale(s, &rce, rcc->pass1_wanted_bits/rcc->pass1_rc_eq_output_sum, i);
-                rcc->pass1_wanted_bits+= s->bit_rate/(1/av_q2d(s->avctx->time_base)); //FIXME missbehaves a little for variable fps
-            }
-        }
-
-    }
-    
-    return 0;
-}
-
-void ff_rate_control_uninit(MpegEncContext *s)
-{
-    RateControlContext *rcc= &s->rc_context;
-    emms_c();
-
-    av_freep(&rcc->entry);
-}
-
-static inline double qp2bits(RateControlEntry *rce, double qp){
-    if(qp<=0.0){
-        av_log(NULL, AV_LOG_ERROR, "qp<=0.0\n");
-    }
-    return rce->qscale * (double)(rce->i_tex_bits + rce->p_tex_bits+1)/ qp;
-}
-
-static inline double bits2qp(RateControlEntry *rce, double bits){
-    if(bits<0.9){
-        av_log(NULL, AV_LOG_ERROR, "bits<0.9\n");
-    }
-    return rce->qscale * (double)(rce->i_tex_bits + rce->p_tex_bits+1)/ bits;
-}
-    
-int ff_vbv_update(MpegEncContext *s, int frame_size){
-    RateControlContext *rcc= &s->rc_context;
-    const double fps= 1/av_q2d(s->avctx->time_base);
-    const int buffer_size= s->avctx->rc_buffer_size;
-    const double min_rate= s->avctx->rc_min_rate/fps;
-    const double max_rate= s->avctx->rc_max_rate/fps;
-    
-//printf("%d %f %d %f %f\n", buffer_size, rcc->buffer_index, frame_size, min_rate, max_rate);
-    if(buffer_size){
-        int left;
-
-        rcc->buffer_index-= frame_size;
-        if(rcc->buffer_index < 0){
-            av_log(s->avctx, AV_LOG_ERROR, "rc buffer underflow\n");
-            rcc->buffer_index= 0;
-        }
-
-        left= buffer_size - rcc->buffer_index - 1;
-        rcc->buffer_index += clip(left, min_rate, max_rate);
-
-        if(rcc->buffer_index > buffer_size){
-            int stuffing= ceil((rcc->buffer_index - buffer_size)/8);
-            
-            if(stuffing < 4 && s->codec_id == CODEC_ID_MPEG4)
-                stuffing=4;
-            rcc->buffer_index -= 8*stuffing;
-            
-            if(s->avctx->debug & FF_DEBUG_RC)
-                av_log(s->avctx, AV_LOG_DEBUG, "stuffing %d bytes\n", stuffing);
-
-            return stuffing;
-        }
-    }
-    return 0;
-}
-
-/**
- * modifies the bitrate curve from pass1 for one frame
- */
-static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_factor, int frame_num){
-    RateControlContext *rcc= &s->rc_context;
-    AVCodecContext *a= s->avctx;
-    double q, bits;
-    const int pict_type= rce->new_pict_type;
-    const double mb_num= s->mb_num;  
-    int i;
-
-    double const_values[]={
-        M_PI,
-        M_E,
-        rce->i_tex_bits*rce->qscale,
-        rce->p_tex_bits*rce->qscale,
-        (rce->i_tex_bits + rce->p_tex_bits)*(double)rce->qscale,
-        rce->mv_bits/mb_num,
-        rce->pict_type == B_TYPE ? (rce->f_code + rce->b_code)*0.5 : rce->f_code,
-        rce->i_count/mb_num,
-        rce->mc_mb_var_sum/mb_num,
-        rce->mb_var_sum/mb_num,
-        rce->pict_type == I_TYPE,
-        rce->pict_type == P_TYPE,
-        rce->pict_type == B_TYPE,
-        rcc->qscale_sum[pict_type] / (double)rcc->frame_count[pict_type],
-        a->qcompress,
-/*        rcc->last_qscale_for[I_TYPE],
-        rcc->last_qscale_for[P_TYPE],
-        rcc->last_qscale_for[B_TYPE],
-        rcc->next_non_b_qscale,*/
-        rcc->i_cplx_sum[I_TYPE] / (double)rcc->frame_count[I_TYPE],
-        rcc->i_cplx_sum[P_TYPE] / (double)rcc->frame_count[P_TYPE],
-        rcc->p_cplx_sum[P_TYPE] / (double)rcc->frame_count[P_TYPE],
-        rcc->p_cplx_sum[B_TYPE] / (double)rcc->frame_count[B_TYPE],
-        (rcc->i_cplx_sum[pict_type] + rcc->p_cplx_sum[pict_type]) / (double)rcc->frame_count[pict_type],
-        0
-    };
-    static const char *const_names[]={
-        "PI",
-        "E",
-        "iTex",
-        "pTex",
-        "tex",
-        "mv",
-        "fCode",
-        "iCount",
-        "mcVar",
-        "var",
-        "isI",
-        "isP",
-        "isB",
-        "avgQP",
-        "qComp",
-/*        "lastIQP",
-        "lastPQP",
-        "lastBQP",
-        "nextNonBQP",*/
-        "avgIITex",
-        "avgPITex",
-        "avgPPTex",
-        "avgBPTex",
-        "avgTex",
-        NULL
-    };
-    static double (*func1[])(void *, double)={
-        (void *)bits2qp,
-        (void *)qp2bits,
-        NULL
-    };
-    static const char *func1_names[]={
-        "bits2qp",
-        "qp2bits",
-        NULL
-    };
-
-    bits= ff_eval(s->avctx->rc_eq, const_values, const_names, func1, func1_names, NULL, NULL, rce);
-    
-    rcc->pass1_rc_eq_output_sum+= bits;
-    bits*=rate_factor;
-    if(bits<0.0) bits=0.0;
-    bits+= 1.0; //avoid 1/0 issues
-    
-    /* user override */
-    for(i=0; i<s->avctx->rc_override_count; i++){
-        RcOverride *rco= s->avctx->rc_override;
-        if(rco[i].start_frame > frame_num) continue;
-        if(rco[i].end_frame   < frame_num) continue;
-    
-        if(rco[i].qscale) 
-            bits= qp2bits(rce, rco[i].qscale); //FIXME move at end to really force it?
-        else
-            bits*= rco[i].quality_factor;
-    }
-
-    q= bits2qp(rce, bits);
-    
-    /* I/B difference */
-    if     (pict_type==I_TYPE && s->avctx->i_quant_factor<0.0)
-        q= -q*s->avctx->i_quant_factor + s->avctx->i_quant_offset;
-    else if(pict_type==B_TYPE && s->avctx->b_quant_factor<0.0)
-        q= -q*s->avctx->b_quant_factor + s->avctx->b_quant_offset;
-        
-    return q;
-}
-
-static double get_diff_limited_q(MpegEncContext *s, RateControlEntry *rce, double q){
-    RateControlContext *rcc= &s->rc_context;
-    AVCodecContext *a= s->avctx;
-    const int pict_type= rce->new_pict_type;
-    const double last_p_q    = rcc->last_qscale_for[P_TYPE];
-    const double last_non_b_q= rcc->last_qscale_for[rcc->last_non_b_pict_type];
-    
-    if     (pict_type==I_TYPE && (a->i_quant_factor>0.0 || rcc->last_non_b_pict_type==P_TYPE))
-        q= last_p_q    *ABS(a->i_quant_factor) + a->i_quant_offset;
-    else if(pict_type==B_TYPE && a->b_quant_factor>0.0)
-        q= last_non_b_q*    a->b_quant_factor  + a->b_quant_offset;
-
-    /* last qscale / qdiff stuff */
-    if(rcc->last_non_b_pict_type==pict_type || pict_type!=I_TYPE){
-        double last_q= rcc->last_qscale_for[pict_type];
-        const int maxdiff= FF_QP2LAMBDA * a->max_qdiff;
-
-        if     (q > last_q + maxdiff) q= last_q + maxdiff;
-        else if(q < last_q - maxdiff) q= last_q - maxdiff;
-    }
-
-    rcc->last_qscale_for[pict_type]= q; //Note we cant do that after blurring
-    
-    if(pict_type!=B_TYPE)
-        rcc->last_non_b_pict_type= pict_type;
-
-    return q;
-}
-
-/**
- * gets the qmin & qmax for pict_type
- */
-static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pict_type){
-    int qmin= s->avctx->lmin;                                                       
-    int qmax= s->avctx->lmax;
-    
-    assert(qmin <= qmax);
-
-    if(pict_type==B_TYPE){
-        qmin= (int)(qmin*ABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5);
-        qmax= (int)(qmax*ABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5);
-    }else if(pict_type==I_TYPE){
-        qmin= (int)(qmin*ABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5);
-        qmax= (int)(qmax*ABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5);
-    }
-
-    qmin= clip(qmin, 1, FF_LAMBDA_MAX);
-    qmax= clip(qmax, 1, FF_LAMBDA_MAX);
-
-    if(qmax<qmin) qmax= qmin;
-    
-    *qmin_ret= qmin;
-    *qmax_ret= qmax;
-}
-
-static double modify_qscale(MpegEncContext *s, RateControlEntry *rce, double q, int frame_num){
-    RateControlContext *rcc= &s->rc_context;
-    int qmin, qmax;
-    double bits;
-    const int pict_type= rce->new_pict_type;
-    const double buffer_size= s->avctx->rc_buffer_size;
-    const double fps= 1/av_q2d(s->avctx->time_base);
-    const double min_rate= s->avctx->rc_min_rate / fps;
-    const double max_rate= s->avctx->rc_max_rate / fps;
-    
-    get_qminmax(&qmin, &qmax, s, pict_type);
-
-    /* modulation */
-    if(s->avctx->rc_qmod_freq && frame_num%s->avctx->rc_qmod_freq==0 && pict_type==P_TYPE)
-        q*= s->avctx->rc_qmod_amp;
-
-    bits= qp2bits(rce, q);
-//printf("q:%f\n", q);
-    /* buffer overflow/underflow protection */
-    if(buffer_size){
-        double expected_size= rcc->buffer_index;
-        double q_limit;
-
-        if(min_rate){
-            double d= 2*(buffer_size - expected_size)/buffer_size;
-            if(d>1.0) d=1.0;
-            else if(d<0.0001) d=0.0001;
-            q*= pow(d, 1.0/s->avctx->rc_buffer_aggressivity);
-
-            q_limit= bits2qp(rce, FFMAX((min_rate - buffer_size + rcc->buffer_index)*3, 1));
-            if(q > q_limit){
-                if(s->avctx->debug&FF_DEBUG_RC){
-                    av_log(s->avctx, AV_LOG_DEBUG, "limiting QP %f -> %f\n", q, q_limit);
-                }
-                q= q_limit;
-            }
-        }
-
-        if(max_rate){
-            double d= 2*expected_size/buffer_size;
-            if(d>1.0) d=1.0;
-            else if(d<0.0001) d=0.0001;
-            q/= pow(d, 1.0/s->avctx->rc_buffer_aggressivity);
-
-            q_limit= bits2qp(rce, FFMAX(rcc->buffer_index/3, 1));
-            if(q < q_limit){
-                if(s->avctx->debug&FF_DEBUG_RC){
-                    av_log(s->avctx, AV_LOG_DEBUG, "limiting QP %f -> %f\n", q, q_limit);
-                }
-                q= q_limit;
-            }
-        }
-    }
-//printf("q:%f max:%f min:%f size:%f index:%d bits:%f agr:%f\n", q,max_rate, min_rate, buffer_size, rcc->buffer_index, bits, s->avctx->rc_buffer_aggressivity);
-    if(s->avctx->rc_qsquish==0.0 || qmin==qmax){
-        if     (q<qmin) q=qmin;
-        else if(q>qmax) q=qmax;
-    }else{
-        double min2= log(qmin);
-        double max2= log(qmax);
-        
-        q= log(q);
-        q= (q - min2)/(max2-min2) - 0.5;
-        q*= -4.0;
-        q= 1.0/(1.0 + exp(q));
-        q= q*(max2-min2) + min2;
-        
-        q= exp(q);
-    }
-    
-    return q;
-}
-
-//----------------------------------
-// 1 Pass Code
-
-static double predict_size(Predictor *p, double q, double var)
-{
-     return p->coeff*var / (q*p->count);
-}
-
-/*
-static double predict_qp(Predictor *p, double size, double var)
-{
-//printf("coeff:%f, count:%f, var:%f, size:%f//\n", p->coeff, p->count, var, size);
-     return p->coeff*var / (size*p->count);
-}
-*/
-
-static void update_predictor(Predictor *p, double q, double var, double size)
-{
-    double new_coeff= size*q / (var + 1);
-    if(var<10) return;
-
-    p->count*= p->decay;
-    p->coeff*= p->decay;
-    p->count++;
-    p->coeff+= new_coeff;
-}
-
-static void adaptive_quantization(MpegEncContext *s, double q){
-    int i;
-    const float lumi_masking= s->avctx->lumi_masking / (128.0*128.0);
-    const float dark_masking= s->avctx->dark_masking / (128.0*128.0);
-    const float temp_cplx_masking= s->avctx->temporal_cplx_masking;
-    const float spatial_cplx_masking = s->avctx->spatial_cplx_masking;
-    const float p_masking = s->avctx->p_masking;
-    const float border_masking = s->avctx->border_masking;
-    float bits_sum= 0.0;
-    float cplx_sum= 0.0;
-    float cplx_tab[s->mb_num];
-    float bits_tab[s->mb_num];
-    const int qmin= s->avctx->mb_lmin;
-    const int qmax= s->avctx->mb_lmax;
-    Picture * const pic= &s->current_picture;
-    const int mb_width = s->mb_width;
-    const int mb_height = s->mb_height;
-    
-    for(i=0; i<s->mb_num; i++){
-        const int mb_xy= s->mb_index2xy[i];
-        float temp_cplx= sqrt(pic->mc_mb_var[mb_xy]); //FIXME merge in pow()
-        float spat_cplx= sqrt(pic->mb_var[mb_xy]);
-        const int lumi= pic->mb_mean[mb_xy];
-        float bits, cplx, factor;
-        int mb_x = mb_xy % s->mb_stride;
-        int mb_y = mb_xy / s->mb_stride;
-        int mb_distance;
-        float mb_factor = 0.0;
-#if 0        
-        if(spat_cplx < q/3) spat_cplx= q/3; //FIXME finetune
-        if(temp_cplx < q/3) temp_cplx= q/3; //FIXME finetune
-#endif   
-        if(spat_cplx < 4) spat_cplx= 4; //FIXME finetune
-        if(temp_cplx < 4) temp_cplx= 4; //FIXME finetune
-
-        if((s->mb_type[mb_xy]&CANDIDATE_MB_TYPE_INTRA)){//FIXME hq mode 
-            cplx= spat_cplx;
-            factor= 1.0 + p_masking;
-        }else{
-            cplx= temp_cplx;
-            factor= pow(temp_cplx, - temp_cplx_masking);
-        }
-        factor*=pow(spat_cplx, - spatial_cplx_masking);
-
-        if(lumi>127)
-            factor*= (1.0 - (lumi-128)*(lumi-128)*lumi_masking);
-        else
-            factor*= (1.0 - (lumi-128)*(lumi-128)*dark_masking);
-
-        if(mb_x < mb_width/5){
-            mb_distance = mb_width/5 - mb_x;
-            mb_factor = (float)mb_distance / (float)(mb_width/5);
-        }else if(mb_x > 4*mb_width/5){
-            mb_distance = mb_x - 4*mb_width/5;
-            mb_factor = (float)mb_distance / (float)(mb_width/5);
-        }
-        if(mb_y < mb_height/5){
-            mb_distance = mb_height/5 - mb_y;
-            mb_factor = FFMAX(mb_factor, (float)mb_distance / (float)(mb_height/5));
-        }else if(mb_y > 4*mb_height/5){
-            mb_distance = mb_y - 4*mb_height/5;
-            mb_factor = FFMAX(mb_factor, (float)mb_distance / (float)(mb_height/5));
-        }
-
-        factor*= 1.0 - border_masking*mb_factor;
-        
-        if(factor<0.00001) factor= 0.00001;
-        
-        bits= cplx*factor;
-        cplx_sum+= cplx;
-        bits_sum+= bits;
-        cplx_tab[i]= cplx;
-        bits_tab[i]= bits;
-    }
-
-    /* handle qmin/qmax cliping */
-    if(s->flags&CODEC_FLAG_NORMALIZE_AQP){
-        float factor= bits_sum/cplx_sum;
-        for(i=0; i<s->mb_num; i++){
-            float newq= q*cplx_tab[i]/bits_tab[i];
-            newq*= factor;
-
-            if     (newq > qmax){
-                bits_sum -= bits_tab[i];
-                cplx_sum -= cplx_tab[i]*q/qmax;
-            }
-            else if(newq < qmin){
-                bits_sum -= bits_tab[i];
-                cplx_sum -= cplx_tab[i]*q/qmin;
-            }
-        }
-        if(bits_sum < 0.001) bits_sum= 0.001;
-        if(cplx_sum < 0.001) cplx_sum= 0.001;
-    }
-   
-    for(i=0; i<s->mb_num; i++){
-        const int mb_xy= s->mb_index2xy[i];
-        float newq= q*cplx_tab[i]/bits_tab[i];
-        int intq;
-
-        if(s->flags&CODEC_FLAG_NORMALIZE_AQP){
-            newq*= bits_sum/cplx_sum;
-        }
-
-        intq= (int)(newq + 0.5);
-
-        if     (intq > qmax) intq= qmax;
-        else if(intq < qmin) intq= qmin;
-//if(i%s->mb_width==0) printf("\n");
-//printf("%2d%3d ", intq, ff_sqrt(s->mc_mb_var[i]));
-        s->lambda_table[mb_xy]= intq;
-    }
-}
-//FIXME rd or at least approx for dquant
-
-float ff_rate_estimate_qscale(MpegEncContext *s)
-{
-    float q;
-    int qmin, qmax;
-    float br_compensation;
-    double diff;
-    double short_term_q;
-    double fps;
-    int picture_number= s->picture_number;
-    int64_t wanted_bits;
-    RateControlContext *rcc= &s->rc_context;
-    AVCodecContext *a= s->avctx;
-    RateControlEntry local_rce, *rce;
-    double bits;
-    double rate_factor;
-    int var;
-    const int pict_type= s->pict_type;
-    Picture * const pic= &s->current_picture;
-    emms_c();
-
-    get_qminmax(&qmin, &qmax, s, pict_type);
-
-    fps= 1/av_q2d(s->avctx->time_base);
-//printf("input_pic_num:%d pic_num:%d frame_rate:%d\n", s->input_picture_number, s->picture_number, s->frame_rate);
-        /* update predictors */
-    if(picture_number>2){
-        const int last_var= s->last_pict_type == I_TYPE ? rcc->last_mb_var_sum : rcc->last_mc_mb_var_sum;
-        update_predictor(&rcc->pred[s->last_pict_type], rcc->last_qscale, sqrt(last_var), s->frame_bits);
-    }
-
-    if(s->flags&CODEC_FLAG_PASS2){
-        assert(picture_number>=0);
-        assert(picture_number<rcc->num_entries);
-        rce= &rcc->entry[picture_number];
-        wanted_bits= rce->expected_bits;
-    }else{
-        rce= &local_rce;
-        wanted_bits= (uint64_t)(s->bit_rate*(double)picture_number/fps);
-    }
-
-    diff= s->total_bits - wanted_bits;
-    br_compensation= (a->bit_rate_tolerance - diff)/a->bit_rate_tolerance;
-    if(br_compensation<=0.0) br_compensation=0.001;
-
-    var= pict_type == I_TYPE ? pic->mb_var_sum : pic->mc_mb_var_sum;
-    
-    short_term_q = 0; /* avoid warning */
-    if(s->flags&CODEC_FLAG_PASS2){
-        if(pict_type!=I_TYPE)
-            assert(pict_type == rce->new_pict_type);
-
-        q= rce->new_qscale / br_compensation;
-//printf("%f %f %f last:%d var:%d type:%d//\n", q, rce->new_qscale, br_compensation, s->frame_bits, var, pict_type);
-    }else{
-        rce->pict_type= 
-        rce->new_pict_type= pict_type;
-        rce->mc_mb_var_sum= pic->mc_mb_var_sum;
-        rce->mb_var_sum   = pic->   mb_var_sum;
-        rce->qscale   = FF_QP2LAMBDA * 2;
-        rce->f_code   = s->f_code;
-        rce->b_code   = s->b_code;
-        rce->misc_bits= 1;
-
-        bits= predict_size(&rcc->pred[pict_type], rce->qscale, sqrt(var));
-        if(pict_type== I_TYPE){
-            rce->i_count   = s->mb_num;
-            rce->i_tex_bits= bits;
-            rce->p_tex_bits= 0;
-            rce->mv_bits= 0;
-        }else{
-            rce->i_count   = 0; //FIXME we do know this approx
-            rce->i_tex_bits= 0;
-            rce->p_tex_bits= bits*0.9;
-            
-            rce->mv_bits= bits*0.1;
-        }
-        rcc->i_cplx_sum [pict_type] += rce->i_tex_bits*rce->qscale;
-        rcc->p_cplx_sum [pict_type] += rce->p_tex_bits*rce->qscale;
-        rcc->mv_bits_sum[pict_type] += rce->mv_bits;
-        rcc->frame_count[pict_type] ++;
-
-        bits= rce->i_tex_bits + rce->p_tex_bits;
-        rate_factor= rcc->pass1_wanted_bits/rcc->pass1_rc_eq_output_sum * br_compensation;
-    
-        q= get_qscale(s, rce, rate_factor, picture_number);
-
-        assert(q>0.0);
-//printf("%f ", q);
-        q= get_diff_limited_q(s, rce, q);
-//printf("%f ", q);
-        assert(q>0.0);
-
-        if(pict_type==P_TYPE || s->intra_only){ //FIXME type dependant blur like in 2-pass
-            rcc->short_term_qsum*=a->qblur;
-            rcc->short_term_qcount*=a->qblur;
-
-            rcc->short_term_qsum+= q;
-            rcc->short_term_qcount++;
-//printf("%f ", q);
-            q= short_term_q= rcc->short_term_qsum/rcc->short_term_qcount;
-//printf("%f ", q);
-        }
-        assert(q>0.0);
-        
-        q= modify_qscale(s, rce, q, picture_number);
-
-        rcc->pass1_wanted_bits+= s->bit_rate/fps;
-
-        assert(q>0.0);
-    }
-
-    if(s->avctx->debug&FF_DEBUG_RC){
-        av_log(s->avctx, AV_LOG_DEBUG, "%c qp:%d<%2.1f<%d %d want:%d total:%d comp:%f st_q:%2.2f size:%d var:%d/%d br:%d fps:%d\n",
-        av_get_pict_type_char(pict_type), qmin, q, qmax, picture_number, (int)wanted_bits/1000, (int)s->total_bits/1000,
-        br_compensation, short_term_q, s->frame_bits, pic->mb_var_sum, pic->mc_mb_var_sum, s->bit_rate/1000, (int)fps
-        );
-    }
-
-    if     (q<qmin) q=qmin; 
-    else if(q>qmax) q=qmax;
-
-    if(s->adaptive_quant)
-        adaptive_quantization(s, q);
-    else
-        q= (int)(q + 0.5);
-    
-    rcc->last_qscale= q;
-    rcc->last_mc_mb_var_sum= pic->mc_mb_var_sum;
-    rcc->last_mb_var_sum= pic->mb_var_sum;
-#if 0
-{
-    static int mvsum=0, texsum=0;
-    mvsum += s->mv_bits;
-    texsum += s->i_tex_bits + s->p_tex_bits;
-    printf("%d %d//\n\n", mvsum, texsum);
-}
-#endif
-    return q;
-}
-
-//----------------------------------------------
-// 2-Pass code
-
-static int init_pass2(MpegEncContext *s)
-{
-    RateControlContext *rcc= &s->rc_context;
-    AVCodecContext *a= s->avctx;
-    int i;
-    double fps= 1/av_q2d(s->avctx->time_base);
-    double complexity[5]={0,0,0,0,0};   // aproximate bits at quant=1
-    double avg_quantizer[5];
-    uint64_t const_bits[5]={0,0,0,0,0}; // quantizer idependant bits
-    uint64_t available_bits[5];
-    uint64_t all_const_bits;
-    uint64_t all_available_bits= (uint64_t)(s->bit_rate*(double)rcc->num_entries/fps);
-    double rate_factor=0;
-    double step;
-    //int last_i_frame=-10000000;
-    const int filter_size= (int)(a->qblur*4) | 1;  
-    double expected_bits;
-    double *qscale, *blured_qscale;
-
-    /* find complexity & const_bits & decide the pict_types */
-    for(i=0; i<rcc->num_entries; i++){
-        RateControlEntry *rce= &rcc->entry[i];
-        
-        rce->new_pict_type= rce->pict_type;
-        rcc->i_cplx_sum [rce->pict_type] += rce->i_tex_bits*rce->qscale;
-        rcc->p_cplx_sum [rce->pict_type] += rce->p_tex_bits*rce->qscale;
-        rcc->mv_bits_sum[rce->pict_type] += rce->mv_bits;
-        rcc->frame_count[rce->pict_type] ++;
-
-        complexity[rce->new_pict_type]+= (rce->i_tex_bits+ rce->p_tex_bits)*(double)rce->qscale;
-        const_bits[rce->new_pict_type]+= rce->mv_bits + rce->misc_bits;
-    }
-    all_const_bits= const_bits[I_TYPE] + const_bits[P_TYPE] + const_bits[B_TYPE];
-    
-    if(all_available_bits < all_const_bits){
-        av_log(s->avctx, AV_LOG_ERROR, "requested bitrate is to low\n");
-        return -1;
-    }
-    
-    /* find average quantizers */
-    avg_quantizer[P_TYPE]=0;
-    for(step=256*256; step>0.0000001; step*=0.5){
-        double expected_bits=0;
-        avg_quantizer[P_TYPE]+= step;
-        
-        avg_quantizer[I_TYPE]= avg_quantizer[P_TYPE]*ABS(s->avctx->i_quant_factor) + s->avctx->i_quant_offset;
-        avg_quantizer[B_TYPE]= avg_quantizer[P_TYPE]*ABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
-        
-        expected_bits= 
-            + all_const_bits 
-            + complexity[I_TYPE]/avg_quantizer[I_TYPE]
-            + complexity[P_TYPE]/avg_quantizer[P_TYPE]
-            + complexity[B_TYPE]/avg_quantizer[B_TYPE];
-            
-        if(expected_bits < all_available_bits) avg_quantizer[P_TYPE]-= step;
-//printf("%f %lld %f\n", expected_bits, all_available_bits, avg_quantizer[P_TYPE]);
-    }
-//printf("qp_i:%f, qp_p:%f, qp_b:%f\n", avg_quantizer[I_TYPE],avg_quantizer[P_TYPE],avg_quantizer[B_TYPE]);
-
-    for(i=0; i<5; i++){
-        available_bits[i]= const_bits[i] + complexity[i]/avg_quantizer[i];
-    }
-//printf("%lld %lld %lld %lld\n", available_bits[I_TYPE], available_bits[P_TYPE], available_bits[B_TYPE], all_available_bits);
-        
-    qscale= av_malloc(sizeof(double)*rcc->num_entries);
-    blured_qscale= av_malloc(sizeof(double)*rcc->num_entries);
-
-    for(step=256*256; step>0.0000001; step*=0.5){
-        expected_bits=0;
-        rate_factor+= step;
-        
-        rcc->buffer_index= s->avctx->rc_buffer_size/2;
-
-        /* find qscale */
-        for(i=0; i<rcc->num_entries; i++){
-            qscale[i]= get_qscale(s, &rcc->entry[i], rate_factor, i);
-        }
-        assert(filter_size%2==1);
-
-        /* fixed I/B QP relative to P mode */
-        for(i=rcc->num_entries-1; i>=0; i--){
-            RateControlEntry *rce= &rcc->entry[i];
-            
-            qscale[i]= get_diff_limited_q(s, rce, qscale[i]);
-        }
-
-        /* smooth curve */
-        for(i=0; i<rcc->num_entries; i++){
-            RateControlEntry *rce= &rcc->entry[i];
-            const int pict_type= rce->new_pict_type;
-            int j;
-            double q=0.0, sum=0.0;
-        
-            for(j=0; j<filter_size; j++){
-                int index= i+j-filter_size/2;
-                double d= index-i;
-                double coeff= a->qblur==0 ? 1.0 : exp(-d*d/(a->qblur * a->qblur));
-            
-                if(index < 0 || index >= rcc->num_entries) continue;
-                if(pict_type != rcc->entry[index].new_pict_type) continue;
-                q+= qscale[index] * coeff;
-                sum+= coeff;
-            }
-            blured_qscale[i]= q/sum;
-        }
-    
-        /* find expected bits */
-        for(i=0; i<rcc->num_entries; i++){
-            RateControlEntry *rce= &rcc->entry[i];
-            double bits;
-            rce->new_qscale= modify_qscale(s, rce, blured_qscale[i], i);
-            bits= qp2bits(rce, rce->new_qscale) + rce->mv_bits + rce->misc_bits;
-//printf("%d %f\n", rce->new_bits, blured_qscale[i]);
-            bits += 8*ff_vbv_update(s, bits);
-
-            rce->expected_bits= expected_bits;
-            expected_bits += bits;
-        }
-
-//        printf("%f %d %f\n", expected_bits, (int)all_available_bits, rate_factor);
-        if(expected_bits > all_available_bits) rate_factor-= step;
-    }
-    av_free(qscale);
-    av_free(blured_qscale);
-
-    if(abs(expected_bits/all_available_bits - 1.0) > 0.01 ){
-        av_log(s->avctx, AV_LOG_ERROR, "Error: 2pass curve failed to converge\n");
-        return -1;
-    }
-
-    return 0;
-}
diff --git a/ffmpeg.src/libavcodec/raw.c b/ffmpeg.src/libavcodec/raw.c
deleted file mode 100644
index 4f829fd..0000000
--- a/ffmpeg.src/libavcodec/raw.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Raw Video Codec
- * Copyright (c) 2001 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-/**
- * @file raw.c
- * Raw Video Codec
- */
- 
-#include "avcodec.h"
-
-typedef struct RawVideoContext {
-    unsigned char * buffer;  /* block of memory for holding one frame */
-    unsigned char * p;       /* current position in buffer */
-    int             length;  /* number of bytes in buffer */
-    AVFrame pic;             ///< AVCodecContext.coded_frame
-} RawVideoContext;
-
-typedef struct PixleFormatTag {
-    int pix_fmt;
-    unsigned int fourcc;
-} PixelFormatTag;
-
-const PixelFormatTag pixelFormatTags[] = {
-    { PIX_FMT_YUV420P, MKTAG('I', '4', '2', '0') }, /* Planar formats */
-    { PIX_FMT_YUV420P, MKTAG('I', 'Y', 'U', 'V') },
-    { PIX_FMT_YUV410P, MKTAG('Y', 'U', 'V', '9') },
-    { PIX_FMT_YUV411P, MKTAG('Y', '4', '1', 'B') },
-    { PIX_FMT_YUV422P, MKTAG('Y', '4', '2', 'B') },
-    { PIX_FMT_GRAY8,   MKTAG('Y', '8', '0', '0') },
-    { PIX_FMT_GRAY8,   MKTAG(' ', ' ', 'Y', '8') },
-
-
-    { PIX_FMT_YUV422,  MKTAG('Y', 'U', 'Y', '2') }, /* Packed formats */
-    { PIX_FMT_YUV422,  MKTAG('Y', '4', '2', '2') },
-    { PIX_FMT_UYVY422, MKTAG('U', 'Y', 'V', 'Y') },
-    { PIX_FMT_GRAY8,   MKTAG('G', 'R', 'E', 'Y') },
-
-    { -1, 0 },
-};
-
-static int findPixelFormat(unsigned int fourcc)
-{
-    const PixelFormatTag * tags = pixelFormatTags;
-    while (tags->pix_fmt >= 0) {
-        if (tags->fourcc == fourcc)
-            return tags->pix_fmt;
-        tags++;
-    }
-    return PIX_FMT_YUV420P;
-}
-
-unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat fmt)
-{
-    const PixelFormatTag * tags = pixelFormatTags;
-    while (tags->pix_fmt >= 0) {
-        if (tags->pix_fmt == fmt)
-	    return tags->fourcc;
-	tags++; 
-    }
-    return 0;
-}
-
-/* RAW Decoder Implementation */
-
-static int raw_init_decoder(AVCodecContext *avctx)
-{
-    RawVideoContext *context = avctx->priv_data;
-
-    if (avctx->codec_tag)
-        avctx->pix_fmt = findPixelFormat(avctx->codec_tag);
-    else if (avctx->bits_per_sample){
-        switch(avctx->bits_per_sample){
-        case 15: avctx->pix_fmt= PIX_FMT_RGB555; break;
-        case 16: avctx->pix_fmt= PIX_FMT_RGB565; break;
-        case 24: avctx->pix_fmt= PIX_FMT_BGR24 ; break;
-        case 32: avctx->pix_fmt= PIX_FMT_RGBA32; break;
-        }
-    }
-    
-    context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
-    context->buffer = av_malloc(context->length);
-    context->p      = context->buffer;
-    context->pic.pict_type = FF_I_TYPE;
-    context->pic.key_frame = 1;
-    
-    avctx->coded_frame= &context->pic;
-    
-    if (!context->buffer)
-        return -1;
-   
-    return 0;
-}
-
-static void flip(AVCodecContext *avctx, AVPicture * picture){
-    if(!avctx->codec_tag && avctx->bits_per_sample && picture->linesize[1]==0){
-        picture->data[0] += picture->linesize[0] * (avctx->height-1);
-        picture->linesize[0] *= -1;
-    }
-}
-
-static int raw_decode(AVCodecContext *avctx,
-			    void *data, int *data_size,
-			    uint8_t *buf, int buf_size)
-{
-    RawVideoContext *context = avctx->priv_data;
-    int bytesNeeded;
-
-    AVPicture * picture = (AVPicture *) data;
-
-    /* Early out without copy if packet size == frame size */
-    if (buf_size == context->length  &&  context->p == context->buffer) {
-        avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height);
-        flip(avctx, picture);        
-        *data_size = sizeof(AVPicture);
-        return buf_size;
-    }
-
-    bytesNeeded = context->length - (context->p - context->buffer);
-    if (buf_size < bytesNeeded) {
-        memcpy(context->p, buf, buf_size);
-        context->p += buf_size;
-        return buf_size;
-    }
-
-    memcpy(context->p, buf, bytesNeeded);
-    context->p = context->buffer;
-    avpicture_fill(picture, context->buffer, avctx->pix_fmt, avctx->width, avctx->height);
-    flip(avctx, picture);        
-    *data_size = sizeof(AVPicture);
-    return bytesNeeded;
-}
-
-static int raw_close_decoder(AVCodecContext *avctx)
-{
-    RawVideoContext *context = avctx->priv_data;
-    
-    av_freep(&context->buffer);
-    return 0;
-}
-
-/* RAW Encoder Implementation */
-
-static int raw_init_encoder(AVCodecContext *avctx)
-{
-    avctx->coded_frame = (AVFrame *)avctx->priv_data;
-    avctx->coded_frame->pict_type = FF_I_TYPE;
-    avctx->coded_frame->key_frame = 1;
-    if(!avctx->codec_tag)
-        avctx->codec_tag = avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
-    return 0;
-}
-
-static int raw_encode(AVCodecContext *avctx,
-			    unsigned char *frame, int buf_size, void *data)
-{
-    return avpicture_layout((AVPicture *)data, avctx->pix_fmt, avctx->width,
-                                               avctx->height, frame, buf_size);
-}
-
-#ifdef CONFIG_RAWVIDEO_ENCODER
-AVCodec rawvideo_encoder = {
-    "rawvideo",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_RAWVIDEO,
-    sizeof(AVFrame),
-    raw_init_encoder,
-    raw_encode,
-};
-#endif // CONFIG_RAWVIDEO_ENCODER
-
-AVCodec rawvideo_decoder = {
-    "rawvideo",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_RAWVIDEO,
-    sizeof(RawVideoContext),
-    raw_init_decoder,
-    NULL,
-    raw_close_decoder,
-    raw_decode,
-};
diff --git a/ffmpeg.src/libavcodec/resample.c b/ffmpeg.src/libavcodec/resample.c
deleted file mode 100644
index 77e5f5f..0000000
--- a/ffmpeg.src/libavcodec/resample.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Sample rate convertion for both audio and video
- * Copyright (c) 2000 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file resample.c
- * Sample rate convertion for both audio and video.
- */
-
-#include "avcodec.h"
-
-struct AVResampleContext;
-
-struct ReSampleContext {
-    struct AVResampleContext *resample_context;
-    short *temp[2];
-    int temp_len;
-    float ratio;
-    /* channel convert */
-    int input_channels, output_channels, filter_channels;
-};
-
-/* n1: number of samples */
-static void stereo_to_mono(short *output, short *input, int n1)
-{
-    short *p, *q;
-    int n = n1;
-
-    p = input;
-    q = output;
-    while (n >= 4) {
-        q[0] = (p[0] + p[1]) >> 1;
-        q[1] = (p[2] + p[3]) >> 1;
-        q[2] = (p[4] + p[5]) >> 1;
-        q[3] = (p[6] + p[7]) >> 1;
-        q += 4;
-        p += 8;
-        n -= 4;
-    }
-    while (n > 0) {
-        q[0] = (p[0] + p[1]) >> 1;
-        q++;
-        p += 2;
-        n--;
-    }
-}
-
-/* n1: number of samples */
-static void mono_to_stereo(short *output, short *input, int n1)
-{
-    short *p, *q;
-    int n = n1;
-    int v;
-
-    p = input;
-    q = output;
-    while (n >= 4) {
-        v = p[0]; q[0] = v; q[1] = v;
-        v = p[1]; q[2] = v; q[3] = v;
-        v = p[2]; q[4] = v; q[5] = v;
-        v = p[3]; q[6] = v; q[7] = v;
-        q += 8;
-        p += 4;
-        n -= 4;
-    }
-    while (n > 0) {
-        v = p[0]; q[0] = v; q[1] = v;
-        q += 2;
-        p += 1;
-        n--;
-    }
-}
-
-/* XXX: should use more abstract 'N' channels system */
-static void stereo_split(short *output1, short *output2, short *input, int n)
-{
-    int i;
-
-    for(i=0;i<n;i++) {
-        *output1++ = *input++;
-        *output2++ = *input++;
-    }
-}
-
-static void stereo_mux(short *output, short *input1, short *input2, int n)
-{
-    int i;
-
-    for(i=0;i<n;i++) {
-        *output++ = *input1++;
-        *output++ = *input2++;
-    }
-}
-
-static void ac3_5p1_mux(short *output, short *input1, short *input2, int n)
-{
-    int i;
-    short l,r;
-
-    for(i=0;i<n;i++) {
-      l=*input1++;
-      r=*input2++;
-      *output++ = l;           /* left */
-      *output++ = (l/2)+(r/2); /* center */
-      *output++ = r;           /* right */
-      *output++ = 0;           /* left surround */
-      *output++ = 0;           /* right surroud */
-      *output++ = 0;           /* low freq */
-    }
-}
-
-ReSampleContext *audio_resample_init(int output_channels, int input_channels, 
-                                      int output_rate, int input_rate)
-{
-    ReSampleContext *s;
-    
-    if ( input_channels > 2)
-      {
-	av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported.");
-	return NULL;
-      }
-
-    s = av_mallocz(sizeof(ReSampleContext));
-    if (!s)
-      {
-	av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for resample context.");
-	return NULL;
-      }
-
-    s->ratio = (float)output_rate / (float)input_rate;
-    
-    s->input_channels = input_channels;
-    s->output_channels = output_channels;
-    
-    s->filter_channels = s->input_channels;
-    if (s->output_channels < s->filter_channels)
-        s->filter_channels = s->output_channels;
-
-/*
- * ac3 output is the only case where filter_channels could be greater than 2.
- * input channels can't be greater than 2, so resample the 2 channels and then
- * expand to 6 channels after the resampling.
- */
-    if(s->filter_channels>2)
-      s->filter_channels = 2;
-
-    s->resample_context= av_resample_init(output_rate, input_rate, 16, 10, 0, 1.0);
-    
-    return s;
-}
-
-/* resample audio. 'nb_samples' is the number of input samples */
-/* XXX: optimize it ! */
-int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples)
-{
-    int i, nb_samples1;
-    short *bufin[2];
-    short *bufout[2];
-    short *buftmp2[2], *buftmp3[2];
-    int lenout;
-
-    if (s->input_channels == s->output_channels && s->ratio == 1.0 && 0) {
-        /* nothing to do */
-        memcpy(output, input, nb_samples * s->input_channels * sizeof(short));
-        return nb_samples;
-    }
-
-    /* XXX: move those malloc to resample init code */
-    for(i=0; i<s->filter_channels; i++){
-        bufin[i]= (short*) av_malloc( (nb_samples + s->temp_len) * sizeof(short) );
-        memcpy(bufin[i], s->temp[i], s->temp_len * sizeof(short));
-        buftmp2[i] = bufin[i] + s->temp_len;
-    }
-    
-    /* make some zoom to avoid round pb */
-    lenout= (int)(nb_samples * s->ratio) + 16;
-    bufout[0]= (short*) av_malloc( lenout * sizeof(short) );
-    bufout[1]= (short*) av_malloc( lenout * sizeof(short) );
-
-    if (s->input_channels == 2 &&
-        s->output_channels == 1) {
-        buftmp3[0] = output;
-        stereo_to_mono(buftmp2[0], input, nb_samples);
-    } else if (s->output_channels >= 2 && s->input_channels == 1) {
-        buftmp3[0] = bufout[0];
-        memcpy(buftmp2[0], input, nb_samples*sizeof(short));
-    } else if (s->output_channels >= 2) {
-        buftmp3[0] = bufout[0];
-        buftmp3[1] = bufout[1];
-        stereo_split(buftmp2[0], buftmp2[1], input, nb_samples);
-    } else {
-        buftmp3[0] = output;
-        memcpy(buftmp2[0], input, nb_samples*sizeof(short));
-    }
-
-    nb_samples += s->temp_len;
-
-    /* resample each channel */
-    nb_samples1 = 0; /* avoid warning */
-    for(i=0;i<s->filter_channels;i++) {
-        int consumed;
-        int is_last= i+1 == s->filter_channels;
-
-        nb_samples1 = av_resample(s->resample_context, buftmp3[i], bufin[i], &consumed, nb_samples, lenout, is_last);
-        s->temp_len= nb_samples - consumed;
-        s->temp[i]= av_realloc(s->temp[i], s->temp_len*sizeof(short));
-        memcpy(s->temp[i], bufin[i] + consumed, s->temp_len*sizeof(short));
-    }
-
-    if (s->output_channels == 2 && s->input_channels == 1) {
-        mono_to_stereo(output, buftmp3[0], nb_samples1);
-    } else if (s->output_channels == 2) {
-        stereo_mux(output, buftmp3[0], buftmp3[1], nb_samples1);
-    } else if (s->output_channels == 6) {
-        ac3_5p1_mux(output, buftmp3[0], buftmp3[1], nb_samples1);
-    }
-
-    for(i=0; i<s->filter_channels; i++)
-        av_free(bufin[i]);
-
-    av_free(bufout[0]);
-    av_free(bufout[1]);
-    return nb_samples1;
-}
-
-void audio_resample_close(ReSampleContext *s)
-{
-    av_resample_close(s->resample_context);
-    av_freep(&s->temp[0]);
-    av_freep(&s->temp[1]);
-    av_free(s);
-}
diff --git a/ffmpeg.src/libavcodec/resample2.c b/ffmpeg.src/libavcodec/resample2.c
deleted file mode 100644
index 4c04c3e..0000000
--- a/ffmpeg.src/libavcodec/resample2.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * audio resampling
- * Copyright (c) 2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
- 
-/**
- * @file resample2.c
- * audio resampling
- * @author Michael Niedermayer <michaelni at gmx.at>
- */
-
-#include "avcodec.h"
-#include "common.h"
-#include "dsputil.h"
-
-#if 1
-#define FILTER_SHIFT 15
-
-#define FELEM int16_t
-#define FELEM2 int32_t
-#define FELEM_MAX INT16_MAX
-#define FELEM_MIN INT16_MIN
-#else
-#define FILTER_SHIFT 22
-
-#define FELEM int32_t
-#define FELEM2 int64_t
-#define FELEM_MAX INT32_MAX
-#define FELEM_MIN INT32_MIN
-#endif
-
-
-typedef struct AVResampleContext{
-    FELEM *filter_bank;
-    int filter_length;
-    int ideal_dst_incr;
-    int dst_incr;
-    int index;
-    int frac;
-    int src_incr;
-    int compensation_distance;
-    int phase_shift;
-    int phase_mask;
-    int linear;
-}AVResampleContext;
-
-/**
- * 0th order modified bessel function of the first kind.
- */
-double bessel(double x){
-    double v=1;
-    double t=1;
-    int i;
-    
-    for(i=1; i<50; i++){
-        t *= i;
-        v += pow(x*x/4, i)/(t*t);
-    }
-    return v;
-}
-
-/**
- * builds a polyphase filterbank.
- * @param factor resampling factor
- * @param scale wanted sum of coefficients for each filter
- * @param type 0->cubic, 1->blackman nuttall windowed sinc, 2->kaiser windowed sinc beta=16
- */
-void av_build_filter(FELEM *filter, double factor, int tap_count, int phase_count, int scale, int type){
-    int ph, i, v;
-    double x, y, w, tab[tap_count];
-    const int center= (tap_count-1)/2;
-
-    /* if upsampling, only need to interpolate, no filter */
-    if (factor > 1.0)
-        factor = 1.0;
-
-    for(ph=0;ph<phase_count;ph++) {
-        double norm = 0;
-        double e= 0;
-        for(i=0;i<tap_count;i++) {
-            x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor;
-            if (x == 0) y = 1.0;
-            else        y = sin(x) / x;
-            switch(type){
-            case 0:{
-                const float d= -0.5; //first order derivative = -0.5
-                x = fabs(((double)(i - center) - (double)ph / phase_count) * factor);
-                if(x<1.0) y= 1 - 3*x*x + 2*x*x*x + d*(            -x*x + x*x*x);
-                else      y=                       d*(-4 + 8*x - 5*x*x + x*x*x);
-                break;}
-            case 1:
-                w = 2.0*x / (factor*tap_count) + M_PI;
-                y *= 0.3635819 - 0.4891775 * cos(w) + 0.1365995 * cos(2*w) - 0.0106411 * cos(3*w);
-                break;
-            case 2:
-                w = 2.0*x / (factor*tap_count*M_PI);
-                y *= bessel(16*sqrt(FFMAX(1-w*w, 0)));
-                break;
-            }
-
-            tab[i] = y;
-            norm += y;
-        }
-
-        /* normalize so that an uniform color remains the same */
-        for(i=0;i<tap_count;i++) {
-            v = clip(lrintf(tab[i] * scale / norm + e), FELEM_MIN, FELEM_MAX);
-            filter[ph * tap_count + i] = v;
-            e += tab[i] * scale / norm - v;
-        }
-    }
-}
-
-/**
- * initalizes a audio resampler.
- * note, if either rate is not a integer then simply scale both rates up so they are
- */
-AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff){
-    AVResampleContext *c= av_mallocz(sizeof(AVResampleContext));
-    double factor= FFMIN(out_rate * cutoff / in_rate, 1.0);
-    int phase_count= 1<<phase_shift;
-    
-    c->phase_shift= phase_shift;
-    c->phase_mask= phase_count-1;
-    c->linear= linear;
-
-    c->filter_length= FFMAX((int)ceil(filter_size/factor), 1);
-    c->filter_bank= av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM));
-    av_build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<<FILTER_SHIFT, 1);
-    memcpy(&c->filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM));
-    c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1];
-
-    c->src_incr= out_rate;
-    c->ideal_dst_incr= c->dst_incr= in_rate * phase_count;
-    c->index= -phase_count*((c->filter_length-1)/2);
-
-    return c;
-}
-
-void av_resample_close(AVResampleContext *c){
-    av_freep(&c->filter_bank);
-    av_freep(&c);
-}
-
-/**
- * Compensates samplerate/timestamp drift. The compensation is done by changing
- * the resampler parameters, so no audible clicks or similar distortions ocur
- * @param compensation_distance distance in output samples over which the compensation should be performed
- * @param sample_delta number of output samples which should be output less
- *
- * example: av_resample_compensate(c, 10, 500)
- * here instead of 510 samples only 500 samples would be output
- *
- * note, due to rounding the actual compensation might be slightly different, 
- * especially if the compensation_distance is large and the in_rate used during init is small
- */
-void av_resample_compensate(AVResampleContext *c, int sample_delta, int compensation_distance){
-//    sample_delta += (c->ideal_dst_incr - c->dst_incr)*(int64_t)c->compensation_distance / c->ideal_dst_incr;
-    c->compensation_distance= compensation_distance;
-    c->dst_incr = c->ideal_dst_incr - c->ideal_dst_incr * (int64_t)sample_delta / compensation_distance;
-}
-
-/**
- * resamples.
- * @param src an array of unconsumed samples
- * @param consumed the number of samples of src which have been consumed are returned here
- * @param src_size the number of unconsumed samples available
- * @param dst_size the amount of space in samples available in dst
- * @param update_ctx if this is 0 then the context wont be modified, that way several channels can be resampled with the same context
- * @return the number of samples written in dst or -1 if an error occured
- */
-int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx){
-    int dst_index, i;
-    int index= c->index;
-    int frac= c->frac;
-    int dst_incr_frac= c->dst_incr % c->src_incr;
-    int dst_incr=      c->dst_incr / c->src_incr;
-    int compensation_distance= c->compensation_distance;
-
-  if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){
-        int64_t index2= ((int64_t)index)<<32;
-        int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr;
-        dst_size= FFMIN(dst_size, (src_size-1-index) * (int64_t)c->src_incr / c->dst_incr);
-        
-        for(dst_index=0; dst_index < dst_size; dst_index++){
-            dst[dst_index] = src[index2>>32];
-            index2 += incr;
-        }
-        frac += dst_index * dst_incr_frac;
-        index += dst_index * dst_incr;
-        index += frac / c->src_incr;
-        frac %= c->src_incr;
-  }else{
-    for(dst_index=0; dst_index < dst_size; dst_index++){
-        FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask);
-        int sample_index= index >> c->phase_shift;
-        FELEM2 val=0;
-                
-        if(sample_index < 0){
-            for(i=0; i<c->filter_length; i++)
-                val += src[ABS(sample_index + i) % src_size] * filter[i];
-        }else if(sample_index + c->filter_length > src_size){
-            break;
-        }else if(c->linear){
-            int64_t v=0;
-            int sub_phase= (frac<<8) / c->src_incr;
-            for(i=0; i<c->filter_length; i++){
-                int64_t coeff= filter[i]*(256 - sub_phase) + filter[i + c->filter_length]*sub_phase;
-                v += src[sample_index + i] * coeff;
-            }
-            val= v>>8;
-        }else{
-            for(i=0; i<c->filter_length; i++){
-                val += src[sample_index + i] * (FELEM2)filter[i];
-            }
-        }
-
-        val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;
-        dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val;
-
-        frac += dst_incr_frac;
-        index += dst_incr;
-        if(frac >= c->src_incr){
-            frac -= c->src_incr;
-            index++;
-        }
-
-        if(dst_index + 1 == compensation_distance){
-            compensation_distance= 0;
-            dst_incr_frac= c->ideal_dst_incr % c->src_incr;
-            dst_incr=      c->ideal_dst_incr / c->src_incr;
-        }
-    }
-  }
-    *consumed= FFMAX(index, 0) >> c->phase_shift;
-    if(index>=0) index &= c->phase_mask;
-
-    if(compensation_distance){
-        compensation_distance -= dst_index;
-        assert(compensation_distance > 0);
-    }
-    if(update_ctx){
-        c->frac= frac;
-        c->index= index;
-        c->dst_incr= dst_incr_frac + c->src_incr*dst_incr;
-        c->compensation_distance= compensation_distance;
-    }
-#if 0    
-    if(update_ctx && !c->compensation_distance){
-#undef rand
-        av_resample_compensate(c, rand() % (8000*2) - 8000, 8000*2);
-av_log(NULL, AV_LOG_DEBUG, "%d %d %d\n", c->dst_incr, c->ideal_dst_incr, c->compensation_distance);
-    }
-#endif
-    
-    return dst_index;
-}
diff --git a/ffmpeg.src/libavcodec/sh4/dsputil_align.c b/ffmpeg.src/libavcodec/sh4/dsputil_align.c
deleted file mode 100644
index a808dd1..0000000
--- a/ffmpeg.src/libavcodec/sh4/dsputil_align.c
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * aligned/packed access motion 
- *
- * Copyright (c) 2001-2003 BERO <bero at geocities.co.jp>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include "../avcodec.h"
-#include "../dsputil.h"
-
-
-#define	LP(p)	*(uint32_t*)(p)
-
-
-#define	UNPACK(ph,pl,tt0,tt1) do { \
-	uint32_t t0,t1; t0=tt0;t1=tt1; \
-	ph = ( (t0 & ~BYTE_VEC32(0x03))>>2) + ( (t1 & ~BYTE_VEC32(0x03))>>2); \
-	pl = (t0 & BYTE_VEC32(0x03)) + (t1 & BYTE_VEC32(0x03)); } while(0)
-
-#define	rnd_PACK(ph,pl,nph,npl)	ph + nph + (((pl + npl + BYTE_VEC32(0x02))>>2) & BYTE_VEC32(0x03))
-#define	no_rnd_PACK(ph,pl,nph,npl)	ph + nph + (((pl + npl + BYTE_VEC32(0x01))>>2) & BYTE_VEC32(0x03))
-
-/* little endian */
-#define	MERGE1(a,b,ofs)	(ofs==0)?a:( ((a)>>(8*ofs))|((b)<<(32-8*ofs)) )
-#define	MERGE2(a,b,ofs)	(ofs==3)?b:( ((a)>>(8*(ofs+1)))|((b)<<(32-8*(ofs+1))) )
-/* big
-#define	MERGE1(a,b,ofs)	(ofs==0)?a:( ((a)<<(8*ofs))|((b)>>(32-8*ofs)) )
-#define	MERGE2(a,b,ofs)	(ofs==3)?b:( ((a)<<(8+8*ofs))|((b)>>(32-8-8*ofs)) )
-*/
-
-
-#define	put(d,s)	d = s
-#define	avg(d,s)	d = rnd_avg32(s,d)
-
-#define	OP_C4(ofs) \
-	ref-=ofs; \
-	do { \
-		OP(LP(dest),MERGE1(LP(ref),LP(ref+4),ofs)); \
-		ref+=stride; \
-		dest+=stride; \
-	} while(--height)
-
-#define	OP_C40() \
-	do { \
-		OP(LP(dest),LP(ref)); \
-		ref+=stride; \
-		dest+=stride; \
-	} while(--height)
-
-
-#define	OP	put
-
-static void put_pixels4_c(uint8_t *dest,const uint8_t *ref, const int stride,int height)
-{
-	switch((int)ref&3){
-	case 0: OP_C40(); return;
-	case 1: OP_C4(1); return;
-	case 2: OP_C4(2); return;
-	case 3: OP_C4(3); return;
-	}
-}
-
-#undef	OP
-#define	OP	avg
-
-static void avg_pixels4_c(uint8_t *dest,const uint8_t *ref, const int stride,int height)
-{
-	switch((int)ref&3){
-	case 0: OP_C40(); return;
-	case 1: OP_C4(1); return;
-	case 2: OP_C4(2); return;
-	case 3: OP_C4(3); return;
-	}
-}
-
-#undef	OP
-
-#define	OP_C(ofs,sz,avg2) \
-{ \
-	ref-=ofs; \
-	do { \
-		uint32_t	t0,t1; \
-		t0 = LP(ref+0); \
-		t1 = LP(ref+4); \
-		OP(LP(dest+0), MERGE1(t0,t1,ofs)); \
-		t0 = LP(ref+8); \
-		OP(LP(dest+4), MERGE1(t1,t0,ofs)); \
-if (sz==16) { \
-		t1 = LP(ref+12); \
-		OP(LP(dest+8), MERGE1(t0,t1,ofs)); \
-		t0 = LP(ref+16); \
-		OP(LP(dest+12), MERGE1(t1,t0,ofs)); \
-} \
-		ref+=stride; \
-		dest+= stride; \
-	} while(--height); \
-}
-
-/* aligned */
-#define	OP_C0(sz,avg2) \
-{ \
-	do { \
-		OP(LP(dest+0), LP(ref+0)); \
-		OP(LP(dest+4), LP(ref+4)); \
-if (sz==16) { \
-		OP(LP(dest+8), LP(ref+8)); \
-		OP(LP(dest+12), LP(ref+12)); \
-} \
-		ref+=stride; \
-		dest+= stride; \
-	} while(--height); \
-}
-
-#define	OP_X(ofs,sz,avg2) \
-{ \
-	ref-=ofs; \
-	do { \
-		uint32_t	t0,t1; \
-		t0 = LP(ref+0); \
-		t1 = LP(ref+4); \
-		OP(LP(dest+0), avg2(MERGE1(t0,t1,ofs),MERGE2(t0,t1,ofs))); \
-		t0 = LP(ref+8); \
-		OP(LP(dest+4), avg2(MERGE1(t1,t0,ofs),MERGE2(t1,t0,ofs))); \
-if (sz==16) { \
-		t1 = LP(ref+12); \
-		OP(LP(dest+8), avg2(MERGE1(t0,t1,ofs),MERGE2(t0,t1,ofs))); \
-		t0 = LP(ref+16); \
-		OP(LP(dest+12), avg2(MERGE1(t1,t0,ofs),MERGE2(t1,t0,ofs))); \
-} \
-		ref+=stride; \
-		dest+= stride; \
-	} while(--height); \
-}
-
-/* aligned */
-#define	OP_Y0(sz,avg2) \
-{ \
-	uint32_t t0,t1,t2,t3,t; \
-\
-	t0 = LP(ref+0); \
-	t1 = LP(ref+4); \
-if (sz==16) { \
-	t2 = LP(ref+8); \
-	t3 = LP(ref+12); \
-} \
-	do { \
-		ref += stride; \
-\
-		t = LP(ref+0); \
-		OP(LP(dest+0), avg2(t0,t)); t0 = t; \
-		t = LP(ref+4); \
-		OP(LP(dest+4), avg2(t1,t)); t1 = t; \
-if (sz==16) { \
-		t = LP(ref+8); \
-		OP(LP(dest+8), avg2(t2,t)); t2 = t; \
-		t = LP(ref+12); \
-		OP(LP(dest+12), avg2(t3,t)); t3 = t; \
-} \
-		dest+= stride; \
-	} while(--height); \
-}
-
-#define	OP_Y(ofs,sz,avg2) \
-{ \
-	uint32_t t0,t1,t2,t3,t,w0,w1; \
-\
-	ref-=ofs; \
-	w0 = LP(ref+0); \
-	w1 = LP(ref+4); \
-	t0 = MERGE1(w0,w1,ofs); \
-	w0 = LP(ref+8); \
-	t1 = MERGE1(w1,w0,ofs); \
-if (sz==16) { \
-	w1 = LP(ref+12); \
-	t2 = MERGE1(w0,w1,ofs); \
-	w0 = LP(ref+16); \
-	t3 = MERGE1(w1,w0,ofs); \
-} \
-	do { \
-		ref += stride; \
-\
-		w0 = LP(ref+0); \
-		w1 = LP(ref+4); \
-		t = MERGE1(w0,w1,ofs); \
-		OP(LP(dest+0), avg2(t0,t)); t0 = t; \
-		w0 = LP(ref+8); \
-		t = MERGE1(w1,w0,ofs); \
-		OP(LP(dest+4), avg2(t1,t)); t1 = t; \
-if (sz==16) { \
-		w1 = LP(ref+12); \
-		t = MERGE1(w0,w1,ofs); \
-		OP(LP(dest+8), avg2(t2,t)); t2 = t; \
-		w0 = LP(ref+16); \
-		t = MERGE1(w1,w0,ofs); \
-		OP(LP(dest+12), avg2(t3,t)); t3 = t; \
-} \
-		dest+=stride; \
-	} while(--height); \
-}
-
-#define OP_X0(sz,avg2) OP_X(0,sz,avg2)
-#define OP_XY0(sz,PACK) OP_XY(0,sz,PACK)
-#define	OP_XY(ofs,sz,PACK) \
-{ \
-	uint32_t	t2,t3,w0,w1; \
-	uint32_t	a0,a1,a2,a3,a4,a5,a6,a7; \
-\
-	ref -= ofs; \
-	w0 = LP(ref+0); \
-	w1 = LP(ref+4); \
-	UNPACK(a0,a1,MERGE1(w0,w1,ofs),MERGE2(w0,w1,ofs)); \
-	w0 = LP(ref+8); \
-	UNPACK(a2,a3,MERGE1(w1,w0,ofs),MERGE2(w1,w0,ofs)); \
-if (sz==16) { \
-	w1 = LP(ref+12); \
-	UNPACK(a4,a5,MERGE1(w0,w1,ofs),MERGE2(w0,w1,ofs)); \
-	w0 = LP(ref+16); \
-	UNPACK(a6,a7,MERGE1(w1,w0,ofs),MERGE2(w1,w0,ofs)); \
-} \
-	do { \
-		ref+=stride; \
-		w0 = LP(ref+0); \
-		w1 = LP(ref+4); \
-		UNPACK(t2,t3,MERGE1(w0,w1,ofs),MERGE2(w0,w1,ofs)); \
-		OP(LP(dest+0),PACK(a0,a1,t2,t3)); \
-		a0 = t2; a1 = t3; \
-		w0 = LP(ref+8); \
-		UNPACK(t2,t3,MERGE1(w1,w0,ofs),MERGE2(w1,w0,ofs)); \
-		OP(LP(dest+4),PACK(a2,a3,t2,t3)); \
-		a2 = t2; a3 = t3; \
-if (sz==16) { \
-		w1 = LP(ref+12); \
-		UNPACK(t2,t3,MERGE1(w0,w1,ofs),MERGE2(w0,w1,ofs)); \
-		OP(LP(dest+8),PACK(a4,a5,t2,t3)); \
-		a4 = t2; a5 = t3; \
-		w0 = LP(ref+16); \
-		UNPACK(t2,t3,MERGE1(w1,w0,ofs),MERGE2(w1,w0,ofs)); \
-		OP(LP(dest+12),PACK(a6,a7,t2,t3)); \
-		a6 = t2; a7 = t3; \
-} \
-		dest+=stride; \
-	} while(--height); \
-}
-
-#define	DEFFUNC(op,rnd,xy,sz,OP_N,avgfunc) \
-static void op##_##rnd##_pixels##sz##_##xy (uint8_t * dest, const uint8_t * ref,	\
-				   const int stride, int height)	\
-{ \
-	switch((int)ref&3) { \
-	case 0:OP_N##0(sz,rnd##_##avgfunc); return; \
-	case 1:OP_N(1,sz,rnd##_##avgfunc); return; \
-	case 2:OP_N(2,sz,rnd##_##avgfunc); return; \
-	case 3:OP_N(3,sz,rnd##_##avgfunc); return; \
-	} \
-}
-
-#define OP put
-
-DEFFUNC(put,   rnd,o,8,OP_C,avg2)
-DEFFUNC(put,   rnd,x,8,OP_X,avg2)
-DEFFUNC(put,no_rnd,x,8,OP_X,avg2)
-DEFFUNC(put,   rnd,y,8,OP_Y,avg2)
-DEFFUNC(put,no_rnd,y,8,OP_Y,avg2)
-DEFFUNC(put,   rnd,xy,8,OP_XY,PACK)
-DEFFUNC(put,no_rnd,xy,8,OP_XY,PACK)
-DEFFUNC(put,   rnd,o,16,OP_C,avg2)
-DEFFUNC(put,   rnd,x,16,OP_X,avg2)
-DEFFUNC(put,no_rnd,x,16,OP_X,avg2)
-DEFFUNC(put,   rnd,y,16,OP_Y,avg2)
-DEFFUNC(put,no_rnd,y,16,OP_Y,avg2)
-DEFFUNC(put,   rnd,xy,16,OP_XY,PACK)
-DEFFUNC(put,no_rnd,xy,16,OP_XY,PACK)
-
-#undef OP
-#define OP avg
-
-DEFFUNC(avg,   rnd,o,8,OP_C,avg2)
-DEFFUNC(avg,   rnd,x,8,OP_X,avg2)
-DEFFUNC(avg,no_rnd,x,8,OP_X,avg2)
-DEFFUNC(avg,   rnd,y,8,OP_Y,avg2)
-DEFFUNC(avg,no_rnd,y,8,OP_Y,avg2)
-DEFFUNC(avg,   rnd,xy,8,OP_XY,PACK)
-DEFFUNC(avg,no_rnd,xy,8,OP_XY,PACK)
-DEFFUNC(avg,   rnd,o,16,OP_C,avg2)
-DEFFUNC(avg,   rnd,x,16,OP_X,avg2)
-DEFFUNC(avg,no_rnd,x,16,OP_X,avg2)
-DEFFUNC(avg,   rnd,y,16,OP_Y,avg2)
-DEFFUNC(avg,no_rnd,y,16,OP_Y,avg2)
-DEFFUNC(avg,   rnd,xy,16,OP_XY,PACK)
-DEFFUNC(avg,no_rnd,xy,16,OP_XY,PACK)
-
-#undef OP
-
-#define	put_no_rnd_pixels8_o	put_rnd_pixels8_o
-#define	put_no_rnd_pixels16_o	put_rnd_pixels16_o
-#define	avg_no_rnd_pixels8_o	avg_rnd_pixels8_o
-#define	avg_no_rnd_pixels16_o	avg_rnd_pixels16_o
-
-#define	put_pixels8_c	put_rnd_pixels8_o
-#define	put_pixels16_c	put_rnd_pixels16_o
-#define	avg_pixels8_c	avg_rnd_pixels8_o
-#define	avg_pixels16_c	avg_rnd_pixels16_o
-#define	put_no_rnd_pixels8_c	put_rnd_pixels8_o
-#define	put_no_rnd_pixels16_c	put_rnd_pixels16_o
-#define	avg_no_rnd_pixels8_c	avg_rnd_pixels8_o
-#define	avg_no_rnd_pixels16_c	avg_rnd_pixels16_o
-
-#define	QPEL
-
-#ifdef QPEL
-
-#include "qpel.c"
-
-#endif
-
-void dsputil_init_align(DSPContext* c, AVCodecContext *avctx)
-{
-	c->put_pixels_tab[0][0] = put_rnd_pixels16_o;
-	c->put_pixels_tab[0][1] = put_rnd_pixels16_x;
-	c->put_pixels_tab[0][2] = put_rnd_pixels16_y;
-	c->put_pixels_tab[0][3] = put_rnd_pixels16_xy;
-	c->put_pixels_tab[1][0] = put_rnd_pixels8_o;
-	c->put_pixels_tab[1][1] = put_rnd_pixels8_x;
-	c->put_pixels_tab[1][2] = put_rnd_pixels8_y;
-	c->put_pixels_tab[1][3] = put_rnd_pixels8_xy;
-
-	c->put_no_rnd_pixels_tab[0][0] = put_no_rnd_pixels16_o;
-	c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x;
-	c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y;
-	c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy;
-	c->put_no_rnd_pixels_tab[1][0] = put_no_rnd_pixels8_o;
-	c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x;
-	c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y;
-	c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels8_xy;
-
-	c->avg_pixels_tab[0][0] = avg_rnd_pixels16_o;
-	c->avg_pixels_tab[0][1] = avg_rnd_pixels16_x;
-	c->avg_pixels_tab[0][2] = avg_rnd_pixels16_y;
-	c->avg_pixels_tab[0][3] = avg_rnd_pixels16_xy;
-	c->avg_pixels_tab[1][0] = avg_rnd_pixels8_o;
-	c->avg_pixels_tab[1][1] = avg_rnd_pixels8_x;
-	c->avg_pixels_tab[1][2] = avg_rnd_pixels8_y;
-	c->avg_pixels_tab[1][3] = avg_rnd_pixels8_xy;
-
-	c->avg_no_rnd_pixels_tab[0][0] = avg_no_rnd_pixels16_o;
-	c->avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x;
-	c->avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y;
-	c->avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy;
-	c->avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels8_o;
-	c->avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels8_x;
-	c->avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels8_y;
-	c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels8_xy;
-
-#ifdef QPEL
-
-#define dspfunc(PFX, IDX, NUM) \
-    c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \
-    c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \
-    c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \
-    c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \
-    c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \
-    c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \
-    c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \
-    c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \
-    c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \
-    c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \
-    c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
-    c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
-    c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
-    c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
-    c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
-    c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
-
-    dspfunc(put_qpel, 0, 16);
-    dspfunc(put_no_rnd_qpel, 0, 16);
-
-    dspfunc(avg_qpel, 0, 16);
-    /* dspfunc(avg_no_rnd_qpel, 0, 16); */
-
-    dspfunc(put_qpel, 1, 8);
-    dspfunc(put_no_rnd_qpel, 1, 8);
-
-    dspfunc(avg_qpel, 1, 8);
-    /* dspfunc(avg_no_rnd_qpel, 1, 8); */
-
-    dspfunc(put_h264_qpel, 0, 16);
-    dspfunc(put_h264_qpel, 1, 8);
-    dspfunc(put_h264_qpel, 2, 4);
-    dspfunc(avg_h264_qpel, 0, 16);
-    dspfunc(avg_h264_qpel, 1, 8);
-    dspfunc(avg_h264_qpel, 2, 4);
-
-#undef dspfunc
-    c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_c;
-    c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_c;
-    c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_c;
-    c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_c;
-    c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_c;
-    c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_c;
-
-    c->put_mspel_pixels_tab[0]= put_mspel8_mc00_c;
-    c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;
-    c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c;
-    c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c;
-    c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c;
-    c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c;
-    c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;
-    c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;
-
-    c->gmc1 = gmc1_c;
-    c->gmc = gmc_c;
-
-#endif
-}
diff --git a/ffmpeg.src/libavcodec/sh4/dsputil_sh4.c b/ffmpeg.src/libavcodec/sh4/dsputil_sh4.c
deleted file mode 100644
index 6cff76c..0000000
--- a/ffmpeg.src/libavcodec/sh4/dsputil_sh4.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- *  sh4 dsputil
- *
- * Copyright (c) 2003 BERO <bero at geocities.co.jp>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "../avcodec.h"
-#include "../dsputil.h"
-
-static void memzero_align8(void *dst,size_t size)
-{
-#if defined(__SH4__) || defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
-	(char*)dst+=size;
-	size/=8*4;
-	asm(
-#if defined(__SH4__)
-	" fschg\n"  //single float mode
-#endif
-	" fldi0 fr0\n"
-	" fldi0 fr1\n"
-	" fschg\n"  // double
-	"1: \n" \
-	" dt %1\n"
-	" fmov	dr0, at -%0\n"
-	" fmov	dr0, at -%0\n"
-	" fmov	dr0, at -%0\n"
-	" bf.s 1b\n"
-	" fmov	dr0, at -%0\n"
-#if defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
-	" fschg" //back to single
-#endif
-	: : "r"(dst),"r"(size): "memory" );
-#else
-	double *d = dst;
-	size/=8*4;
-	do {
-		d[0] = 0.0;
-		d[1] = 0.0;
-		d[2] = 0.0;
-		d[3] = 0.0;
-		d+=4;
-	} while(--size);
-#endif
-}
-
-static void clear_blocks_sh4(DCTELEM *blocks)
-{
-//	if (((int)blocks&7)==0) 
-	memzero_align8(blocks,sizeof(DCTELEM)*6*64);
-}
-
-extern void idct_sh4(DCTELEM *block);
-static void idct_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-	idct_sh4(block);
-	int i;
-	uint8_t *cm = cropTbl + MAX_NEG_CROP;
-	for(i=0;i<8;i++) {
-		dest[0] = cm[block[0]];
-		dest[1] = cm[block[1]];
-		dest[2] = cm[block[2]];
-		dest[3] = cm[block[3]];
-		dest[4] = cm[block[4]];
-		dest[5] = cm[block[5]];
-		dest[6] = cm[block[6]];
-		dest[7] = cm[block[7]];
-		dest+=line_size;
-		block+=8;
-	}
-}
-static void idct_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-	idct_sh4(block);
-	int i;
-	uint8_t *cm = cropTbl + MAX_NEG_CROP;
-	for(i=0;i<8;i++) {
-		dest[0] = cm[dest[0]+block[0]];
-		dest[1] = cm[dest[1]+block[1]];
-		dest[2] = cm[dest[2]+block[2]];
-		dest[3] = cm[dest[3]+block[3]];
-		dest[4] = cm[dest[4]+block[4]];
-		dest[5] = cm[dest[5]+block[5]];
-		dest[6] = cm[dest[6]+block[6]];
-		dest[7] = cm[dest[7]+block[7]];
-		dest+=line_size;
-		block+=8;
-	}
-}
-
-extern void dsputil_init_align(DSPContext* c, AVCodecContext *avctx);
-
-void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx)
-{
-	const int idct_algo= avctx->idct_algo;
-	dsputil_init_align(c,avctx);
-
-	c->clear_blocks = clear_blocks_sh4;
-	if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4){        
-		c->idct_put = idct_put;
-		c->idct_add = idct_add;
-               c->idct     = idct_sh4;
-		c->idct_permutation_type= FF_NO_IDCT_PERM; //FF_SIMPLE_IDCT_PERM; //FF_LIBMPEG2_IDCT_PERM;
-	}
-}
diff --git a/ffmpeg.src/libavcodec/sh4/idct_sh4.c b/ffmpeg.src/libavcodec/sh4/idct_sh4.c
deleted file mode 100644
index 277facd..0000000
--- a/ffmpeg.src/libavcodec/sh4/idct_sh4.c
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * idct for sh4
- *
- * Copyright (c) 2001-2003 BERO <bero at geocities.co.jp>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "../dsputil.h"
-#define c1	1.38703984532214752434	/* sqrt(2)*cos(1*pi/16) */
-#define c2	1.30656296487637657577	/* sqrt(2)*cos(2*pi/16) */
-#define c3	1.17587560241935884520	/* sqrt(2)*cos(3*pi/16) */
-#define c4	1.00000000000000000000	/* sqrt(2)*cos(4*pi/16) */
-#define c5	0.78569495838710234903	/* sqrt(2)*cos(5*pi/16) */
-#define c6	0.54119610014619712324	/* sqrt(2)*cos(6*pi/16) */
-#define c7	0.27589937928294311353	/* sqrt(2)*cos(7*pi/16) */
-
-const	static float even_table[] __attribute__ ((aligned(8))) = {
-	 c4, c4, c4, c4,
-	 c2, c6,-c6,-c2,
-	 c4,-c4,-c4, c4,
-	 c6,-c2, c2,-c6
-};
-
-const	static float odd_table[] __attribute__ ((aligned(8))) = {
-	 c1, c3, c5, c7,
-	 c3,-c7,-c1,-c5,
-	 c5,-c1, c7, c3,
-	 c7,-c5, c3,-c1
-};
-
-#undef	c1
-#undef	c2
-#undef	c3
-#undef	c4
-#undef	c5
-#undef	c6
-#undef	c7
-
-#if defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
-
-#define	load_matrix(table) \
-	__asm__ volatile( \
-	"	fschg\n" \
-	"	fmov	@%0+,xd0\n" \
-	"	fmov	@%0+,xd2\n" \
-	"	fmov	@%0+,xd4\n" \
-	"	fmov	@%0+,xd6\n" \
-	"	fmov	@%0+,xd8\n" \
-	"	fmov	@%0+,xd10\n" \
-	"	fmov	@%0+,xd12\n" \
-	"	fmov	@%0+,xd14\n" \
-	"	fschg\n" \
-	:\
-	: "r"(table)\
-	: "0" \
-	)
-
-#define	ftrv() \
-		__asm__ volatile("ftrv xmtrx,fv0" \
-		: "=f"(fr0),"=f"(fr1),"=f"(fr2),"=f"(fr3) \
-		:  "0"(fr0), "1"(fr1), "2"(fr2), "3"(fr3) );
-
-#define	DEFREG	\
-	register float fr0 __asm__("fr0"); \
-	register float fr1 __asm__("fr1"); \
-	register float fr2 __asm__("fr2"); \
-	register float fr3 __asm__("fr3")
-
-#else
-
-/* generic C code for check */
-
-static void ftrv_(const float xf[],float fv[])
-{
-	float f0,f1,f2,f3;
-	f0 = fv[0];
-	f1 = fv[1];
-	f2 = fv[2];
-	f3 = fv[3];
-	fv[0] = xf[0]*f0 + xf[4]*f1 + xf[ 8]*f2 + xf[12]*f3;
-	fv[1] = xf[1]*f0 + xf[5]*f1 + xf[ 9]*f2 + xf[13]*f3;
-	fv[2] = xf[2]*f0 + xf[6]*f1 + xf[10]*f2 + xf[14]*f3;
-	fv[3] = xf[3]*f0 + xf[7]*f1 + xf[11]*f2 + xf[15]*f3;
-}
-
-static void load_matrix_(float xf[],const float table[])
-{
-	int i;
-	for(i=0;i<16;i++) xf[i]=table[i];
-}
-
-#define	ftrv()	ftrv_(xf,fv)
-#define	load_matrix(table)	load_matrix_(xf,table)
-
-#define	DEFREG \
-	float fv[4],xf[16]
-
-#define	fr0	fv[0]
-#define	fr1	fv[1]
-#define	fr2	fv[2]
-#define	fr3	fv[3]
-
-#endif
-
-#if 1
-#define	DESCALE(x,n)	(x)*(1.0f/(1<<(n)))
-#else
-#define	DESCALE(x,n)	(((int)(x)+(1<<(n-1)))>>(n))
-#endif
-
-/* this code work worse on gcc cvs. 3.2.3 work fine */
-
-
-#if 1
-//optimized 
-
-void idct_sh4(DCTELEM *block)
-{
-	DEFREG;
-
-	int i;
-	float	tblock[8*8],*fblock;
-	int ofs1,ofs2,ofs3;
-
-#if defined(__SH4__)
-#error	"FIXME!! change to single float"
-#endif
-
-	/* row */
-
-	/* even part */
-	load_matrix(even_table);
-
-	fblock = tblock+4;
-	i = 8;
-	do {
-		fr0 = block[0];
-		fr1 = block[2];
-		fr2 = block[4];
-		fr3 = block[6];
-		block+=8;
-		ftrv();
-		*--fblock = fr3;
-		*--fblock = fr2;
-		*--fblock = fr1;
-		*--fblock = fr0;
-		fblock+=8+4;
-	} while(--i);
-	block-=8*8;
-	fblock-=8*8+4;
-
-	load_matrix(odd_table);
-
-	i = 8;
-
-//	ofs1 = sizeof(float)*1;
-//	ofs2 = sizeof(float)*2;
-//	ofs3 = sizeof(float)*3;
-
-	do {
-		float t0,t1,t2,t3;
-		fr0 = block[1];
-		fr1 = block[3];
-		fr2 = block[5];
-		fr3 = block[7];
-		block+=8;
-		ftrv();
-		t0 = *fblock++;
-		t1 = *fblock++;
-		t2 = *fblock++;
-		t3 = *fblock++;
-		fblock+=4;
-		*--fblock = t0 - fr0;
-		*--fblock = t1 - fr1;
-		*--fblock = t2 - fr2;
-		*--fblock = t3 - fr3;
-		*--fblock = t3 + fr3;
-		*--fblock = t2 + fr2;
-		*--fblock = t1 + fr1;
-		*--fblock = t0 + fr0;
-		fblock+=8;
-	} while(--i);
-	block-=8*8;
-	fblock-=8*8;
-
-	/* col */
-
-	/* even part */
-	load_matrix(even_table);
-
-	ofs1 = sizeof(float)*2*8;
-	ofs2 = sizeof(float)*4*8;
-	ofs3 = sizeof(float)*6*8;
-
-	i = 8;
-
-#define	OA(fblock,ofs)	*(float*)((char*)fblock + ofs)
-
-	do {
-		fr0 = OA(fblock,   0);
-		fr1 = OA(fblock,ofs1);
-		fr2 = OA(fblock,ofs2);
-		fr3 = OA(fblock,ofs3);
-		ftrv();
-		OA(fblock,0   ) = fr0;
-		OA(fblock,ofs1) = fr1;
-		OA(fblock,ofs2) = fr2;
-		OA(fblock,ofs3) = fr3;
-		fblock++;
-	} while(--i);
-	fblock-=8;
-
-	load_matrix(odd_table);
-
-	i=8;
-	do {
-		float t0,t1,t2,t3;
-		t0 = OA(fblock,   0); /* [8*0] */
-		t1 = OA(fblock,ofs1); /* [8*2] */
-		t2 = OA(fblock,ofs2); /* [8*4] */
-		t3 = OA(fblock,ofs3); /* [8*6] */
-		fblock+=8;
-		fr0 = OA(fblock,   0); /* [8*1] */
-		fr1 = OA(fblock,ofs1); /* [8*3] */
-		fr2 = OA(fblock,ofs2); /* [8*5] */
-		fr3 = OA(fblock,ofs3); /* [8*7] */
-		fblock+=-8+1;
-		ftrv();
-		block[8*0] = DESCALE(t0 + fr0,3);
-		block[8*7] = DESCALE(t0 - fr0,3);
-		block[8*1] = DESCALE(t1 + fr1,3);
-		block[8*6] = DESCALE(t1 - fr1,3);
-		block[8*2] = DESCALE(t2 + fr2,3);
-		block[8*5] = DESCALE(t2 - fr2,3);
-		block[8*3] = DESCALE(t3 + fr3,3);
-		block[8*4] = DESCALE(t3 - fr3,3);
-		block++;
-	} while(--i);
-
-#if defined(__SH4__)
-#error	"FIXME!! change to double"
-#endif
-}
-#else
-void idct_sh4(DCTELEM *block)
-{
-	DEFREG;
-
-	int i;
-	float	tblock[8*8],*fblock;
-
-	/* row */
-
-	/* even part */
-	load_matrix(even_table);
-
-	fblock = tblock;
-	i = 8;
-	do {
-		fr0 = block[0];
-		fr1 = block[2];
-		fr2 = block[4];
-		fr3 = block[6];
-		block+=8;
-		ftrv();
-		fblock[0] = fr0;
-		fblock[2] = fr1;
-		fblock[4] = fr2;
-		fblock[6] = fr3;
-		fblock+=8;
-	} while(--i);
-	block-=8*8;
-	fblock-=8*8;
-
-	load_matrix(odd_table);
-
-	i = 8;
-
-	do {
-		float t0,t1,t2,t3;
-		fr0 = block[1];
-		fr1 = block[3];
-		fr2 = block[5];
-		fr3 = block[7];
-		block+=8;
-		ftrv();
-		t0 = fblock[0];
-		t1 = fblock[2];
-		t2 = fblock[4];
-		t3 = fblock[6];
-		fblock[0] = t0 + fr0;
-		fblock[7] = t0 - fr0;
-		fblock[1] = t1 + fr1;
-		fblock[6] = t1 - fr1;
-		fblock[2] = t2 + fr2;
-		fblock[5] = t2 - fr2;
-		fblock[3] = t3 + fr3;
-		fblock[4] = t3 - fr3;
-		fblock+=8;
-	} while(--i);
-	block-=8*8;
-	fblock-=8*8;
-
-	/* col */
-
-	/* even part */
-	load_matrix(even_table);
-
-	i = 8;
-
-	do {
-		fr0 = fblock[8*0];
-		fr1 = fblock[8*2];
-		fr2 = fblock[8*4];
-		fr3 = fblock[8*6];
-		ftrv();
-		fblock[8*0] = fr0;
-		fblock[8*2] = fr1;
-		fblock[8*4] = fr2;
-		fblock[8*6] = fr3;
-		fblock++;
-	} while(--i);
-	fblock-=8;
-
-	load_matrix(odd_table);
-
-	i=8;
-	do {
-		float t0,t1,t2,t3;
-		fr0 = fblock[8*1];
-		fr1 = fblock[8*3];
-		fr2 = fblock[8*5];
-		fr3 = fblock[8*7];
-		ftrv();
-		t0 = fblock[8*0];
-		t1 = fblock[8*2];
-		t2 = fblock[8*4];
-		t3 = fblock[8*6];
-		fblock++;
-		block[8*0] = DESCALE(t0 + fr0,3);
-		block[8*7] = DESCALE(t0 - fr0,3);
-		block[8*1] = DESCALE(t1 + fr1,3);
-		block[8*6] = DESCALE(t1 - fr1,3);
-		block[8*2] = DESCALE(t2 + fr2,3);
-		block[8*5] = DESCALE(t2 - fr2,3);
-		block[8*3] = DESCALE(t3 + fr3,3);
-		block[8*4] = DESCALE(t3 - fr3,3);
-		block++;
-	} while(--i);
-}
-#endif
diff --git a/ffmpeg.src/libavcodec/sh4/qpel.c b/ffmpeg.src/libavcodec/sh4/qpel.c
deleted file mode 100644
index 2e6ac8c..0000000
--- a/ffmpeg.src/libavcodec/sh4/qpel.c
+++ /dev/null
@@ -1,1649 +0,0 @@
-/* 
-	this is optimized for sh, which have post increment addressing (*p++)
-	some cpu may be index (p[n]) faster than post increment (*p++)
-*/
-
-#define	LD(adr)	*(uint32_t*)(adr)
-
-#define PIXOP2(OPNAME, OP) \
-/*static inline void OPNAME ## _no_rnd_pixels8_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do {\
-		OP(LP(dst  ),no_rnd_avg32(LD32(src1  ),LD32(src2  )) ); \
-		OP(LP(dst+4),no_rnd_avg32(LD32(src1+4),LD32(src2+4)) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}\
-\
-static inline void OPNAME ## _pixels8_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do {\
-		OP(LP(dst  ),rnd_avg32(LD32(src1  ),LD32(src2  )) ); \
-		OP(LP(dst+4),rnd_avg32(LD32(src1+4),LD32(src2+4)) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}\
-\
-static inline void OPNAME ## _pixels4_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do {\
-		OP(LP(dst  ),rnd_avg32(LD32(src1  ),LD32(src2  )) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}\
-\
-static inline void OPNAME ## _no_rnd_pixels16_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do {\
-		OP(LP(dst  ),no_rnd_avg32(LD32(src1  ),LD32(src2  )) ); \
-		OP(LP(dst+4),no_rnd_avg32(LD32(src1+4),LD32(src2+4)) ); \
-		OP(LP(dst+8),no_rnd_avg32(LD32(src1+8),LD32(src2+8)) ); \
-		OP(LP(dst+12),no_rnd_avg32(LD32(src1+12),LD32(src2+12)) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}\
-\
-static inline void OPNAME ## _pixels16_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do {\
-		OP(LP(dst  ),rnd_avg32(LD32(src1  ),LD32(src2  )) ); \
-		OP(LP(dst+4),rnd_avg32(LD32(src1+4),LD32(src2+4)) ); \
-		OP(LP(dst+8),rnd_avg32(LD32(src1+8),LD32(src2+8)) ); \
-		OP(LP(dst+12),rnd_avg32(LD32(src1+12),LD32(src2+12)) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}*/\
-\
-static inline void OPNAME ## _pixels4_l2_aligned(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do {\
-		OP(LP(dst  ),rnd_avg32(LP(src1  ),LP(src2  )) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}\
-\
-static inline void OPNAME ## _pixels4_l2_aligned2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do {\
-		OP(LP(dst  ),rnd_avg32(LD32(src1  ),LP(src2  )) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}\
-\
-static inline void OPNAME ## _no_rnd_pixels16_l2_aligned2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do {\
-		OP(LP(dst  ),no_rnd_avg32(LD32(src1  ),LP(src2  )) ); \
-		OP(LP(dst+4),no_rnd_avg32(LD32(src1+4),LP(src2+4)) ); \
-		OP(LP(dst+8),no_rnd_avg32(LD32(src1+8),LP(src2+8)) ); \
-		OP(LP(dst+12),no_rnd_avg32(LD32(src1+12),LP(src2+12)) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}\
-\
-static inline void OPNAME ## _pixels16_l2_aligned2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do {\
-		OP(LP(dst  ),rnd_avg32(LD32(src1  ),LP(src2  )) ); \
-		OP(LP(dst+4),rnd_avg32(LD32(src1+4),LP(src2+4)) ); \
-		OP(LP(dst+8),rnd_avg32(LD32(src1+8),LP(src2+8)) ); \
-		OP(LP(dst+12),rnd_avg32(LD32(src1+12),LP(src2+12)) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}\
-\
-static inline void OPNAME ## _no_rnd_pixels8_l2_aligned2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do { /* onlye src2 aligned */\
-		OP(LP(dst  ),no_rnd_avg32(LD32(src1  ),LP(src2  )) ); \
-		OP(LP(dst+4),no_rnd_avg32(LD32(src1+4),LP(src2+4)) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}\
-\
-static inline void OPNAME ## _pixels8_l2_aligned2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do {\
-		OP(LP(dst  ),rnd_avg32(LD32(src1  ),LP(src2  )) ); \
-		OP(LP(dst+4),rnd_avg32(LD32(src1+4),LP(src2+4)) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}\
-\
-static inline void OPNAME ## _no_rnd_pixels8_l2_aligned(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do {\
-		OP(LP(dst  ),no_rnd_avg32(LP(src1  ),LP(src2  )) ); \
-		OP(LP(dst+4),no_rnd_avg32(LP(src1+4),LP(src2+4)) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}\
-\
-static inline void OPNAME ## _pixels8_l2_aligned(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do {\
-		OP(LP(dst  ),rnd_avg32(LP(src1  ),LP(src2  )) ); \
-		OP(LP(dst+4),rnd_avg32(LP(src1+4),LP(src2+4)) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}\
-\
-static inline void OPNAME ## _no_rnd_pixels16_l2_aligned(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do {\
-		OP(LP(dst  ),no_rnd_avg32(LP(src1  ),LP(src2  )) ); \
-		OP(LP(dst+4),no_rnd_avg32(LP(src1+4),LP(src2+4)) ); \
-		OP(LP(dst+8),no_rnd_avg32(LP(src1+8),LP(src2+8)) ); \
-		OP(LP(dst+12),no_rnd_avg32(LP(src1+12),LP(src2+12)) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}\
-\
-static inline void OPNAME ## _pixels16_l2_aligned(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{\
-	do {\
-		OP(LP(dst  ),rnd_avg32(LP(src1  ),LP(src2  )) ); \
-		OP(LP(dst+4),rnd_avg32(LP(src1+4),LP(src2+4)) ); \
-		OP(LP(dst+8),rnd_avg32(LP(src1+8),LP(src2+8)) ); \
-		OP(LP(dst+12),rnd_avg32(LP(src1+12),LP(src2+12)) ); \
-		src1+=src_stride1; \
-		src2+=src_stride2; \
-		dst+=dst_stride; \
-	} while(--h); \
-}\
-\
-static inline void OPNAME ## _no_rnd_pixels16_l2_aligned1(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{ OPNAME ## _no_rnd_pixels16_l2_aligned2(dst,src2,src1,dst_stride,src_stride2,src_stride1,h); } \
-\
-static inline void OPNAME ## _pixels16_l2_aligned1(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{ OPNAME ## _pixels16_l2_aligned2(dst,src2,src1,dst_stride,src_stride2,src_stride1,h); } \
-\
-static inline void OPNAME ## _no_rnd_pixels8_l2_aligned1(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{ OPNAME ## _no_rnd_pixels8_l2_aligned2(dst,src2,src1,dst_stride,src_stride2,src_stride1,h); } \
-\
-static inline void OPNAME ## _pixels8_l2_aligned1(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, int src_stride1, int src_stride2, int h) \
-{ OPNAME ## _pixels8_l2_aligned2(dst,src2,src1,dst_stride,src_stride2,src_stride1,h); } \
-\
-static inline void OPNAME ## _pixels8_l4_aligned(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-	do { \
-		uint32_t a0,a1,a2,a3; \
-		UNPACK(a0,a1,LP(src1),LP(src2)); \
-		UNPACK(a2,a3,LP(src3),LP(src4)); \
-		OP(LP(dst),rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LP(src1+4),LP(src2+4)); \
-		UNPACK(a2,a3,LP(src3+4),LP(src4+4)); \
-		OP(LP(dst+4),rnd_PACK(a0,a1,a2,a3)); \
-		src1+=src_stride1;\
-		src2+=src_stride2;\
-		src3+=src_stride3;\
-		src4+=src_stride4;\
-		dst+=dst_stride;\
-	} while(--h); \
-} \
-\
-static inline void OPNAME ## _no_rnd_pixels8_l4_aligned(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-	do { \
-		uint32_t a0,a1,a2,a3; \
-		UNPACK(a0,a1,LP(src1),LP(src2)); \
-		UNPACK(a2,a3,LP(src3),LP(src4)); \
-		OP(LP(dst),no_rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LP(src1+4),LP(src2+4)); \
-		UNPACK(a2,a3,LP(src3+4),LP(src4+4)); \
-		OP(LP(dst+4),no_rnd_PACK(a0,a1,a2,a3)); \
-		src1+=src_stride1;\
-		src2+=src_stride2;\
-		src3+=src_stride3;\
-		src4+=src_stride4;\
-		dst+=dst_stride;\
-	} while(--h); \
-} \
-\
-static inline void OPNAME ## _pixels8_l4_aligned0(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-	do { \
-		uint32_t a0,a1,a2,a3; /* src1 only not aligned */\
-		UNPACK(a0,a1,LD32(src1),LP(src2)); \
-		UNPACK(a2,a3,LP(src3),LP(src4)); \
-		OP(LP(dst),rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LD32(src1+4),LP(src2+4)); \
-		UNPACK(a2,a3,LP(src3+4),LP(src4+4)); \
-		OP(LP(dst+4),rnd_PACK(a0,a1,a2,a3)); \
-		src1+=src_stride1;\
-		src2+=src_stride2;\
-		src3+=src_stride3;\
-		src4+=src_stride4;\
-		dst+=dst_stride;\
-	} while(--h); \
-} \
-\
-static inline void OPNAME ## _no_rnd_pixels8_l4_aligned0(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-	do { \
-		uint32_t a0,a1,a2,a3; \
-		UNPACK(a0,a1,LD32(src1),LP(src2)); \
-		UNPACK(a2,a3,LP(src3),LP(src4)); \
-		OP(LP(dst),no_rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LD32(src1+4),LP(src2+4)); \
-		UNPACK(a2,a3,LP(src3+4),LP(src4+4)); \
-		OP(LP(dst+4),no_rnd_PACK(a0,a1,a2,a3)); \
-		src1+=src_stride1;\
-		src2+=src_stride2;\
-		src3+=src_stride3;\
-		src4+=src_stride4;\
-		dst+=dst_stride;\
-	} while(--h); \
-} \
-\
-static inline void OPNAME ## _pixels16_l4_aligned(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-	do { \
-		uint32_t a0,a1,a2,a3; \
-		UNPACK(a0,a1,LP(src1),LP(src2)); \
-		UNPACK(a2,a3,LP(src3),LP(src4)); \
-		OP(LP(dst),rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LP(src1+4),LP(src2+4)); \
-		UNPACK(a2,a3,LP(src3+4),LP(src4+4)); \
-		OP(LP(dst+8),rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LP(src1+8),LP(src2+8)); \
-		UNPACK(a2,a3,LP(src3+8),LP(src4+8)); \
-		OP(LP(dst+8),rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LP(src1+12),LP(src2+12)); \
-		UNPACK(a2,a3,LP(src3+12),LP(src4+12)); \
-		OP(LP(dst+12),rnd_PACK(a0,a1,a2,a3)); \
-		src1+=src_stride1;\
-		src2+=src_stride2;\
-		src3+=src_stride3;\
-		src4+=src_stride4;\
-		dst+=dst_stride;\
-	} while(--h); \
-} \
-\
-static inline void OPNAME ## _no_rnd_pixels16_l4_aligned(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-	do { \
-		uint32_t a0,a1,a2,a3; \
-		UNPACK(a0,a1,LP(src1),LP(src2)); \
-		UNPACK(a2,a3,LP(src3),LP(src4)); \
-		OP(LP(dst),no_rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LP(src1+4),LP(src2+4)); \
-		UNPACK(a2,a3,LP(src3+4),LP(src4+4)); \
-		OP(LP(dst+4),no_rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LP(src1+8),LP(src2+8)); \
-		UNPACK(a2,a3,LP(src3+8),LP(src4+8)); \
-		OP(LP(dst+8),no_rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LP(src1+12),LP(src2+12)); \
-		UNPACK(a2,a3,LP(src3+12),LP(src4+12)); \
-		OP(LP(dst+12),no_rnd_PACK(a0,a1,a2,a3)); \
-		src1+=src_stride1;\
-		src2+=src_stride2;\
-		src3+=src_stride3;\
-		src4+=src_stride4;\
-		dst+=dst_stride;\
-	} while(--h); \
-} \
-\
-static inline void OPNAME ## _pixels16_l4_aligned0(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-	do { /* src1 is unaligned */\
-		uint32_t a0,a1,a2,a3; \
-		UNPACK(a0,a1,LD32(src1),LP(src2)); \
-		UNPACK(a2,a3,LP(src3),LP(src4)); \
-		OP(LP(dst),rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LD32(src1+4),LP(src2+4)); \
-		UNPACK(a2,a3,LP(src3+4),LP(src4+4)); \
-		OP(LP(dst+8),rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LD32(src1+8),LP(src2+8)); \
-		UNPACK(a2,a3,LP(src3+8),LP(src4+8)); \
-		OP(LP(dst+8),rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LD32(src1+12),LP(src2+12)); \
-		UNPACK(a2,a3,LP(src3+12),LP(src4+12)); \
-		OP(LP(dst+12),rnd_PACK(a0,a1,a2,a3)); \
-		src1+=src_stride1;\
-		src2+=src_stride2;\
-		src3+=src_stride3;\
-		src4+=src_stride4;\
-		dst+=dst_stride;\
-	} while(--h); \
-} \
-\
-static inline void OPNAME ## _no_rnd_pixels16_l4_aligned0(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-	do { \
-		uint32_t a0,a1,a2,a3; \
-		UNPACK(a0,a1,LD32(src1),LP(src2)); \
-		UNPACK(a2,a3,LP(src3),LP(src4)); \
-		OP(LP(dst),no_rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LD32(src1+4),LP(src2+4)); \
-		UNPACK(a2,a3,LP(src3+4),LP(src4+4)); \
-		OP(LP(dst+4),no_rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LD32(src1+8),LP(src2+8)); \
-		UNPACK(a2,a3,LP(src3+8),LP(src4+8)); \
-		OP(LP(dst+8),no_rnd_PACK(a0,a1,a2,a3)); \
-		UNPACK(a0,a1,LD32(src1+12),LP(src2+12)); \
-		UNPACK(a2,a3,LP(src3+12),LP(src4+12)); \
-		OP(LP(dst+12),no_rnd_PACK(a0,a1,a2,a3)); \
-		src1+=src_stride1;\
-		src2+=src_stride2;\
-		src3+=src_stride3;\
-		src4+=src_stride4;\
-		dst+=dst_stride;\
-	} while(--h); \
-} \
-\
-
-#define op_avg(a, b) a = rnd_avg32(a,b)
-#define op_put(a, b) a = b
-
-PIXOP2(avg, op_avg)
-PIXOP2(put, op_put)
-#undef op_avg
-#undef op_put
-
-#define avg2(a,b) ((a+b+1)>>1)
-#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
-
-
-static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h, int x16, int y16, int rounder)
-{
-    const int A=(16-x16)*(16-y16);
-    const int B=(   x16)*(16-y16);
-    const int C=(16-x16)*(   y16);
-    const int D=(   x16)*(   y16);
-
-    do {
-        int t0,t1,t2,t3;
-        uint8_t *s0 = src;
-        uint8_t *s1 = src+stride;
-        t0 = *s0++; t2 = *s1++;
-        t1 = *s0++; t3 = *s1++;
-        dst[0]= (A*t0 + B*t1 + C*t2 + D*t3 + rounder)>>8;
-        t0 = *s0++; t2 = *s1++;
-        dst[1]= (A*t1 + B*t0 + C*t3 + D*t2 + rounder)>>8;
-        t1 = *s0++; t3 = *s1++;
-        dst[2]= (A*t0 + B*t1 + C*t2 + D*t3 + rounder)>>8;
-        t0 = *s0++; t2 = *s1++;
-        dst[3]= (A*t1 + B*t0 + C*t3 + D*t2 + rounder)>>8;
-        t1 = *s0++; t3 = *s1++;
-        dst[4]= (A*t0 + B*t1 + C*t2 + D*t3 + rounder)>>8;
-        t0 = *s0++; t2 = *s1++;
-        dst[5]= (A*t1 + B*t0 + C*t3 + D*t2 + rounder)>>8;
-        t1 = *s0++; t3 = *s1++;
-        dst[6]= (A*t0 + B*t1 + C*t2 + D*t3 + rounder)>>8;
-        t0 = *s0++; t2 = *s1++;
-        dst[7]= (A*t1 + B*t0 + C*t3 + D*t2 + rounder)>>8;
-        dst+= stride;
-        src+= stride;
-    }while(--h);
-}
-
-static void gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy, 
-                  int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
-{
-    int y, vx, vy;
-    const int s= 1<<shift;
-    
-    width--;
-    height--;
-
-    for(y=0; y<h; y++){
-        int x;
-
-        vx= ox;
-        vy= oy;
-        for(x=0; x<8; x++){ //XXX FIXME optimize
-            int src_x, src_y, frac_x, frac_y, index;
-
-            src_x= vx>>16;
-            src_y= vy>>16;
-            frac_x= src_x&(s-1);
-            frac_y= src_y&(s-1);
-            src_x>>=shift;
-            src_y>>=shift;
-  
-            if((unsigned)src_x < width){
-                if((unsigned)src_y < height){
-                    index= src_x + src_y*stride;
-                    dst[y*stride + x]= (  (  src[index         ]*(s-frac_x)
-                                           + src[index       +1]*   frac_x )*(s-frac_y)
-                                        + (  src[index+stride  ]*(s-frac_x)
-                                           + src[index+stride+1]*   frac_x )*   frac_y
-                                        + r)>>(shift*2);
-                }else{
-                    index= src_x + clip(src_y, 0, height)*stride;                    
-                    dst[y*stride + x]= ( (  src[index         ]*(s-frac_x) 
-                                          + src[index       +1]*   frac_x )*s
-                                        + r)>>(shift*2);
-                }
-            }else{
-                if((unsigned)src_y < height){
-                    index= clip(src_x, 0, width) + src_y*stride;                    
-                    dst[y*stride + x]= (  (  src[index         ]*(s-frac_y) 
-                                           + src[index+stride  ]*   frac_y )*s
-                                        + r)>>(shift*2);
-                }else{
-                    index= clip(src_x, 0, width) + clip(src_y, 0, height)*stride;                    
-                    dst[y*stride + x]=    src[index         ];
-                }
-            }
-            
-            vx+= dxx;
-            vy+= dyx;
-        }
-        ox += dxy;
-        oy += dyy;
-    }
-}
-#define H264_CHROMA_MC(OPNAME, OP)\
-static void OPNAME ## h264_chroma_mc2_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
-    const int A=(8-x)*(8-y);\
-    const int B=(  x)*(8-y);\
-    const int C=(8-x)*(  y);\
-    const int D=(  x)*(  y);\
-    \
-    assert(x<8 && y<8 && x>=0 && y>=0);\
-\
-    do {\
-        int t0,t1,t2,t3; \
-        uint8_t *s0 = src; \
-        uint8_t *s1 = src+stride; \
-        t0 = *s0++; t2 = *s1++; \
-        t1 = *s0++; t3 = *s1++; \
-        OP(dst[0], (A*t0 + B*t1 + C*t2 + D*t3));\
-        t0 = *s0++; t2 = *s1++; \
-        OP(dst[1], (A*t1 + B*t0 + C*t3 + D*t2));\
-        dst+= stride;\
-        src+= stride;\
-    }while(--h);\
-}\
-\
-static void OPNAME ## h264_chroma_mc4_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
-    const int A=(8-x)*(8-y);\
-    const int B=(  x)*(8-y);\
-    const int C=(8-x)*(  y);\
-    const int D=(  x)*(  y);\
-    \
-    assert(x<8 && y<8 && x>=0 && y>=0);\
-\
-    do {\
-        int t0,t1,t2,t3; \
-        uint8_t *s0 = src; \
-        uint8_t *s1 = src+stride; \
-        t0 = *s0++; t2 = *s1++; \
-        t1 = *s0++; t3 = *s1++; \
-        OP(dst[0], (A*t0 + B*t1 + C*t2 + D*t3));\
-        t0 = *s0++; t2 = *s1++; \
-        OP(dst[1], (A*t1 + B*t0 + C*t3 + D*t2));\
-        t1 = *s0++; t3 = *s1++; \
-        OP(dst[2], (A*t0 + B*t1 + C*t2 + D*t3));\
-        t0 = *s0++; t2 = *s1++; \
-        OP(dst[3], (A*t1 + B*t0 + C*t3 + D*t2));\
-        dst+= stride;\
-        src+= stride;\
-    }while(--h);\
-}\
-\
-static void OPNAME ## h264_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
-    const int A=(8-x)*(8-y);\
-    const int B=(  x)*(8-y);\
-    const int C=(8-x)*(  y);\
-    const int D=(  x)*(  y);\
-    \
-    assert(x<8 && y<8 && x>=0 && y>=0);\
-\
-    do {\
-        int t0,t1,t2,t3; \
-        uint8_t *s0 = src; \
-        uint8_t *s1 = src+stride; \
-        t0 = *s0++; t2 = *s1++; \
-        t1 = *s0++; t3 = *s1++; \
-        OP(dst[0], (A*t0 + B*t1 + C*t2 + D*t3));\
-        t0 = *s0++; t2 = *s1++; \
-        OP(dst[1], (A*t1 + B*t0 + C*t3 + D*t2));\
-        t1 = *s0++; t3 = *s1++; \
-        OP(dst[2], (A*t0 + B*t1 + C*t2 + D*t3));\
-        t0 = *s0++; t2 = *s1++; \
-        OP(dst[3], (A*t1 + B*t0 + C*t3 + D*t2));\
-        t1 = *s0++; t3 = *s1++; \
-        OP(dst[4], (A*t0 + B*t1 + C*t2 + D*t3));\
-        t0 = *s0++; t2 = *s1++; \
-        OP(dst[5], (A*t1 + B*t0 + C*t3 + D*t2));\
-        t1 = *s0++; t3 = *s1++; \
-        OP(dst[6], (A*t0 + B*t1 + C*t2 + D*t3));\
-        t0 = *s0++; t2 = *s1++; \
-        OP(dst[7], (A*t1 + B*t0 + C*t3 + D*t2));\
-        dst+= stride;\
-        src+= stride;\
-    }while(--h);\
-}
-
-#define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
-#define op_put(a, b) a = (((b) + 32)>>6)
-
-H264_CHROMA_MC(put_       , op_put)
-H264_CHROMA_MC(avg_       , op_avg)
-#undef op_avg
-#undef op_put
-
-/* not yet optimized */
-static inline void copy_block4(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
-{
-    int i;
-    for(i=0; i<h; i++)
-    {
-        ST32(dst   , LD32(src   ));
-        dst+=dstStride;
-        src+=srcStride;
-    }
-}
-
-static inline void copy_block8(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
-{
-    int i;
-    for(i=0; i<h; i++)
-    {
-        ST32(dst   , LD32(src   ));
-        ST32(dst+4 , LD32(src+4 ));
-        dst+=dstStride;
-        src+=srcStride;
-    }
-}
-
-static inline void copy_block16(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
-{
-    int i;
-    for(i=0; i<h; i++)
-    {
-        ST32(dst   , LD32(src   ));
-        ST32(dst+4 , LD32(src+4 ));
-        ST32(dst+8 , LD32(src+8 ));
-        ST32(dst+12, LD32(src+12));
-        dst+=dstStride;
-        src+=srcStride;
-    }
-}
-
-static inline void copy_block17(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
-{
-    int i;
-    for(i=0; i<h; i++)
-    {
-        ST32(dst   , LD32(src   ));
-        ST32(dst+4 , LD32(src+4 ));
-        ST32(dst+8 , LD32(src+8 ));
-        ST32(dst+12, LD32(src+12));
-        dst[16]= src[16];
-        dst+=dstStride;
-        src+=srcStride;
-    }
-}
-
-static inline void copy_block9(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
-{
-    int i;
-    for(i=0; i<h; i++)
-    {
-        ST32(dst   , LD32(src   ));
-        ST32(dst+4 , LD32(src+4 ));
-        dst[8]= src[8];
-        dst+=dstStride;
-        src+=srcStride;
-    }
-}
-/* end not optimized */
-
-#define QPEL_MC(r, OPNAME, RND, OP) \
-static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    do {\
-        uint8_t *s = src; \
-        int src0,src1,src2,src3,src4,src5,src6,src7,src8;\
-        src0= *s++;\
-        src1= *s++;\
-        src2= *s++;\
-        src3= *s++;\
-        src4= *s++;\
-        OP(dst[0], (src0+src1)*20 - (src0+src2)*6 + (src1+src3)*3 - (src2+src4));\
-        src5= *s++;\
-        OP(dst[1], (src1+src2)*20 - (src0+src3)*6 + (src0+src4)*3 - (src1+src5));\
-        src6= *s++;\
-        OP(dst[2], (src2+src3)*20 - (src1+src4)*6 + (src0+src5)*3 - (src0+src6));\
-        src7= *s++;\
-        OP(dst[3], (src3+src4)*20 - (src2+src5)*6 + (src1+src6)*3 - (src0+src7));\
-        src8= *s++;\
-        OP(dst[4], (src4+src5)*20 - (src3+src6)*6 + (src2+src7)*3 - (src1+src8));\
-        OP(dst[5], (src5+src6)*20 - (src4+src7)*6 + (src3+src8)*3 - (src2+src8));\
-        OP(dst[6], (src6+src7)*20 - (src5+src8)*6 + (src4+src8)*3 - (src3+src7));\
-        OP(dst[7], (src7+src8)*20 - (src6+src8)*6 + (src5+src7)*3 - (src4+src6));\
-        dst+=dstStride;\
-        src+=srcStride;\
-    }while(--h);\
-}\
-\
-static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    int w=8;\
-    do{\
-        uint8_t *s = src, *d=dst;\
-        int src0,src1,src2,src3,src4,src5,src6,src7,src8;\
-        src0 = *s; s+=srcStride; \
-        src1 = *s; s+=srcStride; \
-        src2 = *s; s+=srcStride; \
-        src3 = *s; s+=srcStride; \
-        src4 = *s; s+=srcStride; \
-        OP(*d, (src0+src1)*20 - (src0+src2)*6 + (src1+src3)*3 - (src2+src4));d+=dstStride;\
-        src5 = *s; s+=srcStride; \
-        OP(*d, (src1+src2)*20 - (src0+src3)*6 + (src0+src4)*3 - (src1+src5));d+=dstStride;\
-        src6 = *s; s+=srcStride; \
-        OP(*d, (src2+src3)*20 - (src1+src4)*6 + (src0+src5)*3 - (src0+src6));d+=dstStride;\
-        src7 = *s; s+=srcStride; \
-        OP(*d, (src3+src4)*20 - (src2+src5)*6 + (src1+src6)*3 - (src0+src7));d+=dstStride;\
-        src8 = *s; \
-        OP(*d, (src4+src5)*20 - (src3+src6)*6 + (src2+src7)*3 - (src1+src8));d+=dstStride;\
-        OP(*d, (src5+src6)*20 - (src4+src7)*6 + (src3+src8)*3 - (src2+src8));d+=dstStride;\
-        OP(*d, (src6+src7)*20 - (src5+src8)*6 + (src4+src8)*3 - (src3+src7));d+=dstStride;\
-        OP(*d, (src7+src8)*20 - (src6+src8)*6 + (src5+src7)*3 - (src4+src6));\
-        dst++;\
-        src++;\
-    }while(--w);\
-}\
-\
-static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    do {\
-        uint8_t *s = src;\
-        int src0,src1,src2,src3,src4,src5,src6,src7,src8;\
-        int src9,src10,src11,src12,src13,src14,src15,src16;\
-        src0= *s++;\
-        src1= *s++;\
-        src2= *s++;\
-        src3= *s++;\
-        src4= *s++;\
-        OP(dst[ 0], (src0 +src1 )*20 - (src0 +src2 )*6 + (src1 +src3 )*3 - (src2 +src4 ));\
-        src5= *s++;\
-        OP(dst[ 1], (src1 +src2 )*20 - (src0 +src3 )*6 + (src0 +src4 )*3 - (src1 +src5 ));\
-        src6= *s++;\
-        OP(dst[ 2], (src2 +src3 )*20 - (src1 +src4 )*6 + (src0 +src5 )*3 - (src0 +src6 ));\
-        src7= *s++;\
-        OP(dst[ 3], (src3 +src4 )*20 - (src2 +src5 )*6 + (src1 +src6 )*3 - (src0 +src7 ));\
-        src8= *s++;\
-        OP(dst[ 4], (src4 +src5 )*20 - (src3 +src6 )*6 + (src2 +src7 )*3 - (src1 +src8 ));\
-        src9= *s++;\
-        OP(dst[ 5], (src5 +src6 )*20 - (src4 +src7 )*6 + (src3 +src8 )*3 - (src2 +src9 ));\
-        src10= *s++;\
-        OP(dst[ 6], (src6 +src7 )*20 - (src5 +src8 )*6 + (src4 +src9 )*3 - (src3 +src10));\
-        src11= *s++;\
-        OP(dst[ 7], (src7 +src8 )*20 - (src6 +src9 )*6 + (src5 +src10)*3 - (src4 +src11));\
-        src12= *s++;\
-        OP(dst[ 8], (src8 +src9 )*20 - (src7 +src10)*6 + (src6 +src11)*3 - (src5 +src12));\
-        src13= *s++;\
-        OP(dst[ 9], (src9 +src10)*20 - (src8 +src11)*6 + (src7 +src12)*3 - (src6 +src13));\
-        src14= *s++;\
-        OP(dst[10], (src10+src11)*20 - (src9 +src12)*6 + (src8 +src13)*3 - (src7 +src14));\
-        src15= *s++;\
-        OP(dst[11], (src11+src12)*20 - (src10+src13)*6 + (src9 +src14)*3 - (src8 +src15));\
-        src16= *s++;\
-        OP(dst[12], (src12+src13)*20 - (src11+src14)*6 + (src10+src15)*3 - (src9 +src16));\
-        OP(dst[13], (src13+src14)*20 - (src12+src15)*6 + (src11+src16)*3 - (src10+src16));\
-        OP(dst[14], (src14+src15)*20 - (src13+src16)*6 + (src12+src16)*3 - (src11+src15));\
-        OP(dst[15], (src15+src16)*20 - (src14+src16)*6 + (src13+src15)*3 - (src12+src14));\
-        dst+=dstStride;\
-        src+=srcStride;\
-    }while(--h);\
-}\
-\
-static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    int w=16;\
-    do {\
-        uint8_t *s = src, *d=dst;\
-        int src0,src1,src2,src3,src4,src5,src6,src7,src8;\
-        int src9,src10,src11,src12,src13,src14,src15,src16;\
-        src0 = *s; s+=srcStride; \
-        src1 = *s; s+=srcStride; \
-        src2 = *s; s+=srcStride; \
-        src3 = *s; s+=srcStride; \
-        src4 = *s; s+=srcStride; \
-        OP(*d, (src0 +src1 )*20 - (src0 +src2 )*6 + (src1 +src3 )*3 - (src2 +src4 ));d+=dstStride;\
-        src5 = *s; s+=srcStride; \
-        OP(*d, (src1 +src2 )*20 - (src0 +src3 )*6 + (src0 +src4 )*3 - (src1 +src5 ));d+=dstStride;\
-        src6 = *s; s+=srcStride; \
-        OP(*d, (src2 +src3 )*20 - (src1 +src4 )*6 + (src0 +src5 )*3 - (src0 +src6 ));d+=dstStride;\
-        src7 = *s; s+=srcStride; \
-        OP(*d, (src3 +src4 )*20 - (src2 +src5 )*6 + (src1 +src6 )*3 - (src0 +src7 ));d+=dstStride;\
-        src8 = *s; s+=srcStride; \
-        OP(*d, (src4 +src5 )*20 - (src3 +src6 )*6 + (src2 +src7 )*3 - (src1 +src8 ));d+=dstStride;\
-        src9 = *s; s+=srcStride; \
-        OP(*d, (src5 +src6 )*20 - (src4 +src7 )*6 + (src3 +src8 )*3 - (src2 +src9 ));d+=dstStride;\
-        src10 = *s; s+=srcStride; \
-        OP(*d, (src6 +src7 )*20 - (src5 +src8 )*6 + (src4 +src9 )*3 - (src3 +src10));d+=dstStride;\
-        src11 = *s; s+=srcStride; \
-        OP(*d, (src7 +src8 )*20 - (src6 +src9 )*6 + (src5 +src10)*3 - (src4 +src11));d+=dstStride;\
-        src12 = *s; s+=srcStride; \
-        OP(*d, (src8 +src9 )*20 - (src7 +src10)*6 + (src6 +src11)*3 - (src5 +src12));d+=dstStride;\
-        src13 = *s; s+=srcStride; \
-        OP(*d, (src9 +src10)*20 - (src8 +src11)*6 + (src7 +src12)*3 - (src6 +src13));d+=dstStride;\
-        src14 = *s; s+=srcStride; \
-        OP(*d, (src10+src11)*20 - (src9 +src12)*6 + (src8 +src13)*3 - (src7 +src14));d+=dstStride;\
-        src15 = *s; s+=srcStride; \
-        OP(*d, (src11+src12)*20 - (src10+src13)*6 + (src9 +src14)*3 - (src8 +src15));d+=dstStride;\
-        src16 = *s; \
-        OP(*d, (src12+src13)*20 - (src11+src14)*6 + (src10+src15)*3 - (src9 +src16));d+=dstStride;\
-        OP(*d, (src13+src14)*20 - (src12+src15)*6 + (src11+src16)*3 - (src10+src16));d+=dstStride;\
-        OP(*d, (src14+src15)*20 - (src13+src16)*6 + (src12+src16)*3 - (src11+src15));d+=dstStride;\
-        OP(*d, (src15+src16)*20 - (src14+src16)*6 + (src13+src15)*3 - (src12+src14));\
-        dst++;\
-        src++;\
-    }while(--w);\
-}\
-\
-static void OPNAME ## qpel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## pixels8_c(dst, src, stride, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t half[64];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
-    OPNAME ## pixels8_l2_aligned2(dst, src, half, stride, stride, 8, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t half[64];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
-    OPNAME ## pixels8_l2_aligned2(dst, src+1, half, stride, stride, 8, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t half[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
-    OPNAME ## pixels8_l2_aligned(dst, full, half, stride, 16, 8, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    copy_block9(full, src, 16, stride, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16);\
-}\
-\
-static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t half[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
-    OPNAME ## pixels8_l2_aligned(dst, full+16, half, stride, 16, 8, 8);\
-}\
-static void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l4_aligned(dst, full, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2_aligned(halfH, halfH, full, 8, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_aligned(dst, halfH, halfHV, stride, 8, 8, 8);\
-}\
-static void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l4_aligned0(dst, full+1, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2_aligned1(halfH, halfH, full+1, 8, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_aligned(dst, halfH, halfHV, stride, 8, 8, 8);\
-}\
-static void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l4_aligned(dst, full+16, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2_aligned(halfH, halfH, full, 8, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_aligned(dst, halfH+8, halfHV, stride, 8, 8, 8);\
-}\
-static void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full  , 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l4_aligned0(dst, full+17, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2_aligned1(halfH, halfH, full+1, 8, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_aligned(dst, halfH+8, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_aligned(dst, halfH, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_aligned(dst, halfH+8, halfHV, stride, 8, 8, 8);\
-}\
-static void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_aligned(dst, halfV, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2_aligned(halfH, halfH, full, 8, 8, 16, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
-}\
-static void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_aligned(dst, halfV, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2_aligned1(halfH, halfH, full+1, 8, 8, 16, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
-}\
-static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t halfH[72];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
-}\
-static void OPNAME ## qpel16_mc00_c (uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## pixels16_c(dst, src, stride, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t half[256];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
-    OPNAME ## pixels16_l2_aligned2(dst, src, half, stride, stride, 16, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t half[256];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
-    OPNAME ## pixels16_l2_aligned2(dst, src+1, half, stride, stride, 16, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t half[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
-    OPNAME ## pixels16_l2_aligned(dst, full, half, stride, 24, 16, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    copy_block17(full, src, 24, stride, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24);\
-}\
-\
-static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t half[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
-    OPNAME ## pixels16_l2_aligned(dst, full+24, half, stride, 24, 16, 16);\
-}\
-static void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l4_aligned(dst, full, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2_aligned(halfH, halfH, full, 16, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_aligned(dst, halfH, halfHV, stride, 16, 16, 16);\
-}\
-static void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l4_aligned0(dst, full+1, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2_aligned1(halfH, halfH, full+1, 16, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_aligned(dst, halfH, halfHV, stride, 16, 16, 16);\
-}\
-static void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l4_aligned(dst, full+24, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2_aligned(halfH, halfH, full, 16, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_aligned(dst, halfH+16, halfHV, stride, 16, 16, 16);\
-}\
-static void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full  , 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l4_aligned0(dst, full+25, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2_aligned1(halfH, halfH, full+1, 16, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_aligned(dst, halfH+16, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_aligned(dst, halfH, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_aligned(dst, halfH+16, halfHV, stride, 16, 16, 16);\
-}\
-static void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_aligned(dst, halfV, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2_aligned(halfH, halfH, full, 16, 16, 24, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
-}\
-static void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_aligned(dst, halfV, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2_aligned1(halfH, halfH, full+1, 16, 16, 24, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
-}\
-static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t halfH[272];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
-}
-
-#define op_avg(a, b) a = (((a)+cm[((b) + 16)>>5]+1)>>1)
-#define op_avg_no_rnd(a, b) a = (((a)+cm[((b) + 15)>>5])>>1)
-#define op_put(a, b) a = cm[((b) + 16)>>5]
-#define op_put_no_rnd(a, b) a = cm[((b) + 15)>>5]
-
-QPEL_MC(0, put_       , _       , op_put)
-QPEL_MC(1, put_no_rnd_, _no_rnd_, op_put_no_rnd)
-QPEL_MC(0, avg_       , _       , op_avg)
-//QPEL_MC(1, avg_no_rnd , _       , op_avg)
-#undef op_avg
-#undef op_avg_no_rnd
-#undef op_put
-#undef op_put_no_rnd
-
-#if 1
-#define H264_LOWPASS(OPNAME, OP, OP2) \
-static inline void OPNAME ## h264_qpel_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride,int w,int h){\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    do {\
-        int srcB,srcA,src0,src1,src2,src3,src4,src5,src6;\
-        uint8_t *s = src-2;\
-        srcB = *s++;\
-        srcA = *s++;\
-        src0 = *s++;\
-        src1 = *s++;\
-        src2 = *s++;\
-        src3 = *s++;\
-        OP(dst[0], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
-        src4 = *s++;\
-        OP(dst[1], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
-        src5 = *s++;\
-        OP(dst[2], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
-        src6 = *s++;\
-        OP(dst[3], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
-      if (w>4) { /* it optimized */ \
-        int src7,src8,src9,src10; \
-        src7 = *s++;\
-        OP(dst[4], (src4+src5)*20 - (src3+src6)*5 + (src2+src7));\
-        src8 = *s++;\
-        OP(dst[5], (src5+src6)*20 - (src4+src7)*5 + (src3+src8));\
-        src9 = *s++;\
-        OP(dst[6], (src6+src7)*20 - (src5+src8)*5 + (src4+src9));\
-        src10 = *s++;\
-        OP(dst[7], (src7+src8)*20 - (src6+src9)*5 + (src5+src10));\
-       if (w>8) { \
-        int src11,src12,src13,src14,src15,src16,src17,src18; \
-        src11 = *s++;\
-        OP(dst[8] , (src8 +src9 )*20 - (src7 +src10)*5 + (src6 +src11));\
-        src12 = *s++;\
-        OP(dst[9] , (src9 +src10)*20 - (src8 +src11)*5 + (src7 +src12));\
-        src13 = *s++;\
-        OP(dst[10], (src10+src11)*20 - (src9 +src12)*5 + (src8 +src13));\
-        src14 = *s++;\
-        OP(dst[11], (src11+src12)*20 - (src10+src13)*5 + (src9 +src14));\
-        src15 = *s++;\
-        OP(dst[12], (src12+src13)*20 - (src11+src14)*5 + (src10+src15));\
-        src16 = *s++;\
-        OP(dst[13], (src13+src14)*20 - (src12+src15)*5 + (src11+src16));\
-        src17 = *s++;\
-        OP(dst[14], (src14+src15)*20 - (src13+src16)*5 + (src12+src17));\
-        src18 = *s++;\
-        OP(dst[15], (src15+src16)*20 - (src14+src17)*5 + (src13+src18));\
-       } \
-      } \
-        dst+=dstStride;\
-        src+=srcStride;\
-    }while(--h);\
-}\
-\
-static inline void OPNAME ## h264_qpel_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride,int w,int h){\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    do{\
-        int srcB,srcA,src0,src1,src2,src3,src4,src5,src6;\
-        uint8_t *s = src-2*srcStride,*d=dst;\
-        srcB = *s; s+=srcStride;\
-        srcA = *s; s+=srcStride;\
-        src0 = *s; s+=srcStride;\
-        src1 = *s; s+=srcStride;\
-        src2 = *s; s+=srcStride;\
-        src3 = *s; s+=srcStride;\
-        OP(*d, (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));d+=dstStride;\
-        src4 = *s; s+=srcStride;\
-        OP(*d, (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));d+=dstStride;\
-        src5 = *s; s+=srcStride;\
-        OP(*d, (src2+src3)*20 - (src1+src4)*5 + (src0+src5));d+=dstStride;\
-        src6 = *s; s+=srcStride;\
-        OP(*d, (src3+src4)*20 - (src2+src5)*5 + (src1+src6));d+=dstStride;\
-      if (h>4) { \
-        int src7,src8,src9,src10; \
-        src7 = *s; s+=srcStride;\
-        OP(*d, (src4+src5)*20 - (src3+src6)*5 + (src2+src7));d+=dstStride;\
-        src8 = *s; s+=srcStride;\
-        OP(*d, (src5+src6)*20 - (src4+src7)*5 + (src3+src8));d+=dstStride;\
-        src9 = *s; s+=srcStride;\
-        OP(*d, (src6+src7)*20 - (src5+src8)*5 + (src4+src9));d+=dstStride;\
-        src10 = *s; s+=srcStride;\
-        OP(*d, (src7+src8)*20 - (src6+src9)*5 + (src5+src10));d+=dstStride;\
-       if (h>8) { \
-        int src11,src12,src13,src14,src15,src16,src17,src18; \
-        src11 = *s; s+=srcStride;\
-        OP(*d , (src8 +src9 )*20 - (src7 +src10)*5 + (src6 +src11));d+=dstStride;\
-        src12 = *s; s+=srcStride;\
-        OP(*d , (src9 +src10)*20 - (src8 +src11)*5 + (src7 +src12));d+=dstStride;\
-        src13 = *s; s+=srcStride;\
-        OP(*d, (src10+src11)*20 - (src9 +src12)*5 + (src8 +src13));d+=dstStride;\
-        src14 = *s; s+=srcStride;\
-        OP(*d, (src11+src12)*20 - (src10+src13)*5 + (src9 +src14));d+=dstStride;\
-        src15 = *s; s+=srcStride;\
-        OP(*d, (src12+src13)*20 - (src11+src14)*5 + (src10+src15));d+=dstStride;\
-        src16 = *s; s+=srcStride;\
-        OP(*d, (src13+src14)*20 - (src12+src15)*5 + (src11+src16));d+=dstStride;\
-        src17 = *s; s+=srcStride;\
-        OP(*d, (src14+src15)*20 - (src13+src16)*5 + (src12+src17));d+=dstStride;\
-        src18 = *s; s+=srcStride;\
-        OP(*d, (src15+src16)*20 - (src14+src17)*5 + (src13+src18));d+=dstStride;\
-       } \
-      } \
-        dst++;\
-        src++;\
-    }while(--w);\
-}\
-\
-static inline void OPNAME ## h264_qpel_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride,int w,int h){\
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;\
-    int i;\
-    src -= 2*srcStride;\
-    i= h+5; \
-    do {\
-        int srcB,srcA,src0,src1,src2,src3,src4,src5,src6;\
-        uint8_t *s = src-2;\
-        srcB = *s++;\
-        srcA = *s++;\
-        src0 = *s++;\
-        src1 = *s++;\
-        src2 = *s++;\
-        src3 = *s++;\
-        tmp[0] = ((src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
-        src4 = *s++;\
-        tmp[1] = ((src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
-        src5 = *s++;\
-        tmp[2] = ((src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
-        src6 = *s++;\
-        tmp[3] = ((src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
-      if (w>4) { /* it optimized */ \
-        int src7,src8,src9,src10; \
-        src7 = *s++;\
-        tmp[4] = ((src4+src5)*20 - (src3+src6)*5 + (src2+src7));\
-        src8 = *s++;\
-        tmp[5] = ((src5+src6)*20 - (src4+src7)*5 + (src3+src8));\
-        src9 = *s++;\
-        tmp[6] = ((src6+src7)*20 - (src5+src8)*5 + (src4+src9));\
-        src10 = *s++;\
-        tmp[7] = ((src7+src8)*20 - (src6+src9)*5 + (src5+src10));\
-       if (w>8) { \
-        int src11,src12,src13,src14,src15,src16,src17,src18; \
-        src11 = *s++;\
-        tmp[8] = ((src8 +src9 )*20 - (src7 +src10)*5 + (src6 +src11));\
-        src12 = *s++;\
-        tmp[9] = ((src9 +src10)*20 - (src8 +src11)*5 + (src7 +src12));\
-        src13 = *s++;\
-        tmp[10] = ((src10+src11)*20 - (src9 +src12)*5 + (src8 +src13));\
-        src14 = *s++;\
-        tmp[11] = ((src11+src12)*20 - (src10+src13)*5 + (src9 +src14));\
-        src15 = *s++;\
-        tmp[12] = ((src12+src13)*20 - (src11+src14)*5 + (src10+src15));\
-        src16 = *s++;\
-        tmp[13] = ((src13+src14)*20 - (src12+src15)*5 + (src11+src16));\
-        src17 = *s++;\
-        tmp[14] = ((src14+src15)*20 - (src13+src16)*5 + (src12+src17));\
-        src18 = *s++;\
-        tmp[15] = ((src15+src16)*20 - (src14+src17)*5 + (src13+src18));\
-       } \
-      } \
-        tmp+=tmpStride;\
-        src+=srcStride;\
-    }while(--i);\
-    tmp -= tmpStride*(h+5-2);\
-    i = w; \
-    do {\
-        int tmpB,tmpA,tmp0,tmp1,tmp2,tmp3,tmp4,tmp5,tmp6;\
-        int16_t *s = tmp-2*tmpStride; \
-        uint8_t *d=dst;\
-        tmpB = *s; s+=tmpStride;\
-        tmpA = *s; s+=tmpStride;\
-        tmp0 = *s; s+=tmpStride;\
-        tmp1 = *s; s+=tmpStride;\
-        tmp2 = *s; s+=tmpStride;\
-        tmp3 = *s; s+=tmpStride;\
-        OP2(*d, (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));d+=dstStride;\
-        tmp4 = *s; s+=tmpStride;\
-        OP2(*d, (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));d+=dstStride;\
-        tmp5 = *s; s+=tmpStride;\
-        OP2(*d, (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));d+=dstStride;\
-        tmp6 = *s; s+=tmpStride;\
-        OP2(*d, (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));d+=dstStride;\
-      if (h>4) { \
-        int tmp7,tmp8,tmp9,tmp10; \
-        tmp7 = *s; s+=tmpStride;\
-        OP2(*d, (tmp4+tmp5)*20 - (tmp3+tmp6)*5 + (tmp2+tmp7));d+=dstStride;\
-        tmp8 = *s; s+=tmpStride;\
-        OP2(*d, (tmp5+tmp6)*20 - (tmp4+tmp7)*5 + (tmp3+tmp8));d+=dstStride;\
-        tmp9 = *s; s+=tmpStride;\
-        OP2(*d, (tmp6+tmp7)*20 - (tmp5+tmp8)*5 + (tmp4+tmp9));d+=dstStride;\
-        tmp10 = *s; s+=tmpStride;\
-        OP2(*d, (tmp7+tmp8)*20 - (tmp6+tmp9)*5 + (tmp5+tmp10));d+=dstStride;\
-       if (h>8) { \
-        int tmp11,tmp12,tmp13,tmp14,tmp15,tmp16,tmp17,tmp18; \
-        tmp11 = *s; s+=tmpStride;\
-        OP2(*d , (tmp8 +tmp9 )*20 - (tmp7 +tmp10)*5 + (tmp6 +tmp11));d+=dstStride;\
-        tmp12 = *s; s+=tmpStride;\
-        OP2(*d , (tmp9 +tmp10)*20 - (tmp8 +tmp11)*5 + (tmp7 +tmp12));d+=dstStride;\
-        tmp13 = *s; s+=tmpStride;\
-        OP2(*d, (tmp10+tmp11)*20 - (tmp9 +tmp12)*5 + (tmp8 +tmp13));d+=dstStride;\
-        tmp14 = *s; s+=tmpStride;\
-        OP2(*d, (tmp11+tmp12)*20 - (tmp10+tmp13)*5 + (tmp9 +tmp14));d+=dstStride;\
-        tmp15 = *s; s+=tmpStride;\
-        OP2(*d, (tmp12+tmp13)*20 - (tmp11+tmp14)*5 + (tmp10+tmp15));d+=dstStride;\
-        tmp16 = *s; s+=tmpStride;\
-        OP2(*d, (tmp13+tmp14)*20 - (tmp12+tmp15)*5 + (tmp11+tmp16));d+=dstStride;\
-        tmp17 = *s; s+=tmpStride;\
-        OP2(*d, (tmp14+tmp15)*20 - (tmp13+tmp16)*5 + (tmp12+tmp17));d+=dstStride;\
-        tmp18 = *s; s+=tmpStride;\
-        OP2(*d, (tmp15+tmp16)*20 - (tmp14+tmp17)*5 + (tmp13+tmp18));d+=dstStride;\
-       } \
-      } \
-        dst++;\
-        tmp++;\
-    }while(--i);\
-}\
-\
-static void OPNAME ## h264_qpel4_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    OPNAME ## h264_qpel_h_lowpass(dst,src,dstStride,srcStride,4,4); \
-}\
-static void OPNAME ## h264_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-   OPNAME ## h264_qpel_h_lowpass(dst,src,dstStride,srcStride,8,8); \
-}\
-static void OPNAME ## h264_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-   OPNAME ## h264_qpel_h_lowpass(dst,src,dstStride,srcStride,16,16); \
-}\
-\
-static void OPNAME ## h264_qpel4_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-   OPNAME ## h264_qpel_v_lowpass(dst,src,dstStride,srcStride,4,4); \
-}\
-static void OPNAME ## h264_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-   OPNAME ## h264_qpel_v_lowpass(dst,src,dstStride,srcStride,8,8); \
-}\
-static void OPNAME ## h264_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-   OPNAME ## h264_qpel_v_lowpass(dst,src,dstStride,srcStride,16,16); \
-}\
-static void OPNAME ## h264_qpel4_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
-   OPNAME ## h264_qpel_hv_lowpass(dst,tmp,src,dstStride,tmpStride,srcStride,4,4); \
-}\
-static void OPNAME ## h264_qpel8_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
-   OPNAME ## h264_qpel_hv_lowpass(dst,tmp,src,dstStride,tmpStride,srcStride,8,8); \
-}\
-static void OPNAME ## h264_qpel16_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
-   OPNAME ## h264_qpel_hv_lowpass(dst,tmp,src,dstStride,tmpStride,srcStride,16,16); \
-}\
-
-#define H264_MC(OPNAME, SIZE) \
-static void OPNAME ## h264_qpel ## SIZE ## _mc00_c (uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## pixels ## SIZE ## _c(dst, src, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t half[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(half, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_aligned2(dst, src, half, stride, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc20_c(uint8_t *dst, uint8_t *src, int stride){\
-    OPNAME ## h264_qpel ## SIZE ## _h_lowpass(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc30_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t half[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(half, src, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_aligned2(dst, src+1, half, stride, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    uint8_t half[SIZE*SIZE];\
-    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(half, full_mid, SIZE, SIZE);\
-    OPNAME ## pixels ## SIZE ## _l2_aligned(dst, full_mid, half, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc02_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
-    OPNAME ## h264_qpel ## SIZE ## _v_lowpass(dst, full_mid, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc03_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    uint8_t half[SIZE*SIZE];\
-    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(half, full_mid, SIZE, SIZE);\
-    OPNAME ## pixels ## SIZE ## _l2_aligned(dst, full_mid+SIZE, half, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    uint8_t halfH[SIZE*SIZE];\
-    uint8_t halfV[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\
-    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
-    OPNAME ## pixels ## SIZE ## _l2_aligned(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc31_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    uint8_t halfH[SIZE*SIZE];\
-    uint8_t halfV[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\
-    copy_block ## SIZE (full, src - stride*2 + 1, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
-    OPNAME ## pixels ## SIZE ## _l2_aligned(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc13_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    uint8_t halfH[SIZE*SIZE];\
-    uint8_t halfV[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\
-    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
-    OPNAME ## pixels ## SIZE ## _l2_aligned(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc33_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    uint8_t halfH[SIZE*SIZE];\
-    uint8_t halfV[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\
-    copy_block ## SIZE (full, src - stride*2 + 1, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
-    OPNAME ## pixels ## SIZE ## _l2_aligned(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\
-    int16_t tmp[SIZE*(SIZE+5)];\
-    OPNAME ## h264_qpel ## SIZE ## _hv_lowpass(dst, tmp, src, stride, SIZE, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\
-    int16_t tmp[SIZE*(SIZE+5)];\
-    uint8_t halfH[SIZE*SIZE];\
-    uint8_t halfHV[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_aligned(dst, halfH, halfHV, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc23_c(uint8_t *dst, uint8_t *src, int stride){\
-    int16_t tmp[SIZE*(SIZE+5)];\
-    uint8_t halfH[SIZE*SIZE];\
-    uint8_t halfHV[SIZE*SIZE];\
-    put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\
-    put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_aligned(dst, halfH, halfHV, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    int16_t tmp[SIZE*(SIZE+5)];\
-    uint8_t halfV[SIZE*SIZE];\
-    uint8_t halfHV[SIZE*SIZE];\
-    copy_block ## SIZE (full, src - stride*2, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
-    put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_aligned(dst, halfV, halfHV, stride, SIZE, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc32_c(uint8_t *dst, uint8_t *src, int stride){\
-    uint8_t full[SIZE*(SIZE+5)];\
-    uint8_t * const full_mid= full + SIZE*2;\
-    int16_t tmp[SIZE*(SIZE+5)];\
-    uint8_t halfV[SIZE*SIZE];\
-    uint8_t halfHV[SIZE*SIZE];\
-    copy_block ## SIZE (full, src - stride*2 + 1, SIZE,  stride, SIZE + 5);\
-    put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
-    put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
-    OPNAME ## pixels ## SIZE ## _l2_aligned(dst, halfV, halfHV, stride, SIZE, SIZE, SIZE);\
-}\
-
-#define op_avg(a, b)  a = (((a)+cm[((b) + 16)>>5]+1)>>1)
-//#define op_avg2(a, b) a = (((a)*w1+cm[((b) + 16)>>5]*w2 + o + 64)>>7)
-#define op_put(a, b)  a = cm[((b) + 16)>>5]
-#define op2_avg(a, b)  a = (((a)+cm[((b) + 512)>>10]+1)>>1)
-#define op2_put(a, b)  a = cm[((b) + 512)>>10]
-
-H264_LOWPASS(put_       , op_put, op2_put)
-H264_LOWPASS(avg_       , op_avg, op2_avg)
-H264_MC(put_, 4)
-H264_MC(put_, 8)
-H264_MC(put_, 16)
-H264_MC(avg_, 4)
-H264_MC(avg_, 8)
-H264_MC(avg_, 16)
-
-#undef op_avg
-#undef op_put
-#undef op2_avg
-#undef op2_put
-#endif
-
-static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-    do{
-        int src_1,src0,src1,src2,src3,src4,src5,src6,src7,src8,src9;
-        uint8_t *s = src;
-        src_1 = s[-1];
-        src0 = *s++;
-        src1 = *s++;
-        src2 = *s++;
-        dst[0]= cm[(9*(src0 + src1) - (src_1 + src2) + 8)>>4];
-        src3 = *s++;
-        dst[1]= cm[(9*(src1 + src2) - (src0 + src3) + 8)>>4];
-        src4 = *s++;
-        dst[2]= cm[(9*(src2 + src3) - (src1 + src4) + 8)>>4];
-        src5 = *s++;
-        dst[3]= cm[(9*(src3 + src4) - (src2 + src5) + 8)>>4];
-        src6 = *s++;
-        dst[4]= cm[(9*(src4 + src5) - (src3 + src6) + 8)>>4];
-        src7 = *s++;
-        dst[5]= cm[(9*(src5 + src6) - (src4 + src7) + 8)>>4];
-        src8 = *s++;
-        dst[6]= cm[(9*(src6 + src7) - (src5 + src8) + 8)>>4];
-        src9 = *s++;
-        dst[7]= cm[(9*(src7 + src8) - (src6 + src9) + 8)>>4];
-        dst+=dstStride;
-        src+=srcStride;        
-    }while(--h);
-}
-
-static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-    do{
-        int src_1,src0,src1,src2,src3,src4,src5,src6,src7,src8,src9;
-        uint8_t *s = src,*d = dst;
-        src_1 = *(s-srcStride);
-        src0 = *s; s+=srcStride;
-        src1 = *s; s+=srcStride;
-        src2 = *s; s+=srcStride;
-        *d= cm[(9*(src0 + src1) - (src_1 + src2) + 8)>>4]; d+=dstStride;
-        src3 = *s; s+=srcStride;
-        *d= cm[(9*(src1 + src2) - (src0  + src3) + 8)>>4]; d+=dstStride;
-        src4 = *s; s+=srcStride;
-        *d= cm[(9*(src2 + src3) - (src1  + src4) + 8)>>4]; d+=dstStride;
-        src5 = *s; s+=srcStride;
-        *d= cm[(9*(src3 + src4) - (src2  + src5) + 8)>>4]; d+=dstStride;
-        src6 = *s; s+=srcStride;
-        *d= cm[(9*(src4 + src5) - (src3  + src6) + 8)>>4]; d+=dstStride;
-        src7 = *s; s+=srcStride;
-        *d= cm[(9*(src5 + src6) - (src4  + src7) + 8)>>4]; d+=dstStride;
-        src8 = *s; s+=srcStride;
-        *d= cm[(9*(src6 + src7) - (src5  + src8) + 8)>>4]; d+=dstStride;
-        src9 = *s;
-        *d= cm[(9*(src7 + src8) - (src6  + src9) + 8)>>4]; d+=dstStride;
-        src++;
-        dst++;
-    }while(--w);
-}
-
-static void put_mspel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){
-    put_pixels8_c(dst, src, stride, 8);
-}
-
-static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){
-    uint8_t half[64];
-    wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
-    put_pixels8_l2_aligned2(dst, src, half, stride, stride, 8, 8);
-}
-
-static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){
-    wmv2_mspel8_h_lowpass(dst, src, stride, stride, 8);
-}
-
-static void put_mspel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){
-    uint8_t half[64];
-    wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
-    put_pixels8_l2_aligned2(dst, src+1, half, stride, stride, 8, 8);
-}
-
-static void put_mspel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){
-    wmv2_mspel8_v_lowpass(dst, src, stride, stride, 8);
-}
-
-static void put_mspel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){
-    uint8_t halfH[88];
-    uint8_t halfV[64];
-    uint8_t halfHV[64];
-    wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
-    wmv2_mspel8_v_lowpass(halfV, src, 8, stride, 8);
-    wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8);
-    put_pixels8_l2_aligned(dst, halfV, halfHV, stride, 8, 8, 8);
-}
-static void put_mspel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){
-    uint8_t halfH[88];
-    uint8_t halfV[64];
-    uint8_t halfHV[64];
-    wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
-    wmv2_mspel8_v_lowpass(halfV, src+1, 8, stride, 8);
-    wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8);
-    put_pixels8_l2_aligned(dst, halfV, halfHV, stride, 8, 8, 8);
-}
-static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){
-    uint8_t halfH[88];
-    wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
-    wmv2_mspel8_v_lowpass(dst, halfH+8, stride, 8, 8);
-}
diff --git a/ffmpeg.src/libavcodec/simple_idct.c b/ffmpeg.src/libavcodec/simple_idct.c
deleted file mode 100644
index 4b48819..0000000
--- a/ffmpeg.src/libavcodec/simple_idct.c
+++ /dev/null
@@ -1,585 +0,0 @@
-/*
- * Simple IDCT
- *
- * Copyright (c) 2001 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-/**
- * @file simple_idct.c
- * simpleidct in C.
- */
- 
-/*
-  based upon some outcommented c code from mpeg2dec (idct_mmx.c
-  written by Aaron Holtzman <aholtzma at ess.engr.uvic.ca>) 
- */
-#include "avcodec.h"
-#include "dsputil.h"
-#include "simple_idct.h"
-
-#if 0
-#define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */
-#define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */
-#define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */
-#define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */
-#define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */
-#define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */
-#define W7 565  /* 2048*sqrt (2)*cos (7*pi/16) */
-#define ROW_SHIFT 8
-#define COL_SHIFT 17
-#else
-#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
-#define W3  19266  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W4  16383  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W5  12873  //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W6  8867   //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W7  4520   //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define ROW_SHIFT 11
-#define COL_SHIFT 20 // 6
-#endif
-
-#if defined(ARCH_POWERPC_405)
-
-/* signed 16x16 -> 32 multiply add accumulate */
-#define MAC16(rt, ra, rb) \
-    asm ("maclhw %0, %2, %3" : "=r" (rt) : "0" (rt), "r" (ra), "r" (rb));
-
-/* signed 16x16 -> 32 multiply */
-#define MUL16(rt, ra, rb) \
-    asm ("mullhw %0, %1, %2" : "=r" (rt) : "r" (ra), "r" (rb));
-
-#else
-
-/* signed 16x16 -> 32 multiply add accumulate */
-#define MAC16(rt, ra, rb) rt += (ra) * (rb)
-
-/* signed 16x16 -> 32 multiply */
-#define MUL16(rt, ra, rb) rt = (ra) * (rb)
-
-#endif
-
-static inline void idctRowCondDC (DCTELEM * row)
-{
-	int a0, a1, a2, a3, b0, b1, b2, b3;
-#ifdef FAST_64BIT
-        uint64_t temp;
-#else
-        uint32_t temp;
-#endif
-
-#ifdef FAST_64BIT
-#ifdef WORDS_BIGENDIAN
-#define ROW0_MASK 0xffff000000000000LL
-#else
-#define ROW0_MASK 0xffffLL
-#endif
-        if(sizeof(DCTELEM)==2){
-            if ( ((((uint64_t *)row)[0] & ~ROW0_MASK) | 
-                  ((uint64_t *)row)[1]) == 0) {
-                temp = (row[0] << 3) & 0xffff;
-                temp += temp << 16;
-                temp += temp << 32;
-                ((uint64_t *)row)[0] = temp;
-                ((uint64_t *)row)[1] = temp;
-                return;
-	    }
-        }else{
-            if (!(row[1]|row[2]|row[3]|row[4]|row[5]|row[6]|row[7])) {
-                row[0]=row[1]=row[2]=row[3]=row[4]=row[5]=row[6]=row[7]= row[0] << 3;
-                return;
-            }
-        }
-#else
-        if(sizeof(DCTELEM)==2){
-            if (!(((uint32_t*)row)[1] |
-                  ((uint32_t*)row)[2] |
-                  ((uint32_t*)row)[3] | 
-                  row[1])) {
-                temp = (row[0] << 3) & 0xffff;
-                temp += temp << 16;
-                ((uint32_t*)row)[0]=((uint32_t*)row)[1] =
-                ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp;
-                return;
-            }
-        }else{
-            if (!(row[1]|row[2]|row[3]|row[4]|row[5]|row[6]|row[7])) {
-                row[0]=row[1]=row[2]=row[3]=row[4]=row[5]=row[6]=row[7]= row[0] << 3;
-                return;
-            }
-        }
-#endif
-
-        a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1));
-	a1 = a0;
-	a2 = a0;
-	a3 = a0;
-
-        /* no need to optimize : gcc does it */
-        a0 += W2 * row[2];
-        a1 += W6 * row[2];
-        a2 -= W6 * row[2];
-        a3 -= W2 * row[2];
-
-        MUL16(b0, W1, row[1]);
-        MAC16(b0, W3, row[3]);
-        MUL16(b1, W3, row[1]);
-        MAC16(b1, -W7, row[3]);
-        MUL16(b2, W5, row[1]);
-        MAC16(b2, -W1, row[3]);
-        MUL16(b3, W7, row[1]);
-        MAC16(b3, -W5, row[3]);
-
-#ifdef FAST_64BIT
-        temp = ((uint64_t*)row)[1];
-#else
-        temp = ((uint32_t*)row)[2] | ((uint32_t*)row)[3];
-#endif
-	if (temp != 0) {
-            a0 += W4*row[4] + W6*row[6];
-            a1 += - W4*row[4] - W2*row[6];
-            a2 += - W4*row[4] + W2*row[6];
-            a3 += W4*row[4] - W6*row[6];
-
-            MAC16(b0, W5, row[5]);
-            MAC16(b0, W7, row[7]);
-            
-            MAC16(b1, -W1, row[5]);
-            MAC16(b1, -W5, row[7]);
-            
-            MAC16(b2, W7, row[5]);
-            MAC16(b2, W3, row[7]);
-            
-            MAC16(b3, W3, row[5]);
-            MAC16(b3, -W1, row[7]);
-	}
-
-	row[0] = (a0 + b0) >> ROW_SHIFT;
-	row[7] = (a0 - b0) >> ROW_SHIFT;
-	row[1] = (a1 + b1) >> ROW_SHIFT;
-	row[6] = (a1 - b1) >> ROW_SHIFT;
-	row[2] = (a2 + b2) >> ROW_SHIFT;
-	row[5] = (a2 - b2) >> ROW_SHIFT;
-	row[3] = (a3 + b3) >> ROW_SHIFT;
-	row[4] = (a3 - b3) >> ROW_SHIFT;
-}
-
-static inline void idctSparseColPut (uint8_t *dest, int line_size, 
-                                     DCTELEM * col)
-{
-	int a0, a1, a2, a3, b0, b1, b2, b3;
-        uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-        /* XXX: I did that only to give same values as previous code */
-	a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
-	a1 = a0;
-	a2 = a0;
-	a3 = a0;
-
-        a0 +=  + W2*col[8*2];
-        a1 +=  + W6*col[8*2];
-        a2 +=  - W6*col[8*2];
-        a3 +=  - W2*col[8*2];
-
-        MUL16(b0, W1, col[8*1]);
-        MUL16(b1, W3, col[8*1]);
-        MUL16(b2, W5, col[8*1]);
-        MUL16(b3, W7, col[8*1]);
-
-        MAC16(b0, + W3, col[8*3]);
-        MAC16(b1, - W7, col[8*3]);
-        MAC16(b2, - W1, col[8*3]);
-        MAC16(b3, - W5, col[8*3]);
-
-	if(col[8*4]){
-            a0 += + W4*col[8*4];
-            a1 += - W4*col[8*4];
-            a2 += - W4*col[8*4];
-            a3 += + W4*col[8*4];
-	}
-
-	if (col[8*5]) {
-            MAC16(b0, + W5, col[8*5]);
-            MAC16(b1, - W1, col[8*5]);
-            MAC16(b2, + W7, col[8*5]);
-            MAC16(b3, + W3, col[8*5]);
-	}
-
-	if(col[8*6]){
-            a0 += + W6*col[8*6];
-            a1 += - W2*col[8*6];
-            a2 += + W2*col[8*6];
-            a3 += - W6*col[8*6];
-	}
-
-	if (col[8*7]) {
-            MAC16(b0, + W7, col[8*7]);
-            MAC16(b1, - W5, col[8*7]);
-            MAC16(b2, + W3, col[8*7]);
-            MAC16(b3, - W1, col[8*7]);
-	}
-
-        dest[0] = cm[(a0 + b0) >> COL_SHIFT];
-        dest += line_size;
-        dest[0] = cm[(a1 + b1) >> COL_SHIFT];
-        dest += line_size;
-        dest[0] = cm[(a2 + b2) >> COL_SHIFT];
-        dest += line_size;
-        dest[0] = cm[(a3 + b3) >> COL_SHIFT];
-        dest += line_size;
-        dest[0] = cm[(a3 - b3) >> COL_SHIFT];
-        dest += line_size;
-        dest[0] = cm[(a2 - b2) >> COL_SHIFT];
-        dest += line_size;
-        dest[0] = cm[(a1 - b1) >> COL_SHIFT];
-        dest += line_size;
-        dest[0] = cm[(a0 - b0) >> COL_SHIFT];
-}
-
-static inline void idctSparseColAdd (uint8_t *dest, int line_size, 
-                                     DCTELEM * col)
-{
-	int a0, a1, a2, a3, b0, b1, b2, b3;
-        uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-        /* XXX: I did that only to give same values as previous code */
-	a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
-	a1 = a0;
-	a2 = a0;
-	a3 = a0;
-
-        a0 +=  + W2*col[8*2];
-        a1 +=  + W6*col[8*2];
-        a2 +=  - W6*col[8*2];
-        a3 +=  - W2*col[8*2];
-
-        MUL16(b0, W1, col[8*1]);
-        MUL16(b1, W3, col[8*1]);
-        MUL16(b2, W5, col[8*1]);
-        MUL16(b3, W7, col[8*1]);
-
-        MAC16(b0, + W3, col[8*3]);
-        MAC16(b1, - W7, col[8*3]);
-        MAC16(b2, - W1, col[8*3]);
-        MAC16(b3, - W5, col[8*3]);
-
-	if(col[8*4]){
-            a0 += + W4*col[8*4];
-            a1 += - W4*col[8*4];
-            a2 += - W4*col[8*4];
-            a3 += + W4*col[8*4];
-	}
-
-	if (col[8*5]) {
-            MAC16(b0, + W5, col[8*5]);
-            MAC16(b1, - W1, col[8*5]);
-            MAC16(b2, + W7, col[8*5]);
-            MAC16(b3, + W3, col[8*5]);
-	}
-
-	if(col[8*6]){
-            a0 += + W6*col[8*6];
-            a1 += - W2*col[8*6];
-            a2 += + W2*col[8*6];
-            a3 += - W6*col[8*6];
-	}
-
-	if (col[8*7]) {
-            MAC16(b0, + W7, col[8*7]);
-            MAC16(b1, - W5, col[8*7]);
-            MAC16(b2, + W3, col[8*7]);
-            MAC16(b3, - W1, col[8*7]);
-	}
-
-        dest[0] = cm[dest[0] + ((a0 + b0) >> COL_SHIFT)];
-        dest += line_size;
-        dest[0] = cm[dest[0] + ((a1 + b1) >> COL_SHIFT)];
-        dest += line_size;
-        dest[0] = cm[dest[0] + ((a2 + b2) >> COL_SHIFT)];
-        dest += line_size;
-        dest[0] = cm[dest[0] + ((a3 + b3) >> COL_SHIFT)];
-        dest += line_size;
-        dest[0] = cm[dest[0] + ((a3 - b3) >> COL_SHIFT)];
-        dest += line_size;
-        dest[0] = cm[dest[0] + ((a2 - b2) >> COL_SHIFT)];
-        dest += line_size;
-        dest[0] = cm[dest[0] + ((a1 - b1) >> COL_SHIFT)];
-        dest += line_size;
-        dest[0] = cm[dest[0] + ((a0 - b0) >> COL_SHIFT)];
-}
-
-static inline void idctSparseCol (DCTELEM * col)
-{
-	int a0, a1, a2, a3, b0, b1, b2, b3;
-
-        /* XXX: I did that only to give same values as previous code */
-	a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
-	a1 = a0;
-	a2 = a0;
-	a3 = a0;
-
-        a0 +=  + W2*col[8*2];
-        a1 +=  + W6*col[8*2];
-        a2 +=  - W6*col[8*2];
-        a3 +=  - W2*col[8*2];
-
-        MUL16(b0, W1, col[8*1]);
-        MUL16(b1, W3, col[8*1]);
-        MUL16(b2, W5, col[8*1]);
-        MUL16(b3, W7, col[8*1]);
-
-        MAC16(b0, + W3, col[8*3]);
-        MAC16(b1, - W7, col[8*3]);
-        MAC16(b2, - W1, col[8*3]);
-        MAC16(b3, - W5, col[8*3]);
-
-	if(col[8*4]){
-            a0 += + W4*col[8*4];
-            a1 += - W4*col[8*4];
-            a2 += - W4*col[8*4];
-            a3 += + W4*col[8*4];
-	}
-
-	if (col[8*5]) {
-            MAC16(b0, + W5, col[8*5]);
-            MAC16(b1, - W1, col[8*5]);
-            MAC16(b2, + W7, col[8*5]);
-            MAC16(b3, + W3, col[8*5]);
-	}
-
-	if(col[8*6]){
-            a0 += + W6*col[8*6];
-            a1 += - W2*col[8*6];
-            a2 += + W2*col[8*6];
-            a3 += - W6*col[8*6];
-	}
-
-	if (col[8*7]) {
-            MAC16(b0, + W7, col[8*7]);
-            MAC16(b1, - W5, col[8*7]);
-            MAC16(b2, + W3, col[8*7]);
-            MAC16(b3, - W1, col[8*7]);
-	}
-
-        col[0 ] = ((a0 + b0) >> COL_SHIFT);
-        col[8 ] = ((a1 + b1) >> COL_SHIFT);
-        col[16] = ((a2 + b2) >> COL_SHIFT);
-        col[24] = ((a3 + b3) >> COL_SHIFT);
-        col[32] = ((a3 - b3) >> COL_SHIFT);
-        col[40] = ((a2 - b2) >> COL_SHIFT);
-        col[48] = ((a1 - b1) >> COL_SHIFT);
-        col[56] = ((a0 - b0) >> COL_SHIFT);
-}
-
-void simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    int i;
-    for(i=0; i<8; i++)
-        idctRowCondDC(block + i*8);
-    
-    for(i=0; i<8; i++)
-        idctSparseColPut(dest + i, line_size, block + i);
-}
-
-void simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    int i;
-    for(i=0; i<8; i++)
-        idctRowCondDC(block + i*8);
-    
-    for(i=0; i<8; i++)
-        idctSparseColAdd(dest + i, line_size, block + i);
-}
-
-void simple_idct(DCTELEM *block)
-{
-    int i;
-    for(i=0; i<8; i++)
-        idctRowCondDC(block + i*8);
-    
-    for(i=0; i<8; i++)
-        idctSparseCol(block + i);
-}
-
-/* 2x4x8 idct */
-
-#define CN_SHIFT 12
-#define C_FIX(x) ((int)((x) * (1 << CN_SHIFT) + 0.5))
-#define C1 C_FIX(0.6532814824)
-#define C2 C_FIX(0.2705980501)
-
-/* row idct is multiple by 16 * sqrt(2.0), col idct4 is normalized,
-   and the butterfly must be multiplied by 0.5 * sqrt(2.0) */
-#define C_SHIFT (4+1+12)
-
-static inline void idct4col(uint8_t *dest, int line_size, const DCTELEM *col)
-{
-    int c0, c1, c2, c3, a0, a1, a2, a3;
-    const uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-    a0 = col[8*0];
-    a1 = col[8*2];
-    a2 = col[8*4];
-    a3 = col[8*6];
-    c0 = ((a0 + a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1));
-    c2 = ((a0 - a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1));
-    c1 = a1 * C1 + a3 * C2;
-    c3 = a1 * C2 - a3 * C1;
-    dest[0] = cm[(c0 + c1) >> C_SHIFT];
-    dest += line_size;
-    dest[0] = cm[(c2 + c3) >> C_SHIFT];
-    dest += line_size;
-    dest[0] = cm[(c2 - c3) >> C_SHIFT];
-    dest += line_size;
-    dest[0] = cm[(c0 - c1) >> C_SHIFT];
-}
-
-#define BF(k) \
-{\
-    int a0, a1;\
-    a0 = ptr[k];\
-    a1 = ptr[8 + k];\
-    ptr[k] = a0 + a1;\
-    ptr[8 + k] = a0 - a1;\
-}
-
-/* only used by DV codec. The input must be interlaced. 128 is added
-   to the pixels before clamping to avoid systematic error
-   (1024*sqrt(2)) offset would be needed otherwise. */
-/* XXX: I think a 1.0/sqrt(2) normalization should be needed to
-   compensate the extra butterfly stage - I don't have the full DV
-   specification */
-void simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    int i;
-    DCTELEM *ptr;
-    
-    /* butterfly */
-    ptr = block;
-    for(i=0;i<4;i++) {
-        BF(0);
-        BF(1);
-        BF(2);
-        BF(3);
-        BF(4);
-        BF(5);
-        BF(6);
-        BF(7);
-        ptr += 2 * 8;
-    }
-
-    /* IDCT8 on each line */
-    for(i=0; i<8; i++) {
-        idctRowCondDC(block + i*8);
-    }
-
-    /* IDCT4 and store */
-    for(i=0;i<8;i++) {
-        idct4col(dest + i, 2 * line_size, block + i);
-        idct4col(dest + line_size + i, 2 * line_size, block + 8 + i);
-    }
-}
-
-/* 8x4 & 4x8 WMV2 IDCT */
-#undef CN_SHIFT
-#undef C_SHIFT
-#undef C_FIX
-#undef C1
-#undef C2
-#define CN_SHIFT 12
-#define C_FIX(x) ((int)((x) * 1.414213562 * (1 << CN_SHIFT) + 0.5))
-#define C1 C_FIX(0.6532814824)
-#define C2 C_FIX(0.2705980501)
-#define C3 C_FIX(0.5)
-#define C_SHIFT (4+1+12)
-static inline void idct4col_add(uint8_t *dest, int line_size, const DCTELEM *col)
-{
-    int c0, c1, c2, c3, a0, a1, a2, a3;
-    const uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-    a0 = col[8*0];
-    a1 = col[8*1];
-    a2 = col[8*2];
-    a3 = col[8*3];
-    c0 = (a0 + a2)*C3 + (1 << (C_SHIFT - 1));
-    c2 = (a0 - a2)*C3 + (1 << (C_SHIFT - 1));
-    c1 = a1 * C1 + a3 * C2;
-    c3 = a1 * C2 - a3 * C1;
-    dest[0] = cm[dest[0] + ((c0 + c1) >> C_SHIFT)];
-    dest += line_size;
-    dest[0] = cm[dest[0] + ((c2 + c3) >> C_SHIFT)];
-    dest += line_size;
-    dest[0] = cm[dest[0] + ((c2 - c3) >> C_SHIFT)];
-    dest += line_size;
-    dest[0] = cm[dest[0] + ((c0 - c1) >> C_SHIFT)];
-}
-
-#define RN_SHIFT 15
-#define R_FIX(x) ((int)((x) * 1.414213562 * (1 << RN_SHIFT) + 0.5))
-#define R1 R_FIX(0.6532814824)
-#define R2 R_FIX(0.2705980501)
-#define R3 R_FIX(0.5)
-#define R_SHIFT 11
-static inline void idct4row(DCTELEM *row)
-{
-    int c0, c1, c2, c3, a0, a1, a2, a3;
-    //const uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-    a0 = row[0];
-    a1 = row[1];
-    a2 = row[2];
-    a3 = row[3];
-    c0 = (a0 + a2)*R3 + (1 << (R_SHIFT - 1));
-    c2 = (a0 - a2)*R3 + (1 << (R_SHIFT - 1));
-    c1 = a1 * R1 + a3 * R2;
-    c3 = a1 * R2 - a3 * R1;
-    row[0]= (c0 + c1) >> R_SHIFT;
-    row[1]= (c2 + c3) >> R_SHIFT;
-    row[2]= (c2 - c3) >> R_SHIFT;
-    row[3]= (c0 - c1) >> R_SHIFT;
-}
-
-void simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    int i;
-
-    /* IDCT8 on each line */
-    for(i=0; i<4; i++) {
-        idctRowCondDC(block + i*8);
-    }
-
-    /* IDCT4 and store */
-    for(i=0;i<8;i++) {
-        idct4col_add(dest + i, line_size, block + i);
-    }
-}
-
-void simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block)
-{
-    int i;
-
-    /* IDCT4 on each line */
-    for(i=0; i<8; i++) {
-        idct4row(block + i*8);
-    }
-
-    /* IDCT8 and store */
-    for(i=0; i<4; i++){
-        idctSparseColAdd(dest + i, line_size, block + i);
-    }
-}
-
diff --git a/ffmpeg.src/libavcodec/simple_idct.h b/ffmpeg.src/libavcodec/simple_idct.h
deleted file mode 100644
index 2da8227..0000000
--- a/ffmpeg.src/libavcodec/simple_idct.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Simple IDCT
- *
- * Copyright (c) 2001 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file simple_idct.h
- * simple idct header.
- */
- 
-void simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block);
-void simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block);
-void ff_simple_idct_mmx(int16_t *block);
-void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block);
-void ff_simple_idct_put_mmx(uint8_t *dest, int line_size, int16_t *block);
-void simple_idct(DCTELEM *block);
-
-void simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block);
-
-void simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block);
-void simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block);
diff --git a/ffmpeg.src/libavcodec/sp5x.h b/ffmpeg.src/libavcodec/sp5x.h
deleted file mode 100644
index dee3591..0000000
--- a/ffmpeg.src/libavcodec/sp5x.h
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Sunplus JPEG tables
- * Copyright (c) 2003 the ffmpeg project
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef SP5X_H
-#define SP5X_H
-
-static const uint8_t sp5x_data_sof[] =
-{
-    0xFF, 0xC0,	/* SOF */
-    0x00, 0x11,	/* len */
-    0x08,	/* bits */
-    0x00, 0xf0,	/* height (default: 240) */
-    0x01, 0x40,	/* width (default: 240) */
-    0x03,	/* nb components */
-    0x01, 0x22, 0x00, /* 21 vs 22 ? */
-    0x02, 0x11, 0x01,
-    0x03, 0x11, 0x01
-};
-
-static const uint8_t sp5x_data_sos[] =
-{
-    0xFF, 0xDA,	/* SOS */
-    0x00, 0x0C,	/* len */
-    0x03,	/* nb components */
-    0x01, 0x00,
-    0x02, 0x11,
-    0x03, 0x11,
-    0x00,	/* Ss */
-    0x3F,	/* Se */
-    0x00	/* Ah/Al */
-};
-
-static const uint8_t sp5x_data_dqt[] =
-{
-    0xFF, 0xDB, /* DQT */
-    0x00, 0x84, /* len */
-    0x00,
-    0x05, 0x03, 0x04, 0x04, 0x04, 0x03, 0x05, 0x04,
-    0x04, 0x04, 0x06, 0x05, 0x05, 0x06, 0x08, 0x0D,
-    0x08, 0x08, 0x07, 0x07, 0x08, 0x10, 0x0C, 0x0C,
-    0x0A, 0x0D, 0x14, 0x11, 0x15, 0x14, 0x13, 0x11,
-    0x13, 0x13, 0x16, 0x18, 0x1F, 0x1A, 0x16, 0x17,
-    0x1E, 0x17, 0x13, 0x13, 0x1B, 0x25, 0x1C, 0x1E,
-    0x20, 0x21, 0x23, 0x23, 0x23, 0x15, 0x1A, 0x27,
-    0x29, 0x26, 0x22, 0x29, 0x1F, 0x22, 0x23, 0x22,
-    0x01,
-    0x05, 0x06, 0x06, 0x08, 0x07, 0x08, 0x10, 0x08,
-    0x08, 0x10, 0x22, 0x16, 0x13, 0x16, 0x22, 0x22,
-    0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
-    0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
-    0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
-    0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
-    0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
-    0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22
-};
-
-static const uint8_t sp5x_data_dht[] = {   
-    0xFF, 0xC4,	/* DHT */
-    0x01, 0xA2,	/* len */
-    0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01,
-    0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
-    0x07, 0x08, 0x09, 0x0A, 0x0B, 0x01, 0x00, 0x03,
-    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-    0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
-    0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
-    0x0A, 0x0B, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03,
-    0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00,
-    0x00, 0x01, 0x7D, 0x01, 0x02, 0x03, 0x00, 0x04,
-    0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13,
-    0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81,
-    0x91, 0xA1, 0x08, 0x23, 0x42, 0xB1, 0xC1, 0x15,
-    0x52, 0xD1, 0xF0, 0x24, 0x33, 0x62, 0x72, 0x82,
-    0x09, 0x0A, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x25,
-    0x26, 0x27, 0x28, 0x29, 0x2A, 0x34, 0x35, 0x36,
-    0x37, 0x38, 0x39, 0x3A, 0x43, 0x44, 0x45, 0x46,
-    0x47, 0x48, 0x49, 0x4A, 0x53, 0x54, 0x55, 0x56,
-    0x57, 0x58, 0x59, 0x5A, 0x63, 0x64, 0x65, 0x66,
-    0x67, 0x68, 0x69, 0x6A, 0x73, 0x74, 0x75, 0x76,
-    0x77, 0x78, 0x79, 0x7A, 0x83, 0x84, 0x85, 0x86,
-    0x87, 0x88, 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95,
-    0x96, 0x97, 0x98, 0x99, 0x9A, 0xA2, 0xA3, 0xA4,
-    0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3,
-    0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xC2,
-    0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA,
-    0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9,
-    0xDA, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
-    0xE8, 0xE9, 0xEA, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5,
-    0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0x11, 0x00, 0x02,
-    0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05,
-    0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01,
-    0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06,
-    0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22,
-    0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xA1, 0xB1,
-    0xC1, 0x09, 0x23, 0x33, 0x52, 0xF0, 0x15, 0x62,
-    0x72, 0xD1, 0x0A, 0x16, 0x24, 0x34, 0xE1, 0x25,
-    0xF1, 0x17, 0x18, 0x19, 0x1A, 0x26, 0x27, 0x28,
-    0x29, 0x2A, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
-    0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A,
-    0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
-    0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A,
-    0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A,
-    0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
-    0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
-    0x99, 0x9A, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
-    0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6,
-    0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, 0xC5,
-    0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4,
-    0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xE2, 0xE3,
-    0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xF2,
-    0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA
-};
-
-
-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,
-       45, 44, 51, 58, 74, 62, 51, 54, 70, 55, 44, 45, 64, 87, 65, 70,
-       76, 78, 82, 83, 82, 50, 62, 90, 97, 90, 80, 96, 74, 81, 82, 79 },
-    {  14, 14, 14, 19, 17, 19, 38, 21, 21, 38, 79, 53, 45, 53, 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, 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 }
-};
-
-#if 0
-/* 4NF-M, not ZigZag */
-static const uint8_t sp5x_quant_table_orig[18][64] = 
-{
-    /* index 0, Q50 */
-    {  16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55,
-       14, 13, 16, 24, 40, 57, 69, 56, 14, 17, 22, 29, 51, 87, 80, 62,
-       18, 22, 37, 56, 68,109,103, 77, 24, 35, 55, 64, 81,104,113, 92,
-       49, 64, 78, 87,103,121,120,101, 72, 92, 95, 98,112,100,103, 99 },
-    {  17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99,
-       24, 26, 56, 99, 99, 99, 99, 99, 47, 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 },
-
-    /* index 1, Q70 */
-    {  10,  7,  6, 10, 14, 24, 31, 37,  7,  7,  8, 11, 16, 35, 36, 33,
-        8,  8, 10, 14, 24, 34, 41, 34,  8, 10, 13, 17, 31, 52, 48, 37,
-       11, 13, 22, 34, 41, 65, 62, 46, 14, 21, 33, 38, 49, 62, 68, 55,
-       29, 38, 47, 52, 62, 73, 72, 61, 43, 55, 57, 59, 67, 60, 62, 59 },
-    {  10, 11, 14, 28, 59, 59, 59, 59, 11, 13, 16, 40, 59, 59, 59, 59,
-       14, 16, 34, 59, 59, 59, 59, 59, 28, 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 },
-
-    /* index 2, Q80 */
-    {   6,  4,  4,  6, 10, 16, 20, 24,  5,  5,  6,  8, 10, 23, 24, 22,
-	6,  5,  6, 10, 16, 23, 28, 22,  6,  7,  9, 12, 20, 35, 32, 25,
-        7,  9, 15, 22, 27, 44, 41, 31, 10, 14, 22, 26, 32, 42, 45, 37,
-       20, 26, 31, 35, 41, 48, 48, 40, 29, 37, 38, 39, 45, 40, 41, 40 },
-    {   7,  7, 10, 19, 40, 40, 40, 40,  7,  8, 10, 26, 40, 40, 40, 40,
-       10, 10, 22, 40, 40, 40, 40, 40, 19, 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 },
-
-    /* index 3, Q85 */
-    {   5,  3,  3,  5,  7, 12, 15, 18,  4,  4,  4,  6,  8, 17, 18, 17,
-	4,  4,  5,  7, 12, 17, 21, 17,  4,  5,  7,  9, 15, 26, 24, 19,
-        5,  7, 11, 17, 20, 33, 31, 23,  7, 11, 17, 19, 24, 31, 34, 28,
-       15, 19, 23, 26, 31, 36, 36, 30, 22, 28, 29, 29, 34, 30, 31, 30 },
-    {   5,  5,  7, 14, 30, 30, 30, 30,  5,  6,  8, 20, 30, 30, 30, 30,
-        7,  8, 17, 30, 30, 30, 30, 30, 14, 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 },
-
-    /* index 4, Q90 */
-    {   3,  2,  2,  3,  5,  8, 10, 12,  2,  2,  3,  4,  5, 12, 12, 11,
-        3,  3,  3,  5,  8, 11, 14, 11,  3,  3,  4,  6, 10, 17, 16, 12,
-        4,  4,  7, 11, 14, 22, 21, 15,  5,  7, 11, 13, 16, 21, 23, 18,
-       10, 13, 16, 17, 21, 24, 24, 20, 14, 18, 19, 20, 22, 20, 21, 20 },
-    {   3,  4,  5,  9, 20, 20, 20, 20,  4,  4,  5, 13, 20, 20, 20, 20,
-        5,  5, 11, 20, 20, 20, 20, 20,  9, 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 },
-
-    /* index 5, Q60 */
-    {  13,  9,  8, 13, 19, 32, 41, 49, 10, 10, 11, 15, 21, 46, 48, 44,
-       11, 10, 13, 19, 32, 46, 55, 45, 11, 14, 18, 23, 41, 70, 64, 50,
-       14, 18, 30, 45, 54, 87, 82, 62, 19, 28, 44, 51, 65, 83, 90, 74,
-       39, 51, 62, 70, 82, 97, 96, 81, 58, 74, 76, 78, 90, 80, 82, 79 },
-    {  14, 14, 19, 38, 79, 79, 79, 79, 14, 17, 21, 53, 79, 79, 79, 79,
-       19, 21, 45, 79, 79, 79, 79, 79, 38, 53, 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, 20, 32, 48, 80,102,122, 24, 24, 28, 38, 52,116,120,110,
-       28, 26, 32, 48, 80,114,138,112, 28, 34, 44, 58,102,174,160,124,
-       36, 44, 74,112,136,218,206,154, 48, 70,110,128,162,208,226,184,
-       98,128,156,174,206,242,240,202,144,184,190,196,224,200,206,198 },
-    {  34, 36, 48, 94,198,198,198,198, 36, 42, 52,132,198,198,198,198,
-       48, 52,112,198,198,198,198,198, 94,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 },
-
-    /* index 7, Q95 */
-    {   2,  1,  1,  2,  2,  4,  5,  6,  1,  1,  1,  2,  3,  6,  6,  6,
-        1,  1,  2,  2,  4,  6,  7,  6,  1,  2,  2,  3,  5,  9,  8,  6,
-        2,  2,  4,  6,  7, 11, 10,  8,  2,  4,  6,  6,  8, 10, 11,  9,
-        5,  6,  8,  9, 10, 12, 12, 10,  7,  9, 10, 10, 11, 10, 10, 10 },
-    {   2,  2,  2,  5, 10, 10, 10, 10,  2,  2,  3,  7, 10, 10, 10, 10,
-        2,  3,  6, 10, 10, 10, 10, 10,  5,  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 },
-
-    /* index 8, Q93 */
-    {   2,  2,  1,  2,  3,  6,  7,  9,  2,  2,  2,  3,  4,  8,  8,  8,
-        2,  2,  2,  3,  6,  8, 10,  8,  2,  2,  3,  4,  7, 12, 11,  9,
-        3,  3,  5,  8, 10, 15, 14, 11,  3,  5,  8,  9, 11, 15, 16, 13,
-        7,  9, 11, 12, 14, 17, 17, 14, 10, 13, 13, 14, 16, 14, 14, 14 },
-    {   2,  3,  3,  7, 14, 14, 14, 14,  3,  3,  4,  9, 14, 14, 14, 14,
-        3,  4,  8, 14, 14, 14, 14, 14,  7,  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 }
-};
-#endif
-
-#endif /* SP5X_H */
diff --git a/ffmpeg.src/libavcodec/sparc/dsputil_vis.c b/ffmpeg.src/libavcodec/sparc/dsputil_vis.c
deleted file mode 100644
index 53f38b2..0000000
--- a/ffmpeg.src/libavcodec/sparc/dsputil_vis.c
+++ /dev/null
@@ -1,4091 +0,0 @@
-/*
- * dsputil_vis.c
- * Copyright (C) 2003 David S. Miller <davem at redhat.com>
- *
- * This file is part of ffmpeg, a free MPEG-4 video stream decoder.
- * See http://ffmpeg.sourceforge.net/ for updates.
- *
- * 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 General Public License for more details.
- *
- * You should have received a copy of the Lesser GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/* The *no_round* functions have been added by James A. Morrison, 2003,2004.
-   The vis code from libmpeg2 was adapted for ffmpeg by James A. Morrison.
- */
-
-#include "config.h"
-
-#ifdef ARCH_SPARC
-
-#include <inttypes.h>
-#include <signal.h>
-#include <setjmp.h>
-
-#include "../dsputil.h"
-
-#include "vis.h"
-
-/* The trick used in some of this file is the formula from the MMX
- * motion comp code, which is:
- *
- * (x+y+1)>>1 == (x|y)-((x^y)>>1)
- *
- * This allows us to average 8 bytes at a time in a 64-bit FPU reg.
- * We avoid overflows by masking before we do the shift, and we
- * implement the shift by multiplying by 1/2 using mul8x16.  So in
- * VIS this is (assume 'x' is in f0, 'y' is in f2, a repeating mask
- * of '0xfe' is in f4, a repeating mask of '0x7f' is in f6, and
- * the value 0x80808080 is in f8):
- *
- *	fxor		f0, f2, f10
- *	fand		f10, f4, f10
- *	fmul8x16	f8, f10, f10
- *	fand		f10, f6, f10
- *	for		f0, f2, f12
- *	fpsub16		f12, f10, f10
- */
-
-#define ATTR_ALIGN(alignd) __attribute__ ((aligned(alignd)))
-
-#define DUP4(x) {x, x, x, x}
-#define DUP8(x) {x, x, x, x, x, x, x, x}
-static const int16_t constants1[] ATTR_ALIGN(8) = DUP4 (1);
-static const int16_t constants2[] ATTR_ALIGN(8) = DUP4 (2);
-static const int16_t constants3[] ATTR_ALIGN(8) = DUP4 (3);
-static const int16_t constants6[] ATTR_ALIGN(8) = DUP4 (6);
-static const int8_t constants_fe[] ATTR_ALIGN(8) = DUP8 (0xfe);
-static const int8_t constants_7f[] ATTR_ALIGN(8) = DUP8 (0x7f);
-static const int8_t constants128[] ATTR_ALIGN(8) = DUP8 (128);
-static const int16_t constants256_512[] ATTR_ALIGN(8) =
-	{256, 512, 256, 512};
-static const int16_t constants256_1024[] ATTR_ALIGN(8) =
-	{256, 1024, 256, 1024};
-
-#define REF_0		0
-#define REF_0_1		1
-#define REF_2		2
-#define REF_2_1		3
-#define REF_4		4
-#define REF_4_1		5
-#define REF_6		6
-#define REF_6_1		7
-#define REF_S0		8
-#define REF_S0_1	9
-#define REF_S2		10
-#define REF_S2_1	11
-#define REF_S4		12
-#define REF_S4_1	13
-#define REF_S6		14
-#define REF_S6_1	15
-#define DST_0		16
-#define DST_1		17
-#define DST_2		18
-#define DST_3		19
-#define CONST_1		20
-#define CONST_2		20
-#define CONST_3		20
-#define CONST_6		20
-#define MASK_fe		20
-#define CONST_128	22
-#define CONST_256	22
-#define CONST_512	22
-#define CONST_1024	22
-#define TMP0		24
-#define TMP1		25
-#define TMP2		26
-#define TMP3		27
-#define TMP4		28
-#define TMP5		29
-#define ZERO		30
-#define MASK_7f		30
-
-#define TMP6		32
-#define TMP8		34
-#define TMP10		36
-#define TMP12		38
-#define TMP14		40
-#define TMP16		42
-#define TMP18		44
-#define TMP20		46
-#define TMP22		48
-#define TMP24		50
-#define TMP26		52
-#define TMP28		54
-#define TMP30		56
-#define TMP32		58
-
-static void MC_put_o_16_vis (uint8_t * dest, const uint8_t * _ref,
-			     const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-
-	ref = vis_alignaddr(ref);
-	do {	/* 5 cycles */
-		vis_ld64(ref[0], TMP0);
-
-		vis_ld64_2(ref, 8, TMP2);
-
-		vis_ld64_2(ref, 16, TMP4);
-		ref += stride;
-
-		vis_faligndata(TMP0, TMP2, REF_0);
-		vis_st64(REF_0, dest[0]);
-
-		vis_faligndata(TMP2, TMP4, REF_2);
-		vis_st64_2(REF_2, dest, 8);
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_put_o_8_vis (uint8_t * dest, const uint8_t * _ref,
-			    const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-
-	ref = vis_alignaddr(ref);
-	do {	/* 4 cycles */
-		vis_ld64(ref[0], TMP0);
-
-		vis_ld64(ref[8], TMP2);
-		ref += stride;
-
-		/* stall */
-
-		vis_faligndata(TMP0, TMP2, REF_0);
-		vis_st64(REF_0, dest[0]);
-		dest += stride;
-	} while (--height);
-}
-
-
-static void MC_avg_o_16_vis (uint8_t * dest, const uint8_t * _ref,
-			     const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	int stride_8 = stride + 8;
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[0], TMP0);
-
-	vis_ld64(ref[8], TMP2);
-
-	vis_ld64(ref[16], TMP4);
-
-	vis_ld64(dest[0], DST_0);
-
-	vis_ld64(dest[8], DST_2);
-
-	vis_ld64(constants_fe[0], MASK_fe);
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_ld64(constants_7f[0], MASK_7f);
-	vis_faligndata(TMP2, TMP4, REF_2);
-
-	vis_ld64(constants128[0], CONST_128);
-
-	ref += stride;
-	height = (height >> 1) - 1;
-
-	do {	/* 24 cycles */
-		vis_ld64(ref[0], TMP0);
-		vis_xor(DST_0, REF_0, TMP6);
-
-		vis_ld64_2(ref, 8, TMP2);
-		vis_and(TMP6, MASK_fe, TMP6);
-
-		vis_ld64_2(ref, 16, TMP4);
-		ref += stride;
-		vis_mul8x16(CONST_128, TMP6, TMP6);
-		vis_xor(DST_2, REF_2, TMP8);
-
-		vis_and(TMP8, MASK_fe, TMP8);
-
-		vis_or(DST_0, REF_0, TMP10);
-		vis_ld64_2(dest, stride, DST_0);
-		vis_mul8x16(CONST_128, TMP8, TMP8);
-
-		vis_or(DST_2, REF_2, TMP12);
-		vis_ld64_2(dest, stride_8, DST_2);
-
-		vis_ld64(ref[0], TMP14);
-		vis_and(TMP6, MASK_7f, TMP6);
-
-		vis_and(TMP8, MASK_7f, TMP8);
-
-		vis_psub16(TMP10, TMP6, TMP6);
-		vis_st64(TMP6, dest[0]);
-
-		vis_psub16(TMP12, TMP8, TMP8);
-		vis_st64_2(TMP8, dest, 8);
-
-		dest += stride;
-		vis_ld64_2(ref, 8, TMP16);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64_2(ref, 16, TMP18);
-		vis_faligndata(TMP2, TMP4, REF_2);
-		ref += stride;
-
-		vis_xor(DST_0, REF_0, TMP20);
-
-		vis_and(TMP20, MASK_fe, TMP20);
-
-		vis_xor(DST_2, REF_2, TMP22);
-		vis_mul8x16(CONST_128, TMP20, TMP20);
-
-		vis_and(TMP22, MASK_fe, TMP22);
-
-		vis_or(DST_0, REF_0, TMP24);
-		vis_mul8x16(CONST_128, TMP22, TMP22);
-
-		vis_or(DST_2, REF_2, TMP26);
-
-		vis_ld64_2(dest, stride, DST_0);
-		vis_faligndata(TMP14, TMP16, REF_0);
-
-		vis_ld64_2(dest, stride_8, DST_2);
-		vis_faligndata(TMP16, TMP18, REF_2);
-
-		vis_and(TMP20, MASK_7f, TMP20);
-
-		vis_and(TMP22, MASK_7f, TMP22);
-
-		vis_psub16(TMP24, TMP20, TMP20);
-		vis_st64(TMP20, dest[0]);
-
-		vis_psub16(TMP26, TMP22, TMP22);
-		vis_st64_2(TMP22, dest, 8);
-		dest += stride;
-	} while (--height);
-
-	vis_ld64(ref[0], TMP0);
-	vis_xor(DST_0, REF_0, TMP6);
-
-	vis_ld64_2(ref, 8, TMP2);
-	vis_and(TMP6, MASK_fe, TMP6);
-
-	vis_ld64_2(ref, 16, TMP4);
-	vis_mul8x16(CONST_128, TMP6, TMP6);
-	vis_xor(DST_2, REF_2, TMP8);
-
-	vis_and(TMP8, MASK_fe, TMP8);
-
-	vis_or(DST_0, REF_0, TMP10);
-	vis_ld64_2(dest, stride, DST_0);
-	vis_mul8x16(CONST_128, TMP8, TMP8);
-
-	vis_or(DST_2, REF_2, TMP12);
-	vis_ld64_2(dest, stride_8, DST_2);
-
-	vis_ld64(ref[0], TMP14);
-	vis_and(TMP6, MASK_7f, TMP6);
-
-	vis_and(TMP8, MASK_7f, TMP8);
-
-	vis_psub16(TMP10, TMP6, TMP6);
-	vis_st64(TMP6, dest[0]);
-
-	vis_psub16(TMP12, TMP8, TMP8);
-	vis_st64_2(TMP8, dest, 8);
-
-	dest += stride;
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_faligndata(TMP2, TMP4, REF_2);
-
-	vis_xor(DST_0, REF_0, TMP20);
-
-	vis_and(TMP20, MASK_fe, TMP20);
-
-	vis_xor(DST_2, REF_2, TMP22);
-	vis_mul8x16(CONST_128, TMP20, TMP20);
-
-	vis_and(TMP22, MASK_fe, TMP22);
-
-	vis_or(DST_0, REF_0, TMP24);
-	vis_mul8x16(CONST_128, TMP22, TMP22);
-
-	vis_or(DST_2, REF_2, TMP26);
-
-	vis_and(TMP20, MASK_7f, TMP20);
-
-	vis_and(TMP22, MASK_7f, TMP22);
-
-	vis_psub16(TMP24, TMP20, TMP20);
-	vis_st64(TMP20, dest[0]);
-
-	vis_psub16(TMP26, TMP22, TMP22);
-	vis_st64_2(TMP22, dest, 8);
-}
-
-static void MC_avg_o_8_vis (uint8_t * dest, const uint8_t * _ref,
-			    const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[0], TMP0);
-
-	vis_ld64(ref[8], TMP2);
-
-	vis_ld64(dest[0], DST_0);
-
-	vis_ld64(constants_fe[0], MASK_fe);
-
-	vis_ld64(constants_7f[0], MASK_7f);
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_ld64(constants128[0], CONST_128);
-
-	ref += stride;
-	height = (height >> 1) - 1;
-
-	do {	/* 12 cycles */
-		vis_ld64(ref[0], TMP0);
-		vis_xor(DST_0, REF_0, TMP4);
-
-		vis_ld64(ref[8], TMP2);
-		vis_and(TMP4, MASK_fe, TMP4);
-
-		vis_or(DST_0, REF_0, TMP6);
-		vis_ld64_2(dest, stride, DST_0);
-		ref += stride;
-		vis_mul8x16(CONST_128, TMP4, TMP4);
-
-		vis_ld64(ref[0], TMP12);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64(ref[8], TMP2);
-		vis_xor(DST_0, REF_0, TMP0);
-		ref += stride;
-
-		vis_and(TMP0, MASK_fe, TMP0);
-
-		vis_and(TMP4, MASK_7f, TMP4);
-
-		vis_psub16(TMP6, TMP4, TMP4);
-		vis_st64(TMP4, dest[0]);
-		dest += stride;
-		vis_mul8x16(CONST_128, TMP0, TMP0);
-
-		vis_or(DST_0, REF_0, TMP6);
-		vis_ld64_2(dest, stride, DST_0);
-
-		vis_faligndata(TMP12, TMP2, REF_0);
-
-		vis_and(TMP0, MASK_7f, TMP0);
-
-		vis_psub16(TMP6, TMP0, TMP4);
-		vis_st64(TMP4, dest[0]);
-		dest += stride;
-	} while (--height);
-
-	vis_ld64(ref[0], TMP0);
-	vis_xor(DST_0, REF_0, TMP4);
-
-	vis_ld64(ref[8], TMP2);
-	vis_and(TMP4, MASK_fe, TMP4);
-
-	vis_or(DST_0, REF_0, TMP6);
-	vis_ld64_2(dest, stride, DST_0);
-	vis_mul8x16(CONST_128, TMP4, TMP4);
-
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_xor(DST_0, REF_0, TMP0);
-
-	vis_and(TMP0, MASK_fe, TMP0);
-
-	vis_and(TMP4, MASK_7f, TMP4);
-
-	vis_psub16(TMP6, TMP4, TMP4);
-	vis_st64(TMP4, dest[0]);
-	dest += stride;
-	vis_mul8x16(CONST_128, TMP0, TMP0);
-
-	vis_or(DST_0, REF_0, TMP6);
-
-	vis_and(TMP0, MASK_7f, TMP0);
-
-	vis_psub16(TMP6, TMP0, TMP4);
-	vis_st64(TMP4, dest[0]);
-}
-
-static void MC_put_x_16_vis (uint8_t * dest, const uint8_t * _ref,
-			     const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[0],    TMP0);
-
-	vis_ld64_2(ref, 8,  TMP2);
-
-	vis_ld64_2(ref, 16, TMP4);
-
-	vis_ld64(constants_fe[0], MASK_fe);
-
-	vis_ld64(constants_7f[0], MASK_7f);
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_ld64(constants128[0], CONST_128);
-	vis_faligndata(TMP2, TMP4, REF_4);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_2);
-		vis_faligndata(TMP2, TMP4, REF_6);
-	} else {
-		vis_src1(TMP2, REF_2);
-		vis_src1(TMP4, REF_6);
-	}
-
-	ref += stride;
-	height = (height >> 1) - 1;
-
-	do {	/* 34 cycles */
-		vis_ld64(ref[0],    TMP0);
-		vis_xor(REF_0, REF_2, TMP6);
-
-		vis_ld64_2(ref, 8,  TMP2);
-		vis_xor(REF_4, REF_6, TMP8);
-
-		vis_ld64_2(ref, 16, TMP4);
-		vis_and(TMP6, MASK_fe, TMP6);
-		ref += stride;
-
-		vis_ld64(ref[0],    TMP14);
-		vis_mul8x16(CONST_128, TMP6, TMP6);
-		vis_and(TMP8, MASK_fe, TMP8);
-
-		vis_ld64_2(ref, 8,  TMP16);
-		vis_mul8x16(CONST_128, TMP8, TMP8);
-		vis_or(REF_0, REF_2, TMP10);
-
-		vis_ld64_2(ref, 16, TMP18);
-		ref += stride;
-		vis_or(REF_4, REF_6, TMP12);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_faligndata(TMP2, TMP4, REF_4);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP0, TMP2, REF_2);
-			vis_faligndata(TMP2, TMP4, REF_6);
-		} else {
-			vis_src1(TMP2, REF_2);
-			vis_src1(TMP4, REF_6);
-		}
-
-		vis_and(TMP6, MASK_7f, TMP6);
-
-		vis_and(TMP8, MASK_7f, TMP8);
-
-		vis_psub16(TMP10, TMP6, TMP6);
-		vis_st64(TMP6, dest[0]);
-
-		vis_psub16(TMP12, TMP8, TMP8);
-		vis_st64_2(TMP8, dest, 8);
-		dest += stride;
-
-		vis_xor(REF_0, REF_2, TMP6);
-
-		vis_xor(REF_4, REF_6, TMP8);
-
-		vis_and(TMP6, MASK_fe, TMP6);
-
-		vis_mul8x16(CONST_128, TMP6, TMP6);
-		vis_and(TMP8, MASK_fe, TMP8);
-
-		vis_mul8x16(CONST_128, TMP8, TMP8);
-		vis_or(REF_0, REF_2, TMP10);
-
-		vis_or(REF_4, REF_6, TMP12);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_faligndata(TMP14, TMP16, REF_0);
-
-		vis_faligndata(TMP16, TMP18, REF_4);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP14, TMP16, REF_2);
-			vis_faligndata(TMP16, TMP18, REF_6);
-		} else {
-			vis_src1(TMP16, REF_2);
-			vis_src1(TMP18, REF_6);
-		}
-
-		vis_and(TMP6, MASK_7f, TMP6);
-
-		vis_and(TMP8, MASK_7f, TMP8);
-
-		vis_psub16(TMP10, TMP6, TMP6);
-		vis_st64(TMP6, dest[0]);
-
-		vis_psub16(TMP12, TMP8, TMP8);
-		vis_st64_2(TMP8, dest, 8);
-		dest += stride;
-	} while (--height);
-
-	vis_ld64(ref[0],    TMP0);
-	vis_xor(REF_0, REF_2, TMP6);
-
-	vis_ld64_2(ref, 8,  TMP2);
-	vis_xor(REF_4, REF_6, TMP8);
-
-	vis_ld64_2(ref, 16, TMP4);
-	vis_and(TMP6, MASK_fe, TMP6);
-
-	vis_mul8x16(CONST_128, TMP6, TMP6);
-	vis_and(TMP8, MASK_fe, TMP8);
-
-	vis_mul8x16(CONST_128, TMP8, TMP8);
-	vis_or(REF_0, REF_2, TMP10);
-
-	vis_or(REF_4, REF_6, TMP12);
-
-	vis_alignaddr_g0((void *)off);
-
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_faligndata(TMP2, TMP4, REF_4);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_2);
-		vis_faligndata(TMP2, TMP4, REF_6);
-	} else {
-		vis_src1(TMP2, REF_2);
-		vis_src1(TMP4, REF_6);
-	}
-
-	vis_and(TMP6, MASK_7f, TMP6);
-
-	vis_and(TMP8, MASK_7f, TMP8);
-
-	vis_psub16(TMP10, TMP6, TMP6);
-	vis_st64(TMP6, dest[0]);
-
-	vis_psub16(TMP12, TMP8, TMP8);
-	vis_st64_2(TMP8, dest, 8);
-	dest += stride;
-
-	vis_xor(REF_0, REF_2, TMP6);
-
-	vis_xor(REF_4, REF_6, TMP8);
-
-	vis_and(TMP6, MASK_fe, TMP6);
-
-	vis_mul8x16(CONST_128, TMP6, TMP6);
-	vis_and(TMP8, MASK_fe, TMP8);
-
-	vis_mul8x16(CONST_128, TMP8, TMP8);
-	vis_or(REF_0, REF_2, TMP10);
-
-	vis_or(REF_4, REF_6, TMP12);
-
-	vis_and(TMP6, MASK_7f, TMP6);
-
-	vis_and(TMP8, MASK_7f, TMP8);
-
-	vis_psub16(TMP10, TMP6, TMP6);
-	vis_st64(TMP6, dest[0]);
-
-	vis_psub16(TMP12, TMP8, TMP8);
-	vis_st64_2(TMP8, dest, 8);
-}
-
-static void MC_put_x_8_vis (uint8_t * dest, const uint8_t * _ref,
-			    const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[0], TMP0);
-
-	vis_ld64(ref[8], TMP2);
-
-	vis_ld64(constants_fe[0], MASK_fe);
-
-	vis_ld64(constants_7f[0], MASK_7f);
-
-	vis_ld64(constants128[0], CONST_128);
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_2);
-	} else {
-		vis_src1(TMP2, REF_2);
-	}
-
-	ref += stride;
-	height = (height >> 1) - 1;
-
-	do {	/* 20 cycles */
-		vis_ld64(ref[0], TMP0);
-		vis_xor(REF_0, REF_2, TMP4);
-
-		vis_ld64_2(ref, 8, TMP2);
-		vis_and(TMP4, MASK_fe, TMP4);
-		ref += stride;
-
-		vis_ld64(ref[0], TMP8);
-		vis_or(REF_0, REF_2, TMP6);
-		vis_mul8x16(CONST_128, TMP4, TMP4);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_ld64_2(ref, 8, TMP10);
-		ref += stride;
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP0, TMP2, REF_2);
-		} else {
-			vis_src1(TMP2, REF_2);
-		}
-
-		vis_and(TMP4, MASK_7f, TMP4);
-
-		vis_psub16(TMP6, TMP4, DST_0);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-
-		vis_xor(REF_0, REF_2, TMP12);
-
-		vis_and(TMP12, MASK_fe, TMP12);
-
-		vis_or(REF_0, REF_2, TMP14);
-		vis_mul8x16(CONST_128, TMP12, TMP12);
-
-		vis_alignaddr_g0((void *)off);
-		vis_faligndata(TMP8, TMP10, REF_0);
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP8, TMP10, REF_2);
-		} else {
-			vis_src1(TMP10, REF_2);
-		}
-
-		vis_and(TMP12, MASK_7f, TMP12);
-
-		vis_psub16(TMP14, TMP12, DST_0);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-	} while (--height);
-
-	vis_ld64(ref[0], TMP0);
-	vis_xor(REF_0, REF_2, TMP4);
-
-	vis_ld64_2(ref, 8, TMP2);
-	vis_and(TMP4, MASK_fe, TMP4);
-
-	vis_or(REF_0, REF_2, TMP6);
-	vis_mul8x16(CONST_128, TMP4, TMP4);
-
-	vis_alignaddr_g0((void *)off);
-
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_2);
-	} else {
-		vis_src1(TMP2, REF_2);
-	}
-
-	vis_and(TMP4, MASK_7f, TMP4);
-
-	vis_psub16(TMP6, TMP4, DST_0);
-	vis_st64(DST_0, dest[0]);
-	dest += stride;
-
-	vis_xor(REF_0, REF_2, TMP12);
-
-	vis_and(TMP12, MASK_fe, TMP12);
-
-	vis_or(REF_0, REF_2, TMP14);
-	vis_mul8x16(CONST_128, TMP12, TMP12);
-
-	vis_and(TMP12, MASK_7f, TMP12);
-
-	vis_psub16(TMP14, TMP12, DST_0);
-	vis_st64(DST_0, dest[0]);
-	dest += stride;
-}
-
-static void MC_avg_x_16_vis (uint8_t * dest, const uint8_t * _ref,
-			     const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-
-	vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-	vis_ld64(constants3[0], CONST_3);
-	vis_fzero(ZERO);
-	vis_ld64(constants256_512[0], CONST_256);
-
-	ref = vis_alignaddr(ref);
-	do {	/* 26 cycles */
-		vis_ld64(ref[0], TMP0);
-
-		vis_ld64(ref[8], TMP2);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_ld64(ref[16], TMP4);
-
-		vis_ld64(dest[0], DST_0);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64(dest[8], DST_2);
-		vis_faligndata(TMP2, TMP4, REF_4);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP0, TMP2, REF_2);
-			vis_faligndata(TMP2, TMP4, REF_6);
-		} else {
-			vis_src1(TMP2, REF_2);
-			vis_src1(TMP4, REF_6);
-		}
-
-		vis_mul8x16au(REF_0,   CONST_256, TMP0);
-
-		vis_pmerge(ZERO,     REF_2,     TMP4);
-		vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
-		vis_pmerge(ZERO, REF_2_1, TMP6);
-
-		vis_padd16(TMP0, TMP4, TMP0);
-
-		vis_mul8x16al(DST_0,   CONST_512, TMP4);
-		vis_padd16(TMP2, TMP6, TMP2);
-
-		vis_mul8x16al(DST_1,   CONST_512, TMP6);
-
-		vis_mul8x16au(REF_6,   CONST_256, TMP12);
-
-		vis_padd16(TMP0, TMP4, TMP0);
-		vis_mul8x16au(REF_6_1, CONST_256, TMP14);
-
-		vis_padd16(TMP2, TMP6, TMP2);
-		vis_mul8x16au(REF_4,   CONST_256, TMP16);
-
-		vis_padd16(TMP0, CONST_3, TMP8);
-		vis_mul8x16au(REF_4_1, CONST_256, TMP18);
-
-		vis_padd16(TMP2, CONST_3, TMP10);
-		vis_pack16(TMP8, DST_0);
-
-		vis_pack16(TMP10, DST_1);
-		vis_padd16(TMP16, TMP12, TMP0);
-
-		vis_st64(DST_0, dest[0]);
-		vis_mul8x16al(DST_2,   CONST_512, TMP4);
-		vis_padd16(TMP18, TMP14, TMP2);
-
-		vis_mul8x16al(DST_3,   CONST_512, TMP6);
-		vis_padd16(TMP0, CONST_3, TMP0);
-
-		vis_padd16(TMP2, CONST_3, TMP2);
-
-		vis_padd16(TMP0, TMP4, TMP0);
-
-		vis_padd16(TMP2, TMP6, TMP2);
-		vis_pack16(TMP0, DST_2);
-
-		vis_pack16(TMP2, DST_3);
-		vis_st64(DST_2, dest[8]);
-
-		ref += stride;
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_avg_x_8_vis (uint8_t * dest, const uint8_t * _ref,
-			    const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-	int stride_times_2 = stride << 1;
-
-	vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-	vis_ld64(constants3[0], CONST_3);
-	vis_fzero(ZERO);
-	vis_ld64(constants256_512[0], CONST_256);
-
-	ref = vis_alignaddr(ref);
-	height >>= 2;
-	do {	/* 47 cycles */
-		vis_ld64(ref[0],   TMP0);
-
-		vis_ld64_2(ref, 8, TMP2);
-		ref += stride;
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_ld64(ref[0],   TMP4);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64_2(ref, 8, TMP6);
-		ref += stride;
-
-		vis_ld64(ref[0],   TMP8);
-
-		vis_ld64_2(ref, 8, TMP10);
-		ref += stride;
-		vis_faligndata(TMP4, TMP6, REF_4);
-
-		vis_ld64(ref[0],   TMP12);
-
-		vis_ld64_2(ref, 8, TMP14);
-		ref += stride;
-		vis_faligndata(TMP8, TMP10, REF_S0);
-
-		vis_faligndata(TMP12, TMP14, REF_S4);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-
-			vis_ld64(dest[0], DST_0);
-			vis_faligndata(TMP0, TMP2, REF_2);
-
-			vis_ld64_2(dest, stride, DST_2);
-			vis_faligndata(TMP4, TMP6, REF_6);
-
-			vis_faligndata(TMP8, TMP10, REF_S2);
-
-			vis_faligndata(TMP12, TMP14, REF_S6);
-		} else {
-			vis_ld64(dest[0], DST_0);
-			vis_src1(TMP2, REF_2);
-
-			vis_ld64_2(dest, stride, DST_2);
-			vis_src1(TMP6, REF_6);
-
-			vis_src1(TMP10, REF_S2);
-
-			vis_src1(TMP14, REF_S6);
-		}
-
-		vis_pmerge(ZERO,     REF_0,     TMP0);
-		vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
-		vis_pmerge(ZERO,     REF_2,     TMP4);
-		vis_mul8x16au(REF_2_1, CONST_256, TMP6);
-
-		vis_padd16(TMP0, CONST_3, TMP0);
-		vis_mul8x16al(DST_0,   CONST_512, TMP16);
-
-		vis_padd16(TMP2, CONST_3, TMP2);
-		vis_mul8x16al(DST_1,   CONST_512, TMP18);
-
-		vis_padd16(TMP0, TMP4, TMP0);
-		vis_mul8x16au(REF_4, CONST_256, TMP8);
-
-		vis_padd16(TMP2, TMP6, TMP2);
-		vis_mul8x16au(REF_4_1, CONST_256, TMP10);
-
-		vis_padd16(TMP0, TMP16, TMP0);
-		vis_mul8x16au(REF_6, CONST_256, TMP12);
-
-		vis_padd16(TMP2, TMP18, TMP2);
-		vis_mul8x16au(REF_6_1, CONST_256, TMP14);
-
-		vis_padd16(TMP8, CONST_3, TMP8);
-		vis_mul8x16al(DST_2, CONST_512, TMP16);
-
-		vis_padd16(TMP8, TMP12, TMP8);
-		vis_mul8x16al(DST_3, CONST_512, TMP18);
-
-		vis_padd16(TMP10, TMP14, TMP10);
-		vis_pack16(TMP0, DST_0);
-
-		vis_pack16(TMP2, DST_1);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-		vis_padd16(TMP10, CONST_3, TMP10);
-
-		vis_ld64_2(dest, stride, DST_0);
-		vis_padd16(TMP8, TMP16, TMP8);
-
-		vis_ld64_2(dest, stride_times_2, TMP4/*DST_2*/);
-		vis_padd16(TMP10, TMP18, TMP10);
-		vis_pack16(TMP8, DST_2);
-
-		vis_pack16(TMP10, DST_3);
-		vis_st64(DST_2, dest[0]);
-		dest += stride;
-
-		vis_mul8x16au(REF_S0_1, CONST_256, TMP2);
-		vis_pmerge(ZERO,     REF_S0,     TMP0);
-
-		vis_pmerge(ZERO,     REF_S2,     TMP24);
-		vis_mul8x16au(REF_S2_1, CONST_256, TMP6);
-
-		vis_padd16(TMP0, CONST_3, TMP0);
-		vis_mul8x16au(REF_S4, CONST_256, TMP8);
-
-		vis_padd16(TMP2, CONST_3, TMP2);
-		vis_mul8x16au(REF_S4_1, CONST_256, TMP10);
-
-		vis_padd16(TMP0, TMP24, TMP0);
-		vis_mul8x16au(REF_S6, CONST_256, TMP12);
-
-		vis_padd16(TMP2, TMP6, TMP2);
-		vis_mul8x16au(REF_S6_1, CONST_256, TMP14);
-
-		vis_padd16(TMP8, CONST_3, TMP8);
-		vis_mul8x16al(DST_0,   CONST_512, TMP16);
-
-		vis_padd16(TMP10, CONST_3, TMP10);
-		vis_mul8x16al(DST_1,   CONST_512, TMP18);
-
-		vis_padd16(TMP8, TMP12, TMP8);
-		vis_mul8x16al(TMP4/*DST_2*/, CONST_512, TMP20);
-
-		vis_mul8x16al(TMP5/*DST_3*/, CONST_512, TMP22);
-		vis_padd16(TMP0, TMP16, TMP0);
-
-		vis_padd16(TMP2, TMP18, TMP2);
-		vis_pack16(TMP0, DST_0);
-
-		vis_padd16(TMP10, TMP14, TMP10);
-		vis_pack16(TMP2, DST_1);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-
-		vis_padd16(TMP8, TMP20, TMP8);
-
-		vis_padd16(TMP10, TMP22, TMP10);
-		vis_pack16(TMP8, DST_2);
-
-		vis_pack16(TMP10, DST_3);
-		vis_st64(DST_2, dest[0]);
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_put_y_16_vis (uint8_t * dest, const uint8_t * _ref,
-			     const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-
-	ref = vis_alignaddr(ref);
-	vis_ld64(ref[0], TMP0);
-
-	vis_ld64_2(ref, 8, TMP2);
-
-	vis_ld64_2(ref, 16, TMP4);
-	ref += stride;
-
-	vis_ld64(ref[0], TMP6);
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_ld64_2(ref, 8, TMP8);
-	vis_faligndata(TMP2, TMP4, REF_4);
-
-	vis_ld64_2(ref, 16, TMP10);
-	ref += stride;
-
-	vis_ld64(constants_fe[0], MASK_fe);
-	vis_faligndata(TMP6, TMP8, REF_2);
-
-	vis_ld64(constants_7f[0], MASK_7f);
-	vis_faligndata(TMP8, TMP10, REF_6);
-
-	vis_ld64(constants128[0], CONST_128);
-	height = (height >> 1) - 1;
-	do {	/* 24 cycles */
-		vis_ld64(ref[0], TMP0);
-		vis_xor(REF_0, REF_2, TMP12);
-
-		vis_ld64_2(ref, 8, TMP2);
-		vis_xor(REF_4, REF_6, TMP16);
-
-		vis_ld64_2(ref, 16, TMP4);
-		ref += stride;
-		vis_or(REF_0, REF_2, TMP14);
-
-		vis_ld64(ref[0], TMP6);
-		vis_or(REF_4, REF_6, TMP18);
-
-		vis_ld64_2(ref, 8, TMP8);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64_2(ref, 16, TMP10);
-		ref += stride;
-		vis_faligndata(TMP2, TMP4, REF_4);
-
-		vis_and(TMP12, MASK_fe, TMP12);
-
-		vis_and(TMP16, MASK_fe, TMP16);
-		vis_mul8x16(CONST_128, TMP12, TMP12);
-
-		vis_mul8x16(CONST_128, TMP16, TMP16);
-		vis_xor(REF_0, REF_2, TMP0);
-
-		vis_xor(REF_4, REF_6, TMP2);
-
-		vis_or(REF_0, REF_2, TMP20);
-
-		vis_and(TMP12, MASK_7f, TMP12);
-
-		vis_and(TMP16, MASK_7f, TMP16);
-
-		vis_psub16(TMP14, TMP12, TMP12);
-		vis_st64(TMP12, dest[0]);
-
-		vis_psub16(TMP18, TMP16, TMP16);
-		vis_st64_2(TMP16, dest, 8);
-		dest += stride;
-
-		vis_or(REF_4, REF_6, TMP18);
-
-		vis_and(TMP0, MASK_fe, TMP0);
-
-		vis_and(TMP2, MASK_fe, TMP2);
-		vis_mul8x16(CONST_128, TMP0, TMP0);
-
-		vis_faligndata(TMP6, TMP8, REF_2);
-		vis_mul8x16(CONST_128, TMP2, TMP2);
-
-		vis_faligndata(TMP8, TMP10, REF_6);
-
-		vis_and(TMP0, MASK_7f, TMP0);
-
-		vis_and(TMP2, MASK_7f, TMP2);
-
-		vis_psub16(TMP20, TMP0, TMP0);
-		vis_st64(TMP0, dest[0]);
-
-		vis_psub16(TMP18, TMP2, TMP2);
-		vis_st64_2(TMP2, dest, 8);
-		dest += stride;
-	} while (--height);
-
-	vis_ld64(ref[0], TMP0);
-	vis_xor(REF_0, REF_2, TMP12);
-
-	vis_ld64_2(ref, 8, TMP2);
-	vis_xor(REF_4, REF_6, TMP16);
-
-	vis_ld64_2(ref, 16, TMP4);
-	vis_or(REF_0, REF_2, TMP14);
-
-	vis_or(REF_4, REF_6, TMP18);
-
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_faligndata(TMP2, TMP4, REF_4);
-
-	vis_and(TMP12, MASK_fe, TMP12);
-
-	vis_and(TMP16, MASK_fe, TMP16);
-	vis_mul8x16(CONST_128, TMP12, TMP12);
-
-	vis_mul8x16(CONST_128, TMP16, TMP16);
-	vis_xor(REF_0, REF_2, TMP0);
-
-	vis_xor(REF_4, REF_6, TMP2);
-
-	vis_or(REF_0, REF_2, TMP20);
-
-	vis_and(TMP12, MASK_7f, TMP12);
-
-	vis_and(TMP16, MASK_7f, TMP16);
-
-	vis_psub16(TMP14, TMP12, TMP12);
-	vis_st64(TMP12, dest[0]);
-
-	vis_psub16(TMP18, TMP16, TMP16);
-	vis_st64_2(TMP16, dest, 8);
-	dest += stride;
-
-	vis_or(REF_4, REF_6, TMP18);
-
-	vis_and(TMP0, MASK_fe, TMP0);
-
-	vis_and(TMP2, MASK_fe, TMP2);
-	vis_mul8x16(CONST_128, TMP0, TMP0);
-
-	vis_mul8x16(CONST_128, TMP2, TMP2);
-
-	vis_and(TMP0, MASK_7f, TMP0);
-
-	vis_and(TMP2, MASK_7f, TMP2);
-
-	vis_psub16(TMP20, TMP0, TMP0);
-	vis_st64(TMP0, dest[0]);
-
-	vis_psub16(TMP18, TMP2, TMP2);
-	vis_st64_2(TMP2, dest, 8);
-}
-
-static void MC_put_y_8_vis (uint8_t * dest, const uint8_t * _ref,
-			    const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-
-	ref = vis_alignaddr(ref);
-	vis_ld64(ref[0], TMP0);
-
-	vis_ld64_2(ref, 8, TMP2);
-	ref += stride;
-
-	vis_ld64(ref[0], TMP4);
-
-	vis_ld64_2(ref, 8, TMP6);
-	ref += stride;
-
-	vis_ld64(constants_fe[0], MASK_fe);
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_ld64(constants_7f[0], MASK_7f);
-	vis_faligndata(TMP4, TMP6, REF_2);
-
-	vis_ld64(constants128[0], CONST_128);
-	height = (height >> 1) - 1;
-	do {	/* 12 cycles */
-		vis_ld64(ref[0], TMP0);
-		vis_xor(REF_0, REF_2, TMP4);
-
-		vis_ld64_2(ref, 8, TMP2);
-		ref += stride;
-		vis_and(TMP4, MASK_fe, TMP4);
-
-		vis_or(REF_0, REF_2, TMP6);
-		vis_mul8x16(CONST_128, TMP4, TMP4);
-
-		vis_faligndata(TMP0, TMP2, REF_0);
-		vis_ld64(ref[0], TMP0);
-
-		vis_ld64_2(ref, 8, TMP2);
-		ref += stride;
-		vis_xor(REF_0, REF_2, TMP12);
-
-		vis_and(TMP4, MASK_7f, TMP4);
-
-		vis_and(TMP12, MASK_fe, TMP12);
-
-		vis_mul8x16(CONST_128, TMP12, TMP12);
-		vis_or(REF_0, REF_2, TMP14);
-
-		vis_psub16(TMP6, TMP4, DST_0);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-
-		vis_faligndata(TMP0, TMP2, REF_2);
-
-		vis_and(TMP12, MASK_7f, TMP12);
-
-		vis_psub16(TMP14, TMP12, DST_0);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-	} while (--height);
-
-	vis_ld64(ref[0], TMP0);
-	vis_xor(REF_0, REF_2, TMP4);
-
-	vis_ld64_2(ref, 8, TMP2);
-	vis_and(TMP4, MASK_fe, TMP4);
-
-	vis_or(REF_0, REF_2, TMP6);
-	vis_mul8x16(CONST_128, TMP4, TMP4);
-
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_xor(REF_0, REF_2, TMP12);
-
-	vis_and(TMP4, MASK_7f, TMP4);
-
-	vis_and(TMP12, MASK_fe, TMP12);
-
-	vis_mul8x16(CONST_128, TMP12, TMP12);
-	vis_or(REF_0, REF_2, TMP14);
-
-	vis_psub16(TMP6, TMP4, DST_0);
-	vis_st64(DST_0, dest[0]);
-	dest += stride;
-
-	vis_and(TMP12, MASK_7f, TMP12);
-
-	vis_psub16(TMP14, TMP12, DST_0);
-	vis_st64(DST_0, dest[0]);
-}
-
-static void MC_avg_y_16_vis (uint8_t * dest, const uint8_t * _ref,
-			     const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	int stride_8 = stride + 8;
-	int stride_16 = stride + 16;
-
-	vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[ 0], TMP0);
-	vis_fzero(ZERO);
-
-	vis_ld64(ref[ 8], TMP2);
-
-	vis_ld64(ref[16], TMP4);
-
-	vis_ld64(constants3[0], CONST_3);
-	vis_faligndata(TMP0, TMP2, REF_2);
-
-	vis_ld64(constants256_512[0], CONST_256);
-	vis_faligndata(TMP2, TMP4, REF_6);
-	height >>= 1;
-
-	do {	/* 31 cycles */
-		vis_ld64_2(ref, stride, TMP0);
-		vis_pmerge(ZERO,       REF_2,     TMP12);
-		vis_mul8x16au(REF_2_1, CONST_256, TMP14);
-
-		vis_ld64_2(ref, stride_8, TMP2);
-		vis_pmerge(ZERO,       REF_6,     TMP16);
-		vis_mul8x16au(REF_6_1, CONST_256, TMP18);
-
-		vis_ld64_2(ref, stride_16, TMP4);
-		ref += stride;
-
-		vis_ld64(dest[0], DST_0);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64_2(dest, 8, DST_2);
-		vis_faligndata(TMP2, TMP4, REF_4);
-
-		vis_ld64_2(ref, stride, TMP6);
-		vis_pmerge(ZERO,     REF_0,     TMP0);
-		vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
-		vis_ld64_2(ref, stride_8, TMP8);
-		vis_pmerge(ZERO,     REF_4,     TMP4);
-
-		vis_ld64_2(ref, stride_16, TMP10);
-		ref += stride;
-
-		vis_ld64_2(dest, stride, REF_S0/*DST_4*/);
-		vis_faligndata(TMP6, TMP8, REF_2);
-		vis_mul8x16au(REF_4_1, CONST_256, TMP6);
-
-		vis_ld64_2(dest, stride_8, REF_S2/*DST_6*/);
-		vis_faligndata(TMP8, TMP10, REF_6);
-		vis_mul8x16al(DST_0,   CONST_512, TMP20);
-
-		vis_padd16(TMP0, CONST_3, TMP0);
-		vis_mul8x16al(DST_1,   CONST_512, TMP22);
-
-		vis_padd16(TMP2, CONST_3, TMP2);
-		vis_mul8x16al(DST_2,   CONST_512, TMP24);
-
-		vis_padd16(TMP4, CONST_3, TMP4);
-		vis_mul8x16al(DST_3,   CONST_512, TMP26);
-
-		vis_padd16(TMP6, CONST_3, TMP6);
-
-		vis_padd16(TMP12, TMP20, TMP12);
-		vis_mul8x16al(REF_S0,   CONST_512, TMP20);
-
-		vis_padd16(TMP14, TMP22, TMP14);
-		vis_mul8x16al(REF_S0_1, CONST_512, TMP22);
-
-		vis_padd16(TMP16, TMP24, TMP16);
-		vis_mul8x16al(REF_S2,   CONST_512, TMP24);
-
-		vis_padd16(TMP18, TMP26, TMP18);
-		vis_mul8x16al(REF_S2_1, CONST_512, TMP26);
-
-		vis_padd16(TMP12, TMP0, TMP12);
-		vis_mul8x16au(REF_2,   CONST_256, TMP28);
-
-		vis_padd16(TMP14, TMP2, TMP14);
-		vis_mul8x16au(REF_2_1, CONST_256, TMP30);
-
-		vis_padd16(TMP16, TMP4, TMP16);
-		vis_mul8x16au(REF_6,   CONST_256, REF_S4);
-
-		vis_padd16(TMP18, TMP6, TMP18);
-		vis_mul8x16au(REF_6_1, CONST_256, REF_S6);
-
-		vis_pack16(TMP12, DST_0);
-		vis_padd16(TMP28, TMP0, TMP12);
-
-		vis_pack16(TMP14, DST_1);
-		vis_st64(DST_0, dest[0]);
-		vis_padd16(TMP30, TMP2, TMP14);
-
-		vis_pack16(TMP16, DST_2);
-		vis_padd16(REF_S4, TMP4, TMP16);
-
-		vis_pack16(TMP18, DST_3);
-		vis_st64_2(DST_2, dest, 8);
-		dest += stride;
-		vis_padd16(REF_S6, TMP6, TMP18);
-
-		vis_padd16(TMP12, TMP20, TMP12);
-
-		vis_padd16(TMP14, TMP22, TMP14);
-		vis_pack16(TMP12, DST_0);
-
-		vis_padd16(TMP16, TMP24, TMP16);
-		vis_pack16(TMP14, DST_1);
-		vis_st64(DST_0, dest[0]);
-
-		vis_padd16(TMP18, TMP26, TMP18);
-		vis_pack16(TMP16, DST_2);
-
-		vis_pack16(TMP18, DST_3);
-		vis_st64_2(DST_2, dest, 8);
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_avg_y_8_vis (uint8_t * dest, const uint8_t * _ref,
-			    const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	int stride_8 = stride + 8;
-
-	vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[ 0], TMP0);
-	vis_fzero(ZERO);
-
-	vis_ld64(ref[ 8], TMP2);
-
-	vis_ld64(constants3[0], CONST_3);
-	vis_faligndata(TMP0, TMP2, REF_2);
-
-	vis_ld64(constants256_512[0], CONST_256);
-
-	height >>= 1;
-	do {	/* 20 cycles */
-		vis_ld64_2(ref, stride, TMP0);
-		vis_pmerge(ZERO,       REF_2,     TMP8);
-		vis_mul8x16au(REF_2_1, CONST_256, TMP10);
-
-		vis_ld64_2(ref, stride_8, TMP2);
-		ref += stride;
-
-		vis_ld64(dest[0], DST_0);
-
-		vis_ld64_2(dest, stride, DST_2);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64_2(ref, stride, TMP4);
-		vis_mul8x16al(DST_0,   CONST_512, TMP16);
-		vis_pmerge(ZERO,       REF_0,     TMP12);
-
-		vis_ld64_2(ref, stride_8, TMP6);
-		ref += stride;
-		vis_mul8x16al(DST_1,   CONST_512, TMP18);
-		vis_pmerge(ZERO,       REF_0_1,   TMP14);
-
-		vis_padd16(TMP12, CONST_3, TMP12);
-		vis_mul8x16al(DST_2,   CONST_512, TMP24);
-
-		vis_padd16(TMP14, CONST_3, TMP14);
-		vis_mul8x16al(DST_3,   CONST_512, TMP26);
-
-		vis_faligndata(TMP4, TMP6, REF_2);
-
-		vis_padd16(TMP8, TMP12, TMP8);
-
-		vis_padd16(TMP10, TMP14, TMP10);
-		vis_mul8x16au(REF_2,   CONST_256, TMP20);
-
-		vis_padd16(TMP8, TMP16, TMP0);
-		vis_mul8x16au(REF_2_1, CONST_256, TMP22);
-
-		vis_padd16(TMP10, TMP18, TMP2);
-		vis_pack16(TMP0, DST_0);
-
-		vis_pack16(TMP2, DST_1);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-		vis_padd16(TMP12, TMP20, TMP12);
-
-		vis_padd16(TMP14, TMP22, TMP14);
-
-		vis_padd16(TMP12, TMP24, TMP0);
-
-		vis_padd16(TMP14, TMP26, TMP2);
-		vis_pack16(TMP0, DST_2);
-
-		vis_pack16(TMP2, DST_3);
-		vis_st64(DST_2, dest[0]);
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_put_xy_16_vis (uint8_t * dest, const uint8_t * _ref,
-			      const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-	int stride_8 = stride + 8;
-	int stride_16 = stride + 16;
-
-	vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[ 0], TMP0);
-	vis_fzero(ZERO);
-
-	vis_ld64(ref[ 8], TMP2);
-
-	vis_ld64(ref[16], TMP4);
-
-	vis_ld64(constants2[0], CONST_2);
-	vis_faligndata(TMP0, TMP2, REF_S0);
-
-	vis_ld64(constants256_512[0], CONST_256);
-	vis_faligndata(TMP2, TMP4, REF_S4);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_S2);
-		vis_faligndata(TMP2, TMP4, REF_S6);
-	} else {
-		vis_src1(TMP2, REF_S2);
-		vis_src1(TMP4, REF_S6);
-	}
-
-	height >>= 1;
-	do {
-		vis_ld64_2(ref, stride, TMP0);
-		vis_mul8x16au(REF_S0, CONST_256, TMP12);
-		vis_pmerge(ZERO,      REF_S0_1,  TMP14);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_ld64_2(ref, stride_8, TMP2);
-		vis_mul8x16au(REF_S2, CONST_256, TMP16);
-		vis_pmerge(ZERO,      REF_S2_1,  TMP18);
-
-		vis_ld64_2(ref, stride_16, TMP4);
-		ref += stride;
-		vis_mul8x16au(REF_S4, CONST_256, TMP20);
-		vis_pmerge(ZERO,      REF_S4_1,  TMP22);
-
-		vis_ld64_2(ref, stride, TMP6);
-		vis_mul8x16au(REF_S6, CONST_256, TMP24);
-		vis_pmerge(ZERO,      REF_S6_1,  TMP26);
-
-		vis_ld64_2(ref, stride_8, TMP8);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64_2(ref, stride_16, TMP10);
-		ref += stride;
-		vis_faligndata(TMP2, TMP4, REF_4);
-
-		vis_faligndata(TMP6, TMP8, REF_S0);
-
-		vis_faligndata(TMP8, TMP10, REF_S4);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP0, TMP2, REF_2);
-			vis_faligndata(TMP2, TMP4, REF_6);
-			vis_faligndata(TMP6, TMP8, REF_S2);
-			vis_faligndata(TMP8, TMP10, REF_S6);
-		} else {
-			vis_src1(TMP2, REF_2);
-			vis_src1(TMP4, REF_6);
-			vis_src1(TMP8, REF_S2);
-			vis_src1(TMP10, REF_S6);
-		}
-
-		vis_mul8x16au(REF_0, CONST_256, TMP0);
-		vis_pmerge(ZERO,      REF_0_1,  TMP2);
-
-		vis_mul8x16au(REF_2, CONST_256, TMP4);
-		vis_pmerge(ZERO,      REF_2_1,  TMP6);
-
-		vis_padd16(TMP0, CONST_2, TMP8);
-		vis_mul8x16au(REF_4, CONST_256, TMP0);
-
-		vis_padd16(TMP2, CONST_2, TMP10);
-		vis_mul8x16au(REF_4_1, CONST_256, TMP2);
-
-		vis_padd16(TMP8, TMP4, TMP8);
-		vis_mul8x16au(REF_6, CONST_256, TMP4);
-
-		vis_padd16(TMP10, TMP6, TMP10);
-		vis_mul8x16au(REF_6_1, CONST_256, TMP6);
-
-		vis_padd16(TMP12, TMP8, TMP12);
-
-		vis_padd16(TMP14, TMP10, TMP14);
-
-		vis_padd16(TMP12, TMP16, TMP12);
-
-		vis_padd16(TMP14, TMP18, TMP14);
-		vis_pack16(TMP12, DST_0);
-
-		vis_pack16(TMP14, DST_1);
-		vis_st64(DST_0, dest[0]);
-		vis_padd16(TMP0, CONST_2, TMP12);
-
-		vis_mul8x16au(REF_S0, CONST_256, TMP0);
-		vis_padd16(TMP2, CONST_2, TMP14);
-
-		vis_mul8x16au(REF_S0_1, CONST_256, TMP2);
-		vis_padd16(TMP12, TMP4, TMP12);
-
-		vis_mul8x16au(REF_S2, CONST_256, TMP4);
-		vis_padd16(TMP14, TMP6, TMP14);
-
-		vis_mul8x16au(REF_S2_1, CONST_256, TMP6);
-		vis_padd16(TMP20, TMP12, TMP20);
-
-		vis_padd16(TMP22, TMP14, TMP22);
-
-		vis_padd16(TMP20, TMP24, TMP20);
-
-		vis_padd16(TMP22, TMP26, TMP22);
-		vis_pack16(TMP20, DST_2);
-
-		vis_pack16(TMP22, DST_3);
-		vis_st64_2(DST_2, dest, 8);
-		dest += stride;
-		vis_padd16(TMP0, TMP4, TMP24);
-
-		vis_mul8x16au(REF_S4, CONST_256, TMP0);
-		vis_padd16(TMP2, TMP6, TMP26);
-
-		vis_mul8x16au(REF_S4_1, CONST_256, TMP2);
-		vis_padd16(TMP24, TMP8, TMP24);
-
-		vis_padd16(TMP26, TMP10, TMP26);
-		vis_pack16(TMP24, DST_0);
-
-		vis_pack16(TMP26, DST_1);
-		vis_st64(DST_0, dest[0]);
-		vis_pmerge(ZERO, REF_S6, TMP4);
-
-		vis_pmerge(ZERO,      REF_S6_1,  TMP6);
-
-		vis_padd16(TMP0, TMP4, TMP0);
-
-		vis_padd16(TMP2, TMP6, TMP2);
-
-		vis_padd16(TMP0, TMP12, TMP0);
-
-		vis_padd16(TMP2, TMP14, TMP2);
-		vis_pack16(TMP0, DST_2);
-
-		vis_pack16(TMP2, DST_3);
-		vis_st64_2(DST_2, dest, 8);
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_put_xy_8_vis (uint8_t * dest, const uint8_t * _ref,
-			     const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-	int stride_8 = stride + 8;
-
-	vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[ 0], TMP0);
-	vis_fzero(ZERO);
-
-	vis_ld64(ref[ 8], TMP2);
-
-	vis_ld64(constants2[0], CONST_2);
-
-	vis_ld64(constants256_512[0], CONST_256);
-	vis_faligndata(TMP0, TMP2, REF_S0);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_S2);
-	} else {
-		vis_src1(TMP2, REF_S2);
-	}
-
-	height >>= 1;
-	do {	/* 26 cycles */
-		vis_ld64_2(ref, stride, TMP0);
-		vis_mul8x16au(REF_S0,   CONST_256, TMP8);
-		vis_pmerge(ZERO,        REF_S2,    TMP12);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_ld64_2(ref, stride_8, TMP2);
-		ref += stride;
-		vis_mul8x16au(REF_S0_1, CONST_256, TMP10);
-		vis_pmerge(ZERO,        REF_S2_1,  TMP14);
-
-		vis_ld64_2(ref, stride, TMP4);
-
-		vis_ld64_2(ref, stride_8, TMP6);
-		ref += stride;
-		vis_faligndata(TMP0, TMP2, REF_S4);
-
-		vis_pmerge(ZERO, REF_S4, TMP18);
-
-		vis_pmerge(ZERO, REF_S4_1, TMP20);
-
-		vis_faligndata(TMP4, TMP6, REF_S0);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP0, TMP2, REF_S6);
-			vis_faligndata(TMP4, TMP6, REF_S2);
-		} else {
-			vis_src1(TMP2, REF_S6);
-			vis_src1(TMP6, REF_S2);
-		}
-
-		vis_padd16(TMP18, CONST_2, TMP18);
-		vis_mul8x16au(REF_S6,   CONST_256, TMP22);
-
-		vis_padd16(TMP20, CONST_2, TMP20);
-		vis_mul8x16au(REF_S6_1, CONST_256, TMP24);
-
-		vis_mul8x16au(REF_S0,   CONST_256, TMP26);
-		vis_pmerge(ZERO, REF_S0_1, TMP28);
-
-		vis_mul8x16au(REF_S2,   CONST_256, TMP30);
-		vis_padd16(TMP18, TMP22, TMP18);
-
-		vis_mul8x16au(REF_S2_1, CONST_256, TMP32);
-		vis_padd16(TMP20, TMP24, TMP20);
-
-		vis_padd16(TMP8,  TMP18, TMP8);
-
-		vis_padd16(TMP10, TMP20, TMP10);
-
-		vis_padd16(TMP8,  TMP12, TMP8);
-
-		vis_padd16(TMP10, TMP14, TMP10);
-		vis_pack16(TMP8,  DST_0);
-
-		vis_pack16(TMP10, DST_1);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-		vis_padd16(TMP18, TMP26, TMP18);
-
-		vis_padd16(TMP20, TMP28, TMP20);
-
-		vis_padd16(TMP18, TMP30, TMP18);
-
-		vis_padd16(TMP20, TMP32, TMP20);
-		vis_pack16(TMP18, DST_2);
-
-		vis_pack16(TMP20, DST_3);
-		vis_st64(DST_2, dest[0]);
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_avg_xy_16_vis (uint8_t * dest, const uint8_t * _ref,
-			      const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-	int stride_8 = stride + 8;
-	int stride_16 = stride + 16;
-
-	vis_set_gsr(4 << VIS_GSR_SCALEFACT_SHIFT);
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[ 0], TMP0);
-	vis_fzero(ZERO);
-
-	vis_ld64(ref[ 8], TMP2);
-
-	vis_ld64(ref[16], TMP4);
-
-	vis_ld64(constants6[0], CONST_6);
-	vis_faligndata(TMP0, TMP2, REF_S0);
-
-	vis_ld64(constants256_1024[0], CONST_256);
-	vis_faligndata(TMP2, TMP4, REF_S4);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_S2);
-		vis_faligndata(TMP2, TMP4, REF_S6);
-	} else {
-		vis_src1(TMP2, REF_S2);
-		vis_src1(TMP4, REF_S6);
-	}
-
-	height >>= 1;
-	do {	/* 55 cycles */
-		vis_ld64_2(ref, stride, TMP0);
-		vis_mul8x16au(REF_S0, CONST_256, TMP12);
-		vis_pmerge(ZERO,      REF_S0_1,  TMP14);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_ld64_2(ref, stride_8, TMP2);
-		vis_mul8x16au(REF_S2, CONST_256, TMP16);
-		vis_pmerge(ZERO,      REF_S2_1,  TMP18);
-
-		vis_ld64_2(ref, stride_16, TMP4);
-		ref += stride;
-		vis_mul8x16au(REF_S4, CONST_256, TMP20);
-		vis_pmerge(ZERO,      REF_S4_1,  TMP22);
-
-		vis_ld64_2(ref, stride, TMP6);
-		vis_mul8x16au(REF_S6, CONST_256, TMP24);
-		vis_pmerge(ZERO,      REF_S6_1,  TMP26);
-
-		vis_ld64_2(ref, stride_8, TMP8);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64_2(ref, stride_16, TMP10);
-		ref += stride;
-		vis_faligndata(TMP2, TMP4, REF_4);
-
-		vis_ld64(dest[0], DST_0);
-		vis_faligndata(TMP6, TMP8, REF_S0);
-
-		vis_ld64_2(dest, 8, DST_2);
-		vis_faligndata(TMP8, TMP10, REF_S4);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP0, TMP2, REF_2);
-			vis_faligndata(TMP2, TMP4, REF_6);
-			vis_faligndata(TMP6, TMP8, REF_S2);
-			vis_faligndata(TMP8, TMP10, REF_S6);
-		} else {
-			vis_src1(TMP2, REF_2);
-			vis_src1(TMP4, REF_6);
-			vis_src1(TMP8, REF_S2);
-			vis_src1(TMP10, REF_S6);
-		}
-
-		vis_mul8x16al(DST_0,   CONST_1024, TMP30);
-		vis_pmerge(ZERO, REF_0, TMP0);
-
-		vis_mul8x16al(DST_1,   CONST_1024, TMP32);
-		vis_pmerge(ZERO,      REF_0_1,  TMP2);
-
-		vis_mul8x16au(REF_2, CONST_256, TMP4);
-		vis_pmerge(ZERO,      REF_2_1,  TMP6);
-
-		vis_mul8x16al(DST_2,   CONST_1024, REF_0);
-		vis_padd16(TMP0, CONST_6, TMP0);
-
-		vis_mul8x16al(DST_3,   CONST_1024, REF_2);
-		vis_padd16(TMP2, CONST_6, TMP2);
-
-		vis_padd16(TMP0, TMP4, TMP0);
-		vis_mul8x16au(REF_4, CONST_256, TMP4);
-
-		vis_padd16(TMP2, TMP6, TMP2);
-		vis_mul8x16au(REF_4_1, CONST_256, TMP6);
-
-		vis_padd16(TMP12, TMP0, TMP12);
-		vis_mul8x16au(REF_6, CONST_256, TMP8);
-
-		vis_padd16(TMP14, TMP2, TMP14);
-		vis_mul8x16au(REF_6_1, CONST_256, TMP10);
-
-		vis_padd16(TMP12, TMP16, TMP12);
-		vis_mul8x16au(REF_S0, CONST_256, REF_4);
-
-		vis_padd16(TMP14, TMP18, TMP14);
-		vis_mul8x16au(REF_S0_1, CONST_256, REF_6);
-
-		vis_padd16(TMP12, TMP30, TMP12);
-
-		vis_padd16(TMP14, TMP32, TMP14);
-		vis_pack16(TMP12, DST_0);
-
-		vis_pack16(TMP14, DST_1);
-		vis_st64(DST_0, dest[0]);
-		vis_padd16(TMP4, CONST_6, TMP4);
-
-		vis_ld64_2(dest, stride, DST_0);
-		vis_padd16(TMP6, CONST_6, TMP6);
-		vis_mul8x16au(REF_S2, CONST_256, TMP12);
-
-		vis_padd16(TMP4, TMP8, TMP4);
-		vis_mul8x16au(REF_S2_1, CONST_256,  TMP14);
-
-		vis_padd16(TMP6, TMP10, TMP6);
-
-		vis_padd16(TMP20, TMP4, TMP20);
-
-		vis_padd16(TMP22, TMP6, TMP22);
-
-		vis_padd16(TMP20, TMP24, TMP20);
-
-		vis_padd16(TMP22, TMP26, TMP22);
-
-		vis_padd16(TMP20, REF_0, TMP20);
-		vis_mul8x16au(REF_S4, CONST_256, REF_0);
-
-		vis_padd16(TMP22, REF_2, TMP22);
-		vis_pack16(TMP20, DST_2);
-
-		vis_pack16(TMP22, DST_3);
-		vis_st64_2(DST_2, dest, 8);
-		dest += stride;
-
-		vis_ld64_2(dest, 8, DST_2);
-		vis_mul8x16al(DST_0,   CONST_1024, TMP30);
-		vis_pmerge(ZERO,      REF_S4_1,  REF_2);
-
-		vis_mul8x16al(DST_1,   CONST_1024, TMP32);
-		vis_padd16(REF_4, TMP0, TMP8);
-
-		vis_mul8x16au(REF_S6, CONST_256, REF_4);
-		vis_padd16(REF_6, TMP2, TMP10);
-
-		vis_mul8x16au(REF_S6_1, CONST_256, REF_6);
-		vis_padd16(TMP8, TMP12, TMP8);
-
-		vis_padd16(TMP10, TMP14, TMP10);
-
-		vis_padd16(TMP8, TMP30, TMP8);
-
-		vis_padd16(TMP10, TMP32, TMP10);
-		vis_pack16(TMP8, DST_0);
-
-		vis_pack16(TMP10, DST_1);
-		vis_st64(DST_0, dest[0]);
-
-		vis_padd16(REF_0, TMP4, REF_0);
-
-		vis_mul8x16al(DST_2,   CONST_1024, TMP30);
-		vis_padd16(REF_2, TMP6, REF_2);
-
-		vis_mul8x16al(DST_3,   CONST_1024, TMP32);
-		vis_padd16(REF_0, REF_4, REF_0);
-
-		vis_padd16(REF_2, REF_6, REF_2);
-
-		vis_padd16(REF_0, TMP30, REF_0);
-
-		/* stall */
-
-		vis_padd16(REF_2, TMP32, REF_2);
-		vis_pack16(REF_0, DST_2);
-
-		vis_pack16(REF_2, DST_3);
-		vis_st64_2(DST_2, dest, 8);
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_avg_xy_8_vis (uint8_t * dest, const uint8_t * _ref,
-			     const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-	int stride_8 = stride + 8;
-
-	vis_set_gsr(4 << VIS_GSR_SCALEFACT_SHIFT);
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[0], TMP0);
-	vis_fzero(ZERO);
-
-	vis_ld64_2(ref, 8, TMP2);
-
-	vis_ld64(constants6[0], CONST_6);
-
-	vis_ld64(constants256_1024[0], CONST_256);
-	vis_faligndata(TMP0, TMP2, REF_S0);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_S2);
-	} else {
-		vis_src1(TMP2, REF_S2);
-	}
-
-	height >>= 1;
-	do {	/* 31 cycles */
-		vis_ld64_2(ref, stride, TMP0);
-		vis_mul8x16au(REF_S0, CONST_256, TMP8);
-		vis_pmerge(ZERO,      REF_S0_1,  TMP10);
-
-		vis_ld64_2(ref, stride_8, TMP2);
-		ref += stride;
-		vis_mul8x16au(REF_S2, CONST_256, TMP12);
-		vis_pmerge(ZERO,      REF_S2_1,  TMP14);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_ld64_2(ref, stride, TMP4);
-		vis_faligndata(TMP0, TMP2, REF_S4);
-
-		vis_ld64_2(ref, stride_8, TMP6);
-		ref += stride;
-
-		vis_ld64(dest[0], DST_0);
-		vis_faligndata(TMP4, TMP6, REF_S0);
-
-		vis_ld64_2(dest, stride, DST_2);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP0, TMP2, REF_S6);
-			vis_faligndata(TMP4, TMP6, REF_S2);
-		} else {
-			vis_src1(TMP2, REF_S6);
-			vis_src1(TMP6, REF_S2);
-		}
-
-		vis_mul8x16al(DST_0,   CONST_1024, TMP30);
-		vis_pmerge(ZERO, REF_S4, TMP22);
-
-		vis_mul8x16al(DST_1,   CONST_1024, TMP32);
-		vis_pmerge(ZERO,      REF_S4_1,  TMP24);
-
-		vis_mul8x16au(REF_S6, CONST_256, TMP26);
-		vis_pmerge(ZERO,      REF_S6_1,  TMP28);
-
-		vis_mul8x16au(REF_S0, CONST_256, REF_S4);
-		vis_padd16(TMP22, CONST_6, TMP22);
-
-		vis_mul8x16au(REF_S0_1, CONST_256, REF_S6);
-		vis_padd16(TMP24, CONST_6, TMP24);
-
-		vis_mul8x16al(DST_2,   CONST_1024, REF_0);
-		vis_padd16(TMP22, TMP26, TMP22);
-
-		vis_mul8x16al(DST_3,   CONST_1024, REF_2);
-		vis_padd16(TMP24, TMP28, TMP24);
-
-		vis_mul8x16au(REF_S2, CONST_256, TMP26);
-		vis_padd16(TMP8, TMP22, TMP8);
-
-		vis_mul8x16au(REF_S2_1, CONST_256, TMP28);
-		vis_padd16(TMP10, TMP24, TMP10);
-
-		vis_padd16(TMP8, TMP12, TMP8);
-
-		vis_padd16(TMP10, TMP14, TMP10);
-
-		vis_padd16(TMP8, TMP30, TMP8);
-
-		vis_padd16(TMP10, TMP32, TMP10);
-		vis_pack16(TMP8, DST_0);
-
-		vis_pack16(TMP10, DST_1);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-
-		vis_padd16(REF_S4, TMP22, TMP12);
-
-		vis_padd16(REF_S6, TMP24, TMP14);
-
-		vis_padd16(TMP12, TMP26, TMP12);
-
-		vis_padd16(TMP14, TMP28, TMP14);
-
-		vis_padd16(TMP12, REF_0, TMP12);
-
-		vis_padd16(TMP14, REF_2, TMP14);
-		vis_pack16(TMP12, DST_2);
-
-		vis_pack16(TMP14, DST_3);
-		vis_st64(DST_2, dest[0]);
-		dest += stride;
-	} while (--height);
-}
-
-/* End of rounding code */
-
-/* Start of no rounding code */
-/* The trick used in some of this file is the formula from the MMX
- * motion comp code, which is:
- *
- * (x+y)>>1 == (x&y)+((x^y)>>1)
- *
- * This allows us to average 8 bytes at a time in a 64-bit FPU reg.
- * We avoid overflows by masking before we do the shift, and we
- * implement the shift by multiplying by 1/2 using mul8x16.  So in
- * VIS this is (assume 'x' is in f0, 'y' is in f2, a repeating mask
- * of '0xfe' is in f4, a repeating mask of '0x7f' is in f6, and
- * the value 0x80808080 is in f8):
- *
- *	fxor		f0, f2, f10
- *	fand		f10, f4, f10
- *	fmul8x16	f8, f10, f10
- *	fand		f10, f6, f10
- *	fand		f0, f2, f12
- *	fpadd16		f12, f10, f10
- */
-
-static void MC_put_no_round_o_16_vis (uint8_t * dest, const uint8_t * _ref,
-				      const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-
-	ref = vis_alignaddr(ref);
-	do {	/* 5 cycles */
-		vis_ld64(ref[0], TMP0);
-
-		vis_ld64_2(ref, 8, TMP2);
-
-		vis_ld64_2(ref, 16, TMP4);
-		ref += stride;
-
-		vis_faligndata(TMP0, TMP2, REF_0);
-		vis_st64(REF_0, dest[0]);
-
-		vis_faligndata(TMP2, TMP4, REF_2);
-		vis_st64_2(REF_2, dest, 8);
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_put_no_round_o_8_vis (uint8_t * dest, const uint8_t * _ref,
-			    const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-
-	ref = vis_alignaddr(ref);
-	do {	/* 4 cycles */
-		vis_ld64(ref[0], TMP0);
-
-		vis_ld64(ref[8], TMP2);
-		ref += stride;
-
-		/* stall */
-
-		vis_faligndata(TMP0, TMP2, REF_0);
-		vis_st64(REF_0, dest[0]);
-		dest += stride;
-	} while (--height);
-}
-
-
-static void MC_avg_no_round_o_16_vis (uint8_t * dest, const uint8_t * _ref,
-			     const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	int stride_8 = stride + 8;
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[0], TMP0);
-
-	vis_ld64(ref[8], TMP2);
-
-	vis_ld64(ref[16], TMP4);
-
-	vis_ld64(dest[0], DST_0);
-
-	vis_ld64(dest[8], DST_2);
-
-	vis_ld64(constants_fe[0], MASK_fe);
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_ld64(constants_7f[0], MASK_7f);
-	vis_faligndata(TMP2, TMP4, REF_2);
-
-	vis_ld64(constants128[0], CONST_128);
-
-	ref += stride;
-	height = (height >> 1) - 1;
-
-	do {	/* 24 cycles */
-		vis_ld64(ref[0], TMP0);
-		vis_xor(DST_0, REF_0, TMP6);
-
-		vis_ld64_2(ref, 8, TMP2);
-		vis_and(TMP6, MASK_fe, TMP6);
-
-		vis_ld64_2(ref, 16, TMP4);
-		ref += stride;
-		vis_mul8x16(CONST_128, TMP6, TMP6);
-		vis_xor(DST_2, REF_2, TMP8);
-
-		vis_and(TMP8, MASK_fe, TMP8);
-
-		vis_and(DST_0, REF_0, TMP10);
-		vis_ld64_2(dest, stride, DST_0);
-		vis_mul8x16(CONST_128, TMP8, TMP8);
-
-		vis_and(DST_2, REF_2, TMP12);
-		vis_ld64_2(dest, stride_8, DST_2);
-
-		vis_ld64(ref[0], TMP14);
-		vis_and(TMP6, MASK_7f, TMP6);
-
-		vis_and(TMP8, MASK_7f, TMP8);
-
-		vis_padd16(TMP10, TMP6, TMP6);
-		vis_st64(TMP6, dest[0]);
-
-		vis_padd16(TMP12, TMP8, TMP8);
-		vis_st64_2(TMP8, dest, 8);
-
-		dest += stride;
-		vis_ld64_2(ref, 8, TMP16);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64_2(ref, 16, TMP18);
-		vis_faligndata(TMP2, TMP4, REF_2);
-		ref += stride;
-
-		vis_xor(DST_0, REF_0, TMP20);
-
-		vis_and(TMP20, MASK_fe, TMP20);
-
-		vis_xor(DST_2, REF_2, TMP22);
-		vis_mul8x16(CONST_128, TMP20, TMP20);
-
-		vis_and(TMP22, MASK_fe, TMP22);
-
-		vis_and(DST_0, REF_0, TMP24);
-		vis_mul8x16(CONST_128, TMP22, TMP22);
-
-		vis_and(DST_2, REF_2, TMP26);
-
-		vis_ld64_2(dest, stride, DST_0);
-		vis_faligndata(TMP14, TMP16, REF_0);
-
-		vis_ld64_2(dest, stride_8, DST_2);
-		vis_faligndata(TMP16, TMP18, REF_2);
-
-		vis_and(TMP20, MASK_7f, TMP20);
-
-		vis_and(TMP22, MASK_7f, TMP22);
-
-		vis_padd16(TMP24, TMP20, TMP20);
-		vis_st64(TMP20, dest[0]);
-
-		vis_padd16(TMP26, TMP22, TMP22);
-		vis_st64_2(TMP22, dest, 8);
-		dest += stride;
-	} while (--height);
-
-	vis_ld64(ref[0], TMP0);
-	vis_xor(DST_0, REF_0, TMP6);
-
-	vis_ld64_2(ref, 8, TMP2);
-	vis_and(TMP6, MASK_fe, TMP6);
-
-	vis_ld64_2(ref, 16, TMP4);
-	vis_mul8x16(CONST_128, TMP6, TMP6);
-	vis_xor(DST_2, REF_2, TMP8);
-
-	vis_and(TMP8, MASK_fe, TMP8);
-
-	vis_and(DST_0, REF_0, TMP10);
-	vis_ld64_2(dest, stride, DST_0);
-	vis_mul8x16(CONST_128, TMP8, TMP8);
-
-	vis_and(DST_2, REF_2, TMP12);
-	vis_ld64_2(dest, stride_8, DST_2);
-
-	vis_ld64(ref[0], TMP14);
-	vis_and(TMP6, MASK_7f, TMP6);
-
-	vis_and(TMP8, MASK_7f, TMP8);
-
-	vis_padd16(TMP10, TMP6, TMP6);
-	vis_st64(TMP6, dest[0]);
-
-	vis_padd16(TMP12, TMP8, TMP8);
-	vis_st64_2(TMP8, dest, 8);
-
-	dest += stride;
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_faligndata(TMP2, TMP4, REF_2);
-
-	vis_xor(DST_0, REF_0, TMP20);
-
-	vis_and(TMP20, MASK_fe, TMP20);
-
-	vis_xor(DST_2, REF_2, TMP22);
-	vis_mul8x16(CONST_128, TMP20, TMP20);
-
-	vis_and(TMP22, MASK_fe, TMP22);
-
-	vis_and(DST_0, REF_0, TMP24);
-	vis_mul8x16(CONST_128, TMP22, TMP22);
-
-	vis_and(DST_2, REF_2, TMP26);
-
-	vis_and(TMP20, MASK_7f, TMP20);
-
-	vis_and(TMP22, MASK_7f, TMP22);
-
-	vis_padd16(TMP24, TMP20, TMP20);
-	vis_st64(TMP20, dest[0]);
-
-	vis_padd16(TMP26, TMP22, TMP22);
-	vis_st64_2(TMP22, dest, 8);
-}
-
-static void MC_avg_no_round_o_8_vis (uint8_t * dest, const uint8_t * _ref,
-			    const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[0], TMP0);
-
-	vis_ld64(ref[8], TMP2);
-
-	vis_ld64(dest[0], DST_0);
-
-	vis_ld64(constants_fe[0], MASK_fe);
-
-	vis_ld64(constants_7f[0], MASK_7f);
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_ld64(constants128[0], CONST_128);
-
-	ref += stride;
-	height = (height >> 1) - 1;
-
-	do {	/* 12 cycles */
-		vis_ld64(ref[0], TMP0);
-		vis_xor(DST_0, REF_0, TMP4);
-
-		vis_ld64(ref[8], TMP2);
-		vis_and(TMP4, MASK_fe, TMP4);
-
-		vis_and(DST_0, REF_0, TMP6);
-		vis_ld64_2(dest, stride, DST_0);
-		ref += stride;
-		vis_mul8x16(CONST_128, TMP4, TMP4);
-
-		vis_ld64(ref[0], TMP12);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64(ref[8], TMP2);
-		vis_xor(DST_0, REF_0, TMP0);
-		ref += stride;
-
-		vis_and(TMP0, MASK_fe, TMP0);
-
-		vis_and(TMP4, MASK_7f, TMP4);
-
-		vis_padd16(TMP6, TMP4, TMP4);
-		vis_st64(TMP4, dest[0]);
-		dest += stride;
-		vis_mul8x16(CONST_128, TMP0, TMP0);
-
-		vis_and(DST_0, REF_0, TMP6);
-		vis_ld64_2(dest, stride, DST_0);
-
-		vis_faligndata(TMP12, TMP2, REF_0);
-
-		vis_and(TMP0, MASK_7f, TMP0);
-
-		vis_padd16(TMP6, TMP0, TMP4);
-		vis_st64(TMP4, dest[0]);
-		dest += stride;
-	} while (--height);
-
-	vis_ld64(ref[0], TMP0);
-	vis_xor(DST_0, REF_0, TMP4);
-
-	vis_ld64(ref[8], TMP2);
-	vis_and(TMP4, MASK_fe, TMP4);
-
-	vis_and(DST_0, REF_0, TMP6);
-	vis_ld64_2(dest, stride, DST_0);
-	vis_mul8x16(CONST_128, TMP4, TMP4);
-
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_xor(DST_0, REF_0, TMP0);
-
-	vis_and(TMP0, MASK_fe, TMP0);
-
-	vis_and(TMP4, MASK_7f, TMP4);
-
-	vis_padd16(TMP6, TMP4, TMP4);
-	vis_st64(TMP4, dest[0]);
-	dest += stride;
-	vis_mul8x16(CONST_128, TMP0, TMP0);
-
-	vis_and(DST_0, REF_0, TMP6);
-
-	vis_and(TMP0, MASK_7f, TMP0);
-
-	vis_padd16(TMP6, TMP0, TMP4);
-	vis_st64(TMP4, dest[0]);
-}
-
-static void MC_put_no_round_x_16_vis (uint8_t * dest, const uint8_t * _ref,
-			     const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[0],    TMP0);
-
-	vis_ld64_2(ref, 8,  TMP2);
-
-	vis_ld64_2(ref, 16, TMP4);
-
-	vis_ld64(constants_fe[0], MASK_fe);
-
-	vis_ld64(constants_7f[0], MASK_7f);
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_ld64(constants128[0], CONST_128);
-	vis_faligndata(TMP2, TMP4, REF_4);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_2);
-		vis_faligndata(TMP2, TMP4, REF_6);
-	} else {
-		vis_src1(TMP2, REF_2);
-		vis_src1(TMP4, REF_6);
-	}
-
-	ref += stride;
-	height = (height >> 1) - 1;
-
-	do {	/* 34 cycles */
-		vis_ld64(ref[0],    TMP0);
-		vis_xor(REF_0, REF_2, TMP6);
-
-		vis_ld64_2(ref, 8,  TMP2);
-		vis_xor(REF_4, REF_6, TMP8);
-
-		vis_ld64_2(ref, 16, TMP4);
-		vis_and(TMP6, MASK_fe, TMP6);
-		ref += stride;
-
-		vis_ld64(ref[0],    TMP14);
-		vis_mul8x16(CONST_128, TMP6, TMP6);
-		vis_and(TMP8, MASK_fe, TMP8);
-
-		vis_ld64_2(ref, 8,  TMP16);
-		vis_mul8x16(CONST_128, TMP8, TMP8);
-		vis_and(REF_0, REF_2, TMP10);
-
-		vis_ld64_2(ref, 16, TMP18);
-		ref += stride;
-		vis_and(REF_4, REF_6, TMP12);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_faligndata(TMP2, TMP4, REF_4);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP0, TMP2, REF_2);
-			vis_faligndata(TMP2, TMP4, REF_6);
-		} else {
-			vis_src1(TMP2, REF_2);
-			vis_src1(TMP4, REF_6);
-		}
-
-		vis_and(TMP6, MASK_7f, TMP6);
-
-		vis_and(TMP8, MASK_7f, TMP8);
-
-		vis_padd16(TMP10, TMP6, TMP6);
-		vis_st64(TMP6, dest[0]);
-
-		vis_padd16(TMP12, TMP8, TMP8);
-		vis_st64_2(TMP8, dest, 8);
-		dest += stride;
-
-		vis_xor(REF_0, REF_2, TMP6);
-
-		vis_xor(REF_4, REF_6, TMP8);
-
-		vis_and(TMP6, MASK_fe, TMP6);
-
-		vis_mul8x16(CONST_128, TMP6, TMP6);
-		vis_and(TMP8, MASK_fe, TMP8);
-
-		vis_mul8x16(CONST_128, TMP8, TMP8);
-		vis_and(REF_0, REF_2, TMP10);
-
-		vis_and(REF_4, REF_6, TMP12);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_faligndata(TMP14, TMP16, REF_0);
-
-		vis_faligndata(TMP16, TMP18, REF_4);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP14, TMP16, REF_2);
-			vis_faligndata(TMP16, TMP18, REF_6);
-		} else {
-			vis_src1(TMP16, REF_2);
-			vis_src1(TMP18, REF_6);
-		}
-
-		vis_and(TMP6, MASK_7f, TMP6);
-
-		vis_and(TMP8, MASK_7f, TMP8);
-
-		vis_padd16(TMP10, TMP6, TMP6);
-		vis_st64(TMP6, dest[0]);
-
-		vis_padd16(TMP12, TMP8, TMP8);
-		vis_st64_2(TMP8, dest, 8);
-		dest += stride;
-	} while (--height);
-
-	vis_ld64(ref[0],    TMP0);
-	vis_xor(REF_0, REF_2, TMP6);
-
-	vis_ld64_2(ref, 8,  TMP2);
-	vis_xor(REF_4, REF_6, TMP8);
-
-	vis_ld64_2(ref, 16, TMP4);
-	vis_and(TMP6, MASK_fe, TMP6);
-
-	vis_mul8x16(CONST_128, TMP6, TMP6);
-	vis_and(TMP8, MASK_fe, TMP8);
-
-	vis_mul8x16(CONST_128, TMP8, TMP8);
-	vis_and(REF_0, REF_2, TMP10);
-
-	vis_and(REF_4, REF_6, TMP12);
-
-	vis_alignaddr_g0((void *)off);
-
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_faligndata(TMP2, TMP4, REF_4);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_2);
-		vis_faligndata(TMP2, TMP4, REF_6);
-	} else {
-		vis_src1(TMP2, REF_2);
-		vis_src1(TMP4, REF_6);
-	}
-
-	vis_and(TMP6, MASK_7f, TMP6);
-
-	vis_and(TMP8, MASK_7f, TMP8);
-
-	vis_padd16(TMP10, TMP6, TMP6);
-	vis_st64(TMP6, dest[0]);
-
-	vis_padd16(TMP12, TMP8, TMP8);
-	vis_st64_2(TMP8, dest, 8);
-	dest += stride;
-
-	vis_xor(REF_0, REF_2, TMP6);
-
-	vis_xor(REF_4, REF_6, TMP8);
-
-	vis_and(TMP6, MASK_fe, TMP6);
-
-	vis_mul8x16(CONST_128, TMP6, TMP6);
-	vis_and(TMP8, MASK_fe, TMP8);
-
-	vis_mul8x16(CONST_128, TMP8, TMP8);
-	vis_and(REF_0, REF_2, TMP10);
-
-	vis_and(REF_4, REF_6, TMP12);
-
-	vis_and(TMP6, MASK_7f, TMP6);
-
-	vis_and(TMP8, MASK_7f, TMP8);
-
-	vis_padd16(TMP10, TMP6, TMP6);
-	vis_st64(TMP6, dest[0]);
-
-	vis_padd16(TMP12, TMP8, TMP8);
-	vis_st64_2(TMP8, dest, 8);
-}
-
-static void MC_put_no_round_x_8_vis (uint8_t * dest, const uint8_t * _ref,
-			    const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[0], TMP0);
-
-	vis_ld64(ref[8], TMP2);
-
-	vis_ld64(constants_fe[0], MASK_fe);
-
-	vis_ld64(constants_7f[0], MASK_7f);
-
-	vis_ld64(constants128[0], CONST_128);
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_2);
-	} else {
-		vis_src1(TMP2, REF_2);
-	}
-
-	ref += stride;
-	height = (height >> 1) - 1;
-
-	do {	/* 20 cycles */
-		vis_ld64(ref[0], TMP0);
-		vis_xor(REF_0, REF_2, TMP4);
-
-		vis_ld64_2(ref, 8, TMP2);
-		vis_and(TMP4, MASK_fe, TMP4);
-		ref += stride;
-
-		vis_ld64(ref[0], TMP8);
-		vis_and(REF_0, REF_2, TMP6);
-		vis_mul8x16(CONST_128, TMP4, TMP4);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_ld64_2(ref, 8, TMP10);
-		ref += stride;
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP0, TMP2, REF_2);
-		} else {
-			vis_src1(TMP2, REF_2);
-		}
-
-		vis_and(TMP4, MASK_7f, TMP4);
-
-		vis_padd16(TMP6, TMP4, DST_0);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-
-		vis_xor(REF_0, REF_2, TMP12);
-
-		vis_and(TMP12, MASK_fe, TMP12);
-
-		vis_and(REF_0, REF_2, TMP14);
-		vis_mul8x16(CONST_128, TMP12, TMP12);
-
-		vis_alignaddr_g0((void *)off);
-		vis_faligndata(TMP8, TMP10, REF_0);
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP8, TMP10, REF_2);
-		} else {
-			vis_src1(TMP10, REF_2);
-		}
-
-		vis_and(TMP12, MASK_7f, TMP12);
-
-		vis_padd16(TMP14, TMP12, DST_0);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-	} while (--height);
-
-	vis_ld64(ref[0], TMP0);
-	vis_xor(REF_0, REF_2, TMP4);
-
-	vis_ld64_2(ref, 8, TMP2);
-	vis_and(TMP4, MASK_fe, TMP4);
-
-	vis_and(REF_0, REF_2, TMP6);
-	vis_mul8x16(CONST_128, TMP4, TMP4);
-
-	vis_alignaddr_g0((void *)off);
-
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_2);
-	} else {
-		vis_src1(TMP2, REF_2);
-	}
-
-	vis_and(TMP4, MASK_7f, TMP4);
-
-	vis_padd16(TMP6, TMP4, DST_0);
-	vis_st64(DST_0, dest[0]);
-	dest += stride;
-
-	vis_xor(REF_0, REF_2, TMP12);
-
-	vis_and(TMP12, MASK_fe, TMP12);
-
-	vis_and(REF_0, REF_2, TMP14);
-	vis_mul8x16(CONST_128, TMP12, TMP12);
-
-	vis_and(TMP12, MASK_7f, TMP12);
-
-	vis_padd16(TMP14, TMP12, DST_0);
-	vis_st64(DST_0, dest[0]);
-	dest += stride;
-}
-
-static void MC_avg_no_round_x_16_vis (uint8_t * dest, const uint8_t * _ref,
-			     const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-
-	vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-	vis_ld64(constants3[0], CONST_3);
-	vis_fzero(ZERO);
-	vis_ld64(constants256_512[0], CONST_256);
-
-	ref = vis_alignaddr(ref);
-	do {	/* 26 cycles */
-		vis_ld64(ref[0], TMP0);
-
-		vis_ld64(ref[8], TMP2);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_ld64(ref[16], TMP4);
-
-		vis_ld64(dest[0], DST_0);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64(dest[8], DST_2);
-		vis_faligndata(TMP2, TMP4, REF_4);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP0, TMP2, REF_2);
-			vis_faligndata(TMP2, TMP4, REF_6);
-		} else {
-			vis_src1(TMP2, REF_2);
-			vis_src1(TMP4, REF_6);
-		}
-
-		vis_mul8x16au(REF_0,   CONST_256, TMP0);
-
-		vis_pmerge(ZERO,     REF_2,     TMP4);
-		vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
-		vis_pmerge(ZERO, REF_2_1, TMP6);
-
-		vis_padd16(TMP0, TMP4, TMP0);
-
-		vis_mul8x16al(DST_0,   CONST_512, TMP4);
-		vis_padd16(TMP2, TMP6, TMP2);
-
-		vis_mul8x16al(DST_1,   CONST_512, TMP6);
-
-		vis_mul8x16au(REF_6,   CONST_256, TMP12);
-
-		vis_padd16(TMP0, TMP4, TMP0);
-		vis_mul8x16au(REF_6_1, CONST_256, TMP14);
-
-		vis_padd16(TMP2, TMP6, TMP2);
-		vis_mul8x16au(REF_4,   CONST_256, TMP16);
-
-		vis_padd16(TMP0, CONST_3, TMP8);
-		vis_mul8x16au(REF_4_1, CONST_256, TMP18);
-
-		vis_padd16(TMP2, CONST_3, TMP10);
-		vis_pack16(TMP8, DST_0);
-
-		vis_pack16(TMP10, DST_1);
-		vis_padd16(TMP16, TMP12, TMP0);
-
-		vis_st64(DST_0, dest[0]);
-		vis_mul8x16al(DST_2,   CONST_512, TMP4);
-		vis_padd16(TMP18, TMP14, TMP2);
-
-		vis_mul8x16al(DST_3,   CONST_512, TMP6);
-		vis_padd16(TMP0, CONST_3, TMP0);
-
-		vis_padd16(TMP2, CONST_3, TMP2);
-
-		vis_padd16(TMP0, TMP4, TMP0);
-
-		vis_padd16(TMP2, TMP6, TMP2);
-		vis_pack16(TMP0, DST_2);
-
-		vis_pack16(TMP2, DST_3);
-		vis_st64(DST_2, dest[8]);
-
-		ref += stride;
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_avg_no_round_x_8_vis (uint8_t * dest, const uint8_t * _ref,
-			    const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-	int stride_times_2 = stride << 1;
-
-	vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-	vis_ld64(constants3[0], CONST_3);
-	vis_fzero(ZERO);
-	vis_ld64(constants256_512[0], CONST_256);
-
-	ref = vis_alignaddr(ref);
-	height >>= 2;
-	do {	/* 47 cycles */
-		vis_ld64(ref[0],   TMP0);
-
-		vis_ld64_2(ref, 8, TMP2);
-		ref += stride;
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_ld64(ref[0],   TMP4);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64_2(ref, 8, TMP6);
-		ref += stride;
-
-		vis_ld64(ref[0],   TMP8);
-
-		vis_ld64_2(ref, 8, TMP10);
-		ref += stride;
-		vis_faligndata(TMP4, TMP6, REF_4);
-
-		vis_ld64(ref[0],   TMP12);
-
-		vis_ld64_2(ref, 8, TMP14);
-		ref += stride;
-		vis_faligndata(TMP8, TMP10, REF_S0);
-
-		vis_faligndata(TMP12, TMP14, REF_S4);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-
-			vis_ld64(dest[0], DST_0);
-			vis_faligndata(TMP0, TMP2, REF_2);
-
-			vis_ld64_2(dest, stride, DST_2);
-			vis_faligndata(TMP4, TMP6, REF_6);
-
-			vis_faligndata(TMP8, TMP10, REF_S2);
-
-			vis_faligndata(TMP12, TMP14, REF_S6);
-		} else {
-			vis_ld64(dest[0], DST_0);
-			vis_src1(TMP2, REF_2);
-
-			vis_ld64_2(dest, stride, DST_2);
-			vis_src1(TMP6, REF_6);
-
-			vis_src1(TMP10, REF_S2);
-
-			vis_src1(TMP14, REF_S6);
-		}
-
-		vis_pmerge(ZERO,     REF_0,     TMP0);
-		vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
-		vis_pmerge(ZERO,     REF_2,     TMP4);
-		vis_mul8x16au(REF_2_1, CONST_256, TMP6);
-
-		vis_padd16(TMP0, CONST_3, TMP0);
-		vis_mul8x16al(DST_0,   CONST_512, TMP16);
-
-		vis_padd16(TMP2, CONST_3, TMP2);
-		vis_mul8x16al(DST_1,   CONST_512, TMP18);
-
-		vis_padd16(TMP0, TMP4, TMP0);
-		vis_mul8x16au(REF_4, CONST_256, TMP8);
-
-		vis_padd16(TMP2, TMP6, TMP2);
-		vis_mul8x16au(REF_4_1, CONST_256, TMP10);
-
-		vis_padd16(TMP0, TMP16, TMP0);
-		vis_mul8x16au(REF_6, CONST_256, TMP12);
-
-		vis_padd16(TMP2, TMP18, TMP2);
-		vis_mul8x16au(REF_6_1, CONST_256, TMP14);
-
-		vis_padd16(TMP8, CONST_3, TMP8);
-		vis_mul8x16al(DST_2, CONST_512, TMP16);
-
-		vis_padd16(TMP8, TMP12, TMP8);
-		vis_mul8x16al(DST_3, CONST_512, TMP18);
-
-		vis_padd16(TMP10, TMP14, TMP10);
-		vis_pack16(TMP0, DST_0);
-
-		vis_pack16(TMP2, DST_1);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-		vis_padd16(TMP10, CONST_3, TMP10);
-
-		vis_ld64_2(dest, stride, DST_0);
-		vis_padd16(TMP8, TMP16, TMP8);
-
-		vis_ld64_2(dest, stride_times_2, TMP4/*DST_2*/);
-		vis_padd16(TMP10, TMP18, TMP10);
-		vis_pack16(TMP8, DST_2);
-
-		vis_pack16(TMP10, DST_3);
-		vis_st64(DST_2, dest[0]);
-		dest += stride;
-
-		vis_mul8x16au(REF_S0_1, CONST_256, TMP2);
-		vis_pmerge(ZERO,     REF_S0,     TMP0);
-
-		vis_pmerge(ZERO,     REF_S2,     TMP24);
-		vis_mul8x16au(REF_S2_1, CONST_256, TMP6);
-
-		vis_padd16(TMP0, CONST_3, TMP0);
-		vis_mul8x16au(REF_S4, CONST_256, TMP8);
-
-		vis_padd16(TMP2, CONST_3, TMP2);
-		vis_mul8x16au(REF_S4_1, CONST_256, TMP10);
-
-		vis_padd16(TMP0, TMP24, TMP0);
-		vis_mul8x16au(REF_S6, CONST_256, TMP12);
-
-		vis_padd16(TMP2, TMP6, TMP2);
-		vis_mul8x16au(REF_S6_1, CONST_256, TMP14);
-
-		vis_padd16(TMP8, CONST_3, TMP8);
-		vis_mul8x16al(DST_0,   CONST_512, TMP16);
-
-		vis_padd16(TMP10, CONST_3, TMP10);
-		vis_mul8x16al(DST_1,   CONST_512, TMP18);
-
-		vis_padd16(TMP8, TMP12, TMP8);
-		vis_mul8x16al(TMP4/*DST_2*/, CONST_512, TMP20);
-
-		vis_mul8x16al(TMP5/*DST_3*/, CONST_512, TMP22);
-		vis_padd16(TMP0, TMP16, TMP0);
-
-		vis_padd16(TMP2, TMP18, TMP2);
-		vis_pack16(TMP0, DST_0);
-
-		vis_padd16(TMP10, TMP14, TMP10);
-		vis_pack16(TMP2, DST_1);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-
-		vis_padd16(TMP8, TMP20, TMP8);
-
-		vis_padd16(TMP10, TMP22, TMP10);
-		vis_pack16(TMP8, DST_2);
-
-		vis_pack16(TMP10, DST_3);
-		vis_st64(DST_2, dest[0]);
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_put_no_round_y_16_vis (uint8_t * dest, const uint8_t * _ref,
-			     const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-
-	ref = vis_alignaddr(ref);
-	vis_ld64(ref[0], TMP0);
-
-	vis_ld64_2(ref, 8, TMP2);
-
-	vis_ld64_2(ref, 16, TMP4);
-	ref += stride;
-
-	vis_ld64(ref[0], TMP6);
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_ld64_2(ref, 8, TMP8);
-	vis_faligndata(TMP2, TMP4, REF_4);
-
-	vis_ld64_2(ref, 16, TMP10);
-	ref += stride;
-
-	vis_ld64(constants_fe[0], MASK_fe);
-	vis_faligndata(TMP6, TMP8, REF_2);
-
-	vis_ld64(constants_7f[0], MASK_7f);
-	vis_faligndata(TMP8, TMP10, REF_6);
-
-	vis_ld64(constants128[0], CONST_128);
-	height = (height >> 1) - 1;
-	do {	/* 24 cycles */
-		vis_ld64(ref[0], TMP0);
-		vis_xor(REF_0, REF_2, TMP12);
-
-		vis_ld64_2(ref, 8, TMP2);
-		vis_xor(REF_4, REF_6, TMP16);
-
-		vis_ld64_2(ref, 16, TMP4);
-		ref += stride;
-		vis_and(REF_0, REF_2, TMP14);
-
-		vis_ld64(ref[0], TMP6);
-		vis_and(REF_4, REF_6, TMP18);
-
-		vis_ld64_2(ref, 8, TMP8);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64_2(ref, 16, TMP10);
-		ref += stride;
-		vis_faligndata(TMP2, TMP4, REF_4);
-
-		vis_and(TMP12, MASK_fe, TMP12);
-
-		vis_and(TMP16, MASK_fe, TMP16);
-		vis_mul8x16(CONST_128, TMP12, TMP12);
-
-		vis_mul8x16(CONST_128, TMP16, TMP16);
-		vis_xor(REF_0, REF_2, TMP0);
-
-		vis_xor(REF_4, REF_6, TMP2);
-
-		vis_and(REF_0, REF_2, TMP20);
-
-		vis_and(TMP12, MASK_7f, TMP12);
-
-		vis_and(TMP16, MASK_7f, TMP16);
-
-		vis_padd16(TMP14, TMP12, TMP12);
-		vis_st64(TMP12, dest[0]);
-
-		vis_padd16(TMP18, TMP16, TMP16);
-		vis_st64_2(TMP16, dest, 8);
-		dest += stride;
-
-		vis_and(REF_4, REF_6, TMP18);
-
-		vis_and(TMP0, MASK_fe, TMP0);
-
-		vis_and(TMP2, MASK_fe, TMP2);
-		vis_mul8x16(CONST_128, TMP0, TMP0);
-
-		vis_faligndata(TMP6, TMP8, REF_2);
-		vis_mul8x16(CONST_128, TMP2, TMP2);
-
-		vis_faligndata(TMP8, TMP10, REF_6);
-
-		vis_and(TMP0, MASK_7f, TMP0);
-
-		vis_and(TMP2, MASK_7f, TMP2);
-
-		vis_padd16(TMP20, TMP0, TMP0);
-		vis_st64(TMP0, dest[0]);
-
-		vis_padd16(TMP18, TMP2, TMP2);
-		vis_st64_2(TMP2, dest, 8);
-		dest += stride;
-	} while (--height);
-
-	vis_ld64(ref[0], TMP0);
-	vis_xor(REF_0, REF_2, TMP12);
-
-	vis_ld64_2(ref, 8, TMP2);
-	vis_xor(REF_4, REF_6, TMP16);
-
-	vis_ld64_2(ref, 16, TMP4);
-	vis_and(REF_0, REF_2, TMP14);
-
-	vis_and(REF_4, REF_6, TMP18);
-
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_faligndata(TMP2, TMP4, REF_4);
-
-	vis_and(TMP12, MASK_fe, TMP12);
-
-	vis_and(TMP16, MASK_fe, TMP16);
-	vis_mul8x16(CONST_128, TMP12, TMP12);
-
-	vis_mul8x16(CONST_128, TMP16, TMP16);
-	vis_xor(REF_0, REF_2, TMP0);
-
-	vis_xor(REF_4, REF_6, TMP2);
-
-	vis_and(REF_0, REF_2, TMP20);
-
-	vis_and(TMP12, MASK_7f, TMP12);
-
-	vis_and(TMP16, MASK_7f, TMP16);
-
-	vis_padd16(TMP14, TMP12, TMP12);
-	vis_st64(TMP12, dest[0]);
-
-	vis_padd16(TMP18, TMP16, TMP16);
-	vis_st64_2(TMP16, dest, 8);
-	dest += stride;
-
-	vis_and(REF_4, REF_6, TMP18);
-
-	vis_and(TMP0, MASK_fe, TMP0);
-
-	vis_and(TMP2, MASK_fe, TMP2);
-	vis_mul8x16(CONST_128, TMP0, TMP0);
-
-	vis_mul8x16(CONST_128, TMP2, TMP2);
-
-	vis_and(TMP0, MASK_7f, TMP0);
-
-	vis_and(TMP2, MASK_7f, TMP2);
-
-	vis_padd16(TMP20, TMP0, TMP0);
-	vis_st64(TMP0, dest[0]);
-
-	vis_padd16(TMP18, TMP2, TMP2);
-	vis_st64_2(TMP2, dest, 8);
-}
-
-static void MC_put_no_round_y_8_vis (uint8_t * dest, const uint8_t * _ref,
-			    const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-
-	ref = vis_alignaddr(ref);
-	vis_ld64(ref[0], TMP0);
-
-	vis_ld64_2(ref, 8, TMP2);
-	ref += stride;
-
-	vis_ld64(ref[0], TMP4);
-
-	vis_ld64_2(ref, 8, TMP6);
-	ref += stride;
-
-	vis_ld64(constants_fe[0], MASK_fe);
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_ld64(constants_7f[0], MASK_7f);
-	vis_faligndata(TMP4, TMP6, REF_2);
-
-	vis_ld64(constants128[0], CONST_128);
-	height = (height >> 1) - 1;
-	do {	/* 12 cycles */
-		vis_ld64(ref[0], TMP0);
-		vis_xor(REF_0, REF_2, TMP4);
-
-		vis_ld64_2(ref, 8, TMP2);
-		ref += stride;
-		vis_and(TMP4, MASK_fe, TMP4);
-
-		vis_and(REF_0, REF_2, TMP6);
-		vis_mul8x16(CONST_128, TMP4, TMP4);
-
-		vis_faligndata(TMP0, TMP2, REF_0);
-		vis_ld64(ref[0], TMP0);
-
-		vis_ld64_2(ref, 8, TMP2);
-		ref += stride;
-		vis_xor(REF_0, REF_2, TMP12);
-
-		vis_and(TMP4, MASK_7f, TMP4);
-
-		vis_and(TMP12, MASK_fe, TMP12);
-
-		vis_mul8x16(CONST_128, TMP12, TMP12);
-		vis_and(REF_0, REF_2, TMP14);
-
-		vis_padd16(TMP6, TMP4, DST_0);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-
-		vis_faligndata(TMP0, TMP2, REF_2);
-
-		vis_and(TMP12, MASK_7f, TMP12);
-
-		vis_padd16(TMP14, TMP12, DST_0);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-	} while (--height);
-
-	vis_ld64(ref[0], TMP0);
-	vis_xor(REF_0, REF_2, TMP4);
-
-	vis_ld64_2(ref, 8, TMP2);
-	vis_and(TMP4, MASK_fe, TMP4);
-
-	vis_and(REF_0, REF_2, TMP6);
-	vis_mul8x16(CONST_128, TMP4, TMP4);
-
-	vis_faligndata(TMP0, TMP2, REF_0);
-
-	vis_xor(REF_0, REF_2, TMP12);
-
-	vis_and(TMP4, MASK_7f, TMP4);
-
-	vis_and(TMP12, MASK_fe, TMP12);
-
-	vis_mul8x16(CONST_128, TMP12, TMP12);
-	vis_and(REF_0, REF_2, TMP14);
-
-	vis_padd16(TMP6, TMP4, DST_0);
-	vis_st64(DST_0, dest[0]);
-	dest += stride;
-
-	vis_and(TMP12, MASK_7f, TMP12);
-
-	vis_padd16(TMP14, TMP12, DST_0);
-	vis_st64(DST_0, dest[0]);
-}
-
-static void MC_avg_no_round_y_16_vis (uint8_t * dest, const uint8_t * _ref,
-			     const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	int stride_8 = stride + 8;
-	int stride_16 = stride + 16;
-
-	vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[ 0], TMP0);
-	vis_fzero(ZERO);
-
-	vis_ld64(ref[ 8], TMP2);
-
-	vis_ld64(ref[16], TMP4);
-
-	vis_ld64(constants3[0], CONST_3);
-	vis_faligndata(TMP0, TMP2, REF_2);
-
-	vis_ld64(constants256_512[0], CONST_256);
-	vis_faligndata(TMP2, TMP4, REF_6);
-	height >>= 1;
-
-	do {	/* 31 cycles */
-		vis_ld64_2(ref, stride, TMP0);
-		vis_pmerge(ZERO,       REF_2,     TMP12);
-		vis_mul8x16au(REF_2_1, CONST_256, TMP14);
-
-		vis_ld64_2(ref, stride_8, TMP2);
-		vis_pmerge(ZERO,       REF_6,     TMP16);
-		vis_mul8x16au(REF_6_1, CONST_256, TMP18);
-
-		vis_ld64_2(ref, stride_16, TMP4);
-		ref += stride;
-
-		vis_ld64(dest[0], DST_0);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64_2(dest, 8, DST_2);
-		vis_faligndata(TMP2, TMP4, REF_4);
-
-		vis_ld64_2(ref, stride, TMP6);
-		vis_pmerge(ZERO,     REF_0,     TMP0);
-		vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
-		vis_ld64_2(ref, stride_8, TMP8);
-		vis_pmerge(ZERO,     REF_4,     TMP4);
-
-		vis_ld64_2(ref, stride_16, TMP10);
-		ref += stride;
-
-		vis_ld64_2(dest, stride, REF_S0/*DST_4*/);
-		vis_faligndata(TMP6, TMP8, REF_2);
-		vis_mul8x16au(REF_4_1, CONST_256, TMP6);
-
-		vis_ld64_2(dest, stride_8, REF_S2/*DST_6*/);
-		vis_faligndata(TMP8, TMP10, REF_6);
-		vis_mul8x16al(DST_0,   CONST_512, TMP20);
-
-		vis_padd16(TMP0, CONST_3, TMP0);
-		vis_mul8x16al(DST_1,   CONST_512, TMP22);
-
-		vis_padd16(TMP2, CONST_3, TMP2);
-		vis_mul8x16al(DST_2,   CONST_512, TMP24);
-
-		vis_padd16(TMP4, CONST_3, TMP4);
-		vis_mul8x16al(DST_3,   CONST_512, TMP26);
-
-		vis_padd16(TMP6, CONST_3, TMP6);
-
-		vis_padd16(TMP12, TMP20, TMP12);
-		vis_mul8x16al(REF_S0,   CONST_512, TMP20);
-
-		vis_padd16(TMP14, TMP22, TMP14);
-		vis_mul8x16al(REF_S0_1, CONST_512, TMP22);
-
-		vis_padd16(TMP16, TMP24, TMP16);
-		vis_mul8x16al(REF_S2,   CONST_512, TMP24);
-
-		vis_padd16(TMP18, TMP26, TMP18);
-		vis_mul8x16al(REF_S2_1, CONST_512, TMP26);
-
-		vis_padd16(TMP12, TMP0, TMP12);
-		vis_mul8x16au(REF_2,   CONST_256, TMP28);
-
-		vis_padd16(TMP14, TMP2, TMP14);
-		vis_mul8x16au(REF_2_1, CONST_256, TMP30);
-
-		vis_padd16(TMP16, TMP4, TMP16);
-		vis_mul8x16au(REF_6,   CONST_256, REF_S4);
-
-		vis_padd16(TMP18, TMP6, TMP18);
-		vis_mul8x16au(REF_6_1, CONST_256, REF_S6);
-
-		vis_pack16(TMP12, DST_0);
-		vis_padd16(TMP28, TMP0, TMP12);
-
-		vis_pack16(TMP14, DST_1);
-		vis_st64(DST_0, dest[0]);
-		vis_padd16(TMP30, TMP2, TMP14);
-
-		vis_pack16(TMP16, DST_2);
-		vis_padd16(REF_S4, TMP4, TMP16);
-
-		vis_pack16(TMP18, DST_3);
-		vis_st64_2(DST_2, dest, 8);
-		dest += stride;
-		vis_padd16(REF_S6, TMP6, TMP18);
-
-		vis_padd16(TMP12, TMP20, TMP12);
-
-		vis_padd16(TMP14, TMP22, TMP14);
-		vis_pack16(TMP12, DST_0);
-
-		vis_padd16(TMP16, TMP24, TMP16);
-		vis_pack16(TMP14, DST_1);
-		vis_st64(DST_0, dest[0]);
-
-		vis_padd16(TMP18, TMP26, TMP18);
-		vis_pack16(TMP16, DST_2);
-
-		vis_pack16(TMP18, DST_3);
-		vis_st64_2(DST_2, dest, 8);
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_avg_no_round_y_8_vis (uint8_t * dest, const uint8_t * _ref,
-			    const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	int stride_8 = stride + 8;
-
-	vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[ 0], TMP0);
-	vis_fzero(ZERO);
-
-	vis_ld64(ref[ 8], TMP2);
-
-	vis_ld64(constants3[0], CONST_3);
-	vis_faligndata(TMP0, TMP2, REF_2);
-
-	vis_ld64(constants256_512[0], CONST_256);
-
-	height >>= 1;
-	do {	/* 20 cycles */
-		vis_ld64_2(ref, stride, TMP0);
-		vis_pmerge(ZERO,       REF_2,     TMP8);
-		vis_mul8x16au(REF_2_1, CONST_256, TMP10);
-
-		vis_ld64_2(ref, stride_8, TMP2);
-		ref += stride;
-
-		vis_ld64(dest[0], DST_0);
-
-		vis_ld64_2(dest, stride, DST_2);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64_2(ref, stride, TMP4);
-		vis_mul8x16al(DST_0,   CONST_512, TMP16);
-		vis_pmerge(ZERO,       REF_0,     TMP12);
-
-		vis_ld64_2(ref, stride_8, TMP6);
-		ref += stride;
-		vis_mul8x16al(DST_1,   CONST_512, TMP18);
-		vis_pmerge(ZERO,       REF_0_1,   TMP14);
-
-		vis_padd16(TMP12, CONST_3, TMP12);
-		vis_mul8x16al(DST_2,   CONST_512, TMP24);
-
-		vis_padd16(TMP14, CONST_3, TMP14);
-		vis_mul8x16al(DST_3,   CONST_512, TMP26);
-
-		vis_faligndata(TMP4, TMP6, REF_2);
-
-		vis_padd16(TMP8, TMP12, TMP8);
-
-		vis_padd16(TMP10, TMP14, TMP10);
-		vis_mul8x16au(REF_2,   CONST_256, TMP20);
-
-		vis_padd16(TMP8, TMP16, TMP0);
-		vis_mul8x16au(REF_2_1, CONST_256, TMP22);
-
-		vis_padd16(TMP10, TMP18, TMP2);
-		vis_pack16(TMP0, DST_0);
-
-		vis_pack16(TMP2, DST_1);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-		vis_padd16(TMP12, TMP20, TMP12);
-
-		vis_padd16(TMP14, TMP22, TMP14);
-
-		vis_padd16(TMP12, TMP24, TMP0);
-
-		vis_padd16(TMP14, TMP26, TMP2);
-		vis_pack16(TMP0, DST_2);
-
-		vis_pack16(TMP2, DST_3);
-		vis_st64(DST_2, dest[0]);
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_put_no_round_xy_16_vis (uint8_t * dest, const uint8_t * _ref,
-				       const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-	int stride_8 = stride + 8;
-	int stride_16 = stride + 16;
-
-	vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[ 0], TMP0);
-	vis_fzero(ZERO);
-
-	vis_ld64(ref[ 8], TMP2);
-
-	vis_ld64(ref[16], TMP4);
-
-	vis_ld64(constants1[0], CONST_1);
-	vis_faligndata(TMP0, TMP2, REF_S0);
-
-	vis_ld64(constants256_512[0], CONST_256);
-	vis_faligndata(TMP2, TMP4, REF_S4);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_S2);
-		vis_faligndata(TMP2, TMP4, REF_S6);
-	} else {
-		vis_src1(TMP2, REF_S2);
-		vis_src1(TMP4, REF_S6);
-	}
-
-	height >>= 1;
-	do {
-		vis_ld64_2(ref, stride, TMP0);
-		vis_mul8x16au(REF_S0, CONST_256, TMP12);
-		vis_pmerge(ZERO,      REF_S0_1,  TMP14);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_ld64_2(ref, stride_8, TMP2);
-		vis_mul8x16au(REF_S2, CONST_256, TMP16);
-		vis_pmerge(ZERO,      REF_S2_1,  TMP18);
-
-		vis_ld64_2(ref, stride_16, TMP4);
-		ref += stride;
-		vis_mul8x16au(REF_S4, CONST_256, TMP20);
-		vis_pmerge(ZERO,      REF_S4_1,  TMP22);
-
-		vis_ld64_2(ref, stride, TMP6);
-		vis_mul8x16au(REF_S6, CONST_256, TMP24);
-		vis_pmerge(ZERO,      REF_S6_1,  TMP26);
-
-		vis_ld64_2(ref, stride_8, TMP8);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64_2(ref, stride_16, TMP10);
-		ref += stride;
-		vis_faligndata(TMP2, TMP4, REF_4);
-
-		vis_faligndata(TMP6, TMP8, REF_S0);
-
-		vis_faligndata(TMP8, TMP10, REF_S4);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP0, TMP2, REF_2);
-			vis_faligndata(TMP2, TMP4, REF_6);
-			vis_faligndata(TMP6, TMP8, REF_S2);
-			vis_faligndata(TMP8, TMP10, REF_S6);
-		} else {
-			vis_src1(TMP2, REF_2);
-			vis_src1(TMP4, REF_6);
-			vis_src1(TMP8, REF_S2);
-			vis_src1(TMP10, REF_S6);
-		}
-
-		vis_mul8x16au(REF_0, CONST_256, TMP0);
-		vis_pmerge(ZERO,      REF_0_1,  TMP2);
-
-		vis_mul8x16au(REF_2, CONST_256, TMP4);
-		vis_pmerge(ZERO,      REF_2_1,  TMP6);
-
-		vis_padd16(TMP0, CONST_2, TMP8);
-		vis_mul8x16au(REF_4, CONST_256, TMP0);
-
-		vis_padd16(TMP2, CONST_1, TMP10);
-		vis_mul8x16au(REF_4_1, CONST_256, TMP2);
-
-		vis_padd16(TMP8, TMP4, TMP8);
-		vis_mul8x16au(REF_6, CONST_256, TMP4);
-
-		vis_padd16(TMP10, TMP6, TMP10);
-		vis_mul8x16au(REF_6_1, CONST_256, TMP6);
-
-		vis_padd16(TMP12, TMP8, TMP12);
-
-		vis_padd16(TMP14, TMP10, TMP14);
-
-		vis_padd16(TMP12, TMP16, TMP12);
-
-		vis_padd16(TMP14, TMP18, TMP14);
-		vis_pack16(TMP12, DST_0);
-
-		vis_pack16(TMP14, DST_1);
-		vis_st64(DST_0, dest[0]);
-		vis_padd16(TMP0, CONST_1, TMP12);
-
-		vis_mul8x16au(REF_S0, CONST_256, TMP0);
-		vis_padd16(TMP2, CONST_1, TMP14);
-
-		vis_mul8x16au(REF_S0_1, CONST_256, TMP2);
-		vis_padd16(TMP12, TMP4, TMP12);
-
-		vis_mul8x16au(REF_S2, CONST_256, TMP4);
-		vis_padd16(TMP14, TMP6, TMP14);
-
-		vis_mul8x16au(REF_S2_1, CONST_256, TMP6);
-		vis_padd16(TMP20, TMP12, TMP20);
-
-		vis_padd16(TMP22, TMP14, TMP22);
-
-		vis_padd16(TMP20, TMP24, TMP20);
-
-		vis_padd16(TMP22, TMP26, TMP22);
-		vis_pack16(TMP20, DST_2);
-
-		vis_pack16(TMP22, DST_3);
-		vis_st64_2(DST_2, dest, 8);
-		dest += stride;
-		vis_padd16(TMP0, TMP4, TMP24);
-
-		vis_mul8x16au(REF_S4, CONST_256, TMP0);
-		vis_padd16(TMP2, TMP6, TMP26);
-
-		vis_mul8x16au(REF_S4_1, CONST_256, TMP2);
-		vis_padd16(TMP24, TMP8, TMP24);
-
-		vis_padd16(TMP26, TMP10, TMP26);
-		vis_pack16(TMP24, DST_0);
-
-		vis_pack16(TMP26, DST_1);
-		vis_st64(DST_0, dest[0]);
-		vis_pmerge(ZERO, REF_S6, TMP4);
-
-		vis_pmerge(ZERO,      REF_S6_1,  TMP6);
-
-		vis_padd16(TMP0, TMP4, TMP0);
-
-		vis_padd16(TMP2, TMP6, TMP2);
-
-		vis_padd16(TMP0, TMP12, TMP0);
-
-		vis_padd16(TMP2, TMP14, TMP2);
-		vis_pack16(TMP0, DST_2);
-
-		vis_pack16(TMP2, DST_3);
-		vis_st64_2(DST_2, dest, 8);
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_put_no_round_xy_8_vis (uint8_t * dest, const uint8_t * _ref,
-				      const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-	int stride_8 = stride + 8;
-
-	vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[ 0], TMP0);
-	vis_fzero(ZERO);
-
-	vis_ld64(ref[ 8], TMP2);
-
-	vis_ld64(constants1[0], CONST_1);
-
-	vis_ld64(constants256_512[0], CONST_256);
-	vis_faligndata(TMP0, TMP2, REF_S0);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_S2);
-	} else {
-		vis_src1(TMP2, REF_S2);
-	}
-
-	height >>= 1;
-	do {	/* 26 cycles */
-		vis_ld64_2(ref, stride, TMP0);
-		vis_mul8x16au(REF_S0,   CONST_256, TMP8);
-		vis_pmerge(ZERO,        REF_S2,    TMP12);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_ld64_2(ref, stride_8, TMP2);
-		ref += stride;
-		vis_mul8x16au(REF_S0_1, CONST_256, TMP10);
-		vis_pmerge(ZERO,        REF_S2_1,  TMP14);
-
-		vis_ld64_2(ref, stride, TMP4);
-
-		vis_ld64_2(ref, stride_8, TMP6);
-		ref += stride;
-		vis_faligndata(TMP0, TMP2, REF_S4);
-
-		vis_pmerge(ZERO, REF_S4, TMP18);
-
-		vis_pmerge(ZERO, REF_S4_1, TMP20);
-
-		vis_faligndata(TMP4, TMP6, REF_S0);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP0, TMP2, REF_S6);
-			vis_faligndata(TMP4, TMP6, REF_S2);
-		} else {
-			vis_src1(TMP2, REF_S6);
-			vis_src1(TMP6, REF_S2);
-		}
-
-		vis_padd16(TMP18, CONST_1, TMP18);
-		vis_mul8x16au(REF_S6,   CONST_256, TMP22);
-
-		vis_padd16(TMP20, CONST_1, TMP20);
-		vis_mul8x16au(REF_S6_1, CONST_256, TMP24);
-
-		vis_mul8x16au(REF_S0,   CONST_256, TMP26);
-		vis_pmerge(ZERO, REF_S0_1, TMP28);
-
-		vis_mul8x16au(REF_S2,   CONST_256, TMP30);
-		vis_padd16(TMP18, TMP22, TMP18);
-
-		vis_mul8x16au(REF_S2_1, CONST_256, TMP32);
-		vis_padd16(TMP20, TMP24, TMP20);
-
-		vis_padd16(TMP8,  TMP18, TMP8);
-
-		vis_padd16(TMP10, TMP20, TMP10);
-
-		vis_padd16(TMP8,  TMP12, TMP8);
-
-		vis_padd16(TMP10, TMP14, TMP10);
-		vis_pack16(TMP8,  DST_0);
-
-		vis_pack16(TMP10, DST_1);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-		vis_padd16(TMP18, TMP26, TMP18);
-
-		vis_padd16(TMP20, TMP28, TMP20);
-
-		vis_padd16(TMP18, TMP30, TMP18);
-
-		vis_padd16(TMP20, TMP32, TMP20);
-		vis_pack16(TMP18, DST_2);
-
-		vis_pack16(TMP20, DST_3);
-		vis_st64(DST_2, dest[0]);
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_avg_no_round_xy_16_vis (uint8_t * dest, const uint8_t * _ref,
-				       const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-	int stride_8 = stride + 8;
-	int stride_16 = stride + 16;
-
-	vis_set_gsr(4 << VIS_GSR_SCALEFACT_SHIFT);
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[ 0], TMP0);
-	vis_fzero(ZERO);
-
-	vis_ld64(ref[ 8], TMP2);
-
-	vis_ld64(ref[16], TMP4);
-
-	vis_ld64(constants6[0], CONST_6);
-	vis_faligndata(TMP0, TMP2, REF_S0);
-
-	vis_ld64(constants256_1024[0], CONST_256);
-	vis_faligndata(TMP2, TMP4, REF_S4);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_S2);
-		vis_faligndata(TMP2, TMP4, REF_S6);
-	} else {
-		vis_src1(TMP2, REF_S2);
-		vis_src1(TMP4, REF_S6);
-	}
-
-	height >>= 1;
-	do {	/* 55 cycles */
-		vis_ld64_2(ref, stride, TMP0);
-		vis_mul8x16au(REF_S0, CONST_256, TMP12);
-		vis_pmerge(ZERO,      REF_S0_1,  TMP14);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_ld64_2(ref, stride_8, TMP2);
-		vis_mul8x16au(REF_S2, CONST_256, TMP16);
-		vis_pmerge(ZERO,      REF_S2_1,  TMP18);
-
-		vis_ld64_2(ref, stride_16, TMP4);
-		ref += stride;
-		vis_mul8x16au(REF_S4, CONST_256, TMP20);
-		vis_pmerge(ZERO,      REF_S4_1,  TMP22);
-
-		vis_ld64_2(ref, stride, TMP6);
-		vis_mul8x16au(REF_S6, CONST_256, TMP24);
-		vis_pmerge(ZERO,      REF_S6_1,  TMP26);
-
-		vis_ld64_2(ref, stride_8, TMP8);
-		vis_faligndata(TMP0, TMP2, REF_0);
-
-		vis_ld64_2(ref, stride_16, TMP10);
-		ref += stride;
-		vis_faligndata(TMP2, TMP4, REF_4);
-
-		vis_ld64(dest[0], DST_0);
-		vis_faligndata(TMP6, TMP8, REF_S0);
-
-		vis_ld64_2(dest, 8, DST_2);
-		vis_faligndata(TMP8, TMP10, REF_S4);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP0, TMP2, REF_2);
-			vis_faligndata(TMP2, TMP4, REF_6);
-			vis_faligndata(TMP6, TMP8, REF_S2);
-			vis_faligndata(TMP8, TMP10, REF_S6);
-		} else {
-			vis_src1(TMP2, REF_2);
-			vis_src1(TMP4, REF_6);
-			vis_src1(TMP8, REF_S2);
-			vis_src1(TMP10, REF_S6);
-		}
-
-		vis_mul8x16al(DST_0,   CONST_1024, TMP30);
-		vis_pmerge(ZERO, REF_0, TMP0);
-
-		vis_mul8x16al(DST_1,   CONST_1024, TMP32);
-		vis_pmerge(ZERO,      REF_0_1,  TMP2);
-
-		vis_mul8x16au(REF_2, CONST_256, TMP4);
-		vis_pmerge(ZERO,      REF_2_1,  TMP6);
-
-		vis_mul8x16al(DST_2,   CONST_1024, REF_0);
-		vis_padd16(TMP0, CONST_6, TMP0);
-
-		vis_mul8x16al(DST_3,   CONST_1024, REF_2);
-		vis_padd16(TMP2, CONST_6, TMP2);
-
-		vis_padd16(TMP0, TMP4, TMP0);
-		vis_mul8x16au(REF_4, CONST_256, TMP4);
-
-		vis_padd16(TMP2, TMP6, TMP2);
-		vis_mul8x16au(REF_4_1, CONST_256, TMP6);
-
-		vis_padd16(TMP12, TMP0, TMP12);
-		vis_mul8x16au(REF_6, CONST_256, TMP8);
-
-		vis_padd16(TMP14, TMP2, TMP14);
-		vis_mul8x16au(REF_6_1, CONST_256, TMP10);
-
-		vis_padd16(TMP12, TMP16, TMP12);
-		vis_mul8x16au(REF_S0, CONST_256, REF_4);
-
-		vis_padd16(TMP14, TMP18, TMP14);
-		vis_mul8x16au(REF_S0_1, CONST_256, REF_6);
-
-		vis_padd16(TMP12, TMP30, TMP12);
-
-		vis_padd16(TMP14, TMP32, TMP14);
-		vis_pack16(TMP12, DST_0);
-
-		vis_pack16(TMP14, DST_1);
-		vis_st64(DST_0, dest[0]);
-		vis_padd16(TMP4, CONST_6, TMP4);
-
-		vis_ld64_2(dest, stride, DST_0);
-		vis_padd16(TMP6, CONST_6, TMP6);
-		vis_mul8x16au(REF_S2, CONST_256, TMP12);
-
-		vis_padd16(TMP4, TMP8, TMP4);
-		vis_mul8x16au(REF_S2_1, CONST_256,  TMP14);
-
-		vis_padd16(TMP6, TMP10, TMP6);
-
-		vis_padd16(TMP20, TMP4, TMP20);
-
-		vis_padd16(TMP22, TMP6, TMP22);
-
-		vis_padd16(TMP20, TMP24, TMP20);
-
-		vis_padd16(TMP22, TMP26, TMP22);
-
-		vis_padd16(TMP20, REF_0, TMP20);
-		vis_mul8x16au(REF_S4, CONST_256, REF_0);
-
-		vis_padd16(TMP22, REF_2, TMP22);
-		vis_pack16(TMP20, DST_2);
-
-		vis_pack16(TMP22, DST_3);
-		vis_st64_2(DST_2, dest, 8);
-		dest += stride;
-
-		vis_ld64_2(dest, 8, DST_2);
-		vis_mul8x16al(DST_0,   CONST_1024, TMP30);
-		vis_pmerge(ZERO,      REF_S4_1,  REF_2);
-
-		vis_mul8x16al(DST_1,   CONST_1024, TMP32);
-		vis_padd16(REF_4, TMP0, TMP8);
-
-		vis_mul8x16au(REF_S6, CONST_256, REF_4);
-		vis_padd16(REF_6, TMP2, TMP10);
-
-		vis_mul8x16au(REF_S6_1, CONST_256, REF_6);
-		vis_padd16(TMP8, TMP12, TMP8);
-
-		vis_padd16(TMP10, TMP14, TMP10);
-
-		vis_padd16(TMP8, TMP30, TMP8);
-
-		vis_padd16(TMP10, TMP32, TMP10);
-		vis_pack16(TMP8, DST_0);
-
-		vis_pack16(TMP10, DST_1);
-		vis_st64(DST_0, dest[0]);
-
-		vis_padd16(REF_0, TMP4, REF_0);
-
-		vis_mul8x16al(DST_2,   CONST_1024, TMP30);
-		vis_padd16(REF_2, TMP6, REF_2);
-
-		vis_mul8x16al(DST_3,   CONST_1024, TMP32);
-		vis_padd16(REF_0, REF_4, REF_0);
-
-		vis_padd16(REF_2, REF_6, REF_2);
-
-		vis_padd16(REF_0, TMP30, REF_0);
-
-		/* stall */
-
-		vis_padd16(REF_2, TMP32, REF_2);
-		vis_pack16(REF_0, DST_2);
-
-		vis_pack16(REF_2, DST_3);
-		vis_st64_2(DST_2, dest, 8);
-		dest += stride;
-	} while (--height);
-}
-
-static void MC_avg_no_round_xy_8_vis (uint8_t * dest, const uint8_t * _ref,
-				      const int stride, int height)
-{
-	uint8_t *ref = (uint8_t *) _ref;
-	unsigned long off = (unsigned long) ref & 0x7;
-	unsigned long off_plus_1 = off + 1;
-	int stride_8 = stride + 8;
-
-	vis_set_gsr(4 << VIS_GSR_SCALEFACT_SHIFT);
-
-	ref = vis_alignaddr(ref);
-
-	vis_ld64(ref[0], TMP0);
-	vis_fzero(ZERO);
-
-	vis_ld64_2(ref, 8, TMP2);
-
-	vis_ld64(constants6[0], CONST_6);
-
-	vis_ld64(constants256_1024[0], CONST_256);
-	vis_faligndata(TMP0, TMP2, REF_S0);
-
-	if (off != 0x7) {
-		vis_alignaddr_g0((void *)off_plus_1);
-		vis_faligndata(TMP0, TMP2, REF_S2);
-	} else {
-		vis_src1(TMP2, REF_S2);
-	}
-
-	height >>= 1;
-	do {	/* 31 cycles */
-		vis_ld64_2(ref, stride, TMP0);
-		vis_mul8x16au(REF_S0, CONST_256, TMP8);
-		vis_pmerge(ZERO,      REF_S0_1,  TMP10);
-
-		vis_ld64_2(ref, stride_8, TMP2);
-		ref += stride;
-		vis_mul8x16au(REF_S2, CONST_256, TMP12);
-		vis_pmerge(ZERO,      REF_S2_1,  TMP14);
-
-		vis_alignaddr_g0((void *)off);
-
-		vis_ld64_2(ref, stride, TMP4);
-		vis_faligndata(TMP0, TMP2, REF_S4);
-
-		vis_ld64_2(ref, stride_8, TMP6);
-		ref += stride;
-
-		vis_ld64(dest[0], DST_0);
-		vis_faligndata(TMP4, TMP6, REF_S0);
-
-		vis_ld64_2(dest, stride, DST_2);
-
-		if (off != 0x7) {
-			vis_alignaddr_g0((void *)off_plus_1);
-			vis_faligndata(TMP0, TMP2, REF_S6);
-			vis_faligndata(TMP4, TMP6, REF_S2);
-		} else {
-			vis_src1(TMP2, REF_S6);
-			vis_src1(TMP6, REF_S2);
-		}
-
-		vis_mul8x16al(DST_0,   CONST_1024, TMP30);
-		vis_pmerge(ZERO, REF_S4, TMP22);
-
-		vis_mul8x16al(DST_1,   CONST_1024, TMP32);
-		vis_pmerge(ZERO,      REF_S4_1,  TMP24);
-
-		vis_mul8x16au(REF_S6, CONST_256, TMP26);
-		vis_pmerge(ZERO,      REF_S6_1,  TMP28);
-
-		vis_mul8x16au(REF_S0, CONST_256, REF_S4);
-		vis_padd16(TMP22, CONST_6, TMP22);
-
-		vis_mul8x16au(REF_S0_1, CONST_256, REF_S6);
-		vis_padd16(TMP24, CONST_6, TMP24);
-
-		vis_mul8x16al(DST_2,   CONST_1024, REF_0);
-		vis_padd16(TMP22, TMP26, TMP22);
-
-		vis_mul8x16al(DST_3,   CONST_1024, REF_2);
-		vis_padd16(TMP24, TMP28, TMP24);
-
-		vis_mul8x16au(REF_S2, CONST_256, TMP26);
-		vis_padd16(TMP8, TMP22, TMP8);
-
-		vis_mul8x16au(REF_S2_1, CONST_256, TMP28);
-		vis_padd16(TMP10, TMP24, TMP10);
-
-		vis_padd16(TMP8, TMP12, TMP8);
-
-		vis_padd16(TMP10, TMP14, TMP10);
-
-		vis_padd16(TMP8, TMP30, TMP8);
-
-		vis_padd16(TMP10, TMP32, TMP10);
-		vis_pack16(TMP8, DST_0);
-
-		vis_pack16(TMP10, DST_1);
-		vis_st64(DST_0, dest[0]);
-		dest += stride;
-
-		vis_padd16(REF_S4, TMP22, TMP12);
-
-		vis_padd16(REF_S6, TMP24, TMP14);
-
-		vis_padd16(TMP12, TMP26, TMP12);
-
-		vis_padd16(TMP14, TMP28, TMP14);
-
-		vis_padd16(TMP12, REF_0, TMP12);
-
-		vis_padd16(TMP14, REF_2, TMP14);
-		vis_pack16(TMP12, DST_2);
-
-		vis_pack16(TMP14, DST_3);
-		vis_st64(DST_2, dest[0]);
-		dest += stride;
-	} while (--height);
-}
-
-/* End of no rounding code */
-
-static sigjmp_buf jmpbuf;
-static volatile sig_atomic_t canjump = 0;
- 
-static void sigill_handler (int sig)
-{
-    if (!canjump) {
-        signal (sig, SIG_DFL);
-        raise (sig);
-    }
-
-    canjump = 0;
-    siglongjmp (jmpbuf, 1);
-}
-
-#define ACCEL_SPARC_VIS 1
-#define ACCEL_SPARC_VIS2 2
-
-static int vis_level ()
-{
-    int accel = 0;
-
-    signal (SIGILL, sigill_handler);
-    if (sigsetjmp (jmpbuf, 1)) {
-        signal (SIGILL, SIG_DFL);
-        return accel;
-    }
- 
-    canjump = 1;
- 
-    /* pdist %f0, %f0, %f0 */
-    __asm__ __volatile__(".word\t0x81b007c0");
-
-    canjump = 0;
-    accel |= ACCEL_SPARC_VIS;
-
-    if (sigsetjmp (jmpbuf, 1)) {
-        signal (SIGILL, SIG_DFL);
-        return accel;
-    }
-
-    canjump = 1;
-
-    /* edge8n %g0, %g0, %g0 */
-    __asm__ __volatile__(".word\t0x81b00020");
-
-    canjump = 0;
-    accel |= ACCEL_SPARC_VIS2;
-
-    signal (SIGILL, SIG_DFL);
-
-    return accel;
-}
-
-/* libavcodec initialization code */
-void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx)
-{
-  /* VIS specific optimisations */
-  int accel = vis_level ();
-
-  if (accel & ACCEL_SPARC_VIS) {
-      c->put_pixels_tab[0][0] = MC_put_o_16_vis;
-      c->put_pixels_tab[0][1] = MC_put_x_16_vis;
-      c->put_pixels_tab[0][2] = MC_put_y_16_vis;
-      c->put_pixels_tab[0][3] = MC_put_xy_16_vis;
-      
-      c->put_pixels_tab[1][0] = MC_put_o_8_vis;
-      c->put_pixels_tab[1][1] = MC_put_x_8_vis;
-      c->put_pixels_tab[1][2] = MC_put_y_8_vis;
-      c->put_pixels_tab[1][3] = MC_put_xy_8_vis;
-      
-      c->avg_pixels_tab[0][0] = MC_avg_o_16_vis;
-      c->avg_pixels_tab[0][1] = MC_avg_x_16_vis;
-      c->avg_pixels_tab[0][2] = MC_avg_y_16_vis;
-      c->avg_pixels_tab[0][3] = MC_avg_xy_16_vis;
-  
-      c->avg_pixels_tab[1][0] = MC_avg_o_8_vis;
-      c->avg_pixels_tab[1][1] = MC_avg_x_8_vis;
-      c->avg_pixels_tab[1][2] = MC_avg_y_8_vis;
-      c->avg_pixels_tab[1][3] = MC_avg_xy_8_vis;
-  
-      c->put_no_rnd_pixels_tab[0][0] = MC_put_no_round_o_16_vis;
-      c->put_no_rnd_pixels_tab[0][1] = MC_put_no_round_x_16_vis;
-      c->put_no_rnd_pixels_tab[0][2] = MC_put_no_round_y_16_vis;
-      c->put_no_rnd_pixels_tab[0][3] = MC_put_no_round_xy_16_vis;
-      
-      c->put_no_rnd_pixels_tab[1][0] = MC_put_no_round_o_8_vis;
-      c->put_no_rnd_pixels_tab[1][1] = MC_put_no_round_x_8_vis;
-      c->put_no_rnd_pixels_tab[1][2] = MC_put_no_round_y_8_vis;
-      c->put_no_rnd_pixels_tab[1][3] = MC_put_no_round_xy_8_vis;
-  
-      c->avg_no_rnd_pixels_tab[0][0] = MC_avg_no_round_o_16_vis;
-      c->avg_no_rnd_pixels_tab[0][1] = MC_avg_no_round_x_16_vis;
-      c->avg_no_rnd_pixels_tab[0][2] = MC_avg_no_round_y_16_vis;
-      c->avg_no_rnd_pixels_tab[0][3] = MC_avg_no_round_xy_16_vis;
-  
-      c->avg_no_rnd_pixels_tab[1][0] = MC_avg_no_round_o_8_vis;
-      c->avg_no_rnd_pixels_tab[1][1] = MC_avg_no_round_x_8_vis;
-      c->avg_no_rnd_pixels_tab[1][2] = MC_avg_no_round_y_8_vis;
-      c->avg_no_rnd_pixels_tab[1][3] = MC_avg_no_round_xy_8_vis;
-  }
-}
-
-#endif  /* !(ARCH_SPARC) */
diff --git a/ffmpeg.src/libavcodec/sparc/vis.h b/ffmpeg.src/libavcodec/sparc/vis.h
deleted file mode 100644
index 07dda29..0000000
--- a/ffmpeg.src/libavcodec/sparc/vis.h
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * vis.h
- * Copyright (C) 2003 David S. Miller <davem at redhat.com>
- *
- * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
- * See http://libmpeg2.sourceforge.net/ for updates.
- *
- * mpeg2dec 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.
- *
- * mpeg2dec 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/* You may be asking why I hard-code the instruction opcodes and don't
- * use the normal VIS assembler mnenomics for the VIS instructions.
- *
- * The reason is that Sun, in their infinite wisdom, decided that a binary
- * using a VIS instruction will cause it to be marked (in the ELF headers)
- * as doing so, and this prevents the OS from loading such binaries if the
- * current cpu doesn't have VIS.  There is no way to easily override this
- * behavior of the assembler that I am aware of.
- *
- * This totally defeats what libmpeg2 is trying to do which is allow a
- * single binary to be created, and then detect the availability of VIS
- * at runtime.
- *
- * I'm not saying that tainting the binary by default is bad, rather I'm
- * saying that not providing a way to override this easily unnecessarily
- * ties people's hands.
- *
- * Thus, we do the opcode encoding by hand and output 32-bit words in
- * the assembler to keep the binary from becoming tainted.
- */
-
-#define vis_opc_base	((0x1 << 31) | (0x36 << 19))
-#define vis_opf(X)	((X) << 5)
-#define vis_sreg(X)	(X)
-#define vis_dreg(X)	(((X)&0x1f)|((X)>>5))
-#define vis_rs1_s(X)	(vis_sreg(X) << 14)
-#define vis_rs1_d(X)	(vis_dreg(X) << 14)
-#define vis_rs2_s(X)	(vis_sreg(X) << 0)
-#define vis_rs2_d(X)	(vis_dreg(X) << 0)
-#define vis_rd_s(X)	(vis_sreg(X) << 25)
-#define vis_rd_d(X)	(vis_dreg(X) << 25)
-
-#define vis_ss2s(opf,rs1,rs2,rd) \
-	__asm__ __volatile__ (".word %0" \
-			      : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs1_s(rs1) | \
-                                       vis_rs2_s(rs2) | \
-                                       vis_rd_s(rd)))
-
-#define vis_dd2d(opf,rs1,rs2,rd) \
-	__asm__ __volatile__ (".word %0" \
-			      : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs1_d(rs1) | \
-                                       vis_rs2_d(rs2) | \
-                                       vis_rd_d(rd)))
-
-#define vis_ss2d(opf,rs1,rs2,rd) \
-	__asm__ __volatile__ (".word %0" \
-			      : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs1_s(rs1) | \
-                                       vis_rs2_s(rs2) | \
-                                       vis_rd_d(rd)))
-
-#define vis_sd2d(opf,rs1,rs2,rd) \
-	__asm__ __volatile__ (".word %0" \
-			      : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs1_s(rs1) | \
-                                       vis_rs2_d(rs2) | \
-                                       vis_rd_d(rd)))
-
-#define vis_d2s(opf,rs2,rd) \
-	__asm__ __volatile__ (".word %0" \
-			      : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs2_d(rs2) | \
-                                       vis_rd_s(rd)))
-
-#define vis_s2d(opf,rs2,rd) \
-	__asm__ __volatile__ (".word %0" \
-			      : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs2_s(rs2) | \
-                                       vis_rd_d(rd)))
-
-#define vis_d12d(opf,rs1,rd) \
-	__asm__ __volatile__ (".word %0" \
-			      : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs1_d(rs1) | \
-                                       vis_rd_d(rd)))
-
-#define vis_d22d(opf,rs2,rd) \
-	__asm__ __volatile__ (".word %0" \
-			      : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs2_d(rs2) | \
-                                       vis_rd_d(rd)))
-
-#define vis_s12s(opf,rs1,rd) \
-	__asm__ __volatile__ (".word %0" \
-			      : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs1_s(rs1) | \
-                                       vis_rd_s(rd)))
-
-#define vis_s22s(opf,rs2,rd) \
-	__asm__ __volatile__ (".word %0" \
-			      : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs2_s(rs2) | \
-                                       vis_rd_s(rd)))
-
-#define vis_s(opf,rd) \
-	__asm__ __volatile__ (".word %0" \
-			      : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rd_s(rd)))
-
-#define vis_d(opf,rd) \
-	__asm__ __volatile__ (".word %0" \
-			      : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rd_d(rd)))
-
-#define vis_r2m(op,rd,mem) \
-	__asm__ __volatile__ (#op "\t%%f" #rd ", [%0]" : : "r" (&(mem)) )
-
-#define vis_r2m_2(op,rd,mem1,mem2) \
-	__asm__ __volatile__ (#op "\t%%f" #rd ", [%0 + %1]" : : "r" (mem1), "r" (mem2) )
-
-#define vis_m2r(op,mem,rd) \
-	__asm__ __volatile__ (#op "\t[%0], %%f" #rd : : "r" (&(mem)) )
-
-#define vis_m2r_2(op,mem1,mem2,rd) \
-	__asm__ __volatile__ (#op "\t[%0 + %1], %%f" #rd : : "r" (mem1), "r" (mem2) )
-
-static inline void vis_set_gsr(unsigned int _val)
-{
-	register unsigned int val asm("g1");
-
-	val = _val;
-	__asm__ __volatile__(".word 0xa7804000"
-			     : : "r" (val));
-}
-
-#define VIS_GSR_ALIGNADDR_MASK	0x0000007
-#define VIS_GSR_ALIGNADDR_SHIFT	0
-#define VIS_GSR_SCALEFACT_MASK	0x0000078
-#define VIS_GSR_SCALEFACT_SHIFT	3
-
-#define vis_ld32(mem,rs1)		vis_m2r(ld, mem, rs1)
-#define vis_ld32_2(mem1,mem2,rs1)	vis_m2r_2(ld, mem1, mem2, rs1)
-#define vis_st32(rs1,mem)		vis_r2m(st, rs1, mem)
-#define vis_st32_2(rs1,mem1,mem2)	vis_r2m_2(st, rs1, mem1, mem2)
-#define vis_ld64(mem,rs1)		vis_m2r(ldd, mem, rs1)
-#define vis_ld64_2(mem1,mem2,rs1)	vis_m2r_2(ldd, mem1, mem2, rs1)
-#define vis_st64(rs1,mem)		vis_r2m(std, rs1, mem)
-#define vis_st64_2(rs1,mem1,mem2)	vis_r2m_2(std, rs1, mem1, mem2)
-
-#define vis_ldblk(mem, rd) \
-do {	register void *__mem asm("g1"); \
-	__mem = &(mem); \
-	__asm__ __volatile__(".word 0xc1985e00 | %1" \
-			     : \
-			     : "r" (__mem), \
-			       "i" (vis_rd_d(rd)) \
-			     : "memory"); \
-} while (0)
-
-#define vis_stblk(rd, mem) \
-do {	register void *__mem asm("g1"); \
-	__mem = &(mem); \
-	__asm__ __volatile__(".word 0xc1b85e00 | %1" \
-			     : \
-			     : "r" (__mem), \
-			       "i" (vis_rd_d(rd)) \
-			     : "memory"); \
-} while (0)
-
-#define vis_membar_storestore()	\
-	__asm__ __volatile__(".word 0x8143e008" : : : "memory")
-
-#define vis_membar_sync()	\
-	__asm__ __volatile__(".word 0x8143e040" : : : "memory")
-
-/* 16 and 32 bit partitioned addition and subtraction.  The normal
- * versions perform 4 16-bit or 2 32-bit additions or subtractions.
- * The 's' versions perform 2 16-bit or 1 32-bit additions or
- * subtractions.
- */
-
-#define vis_padd16(rs1,rs2,rd)		vis_dd2d(0x50, rs1, rs2, rd)
-#define vis_padd16s(rs1,rs2,rd)		vis_ss2s(0x51, rs1, rs2, rd)
-#define vis_padd32(rs1,rs2,rd)		vis_dd2d(0x52, rs1, rs2, rd)
-#define vis_padd32s(rs1,rs2,rd)		vis_ss2s(0x53, rs1, rs2, rd)
-#define vis_psub16(rs1,rs2,rd)		vis_dd2d(0x54, rs1, rs2, rd)
-#define vis_psub16s(rs1,rs2,rd)		vis_ss2s(0x55, rs1, rs2, rd)
-#define vis_psub32(rs1,rs2,rd)		vis_dd2d(0x56, rs1, rs2, rd)
-#define vis_psub32s(rs1,rs2,rd)		vis_ss2s(0x57, rs1, rs2, rd)
-
-/* Pixel formatting instructions.  */
-
-#define vis_pack16(rs2,rd)		vis_d2s( 0x3b,      rs2, rd)
-#define vis_pack32(rs1,rs2,rd)		vis_dd2d(0x3a, rs1, rs2, rd)
-#define vis_packfix(rs2,rd)		vis_d2s( 0x3d,      rs2, rd)
-#define vis_expand(rs2,rd)		vis_s2d( 0x4d,      rs2, rd)
-#define vis_pmerge(rs1,rs2,rd)		vis_ss2d(0x4b, rs1, rs2, rd)
-
-/* Partitioned multiply instructions.  */
-
-#define vis_mul8x16(rs1,rs2,rd)		vis_sd2d(0x31, rs1, rs2, rd)
-#define vis_mul8x16au(rs1,rs2,rd)	vis_ss2d(0x33, rs1, rs2, rd)
-#define vis_mul8x16al(rs1,rs2,rd)	vis_ss2d(0x35, rs1, rs2, rd)
-#define vis_mul8sux16(rs1,rs2,rd)	vis_dd2d(0x36, rs1, rs2, rd)
-#define vis_mul8ulx16(rs1,rs2,rd)	vis_dd2d(0x37, rs1, rs2, rd)
-#define vis_muld8sux16(rs1,rs2,rd)	vis_ss2d(0x38, rs1, rs2, rd)
-#define vis_muld8ulx16(rs1,rs2,rd)	vis_ss2d(0x39, rs1, rs2, rd)
-
-/* Alignment instructions.  */
-
-static inline void *vis_alignaddr(void *_ptr)
-{
-	register void *ptr asm("g1");
-
-	ptr = _ptr;
-
-	__asm__ __volatile__(".word %2"
-			     : "=&r" (ptr)
-			     : "0" (ptr),
-			       "i" (vis_opc_base | vis_opf(0x18) |
-				    vis_rs1_s(1) |
-				    vis_rs2_s(0) |
-				    vis_rd_s(1)));
-
-	return ptr;
-}
-
-static inline void vis_alignaddr_g0(void *_ptr)
-{
-	register void *ptr asm("g1");
-
-	ptr = _ptr;
-
-	__asm__ __volatile__(".word %2"
-			     : "=&r" (ptr)
-			     : "0" (ptr),
-			       "i" (vis_opc_base | vis_opf(0x18) |
-				    vis_rs1_s(1) |
-				    vis_rs2_s(0) |
-				    vis_rd_s(0)));
-}
-
-static inline void *vis_alignaddrl(void *_ptr)
-{
-	register void *ptr asm("g1");
-
-	ptr = _ptr;
-
-	__asm__ __volatile__(".word %2"
-			     : "=&r" (ptr)
-			     : "0" (ptr),
-			       "i" (vis_opc_base | vis_opf(0x19) |
-				    vis_rs1_s(1) |
-				    vis_rs2_s(0) |
-				    vis_rd_s(1)));
-
-	return ptr;
-}
-
-static inline void vis_alignaddrl_g0(void *_ptr)
-{
-	register void *ptr asm("g1");
-
-	ptr = _ptr;
-
-	__asm__ __volatile__(".word %2"
-			     : "=&r" (ptr)
-			     : "0" (ptr),
-			       "i" (vis_opc_base | vis_opf(0x19) |
-				    vis_rs1_s(1) |
-				    vis_rs2_s(0) |
-				    vis_rd_s(0)));
-}
-
-#define vis_faligndata(rs1,rs2,rd)	vis_dd2d(0x48, rs1, rs2, rd)
-
-/* Logical operate instructions.  */
-
-#define vis_fzero(rd)			vis_d(   0x60,           rd)
-#define vis_fzeros(rd)			vis_s(   0x61,           rd)
-#define vis_fone(rd)			vis_d(   0x7e,           rd)
-#define vis_fones(rd)			vis_s(   0x7f,           rd)
-#define vis_src1(rs1,rd)		vis_d12d(0x74, rs1,      rd)
-#define vis_src1s(rs1,rd)		vis_s12s(0x75, rs1,      rd)
-#define vis_src2(rs2,rd)		vis_d22d(0x78,      rs2, rd)
-#define vis_src2s(rs2,rd)		vis_s22s(0x79,      rs2, rd)
-#define vis_not1(rs1,rd)		vis_d12d(0x6a, rs1,      rd)
-#define vis_not1s(rs1,rd)		vis_s12s(0x6b, rs1,      rd)
-#define vis_not2(rs2,rd)		vis_d22d(0x66,      rs2, rd)
-#define vis_not2s(rs2,rd)		vis_s22s(0x67,      rs2, rd)
-#define vis_or(rs1,rs2,rd)		vis_dd2d(0x7c, rs1, rs2, rd)
-#define vis_ors(rs1,rs2,rd)		vis_ss2s(0x7d, rs1, rs2, rd)
-#define vis_nor(rs1,rs2,rd)		vis_dd2d(0x62, rs1, rs2, rd)
-#define vis_nors(rs1,rs2,rd)		vis_ss2s(0x63, rs1, rs2, rd)
-#define vis_and(rs1,rs2,rd)		vis_dd2d(0x70, rs1, rs2, rd)
-#define vis_ands(rs1,rs2,rd)		vis_ss2s(0x71, rs1, rs2, rd)
-#define vis_nand(rs1,rs2,rd)		vis_dd2d(0x6e, rs1, rs2, rd)
-#define vis_nands(rs1,rs2,rd)		vis_ss2s(0x6f, rs1, rs2, rd)
-#define vis_xor(rs1,rs2,rd)		vis_dd2d(0x6c, rs1, rs2, rd)
-#define vis_xors(rs1,rs2,rd)		vis_ss2s(0x6d, rs1, rs2, rd)
-#define vis_xnor(rs1,rs2,rd)		vis_dd2d(0x72, rs1, rs2, rd)
-#define vis_xnors(rs1,rs2,rd)		vis_ss2s(0x73, rs1, rs2, rd)
-#define vis_ornot1(rs1,rs2,rd)		vis_dd2d(0x7a, rs1, rs2, rd)
-#define vis_ornot1s(rs1,rs2,rd)		vis_ss2s(0x7b, rs1, rs2, rd)
-#define vis_ornot2(rs1,rs2,rd)		vis_dd2d(0x76, rs1, rs2, rd)
-#define vis_ornot2s(rs1,rs2,rd)		vis_ss2s(0x77, rs1, rs2, rd)
-#define vis_andnot1(rs1,rs2,rd)		vis_dd2d(0x68, rs1, rs2, rd)
-#define vis_andnot1s(rs1,rs2,rd)	vis_ss2s(0x69, rs1, rs2, rd)
-#define vis_andnot2(rs1,rs2,rd)		vis_dd2d(0x64, rs1, rs2, rd)
-#define vis_andnot2s(rs1,rs2,rd)	vis_ss2s(0x65, rs1, rs2, rd)
-
-/* Pixel component distance.  */
-
-#define vis_pdist(rs1,rs2,rd)		vis_dd2d(0x3e, rs1, rs2, rd)
diff --git a/ffmpeg.src/libavcodec/svq1_cb.h b/ffmpeg.src/libavcodec/svq1_cb.h
deleted file mode 100644
index c6735fe..0000000
--- a/ffmpeg.src/libavcodec/svq1_cb.h
+++ /dev/null
@@ -1,1576 +0,0 @@
-/*
- * 
- * Copyright (C) 2002 the xine project
- * Copyright (C) 2002 the ffmpeg project
- * 
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Ported to mplayer by Arpi <arpi at thot.banki.hu>
- * Ported to libavcodec by Nick Kurshev <nickols_k at mail.ru>
- *
- */
-
-/**
- * @file svq1_cb.h
- * svq1 code books.
- */
- 
-/* 6x16-entry codebook for inter-coded 4x2 vectors */
-static const int8_t svq1_inter_codebook_4x2[768] = {
-    7,  2, -6, -7,  7,  3, -3, -4, -7, -2,  7,  8, -8, -4,  3,  4,
-   19, 17,  9,  3,-14,-16,-12, -8,-18,-16, -8, -3, 11, 14, 12,  8,
-    7,-16,-10, 20,  7,-17,-10, 20, -6, 18,  8,-21, -7, 18,  9,-20,
-   25,  3,-20,-14, 29,  7,-18,-13,-29, -4, 21, 14,-31, -6, 20, 14,
-  -19,-26,-28,-24, 31, 32, 22, 10, 15, 24, 31, 28,-32,-32,-22,-13,
-    2, -8,-23,-26, -9,  3, 27, 35,  3, 11, 21, 21,  8, -4,-27,-34,
-  -30,-31, 12, 47,-29,-30, 13, 47, 38, 30,-17,-46, 34, 26,-19,-46,
-  -42,-50,-51,-43, 34, 48, 55, 48, 48, 54, 51, 42,-44,-52,-53,-47,
-    4,  5,  0, -6, -2, -2,  0,  1,-11, -6, -1, -2,  1,  8,  9,  1,
-    0,  1, -6,  5,  8,  1,-12,  2,  7,-14, -7,  8,  5, -8,  0,  8,
-    1,  4, 11,  8,-12, -8,  0, -5, -1,  1,  0,  4,-15, -8,  3, 16,
-   17,  8, -4, -6,  9, -4,-13, -8,  2,  6,  1,-18, -1, 11, 11,-12,
-    6,  0,  2,  0, 14,  6, -7,-21,  1, -1,-13,-20,  1,  1, 10, 21,
-  -22, -5,  7, 13,-11, -1,  4, 12, -7,  0, 14, 19, -4,  3, -5,-19,
-  -26,-14, 10, 15, 18,  4, -6, -2, 25, 19, -5,-18,-20, -7,  4,  2,
-  -13, -6, -1, -4, 25, 37, -2,-35,  5,  4,  1,  1,-21,-36,  2, 43,
-    2, -2, -1,  3,  8, -2, -6, -1, -2, -3,  2, 12, -5, -2, -2, -1,
-   -3, -1, -1, -5, -1,  7,  8, -2,  2,  7,  5, -3,  1,  1, -3, -8,
-   -3, -1, -3, -2, -2, -3,  2, 13, 15,  0,-11, -6,  3,  0,  0,  0,
-   -6, -9, -5, -4, 18,  4,  1,  3, 12,  3,  0,  4,-16, -3,  3, -3,
-  -17,  3, 18,  2, -1, -3, -1, -1, -6, 16, -8,  0, -9, 14, -7,  0,
-    3,-13, 14, -5,  3,-13, 14, -4, -7, 20, 14,-23,  8, -7, -8,  4,
-    8,-15,-19, 16,-10, 13, 11, -3,  9, -1,  1, 26,  5,-15,-27,  2,
-  -20,  7, 16, -4,-40,  9, 31,  1, 26,-12,-30, -7, 40, -2,-19,  4,
-    6,  0,  0,  0, -6, -2,  1,  2,  0, -1,  0, -6,  9,  0, -2, -1,
-   -7,  8,  2, -3, -1,  2, -3,  2,  7, -4, -2,  4,  2,  0,  0, -6,
-   -3, -2,  9,  2, -2, -1,  0, -4, -3, -3,  0, -3, -6,  2, 10,  4,
-    3,  0,-10,  8,  0,  0, -4,  4, -1,  1,  4,  2,  3, -7, -9,  7,
-    2,  1, -9, -4, -1, 12,  0,  0,  3, -1,  7, -4,  3,-14,  4,  2,
-  -12, -9,  1, 11,  2,  5,  1,  0,  3,  1,  0,  2,  0,  8,  6,-19,
-   -6,-10, -7, -4,  9,  7,  5,  7,  6, 21,  3, -3,-11, -9, -5, -2,
-   -4, -9,-16, -1, -2, -5,  1, 36,  8, 11, 19,  0,  2,  5, -4,-41,
-   -1, -1, -2, -1, -2, -2,  1,  6,  0,  4,  1, -8,  1,  1,  1,  0,
-   -2, -3,  4,  0,  2, -1,  3, -3,  1,  3, -4,  1, -1,  3,  0, -5,
-    3,  4,  2,  3, -2, -3, -6, -1, -2, -3, -2,  2, -4,  8,  1,  0,
-   -7,  4,  2,  6, -7, -1,  1,  0, -2,  2, -4,  1,  8, -6,  2, -1,
-   -6,  2,  0,  2,  5,  4, -8, -1, -1,-11,  0,  9,  0, -2,  2,  2,
-   17, -5, -4, -1, -1, -4, -2, -2,  0,-13,  9, -3, -1, 12, -7,  2,
-    0, -2, -5,  2, -7, -5, 20, -3,  7,  7, -1,-30,  3,  5,  8,  1,
-   -6,  3, -1, -4,  2, -2,-11, 18,  0, -7,  3, 14, 20, -3,-18, -9,
-    7, -2,  0, -1, -2,  0,  0, -1, -4, -1,  1,  0, -2,  2,  0,  4,
-    1, -3,  2,  1,  3,  1, -5,  1, -3,  0, -1, -2,  7,  1,  0, -3,
-    2,  5,  0, -2,  2, -5, -1,  1, -1, -2,  4, -1,  0, -3,  5,  0,
-    0,  3, -1, -2, -4,  1,  5, -1, -1,  0, -1,  9, -1, -2, -1, -1,
-   -2,  5,  5, -1, -2,  2, -3, -2,  1,  2,-11,  1,  2,  1,  3,  2,
-    2,-10, -1, -2,  4,  2,  4,  1,  4,  5, -5,  1,  0,  6,-11,  1,
-    1,  0,  6,  6,  0,  2,  1,-15,  7,  3,  5,  9,-30,  2,  2,  2,
-  -34,  1,  9,  2,  5,  8,  8,  2,  7,  2,  6,  6,  2,-27,  1,  4
-};
-
-/* 6x16-entry codebook for inter-coded 4x4 vectors */
-static const int8_t svq1_inter_codebook_4x4[1536] = {
-    4,  0, -6, -7, -4, -8,-13, -9, -8, -8, -1,  6, -2,  5, 22, 27,
-  -16, -7, 11, 10,-18, -7, 13, 10,-15, -4, 12,  8, -9, -1,  9,  5,
-   -2,  2, 15,-16, -3,  2, 19,-19, -3,  2, 19,-19, -2,  3, 15,-14,
-   17, 22, 22, 16, -6, -7, -5, -2,-12,-16,-16,-12,  1,  1, -1, -3,
-   11,-17,  0,  8, 14,-21, -1,  9, 14,-21, -2,  8, 11,-16, -2,  6,
-    7, -2,-16, 11,  9, -2,-21, 14, 10, -1,-22, 14,  8, -1,-18, 10,
-  -10, 16,  3, -9,-13, 20,  4,-11,-14, 21,  4,-10,-11, 16,  3, -8,
-   11,  4, -9, -9, 15,  6,-12,-14, 17,  8,-12,-14, 16, 10, -7,-11,
-    4, 10, 14, 13, -1,  7, 15, 16,-12, -7,  3,  8,-20,-23,-18,-10,
-  -10,-18,-26,-25,  4,  1, -6,-11, 13, 15, 11,  3, 12, 15, 13,  8,
-  -16,-19,-16,-11,  7, 12, 15, 11, 11, 16, 16, 11, -6, -9,-11,-10,
-   18, 19, 12,  5, 18, 16,  5, -4,  6,  0,-10,-15, -9,-17,-23,-22,
-  -10,-14, -1, 21,-11,-17,  0, 29,-11,-16,  1, 30,-10,-14,  0, 23,
-  -16,-17,-12, -6,-19,-19,-14, -7, -3, -1,  1,  2, 27, 35, 29, 19,
-  -37, -8, 23, 23,-42, -9, 28, 29,-43,-10, 26, 28,-38,-11, 19, 22,
-   32, 16,-16,-33, 39, 20,-18,-37, 38, 19,-19,-38, 32, 15,-17,-34,
-   24,  9, -6, -4, -1,-10, -6,  3, -8, -9, -1,  3,  3,  7,  2, -6,
-   -1, -3, -1,  0, -1,  4,  2, -7, -3, 11,  3,-16,  1, 20,  9,-18,
-   -3, -8,  6, 12, -5,-10,  7, 13, -6, -9,  5,  7, -5, -5,  2, -1,
-   -8, 12, -3, -1,-10, 15, -3,  1,-11, 13, -4,  1,-11,  8, -3,  2,
-    9,  6, -5,-12,  3,  0, -8,-13, -4, -4, -1, -1, -4,  1, 15, 18,
-    9, 13, 14, 12,  4,  3, -1, -2, -2, -5, -8, -5, -7,-11, -9, -4,
-    7, -5, -7, -4, 14, -2, -7, -4, 17,  0, -8, -5, 15,  1, -7, -5,
-  -10, -1,  6,  4,-15, -9,  2,  4,  2, -1, -3,  0, 25, 13, -8,-10,
-    7, 11, -3,-16,  7, 11, -3,-15,  6,  7, -2, -9,  4,  2, -3, -5,
-   -7, -1, -1,  0, -9, -2,  2,  6,-12, -4,  6, 14,-13, -6,  8, 19,
-  -18,-18,-11, -5, -3,  0,  3,  4,  6,  8,  6,  6,  6,  6,  6,  6,
-   -5,  3, 13,-10, -6,  1, 15, -9, -6, -3, 15, -6, -6, -6, 10, -3,
-    9,  1, -9, -9, 11,  9,  6,  5,  0,  3,  8,  7,-15,-14, -6, -5,
-  -11, -6, 11, 19, -2, -5, -9, -8,  6,  2, -9,-10,  6,  5,  4,  5,
-   -7, -3,  8, 15, -1,  3, 10, 15,  5,  5, -1, -2,  4, -2,-21,-25,
-    6, -6, -6,  5,  8, -9, -7,  9,  8,-12, -7, 13,  4,-14, -7, 14,
-   -4, -3,  1,  1, -3, -5, -2, -3,  7,  0, -2, -4, 20,  7, -4, -4,
-   -3,-20, -6, 10,  6,  0,  0,  1,  5,  8,  5, -1, -3,  0,  0, -2,
-   13,  6, -1,  2,  5,  3,  2,  3, -3,  0,  3,  0,-16, -8, -2, -5,
-   -2, -7, -6,  0, -3, -6, -3,  1, -5, -1,  2, -1, -1, 12, 16,  5,
-   -7,  1,  9,  8,-10, -2,  5,  3, -6,  2,  7,  3, -4,  0, -1, -7,
-    3,  4, -9,-24,  0,  2,  6,  3, -1, -1,  4,  7,  5,  3, -1, -2,
-    3,  6, -9,  2,  1,  6,-13,  1,  1,  8,-10,  2,  1,  8, -7,  1,
-   -3, -3,  2, 22, -2, -3, -5, 12, -2, -3,-10,  2, -3, -1, -4,  2,
-   11, 12,  8,  2, -5, -5, -5, -8, -6, -4,  0, -3, -2, -1,  3,  3,
-   12, -6, -2, -1, 12, -8, -2, -2,  9, -7,  0, -3,  4, -6,  2, -2,
-  -19,  1, 12, -3, -4,  4,  5, -4,  6,  1, -2, -1,  4, -4, -2,  7,
-   -3, -4, -7, -8, -4, -4, -2,  0, -1,  2, 14, 16, -4, -2,  4,  4,
-   -1,  7,  2, -5, -2,  0, -1,  1,  4, -3, -1, 13,  6,-12,-14,  8,
-   -1,  5,  4, -5, -2,  5,  3, -9, -2,  7,  4,-12, -1,  7,  4, -9,
-   -6, -3,  1,  1, 11, 11,  0, -6,  6,  4, -2, -7,-12,-10,  3, 10,
-   -2, -3, -3, -2,  6, 11, 14, 10, -9,-11,-10,-10,  2,  2,  3,  2,
-   -7, -5, -7, -1, -1,  2,  0,  7, -1,  1,  0,  9,  3,  4, -5, -1,
-   10, -1,-15, -1,  4,  1, -5,  2, -3,  1, -1,  1, -3,  1,  4,  4,
-    2, -1,  4, 10,  6,  2, -1,  0,  2,  2, -7,-12, -4,  2,  0, -3,
-   -1, -4, -1, -8,  3, -1,  2, -9,  4,  0,  5, -5,  2,  0,  8,  3,
-    3,  2,  1,  1,  4, -2,  0,  3,  2, -1,  4,  1,  0,  6, -1,-25,
-   -1, -2, -2, -4, -3,  0, -1, -4, -1, -1, -4,  2,  0, -6,  2, 25,
-  -11, -1,  5,  0,  7,  0, -2,  2, 10, -1, -3,  4, -5, -5, -2, -1,
-    0,  6,  3, -1, -2, -1, -1,  1, -1, -7,-12, -5,  8,  6,  2,  4,
-    2,  6, -1, -6,  9, 10, -1, -4,  1,  0, -4,  0,  3, -2, -9, -5,
-   -4,  3,  4,  0, -4,  3,  3,  0,-11,  0,  3,  2,-11,  3,  7,  2,
-    2, -4,  7,  3,  1, -8,  7,  1, -1,-12,  4,  1,  3, -9,  2,  2,
-    2, -2, -2,  9,-17, -3,  3,  1, -4,  7,  1, -6,  5,  4, -1,  3,
-   -1,  2,  0, -4, -7,  8, 12, -1, -2,  5,  4, -5,  3, -5, -8, -2,
-    0,  0, -5, -2, -2, -8,  3, 27, -1, -4, -3,  6, -3,  1, -2, -7,
-    4,  4,  1, -1, -7,-10, -7, -3, 10, 10,  5,  3, -2, -2, -4, -3,
-    0,  1,  5,  7,  4, -2,-16,-20,  0,  4,  7,  8,  2,  0, -2, -1,
-   -2,  1,  3, 17, -3,  1, -2, -1, -1, -2, -1, -2, -1, -5, -1,  0,
-    5, -3,  1,  0,  6, -2,  0,  0, -1, -2,  0, -3,-11,  1,  8, -1,
-    3,  0,  0,  0,  0,  2,  4,  1,  2,  0,  6,  1, -2,-18, -3,  2,
-  -14,  0,  6,  1, -5, -2, -1,  1, -1,  1,  0,  1,  1,  7,  4,  0,
-   -1,  0,  1, -4,  1,  8,  3, -4, -3,  4,  1,  3, -6,  1, -4,  1,
-    1,-12,  3,  3, -1,-10,  0, -1,  2,  0,  2,  1,  3,  2,  2,  4,
-    3,  0,  0,  3,  2,  0, -2,  1,  5,  2, -5,  0,  6, -1,-14, -1,
-   -2, -6, -3, -3,  2, -1,  4,  5,  6, -1, -2,  0,  4,  4, -1, -5,
-   -4,  1,-11,  0, -1,  2, -4,  1,  2, -3,  3, -1,  1, -2, 15,  0,
-    1, -1,  0, -2,  1, -4, -7,  1, -2, -6, -1, 21, -2,  2, -1,  1,
-   21, -1, -2,  0, -1, -3,  1, -2, -9, -2,  2, -1,  2,  1, -4, -1,
-    1,  8,  2, -6,-10, -1,  4,  0, -4, -3,  3,  3,  5,  0, -1, -1,
-    3,  2,  1, -2, -2, -2,  4,  3,  5,  2, -4,-17,  0, -2,  4,  3,
-   -7, -4,  0,  3,  9,  9,  2, -1,-11, -6,  0, -1,  5,  1,  0,  1,
-    0, 17,  5,-11,  3, -2, -6,  0,  2, -2, -4,  1, -4,  1,  2, -1,
-   -5, -1, -5, -3, -3,  5, -3, -2,  4, 16,  2, -5, -2,  5, -1, -1,
-    0,  0, -4,  1, -1,  2,  5, 11, -1, -1, -2,  1, -4, -2, -3, -1,
-   -5, -1, 10,  0,  6,  1,  0, -3,  0, -4,  1,  0, -2, -4,  3, -1,
-    6,  9,  3,  0, -2,  1, -2,  0, -2, -3, -2, -2,  1,  0,  1, -6,
-    1,  0,  2,  1, -1,  3, -2,  1,  0, -1,-15,  0, -1,  5,  2,  6,
-    2,  0,  2,  2,  0,-12, -4,  6,  0,  1,  4, -1,  1,  2,  1, -4,
-    1, -2, -7,  0,  0,  0,  0, -1, -5,  2, 11,  3,  1,  3,  0, -6,
-    0, -3, -9, -4,  1,  3, -1,  0,  4,  1, -2,  0,  7, -3, -1,  6,
-    1, -2,  6,  2,  0, -1,  3, -2, -2,  4,  0,  2, -1,  2,-14,  2,
-    2,  2,  0, -1, -2,  3, -3,-14,  0,  2,  3, -3,  5,  1,  3,  2,
-    1, -3,  4,-14,  1, -2, 11, -1,  0, -1,  3,  0, -1,  1,  0,  2,
-   -2,  3, -3,  2, -4, -1, -4,  3, -1,  2,  1,  3, -6, -2,  2,  7,
-   -2,  1,  2,  0, -2,  0,  0, -1, 12,  5, -1,  2, -8, -1,  1, -7,
-    2, -2, -4,  2, 11,  0,-11, -2,  3,  1, -3, -1,  0,  3,  1, -1,
-    0,  3,  0, -2,  0, -6, -1, -3, 12, -7, -2,  0,  7, -2,  1,  1,
-    1,  2,  2,  2, -1,  2,  0,  2,-23,  0,  4,  0,  3,  2,  1,  3,
-   -4, -5, -1,  5, -3,  5, 10, -1,  0,  0,  3, -4,  1, -1,  2, -5
-};
-
-/* 6x16-entry codebook for inter-coded 8x4 vectors */
-static const int8_t svq1_inter_codebook_8x4[3072] = {
-    9,  8,  4,  0, -3, -4, -4, -3,  9,  8,  4, -1, -4, -5, -5, -3,
-    8,  7,  3, -2, -5, -5, -5, -4,  6,  4,  1, -2, -4, -5, -4, -3,
-  -12,-14,-11, -4,  1,  5,  6,  6, -8,-10, -7, -5, -2,  1,  1,  1,
-    5,  4,  3,  1,  0,  0, -1, -1, 13, 13,  9,  6,  3,  0, -1, -2,
-   -4, -4, -3, -1,  1,  4,  8, 11, -5, -6, -4, -2,  0,  3,  8, 12,
-   -7, -7, -6, -4, -2,  2,  7, 10, -7, -7, -5, -4, -2,  1,  5,  8,
-   -3, -2, -1,  1,  3,  6,  7,  6,  2,  3,  5,  7,  8,  8,  6,  4,
-    4,  5,  4,  3,  1, -2, -6, -7,  1,  0, -2, -7,-10,-14,-17,-16,
-   -5, -4,  1,  8,  9,  3, -3, -7, -7, -6,  1, 11, 12,  5, -3, -8,
-   -8, -7,  0,  9, 11,  5, -3, -7, -8, -6, -1,  5,  8,  4, -2, -6,
-   -4, -5, -7, -8, -9, -9, -8, -6, -4, -5, -6, -7, -7, -6, -4, -2,
-    0,  1,  2,  3,  5,  8, 10,  9,  1,  2,  3,  6,  9, 12, 14, 13,
-    5,  6,  6,  5,  4,  3,  2,  1,  5,  6,  7,  7,  6,  6,  6,  4,
-   -1,  0,  1,  1,  3,  5,  5,  5,-13,-16,-17,-17,-14,-10, -6, -4,
-    9, 11, 13, 16, 15, 13, 12, 10, -4, -5, -6, -7, -7, -7, -6, -5,
-   -6, -6, -7, -7, -7, -7, -6, -5, -2, -1,  0,  0,  0,  0,  0, -1,
-  -11,-13,-15,-16,-16,-14,-12,-10,  2,  3,  4,  5,  4,  3,  3,  3,
-    6,  7,  8,  8,  8,  7,  6,  5,  3,  4,  3,  3,  3,  3,  3,  3,
-    3,  4,  4,  1, -2, -7,-13,-17,  5,  7,  7,  5,  1, -5,-13,-19,
-    6,  8,  9,  8,  5, -1, -9,-16,  6,  8, 10, 10,  7,  2, -4,-11,
-   18,  9, -1,-10,-13, -9, -4,  0, 22, 12, -1,-12,-15,-10, -4,  2,
-   23, 13,  0,-10,-13, -9, -3,  2, 20, 12,  2, -6, -9, -6, -2,  2,
-   -6, -6, -6, -7, -7, -7, -7, -6, -6, -7, -8, -8, -9, -9, -9, -8,
-   -3, -3, -3, -3, -3, -3, -3, -3, 12, 15, 18, 21, 21, 19, 17, 14,
-   14, 16, 18, 18, 18, 16, 15, 13,  5,  6,  6,  5,  5,  4,  4,  3,
-   -6, -7, -9,-10,-10,-10, -9, -7,-10,-11,-13,-14,-14,-13,-12,-10,
-  -27,-17, -4,  5,  9, 10, 10,  7,-32,-19, -3,  7, 11, 12, 11,  8,
-  -30,-16, -2,  8, 12, 12, 10,  7,-23,-12,  0,  7, 10, 11,  9,  6,
-   16, 17, 16, 12,  6, -1, -8,-12, 17, 18, 15, 10,  1, -8,-15,-18,
-   15, 14, 10,  4, -5,-14,-20,-23, 10,  8,  4, -1, -9,-16,-21,-22,
-  -10,-12,-12,-11, -5,  4, 14, 20,-11,-13,-15,-12, -4,  7, 19, 27,
-  -11,-13,-14,-11, -3,  8, 21, 28,-10,-11,-12, -9, -2,  8, 18, 25,
-   -1, -1, -1,  1,  4,  6,  6,  5,  0,  0,  0,  2,  4,  3,  1, -2,
-    0,  0,  2,  4,  4, -1, -7,-10,  0,  0,  3,  5,  3, -3,-11,-15,
-  -14,-13, -8, -1,  3,  3, -1, -4, -5, -4, -1,  4,  8,  8,  3,  0,
-    3,  2,  2,  3,  4,  5,  3,  1,  5,  3,  0, -2, -2, -1, -1, -1,
-    9,  1, -6, -6, -5, -3, -2, -1, 12,  1, -6, -6, -4, -2, -1,  0,
-   14,  4, -4, -4, -2, -2, -1, -1, 14,  6, -1, -1, -1, -1, -1, -1,
-    4,  6,  8, 10, 11,  9,  7,  5, -1, -1, -1,  0,  0, -1, -1, -2,
-   -2, -4, -4, -5, -5, -5, -5, -4, -2, -3, -3, -4, -4, -3, -2, -1,
-    2,  3,  4,  4,  3,  1,  0,  0, -1,  1,  4,  5,  6,  5,  4,  3,
-   -8, -6, -2,  2,  3,  4,  4,  3,-14,-13, -9, -5, -2, -1,  0,  0,
-   -3, -4, -5, -4,  0,  7, 12, 13, -3, -4, -5, -5, -2,  4,  9, 10,
-   -2, -3, -4, -5, -4, -1,  3,  4, -1, -1, -2, -3, -3, -2,  0,  1,
-    9,  5, -2, -8,-11,-10, -7, -4, 12, 10,  6,  2,  0, -1,  0,  0,
-    2,  2,  3,  4,  3,  1,  1,  1, -9, -8, -4,  0,  1,  2,  1,  0,
-    6,  8,  8,  5,  1, -5,-11,-13,  0,  1,  2,  2, -1, -4, -8,-11,
-   -3, -2,  1,  3,  3,  1, -1, -4, -2, -1,  2,  5,  6,  6,  4,  1,
-    3,  4,  5,  5,  4,  1, -3, -6,  5,  6,  4,  2,  2,  2,  0, -3,
-    6,  5,  0, -5, -5, -2, -1, -2,  7,  4, -3,-11,-12, -7, -3, -2,
-    1,  0, -1, -1, -1,  0,  0,  0,  2,  3,  4,  4,  5,  5,  4,  3,
-   -7, -9, -9,-10,-10, -9, -7, -6,  3,  4,  5,  6,  5,  5,  5,  5,
-   -7, -7, -7, -7, -6, -6, -5, -4, -5, -4, -3, -1, -1, -1,  0,  0,
-   -3, -2,  1,  4,  5,  5,  5,  5, -2, -1,  3,  6,  9, 10, 10,  9,
-  -14,  1, 10,  3, -2,  0,  1,  1,-16,  2, 13,  3, -3, -1,  1,  0,
-  -15,  2, 12,  3, -4, -2,  1,  1,-10,  3, 10,  2, -3, -1,  1,  1,
-    0,  1,  4,  2, -5,-10, -3, 11, -1,  1,  4,  2, -6,-13, -2, 15,
-   -1,  0,  3,  1, -6,-12, -1, 15, -1,  1,  2,  1, -4, -8,  0, 11,
-   10,  5, -2, -2,  2,  5,  1, -4,  7,  0, -8, -6,  1,  5,  2, -4,
-    2, -5,-12, -7,  2,  7,  4, -1, -1, -7,-10, -4,  4,  9,  7,  2,
-   -5, -5, -4, -6, -6, -5, -5, -3, -1, -2, -2, -4, -5, -6, -5, -4,
-    6,  7,  7,  4,  0, -2, -3, -3, 13, 14, 13, 10,  5,  1, -1, -2,
-    1,  1,  2,  2,  2,  2,  2,  2, -5, -6, -8, -9, -9, -8, -7, -6,
-    7,  9, 10, 11, 11,  9,  7,  5, -1, -2, -3, -3, -4, -4, -4, -3,
-   -1, -1,  0,  0,  0,  0, -1, -1, -3, -3, -4, -5, -4, -3, -3, -2,
-    2,  1, -1, -3, -3, -2, -1,  0, 12, 12,  8,  3,  1,  0,  0,  1,
-   -6, -8, -8, -6, -2,  2,  6,  8,  1,  1, -1, -2,  0,  3,  5,  7,
-    3,  3,  1, -1, -1,  0,  0,  2,  0,  1,  0, -1, -1, -1, -2, -1,
-    1,  0,  0,  0,  0,  0,  2,  4,  2,  1,  3,  4,  3,  1,  0,  2,
-    2,  1,  0,  0, -1, -1,  0,  3,  5,  1, -6,-12,-13, -8, -1,  4,
-   -2,  0, -1, -2, -1,  0,  2,  3, -6, -3, -2,  0,  1,  1,  1,  1,
-   -9, -5,  0,  4,  5,  3,  1,  0, -8, -3,  3,  7,  8,  4,  1,  0,
-    1,  2,  2,  3,  3,  1, -1, -3,  4,  5,  5,  6,  6,  5,  2,  0,
-    0,  0,  0,  0,  1,  0, -2, -4, -3, -3, -4, -3, -3, -4, -7, -8,
-   14, 12,  6, -1, -3, -3,  0,  0,  7,  5,  1, -3, -5, -4, -2, -1,
-   -2, -2, -2, -2, -2, -2, -1, -1, -6, -4, -1,  1,  1,  1,  0, -1,
-    2,  2,  1, -3, -6, -7, -6, -3,  1,  0, -1, -3, -2,  1,  4,  6,
-    0,  0,  1,  2,  4,  7,  8,  7,  0,  0,  0,  0, -1, -4, -7, -8,
-    0,  2,  1, -2, -3, -3, -2, -1, -1,  1,  0, -3, -5, -2,  0,  2,
-   -2, -1, -2, -5, -4,  1,  6,  9, -3, -2, -3, -4, -2,  5, 11, 13,
-   -4, -2,  2,  6,  4, -3,-10,-14, -2, -1,  1,  4,  4,  1, -1, -2,
-    0,  0, -1, -2, -2,  0,  4,  6,  2,  2,  0, -3, -3,  0,  5,  9,
-   -4, -4, -2,  1,  6,  9,  3, -7, -2, -2, -2, -1,  4,  8,  0,-11,
-    1,  1,  0,  0,  2,  6, -1,-10,  2,  2,  1,  0,  2,  4,  0, -7,
-   -1, -2, -3, -6, -7, -8, -8, -8,  2,  3,  3,  1, -1, -2, -3, -4,
-    5,  5,  5,  4,  3,  2,  0, -1,  3,  3,  3,  3,  2,  2,  1,  1,
-    3,  3,  2, -2, -3,  0,  7, 10,  1,  2,  2, -2, -5, -4,  0,  3,
-    0,  3,  4,  2, -3, -5, -6, -4,  0,  2,  4,  4,  1, -4, -7, -7,
-    2,  4,  5,  5,  5,  5,  6,  6, -4, -4, -3, -5, -5, -3, -3, -2,
-   -3, -4, -4, -5, -4, -2, -2, -2,  1,  1,  0,  0,  2,  4,  5,  4,
-   -2,  0,  3,  4,  4,  3,  2,  2, -9, -7, -4,  0,  3,  6,  6,  6,
-   -5, -5, -3, -2,  0,  1,  3,  4,  5,  5,  2, -2, -4, -6, -5, -3,
-    1, -6, -4,  7,  5, -2, -2,  1,  5, -5, -4,  6,  4, -5, -4,  1,
-    5, -5, -4,  6,  4, -5, -3,  1,  1, -7, -3,  8,  7, -1, -3,  1,
-   -8, -7, -4,  0,  2,  4,  5,  5,  5,  6,  5,  2, -1, -5, -7, -7,
-    5,  6,  4,  1, -3, -5, -6, -5, -7, -7, -5, -2,  1,  6,  9, 10,
-    6,  3,  0,  1,  3,  0, -8,-14,  3,  0, -1,  1,  4,  3,  0, -4,
-    1,  0,  0,  1,  2,  1,  1,  1, -1, -1,  1,  2,  1, -1, -1,  0,
-    1,  1,  1,  1,  0, -2, -3,  0,  1,  2,  1,  0, -2, -8, -9, -4,
-    1,  3,  3,  2,  1, -3, -3,  1,  0,  1,  1,  1,  1,  1,  4,  8,
-    2,  5,  9,  7,  2, -1, -1,  1, -4, -1,  1,  0, -3, -4, -1,  2,
-   -3,  0,  3,  3,  0, -1,  0,  2, -4, -1,  1,  1, -2, -4, -5, -4,
-    1, -1, -2, -2, -1,  2,  4,  5,  2,  1,  1,  0, -1, -1,  0,  0,
-    2,  3,  4,  5,  4,  2,  1,  0, -9, -9, -6, -3, -1, -1, -1, -1,
-   -6, -6,  4,  7,  0, -2, -1, -2, -1, -2,  5,  6, -1, -2,  0, -1,
-    4, -1,  1,  0, -4, -2,  0, -2,  7,  1, -1, -2, -3,  1,  3,  1,
-    4,  2,  1,  3,  3,  1,  1,  2,  2, -2, -4,  0,  3,  1,  0,  0,
-    1, -4, -8, -4,  1,  2,  1,  0,  2, -3, -9, -6,  0,  3,  3,  2,
-   -1, -1,  0, -1, -1,  0,  1,  2,  3,  1, -4, -8, -7, -3,  1,  2,
-    2, -1, -3, -2, -1,  0,  1,  0, -1,  0,  5, 11,  9,  3, -1, -3,
-   -1, -2, -2, -1,  1,  1,  1,  1,  0, -1,  0,  3,  6,  6,  5,  5,
-    2,  1, -1, -1, -2, -5, -6, -4,  2,  2,  2,  1, -1, -4, -5, -5,
-   -1, -3, -6, -7, -6, -4, -1,  1,  5,  5,  3,  4,  4,  3,  4,  5,
-   -1, -2, -3, -2, -2, -2,  0,  1,  0,  0,  0,  0,  0,  1,  2,  3,
-   -6, -6, -4, -1,  2,  2,  2,  2, -6, -7, -5, -2,  0, -1, -1,  0,
-    2,  2,  2,  4,  4,  3,  3,  4,  2,  1,  0, -1,  0,  0,  2,  4,
-   12,  5, -5, -8, -5,  0,  2,  2,  2, -3, -6, -3,  0,  0, -1, -2,
-   -2, -3, -1,  3,  4,  1, -2, -3,  2,  2,  3,  4,  3,  1, -1, -1,
-    3,  2,  1,  0,  1,  4,  3,  0,  4,  3,  0, -5, -6,  0,  3,  3,
-    2,  3,  1, -7,-12, -6,  1,  3,  1,  3,  4, -1, -6, -4,  0,  1,
-   -9, -4,  2,  6,  7,  4,  1,  0, -7, -1,  4,  6,  4,  0, -3, -3,
-   -6,  0,  4,  4,  1, -2, -3, -2, -4,  1,  3,  2,  0, -2, -1,  0,
-    0,  5,  2, -5, -3,  3,  1, -4, -2,  4,  2, -6, -3,  6,  4, -3,
-   -1,  5,  3, -5, -1,  7,  3, -4, -1,  2,  0, -6, -3,  5,  3, -3,
-   -8, -3,  3,  5,  3,  1, -2, -2,  2,  4,  4, -2, -4, -3,  1,  3,
-    2,  1, -3, -5, -3,  3,  4,  3, -5, -6, -5,  3, 10,  8, -1, -5,
-    0,  3,  2, -4, -9, -7,  0,  6, -5, -1,  5,  7,  4, -1, -3, -3,
-   -5, -5, -2,  3,  6,  5, -1, -4,  9,  6,  0, -4, -2,  1,  1, -1,
-   -1, -1, -1,  1,  1,  0, -1,  0, -1,  0,  0,  0,  0, -1, -1,  0,
-    2,  1, -2, -1,  1,  1,  0,  0, 12,  8,  2, -1, -1, -4, -7, -7,
-    2,  1,  3,  6,  7,  4,  2,  0,  1,  0, -1,  0, -1, -4, -7, -8,
-    0,  0, -1,  0,  0,  0, -1, -3,  0,  0,  0,  0,  1,  1,  0, -2,
-   -1,  0,  1,  1,  0,  0, -1, -2,  0,  0, -1, -3, -4, -3, -1,  1,
-   -1,  0,  0,  0,  1,  4, 10, 12, -1,  0, -2, -2, -3, -3, -1,  1,
-   -3, -1, -2, -4,  2,  9,  9,  7, -3,  0, -1, -3,  0,  2, -1,  1,
-   -1,  1, -2, -3,  0, -1, -3,  0,  0,  0, -3, -2,  0, -1, -1,  1,
-   -1, -2, -1, -1, -2, -1, -1, -2,  2, -1, -2, -1,  0,  1,  0, -2,
-    3, -1, -2,  2,  5,  3, -1, -3,  1, -5, -5,  1,  6,  6,  2,  0,
-    1,  2,  0, -1,  0,  1,  0, -2, -5, -3, -1,  0,  1,  2,  1, -2,
-   -7, -5, -2, -2, -2, -2,  0,  1, -1,  0,  1,  1,  0,  3,  9, 12,
-    0,  6,  5,  1, -2, -3,  0,  3,  0,  6,  5,  1,  1,  1,  2,  3,
-   -5, -2, -2, -3,  0,  0,  0,  0, -6, -3, -3, -2,  0,  0, -1, -2,
-    4,  4,  2,  1,  0, -1, -1,  0, -2, -2,  0,  1,  2,  1,  1,  0,
-    2,  2,  1, -1, -3, -5, -9,-10,  2,  1, -1, -1,  1,  4,  4,  1,
-    4,  0, -2, -2, -2, -2, -1,  0,  7,  1, -4, -3, -2,  0,  1,  1,
-   10,  5, -1, -2,  0,  1,  1,  0,  5,  1, -3, -4, -3, -1, -1, -2,
-    2,  1, -1, -3, -3,  1,  1, -1, -2, -1,  3,  0, -1,  1,  1,  0,
-   -3,  1,  7,  2, -3, -2, -1,  0, -2,  4,  8, -1, -8, -5,  0,  2,
-   -4, -1,  1,  2,  1, -3, -4, -2, -5, -3, -2,  1,  4,  4,  4,  6,
-   -3, -2, -4, -3,  0,  1,  1,  2,  2,  2,  2,  1,  2,  1, -1, -1,
-   -4, -1,  0, -1, -3, -3, -1, -1,  1,  4,  4,  2,  0, -1, -2, -3,
-    4,  6,  5,  3,  2,  1, -2, -4,  0,  1,  1,  1,  1, -1, -4, -6,
-    1,  2,  2, -1, -6, -5, -1,  2, -3, -2,  1,  1, -4, -3,  2,  5,
-   -2, -1,  2,  2, -3, -4,  0,  3, -2, -2,  2,  6,  5,  2,  1,  2,
-    2, -3, -3,  0,  0,  2,  3,  1,  3, -1,  1,  3,  1,  2, -1, -5,
-   -5, -7, -4, -2,  1,  8,  8,  1, -1,  0,  2,  0, -3,  0,  1, -3,
-   -2, -5, -5, -2, -3, -1,  0, -2, -1, -4,  0,  4,  0,  2,  4,  0,
-    0,  0,  8, 10,  2,  1,  3, -1, -4, -3,  2,  3, -3, -3,  1, -1,
-    1, -2, -4,  2,  7,  3, -2, -1,  6,  4, -2, -1,  2,  0, -1,  3,
-    1,  1, -2, -2, -2, -5, -3,  4, -6, -2,  1,  1, -1, -4, -2,  4,
-   -2, -1, -2, -2,  0,  1,  0, -2, -1,  1,  0, -1,  0,  0, -1, -3,
-    0,  1, -2, -4, -3, -1,  0,  0,  6,  8,  5,  0,  0,  1,  2,  3,
-   -2, -2,  2,  5,  2,  0,  0,  1,  2, -2, -2, -1, -1,  1,  2,  4,
-    2, -1,  0,  1,  0,  0,  0,  1, -8, -7, -1,  1, -1, -1,  1,  3,
-    0,  3,  6,  2, -2,  1,  2,  0,-10, -7, -1,  0, -3, -1,  2,  1,
-    0,  0,  2,  2,  1,  1,  1, -1,  3,  0, -2, -2,  0,  2,  1,  0,
-    8,  1,  0,  0, -2, -3, -1,  0,  2, -2,  2,  5,  1, -2, -1,  1,
-   -3, -6, -3, -1, -3, -3, -1,  2,  2,  0,  1,  2,  2,  1,  0,  0,
-    1, -1, -1, -2, -1,  0,  1,  0, 15,  9,  2, -1, -2, -3, -3, -3,
-    0, -3, -2,  0,  0, -1, -1, -1,  1,  0,  1,  0,  0, -1, -1, -1,
-    0,  2,  2, -2, -3, -3, -7, -8,  0,  2,  2,  0,  1,  2,  1,  1,
-    1,  2,  2,  2,  3,  1,  0,  3,  1,  0, -1, -2, -1, -2,  0,  5,
-  -11, -6, -1,  1,  2,  3,  1, -3,  1,  4,  3, -1, -2,  1,  2, -1,
-    2,  2,  1, -1, -2,  0,  1, -1,  0,  0, -1, -1,  0,  2,  3,  2,
-    1,  1,  2,  1, -1,  1,  0, -4,  0,  0,  0, -2, -2,  2,  4, -2,
-   -2, -3,  0,  0, -1,  2,  1, -6,  0,  2,  5,  5,  3,  2, -1, -7,
-    4,  2,  0,  0,  3,  3,  1, -1,  0, -1, -1,  3,  6,  4,  1, -1,
-   -2, -2,  0,  2,  2,  0, -2, -2, -1,  0, -1, -5, -7, -5, -1,  1,
-    5, -1, -2,  0,  2,  4,  2, -5,  0, -5, -2,  2,  1,  2,  0, -6,
-    6,  1,  0,  1, -2, -1,  4,  2,  2, -3, -3,  0, -1, -2,  0,  0,
-    1, -1,  0,  2,  0,  0,  6, 11,  2, -1, -1,  0, -3, -2,  3,  5,
-    0, -2, -1,  0, -1,  0,  0, -3,  1, -1, -1, -1, -2, -1, -3, -7,
-    1,  1, -2, -2,  1,  3,  1, -2, -1,  2,  0, -1, -1,  1,  0,  0,
-   -4,  2,  3, -1, -2, -2,  0,  1,-11, -2,  4,  5,  6,  2, -1, -2,
-   -6, -2,  1, -1, -3, -4,  1,  9, -3,  0,  3,  3,  2, -3, -3,  3,
-    1,  1,  0,  0,  1, -1, -2,  3,  2,  0, -3, -3,  0, -1, -1,  3,
-    1, -1, -3,  1,  2, -6, -4,  6,  0, -2, -5, -2,  0, -3, -2,  3,
-    2,  2,  1, -2, -2,  1,  2, -1, -1,  1,  1, -2, -1,  6,  7, -1,
-    1,  0, -4, -2,  1, -2, -3,  1, -4,  0, -3, -2,  2,  0, -3,  0,
-   -3,  4,  3,  1,  8,  7,  0, -1, -3,  4,  1, -4,  2,  3, -2, -3,
-   -3,  6,  1, -4,  1,  1, -1, -1, -2,  4, -3, -3,  3,  0, -1, -1,
-    1,  2, -4,  2,  4, -3, -1,  2,  3, -1, -4,  5,  4, -6, -3,  2
-};
-
-/* 6x16-entry codebook for inter-coded 8x8 vectors */
-static const int8_t svq1_inter_codebook_8x8[6144] = {
-   -4, -3,  4,  5,  2,  1,  1,  0, -5, -3,  5,  5,  2,  1,  0,  0,
-   -6, -4,  5,  5,  2,  1,  0,  0, -7, -4,  4,  5,  2,  1,  0,  0,
-   -8, -5,  3,  4,  2,  1,  0,  0, -8, -6,  3,  4,  1,  1,  1,  0,
-   -8, -6,  2,  4,  2,  1,  1,  0, -8, -6,  2,  4,  1,  1,  1,  1,
-   -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -2, -2, -2, -2, -2,
-   -2, -3, -3, -3, -3, -3, -3, -3, -2, -3, -3, -3, -3, -3, -4, -3,
-   -2, -2, -2, -2, -2, -3, -3, -2,  1,  1,  1,  1,  1,  0, -1, -1,
-    4,  5,  5,  5,  4,  3,  3,  2,  7,  7,  8,  8,  8,  7,  6,  5,
-    2,  1,  2,  4,  4,  0, -4, -6,  1,  1,  2,  5,  5,  1, -5, -7,
-    1,  2,  1,  4,  5,  1, -5, -8,  1,  1,  1,  5,  5,  0, -6, -8,
-    0,  1,  1,  5,  6,  1, -6, -9,  0,  0,  1,  4,  5,  0, -5, -8,
-    0,  0,  1,  4,  5,  0, -5, -7,  0,  0,  1,  4,  4,  1, -4, -7,
-    1,  2,  3,  0, -3, -4, -3, -1,  1,  3,  4,  0, -3, -4, -3, -1,
-    2,  4,  5,  1, -3, -4, -3, -2,  2,  5,  6,  1, -3, -5, -4, -2,
-    3,  6,  6,  1, -3, -5, -4, -2,  3,  6,  6,  1, -3, -5, -4, -2,
-    3,  6,  6,  1, -3, -5, -4, -2,  3,  5,  5,  1, -3, -4, -4, -2,
-    2,  2,  2,  2,  1,  0,  0, -1,  4,  4,  4,  3,  2,  1,  1,  0,
-    4,  5,  4,  4,  3,  3,  2,  1,  4,  4,  4,  4,  4,  3,  2,  2,
-    2,  3,  3,  3,  3,  3,  2,  1, -1, -1, -1, -1,  0,  0,  0,  0,
-   -5, -6, -6, -5, -5, -4, -3, -3, -7, -9, -9, -8, -7, -6, -6, -5,
-    6,  6,  6,  6,  6,  5,  5,  4,  4,  4,  4,  3,  3,  3,  3,  2,
-    0, -1, -1, -1, -2, -2, -1, -1, -3, -5, -6, -6, -6, -6, -5, -4,
-   -3, -5, -6, -7, -6, -6, -5, -4, -1, -2, -2, -2, -2, -2, -1, -1,
-    0,  1,  1,  1,  1,  1,  1,  1,  3,  3,  3,  3,  3,  3,  3,  3,
-    2,  1, -2, -5, -4,  0,  2,  5,  2,  1, -2, -6, -5,  0,  3,  5,
-    2,  1, -2, -6, -6, -1,  3,  6,  3,  2, -2, -7, -6,  0,  4,  7,
-    2,  1, -2, -7, -5,  0,  5,  7,  2,  1, -2, -6, -5,  0,  4,  7,
-    2,  1, -2, -6, -4,  0,  4,  6,  1,  1, -2, -5, -4,  0,  3,  6,
-  -10, -9, -6, -4, -1,  2,  3,  2,-10, -9, -5, -3,  0,  4,  4,  3,
-   -9, -7, -3, -1,  2,  5,  5,  3, -7, -5, -2,  0,  3,  5,  5,  3,
-   -6, -3,  0,  1,  4,  6,  5,  3, -4, -2,  1,  2,  3,  5,  4,  2,
-   -2,  0,  1,  2,  2,  4,  3,  1, -1,  1,  2,  2,  2,  3,  3,  1,
-   -4, -5, -5, -6, -6, -6, -6, -5, -3, -3, -4, -4, -4, -4, -4, -4,
-    0,  0,  0,  0, -1, -1, -1, -1,  5,  5,  6,  5,  5,  4,  3,  2,
-    5,  6,  7,  7,  7,  6,  5,  4,  3,  3,  4,  4,  4,  4,  3,  2,
-    0, -1,  0,  0, -1, -1,  0, -1, -3, -3, -4, -4, -4, -4, -3, -3,
-    1, -2, -5,  1,  5,  4,  2,  0,  1, -3, -6,  1,  6,  5,  2,  0,
-    0, -4, -7,  0,  6,  6,  2,  1, -1, -5, -9, -1,  6,  6,  3,  1,
-   -1, -6,-10, -2,  6,  6,  3,  1, -1, -6, -9, -2,  5,  6,  3,  1,
-   -2, -6, -9, -2,  5,  5,  3,  1, -2, -6, -7, -2,  4,  4,  2,  1,
-   -5, -7, -8, -9, -9, -8, -7, -6, -5, -6, -6, -7, -7, -6, -6, -5,
-   -3, -3, -3, -4, -5, -5, -4, -4, -1,  0,  0, -1, -1, -1, -1, -1,
-    0,  1,  2,  2,  2,  2,  2,  1,  2,  3,  4,  5,  5,  5,  5,  4,
-    3,  4,  5,  6,  8,  8,  8,  7,  3,  4,  5,  6,  7,  7,  7,  6,
-    5,  6,  7,  8,  9, 10, 10,  9,  3,  4,  6,  7,  8,  9,  9,  8,
-    0,  1,  2,  3,  4,  5,  5,  5, -1, -2, -1, -1,  0,  1,  2,  2,
-   -2, -3, -3, -3, -3, -2, -1,  0, -3, -4, -5, -5, -5, -5, -5, -4,
-   -4, -5, -5, -6, -7, -7, -6, -5, -3, -4, -5, -6, -7, -7, -6, -6,
-   13,  7,  0, -3, -3, -4, -4, -5, 14,  7,  0, -3, -3, -4, -4, -4,
-   15,  8, -1, -4, -4, -4, -5, -4, 15,  8, -1, -4, -4, -5, -4, -3,
-   15,  7, -1, -4, -5, -5, -5, -4, 14,  7, -1, -4, -4, -4, -4, -3,
-   12,  6, -1, -4, -4, -4, -4, -3, 11,  5, -1, -4, -4, -4, -4, -3,
-  -17, -4,  5,  4,  4,  4,  3,  3,-18, -5,  5,  4,  4,  4,  3,  3,
-  -19, -5,  6,  4,  4,  4,  3,  2,-20, -5,  6,  4,  4,  4,  3,  3,
-  -20, -4,  6,  4,  4,  5,  3,  3,-19, -5,  6,  4,  4,  5,  3,  3,
-  -18, -4,  5,  4,  4,  4,  3,  2,-17, -5,  4,  3,  4,  4,  3,  3,
-   -6, -6, -6, -4, -2,  1,  6, 11, -6, -7, -7, -4, -2,  2,  8, 13,
-   -8, -8, -7, -4, -2,  3,  9, 14, -8, -8, -7, -5, -1,  4, 10, 16,
-   -8, -8, -7, -5, -1,  4, 10, 17, -8, -8, -7, -4,  0,  5, 10, 16,
-   -8, -8, -6, -3,  0,  4,  9, 15, -7, -7, -5, -3,  0,  4,  8, 12,
-    8,  7,  7,  5,  2, -2, -8,-14,  8,  8,  7,  5,  2, -2, -8,-15,
-    8,  8,  7,  5,  1, -3, -9,-16,  8,  8,  7,  5,  1, -3,-10,-17,
-    8,  9,  8,  5,  1, -3,-10,-17,  8,  8,  7,  4,  1, -4,-10,-16,
-    7,  7,  7,  4,  1, -3, -9,-14,  6,  7,  6,  3,  0, -3, -9,-13,
-    5,  1, -4, -4, -3, -1,  0,  0,  7,  2, -3, -3, -2, -1,  1,  0,
-    7,  1, -3, -3, -1,  0,  1,  1,  6,  1, -3, -2, -1,  1,  1,  0,
-    6,  0, -4, -2, -1,  0,  1,  0,  5,  0, -4, -3, -1,  0,  0, -1,
-    5,  0, -3, -1,  0,  0,  0, -2,  4,  1, -2, -1,  0,  1,  0, -1,
-    2,  2,  1,  1, -2, -6, -8, -8,  1,  1,  1,  1, -2, -5, -8, -8,
-    1,  1,  1,  0, -1, -3, -5, -5,  0,  0,  0,  0, -1, -1, -1, -2,
-    0, -1,  0,  0,  0,  0,  1,  0,  1,  0,  0,  0,  1,  2,  3,  2,
-    2,  1,  1,  1,  2,  3,  4,  3,  3,  3,  3,  3,  4,  4,  5,  4,
-   -4, -4, -3, -2,  0,  0,  1,  1, -4, -4, -3, -2, -1,  0,  0,  1,
-   -2, -2, -2, -1, -1, -1,  0,  0,  0,  1,  0,  0,  0,  0,  0, -1,
-    2,  2,  2,  2,  2,  2,  1,  1,  3,  4,  4,  4,  4,  4,  4,  3,
-    1,  1,  1,  3,  3,  4,  3,  3, -5, -6, -5, -4, -3, -3, -2, -2,
-   -4, -2, -1, -1, -1, -1,  0,  1, -4, -2, -1, -1, -1, -1,  0,  1,
-   -3, -2, -1, -1, -1,  0,  1,  2, -4, -3, -2, -1, -1,  1,  3,  3,
-   -4, -3, -3, -1, -1,  1,  4,  5, -4, -3, -2, -2, -1,  1,  4,  7,
-   -2, -2, -1, -1,  0,  2,  6,  8, -1,  0,  0,  1,  1,  4,  7,  8,
-   -3, -3, -3, -2, -2, -1, -1,  0, -1, -1,  0,  1,  2,  2,  3,  3,
-    0,  1,  2,  4,  5,  6,  6,  5, -1,  0,  2,  3,  5,  6,  5,  3,
-   -1, -1,  0,  2,  3,  3,  2,  1, -2, -2, -1,  0, -1, -3, -4, -4,
-    0,  0, -1, -1, -2, -4, -8, -7,  1,  2,  1,  0, -1, -4, -6, -7,
-   -2,  4,  1, -6,  0,  3,  0,  0, -2,  5,  1, -7,  0,  3,  0,  0,
-   -3,  5,  1, -8,  0,  3, -1, -1, -2,  6,  1, -9,  0,  3,  0, -1,
-   -2,  6,  2, -8,  0,  4,  0, -1, -3,  5,  1, -7,  1,  4,  0,  0,
-   -2,  4,  1, -7,  0,  4,  1,  0, -1,  4,  1, -6,  0,  3,  1,  0,
-    0,  0,  0,  3,  4,  5,  4,  1,  1,  1,  1,  2,  3,  3,  2,  0,
-    2,  2,  1,  2,  2,  1, -1, -2,  4,  3,  1,  1,  0, -1, -3, -5,
-    5,  3,  1, -1, -2, -3, -4, -6,  5,  3,  0, -2, -3, -5, -6, -7,
-    4,  3,  0, -2, -3, -4, -5, -5,  4,  3,  0, -1, -2, -2, -3, -3,
-    0,  0,  0,  0, -1, -5, -2,  6,  0,  0,  0,  1, -1, -6, -2,  8,
-    0,  0,  0,  2,  0, -6, -3,  9,  0, -1,  0,  2,  0, -7, -2, 10,
-    0, -1,  0,  2, -1, -8, -3, 10,  0, -1, -1,  2, -1, -7, -3,  9,
-    0, -1,  0,  1, -1, -6, -3,  8,  0,  0,  0,  1,  0, -5, -2,  7,
-    2,  3,  3,  2,  1,  0, -1, -1,  3,  4,  3,  2,  1,  0, -1, -2,
-    3,  4,  4,  2,  1, -1, -2, -3,  2,  3,  3,  2,  0, -1, -2, -3,
-   -1,  0,  1,  1,  0, -1, -2, -2, -5, -4, -3, -1,  0,  1,  1,  1,
-   -8, -8, -5, -1,  1,  3,  4,  3,-10, -9, -5,  0,  3,  5,  6,  5,
-   -5, -1,  4,  5,  3,  1,  0,  0, -6, -1,  4,  5,  2,  0, -1, -2,
-   -6, -1,  5,  4,  2, -1, -2, -2, -7, -1,  4,  4,  1, -2, -3, -3,
-   -6, -1,  5,  4,  1, -2, -3, -3, -5,  0,  4,  4,  1, -1, -2, -2,
-   -4,  0,  5,  4,  1, -1, -1, -2, -3,  1,  4,  3,  1, -1, -1, -2,
-   -2, -3, -2,  1,  4,  6,  5,  3, -3, -4, -4,  0,  3,  5,  4,  2,
-   -3, -5, -5, -1,  2,  4,  3,  1, -4, -6, -4, -1,  2,  4,  2, -1,
-   -2, -4, -3,  1,  2,  4,  2, -1, -2, -4, -2,  1,  3,  3,  1, -2,
-   -2, -3, -2,  1,  3,  3,  1, -2, -2, -2, -1,  1,  3,  3,  0, -2,
-   -4, -4, -3, -2, -1,  2,  5,  7, -4, -4, -3, -3, -2,  1,  5,  7,
-   -2, -3, -2, -3, -3, -1,  3,  5, -1, -1,  0, -2, -3, -2,  2,  4,
-    1,  1,  1, -1, -4, -3,  1,  3,  4,  3,  2, -1, -4, -3, -1,  1,
-    6,  4,  3,  0, -3, -3, -2,  0,  6,  5,  3,  1, -2, -3, -2, -1,
-   12, 11,  8,  4,  0, -2, -2, -1, 10,  9,  6,  2, -1, -2, -1,  0,
-    4,  3,  2,  0, -1, -1,  0,  1, -1, -1, -1, -1, -2,  0,  1,  2,
-   -3, -5, -4, -2, -2,  0,  2,  3, -5, -5, -4, -2, -1,  0,  1,  2,
-   -5, -5, -4, -2, -1,  0,  1,  1, -4, -4, -3, -2, -2, -1,  0,  0,
-    3,  3,  2, -1, -3, -4, -3, -2,  3,  2,  0, -2, -4, -4, -3, -2,
-    2,  2,  1, -1, -3, -5, -4, -3,  3,  3,  3,  1, -2, -3, -3, -3,
-    4,  4,  4,  3,  0, -2, -2, -2,  5,  5,  5,  3,  0, -1, -2, -2,
-    5,  5,  4,  2, -1, -2, -3, -2,  3,  3,  3,  0, -2, -4, -4, -4,
-   -1, -1,  4, -2, -2,  6,  2, -5, -1,  0,  4, -2, -3,  6,  2, -6,
-   -1,  0,  4, -2, -3,  7,  3, -7, -1, -1,  4, -3, -4,  8,  3, -7,
-    0, -1,  4, -3, -4,  7,  3, -6, -1, -1,  4, -3, -4,  7,  3, -6,
-   -1, -1,  3, -3, -4,  6,  3, -6, -1,  0,  3, -2, -3,  6,  3, -5,
-    1, -2, -7,  2,  5, -2, -1,  1,  1, -2, -8,  3,  6, -3, -1,  2,
-    2, -2, -9,  4,  7, -4, -2,  2,  3, -1, -9,  5,  7, -4, -1,  3,
-    3, -1, -9,  4,  7, -4, -2,  2,  3, -1, -7,  4,  6, -4, -2,  1,
-    2,  0, -6,  4,  6, -4, -1,  1,  2,  0, -5,  3,  4, -3, -1,  1,
-   -2,  2,  2,  0,  0, -1, -3, -4, -2,  2,  2,  1,  1,  0, -2, -4,
-   -2,  2,  2,  2,  2,  1, -1, -2, -3,  2,  3,  3,  4,  2,  0, -2,
-   -3,  2,  3,  2,  4,  2,  0, -3, -4,  1,  2,  1,  2,  1, -1, -3,
-   -5,  0,  1,  0,  1,  1, -2, -3, -4,  0,  0,  0,  1,  0, -2, -3,
-    0,  0, -1, -2, -2,  2,  7,  8,  0,  0, -1, -3, -2,  1,  6,  7,
-    0,  1, -1, -3, -3,  0,  4,  5,  0,  1,  0, -1, -1,  0,  1,  3,
-    0,  2,  1,  1,  0, -1,  0,  1, -2,  0,  1,  2,  1,  0, -1, -1,
-   -5, -2,  0,  1,  1,  0, -3, -3, -6, -4, -1,  1,  1, -1, -3, -4,
-   -4, -2,  2,  5,  6,  4,  3,  2, -5, -3,  1,  4,  4,  2,  0,  0,
-   -4, -2,  0,  2,  1, -1, -2, -2, -2, -1,  0,  1,  0, -2, -3, -2,
-   -2,  0,  0,  0, -1, -1, -2, -1, -2, -1, -1,  0,  0,  0,  1,  2,
-   -2, -2, -1, -1,  0,  1,  3,  4, -2, -3, -2, -1,  0,  2,  4,  5,
-    2,  1, -2, -2, -1,  0,  1,  0,  1,  0, -3, -3, -1,  0,  1,  0,
-    0, -1, -3, -3, -1,  1,  1,  1,  0,  0, -3, -1,  1,  2,  3,  3,
-    0, -1, -3, -1,  1,  3,  3,  3, -2, -2, -4, -2,  1,  3,  4,  4,
-   -3, -3, -4, -2,  1,  3,  3,  4, -2, -3, -5, -2,  1,  2,  3,  3,
-    4,  5,  3,  4,  4,  4,  4,  5,  3,  3,  1,  0,  0,  0,  0,  1,
-    1,  1, -1, -2, -3, -4, -3, -2,  2,  2,  0, -2, -2, -4, -3, -2,
-    2,  3,  1, -1, -1, -3, -3, -2,  1,  2,  0,  0, -1, -2, -2, -1,
-    0,  1,  0, -1, -1, -3, -2, -1,  1,  1,  0, -1, -1, -2, -2, -2,
-   -2, -1, -1,  0,  1,  2,  1,  0,  1,  2,  3,  5,  6,  5,  5,  3,
-    1,  2,  3,  4,  5,  5,  4,  3, -2, -2, -3, -3, -2, -1,  0,  0,
-   -3, -3, -4, -5, -4, -3, -2, -1, -1, -1, -2, -2, -2, -1,  0,  0,
-    0,  1,  0, -1, -1,  0,  0,  1, -1,  0, -1, -2, -3, -2, -2, -1,
-    7,  7,  6,  5,  4,  2, -1, -2,  3,  3,  2,  2,  1,  0, -2, -3,
-    0, -1, -1, -1,  0, -1, -2, -2, -1, -3, -2, -1,  0,  0,  0,  1,
-    0, -2, -2, -1, -1,  1,  2,  2,  3,  1, -1, -1, -1,  1,  2,  2,
-    3,  1, -2, -3, -2, -1,  1,  2,  1, -2, -5, -6, -5, -3, -2,  0,
-    0, -1, -2, -3, -1,  0, -2, -2,  0,  0, -1, -1,  0,  1, -1, -2,
-    0,  0, -2, -1,  0,  0,  0, -2, -1, -2, -3, -3, -2, -1, -3, -3,
-   -1, -2, -3, -3, -2, -2, -3, -4,  2,  2,  0,  0,  0,  0, -1, -2,
-    5,  5,  3,  2,  2,  2,  0, -1,  8,  8,  6,  5,  4,  4,  2,  1,
-   -7, -8, -6, -3, -1, -1, -2, -1, -5, -5, -3,  0,  2,  1,  0,  0,
-   -1, -1,  0,  3,  4,  3,  1,  1,  2,  1,  1,  3,  4,  3,  2,  2,
-    3,  2,  0,  2,  3,  2,  1,  2,  4,  2, -1, -1,  0,  1,  1,  1,
-    3,  2, -2, -3, -2, -1,  0,  1,  3,  1, -3, -4, -3, -2,  0,  1,
-   -4, -2, -1,  2,  3,  3,  1,  0, -7, -5, -4, -2,  0,  0, -1, -2,
-   -6, -5, -5, -4, -2, -2, -2, -3, -1,  0, -1, -1,  0,  0,  0, -1,
-    2,  3,  2,  2,  2,  2,  1,  0,  3,  5,  4,  3,  1,  0,  1,  0,
-    3,  4,  3,  2,  0, -1, -1, -1,  5,  5,  3,  1,  0, -1, -1, -1,
-    1,  1,  0, -1, -3, -5, -6, -4,  1,  1,  0,  0,  0, -3, -3, -1,
-    0, -1, -1,  0,  1,  0,  1,  3, -2, -2, -3, -1,  2,  2,  4,  7,
-   -2, -2, -2,  0,  2,  2,  3,  6, -1,  0,  0,  1,  1,  0,  0,  3,
-    0,  3,  3,  3,  1, -2, -3, -1,  1,  3,  4,  3,  0, -3, -5, -4,
-    0,  2,  0, -1, -3, -4, -2, -2,  1,  4,  2,  0, -2, -3, -2, -1,
-    3,  6,  3,  1, -2, -2,  0, -1,  4,  7,  4,  1, -2, -3, -1,  0,
-    3,  6,  3,  0, -3, -3, -1,  0,  1,  3,  0, -1, -3, -2,  1,  1,
-    0,  1, -1, -2, -3, -1,  2,  2, -2, -1, -3, -3, -3, -1,  1,  2,
-    3,  1, -1,  0,  1,  0,  0,  0,  2, -1, -2, -1,  1,  0, -1, -1,
-    1, -1, -2,  0,  1,  0, -2, -3,  0, -2, -1,  1,  3,  1, -3, -5,
-    0, -2, -1,  2,  5,  2, -3, -5,  0, -2, -1,  4,  6,  3, -2, -5,
-    0, -2,  0,  4,  7,  4, -2, -4,  0, -2,  0,  4,  6,  4, -2, -4,
-   -2, -2, -3, -4, -3, -2, -1,  0,  1,  1,  0, -1, -1, -1,  0,  1,
-    3,  3,  2,  2,  1,  1,  1,  1,  2,  2,  2,  2,  1,  0,  0,  1,
-    0,  0,  0,  0, -1, -1, -1, -1, -4, -4, -4, -4, -4, -4, -4, -3,
-   -3, -3, -2, -3, -2, -1, -1,  0,  3,  4,  4,  5,  5,  6,  6,  7,
-   -1, -2,  7, -2, -4, -1, -1,  0, -1, -2,  9, -1, -4, -1, -1,  0,
-   -1, -3, 10, -1, -4, -1, -1,  1, -1, -3, 10, -2, -3, -1, -1,  2,
-   -1, -2, 10, -2, -4, -1, -1,  2, -1, -2,  9, -2, -4, -1, -1,  2,
-   -1, -2,  8, -2, -4,  0, -1,  1,  0, -2,  7, -2, -3, -1,  0,  2,
-    3, -4,  1,  3, -3, -2,  1,  0,  3, -5,  1,  4, -3, -2,  1,  0,
-    3, -6,  2,  5, -3, -1,  3,  0,  3, -6,  2,  5, -3, -1,  2,  0,
-    3, -6,  1,  5, -4, -2,  3,  0,  3, -6,  1,  5, -3, -2,  2,  0,
-    2, -6,  1,  4, -3, -1,  1,  0,  2, -6,  1,  4, -2, -1,  1,  0,
-    0,  0,  1,  1,  1,  0,  0,  2,  0, -1,  1,  1,  1,  0,  0,  2,
-    0, -1,  0,  0,  0,  0,  0,  2,  0, -1,  0,  0,  0,  0, -1,  0,
-    1,  0,  1,  0,  0, -1, -2, -1,  3,  1,  1,  0,  0, -2, -4, -3,
-    5,  3,  2,  1,  0, -3, -5, -4,  5,  4,  2,  0, -1, -4, -5, -5,
-    1,  0, -1, -2, -2, -3, -6, -9,  2,  0, -1, -1,  0,  0, -3, -6,
-    1,  0,  0, -1,  0,  0, -2, -5,  2,  1,  1,  1,  1,  2, -1, -3,
-    1,  1,  2,  1,  2,  2,  1, -1,  1,  1,  2,  1,  1,  1,  1,  1,
-    0,  0,  2,  1,  0,  0,  2,  2,  0,  1,  2,  2,  0,  0,  2,  2,
-   -4, -3,  0,  1,  4,  6,  4,  3, -3, -2,  0,  0,  2,  4,  1,  0,
-   -1, -1,  0,  0,  1,  1, -2, -3,  1,  1,  1,  0,  1,  1, -3, -5,
-    1,  1,  1,  0,  1,  1, -3, -5, -1,  0,  0, -1,  1,  1, -2, -4,
-   -1,  0,  0, -1,  1,  2,  0, -2, -1,  0,  0,  0,  2,  3,  1,  0,
-   -1,  0,  3,  4,  0, -4, -5, -5,  0,  0,  4,  5,  2, -2, -3, -2,
-    0, -1,  2,  4,  2, -1, -1,  0,  0, -2, -1,  1,  0, -2,  0,  1,
-    1, -2, -2,  0,  0, -1, -1,  1,  1, -2, -3,  0,  1,  0, -1,  0,
-    1, -2, -2,  1,  3,  1,  0,  0,  1, -2, -1,  2,  4,  2,  0,  0,
-    1,  2,  3,  2,  0,  2,  2,  1, -1,  0,  1,  0, -3,  1,  1,  1,
-   -1,  0,  0, -2, -4,  0,  2,  1, -1,  2,  2, -1, -5,  0,  2,  1,
-   -1,  3,  4, -1, -5,  0,  2,  1, -2,  2,  4,  0, -4, -1,  0,  0,
-   -4,  0,  2,  0, -4, -2,  0,  0, -5, -1,  2,  1, -2,  1,  3,  2,
-    1,  0,  1,  0,  1,  2, -1, -2,  2,  0, -1, -2,  1,  3,  0, -1,
-    3,  0, -2, -4,  0,  3,  1,  0,  5,  1, -3, -5, -2,  2,  1,  1,
-    6,  1, -2, -5, -2,  1,  0,  1,  5,  1, -1, -5, -2,  0, -1,  0,
-    3,  0, -2, -4, -2,  0, -1,  0,  1, -1,  0, -2,  0,  1,  0,  1,
-    1,  1,  2,  3,  2,  1,  1,  2, -1, -1,  0,  1,  1,  0,  1,  1,
-   -4, -3,  0,  0,  1,  1,  1,  2, -4, -3,  0,  2,  2,  2,  3,  2,
-   -5, -4,  0,  1,  1,  1,  1,  2, -5, -4, -1, -1, -2, -2, -1,  0,
-   -3, -2,  0,  0, -2, -3, -2, -1,  2,  3,  4,  4,  2,  0,  0,  0,
-   -4, -2,  0,  1,  0,  0,  0,  0, -3, -1,  1,  1,  0,  0,  0,  0,
-   -2,  0,  2,  2,  0,  0,  0,  2, -1,  1,  2,  1, -1,  0,  3,  5,
-    0,  2,  1, -1, -2,  0,  5,  6,  0,  1,  0, -3, -3,  0,  4,  6,
-    1,  1, -2, -4, -4, -3,  1,  2,  1,  0, -2, -4, -5, -4, -2,  0,
-   -1, -3, -3, -3, -3, -2, -1, -1,  3,  2,  1,  0,  0,  1,  1,  1,
-    5,  4,  3,  2,  1,  1,  2,  2,  2,  1,  0, -2, -2, -2, -1, -1,
-    0,  0,  0, -1, -2, -2, -2, -2,  0,  1,  3,  3,  2,  1, -1, -1,
-    0,  1,  3,  4,  3,  2,  1, -1, -4, -3, -1,  1,  0, -2, -3, -3,
-   -3, -4, -7, -8, -7, -4, -1,  2,  0, -1, -3, -4, -4, -2,  0,  2,
-    1,  0,  0, -1, -3, -2,  0,  2,  2,  1,  1,  0, -1, -1,  0,  2,
-    1,  1,  1,  1,  0,  0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,
-    0,  0,  1,  2,  3,  3,  2,  2,  0,  0,  1,  3,  4,  4,  3,  2,
-    3,  3,  3,  0, -1,  0,  1,  2,  1,  1,  1, -1, -2, -1, -1,  1,
-   -2, -2, -1, -3, -3, -2, -2,  0, -4, -4, -2, -2, -2, -2, -3,  0,
-   -4, -4, -1,  1,  1,  0, -1,  2, -3, -1,  2,  3,  4,  3,  3,  5,
-   -2,  0,  2,  3,  3,  3,  3,  3, -2, -2,  0,  0,  0,  0,  0,  1,
-    0,  2,  1, -1, -3, -1,  3, -2, -1,  0, -1, -1, -3,  0,  4, -2,
-   -2, -2, -2, -2, -2,  1,  5, -2, -3, -2, -3, -1, -2,  1,  4, -3,
-   -2,  0, -1,  0, -1,  0,  3, -5,  1,  2,  1,  2,  0,  0,  2, -5,
-    2,  4,  2,  3,  1,  1,  3, -3,  1,  2,  1,  1,  0,  1,  4, -2,
-    4, -3, -4, -1,  3,  3,  1,  3,  4, -4, -4, -1,  3,  2,  0,  2,
-    4, -3, -4,  0,  2,  2, -1,  1,  4, -3, -2,  1,  2,  1, -2,  0,
-    2, -4, -2,  1,  2,  0, -3,  0,  2, -3, -2,  0,  1,  0, -2,  2,
-    3, -1, -1,  0,  0,  0,  0,  3,  2, -2, -2, -2, -1, -1, -1,  2,
-    2,  2,  3,  4,  3,  1,  0, -1,  1,  0,  1,  2,  1, -1, -2, -2,
-    2,  1,  2,  1,  1,  0, -1, -1,  4,  3,  4,  3,  2,  1,  1,  1,
-    3,  2,  2,  2,  1,  1,  1,  1, -1, -2, -1,  0, -1, -1, -1, -1,
-   -3, -3, -2, -1, -2, -2, -2, -2, -4, -4, -3, -3, -4, -4, -3, -3,
-    2,  1, -1, -3, -4, -2,  3,  4,  2,  2,  1, -1, -3, -2,  1,  2,
-    1,  2,  3,  3,  0, -2, -1, -2, -1,  0,  2,  4,  2,  0, -1, -3,
-   -2, -2,  0,  3,  3,  2,  0, -3,  0, -2, -3, -1,  1,  2,  2, -1,
-    3, -1, -4, -5, -3,  0,  2,  0,  6,  3, -2, -6, -5,  0,  3,  1,
-   -2,  3, -2,  0,  3, -2, -2,  1, -3,  4, -3,  0,  3, -2, -1,  2,
-   -3,  5, -3,  0,  4, -2, -1,  2, -2,  4, -4, -1,  3, -3, -2,  2,
-   -3,  4, -3,  0,  3, -3, -1,  2, -2,  5, -2,  0,  3, -3, -1,  2,
-   -2,  4, -3,  1,  3, -2, -1,  2, -2,  3, -2,  1,  3, -2,  0,  2,
-    1,  0,  0, -1,  1,  2, -4, -1,  2,  0,  0, -1,  1,  2, -4, -2,
-    1,  1,  1, -1,  2,  4, -2,  0,  0, -1,  1, -1,  2,  5, -1,  1,
-    0, -1,  0, -2,  1,  5, -1,  1,  0, -1, -1, -2,  0,  3, -3, -1,
-    1,  1,  0, -2,  0,  3, -3, -1,  1,  1,  0, -3,  0,  3, -2,  0,
-    1,  0, -1,  1,  1,  2,  4,  5,  1,  0, -1,  1,  1,  1,  5,  7,
-    0,  0, -2, -1, -1,  0,  3,  5,  0, -1, -2, -1, -1, -1,  2,  3,
-    0, -1, -3, -1, -1, -1,  1,  2, -1, -2, -4, -2, -2, -2,  0,  0,
-   -1, -2, -2, -1, -2, -2,  0,  0,  0, -1, -1,  0, -1, -1,  0,  0,
-    3,  3,  0, -1, -1,  1,  4,  4,  2,  3,  0, -2, -2,  0,  1,  1,
-    2,  3,  1, -1, -1,  0,  1,  0,  1,  2,  0, -1, -1, -1,  0, -2,
-    0,  1,  0, -1, -2, -1,  0, -2,  0,  1,  0, -1, -2, -1,  1,  0,
-    1,  1, -1, -3, -4, -3,  1,  3,  1,  2, -1, -3, -5, -4,  1,  3,
-   -3, -2,  0,  1,  1,  1,  0, -2,  0,  1,  1,  1,  0,  0, -1, -3,
-    1,  2,  1,  1,  0, -1, -1, -2,  0, -1, -3, -1, -1, -1,  0, -1,
-    0, -3, -6, -3, -2, -1,  1,  1,  2, -1, -4, -3, -2,  0,  2,  2,
-    5,  4,  1,  1,  0,  1,  3,  2,  5,  4,  2,  1,  0, -1,  0,  1,
-   -2,  0, -2, -5, -6, -3,  0,  0, -2,  0,  1,  0, -1,  1,  2,  2,
-   -2,  0,  1,  3,  2,  2,  2,  1, -2,  0,  2,  4,  3,  2,  1,  1,
-   -2,  0,  2,  3,  2,  0, -1,  0, -3, -1,  1,  1,  0, -1, -1,  1,
-   -4, -1,  1,  0, -1, -2,  0,  2, -4, -1,  0, -1, -1, -2,  1,  4,
-   -3,  0,  0, -1,  1,  1,  1,  0, -3,  1,  0, -1,  0,  0, -1, -1,
-   -1,  3,  3,  0,  1,  0,  0,  1, -3,  2,  2, -2, -1,  0,  0,  1,
-   -5,  0,  0, -2, -1,  1,  0,  2, -7, -2,  1,  0,  1,  2,  2,  2,
-   -5,  0,  3,  2,  3,  3,  2,  2, -3,  2,  4,  1,  0,  0, -2, -3,
-    5,  2, -2, -2,  0, -1, -1, -1,  2, -1, -4, -3, -1, -2, -1, -1,
-    0, -2, -2,  1,  2, -1,  0,  1, -1, -2, -1,  3,  3, -1,  0,  2,
-    1,  0,  0,  3,  3, -2, -1,  2,  2,  1,  1,  3,  2, -2, -2,  0,
-    1,  0, -1,  1,  1, -3, -3, -2,  1,  0,  1,  2,  3,  0,  0,  0,
-   -4, -5, -3,  0,  1, -1, -2, -1, -2, -3, -1,  1,  2,  0,  0,  0,
-    1,  1,  2,  1,  2,  1,  1,  1,  3,  4,  3,  1,  0, -2, -1, -1,
-    3,  3,  2,  0, -2, -3, -3, -2,  1,  1,  0, -1, -2, -4, -2, -2,
-    2,  1,  0,  0,  0, -1,  0,  1,  2,  1,  1,  1,  1,  1,  1,  3,
-    0,  0,  0, -1, -2, -1,  1,  0, -2, -1, -1, -2, -3, -2,  0,  0,
-   -1,  0,  0, -1, -2,  0,  1,  1,  1,  1,  0, -1, -1,  1,  3,  1,
-    2,  2,  0, -2, -1,  2,  3,  0,  3,  1, -1, -1,  1,  4,  2, -2,
-    2,  0, -3, -1,  3,  5,  0, -5,  1, -1, -2,  0,  3,  3, -1, -6,
-   -1,  0,  3,  4,  2,  0,  1,  2, -2, -1,  0,  1, -1, -2,  0,  1,
-   -2, -3, -2, -3, -6, -7, -6, -3,  2,  2,  3,  1, -1, -2, -3, -2,
-    2,  2,  3,  1,  0,  0,  0,  0,  2,  1,  1,  0,  1,  1,  0,  1,
-    1,  0,  0,  0,  0,  1,  1,  2,  1,  0, -1,  0,  0,  2,  2,  1,
-    1,  1,  3,  1, -1, -1, -1,  1, -2, -1,  0,  0, -2, -2, -1,  2,
-   -2, -2,  1,  1,  1,  0,  1,  3, -2, -2,  0, -1,  0, -1,  0,  2,
-    0,  0,  1,  0, -1, -1, -2,  1,  3,  2,  2,  1,  0, -2, -2,  1,
-    5,  3,  3,  2,  1,  1,  1,  4,  0, -3, -4, -5, -4, -3, -1,  1,
-   -6, -4, -1,  2,  2,  0,  0, -1, -4, -2,  1,  3,  3,  2,  2,  0,
-   -3, -2, -1,  2,  3,  3,  2,  0, -3, -2, -2,  1,  2,  1,  1, -1,
-   -2, -2, -2,  0,  2,  2,  1, -1, -1, -1, -1,  1,  2,  3,  2,  0,
-   -1, -1, -2,  1,  2,  2,  2, -1,  0, -1, -2,  0,  2,  1,  0, -1,
-    6,  4,  2,  1,  0,  0,  0,  1,  4,  2, -1, -2, -2, -2, -1, -1,
-    2,  1, -1, -2, -2, -2, -2, -1,  2,  2,  0, -2, -2, -2, -1,  0,
-    0,  0, -1, -2, -2, -1,  0,  1, -3, -3, -2, -1, -1, -2, -1,  0,
-   -3, -2,  2,  3,  2,  0, -1, -2, -2,  0,  4,  5,  5,  2,  0, -1,
-    5,  4,  2,  0, -1, -2, -1, -1,  4,  3,  2,  1,  0, -1,  0, -1,
-    1,  1,  0,  1,  1,  0,  1, -1, -2, -1, -1,  0,  0, -2, -2, -3,
-   -1,  0,  0,  0, -1, -3, -3, -5,  0,  1,  1, -1, -1, -2, -2, -3,
-   -1, -1, -1, -2, -1,  1,  3,  1, -1, -2, -2, -1,  2,  5,  6,  5,
-   -3, -3, -2,  1,  1, -2, -1, -1,  1,  2,  3,  4,  1, -3, -1, -3,
-    3,  2,  0,  1, -1, -3, -1, -3,  1,  0, -1,  0, -1, -1,  1,  0,
-    1,  1,  0,  1,  2,  2,  5,  3,  1,  1,  1,  2,  2,  2,  3,  0,
-   -3, -1, -2, -2, -3, -3, -1, -3, -1,  1,  1,  0, -1, -1,  0, -2,
-    2,  0, -2, -2,  2,  4,  1, -2,  1,  0, -2, -1,  3,  5,  2, -1,
-   -1, -2, -3, -2,  1,  3,  1, -2, -1, -2, -1, -1,  0,  2,  1, -1,
-    0,  0,  1,  1,  1,  2,  2,  0,  0,  1,  4,  4,  2,  2,  3,  1,
-   -2, -1,  2,  1, -2, -3, -2, -3, -1,  0,  1,  0, -3, -4, -4, -5,
-    4,  0, -3, -4, -4, -4, -2, -1,  5,  0, -1,  0, -1, -3, -2, -1,
-    4,  0,  0,  1,  1,  0,  0,  0,  0, -3, -2, -1,  0,  0,  1,  0,
-    0, -2,  0,  0,  1,  1,  2,  1,  2,  0,  0,  0,  1,  1,  1,  0,
-    2,  0, -1, -1,  1,  1,  1,  0,  1, -1, -2, -2,  0,  2,  2,  2,
-   -3, -5, -2,  0, -1, -3, -3,  0,  0, -2,  0,  2,  2,  0,  0,  3,
-    2, -1, -2,  0,  0, -1, -1,  2,  5,  2, -1, -1, -1, -1, -1,  2,
-    5,  2,  0, -1, -1,  0, -1,  2,  2,  1,  0,  0,  0,  1,  0,  2,
-   -1, -1,  1,  1,  2,  2,  1,  2, -3, -2,  0,  0,  0,  0, -2, -1,
-    0,  3,  2,  0, -2, -3, -3, -3,  0,  3,  3,  1,  0,  0,  1,  2,
-   -1,  0, -1, -2, -1, -1,  1,  3, -1,  0, -1, -2, -1, -1,  0,  2,
-   -1,  0, -1, -2,  0,  0, -1,  2, -1,  0, -1, -2, -1, -1, -2,  1,
-    0,  1,  0, -3, -1, -1, -1,  2,  5,  5,  2, -1, -1, -1,  1,  3,
-    0,  0,  1, -1, -3, -2,  0,  2,  1,  1,  3,  0, -2, -2,  0,  1,
-    1,  1,  3,  1,  0,  0, -1, -1,  0, -1,  2,  1,  1,  0, -1, -3,
-   -1, -2,  1,  1,  1,  0, -2, -4, -1,  0,  2,  1,  1,  0, -1, -3,
-    1,  1,  3,  2,  1,  0, -2, -3,  2,  2,  4,  2,  1, -1, -2, -4,
-    1,  2,  2,  2,  0, -2,  0,  2, -1, -1, -2, -3, -4, -5, -3,  1,
-    0,  1,  1,  0, -1, -1, -1,  1,  0,  1,  1,  1,  0,  0,  0,  2,
-    0,  1,  1,  2,  1,  1,  1,  2, -1, -1,  0,  2,  2,  2,  2,  3,
-   -2, -4, -4, -1, -2, -2, -2,  0,  1,  0,  0,  1,  0,  0,  0,  1,
-    0, -1, -3, -2,  0,  2,  2,  1,  0, -1, -2, -3,  0,  1,  1,  2,
-    1,  0, -2, -3, -1,  0,  0,  1, -1,  0, -1, -2,  0,  0, -1,  0,
-   -1,  1,  1,  0,  2,  2,  0,  0,  0,  2,  3,  1,  3,  5,  3,  2,
-   -1,  1,  1, -2,  0,  3,  1,  1, -1,  0,  0, -4, -4, -1, -1, -1,
-   -1,  1,  1,  0,  1,  2,  1,  2, -3,  0,  1,  0,  1,  1,  0,  2,
-   -5, -3, -1, -1,  0,  1,  0,  1, -4, -3, -2, -3, -2, -1, -1,  0,
-    0,  0, -1, -2, -2, -2, -2,  0,  3,  4,  2,  0,  0,  0,  0,  1,
-    2,  1,  0,  0,  0,  0, -1,  0,  0,  1,  2,  3,  4,  4,  3,  2,
-   -1,  4,  7,  4,  0,  0,  0,  0, -1,  4,  6,  3,  0,  1,  1,  1,
-    0,  3,  4,  0, -1,  0,  0,  1,  0,  1,  1, -2, -1,  0, -1, -1,
-   -1,  0, -1, -1, -1,  0,  0,  0, -1, -1, -1,  0,  0,  0,  0,  0,
-   -1, -3, -3,  0,  1, -1, -2, -1, -3, -4, -4, -2, -1, -2, -2, -1,
-    2,  2,  1,  0,  1,  1,  0, -3, -2, -1,  0,  0,  1,  1,  0, -3,
-   -2, -1,  0,  1,  2,  1,  1, -2,  1,  2,  2,  2,  3,  3,  2, -1,
-    1,  2,  1,  0,  1,  1,  2, -1,  0,  1, -2, -4, -2,  0,  1, -1,
-    1,  1, -1, -3, -2,  0, -1, -3,  1,  2,  0, -1,  0,  1, -1, -4,
-   -1, -1, -2, -2,  0,  3,  4,  3,  1,  1, -1, -3, -2,  0,  0,  0,
-    2,  2,  2,  2,  2,  1, -1, -1,  1,  1,  1,  3,  3,  0, -2, -2,
-    0, -1, -1, -1,  0, -2, -1, -1, -1, -3, -4, -3, -2, -2,  0,  2,
-   -1, -1,  0,  1,  2,  2,  3,  5, -2, -1, -1,  0,  0,  0,  0,  1,
-   -2, -3,  2,  0,  0,  1,  1, -1, -1, -4,  1, -2, -1,  2,  2,  0,
-    1, -4,  0, -2, -2,  1,  1, -1,  2, -3,  1, -1, -1,  1,  1, -1,
-    3, -2,  3,  1,  0,  1,  1, -1,  1, -3,  2,  1,  0,  1,  0, -1,
-   -1, -5,  1,  0, -1,  0,  1,  1,  0, -3,  3,  3,  1,  2,  3,  3,
-    0, -1, -2,  1,  5,  5,  2, -1,  1, -1, -2, -1,  1,  1, -2, -5,
-    1,  1, -1, -2, -1, -1, -1, -3,  1,  1, -1, -1, -1,  2,  4,  3,
-   -1, -1, -1, -1, -1,  0,  4,  3, -1, -1,  0,  1, -1, -3, -1, -1,
-    0,  0,  0,  2,  2,  0,  0, -1,  0, -2, -3,  0,  1,  1,  3,  2,
-    2,  3,  2,  1,  0,  0, -2, -2,  2,  3,  0,  1,  1,  3,  3,  2,
-    0,  0, -3, -1, -1,  2,  2,  3, -2, -2, -3,  1,  1,  2,  1,  1,
-   -2, -1, -2,  2,  1,  1, -1, -2,  0,  1,  0,  2,  0,  0, -2, -2,
-    0,  1,  0,  2,  0,  0, -2, -2, -3, -2, -2,  0, -1, -2, -2, -3,
-    0,  1, -1,  3, -1,  1,  3, -1,  0,  1, -1,  3, -1, -1,  2, -3,
-    1,  1, -2,  3, -1, -3,  0, -3,  2,  2, -2,  3,  0, -2,  1, -2,
-    1,  1, -3,  3, -1, -2,  1, -3,  1,  1, -3,  3,  0, -1,  1, -2,
-    1,  2, -1,  4,  0, -1,  1, -2,  0,  1, -1,  3, -1, -3,  0, -3,
-   -3, -3, -1,  1,  2,  1, -1, -2, -2, -2,  0,  2,  1,  0, -2, -2,
-   -3, -2,  1,  2,  1, -1, -2, -1, -3, -2,  2,  4,  0, -2, -2,  1,
-   -3, -1,  2,  4,  0, -2, -2,  2, -1,  1,  4,  3, -1, -3, -2,  2,
-    0,  2,  4,  2, -1, -2, -1,  2,  0,  1,  2,  0, -1,  0,  1,  3,
-    3,  0, -5,  1,  4,  0,  0,  1,  1, -2, -5,  2,  5, -1, -2,  1,
-   -1,  0,  0,  3,  3,  1,  0, -1, -2,  3,  4, -2, -3, -1,  0, -2,
-   -3,  3,  5, -3, -3,  0,  0, -2, -1,  3,  2, -2, -2,  2,  2, -1,
-    2,  0,  0, -1,  0,  0,  0,  0,  0, -3, -2,  1,  3,  0, -2, -2
-};
-
-/* list of codebooks for inter-coded vectors */
-static const int8_t* const svq1_inter_codebooks[4] = {
-    svq1_inter_codebook_4x2, svq1_inter_codebook_4x4,
-    svq1_inter_codebook_8x4, svq1_inter_codebook_8x8
-};
-
-static const int8_t svq1_inter_codebook_sum[4][16*6] = {
- {
- -1,  1, -2,  0,  1, -1, -1, -1, -2, -1,  1, -1, -1,  0, -1, -1,
-  0, -1, -1, -1, -1,  0, -1,  0,  0,  0, -3,  1, -1,  0,  1, -1,
-  1, -1,  2,  2,  1,  1,  2,  0,  0,  0, -1,  1,  1,  0,  0,  0,
-  1, -1,  0,  1, -1,  1,  1,  0,  1,  0, -1,  1,  1,  0,  0,  0,
- -2,  0,  0, -2,  0,  0, -2,  0, -2, -1, -2, -1,  0,  0, -1,  0,
-  1,  0,  1, -1,  2,  2,  1,  2,  2,  1,  0,  1,  1,  0,  1,  1,
- },{
- -2,  1, -1, -1,  1,  0,  1, -1, -1, -1,  1, -1,  0, -1,  0, -1,
-  0,  0,  0, -2,  0,  1,  0, -1, -1,  0,  2, -3,  1, -2,  3, -1,
-  2,  0,  2,  1,  1, -1,  1,  1,  0,  0,  1,  1,  2, -2,  1,  0,
- -2, -1,  2, -2, -2,  0, -3,  0, -1,  0, -1,  0, -1,  0, -2, -3,
-  1, -2, -2, -1,  1, -1, -1,  1, -1,  1,  1,  0, -2,  0,  1,  1,
-  1,  1,  2,  1,  0,  0, -1,  0,  0,  1,  0,  1, -1,  1,  0,  2,
- },{
-  0,  0,  0, -3,  1,  1,  1, -3,  0, -1,  0, -3,  1, -3,  0, -2,
-  1,  2, -1, -3,  0, -3,  1, -1,  0, -1,  0,  0,  1,  2,  1,  1,
- -1,  2, -3,  3,  1,  0, -5,  1,  0, -1, -3,  1,  0,  2,  0, -3,
-  4,  2,  0, -2,  1, -2,  3, -2,  1,  1,  0, -1,  2,  5,  3,  1,
- -1,  0,  2, -3, -2,  0,  0, -2,  2, -3, -1, -1,  2,  1,  0, -2,
-  3, -1,  1, -1,  2,  4,  0,  1,  0,  1,  0, -1, -3, -2, -1,  0,
- },{
-  0,  2, -1, -1,  2, -4, -2,  3,  0, -1, -5,  1,  0,  1,  0,  6,
- -2,  2,  0,  1,  1, -1, -1, -2,  1, -2, -1,  0,  2, -2, -2, -1,
- -4,  2, -1, -3, -1, -2,  2, -1,  2, -1,  2,  0,  3, -3, -3,  0,
- -3,  0,  0, -2,  4, -4,  0, -1,  4,  0, -2, -2,  3, -2,  0,  4,
-  5,  0,  1,  0, -3,  3,  3,  2,  0,  0,  1,  2, -5, -2, -3,  0,
- -3,  2, -2,  2, -2,  4,  7, -3,  4,  2,  3,  2, -1,  0, -3,  1,
- }
-};
-
-/* 6x16-entry codebook for intra-coded 4x2 vectors */
-static const int8_t svq1_intra_codebook_4x2[768] = {
-   12, 13, 13, 11, -7,-10,-15,-17,-16,-15,-12,-10, 11, 15, 15, 12,
-    2, 17, 20, 15,-45,-24,  2, 13, 21, 20, -6,-36, 12, 16, -1,-27,
-  -18,-21, 10, 45,-11,-20, -7, 21, 43, -8,-28,  0, 33,-16,-28,  3,
-  -12,-18,-18, -6,-20,-10, 28, 55, -5,-18,-21,-18, 56, 30, -6,-20,
-  -34, 27, 29,-22,-30, 29, 26,-25, 30, 34, 33, 26,-25,-31,-35,-33,
-  -31,-35,-36,-32, 29, 36, 37, 31,-71,-12, 38, 34,-63, -1, 42, 33,
-   58, 37,-31,-60, 55, 34,-33,-61,-57,-57, 22, 93,-57,-58, 21, 93,
-   59, 69, 70, 62,-63,-68,-68,-60,-64,-71,-71,-64, 63, 73, 72, 62,
-   -2,  0,  7, 15,-11,-10, -3,  5, -5, -8,-10,-10,  1,  9, 14,  9,
-   15,  8, -4,-11, 12,  2,-11,-12, -8,  0, 19, 28,  4, -1,-15,-26,
-  -15, 27,  2,-14,-14, 22,  1, -9, -4, -6,-13,-10, -6,-14,  6, 47,
-  -35,-20,  6, 23,  6,  9,  6,  4, -6,  2, 23,-22, -7,  4, 28,-21,
-   20,-22, -2,  6, 22,-28, -5,  8,-10,-18,-16,-12, 36, 19,  2, -1,
-   -3,  0,  4,  8,-45,-10, 23, 23, 40, 15,-20,-35, -4, -1,  4,  1,
-    9, -5,-33, 24,  8,  3,-26, 19, -1,  4,  6, -3, 32, 25,-13,-49,
-   24, 24, 15,  7,-17,-27,-19, -7,-47,  0, 39, 24,-21, -6,  7,  4,
-   -1,  0,-10,-13,  1,  1,  5, 16, 20,  5, -3, -9, -1, -4, -2, -6,
-  -17, -7,  1,  4, 12,  7,  0,  0,  3,  0, 12, 11, -3,  1,  0,-23,
-    4, 17, -6,  0,  6,  3,-25,  0,-17, 10,  8,  5,-14,  4,  1,  4,
-   13, 10,  4,  2,-23, -9,  1,  2,  3, -3,  1,  7,  1,-23, -7, 20,
-   -7,-18,  2, 12, -5, -4, 10,  9,  4, 10,  7,-24,  6,  3,  4,-10,
-   22,-14,-22,  6,  0,  5,  5, -1, -4,  3,-11, -4, -7, 31,  7,-14,
-   -5,-16, -1, 42, -4, -2, -9, -5,  5, -8, -6, -3, 42, -4,-21, -5,
-  -18, 12, 20,-12, 13,-13,-10,  7, -8, -9, -2,-18,-16,  6, 40,  8,
-   10, -1,  0,  4, -3,  4, -1,-13, -2,  6,  1,-15,  5,  3,  1,  2,
-   -4, -2,  1,  3, 15,  0, -9, -4, -3, -4, -4, -4, -3,  5, 16, -3,
-    2, 13,  3,  4, -3, -8,-10,  0, -6, -2, -4, -1, -2, -3, -6, 23,
-    6, -6,  7,  1,  4,-18,  5,  1, -1,  1,-15, 14, -5,  6, -4,  4,
-    2,  2,  2,  6,-24,  2,  7,  3,-26,  0,  3,  3,  5,  7,  1,  6,
-   14, -2,-18, -3,  7,  5, -4,  2, -6,  3, 32,  1, -6, -6, -6,-12,
-    5,-36,  7,  6,  9, -1, 11,  0,  4,  4,  5,  3,  4, 15,  3,-38,
-   10, 23, -5,-42,  0,  4,  4,  4, 23, 17, -6,-13,-13,-37,  1, 29,
-    5,-14, -1,  1,  5,  0,  3,  1,  0,  4, -5,  2,  8,  0,  0,-10,
-    4,  7, -2, -3,-10,  3,  1,  1,-12, -1, 13,  3,  0, -1,  1, -3,
-    0, -1,  3,  1, -6, -9,  3,  9, -6,  1, -4, -6,  8, -1,  0,  8,
-   -3, -3,  0, 18, -5, -1, -4, -1, -8, -2,  3, -4,  0, 17, -1, -5,
-    5, -2,  9,-10,  1, -5,  6, -5,  4,  2,  2,  3, 10,-14, -8,  1,
-   -1, -2,-18, -1, -1, 20,  1,  2, -1,  1, -9,  1, -1, -9, 22, -4,
-    6, -4,  8, -3, -1,  7,-19,  5, -7, 31, -4, -4, -6,  0, -5, -5,
-   -7, -8,-19, -4,  1,  1,  4, 32, 38, -1, -8,  4, -7, -8, -6,-12,
-   -1,  0, -7,  1, -1,  9, -1,  0,  9, -1, -1,  0,  2, -6,  1, -3,
-  -12,  0,  2,  1,  1,  1,  8,  0,  9,  1,  0,  2, -2,  1,-11,  0,
-    0,  8,  2,-10, -1,  2, -1,  0, -2, -4,  0, -5, -2, -1, -1, 14,
-   -3,  7, -1,  5,  0,-10,  1,  1, -1, -5, 14, -1, -2,  1, -3, -2,
-   -6,  0,  0,  6,  2,  3, -9,  4,  4, -5, -1, -1, -7,  3,  8, -1,
-    2, -4, -1,-11, 11,  2,  1,  0, -1,  2,  3,  9,  0,  2,  0,-15,
-    3,  5,-20,  3,  3, -1,  3,  3,  1, -1, 16,  1,  2,-29,  9,  2,
-  -13, -6, -1, -3, 36, -1, -8, -3,  2,  5,  4,  2,-37,  9, 11,  3
-};
-
-/* 6x16-entry codebook for intra-coded 4x4 vectors */
-static const int8_t svq1_intra_codebook_4x4[1536] = {
-  -11, -3,  3,  6,-10, -1,  5,  7, -9, -1,  6,  7, -9, -1,  4,  6,
-    5,  7,  0,-14,  6,  9,  2,-15,  6,  9,  2,-15,  4,  6,  0,-14,
-   16,  3, -5, -6, 16,  1, -8, -8, 14, -1, -9, -9, 12,  0, -8, -8,
-    8, 12, 16, 17, -2,  2,  6,  9,-10, -8, -4,  0,-15,-14,-11, -7,
-   -7,-10, -2, 16, -7,-11, -3, 18, -7,-11, -1, 20, -6, -8,  1, 19,
-   -9,-13,-16,-17,  2, -2, -7, -9, 11,  8,  4, -1, 16, 15, 11,  7,
-  -22, -2, 13, 15,-24, -2, 14, 16,-25, -4, 13, 15,-25, -6, 10, 13,
-   26, 26, 22, 16, 17, 15,  9,  3, -2, -6,-11,-14,-20,-25,-28,-28,
-  -27,-27,-25,-21,-16,-15,-11, -7,  3,  8, 12, 13, 23, 28, 31, 30,
-   20, 16, -7,-33, 22, 19, -6,-35, 22, 19, -6,-34, 20, 17, -6,-32,
-  -20,-20,  2, 38,-21,-22,  2, 40,-21,-22,  2, 40,-20,-20,  3, 38,
-  -47, -4, 24, 26,-50, -3, 26, 27,-50, -3, 26, 27,-47, -4, 24, 26,
-   45,  6,-23,-27, 48,  5,-25,-28, 48,  5,-26,-28, 44,  6,-24,-27,
-  -30,-36,-10, 76,-31,-37,-11, 78,-31,-37,-11, 78,-31,-36,-10, 77,
-  -53,-32, 35, 52,-54,-34, 36, 52,-54,-34, 36, 52,-53,-33, 34, 51,
-  -93,-34, 62, 65,-93,-34, 62, 66,-93,-34, 62, 65,-93,-34, 60, 64,
-   -7,  0,  2,  2, -8, -1,  3,  3, -8,  0,  4,  5, -6,  1,  5,  5,
-    3,  7, 11, 11,  2,  2,  3,  3,  1, -2, -6, -7,  1, -5,-11,-13,
-    3, -2, -4, -3,  7,  0, -5, -5, 12,  4, -5, -7, 14,  6, -4, -7,
-   18, 14,  3, -2,  6,  4,  0, -3, -8, -5, -2,  0,-16,-11, -2,  2,
-   -8, -6,  7, 18, -7, -8,  2, 13, -4, -6, -2,  6,  0, -4, -3,  1,
-    1, -3,-13,-18,  0, -1, -5, -7, -1,  1,  6,  7, -2,  4, 15, 17,
-  -15,-14, -7, -2, -6, -5, -1,  0,  6,  6,  3,  1, 15, 13,  6,  1,
-    2, -2,-11, 10,  2, -1,-12, 11,  3, -1,-12, 11,  2, -2,-11, 11,
-   -9, 14, -1, -5, -9, 15, -2, -5, -8, 16, -2, -5, -7, 15, -1, -4,
-    2,  6,  8,  8, -2,  3,  9, 12,-11, -5,  4, 10,-19,-16, -8,  0,
-   14,  8, -7,-15, 12,  7, -7,-14,  8,  5, -4, -9,  5,  3, -1, -4,
-   12,-14, -2,  2, 13,-15, -1,  3, 14,-15, -1,  3, 13,-14, -1,  3,
-    0,  6, 10,-13,  0,  6, 10,-15,  0,  7,  9,-17,  1,  6,  8,-16,
-   -8, -5, 15, -2, -8, -6, 17, -2, -8, -6, 16, -3, -8, -5, 15, -2,
-   -9,-11,-11,-10,  9, 10,  9,  8,  8, 10, 10,  9, -8, -9, -8, -7,
-    9, 10,  9,  7, -8,-10,-10,-10, -7,-10,-11,-11, 11, 12, 11,  8,
-    0, 10,  7,  0,  0,  7,  0, -6,  0,  2, -5, -6, -2, -1, -4, -1,
-    5,  0, -6, -9,  2,  2,  2,  1, -2,  0,  5,  7, -6, -5,  1,  4,
-    3, -8,  2, -1,  4, -9,  3,  0,  5, -7,  3,  0,  7, -5,  3,  0,
-   -5, -3,  2,  9, -6, -3,  1,  8, -6, -3,  1,  7, -5, -2,  0,  4,
-   13,  8,  3,  1, -3, -5, -4, -1, -8, -7, -3,  0, -1,  1,  3,  2,
-    3,  2, -5,-12,  4,  3, -2, -9,  3,  4,  1, -4,  3,  5,  4, -1,
-   -9, -8, -4,  0,  8,  6,  2,  0, 10,  8,  3,  0, -6, -5, -3, -1,
-   -3, -9,-12, -5,  0, -3, -5,  0,  2,  3,  2,  4,  5,  8,  7,  6,
-   -1, -2,  5, 12, -1, -1,  5,  9,  2,  1, -1, -2,  2, -1,-11,-17,
-   -7,  3,  3, -1, -9,  3,  4, -1,-10,  4,  6, -1, -9,  5,  7,  0,
-  -18, -7,  2,  2, -8,  1,  5,  3,  3,  4,  1,  0,  9,  5, -2, -3,
-   -2,  0,  6,  8, -4, -5, -5, -3,  1, -2, -6, -8, 10,  9,  3, -1,
-    0, -2, -2,  0,  0, -4, -5,  0, -2, -8, -4,  8, -5, -7,  6, 24,
-    9,  1, -7,  1,  9,  1, -8,  1,  8,  0,-10,  1,  8, -1,-11, -1,
-    8,  8,  6,  3,  5,  4,  3,  2, -2, -3, -1,  0,-10,-13, -8, -4,
-    0,  4,  2, -3,  0,  6,  3, -5,  3, 10,  2,-12,  5, 10, -4,-22,
-    0, -4, -1,  3,  1, -4, -1,  5,  1, -5,  0,  8, -1, -6, -2,  7,
-   -1, -1, -2, -4, -1, -2, -4, -6, -1, -1, -1, -2,  1,  5, 10,  9,
-   10,  3,  0, -2,  6, -1, -2, -5,  3, -1, -2, -6,  2,  0,  0, -5,
-    6,  3,  0,  0,  6,  3,  1,  1,  4, -2, -2,  1,  0, -9, -9, -2,
-  -11, -3,  1,  2, -6,  2,  4,  5, -3,  2,  3,  4, -2,  1,  1,  2,
-   -6, -4, -1, -2,  2, -1, -1, -2, 10,  2, -2, -2, 11,  2, -4, -1,
-    6,  0, -2,  2,  3,  3,  0,  0, -6,  3,  3,  0,-17, -1,  5,  0,
-   -1,  4, 10, 11, -3, -2,  0,  1, -3, -4, -5, -3, -1, -2, -2, -1,
-    2, -3, -9,-12,  3,  3,  3,  2,  2,  2,  4,  4,  2,  1, -1, -2,
-   -2,  9,  5,-10, -3,  5,  5, -5, -2,  1,  2,  0, -1, -2, -2,  1,
-   -2, -3,  7, -2, -1, -3,  7, -3, -1, -2,  8, -4, -2, -2,  7, -3,
-    1, -8, -3, 12,  2, -2, -2,  4,  1,  3,  0, -5, -1,  5,  2, -7,
-   -1,  3,  1, -5, -7, -2,  3,  1, -2, -7, -2,  2, 20,  3, -5, -1,
-    5,  0, -3, -2, -7, -7,  0,  6, -6,  0,  7,  6,  2,  6,  0, -7,
-   -2,  6, -7,  1, -2,  7, -8,  3, -2,  7, -7,  3, -1,  7, -6,  2,
-   -5, -2,  5,  7,  4,  1, -4, -8,  6,  3, -2, -5, -7, -5,  3,  7,
-   -1, -1,  6,  5,  0, -1,  1, -4,  2,  1,  0, -7,  1,  0,  0, -4,
-   -8,  0,  3,  1, -2,  1, -1, -1,  1, -1, -3,  1,  1, -2,  1,  9,
-    5,  2, -3, -4, -1,  0, -1, -3, -3,  1,  3,  1, -4,  0,  4,  2,
-    2, -2, -2, 12,  0, -2, -5,  3, -1,  0, -3,  1, -3, -1, -2,  1,
-    1,  5,  3,  0, -6, -4, -2,  1,  0, -2, -2,  2,  6,  1, -4, -1,
-   -3, -5, -5, -1,  3,  5,  5,  4,  0,  3,  1, -1, -2,  1, -2, -3,
-    2, -4, -5, -3,  4, -2, -3, -2,  6,  0, -1, -1,  7,  1,  0,  0,
-   -3, -2, -2,  0, -2, -3, -5, -1, -2,  2,  0, -1, -1, 11,  9, -1,
-    0,  1, -1,-10, -1,  1,  0, -6,  1,  0,  1,  4,  2, -5, -1, 13,
-   -2,  4,  5,  0, -5,  1,  6,  3, -6, -2,  3,  2, -5, -2,  0, -2,
-   -1,  1,  1, -2, -1, -2,  0,  2,  5,  5,  5,  7,  0, -4, -8, -7,
-    0,  2, -1, -5, -1,  2,  2, -3,  0,  5,  3, -5,  3,  8,  2,-12,
-    8,  4,  0, -2, 10, -1, -4, -1,  3, -6, -3,  0, -4, -5,  0,  0,
-    0,-10, -4,  2, -1, -6,  3,  5, -1, -3,  6,  4,  0, -2,  4,  2,
-    0,  8,  1, -1,  0, 11,  1, -3, -1,  6, -2, -4, -3, -2, -7, -4,
-    0, -1, -1, -1,  4,  5,  6,  5, -5, -9, -8, -5,  2,  2,  3,  2,
-    0,  2,  6,  1,  2,  0,  3,  0,  1, -2, -1, -2,  0, -1, -3, -6,
-    0,  0,  2,  0,  4,  0,  2,  1,  5, -2,  0,  0, -2, -9, -1,  2,
-    0,  1,  0,-10, -1,  1,  8,  0, -1, -2,  4,  0,  1, -1,  2, -1,
-   -3, -2,  2, -1, -3, -1,  2, -3,  0, -1,  1,  0,  8,  1, -1,  3,
-    0,  1,  1,  2,  0, -4, -2,  0, -1, -5,  1, -1, -2, -1, 11,  2,
-    1,  5, -2, -2,  0,  2, -4,  0, -2,  1, -5,  1,  0,  5,  0,  1,
-   -5, -3,  0,  6, -4,  2,  0,  0, -3,  5,  1,  0, -3,  3,  0,  0,
-    3, -2, -3,  1,  1, -4,  0,  8, -2, -3, -2,  3,  1,  2, -1, -1,
-    1,  1,  0,  2,  2,  0,  1,  6,  1, -1,  2,  1,  0,  3,  0,-19,
-    1, -3, -2,  2,  6,  5, -2, -7, -3,  1,  3,  1, -1, -1,  0,  2,
-   -8, -1, -1, -4,  1,  1, -1,  2,  4,  3,  2,  3, -5,  1,  3,  0,
-    0,  2, -1,  1, -3,  0,  0,  5, -5, -2,  0,  8, -4, -4, -4,  6,
-    1,  2,  1,  2,  2,  2, -3,  2,  4,  0, -9,  0,  7,  0,-11,  1,
-    0,  0,  0, -2,  3,  3, -1, -6,  4,  3, -3,-10, -1,  2,  6,  2,
-    7, -2, -3,  5, -4,  0,  3, -1, -4,  2,  1, -7,  2, -1, -1,  3,
-    3,  2,  2,  2, -5, -7, -7, -5,  5,  6,  4,  2, -2, -1,  0,  1
-};
-
-/* 6x16-entry codebook for intra-coded 8x4 vectors */
-static const int8_t svq1_intra_codebook_8x4[3072] = {
-    5,  6,  6,  6,  7,  7,  8,  8,  0,  0,  0,  0,  0,  1,  2,  3,
-   -3, -4, -4, -5, -5, -4, -3, -2, -4, -4, -4, -5, -4, -4, -3, -3,
-    1,  2,  2,  2,  2,  3,  3,  3,  2,  3,  3,  4,  4,  5,  5,  5,
-   -1,  0,  1,  1,  2,  3,  4,  4, -9,-10, -9, -9, -8, -7, -6, -5,
-   -4, -4, -5, -6, -6, -7, -7, -7,  0, -1, -2, -2, -3, -3, -4, -4,
-    4,  4,  3,  3,  2,  1,  1,  0,  7,  7,  7,  6,  6,  5,  4,  4,
-    2,  4,  5,  6,  4,  1, -3, -6,  3,  4,  5,  5,  4,  0, -5, -8,
-    2,  3,  4,  4,  2, -2, -7,-10,  2,  2,  2,  1,  0, -4, -9,-12,
-   -9, -7, -3,  1,  4,  4,  3,  3,-10, -7, -2,  3,  5,  5,  3,  3,
-   -9, -6, -2,  3,  6,  5,  4,  3, -8, -6, -1,  3,  4,  4,  3,  2,
-   -5, -5, -5, -5, -3,  1,  4,  7, -5, -5, -5, -4, -2,  1,  6,  8,
-   -4, -5, -4, -3, -1,  3,  8, 10, -3, -4, -3, -2,  1,  5,  9, 11,
-   -2, -2, -2, -2, -2, -2, -2, -2, -4, -5, -5, -5, -5, -5, -5, -4,
-   -3, -4, -4, -4, -4, -4, -4, -3,  9, 10, 10, 11, 11, 11, 10, 10,
-    7,  4,  1, -2, -4, -6, -9,-10,  9,  7,  3,  0, -2, -4, -8, -9,
-   11,  8,  4,  2,  0, -3, -6, -8, 11,  9,  5,  3,  1, -2, -5, -7,
-  -13,-13,-13,-12,-11,-10, -8, -8,  0,  1,  2,  3,  4,  4,  4,  3,
-    3,  4,  5,  6,  6,  6,  5,  4,  3,  4,  4,  4,  3,  3,  3,  2,
-   10, 10, 11, 10,  9,  9,  8,  7,  6,  6,  6,  6,  5,  4,  3,  2,
-    0,  0,  0, -1, -2, -3, -4, -4,-10,-10,-11,-12,-13,-14,-14,-14,
-   16, 16, 17, 16, 15, 13, 12, 11, -1, -2, -3, -4, -4, -4, -4, -3,
-   -4, -5, -6, -6, -6, -6, -6, -6, -5, -6, -6, -6, -6, -6, -5, -5,
-  -13,-13,-13,-12,-11,-10, -8, -6, -9, -8, -7, -6, -4, -2,  0,  1,
-   -2, -1,  1,  3,  5,  7,  8,  9,  5,  7,  9, 11, 13, 14, 15, 15,
-   16, 14, 11,  7,  2, -3, -7, -9, 14, 12,  8,  3, -1, -6, -9,-11,
-   11,  9,  4,  0, -4, -8,-11,-13,  8,  5,  1, -3, -6,-10,-12,-14,
-  -18,-15, -9, -3,  1,  6,  9, 11,-17,-13, -7, -1,  3,  7, 11, 12,
-  -15,-11, -5,  1,  5,  9, 12, 13,-13, -9, -3,  2,  5,  9, 11, 13,
-   22, 21, 19, 15, 10,  3, -4, -9, 20, 18, 15,  9,  2, -5,-12,-17,
-   16, 13,  8,  1, -7,-14,-20,-24, 10,  6, -1, -8,-15,-21,-25,-27,
-  -25,-23,-20,-14, -7,  1,  9, 14,-23,-21,-16, -9,  0,  9, 16, 21,
-  -20,-16,-10, -1,  8, 16, 22, 25,-15,-11, -3,  6, 14, 20, 25, 27,
-   -4, -2,  0,  1,  2,  2,  2,  2, -5, -2,  0,  2,  3,  3,  3,  3,
-   -6, -4, -1,  1,  2,  3,  3,  3, -7, -5, -2,  0,  1,  1,  2,  2,
-    2,  1,  1,  1,  1,  0, -2, -3,  3,  3,  2,  1,  0, -1, -3, -4,
-    4,  3,  2,  1,  0, -2, -4, -6,  5,  4,  3,  1, -1, -3, -5, -6,
-    5,  6,  6,  4,  2,  0, -2, -3,  3,  4,  4,  4,  3,  1,  0, -1,
-   -2, -2, -1, -1, -1, -1, -2, -2, -5, -4, -3, -2, -2, -2, -3, -3,
-   -1, -1, -1, -1, -1, -1, -1, -1, -3, -4, -4, -4, -3, -3, -3, -3,
-   -1, -1, -1, -1, -1, -1, -1, -2,  5,  6,  6,  6,  6,  5,  4,  3,
-    4,  4,  4,  4,  4,  5,  6,  7,  0, -1, -1, -1, -1,  0,  1,  2,
-   -2, -3, -3, -3, -3, -2, -1,  0, -3, -3, -4, -4, -4, -3, -2, -1,
-    0, -2, -4, -4, -2,  0,  2,  3,  0, -2, -3, -3, -1,  2,  4,  5,
-   -1, -2, -4, -3,  0,  3,  5,  6, -2, -3, -4, -3, -1,  2,  4,  5,
-    9,  4,  0, -3, -3, -1,  0,  1,  8,  4, -1, -4, -3, -1,  1,  2,
-    6,  2, -3, -5, -4, -2,  0,  1,  5,  1, -3, -4, -4, -2,  0,  1,
-    5,  3,  1, -1, -4, -8,-10,-10,  3,  3,  2,  1,  0, -2, -3, -4,
-    1,  1,  1,  2,  3,  2,  1,  0, -1,  0,  1,  2,  3,  4,  3,  2,
-    0,  1,  2,  2,  1, -1, -3, -3,  0,  1,  1,  1, -1, -2, -4, -3,
-   -3, -3, -3, -3, -3, -3, -1,  2, -4, -4, -3,  0,  3,  7, 12, 14,
-   -5, -5, -6, -6, -6, -6, -6, -5,  2,  2,  2,  1,  0,  0,  0,  0,
-    4,  4,  3,  2,  1,  0,  0,  0,  6,  6,  5,  4,  2,  2,  1,  1,
-   -7, -7, -6, -3,  0,  4,  7,  8, -1, -2, -3, -3, -2, -1,  1,  2,
-    3,  3,  1, -1, -2, -2, -2, -1,  6,  6,  4,  2,  0, -2, -2, -2,
-   -6, -5, -2,  2,  5,  9, 11, 12, -4, -4, -2,  0,  2,  4,  5,  6,
-   -3, -2, -2, -2, -2, -1,  0,  1, -2, -2, -2, -3, -3, -3, -3, -2,
-   -7, -3,  1,  3,  3,  0, -3, -5, -6, -2,  3,  5,  4,  1, -3, -5,
-   -5, -1,  4,  6,  5,  2, -3, -4, -4,  0,  5,  7,  6,  3, -1, -3,
-    0,  0,  0,  0,  0,  0,  0,  0, -2, -2, -3, -3, -3, -3, -2, -1,
-    6,  7,  8,  9,  9,  8,  7,  6, -4, -4, -5, -5, -6, -6, -5, -4,
-   -9, -8, -6, -4,  0,  3,  6,  6, -5, -4, -1,  3,  5,  6,  5,  3,
-    1,  3,  6,  6,  4,  1, -2, -5,  6,  7,  5,  1, -3, -7,-10,-11,
-   10,  9,  5,  1, -3, -6, -6, -4,  5,  3, -1, -5, -6, -5, -2,  2,
-   -2, -4, -6, -6, -4,  1,  6, 10, -6, -7, -7, -4,  1,  7, 11, 12,
-    6,  5,  3,  2,  0,  0,  0,  0,  2,  1, -1, -2, -3, -2, -1, -1,
-    0, -1, -2, -4, -4, -2, -1,  1,  0,  0, -1, -2, -1,  0,  2,  3,
-    0, -1, -2, -2, -2, -2, -1, -1,  5,  4,  2,  1,  0,  0,  0,  0,
-    6,  5,  3,  1,  0,  0,  0,  0,  2,  0, -2, -4, -4, -3, -2, -2,
-   -7, -4,  0,  2,  2,  2,  2,  1, -7, -3,  0,  0,  0,  0,  0,  0,
-   -4, -1,  1,  1,  0,  0,  0,  1, -1,  1,  2,  2,  2,  2,  3,  3,
-   -2,  0,  2,  2,  1,  1,  1,  1, -1,  1,  2,  2,  1,  0,  0, -1,
-    0,  2,  4,  2,  0, -1, -2, -3,  1,  2,  3,  1, -2, -4, -6, -6,
-    1,  2,  2,  4,  5,  6,  4,  1,  0, -1, -1, -1,  0,  0, -2, -4,
-    0,  0, -1, -2, -2, -2, -4, -6,  2,  1,  0,  0,  1,  1, -1, -3,
-    1,  1,  1,  1,  1,  2,  3,  3,  0,  0,  1,  0,  1,  2,  4,  4,
-   -1, -1, -1, -1,  0,  1,  2,  3, -4, -4, -5, -5, -5, -3, -1,  0,
-   -6, -5, -5, -4, -3, -2, -1, -1, -1,  0,  0,  1,  1,  2,  3,  3,
-    0,  1,  1,  1,  2,  2,  3,  4,  0,  0, -1, -1,  0,  1,  2,  3,
-    0,  1,  1,  1,  0,  0, -1, -1,  1,  3,  3,  2,  1, -1, -2, -2,
-   -2,  0,  2,  2,  2,  2,  1,  1, -9, -8, -4, -2,  1,  3,  3,  3,
-   -1, -1, -1, -2, -3, -3, -3, -4,  0,  0,  0, -1, -2, -2, -3, -3,
-    2,  2,  2,  0, -1, -1, -1, -1,  5,  5,  4,  3,  2,  2,  2,  2,
-    6,  3, -1, -4, -3, -1,  1,  1,  2, -1, -3, -4, -1,  2,  2,  0,
-   -1, -2, -2,  1,  4,  4,  1, -3, -2, -1,  1,  4,  6,  3, -3, -8,
-    3,  3,  2,  1, -1, -2, -2, -2, -4, -4, -2, -1,  1,  3,  4,  4,
-   -4, -5, -5, -4, -2,  0,  2,  2,  7,  7,  4,  1, -1, -2, -3, -2,
-   -1,  1,  3,  0, -4, -6,  0,  6, -2,  1,  4,  1, -4, -6, -1,  7,
-   -3,  1,  4,  2, -3, -6, -1,  6, -2,  0,  3,  2, -2, -5, -1,  4,
-    1, -1, -2,  1,  4,  4, -1, -7,  1, -1, -4, -1,  5,  6,  0, -6,
-    3,  0, -4, -3,  3,  6,  2, -4,  3,  0, -5, -4,  1,  4,  1, -3,
-    2,  2,  3,  3,  3,  3,  2,  2, -4, -5, -6, -7, -7, -7, -7, -6,
-    1,  2,  3,  3,  3,  3,  2,  2,  0,  0,  1,  1,  1,  2,  2,  1,
-    3, -3, -3,  3,  4, -2, -2,  2,  3, -4, -4,  4,  4, -4, -4,  2,
-    4, -4, -4,  4,  4, -4, -3,  3,  3, -3, -4,  3,  3, -3, -3,  3,
-   -2, -2, -2, -2, -2, -2, -1, -1,  6,  7,  8,  8,  8,  7,  6,  5,
-   -5, -6, -7, -7, -8, -7, -6, -5,  1,  1,  2,  2,  2,  2,  1,  1,
-    0,  0,  0,  0,  0, -1,  0,  0, -1,  0,  0,  0,  0, -1,  0,  0,
-   -2, -3, -2, -2, -2, -3, -3, -3,  2,  3,  5,  6,  4,  2,  1,  0,
-    8,  6,  2,  0,  0,  0,  0,  0,  4,  1,  0,  0,  0, -1, -1, -1,
-    1, -1,  0,  0,  0, -1, -2, -3, -2, -2, -1,  0,  0, -2, -4, -5,
-    3,  1, -1, -2, -3, -4, -5, -5,  2,  1,  0,  0,  1,  1,  0,  0,
-    0, -1, -1,  0,  2,  2,  2,  2, -1, -2, -1,  1,  2,  2,  2,  2,
-    0, -1, -2, -1, -1, -1, -1,  0, -1, -2, -2, -1, -1,  0,  0,  1,
-    2,  1,  1,  2,  2,  1,  1,  0,  6,  5,  3,  1,  0, -2, -4, -4,
-   -3, -2, -1,  0,  1,  1,  0, -1,  0,  1,  3,  4,  5,  5,  3,  1,
-   -1, -1, -1,  0,  1,  0, -1, -2, -2, -2, -2, -1,  0, -1, -2, -3,
-    0, -1, -2, -2, -1, -1,  0,  2,  1, -1, -2, -1, -1, -1,  0,  2,
-    1,  0, -2, -2, -2, -2,  1,  5,  1, -1, -2, -2, -2,  0,  5, 10,
-    0,  0,  0,  0,  0, -1, -1, -1, -1, -1, -1,  0,  0,  0,  1,  2,
-    1,  2,  2,  3,  4,  4,  6,  5, -3, -3, -3, -2, -2, -3, -3, -3,
-    1, -1, -2, -2,  0,  3,  5,  7,  2,  0, -2, -3, -2,  0,  2,  3,
-    3,  1, -2, -3, -3, -2, -1, -1,  3,  1,  0, -1, -1, -1, -1, -1,
-    1,  3,  5,  4,  2, -1, -3, -4, -3, -2,  1,  2,  1,  0, -1, -2,
-   -5, -3,  0,  2,  2,  1,  0,  0, -3, -1,  1,  2,  2,  1,  0,  0,
-    0, -1, -1, -1,  1,  2,  3,  4, -3, -4, -4, -3, -1,  0,  0,  1,
-   -2, -3, -2, -1,  1,  1,  1,  1, -2, -2,  0,  3,  4,  4,  3,  2,
-   -4, -4, -3, -2, -1,  1,  2,  3,  0,  1,  1,  1, -1, -2, -3, -3,
-    3,  4,  5,  4,  2, -1, -3, -3, -2, -2,  0,  2,  2,  2,  1,  0,
-   -4,  0,  5,  7,  4, -1, -4, -4, -1,  2,  4,  3,  0, -3, -3, -2,
-    2,  1,  0, -1, -2, -2,  0,  1,  0,  0, -1, -2, -2, -1,  1,  2,
-   -4, -3, -2, -1,  0,  1,  2,  2, 10,  9,  5,  0, -3, -4, -3, -2,
-    1, -1, -2, -2, -1,  0,  0,  0, -2, -2, -1,  1,  1,  1,  0, -1,
-   -5, -3,  0,  3,  4,  2,  0, -2, -2, -1,  0,  1,  1,  0, -1, -1,
-    3,  2, -1, -2, -2, -1,  1,  1,  7,  5, -1, -5, -6, -2,  2,  4,
-   -2,  3,  3, -3, -4,  1,  2, -2, -3,  3,  4, -3, -4,  2,  3, -2,
-   -3,  3,  4, -3, -4,  2,  3, -2, -4,  2,  4, -2, -3,  1,  2, -1,
-    4,  3, -1, -3, -3, -1,  1,  2, -4, -6, -4,  0,  4,  5,  4,  1,
-    0,  2,  5,  6,  2, -3, -5, -4,  1,  1, -1, -3, -5, -2,  2,  4,
-   -1,  0,  1,  2,  2,  3,  3,  4, -1,  0,  1,  1,  0, -1, -1, -1,
-   -1,  0,  1,  2,  2,  1, -1, -2, -3, -2, -1,  0,  0, -1, -2, -3,
-    1,  1,  1,  1,  0,  0,  1,  2,  1,  0, -1,  0,  0,  1,  1,  0,
-    1, -2, -4, -1,  1,  2,  1,  0,  1, -4, -7, -3,  1,  3,  2,  1,
-    1,  1,  1,  1,  1,  1,  0, -1,  1,  1,  1,  0,  1,  2,  2,  0,
-    1,  1,  0,  0,  0,  2,  0, -3,  3,  2,  0, -1, -1, -2, -6, -9,
-    0,  0,  0,  1,  0,  0,  1,  2,  1,  0,  0,  0, -1, -1,  0,  2,
-    0,  1,  1,  1, -1, -3, -2,  0, -7, -5,  1,  6,  6,  2, -1, -1,
-    3,  1, -1, -3, -4, -2,  1,  4,  2,  0, -2, -3, -4, -3, -1,  2,
-    2,  2,  1,  1,  1,  0,  0,  1,  1,  1,  0,  0,  0,  0,  0,  1,
-   -1,  1,  1, -2, -5, -6, -4, -1, -1,  1,  4,  3,  2,  0,  1,  2,
-   -1,  0,  2,  3,  1,  0,  0,  1, -1,  0,  1,  0,  0, -1, -1,  0,
-    0,  1,  2,  2,  0, -2, -1,  1, -2, -1, -1, -2, -1,  2,  6,  8,
-   -1, -1, -2, -3, -2,  0,  1,  2, -1,  0,  0, -1, -1,  0, -1, -1,
-    2,  1,  1,  1,  1,  0,  0,  0,  0,  0,  1,  1,  1, -1, -1,  1,
-   -1,  0,  2,  2, -1, -3, -2,  3,  0,  2,  3,  0, -5, -7, -2,  4,
-   -1,  0,  0,  0, -1, -2, -3, -3, -1,  0, -1, -2, -2, -2, -2, -2,
-    1,  1,  0,  0,  1,  2,  0, -1,  1,  2,  1,  2,  5,  6,  2,  0,
-   -2, -4, -3,  0,  2,  2,  0, -3,  3,  1,  0,  1,  2,  1, -2, -3,
-    3,  1,  0,  0,  0,  0,  0, -1,  1, -1, -2, -2, -1,  1,  3,  3,
-    3,  2,  1,  2,  4,  3,  1, -2, -2, -4, -4, -3, -1,  0, -2, -3,
-    1,  0, -1, -1,  0,  1,  0, -1,  3,  2,  0,  0,  0,  1,  1,  0,
-    1,  1,  0,  0,  0,  0,  0,  0,  2,  3,  3,  2,  2,  2,  1,  1,
-    0, -1, -2, -3, -5, -5, -5, -4,  1,  1,  0, -1,  0,  1,  3,  3,
-   -9, -6, -2,  0,  1,  1,  2,  2, -6, -2,  1,  2,  1,  1,  0,  1,
-   -2,  1,  2,  2,  1,  1,  1,  1,  0,  2,  2,  1,  0,  1,  1,  1,
-    1,  0,  0,  0,  0,  0, -1,  0,  0,  0,  0,  0, -1, -3, -2,  0,
-   -3, -3, -3, -2, -1,  3,  7,  9,  1,  2,  2,  2,  0, -2, -4, -3,
-    2,  0, -2, -1,  3,  4, -1, -6,  1,  0, -2, -3, -1,  3,  3,  0,
-    0,  3,  3,  0, -2, -1,  1,  1, -6, -1,  3,  2, -1, -2,  0,  1,
-    5,  3,  0, -2, -3,  0,  2,  1,  1,  1,  2,  2,  0, -2, -4, -7,
-   -3, -2,  1,  2,  2,  1, -1, -4,  2,  2,  0, -2, -2,  0,  2,  2,
-    0,  0, -2, -3, -2, -1,  0,  0,  0,  0,  0,  0,  0,  0,  2,  2,
-   -2, -1,  0,  1,  0,  1,  2,  3, -4, -2,  0,  0, -1,  0,  2,  3,
-   -2, -2, -2, -1, -1,  0,  2,  4,  0,  0,  0,  0, -1, -1,  0,  1,
-    0, -1, -1, -1, -1, -1,  0,  0,  6,  4,  2,  0, -1, -2, -1, -1,
-    0,  1,  1,  1,  1, -1, -5,-10,  1,  1,  1,  1,  1,  1,  0, -4,
-    1,  0,  1,  1,  1,  1,  1, -1,  2,  1,  1,  1,  0,  0,  0,  0,
-   -3,  1,  4,  3,  3,  1, -1,  0, -4,  0,  1,  0, -1,  0,  0,  0,
-   -5,  0,  2,  1,  1,  1,  0, -1, -1,  2,  1, -2, -2, -1,  0, -1,
-    2,  4,  5,  3,  0, -1,  1,  2,  0,  0,  1,  0, -2, -2, -1, -1,
-   -2, -2, -2, -2, -3, -2, -1,  0,  0,  0,  1,  0,  0,  0,  1,  2,
-    0, -2, -2, -3, -1,  2,  2, -1,  1,  0,  0,  0,  1,  5,  3, -2,
-   -1, -1,  0, -1,  0,  2,  0, -5, -1,  0,  1,  0,  0,  2,  2, -2,
-    3,  1, -1, -1,  0,  1,  1,  2,  1,  0,  0,  1,  1,  1,  1,  1,
-  -10, -8, -2,  1,  2,  1,  1,  1, -1,  1,  2,  1,  0,  0,  0,  0,
-   -1, -1,  0,  1,  2,  2,  2,  1, -1, -1, -1,  0, -1, -3, -5, -4,
-    1,  1,  2,  1,  1,  0,  0,  2, -1, -2, -1, -1, -1,  0,  2,  4,
-   -3, -7, -5,  0,  2,  0,  0,  0,  3, -1, -2,  1,  2,  1,  1,  2,
-    1, -2, -1,  1,  2,  1,  0,  1,  0, -1,  0,  3,  2, -1, -1, -1,
-    2,  1,  1,  0,  0,  0,  0,  0, -9, -7, -2,  3,  3,  2,  1,  1,
-    3,  2,  0, -2, -2, -1,  1,  1,  0, -1,  0,  0,  1,  1,  0,  0,
-   -2, -1,  1,  1,  1,  0,  0,  0,  1,  2,  1, -2, -4, -3,  1,  2,
-    1,  2,  1, -2, -3,  0,  3,  1, -1, -1,  0,  0,  1,  3,  0, -4,
-    2,  0, -1,  1,  2, -2, -2,  3,  2,  0, -1,  2,  3, -2, -4,  1,
-    0,  1,  1,  1,  2, -2, -6, -2, -1,  0,  0,  0,  2,  0, -2, -1,
-   -1, -1,  1,  2,  1, -2, -3, -2,  3, -1, -2, -1, -1,  0,  1,  2,
-   10,  4,  0,  0, -1, -2, -2, -1,  3, -1, -2, -1,  0, -1, -1,  0,
-   -5,  2,  7,  1, -4, -2,  1,  0, -2,  2,  3, -1, -3,  0,  2,  0,
-    2,  1,  0,  0,  1,  1, -1, -2,  1, -2, -2, -1, -1, -2,  0,  0,
-    0,  3, -2, -7, -1,  3,  0,  0,  1,  3, -3, -5,  2,  3, -1,  0,
-    0,  2, -2, -2,  4,  2, -2,  0, -1,  1, -1,  0,  2, -1, -2,  1,
-    4,  0, -3, -4, -2,  1,  2,  1,  0,  0,  3,  5,  3,  1, -1, -2,
-    1,  1,  1, -1, -3, -1,  1,  1,  1, -1, -2, -2,  0,  0, -1, -2
-};
-
-/* 6x16-entry codebook for intra-coded 8x8 vectors */
-static const int8_t svq1_intra_codebook_8x8[6144] = {
-    4,  4,  3,  2,  2,  1,  0, -1,  4,  3,  3,  2,  1,  0, -1, -1,
-    3,  3,  2,  2,  1,  0, -1, -2,  3,  2,  2,  1,  0, -1, -2, -3,
-    2,  2,  1,  0, -1, -1, -2, -3,  2,  1,  0,  0, -1, -2, -3, -4,
-    1,  0,  0, -1, -2, -3, -4, -4,  0,  0, -1, -2, -2, -3, -4, -4,
-    2,  3,  3,  3,  3,  3,  3,  3,  2,  2,  2,  2,  2,  2,  3,  3,
-    1,  2,  2,  2,  2,  2,  2,  2,  0,  1,  1,  1,  1,  1,  1,  1,
-   -1,  0,  0,  0,  0,  0,  1,  1, -2, -2, -1, -1, -1, -1, -1, -1,
-   -3, -3, -3, -3, -3, -3, -2, -2, -5, -4, -4, -4, -4, -4, -4, -3,
-   -4, -2, -1,  0,  1,  2,  2,  3, -4, -2, -1,  0,  1,  2,  3,  3,
-   -4, -3, -1,  0,  1,  2,  3,  3, -4, -3, -1,  0,  1,  2,  3,  3,
-   -5, -3, -1,  0,  1,  2,  3,  3, -5, -3, -1,  0,  1,  2,  3,  3,
-   -5, -3, -1,  0,  1,  1,  2,  3, -5, -3, -2, -1,  0,  1,  2,  3,
-    4,  4,  5,  5,  6,  6,  7,  7,  2,  2,  2,  3,  3,  4,  4,  4,
-    0,  0,  0,  0,  1,  1,  1,  2, -2, -2, -2, -2, -1, -1, -1,  0,
-   -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
-   -1, -2, -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -2, -2, -2, -2,
-    5,  3,  1, -1, -2, -3, -3, -3,  5,  3,  1, -1, -2, -3, -3, -3,
-    5,  3,  1, -1, -2, -3, -3, -3,  5,  3,  1, -1, -2, -3, -3, -3,
-    5,  4,  1,  0, -2, -3, -3, -3,  6,  4,  2,  0, -2, -2, -3, -3,
-    6,  4,  2,  0, -1, -2, -2, -3,  6,  4,  2,  1, -1, -2, -2, -2,
-   -1,  1,  3,  3,  2,  0, -3, -6, -1,  1,  3,  4,  3,  0, -3, -6,
-   -1,  1,  4,  4,  3,  1, -3, -6, -1,  1,  3,  4,  3,  1, -3, -6,
-   -2,  1,  3,  4,  3,  1, -3, -6, -2,  1,  3,  4,  3,  1, -3, -7,
-   -2,  1,  3,  3,  2,  0, -3, -7, -2,  0,  2,  3,  2,  0, -3, -6,
-   10,  9,  8,  6,  6,  5,  4,  4,  6,  5,  4,  3,  2,  2,  2,  1,
-    2,  1,  0, -1, -2, -2, -2, -1, -1, -2, -3, -4, -4, -4, -4, -3,
-   -2, -3, -4, -4, -5, -4, -4, -3, -2, -2, -3, -3, -3, -3, -2, -2,
-   -1, -1, -1, -1, -1, -1, -1,  0,  1,  1,  1,  1,  1,  1,  1,  2,
-   -2, -1,  1,  2,  4,  5,  7,  8, -3, -2,  0,  1,  3,  5,  7,  8,
-   -4, -3, -1,  0,  2,  4,  6,  7, -5, -4, -2, -1,  1,  3,  5,  7,
-   -6, -5, -3, -2,  0,  2,  4,  6, -6, -5, -4, -2, -1,  1,  3,  5,
-   -7, -6, -5, -3, -2,  0,  2,  3, -8, -7, -5, -4, -3, -1,  1,  2,
-   11,  9,  7,  5,  3,  1, -1, -1, 10,  8,  6,  3,  1,  0, -2, -2,
-    9,  7,  5,  2,  0, -2, -3, -4,  8,  6,  3,  1, -1, -3, -4, -4,
-    6,  4,  2, -1, -3, -4, -5, -5,  5,  3,  0, -2, -4, -5, -6, -6,
-    3,  1, -1, -3, -5, -6, -7, -7,  2,  0, -2, -4, -6, -6, -7, -7,
-    5,  6,  7,  7,  7,  8,  8,  8,  3,  4,  5,  5,  6,  6,  6,  6,
-    0,  2,  2,  3,  4,  4,  4,  5, -2, -1,  0,  1,  2,  2,  3,  3,
-   -4, -3, -2, -1,  0,  1,  1,  2, -6, -5, -4, -3, -2, -2, -1,  0,
-   -8, -7, -6, -6, -5, -4, -3, -3,-10, -9, -8, -8, -7, -6, -6, -5,
-    6,  5,  3,  1, -1, -3, -6, -8,  6,  5,  4,  2, -1, -3, -6, -8,
-    6,  5,  4,  2,  0, -3, -6, -8,  6,  5,  4,  2,  0, -3, -6, -8,
-    6,  6,  4,  2,  0, -3, -6, -8,  6,  5,  4,  2,  0, -3, -6, -8,
-    6,  5,  4,  2,  0, -3, -6, -8,  6,  5,  4,  2, -1, -3, -5, -8,
-   11, 10,  9,  8,  7,  6,  5,  4,  8,  8,  7,  6,  5,  4,  3,  2,
-    6,  5,  4,  4,  2,  2,  1,  0,  3,  3,  2,  1,  0,  0, -1, -2,
-    1,  1,  0, -1, -2, -2, -3, -3, -1, -1, -2, -3, -4, -4, -5, -5,
-   -3, -4, -4, -5, -6, -6, -7, -7, -5, -5, -6, -7, -8, -8, -8, -8,
-  -14,-13,-12,-11, -9, -7, -6, -4,-12,-11,-10, -9, -7, -5, -3, -1,
-  -10, -9, -7, -6, -3, -2,  0,  2, -8, -6, -4, -2,  0,  2,  4,  5,
-   -5, -3,  0,  2,  4,  5,  7,  8, -2,  0,  2,  4,  6,  8,  9, 10,
-    0,  3,  5,  7,  8, 10, 11, 12,  3,  5,  7,  8, 10, 11, 12, 12,
-  -19,-19,-18,-18,-17,-16,-15,-14,-15,-15,-14,-13,-12,-11,-10, -9,
-  -11,-10, -9, -8, -6, -5, -4, -3, -6, -5, -3, -2, -1,  0,  1,  2,
-   -1,  0,  2,  3,  4,  5,  6,  6,  4,  6,  7,  8,  9, 10, 10, 10,
-    9, 10, 11, 12, 13, 14, 14, 14, 12, 14, 14, 15, 16, 16, 16, 16,
-   22, 21, 19, 17, 14, 11,  9,  5, 20, 19, 17, 14, 11,  8,  4,  1,
-   17, 15, 13, 10,  6,  3,  0, -4, 13, 11,  8,  5,  1, -2, -5, -9,
-    9,  6,  3, -1, -4, -7,-11,-13,  4,  0, -3, -6, -9,-12,-15,-17,
-   -2, -5, -8,-11,-14,-16,-18,-20, -8,-10,-13,-16,-17,-19,-21,-22,
-   17, 18, 18, 18, 17, 16, 16, 14, 16, 16, 15, 15, 14, 13, 12, 11,
-   12, 12, 11, 10,  9,  8,  7,  5,  7,  6,  6,  4,  3,  2,  1, -1,
-    1,  0, -1, -2, -3, -4, -5, -6, -5, -6, -7, -8, -9,-10,-11,-12,
-  -11,-12,-13,-14,-15,-16,-16,-17,-16,-17,-17,-18,-19,-20,-20,-20,
-    0,  0,  0,  0, -1, -1, -2, -3,  1,  0,  0,  0,  0, -1, -2, -3,
-    1,  1,  0,  0, -1, -1, -2, -2,  1,  1,  1,  0,  0, -1, -1, -2,
-    2,  1,  1,  1,  0, -1, -1, -2,  2,  2,  1,  1,  0,  0, -1, -2,
-    2,  2,  1,  1,  1,  0, -1, -1,  2,  2,  1,  1,  1,  0,  0, -2,
-    0, -1, -1,  0,  0,  1,  2,  3,  0, -1, -1,  0,  1,  1,  2,  2,
-   -1, -1, -1, -1,  0,  1,  2,  2, -1, -1, -2, -1,  0,  1,  1,  2,
-   -1, -2, -2, -1,  0,  0,  1,  2, -1, -2, -2, -2, -1,  0,  1,  2,
-   -1, -1, -2, -1,  0,  0,  1,  2, -1, -1, -1, -1,  0,  1,  1,  2,
-    3,  2,  2,  2,  1,  1,  0,  0,  3,  2,  2,  2,  2,  1,  0,  0,
-    2,  2,  2,  1,  1,  1,  0,  0,  2,  2,  1,  1,  1,  0,  0, -1,
-    1,  1,  1,  0,  0,  0, -1, -1,  0,  0, -1, -1, -1, -1, -1, -1,
-   -2, -2, -2, -2, -2, -2, -2, -2, -2, -3, -3, -3, -2, -2, -2, -2,
-    5,  2,  0,  0, -1,  0,  0,  0,  4,  2,  0, -1, -1, -1,  0, -1,
-    4,  1, -1, -1, -2, -1, -1, -1,  4,  1, -1, -1, -2, -1, -1, -1,
-    4,  1, -1, -2, -2, -1, -1, -1,  4,  1, -1, -2, -2, -1, -1, -1,
-    4,  1, -1, -1, -1, -1, -1, -1,  4,  2,  0, -1,  0,  0,  0, -1,
-   -2, -1,  0,  1,  1,  1,  1,  1, -3, -1,  0,  1,  1,  1,  1,  1,
-   -3, -1,  0,  1,  1,  1,  1,  1, -3, -1,  0,  1,  1,  1,  1,  1,
-   -3, -2,  0,  1,  2,  2,  1,  1, -4, -2,  0,  1,  2,  2,  2,  2,
-   -5, -3, -1,  1,  1,  2,  1,  2, -5, -3, -2,  0,  1,  1,  1,  1,
-    3,  3,  1,  0, -2, -4, -4, -5,  3,  3,  2,  0, -1, -2, -3, -4,
-    2,  2,  1,  1,  0, -1, -2, -2,  1,  1,  1,  1,  1,  0,  0,  0,
-    0,  0,  0,  1,  1,  1,  1,  1, -2, -1, -1,  0,  0,  1,  2,  2,
-   -3, -2, -2, -1,  0,  1,  2,  3, -3, -3, -2, -1,  0,  1,  2,  3,
-   -3, -3, -3, -3, -3, -2, -2, -2, -3, -3, -2, -2, -2, -1, -1, -1,
-   -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1,  0,  0,  0,  0,  0,
-    0,  0,  0,  0,  1,  1,  1,  1,  0,  0,  1,  1,  2,  2,  2,  2,
-    1,  1,  1,  2,  2,  3,  3,  3,  2,  2,  2,  2,  3,  3,  3,  3,
-   -8, -7, -5, -3, -2, -1,  0, -1, -4, -3, -1,  0,  1,  2,  1,  1,
-   -1,  1,  2,  3,  3,  2,  2,  1,  1,  2,  3,  3,  2,  2,  1,  0,
-    2,  3,  3,  2,  1,  0,  0, -1,  1,  2,  1,  0, -1, -1, -1, -1,
-    1,  1,  0, -1, -1, -2, -2, -1,  1,  1,  0,  0, -1, -1,  0, -1,
-   -4, -3, -2,  0,  1,  2,  3,  3, -4, -3, -2,  0,  1,  2,  2,  2,
-   -3, -3, -2, -1,  0,  1,  1,  1, -2, -2, -2, -1, -1,  0,  0,  0,
-    0, -1, -1, -1, -1, -1, -1, -1,  2,  1,  1,  0,  0, -1, -1, -2,
-    3,  3,  3,  1,  0, -1, -2, -2,  5,  4,  4,  2,  1,  0, -1, -2,
-    0,  0,  0,  0,  1,  2,  3,  3,  0, -1,  0,  0,  1,  2,  3,  3,
-    0, -1,  0,  0,  1,  2,  3,  2,  0,  0,  0,  1,  1,  2,  2,  2,
-    2,  1,  1,  1,  1,  1,  1,  0,  2,  2,  2,  1,  0,  0, -1, -2,
-    2,  1,  0,  0, -2, -3, -5, -6,  0, -1, -1, -3, -5, -6, -8, -9,
-   -2,  0,  1,  2,  2,  1, -1, -4, -2,  0,  2,  2,  2,  1, -1, -4,
-   -2,  0,  2,  2,  2,  1, -1, -3, -2,  0,  2,  2,  2,  1, -1, -3,
-   -2, -1,  2,  2,  2,  1, -1, -3, -2, -1,  1,  2,  2,  1, -1, -3,
-   -3, -1,  1,  2,  2,  1, -1, -3, -2, -1,  1,  2,  2,  1, -1, -3,
-   -1,  1,  1, -1, -3, -3,  0,  4, -1,  1,  1, -1, -3, -3,  0,  4,
-   -1,  1,  1,  0, -3, -3,  0,  4, -1,  1,  2,  0, -3, -3,  0,  5,
-    0,  1,  2,  0, -3, -4,  0,  4,  0,  1,  2,  0, -3, -4,  0,  5,
-    0,  1,  2,  0, -3, -3,  0,  4,  0,  1,  2, -1, -2, -2,  0,  4,
-    6,  6,  5,  6,  5,  5,  5,  5,  2,  2,  2,  2,  2,  2,  2,  2,
-    0,  0,  0,  0,  0,  0,  0,  0, -1, -1, -1, -1, -2, -2, -2, -2,
-   -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
-   -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-    2,  2,  2,  2,  2,  2,  2,  2,  0,  1,  1,  0,  0,  0,  0,  0,
-   -1, -2, -2, -2, -2, -2, -2, -1, -3, -3, -3, -3, -3, -3, -3, -2,
-   -3, -4, -4, -3, -3, -3, -2, -2, -2, -2, -2, -2, -1, -1,  0,  0,
-    0,  1,  1,  1,  2,  2,  3,  3,  3,  4,  4,  5,  5,  6,  6,  6,
-    4,  1, -2, -3, -3, -1,  1,  3,  4,  1, -2, -4, -3, -1,  1,  3,
-    5,  1, -2, -4, -3, -1,  1,  4,  5,  1, -2, -3, -3, -1,  2,  4,
-    5,  1, -2, -3, -3, -1,  2,  4,  4,  0, -3, -4, -3, -1,  2,  4,
-    4,  0, -3, -3, -3, -1,  1,  3,  3,  0, -2, -3, -2, -1,  1,  3,
-   -3, -4, -4, -4, -4, -4, -4, -4, -1, -1, -1, -1, -1, -1, -2, -2,
-    2,  1,  1,  2,  2,  1,  1,  1,  3,  3,  3,  4,  4,  3,  3,  3,
-    3,  3,  3,  4,  4,  4,  3,  3,  1,  2,  1,  2,  2,  2,  2,  2,
-   -2, -2, -2, -1, -1, -1,  0,  0, -4, -4, -4, -4, -3, -3, -3, -3,
-   -1, -2, -3, -3, -2, -2, -1,  0,  0, -1, -2, -2, -2, -1,  0,  1,
-    2,  1, -1, -1, -1, -1,  0,  1,  3,  1,  0, -1, -1,  0,  0,  1,
-    3,  2,  0, -1,  0,  0,  0,  1,  3,  1,  0, -1,  0,  0,  0,  1,
-    3,  1,  0, -1,  0,  0,  0,  1,  2,  1,  0,  0,  0,  0,  0,  1,
-    0,  0,  0,  1,  1,  2,  3,  4,  0,  0, -1,  0,  0,  0,  2,  3,
-    0, -1, -1, -1, -1, -1,  0,  1,  0, -1, -1, -1, -1, -1, -1,  0,
-    0,  0, -1, -1, -1, -2, -2, -1,  1,  0,  0, -1, -1, -2, -2, -1,
-    2,  2,  1,  0, -1, -1, -1, -1,  3,  3,  2,  1,  0, -1, -1,  0,
-    1,  0,  1,  0,  0, -1, -2, -1,  0,  0,  0,  0, -1, -1, -2, -1,
-    0, -1,  0,  0, -1, -1, -1, -1, -1, -1, -1,  0,  0,  0,  0,  0,
-   -1, -1, -1,  0,  0,  0,  1,  1, -1, -1, -1,  0,  1,  1,  2,  3,
-   -2, -2, -1,  0,  1,  2,  3,  4, -2, -2, -1,  0,  1,  2,  4,  5,
-   -3, -1,  1,  0,  0, -1,  0,  1, -3,  0,  1,  0, -1, -1,  0,  2,
-   -3,  0,  1,  0, -1, -1,  0,  2, -2,  1,  2,  0, -1, -1,  0,  2,
-   -2,  1,  2,  0, -1, -1,  0,  2, -2,  1,  2,  0, -1, -1,  0,  2,
-   -1,  2,  2,  0, -1, -1,  0,  2, -1,  1,  1,  0, -1, -1, -1,  1,
-   -2, -2, -1,  1,  3,  4,  3,  1, -2, -2, -1,  0,  2,  3,  2,  0,
-   -2, -2, -1,  0,  1,  2,  1, -1, -1, -1, -1,  0,  1,  2,  1, -1,
-   -1, -1, -1,  0,  1,  1,  0, -2,  0, -1, -1,  0,  1,  1,  0, -1,
-    0, -1, -1,  0,  1,  1,  1, -1,  0, -1, -1,  0,  0,  1,  0, -1,
-   -2, -1,  0,  1,  1,  1,  1,  1, -2, -1,  0,  0,  0,  0,  0,  0,
-   -2, -1, -1,  0, -1, -1, -2, -2, -2, -1, -1, -1, -1, -2, -2, -3,
-   -1,  0,  1,  1,  0, -1, -2, -2,  1,  2,  3,  3,  2,  1,  0,  0,
-    1,  2,  3,  3,  3,  2,  1,  0,  0,  0,  1,  1,  1,  1,  0,  0,
-    0, -1, -1, -1,  0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  1,  1,
-    1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  1,  1,  1,  1,
-    1,  1,  1,  1,  1,  1,  1,  1, -1,  0,  0,  1,  1,  0,  0,  0,
-   -3, -2, -1, -1, -1, -1,  0, -1, -5, -5, -4, -3, -2, -2, -2, -1,
-    1,  1,  1,  1,  2,  1,  0, -1,  1,  1,  1,  2,  1,  1,  0, -1,
-    1,  1,  1,  1,  1,  1,  0, -2,  2,  1,  1,  1,  1,  1,  0, -2,
-    1,  1,  0,  0,  0,  0, -1, -3,  1,  1,  0,  0,  0, -1, -2, -3,
-    1,  1,  0,  0, -1, -1, -2, -4,  1,  0,  0, -1, -2, -2, -3, -4,
-    8,  7,  5,  3,  2,  1,  1,  1,  2,  1,  0,  0, -1, -1, -2, -1,
-   -1, -1, -1, -2, -2, -2, -2, -1, -1, -1, -1, -1,  0, -1, -1,  0,
-    0,  0,  0,  1,  1,  0,  0,  0,  0,  0,  1,  1,  1,  0,  0,  0,
-   -1,  0,  0,  0,  0,  0, -1, -1, -2, -2, -1, -1, -1, -2, -2, -1,
-    9,  4,  0, -2, -2, -2, -1, -1,  7,  2, -1, -2, -2, -1,  0,  0,
-    4,  0, -2, -2, -1,  0,  1,  1,  1, -2, -2, -2, -1,  0,  1,  1,
-   -1, -2, -2, -1,  0,  1,  1,  1, -1, -2, -1,  0,  1,  1,  1,  0,
-   -1, -1,  0,  1,  1,  1,  0, -1,  0, -1,  0,  1,  0,  0, -1, -1,
-    0,  1,  1,  1,  1,  1,  0,  0,  1,  2,  2,  2,  1,  0,  0,  0,
-    2,  2,  2,  2,  1,  0, -1, -1,  1,  1,  1,  0, -1, -2, -2, -2,
-    0,  0,  0, -1, -2, -3, -2, -2, -1, -1, -1, -2, -2, -2, -1,  0,
-   -1, -1, -1, -1,  0,  0,  1,  2, -1, -1, -1,  0,  1,  2,  3,  4,
-   -1, -1,  0,  0, -1, -2, -3, -3, -1, -1,  0,  0,  0, -1, -1, -1,
-   -2, -2, -1,  0,  1,  1,  1,  1, -2, -2, -2,  0,  1,  2,  3,  3,
-   -1, -1, -1,  0,  1,  3,  3,  3,  1,  0,  0,  0,  1,  1,  2,  2,
-    2,  2,  1,  0,  0, -1, -1, -1,  3,  2,  1,  0, -1, -2, -3, -3,
-   -1, -1, -1, -2, -2, -3, -4, -5,  0,  0,  0, -1, -1, -3, -3, -4,
-    1,  1,  1,  0,  0, -1, -2, -3,  2,  2,  2,  1,  1,  0, -1, -1,
-    2,  2,  2,  2,  1,  1,  0, -1,  2,  2,  2,  2,  2,  1,  0,  0,
-    1,  1,  2,  1,  1,  1,  0,  0,  0,  0,  1,  1,  0,  0,  0, -1,
-   -2,  2,  3,  1, -1,  1,  1, -1, -3,  2,  3,  0, -1,  1,  1, -1,
-   -3,  2,  3,  0, -1,  1,  1, -1, -4,  2,  3,  0, -1,  1,  1, -2,
-   -4,  1,  3,  0, -1,  1,  1, -2, -4,  1,  3, -1, -2,  1,  1, -2,
-   -3,  1,  2,  0, -1,  1,  1, -2, -3,  1,  2,  0, -1,  1,  1, -1,
-   -1, -1, -1, -2, -2, -2, -2, -2,  1,  1,  1,  1,  0,  0,  0,  0,
-    1,  2,  2,  2,  2,  2,  2,  2,  0,  0,  1,  1,  1,  2,  2,  2,
-   -2, -2, -1, -1, -1,  0,  0,  0, -3, -3, -3, -3, -3, -3, -3, -2,
-   -1, -1, -1, -1, -2, -2, -2, -2,  4,  4,  4,  4,  4,  3,  3,  2,
-   -3, -3, -2, -1,  0,  1,  2,  5, -3, -3, -3, -2, -1,  1,  3,  6,
-   -3, -3, -2, -2,  0,  2,  3,  5, -3, -2, -2, -2,  0,  1,  3,  5,
-   -2, -2, -2, -1, -1,  1,  3,  5, -2, -2, -1, -1,  0,  1,  2,  4,
-   -1, -1, -1, -1,  0,  1,  1,  4, -1, -1, -1, -1,  0,  1,  2,  3,
-    0, -1,  0,  1,  1,  0, -1, -1,  0,  0,  0,  1,  2,  0, -1, -1,
-    1,  0, -1,  0,  1,  0,  0,  0,  1, -1, -2, -1,  0,  0,  0,  0,
-    1, -2, -3, -1,  0,  0,  0,  1,  1, -1, -3, -2,  0,  1,  1,  2,
-    1, -1, -2, -1,  0,  1,  1,  2,  2,  0, -1,  0,  1,  1,  2,  2,
-    1,  1,  1,  1,  0,  0,  1,  2, -1,  0,  0, -1,  0,  0,  0,  1,
-   -3, -2, -1, -1, -1,  0,  1,  1, -4, -2, -1,  0,  0,  1,  1,  1,
-   -3, -2,  0,  0,  1,  1,  1,  1, -3, -1,  0,  1,  1,  1,  0,  0,
-   -1,  0,  1,  1,  1,  0,  0, -1,  0,  1,  2,  2,  1,  0,  0, -1,
-   -4, -4, -4, -3, -2, -1, -1, -1, -2, -2, -2, -1,  0,  0,  0,  0,
-   -1,  0,  0,  0,  1,  1,  1,  1,  0,  0,  1,  1,  1,  1,  1,  1,
-    0,  0,  1,  1,  2,  2,  1,  0,  0,  0,  1,  1,  1,  1,  1,  0,
-    0,  0,  0,  1,  1,  1,  1,  0, -1,  0,  0,  1,  1,  1,  0,  0,
-    1,  2,  2,  2,  1, -1, -2, -4,  1,  1,  2,  2,  1,  0, -2, -4,
-    0,  1,  1,  1,  1,  0, -1, -3, -1,  0,  1,  1,  0,  0, -1, -2,
-   -1,  0,  1,  1,  1,  0,  0, -1, -2, -1,  0,  0,  0,  0,  0, -1,
-   -1, -1,  0,  1,  1,  0,  0,  0, -1,  0,  1,  1,  1,  1,  1,  0,
-    2,  2,  0, -1, -2, -1, -1, -2,  1,  1, -1, -2, -2, -1, -1, -2,
-    1,  1, -1, -2, -2,  0,  0, -1,  1,  1,  0, -2, -1,  1,  1,  0,
-    1,  1,  0, -1, -1,  1,  2,  1,  1,  1,  0, -1, -1,  1,  2,  1,
-    1,  1,  0, -1, -1,  1,  1,  1,  1,  1,  0, -1,  0,  1,  1,  1,
-    0,  0, -1, -2, -4, -4, -4, -4,  3,  3,  3,  2,  1,  0,  0,  0,
-    3,  3,  3,  3,  2,  2,  2,  2,  0,  0,  0,  0,  0,  0,  0,  1,
-   -1, -1, -1, -1, -1, -1, -1,  0,  0, -1,  0,  0, -1,  0,  0,  0,
-    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, -1, -1,  0,
-   -1, -1,  0, -1, -1,  1,  2, -1,  1,  1,  0,  0,  0,  2,  3, -1,
-    1,  1,  0, -1, -1,  1,  3, -1,  1,  1,  0, -2, -2,  0,  1, -2,
-    1,  0,  0, -2, -2,  0,  1, -3,  0,  0,  0,  0, -1,  1,  1, -3,
-    0,  1,  1,  0,  1,  2,  1, -3, -1,  0,  1,  1,  1,  2,  1, -4,
-   -4, -3,  0,  1,  1,  1,  0,  0, -4, -2,  0,  1,  1,  1,  0, -1,
-   -3, -1,  1,  1,  1,  0, -1, -1, -1,  1,  1,  1,  1,  0, -1,  0,
-    1,  2,  2,  1,  0, -1,  0,  0,  2,  2,  1,  0, -1, -1,  0,  1,
-    2,  1,  0, -1, -2, -1,  0,  1,  2,  2,  0, -1, -2, -1,  1,  1,
-    1,  1,  0,  0, -1, -1, -1, -1,  0, -1, -1, -1, -1, -1, -1, -1,
-   -1, -1, -1, -1, -1, -1, -1, -1,  0,  0, -1, -1, -1, -1, -1, -1,
-    1,  0,  0, -1, -1, -1, -1, -1,  2,  1,  0,  0, -1, -1, -1, -1,
-    5,  3,  2,  1,  0,  0,  0,  0,  6,  5,  3,  2,  1,  0,  0,  0,
-    4,  4,  3,  1,  0,  0,  0,  1,  3,  3,  2,  1,  0,  0,  0,  1,
-    2,  2,  1,  0, -1, -1,  0,  1,  0,  0,  0, -1, -1, -1,  0,  1,
-    0,  0, -1, -1, -2, -1,  0,  2,  0, -1, -1, -2, -2, -2,  0,  1,
-    0, -1, -1, -2, -2, -2, -1,  0,  0,  0, -1, -2, -2, -2, -1,  0,
-    0,  0, -1, -1, -1,  0,  2,  3,  0, -1, -2, -2, -1, -1,  1,  2,
-    1,  0, -1, -1, -1,  0,  0,  0,  1,  1,  1,  0,  0,  0, -1, -1,
-    1,  2,  1,  0,  0, -1, -1, -1, -1,  0,  0,  0, -1, -1, -1, -1,
-   -3, -2, -1, -1,  0,  1,  1,  2, -4, -3, -1,  1,  2,  3,  5,  5,
-    0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1,  1,  1,  1,
-    0,  0,  0, -1,  0,  0,  0,  1, -1, -1, -2, -2, -2, -1, -1,  0,
-    0,  0,  0,  0,  0,  1,  1,  1,  2,  2,  2,  2,  2,  3,  3,  3,
-    1,  1,  1,  1,  2,  2,  1,  1, -4, -3, -4, -4, -4, -4, -3, -3,
-   -1,  0,  1,  2,  2,  3,  3,  3, -1, -1, -1, -1,  0,  0,  0,  0,
-    0,  0, -1, -2, -2, -3, -3, -2,  3,  2,  1,  0, -1, -2, -2, -2,
-    4,  3,  2,  1,  1,  0,  0,  0,  2,  2,  1,  1,  0,  1,  1,  1,
-    0, -1, -1, -1, -1,  0,  0,  1, -2, -2, -2, -2, -2, -1,  0,  0,
-    1, -1,  0,  2,  1, -2, -1,  1,  1, -1,  0,  2,  1, -2, -2,  1,
-    1, -1,  0,  3,  2, -2, -1,  1,  0, -2,  0,  3,  2, -2, -2,  1,
-    0, -2,  0,  3,  2, -2, -2,  1,  0, -2,  0,  3,  1, -2, -1,  1,
-    0, -2,  0,  2,  1, -2, -2,  1,  0, -1,  0,  2,  1, -2, -1,  1,
-    0,  1,  2,  2,  3,  3,  2,  2,  0,  1,  1,  2,  3,  3,  2,  1,
-    0,  0,  1,  2,  2,  2,  2,  1, -1,  0,  0,  1,  1,  1,  1,  1,
-   -1, -1,  0,  0,  0,  0,  0,  0, -1, -1, -1, -1, -1, -1, -1, -1,
-   -2, -2, -2, -2, -2, -2, -2, -1, -2, -2, -2, -2, -2, -2, -2, -1,
-    0,  0, -1, -2, -1,  0,  3,  5,  0,  0, -1, -1, -1,  0,  2,  4,
-    1,  1,  0,  0, -1, -1,  1,  2,  1,  2,  1,  1,  0, -1, -1,  0,
-    0,  1,  2,  1,  0, -1, -2, -2, -1,  0,  1,  2,  1,  0, -3, -3,
-   -2, -1,  1,  2,  2,  0, -2, -4, -2, -1,  0,  2,  2,  1, -1, -3,
-    0,  0,  0,  0,  0,  0, -1, -1,  0,  0, -1,  0,  0,  0,  0,  0,
-   -1, -1, -1, -1,  0,  0,  0,  0, -1, -1, -1, -1, -1, -1, -1,  0,
-   -1, -1, -1, -1, -1, -1, -1,  0, -1,  0,  0,  0,  0, -1, -1,  0,
-    0,  0,  1,  1,  0,  0,  0,  1,  3,  3,  3,  4,  3,  3,  3,  3,
-    5,  1, -2, -2,  0,  0,  0, -1,  4, -1, -3, -1,  0,  0,  0, -1,
-    3, -1, -1,  0,  1,  1,  0, -1,  2,  0,  0,  1,  1,  1,  0, -2,
-    1,  0,  0,  1,  1,  1,  0, -2,  0, -1, -1, -1,  0,  0,  0, -1,
-    0, -1, -1, -1, -1,  0,  0, -1,  2,  1,  0,  0,  0,  1,  0,  0,
-    1,  0,  1,  1,  1,  1,  0,  0,  1,  0,  0,  1,  1,  0,  0,  0,
-    1, -1, -1,  0,  0,  0,  0,  0,  2,  0, -1, -1, -1, -1, -1,  0,
-    3,  1, -1, -1, -2, -2, -2, -1,  4,  2,  1,  0, -1, -2, -2, -1,
-    2,  1,  0,  0, -1, -1,  0,  0,  0, -1, -1, -1, -1,  0,  1,  1,
-    0,  1,  2,  2,  2,  1, -1, -3,  0,  0,  1,  1,  1,  0, -1, -2,
-    0,  0,  0,  0,  0,  0, -1, -1,  0,  0, -1,  0,  0,  1,  1,  0,
-    0,  0, -1,  0,  1,  1,  1,  1,  0,  0,  0,  0,  1,  1,  1,  0,
-    0,  0,  1,  1,  2,  1, -1, -3,  0,  0,  0,  1,  1, -1, -4, -5,
-   -2, -2, -2, -1,  0,  2,  2,  2,  0,  0,  0,  0,  1,  1,  1,  0,
-    1,  1,  1,  1,  1,  0, -2, -3,  0,  0,  1,  1,  0, -1, -3, -4,
-   -1, -1,  0,  1,  0,  0, -2, -3, -1, -1,  0,  1,  1,  1,  0, -1,
-    0,  0,  0,  1,  1,  1,  1,  0,  1,  1,  1,  1,  0,  0,  0,  0,
-    0,  1,  0,  0,  1,  1,  1,  2,  1,  2,  0,  0,  0,  0, -1,  1,
-    0,  2,  0, -1,  1,  0, -1,  0,  0,  1,  0,  0,  2,  1,  0,  1,
-    0,  1, -1,  0,  2,  2,  0,  1, -1,  0, -1, -1,  2,  1,  1,  2,
-   -2, -2, -3, -2,  0,  1,  1,  1, -2, -2, -3, -3, -1, -1, -1,  0,
-   -3, -1,  0,  1,  2,  1,  1,  0, -3, -1,  0,  1,  2,  1,  1,  1,
-   -2,  0,  0,  1,  1,  1,  1,  1, -1,  0,  0,  0,  0,  0,  0,  0,
-   -2,  0,  0,  0,  0, -1, -1,  0, -2,  0,  0,  0,  0,  0, -1, -1,
-   -3,  0,  1,  1,  1,  1,  0,  1, -5, -2,  0,  1,  2,  2,  1,  2,
-   -2, -1, -1,  0,  0,  1,  2,  3,  0,  0,  1,  1,  0,  0,  1,  2,
-    0,  0,  1,  0, -1, -1,  0,  1, -1, -1, -1, -1, -2, -2, -1,  0,
-   -2, -2, -2, -2, -2, -1,  0,  1,  0,  0,  0, -1,  0,  1,  2,  2,
-    2,  1,  0,  0,  0,  1,  2,  2,  2,  1,  0, -1, -1, -1,  0,  0,
-    0,  1,  1,  1,  1,  1, -1, -4, -1, -1,  0,  1,  1,  1,  0, -3,
-   -2, -1,  0,  0,  1,  2,  2, -2, -1,  0,  0,  0,  0,  2,  3, -1,
-   -1,  0,  0,  0,  0,  1,  2,  0,  0,  0, -1, -2, -1,  1,  1,  0,
-    0,  0, -1, -2, -2,  0,  2,  1,  0,  0, -1, -2, -1,  1,  2,  2,
-    1,  0,  0,  0, -2, -3, -2, -3,  0,  0,  1,  0, -2, -2, -1, -1,
-    0, -1,  1,  1, -1, -1,  0,  0,  0, -1,  1,  1, -1, -1,  0,  0,
-    0,  1,  2,  1, -1, -1,  0,  1,  1,  2,  3,  2,  0,  0,  1,  2,
-   -1,  0,  2,  1,  0,  0,  2,  3, -2, -1,  0,  0, -1,  0,  1,  2,
-    1,  1,  0, -1, -2, -2, -1,  1,  1,  1,  1, -1, -2, -2,  0,  2,
-    1,  1,  1, -1, -1, -1,  0,  2,  0,  0,  0,  0,  0,  0,  1,  2,
-   -1, -1, -1,  0,  0,  0,  1,  2, -1, -2, -1,  1,  1,  1,  0,  0,
-   -1, -2, -1,  1,  2,  2,  0, -1, -1, -2, -1,  2,  2,  2,  0, -1,
-   -1, -1, -1, -2, -1, -1,  0,  1,  0,  0, -1, -1, -1,  0,  1,  2,
-    1,  0,  0,  0,  0,  1,  1,  2,  1,  1,  0,  0,  1,  1,  1,  1,
-    1,  1,  0,  1,  1,  0,  1,  1,  1,  1,  1,  1,  0, -1, -1, -1,
-    1,  2,  1,  0, -1, -2, -2, -3,  2,  2,  1,  0, -2, -3, -4, -4,
-   -4, -2,  1,  1,  1,  1,  0,  0, -2,  0,  1,  0,  0,  0,  0,  0,
-    0,  1,  1, -2, -2, -1,  0,  1,  2,  2,  1, -2, -2, -1,  1,  2,
-    1,  2,  1, -2, -2, -1,  1,  2, -1,  1,  1, -1, -1, -1,  0,  1,
-   -2,  0,  1,  1,  0, -1, -1,  0, -2,  0,  2,  2,  1, -1, -1,  0,
-    1,  1,  0,  0,  0,  1,  0,  0, -2, -3, -3, -2, -2, -1,  0,  0,
-   -3, -4, -3, -2, -1,  0,  0,  0, -1, -1,  0,  1,  2,  3,  2,  1,
-    0,  1,  2,  3,  3,  3,  2,  1,  1,  1,  1,  2,  1,  0,  0, -1,
-    0,  0,  0,  0, -1, -1, -1, -1,  0, -1, -1,  0,  0,  0,  0,  0,
-    1,  1,  0,  0, -1, -1,  0,  2,  0,  0,  1,  0, -1, -1,  1,  1,
-   -2, -1,  0,  1,  1,  1,  1,  1, -3, -3,  0,  2,  2,  1,  1,  0,
-   -2, -2,  0,  1,  1,  1,  0,  0,  1,  0,  0,  0,  0,  0, -1, -1,
-    3,  1, -1, -3, -2, -1,  0,  1,  4,  2, -1, -3, -3, -1,  1,  2,
-    0,  0,  0, -1, -1, -1, -1, -1,  1,  2,  1,  0,  0,  0, -1, -1,
-    2,  3,  3,  2,  1,  0, -1, -1,  3,  4,  4,  2,  1,  0, -1, -2,
-    3,  3,  2,  1,  0, -1, -2, -2,  1,  1,  0, -1, -1, -2, -2, -3,
-    0,  0,  0, -1, -1, -2, -2, -2, -1, -1, -1, -1, -1, -2, -2, -1,
-    1,  2,  2,  2,  2,  1,  2,  2,  0,  1,  1,  1,  1,  0,  0,  0,
-    0,  0,  0,  1,  1,  0, -1, -2,  0,  0,  0,  0,  1,  0, -1, -4,
-    1,  0,  0,  0,  0,  0, -2, -5,  1,  0,  0,  0,  0,  0, -1, -4,
-    1,  0, -1,  0,  0,  0, -1, -3,  0, -1, -1,  0,  1,  1,  1, -1,
-   -2, -1,  0,  0, -1, -1, -1, -2, -1,  0,  0,  0, -1, -1, -2, -2,
-    0,  1,  1,  0, -1, -1, -1, -2,  0,  1,  1,  0,  0,  0, -1, -1,
-    0,  1,  0,  0,  1,  1,  1,  0,  1,  1,  0,  0,  1,  2,  2,  1,
-    1,  1,  0,  0,  1,  2,  2,  1,  1,  1,  0, -1,  0,  1,  1,  0,
-    4,  2,  1,  0,  0,  1,  1,  1,  4,  2,  1,  0,  0,  0,  0,  1,
-    3,  1,  0,  0, -1, -1, -1,  0,  1,  0,  0, -1, -1, -2, -1,  0,
-    0,  0,  0,  0, -1, -1, -1,  0, -1, -1,  0,  0, -1, -1,  0,  1,
-   -2, -1,  0, -1, -1,  0,  0,  1, -2, -2, -1, -2, -1,  0,  0,  1,
-    0,  1,  1,  1,  2,  1,  0, -1, -1, -1, -1,  0,  0, -1, -2, -2,
-   -1,  0, -1,  0,  0, -1, -2, -1,  0,  0,  0,  0,  0,  0,  1,  2,
-    0,  0,  0,  0,  0,  0,  2,  3, -1,  0, -1, -1, -1, -1,  0,  3,
-   -1,  0,  0, -1, -1, -2,  0,  3,  0,  0,  0,  0, -1, -1,  1,  4,
-    2,  2,  0,  0,  0,  0,  0,  1,  1,  1, -1, -2, -1, -2, -1,  1,
-   -1, -1, -2, -2, -2, -3, -2,  0, -1,  0, -1, -1, -1, -2, -1,  1,
-    1,  1,  0,  0,  1,  0,  0,  1,  2,  2,  0,  0,  1,  0,  0,  1,
-    2,  2,  0,  0,  0,  0, -1, -1,  2,  2,  0,  0,  1,  0, -1, -1,
-   -1,  0,  1,  1,  0, -1, -1, -1,  1,  2,  3,  2,  1,  0,  0,  0,
-    0,  1,  1,  1,  0, -1,  0,  0, -2, -2, -1,  0,  1,  0,  0,  0,
-   -2, -2, -1,  2,  2,  2,  1,  0, -2, -1,  0,  1,  1,  0,  0, -1,
-   -1, -1,  0,  0, -1, -2, -1, -2,  0,  1,  1,  1,  0,  0,  1,  1,
-   -3, -3, -3, -2, -1, -1, -2, -2, -1, -1,  0,  1,  2,  1,  0,  0,
-    1,  1,  1,  2,  2,  1,  0,  0,  1,  1,  1,  1,  1,  0, -1,  1,
-    1,  0, -1, -1,  0,  0, -1,  1,  0, -1, -1, -1,  0, -1, -1,  1,
-    1,  0, -1,  0,  0, -1,  0,  2,  2,  0, -1,  0,  0,  0,  0,  2,
-    1,  0, -2, -1,  0,  1,  1,  0,  2,  0, -1, -1,  0,  1,  1,  0,
-    1,  0, -2, -1,  0,  1,  0, -1,  1,  0, -1, -1,  0,  1,  0, -1,
-    0,  1,  1,  0,  1,  1,  0,  0, -2,  1,  2,  1,  0,  0,  0,  1,
-   -5,  0,  2,  1,  0, -1,  0,  1, -6, -1,  2,  1,  0, -1,  0,  0,
-    5,  3,  0, -1, -2, -1, -1, -1,  1,  1,  0, -1, -1,  0, -1, -1,
-   -1,  0,  1,  1,  2,  2,  1,  0, -2, -1,  0,  1,  2,  1,  1,  1,
-   -2, -1, -1, -1,  0, -1,  0,  1,  0,  1,  0,  0, -1, -1,  0,  0,
-    0,  1,  1,  1,  1,  0,  0,  0, -3, -2,  0,  1,  1,  0,  0, -1,
-   -1,  0,  1,  0, -1,  0,  2,  3, -1,  0,  0, -2, -4, -2, -1,  0,
-    0,  1,  1,  0, -2, -1,  0, -1,  1,  2,  3,  1,  0,  1,  1,  0,
-   -1,  0,  1,  1,  1,  1,  1,  0, -2, -3, -2,  0,  0,  0,  1,  0,
-   -1, -2, -2,  0,  1,  0,  0, -1,  3,  1,  0,  0,  1,  0, -1, -1,
-   -2, -1,  0,  0, -1, -1,  0,  0, -1,  0,  0,  0,  0,  1,  1,  1,
-   -1, -1, -1,  0,  1,  1,  1,  1,  0, -2, -3, -1,  1,  0,  0,  0,
-    1, -1, -3, -1,  1,  1,  0, -1,  3,  1, -1,  1,  2,  2,  0, -1,
-    3,  1,  0,  1,  2,  1,  1,  0,  0, -2, -2, -1, -1,  0,  0,  0,
-    1,  0, -1, -1,  1,  2,  1,  0,  0, -1, -2, -1,  1,  2,  2,  1,
-   -1, -1, -1,  0,  0,  1,  2,  0, -2,  0,  0,  0,  0,  0,  1, -1,
-   -1,  0,  1,  0, -1, -1, -1, -1,  0,  1,  1,  2,  0, -2, -1,  0,
-    1,  2,  2,  2,  1, -1, -1,  0,  0,  1,  1,  1,  0, -2, -2, -1,
-    0,  0, -1, -1, -1, -1, -2, -2,  0,  0, -1,  0,  1,  2,  2,  1,
-    0,  0, -1, -1,  0,  1,  2,  2,  1,  1, -1, -2, -1, -1, -1, -1,
-    2,  2,  1,  0,  0, -1, -2, -2,  1,  2,  2,  1,  0,  0, -2, -2,
-    0,  0,  0,  0,  1,  1,  0, -1,  0, -1, -1, -1,  2,  3,  2,  1,
-    0, -2,  1,  2, -1,  0,  0,  1, -1, -2,  2,  3, -1,  0,  0,  0,
-    0, -2,  2,  3, -1, -1,  0,  0,  0, -1,  3,  2, -2,  0,  1,  0,
-    0, -1,  3,  1, -2,  0,  1,  0,  0, -1,  2,  1, -1,  1,  0, -1,
-    0,  0,  1, -1, -2,  0,  0, -1,  1,  0,  0, -2, -2, -1, -1, -1,
-    1,  1,  1,  1,  1, -1, -1, -2,  0,  0,  0,  1,  1,  1,  1,  1,
-    0,  0,  0,  1,  1,  1,  2,  3,  1,  0,  0, -1,  0,  0,  1,  2,
-    0, -1, -1, -2, -1,  0,  1,  2, -2, -2, -2, -2, -1,  0,  1,  1,
-   -1, -1, -1, -1,  0,  0,  0, -1,  2,  2,  2,  0, -1, -1, -2, -4,
-   -1, -2, -1, -1,  0,  1,  2,  3, -1, -1, -1, -1,  0,  1,  2,  3,
-    1,  0, -1,  0, -1,  0,  1,  2,  1,  0,  0,  0, -1,  0,  2,  2,
-    1,  0, -1, -1, -2,  0,  1,  2,  0, -2, -2, -2, -3, -1,  0,  1,
-    0, -2, -2, -2, -2, -1,  1,  1,  0,  0,  0,  0,  0,  1,  2,  2
-};
-
-/* list of codebooks for intra-coded vectors */
-static const int8_t* const svq1_intra_codebooks[4] = {
-    svq1_intra_codebook_4x2, svq1_intra_codebook_4x4,
-    svq1_intra_codebook_8x4, svq1_intra_codebook_8x8
-};
-
-static const int8_t svq1_intra_codebook_sum[4][16*6] = {
- {
-  0,  0,  0, -1, -1, -1, -1, -2,  0, -1, -1,  0, -1,  0,  1,  0,
-  1,  0, -1,  1,  0,  0, -1,  1, -1,  0,  0,  0, -1,  1,  0,  0,
- -1,  0,  0,  1, -1,  1,  0, -1, -1,  0,  1,  1,  0,  0, -1,  1,
-  0,  1,  0,  0,  1, -1,  0,  0,  0, -1,  1,  0,  1,  0, -2,  1,
-  0, -1,  1,  0,  0,  0,  1,  0, -1,  0,  0,  0, -1,  0,  0,  0,
-  0,  1,  1,  0,  0, -1,  0,  1,  0,  0,  0,  0, -1,  1,  1, -1,
- },{
- -1, -2,  0, -1,  1,  0, -1,  0, -1, -4, -1, -2, -1, -2,  1, -2,
-  0,  0,  4, -2, -1,  1,  1,  0,  2,  1,  1,  0,  2,  0,  0,  0,
-  1,  1,  0, -1, -1, -1,  1,  0, -1, -3, -3,  1, -1,  1, -2, -1,
-  1, -1,  0,  1,  2,  1, -1, -1,  1,  1,  1,  2,  1,  0,  1, -2,
- -2,  0, -1, -2, -2,  0, -1, -1, -1,  0,  1,  0, -1, -1,  0, -1,
-  0,  2,  1,  2,  2,  1, -1,  1,  0,  2,  0, -1,  1,  0,  0,  0,
- },{
- -2,  0, -1, -1,  1,  1, -2,  0, -2,  0,  1, -2, -2,  1, -1, -1,
-  3, -2,  0, -3, -4, -3,  2,  1,  0,  3, -2,  2,  3,  2,  2, -1,
- -3,  1,  0,  1,  0,  0,  0,  1, -2,  1, -2, -2, -1, -2, -2,  2,
-  0, -4,  0,  2, -1,  0,  2,  2,  2,  1,  0, -1, -1,  1, -3,  2,
-  2,  1,  0,  3,  1, -1,  1,  3,  1,  0,  1,  1,  2, -1,  1, -1,
- -2, -1,  0, -1,  1, -1,  1, -2, -2, -1, -1, -3,  1, -4, -3,  1,
- },{
- -2,  0, -2,  3, -1, -1,  0,  2,  2, -1, -3,  2,  1,  0, -2, -1,
- -3, -2, -2,  1,  2, -3,  0,  1, -5, -2, -3,  0, -2, -1,  2,  0,
- -1, -1,  0, -2,  1,  3, -7, -2, -2, -1,  2, -1,  0,  3,  1,  3,
-  1,  0,  0,  1,  2,  3,  1,  2,  0, -2, -2,  1,  1,  2,  2,  3,
-  4,  1, -1,  2, -2,  4,  0,  0,  0,  4,  2,  0, -2, -2,  2, -4,
- -1,  5, -2, -2, -3,  2, -3, -1,  3, -3,  0,  4,  3,  0,  1, -2,
- }
-};
diff --git a/ffmpeg.src/libavcodec/utils.c b/ffmpeg.src/libavcodec/utils.c
deleted file mode 100644
index 26c5645..0000000
--- a/ffmpeg.src/libavcodec/utils.c
+++ /dev/null
@@ -1,1297 +0,0 @@
-/*
- * utils for libavcodec
- * Copyright (c) 2001 Fabrice Bellard.
- * Copyright (c) 2003 Michel Bardiaux for the av_log API
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-/**
- * @file utils.c
- * utils.
- */
- 
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-#include "integer.h"
-#include "opt.h"
-#include <stdarg.h>
-#include <limits.h>
-#include <float.h>
-
-const uint8_t ff_reverse[256]={
-0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0,
-0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,
-0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4,
-0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,
-0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2,
-0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,
-0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6,
-0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,
-0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1,
-0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9,
-0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
-0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD,
-0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,
-0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB,
-0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,
-0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF,
-};
-
-static int volatile entangled_thread_counter=0;
-
-void avcodec_default_free_buffers(AVCodecContext *s);
-
-void *av_mallocz(unsigned int size)
-{
-    void *ptr;
-    
-    ptr = av_malloc(size);
-    if (!ptr)
-        return NULL;
-    memset(ptr, 0, size);
-    return ptr;
-}
-
-char *av_strdup(const char *s)
-{
-    char *ptr;
-    int len;
-    len = strlen(s) + 1;
-    ptr = av_malloc(len);
-    if (!ptr)
-        return NULL;
-    memcpy(ptr, s, len);
-    return ptr;
-}
-
-/**
- * realloc which does nothing if the block is large enough
- */
-void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size)
-{
-    if(min_size < *size) 
-        return ptr;
-    
-    *size= FFMAX(17*min_size/16 + 32, min_size);
-
-    return av_realloc(ptr, *size);
-}
-
-
-static unsigned int last_static = 0;
-static unsigned int allocated_static = 0;
-static void** array_static = NULL;
-
-/**
- * allocation of static arrays - do not use for normal allocation.
- */
-void *av_mallocz_static(unsigned int size)
-{
-    void *ptr = av_mallocz(size);
-
-    if(ptr){ 
-        array_static =av_fast_realloc(array_static, &allocated_static, sizeof(void*)*(last_static+1));
-        if(!array_static)
-            return NULL;
-        array_static[last_static++] = ptr;
-    }
-
-    return ptr;
-}
-
-/**
- * same as above, but does realloc
- */
-
-void *av_realloc_static(void *ptr, unsigned int size)
-{
-    int i;
-    if(!ptr)
-      return av_mallocz_static(size);
-    /* Look for the old ptr */
-    for(i = 0; i < last_static; i++) {
-        if(array_static[i] == ptr) {
-            array_static[i] = av_realloc(array_static[i], size);
-            return array_static[i];
-        }
-    }
-    return NULL;
-
-}
-
-/**
- * free all static arrays and reset pointers to 0.
- */
-void av_free_static(void)
-{
-    while(last_static){
-        av_freep(&array_static[--last_static]);
-    }
-    av_freep(&array_static);
-}
-
-/**
- * Call av_free_static automatically before it's too late
- */
-
-static void do_free() __attribute__ ((destructor));
-
-static void do_free()
-{
-    av_free_static();
-}
-
-/**
- * Frees memory and sets the pointer to NULL.
- * @param arg pointer to the pointer which should be freed
- */
-void av_freep(void *arg)
-{
-    void **ptr= (void**)arg;
-    av_free(*ptr);
-    *ptr = NULL;
-}
-
-/* encoder management */
-AVCodec *first_avcodec = NULL;
-
-void register_avcodec(AVCodec *format)
-{
-    AVCodec **p;
-    p = &first_avcodec;
-    while (*p != NULL) p = &(*p)->next;
-    *p = format;
-    format->next = NULL;
-}
-
-void avcodec_set_dimensions(AVCodecContext *s, int width, int height){
-    s->coded_width = width;
-    s->coded_height= height;
-    s->width = -((-width )>>s->lowres);
-    s->height= -((-height)>>s->lowres);
-}
-
-typedef struct InternalBuffer{
-    int last_pic_num;
-    uint8_t *base[4];
-    uint8_t *data[4];
-    int linesize[4];
-}InternalBuffer;
-
-#define INTERNAL_BUFFER_SIZE 32
-
-#define ALIGN(x, a) (((x)+(a)-1)&~((a)-1))
-
-void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
-    int w_align= 1;    
-    int h_align= 1;    
-    
-    switch(s->pix_fmt){
-    case PIX_FMT_YUV420P:
-    case PIX_FMT_YUV422:
-    case PIX_FMT_UYVY422:
-    case PIX_FMT_YUV422P:
-    case PIX_FMT_YUV444P:
-    case PIX_FMT_GRAY8:
-    case PIX_FMT_YUVJ420P:
-    case PIX_FMT_YUVJ422P:
-    case PIX_FMT_YUVJ444P:
-        w_align= 16; //FIXME check for non mpeg style codecs and use less alignment
-        h_align= 16;
-        break;
-    case PIX_FMT_YUV411P:
-    case PIX_FMT_UYVY411:
-        w_align=32;
-        h_align=8;
-        break;
-    case PIX_FMT_YUV410P:
-        if(s->codec_id == CODEC_ID_SVQ1){
-            w_align=64;
-            h_align=64;
-        }
-    case PIX_FMT_RGB555:
-        if(s->codec_id == CODEC_ID_RPZA){
-            w_align=4;
-            h_align=4;
-        }
-    case PIX_FMT_PAL8:
-        if(s->codec_id == CODEC_ID_SMC){
-            w_align=4;
-            h_align=4;
-        }
-        break;
-    case PIX_FMT_BGR24:
-        if((s->codec_id == CODEC_ID_MSZH) || (s->codec_id == CODEC_ID_ZLIB)){
-            w_align=4;
-            h_align=4;
-        }
-        break;
-    default:
-        w_align= 1;
-        h_align= 1;
-        break;
-    }
-
-    *width = ALIGN(*width , w_align);
-    *height= ALIGN(*height, h_align);
-}
-
-int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){
-    if((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/4)
-        return 0;
-    
-    av_log(av_log_ctx, AV_LOG_ERROR, "picture size invalid (%ux%u)\n", w, h);
-    return -1;
-}
-
-int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
-    int i;
-    int w= s->width;
-    int h= s->height;
-    InternalBuffer *buf;
-    int *picture_number;
-
-    assert(pic->data[0]==NULL);
-    assert(INTERNAL_BUFFER_SIZE > s->internal_buffer_count);
-
-    if(avcodec_check_dimensions(s,w,h))
-        return -1;
-
-    if(s->internal_buffer==NULL){
-        s->internal_buffer= av_mallocz(INTERNAL_BUFFER_SIZE*sizeof(InternalBuffer));
-    }
-#if 0
-    s->internal_buffer= av_fast_realloc(
-        s->internal_buffer, 
-        &s->internal_buffer_size, 
-        sizeof(InternalBuffer)*FFMAX(99,  s->internal_buffer_count+1)/*FIXME*/
-        );
-#endif
-     
-    buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
-    picture_number= &(((InternalBuffer*)s->internal_buffer)[INTERNAL_BUFFER_SIZE-1]).last_pic_num; //FIXME ugly hack
-    (*picture_number)++;
-    
-    if(buf->base[0]){
-        pic->age= *picture_number - buf->last_pic_num;
-        buf->last_pic_num= *picture_number;
-    }else{
-        int h_chroma_shift, v_chroma_shift;
-        int pixel_size;
-        
-        avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
-        
-        switch(s->pix_fmt){
-        case PIX_FMT_RGB555:
-        case PIX_FMT_RGB565:
-        case PIX_FMT_YUV422:
-        case PIX_FMT_UYVY422:
-            pixel_size=2;
-            break;
-        case PIX_FMT_RGB24:
-        case PIX_FMT_BGR24:
-            pixel_size=3;
-            break;
-        case PIX_FMT_RGBA32:
-            pixel_size=4;
-            break;
-        default:
-            pixel_size=1;
-        }
-
-        avcodec_align_dimensions(s, &w, &h);
-            
-        if(!(s->flags&CODEC_FLAG_EMU_EDGE)){
-            w+= EDGE_WIDTH*2;
-            h+= EDGE_WIDTH*2;
-        }
-        
-        buf->last_pic_num= -256*256*256*64;
-
-        for(i=0; i<3; i++){
-            const int h_shift= i==0 ? 0 : h_chroma_shift;
-            const int v_shift= i==0 ? 0 : v_chroma_shift;
-
-            //FIXME next ensures that linesize= 2^x uvlinesize, thats needed because some MC code assumes it
-            buf->linesize[i]= ALIGN(pixel_size*w>>h_shift, STRIDE_ALIGN<<(h_chroma_shift-h_shift)); 
-
-            buf->base[i]= av_malloc((buf->linesize[i]*h>>v_shift)+16); //FIXME 16
-            if(buf->base[i]==NULL) return -1;
-            memset(buf->base[i], 128, buf->linesize[i]*h>>v_shift);
-        
-            if(s->flags&CODEC_FLAG_EMU_EDGE)
-                buf->data[i] = buf->base[i];
-            else
-                buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), STRIDE_ALIGN);
-        }
-        pic->age= 256*256*256*64;
-    }
-    pic->type= FF_BUFFER_TYPE_INTERNAL;
-
-    for(i=0; i<4; i++){
-        pic->base[i]= buf->base[i];
-        pic->data[i]= buf->data[i];
-        pic->linesize[i]= buf->linesize[i];
-    }
-    s->internal_buffer_count++;
-
-    return 0;
-}
-
-void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
-    int i;
-    InternalBuffer *buf, *last, temp;
-
-    assert(pic->type==FF_BUFFER_TYPE_INTERNAL);
-    assert(s->internal_buffer_count);
-
-    buf = NULL; /* avoids warning */
-    for(i=0; i<s->internal_buffer_count; i++){ //just 3-5 checks so is not worth to optimize
-        buf= &((InternalBuffer*)s->internal_buffer)[i];
-        if(buf->data[0] == pic->data[0])
-            break;
-    }
-    assert(i < s->internal_buffer_count);
-    s->internal_buffer_count--;
-    last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];
-
-    temp= *buf;
-    *buf= *last;
-    *last= temp;
-
-    for(i=0; i<3; i++){
-        pic->data[i]=NULL;
-//        pic->base[i]=NULL;
-    }
-//printf("R%X\n", pic->opaque);
-}
-
-int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){
-    AVFrame temp_pic;
-    int i;
-
-    /* If no picture return a new buffer */
-    if(pic->data[0] == NULL) {
-        /* We will copy from buffer, so must be readable */
-        pic->buffer_hints |= FF_BUFFER_HINTS_READABLE;
-        return s->get_buffer(s, pic);
-    }
-
-    /* If internal buffer type return the same buffer */
-    if(pic->type == FF_BUFFER_TYPE_INTERNAL)
-        return 0;
-
-    /*
-     * Not internal type and reget_buffer not overridden, emulate cr buffer
-     */
-    temp_pic = *pic;
-    for(i = 0; i < 4; i++)
-        pic->data[i] = pic->base[i] = NULL;
-    pic->opaque = NULL;
-    /* Allocate new frame */
-    if (s->get_buffer(s, pic))
-        return -1;
-    /* Copy image data from old buffer to new buffer */
-    img_copy((AVPicture*)pic, (AVPicture*)&temp_pic, s->pix_fmt, s->width,
-             s->height);
-    s->release_buffer(s, &temp_pic); // Release old frame
-    return 0;
-}
-
-int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count){
-    int i;
-
-    for(i=0; i<count; i++){
-        int r= func(c, arg[i]);
-        if(ret) ret[i]= r;
-    }
-    return 0;
-}
-
-enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt){
-    return fmt[0];
-}
-
-static const char* context_to_name(void* ptr) {
-    AVCodecContext *avc= ptr;
-
-    if(avc && avc->codec && avc->codec->name)
-        return avc->codec->name; 
-    else
-        return "NULL";
-}
-
-#define OFFSET(x) (int)&((AVCodecContext*)0)->x
-#define DEFAULT 0 //should be NAN but it doesnt work as its not a constant in glibc as required by ANSI/ISO C
-//these names are too long to be readable
-#define V AV_OPT_FLAG_VIDEO_PARAM
-#define A AV_OPT_FLAG_AUDIO_PARAM
-#define S AV_OPT_FLAG_SUBTITLE_PARAM
-#define E AV_OPT_FLAG_ENCODING_PARAM 
-#define D AV_OPT_FLAG_DECODING_PARAM
-
-static AVOption options[]={
-{"bit_rate", NULL, OFFSET(bit_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|A|E},
-{"bit_rate_tolerance", NULL, OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, V|A|E|D, "flags"},
-{"mv4", "use four motion vector by macroblock (mpeg4)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_4MV, INT_MIN, INT_MAX, V|E, "flags"},
-{"obmc", "use overlapped block motion compensation (h263+)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_OBMC, INT_MIN, INT_MAX, V|E, "flags"},
-{"qpel", "use 1/4 pel motion compensation", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_QPEL, INT_MIN, INT_MAX, V|E, "flags"},
-{"loop", "use loop filter", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_LOOP_FILTER, INT_MIN, INT_MAX, V|E, "flags"},
-{"qscale", "use fixed qscale", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_QSCALE, INT_MIN, INT_MAX, 0, "flags"},
-{"gmc", "use gmc", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_GMC, INT_MIN, INT_MAX, V|E, "flags"},
-{"mv0", "always try a mb with mv=<0,0>", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_MV0, INT_MIN, INT_MAX, V|E, "flags"},
-{"part", "use data partitioning", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_PART, INT_MIN, INT_MAX, V|E, "flags"},
-{"input_preserved", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG_INPUT_PRESERVED, INT_MIN, INT_MAX, 0, "flags"},
-{"pass1", "use internal 2pass ratecontrol in first  pass mode", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_PASS1, INT_MIN, INT_MAX, 0, "flags"},
-{"pass2", "use internal 2pass ratecontrol in second pass mode", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_PASS2, INT_MIN, INT_MAX, 0, "flags"},
-{"extern_huff", "use external huffman table (for mjpeg)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_EXTERN_HUFF, INT_MIN, INT_MAX, 0, "flags"},
-{"gray", "only decode/encode grayscale", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_GRAY, INT_MIN, INT_MAX, V|E|D, "flags"},
-{"emu_edge", "don't draw edges", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_EMU_EDGE, INT_MIN, INT_MAX, 0, "flags"},
-{"psnr", "error[?] variables will be set during encoding", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_PSNR, INT_MIN, INT_MAX, V|E, "flags"},
-{"truncated", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG_TRUNCATED, INT_MIN, INT_MAX, 0, "flags"},
-{"naq", "normalize adaptive quantization", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_NORMALIZE_AQP, INT_MIN, INT_MAX, V|E, "flags"},
-{"ildct", "use interlaced dct", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_INTERLACED_DCT, INT_MIN, INT_MAX, V|E, "flags"},
-{"low_delay", "force low delay", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_LOW_DELAY, INT_MIN, INT_MAX, V|D, "flags"},
-{"alt", "enable alternate scantable (mpeg2/mpeg4)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_ALT_SCAN, INT_MIN, INT_MAX, V|E, "flags"},
-{"trell", "use trellis quantization", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_TRELLIS_QUANT, INT_MIN, INT_MAX, V|E, "flags"},
-{"global_header", "place global headers in extradata instead of every keyframe", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_GLOBAL_HEADER, INT_MIN, INT_MAX, 0, "flags"},
-{"bitexact", "use only bitexact stuff (except (i)dct)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_BITEXACT, INT_MIN, INT_MAX, A|V|S|D|E, "flags"},
-{"aic", "h263 advanced intra coding / mpeg4 ac prediction", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_AC_PRED, INT_MIN, INT_MAX, V|E, "flags"},
-{"umv", "use unlimited motion vectors", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_H263P_UMV, INT_MIN, INT_MAX, V|E, "flags"},
-{"cbp", "use rate distortion optimization for cbp", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_CBP_RD, INT_MIN, INT_MAX, V|E, "flags"},
-{"qprd", "use rate distortion optimization for qp selectioon", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_QP_RD, INT_MIN, INT_MAX, V|E, "flags"},
-{"aiv", "h263 alternative inter vlc", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_H263P_AIV, INT_MIN, INT_MAX, V|E, "flags"},
-{"slice", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG_H263P_SLICE_STRUCT, INT_MIN, INT_MAX, V|E, "flags"},
-{"ilme", "interlaced motion estimation", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_INTERLACED_ME, INT_MIN, INT_MAX, V|E, "flags"},
-{"scan_offset", "will reserve space for svcd scan offset user data", 0, FF_OPT_TYPE_CONST, CODEC_FLAG_SVCD_SCAN_OFFSET, INT_MIN, INT_MAX, V|E, "flags"},
-{"cgop", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG_CLOSED_GOP, INT_MIN, INT_MAX, V|E, "flags"},
-{"fast", "allow non spec compliant speedup tricks", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_FAST, INT_MIN, INT_MAX, V|E, "flags2"},
-{"sgop", "strictly enforce gop size", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_STRICT_GOP, INT_MIN, INT_MAX, V|E, "flags2"},
-{"noout", "skip bitstream encoding", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_NO_OUTPUT, INT_MIN, INT_MAX, V|E, "flags2"},
-{"local_header", "place global headers at every keyframe instead of in extradata", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_LOCAL_HEADER, INT_MIN, INT_MAX, V|E, "flags2"},
-{"sub_id", NULL, OFFSET(sub_id), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"me_method", NULL, OFFSET(me_method), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "me_method"},
-{"extradata_size", NULL, OFFSET(extradata_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"time_base", NULL, OFFSET(time_base), FF_OPT_TYPE_RATIONAL, DEFAULT, INT_MIN, INT_MAX},
-{"gop_size", NULL, OFFSET(gop_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"rate_emu", NULL, OFFSET(rate_emu), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"sample_rate", NULL, OFFSET(sample_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"channels", NULL, OFFSET(channels), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"frame_size", NULL, OFFSET(frame_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"frame_number", NULL, OFFSET(frame_number), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"real_pict_num", NULL, OFFSET(real_pict_num), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"delay", NULL, OFFSET(delay), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"qcompress", NULL, OFFSET(qcompress), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"qblur", NULL, OFFSET(qblur), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"qmin", NULL, OFFSET(qmin), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"qmax", NULL, OFFSET(qmax), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"max_qdiff", NULL, OFFSET(max_qdiff), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"max_b_frames", NULL, OFFSET(max_b_frames), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"b_quant_factor", NULL, OFFSET(b_quant_factor), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"rc_strategy", NULL, OFFSET(rc_strategy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"b_frame_strategy", NULL, OFFSET(b_frame_strategy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"hurry_up", NULL, OFFSET(hurry_up), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
-{"rtp_mode", NULL, OFFSET(rtp_mode), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"rtp_payload_size", NULL, OFFSET(rtp_payload_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"mv_bits", NULL, OFFSET(mv_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"header_bits", NULL, OFFSET(header_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"i_tex_bits", NULL, OFFSET(i_tex_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"p_tex_bits", NULL, OFFSET(p_tex_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"i_count", NULL, OFFSET(i_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"p_count", NULL, OFFSET(p_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"skip_count", NULL, OFFSET(skip_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"misc_bits", NULL, OFFSET(misc_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"frame_bits", NULL, OFFSET(frame_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"codec_tag", NULL, OFFSET(codec_tag), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"bugs", NULL, OFFSET(workaround_bugs), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D, "bug"},
-{"autodetect", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_AUTODETECT, INT_MIN, INT_MAX, V|D, "bug"},
-{"old_msmpeg4", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_OLD_MSMPEG4, INT_MIN, INT_MAX, V|D, "bug"},
-{"xvid_ilace", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_XVID_ILACE, INT_MIN, INT_MAX, V|D, "bug"},
-{"ump4", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_UMP4, INT_MIN, INT_MAX, V|D, "bug"},
-{"no_padding", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_NO_PADDING, INT_MIN, INT_MAX, V|D, "bug"},
-{"amv", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_AMV, INT_MIN, INT_MAX, V|D, "bug"},
-{"ac_vlc", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_AC_VLC, INT_MIN, INT_MAX, V|D, "bug"},
-{"qpel_chroma", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_QPEL_CHROMA, INT_MIN, INT_MAX, V|D, "bug"},
-{"std_qpel", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_STD_QPEL, INT_MIN, INT_MAX, V|D, "bug"},
-{"qpel_chroma2", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_QPEL_CHROMA2, INT_MIN, INT_MAX, V|D, "bug"},
-{"direct_blocksize", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_DIRECT_BLOCKSIZE, INT_MIN, INT_MAX, V|D, "bug"},
-{"edge", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_EDGE, INT_MIN, INT_MAX, V|D, "bug"},
-{"hpel_chroma", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_HPEL_CHROMA, INT_MIN, INT_MAX, V|D, "bug"},
-{"dc_clip", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_DC_CLIP, INT_MIN, INT_MAX, V|D, "bug"},
-{"ms", NULL, 0, FF_OPT_TYPE_CONST, FF_BUG_MS, INT_MIN, INT_MAX, V|D, "bug"},
-{"lelim", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)", OFFSET(luma_elim_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"celim", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)", OFFSET(chroma_elim_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"strict", NULL, OFFSET(strict_std_compliance), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "strict"},
-{"very", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_VERY_STRICT, INT_MIN, INT_MAX, V|E, "strict"},
-{"strict", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_STRICT, INT_MIN, INT_MAX, V|E, "strict"},
-{"normal", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_NORMAL, INT_MIN, INT_MAX, V|E, "strict"},
-{"inofficial", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_INOFFICIAL, INT_MIN, INT_MAX, V|E, "strict"},
-{"experimental", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_EXPERIMENTAL, INT_MIN, INT_MAX, V|E, "strict"},
-{"b_quant_offset", NULL, OFFSET(b_quant_offset), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"error_resilience", NULL, OFFSET(error_resilience), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D, "er"},
-{"careful", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_CAREFUL, INT_MIN, INT_MAX, V|D, "er"},
-{"compliant", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_COMPLIANT, INT_MIN, INT_MAX, V|D, "er"},
-{"aggressive", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_AGGRESSIVE, INT_MIN, INT_MAX, V|D, "er"},
-{"very_aggressive", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_VERY_AGGRESSIVE, INT_MIN, INT_MAX, V|D, "er"},
-{"has_b_frames", NULL, OFFSET(has_b_frames), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"block_align", NULL, OFFSET(block_align), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"parse_only", NULL, OFFSET(parse_only), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"mpeg_quant", NULL, OFFSET(mpeg_quant), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"stats_out", NULL, OFFSET(stats_out), FF_OPT_TYPE_STRING, DEFAULT, CHAR_MIN, CHAR_MAX},
-{"stats_in", NULL, OFFSET(stats_in), FF_OPT_TYPE_STRING, DEFAULT, CHAR_MIN, CHAR_MAX},
-{"rc_qsquish", NULL, OFFSET(rc_qsquish), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"rc_qmod_amp", NULL, OFFSET(rc_qmod_amp), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"rc_qmod_freq", NULL, OFFSET(rc_qmod_freq), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"rc_override_count", NULL, OFFSET(rc_override_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"rc_eq", NULL, OFFSET(rc_eq), FF_OPT_TYPE_STRING, DEFAULT, CHAR_MIN, CHAR_MAX, V|E},
-{"rc_max_rate", NULL, OFFSET(rc_max_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"rc_min_rate", NULL, OFFSET(rc_min_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"rc_buffer_size", NULL, OFFSET(rc_buffer_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"rc_buf_aggressivity", NULL, OFFSET(rc_buffer_aggressivity), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"i_quant_factor", NULL, OFFSET(i_quant_factor), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"i_quant_offset", NULL, OFFSET(i_quant_offset), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"rc_initial_cplx", NULL, OFFSET(rc_initial_cplx), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"dct", NULL, OFFSET(dct_algo), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|E, "dct"},
-{"auto", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_AUTO, INT_MIN, INT_MAX, V|E, "dct"},
-{"fastint", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_FASTINT, INT_MIN, INT_MAX, V|E, "dct"},
-{"int", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_INT, INT_MIN, INT_MAX, V|E, "dct"},
-{"mmx", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_MMX, INT_MIN, INT_MAX, V|E, "dct"},
-{"mlib", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_MLIB, INT_MIN, INT_MAX, V|E, "dct"},
-{"altivec", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_ALTIVEC, INT_MIN, INT_MAX, V|E, "dct"},
-{"faan", NULL, 0, FF_OPT_TYPE_CONST, FF_DCT_FAAN, INT_MIN, INT_MAX, V|E, "dct"},
-{"lumi_mask", NULL, OFFSET(lumi_masking), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"tcplx_mask", NULL, OFFSET(temporal_cplx_masking), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"scplx_mask", NULL, OFFSET(spatial_cplx_masking), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"p_mask", NULL, OFFSET(p_masking), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"dark_mask", NULL, OFFSET(dark_masking), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"unused", NULL, OFFSET(unused), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"idct", NULL, OFFSET(idct_algo), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|E|D, "idct"},
-{"auto", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_AUTO, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"int", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_INT, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"simple", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_SIMPLE, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"simplemmx", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_SIMPLEMMX, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"libmpeg2mmx", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_LIBMPEG2MMX, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"ps2", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_PS2, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"mlib", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_MLIB, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"arm", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_ARM, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"altivec", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_ALTIVEC, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"sh4", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_SH4, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"simplearm", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_SIMPLEARM, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"h264", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_H264, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"vp3", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_VP3, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"ipp", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_IPP, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"xvidmmx", NULL, 0, FF_OPT_TYPE_CONST, FF_IDCT_XVIDMMX, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"slice_count", NULL, OFFSET(slice_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"ec", NULL, OFFSET(error_concealment), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, V|D, "ec"},
-{"guess_mvs", NULL, 0, FF_OPT_TYPE_CONST, FF_EC_GUESS_MVS, INT_MIN, INT_MAX, V|D, "ec"},
-{"deblock", NULL, 0, FF_OPT_TYPE_CONST, FF_EC_DEBLOCK, INT_MIN, INT_MAX, V|D, "ec"},
-{"bits_per_sample", NULL, OFFSET(bits_per_sample), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"pred", NULL, OFFSET(prediction_method), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "pred"},
-{"left", NULL, 0, FF_OPT_TYPE_CONST, FF_PRED_LEFT, INT_MIN, INT_MAX, V|E, "pred"},
-{"plane", NULL, 0, FF_OPT_TYPE_CONST, FF_PRED_PLANE, INT_MIN, INT_MAX, V|E, "pred"},
-{"median", NULL, 0, FF_OPT_TYPE_CONST, FF_PRED_MEDIAN, INT_MIN, INT_MAX, V|E, "pred"},
-{"aspect", NULL, OFFSET(sample_aspect_ratio), FF_OPT_TYPE_RATIONAL, DEFAULT, 0, 10, V|E},
-{"debug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, DEFAULT, 0, INT_MAX, V|A|S|E|D, "debug"},
-{"pict", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_PICT_INFO, INT_MIN, INT_MAX, V|D, "debug"},
-{"rc", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_RC, INT_MIN, INT_MAX, V|E, "debug"},
-{"bitstream", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_BITSTREAM, INT_MIN, INT_MAX, V|D, "debug"},
-{"mb_type", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_MB_TYPE, INT_MIN, INT_MAX, V|D, "debug"},
-{"qp", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_QP, INT_MIN, INT_MAX, V|D, "debug"},
-{"mv", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_MV, INT_MIN, INT_MAX, V|D, "debug"},
-{"dct_coeff", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_DCT_COEFF, INT_MIN, INT_MAX, V|D, "debug"},
-{"skip", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_SKIP, INT_MIN, INT_MAX, V|D, "debug"},
-{"startcode", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_STARTCODE, INT_MIN, INT_MAX, V|D, "debug"},
-{"pts", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_PTS, INT_MIN, INT_MAX, V|D, "debug"},
-{"er", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_ER, INT_MIN, INT_MAX, V|D, "debug"},
-{"mmco", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_MMCO, INT_MIN, INT_MAX, V|D, "debug"},
-{"bugs", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_BUGS, INT_MIN, INT_MAX, V|D, "debug"},
-{"vis_qp", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_QP, INT_MIN, INT_MAX, V|D, "debug"},
-{"vis_mb_type", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MB_TYPE, INT_MIN, INT_MAX, V|D, "debug"},
-{"vismv", "visualize motion vectors", OFFSET(debug_mv), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, V|D, "debug_mv"},
-{"pf", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_P_FOR, INT_MIN, INT_MAX, V|D, "debug_mv"},
-{"bf", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_B_FOR, INT_MIN, INT_MAX, V|D, "debug_mv"},
-{"bb", NULL, 0, FF_OPT_TYPE_CONST, FF_DEBUG_VIS_MV_B_BACK, INT_MIN, INT_MAX, V|D, "debug_mv"},
-{"mb_qmin", NULL, OFFSET(mb_qmin), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"mb_qmax", NULL, OFFSET(mb_qmax), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"cmp", "full pel me compare function", OFFSET(me_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"subcmp", "sub pel me compare function", OFFSET(me_sub_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"mbcmp", "macroblock compare function", OFFSET(mb_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"ildctcmp", "interlaced dct compare function", OFFSET(ildct_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"dia_size", NULL, OFFSET(dia_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"last_pred", NULL, OFFSET(last_predictor_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"preme", NULL, OFFSET(pre_me), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"precmp", "pre motion estimation compare function", OFFSET(me_pre_cmp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"sad", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_SAD, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"sse", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_SSE, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"satd", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_SATD, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"dct", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_DCT, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"psnr", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_PSNR, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"bit", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_BIT, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"rd", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_RD, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"zero", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_ZERO, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"vsad", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_VSAD, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"vsse", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_VSSE, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"nsse", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_NSSE, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"w53", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_W53, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"w97", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_W97, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"dctmax", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_DCTMAX, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"chroma", NULL, 0, FF_OPT_TYPE_CONST, FF_CMP_CHROMA, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"pre_dia_size", NULL, OFFSET(pre_dia_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"subq", NULL, OFFSET(me_subpel_quality), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"dtg_active_format", NULL, OFFSET(dtg_active_format), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"me_range", NULL, OFFSET(me_range), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"ibias", NULL, OFFSET(intra_quant_bias), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"pbias", NULL, OFFSET(inter_quant_bias), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"color_table_id", NULL, OFFSET(color_table_id), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"internal_buffer_count", NULL, OFFSET(internal_buffer_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"global_quality", NULL, OFFSET(global_quality), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"coder", NULL, OFFSET(coder_type), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "coder"},
-{"vlc", NULL, 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_VLC, INT_MIN, INT_MAX, V|E, "coder"},
-{"ac", NULL, 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_AC, INT_MIN, INT_MAX, V|E, "coder"},
-{"context_model", NULL, OFFSET(context_model), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"slice_flags", NULL, OFFSET(slice_flags), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"xvmc_acceleration", NULL, OFFSET(xvmc_acceleration), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"mbd", NULL, OFFSET(mb_decision), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "mbd"},
-{"simple", NULL, 0, FF_OPT_TYPE_CONST, FF_MB_DECISION_SIMPLE, INT_MIN, INT_MAX, V|E, "mbd"},
-{"bits", NULL, 0, FF_OPT_TYPE_CONST, FF_MB_DECISION_BITS, INT_MIN, INT_MAX, V|E, "mbd"},
-{"rd", NULL, 0, FF_OPT_TYPE_CONST, FF_MB_DECISION_RD, INT_MIN, INT_MAX, V|E, "mbd"},
-{"stream_codec_tag", NULL, OFFSET(stream_codec_tag), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"sc_threshold", NULL, OFFSET(scenechange_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"lmin", "min lagrange factor", OFFSET(lmin), FF_OPT_TYPE_INT,  2*FF_QP2LAMBDA, 0, INT_MAX, V|E},
-{"lmax", "max lagrange factor", OFFSET(lmax), FF_OPT_TYPE_INT, 31*FF_QP2LAMBDA, 0, INT_MAX, V|E},
-{"noise_reduction", NULL, OFFSET(noise_reduction), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"rc_init_occupancy", NULL, OFFSET(rc_initial_buffer_occupancy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"inter_threshold", NULL, OFFSET(inter_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"flags2", NULL, OFFSET(flags2), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"error_rate", NULL, OFFSET(error_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"antialias", NULL, OFFSET(antialias_algo), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D, "aa"},
-{"auto", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_AUTO, INT_MIN, INT_MAX, V|D, "aa"},
-{"fastint", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_FASTINT, INT_MIN, INT_MAX, V|D, "aa"},
-{"int", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_INT, INT_MIN, INT_MAX, V|D, "aa"},
-{"float", NULL, 0, FF_OPT_TYPE_CONST, FF_AA_FLOAT, INT_MIN, INT_MAX, V|D, "aa"},
-{"qns", NULL, OFFSET(quantizer_noise_shaping), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"thread_count", NULL, OFFSET(thread_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E|D},
-{"me_threshold", "motion estimaton threshold", OFFSET(me_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"mb_threshold", NULL, OFFSET(mb_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"dc", NULL, OFFSET(intra_dc_precision), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"nsse_weight", NULL, OFFSET(nsse_weight), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"skip_top", NULL, OFFSET(skip_top), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
-{"skip_bottom", NULL, OFFSET(skip_bottom), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
-{"profile", NULL, OFFSET(profile), FF_OPT_TYPE_INT, FF_PROFILE_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "profile"},
-{"unknown", NULL, 0, FF_OPT_TYPE_CONST, FF_PROFILE_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "profile"},
-{"level", NULL, OFFSET(level), FF_OPT_TYPE_INT, FF_LEVEL_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "level"},
-{"unknown", NULL, 0, FF_OPT_TYPE_CONST, FF_LEVEL_UNKNOWN, INT_MIN, INT_MAX, V|A|E, "level"},
-{"lowres", NULL, OFFSET(lowres), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|D},
-{"frame_skip_threshold", NULL, OFFSET(frame_skip_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"frame_skip_factor", NULL, OFFSET(frame_skip_factor), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"frame_skip_exp", NULL, OFFSET(frame_skip_exp), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"skipcmp", "frame skip comapare function", OFFSET(frame_skip_cmp), FF_OPT_TYPE_INT, FF_CMP_DCTMAX, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"border_mask", NULL, OFFSET(border_masking), FF_OPT_TYPE_FLOAT, DEFAULT, FLT_MIN, FLT_MAX, V|E},
-{"mb_lmin", NULL, OFFSET(mb_lmin), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"mb_lmax", NULL, OFFSET(mb_lmax), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"me_penalty_compensation", NULL, OFFSET(me_penalty_compensation), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{NULL},
-};
-
-#undef A
-#undef V
-
-static AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options };
-
-void avcodec_get_context_defaults(AVCodecContext *s){
-    memset(s, 0, sizeof(AVCodecContext));
-
-    s->av_class= &av_codec_context_class;
-    s->bit_rate= 800*1000;
-    s->bit_rate_tolerance= s->bit_rate*10;
-    s->qmin= 2;
-    s->qmax= 31;
-    s->mb_lmin= FF_QP2LAMBDA * 2;
-    s->mb_lmax= FF_QP2LAMBDA * 31;
-    s->rc_eq= "tex^qComp";
-    s->qcompress= 0.5;
-    s->max_qdiff= 3;
-    s->b_quant_factor=1.25;
-    s->b_quant_offset=1.25;
-    s->i_quant_factor=-0.8;
-    s->i_quant_offset=0.0;
-    s->error_concealment= 3;
-    s->error_resilience= 1;
-    s->workaround_bugs= FF_BUG_AUTODETECT;
-    s->time_base= (AVRational){0,1};
-    s->gop_size= 50;
-    s->me_method= ME_EPZS;
-    s->get_buffer= avcodec_default_get_buffer;
-    s->release_buffer= avcodec_default_release_buffer;
-    s->get_format= avcodec_default_get_format;
-    s->execute= avcodec_default_execute;
-    s->thread_count=1;
-    s->me_subpel_quality=8;
-    s->lmin= FF_QP2LAMBDA * s->qmin;
-    s->lmax= FF_QP2LAMBDA * s->qmax;
-    s->sample_aspect_ratio= (AVRational){0,1};
-    s->ildct_cmp= FF_CMP_VSAD;
-    s->profile= FF_PROFILE_UNKNOWN;
-    s->level= FF_LEVEL_UNKNOWN;
-    s->me_penalty_compensation= 256;
-    s->pix_fmt= PIX_FMT_NONE;
-    s->frame_skip_cmp= FF_CMP_DCTMAX;
-    
-    s->intra_quant_bias= FF_DEFAULT_QUANT_BIAS;
-    s->inter_quant_bias= FF_DEFAULT_QUANT_BIAS;
-    s->palctrl = NULL;
-    s->reget_buffer= avcodec_default_reget_buffer;
-}
-
-/**
- * allocates a AVCodecContext and set it to defaults.
- * this can be deallocated by simply calling free() 
- */
-AVCodecContext *avcodec_alloc_context(void){
-    AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
-    
-    if(avctx==NULL) return NULL;
-    
-    avcodec_get_context_defaults(avctx);
-    
-    return avctx;
-}
-
-void avcodec_get_frame_defaults(AVFrame *pic){
-    memset(pic, 0, sizeof(AVFrame));
-
-    pic->pts= AV_NOPTS_VALUE;
-    pic->key_frame= 1;
-}
-
-/**
- * allocates a AVPFrame and set it to defaults.
- * this can be deallocated by simply calling free() 
- */
-AVFrame *avcodec_alloc_frame(void){
-    AVFrame *pic= av_malloc(sizeof(AVFrame));
-    
-    if(pic==NULL) return NULL;
-    
-    avcodec_get_frame_defaults(pic);
-    
-    return pic;
-}
-
-int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
-{
-    int ret= -1;
-    
-    entangled_thread_counter++;
-    if(entangled_thread_counter != 1){
-        av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
-        goto end;
-    }
-
-    if(avctx->codec)
-        goto end;
-
-    avctx->codec = codec;
-    avctx->codec_id = codec->id;
-    avctx->frame_number = 0;
-    if (codec->priv_data_size > 0) {
-        avctx->priv_data = av_mallocz(codec->priv_data_size);
-        if (!avctx->priv_data) 
-            goto end;
-    } else {
-        avctx->priv_data = NULL;
-    }
-
-    if(avctx->coded_width && avctx->coded_height)
-        avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
-    else if(avctx->width && avctx->height)
-        avcodec_set_dimensions(avctx, avctx->width, avctx->height);
-
-    if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height)){
-        av_freep(&avctx->priv_data);
-        goto end;
-    }
-
-    ret = avctx->codec->init(avctx);
-    if (ret < 0) {
-        av_freep(&avctx->priv_data);
-        goto end;
-    }
-    ret=0;
-end:
-    entangled_thread_counter--;
-    return ret;
-}
-
-int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
-                         const short *samples)
-{
-    if(buf_size < FF_MIN_BUFFER_SIZE && 0){
-        av_log(avctx, AV_LOG_ERROR, "buffer smaller then minimum size\n");
-        return -1;
-    }
-    if((avctx->codec->capabilities & CODEC_CAP_DELAY) || samples){
-        int ret = avctx->codec->encode(avctx, buf, buf_size, (void *)samples);
-        avctx->frame_number++;
-        return ret;
-    }else
-        return 0;
-}
-
-int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
-                         const AVFrame *pict)
-{
-    if(buf_size < FF_MIN_BUFFER_SIZE){
-        av_log(avctx, AV_LOG_ERROR, "buffer smaller then minimum size\n");
-        return -1;
-    }
-    if(avcodec_check_dimensions(avctx,avctx->width,avctx->height))
-        return -1;
-    if((avctx->codec->capabilities & CODEC_CAP_DELAY) || pict){
-        int ret = avctx->codec->encode(avctx, buf, buf_size, (void *)pict);
-        avctx->frame_number++;
-        emms_c(); //needed to avoid an emms_c() call before every return;
-    
-        return ret;
-    }else
-        return 0;
-}
-
-int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
-                            const AVSubtitle *sub)
-{
-    int ret;
-    ret = avctx->codec->encode(avctx, buf, buf_size, (void *)sub);
-    avctx->frame_number++;
-    return ret;
-}
-
-/** 
- * decode a frame. 
- * @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes
- * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
- * @param buf_size the size of the buffer in bytes
- * @param got_picture_ptr zero if no frame could be decompressed, Otherwise, it is non zero
- * @return -1 if error, otherwise return the number of
- * bytes used. 
- */
-int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, 
-                         int *got_picture_ptr,
-                         uint8_t *buf, int buf_size)
-{
-    int ret;
-    
-    *got_picture_ptr= 0;
-    if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height))
-        return -1;
-    if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
-        ret = avctx->codec->decode(avctx, picture, got_picture_ptr, 
-                                buf, buf_size);
-
-        emms_c(); //needed to avoid an emms_c() call before every return;
-    
-        if (*got_picture_ptr)                           
-            avctx->frame_number++;
-    }else
-        ret= 0;
-
-    return ret;
-}
-
-/* decode an audio frame. return -1 if error, otherwise return the
-   *number of bytes used. If no frame could be decompressed,
-   *frame_size_ptr is zero. Otherwise, it is the decompressed frame
-   *size in BYTES. */
-int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, 
-                         int *frame_size_ptr,
-                         uint8_t *buf, int buf_size)
-{
-    int ret;
-
-    *frame_size_ptr= 0;
-    if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
-        ret = avctx->codec->decode(avctx, samples, frame_size_ptr, 
-                                buf, buf_size);
-        avctx->frame_number++;
-    }else
-        ret= 0;
-    return ret;
-}
-
-/* decode a subtitle message. return -1 if error, otherwise return the
-   *number of bytes used. If no subtitle could be decompressed,
-   *got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
-int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
-                            int *got_sub_ptr,
-                            const uint8_t *buf, int buf_size)
-{
-    int ret;
-
-    *got_sub_ptr = 0;
-    ret = avctx->codec->decode(avctx, sub, got_sub_ptr, 
-                               (uint8_t *)buf, buf_size);
-    if (*got_sub_ptr)
-        avctx->frame_number++;
-    return ret;
-}
-
-int avcodec_close(AVCodecContext *avctx)
-{
-    entangled_thread_counter++;
-    if(entangled_thread_counter != 1){
-        av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
-        entangled_thread_counter--;
-        return -1;
-    }
-
-    if (avctx->codec->close)
-        avctx->codec->close(avctx);
-    avcodec_default_free_buffers(avctx);
-    av_freep(&avctx->priv_data);
-    avctx->codec = NULL;
-    entangled_thread_counter--;
-    return 0;
-}
-
-AVCodec *avcodec_find_encoder(enum CodecID id)
-{
-    AVCodec *p;
-    p = first_avcodec;
-    while (p) {
-        if (p->encode != NULL && p->id == id)
-            return p;
-        p = p->next;
-    }
-    return NULL;
-}
-
-AVCodec *avcodec_find_encoder_by_name(const char *name)
-{
-    AVCodec *p;
-    p = first_avcodec;
-    while (p) {
-        if (p->encode != NULL && strcmp(name,p->name) == 0)
-            return p;
-        p = p->next;
-    }
-    return NULL;
-}
-
-AVCodec *avcodec_find_decoder(enum CodecID id)
-{
-    AVCodec *p;
-    p = first_avcodec;
-    while (p) {
-        if (p->decode != NULL && p->id == id)
-            return p;
-        p = p->next;
-    }
-    return NULL;
-}
-
-AVCodec *avcodec_find_decoder_by_name(const char *name)
-{
-    AVCodec *p;
-    p = first_avcodec;
-    while (p) {
-        if (p->decode != NULL && strcmp(name,p->name) == 0)
-            return p;
-        p = p->next;
-    }
-    return NULL;
-}
-
-void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
-{
-    const char *codec_name;
-    AVCodec *p;
-    char buf1[32];
-    char channels_str[100];
-    int bitrate;
-
-    if (encode)
-        p = avcodec_find_encoder(enc->codec_id);
-    else
-        p = avcodec_find_decoder(enc->codec_id);
-
-    if (p) {
-        codec_name = p->name;
-        if (!encode && enc->codec_id == CODEC_ID_MP3) {
-            if (enc->sub_id == 2)
-                codec_name = "mp2";
-            else if (enc->sub_id == 1)
-                codec_name = "mp1";
-        }
-    } else if (enc->codec_id == CODEC_ID_MPEG2TS) {
-        /* fake mpeg2 transport stream codec (currently not
-           registered) */
-        codec_name = "mpeg2ts";
-    } else if (enc->codec_name[0] != '\0') {
-        codec_name = enc->codec_name;
-    } else {
-        /* output avi tags */
-        if(   isprint(enc->codec_tag&0xFF) && isprint((enc->codec_tag>>8)&0xFF) 
-           && isprint((enc->codec_tag>>16)&0xFF) && isprint((enc->codec_tag>>24)&0xFF)){
-            snprintf(buf1, sizeof(buf1), "%c%c%c%c / 0x%04X", 
-                     enc->codec_tag & 0xff,
-                     (enc->codec_tag >> 8) & 0xff,
-                     (enc->codec_tag >> 16) & 0xff,
-                     (enc->codec_tag >> 24) & 0xff,
-                      enc->codec_tag);
-        } else {
-            snprintf(buf1, sizeof(buf1), "0x%04x", enc->codec_tag);
-        }
-        codec_name = buf1;
-    }
-
-    switch(enc->codec_type) {
-    case CODEC_TYPE_VIDEO:
-        snprintf(buf, buf_size,
-                 "Video: %s%s",
-                 codec_name, enc->mb_decision ? " (hq)" : "");
-        if (enc->pix_fmt != PIX_FMT_NONE) {
-            snprintf(buf + strlen(buf), buf_size - strlen(buf),
-                     ", %s",
-                     avcodec_get_pix_fmt_name(enc->pix_fmt));
-        }
-        if (enc->width) {
-            snprintf(buf + strlen(buf), buf_size - strlen(buf),
-                     ", %dx%d, %0.2f fps",
-                     enc->width, enc->height, 
-                     1/av_q2d(enc->time_base));
-        }
-        if (encode) {
-            snprintf(buf + strlen(buf), buf_size - strlen(buf),
-                     ", q=%d-%d", enc->qmin, enc->qmax);
-        }
-        bitrate = enc->bit_rate;
-        break;
-    case CODEC_TYPE_AUDIO:
-        snprintf(buf, buf_size,
-                 "Audio: %s",
-                 codec_name);
-        switch (enc->channels) {
-            case 1:
-                strcpy(channels_str, "mono");
-                break;
-            case 2:
-                strcpy(channels_str, "stereo");
-                break;
-            case 6:
-                strcpy(channels_str, "5:1");
-                break;
-            default:
-                snprintf(channels_str, sizeof(channels_str), "%d channels", enc->channels);
-                break;
-        }
-        if (enc->sample_rate) {
-            snprintf(buf + strlen(buf), buf_size - strlen(buf),
-                     ", %d Hz, %s",
-                     enc->sample_rate,
-                     channels_str);
-        }
-        
-        /* for PCM codecs, compute bitrate directly */
-        switch(enc->codec_id) {
-        case CODEC_ID_PCM_S32LE:
-        case CODEC_ID_PCM_S32BE:
-        case CODEC_ID_PCM_U32LE:
-        case CODEC_ID_PCM_U32BE:
-            bitrate = enc->sample_rate * enc->channels * 32;
-            break;
-        case CODEC_ID_PCM_S24LE:
-        case CODEC_ID_PCM_S24BE:
-        case CODEC_ID_PCM_U24LE:
-        case CODEC_ID_PCM_U24BE:
-        case CODEC_ID_PCM_S24DAUD:
-            bitrate = enc->sample_rate * enc->channels * 24;
-            break;
-        case CODEC_ID_PCM_S16LE:
-        case CODEC_ID_PCM_S16BE:
-        case CODEC_ID_PCM_U16LE:
-        case CODEC_ID_PCM_U16BE:
-            bitrate = enc->sample_rate * enc->channels * 16;
-            break;
-        case CODEC_ID_PCM_S8:
-        case CODEC_ID_PCM_U8:
-        case CODEC_ID_PCM_ALAW:
-        case CODEC_ID_PCM_MULAW:
-            bitrate = enc->sample_rate * enc->channels * 8;
-            break;
-        default:
-            bitrate = enc->bit_rate;
-            break;
-        }
-        break;
-    case CODEC_TYPE_DATA:
-        snprintf(buf, buf_size, "Data: %s", codec_name);
-        bitrate = enc->bit_rate;
-        break;
-    case CODEC_TYPE_SUBTITLE:
-        snprintf(buf, buf_size, "Subtitle: %s", codec_name);
-        bitrate = enc->bit_rate;
-        break;
-    default:
-        snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type);
-        return;
-    }
-    if (encode) {
-        if (enc->flags & CODEC_FLAG_PASS1)
-            snprintf(buf + strlen(buf), buf_size - strlen(buf),
-                     ", pass 1");
-        if (enc->flags & CODEC_FLAG_PASS2)
-            snprintf(buf + strlen(buf), buf_size - strlen(buf),
-                     ", pass 2");
-    }
-    if (bitrate != 0) {
-        snprintf(buf + strlen(buf), buf_size - strlen(buf), 
-                 ", %d kb/s", bitrate / 1000);
-    }
-}
-
-unsigned avcodec_version( void )
-{
-  return LIBAVCODEC_VERSION_INT;
-}
-
-unsigned avcodec_build( void )
-{
-  return LIBAVCODEC_BUILD;
-}
-
-/* must be called before any other functions */
-void avcodec_init(void)
-{
-    static int inited = 0;
-
-    if (inited != 0)
-	return;
-    inited = 1;
-
-    dsputil_static_init();
-}
-
-/**
- * Flush buffers, should be called when seeking or when swicthing to a different stream.
- */
-void avcodec_flush_buffers(AVCodecContext *avctx)
-{
-    if(avctx->codec->flush)
-        avctx->codec->flush(avctx);
-}
-
-void avcodec_default_free_buffers(AVCodecContext *s){
-    int i, j;
-
-    if(s->internal_buffer==NULL) return;
-    
-    for(i=0; i<INTERNAL_BUFFER_SIZE; i++){
-        InternalBuffer *buf= &((InternalBuffer*)s->internal_buffer)[i];
-        for(j=0; j<4; j++){
-            av_freep(&buf->base[j]);
-            buf->data[j]= NULL;
-        }
-    }
-    av_freep(&s->internal_buffer);
-    
-    s->internal_buffer_count=0;
-}
-
-char av_get_pict_type_char(int pict_type){
-    switch(pict_type){
-    case I_TYPE: return 'I'; 
-    case P_TYPE: return 'P'; 
-    case B_TYPE: return 'B'; 
-    case S_TYPE: return 'S'; 
-    case SI_TYPE:return 'i'; 
-    case SP_TYPE:return 'p'; 
-    default:     return '?';
-    }
-}
-
-/* av_log API */
-
-static int av_log_level = AV_LOG_INFO;
-
-static void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
-{
-    static int print_prefix=1;
-    AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
-    if(level>av_log_level)
-	return;
-#undef fprintf
-    if(print_prefix && avc) {
-	    fprintf(stderr, "[%s @ %p]", avc->item_name(ptr), avc);
-    }
-#define fprintf please_use_av_log
-        
-    print_prefix= strstr(fmt, "\n") != NULL;
-        
-    vfprintf(stderr, fmt, vl);
-}
-
-static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;
-
-void av_log(void* avcl, int level, const char *fmt, ...)
-{
-    va_list vl;
-    va_start(vl, fmt);
-    av_vlog(avcl, level, fmt, vl);
-    va_end(vl);
-}
-
-void av_vlog(void* avcl, int level, const char *fmt, va_list vl)
-{
-    av_log_callback(avcl, level, fmt, vl);
-}
-
-int av_log_get_level(void)
-{
-    return av_log_level;
-}
-
-void av_log_set_level(int level)
-{
-    av_log_level = level;
-}
-
-void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
-{
-    av_log_callback = callback;
-}
-
-#if !defined(HAVE_THREADS)
-int avcodec_thread_init(AVCodecContext *s, int thread_count){
-    return -1;
-}
-#endif
-
-unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
-{
-    unsigned int n = 0;
-
-    while(v >= 0xff) {
-        *s++ = 0xff;
-        v -= 0xff;
-        n++;
-    }
-    *s = v;
-    n++;
-    return n;
-}
diff --git a/ffmpeg.src/libavcodec/vc9data.h b/ffmpeg.src/libavcodec/vc9data.h
deleted file mode 100644
index 93db351..0000000
--- a/ffmpeg.src/libavcodec/vc9data.h
+++ /dev/null
@@ -1,406 +0,0 @@
-/**
- * @file vc9data.h
- * VC9 tables.
- */
-
-#ifndef VC9DATA_H
-#define VC9DATA_H
-
-/* bfraction is fractional, we scale to the GCD 3*5*7*8 = 840 */
-const int16_t vc9_bfraction_lut[23] = {
-  420 /*1/2*/, 280 /*1/3*/, 560 /*2/3*/, 210 /*1/4*/,
-  630 /*3/4*/, 168 /*1/5*/, 336 /*2/5*/,
-  504 /*3/5*/, 672 /*4/5*/, 140 /*1/6*/, 700 /*5/6*/,
-  120 /*1/7*/, 240 /*2/7*/, 360 /*3/7*/, 480 /*4/7*/,
-  600 /*5/7*/, 720 /*6/7*/, 105 /*1/8*/, 315 /*3/8*/,
-  525 /*5/8*/, 735 /*7/8*/,
-  -1 /*inv.*/, 0 /*BI fm*/
-};
-const uint8_t vc9_bfraction_bits[23] = {
-    3, 3, 3, 3,
-    3, 3, 3,
-    7, 7, 7, 7,
-    7, 7, 7, 7,
-    7, 7, 7, 7,
-    7, 7,
-    7, 7
-};
-const uint8_t vc9_bfraction_codes[23] = {
-     0,   1,   2,   3,
-     4,   5,   6,
-   112, 113, 114, 115,
-   116, 117, 118, 119,
-   120, 121, 122, 123,
-   124, 125,
-   126, 127
-};
-
-//Same as H.264
-static const AVRational vc9_pixel_aspect[16]={
- {0, 1},
- {1, 1},
- {12, 11},
- {10, 11},
- {16, 11},
- {40, 33},
- {24, 11},
- {20, 11},
- {32, 11},
- {80, 33},
- {18, 11},
- {15, 11},
- {64, 33},
- {160, 99},
- {0, 1},
- {0, 1}
-};
-
-/* BitPlane IMODE - such a small table... */
-static const uint8_t vc9_imode_codes[7] = {
-  0, 2, 1, 3, 1, 2, 3
-};
-static const uint8_t vc9_imode_bits[7] = {
-  4, 2, 3, 2, 4, 3, 3
-};
-
-/* Normal-2 imode */
-static const uint8_t vc9_norm2_codes[4] = {
-  0, 4, 5, 3
-};
-static const uint8_t vc9_norm2_bits[4] = {
-  1, 3, 3, 2
-};
-
-static const uint16_t vc9_norm6_codes[64] = {
-0x001, 0x002, 0x003, 0x000, 0x004, 0x001, 0x002, 0x047, 0x005, 0x003, 0x004, 0x04B, 0x005, 0x04D, 0x04E, 0x30E, 
-0x006, 0x006, 0x007, 0x053, 0x008, 0x055, 0x056, 0x30D, 0x009, 0x059, 0x05A, 0x30C, 0x05C, 0x30B, 0x30A, 0x037, 
-0x007, 0x00A, 0x00B, 0x043, 0x00C, 0x045, 0x046, 0x309, 0x00D, 0x049, 0x04A, 0x308, 0x04C, 0x307, 0x306, 0x036, 
-0x00E, 0x051, 0x052, 0x305, 0x054, 0x304, 0x303, 0x035, 0x058, 0x302, 0x301, 0x034, 0x300, 0x033, 0x032, 0x007, 
-};
-
-static const uint8_t vc9_norm6_bits[64] = {
- 1,  4,  4,  8,  4,  8,  8, 10,  4,  8,  8, 10,  8, 10, 10, 13, 
- 4,  8,  8, 10,  8, 10, 10, 13,  8, 10, 10, 13, 10, 13, 13,  9, 
- 4,  8,  8, 10,  8, 10, 10, 13,  8, 10, 10, 13, 10, 13, 13,  9, 
- 8, 10, 10, 13, 10, 13, 13,  9, 10, 13, 13,  9, 13,  9,  9,  6,
-};
-/* Normal-6 imode */
-static const uint8_t vc9_norm6_spec[64][5] = {
-{ 0,  1, 1        },
-{ 1,  2, 4        },
-{ 2,  3, 4        },
-{ 3,  0, 8        },
-{ 4,  4, 4        },
-{ 5,  1, 8        },
-{ 6,  2, 8        },
-{ 7,  2, 5,  7, 5 },
-{ 8,  5, 4        },
-{ 9,  3, 8        },
-{10,  4, 8        },
-{11,  2, 5, 11, 5 },
-{12,  5, 8        },
-{13,  2, 5, 13, 5 },
-{14,  2, 5, 14, 5 },
-{15,  3, 5, 14, 8 },
-{16,  6, 4        },
-{17,  6, 8        },
-{18,  7, 8        },
-{19,  2, 5, 19, 5 },
-{20,  8, 8        },
-{21,  2, 5, 21, 5 },
-{22,  2, 5, 22, 5 },
-{23,  3, 5, 13, 8 },
-{24,  9, 8        },
-{25,  2, 5, 25, 5 },
-{26,  2, 5, 26, 5 },
-{27,  3, 5, 12, 8 },
-{28,  2, 5, 28, 5 },
-{29,  3, 5, 11, 8 },
-{30,  3, 5, 10, 8 },
-{31,  3, 5,  7, 4 },
-{32,  7, 4        },
-{33, 10, 8        },
-{34, 11, 8        },
-{35,  2, 5,  3, 5 },
-{36, 12, 8        },
-{37,  2, 5,  5, 5 },
-{38,  2, 5,  6, 5 },
-{39,  3, 5,  9, 8 },
-{40, 13, 8        },
-{41,  2, 5,  9, 5 },
-{42,  2, 5, 10, 5 },
-{43,  3, 5,  8, 8 },
-{44,  2, 5, 12, 5 },
-{45,  3, 5,  7, 8 },
-{46,  3, 5,  6, 8 },
-{47,  3, 5,  6, 4 },
-{48, 14, 8        },
-{49,  2, 5, 17, 5 },
-{50,  2, 5, 18, 5 },
-{51,  3, 5,  5, 8 },
-{52,  2, 5, 20, 5 },
-{53,  3, 5,  4, 8 },
-{54,  3, 5,  3, 8 },
-{55,  3, 5,  5, 4 },
-{56,  2, 5, 24, 5 },
-{57,  3, 5,  2, 8 },
-{58,  3, 5,  1, 8 },
-{59,  3, 5,  4, 4 },
-{60,  3, 5,  0, 8 },
-{61,  3, 5,  3, 4 },
-{62,  3, 5,  2, 4 },
-{63,  3, 5,  1, 1 },
-};
-
-/* 4MV Block pattern VLC tables */
-static const uint8_t vc9_4mv_block_pattern_codes[4][16] = {
-  { 14, 58, 59, 25, 12, 26, 15, 15, 13, 24, 27,  0, 28,  1,  2,  2},
-  {  8, 18, 19,  4, 20,  5, 30, 11, 21, 31,  6, 12,  7, 13, 14,  0},
-  { 15,  6,  7,  2,  8,  3, 28,  9, 10, 29,  4, 11,  5, 12, 13,  0},
-  {  0, 11, 12,  4, 13,  5, 30, 16, 14, 31,  6, 17,  7, 18, 19, 19}
-};
-static const uint8_t vc9_4mv_block_pattern_bits[4][16] = {
-  { 5, 6, 6, 5, 5, 5, 5, 4, 5, 5, 5, 3, 5, 3, 3, 2},
-  { 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4, 4, 4, 4, 4, 2},
-  { 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 4, 4, 4, 4, 4, 3},
-  { 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4}
-};
-
-const uint8_t wmv3_dc_scale_table[32]={
-    0, 4, 6, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21
-};
-
-/* P-Picture CBPCY VLC tables */
-static const uint16_t vc9_cbpcy_p_codes[4][64] = {
-  {
-      0,   1,   1,   4,   5,   1,  12,   4,  13,  14,  10,  11,  12,   7,  13,   2,
-     15,   1,  96,   1,  49,  97,   2, 100,   3,   4,   5, 101, 102,  52,  53,   4,
-      6,   7,  54, 103,   8,   9,  10, 110,  11,  12, 111,  56, 114,  58, 115,   5,
-     13,   7,   8,   9,  10,  11,  12,  30,  13,  14,  15, 118, 119,  62,  63,   3
-  },
-  {
-      0,   1,   2,   1,   3,   1,  16,  17,   5,  18,  12,  19,  13,   1,  28,  58,
-      1,   1,   1,   2,   3,   2,   3, 236, 237,   4,   5, 238,   6,   7, 239,   8,
-      9, 240,  10,  11, 121, 122,  12,  13,  14,  15, 241, 246,  16,  17, 124,  63,
-     18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31, 247, 125
-  },
-  {
-      0,   1,   2,   3,   2,   3,   1,   4,   5,  24,   7,  13,  16,  17,   9,   5,
-     25,   1,   1,   1,   2,   3,  96, 194,   1,   2,  98,  99, 195, 200, 101,  26,
-    201, 102, 412, 413, 414,  54, 220, 111, 221,   3, 224, 113, 225, 114, 230,  29,
-    231, 415, 240,   4, 241, 484,   5, 243,   3, 244, 245, 485, 492, 493, 247,  31
-  },
-  {
-      0,   1,   1,   1,   2,   2,   3,   4,   3,   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,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,
-     44,  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  28,  29,  30,  31
-   }
-};
-static const uint8_t vc9_cbpcy_p_bits[4][64] = {
-  {
-    13,  6,  5,  6,  6,  7,  7,  5,  7,  7,  6,  6,  6,  5,  6,  3,
-     7,  8,  8, 13,  7,  8, 13,  8, 13, 13, 13,  8,  8,  7,  7,  3,
-    13, 13,  7,  8, 13, 13, 13,  8, 13, 13,  8,  7,  8,  7,  8,  3,
-    13, 12, 12, 12, 12, 12, 12,  6, 12, 12, 12,  8,  8,  7,  7,  2
-  },
-  {
-    14,  3,  3,  5,  3,  4,  5,  5,  3,  5,  4,  5,  4,  6,  5,  6,
-     8, 14, 13,  8,  8, 13, 13,  8,  8, 13, 13,  8, 13, 13,  8, 13,
-    13,  8, 13, 13,  7,  7, 13, 13, 13, 13,  8,  8, 13, 13,  7,  6,
-    13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,  8,  7
-  },
-  {
-    13,  5,  5,  5,  4,  4,  6,  4,  4,  6,  4,  5,  5,  5,  4,  3,
-     6,  8, 10,  9,  8,  8,  7,  8, 13, 13,  7,  7,  8,  8,  7,  5,
-     8,  7,  9,  9,  9,  6,  8,  7,  8, 13,  8,  7,  8,  7,  8,  5,
-     8,  9,  8, 13,  8,  9, 13,  8, 12,  8,  8,  9,  9,  9,  8,  5
-  },
-  {
-     9,  2,  3,  9,  2,  9,  9,  9,  2,  9,  9,  9,  9,  9,  9,  9,
-     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
-     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
-     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  8,  8,  8,  8
-  }
-};
-
-/* MacroBlock Transform Type: 7.1.3.11, p89
- * 8x8:B
- * 8x4:B:btm  8x4:B:top  8x4:B:both,
- * 4x8:B:right  4x8:B:left  4x8:B:both
- * 4x4:B  8x8:MB
- * 8x4:MB:btm  8x4:MB:top  8x4,MB,both
- * 4x8,MB,right  4x8,MB,left
- * 4x4,MB                               */
-static const uint16_t vc9_ttmb_codes[3][16] = {
-  {
-    0x0003,
-    0x002E, 0x005F, 0x0000,
-    0x0016, 0x0015, 0x0001,
-    0x0004, 0x0014,
-    0x02F1, 0x0179, 0x017B,
-    0x0BC0, 0x0BC1, 0x05E1,
-    0x017A
-  },
-  {
-    0x0006,
-    0x0006, 0x0003, 0x0007,
-    0x000F, 0x000E, 0x0000,
-    0x0002, 0x0002,
-    0x0014, 0x0011, 0x000B,
-    0x0009, 0x0021, 0x0015,
-    0x0020
-  },
-  {
-    0x0006,
-    0x0000, 0x000E, 0x0005,
-    0x0002, 0x0003, 0x0003,
-    0x000F, 0x0002,
-    0x0081, 0x0021, 0x0009,
-    0x0101, 0x0041, 0x0011,
-    0x0100
-  }
-};
-
-static const uint8_t vc9_ttmb_bits[3][16] = {
-  {
-     2,
-     6,  7,  2,
-     5,  5,  2,
-     3,  5,
-    10,  9,  9,
-    12, 12, 11,
-     9
-  },
-  {
-    3,
-    4, 4, 4,
-    4, 4, 3,
-    3, 2,
-    7, 7, 6,
-    6, 8, 7,
-    8
-  },
-  {
-     3,
-     3, 4, 5,
-     3, 3, 4,
-     4, 2,
-    10, 8, 6,
-    11, 9, 7,
-    11
-  }
-};  
-
-/* TTBLK (Transform Type per Block) tables */
-static const uint8_t vc9_ttblk_codes[3][8] = {
-  {  0,  1,  3,  5, 16, 17, 18, 19},
-  {  3,  0,  1,  2,  3,  5,  8,  9},
-  {  1,  0,  1,  4,  6,  7, 10, 11}
-};
-static const uint8_t vc9_ttblk_bits[3][8] = {
-  {  2,  2,  2,  3,  5,  5,  5,  5},
-  {  2,  3,  3,  3,  3,  3,  4,  4},
-  {  2,  3,  3,  3,  3,  3,  4,  4}
-};
-
-/* SUBBLKPAT tables, p93-94, reordered */
-static const uint8_t vc9_subblkpat_codes[3][15] = {
-  { 14, 12,  7, 11,  9, 26,  2, 10, 27,  8,  0,  6,  1, 15,  1},
-  { 14,  0,  8, 15, 10,  4, 23, 13,  5,  9, 25,  3, 24, 22,  1},
-  {  5,  6,  2,  2,  8,  0, 28,  3,  1,  3, 29,  1, 19, 18, 15}
-};
-static const uint8_t vc9_subblkpat_bits[3][15] = {
-  {  5,  5,  5,  5,  5,  6,  4,  5,  6,  5,  4,  5,  4,  5,  1},
-  {  4,  3,  4,  4,  4,  5,  5,  4,  5,  4,  5,  4,  5,  5,  2},
-  {  3,  3,  4,  3,  4,  5,  5,  3,  5,  4,  5,  4,  5,  5,  4}
-};
-
-/* MV differential tables, p265 */
-static const uint16_t vc9_mv_diff_codes[4][73] = {
-  {
-       0,    2,    3,    8,  576,    3,    2,    6,
-       5,  577,  578,    7,    8,    9,   40,   19,
-      37,   82,   21,   22,   23,  579,  580,  166,
-      96,  167,   49,  194,  195,  581,  582,  583,
-     292,  293,  294,   13,    2,    7,   24,   50,
-     102,  295,   13,    7,    8,   18,   50,  103,
-      38,   20,   21,   22,   39,  204,  103,   23,
-      24,   25,  104,  410,  105,  106,  107,  108,
-     109,  220,  411,  442,  222,  443,  446,  447,
-       7 /* 73 elements */
-  },
-  {
-       0,    4,    5,    3,    4,    3,    4,    5,
-      20,    6,   21,   44,   45,   46, 3008,   95,
-     112,  113,   57, 3009, 3010,  116,  117, 3011,
-     118, 3012, 3013, 3014, 3015, 3016, 3017, 3018,
-    3019, 3020, 3021, 3022,    1,    4,   15,  160,
-     161,   41,    6,   11,   42,  162,   43,  119,
-      56,   57,   58,  163,  236,  237, 3023,  119,
-     120,  242,  122,  486, 1512,  487,  246,  494,
-    1513,  495, 1514, 1515, 1516, 1517, 1518, 1519,
-      31 /* 73 elements */
-  },
-  {
-       0,  512,  513,  514,  515,    2,    3,  258,
-     259,  260,  261,  262,  263,  264,  265,  266,
-     267,  268,  269,  270,  271,  272,  273,  274,
-     275,  276,  277,  278,  279,  280,  281,  282,
-     283,  284,  285,  286,    1,    5,  287,  288,
-     289,  290,    6,    7,  291,  292,  293,  294,
-     295,  296,  297,  298,  299,  300,  301,  302,
-     303,  304,  305,  306,  307,  308,  309,  310,
-     311,  312,  313,  314,  315,  316,  317,  318,
-     319 /* 73 elements */
-  },
-  {
-       0,    1,    1,    2,    3,    4,    1,    5,
-       4,    3,    5,    8,    6,    9,   10,   11,
-      12,    7,  104,   14,  105,    4,   10,   15,
-      11,    6,   14,    8,  106,  107,  108,   15,
-     109,    9,   55,   10,    1,    2,    1,    2,
-       3,   12,    6,    2,    6,    7,   28,    7,
-      15,    8,    5,   18,   29,  152,   77,   24,
-      25,   26,   39,  108,   13,  109,   55,   56,
-      57,  116,   11,  153,  234,  235,  118,  119,
-      15 /* 73 elements */
-  }
-};
-static const uint8_t vc9_mv_diff_bits[4][73] = {
-  {
-     6,  7,  7,  8, 14,  6,  5,  6,  7, 14, 14,  6,  6,  6,  8,  9,
-    10,  9,  7,  7,  7, 14, 14, 10,  9, 10,  8, 10, 10, 14, 14, 14,
-    13, 13, 13,  6,  3,  5,  6,  8,  9, 13,  5,  4,  4,  5,  7,  9,
-     6,  5,  5,  5,  6,  9,  8,  5,  5,  5,  7, 10,  7,  7,  7,  7,
-     7,  8, 10,  9,  8,  9,  9,  9,  3 /* 73 elements */
-  },
-  {
-     5,  7,  7,  6,  6,  5,  5,  6,  7,  5,  7,  8,  8,  8, 14,  9,
-     9,  9,  8, 14, 14,  9,  9, 14,  9, 14, 14, 14, 14, 14, 14, 14,
-    14, 14, 14, 14,  2,  3,  6,  8,  8,  6,  3,  4,  6,  8,  6,  9,
-     6,  6,  6,  8,  8,  8, 14,  7,  7,  8,  7,  9, 13,  9,  8,  9,
-    13,  9, 13, 13, 13, 13, 13, 13,  5 /* 73 elements */
-     
-  },
-  {
-     3, 12, 12, 12, 12,  3,  4, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-    11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-    11, 11, 11, 11,  1,  5, 11, 11, 11, 11,  4,  4, 11, 11, 11, 11,
-    11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-    11, 11, 11, 11, 11, 11, 11, 11, 11 /* 73 elements */
-  },
-  {
-    15, 11, 15, 15, 15, 15, 12, 15, 12, 11, 12, 12, 15, 12, 12, 12,
-    12, 15, 15, 12, 15, 10, 11, 12, 11, 10, 11, 10, 15, 15, 15, 11,
-    15, 10, 14, 10,  4,  4,  5,  7,  8,  9,  5,  3,  4,  5,  6,  8,
-     5,  4,  3,  5,  6,  8,  7,  5,  5,  5,  6,  7,  9,  7,  6,  6,
-     6,  7, 10,  8,  8,  8,  7,  7,  4 /* 73 elements */
-  }
-};
-
-/* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */
-
-/* Scantables/ZZ scan are at 11.9 (p262) and 8.1.1.12 (p10) */
-
-#endif /* VC9DATA_H */
diff --git a/ffmpeg.src/libavcodec/vp3dsp.c b/ffmpeg.src/libavcodec/vp3dsp.c
deleted file mode 100644
index 1fa6d09..0000000
--- a/ffmpeg.src/libavcodec/vp3dsp.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copyright (C) 2004 the ffmpeg project
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/**
- * @file vp3dsp.c
- * Standard C DSP-oriented functions cribbed from the original VP3 
- * source code.
- */
-
-#include "common.h"
-#include "avcodec.h"
-#include "dsputil.h"
-
-#define IdctAdjustBeforeShift 8
-#define xC1S7 64277
-#define xC2S6 60547
-#define xC3S5 54491
-#define xC4S4 46341
-#define xC5S3 36410
-#define xC6S2 25080
-#define xC7S1 12785
-
-static always_inline void idct(uint8_t *dst, int stride, int16_t *input, int type)
-{
-    int16_t *ip = input;
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;
-
-    int A_, B_, C_, D_, _Ad, _Bd, _Cd, _Dd, E_, F_, G_, H_;
-    int _Ed, _Gd, _Add, _Bdd, _Fd, _Hd;
-    int t1, t2;
-
-    int i;
-    
-    /* Inverse DCT on the rows now */
-    for (i = 0; i < 8; i++) {
-        /* Check for non-zero values */
-        if ( ip[0] | ip[1] | ip[2] | ip[3] | ip[4] | ip[5] | ip[6] | ip[7] ) {
-            t1 = (int32_t)(xC1S7 * ip[1]);
-            t2 = (int32_t)(xC7S1 * ip[7]);
-            t1 >>= 16;
-            t2 >>= 16;
-            A_ = t1 + t2;
-
-            t1 = (int32_t)(xC7S1 * ip[1]);
-            t2 = (int32_t)(xC1S7 * ip[7]);
-            t1 >>= 16;
-            t2 >>= 16;
-            B_ = t1 - t2;
-
-            t1 = (int32_t)(xC3S5 * ip[3]);
-            t2 = (int32_t)(xC5S3 * ip[5]);
-            t1 >>= 16;
-            t2 >>= 16;
-            C_ = t1 + t2;
-
-            t1 = (int32_t)(xC3S5 * ip[5]);
-            t2 = (int32_t)(xC5S3 * ip[3]);
-            t1 >>= 16;
-            t2 >>= 16;
-            D_ = t1 - t2;
-
-
-            t1 = (int32_t)(xC4S4 * (A_ - C_));
-            t1 >>= 16;
-            _Ad = t1;
-
-            t1 = (int32_t)(xC4S4 * (B_ - D_));
-            t1 >>= 16;
-            _Bd = t1;
-
-
-            _Cd = A_ + C_;
-            _Dd = B_ + D_;
-
-            t1 = (int32_t)(xC4S4 * (ip[0] + ip[4]));
-            t1 >>= 16;
-            E_ = t1;
-
-            t1 = (int32_t)(xC4S4 * (ip[0] - ip[4]));
-            t1 >>= 16;
-            F_ = t1;
-
-            t1 = (int32_t)(xC2S6 * ip[2]);
-            t2 = (int32_t)(xC6S2 * ip[6]);
-            t1 >>= 16;
-            t2 >>= 16;
-            G_ = t1 + t2;
-
-            t1 = (int32_t)(xC6S2 * ip[2]);
-            t2 = (int32_t)(xC2S6 * ip[6]);
-            t1 >>= 16;
-            t2 >>= 16;
-            H_ = t1 - t2;
-
-
-            _Ed = E_ - G_;
-            _Gd = E_ + G_;
-
-            _Add = F_ + _Ad;
-            _Bdd = _Bd - H_;
-
-            _Fd = F_ - _Ad;
-            _Hd = _Bd + H_;
-
-            /*  Final sequence of operations over-write original inputs. */
-            ip[0] = _Gd + _Cd ;
-            ip[7] = _Gd - _Cd ;
-
-            ip[1] = _Add + _Hd;
-            ip[2] = _Add - _Hd;
-
-            ip[3] = _Ed + _Dd ;
-            ip[4] = _Ed - _Dd ;
-
-            ip[5] = _Fd + _Bdd;
-            ip[6] = _Fd - _Bdd;
-
-        }
-
-        ip += 8;            /* next row */
-    }
-    
-    ip = input;
-
-    for ( i = 0; i < 8; i++) {
-        /* Check for non-zero values (bitwise or faster than ||) */
-        if ( ip[1 * 8] | ip[2 * 8] | ip[3 * 8] |
-             ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8] ) {
-
-            t1 = (int32_t)(xC1S7 * ip[1*8]);
-            t2 = (int32_t)(xC7S1 * ip[7*8]);
-            t1 >>= 16;
-            t2 >>= 16;
-            A_ = t1 + t2;
-
-            t1 = (int32_t)(xC7S1 * ip[1*8]);
-            t2 = (int32_t)(xC1S7 * ip[7*8]);
-            t1 >>= 16;
-            t2 >>= 16;
-            B_ = t1 - t2;
-
-            t1 = (int32_t)(xC3S5 * ip[3*8]);
-            t2 = (int32_t)(xC5S3 * ip[5*8]);
-            t1 >>= 16;
-            t2 >>= 16;
-            C_ = t1 + t2;
-
-            t1 = (int32_t)(xC3S5 * ip[5*8]);
-            t2 = (int32_t)(xC5S3 * ip[3*8]);
-            t1 >>= 16;
-            t2 >>= 16;
-            D_ = t1 - t2;
-
-
-            t1 = (int32_t)(xC4S4 * (A_ - C_));
-            t1 >>= 16;
-            _Ad = t1;
-
-            t1 = (int32_t)(xC4S4 * (B_ - D_));
-            t1 >>= 16;
-            _Bd = t1;
-
-
-            _Cd = A_ + C_;
-            _Dd = B_ + D_;
-
-            t1 = (int32_t)(xC4S4 * (ip[0*8] + ip[4*8]));
-            t1 >>= 16;
-            E_ = t1;
-
-            t1 = (int32_t)(xC4S4 * (ip[0*8] - ip[4*8]));
-            t1 >>= 16;
-            F_ = t1;
-
-            t1 = (int32_t)(xC2S6 * ip[2*8]);
-            t2 = (int32_t)(xC6S2 * ip[6*8]);
-            t1 >>= 16;
-            t2 >>= 16;
-            G_ = t1 + t2;
-
-            t1 = (int32_t)(xC6S2 * ip[2*8]);
-            t2 = (int32_t)(xC2S6 * ip[6*8]);
-            t1 >>= 16;
-            t2 >>= 16;
-            H_ = t1 - t2;
-
-
-            _Ed = E_ - G_;
-            _Gd = E_ + G_;
-
-            _Add = F_ + _Ad;
-            _Bdd = _Bd - H_;
-
-            _Fd = F_ - _Ad;
-            _Hd = _Bd + H_;
-
-            if(type==1){  //HACK
-                _Gd += 16*128;
-                _Add+= 16*128;
-                _Ed += 16*128;
-                _Fd += 16*128;
-            }
-            _Gd += IdctAdjustBeforeShift;
-            _Add += IdctAdjustBeforeShift;
-            _Ed += IdctAdjustBeforeShift;
-            _Fd += IdctAdjustBeforeShift;
-
-            /* Final sequence of operations over-write original inputs. */
-            if(type==0){
-                ip[0*8] = (_Gd + _Cd )  >> 4;
-                ip[7*8] = (_Gd - _Cd )  >> 4;
-    
-                ip[1*8] = (_Add + _Hd ) >> 4;
-                ip[2*8] = (_Add - _Hd ) >> 4;
-    
-                ip[3*8] = (_Ed + _Dd )  >> 4;
-                ip[4*8] = (_Ed - _Dd )  >> 4;
-    
-                ip[5*8] = (_Fd + _Bdd ) >> 4;
-                ip[6*8] = (_Fd - _Bdd ) >> 4;
-            }else if(type==1){
-                dst[0*stride] = cm[(_Gd + _Cd )  >> 4];
-                dst[7*stride] = cm[(_Gd - _Cd )  >> 4];
-    
-                dst[1*stride] = cm[(_Add + _Hd ) >> 4];
-                dst[2*stride] = cm[(_Add - _Hd ) >> 4];
-    
-                dst[3*stride] = cm[(_Ed + _Dd )  >> 4];
-                dst[4*stride] = cm[(_Ed - _Dd )  >> 4];
-    
-                dst[5*stride] = cm[(_Fd + _Bdd ) >> 4];
-                dst[6*stride] = cm[(_Fd - _Bdd ) >> 4];
-            }else{
-                dst[0*stride] = cm[dst[0*stride] + ((_Gd + _Cd )  >> 4)];
-                dst[7*stride] = cm[dst[7*stride] + ((_Gd - _Cd )  >> 4)];
-    
-                dst[1*stride] = cm[dst[1*stride] + ((_Add + _Hd ) >> 4)];
-                dst[2*stride] = cm[dst[2*stride] + ((_Add - _Hd ) >> 4)];
-    
-                dst[3*stride] = cm[dst[3*stride] + ((_Ed + _Dd )  >> 4)];
-                dst[4*stride] = cm[dst[4*stride] + ((_Ed - _Dd )  >> 4)];
-    
-                dst[5*stride] = cm[dst[5*stride] + ((_Fd + _Bdd ) >> 4)];
-                dst[6*stride] = cm[dst[6*stride] + ((_Fd - _Bdd ) >> 4)];
-            }
-
-        } else {
-            if(type==0){
-                ip[0*8] = 
-                ip[1*8] = 
-                ip[2*8] = 
-                ip[3*8] = 
-                ip[4*8] = 
-                ip[5*8] = 
-                ip[6*8] =
-                ip[7*8] = ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20);
-            }else if(type==1){
-                dst[0*stride]=
-                dst[1*stride]=
-                dst[2*stride]=
-                dst[3*stride]=
-                dst[4*stride]=
-                dst[5*stride]=
-                dst[6*stride]=
-                dst[7*stride]= 128 + ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20);
-            }else{
-                if(ip[0*8]){
-                    int v= ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20);
-                    dst[0*stride] = cm[dst[0*stride] + v];
-                    dst[1*stride] = cm[dst[1*stride] + v];
-                    dst[2*stride] = cm[dst[2*stride] + v];
-                    dst[3*stride] = cm[dst[3*stride] + v];
-                    dst[4*stride] = cm[dst[4*stride] + v];
-                    dst[5*stride] = cm[dst[5*stride] + v];
-                    dst[6*stride] = cm[dst[6*stride] + v];
-                    dst[7*stride] = cm[dst[7*stride] + v];
-                }
-            }
-        }
-
-        ip++;            /* next column */
-        dst++;
-    }
-}
-
-void ff_vp3_idct_c(DCTELEM *block/* align 16*/){
-    idct(NULL, 0, block, 0);
-}
-    
-void ff_vp3_idct_put_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/){
-    idct(dest, line_size, block, 1);
-}
-
-void ff_vp3_idct_add_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/){
-    idct(dest, line_size, block, 2);
-}
diff --git a/ffmpeg.src/libavcodec/wmadata.h b/ffmpeg.src/libavcodec/wmadata.h
deleted file mode 100644
index ee17207..0000000
--- a/ffmpeg.src/libavcodec/wmadata.h
+++ /dev/null
@@ -1,1412 +0,0 @@
-/**
- * @file wmadata.h
- * Various WMA tables.
- */
-
-static const uint16_t wma_critical_freqs[25] = {
-    100,   200,  300, 400,   510,  630,  770,    920,
-    1080, 1270, 1480, 1720, 2000, 2320, 2700,   3150,
-    3700, 4400, 5300, 6400, 7700, 9500, 12000, 15500,
-    24500,
-};
-
-/* first value is number of bands */
-static const uint8_t exponent_band_22050[3][25] = {
-    { 10, 4, 8, 4, 8, 8, 12, 20, 24, 24, 16, },
-    { 14, 4, 8, 8, 4, 12, 12, 16, 24, 16, 20, 24, 32, 40, 36, },
-    { 23, 4, 4, 4, 8, 4, 4, 8, 8, 8, 8, 8, 12, 12, 16, 16, 24, 24, 32, 44, 48, 60, 84, 72, },
-};
-
-static const uint8_t exponent_band_32000[3][25] = {
-    { 11, 4, 4, 8, 4, 4, 12, 16, 24, 20, 28, 4, },
-    { 15, 4, 8, 4, 4, 8, 8, 16, 20, 12, 20, 20, 28, 40, 56, 8, },
-    { 16, 8, 4, 8, 8, 12, 16, 20, 24, 40, 32, 32, 44, 56, 80, 112, 16, },
-};
-
-static const uint8_t exponent_band_44100[3][25] = {
-    { 12,  4,   4,   4,   4,   4,   8,   8,   8,  12,  16,  20,  36, },
-    { 15,  4,   8,   4,   8,   8,   4,   8,   8,  12,  12,  12,  24,  28,  40,  76, },
-    { 17,  4,   8,   8,   4,  12,  12,   8,   8,  24,  16,  20,  24,  32,  40,  60,  80, 152, },
-};
-
-static const uint16_t hgain_huffcodes[37] = {
- 0x00003, 0x002e7, 0x00001, 0x005cd, 0x0005d, 0x005c9, 0x0005e, 0x00003,
- 0x00016, 0x0000b, 0x00001, 0x00006, 0x00001, 0x00006, 0x00004, 0x00005,
- 0x00004, 0x00007, 0x00003, 0x00007, 0x00004, 0x0000a, 0x0000a, 0x00002,
- 0x00003, 0x00000, 0x00005, 0x00002, 0x0005f, 0x00004, 0x00003, 0x00002,
- 0x005c8, 0x000b8, 0x005ca, 0x005cb, 0x005cc,
-};
-
-static const uint8_t hgain_huffbits[37] = {
- 10, 12, 10, 13,  9, 13,  9,  8,
-  7,  5,  5,  4,  4,  3,  3,  3,
-  4,  3,  4,  4,  5,  5,  6,  8,
-  7, 10,  8, 10,  9,  8,  9,  9,
- 13, 10, 13, 13, 13,
-};
-
-static const float lsp_codebook[NB_LSP_COEFS][16] = {
- { 1.98732877, 1.97944528, 1.97179088, 1.96260549, 1.95038374, 1.93336114, 1.90719232, 1.86191415, },
- { 1.97260000, 1.96083160, 1.94982586, 1.93806164, 1.92516608, 1.91010199, 1.89232331, 1.87149812,
-   1.84564818, 1.81358067, 1.77620070, 1.73265264, 1.67907855, 1.60959081, 1.50829650, 1.33120330, },
- { 1.90109110, 1.86482426, 1.83419671, 1.80168452, 1.76650116, 1.72816320, 1.68502700, 1.63738256,
-   1.58501580, 1.51795181, 1.43679906, 1.33950585, 1.24176208, 1.12260729, 0.96749668, 0.74048265, },
- { 1.76943864, 1.67822463, 1.59946365, 1.53560582, 1.47470796, 1.41210167, 1.34509536, 1.27339507,
-   1.19303814, 1.09765169, 0.98818722, 0.87239446, 0.74369172, 0.59768184, 0.43168630, 0.17977021, },
- { 1.43428349, 1.32038354, 1.21074086, 1.10577988, 1.00561746, 0.90335924, 0.80437489, 0.70709671,
-   0.60427395, 0.49814048, 0.38509539, 0.27106800, 0.14407416, 0.00219910, -0.16725141, -0.36936085, },
- { 0.99895687, 0.84188166, 0.70753739, 0.57906595, 0.47055563, 0.36966965, 0.26826648, 0.17163380,
-   0.07208392, -0.03062936, -1.40037388, -0.25128968, -0.37213937, -0.51075646, -0.64887512, -0.80308031, },
- { 0.26515280, 0.06313551, -0.08872080, -0.21103548, -0.31069678, -0.39680323, -0.47223474, -0.54167135,
-   -0.61444740, -0.68943343, -0.76580211, -0.85170082, -0.95289061, -1.06514703, -1.20510707, -1.37617746, },
- { -0.53940301, -0.73770929, -0.88424876, -1.01117930, -1.13389091, -1.26830073, -1.42041987, -1.62033919,
-   -1.10158808, -1.16512566, -1.23337128, -1.30414401, -1.37663312, -1.46853845, -1.57625798, -1.66893638, },
- { -0.38601997, -0.56009350, -0.66978483, -0.76028471, -0.83846064, -0.90868087, -0.97408881, -1.03694962, },
- { -1.56144989, -1.65944032, -1.72689685, -1.77857740, -1.82203011, -1.86220079, -1.90283983, -1.94820479, },
-};
-
-static const uint32_t scale_huffcodes[121] = {
- 0x3ffe8, 0x3ffe6, 0x3ffe7, 0x3ffe5, 0x7fff5, 0x7fff1, 0x7ffed, 0x7fff6,
- 0x7ffee, 0x7ffef, 0x7fff0, 0x7fffc, 0x7fffd, 0x7ffff, 0x7fffe, 0x7fff7,
- 0x7fff8, 0x7fffb, 0x7fff9, 0x3ffe4, 0x7fffa, 0x3ffe3, 0x1ffef, 0x1fff0,
- 0x0fff5, 0x1ffee, 0x0fff2, 0x0fff3, 0x0fff4, 0x0fff1, 0x07ff6, 0x07ff7,
- 0x03ff9, 0x03ff5, 0x03ff7, 0x03ff3, 0x03ff6, 0x03ff2, 0x01ff7, 0x01ff5,
- 0x00ff9, 0x00ff7, 0x00ff6, 0x007f9, 0x00ff4, 0x007f8, 0x003f9, 0x003f7,
- 0x003f5, 0x001f8, 0x001f7, 0x000fa, 0x000f8, 0x000f6, 0x00079, 0x0003a,
- 0x00038, 0x0001a, 0x0000b, 0x00004, 0x00000, 0x0000a, 0x0000c, 0x0001b,
- 0x00039, 0x0003b, 0x00078, 0x0007a, 0x000f7, 0x000f9, 0x001f6, 0x001f9,
- 0x003f4, 0x003f6, 0x003f8, 0x007f5, 0x007f4, 0x007f6, 0x007f7, 0x00ff5,
- 0x00ff8, 0x01ff4, 0x01ff6, 0x01ff8, 0x03ff8, 0x03ff4, 0x0fff0, 0x07ff4,
- 0x0fff6, 0x07ff5, 0x3ffe2, 0x7ffd9, 0x7ffda, 0x7ffdb, 0x7ffdc, 0x7ffdd,
- 0x7ffde, 0x7ffd8, 0x7ffd2, 0x7ffd3, 0x7ffd4, 0x7ffd5, 0x7ffd6, 0x7fff2,
- 0x7ffdf, 0x7ffe7, 0x7ffe8, 0x7ffe9, 0x7ffea, 0x7ffeb, 0x7ffe6, 0x7ffe0,
- 0x7ffe1, 0x7ffe2, 0x7ffe3, 0x7ffe4, 0x7ffe5, 0x7ffd7, 0x7ffec, 0x7fff4,
- 0x7fff3,
-};
-
-static const uint8_t scale_huffbits[121] = {
- 18, 18, 18, 18, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 18, 19, 18, 17, 17,
- 16, 17, 16, 16, 16, 16, 15, 15,
- 14, 14, 14, 14, 14, 14, 13, 13,
- 12, 12, 12, 11, 12, 11, 10, 10,
- 10,  9,  9,  8,  8,  8,  7,  6,
-  6,  5,  4,  3,  1,  4,  4,  5,
-  6,  6,  7,  7,  8,  8,  9,  9,
- 10, 10, 10, 11, 11, 11, 11, 12,
- 12, 13, 13, 13, 14, 14, 16, 15,
- 16, 15, 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,
- 19,
-};
-
-static const uint32_t coef0_huffcodes[666] = {
- 0x00258, 0x0003d, 0x00000, 0x00005, 0x00008, 0x00008, 0x0000c, 0x0001b,
- 0x0001f, 0x00015, 0x00024, 0x00032, 0x0003a, 0x00026, 0x0002c, 0x0002f,
- 0x0004a, 0x0004d, 0x00061, 0x00070, 0x00073, 0x00048, 0x00052, 0x0005a,
- 0x0005d, 0x0006e, 0x00099, 0x0009e, 0x000c1, 0x000ce, 0x000e4, 0x000f0,
- 0x00093, 0x0009e, 0x000a2, 0x000a1, 0x000b8, 0x000d2, 0x000d3, 0x0012e,
- 0x00130, 0x000de, 0x0012d, 0x0019b, 0x001e4, 0x00139, 0x0013a, 0x0013f,
- 0x0014f, 0x0016d, 0x001a2, 0x0027c, 0x0027e, 0x00332, 0x0033c, 0x0033f,
- 0x0038b, 0x00396, 0x003c5, 0x00270, 0x0027c, 0x0025a, 0x00395, 0x00248,
- 0x004bd, 0x004fb, 0x00662, 0x00661, 0x0071b, 0x004e6, 0x004ff, 0x00666,
- 0x0071c, 0x0071a, 0x0071f, 0x00794, 0x00536, 0x004e2, 0x0078e, 0x004ee,
- 0x00518, 0x00535, 0x004fb, 0x0078d, 0x00530, 0x00680, 0x0068f, 0x005cb,
- 0x00965, 0x006a6, 0x00967, 0x0097f, 0x00682, 0x006ae, 0x00cd0, 0x00e28,
- 0x00f13, 0x00f1f, 0x009f5, 0x00cd3, 0x00f11, 0x00926, 0x00964, 0x00f32,
- 0x00f12, 0x00f30, 0x00966, 0x00d0b, 0x00a68, 0x00b91, 0x009c7, 0x00b73,
- 0x012fa, 0x0131d, 0x013f9, 0x01ca0, 0x0199c, 0x01c7a, 0x0198c, 0x01248,
- 0x01c74, 0x01c64, 0x0139e, 0x012fd, 0x00a77, 0x012fc, 0x01c7b, 0x012ca,
- 0x014cc, 0x014d2, 0x014e3, 0x014dc, 0x012dc, 0x03344, 0x02598, 0x0263c,
- 0x0333b, 0x025e6, 0x01a1c, 0x01e3c, 0x014e2, 0x033d4, 0x01a11, 0x03349,
- 0x03cce, 0x014e1, 0x01a34, 0x0273e, 0x02627, 0x0273f, 0x038ee, 0x03971,
- 0x03c67, 0x03c61, 0x0333d, 0x038c2, 0x0263f, 0x038cd, 0x02638, 0x02e41,
- 0x0351f, 0x03348, 0x03c66, 0x03562, 0x02989, 0x027d5, 0x0333c, 0x02e4f,
- 0x0343b, 0x02ddf, 0x04bc8, 0x029c0, 0x02e57, 0x04c72, 0x025b7, 0x03547,
- 0x03540, 0x029d3, 0x04c45, 0x025bb, 0x06600, 0x04c73, 0x04bce, 0x0357b,
- 0x029a6, 0x029d2, 0x0263e, 0x0298a, 0x07183, 0x06602, 0x07958, 0x04b66,
- 0x0537d, 0x05375, 0x04fe9, 0x04b67, 0x0799f, 0x04bc9, 0x051fe, 0x06a3b,
- 0x05bb6, 0x04fa8, 0x0728f, 0x05376, 0x0492c, 0x0537e, 0x0795a, 0x06a3c,
- 0x0e515, 0x07887, 0x0683a, 0x051f9, 0x051fd, 0x0cc6a, 0x06a8a, 0x0cc6d,
- 0x05bb3, 0x0683b, 0x051fc, 0x05378, 0x0728e, 0x07886, 0x05bb7, 0x0f2a4,
- 0x0795b, 0x0683c, 0x09fc1, 0x0683d, 0x0b752, 0x09678, 0x0a3e8, 0x06ac7,
- 0x051f0, 0x0b759, 0x06af3, 0x04b6b, 0x0f2a0, 0x0f2ad, 0x096c3, 0x0e518,
- 0x0b75c, 0x0d458, 0x0cc6b, 0x0537c, 0x067aa, 0x04fea, 0x0343a, 0x0cc71,
- 0x0967f, 0x09fc4, 0x096c2, 0x0e516, 0x0f2a1, 0x0d45c, 0x0d45d, 0x0d45e,
- 0x12fb9, 0x0967e, 0x1982f, 0x09883, 0x096c4, 0x0b753, 0x12fb8, 0x0f2a8,
- 0x1ca21, 0x096c5, 0x0e51a, 0x1ca27, 0x12f3c, 0x0d471, 0x0f2aa, 0x0b75b,
- 0x12fbb, 0x0f2a9, 0x0f2ac, 0x0d45a, 0x0b74f, 0x096c8, 0x16e91, 0x096ca,
- 0x12fbf, 0x0d0a7, 0x13103, 0x0d516, 0x16e99, 0x12cbd, 0x0a3ea, 0x19829,
- 0x0b755, 0x29ba7, 0x1ca28, 0x29ba5, 0x16e93, 0x1982c, 0x19828, 0x25994,
- 0x0a3eb, 0x1ca29, 0x16e90, 0x1ca25, 0x1982d, 0x1ca26, 0x16e9b, 0x0b756,
- 0x0967c, 0x25997, 0x0b75f, 0x198d3, 0x0b757, 0x19a2a, 0x0d45b, 0x0e517,
- 0x1ca24, 0x1ca23, 0x1ca22, 0x0b758, 0x16e97, 0x0cd14, 0x13100, 0x00007,
- 0x0003b, 0x0006b, 0x00097, 0x00138, 0x00125, 0x00173, 0x00258, 0x00335,
- 0x0028e, 0x004c6, 0x00715, 0x00729, 0x004ef, 0x00519, 0x004ed, 0x00532,
- 0x0068c, 0x00686, 0x00978, 0x00e5d, 0x00e31, 0x009f4, 0x00b92, 0x012f8,
- 0x00d06, 0x00a67, 0x00d44, 0x00a76, 0x00d59, 0x012cd, 0x01c78, 0x01c75,
- 0x0199f, 0x0198f, 0x01c67, 0x014c6, 0x01c79, 0x01c76, 0x00b94, 0x00d1b,
- 0x01e32, 0x01e31, 0x01ab0, 0x01a05, 0x01aa1, 0x0333a, 0x025e5, 0x02626,
- 0x03541, 0x03544, 0x03421, 0x03546, 0x02e55, 0x02e56, 0x0492d, 0x02dde,
- 0x0299b, 0x02ddc, 0x0357a, 0x0249c, 0x0668b, 0x1c77f, 0x1ca20, 0x0d45f,
- 0x09886, 0x16e9a, 0x0f2a7, 0x0b751, 0x0a3ee, 0x0cf59, 0x0cf57, 0x0b754,
- 0x0d0a6, 0x16e98, 0x0b760, 0x06ac6, 0x0a3f0, 0x12fbe, 0x13104, 0x0f2a5,
- 0x0a3ef, 0x0d472, 0x12cba, 0x1982e, 0x16e9c, 0x1c77e, 0x198d0, 0x13105,
- 0x16e92, 0x0b75d, 0x0d459, 0x0001a, 0x000c0, 0x0016c, 0x003cd, 0x00350,
- 0x0067b, 0x0051e, 0x006a9, 0x009f4, 0x00b72, 0x00d09, 0x01249, 0x01e3d,
- 0x01ca1, 0x01a1f, 0x01721, 0x01a8a, 0x016e8, 0x03347, 0x01a35, 0x0249d,
- 0x0299a, 0x02596, 0x02e4e, 0x0298b, 0x07182, 0x04c46, 0x025ba, 0x02e40,
- 0x027d6, 0x04fe8, 0x06607, 0x05310, 0x09884, 0x072e1, 0x06a3d, 0x04b6a,
- 0x04c7a, 0x06603, 0x04c7b, 0x03428, 0x06605, 0x09664, 0x09fc0, 0x071de,
- 0x06601, 0x05bb2, 0x09885, 0x0a3e2, 0x1c61f, 0x12cbb, 0x0b750, 0x0cf58,
- 0x0967d, 0x25995, 0x668ad, 0x0b75a, 0x09fc2, 0x0537f, 0x0b75e, 0x13fae,
- 0x12fbc, 0x00031, 0x001c4, 0x004c5, 0x005b8, 0x00cf4, 0x0096f, 0x00d46,
- 0x01e57, 0x01a04, 0x02625, 0x03346, 0x028f9, 0x04c47, 0x072e0, 0x04b69,
- 0x03420, 0x07957, 0x06639, 0x0799e, 0x07959, 0x07881, 0x04b68, 0x09fc3,
- 0x09fd6, 0x0cc70, 0x0a3f1, 0x12cbe, 0x0e30e, 0x0e51b, 0x06af2, 0x12cbc,
- 0x1c77d, 0x0f2ab, 0x12fbd, 0x1aa2f, 0x0a3ec, 0x0d473, 0x05377, 0x0a3e9,
- 0x1982b, 0x0e300, 0x12f3f, 0x0cf5f, 0x096c0, 0x38c3c, 0x16e94, 0x16e95,
- 0x12f3d, 0x29ba4, 0x29ba6, 0x1c77c, 0x6a8ba, 0x3545c, 0x33457, 0x668ac,
- 0x6a8bb, 0x16e9d, 0x0e519, 0x25996, 0x12f3e, 0x00036, 0x0033e, 0x006ad,
- 0x00d03, 0x012c8, 0x0124a, 0x03c42, 0x03ccd, 0x06606, 0x07880, 0x06852,
- 0x06a3a, 0x05bb4, 0x0f2a2, 0x09fc7, 0x12cb9, 0x0cc6c, 0x0a6e8, 0x096c1,
- 0x0004a, 0x00355, 0x012f9, 0x014e8, 0x01abe, 0x025b6, 0x0492e, 0x09fc6,
- 0x051ff, 0x0cc6f, 0x096cb, 0x0d071, 0x198d1, 0x12cb8, 0x38c3d, 0x13faf,
- 0x096c9, 0x0009d, 0x00539, 0x012ce, 0x0341f, 0x029c1, 0x04b33, 0x0a3e3,
- 0x0d070, 0x16e96, 0x0b763, 0x000a0, 0x009ce, 0x038cc, 0x0343d, 0x051fa,
- 0x09888, 0x12fba, 0x000df, 0x00a75, 0x029a7, 0x09fc5, 0x0e301, 0x0967b,
- 0x001e7, 0x012c9, 0x051fb, 0x09889, 0x0f2a6, 0x0016f, 0x01cb9, 0x0cf5a,
- 0x12cbf, 0x09679, 0x00272, 0x01a15, 0x0967a, 0x003cb, 0x025f6, 0x0b762,
- 0x0028d, 0x03c60, 0x0cf5e, 0x00352, 0x03ccc, 0x0072f, 0x07186, 0x004ec,
- 0x05379, 0x0068e, 0x09887, 0x006a7, 0x06af1, 0x00e29, 0x0cf5b, 0x00f31,
- 0x0d470, 0x009c6, 0x013fb, 0x13102, 0x019a5, 0x13101, 0x01983, 0x01c65,
- 0x0124f, 0x014c7, 0x01726, 0x01abf, 0x03304, 0x02624, 0x03c41, 0x027d7,
- 0x02ddd, 0x02e54, 0x0343c, 0x06604, 0x07181, 0x0663a, 0x04fa9, 0x0663b,
- 0x05311, 0x0537a, 0x06839, 0x05bb5, 0x0492f, 0x06af0, 0x096c7, 0x0cc6e,
- 0x0537b, 0x0cf5c, 0x0cf56, 0x198d2, 0x0cf5d, 0x0a3ed, 0x0f2a3, 0x1982a,
- 0x0b761, 0x096c6,
-};
-
-static const uint8_t coef0_huffbits[666] = {
- 11,  6,  2,  3,  4,  5,  5,  5,
-  5,  6,  6,  6,  6,  7,  7,  7,
-  7,  7,  7,  7,  7,  8,  8,  8,
-  8,  8,  8,  8,  8,  8,  8,  8,
-  9,  9,  9,  9,  9,  9,  9,  9,
-  9,  9,  9,  9,  9, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 11, 11, 11, 10, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 12, 12, 11, 12,
- 12, 12, 12, 11, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 13, 13, 12,
- 12, 12, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 14,
- 13, 13, 13, 13, 13, 13, 13, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 13, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 15,
- 15, 14, 14, 15, 15, 15, 14, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 14, 15, 15, 15, 15, 16,
- 16, 16, 15, 16, 15, 15, 16, 16,
- 16, 16, 15, 16, 16, 16, 15, 16,
- 16, 15, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 15, 15, 16, 16,
- 15, 16, 16, 16, 17, 17, 17, 16,
- 16, 17, 16, 16, 16, 16, 17, 16,
- 17, 17, 16, 16, 15, 15, 15, 16,
- 17, 16, 17, 16, 16, 17, 17, 17,
- 17, 17, 17, 16, 17, 17, 17, 16,
- 17, 17, 16, 17, 17, 17, 16, 17,
- 17, 16, 16, 17, 17, 17, 18, 17,
- 17, 17, 17, 17, 18, 18, 17, 17,
- 17, 19, 17, 19, 18, 17, 17, 18,
- 17, 17, 18, 17, 17, 17, 18, 17,
- 17, 18, 17, 17, 17, 17, 17, 16,
- 17, 17, 17, 17, 18, 16, 17,  4,
-  6,  8,  9,  9, 10, 10, 10, 10,
- 11, 11, 11, 11, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 14, 13, 13, 13, 13,
- 13, 13, 14, 14, 14, 14, 14, 14,
- 15, 15, 15, 15, 15, 15, 16, 15,
- 15, 15, 15, 15, 15, 17, 17, 17,
- 16, 18, 16, 17, 17, 16, 16, 17,
- 17, 18, 17, 16, 17, 17, 17, 16,
- 17, 17, 18, 17, 18, 17, 17, 17,
- 18, 17, 17,  5,  8, 10, 10, 11,
- 11, 12, 12, 12, 13, 13, 14, 13,
- 13, 14, 14, 14, 14, 14, 14, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 16, 16, 15, 16, 16,
- 15, 15, 15, 15, 15, 16, 16, 15,
- 15, 16, 16, 17, 17, 18, 17, 16,
- 17, 18, 19, 17, 16, 16, 17, 17,
- 17,  6,  9, 11, 12, 12, 13, 13,
- 13, 14, 14, 14, 15, 15, 15, 16,
- 15, 15, 15, 15, 15, 15, 16, 16,
- 16, 16, 17, 18, 16, 16, 16, 18,
- 17, 16, 17, 18, 17, 17, 16, 17,
- 17, 16, 17, 16, 17, 18, 18, 18,
- 17, 19, 19, 17, 20, 19, 18, 19,
- 20, 18, 16, 18, 17,  7, 10, 12,
- 13, 13, 14, 14, 14, 15, 15, 16,
- 16, 16, 16, 16, 18, 16, 17, 17,
-  8, 11, 13, 14, 14, 15, 16, 16,
- 16, 16, 17, 17, 17, 18, 18, 17,
- 17,  8, 12, 14, 15, 15, 15, 17,
- 17, 18, 17,  9, 12, 14, 15, 16,
- 16, 17,  9, 13, 15, 16, 16, 17,
-  9, 13, 16, 16, 16, 10, 13, 16,
- 18, 17, 10, 14, 17, 10, 14, 17,
- 11, 14, 16, 11, 14, 11, 15, 12,
- 16, 12, 16, 12, 16, 12, 16, 12,
- 17, 13, 13, 17, 13, 17, 13, 13,
- 14, 14, 14, 14, 14, 14, 14, 15,
- 15, 15, 15, 15, 15, 15, 16, 15,
- 16, 16, 16, 16, 16, 16, 17, 16,
- 16, 16, 16, 17, 16, 17, 16, 17,
- 17, 17,
-};
-
-static const uint32_t coef1_huffcodes[555] = {
- 0x00115, 0x00002, 0x00001, 0x00000, 0x0000d, 0x00007, 0x00013, 0x0001d,
- 0x00008, 0x0000c, 0x00023, 0x0002b, 0x0003f, 0x00017, 0x0001b, 0x00043,
- 0x00049, 0x00050, 0x00055, 0x00054, 0x00067, 0x00064, 0x0007b, 0x0002d,
- 0x00028, 0x0002a, 0x00085, 0x00089, 0x0002b, 0x00035, 0x00090, 0x00091,
- 0x00094, 0x00088, 0x000c1, 0x000c6, 0x000f2, 0x000e3, 0x000c5, 0x000e2,
- 0x00036, 0x000f0, 0x000a7, 0x000cd, 0x000fb, 0x00059, 0x00116, 0x00103,
- 0x00108, 0x0012b, 0x0012d, 0x00188, 0x0012e, 0x0014c, 0x001c3, 0x00187,
- 0x001e7, 0x0006f, 0x00094, 0x00069, 0x001e6, 0x001ca, 0x00147, 0x00195,
- 0x000a7, 0x00213, 0x00209, 0x00303, 0x00295, 0x00289, 0x0028c, 0x0028d,
- 0x00312, 0x00330, 0x0029b, 0x00308, 0x00328, 0x0029a, 0x0025e, 0x003c5,
- 0x00384, 0x0039f, 0x00397, 0x00296, 0x0032e, 0x00332, 0x003c6, 0x003e6,
- 0x0012d, 0x000d1, 0x00402, 0x000dd, 0x00161, 0x0012b, 0x00127, 0x0045d,
- 0x00601, 0x004ab, 0x0045f, 0x00410, 0x004bf, 0x00528, 0x0045c, 0x00424,
- 0x00400, 0x00511, 0x00618, 0x0073d, 0x0063a, 0x00614, 0x0073c, 0x007c0,
- 0x007cf, 0x00802, 0x00966, 0x00964, 0x00951, 0x008a0, 0x00346, 0x00803,
- 0x00a52, 0x0024a, 0x007c1, 0x0063f, 0x00126, 0x00406, 0x00789, 0x008a2,
- 0x00960, 0x00967, 0x00c05, 0x00c70, 0x00c79, 0x00a5d, 0x00c26, 0x00c4d,
- 0x00372, 0x008a5, 0x00c08, 0x002c5, 0x00f11, 0x00cc4, 0x00f8e, 0x00e16,
- 0x00496, 0x00e77, 0x00f9c, 0x00c25, 0x00f1e, 0x00c27, 0x00f1f, 0x00e17,
- 0x00ccd, 0x00355, 0x00c09, 0x00c78, 0x00f90, 0x00521, 0x00357, 0x00356,
- 0x0068e, 0x00f9d, 0x00c04, 0x00e58, 0x00a20, 0x00a2c, 0x00c4c, 0x0052f,
- 0x00f8d, 0x01178, 0x01053, 0x01097, 0x0180f, 0x0180d, 0x012fb, 0x012aa,
- 0x0202a, 0x00a40, 0x018ed, 0x01ceb, 0x01455, 0x018e3, 0x012a1, 0x00354,
- 0x00353, 0x00f1c, 0x00c7b, 0x00c37, 0x0101d, 0x012cb, 0x01142, 0x0197d,
- 0x01095, 0x01e3b, 0x0186b, 0x00588, 0x01c2a, 0x014b8, 0x01e3a, 0x018ec,
- 0x01f46, 0x012fa, 0x00a53, 0x01ce8, 0x00a55, 0x01c29, 0x0117b, 0x01052,
- 0x012a0, 0x00589, 0x00950, 0x01c2b, 0x00a50, 0x0208b, 0x0180e, 0x02027,
- 0x02556, 0x01e20, 0x006e7, 0x01c28, 0x0197a, 0x00684, 0x020a2, 0x01f22,
- 0x03018, 0x039cf, 0x03e25, 0x02557, 0x0294c, 0x028a6, 0x00d11, 0x028a9,
- 0x02979, 0x00d46, 0x00a56, 0x039ce, 0x030cc, 0x0329a, 0x0149d, 0x0510f,
- 0x0451c, 0x02028, 0x03299, 0x01ced, 0x014b9, 0x00f85, 0x00c7a, 0x01800,
- 0x00341, 0x012ca, 0x039c8, 0x0329d, 0x00d0d, 0x03e20, 0x05144, 0x00d45,
- 0x030d0, 0x0186d, 0x030d5, 0x00d0f, 0x00d40, 0x04114, 0x020a1, 0x0297f,
- 0x03e24, 0x032f1, 0x04047, 0x030d4, 0x028a8, 0x00d0e, 0x0451d, 0x04044,
- 0x0297e, 0x04042, 0x030d2, 0x030cf, 0x03e21, 0x03e26, 0x028a5, 0x0451a,
- 0x00d48, 0x01a16, 0x00d44, 0x04518, 0x0149b, 0x039ca, 0x01498, 0x0403d,
- 0x0451b, 0x0149c, 0x032f3, 0x030cb, 0x08073, 0x03e22, 0x0529a, 0x020aa,
- 0x039cc, 0x0738a, 0x06530, 0x07389, 0x06193, 0x08071, 0x04043, 0x030ce,
- 0x05147, 0x07388, 0x05145, 0x08072, 0x04521, 0x00d47, 0x0297c, 0x030cd,
- 0x030ca, 0x0000b, 0x0000c, 0x00083, 0x000e4, 0x00048, 0x00102, 0x001cc,
- 0x001f5, 0x00097, 0x0020b, 0x00124, 0x00453, 0x00627, 0x00639, 0x00605,
- 0x00517, 0x001b8, 0x00663, 0x00667, 0x007c3, 0x00823, 0x00961, 0x00963,
- 0x00e5a, 0x00e59, 0x00a2b, 0x00cbf, 0x00292, 0x00a2d, 0x007d0, 0x00953,
- 0x00cc5, 0x00f84, 0x004ab, 0x014a7, 0x0068a, 0x0117a, 0x0052e, 0x01442,
- 0x0052c, 0x00c77, 0x00f8f, 0x004aa, 0x01094, 0x01801, 0x012c4, 0x0297b,
- 0x00952, 0x01f19, 0x006a5, 0x01149, 0x012c5, 0x01803, 0x022f2, 0x0329b,
- 0x04520, 0x0149e, 0x00d13, 0x01f16, 0x01ce9, 0x0101c, 0x006e6, 0x039c9,
- 0x06191, 0x07c8e, 0x06192, 0x0ca63, 0x039cd, 0x06190, 0x06884, 0x06885,
- 0x07382, 0x00d49, 0x00d41, 0x0450c, 0x0149a, 0x030d1, 0x08077, 0x03e23,
- 0x01a15, 0x0e701, 0x0e702, 0x08079, 0x0822a, 0x0a218, 0x07887, 0x0403f,
- 0x0520b, 0x0529b, 0x0e700, 0x04519, 0x00007, 0x000e0, 0x000d0, 0x0039b,
- 0x003e5, 0x00163, 0x0063e, 0x007c9, 0x00806, 0x00954, 0x01044, 0x01f44,
- 0x0197c, 0x01f45, 0x00a51, 0x01f47, 0x00951, 0x0052d, 0x02291, 0x0092f,
- 0x00a54, 0x00d12, 0x0297d, 0x00d0c, 0x01499, 0x0329e, 0x032f0, 0x02025,
- 0x039c6, 0x00a57, 0x03e46, 0x00d42, 0x0738b, 0x05146, 0x04046, 0x08078,
- 0x0510e, 0x07886, 0x02904, 0x04156, 0x04157, 0x06032, 0x030d3, 0x08bce,
- 0x04040, 0x0403e, 0x0a414, 0x10457, 0x08075, 0x06887, 0x07c8f, 0x039c7,
- 0x07387, 0x08070, 0x08bcf, 0x1482a, 0x10456, 0x1482b, 0x01a17, 0x06886,
- 0x0450d, 0x00013, 0x0006b, 0x00615, 0x0080b, 0x0082b, 0x00952, 0x00e5b,
- 0x018e2, 0x0186c, 0x01f18, 0x0329f, 0x00d43, 0x03e29, 0x05140, 0x05141,
- 0x0ca62, 0x06033, 0x03c42, 0x03e28, 0x0450f, 0x0a21a, 0x07384, 0x0a219,
- 0x0e703, 0x0a21b, 0x01a14, 0x07383, 0x045e6, 0x0007a, 0x0012c, 0x00ccc,
- 0x0068f, 0x01802, 0x00a52, 0x00953, 0x04045, 0x01a20, 0x0451f, 0x000a4,
- 0x00735, 0x01cec, 0x02029, 0x020a3, 0x0451e, 0x00069, 0x00c24, 0x02024,
- 0x032f2, 0x05142, 0x00196, 0x00523, 0x000a6, 0x0197b, 0x0030b, 0x0092e,
- 0x003e9, 0x03e27, 0x00160, 0x05143, 0x00652, 0x04041, 0x00734, 0x028a7,
- 0x0080f, 0x01483, 0x0097c, 0x00340, 0x0068b, 0x00522, 0x01054, 0x01096,
- 0x01f17, 0x0202b, 0x01cea, 0x020a0, 0x02978, 0x02026, 0x0297a, 0x039cb,
- 0x03e2b, 0x0149f, 0x0329c, 0x07385, 0x08074, 0x0450e, 0x03e2a, 0x05149,
- 0x08076, 0x07386, 0x05148,
-};
-
-static const uint8_t coef1_huffbits[555] = {
-  9,  5,  2,  4,  4,  5,  5,  5,
-  6,  6,  6,  6,  6,  7,  7,  7,
-  7,  7,  7,  7,  7,  7,  7,  8,
-  8,  8,  8,  8,  8,  8,  8,  8,
-  8,  8,  8,  8,  8,  8,  8,  8,
-  9,  8,  8,  8,  8,  9,  9,  9,
-  9,  9,  9,  9,  9,  9,  9,  9,
-  9, 10, 10, 10,  9,  9,  9,  9,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 11, 11, 11, 11, 11, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 13, 12, 12, 12, 12, 12, 12, 12,
- 13, 12, 12, 12, 12, 12, 12, 12,
- 12, 13, 12, 12, 12, 13, 13, 13,
- 13, 12, 12, 12, 12, 12, 12, 13,
- 12, 13, 13, 13, 13, 13, 13, 13,
- 14, 14, 13, 13, 13, 13, 13, 13,
- 13, 12, 12, 12, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 14, 13, 14, 13, 13, 13,
- 13, 13, 14, 13, 14, 14, 13, 14,
- 14, 13, 14, 13, 13, 14, 14, 13,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 15, 14, 14, 14, 14, 15, 15,
- 15, 14, 14, 13, 13, 12, 12, 13,
- 13, 13, 14, 14, 15, 14, 15, 15,
- 14, 13, 14, 15, 15, 15, 14, 14,
- 14, 14, 15, 14, 14, 15, 15, 15,
- 14, 15, 14, 14, 14, 14, 14, 15,
- 15, 16, 15, 15, 15, 14, 15, 15,
- 15, 15, 14, 14, 16, 14, 15, 14,
- 14, 15, 15, 15, 15, 16, 15, 14,
- 15, 15, 15, 16, 15, 15, 14, 14,
- 14,  4,  7,  8,  8,  9,  9,  9,
-  9, 10, 10, 11, 11, 11, 11, 11,
- 11, 12, 11, 11, 11, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 11, 12,
- 12, 12, 13, 13, 13, 13, 13, 13,
- 13, 12, 12, 13, 13, 13, 13, 14,
- 14, 13, 14, 13, 13, 13, 14, 14,
- 15, 15, 14, 13, 13, 13, 14, 14,
- 15, 15, 15, 16, 14, 15, 17, 17,
- 15, 15, 15, 15, 15, 14, 16, 14,
- 16, 16, 16, 16, 16, 16, 15, 15,
- 17, 15, 16, 15,  6,  8, 10, 10,
- 10, 11, 11, 11, 12, 12, 13, 13,
- 13, 13, 14, 13, 14, 13, 14, 14,
- 14, 14, 14, 15, 15, 14, 14, 14,
- 14, 14, 14, 15, 15, 15, 15, 16,
- 15, 15, 16, 15, 15, 15, 14, 16,
- 15, 15, 18, 17, 16, 17, 15, 14,
- 15, 16, 16, 19, 17, 19, 16, 17,
- 15,  7, 10, 11, 12, 12, 12, 12,
- 13, 13, 13, 14, 15, 14, 15, 15,
- 16, 15, 14, 14, 15, 16, 15, 16,
- 16, 16, 16, 15, 15,  7, 11, 12,
- 13, 13, 14, 14, 15, 15, 15,  8,
- 11, 13, 14, 14, 15,  9, 12, 14,
- 14, 15,  9, 13, 10, 13, 10, 14,
- 10, 14, 11, 15, 11, 15, 11, 14,
- 12, 15, 12, 13, 13, 13, 13, 13,
- 13, 14, 13, 14, 14, 14, 14, 14,
- 14, 15, 14, 15, 16, 15, 14, 15,
- 16, 15, 15,
-};
-
-static const uint32_t coef2_huffcodes[1336] = {
- 0x003e6, 0x000f6, 0x00000, 0x00002, 0x00006, 0x0000f, 0x0001b, 0x00028,
- 0x00039, 0x0003f, 0x0006b, 0x00076, 0x000b7, 0x000e8, 0x000ef, 0x00169,
- 0x001a7, 0x001d4, 0x001dc, 0x002c4, 0x00349, 0x00355, 0x00391, 0x003dc,
- 0x00581, 0x005b2, 0x00698, 0x0070c, 0x00755, 0x0073a, 0x00774, 0x007cf,
- 0x00b0a, 0x00b66, 0x00d2e, 0x00d5e, 0x00e1b, 0x00eac, 0x00e5a, 0x00f7e,
- 0x00fa1, 0x0163e, 0x01a37, 0x01a52, 0x01c39, 0x01ab3, 0x01d5f, 0x01cb6,
- 0x01f52, 0x01dd9, 0x02c04, 0x02c2e, 0x02c2d, 0x02c23, 0x03467, 0x034a3,
- 0x0351b, 0x03501, 0x03a5d, 0x0351c, 0x03875, 0x03dea, 0x0397b, 0x039db,
- 0x03df1, 0x039d8, 0x03bb4, 0x0580a, 0x0584d, 0x05842, 0x05b13, 0x058ea,
- 0x0697d, 0x06a06, 0x068cc, 0x06ac7, 0x06a96, 0x072f4, 0x07543, 0x072b4,
- 0x07d20, 0x0b003, 0x073b5, 0x07be6, 0x0d180, 0x07bd1, 0x07cb8, 0x07d06,
- 0x07d25, 0x0d2f2, 0x0d19a, 0x0d334, 0x0e1dc, 0x0d529, 0x0d584, 0x0e1d2,
- 0x0e5e3, 0x0eec4, 0x0e564, 0x0fa49, 0x16001, 0x0eedc, 0x0f7fa, 0x1a32c,
- 0x16131, 0x16003, 0x0f9c8, 0x1ef80, 0x1d2a0, 0x1aa4b, 0x0f7ce, 0x1abfe,
- 0x1aa50, 0x1a458, 0x1a816, 0x1cae4, 0x1d2fe, 0x1d52e, 0x1aa4c, 0x2c245,
- 0x1d2a1, 0x1a35d, 0x1ca1b, 0x1d5d8, 0x1f531, 0x1ca1c, 0x1f389, 0x1f4af,
- 0x3a5e7, 0x351fb, 0x2c24b, 0x34bce, 0x2c24d, 0x2c249, 0x2c24a, 0x72dfc,
- 0x357ef, 0x35002, 0x3a5e6, 0x39431, 0x5843b, 0x34a77, 0x58431, 0x3a5f3,
- 0x3a5dd, 0x3e5e5, 0x356bd, 0x3976e, 0x6a3d2, 0x3500d, 0x694c4, 0x580bd,
- 0x3e5e8, 0x74b95, 0x34a6e, 0x3977c, 0x39432, 0x5b0d2, 0x6a3d8, 0x580b8,
- 0x5b0cb, 0x5b0d7, 0x72dee, 0x72ded, 0x72dec, 0x74b9c, 0x3977f, 0x72dea,
- 0x74b9e, 0x7be7d, 0x580bf, 0x5b0d5, 0x7cba8, 0x74b91, 0x3e5dd, 0xb6171,
- 0xd46b3, 0xd46b9, 0x7cba1, 0x74b9f, 0x72de1, 0xe59f5, 0x3e5eb, 0x00004,
- 0x00015, 0x00038, 0x00075, 0x000e8, 0x001d3, 0x00347, 0x0039c, 0x00690,
- 0x0074a, 0x00b60, 0x00e93, 0x00f74, 0x0163d, 0x01a5a, 0x01d24, 0x01cbe,
- 0x01f4b, 0x03468, 0x03562, 0x03947, 0x03e82, 0x05804, 0x05b12, 0x05803,
- 0x0696d, 0x06a9e, 0x0697c, 0x06978, 0x06afb, 0x074b2, 0x072f5, 0x073c0,
- 0x07541, 0x06944, 0x074b7, 0x070d3, 0x07ba9, 0x0b0b1, 0x0d1af, 0x0e1dd,
- 0x0e5e2, 0x0e1a3, 0x0eec3, 0x1612f, 0x0e961, 0x0eeda, 0x0e78e, 0x0fa48,
- 0x1612c, 0x0e511, 0x0e565, 0x0e953, 0x1aa4a, 0x0e59d, 0x1d52c, 0x1a811,
- 0x1cae7, 0x1abfc, 0x1d52d, 0x1cacf, 0x1cf05, 0x2c254, 0x34a72, 0x1f4ac,
- 0x3976b, 0x34a71, 0x2c6d9, 0x2d873, 0x34a6a, 0x357e7, 0x3464c, 0x3e5f5,
- 0x58433, 0x1f53a, 0x3500a, 0x357ea, 0x34a73, 0x3942f, 0x357e5, 0x39775,
- 0x694cd, 0x39772, 0x7cba5, 0x6a3ef, 0x35483, 0x74b98, 0x5b0c1, 0x39770,
- 0x3a5d7, 0x39433, 0x39434, 0x694ce, 0x580be, 0x3e5ff, 0x6a3ec, 0xb616f,
- 0xd46b1, 0x6a3d1, 0x72de5, 0x74b6e, 0x72de9, 0x3e700, 0xd46b6, 0x6a3e9,
- 0x74b69, 0xe5675, 0xd46b8, 0x7cbaa, 0x3a5d1, 0x0000c, 0x0003c, 0x000eb,
- 0x001f1, 0x003a4, 0x006a8, 0x007d5, 0x00d43, 0x00e77, 0x016c5, 0x01cb1,
- 0x02c5d, 0x03a55, 0x03a56, 0x03e51, 0x03bb5, 0x05b0a, 0x06a9f, 0x074b8,
- 0x07d28, 0x0d187, 0x0d40e, 0x0d52e, 0x0d425, 0x0eae3, 0x0e1d3, 0x1612e,
- 0x0e59e, 0x0eec2, 0x0e578, 0x0e51a, 0x0e579, 0x0e515, 0x0e960, 0x0d183,
- 0x0d220, 0x0d2cb, 0x0e512, 0x16c3e, 0x16002, 0x16c42, 0x1cae9, 0x3461a,
- 0x1d2fa, 0x1a308, 0x1a849, 0x1cf07, 0x1f38f, 0x34b65, 0x2c253, 0x1ef9e,
- 0x1cbc3, 0x1cbc1, 0x2c255, 0x1f384, 0x58435, 0x2c5cd, 0x3a5f7, 0x2c252,
- 0x3959c, 0x2c6d8, 0x3a5d3, 0x6ad78, 0x6a3f2, 0x7cba9, 0xb6176, 0x72deb,
- 0x39764, 0x3e5f6, 0x3a5d8, 0x74a8c, 0x6a3e6, 0x694d1, 0x6ad79, 0x1a4592,
- 0xe59fb, 0x7cbb3, 0x5b0cd, 0x00017, 0x000b5, 0x002c3, 0x005b7, 0x00b1c,
- 0x00e5c, 0x0163f, 0x01ab2, 0x01efa, 0x0348a, 0x0396e, 0x058da, 0x06963,
- 0x06a30, 0x072cd, 0x073cf, 0x07ce7, 0x0d2ca, 0x0d2d8, 0x0e764, 0x0e794,
- 0x16008, 0x16167, 0x1617e, 0x1aa49, 0x1a30b, 0x1a813, 0x2c6da, 0x1a580,
- 0x1cbc2, 0x0f9ca, 0x1617f, 0x1d2fe, 0x0f7fc, 0x16c40, 0x0e513, 0x0eec5,
- 0x0f7c3, 0x1d508, 0x1a81e, 0x1d2fd, 0x39430, 0x35486, 0x3e5fd, 0x2c24c,
- 0x2c75a, 0x34a74, 0x3a5f4, 0x3464d, 0x694ca, 0x3a5f1, 0x1d509, 0x1d5c0,
- 0x34648, 0x3464e, 0x6a3d5, 0x6a3e8, 0x6a3e7, 0x5b0c3, 0x2c248, 0x1f38a,
- 0x3a5f2, 0x6a3e5, 0x00029, 0x00168, 0x0058c, 0x00b67, 0x00f9d, 0x01c3d,
- 0x01cbf, 0x02c20, 0x0351d, 0x03df6, 0x06af9, 0x072b5, 0x0b1d7, 0x0b0b2,
- 0x0d40a, 0x0d52b, 0x0e952, 0x0e797, 0x163c3, 0x1c3a0, 0x1f386, 0x1ca21,
- 0x34655, 0x2c247, 0x1f53b, 0x2c250, 0x2c24f, 0x1f385, 0x1ef5d, 0x1cf15,
- 0x1caea, 0x1ab0a, 0x1cf19, 0x1f53d, 0x1d5c2, 0x1d2fb, 0x1ef58, 0x34a78,
- 0x357ec, 0x1f533, 0x3a5e1, 0x694d2, 0x58482, 0x3a5ee, 0x2c6dc, 0x357eb,
- 0x5b0c4, 0x39778, 0x6a3e1, 0x7cbb4, 0x3a5e1, 0x74b68, 0x3a5ef, 0x3a5d2,
- 0x39424, 0x72de2, 0xe59f6, 0xe59f7, 0x3e702, 0x3e5ec, 0x1f38b, 0x0003b,
- 0x001f0, 0x00777, 0x00fa8, 0x01cb2, 0x02d84, 0x03a57, 0x03dd6, 0x06917,
- 0x06a11, 0x07d07, 0x0eae2, 0x0e796, 0x0f9c9, 0x0f7fb, 0x16166, 0x16160,
- 0x1ab1b, 0x1abfa, 0x2d87b, 0x1d2f7, 0x39768, 0x1f38c, 0x34653, 0x34651,
- 0x6a3d9, 0x35001, 0x3abbd, 0x38742, 0x39426, 0x34a76, 0x3a5ec, 0x34a75,
- 0x35000, 0x35488, 0x1cf10, 0x2c6db, 0x357ed, 0x357e8, 0x357e9, 0x3a5f0,
- 0x694c2, 0xb6178, 0x72df5, 0x39425, 0x3942b, 0x74b6d, 0x74b6f, 0xb6177,
- 0xb6179, 0x74b6a, 0xb6172, 0x58487, 0x3e5ee, 0x3e5ed, 0x72df2, 0x72df4,
- 0x7cbae, 0x6a3ca, 0x70e86, 0x34bcf, 0x6a3c8, 0x00059, 0x00384, 0x00d5b,
- 0x01c38, 0x03560, 0x0395b, 0x0584e, 0x06964, 0x073cd, 0x0b1e7, 0x0e798,
- 0x0e78d, 0x0fa43, 0x1a848, 0x1a32f, 0x1aa4e, 0x3464a, 0x1f4ab, 0x1f38d,
- 0x3a5eb, 0x3a5d4, 0x3548a, 0x6a3c7, 0x5b0d0, 0x6a3c5, 0x7cbb0, 0x694cb,
- 0x3a5e5, 0x3e5e2, 0x3942c, 0x2d872, 0x1f4ae, 0x3a5d5, 0x694d3, 0x58481,
- 0x35009, 0x39774, 0x58432, 0xb616c, 0x5b0db, 0x3548b, 0xb6174, 0x1d5d95,
- 0xb004c, 0x7cbb2, 0x3a5e5, 0x74a8f, 0xe59f9, 0x72df6, 0xe59fd, 0x7cbad,
- 0xd427d, 0x72cff, 0x3977a, 0x5b0d9, 0xb616d, 0xb616b, 0x1a4593, 0x7cbaf,
- 0x5b0da, 0x00071, 0x003eb, 0x01603, 0x02c6c, 0x03961, 0x068c8, 0x06a31,
- 0x072bd, 0x0d2c2, 0x0e51b, 0x0e5e6, 0x1abfb, 0x1d2ff, 0x1cae5, 0x1ef5c,
- 0x1ef5e, 0x1cf13, 0x34a6d, 0x3976d, 0xb616a, 0x3e5f2, 0x6a3c4, 0xb6169,
- 0x3e5dc, 0x580b9, 0x74b99, 0x75764, 0x58434, 0x3a5d9, 0x6945a, 0x69459,
- 0x3548c, 0x3a5e9, 0x69457, 0x72df1, 0x6945e, 0x6a35e, 0x3e701, 0xb6168,
- 0x5b0dd, 0x3a5de, 0x6a3c2, 0xd4278, 0x6a3cc, 0x72dfd, 0xb6165, 0x16009a,
- 0x7cbb1, 0xd427c, 0xb6162, 0xe765e, 0x1cecbe, 0x7cbb6, 0x69454, 0xb6160,
- 0xd427a, 0x1d5d96, 0xb1d6d, 0xe59f4, 0x72de8, 0x3a5db, 0x0007a, 0x006ae,
- 0x01c3c, 0x03aba, 0x058e9, 0x072cc, 0x0d2dd, 0x0d22d, 0x0eec1, 0x0eedb,
- 0x1d2a2, 0x1ef5b, 0x357e2, 0x3abbf, 0x1d2f9, 0x35004, 0x3a5dc, 0x351fc,
- 0x3976c, 0x6a3c6, 0x6a3cb, 0x3e5ea, 0xe59f3, 0x6a3ce, 0x69452, 0xe59f0,
- 0x74b90, 0xd4279, 0xd427b, 0x7cbb5, 0x5b0c5, 0x3a5e3, 0x3a5e2, 0x000d0,
- 0x00775, 0x01efe, 0x03dd5, 0x0728c, 0x07cb9, 0x0e1a2, 0x0ea85, 0x0eed8,
- 0x1a30a, 0x1aa4f, 0x3a5df, 0x35008, 0x3a5e0, 0x3e5f4, 0x3e5f7, 0xb1d6c,
- 0x5843e, 0x34a70, 0x72df8, 0x74b6b, 0xd427f, 0x72df0, 0x5b0bf, 0x5b0c0,
- 0xd46b0, 0x72def, 0xe59f8, 0x162e64, 0xb1d6f, 0x3a5e0, 0x39427, 0x69166,
- 0x6a3e2, 0x6a3e3, 0x74a8d, 0xd427e, 0x1d5d97, 0xd46b4, 0x5b0d8, 0x6a3d3,
- 0x000e0, 0x00b63, 0x034cc, 0x06a33, 0x073c9, 0x0e1a0, 0x0f7fd, 0x0f9cc,
- 0x1617d, 0x1caeb, 0x1f4a9, 0x3abb3, 0x69450, 0x39420, 0x39777, 0x3e5e0,
- 0x6a3d4, 0x6a3ed, 0xb6166, 0xe59f1, 0xb1d6e, 0xe5676, 0x6a3ea, 0xe5674,
- 0xb6163, 0xd46b7, 0x7cba6, 0xd46ba, 0x1d5d94, 0xb6164, 0x6a3f1, 0x7cba2,
- 0x69451, 0x72dfa, 0xd46bb, 0x72df7, 0x74b94, 0x1cecbf, 0xe59fa, 0x16009b,
- 0x6a3e4, 0x000e6, 0x00e94, 0x03876, 0x070ef, 0x0d52a, 0x16015, 0x16014,
- 0x1abf9, 0x1cf17, 0x34a79, 0x34650, 0x3e705, 0x6a3d0, 0x58430, 0x74b9d,
- 0x7be7e, 0x5b0be, 0x39773, 0x6a3de, 0x000fb, 0x00f7b, 0x03dd7, 0x07bd0,
- 0x0e59c, 0x0f9cd, 0x1cf18, 0x1d2ff, 0x34a7a, 0x39429, 0x3500c, 0x72de0,
- 0x69456, 0x7be7c, 0xd46b5, 0xd46b2, 0x6a3dd, 0x001a2, 0x0163b, 0x06913,
- 0x0b016, 0x0fa42, 0x1a32d, 0x1cf06, 0x34a7c, 0x34a7d, 0xb6161, 0x35481,
- 0x3e5fa, 0x7cba0, 0x7be7f, 0x7cba3, 0x7cba7, 0x5b0d3, 0x72de6, 0x6a3dc,
- 0x001a9, 0x01ab4, 0x06a34, 0x0d46a, 0x16130, 0x1ef5f, 0x1f532, 0x1f536,
- 0x3942e, 0x58436, 0x6a3db, 0x6945b, 0x001c9, 0x01ca0, 0x0728b, 0x0eed9,
- 0x1f539, 0x1ca1d, 0x39765, 0x39766, 0x58439, 0x6945d, 0x39767, 0x001d3,
- 0x01f2c, 0x07bfc, 0x16161, 0x34652, 0x3a5ed, 0x3548d, 0x58438, 0x6a3da,
- 0x002c1, 0x02c5e, 0x0d335, 0x1ab1a, 0x2d874, 0x35006, 0x35484, 0x5b0cc,
- 0x74b9a, 0x72df3, 0x6a3d6, 0x002da, 0x034b3, 0x0d5ae, 0x1caee, 0x2d871,
- 0x357e3, 0x74b97, 0x72df9, 0x580ba, 0x5b0d4, 0x0034d, 0x0354e, 0x0f750,
- 0x1cbc0, 0x3a5e7, 0x3a5e4, 0x00385, 0x03a58, 0x16c41, 0x2c5cf, 0x3e5e1,
- 0x74b6c, 0xe5677, 0x6a3df, 0x00390, 0x03e50, 0x163c2, 0x2d876, 0x35482,
- 0x5b0d6, 0x5843a, 0x0039f, 0x0585e, 0x1a583, 0x3500f, 0x74b93, 0x39771,
- 0x003e4, 0x06912, 0x16c43, 0x357e1, 0x0058a, 0x0696f, 0x1f538, 0x5b0c9,
- 0x6a3cf, 0x005b6, 0x06af8, 0x1f534, 0x58483, 0x6a3e0, 0x00695, 0x07d02,
- 0x1cae8, 0x58485, 0x006a2, 0x0754a, 0x357ee, 0x3977b, 0x00748, 0x074b2,
- 0x34a7b, 0x00729, 0x0b1e0, 0x34649, 0x3e5e3, 0x0073d, 0x0d2c4, 0x3e5e6,
- 0x007bb, 0x0b099, 0x39762, 0x5b0ce, 0x6945f, 0x007d1, 0x0d5ab, 0x39779,
- 0x007d3, 0x0d52f, 0x39763, 0x6945c, 0x00b1a, 0x0d2c5, 0x35489, 0x00d23,
- 0x0eaed, 0x3e5f8, 0x00d32, 0x16016, 0x3e5fb, 0x00d41, 0x0e768, 0x3a5ed,
- 0x00e1f, 0x16017, 0x58027, 0x00ead, 0x0fa07, 0x69455, 0x00e54, 0x1612b,
- 0x00e55, 0x1a581, 0x00f78, 0x1a32b, 0x580bc, 0x6a3ee, 0x00f79, 0x1abfd,
- 0x00f95, 0x1ab18, 0x6a3f0, 0x01637, 0x1aa4d, 0x0162d, 0x1f53c, 0x6a3f3,
- 0x01a31, 0x1a810, 0x39769, 0x01a50, 0x1caef, 0x01a36, 0x1a32e, 0x01a67,
- 0x1f38e, 0x01a85, 0x1ef59, 0x01aa6, 0x1ef83, 0x01d51, 0x2c012, 0x01d53,
- 0x2d879, 0x01d5e, 0x35005, 0x01cba, 0x1cf04, 0x69453, 0x01d2d, 0x351ff,
- 0x01f2d, 0x2d86f, 0x01f29, 0x35007, 0x02c22, 0x351fa, 0x02c03, 0x3a5ec,
- 0x02c5f, 0x3a5eb, 0x02c58, 0x34a6b, 0x03469, 0x356be, 0x02c59, 0x34a6c,
- 0x0346a, 0x3a5ea, 0x034bd, 0x034bf, 0x356bf, 0x0386a, 0x03ab9, 0x5843f,
- 0x0386b, 0x3a5f5, 0x03a4b, 0x39421, 0x03aa4, 0x3a5e9, 0x03a5a, 0x03960,
- 0x3977e, 0x03de9, 0x03958, 0x03df7, 0x039e1, 0x3e5e4, 0x0395f, 0x69458,
- 0x03e91, 0x03df2, 0x39428, 0x058f2, 0x03e80, 0x6a3c3, 0x03e93, 0x694c0,
- 0x058b8, 0x5b0ca, 0x0584f, 0x694c1, 0x058f1, 0x068d6, 0x06a10, 0x06ac3,
- 0x06a32, 0x070d2, 0x06911, 0x074b1, 0x07494, 0x06ad4, 0x06ad6, 0x072b8,
- 0x06afa, 0x074b3, 0x07540, 0x073ce, 0x0b005, 0x074b3, 0x07495, 0x074b9,
- 0x0d336, 0x07bff, 0x07763, 0x073c8, 0x07d29, 0x0b622, 0x0d221, 0x0d181,
- 0x0b1d1, 0x074b8, 0x0b1d0, 0x0d19b, 0x0d2c3, 0x0b172, 0x0d2dc, 0x0b623,
- 0x0d5aa, 0x0d426, 0x0d182, 0x0e795, 0x0e1d1, 0x0d337, 0x0e96c, 0x0e5e4,
- 0x0e514, 0x0eaee, 0x16000, 0x0e767, 0x0e1a1, 0x0e78f, 0x16004, 0x0f7c2,
- 0x0e799, 0x0e5e7, 0x0e566, 0x0e769, 0x0f751, 0x0eede, 0x0fa06, 0x16005,
- 0x0fa9f, 0x1a5e6, 0x0e766, 0x1636f, 0x0eedd, 0x0eec0, 0x1a309, 0x1ceca,
- 0x163cd, 0x0f9cb, 0x0eedf, 0x1a582, 0x1612d, 0x0e5e5, 0x1abf8, 0x1a30c,
- 0x1ca1f, 0x163cc, 0x1a35c, 0x1ca1e, 0x1aa51, 0x163ac, 0x1a84e, 0x1a53f,
- 0x1cf16, 0x1d2fc, 0x1a5b3, 0x1ab19, 0x1a81f, 0x1d5c3, 0x16c3f, 0x1d5c1,
- 0x1d2fc, 0x1f4aa, 0x1a812, 0x1f535, 0x1cf12, 0x1a817, 0x1617c, 0x1ab0b,
- 0x1d2f8, 0x1ef82, 0x2d87a, 0x1d52f, 0x1f530, 0x1aa48, 0x35487, 0x1d2fd,
- 0x1f4ad, 0x1cf11, 0x3461b, 0x35485, 0x1ca20, 0x1caed, 0x1cae6, 0x1abff,
- 0x3464f, 0x34a6f, 0x1ef81, 0x3464b, 0x39d96, 0x1f383, 0x1f537, 0x1cf14,
- 0x2c5ce, 0x3500e, 0x2c251, 0x1caec, 0x1f387, 0x34654, 0x357e4, 0x2d878,
- 0x3500b, 0x35480, 0x3a5e8, 0x3548e, 0x34b64, 0x1f4a8, 0x35003, 0x3e5df,
- 0x2d870, 0x357e6, 0x3e5f0, 0x1ef5a, 0x3a5ea, 0x1f388, 0x3e703, 0x2c24e,
- 0x3a5e2, 0x351fd, 0x2c6dd, 0x3e704, 0x351fe, 0x2d875, 0x5b0c7, 0x3976a,
- 0x3a5e6, 0x39423, 0x58480, 0x2c246, 0x3a5e3, 0x2d877, 0x3e5f1, 0x3abbe,
- 0x58489, 0x3e5f9, 0x357e0, 0x3abbc, 0x5b0c6, 0x69167, 0x69165, 0x3e5e9,
- 0x39422, 0x3976f, 0x3977d, 0x3e5de, 0x6a3c9, 0x58b98, 0x3a5f6, 0x3a5d0,
- 0x58486, 0x6a3c1, 0x3e5fc, 0x5b0dc, 0x3548f, 0x3942d, 0x694c9, 0x58484,
- 0x3a5e8, 0x74b9b, 0x74b96, 0x694d0, 0x58488, 0x3a5e4, 0x3942a, 0x72ec2,
- 0x39776, 0x5b0d1, 0x5b0cf, 0x3a5d6, 0xe59fc, 0x5b0c8, 0x3e5e7, 0x7cbb7,
- 0x70e87, 0x7cbab, 0x5b0c2, 0x694c3, 0x74a8e, 0x3e5f3, 0x6a3cd, 0x72dfe,
- 0x73b2e, 0x72ec0, 0x694c5, 0x58437, 0x694c8, 0x72dff, 0x39435, 0x5843d,
- 0x6a3d7, 0x72ec1, 0xd22c8, 0x694cf, 0xb6173, 0x3e5fe, 0x580bb, 0xe59f2,
- 0xb616e, 0xb6175, 0x3a5da, 0x5b0bd, 0x694cc, 0x5843c, 0x694c7, 0x74b92,
- 0x72ec3, 0x694c6, 0xb6170, 0x7cbac, 0xb1733, 0x7cba4, 0xb6167, 0x72de7,
- 0x72de4, 0x6a3c0, 0x3e5ef, 0x162e65, 0x72de3, 0x72dfb, 0x6a35f, 0x6a3eb,
-};
-
-static const uint8_t coef2_huffbits[1336] = {
- 11,  9,  2,  3,  4,  4,  5,  6,
-  6,  7,  7,  8,  8,  8,  9,  9,
-  9,  9, 10, 10, 10, 10, 11, 11,
- 11, 11, 11, 11, 11, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 16, 15, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 18, 17, 17, 17, 17,
- 17, 17, 17, 18, 18, 17, 17, 18,
- 17, 17, 18, 17, 18, 18, 18, 18,
- 19, 18, 18, 18, 18, 18, 18, 20,
- 18, 18, 18, 19, 19, 18, 19, 18,
- 19, 19, 18, 19, 19, 18, 19, 19,
- 19, 19, 18, 19, 19, 19, 19, 19,
- 19, 19, 20, 20, 20, 19, 19, 20,
- 19, 20, 19, 19, 20, 19, 19, 20,
- 20, 20, 20, 19, 20, 21, 19,  3,
-  5,  7,  8,  9,  9, 10, 11, 11,
- 12, 12, 12, 13, 13, 13, 13, 14,
- 14, 14, 14, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 16, 16,
- 15, 15, 15, 15, 16, 16, 16, 16,
- 17, 16, 17, 17, 16, 17, 17, 17,
- 17, 17, 17, 16, 17, 17, 17, 17,
- 18, 17, 17, 18, 18, 18, 18, 18,
- 19, 18, 18, 18, 18, 18, 18, 19,
- 19, 18, 18, 18, 18, 19, 18, 19,
- 19, 19, 20, 19, 18, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 20,
- 20, 19, 20, 19, 20, 19, 20, 19,
- 19, 21, 20, 20, 19,  4,  7,  8,
- 10, 11, 11, 12, 12, 13, 13, 14,
- 14, 14, 14, 15, 15, 15, 15, 15,
- 16, 16, 16, 16, 16, 16, 16, 17,
- 17, 17, 17, 17, 17, 17, 16, 16,
- 16, 16, 17, 17, 17, 17, 18, 18,
- 18, 17, 17, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 19, 18, 18, 18,
- 19, 18, 19, 19, 19, 20, 20, 20,
- 19, 19, 19, 19, 19, 19, 19, 21,
- 21, 20, 19,  5,  8, 10, 11, 12,
- 13, 13, 13, 14, 14, 15, 15, 15,
- 15, 16, 16, 16, 16, 16, 17, 17,
- 17, 17, 17, 17, 17, 17, 18, 17,
- 18, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 19, 18, 19, 18,
- 18, 18, 18, 18, 19, 18, 17, 17,
- 18, 18, 19, 19, 19, 19, 18, 18,
- 18, 19,  6,  9, 11, 12, 13, 13,
- 14, 14, 14, 15, 15, 16, 16, 16,
- 16, 16, 16, 17, 17, 17, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 17, 18, 18, 17, 18, 18, 18,
- 18, 18, 18, 19, 19, 18, 18, 18,
- 19, 19, 19, 20, 19, 19, 18, 19,
- 19, 20, 21, 21, 19, 19, 18,  6,
- 10, 12, 13, 14, 14, 14, 15, 15,
- 15, 16, 16, 17, 17, 17, 17, 17,
- 17, 17, 18, 18, 19, 18, 18, 18,
- 19, 18, 18, 18, 19, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18,
- 19, 20, 20, 19, 19, 19, 19, 20,
- 20, 19, 20, 19, 19, 19, 20, 20,
- 20, 19, 19, 18, 19,  7, 10, 12,
- 13, 14, 15, 15, 15, 16, 16, 17,
- 17, 17, 17, 17, 17, 18, 18, 18,
- 18, 19, 18, 19, 19, 19, 20, 19,
- 18, 19, 19, 18, 18, 19, 19, 19,
- 18, 19, 19, 20, 19, 18, 20, 21,
- 20, 20, 19, 19, 21, 20, 21, 20,
- 20, 20, 19, 19, 20, 20, 21, 20,
- 19,  7, 11, 13, 14, 15, 15, 15,
- 16, 16, 17, 17, 17, 17, 18, 18,
- 18, 18, 18, 19, 20, 19, 19, 20,
- 19, 19, 19, 19, 19, 19, 19, 19,
- 18, 18, 19, 20, 19, 19, 19, 20,
- 19, 19, 19, 20, 19, 20, 20, 21,
- 20, 20, 20, 21, 22, 20, 19, 20,
- 20, 21, 20, 21, 20, 19,  8, 11,
- 13, 14, 15, 16, 16, 16, 17, 17,
- 17, 18, 18, 18, 18, 18, 19, 18,
- 19, 19, 19, 19, 21, 19, 19, 21,
- 19, 20, 20, 20, 19, 18, 18,  8,
- 12, 14, 15, 16, 16, 16, 16, 17,
- 17, 17, 19, 18, 18, 19, 19, 20,
- 19, 18, 20, 19, 20, 20, 19, 19,
- 20, 20, 21, 21, 20, 19, 19, 19,
- 19, 19, 19, 20, 21, 20, 19, 19,
-  8, 12, 14, 15, 16, 16, 17, 17,
- 17, 18, 18, 18, 19, 19, 19, 19,
- 19, 19, 20, 21, 20, 21, 19, 21,
- 20, 20, 20, 20, 21, 20, 19, 20,
- 19, 20, 20, 20, 19, 22, 21, 21,
- 19,  9, 12, 14, 15, 16, 17, 17,
- 17, 18, 18, 18, 19, 19, 19, 19,
- 20, 19, 19, 19,  9, 13, 15, 16,
- 17, 17, 18, 18, 18, 19, 18, 20,
- 19, 20, 20, 20, 19,  9, 13, 15,
- 16, 17, 17, 18, 18, 18, 20, 18,
- 19, 20, 20, 20, 20, 19, 20, 19,
-  9, 13, 15, 16, 17, 18, 18, 18,
- 19, 19, 19, 19, 10, 14, 16, 17,
- 18, 18, 19, 19, 19, 19, 19, 10,
- 14, 16, 17, 18, 18, 18, 19, 19,
- 10, 14, 16, 17, 18, 18, 18, 19,
- 19, 20, 19, 10, 14, 16, 18, 18,
- 18, 19, 20, 19, 19, 10, 14, 17,
- 18, 18, 18, 10, 15, 17, 18, 19,
- 19, 21, 19, 11, 15, 17, 18, 18,
- 19, 19, 11, 15, 17, 18, 19, 19,
- 11, 15, 17, 18, 11, 15, 18, 19,
- 19, 11, 15, 18, 19, 19, 11, 16,
- 18, 19, 11, 15, 18, 19, 11, 16,
- 18, 12, 16, 18, 19, 12, 16, 19,
- 12, 16, 19, 19, 19, 12, 16, 19,
- 12, 16, 19, 19, 12, 16, 18, 12,
- 16, 19, 12, 17, 19, 12, 17, 19,
- 12, 17, 19, 12, 17, 19, 13, 17,
- 13, 17, 13, 17, 19, 19, 13, 17,
- 13, 17, 19, 13, 17, 13, 18, 19,
- 13, 17, 19, 13, 18, 13, 17, 13,
- 18, 13, 18, 13, 18, 13, 18, 13,
- 18, 13, 18, 14, 18, 19, 14, 18,
- 14, 18, 14, 18, 14, 18, 14, 19,
- 14, 19, 14, 18, 14, 18, 14, 18,
- 14, 19, 14, 14, 18, 14, 14, 19,
- 14, 18, 14, 19, 14, 19, 14, 15,
- 19, 15, 15, 15, 15, 19, 15, 19,
- 15, 15, 19, 15, 15, 19, 15, 19,
- 15, 19, 15, 19, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 16,
- 15, 15, 15, 16, 16, 16, 15, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 17, 16, 16, 16, 17,
- 17, 16, 17, 17, 16, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 18,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 18, 17, 17, 18, 17, 17, 17, 17,
- 18, 18, 17, 17, 17, 17, 17, 17,
- 17, 18, 17, 18, 18, 17, 17, 17,
- 18, 18, 18, 17, 18, 17, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 17,
- 18, 18, 18, 18, 19, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 19,
- 18, 18, 19, 18, 18, 18, 19, 18,
- 19, 18, 18, 19, 18, 18, 19, 19,
- 19, 19, 19, 18, 19, 18, 19, 18,
- 19, 19, 18, 18, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 18, 19,
- 19, 19, 19, 19, 18, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 20,
- 19, 19, 19, 19, 21, 19, 19, 20,
- 19, 20, 19, 19, 19, 19, 19, 20,
- 20, 20, 19, 19, 19, 20, 19, 19,
- 19, 20, 20, 19, 20, 19, 19, 21,
- 20, 20, 19, 19, 19, 19, 19, 19,
- 20, 19, 20, 20, 20, 20, 20, 20,
- 20, 19, 19, 21, 20, 20, 19, 19,
-};
-
-static const uint32_t coef3_huffcodes[1072] = {
- 0x001b2, 0x00069, 0x00000, 0x00004, 0x00006, 0x0000e, 0x00014, 0x00019,
- 0x00016, 0x0002b, 0x00030, 0x0003d, 0x0003c, 0x0005a, 0x0005f, 0x0006d,
- 0x0007e, 0x0005f, 0x0007f, 0x000b6, 0x000bc, 0x000d8, 0x000f2, 0x000fe,
- 0x000bc, 0x000fc, 0x00161, 0x0016e, 0x00174, 0x00176, 0x001a2, 0x001e3,
- 0x001f3, 0x00174, 0x0017a, 0x001ea, 0x002a8, 0x002c4, 0x002e6, 0x00314,
- 0x00346, 0x00367, 0x003e9, 0x002e5, 0x002ee, 0x003d6, 0x00555, 0x00554,
- 0x00557, 0x005c3, 0x005d6, 0x006e0, 0x0062f, 0x006e2, 0x00799, 0x00789,
- 0x007fa, 0x005ce, 0x007fe, 0x005ec, 0x007cc, 0x007af, 0x00aa7, 0x00b19,
- 0x00b94, 0x00b85, 0x00b9f, 0x00c48, 0x00c45, 0x00dd8, 0x00c4c, 0x00c4b,
- 0x00d99, 0x00d1f, 0x00dc2, 0x00f95, 0x00fa2, 0x00bb5, 0x00b9f, 0x00f5d,
- 0x00bbf, 0x00f47, 0x0154a, 0x00fd5, 0x00f45, 0x00f7f, 0x0160d, 0x01889,
- 0x01757, 0x01722, 0x018b3, 0x0172d, 0x01a39, 0x01a18, 0x01bb3, 0x01b30,
- 0x01e63, 0x0173c, 0x01b35, 0x01723, 0x01e80, 0x01fee, 0x01761, 0x01ffc,
- 0x01f7f, 0x02c7c, 0x01fa1, 0x0177b, 0x01755, 0x0175a, 0x01fa6, 0x02eab,
- 0x0310a, 0x02c69, 0x03669, 0x03127, 0x03103, 0x02e43, 0x03662, 0x03165,
- 0x03124, 0x0313b, 0x03111, 0x03668, 0x0343b, 0x03c52, 0x03efc, 0x02e6c,
- 0x03fda, 0x03ef8, 0x02e7b, 0x03ee2, 0x03cc5, 0x03d72, 0x058c0, 0x03df8,
- 0x02ea9, 0x03e7e, 0x0556d, 0x05c82, 0x03d71, 0x03e7b, 0x03c42, 0x058d7,
- 0x03f4e, 0x06200, 0x03d70, 0x05cb2, 0x05c96, 0x05cb0, 0x03f45, 0x05cb1,
- 0x02e6d, 0x03110, 0x02f68, 0x05c90, 0x07ca6, 0x07c88, 0x06204, 0x062c8,
- 0x078a6, 0x07986, 0x079d5, 0x0b1ad, 0x07989, 0x0b079, 0x05cdd, 0x0aad4,
- 0x05de8, 0x07dcd, 0x07987, 0x05d67, 0x05d99, 0x0b91d, 0x07cf1, 0x05d9b,
- 0x079d7, 0x0b07b, 0x05c85, 0x05d9a, 0x07dcc, 0x07ebf, 0x07dce, 0x07dfb,
- 0x07ec0, 0x07d1a, 0x07a07, 0x05c84, 0x0c471, 0x07cf2, 0x0baef, 0x0b9d2,
- 0x05deb, 0x07bd6, 0x0b845, 0x05d98, 0x0b91a, 0x0bae8, 0x0c4e0, 0x0dc31,
- 0x0f93d, 0x0bbce, 0x0d1d2, 0x0f7a9, 0x0d9b9, 0x0bbcb, 0x0b900, 0x0aad7,
- 0x0babd, 0x0c4e1, 0x0f46f, 0x0c588, 0x0c58b, 0x160e6, 0x0bbcf, 0x0bac3,
- 0x0f945, 0x0f7a3, 0x0d1c1, 0x0fb8e, 0x0f7a4, 0x0fb8c, 0x0f40c, 0x0c473,
- 0x0fd72, 0x0bbcd, 0x0fffa, 0x0f940, 0x0bbc9, 0x0f7a8, 0x1a1ed, 0x0bbc5,
- 0x1f26f, 0x163fd, 0x160c7, 0x1a1f5, 0x0f947, 0x163fc, 0x154b3, 0x0fff6,
- 0x163f6, 0x160e9, 0x1a1f0, 0x0bab9, 0x0baba, 0x17086, 0x0b903, 0x0fd75,
- 0x0f308, 0x176f3, 0x163ff, 0x0fd7d, 0x1bb78, 0x163fb, 0x188db, 0x1a1f7,
- 0x154b2, 0x172fd, 0x163f4, 0x1bb73, 0x172ff, 0x0babc, 0x0f97d, 0x1a1f3,
- 0x1bb6d, 0x1ffd5, 0x1a1f4, 0x1f272, 0x17380, 0x17382, 0x1ffe7, 0x0bac8,
- 0x0bbc4, 0x188d3, 0x160e0, 0x0fd7b, 0x1725f, 0x172f5, 0x1bb79, 0x1fad9,
- 0x1f269, 0x188d0, 0x0bac4, 0x0bac5, 0x31185, 0x188d2, 0x188cc, 0x31187,
- 0x3e7fe, 0x188d1, 0x1bb6c, 0x1f268, 0x1fad2, 0x1ffd9, 0x1a1ea, 0x1bb68,
- 0x1facb, 0x3fdb2, 0x1e81a, 0x188ce, 0x172fb, 0x1a1ef, 0x1face, 0x1bb70,
- 0x0bac1, 0x1bb6b, 0x172f8, 0x1bb66, 0x1ffdf, 0x1bb6a, 0x1ffd7, 0x1f266,
- 0x176f8, 0x37653, 0x1fa7e, 0x31182, 0x1fac8, 0x2c7e3, 0x370ee, 0x176ec,
- 0x176e9, 0x2e4bc, 0x160c5, 0x3765a, 0x3ce9c, 0x17373, 0x176e8, 0x188d4,
- 0x176f1, 0x176ef, 0x37659, 0x1bb7c, 0x1ffde, 0x176f2, 0x3118b, 0x2c7d4,
- 0x37651, 0x5ce9f, 0x37650, 0x31191, 0x3f4f6, 0x3f4f5, 0x7a06c, 0x1fac1,
- 0x5c97b, 0x2c7e0, 0x79d3a, 0x3e7fd, 0x2c7df, 0x3f4f0, 0x7a06d, 0x376c1,
- 0x79d3b, 0x00004, 0x00014, 0x00059, 0x000ab, 0x000b8, 0x00177, 0x001f5,
- 0x001f2, 0x00315, 0x003fc, 0x005bd, 0x0062d, 0x006e8, 0x007dd, 0x00b04,
- 0x007cd, 0x00b1e, 0x00d1e, 0x00f15, 0x00f3b, 0x00f41, 0x01548, 0x018b0,
- 0x0173b, 0x01884, 0x01a1c, 0x01bb4, 0x01f25, 0x017b5, 0x0176d, 0x01ef8,
- 0x02e73, 0x03107, 0x03125, 0x03105, 0x02e49, 0x03ce8, 0x03ef9, 0x03e5e,
- 0x02e72, 0x03471, 0x03fd9, 0x0623f, 0x078a0, 0x06867, 0x05cb3, 0x06272,
- 0x068ec, 0x06e9a, 0x079d4, 0x06e98, 0x0b1aa, 0x06e1a, 0x07985, 0x068ee,
- 0x06e9b, 0x05c88, 0x0b1ac, 0x07dfa, 0x05d65, 0x07cf0, 0x07cbf, 0x0c475,
- 0x160eb, 0x1bb7e, 0x0f7a6, 0x1fedd, 0x160e3, 0x0fffb, 0x0fb8d, 0x0fff9,
- 0x0d1c0, 0x0c58c, 0x1a1e9, 0x0bab8, 0x0f5cf, 0x0fff5, 0x376c5, 0x1a1ec,
- 0x160ed, 0x1fede, 0x1fac9, 0x1a1eb, 0x1f224, 0x176ee, 0x0fd79, 0x17080,
- 0x17387, 0x1bb7a, 0x1ffe9, 0x176f7, 0x17385, 0x17781, 0x2c7d5, 0x17785,
- 0x1ffe3, 0x163f5, 0x1fac2, 0x3e7f9, 0x3118d, 0x3fdb1, 0x1ffe2, 0x1f226,
- 0x3118a, 0x2c7d9, 0x31190, 0x3118c, 0x3f4f3, 0x1bb7f, 0x1bb72, 0x31184,
- 0xb92f4, 0x3e7fb, 0x6e1d9, 0x1faca, 0x62300, 0x3fdb8, 0x3d037, 0x3e7fc,
- 0x62301, 0x3f4f2, 0x1f26a, 0x0000e, 0x00063, 0x000f8, 0x001ee, 0x00377,
- 0x003f7, 0x006e3, 0x005cc, 0x00b05, 0x00dd2, 0x00fd4, 0x0172e, 0x0172a,
- 0x01e23, 0x01f2d, 0x01763, 0x01769, 0x0176c, 0x02e75, 0x03104, 0x02ec1,
- 0x03e58, 0x0583f, 0x03f62, 0x03f44, 0x058c5, 0x0623c, 0x05cf4, 0x07bd7,
- 0x05d9d, 0x0aad2, 0x05d66, 0x0b1a9, 0x0b078, 0x07cfe, 0x0b918, 0x0c46f,
- 0x0b919, 0x0b847, 0x06e1b, 0x0b84b, 0x0aad8, 0x0fd74, 0x172f4, 0x17081,
- 0x0f97c, 0x1f273, 0x0f7a0, 0x0fd7c, 0x172f7, 0x0fd7a, 0x1bb77, 0x172fe,
- 0x1f270, 0x0fd73, 0x1bb7b, 0x1a1bc, 0x1bb7d, 0x0bbc3, 0x172f6, 0x0baeb,
- 0x0fb8f, 0x3f4f4, 0x3fdb4, 0x376c8, 0x3e7fa, 0x1ffd0, 0x62303, 0xb92f5,
- 0x1f261, 0x31189, 0x3fdb5, 0x2c7db, 0x376c9, 0x1fad6, 0x1fad1, 0x00015,
- 0x000f0, 0x002e0, 0x0058e, 0x005d7, 0x00c4d, 0x00fa1, 0x00bdb, 0x01756,
- 0x01f70, 0x02c19, 0x0313c, 0x0370f, 0x03cc0, 0x02ea8, 0x058c6, 0x058c7,
- 0x02eb7, 0x058d0, 0x07d18, 0x0aa58, 0x0b848, 0x05d9e, 0x05d6c, 0x0b84c,
- 0x0c589, 0x0b901, 0x163f8, 0x0bac9, 0x0b9c5, 0x0f93c, 0x188d8, 0x0bbc7,
- 0x160ec, 0x0fd6f, 0x188d9, 0x160ea, 0x0f7a7, 0x0f944, 0x0baab, 0x0dc3a,
- 0x188cf, 0x176fb, 0x2c7d8, 0x2c7d7, 0x1bb75, 0x5ce9e, 0x62302, 0x370ed,
- 0x176f4, 0x1ffd1, 0x370ef, 0x3f4f8, 0x376c7, 0x1ffe1, 0x376c6, 0x176ff,
- 0x6e1d8, 0x176f6, 0x17087, 0x0f5cd, 0x00035, 0x001a0, 0x0058b, 0x00aac,
- 0x00b9a, 0x0175f, 0x01e22, 0x01e8c, 0x01fb2, 0x0310b, 0x058d1, 0x0552e,
- 0x05c27, 0x0686e, 0x07ca7, 0x0c474, 0x0dc33, 0x07bf2, 0x05de9, 0x07a35,
- 0x0baaa, 0x0b9eb, 0x0fb95, 0x0b9b8, 0x17381, 0x1f262, 0x188cd, 0x17088,
- 0x172fa, 0x0f7a2, 0x1fad3, 0x0bac0, 0x3765c, 0x1fedf, 0x1f225, 0x1fad4,
- 0x2c7da, 0x5ce9d, 0x3e7f8, 0x1e203, 0x188d7, 0x00054, 0x002c0, 0x007a1,
- 0x00f78, 0x01b36, 0x01fa3, 0x0313a, 0x03436, 0x0343a, 0x07d1d, 0x07bd8,
- 0x05cdf, 0x0b846, 0x0b189, 0x0d9b8, 0x0fff8, 0x0d9be, 0x0c58a, 0x05dea,
- 0x0d1d3, 0x160e4, 0x1f26b, 0x188da, 0x1e202, 0x2c7d2, 0x163fe, 0x31193,
- 0x17782, 0x376c2, 0x2c7d1, 0x3fdb0, 0x3765d, 0x2c7d0, 0x1fad0, 0x1e201,
- 0x188dd, 0x2c7e2, 0x37657, 0x37655, 0x376c4, 0x376c0, 0x176ea, 0x0006f,
- 0x003cf, 0x00dd5, 0x01f23, 0x02c61, 0x02ed0, 0x05d54, 0x0552d, 0x07883,
- 0x0b1a8, 0x0b91c, 0x0babf, 0x0b902, 0x0f7aa, 0x0f7a5, 0x1a1e8, 0x1ffd6,
- 0x0babe, 0x1a1bf, 0x163f3, 0x1ffd8, 0x1fad7, 0x1f275, 0x1ffdc, 0x0007d,
- 0x005bc, 0x01549, 0x02a99, 0x03def, 0x06273, 0x079d6, 0x07d1b, 0x0aad3,
- 0x0d0fc, 0x2c7dd, 0x188d6, 0x0bac2, 0x2c7e1, 0x1bb76, 0x1a1bd, 0x31186,
- 0x0fd78, 0x1a1be, 0x31183, 0x3fdb6, 0x3f4f1, 0x37652, 0x1fad5, 0x3f4f9,
- 0x3e7ff, 0x5ce9c, 0x3765b, 0x31188, 0x17372, 0x000bd, 0x0078b, 0x01f21,
- 0x03c43, 0x03ded, 0x0aad6, 0x07ec1, 0x0f942, 0x05c86, 0x17089, 0x0babb,
- 0x1ffe8, 0x2c7de, 0x1f26e, 0x1fac4, 0x3f4f7, 0x37656, 0x1fa7d, 0x376c3,
- 0x3fdb3, 0x3118f, 0x1fac6, 0x000f8, 0x007ed, 0x01efd, 0x03e7a, 0x05c91,
- 0x0aad9, 0x0baec, 0x0dc32, 0x0f46e, 0x1e200, 0x176fa, 0x3765e, 0x3fdb7,
- 0x2c7d6, 0x3fdb9, 0x37654, 0x37658, 0x3118e, 0x1ffdb, 0x000f6, 0x00c43,
- 0x03106, 0x068ef, 0x0b84d, 0x0b188, 0x0bbcc, 0x1f264, 0x1bb69, 0x17386,
- 0x1fac0, 0x00171, 0x00f39, 0x03e41, 0x068ed, 0x0d9bc, 0x0f7a1, 0x1bb67,
- 0x1ffdd, 0x176f9, 0x001b9, 0x00f7d, 0x03f63, 0x0d0fd, 0x0b9ea, 0x188dc,
- 0x1fac3, 0x1a1f2, 0x31192, 0x1ffe4, 0x001f6, 0x01754, 0x06865, 0x0f309,
- 0x160e5, 0x176f5, 0x3765f, 0x1facc, 0x001e9, 0x01a1a, 0x06201, 0x0f105,
- 0x176f0, 0x002df, 0x01756, 0x05d6d, 0x163fa, 0x176ed, 0x00342, 0x02e40,
- 0x0d0ff, 0x17082, 0x003cd, 0x02a98, 0x0fffc, 0x2c7dc, 0x1fa7f, 0x003fe,
- 0x03764, 0x0fffd, 0x176fc, 0x1fac5, 0x002f7, 0x02ed1, 0x0fb97, 0x0058a,
- 0x02edc, 0x0bbc8, 0x005d4, 0x0623d, 0x160e8, 0x0062e, 0x05830, 0x163f9,
- 0x006eb, 0x06205, 0x1f274, 0x007de, 0x062c9, 0x1f265, 0x005c9, 0x05cde,
- 0x1ffd3, 0x005d4, 0x07988, 0x007ce, 0x0b849, 0x00b1b, 0x05c89, 0x1fac7,
- 0x00b93, 0x05c83, 0x00b9e, 0x0f14f, 0x00c4a, 0x0b9c7, 0x00dd4, 0x0c470,
- 0x1f271, 0x00f38, 0x0fb96, 0x176eb, 0x00fa0, 0x163f7, 0x00bb2, 0x0b91b,
- 0x00bbe, 0x0f102, 0x00f44, 0x0f946, 0x1facd, 0x00f79, 0x0d9bd, 0x0154d,
- 0x0bbc6, 0x00fd2, 0x160e7, 0x0172b, 0x188cb, 0x0175e, 0x0fd76, 0x0175c,
- 0x1bb71, 0x0189f, 0x1a1ee, 0x01f24, 0x1a1f6, 0x01ba7, 0x0bbca, 0x01f7d,
- 0x0ffff, 0x01f2e, 0x1bb65, 0x01bb5, 0x172f9, 0x01fef, 0x1f26c, 0x01f3e,
- 0x0fd77, 0x01762, 0x1bb6e, 0x01ef9, 0x172fc, 0x01fa0, 0x02ab7, 0x02e4a,
- 0x1f267, 0x01fb3, 0x1ffda, 0x02e42, 0x03101, 0x17780, 0x0313d, 0x03475,
- 0x17784, 0x03126, 0x1facf, 0x03c51, 0x17783, 0x03e40, 0x1ffe5, 0x03663,
- 0x1ffe0, 0x03e8f, 0x1f26d, 0x0343c, 0x03cc1, 0x176fd, 0x03e45, 0x02ec0,
- 0x03f61, 0x03dee, 0x03fd8, 0x0583e, 0x02e45, 0x03e59, 0x03d02, 0x05ce8,
- 0x05568, 0x176fe, 0x02f69, 0x1fad8, 0x058c1, 0x05c83, 0x1ffe6, 0x06271,
- 0x06e1c, 0x062c7, 0x068e1, 0x0552f, 0x06864, 0x06866, 0x06e99, 0x05cbc,
- 0x07ca5, 0x078a1, 0x05c82, 0x07dcf, 0x0623b, 0x0623e, 0x068e8, 0x07a36,
- 0x05d9c, 0x0b077, 0x07cf3, 0x07a34, 0x07ca4, 0x07d19, 0x079d2, 0x07d1c,
- 0x07bd9, 0x0b84a, 0x0fb94, 0x0aad5, 0x0dc30, 0x07bf3, 0x0baee, 0x0b07a,
- 0x0c472, 0x0b91e, 0x0d9ba, 0x05d9f, 0x0d0fe, 0x0b9c6, 0x05c87, 0x0f14e,
- 0x0baed, 0x0b92e, 0x0f103, 0x0b9c4, 0x0fb91, 0x0d9bb, 0x0b1ab, 0x0c58d,
- 0x0fffe, 0x0f93b, 0x0f941, 0x0baea, 0x0b91f, 0x0f5cc, 0x0d9bf, 0x0f943,
- 0x0f104, 0x1f260, 0x0fb92, 0x0f93f, 0x0f3a6, 0x0bac7, 0x0f7ab, 0x0bac6,
- 0x17383, 0x0fd6d, 0x0bae9, 0x0fd6e, 0x1e74f, 0x188ca, 0x1f227, 0x0fb93,
- 0x0fb90, 0x0fff7, 0x17085, 0x17083, 0x160e1, 0x17084, 0x0f93e, 0x160e2,
- 0x160c6, 0x1a1f1, 0x1bb6f, 0x17384, 0x0fd70, 0x1f263, 0x188d5, 0x173a6,
- 0x0f5ce, 0x163f2, 0x0fd71, 0x1ffd2, 0x160c4, 0x1ffd4, 0x2c7d3, 0x1bb74,
-};
-
-static const uint8_t coef3_huffbits[1072] = {
-  9,  7,  2,  3,  4,  4,  5,  5,
-  6,  6,  6,  6,  7,  7,  7,  7,
-  7,  8,  8,  8,  8,  8,  8,  8,
-  9,  9,  9,  9,  9,  9,  9,  9,
-  9, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 12, 11, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 14, 13, 14, 14, 13, 14, 13,
- 13, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 15,
- 14, 14, 15, 14, 14, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 14, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 14, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 16, 15, 16, 16, 16,
- 16, 15, 15, 16, 16, 16, 16, 16,
- 15, 16, 16, 16, 15, 16, 15, 15,
- 16, 15, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 17, 16, 17, 16, 17, 17, 16,
- 17, 16, 17, 16, 16, 17, 17, 17,
- 16, 17, 16, 16, 17, 16, 17, 16,
- 17, 17, 16, 16, 17, 17, 17, 17,
- 17, 17, 17, 17, 16, 17, 17, 16,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 16, 18, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 16, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 18,
- 17, 17, 17, 17, 18, 17, 17, 18,
- 19, 17, 17, 17, 18, 17, 17, 17,
- 18, 18, 18, 17, 17, 17, 18, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 17, 18, 18, 18, 18, 17,
- 18, 18, 18, 17, 17, 18, 18, 18,
- 18, 19, 18, 18, 19, 19, 20, 18,
- 19, 18, 19, 19, 18, 19, 20, 18,
- 19,  4,  6,  7,  8,  9,  9,  9,
- 10, 10, 10, 11, 11, 11, 11, 12,
- 12, 12, 12, 12, 12, 13, 13, 13,
- 13, 13, 13, 13, 13, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 16, 15, 15, 15,
- 15, 16, 16, 15, 16, 16, 15, 16,
- 17, 17, 17, 17, 17, 16, 16, 16,
- 16, 16, 17, 17, 17, 16, 18, 17,
- 17, 17, 18, 17, 17, 18, 17, 17,
- 17, 17, 17, 18, 17, 18, 18, 18,
- 17, 17, 18, 19, 18, 18, 17, 17,
- 18, 18, 18, 18, 19, 17, 17, 18,
- 20, 19, 19, 18, 19, 18, 19, 19,
- 19, 19, 17,  5,  7,  9, 10, 10,
- 11, 11, 12, 12, 12, 13, 13, 13,
- 13, 13, 14, 14, 14, 14, 14, 15,
- 14, 15, 15, 15, 15, 15, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 15, 16, 16, 17, 17, 17,
- 16, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 16,
- 16, 19, 18, 18, 19, 17, 19, 20,
- 17, 18, 18, 18, 18, 18, 18,  6,
-  8, 10, 11, 12, 12, 12, 13, 13,
- 13, 14, 14, 14, 14, 15, 15, 15,
- 15, 15, 15, 16, 16, 16, 16, 16,
- 16, 17, 17, 17, 16, 16, 17, 17,
- 17, 17, 17, 17, 17, 16, 16, 16,
- 17, 18, 18, 18, 17, 19, 19, 18,
- 18, 17, 18, 19, 18, 17, 18, 18,
- 19, 18, 17, 17,  6,  9, 11, 12,
- 13, 13, 13, 14, 14, 14, 15, 15,
- 15, 15, 15, 16, 16, 16, 16, 16,
- 16, 17, 16, 17, 17, 17, 17, 17,
- 17, 17, 18, 17, 18, 17, 17, 18,
- 18, 19, 19, 17, 17,  7, 10, 12,
- 13, 13, 14, 14, 14, 14, 15, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 17, 17, 17, 17, 18, 17, 18,
- 18, 18, 18, 18, 18, 18, 18, 17,
- 17, 18, 18, 18, 18, 18, 18,  7,
- 10, 12, 13, 14, 15, 15, 15, 15,
- 16, 16, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 18, 17, 17,  8,
- 11, 13, 14, 15, 15, 15, 15, 16,
- 16, 18, 17, 17, 18, 17, 17, 18,
- 17, 17, 18, 18, 19, 18, 18, 19,
- 19, 19, 18, 18, 18,  8, 11, 13,
- 14, 15, 16, 16, 16, 16, 17, 17,
- 17, 18, 17, 18, 19, 18, 18, 18,
- 18, 18, 18,  8, 12, 14, 15, 15,
- 16, 16, 16, 17, 17, 18, 18, 18,
- 18, 18, 18, 18, 18, 17,  9, 12,
- 14, 15, 16, 16, 17, 17, 17, 17,
- 18,  9, 12, 14, 15, 16, 17, 17,
- 17, 18,  9, 13, 15, 16, 17, 17,
- 18, 17, 18, 17,  9, 13, 15, 16,
- 17, 18, 18, 18, 10, 13, 15, 16,
- 18, 10, 14, 16, 17, 18, 10, 14,
- 16, 17, 10, 14, 16, 18, 18, 10,
- 14, 16, 18, 18, 11, 15, 16, 11,
- 15, 17, 11, 15, 17, 11, 15, 17,
- 11, 15, 17, 11, 15, 17, 12, 16,
- 17, 12, 15, 12, 16, 12, 16, 18,
- 12, 16, 12, 16, 12, 16, 12, 16,
- 17, 12, 16, 18, 12, 17, 13, 16,
- 13, 16, 13, 16, 18, 13, 16, 13,
- 17, 13, 17, 13, 17, 13, 17, 13,
- 17, 13, 17, 13, 17, 13, 17, 13,
- 16, 13, 17, 13, 17, 13, 17, 14,
- 17, 14, 17, 14, 17, 14, 14, 14,
- 17, 14, 17, 14, 14, 18, 14, 14,
- 18, 14, 18, 14, 18, 14, 17, 14,
- 17, 14, 17, 14, 14, 18, 14, 15,
- 15, 15, 14, 15, 15, 14, 15, 15,
- 15, 18, 15, 18, 15, 15, 17, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 16, 15, 15, 15, 15, 16,
- 16, 16, 16, 16, 15, 15, 15, 15,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 17, 16, 16,
- 16, 17, 16, 16, 16, 17, 17, 17,
- 17, 17, 16, 17, 17, 17, 17, 16,
- 16, 16, 17, 17, 17, 17, 16, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 18, 17,
-};
-
-static const uint32_t coef4_huffcodes[476] = {
- 0x00f01, 0x0001e, 0x00000, 0x00004, 0x00006, 0x0000d, 0x0000a, 0x00017,
- 0x0001d, 0x00017, 0x0002c, 0x00031, 0x00039, 0x0003e, 0x00039, 0x0005a,
- 0x00066, 0x00070, 0x0007b, 0x00070, 0x00077, 0x000af, 0x000c9, 0x000f2,
- 0x000f4, 0x000b2, 0x000e3, 0x0015b, 0x0015d, 0x00181, 0x0019d, 0x001e3,
- 0x001c5, 0x002b5, 0x002db, 0x00338, 0x003c3, 0x003cc, 0x003f0, 0x002cd,
- 0x003fa, 0x003a1, 0x005b4, 0x00657, 0x007ab, 0x0074d, 0x0074c, 0x00ac1,
- 0x00ac5, 0x0076b, 0x00ca8, 0x00f04, 0x00f00, 0x00fe3, 0x00f3c, 0x00f10,
- 0x00f39, 0x00fe6, 0x00e26, 0x00e90, 0x016c5, 0x01827, 0x01954, 0x015c5,
- 0x01958, 0x01f8a, 0x01c4a, 0x02b0f, 0x02b41, 0x02b0e, 0x033c6, 0x03050,
- 0x01c4f, 0x02d88, 0x0305c, 0x03c18, 0x02b4f, 0x02cc2, 0x03a47, 0x05680,
- 0x0569d, 0x06442, 0x06443, 0x06446, 0x0656e, 0x06444, 0x07120, 0x0748a,
- 0x0c1ba, 0x07e22, 0x07aa6, 0x07f25, 0x07aa7, 0x07e20, 0x0c11b, 0x0c118,
- 0x07aa5, 0x0ad0a, 0x0f389, 0x19ebb, 0x0caad, 0x0fe42, 0x0fe40, 0x16c34,
- 0x2b4e5, 0x33d65, 0x16c30, 0x1e7ae, 0x1e25c, 0x18370, 0x1e703, 0x19eba,
- 0x16c37, 0x0e234, 0x16c6e, 0x00004, 0x0002a, 0x00061, 0x00075, 0x000cb,
- 0x000ff, 0x00190, 0x001eb, 0x001d1, 0x002b9, 0x00307, 0x00339, 0x0033f,
- 0x003fb, 0x003b4, 0x0060c, 0x00679, 0x00645, 0x0067d, 0x0078a, 0x007e3,
- 0x00749, 0x00ac4, 0x00ad2, 0x00ae3, 0x00c10, 0x00c16, 0x00ad1, 0x00cf4,
- 0x00fe2, 0x01586, 0x00e9d, 0x019f1, 0x01664, 0x01e26, 0x01d38, 0x02b4d,
- 0x033c5, 0x01fc2, 0x01fc3, 0x01d28, 0x03c1d, 0x0598e, 0x0f094, 0x07aa4,
- 0x0ad38, 0x0ac0c, 0x0c11a, 0x079ea, 0x0c881, 0x0fe44, 0x0b635, 0x0ac0d,
- 0x0b61e, 0x05987, 0x07121, 0x0f382, 0x0f387, 0x0e237, 0x0fe47, 0x0f383,
- 0x0f091, 0x0f385, 0x0e233, 0x182ee, 0x19eb8, 0x1663e, 0x0f093, 0x00014,
- 0x00058, 0x00159, 0x00167, 0x00300, 0x003d4, 0x005b5, 0x0079d, 0x0076a,
- 0x00b67, 0x00b60, 0x00f05, 0x00cf0, 0x00f17, 0x00e95, 0x01822, 0x01913,
- 0x016c2, 0x0182f, 0x01959, 0x01fcb, 0x01e27, 0x01c40, 0x033c7, 0x01e7b,
- 0x01c49, 0x02d89, 0x01e23, 0x01660, 0x03f12, 0x02cc6, 0x033e1, 0x05b34,
- 0x0609a, 0x06569, 0x07488, 0x07e21, 0x0cf5f, 0x0712c, 0x0389d, 0x067cf,
- 0x07f28, 0x1663f, 0x33d67, 0x1663d, 0x1e25d, 0x3c1ab, 0x15c44, 0x16c36,
- 0x0001f, 0x000ec, 0x00323, 0x005b2, 0x0079f, 0x00ac2, 0x00f16, 0x00e9e,
- 0x01956, 0x01e0f, 0x019ea, 0x01666, 0x02b89, 0x02b02, 0x02d8c, 0x03c1b,
- 0x03c19, 0x032b5, 0x03f9c, 0x02ccf, 0x03897, 0x05b35, 0x0ad02, 0x07f29,
- 0x06441, 0x03884, 0x07888, 0x0784e, 0x06568, 0x0c1bb, 0x05986, 0x067cc,
- 0x0fe49, 0x0fe48, 0x0c1bc, 0x0fe41, 0x18371, 0x1663c, 0x0e231, 0x0711e,
- 0x0ad09, 0x0f092, 0x0002d, 0x001db, 0x00781, 0x00c1a, 0x00f55, 0x01580,
- 0x01ea8, 0x02d9b, 0x032af, 0x03f16, 0x03c1c, 0x07834, 0x03c45, 0x0389c,
- 0x067ce, 0x06445, 0x0c1b9, 0x07889, 0x07f3a, 0x0784f, 0x07f2b, 0x0ad0b,
- 0x0f090, 0x0c11d, 0x0e94e, 0x0711f, 0x0e9f1, 0x0f38e, 0x079e9, 0x0ad03,
- 0x0f09b, 0x0caae, 0x0fe46, 0x2b4e6, 0x0e9f0, 0x19eb6, 0x67ac1, 0x67ac0,
- 0x33d66, 0x0f388, 0x00071, 0x003a0, 0x00ca9, 0x01829, 0x01d39, 0x02b43,
- 0x02cc4, 0x06554, 0x0f09a, 0x0b61f, 0x067cd, 0x0711c, 0x0b636, 0x07f2a,
- 0x0b634, 0x0c11f, 0x0cf5e, 0x0b61d, 0x0f06b, 0x0caab, 0x0c1be, 0x0e94c,
- 0x0f099, 0x182ed, 0x0e94f, 0x0c119, 0x0e232, 0x2b4e4, 0x0f38a, 0x19eb4,
- 0x1e25f, 0x0e94d, 0x000b7, 0x00785, 0x016cc, 0x03051, 0x033c4, 0x0656f,
- 0x03891, 0x0711d, 0x0caaf, 0x0f097, 0x07489, 0x0f098, 0x0c880, 0x0caaa,
- 0x0f386, 0x19eb7, 0x16c6f, 0x0f384, 0x182e8, 0x182e9, 0x0e230, 0x1e700,
- 0x33d62, 0x33d63, 0x33d64, 0x16c33, 0x0e216, 0x000fd, 0x00c15, 0x01665,
- 0x03c4a, 0x07f3b, 0x07896, 0x0c11c, 0x0e215, 0x16c32, 0x0f38b, 0x0f38d,
- 0x182ea, 0x1e701, 0x712df, 0x15c46, 0x00194, 0x00fe0, 0x03f13, 0x0748b,
- 0x0f096, 0x0cf80, 0x1e25e, 0xe25bd, 0x33d61, 0x16c31, 0x001f9, 0x01912,
- 0x05710, 0x0f3d0, 0x0c1bf, 0x00301, 0x01e24, 0x0ad08, 0x003cd, 0x01c41,
- 0x0c1bd, 0x00563, 0x03a52, 0x0f3d1, 0x00570, 0x02cce, 0x0e217, 0x0067b,
- 0x0655d, 0x0074b, 0x06447, 0x00c12, 0x074fb, 0x00f08, 0x0b61c, 0x00e22,
- 0x0fe43, 0x016c7, 0x01836, 0x019f2, 0x01c43, 0x01d3f, 0x01fcf, 0x02b4c,
- 0x0304c, 0x032b6, 0x03a46, 0x05607, 0x03f17, 0x02cc5, 0x0609b, 0x0655c,
- 0x07e23, 0x067c1, 0x07f26, 0x07f27, 0x0f095, 0x0e9f3, 0x0cf81, 0x0c11e,
- 0x0caac, 0x0f38f, 0x0e9f2, 0x074fa, 0x0e236, 0x0fe45, 0x1c428, 0x0e235,
- 0x182ef, 0x19eb5, 0x0f3d6, 0x182ec, 0x16c35, 0x0f38c, 0x2b4e7, 0x15c47,
- 0xe25bc, 0x1e702, 0x1c4b6, 0x0e25a, 0x3c1aa, 0x15c45, 0x1c429, 0x19eb9,
- 0x1e7af, 0x182eb, 0x1e0d4, 0x3896e,
-};
-
-static const uint8_t coef4_huffbits[476] = {
- 12,  6,  2,  3,  4,  4,  5,  5,
-  5,  6,  6,  6,  6,  6,  7,  7,
-  7,  7,  7,  8,  8,  8,  8,  8,
-  8,  9,  9,  9,  9,  9,  9,  9,
- 10, 10, 10, 10, 10, 10, 10, 11,
- 10, 11, 11, 11, 11, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 13, 13, 13, 13, 13, 13,
- 13, 13, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 16, 16,
- 16, 15, 15, 15, 15, 15, 16, 16,
- 15, 16, 16, 17, 16, 16, 16, 17,
- 18, 18, 17, 17, 17, 17, 17, 17,
- 17, 17, 17,  4,  6,  7,  8,  8,
-  8,  9,  9, 10, 10, 10, 10, 10,
- 10, 11, 11, 11, 11, 11, 11, 11,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 13, 13, 13, 14, 13, 14, 14,
- 14, 13, 13, 14, 14, 16, 16, 15,
- 16, 16, 16, 15, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 17, 16, 16,
- 16, 16, 17, 17, 17, 18, 16,  5,
-  8,  9, 10, 10, 10, 11, 11, 12,
- 12, 12, 12, 12, 12, 13, 13, 13,
- 13, 13, 13, 13, 13, 14, 14, 13,
- 14, 14, 13, 14, 14, 15, 14, 15,
- 15, 15, 16, 15, 16, 16, 15, 15,
- 15, 18, 18, 18, 17, 18, 17, 17,
-  6,  9, 10, 11, 11, 12, 12, 13,
- 13, 13, 13, 14, 14, 14, 14, 14,
- 14, 14, 14, 15, 15, 15, 16, 15,
- 15, 15, 15, 15, 15, 16, 16, 15,
- 16, 16, 16, 16, 17, 18, 17, 16,
- 16, 16,  7, 10, 11, 12, 12, 13,
- 13, 14, 14, 14, 14, 15, 14, 15,
- 15, 15, 16, 15, 15, 15, 15, 16,
- 16, 16, 17, 16, 17, 16, 15, 16,
- 16, 16, 16, 18, 17, 17, 19, 19,
- 18, 16,  7, 11, 12, 13, 14, 14,
- 15, 15, 16, 16, 15, 16, 16, 15,
- 16, 16, 16, 16, 16, 16, 16, 17,
- 16, 17, 17, 16, 17, 18, 16, 17,
- 17, 17,  8, 11, 13, 14, 14, 15,
- 15, 16, 16, 16, 16, 16, 16, 16,
- 16, 17, 17, 16, 17, 17, 17, 17,
- 18, 18, 18, 17, 17,  8, 12, 14,
- 14, 15, 15, 16, 17, 17, 16, 16,
- 17, 17, 20, 17,  9, 12, 14, 16,
- 16, 16, 17, 21, 18, 17,  9, 13,
- 15, 16, 16, 10, 13, 16, 10, 14,
- 16, 11, 15, 16, 11, 15, 17, 11,
- 15, 12, 15, 12, 16, 12, 16, 13,
- 16, 13, 13, 13, 14, 14, 13, 14,
- 14, 14, 15, 15, 14, 15, 15, 15,
- 15, 15, 15, 15, 16, 17, 16, 16,
- 16, 16, 17, 16, 17, 16, 18, 17,
- 17, 17, 16, 17, 17, 16, 18, 17,
- 21, 17, 18, 17, 18, 17, 18, 17,
- 17, 17, 17, 19,
-};
-
-static const uint32_t coef5_huffcodes[435] = {
- 0x00347, 0x0000b, 0x00001, 0x00001, 0x0000c, 0x00004, 0x00010, 0x00015,
- 0x0001f, 0x0000b, 0x00023, 0x00026, 0x00029, 0x00035, 0x00037, 0x00001,
- 0x00015, 0x0001a, 0x0001d, 0x0001c, 0x0001e, 0x0004e, 0x00049, 0x00051,
- 0x00078, 0x00004, 0x00000, 0x00008, 0x0000d, 0x0007b, 0x00005, 0x00032,
- 0x00095, 0x00091, 0x00096, 0x000a1, 0x000d9, 0x00003, 0x00019, 0x00061,
- 0x00066, 0x00060, 0x00017, 0x0000e, 0x00063, 0x001a0, 0x001b7, 0x001e6,
- 0x001e7, 0x001b6, 0x00018, 0x001e8, 0x00038, 0x00031, 0x00005, 0x0003d,
- 0x00027, 0x001ea, 0x0001a, 0x000c5, 0x000f9, 0x000ff, 0x000db, 0x00250,
- 0x000fc, 0x0025c, 0x00008, 0x00075, 0x003d7, 0x003d3, 0x001b0, 0x0007c,
- 0x003ca, 0x00036, 0x00189, 0x004a6, 0x004a2, 0x004fb, 0x000c0, 0x0007f,
- 0x0009a, 0x00311, 0x0006e, 0x0009b, 0x0068c, 0x006c0, 0x00484, 0x00012,
- 0x000c3, 0x0094f, 0x00979, 0x009f9, 0x00d09, 0x00da6, 0x00da8, 0x00901,
- 0x000c1, 0x00373, 0x00d08, 0x009fa, 0x00d8b, 0x00d85, 0x00d86, 0x000df,
- 0x006e2, 0x000ce, 0x00f24, 0x009fe, 0x001f7, 0x007c1, 0x000cf, 0x009fc,
- 0x009ff, 0x00d89, 0x00da9, 0x009fd, 0x001f8, 0x01a36, 0x0128c, 0x0129d,
- 0x01a37, 0x00196, 0x003ea, 0x00f8b, 0x00d93, 0x01e45, 0x01e58, 0x01e4b,
- 0x01e59, 0x013f1, 0x00309, 0x00265, 0x00308, 0x0243a, 0x027e1, 0x00f89,
- 0x00324, 0x03cbc, 0x03c86, 0x03695, 0x0243c, 0x0243b, 0x0243e, 0x01e4a,
- 0x003a5, 0x03468, 0x03428, 0x03c84, 0x027e0, 0x025e2, 0x01880, 0x00197,
- 0x00325, 0x03cb7, 0x0791e, 0x007ec, 0x06c75, 0x004c8, 0x04bc7, 0x004c6,
- 0x00983, 0x0481e, 0x01b53, 0x0251b, 0x01b58, 0x00984, 0x04fa8, 0x03cbb,
- 0x00f8a, 0x00322, 0x0346a, 0x0243d, 0x00326, 0x03469, 0x0481f, 0x0481d,
- 0x00746, 0x09032, 0x01b50, 0x01d13, 0x0d8e4, 0x0481b, 0x06c74, 0x0796b,
- 0x07969, 0x00985, 0x0d8e3, 0x00986, 0x00fa2, 0x01301, 0x06c7c, 0x00987,
- 0x03cb8, 0x0f4af, 0x00e88, 0x1b1c0, 0x00fce, 0x033eb, 0x03f6a, 0x03f69,
- 0x00fcf, 0x0791f, 0x004c9, 0x04871, 0x00fcd, 0x00982, 0x00fcc, 0x00fa3,
- 0x01d12, 0x0796c, 0x01b47, 0x00321, 0x0796a, 0x0d8e2, 0x04872, 0x04873,
- 0x0000e, 0x00014, 0x0000a, 0x000a0, 0x00012, 0x0007d, 0x001a2, 0x0003b,
- 0x0025f, 0x000dd, 0x0027c, 0x00343, 0x00368, 0x0036b, 0x0003e, 0x001fa,
- 0x00485, 0x001b3, 0x0007f, 0x001b1, 0x0019e, 0x004ba, 0x007ad, 0x00339,
- 0x00066, 0x007a4, 0x00793, 0x006c6, 0x0007e, 0x000f1, 0x00372, 0x009fb,
- 0x00d83, 0x00d8a, 0x00947, 0x009f4, 0x001d0, 0x01b09, 0x01b4b, 0x007ec,
- 0x003e1, 0x000ca, 0x003ec, 0x02539, 0x04fa9, 0x01b57, 0x03429, 0x03d2a,
- 0x00d97, 0x003a7, 0x00dc0, 0x00d96, 0x00dc1, 0x007eb, 0x03cba, 0x00c43,
- 0x00c41, 0x01b52, 0x007ef, 0x00323, 0x03cb9, 0x03c83, 0x007d0, 0x007ed,
- 0x06c7f, 0x09033, 0x03f6c, 0x36383, 0x1e95d, 0x06c78, 0x00747, 0x01b51,
- 0x00022, 0x00016, 0x00039, 0x00252, 0x00079, 0x00486, 0x00338, 0x00369,
- 0x00d88, 0x00026, 0x00d87, 0x00f4b, 0x00d82, 0x00027, 0x001e1, 0x01a15,
- 0x007c7, 0x012f0, 0x001e0, 0x006d0, 0x01a16, 0x01e44, 0x01e5f, 0x03690,
- 0x00d90, 0x00c42, 0x00daf, 0x00d92, 0x00f80, 0x00cfb, 0x0342f, 0x0487f,
- 0x01b46, 0x07968, 0x00d95, 0x00d91, 0x01b55, 0x03f68, 0x04bc6, 0x03cbd,
- 0x00f81, 0x00320, 0x00069, 0x000fe, 0x006d5, 0x0033f, 0x000de, 0x007c6,
- 0x01e40, 0x00d94, 0x00f88, 0x03c8e, 0x03694, 0x00dae, 0x00dad, 0x00267,
- 0x003a6, 0x00327, 0x0487e, 0x007ee, 0x00749, 0x004c7, 0x03692, 0x01b56,
- 0x00fd1, 0x07a56, 0x06c77, 0x09031, 0x00748, 0x06c7a, 0x0796d, 0x033ea,
- 0x06c76, 0x00fd0, 0x36382, 0x1e417, 0x00745, 0x04faf, 0x0d8e1, 0x03f6b,
- 0x1e95c, 0x04fad, 0x0009e, 0x004bd, 0x0067c, 0x01b08, 0x003eb, 0x01b45,
- 0x03691, 0x0d8e5, 0x07904, 0x00981, 0x007ea, 0x019f4, 0x06c7d, 0x04fab,
- 0x04fac, 0x06c7e, 0x01300, 0x06c7b, 0x0006f, 0x003f7, 0x03c85, 0x004c4,
- 0x0001e, 0x006e1, 0x03693, 0x01b44, 0x00241, 0x01e46, 0x0019d, 0x00266,
- 0x004bb, 0x02538, 0x007ac, 0x01b54, 0x00902, 0x04870, 0x00da7, 0x00900,
- 0x00185, 0x06c79, 0x006e3, 0x003e9, 0x01e94, 0x003ed, 0x003f2, 0x0342e,
- 0x0346b, 0x0251a, 0x004c5, 0x01881, 0x0481c, 0x01b59, 0x03c87, 0x04fae,
- 0x007e9, 0x03f6d, 0x0f20a, 0x09030, 0x04faa, 0x0d8e6, 0x03f6f, 0x0481a,
- 0x03f6e, 0x1e416, 0x0d8e7,
-};
-
-static const uint8_t coef5_huffbits[435] = {
- 10,  4,  2,  4,  4,  5,  5,  5,
-  5,  6,  6,  6,  6,  6,  6,  7,
-  7,  7,  7,  7,  7,  7,  7,  7,
-  7,  8,  8,  8,  8,  7,  8,  8,
-  8,  8,  8,  8,  8,  9,  9,  9,
-  9,  9,  9,  9,  9,  9,  9,  9,
-  9,  9, 10,  9, 10, 10, 10, 10,
- 10,  9, 10, 10, 10, 10, 10, 10,
- 10, 10, 11, 11, 10, 10, 11, 11,
- 10, 11, 11, 11, 11, 11, 12, 12,
- 12, 12, 12, 12, 11, 11, 11, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 13,
- 13, 13, 12, 12, 13, 13, 13, 12,
- 12, 12, 12, 12, 13, 13, 13, 13,
- 13, 14, 14, 14, 14, 13, 13, 13,
- 13, 13, 14, 14, 14, 14, 14, 14,
- 15, 14, 14, 14, 14, 14, 14, 13,
- 14, 14, 14, 14, 14, 14, 15, 14,
- 15, 14, 15, 15, 15, 15, 15, 15,
- 16, 15, 15, 14, 15, 16, 15, 14,
- 14, 15, 14, 14, 15, 14, 15, 15,
- 15, 16, 15, 17, 16, 15, 15, 15,
- 15, 16, 16, 16, 16, 17, 15, 16,
- 14, 16, 16, 17, 16, 16, 16, 16,
- 16, 15, 15, 15, 16, 16, 16, 16,
- 17, 15, 15, 15, 15, 16, 15, 15,
-  4,  7,  8,  8,  9,  9,  9, 10,
- 10, 10, 10, 10, 10, 10, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 12,
- 12, 11, 11, 11, 12, 12, 12, 12,
- 12, 12, 12, 12, 13, 13, 13, 13,
- 12, 13, 14, 14, 15, 15, 14, 14,
- 14, 14, 14, 14, 14, 15, 14, 14,
- 14, 15, 15, 15, 14, 14, 15, 15,
- 15, 16, 16, 18, 17, 15, 15, 15,
-  6,  9, 10, 10, 11, 11, 12, 12,
- 12, 13, 12, 12, 12, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 14,
- 14, 14, 14, 14, 14, 14, 14, 15,
- 15, 15, 14, 14, 15, 16, 15, 14,
- 14, 15,  7, 10, 11, 12, 13, 13,
- 13, 14, 14, 14, 14, 14, 14, 14,
- 14, 15, 15, 15, 15, 15, 14, 15,
- 16, 15, 15, 16, 15, 15, 15, 16,
- 15, 16, 18, 17, 15, 15, 16, 16,
- 17, 15,  8, 11, 13, 13, 14, 15,
- 14, 16, 15, 16, 15, 15, 15, 15,
- 15, 15, 17, 15,  9, 12, 14, 15,
- 10, 13, 14, 15, 10, 13, 11, 14,
- 11, 14, 11, 15, 12, 15, 12, 12,
- 13, 15, 13, 14, 13, 14, 14, 14,
- 14, 14, 15, 15, 15, 15, 14, 15,
- 15, 16, 16, 16, 15, 16, 16, 15,
- 16, 17, 16,
-};
-
-static const uint16_t levels0[60] = {
-317, 92, 62, 60, 19, 17, 10,  7,
-  6,  5,  5,  3,  3,  3,  2,  2,
-  2,  2,  2,  2,  2,  1,  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,
-  1,  1,  1,  1,
-};
-
-static const uint16_t levels1[40] = {
-311, 91, 61, 28, 10,  6,  5,  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,
-};
-
-static const uint16_t levels2[340] = {
-181,110, 78, 63, 61, 62, 60, 61,
- 33, 41, 41, 19, 17, 19, 12, 11,
-  9, 11, 10,  6,  8,  7,  6,  4,
-  5,  5,  4,  4,  3,  4,  3,  5,
-  3,  4,  3,  3,  3,  3,  3,  3,
-  2,  2,  4,  2,  3,  2,  3,  3,
-  2,  2,  2,  2,  2,  2,  2,  2,
-  3,  2,  2,  2,  2,  2,  2,  2,
-  2,  2,  2,  1,  2,  1,  2,  2,
-  2,  2,  1,  2,  1,  1,  1,  2,
-  2,  1,  2,  1,  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,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  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 levels3[180] = {
-351,122, 76, 61, 41, 42, 24, 30,
- 22, 19, 11,  9, 10,  8,  5,  5,
-  4,  5,  5,  3,  3,  3,  3,  3,
-  3,  3,  2,  2,  3,  2,  2,  2,
-  3,  3,  2,  2,  2,  3,  2,  2,
-  2,  2,  2,  2,  2,  2,  2,  2,
-  2,  2,  2,  2,  2,  2,  1,  1,
-  2,  2,  1,  2,  1,  2,  2,  2,
-  2,  2,  2,  1,  2,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  2,
-  2,  1,  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,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  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 levels4[70] = {
-113, 68, 49, 42, 40, 32, 27, 15,
- 10,  5,  3,  3,  3,  3,  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,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,  1,  1,
-  1,  1,  1,  1,  1,  1,
-};
-
-static const uint16_t levels5[40] = {
-214, 72, 42, 40, 18,  4,  4,  2,
-  2,  2,  2,  2,  1,  1,  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,
-};
-    
-static const CoefVLCTable coef_vlcs[6] = {
-    { 
-        sizeof(coef0_huffbits), coef0_huffcodes, coef0_huffbits, levels0,
-    },
-    { 
-        sizeof(coef1_huffbits), coef1_huffcodes, coef1_huffbits, levels1,
-    },
-    { 
-        sizeof(coef2_huffbits), coef2_huffcodes, coef2_huffbits, levels2,
-    },
-    { 
-        sizeof(coef3_huffbits), coef3_huffcodes, coef3_huffbits, levels3,
-    },
-    { 
-        sizeof(coef4_huffbits), coef4_huffcodes, coef4_huffbits, levels4,
-    },
-    { 
-        sizeof(coef5_huffbits), coef5_huffcodes, coef5_huffbits, levels5,
-    },
-};
diff --git a/ffmpeg.src/libavcodec/wmv2.c b/ffmpeg.src/libavcodec/wmv2.c
deleted file mode 100644
index 75e924c..0000000
--- a/ffmpeg.src/libavcodec/wmv2.c
+++ /dev/null
@@ -1,855 +0,0 @@
-/*
- * Copyright (c) 2002 The FFmpeg Project.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-/**
- * @file wmv2.c
- * wmv2 codec.
- */
- 
-#include "simple_idct.h"
- 
-#define SKIP_TYPE_NONE 0
-#define SKIP_TYPE_MPEG 1
-#define SKIP_TYPE_ROW  2
-#define SKIP_TYPE_COL  3
-
-
-typedef struct Wmv2Context{
-    MpegEncContext s;
-    int j_type_bit;
-    int j_type;
-    int flag3;
-    int flag63;
-    int abt_flag;
-    int abt_type;
-    int abt_type_table[6];
-    int per_mb_abt;
-    int per_block_abt;
-    int mspel_bit;
-    int cbp_table_index;
-    int top_left_mv_flag;
-    int per_mb_rl_bit;
-    int skip_type;
-    int hshift;
-    
-    ScanTable abt_scantable[2];
-    DCTELEM abt_block2[6][64] __align8;
-}Wmv2Context;
-
-static void wmv2_common_init(Wmv2Context * w){
-    MpegEncContext * const s= &w->s;
-        
-    ff_init_scantable(s->dsp.idct_permutation, &w->abt_scantable[0], wmv2_scantableA);
-    ff_init_scantable(s->dsp.idct_permutation, &w->abt_scantable[1], wmv2_scantableB);
-}
-
-#ifdef CONFIG_ENCODERS
-
-static int encode_ext_header(Wmv2Context *w){
-    MpegEncContext * const s= &w->s;
-    PutBitContext pb;
-    int code;
-        
-    init_put_bits(&pb, s->avctx->extradata, s->avctx->extradata_size);
-
-    put_bits(&pb, 5, s->avctx->time_base.den / s->avctx->time_base.num); //yes 29.97 -> 29
-    put_bits(&pb, 11, FFMIN(s->bit_rate/1024, 2047));
-    
-    put_bits(&pb, 1, w->mspel_bit=1);
-    put_bits(&pb, 1, w->flag3=1);
-    put_bits(&pb, 1, w->abt_flag=1);
-    put_bits(&pb, 1, w->j_type_bit=1);
-    put_bits(&pb, 1, w->top_left_mv_flag=0);
-    put_bits(&pb, 1, w->per_mb_rl_bit=1);
-    put_bits(&pb, 3, code=1);
-    
-    flush_put_bits(&pb);
-
-    s->slice_height = s->mb_height / code;
-    
-    return 0;
-}
-
-static int wmv2_encode_init(AVCodecContext *avctx){
-    Wmv2Context * const w= avctx->priv_data;
-    
-    if(MPV_encode_init(avctx) < 0)
-        return -1;
-    
-    wmv2_common_init(w);
-
-    avctx->extradata_size= 4;
-    avctx->extradata= av_mallocz(avctx->extradata_size + 10);
-    encode_ext_header(w);
-    
-    return 0;
-}
-
-#if 0 /* unused, remove? */
-static int wmv2_encode_end(AVCodecContext *avctx){
-    
-    if(MPV_encode_end(avctx) < 0)
-        return -1;
-    
-    avctx->extradata_size= 0;
-    av_freep(&avctx->extradata);
-    
-    return 0;
-}
-#endif
-
-int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number)
-{
-    Wmv2Context * const w= (Wmv2Context*)s;
-
-    put_bits(&s->pb, 1, s->pict_type - 1);
-    if(s->pict_type == I_TYPE){
-        put_bits(&s->pb, 7, 0);
-    }
-    put_bits(&s->pb, 5, s->qscale);
-
-    s->dc_table_index = 1;
-    s->mv_table_index = 1; /* only if P frame */
-//    s->use_skip_mb_code = 1; /* only if P frame */
-    s->per_mb_rl_table = 0;
-    s->mspel= 0;
-    w->per_mb_abt=0;
-    w->abt_type=0;
-    w->j_type=0;
-
-    assert(s->flipflop_rounding);
-
-    if (s->pict_type == I_TYPE) {
-        assert(s->no_rounding==1);
-        if(w->j_type_bit) put_bits(&s->pb, 1, w->j_type);
-        
-        if(w->per_mb_rl_bit) put_bits(&s->pb, 1, s->per_mb_rl_table);
-        
-        if(!s->per_mb_rl_table){
-            code012(&s->pb, s->rl_chroma_table_index);
-            code012(&s->pb, s->rl_table_index);
-        }
-
-        put_bits(&s->pb, 1, s->dc_table_index);
-
-        s->inter_intra_pred= 0;
-    }else{
-        int cbp_index;
-
-        put_bits(&s->pb, 2, SKIP_TYPE_NONE);
-        
-        code012(&s->pb, cbp_index=0);
-        if(s->qscale <= 10){
-            int map[3]= {0,2,1};
-            w->cbp_table_index= map[cbp_index];
-        }else if(s->qscale <= 20){
-            int map[3]= {1,0,2};
-            w->cbp_table_index= map[cbp_index];
-        }else{
-            int map[3]= {2,1,0};
-            w->cbp_table_index= map[cbp_index];
-        }
-
-        if(w->mspel_bit) put_bits(&s->pb, 1, s->mspel);
-    
-        if(w->abt_flag){
-            put_bits(&s->pb, 1, w->per_mb_abt^1);
-            if(!w->per_mb_abt){
-                code012(&s->pb, w->abt_type);
-            }
-        }
-
-        if(w->per_mb_rl_bit) put_bits(&s->pb, 1, s->per_mb_rl_table);
-        
-        if(!s->per_mb_rl_table){
-            code012(&s->pb, s->rl_table_index);
-            s->rl_chroma_table_index = s->rl_table_index;
-        }
-        put_bits(&s->pb, 1, s->dc_table_index);
-        put_bits(&s->pb, 1, s->mv_table_index);
-    
-        s->inter_intra_pred= 0;//(s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
-    }
-    s->esc3_level_length= 0;
-    s->esc3_run_length= 0;
-
-    return 0;
-}
-
-// nearly idential to wmv1 but thats just because we dont use the useless M$ crap features
-// its duplicated here in case someone wants to add support for these carp features
-void ff_wmv2_encode_mb(MpegEncContext * s, 
-                       DCTELEM block[6][64],
-                       int motion_x, int motion_y)
-{
-    Wmv2Context * const w= (Wmv2Context*)s;
-    int cbp, coded_cbp, i;
-    int pred_x, pred_y;
-    uint8_t *coded_block;
-
-    handle_slices(s);
-    
-    if (!s->mb_intra) {
-	/* compute cbp */
-        set_stat(ST_INTER_MB);
-	cbp = 0;
-	for (i = 0; i < 6; i++) {
-	    if (s->block_last_index[i] >= 0)
-		cbp |= 1 << (5 - i);
-	}
-        
-        put_bits(&s->pb, 
-                 wmv2_inter_table[w->cbp_table_index][cbp + 64][1], 
-                 wmv2_inter_table[w->cbp_table_index][cbp + 64][0]);
-
-        /* motion vector */
-        h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
-        msmpeg4_encode_motion(s, motion_x - pred_x, 
-                              motion_y - pred_y);
-    } else {
-	/* compute cbp */
-	cbp = 0;
-        coded_cbp = 0;
-	for (i = 0; i < 6; i++) {
-            int val, pred;
-            val = (s->block_last_index[i] >= 1);
-            cbp |= val << (5 - i);
-            if (i < 4) {
-                /* predict value for close blocks only for luma */
-                pred = coded_block_pred(s, i, &coded_block);
-                *coded_block = val;
-                val = val ^ pred;
-            }
-            coded_cbp |= val << (5 - i);
-	}
-#if 0
-        if (coded_cbp)
-            printf("cbp=%x %x\n", cbp, coded_cbp);
-#endif
-
-        if (s->pict_type == I_TYPE) {
-            set_stat(ST_INTRA_MB);
-            put_bits(&s->pb, 
-                     ff_msmp4_mb_i_table[coded_cbp][1], ff_msmp4_mb_i_table[coded_cbp][0]);
-        } else {
-            put_bits(&s->pb, 
-                     wmv2_inter_table[w->cbp_table_index][cbp][1], 
-                     wmv2_inter_table[w->cbp_table_index][cbp][0]);
-        }
-        set_stat(ST_INTRA_MB);
-        put_bits(&s->pb, 1, 0);	/* no AC prediction yet */
-        if(s->inter_intra_pred){
-            s->h263_aic_dir=0;
-            put_bits(&s->pb, table_inter_intra[s->h263_aic_dir][1], table_inter_intra[s->h263_aic_dir][0]);
-        }
-    }
-
-    for (i = 0; i < 6; i++) {
-        msmpeg4_encode_block(s, block[i], i);
-    }
-}
-#endif //CONFIG_ENCODERS
-
-static void parse_mb_skip(Wmv2Context * w){
-    int mb_x, mb_y;
-    MpegEncContext * const s= &w->s;
-    uint32_t * const mb_type= s->current_picture_ptr->mb_type;
-
-    w->skip_type= get_bits(&s->gb, 2);
-    switch(w->skip_type){
-    case SKIP_TYPE_NONE:
-        for(mb_y=0; mb_y<s->mb_height; mb_y++){
-            for(mb_x=0; mb_x<s->mb_width; mb_x++){
-                mb_type[mb_y*s->mb_stride + mb_x]= MB_TYPE_16x16 | MB_TYPE_L0;
-            }
-        }
-        break;
-    case SKIP_TYPE_MPEG:
-        for(mb_y=0; mb_y<s->mb_height; mb_y++){
-            for(mb_x=0; mb_x<s->mb_width; mb_x++){
-                mb_type[mb_y*s->mb_stride + mb_x]= (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
-            }
-        }
-        break;
-    case SKIP_TYPE_ROW:
-        for(mb_y=0; mb_y<s->mb_height; mb_y++){
-            if(get_bits1(&s->gb)){
-                for(mb_x=0; mb_x<s->mb_width; mb_x++){
-                    mb_type[mb_y*s->mb_stride + mb_x]=  MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
-                }
-            }else{
-                for(mb_x=0; mb_x<s->mb_width; mb_x++){
-                    mb_type[mb_y*s->mb_stride + mb_x]= (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
-                }
-            }
-        }
-        break;
-    case SKIP_TYPE_COL:
-        for(mb_x=0; mb_x<s->mb_width; mb_x++){
-            if(get_bits1(&s->gb)){
-                for(mb_y=0; mb_y<s->mb_height; mb_y++){
-                    mb_type[mb_y*s->mb_stride + mb_x]=  MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
-                }
-            }else{
-                for(mb_y=0; mb_y<s->mb_height; mb_y++){
-                    mb_type[mb_y*s->mb_stride + mb_x]= (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
-                }
-            }
-        }
-        break;
-    }
-}
-
-static int decode_ext_header(Wmv2Context *w){
-    MpegEncContext * const s= &w->s;
-    GetBitContext gb;
-    int fps;
-    int code;
-
-    if(s->avctx->extradata_size<4) return -1;
-    
-    init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);
-
-    fps                = get_bits(&gb, 5);
-    s->bit_rate        = get_bits(&gb, 11)*1024;
-    w->mspel_bit       = get_bits1(&gb);
-    w->flag3           = get_bits1(&gb);
-    w->abt_flag        = get_bits1(&gb);
-    w->j_type_bit      = get_bits1(&gb);
-    w->top_left_mv_flag= get_bits1(&gb);
-    w->per_mb_rl_bit   = get_bits1(&gb);
-    code               = get_bits(&gb, 3);
-    
-    if(code==0) return -1;
-
-    s->slice_height = s->mb_height / code;
-
-    if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-        av_log(s->avctx, AV_LOG_DEBUG, "fps:%d, br:%d, qpbit:%d, abt_flag:%d, j_type_bit:%d, tl_mv_flag:%d, mbrl_bit:%d, code:%d, flag3:%d, slices:%d\n", 
-        fps, s->bit_rate, w->mspel_bit, w->abt_flag, w->j_type_bit, w->top_left_mv_flag, w->per_mb_rl_bit, code, w->flag3, 
-        code);
-    }
-    return 0;
-}
-
-int ff_wmv2_decode_picture_header(MpegEncContext * s)
-{
-    Wmv2Context * const w= (Wmv2Context*)s;
-    int code;
-
-#if 0
-{
-int i;
-for(i=0; i<s->gb.size*8; i++)
-    printf("%d", get_bits1(&s->gb));
-//    get_bits1(&s->gb);
-printf("END\n");
-return -1;
-}
-#endif
-    if(s->picture_number==0)
-        decode_ext_header(w);
-
-    s->pict_type = get_bits(&s->gb, 1) + 1;
-    if(s->pict_type == I_TYPE){
-        code = get_bits(&s->gb, 7);
-        av_log(s->avctx, AV_LOG_DEBUG, "I7:%X/\n", code);
-    }
-    s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
-    if(s->qscale < 0)
-       return -1;
-       
-    return 0;
-}
-
-int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s)
-{
-    Wmv2Context * const w= (Wmv2Context*)s;
-
-    if (s->pict_type == I_TYPE) {
-        if(w->j_type_bit) w->j_type= get_bits1(&s->gb);
-        else              w->j_type= 0; //FIXME check
-        
-        if(!w->j_type){
-            if(w->per_mb_rl_bit) s->per_mb_rl_table= get_bits1(&s->gb);
-            else                 s->per_mb_rl_table= 0;
-        
-            if(!s->per_mb_rl_table){
-                s->rl_chroma_table_index = decode012(&s->gb);
-                s->rl_table_index = decode012(&s->gb);
-            }
-
-            s->dc_table_index = get_bits1(&s->gb);
-        }
-        s->inter_intra_pred= 0;
-        s->no_rounding = 1;
-        if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-	    av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n", 
-		s->qscale,
-		s->rl_chroma_table_index,
-		s->rl_table_index, 
-		s->dc_table_index,
-                s->per_mb_rl_table,
-                w->j_type);
-        }
-    }else{
-        int cbp_index;
-        w->j_type=0;
-
-        parse_mb_skip(w);
-        cbp_index= decode012(&s->gb);
-        if(s->qscale <= 10){
-            int map[3]= {0,2,1};
-            w->cbp_table_index= map[cbp_index];
-        }else if(s->qscale <= 20){
-            int map[3]= {1,0,2};
-            w->cbp_table_index= map[cbp_index];
-        }else{
-            int map[3]= {2,1,0};
-            w->cbp_table_index= map[cbp_index];
-        }
-
-        if(w->mspel_bit) s->mspel= get_bits1(&s->gb);
-        else             s->mspel= 0; //FIXME check
-    
-        if(w->abt_flag){
-            w->per_mb_abt= get_bits1(&s->gb)^1;
-            if(!w->per_mb_abt){
-                w->abt_type= decode012(&s->gb);
-            }
-        }
-
-        if(w->per_mb_rl_bit) s->per_mb_rl_table= get_bits1(&s->gb);
-        else                 s->per_mb_rl_table= 0;
-        
-        if(!s->per_mb_rl_table){
-            s->rl_table_index = decode012(&s->gb);
-            s->rl_chroma_table_index = s->rl_table_index;
-        }
-
-        s->dc_table_index = get_bits1(&s->gb);
-        s->mv_table_index = get_bits1(&s->gb);
-    
-        s->inter_intra_pred= 0;//(s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
-        s->no_rounding ^= 1;
-        
-        if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-            av_log(s->avctx, AV_LOG_DEBUG, "rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n", 
-		s->rl_table_index, 
-		s->rl_chroma_table_index, 
-		s->dc_table_index,
-		s->mv_table_index,
-                s->per_mb_rl_table,
-                s->qscale,
-                s->mspel,
-                w->per_mb_abt,
-                w->abt_type,
-                w->cbp_table_index,
-                s->inter_intra_pred);
-        }
-    }
-    s->esc3_level_length= 0;
-    s->esc3_run_length= 0;
-    
-s->picture_number++; //FIXME ?
-
-
-//    if(w->j_type)
-//        return wmv2_decode_j_picture(w); //FIXME
-
-    if(w->j_type){
-        av_log(s->avctx, AV_LOG_ERROR, "J-type picture is not supported\n");
-        return -1;
-    }
-
-    return 0;
-}
-
-static inline int wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr){
-    MpegEncContext * const s= &w->s;
-    int ret;
-   
-    ret= msmpeg4_decode_motion(s, mx_ptr, my_ptr);
-   
-    if(ret<0) return -1;
-   
-    if((((*mx_ptr)|(*my_ptr)) & 1) && s->mspel)
-        w->hshift= get_bits1(&s->gb);
-    else 
-        w->hshift= 0;
-
-//printf("%d %d  ", *mx_ptr, *my_ptr);
-   
-    return 0;
-}
-
-static int16_t *wmv2_pred_motion(Wmv2Context *w, int *px, int *py){
-    MpegEncContext * const s= &w->s;
-    int xy, wrap, diff, type;
-    int16_t *A, *B, *C, *mot_val;
-
-    wrap = s->b8_stride;
-    xy = s->block_index[0];
-
-    mot_val = s->current_picture.motion_val[0][xy];
-
-    A = s->current_picture.motion_val[0][xy - 1];
-    B = s->current_picture.motion_val[0][xy - wrap];
-    C = s->current_picture.motion_val[0][xy + 2 - wrap];
-    
-    if(s->mb_x && !s->first_slice_line && !s->mspel && w->top_left_mv_flag)
-        diff= FFMAX(ABS(A[0] - B[0]), ABS(A[1] - B[1]));
-    else 
-        diff=0;
-    
-    if(diff >= 8)
-        type= get_bits1(&s->gb);
-    else
-        type= 2;
-    
-    if(type == 0){
-        *px= A[0];
-        *py= A[1];
-    }else if(type == 1){
-        *px= B[0];
-        *py= B[1];
-    }else{
-        /* special case for first (slice) line */
-        if (s->first_slice_line) {
-            *px = A[0];
-            *py = A[1];
-        } else {
-            *px = mid_pred(A[0], B[0], C[0]);
-            *py = mid_pred(A[1], B[1], C[1]);
-        }
-    }
-
-    return mot_val;
-}
-
-static inline int wmv2_decode_inter_block(Wmv2Context *w, DCTELEM *block, int n, int cbp){
-    MpegEncContext * const s= &w->s;
-    static const int sub_cbp_table[3]= {2,3,1};
-    int sub_cbp;
-
-    if(!cbp){ 
-        s->block_last_index[n] = -1;
-
-        return 0;
-    }
-    
-    if(w->per_block_abt)
-        w->abt_type= decode012(&s->gb);
-#if 0
-    if(w->per_block_abt)
-        printf("B%d", w->abt_type);
-#endif
-    w->abt_type_table[n]= w->abt_type;
-
-    if(w->abt_type){
-//        const uint8_t *scantable= w->abt_scantable[w->abt_type-1].permutated;
-        const uint8_t *scantable= w->abt_scantable[w->abt_type-1].scantable;
-//        const uint8_t *scantable= w->abt_type-1 ? w->abt_scantable[1].permutated : w->abt_scantable[0].scantable;
-
-        sub_cbp= sub_cbp_table[ decode012(&s->gb) ];
-//        printf("S%d", sub_cbp);
-
-        if(sub_cbp&1){
-            if (msmpeg4_decode_block(s, block, n, 1, scantable) < 0)
-                return -1;
-        }
-        
-        if(sub_cbp&2){
-            if (msmpeg4_decode_block(s, w->abt_block2[n], n, 1, scantable) < 0)
-                return -1;
-        }
-        s->block_last_index[n] = 63;
-
-        return 0;
-    }else{
-        return msmpeg4_decode_block(s, block, n, 1, s->inter_scantable.permutated);
-    }
-}
-
-static void wmv2_add_block(Wmv2Context *w, DCTELEM *block1, uint8_t *dst, int stride, int n){
-    MpegEncContext * const s= &w->s;
-
-  if (s->block_last_index[n] >= 0) {
-    switch(w->abt_type_table[n]){
-    case 0:
-        s->dsp.idct_add (dst, stride, block1);
-        break;
-    case 1:
-        simple_idct84_add(dst           , stride, block1);
-        simple_idct84_add(dst + 4*stride, stride, w->abt_block2[n]);
-        memset(w->abt_block2[n], 0, 64*sizeof(DCTELEM));
-        break;
-    case 2:
-        simple_idct48_add(dst           , stride, block1);
-        simple_idct48_add(dst + 4       , stride, w->abt_block2[n]);
-        memset(w->abt_block2[n], 0, 64*sizeof(DCTELEM));
-        break;
-    default:
-        av_log(s->avctx, AV_LOG_ERROR, "internal error in WMV2 abt\n");
-    }
-  }
-}
-
-void ff_wmv2_add_mb(MpegEncContext *s, DCTELEM block1[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr){
-    Wmv2Context * const w= (Wmv2Context*)s;
-
-    wmv2_add_block(w, block1[0], dest_y                    , s->linesize, 0);
-    wmv2_add_block(w, block1[1], dest_y + 8                , s->linesize, 1);
-    wmv2_add_block(w, block1[2], dest_y +     8*s->linesize, s->linesize, 2);
-    wmv2_add_block(w, block1[3], dest_y + 8 + 8*s->linesize, s->linesize, 3);
-    
-    if(s->flags&CODEC_FLAG_GRAY) return;
-    
-    wmv2_add_block(w, block1[4], dest_cb                   , s->uvlinesize, 4);
-    wmv2_add_block(w, block1[5], dest_cr                   , s->uvlinesize, 5);
-}
-
-void ff_mspel_motion(MpegEncContext *s,
-                               uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
-                               uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
-                               int motion_x, int motion_y, int h)
-{
-    Wmv2Context * const w= (Wmv2Context*)s;
-    uint8_t *ptr;
-    int dxy, offset, mx, my, src_x, src_y, v_edge_pos, linesize, uvlinesize;
-    int emu=0;
-    
-    dxy = ((motion_y & 1) << 1) | (motion_x & 1);
-    dxy = 2*dxy + w->hshift;
-    src_x = s->mb_x * 16 + (motion_x >> 1);
-    src_y = s->mb_y * 16 + (motion_y >> 1);
-                
-    /* WARNING: do no forget half pels */
-    v_edge_pos = s->v_edge_pos;
-    src_x = clip(src_x, -16, s->width);
-    src_y = clip(src_y, -16, s->height);
-    linesize   = s->linesize;
-    uvlinesize = s->uvlinesize;
-    ptr = ref_picture[0] + (src_y * linesize) + src_x;
-
-    if(s->flags&CODEC_FLAG_EMU_EDGE){
-        if(src_x<1 || src_y<1 || src_x + 17  >= s->h_edge_pos
-                              || src_y + h+1 >= v_edge_pos){
-            ff_emulated_edge_mc(s->edge_emu_buffer, ptr - 1 - s->linesize, s->linesize, 19, 19, 
-                             src_x-1, src_y-1, s->h_edge_pos, s->v_edge_pos);
-            ptr= s->edge_emu_buffer + 1 + s->linesize;
-            emu=1;
-        }
-    }
-
-    s->dsp.put_mspel_pixels_tab[dxy](dest_y             , ptr             , linesize);
-    s->dsp.put_mspel_pixels_tab[dxy](dest_y+8           , ptr+8           , linesize);
-    s->dsp.put_mspel_pixels_tab[dxy](dest_y  +8*linesize, ptr  +8*linesize, linesize);
-    s->dsp.put_mspel_pixels_tab[dxy](dest_y+8+8*linesize, ptr+8+8*linesize, linesize);
-
-    if(s->flags&CODEC_FLAG_GRAY) return;
-
-    if (s->out_format == FMT_H263) {
-        dxy = 0;
-        if ((motion_x & 3) != 0)
-            dxy |= 1;
-        if ((motion_y & 3) != 0)
-            dxy |= 2;
-        mx = motion_x >> 2;
-        my = motion_y >> 2;
-    } else {
-        mx = motion_x / 2;
-        my = motion_y / 2;
-        dxy = ((my & 1) << 1) | (mx & 1);
-        mx >>= 1;
-        my >>= 1;
-    }
-    
-    src_x = s->mb_x * 8 + mx;
-    src_y = s->mb_y * 8 + my;
-    src_x = clip(src_x, -8, s->width >> 1);
-    if (src_x == (s->width >> 1))
-        dxy &= ~1;
-    src_y = clip(src_y, -8, s->height >> 1);
-    if (src_y == (s->height >> 1))
-        dxy &= ~2;
-    offset = (src_y * uvlinesize) + src_x;
-    ptr = ref_picture[1] + offset;
-    if(emu){
-        ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, 
-                         src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
-        ptr= s->edge_emu_buffer;
-    }
-    pix_op[1][dxy](dest_cb, ptr, uvlinesize, h >> 1);
-
-    ptr = ref_picture[2] + offset;
-    if(emu){
-        ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, 
-                         src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
-        ptr= s->edge_emu_buffer;
-    }
-    pix_op[1][dxy](dest_cr, ptr, uvlinesize, h >> 1);
-}
-
-
-static int wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
-{
-    Wmv2Context * const w= (Wmv2Context*)s;
-    int cbp, code, i;
-    uint8_t *coded_val;
-
-    if(w->j_type) return 0;
-    
-    if (s->pict_type == P_TYPE) {
-        if(IS_SKIP(s->current_picture.mb_type[s->mb_y * s->mb_stride + s->mb_x])){
-            /* skip mb */
-            s->mb_intra = 0;
-            for(i=0;i<6;i++)
-                s->block_last_index[i] = -1;
-            s->mv_dir = MV_DIR_FORWARD;
-            s->mv_type = MV_TYPE_16X16;
-            s->mv[0][0][0] = 0;
-            s->mv[0][0][1] = 0;
-            s->mb_skipped = 1;
-            w->hshift=0;
-            return 0;
-        }
-
-        code = get_vlc2(&s->gb, mb_non_intra_vlc[w->cbp_table_index].table, MB_NON_INTRA_VLC_BITS, 3);
-        if (code < 0)
-            return -1;
-	s->mb_intra = (~code & 0x40) >> 6;
-            
-        cbp = code & 0x3f;
-    } else {
-        s->mb_intra = 1;
-        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 -1;
-        }
-        /* predict coded block pattern */
-        cbp = 0;
-        for(i=0;i<6;i++) {
-            int val = ((code >> (5 - i)) & 1);
-            if (i < 4) {
-                int pred = coded_block_pred(s, i, &coded_val);
-                val = val ^ pred;
-                *coded_val = val;
-            }
-            cbp |= val << (5 - i);
-        }
-    }
-
-    if (!s->mb_intra) {
-        int mx, my;
-//printf("P at %d %d\n", s->mb_x, s->mb_y);
-        wmv2_pred_motion(w, &mx, &my);
-        
-        if(cbp){
-            s->dsp.clear_blocks(s->block[0]);
-            if(s->per_mb_rl_table){
-                s->rl_table_index = decode012(&s->gb);
-                s->rl_chroma_table_index = s->rl_table_index;
-            }
-
-            if(w->abt_flag && w->per_mb_abt){
-                w->per_block_abt= get_bits1(&s->gb);
-                if(!w->per_block_abt)
-                    w->abt_type= decode012(&s->gb);
-            }else
-                w->per_block_abt=0;
-        }
-        
-        if (wmv2_decode_motion(w, &mx, &my) < 0)
-            return -1;
-
-        s->mv_dir = MV_DIR_FORWARD;
-        s->mv_type = MV_TYPE_16X16;
-        s->mv[0][0][0] = mx;
-        s->mv[0][0][1] = my;
-
-        for (i = 0; i < 6; i++) {
-            if (wmv2_decode_inter_block(w, block[i], i, (cbp >> (5 - i)) & 1) < 0)
-	    {
-	        av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding inter block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
-	        return -1;
-	    }
-        }    
-    } else {
-//if(s->pict_type==P_TYPE)
-//   printf("%d%d ", s->inter_intra_pred, cbp);
-//printf("I at %d %d %d %06X\n", s->mb_x, s->mb_y, ((cbp&3)? 1 : 0) +((cbp&0x3C)? 2 : 0), show_bits(&s->gb, 24));
-        s->ac_pred = get_bits1(&s->gb);
-        if(s->inter_intra_pred){
-            s->h263_aic_dir= get_vlc2(&s->gb, inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1);
-//            printf("%d%d %d %d/", s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
-        }
-        if(s->per_mb_rl_table && cbp){
-            s->rl_table_index = decode012(&s->gb);
-            s->rl_chroma_table_index = s->rl_table_index;
-        }
-    
-        s->dsp.clear_blocks(s->block[0]);
-        for (i = 0; i < 6; i++) {
-            if (msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
-	    {
-	        av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding intra block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
-	        return -1;
-	    }
-        }    
-    }
-
-    return 0;
-}
-
-static int wmv2_decode_init(AVCodecContext *avctx){
-    Wmv2Context * const w= avctx->priv_data;
-    
-    if(ff_h263_decode_init(avctx) < 0)
-        return -1;
-    
-    wmv2_common_init(w);
-    
-    return 0;
-}
-
-AVCodec wmv2_decoder = {
-    "wmv2",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_WMV2,
-    sizeof(Wmv2Context),
-    wmv2_decode_init,
-    NULL,
-    ff_h263_decode_end,
-    ff_h263_decode_frame,
-    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
-};
-
-#ifdef CONFIG_ENCODERS
-AVCodec wmv2_encoder = {
-    "wmv2",
-    CODEC_TYPE_VIDEO,
-    CODEC_ID_WMV2,
-    sizeof(Wmv2Context),
-    wmv2_encode_init,
-    MPV_encode_picture,
-    MPV_encode_end,
-};
-#endif
diff --git a/ffmpeg.src/libavformat/Makefile b/ffmpeg.src/libavformat/Makefile
deleted file mode 100644
index 6d58e98..0000000
--- a/ffmpeg.src/libavformat/Makefile
+++ /dev/null
@@ -1,97 +0,0 @@
-#
-# libavformat Makefile
-# (c) 2000-2003 Fabrice Bellard
-#
-include ../config.mak
-
-VPATH=$(SRC_PATH)/libavformat
-
-CFLAGS=$(OPTFLAGS) -I.. -I$(SRC_PATH) -I$(SRC_PATH)/libavutil -I$(SRC_PATH)/libavcodec -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE
-
-OBJS= utils.o cutils.o os_support.o allformats.o
-PPOBJS=
-
-# mux and demuxes
-OBJS+=mpeg.o mpegts.o mpegtsenc.o 
-
-# file I/O
-OBJS+= avio.o aviobuf.o file.o 
-
-EXTRALIBS += -L../libavutil -lavutil$(BUILDSUF)
-
-ifeq ($(TARGET_ARCH_SPARC64),yes)
-CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc
-endif
-
-LIB= $(LIBPREF)avformat$(LIBSUF)
-ifeq ($(BUILD_SHARED),yes)
-SLIB= $(SLIBPREF)avformat$(SLIBSUF)
-
-AVCLIBS+=-lavcodec$(BUILDSUF) -L../libavcodec
-ifeq ($(CONFIG_MP3LAME),yes)
-AVCLIBS+=-lmp3lame
-endif
-endif
-
-SRCS := $(OBJS:.o=.c) $(PPOBJS:.o=.cpp)
-
-all: $(LIB) $(SLIB)
-
-$(LIB): $(OBJS) $(PPOBJS)
-	rm -f $@
-	$(AR) rc $@ $(OBJS) $(PPOBJS)
-	$(RANLIB) $@
-
-$(SLIB): $(OBJS)
-ifeq ($(CONFIG_WIN32),yes)
-	$(CC) $(SHFLAGS) -Wl,--output-def,$(@:.dll=.def) -o $@ $(OBJS) $(PPOBJS) $(AVCLIBS) $(EXTRALIBS)
-	-lib /machine:i386 /def:$(@:.dll=.def)
-else
-	$(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(PPOBJS) $(AVCLIBS) $(EXTRALIBS)
-endif
-
-depend: $(SRCS)
-	$(CC) -MM $(CFLAGS) $^ 1>.depend
-
-ifeq ($(BUILD_SHARED),yes)
-install: all install-headers
-ifeq ($(CONFIG_WIN32),yes)
-	install $(INSTALLSTRIP) -m 755 $(SLIB) "$(prefix)"
-else
-	install -d $(libdir)
-	install $(INSTALLSTRIP) -m 755 $(SLIB) $(libdir)/libavformat-$(VERSION).so
-	ln -sf libavformat-$(VERSION).so $(libdir)/libavformat.so
-	$(LDCONFIG) || true
-endif
-else
-install:
-endif
-
-installlib: all install-headers
-	install -m 644 $(LIB) "$(libdir)"
-
-install-headers:
-	mkdir -p "$(prefix)/include/ffmpeg"
-	install -m 644 $(SRC_PATH)/libavformat/avformat.h $(SRC_PATH)/libavformat/avio.h \
-                "$(prefix)/include/ffmpeg"
-#                $(SRC_PATH)/libavformat/rtp.h $(SRC_PATH)/libavformat/rtsp.h 
-#                $(SRC_PATH)/libavformat/rtspcodes.h 
-	install -d $(libdir)/pkgconfig
-	install -m 644 ../libavformat.pc $(libdir)/pkgconfig
-
-%.o: %.c
-	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $< 
-
-# BeOS: remove -Wall to get rid of all the "multibyte constant" warnings
-%.o: %.cpp
-	g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $< 
-
-distclean clean: 
-	rm -f *.o *.d .depend *~ *.a *.so $(LIB)
-
-#
-# include dependency files if they exist
-#
-ifneq ($(wildcard .depend),)
-include .depend
-endif
diff --git a/ffmpeg.src/libavformat/allformats.c b/ffmpeg.src/libavformat/allformats.c
deleted file mode 100644
index f4b175c..0000000
--- a/ffmpeg.src/libavformat/allformats.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Register all the formats and protocols
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avformat.h"
-
-/* If you do not call this function, then you can select exactly which
-   formats you want to support */
-
-/**
- * Initialize libavcodec and register all the codecs and formats.
- */
-void av_register_all(void)
-{
-    static int inited = 0;
-    
-    if (inited != 0)
-        return;
-    inited = 1;
-
-    avcodec_init();
-    avcodec_register_all();
-
-    mpegps_init();
-    mpegts_init();
-    
-    /* file protocols */
-    register_protocol(&file_protocol);
-    register_protocol(&pipe_protocol);
-}
diff --git a/ffmpeg.src/libavformat/avformat.h b/ffmpeg.src/libavformat/avformat.h
deleted file mode 100644
index 9a2d4eb..0000000
--- a/ffmpeg.src/libavformat/avformat.h
+++ /dev/null
@@ -1,717 +0,0 @@
-#ifndef AVFORMAT_H
-#define AVFORMAT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define LIBAVFORMAT_VERSION_INT ((49<<16)+(1<<8)+0)
-#define LIBAVFORMAT_VERSION     49.1.0
-#define LIBAVFORMAT_BUILD       LIBAVFORMAT_VERSION_INT
-
-#define LIBAVFORMAT_IDENT       "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
-
-#include <time.h>
-#include <stdio.h>  /* FILE */
-#include "avcodec.h"
-
-#include "avio.h"
-
-/* packet functions */
-
-#ifndef MAXINT64
-#define MAXINT64 int64_t_C(0x7fffffffffffffff)
-#endif
-
-#ifndef MININT64
-#define MININT64 int64_t_C(0x8000000000000000)
-#endif
-
-typedef struct AVPacket {
-    int64_t pts;                            ///< presentation time stamp in time_base units
-    int64_t dts;                            ///< decompression time stamp in time_base units
-    uint8_t *data;
-    int   size;
-    int   stream_index;
-    int   flags;
-    int   duration;                         ///< presentation duration in time_base units (0 if not available)
-    void  (*destruct)(struct AVPacket *);
-    void  *priv;
-    int64_t pos;                            ///< byte position in stream, -1 if unknown
-} AVPacket; 
-#define PKT_FLAG_KEY   0x0001
-
-void av_destruct_packet_nofree(AVPacket *pkt);
-void av_destruct_packet(AVPacket *pkt);
-
-/* initialize optional fields of a packet */
-static inline void av_init_packet(AVPacket *pkt)
-{
-    pkt->pts   = AV_NOPTS_VALUE;
-    pkt->dts   = AV_NOPTS_VALUE;
-    pkt->pos   = -1;
-    pkt->duration = 0;
-    pkt->flags = 0;
-    pkt->stream_index = 0;
-    pkt->destruct= av_destruct_packet_nofree;
-}
-
-int av_new_packet(AVPacket *pkt, int size);
-int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
-int av_dup_packet(AVPacket *pkt);
-
-/**
- * Free a packet
- *
- * @param pkt packet to free
- */
-static inline void av_free_packet(AVPacket *pkt)
-{
-    if (pkt && pkt->destruct) {
-	pkt->destruct(pkt);
-    }
-}
-
-/*************************************************/
-/* fractional numbers for exact pts handling */
-
-/* the exact value of the fractional number is: 'val + num / den'. num
-   is assumed to be such as 0 <= num < den */
-typedef struct AVFrac {
-    int64_t val, num, den; 
-} AVFrac;
-
-void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den);
-void av_frac_add(AVFrac *f, int64_t incr);
-void av_frac_set(AVFrac *f, int64_t val);
-
-/*************************************************/
-/* input/output formats */
-
-struct AVFormatContext;
-
-/* this structure contains the data a format has to probe a file */
-typedef struct AVProbeData {
-    const char *filename;
-    unsigned char *buf;
-    int buf_size;
-} AVProbeData;
-
-#define AVPROBE_SCORE_MAX 100
-
-typedef struct AVFormatParameters {
-    AVRational time_base;
-    int sample_rate;
-    int channels;
-    int width;
-    int height;
-    enum PixelFormat pix_fmt;
-    struct AVImageFormat *image_format;
-    int channel; /* used to select dv channel */
-    const char *device; /* video, audio or DV device */
-    const char *standard; /* tv standard, NTSC, PAL, SECAM */
-    int mpeg2ts_raw:1;  /* force raw MPEG2 transport stream output, if possible */
-    int mpeg2ts_compute_pcr:1; /* compute exact PCR for each transport
-                                  stream packet (only meaningful if
-                                  mpeg2ts_raw is TRUE */
-    int initial_pause:1;       /* do not begin to play the stream
-                                  immediately (RTSP only) */
-    enum CodecID video_codec_id;
-    enum CodecID audio_codec_id;
-} AVFormatParameters;
-
-#define AVFMT_NOFILE        0x0001 /* no file should be opened */
-#define AVFMT_NEEDNUMBER    0x0002 /* needs '%d' in filename */ 
-#define AVFMT_SHOW_IDS      0x0008 /* show format stream IDs numbers */
-#define AVFMT_RAWPICTURE    0x0020 /* format wants AVPicture structure for
-                                      raw picture data */
-#define AVFMT_GLOBALHEADER  0x0040 /* format wants global header */
-
-typedef struct AVOutputFormat {
-    const char *name;
-    const char *long_name;
-    const char *mime_type;
-    const char *extensions; /* comma separated extensions */
-    /* size of private data so that it can be allocated in the wrapper */
-    int priv_data_size;
-    /* output support */
-    enum CodecID audio_codec; /* default audio codec */
-    enum CodecID video_codec; /* default video codec */
-    int (*write_header)(struct AVFormatContext *);
-    int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
-    int (*write_trailer)(struct AVFormatContext *);
-    /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER */
-    int flags;
-    /* currently only used to set pixel format if not YUV420P */
-    int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
-    int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush);
-    /* private fields */
-    struct AVOutputFormat *next;
-} AVOutputFormat;
-
-typedef struct AVInputFormat {
-    const char *name;
-    const char *long_name;
-    /* size of private data so that it can be allocated in the wrapper */
-    int priv_data_size;
-    /* tell if a given file has a chance of being parsing by this format */
-    int (*read_probe)(AVProbeData *);
-    /* read the format header and initialize the AVFormatContext
-       structure. Return 0 if OK. 'ap' if non NULL contains
-       additionnal paramters. Only used in raw format right
-       now. 'av_new_stream' should be called to create new streams.  */
-    int (*read_header)(struct AVFormatContext *,
-                       AVFormatParameters *ap);
-    /* read one packet and put it in 'pkt'. pts and flags are also
-       set. 'av_new_stream' can be called only if the flag
-       AVFMTCTX_NOHEADER is used. */
-    int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
-    /* close the stream. The AVFormatContext and AVStreams are not
-       freed by this function */
-    int (*read_close)(struct AVFormatContext *);
-    /** 
-     * seek to a given timestamp relative to the frames in 
-     * stream component stream_index
-     * @param stream_index must not be -1
-     * @param flags selects which direction should be preferred if no exact 
-     *              match is available
-     */
-    int (*read_seek)(struct AVFormatContext *, 
-                     int stream_index, int64_t timestamp, int flags);
-    /**
-     * gets the next timestamp in AV_TIME_BASE units.
-     */
-    int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
-                              int64_t *pos, int64_t pos_limit);
-    /* can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
-    int flags;
-    /* if extensions are defined, then no probe is done. You should
-       usually not use extension format guessing because it is not
-       reliable enough */
-    const char *extensions;
-    /* general purpose read only value that the format can use */
-    int value;
-
-    /* start/resume playing - only meaningful if using a network based format
-       (RTSP) */
-    int (*read_play)(struct AVFormatContext *);
-
-    /* pause playing - only meaningful if using a network based format
-       (RTSP) */
-    int (*read_pause)(struct AVFormatContext *);
-
-    /* private fields */
-    struct AVInputFormat *next;
-} AVInputFormat;
-
-typedef struct AVIndexEntry {
-    int64_t pos;
-    int64_t timestamp;
-#define AVINDEX_KEYFRAME 0x0001
-/* the following 2 flags indicate that the next/prev keyframe is known, and scaning for it isnt needed */
-    int flags;
-    int min_distance;         /* min distance between this and the previous keyframe, used to avoid unneeded searching */
-} AVIndexEntry;
-
-typedef struct AVStream {
-    int index;    /* stream index in AVFormatContext */
-    int id;       /* format specific stream id */
-    AVCodecContext *codec; /* codec context */
-    /**
-     * real base frame rate of the stream.
-     * for example if the timebase is 1/90000 and all frames have either 
-     * approximately 3600 or 1800 timer ticks then r_frame_rate will be 50/1
-     */
-    AVRational r_frame_rate;
-    void *priv_data;
-    /* internal data used in av_find_stream_info() */
-    int64_t codec_info_duration;     
-    int codec_info_nb_frames;
-    /* encoding: PTS generation when outputing stream */
-    AVFrac pts;
-
-    /**
-     * this is the fundamental unit of time (in seconds) in terms
-     * of which frame timestamps are represented. for fixed-fps content,
-     * timebase should be 1/framerate and timestamp increments should be
-     * identically 1.
-     */
-    AVRational time_base;
-    int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */
-    /* ffmpeg.c private use */
-    int stream_copy; /* if TRUE, just copy stream */
-    enum AVDiscard discard; ///< selects which packets can be discarded at will and dont need to be demuxed
-    //FIXME move stuff to a flags field?
-    /* quality, as it has been removed from AVCodecContext and put in AVVideoFrame
-     * MN:dunno if thats the right place, for it */
-    float quality; 
-    /* decoding: position of the first frame of the component, in
-       AV_TIME_BASE fractional seconds. */
-    int64_t start_time; 
-    /* decoding: duration of the stream, in AV_TIME_BASE fractional
-       seconds. */
-    int64_t duration;
-
-    char language[4]; /* ISO 639 3-letter language code (empty string if undefined) */
-
-    /* av_read_frame() support */
-    int need_parsing;                  ///< 1->full parsing needed, 2->only parse headers dont repack
-    struct AVCodecParserContext *parser;
-
-    int64_t cur_dts;
-    int last_IP_duration;
-    int64_t last_IP_pts;
-    /* av_seek_frame() support */
-    AVIndexEntry *index_entries; /* only used if the format does not
-                                    support seeking natively */
-    int nb_index_entries;
-    int index_entries_allocated_size;
-    
-    int64_t nb_frames;                 ///< number of frames in this stream if known or 0
-} AVStream;
-
-#define AVFMTCTX_NOHEADER      0x0001 /* signal that no header is present
-                                         (streams are added dynamically) */
-
-#define MAX_STREAMS 20
-
-/* format I/O context */
-typedef struct AVFormatContext {
-    const AVClass *av_class; /* set by av_alloc_format_context */
-    /* can only be iformat or oformat, not both at the same time */
-    struct AVInputFormat *iformat;
-    struct AVOutputFormat *oformat;
-    void *priv_data;
-    ByteIOContext pb;
-    int nb_streams;
-    AVStream *streams[MAX_STREAMS];
-    char filename[1024]; /* input or output filename */
-    /* stream info */
-    int64_t timestamp;
-    char title[512];
-    char author[512];
-    char copyright[512];
-    char comment[512];
-    char album[512];
-    int year;  /* ID3 year, 0 if none */
-    int track; /* track number, 0 if none */
-    char genre[32]; /* ID3 genre */
-
-    int ctx_flags; /* format specific flags, see AVFMTCTX_xx */
-    /* private data for pts handling (do not modify directly) */
-    /* This buffer is only needed when packets were already buffered but
-       not decoded, for example to get the codec parameters in mpeg
-       streams */
-    struct AVPacketList *packet_buffer;
-
-    /* decoding: position of the first frame of the component, in
-       AV_TIME_BASE fractional seconds. NEVER set this value directly:
-       it is deduced from the AVStream values.  */
-    int64_t start_time; 
-    /* decoding: duration of the stream, in AV_TIME_BASE fractional
-       seconds. NEVER set this value directly: it is deduced from the
-       AVStream values.  */
-    int64_t duration;
-    /* decoding: total file size. 0 if unknown */
-    int64_t file_size;
-    /* decoding: total stream bitrate in bit/s, 0 if not
-       available. Never set it directly if the file_size and the
-       duration are known as ffmpeg can compute it automatically. */
-    int bit_rate;
-
-    /* av_read_frame() support */
-    AVStream *cur_st;
-    const uint8_t *cur_ptr;
-    int cur_len;
-    AVPacket cur_pkt;
-
-    /* av_seek_frame() support */
-    int64_t data_offset; /* offset of the first packet */
-    int index_built;
-    
-    int mux_rate;
-    int packet_size;
-    int preload;
-    int max_delay;
-
-#define AVFMT_NOOUTPUTLOOP -1 
-#define AVFMT_INFINITEOUTPUTLOOP 0 
-    /* number of times to loop output in formats that support it */
-    int loop_output;
-    
-    int flags;
-#define AVFMT_FLAG_GENPTS       0x0001 ///< generate pts if missing even if it requires parsing future frames
-} AVFormatContext;
-
-typedef struct AVPacketList {
-    AVPacket pkt;
-    struct AVPacketList *next;
-} AVPacketList;
-
-extern AVInputFormat *first_iformat;
-extern AVOutputFormat *first_oformat;
-
-/* still image support */
-struct AVInputImageContext;
-typedef struct AVInputImageContext AVInputImageContext;
-
-typedef struct AVImageInfo {
-    enum PixelFormat pix_fmt; /* requested pixel format */
-    int width; /* requested width */
-    int height; /* requested height */
-    int interleaved; /* image is interleaved (e.g. interleaved GIF) */
-    AVPicture pict; /* returned allocated image */
-} AVImageInfo;
-
-/* AVImageFormat.flags field constants */
-#define AVIMAGE_INTERLEAVED 0x0001 /* image format support interleaved output */
-
-typedef struct AVImageFormat {
-    const char *name;
-    const char *extensions;
-    /* tell if a given file has a chance of being parsing by this format */
-    int (*img_probe)(AVProbeData *);
-    /* read a whole image. 'alloc_cb' is called when the image size is
-       known so that the caller can allocate the image. If 'allo_cb'
-       returns non zero, then the parsing is aborted. Return '0' if
-       OK. */
-    int (*img_read)(ByteIOContext *, 
-                    int (*alloc_cb)(void *, AVImageInfo *info), void *);
-    /* write the image */
-    int supported_pixel_formats; /* mask of supported formats for output */
-    int (*img_write)(ByteIOContext *, AVImageInfo *);
-    int flags;
-    struct AVImageFormat *next;
-} AVImageFormat;
-
-void av_register_image_format(AVImageFormat *img_fmt);
-AVImageFormat *av_probe_image_format(AVProbeData *pd);
-AVImageFormat *guess_image_format(const char *filename);
-enum CodecID av_guess_image2_codec(const char *filename);
-int av_read_image(ByteIOContext *pb, const char *filename,
-                  AVImageFormat *fmt,
-                  int (*alloc_cb)(void *, AVImageInfo *info), void *opaque);
-int av_write_image(ByteIOContext *pb, AVImageFormat *fmt, AVImageInfo *img);
-
-extern AVImageFormat *first_image_format;
-
-extern AVImageFormat pnm_image_format;
-extern AVImageFormat pbm_image_format;
-extern AVImageFormat pgm_image_format;
-extern AVImageFormat ppm_image_format;
-extern AVImageFormat pam_image_format;
-extern AVImageFormat pgmyuv_image_format;
-extern AVImageFormat yuv_image_format;
-#ifdef CONFIG_ZLIB
-extern AVImageFormat png_image_format;
-#endif
-extern AVImageFormat jpeg_image_format;
-extern AVImageFormat gif_image_format;
-extern AVImageFormat sgi_image_format;
-
-/* XXX: use automatic init with either ELF sections or C file parser */
-/* modules */
-
-/* mpeg.c */
-extern AVInputFormat mpegps_demux;
-int mpegps_init(void);
-
-/* mpegts.c */
-extern AVInputFormat mpegts_demux;
-int mpegts_init(void);
-
-/* rm.c */
-int rm_init(void);
-
-/* crc.c */
-int crc_init(void);
-
-/* img.c */
-int img_init(void);
-
-/* img2.c */
-int img2_init(void);
-
-/* asf.c */
-int asf_init(void);
-
-/* avienc.c */
-int avienc_init(void);
-
-/* avidec.c */
-int avidec_init(void);
-
-/* swf.c */
-int swf_init(void);
-
-/* mov.c */
-int mov_init(void);
-
-/* movenc.c */
-int movenc_init(void);
-
-/* flvenc.c */
-int flvenc_init(void);
-
-/* flvdec.c */
-int flvdec_init(void);
-
-/* jpeg.c */
-int jpeg_init(void);
-
-/* gif.c */
-int gif_init(void);
-
-/* au.c */
-int au_init(void);
-
-/* amr.c */
-int amr_init(void);
-
-/* wav.c */
-int ff_wav_init(void);
-
-/* mmf.c */
-int ff_mmf_init(void);
-
-/* raw.c */
-int pcm_read_seek(AVFormatContext *s, 
-                  int stream_index, int64_t timestamp, int flags);
-int raw_init(void);
-
-/* mp3.c */
-int mp3_init(void);
-
-/* yuv4mpeg.c */
-int yuv4mpeg_init(void);
-
-/* ogg2.c */
-int ogg_init(void);
-
-/* ogg.c */
-int libogg_init(void);
-
-/* dv.c */
-int ff_dv_init(void);
-
-/* ffm.c */
-int ffm_init(void);
-
-/* rtsp.c */
-extern AVInputFormat redir_demux;
-int redir_open(AVFormatContext **ic_ptr, ByteIOContext *f);
-
-/* 4xm.c */
-int fourxm_init(void);
-
-/* psxstr.c */
-int str_init(void);
-
-/* idroq.c */
-int roq_init(void);
-
-/* ipmovie.c */
-int ipmovie_init(void);
-
-/* nut.c */
-int nut_init(void);
-
-/* wc3movie.c */
-int wc3_init(void);
-
-/* westwood.c */
-int westwood_init(void);
-
-/* segafilm.c */
-int film_init(void);
-
-/* idcin.c */
-int idcin_init(void);
-
-/* flic.c */
-int flic_init(void);
-
-/* sierravmd.c */
-int vmd_init(void);
-
-/* matroska.c */
-int matroska_init(void);
-
-/* sol.c */
-int sol_init(void);
-
-/* electronicarts.c */
-int ea_init(void);
-
-/* nsvdec.c */
-int nsvdec_init(void);
-
-/* daud.c */
-int daud_init(void);
-
-// #include "rtp.h"
-
-// #include "rtsp.h"
-
-/* yuv4mpeg.c */
-extern AVOutputFormat yuv4mpegpipe_oformat;
-
-/* utils.c */
-void av_register_input_format(AVInputFormat *format);
-void av_register_output_format(AVOutputFormat *format);
-AVOutputFormat *guess_stream_format(const char *short_name, 
-                                    const char *filename, const char *mime_type);
-AVOutputFormat *guess_format(const char *short_name, 
-                             const char *filename, const char *mime_type);
-enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, 
-                            const char *filename, const char *mime_type, enum CodecType type);
-
-void av_hex_dump(FILE *f, uint8_t *buf, int size);
-void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
-
-void av_register_all(void);
-
-typedef struct FifoBuffer {
-    uint8_t *buffer;
-    uint8_t *rptr, *wptr, *end;
-} FifoBuffer;
-
-int fifo_init(FifoBuffer *f, int size);
-void fifo_free(FifoBuffer *f);
-int fifo_size(FifoBuffer *f, uint8_t *rptr);
-int fifo_read(FifoBuffer *f, uint8_t *buf, int buf_size, uint8_t **rptr_ptr);
-void fifo_write(FifoBuffer *f, uint8_t *buf, int size, uint8_t **wptr_ptr);
-int put_fifo(ByteIOContext *pb, FifoBuffer *f, int buf_size, uint8_t **rptr_ptr);
-void fifo_realloc(FifoBuffer *f, unsigned int size);
-
-/* media file input */
-AVInputFormat *av_find_input_format(const char *short_name);
-AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
-int av_open_input_stream(AVFormatContext **ic_ptr, 
-                         ByteIOContext *pb, const char *filename, 
-                         AVInputFormat *fmt, AVFormatParameters *ap);
-int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, 
-                       AVInputFormat *fmt,
-                       int buf_size,
-                       AVFormatParameters *ap);
-/* no av_open for output, so applications will need this: */
-AVFormatContext *av_alloc_format_context(void);
-
-#define AVERROR_UNKNOWN     (-1)  /* unknown error */
-#define AVERROR_IO          (-2)  /* i/o error */
-#define AVERROR_NUMEXPECTED (-3)  /* number syntax expected in filename */
-#define AVERROR_INVALIDDATA (-4)  /* invalid data found */
-#define AVERROR_NOMEM       (-5)  /* not enough memory */
-#define AVERROR_NOFMT       (-6)  /* unknown format */
-#define AVERROR_NOTSUPP     (-7)  /* operation not supported */
- 
-int av_find_stream_info(AVFormatContext *ic);
-int av_read_packet(AVFormatContext *s, AVPacket *pkt);
-int av_read_frame(AVFormatContext *s, AVPacket *pkt);
-int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags);
-int av_read_play(AVFormatContext *s);
-int av_read_pause(AVFormatContext *s);
-void av_close_input_file(AVFormatContext *s);
-AVStream *av_new_stream(AVFormatContext *s, int id);
-void av_set_pts_info(AVStream *s, int pts_wrap_bits,
-                     int pts_num, int pts_den);
-
-#define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
-#define AVSEEK_FLAG_BYTE     2 ///< seeking based on position in bytes
-#define AVSEEK_FLAG_ANY      4 ///< seek to any frame, even non keyframes
-
-int av_find_default_stream_index(AVFormatContext *s);
-int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
-int av_add_index_entry(AVStream *st,
-                       int64_t pos, int64_t timestamp, int distance, int flags);
-int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags);
-
-/* media file output */
-int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
-int av_write_header(AVFormatContext *s);
-int av_write_frame(AVFormatContext *s, AVPacket *pkt);
-int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
-
-int av_write_trailer(AVFormatContext *s);
-
-void dump_format(AVFormatContext *ic,
-                 int index, 
-                 const char *url,
-                 int is_output);
-int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
-int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg);
-int64_t parse_date(const char *datestr, int duration);
-
-int64_t av_gettime(void);
-
-/* ffm specific for ffserver */
-#define FFM_PACKET_SIZE 4096
-offset_t ffm_read_write_index(int fd);
-void ffm_write_write_index(int fd, offset_t pos);
-void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
-
-int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
-
-int get_frame_filename(char *buf, int buf_size,
-                       const char *path, int number);
-int filename_number_test(const char *filename);
-
-/* grab specific */
-int video_grab_init(void);
-int audio_init(void);
-
-/* DV1394 */
-int dv1394_init(void);
-int dc1394_init(void);
-
-#ifdef HAVE_AV_CONFIG_H
-
-#include "os_support.h"
-
-int strstart(const char *str, const char *val, const char **ptr);
-int stristart(const char *str, const char *val, const char **ptr);
-void pstrcpy(char *buf, int buf_size, const char *str);
-char *pstrcat(char *buf, int buf_size, const char *s);
-
-void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem);
-
-#ifdef __GNUC__
-#define dynarray_add(tab, nb_ptr, elem)\
-do {\
-    typeof(tab) _tab = (tab);\
-    typeof(elem) _elem = (elem);\
-    (void)sizeof(**_tab == _elem); /* check that types are compatible */\
-    __dynarray_add((unsigned long **)_tab, nb_ptr, (unsigned long)_elem);\
-} while(0)
-#else
-#define dynarray_add(tab, nb_ptr, elem)\
-do {\
-    __dynarray_add((unsigned long **)(tab), nb_ptr, (unsigned long)(elem));\
-} while(0)
-#endif
-
-time_t mktimegm(struct tm *tm);
-struct tm *brktimegm(time_t secs, struct tm *tm);
-const char *small_strptime(const char *p, const char *fmt, 
-                           struct tm *dt);
-
-struct in_addr;
-int resolve_host(struct in_addr *sin_addr, const char *hostname);
-
-void url_split(char *proto, int proto_size,
-               char *authorization, int authorization_size,
-               char *hostname, int hostname_size,
-               int *port_ptr,
-               char *path, int path_size,
-               const char *url);
-
-int match_ext(const char *filename, const char *extensions);
-
-#endif /* HAVE_AV_CONFIG_H */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* AVFORMAT_H */
-
diff --git a/ffmpeg.src/libavformat/avio.c b/ffmpeg.src/libavformat/avio.c
deleted file mode 100644
index f4cee60..0000000
--- a/ffmpeg.src/libavformat/avio.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Unbuffered io for ffmpeg system
- * Copyright (c) 2001 Fabrice Bellard
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avformat.h"
-
-static int default_interrupt_cb(void);
-
-URLProtocol *first_protocol = NULL;
-URLInterruptCB *url_interrupt_cb = default_interrupt_cb;
-
-int register_protocol(URLProtocol *protocol)
-{
-    URLProtocol **p;
-    p = &first_protocol;
-    while (*p != NULL) p = &(*p)->next;
-    *p = protocol;
-    protocol->next = NULL;
-    return 0;
-}
-
-int url_open(URLContext **puc, const char *filename, int flags)
-{
-    URLContext *uc;
-    URLProtocol *up;
-    const char *p;
-    char proto_str[128], *q;
-    int err;
-
-    p = filename;
-    q = proto_str;
-    while (*p != '\0' && *p != ':') {
-        /* protocols can only contain alphabetic chars */
-        if (!isalpha(*p))
-            goto file_proto;
-        if ((q - proto_str) < sizeof(proto_str) - 1)
-            *q++ = *p;
-        p++;
-    }
-    /* if the protocol has length 1, we consider it is a dos drive */
-    if (*p == '\0' || (q - proto_str) <= 1) {
-    file_proto:
-        strcpy(proto_str, "file");
-    } else {
-        *q = '\0';
-    }
-    
-    up = first_protocol;
-    while (up != NULL) {
-        if (!strcmp(proto_str, up->name))
-            goto found;
-        up = up->next;
-    }
-    err = -ENOENT;
-    goto fail;
- found:
-    uc = av_malloc(sizeof(URLContext) + strlen(filename));
-    if (!uc) {
-        err = -ENOMEM;
-        goto fail;
-    }
-    strcpy(uc->filename, filename);
-    uc->prot = up;
-    uc->flags = flags;
-    uc->is_streamed = 0; /* default = not streamed */
-    uc->max_packet_size = 0; /* default: stream file */
-    err = up->url_open(uc, filename, flags);
-    if (err < 0) {
-        av_free(uc);
-        *puc = NULL;
-        return err;
-    }
-    *puc = uc;
-    return 0;
- fail:
-    *puc = NULL;
-    return err;
-}
-
-int url_read(URLContext *h, unsigned char *buf, int size)
-{
-    int ret;
-    if (h->flags & URL_WRONLY)
-        return AVERROR_IO;
-    ret = h->prot->url_read(h, buf, size);
-    return ret;
-}
-
-#ifdef CONFIG_ENCODERS
-int url_write(URLContext *h, unsigned char *buf, int size)
-{
-    int ret;
-    if (!(h->flags & (URL_WRONLY | URL_RDWR)))
-        return AVERROR_IO;
-    /* avoid sending too big packets */
-    if (h->max_packet_size && size > h->max_packet_size)
-        return AVERROR_IO; 
-    ret = h->prot->url_write(h, buf, size);
-    return ret;
-}
-#endif //CONFIG_ENCODERS
-
-offset_t url_seek(URLContext *h, offset_t pos, int whence)
-{
-    offset_t ret;
-
-    if (!h->prot->url_seek)
-        return -EPIPE;
-    ret = h->prot->url_seek(h, pos, whence);
-    return ret;
-}
-
-int url_close(URLContext *h)
-{
-    int ret;
-
-    ret = h->prot->url_close(h);
-    av_free(h);
-    return ret;
-}
-
-int url_exist(const char *filename)
-{
-    URLContext *h;
-    if (url_open(&h, filename, URL_RDONLY) < 0)
-        return 0;
-    url_close(h);
-    return 1;
-}
-
-offset_t url_filesize(URLContext *h)
-{
-    offset_t pos, size;
-    
-    pos = url_seek(h, 0, SEEK_CUR);
-    size = url_seek(h, -1, SEEK_END)+1;
-    url_seek(h, pos, SEEK_SET);
-    return size;
-}
-
-/* 
- * Return the maximum packet size associated to packetized file
- * handle. If the file is not packetized (stream like http or file on
- * disk), then 0 is returned.
- * 
- * @param h file handle
- * @return maximum packet size in bytes
- */
-int url_get_max_packet_size(URLContext *h)
-{
-    return h->max_packet_size;
-}
-
-void url_get_filename(URLContext *h, char *buf, int buf_size)
-{
-    pstrcpy(buf, buf_size, h->filename);
-}
-
-
-static int default_interrupt_cb(void)
-{
-    return 0;
-}
-
-/** 
- * The callback is called in blocking functions to test regulary if
- * asynchronous interruption is needed. -EINTR is returned in this
- * case by the interrupted function. 'NULL' means no interrupt
- * callback is given.  
- */
-void url_set_interrupt_cb(URLInterruptCB *interrupt_cb)
-{
-    if (!interrupt_cb)
-        interrupt_cb = default_interrupt_cb;
-    url_interrupt_cb = interrupt_cb;
-}
diff --git a/ffmpeg.src/libavformat/avio.h b/ffmpeg.src/libavformat/avio.h
deleted file mode 100644
index 51ef472..0000000
--- a/ffmpeg.src/libavformat/avio.h
+++ /dev/null
@@ -1,180 +0,0 @@
-#ifndef AVIO_H
-#define AVIO_H
-
-/* output byte stream handling */
-
-typedef int64_t offset_t;
-
-/* unbuffered I/O */
-
-struct URLContext {
-    struct URLProtocol *prot;
-    int flags;        
-    int is_streamed;  /* true if streamed (no seek possible), default = false */
-    int max_packet_size;  /* if non zero, the stream is packetized with this max packet size */
-    void *priv_data;
-    char filename[1]; /* specified filename */
-};
-
-typedef struct URLContext URLContext;
-
-typedef struct URLPollEntry {
-    URLContext *handle;
-    int events;
-    int revents;
-} URLPollEntry;
-
-#define URL_RDONLY 0
-#define URL_WRONLY 1
-#define URL_RDWR   2
-
-typedef int URLInterruptCB(void);
-
-int url_open(URLContext **h, const char *filename, int flags);
-int url_read(URLContext *h, unsigned char *buf, int size);
-int url_write(URLContext *h, unsigned char *buf, int size);
-offset_t url_seek(URLContext *h, offset_t pos, int whence);
-int url_close(URLContext *h);
-int url_exist(const char *filename);
-offset_t url_filesize(URLContext *h);
-int url_get_max_packet_size(URLContext *h);
-void url_get_filename(URLContext *h, char *buf, int buf_size);
-
-/* the callback is called in blocking functions to test regulary if
-   asynchronous interruption is needed. -EINTR is returned in this
-   case by the interrupted function. 'NULL' means no interrupt
-   callback is given. */
-void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
-
-/* not implemented */
-int url_poll(URLPollEntry *poll_table, int n, int timeout);
-
-typedef struct URLProtocol {
-    const char *name;
-    int (*url_open)(URLContext *h, const char *filename, int flags);
-    int (*url_read)(URLContext *h, unsigned char *buf, int size);
-    int (*url_write)(URLContext *h, unsigned char *buf, int size);
-    offset_t (*url_seek)(URLContext *h, offset_t pos, int whence);
-    int (*url_close)(URLContext *h);
-    struct URLProtocol *next;
-} URLProtocol;
-
-extern URLProtocol *first_protocol;
-extern URLInterruptCB *url_interrupt_cb;
-
-int register_protocol(URLProtocol *protocol);
-
-typedef struct {
-    unsigned char *buffer;
-    int buffer_size;
-    unsigned char *buf_ptr, *buf_end;
-    void *opaque;
-    int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
-    int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
-    offset_t (*seek)(void *opaque, offset_t offset, int whence);
-    offset_t pos; /* position in the file of the current buffer */
-    int must_flush; /* true if the next seek should flush */
-    int eof_reached; /* true if eof reached */
-    int write_flag;  /* true if open for writing */
-    int is_streamed;
-    int max_packet_size;
-    unsigned long checksum;
-    unsigned char *checksum_ptr;
-    unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
-    int error;         ///< contains the error code or 0 if no error happened
-} ByteIOContext;
-
-int init_put_byte(ByteIOContext *s,
-                  unsigned char *buffer,
-                  int buffer_size,
-                  int write_flag,
-                  void *opaque,
-                  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
-                  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
-                  offset_t (*seek)(void *opaque, offset_t offset, int whence));
-
-void put_byte(ByteIOContext *s, int b);
-void put_buffer(ByteIOContext *s, const unsigned char *buf, int size);
-void put_le64(ByteIOContext *s, uint64_t val);
-void put_be64(ByteIOContext *s, uint64_t val);
-void put_le32(ByteIOContext *s, unsigned int val);
-void put_be32(ByteIOContext *s, unsigned int val);
-void put_be24(ByteIOContext *s, unsigned int val);
-void put_le16(ByteIOContext *s, unsigned int val);
-void put_be16(ByteIOContext *s, unsigned int val);
-void put_tag(ByteIOContext *s, const char *tag);
-
-void put_strz(ByteIOContext *s, const char *buf);
-
-offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence);
-void url_fskip(ByteIOContext *s, offset_t offset);
-offset_t url_ftell(ByteIOContext *s);
-offset_t url_fsize(ByteIOContext *s);
-int url_feof(ByteIOContext *s);
-int url_ferror(ByteIOContext *s);
-
-#define URL_EOF (-1)
-int url_fgetc(ByteIOContext *s);
-#ifdef __GNUC__
-int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
-#else
-int url_fprintf(ByteIOContext *s, const char *fmt, ...);
-#endif
-char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
-
-void put_flush_packet(ByteIOContext *s);
-
-int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
-int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size);
-int get_byte(ByteIOContext *s);
-unsigned int get_le32(ByteIOContext *s);
-uint64_t get_le64(ByteIOContext *s);
-unsigned int get_le16(ByteIOContext *s);
-
-char *get_strz(ByteIOContext *s, char *buf, int maxlen);
-unsigned int get_be16(ByteIOContext *s);
-unsigned int get_be24(ByteIOContext *s);
-unsigned int get_be32(ByteIOContext *s);
-uint64_t get_be64(ByteIOContext *s);
-
-static inline int url_is_streamed(ByteIOContext *s)
-{
-    return s->is_streamed;
-}
-
-int url_fdopen(ByteIOContext *s, URLContext *h);
-int url_setbufsize(ByteIOContext *s, int buf_size);
-int url_fopen(ByteIOContext *s, const char *filename, int flags);
-int url_fclose(ByteIOContext *s);
-URLContext *url_fileno(ByteIOContext *s);
-int url_fget_max_packet_size(ByteIOContext *s);
-
-int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags);
-int url_close_buf(ByteIOContext *s);
-
-int url_open_dyn_buf(ByteIOContext *s);
-int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size);
-int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer);
-
-unsigned long get_checksum(ByteIOContext *s);
-void init_checksum(ByteIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum);
-unsigned long update_adler32(unsigned long adler, const uint8_t *buf, unsigned int len);
-
-/* file.c */
-extern URLProtocol file_protocol;
-extern URLProtocol pipe_protocol;
-
-/* udp.c */
-extern URLProtocol udp_protocol;
-int udp_set_remote_url(URLContext *h, const char *uri);
-int udp_get_local_port(URLContext *h);
-int udp_get_file_handle(URLContext *h);
-
-/* tcp.c  */
-extern URLProtocol tcp_protocol;
-
-/* http.c */
-extern URLProtocol http_protocol;
-
-#endif
-
diff --git a/ffmpeg.src/libavformat/aviobuf.c b/ffmpeg.src/libavformat/aviobuf.c
deleted file mode 100644
index f6f65c1..0000000
--- a/ffmpeg.src/libavformat/aviobuf.c
+++ /dev/null
@@ -1,782 +0,0 @@
-/*
- * Buffered I/O for ffmpeg system
- * Copyright (c) 2000,2001 Fabrice Bellard
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avformat.h"
-#include "avio.h"
-#include <stdarg.h>
-
-#define IO_BUFFER_SIZE 32768
-
-int init_put_byte(ByteIOContext *s,
-                  unsigned char *buffer,
-                  int buffer_size,
-                  int write_flag,
-                  void *opaque,
-                  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
-                  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
-                  offset_t (*seek)(void *opaque, offset_t offset, int whence))
-{
-    s->buffer = buffer;
-    s->buffer_size = buffer_size;
-    s->buf_ptr = buffer;
-    s->write_flag = write_flag;
-    if (!s->write_flag) 
-        s->buf_end = buffer;
-    else
-        s->buf_end = buffer + buffer_size;
-    s->opaque = opaque;
-    s->write_packet = write_packet;
-    s->read_packet = read_packet;
-    s->seek = seek;
-    s->pos = 0;
-    s->must_flush = 0;
-    s->eof_reached = 0;
-    s->error = 0;
-    s->is_streamed = 0;
-    s->max_packet_size = 0;
-    s->update_checksum= NULL;
-    return 0;
-}
-                  
-
-#ifdef CONFIG_ENCODERS
-static void flush_buffer(ByteIOContext *s)
-{
-    if (s->buf_ptr > s->buffer) {
-        if (s->write_packet && !s->error){
-            int ret= s->write_packet(s->opaque, s->buffer, s->buf_ptr - s->buffer);
-            if(ret < 0){
-                s->error = ret;
-            }
-        }
-        if(s->update_checksum){
-            s->checksum= s->update_checksum(s->checksum, s->checksum_ptr, s->buf_ptr - s->checksum_ptr);
-            s->checksum_ptr= s->buffer;
-        }
-        s->pos += s->buf_ptr - s->buffer;
-    }
-    s->buf_ptr = s->buffer;
-}
-
-void put_byte(ByteIOContext *s, int b)
-{
-    *(s->buf_ptr)++ = b;
-    if (s->buf_ptr >= s->buf_end) 
-        flush_buffer(s);
-}
-
-void put_buffer(ByteIOContext *s, const unsigned char *buf, int size)
-{
-    int len;
-
-    while (size > 0) {
-        len = (s->buf_end - s->buf_ptr);
-        if (len > size)
-            len = size;
-        memcpy(s->buf_ptr, buf, len);
-        s->buf_ptr += len;
-
-        if (s->buf_ptr >= s->buf_end) 
-            flush_buffer(s);
-
-        buf += len;
-        size -= len;
-    }
-}
-
-void put_flush_packet(ByteIOContext *s)
-{
-    flush_buffer(s);
-    s->must_flush = 0;
-}
-#endif //CONFIG_ENCODERS
-
-offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence)
-{
-    offset_t offset1;
-
-    if (whence != SEEK_CUR && whence != SEEK_SET)
-        return -EINVAL;
-    
-#ifdef CONFIG_ENCODERS
-    if (s->write_flag) {
-        if (whence == SEEK_CUR) {
-            offset1 = s->pos + (s->buf_ptr - s->buffer);
-            if (offset == 0)
-                return offset1;
-            offset += offset1;
-        }
-        offset1 = offset - s->pos;
-        if (!s->must_flush && 
-            offset1 >= 0 && offset1 < (s->buf_end - s->buffer)) {
-            /* can do the seek inside the buffer */
-            s->buf_ptr = s->buffer + offset1;
-        } else {
-            if (!s->seek)
-                return -EPIPE;
-            flush_buffer(s);
-            s->must_flush = 1;
-            s->buf_ptr = s->buffer;
-            s->seek(s->opaque, offset, SEEK_SET);
-            s->pos = offset;
-        }
-    } else 
-#endif //CONFIG_ENCODERS
-    {
-        if (whence == SEEK_CUR) {
-            offset1 = s->pos - (s->buf_end - s->buffer) + (s->buf_ptr - s->buffer);
-            if (offset == 0)
-                return offset1;
-            offset += offset1;
-        }
-        offset1 = offset - (s->pos - (s->buf_end - s->buffer));
-        if (offset1 >= 0 && offset1 <= (s->buf_end - s->buffer)) {
-            /* can do the seek inside the buffer */
-            s->buf_ptr = s->buffer + offset1;
-        } else {
-            if (!s->seek)
-                return -EPIPE;
-            s->buf_ptr = s->buffer;
-            s->buf_end = s->buffer;
-            if (s->seek(s->opaque, offset, SEEK_SET) == (offset_t)-EPIPE)
-                return -EPIPE;
-            s->pos = offset;
-        }
-        s->eof_reached = 0;
-    }
-    return offset;
-}
-
-void url_fskip(ByteIOContext *s, offset_t offset)
-{
-    url_fseek(s, offset, SEEK_CUR);
-}
-
-offset_t url_ftell(ByteIOContext *s)
-{
-    return url_fseek(s, 0, SEEK_CUR);
-}
-
-offset_t url_fsize(ByteIOContext *s)
-{
-    offset_t size;
-    
-    if (!s->seek)
-        return -EPIPE;
-    size = s->seek(s->opaque, -1, SEEK_END) + 1;
-    s->seek(s->opaque, s->pos, SEEK_SET);
-    return size;
-}
-
-int url_feof(ByteIOContext *s)
-{
-    return s->eof_reached;
-}
-
-int url_ferror(ByteIOContext *s)
-{
-    return s->error;
-}
-
-#ifdef CONFIG_ENCODERS
-void put_le32(ByteIOContext *s, unsigned int val)
-{
-    put_byte(s, val);
-    put_byte(s, val >> 8);
-    put_byte(s, val >> 16);
-    put_byte(s, val >> 24);
-}
-
-void put_be32(ByteIOContext *s, unsigned int val)
-{
-    put_byte(s, val >> 24);
-    put_byte(s, val >> 16);
-    put_byte(s, val >> 8);
-    put_byte(s, val);
-}
-
-void put_strz(ByteIOContext *s, const char *str)
-{
-    if (str)
-        put_buffer(s, (const unsigned char *) str, strlen(str) + 1);
-    else
-        put_byte(s, 0);
-}
-
-void put_le64(ByteIOContext *s, uint64_t val)
-{
-    put_le32(s, (uint32_t)(val & 0xffffffff));
-    put_le32(s, (uint32_t)(val >> 32));
-}
-
-void put_be64(ByteIOContext *s, uint64_t val)
-{
-    put_be32(s, (uint32_t)(val >> 32));
-    put_be32(s, (uint32_t)(val & 0xffffffff));
-}
-
-void put_le16(ByteIOContext *s, unsigned int val)
-{
-    put_byte(s, val);
-    put_byte(s, val >> 8);
-}
-
-void put_be16(ByteIOContext *s, unsigned int val)
-{
-    put_byte(s, val >> 8);
-    put_byte(s, val);
-}
-
-void put_be24(ByteIOContext *s, unsigned int val)
-{
-    put_be16(s, val >> 8);
-    put_byte(s, val);
-}
-
-void put_tag(ByteIOContext *s, const char *tag)
-{
-    while (*tag) {
-        put_byte(s, *tag++);
-    }
-}
-#endif //CONFIG_ENCODERS
-
-/* Input stream */
-
-static void fill_buffer(ByteIOContext *s)
-{
-    int len;
-
-    /* no need to do anything if EOF already reached */
-    if (s->eof_reached)
-        return;
-
-    if(s->update_checksum){
-        if(s->buf_end > s->checksum_ptr)
-            s->checksum= s->update_checksum(s->checksum, s->checksum_ptr, s->buf_end - s->checksum_ptr);
-        s->checksum_ptr= s->buffer;
-    }
-
-    len = s->read_packet(s->opaque, s->buffer, s->buffer_size);
-    if (len <= 0) {
-        /* do not modify buffer if EOF reached so that a seek back can
-           be done without rereading data */
-        s->eof_reached = 1;
-    if(len<0)
-        s->error= len;
-    } else {
-        s->pos += len;
-        s->buf_ptr = s->buffer;
-        s->buf_end = s->buffer + len;
-    }
-}
-
-unsigned long get_checksum(ByteIOContext *s){
-    s->checksum= s->update_checksum(s->checksum, s->checksum_ptr, s->buf_ptr - s->checksum_ptr);
-    s->update_checksum= NULL;
-    return s->checksum;
-}
-
-void init_checksum(ByteIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum){
-    s->update_checksum= update_checksum;
-    if(s->update_checksum){
-        s->checksum= s->update_checksum(checksum, NULL, 0);
-        s->checksum_ptr= s->buf_ptr;
-    }
-}
-
-/* NOTE: return 0 if EOF, so you cannot use it if EOF handling is
-   necessary */
-/* XXX: put an inline version */
-int get_byte(ByteIOContext *s)
-{
-    if (s->buf_ptr < s->buf_end) {
-        return *s->buf_ptr++;
-    } else {
-        fill_buffer(s);
-        if (s->buf_ptr < s->buf_end)
-            return *s->buf_ptr++;
-        else
-            return 0;
-    }
-}
-
-/* NOTE: return URL_EOF (-1) if EOF */
-int url_fgetc(ByteIOContext *s)
-{
-    if (s->buf_ptr < s->buf_end) {
-        return *s->buf_ptr++;
-    } else {
-        fill_buffer(s);
-        if (s->buf_ptr < s->buf_end)
-            return *s->buf_ptr++;
-        else
-            return URL_EOF;
-    }
-}
-
-int get_buffer(ByteIOContext *s, unsigned char *buf, int size)
-{
-    int len, size1;
-
-    size1 = size;
-    while (size > 0) {
-        len = s->buf_end - s->buf_ptr;
-        if (len > size)
-            len = size;
-        if (len == 0) {
-            if(size > s->buffer_size && !s->update_checksum){
-                len = s->read_packet(s->opaque, buf, size);
-                if (len <= 0) {
-                    /* do not modify buffer if EOF reached so that a seek back can
-                    be done without rereading data */
-                    s->eof_reached = 1;
-                    if(len<0)
-                        s->error= len;
-                    break;
-                } else {
-                    s->pos += len;
-                    size -= len;
-                    buf += len;
-                    s->buf_ptr = s->buffer;
-                    s->buf_end = s->buffer/* + len*/;
-                }
-            }else{
-                fill_buffer(s);
-                len = s->buf_end - s->buf_ptr;
-                if (len == 0)
-                    break;
-            }
-        } else {
-            memcpy(buf, s->buf_ptr, len);
-            buf += len;
-            s->buf_ptr += len;
-            size -= len;
-        }
-    }
-    return size1 - size;
-}
-
-int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size)
-{
-    int len;
-    
-    if(size<0)
-        return -1;
-
-    len = s->buf_end - s->buf_ptr;
-    if (len == 0) {
-        fill_buffer(s);
-        len = s->buf_end - s->buf_ptr;
-    }
-    if (len > size)
-        len = size;
-    memcpy(buf, s->buf_ptr, len);
-    s->buf_ptr += len;
-    return len;
-}
-
-unsigned int get_le16(ByteIOContext *s)
-{
-    unsigned int val;
-    val = get_byte(s);
-    val |= get_byte(s) << 8;
-    return val;
-}
-
-unsigned int get_le32(ByteIOContext *s)
-{
-    unsigned int val;
-    val = get_le16(s);
-    val |= get_le16(s) << 16;
-    return val;
-}
-
-uint64_t get_le64(ByteIOContext *s)
-{
-    uint64_t val;
-    val = (uint64_t)get_le32(s);
-    val |= (uint64_t)get_le32(s) << 32;
-    return val;
-}
-
-unsigned int get_be16(ByteIOContext *s)
-{
-    unsigned int val;
-    val = get_byte(s) << 8;
-    val |= get_byte(s);
-    return val;
-}
-
-unsigned int get_be24(ByteIOContext *s)
-{
-    unsigned int val;
-    val = get_be16(s) << 8;
-    val |= get_byte(s);
-    return val;
-}
-unsigned int get_be32(ByteIOContext *s)
-{
-    unsigned int val;
-    val = get_be16(s) << 16;
-    val |= get_be16(s);
-    return val;
-}
-
-char *get_strz(ByteIOContext *s, char *buf, int maxlen)
-{
-    int i = 0;
-    char c;
-
-    while ((c = get_byte(s))) {
-        if (i < maxlen-1)
-            buf[i++] = c;
-    }
-    
-    buf[i] = 0; /* Ensure null terminated, but may be truncated */
-
-    return buf;
-}
-
-uint64_t get_be64(ByteIOContext *s)
-{
-    uint64_t val;
-    val = (uint64_t)get_be32(s) << 32;
-    val |= (uint64_t)get_be32(s);
-    return val;
-}
-
-/* link with avio functions */
-
-#ifdef CONFIG_ENCODERS
-static int url_write_packet(void *opaque, uint8_t *buf, int buf_size)
-{
-    URLContext *h = opaque;
-    return url_write(h, buf, buf_size);
-}
-#else
-#define	url_write_packet NULL
-#endif //CONFIG_ENCODERS
-
-static int url_read_packet(void *opaque, uint8_t *buf, int buf_size)
-{
-    URLContext *h = opaque;
-    return url_read(h, buf, buf_size);
-}
-
-static offset_t url_seek_packet(void *opaque, offset_t offset, int whence)
-{
-    URLContext *h = opaque;
-    return url_seek(h, offset, whence);
-    //return 0;
-}
-
-int url_fdopen(ByteIOContext *s, URLContext *h)
-{
-    uint8_t *buffer;
-    int buffer_size, max_packet_size;
-
-    
-    max_packet_size = url_get_max_packet_size(h);
-    if (max_packet_size) {
-        buffer_size = max_packet_size; /* no need to bufferize more than one packet */
-    } else {
-        buffer_size = IO_BUFFER_SIZE;
-    }
-    buffer = av_malloc(buffer_size);
-    if (!buffer)
-        return -ENOMEM;
-
-    if (init_put_byte(s, buffer, buffer_size, 
-                      (h->flags & URL_WRONLY || h->flags & URL_RDWR), h,
-                      url_read_packet, url_write_packet, url_seek_packet) < 0) {
-        av_free(buffer);
-        return AVERROR_IO;
-    }
-    s->is_streamed = h->is_streamed;
-    s->max_packet_size = max_packet_size;
-    return 0;
-}
-
-/* XXX: must be called before any I/O */
-int url_setbufsize(ByteIOContext *s, int buf_size)
-{
-    uint8_t *buffer;
-    buffer = av_malloc(buf_size);
-    if (!buffer)
-        return -ENOMEM;
-
-    av_free(s->buffer);
-    s->buffer = buffer;
-    s->buffer_size = buf_size;
-    s->buf_ptr = buffer;
-    if (!s->write_flag) 
-        s->buf_end = buffer;
-    else
-        s->buf_end = buffer + buf_size;
-    return 0;
-}
-
-/* NOTE: when opened as read/write, the buffers are only used for
-   reading */
-int url_fopen(ByteIOContext *s, const char *filename, int flags)
-{
-    URLContext *h;
-    int err;
-
-    err = url_open(&h, filename, flags);
-    if (err < 0)
-        return err;
-    err = url_fdopen(s, h);
-    if (err < 0) {
-        url_close(h);
-        return err;
-    }
-    return 0;
-}
-
-int url_fclose(ByteIOContext *s)
-{
-    URLContext *h = s->opaque;
-    
-    av_free(s->buffer);
-    memset(s, 0, sizeof(ByteIOContext));
-    return url_close(h);
-}
-
-URLContext *url_fileno(ByteIOContext *s)
-{
-    return s->opaque;
-}
-
-#ifdef CONFIG_ENCODERS
-/* XXX: currently size is limited */
-int url_fprintf(ByteIOContext *s, const char *fmt, ...)
-{
-    va_list ap;
-    char buf[4096];
-    int ret;
-
-    va_start(ap, fmt);
-    ret = vsnprintf(buf, sizeof(buf), fmt, ap);
-    va_end(ap);
-    put_buffer(s, buf, strlen(buf));
-    return ret;
-}
-#endif //CONFIG_ENCODERS
-
-/* note: unlike fgets, the EOL character is not returned and a whole
-   line is parsed. return NULL if first char read was EOF */
-char *url_fgets(ByteIOContext *s, char *buf, int buf_size)
-{
-    int c;
-    char *q;
-
-    c = url_fgetc(s);
-    if (c == EOF)
-        return NULL;
-    q = buf;
-    for(;;) {
-        if (c == EOF || c == '\n')
-            break;
-        if ((q - buf) < buf_size - 1)
-            *q++ = c;
-        c = url_fgetc(s);
-    }
-    if (buf_size > 0)
-        *q = '\0';
-    return buf;
-}
-
-/* 
- * Return the maximum packet size associated to packetized buffered file
- * handle. If the file is not packetized (stream like http or file on
- * disk), then 0 is returned.
- * 
- * @param h buffered file handle
- * @return maximum packet size in bytes
- */
-int url_fget_max_packet_size(ByteIOContext *s)
-{
-    return s->max_packet_size;
-}
-
-#ifdef CONFIG_ENCODERS
-/* buffer handling */
-int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags)
-{
-    return init_put_byte(s, buf, buf_size, 
-                         (flags & URL_WRONLY || flags & URL_RDWR),
-                         NULL, NULL, NULL, NULL);
-}
-
-/* return the written or read size */
-int url_close_buf(ByteIOContext *s)
-{
-    put_flush_packet(s);
-    return s->buf_ptr - s->buffer;
-}
-
-/* output in a dynamic buffer */
-
-typedef struct DynBuffer {
-    int pos, size, allocated_size;
-    uint8_t *buffer;
-    int io_buffer_size;
-    uint8_t io_buffer[1];
-} DynBuffer;
-
-static int dyn_buf_write(void *opaque, uint8_t *buf, int buf_size)
-{
-    DynBuffer *d = opaque;
-    int new_size, new_allocated_size;
-    
-    /* reallocate buffer if needed */
-    new_size = d->pos + buf_size;
-    new_allocated_size = d->allocated_size;
-    if(new_size < d->pos || new_size > INT_MAX/2)
-        return -1;
-    while (new_size > new_allocated_size) {
-        if (!new_allocated_size)
-            new_allocated_size = new_size;
-        else
-            new_allocated_size += new_allocated_size / 2 + 1;    
-    }
-    
-    if (new_allocated_size > d->allocated_size) {
-        d->buffer = av_realloc(d->buffer, new_allocated_size);
-        if(d->buffer == NULL)
-             return -1234;
-        d->allocated_size = new_allocated_size;
-    }
-    memcpy(d->buffer + d->pos, buf, buf_size);
-    d->pos = new_size;
-    if (d->pos > d->size)
-        d->size = d->pos;
-    return buf_size;
-}
-
-static int dyn_packet_buf_write(void *opaque, uint8_t *buf, int buf_size)
-{
-    unsigned char buf1[4];
-    int ret;
-
-    /* packetized write: output the header */
-    buf1[0] = (buf_size >> 24);
-    buf1[1] = (buf_size >> 16);
-    buf1[2] = (buf_size >> 8);
-    buf1[3] = (buf_size);
-    ret= dyn_buf_write(opaque, buf1, 4);
-    if(ret < 0)
-        return ret;
-
-    /* then the data */
-    return dyn_buf_write(opaque, buf, buf_size);
-}
-
-static offset_t dyn_buf_seek(void *opaque, offset_t offset, int whence)
-{
-    DynBuffer *d = opaque;
-
-    if (whence == SEEK_CUR)
-        offset += d->pos;
-    else if (whence == SEEK_END)
-        offset += d->size;
-    if (offset < 0 || offset > 0x7fffffffLL)
-        return -1;
-    d->pos = offset;
-    return 0;
-}
-
-static int url_open_dyn_buf_internal(ByteIOContext *s, int max_packet_size)
-{
-    DynBuffer *d;
-    int io_buffer_size, ret;
-    
-    if (max_packet_size) 
-        io_buffer_size = max_packet_size;
-    else
-        io_buffer_size = 1024;
-        
-    if(sizeof(DynBuffer) + io_buffer_size < io_buffer_size)
-        return -1;
-    d = av_malloc(sizeof(DynBuffer) + io_buffer_size);
-    if (!d)
-        return -1;
-    d->io_buffer_size = io_buffer_size;
-    d->buffer = NULL;
-    d->pos = 0;
-    d->size = 0;
-    d->allocated_size = 0;
-    ret = init_put_byte(s, d->io_buffer, io_buffer_size, 
-                        1, d, NULL, 
-                        max_packet_size ? dyn_packet_buf_write : dyn_buf_write, 
-                        max_packet_size ? NULL : dyn_buf_seek);
-    if (ret == 0) {
-        s->max_packet_size = max_packet_size;
-    }
-    return ret;
-}
-
-/*
- * Open a write only memory stream.
- * 
- * @param s new IO context
- * @return zero if no error.
- */
-int url_open_dyn_buf(ByteIOContext *s)
-{
-    return url_open_dyn_buf_internal(s, 0);
-}
-
-/*
- * Open a write only packetized memory stream with a maximum packet
- * size of 'max_packet_size'.  The stream is stored in a memory buffer
- * with a big endian 4 byte header giving the packet size in bytes.
- * 
- * @param s new IO context
- * @param max_packet_size maximum packet size (must be > 0) 
- * @return zero if no error.
- */
-int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size)
-{
-    if (max_packet_size <= 0)
-        return -1;
-    return url_open_dyn_buf_internal(s, max_packet_size);
-}
-
-/* 
- * Return the written size and a pointer to the buffer. The buffer
- *  must be freed with av_free(). 
- * @param s IO context
- * @param pointer to a byte buffer
- * @return the length of the byte buffer
- */
-int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer)
-{
-    DynBuffer *d = s->opaque;
-    int size;
-
-    put_flush_packet(s);
-
-    *pbuffer = d->buffer;
-    size = d->size;
-    av_free(d);
-    return size;
-}
-#endif //CONFIG_ENCODERS
diff --git a/ffmpeg.src/libavformat/cutils.c b/ffmpeg.src/libavformat/cutils.c
deleted file mode 100644
index 1415e4e..0000000
--- a/ffmpeg.src/libavformat/cutils.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Various simple utilities for ffmpeg system
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avformat.h"
-
-#if !defined(CONFIG_NOCUTILS)
-/**
- * Return TRUE if val is a prefix of str. If it returns TRUE, ptr is
- * set to the next character in 'str' after the prefix.
- *
- * @param str input string
- * @param val prefix to test
- * @param ptr updated after the prefix in str in there is a match
- * @return TRUE if there is a match
- */
-int strstart(const char *str, const char *val, const char **ptr)
-{
-    const char *p, *q;
-    p = str;
-    q = val;
-    while (*q != '\0') {
-        if (*p != *q)
-            return 0;
-        p++;
-        q++;
-    }
-    if (ptr)
-        *ptr = p;
-    return 1;
-}
-
-/**
- * Return TRUE if val is a prefix of str (case independent). If it
- * returns TRUE, ptr is set to the next character in 'str' after the
- * prefix.
- *
- * @param str input string
- * @param val prefix to test
- * @param ptr updated after the prefix in str in there is a match
- * @return TRUE if there is a match */
-int stristart(const char *str, const char *val, const char **ptr)
-{
-    const char *p, *q;
-    p = str;
-    q = val;
-    while (*q != '\0') {
-	if (toupper(*(const unsigned char *)p) != toupper(*(const unsigned char *)q))
-            return 0;
-        p++;
-        q++;
-    }
-    if (ptr)
-        *ptr = p;
-    return 1;
-}
-
-/**
- * Copy the string str to buf. If str length is bigger than buf_size -
- * 1 then it is clamped to buf_size - 1.
- * NOTE: this function does what strncpy should have done to be
- * useful. NEVER use strncpy.
- * 
- * @param buf destination buffer
- * @param buf_size size of destination buffer
- * @param str source string
- */
-void pstrcpy(char *buf, int buf_size, const char *str)
-{
-    int c;
-    char *q = buf;
-
-    if (buf_size <= 0)
-        return;
-
-    for(;;) {
-        c = *str++;
-        if (c == 0 || q >= buf + buf_size - 1)
-            break;
-        *q++ = c;
-    }
-    *q = '\0';
-}
-
-/* strcat and truncate. */
-char *pstrcat(char *buf, int buf_size, const char *s)
-{
-    int len;
-    len = strlen(buf);
-    if (len < buf_size) 
-        pstrcpy(buf + len, buf_size - len, s);
-    return buf;
-}
-
-#endif
-
-/* add one element to a dynamic array */
-void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem)
-{
-    int nb, nb_alloc;
-    unsigned long *tab;
-
-    nb = *nb_ptr;
-    tab = *tab_ptr;
-    if ((nb & (nb - 1)) == 0) {
-        if (nb == 0)
-            nb_alloc = 1;
-        else
-            nb_alloc = nb * 2;
-        tab = av_realloc(tab, nb_alloc * sizeof(unsigned long));
-        *tab_ptr = tab;
-    }
-    tab[nb++] = elem;
-    *nb_ptr = nb;
-}
-
-time_t mktimegm(struct tm *tm)
-{
-    time_t t;
-
-    int y = tm->tm_year + 1900, m = tm->tm_mon + 1, d = tm->tm_mday;
-
-    if (m < 3) {
-        m += 12;
-        y--;
-    }
-
-    t = 86400 * 
-        (d + (153 * m - 457) / 5 + 365 * y + y / 4 - y / 100 + y / 400 - 719469);
-
-    t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec;
-
-    return t;
-}
-
-#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 *brktimegm(time_t secs, struct tm *tm)
-{   
-    int days, y, ny, m;
-    int md[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
-
-    days = secs / 86400;
-    secs %= 86400;
-    tm->tm_hour = secs / 3600;
-    tm->tm_min = (secs % 3600) / 60;
-    tm->tm_sec =  secs % 60;
-
-    /* oh well, may be someone some day will invent a formula for this stuff */
-    y = 1970; /* start "guessing" */
-    while (days >= (ISLEAP(y)?366:365)) {
-	ny = (y + days/366);
-	days -= (ny - y) * 365 + LEAPS_COUNT(ny - 1) - LEAPS_COUNT(y - 1);
-	y = ny;
-    }
-    md[1] = ISLEAP(y)?29:28;
-    for (m=0; days >= md[m]; m++)
-	 days -= md[m];
-
-    tm->tm_year = y;  /* unlike gmtime_r we store complete year here */
-    tm->tm_mon = m+1; /* unlike gmtime_r tm_mon is from 1 to 12 */
-    tm->tm_mday = days+1;
-
-    return tm;
-}
-
-/* get a positive number between n_min and n_max, for a maximum length
-   of len_max. Return -1 if error. */
-static int date_get_num(const char **pp,
-                        int n_min, int n_max, int len_max)
-{
-    int i, val, c;
-    const char *p;
-
-    p = *pp;
-    val = 0;
-    for(i = 0; i < len_max; i++) {
-        c = *p;
-        if (!isdigit(c))
-            break;
-        val = (val * 10) + c - '0';
-        p++;
-    }
-    /* no number read ? */
-    if (p == *pp)
-        return -1;
-    if (val < n_min || val > n_max)
-        return -1;
-    *pp = p;
-    return val;
-}
-
-/* small strptime for ffmpeg */
-const char *small_strptime(const char *p, const char *fmt, 
-                           struct tm *dt)
-{
-    int c, val;
-
-    for(;;) {
-        c = *fmt++;
-        if (c == '\0') {
-            return p;
-        } else if (c == '%') {
-            c = *fmt++;
-            switch(c) {
-            case 'H':
-                val = date_get_num(&p, 0, 23, 2);
-                if (val == -1)
-                    return NULL;
-                dt->tm_hour = val;
-                break;
-            case 'M':
-                val = date_get_num(&p, 0, 59, 2);
-                if (val == -1)
-                    return NULL;
-                dt->tm_min = val;
-                break;
-            case 'S':
-                val = date_get_num(&p, 0, 59, 2);
-                if (val == -1)
-                    return NULL;
-                dt->tm_sec = val;
-                break;
-            case 'Y':
-                val = date_get_num(&p, 0, 9999, 4);
-                if (val == -1)
-                    return NULL;
-                dt->tm_year = val - 1900;
-                break;
-            case 'm':
-                val = date_get_num(&p, 1, 12, 2);
-                if (val == -1)
-                    return NULL;
-                dt->tm_mon = val - 1;
-                break;
-            case 'd':
-                val = date_get_num(&p, 1, 31, 2);
-                if (val == -1)
-                    return NULL;
-                dt->tm_mday = val;
-                break;
-            case '%':
-                goto match;
-            default:
-                return NULL;
-            }
-        } else {
-        match:
-            if (c != *p)
-                return NULL;
-            p++;
-        }
-    }
-    return p;
-}
-
diff --git a/ffmpeg.src/libavformat/file.c b/ffmpeg.src/libavformat/file.c
deleted file mode 100644
index fc75ee0..0000000
--- a/ffmpeg.src/libavformat/file.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Buffered file io for ffmpeg system
- * Copyright (c) 2001 Fabrice Bellard
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avformat.h"
-#include <fcntl.h>
-#ifndef CONFIG_WIN32
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#else
-#include <io.h>
-#define open(fname,oflag,pmode) _open(fname,oflag,pmode)
-#endif /* CONFIG_WIN32 */
-
-
-/* standard file protocol */
-
-static int file_open(URLContext *h, const char *filename, int flags)
-{
-    int access;
-    int fd;
-
-    strstart(filename, "file:", &filename);
-
-    if (flags & URL_RDWR) {
-        access = O_CREAT | O_TRUNC | O_RDWR;
-    } else if (flags & URL_WRONLY) {
-        access = O_CREAT | O_TRUNC | O_WRONLY;
-    } else {
-        access = O_RDONLY;
-    }
-#if defined(CONFIG_WIN32) || defined(CONFIG_OS2) || defined(__CYGWIN__)
-    access |= O_BINARY;
-#endif
-    fd = open(filename, access, 0666);
-    if (fd < 0)
-        return -ENOENT;
-    h->priv_data = (void *)(size_t)fd;
-    return 0;
-}
-
-static int file_read(URLContext *h, unsigned char *buf, int size)
-{
-    int fd = (size_t)h->priv_data;
-    return read(fd, buf, size);
-}
-
-static int file_write(URLContext *h, unsigned char *buf, int size)
-{
-    int fd = (size_t)h->priv_data;
-    return write(fd, buf, size);
-}
-
-/* XXX: use llseek */
-static offset_t file_seek(URLContext *h, offset_t pos, int whence)
-{
-    int fd = (size_t)h->priv_data;
-#if defined(CONFIG_WIN32) && !defined(__CYGWIN__) 
-    return _lseeki64(fd, pos, whence);
-#else
-    return lseek(fd, pos, whence);
-#endif
-}
-
-static int file_close(URLContext *h)
-{
-    int fd = (size_t)h->priv_data;
-    return close(fd);
-}
-
-URLProtocol file_protocol = {
-    "file",
-    file_open,
-    file_read,
-    file_write,
-    file_seek,
-    file_close,
-};
-
-/* pipe protocol */
-
-static int pipe_open(URLContext *h, const char *filename, int flags)
-{
-    int fd;
-
-    if (flags & URL_WRONLY) {
-        fd = 1;
-    } else {
-        fd = 0;
-    }
-#if defined(CONFIG_WIN32) || defined(CONFIG_OS2) || defined(__CYGWIN__)
-    setmode(fd, O_BINARY);
-#endif
-    h->priv_data = (void *)(size_t)fd;
-    h->is_streamed = 1;
-    return 0;
-}
-
-static int pipe_read(URLContext *h, unsigned char *buf, int size)
-{
-    int fd = (size_t)h->priv_data;
-    return read(fd, buf, size);
-}
-
-static int pipe_write(URLContext *h, unsigned char *buf, int size)
-{
-    int fd = (size_t)h->priv_data;
-    return write(fd, buf, size);
-}
-
-static int pipe_close(URLContext *h)
-{
-    return 0;
-}
-
-URLProtocol pipe_protocol = {
-    "pipe",
-    pipe_open,
-    pipe_read,
-    pipe_write,
-    NULL,
-    pipe_close,
-};
diff --git a/ffmpeg.src/libavformat/mpeg.c b/ffmpeg.src/libavformat/mpeg.c
deleted file mode 100644
index a597495..0000000
--- a/ffmpeg.src/libavformat/mpeg.c
+++ /dev/null
@@ -1,1804 +0,0 @@
-/*
- * MPEG1/2 mux/demux
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avformat.h"
-#include "bitstream.h"
-
-#define MAX_PAYLOAD_SIZE 4096
-//#define DEBUG_SEEK
-
-#undef NDEBUG
-#include <assert.h>
-
-typedef struct PacketDesc {
-    int64_t pts;
-    int64_t dts;
-    int size;
-    int unwritten_size;
-    int flags;
-    struct PacketDesc *next;
-} PacketDesc;
-
-typedef struct {
-    FifoBuffer fifo;
-    uint8_t id;
-    int max_buffer_size; /* in bytes */
-    int buffer_index;
-    PacketDesc *predecode_packet;
-    PacketDesc *premux_packet;
-    PacketDesc **next_packet;
-    int packet_number;
-    uint8_t lpcm_header[3];
-    int lpcm_align;
-    uint8_t *fifo_iframe_ptr;
-    int align_iframe;
-    int64_t vobu_start_pts;
-} StreamInfo;
-
-typedef struct {
-    int packet_size; /* required packet size */
-    int packet_number;
-    int pack_header_freq;     /* frequency (in packets^-1) at which we send pack headers */
-    int system_header_freq;
-    int system_header_size;
-    int mux_rate; /* bitrate in units of 50 bytes/s */
-    /* stream info */
-    int audio_bound;
-    int video_bound;
-    int is_mpeg2;
-    int is_vcd;
-    int is_svcd;
-    int is_dvd;
-    int64_t last_scr; /* current system clock */
-
-    double vcd_padding_bitrate; //FIXME floats
-    int64_t vcd_padding_bytes_written;
-
-} MpegMuxContext;
-
-#define PACK_START_CODE             ((unsigned int)0x000001ba)
-#define SYSTEM_HEADER_START_CODE    ((unsigned int)0x000001bb)
-#define SEQUENCE_END_CODE           ((unsigned int)0x000001b7)
-#define PACKET_START_CODE_MASK      ((unsigned int)0xffffff00)
-#define PACKET_START_CODE_PREFIX    ((unsigned int)0x00000100)
-#define ISO_11172_END_CODE          ((unsigned int)0x000001b9)
-  
-/* mpeg2 */
-#define PROGRAM_STREAM_MAP 0x1bc
-#define PRIVATE_STREAM_1   0x1bd
-#define PADDING_STREAM     0x1be
-#define PRIVATE_STREAM_2   0x1bf
-
-
-#define AUDIO_ID 0xc0
-#define VIDEO_ID 0xe0
-#define AC3_ID   0x80
-#define DTS_ID   0x8a
-#define LPCM_ID  0xa0
-#define SUB_ID   0x20
-
-#define STREAM_TYPE_VIDEO_MPEG1     0x01
-#define STREAM_TYPE_VIDEO_MPEG2     0x02
-#define STREAM_TYPE_AUDIO_MPEG1     0x03
-#define STREAM_TYPE_AUDIO_MPEG2     0x04
-#define STREAM_TYPE_PRIVATE_SECTION 0x05
-#define STREAM_TYPE_PRIVATE_DATA    0x06
-#define STREAM_TYPE_AUDIO_AAC       0x0f
-#define STREAM_TYPE_VIDEO_MPEG4     0x10
-#define STREAM_TYPE_VIDEO_H264      0x1b
-
-#define STREAM_TYPE_AUDIO_AC3       0x81
-#define STREAM_TYPE_AUDIO_DTS       0x8a
-
-static const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 };
-
-#ifdef CONFIG_ENCODERS
-static AVOutputFormat mpeg1system_mux;
-static AVOutputFormat mpeg1vcd_mux;
-static AVOutputFormat mpeg2vob_mux;
-static AVOutputFormat mpeg2svcd_mux;
-static AVOutputFormat mpeg2dvd_mux;
-
-static int put_pack_header(AVFormatContext *ctx, 
-                           uint8_t *buf, int64_t timestamp)
-{
-    MpegMuxContext *s = ctx->priv_data;
-    PutBitContext pb;
-    
-    init_put_bits(&pb, buf, 128);
-
-    put_bits(&pb, 32, PACK_START_CODE);
-    if (s->is_mpeg2) {
-        put_bits(&pb, 2, 0x1);
-    } else {
-        put_bits(&pb, 4, 0x2);
-    }
-    put_bits(&pb, 3, (uint32_t)((timestamp >> 30) & 0x07));
-    put_bits(&pb, 1, 1);
-    put_bits(&pb, 15, (uint32_t)((timestamp >> 15) & 0x7fff));
-    put_bits(&pb, 1, 1);
-    put_bits(&pb, 15, (uint32_t)((timestamp) & 0x7fff));
-    put_bits(&pb, 1, 1);
-    if (s->is_mpeg2) {
-        /* clock extension */
-        put_bits(&pb, 9, 0);
-    }
-    put_bits(&pb, 1, 1);
-    put_bits(&pb, 22, s->mux_rate);
-    put_bits(&pb, 1, 1);
-    if (s->is_mpeg2) {
-        put_bits(&pb, 1, 1);
-        put_bits(&pb, 5, 0x1f); /* reserved */
-        put_bits(&pb, 3, 0); /* stuffing length */
-    }
-    flush_put_bits(&pb);
-    return pbBufPtr(&pb) - pb.buf;
-}
-
-static int put_system_header(AVFormatContext *ctx, uint8_t *buf,int only_for_stream_id)
-{
-    MpegMuxContext *s = ctx->priv_data;
-    int size, i, private_stream_coded, id;
-    PutBitContext pb;
-
-    init_put_bits(&pb, buf, 128);
-
-    put_bits(&pb, 32, SYSTEM_HEADER_START_CODE);
-    put_bits(&pb, 16, 0);
-    put_bits(&pb, 1, 1);
-    
-    put_bits(&pb, 22, s->mux_rate); /* maximum bit rate of the multiplexed stream */
-    put_bits(&pb, 1, 1); /* marker */
-    if (s->is_vcd && only_for_stream_id==VIDEO_ID) {
-        /* This header applies only to the video stream (see VCD standard p. IV-7)*/
-        put_bits(&pb, 6, 0);
-    } else
-        put_bits(&pb, 6, s->audio_bound);
-
-    if (s->is_vcd) {
-        /* see VCD standard, p. IV-7*/
-        put_bits(&pb, 1, 0); 
-        put_bits(&pb, 1, 1);
-    } else {
-        put_bits(&pb, 1, 0); /* variable bitrate*/
-        put_bits(&pb, 1, 0); /* non constrainted bit stream */
-    }
-    
-    if (s->is_vcd || s->is_dvd) {
-        /* see VCD standard p IV-7 */
-        put_bits(&pb, 1, 1); /* audio locked */
-        put_bits(&pb, 1, 1); /* video locked */
-    } else {
-        put_bits(&pb, 1, 0); /* audio locked */
-        put_bits(&pb, 1, 0); /* video locked */
-    }
-
-    put_bits(&pb, 1, 1); /* marker */
-
-    if (s->is_vcd && only_for_stream_id==AUDIO_ID) {
-        /* This header applies only to the audio stream (see VCD standard p. IV-7)*/
-        put_bits(&pb, 5, 0);
-    } else
-        put_bits(&pb, 5, s->video_bound);
-    
-    if (s->is_dvd) {
-        put_bits(&pb, 1, 0);    /* packet_rate_restriction_flag */
-        put_bits(&pb, 7, 0x7f); /* reserved byte */
-    } else
-        put_bits(&pb, 8, 0xff); /* reserved byte */
-    
-    /* DVD-Video Stream_bound entries
-    id (0xB9) video, maximum P-STD for stream 0xE0. (P-STD_buffer_bound_scale = 1) 
-    id (0xB8) audio, maximum P-STD for any MPEG audio (0xC0 to 0xC7) streams. If there are none set to 4096 (32x128). (P-STD_buffer_bound_scale = 0) 
-    id (0xBD) private stream 1 (audio other than MPEG and subpictures). (P-STD_buffer_bound_scale = 1) 
-    id (0xBF) private stream 2, NAV packs, set to 2x1024. */
-    if (s->is_dvd) {
-        
-        int P_STD_max_video = 0;
-        int P_STD_max_mpeg_audio = 0;
-        int P_STD_max_mpeg_PS1 = 0;
-        
-        for(i=0;i<ctx->nb_streams;i++) {
-            StreamInfo *stream = ctx->streams[i]->priv_data;
-
-            id = stream->id;
-            if (id == 0xbd && stream->max_buffer_size > P_STD_max_mpeg_PS1) {
-                P_STD_max_mpeg_PS1 = stream->max_buffer_size;
-            } else if (id >= 0xc0 && id <= 0xc7 && stream->max_buffer_size > P_STD_max_mpeg_audio) {
-                P_STD_max_mpeg_audio = stream->max_buffer_size;
-            } else if (id == 0xe0 && stream->max_buffer_size > P_STD_max_video) {
-                P_STD_max_video = stream->max_buffer_size;
-            }
-        }
-
-        /* video */
-        put_bits(&pb, 8, 0xb9); /* stream ID */
-        put_bits(&pb, 2, 3);
-        put_bits(&pb, 1, 1);
-        put_bits(&pb, 13, P_STD_max_video / 1024);
-
-        /* audio */
-        if (P_STD_max_mpeg_audio == 0)
-            P_STD_max_mpeg_audio = 4096;
-        put_bits(&pb, 8, 0xb8); /* stream ID */
-        put_bits(&pb, 2, 3);
-        put_bits(&pb, 1, 0);
-        put_bits(&pb, 13, P_STD_max_mpeg_audio / 128);
-
-        /* private stream 1 */
-        put_bits(&pb, 8, 0xbd); /* stream ID */
-        put_bits(&pb, 2, 3);
-        put_bits(&pb, 1, 0);
-        put_bits(&pb, 13, P_STD_max_mpeg_PS1 / 128);
-
-        /* private stream 2 */
-        put_bits(&pb, 8, 0xbf); /* stream ID */
-        put_bits(&pb, 2, 3);
-        put_bits(&pb, 1, 1);
-        put_bits(&pb, 13, 2);
-    }
-    else {
-        /* audio stream info */
-        private_stream_coded = 0;
-        for(i=0;i<ctx->nb_streams;i++) {
-            StreamInfo *stream = ctx->streams[i]->priv_data;
-            
-
-            /* For VCDs, only include the stream info for the stream
-            that the pack which contains this system belongs to.
-            (see VCD standard p. IV-7) */
-            if ( !s->is_vcd || stream->id==only_for_stream_id
-                || only_for_stream_id==0) {
-
-                id = stream->id;
-                if (id < 0xc0) {
-                    /* special case for private streams (AC3 use that) */
-                    if (private_stream_coded)
-                        continue;
-                    private_stream_coded = 1;
-                    id = 0xbd;
-                }
-                put_bits(&pb, 8, id); /* stream ID */
-                put_bits(&pb, 2, 3);
-                if (id < 0xe0) {
-                    /* audio */
-                    put_bits(&pb, 1, 0);
-                    put_bits(&pb, 13, stream->max_buffer_size / 128);
-                } else {
-                    /* video */
-                    put_bits(&pb, 1, 1);
-                    put_bits(&pb, 13, stream->max_buffer_size / 1024);
-                }
-            }
-        }
-    }
-
-    flush_put_bits(&pb);
-    size = pbBufPtr(&pb) - pb.buf;
-    /* patch packet size */
-    buf[4] = (size - 6) >> 8;
-    buf[5] = (size - 6) & 0xff;
-
-    return size;
-}
-
-static int get_system_header_size(AVFormatContext *ctx)
-{
-    int buf_index, i, private_stream_coded;
-    StreamInfo *stream;
-    MpegMuxContext *s = ctx->priv_data;
-
-    if (s->is_dvd)
-       return 18; // DVD-Video system headers are 18 bytes fixed length.
-
-    buf_index = 12;
-    private_stream_coded = 0;
-    for(i=0;i<ctx->nb_streams;i++) {
-        stream = ctx->streams[i]->priv_data;
-        if (stream->id < 0xc0) {
-            if (private_stream_coded)
-                continue;
-            private_stream_coded = 1;
-        }
-        buf_index += 3;
-    }
-    return buf_index;
-}
-
-static int mpeg_mux_init(AVFormatContext *ctx)
-{
-    MpegMuxContext *s = ctx->priv_data;
-    int bitrate, i, mpa_id, mpv_id, mps_id, ac3_id, dts_id, lpcm_id, j;
-    AVStream *st;
-    StreamInfo *stream;
-    int audio_bitrate;
-    int video_bitrate;
-
-    s->packet_number = 0;
-    s->is_vcd = (ctx->oformat == &mpeg1vcd_mux);
-    s->is_svcd = (ctx->oformat == &mpeg2svcd_mux);
-    s->is_mpeg2 = (ctx->oformat == &mpeg2vob_mux || ctx->oformat == &mpeg2svcd_mux || ctx->oformat == &mpeg2dvd_mux);
-    s->is_dvd = (ctx->oformat == &mpeg2dvd_mux);
-    
-    if(ctx->packet_size)
-        s->packet_size = ctx->packet_size;
-    else
-        s->packet_size = 2048;
-       
-    s->vcd_padding_bytes_written = 0;
-    s->vcd_padding_bitrate=0;
-        
-    s->audio_bound = 0;
-    s->video_bound = 0;
-    mpa_id = AUDIO_ID;
-    ac3_id = AC3_ID;
-    dts_id = DTS_ID;
-    mpv_id = VIDEO_ID;
-    mps_id = SUB_ID;
-    lpcm_id = LPCM_ID;
-    for(i=0;i<ctx->nb_streams;i++) {
-        st = ctx->streams[i];
-        stream = av_mallocz(sizeof(StreamInfo));
-        if (!stream)
-            goto fail;
-        st->priv_data = stream;
-
-        av_set_pts_info(st, 64, 1, 90000);
-
-        switch(st->codec->codec_type) {
-        case CODEC_TYPE_AUDIO:
-            if (st->codec->codec_id == CODEC_ID_AC3) {
-                stream->id = ac3_id++;
-            } else if (st->codec->codec_id == CODEC_ID_DTS) {
-                stream->id = dts_id++;
-            } else if (st->codec->codec_id == CODEC_ID_PCM_S16BE) {
-                stream->id = lpcm_id++;
-                for(j = 0; j < 4; j++) {
-                    if (lpcm_freq_tab[j] == st->codec->sample_rate)
-                        break;
-                }
-                if (j == 4)
-                    goto fail;
-                if (st->codec->channels > 8)
-                    return -1;
-                stream->lpcm_header[0] = 0x0c;
-                stream->lpcm_header[1] = (st->codec->channels - 1) | (j << 4);
-                stream->lpcm_header[2] = 0x80;
-                stream->lpcm_align = st->codec->channels * 2;
-            } else {
-                stream->id = mpa_id++;
-            }
-
-            /* This value HAS to be used for VCD (see VCD standard, p. IV-7).
-               Right now it is also used for everything else.*/
-            stream->max_buffer_size = 4 * 1024; 
-            s->audio_bound++;
-            break;
-        case CODEC_TYPE_VIDEO:
-            stream->id = mpv_id++;
-            if (st->codec->rc_buffer_size)
-                stream->max_buffer_size = 6*1024 + st->codec->rc_buffer_size/8;
-            else
-                stream->max_buffer_size = 230*1024; //FIXME this is probably too small as default
-#if 0
-                /* see VCD standard, p. IV-7*/
-                stream->max_buffer_size = 46 * 1024; 
-            else
-                /* This value HAS to be used for SVCD (see SVCD standard, p. 26 V.2.3.2).
-                   Right now it is also used for everything else.*/
-                stream->max_buffer_size = 230 * 1024; 
-#endif
-            s->video_bound++;
-            break;
-        case CODEC_TYPE_SUBTITLE:
-            stream->id = mps_id++;
-            stream->max_buffer_size = 16 * 1024;
-            break;
-        default:
-            return -1;
-        }
-        fifo_init(&stream->fifo, 16);
-    }
-    bitrate = 0;
-    audio_bitrate = 0;
-    video_bitrate = 0;
-    for(i=0;i<ctx->nb_streams;i++) {
-        int codec_rate;
-        st = ctx->streams[i];
-        stream = (StreamInfo*) st->priv_data;
-
-        if(st->codec->rc_max_rate || stream->id==VIDEO_ID)
-            codec_rate= st->codec->rc_max_rate;
-        else
-            codec_rate= st->codec->bit_rate;
-                
-        if(!codec_rate)
-            codec_rate= (1<<21)*8*50/ctx->nb_streams;
-            
-        bitrate += codec_rate;
-
-        if (stream->id==AUDIO_ID)
-            audio_bitrate += codec_rate;
-        else if (stream->id==VIDEO_ID)
-            video_bitrate += codec_rate;
-    }
-    
-    if(ctx->mux_rate){
-        s->mux_rate= (ctx->mux_rate + (8 * 50) - 1) / (8 * 50);
-    } else {
-        /* we increase slightly the bitrate to take into account the
-           headers. XXX: compute it exactly */
-        bitrate += bitrate*5/100;
-        bitrate += 10000;
-        s->mux_rate = (bitrate + (8 * 50) - 1) / (8 * 50);
-    }
-
-    if (s->is_vcd) {
-        double overhead_rate;
-
-        /* The VCD standard mandates that the mux_rate field is 3528
-           (see standard p. IV-6).
-           The value is actually "wrong", i.e. if you calculate
-           it using the normal formula and the 75 sectors per second transfer
-           rate you get a different value because the real pack size is 2324,
-           not 2352. But the standard explicitly specifies that the mux_rate
-           field in the header must have this value.*/
-//        s->mux_rate=2352 * 75 / 50;    /* = 3528*/
-
-        /* The VCD standard states that the muxed stream must be
-           exactly 75 packs / second (the data rate of a single speed cdrom).
-           Since the video bitrate (probably 1150000 bits/sec) will be below
-           the theoretical maximum we have to add some padding packets
-           to make up for the lower data rate.
-           (cf. VCD standard p. IV-6 )*/
-
-        /* Add the header overhead to the data rate.
-           2279 data bytes per audio pack, 2294 data bytes per video pack*/
-        overhead_rate = ((audio_bitrate / 8.0) / 2279) * (2324 - 2279);
-        overhead_rate += ((video_bitrate / 8.0) / 2294) * (2324 - 2294);
-        overhead_rate *= 8;
-        
-        /* Add padding so that the full bitrate is 2324*75 bytes/sec */
-        s->vcd_padding_bitrate = 2324 * 75 * 8 - (bitrate + overhead_rate);
-    }
-    
-    if (s->is_vcd || s->is_mpeg2)
-        /* every packet */
-        s->pack_header_freq = 1;
-    else
-        /* every 2 seconds */
-        s->pack_header_freq = 2 * bitrate / s->packet_size / 8;
-
-    /* the above seems to make pack_header_freq zero sometimes */
-    if (s->pack_header_freq == 0)
-       s->pack_header_freq = 1;
-    
-    if (s->is_mpeg2)
-        /* every 200 packets. Need to look at the spec.  */
-        s->system_header_freq = s->pack_header_freq * 40;
-    else if (s->is_vcd)
-        /* the standard mandates that there are only two system headers
-           in the whole file: one in the first packet of each stream.
-           (see standard p. IV-7 and IV-8) */
-        s->system_header_freq = 0x7fffffff;
-    else
-        s->system_header_freq = s->pack_header_freq * 5;
-    
-    for(i=0;i<ctx->nb_streams;i++) {
-        stream = ctx->streams[i]->priv_data;
-        stream->packet_number = 0;
-    }
-    s->system_header_size = get_system_header_size(ctx);
-    s->last_scr = 0;
-    return 0;
- fail:
-    for(i=0;i<ctx->nb_streams;i++) {
-        av_free(ctx->streams[i]->priv_data);
-    }
-    return -ENOMEM;
-}
-
-static inline void put_timestamp(ByteIOContext *pb, int id, int64_t timestamp)
-{
-    put_byte(pb, 
-             (id << 4) | 
-             (((timestamp >> 30) & 0x07) << 1) | 
-             1);
-    put_be16(pb, (uint16_t)((((timestamp >> 15) & 0x7fff) << 1) | 1));
-    put_be16(pb, (uint16_t)((((timestamp) & 0x7fff) << 1) | 1));
-}
-
-
-/* return the number of padding bytes that should be inserted into
-   the multiplexed stream.*/
-static int get_vcd_padding_size(AVFormatContext *ctx, int64_t pts)
-{
-    MpegMuxContext *s = ctx->priv_data;
-    int pad_bytes = 0;
-
-    if (s->vcd_padding_bitrate > 0 && pts!=AV_NOPTS_VALUE)
-    {
-        int64_t full_pad_bytes;
-        
-        full_pad_bytes = (int64_t)((s->vcd_padding_bitrate * (pts / 90000.0)) / 8.0); //FIXME this is wrong
-        pad_bytes = (int) (full_pad_bytes - s->vcd_padding_bytes_written);
-
-        if (pad_bytes<0)
-            /* might happen if we have already padded to a later timestamp. This
-               can occur if another stream has already advanced further.*/
-            pad_bytes=0;
-    }
-
-    return pad_bytes;
-}
-
-
-#if 0 /* unused, remove? */
-/* return the exact available payload size for the next packet for
-   stream 'stream_index'. 'pts' and 'dts' are only used to know if
-   timestamps are needed in the packet header. */
-static int get_packet_payload_size(AVFormatContext *ctx, int stream_index,
-                                   int64_t pts, int64_t dts)
-{
-    MpegMuxContext *s = ctx->priv_data;
-    int buf_index;
-    StreamInfo *stream;
-
-    stream = ctx->streams[stream_index]->priv_data;
-
-    buf_index = 0;
-    if (((s->packet_number % s->pack_header_freq) == 0)) {
-        /* pack header size */
-        if (s->is_mpeg2) 
-            buf_index += 14;
-        else
-            buf_index += 12;
-        
-        if (s->is_vcd) {
-            /* there is exactly one system header for each stream in a VCD MPEG,
-               One in the very first video packet and one in the very first
-               audio packet (see VCD standard p. IV-7 and IV-8).*/
-            
-            if (stream->packet_number==0)
-                /* The system headers refer only to the stream they occur in,
-                   so they have a constant size.*/
-                buf_index += 15;
-
-        } else {            
-            if ((s->packet_number % s->system_header_freq) == 0)
-                buf_index += s->system_header_size;
-        }
-    }
-
-    if ((s->is_vcd && stream->packet_number==0)
-        || (s->is_svcd && s->packet_number==0))
-        /* the first pack of each stream contains only the pack header,
-           the system header and some padding (see VCD standard p. IV-6) 
-           Add the padding size, so that the actual payload becomes 0.*/
-        buf_index += s->packet_size - buf_index;
-    else {
-        /* packet header size */
-        buf_index += 6;
-        if (s->is_mpeg2) {
-            buf_index += 3;
-            if (stream->packet_number==0)
-                buf_index += 3; /* PES extension */
-            buf_index += 1;    /* obligatory stuffing byte */
-        }
-        if (pts != AV_NOPTS_VALUE) {
-            if (dts != pts)
-                buf_index += 5 + 5;
-            else
-                buf_index += 5;
-
-        } else {
-            if (!s->is_mpeg2)
-                buf_index++;
-        }
-    
-        if (stream->id < 0xc0) {
-            /* AC3/LPCM private data header */
-            buf_index += 4;
-            if (stream->id >= 0xa0) {
-                int n;
-                buf_index += 3;
-                /* NOTE: we round the payload size to an integer number of
-                   LPCM samples */
-                n = (s->packet_size - buf_index) % stream->lpcm_align;
-                if (n)
-                    buf_index += (stream->lpcm_align - n);
-            }
-        }
-
-        if (s->is_vcd && stream->id == AUDIO_ID)
-            /* The VCD standard demands that 20 zero bytes follow
-               each audio packet (see standard p. IV-8).*/
-            buf_index+=20;
-    }
-    return s->packet_size - buf_index; 
-}
-#endif
-
-/* Write an MPEG padding packet header. */
-static void put_padding_packet(AVFormatContext *ctx, ByteIOContext *pb,int packet_bytes)
-{
-    MpegMuxContext *s = ctx->priv_data;
-    int i;
-    
-    put_be32(pb, PADDING_STREAM);
-    put_be16(pb, packet_bytes - 6);
-    if (!s->is_mpeg2) {
-        put_byte(pb, 0x0f);
-        packet_bytes -= 7;
-    } else
-        packet_bytes -= 6;
-
-    for(i=0;i<packet_bytes;i++)
-        put_byte(pb, 0xff);
-}
-
-static int get_nb_frames(AVFormatContext *ctx, StreamInfo *stream, int len){
-    int nb_frames=0;
-    PacketDesc *pkt_desc= stream->premux_packet;
-
-    while(len>0){ 
-        if(pkt_desc->size == pkt_desc->unwritten_size)
-            nb_frames++;
-        len -= pkt_desc->unwritten_size;
-        pkt_desc= pkt_desc->next;
-    }
-
-    return nb_frames;
-}
-
-/* flush the packet on stream stream_index */
-static int flush_packet(AVFormatContext *ctx, int stream_index, 
-                         int64_t pts, int64_t dts, int64_t scr, int trailer_size)
-{
-    MpegMuxContext *s = ctx->priv_data;
-    StreamInfo *stream = ctx->streams[stream_index]->priv_data;
-    uint8_t *buf_ptr;
-    int size, payload_size, startcode, id, stuffing_size, i, header_len;
-    int packet_size;
-    uint8_t buffer[128];
-    int zero_trail_bytes = 0;
-    int pad_packet_bytes = 0;
-    int pes_flags;
-    int general_pack = 0;  /*"general" pack without data specific to one stream?*/
-    int nb_frames;
-    
-    id = stream->id;
-    
-#if 0
-    printf("packet ID=%2x PTS=%0.3f\n", 
-           id, pts / 90000.0);
-#endif
-
-    buf_ptr = buffer;
-
-    if ((s->packet_number % s->pack_header_freq) == 0 || s->last_scr != scr) {
-        /* output pack and systems header if needed */
-        size = put_pack_header(ctx, buf_ptr, scr);
-        buf_ptr += size;
-        s->last_scr= scr;
-
-        if (s->is_vcd) {
-            /* there is exactly one system header for each stream in a VCD MPEG,
-               One in the very first video packet and one in the very first
-               audio packet (see VCD standard p. IV-7 and IV-8).*/
-            
-            if (stream->packet_number==0) {
-                size = put_system_header(ctx, buf_ptr, id);
-                buf_ptr += size;
-            }
-        } else if (s->is_dvd) {
-            if (stream->align_iframe || s->packet_number == 0){
-                int bytes_to_iframe;
-                int PES_bytes_to_fill;
-                if (stream->fifo_iframe_ptr >= stream->fifo.rptr) {
-                    bytes_to_iframe = stream->fifo_iframe_ptr - stream->fifo.rptr;
-                } else {
-                    bytes_to_iframe = (stream->fifo.end - stream->fifo.rptr) + (stream->fifo_iframe_ptr - stream->fifo.buffer);
-                }
-                PES_bytes_to_fill = s->packet_size - size - 10;
-
-                if (pts != AV_NOPTS_VALUE) {
-                    if (dts != pts)
-                        PES_bytes_to_fill -= 5 + 5;
-                    else
-                        PES_bytes_to_fill -= 5;
-                }
-
-                if (bytes_to_iframe == 0 || s->packet_number == 0) {
-                    size = put_system_header(ctx, buf_ptr, 0);
-                    buf_ptr += size;
-                    size = buf_ptr - buffer;
-                    put_buffer(&ctx->pb, buffer, size);
-
-                    put_be32(&ctx->pb, PRIVATE_STREAM_2);
-                    put_be16(&ctx->pb, 0x03d4);         // length
-                    put_byte(&ctx->pb, 0x00);           // substream ID, 00=PCI
-                    for (i = 0; i < 979; i++)
-                        put_byte(&ctx->pb, 0x00);
-
-                    put_be32(&ctx->pb, PRIVATE_STREAM_2);
-                    put_be16(&ctx->pb, 0x03fa);         // length
-                    put_byte(&ctx->pb, 0x01);           // substream ID, 01=DSI
-                    for (i = 0; i < 1017; i++)
-                        put_byte(&ctx->pb, 0x00);
-
-                    memset(buffer, 0, 128);
-                    buf_ptr = buffer;
-                    s->packet_number++;
-                    stream->align_iframe = 0;
-                    scr += s->packet_size*90000LL / (s->mux_rate*50LL); //FIXME rounding and first few bytes of each packet
-                    size = put_pack_header(ctx, buf_ptr, scr);
-                    s->last_scr= scr;
-                    buf_ptr += size;
-                    /* GOP Start */
-                } else if (bytes_to_iframe < PES_bytes_to_fill) {
-                    pad_packet_bytes = PES_bytes_to_fill - bytes_to_iframe;
-                }
-            }
-        } else {
-            if ((s->packet_number % s->system_header_freq) == 0) {
-                size = put_system_header(ctx, buf_ptr, 0);
-                buf_ptr += size;
-            }
-        }
-    }
-    size = buf_ptr - buffer;
-    put_buffer(&ctx->pb, buffer, size);
-
-    packet_size = s->packet_size - size;
-
-    if (s->is_vcd && id == AUDIO_ID)
-        /* The VCD standard demands that 20 zero bytes follow
-           each audio pack (see standard p. IV-8).*/
-        zero_trail_bytes += 20;
-            
-    if ((s->is_vcd && stream->packet_number==0)
-        || (s->is_svcd && s->packet_number==0)) {
-        /* for VCD the first pack of each stream contains only the pack header,
-           the system header and lots of padding (see VCD standard p. IV-6).
-           In the case of an audio pack, 20 zero bytes are also added at
-           the end.*/
-        /* For SVCD we fill the very first pack to increase compatibility with
-           some DVD players. Not mandated by the standard.*/
-        if (s->is_svcd)
-            general_pack = 1;    /* the system header refers to both streams and no stream data*/
-        pad_packet_bytes = packet_size - zero_trail_bytes;
-    }
-
-    packet_size -= pad_packet_bytes + zero_trail_bytes;
-
-    if (packet_size > 0) {
-
-        /* packet header size */
-        packet_size -= 6;
-        
-        /* packet header */
-        if (s->is_mpeg2) {
-            header_len = 3;
-            if (stream->packet_number==0)
-                header_len += 3; /* PES extension */
-            header_len += 1; /* obligatory stuffing byte */
-        } else {
-            header_len = 0;
-        }
-        if (pts != AV_NOPTS_VALUE) {
-            if (dts != pts)
-                header_len += 5 + 5;
-            else
-                header_len += 5;
-        } else {
-            if (!s->is_mpeg2)
-                header_len++;
-        }
-
-        payload_size = packet_size - header_len;
-        if (id < 0xc0) {
-            startcode = PRIVATE_STREAM_1;
-            payload_size -= 1;
-            if (id >= 0x40) {
-                payload_size -= 3;
-                if (id >= 0xa0)
-                    payload_size -= 3;
-            }
-        } else {
-            startcode = 0x100 + id;
-        }
-
-        stuffing_size = payload_size - fifo_size(&stream->fifo, stream->fifo.rptr);
-
-        // first byte doesnt fit -> reset pts/dts + stuffing
-        if(payload_size <= trailer_size && pts != AV_NOPTS_VALUE){
-            int timestamp_len=0;
-            if(dts != pts) 
-                timestamp_len += 5;
-            if(pts != AV_NOPTS_VALUE)
-                timestamp_len += s->is_mpeg2 ? 5 : 4;
-            pts=dts= AV_NOPTS_VALUE;
-            header_len -= timestamp_len;
-            if (s->is_dvd && stream->align_iframe) {
-                pad_packet_bytes += timestamp_len;
-                packet_size -= timestamp_len;
-            } else {
-                payload_size += timestamp_len;
-            }
-            stuffing_size += timestamp_len;
-            if(payload_size > trailer_size)
-                stuffing_size += payload_size - trailer_size;
-        }
-
-        if (pad_packet_bytes > 0 && pad_packet_bytes <= 7) { // can't use padding, so use stuffing
-            packet_size += pad_packet_bytes;
-            payload_size += pad_packet_bytes; // undo the previous adjustment
-            if (stuffing_size < 0) {
-                stuffing_size = pad_packet_bytes;
-            } else {
-                stuffing_size += pad_packet_bytes;
-            }
-            pad_packet_bytes = 0;
-        }
-
-        if (stuffing_size < 0)
-            stuffing_size = 0;
-        if (stuffing_size > 16) {    /*<=16 for MPEG-1, <=32 for MPEG-2*/
-            pad_packet_bytes += stuffing_size;
-            packet_size -= stuffing_size;
-            payload_size -= stuffing_size;
-            stuffing_size = 0;
-        }
-        
-        nb_frames= get_nb_frames(ctx, stream, payload_size - stuffing_size);
-
-        put_be32(&ctx->pb, startcode);
-
-        put_be16(&ctx->pb, packet_size);
-        
-        if (!s->is_mpeg2)
-            for(i=0;i<stuffing_size;i++)
-                put_byte(&ctx->pb, 0xff);
-
-        if (s->is_mpeg2) {
-            put_byte(&ctx->pb, 0x80); /* mpeg2 id */
-
-            pes_flags=0;
-
-            if (pts != AV_NOPTS_VALUE) {
-                pes_flags |= 0x80;
-                if (dts != pts)
-                    pes_flags |= 0x40;
-            }
-
-            /* Both the MPEG-2 and the SVCD standards demand that the
-               P-STD_buffer_size field be included in the first packet of
-               every stream. (see SVCD standard p. 26 V.2.3.1 and V.2.3.2
-               and MPEG-2 standard 2.7.7) */
-            if (stream->packet_number == 0)
-                pes_flags |= 0x01;
-
-            put_byte(&ctx->pb, pes_flags); /* flags */
-            put_byte(&ctx->pb, header_len - 3 + stuffing_size);
-
-            if (pes_flags & 0x80)  /*write pts*/
-                put_timestamp(&ctx->pb, (pes_flags & 0x40) ? 0x03 : 0x02, pts);
-            if (pes_flags & 0x40)  /*write dts*/
-                put_timestamp(&ctx->pb, 0x01, dts);
-            
-            if (pes_flags & 0x01) {  /*write pes extension*/
-                put_byte(&ctx->pb, 0x10); /* flags */
-
-                /* P-STD buffer info */                
-                if (id == AUDIO_ID)
-                    put_be16(&ctx->pb, 0x4000 | stream->max_buffer_size/128);
-                else
-                    put_be16(&ctx->pb, 0x6000 | stream->max_buffer_size/1024);
-            }
-
-        } else {
-            if (pts != AV_NOPTS_VALUE) {
-                if (dts != pts) {
-                    put_timestamp(&ctx->pb, 0x03, pts);
-                    put_timestamp(&ctx->pb, 0x01, dts);
-                } else {
-                    put_timestamp(&ctx->pb, 0x02, pts);
-                }
-            } else {
-                put_byte(&ctx->pb, 0x0f);
-            }
-        }
-
-        if (s->is_mpeg2) {
-            /* special stuffing byte that is always written
-               to prevent accidental generation of start codes. */
-            put_byte(&ctx->pb, 0xff);
-
-            for(i=0;i<stuffing_size;i++)
-                put_byte(&ctx->pb, 0xff);
-        }
-
-        if (startcode == PRIVATE_STREAM_1) {
-            put_byte(&ctx->pb, id);
-            if (id >= 0xa0) {
-                /* LPCM (XXX: check nb_frames) */
-                put_byte(&ctx->pb, 7);
-                put_be16(&ctx->pb, 4); /* skip 3 header bytes */
-                put_byte(&ctx->pb, stream->lpcm_header[0]);
-                put_byte(&ctx->pb, stream->lpcm_header[1]);
-                put_byte(&ctx->pb, stream->lpcm_header[2]);
-            } else if (id >= 0x40) {
-                /* AC3 */
-                put_byte(&ctx->pb, nb_frames);
-                put_be16(&ctx->pb, trailer_size+1);
-            }
-        }
-
-        /* output data */
-        if(put_fifo(&ctx->pb, &stream->fifo, payload_size - stuffing_size, &stream->fifo.rptr) < 0)
-            return -1;
-    }else{
-        payload_size=
-        stuffing_size= 0;
-    }
-
-    if (pad_packet_bytes > 0)
-        put_padding_packet(ctx,&ctx->pb, pad_packet_bytes);    
-
-    for(i=0;i<zero_trail_bytes;i++)
-        put_byte(&ctx->pb, 0x00);
-        
-    put_flush_packet(&ctx->pb);
-    
-    s->packet_number++;
-
-    /* only increase the stream packet number if this pack actually contains
-       something that is specific to this stream! I.e. a dedicated header
-       or some data.*/
-    if (!general_pack)
-        stream->packet_number++;
-    
-    return payload_size - stuffing_size;
-}
-
-static void put_vcd_padding_sector(AVFormatContext *ctx)
-{
-    /* There are two ways to do this padding: writing a sector/pack
-       of 0 values, or writing an MPEG padding pack. Both seem to
-       work with most decoders, BUT the VCD standard only allows a 0-sector
-       (see standard p. IV-4, IV-5).
-       So a 0-sector it is...*/
-
-    MpegMuxContext *s = ctx->priv_data;
-    int i;
-
-    for(i=0;i<s->packet_size;i++)
-        put_byte(&ctx->pb, 0);
-
-    s->vcd_padding_bytes_written += s->packet_size;
-        
-    put_flush_packet(&ctx->pb);
-    
-    /* increasing the packet number is correct. The SCR of the following packs
-       is calculated from the packet_number and it has to include the padding
-       sector (it represents the sector index, not the MPEG pack index)
-       (see VCD standard p. IV-6)*/
-    s->packet_number++;
-}
-
-#if 0 /* unused, remove? */
-static int64_t get_vcd_scr(AVFormatContext *ctx,int stream_index,int64_t pts)
-{
-    MpegMuxContext *s = ctx->priv_data;
-    int64_t scr;
-
-        /* Since the data delivery rate is constant, SCR is computed
-           using the formula C + i * 1200 where C is the start constant
-           and i is the pack index.
-           It is recommended that SCR 0 is at the beginning of the VCD front
-           margin (a sequence of empty Form 2 sectors on the CD).
-           It is recommended that the front margin is 30 sectors long, so
-           we use C = 30*1200 = 36000
-           (Note that even if the front margin is not 30 sectors the file
-           will still be correct according to the standard. It just won't have
-           the "recommended" value).*/
-        scr = 36000 + s->packet_number * 1200;
-
-    return scr;
-}    
-#endif
-
-static int remove_decoded_packets(AVFormatContext *ctx, int64_t scr){
-//    MpegMuxContext *s = ctx->priv_data;
-    int i;
-
-    for(i=0; i<ctx->nb_streams; i++){
-        AVStream *st = ctx->streams[i];
-        StreamInfo *stream = st->priv_data;
-        PacketDesc *pkt_desc= stream->predecode_packet;
-        
-        while(pkt_desc && scr > pkt_desc->dts){ //FIXME > vs >=
-            if(stream->buffer_index < pkt_desc->size || 
-               stream->predecode_packet == stream->premux_packet){
-                av_log(ctx, AV_LOG_ERROR, "buffer underflow\n");
-                break;
-            }
-            stream->buffer_index -= pkt_desc->size;
-
-            stream->predecode_packet= pkt_desc->next;
-            av_freep(&pkt_desc);
-        }
-    }
-    
-    return 0;
-}
-
-static int output_packet(AVFormatContext *ctx, int flush){
-    MpegMuxContext *s = ctx->priv_data;
-    AVStream *st;
-    StreamInfo *stream;
-    int i, avail_space, es_size, trailer_size;
-    int best_i= -1;
-    int best_score= INT_MIN;
-    int ignore_constraints=0;
-    int64_t scr= s->last_scr;
-    PacketDesc *timestamp_packet;
-    const int64_t max_delay= av_rescale(ctx->max_delay, 90000, AV_TIME_BASE);
-
-retry:
-    for(i=0; i<ctx->nb_streams; i++){
-        AVStream *st = ctx->streams[i];
-        StreamInfo *stream = st->priv_data;
-        const int avail_data=  fifo_size(&stream->fifo, stream->fifo.rptr);
-        const int space= stream->max_buffer_size - stream->buffer_index;
-        int rel_space= 1024*space / stream->max_buffer_size;
-        PacketDesc *next_pkt= stream->premux_packet;
-
-        /* for subtitle, a single PES packet must be generated,
-           so we flush after every single subtitle packet */
-        if(s->packet_size > avail_data && !flush
-           && st->codec->codec_type != CODEC_TYPE_SUBTITLE)
-            return 0;
-        if(avail_data==0)
-            continue;
-        assert(avail_data>0);
-
-        if(space < s->packet_size && !ignore_constraints)
-            continue;
-            
-        if(next_pkt && next_pkt->dts - scr > max_delay)
-            continue;
-            
-        if(rel_space > best_score){
-            best_score= rel_space;
-            best_i = i;
-            avail_space= space;
-        }
-    }
-    
-    if(best_i < 0){
-        int64_t best_dts= INT64_MAX;
-
-        for(i=0; i<ctx->nb_streams; i++){
-            AVStream *st = ctx->streams[i];
-            StreamInfo *stream = st->priv_data;
-            PacketDesc *pkt_desc= stream->predecode_packet;
-            if(pkt_desc && pkt_desc->dts < best_dts)
-                best_dts= pkt_desc->dts;
-        }
-
-#if 0
-        av_log(ctx, AV_LOG_DEBUG, "bumping scr, scr:%f, dts:%f\n", 
-               scr/90000.0, best_dts/90000.0);
-#endif
-        if(best_dts == INT64_MAX)
-            return 0;
-
-        if(scr >= best_dts+1 && !ignore_constraints){
-            av_log(ctx, AV_LOG_ERROR, "packet too large, ignoring buffer limits to mux it\n");
-            ignore_constraints= 1;
-        }
-        scr= FFMAX(best_dts+1, scr);
-        if(remove_decoded_packets(ctx, scr) < 0)
-            return -1;
-        goto retry;
-    }
-
-    assert(best_i >= 0);
-    
-    st = ctx->streams[best_i];
-    stream = st->priv_data;
-    
-    assert(fifo_size(&stream->fifo, stream->fifo.rptr) > 0);
-
-    assert(avail_space >= s->packet_size || ignore_constraints);
-    
-    timestamp_packet= stream->premux_packet;
-    if(timestamp_packet->unwritten_size == timestamp_packet->size){
-        trailer_size= 0;
-    }else{
-        trailer_size= timestamp_packet->unwritten_size;
-        timestamp_packet= timestamp_packet->next;
-    }
-
-    if(timestamp_packet){
-//av_log(ctx, AV_LOG_DEBUG, "dts:%f pts:%f scr:%f stream:%d\n", timestamp_packet->dts/90000.0, timestamp_packet->pts/90000.0, scr/90000.0, best_i);
-        es_size= flush_packet(ctx, best_i, timestamp_packet->pts, timestamp_packet->dts, scr, trailer_size);
-    }else{
-        assert(fifo_size(&stream->fifo, stream->fifo.rptr) == trailer_size);
-        es_size= flush_packet(ctx, best_i, AV_NOPTS_VALUE, AV_NOPTS_VALUE, scr, trailer_size);
-    }
-
-    if (s->is_vcd) {
-        /* Write one or more padding sectors, if necessary, to reach
-           the constant overall bitrate.*/
-        int vcd_pad_bytes;
-
-        while((vcd_pad_bytes = get_vcd_padding_size(ctx,stream->premux_packet->pts) ) >= s->packet_size){ //FIXME pts cannot be correct here
-            put_vcd_padding_sector(ctx);
-            s->last_scr += s->packet_size*90000LL / (s->mux_rate*50LL); //FIXME rounding and first few bytes of each packet
-        }
-    }
-    
-    stream->buffer_index += es_size;
-    s->last_scr += s->packet_size*90000LL / (s->mux_rate*50LL); //FIXME rounding and first few bytes of each packet
-    
-    while(stream->premux_packet && stream->premux_packet->unwritten_size <= es_size){
-        es_size -= stream->premux_packet->unwritten_size;
-        stream->premux_packet= stream->premux_packet->next;
-    }
-    if(es_size)
-        stream->premux_packet->unwritten_size -= es_size;
-    
-    if(remove_decoded_packets(ctx, s->last_scr) < 0)
-        return -1;
-
-    return 1;
-}
-
-static int mpeg_mux_write_packet(AVFormatContext *ctx, AVPacket *pkt)
-{
-    MpegMuxContext *s = ctx->priv_data;
-    int stream_index= pkt->stream_index;
-    int size= pkt->size;
-    uint8_t *buf= pkt->data;
-    AVStream *st = ctx->streams[stream_index];
-    StreamInfo *stream = st->priv_data;
-    int64_t pts, dts;
-    PacketDesc *pkt_desc;
-    const int preload= av_rescale(ctx->preload, 90000, AV_TIME_BASE);
-    const int is_iframe = st->codec->codec_type == CODEC_TYPE_VIDEO && (pkt->flags & PKT_FLAG_KEY);
-    
-    pts= pkt->pts;
-    dts= pkt->dts;
-
-    if(pts != AV_NOPTS_VALUE) pts += preload;
-    if(dts != AV_NOPTS_VALUE) dts += preload;
-
-//av_log(ctx, AV_LOG_DEBUG, "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));
-    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;
-
-    fifo_realloc(&stream->fifo, fifo_size(&stream->fifo, NULL) + size + 1);
-
-    if (s->is_dvd){
-        if (is_iframe && (s->packet_number == 0 || (pts - stream->vobu_start_pts >= 36000))) { // min VOBU length 0.4 seconds (mpucoder)
-            stream->fifo_iframe_ptr = stream->fifo.wptr;
-            stream->align_iframe = 1;
-            stream->vobu_start_pts = pts;
-        } else {
-            stream->align_iframe = 0;
-        }
-    }
-
-    fifo_write(&stream->fifo, buf, size, &stream->fifo.wptr);
-
-    for(;;){
-        int ret= output_packet(ctx, 0);
-        if(ret<=0) 
-            return ret;
-    }
-}
-
-static int mpeg_mux_end(AVFormatContext *ctx)
-{
-//    MpegMuxContext *s = ctx->priv_data;
-    StreamInfo *stream;
-    int i;
-    
-    for(;;){
-        int ret= output_packet(ctx, 1);
-        if(ret<0) 
-            return ret;
-        else if(ret==0)
-            break;
-    }
-
-    /* End header according to MPEG1 systems standard. We do not write
-       it as it is usually not needed by decoders and because it
-       complicates MPEG stream concatenation. */
-    //put_be32(&ctx->pb, ISO_11172_END_CODE);
-    //put_flush_packet(&ctx->pb);
-
-    for(i=0;i<ctx->nb_streams;i++) {
-        stream = ctx->streams[i]->priv_data;
-
-        assert(fifo_size(&stream->fifo, stream->fifo.rptr) == 0);
-        fifo_free(&stream->fifo);
-    }
-    return 0;
-}
-#endif //CONFIG_ENCODERS
-
-/*********************************************/
-/* demux code */
-
-#define MAX_SYNC_SIZE 100000
-
-static int mpegps_probe(AVProbeData *p)
-{
-    int i;
-    int size= FFMIN(20, p->buf_size);
-    uint32_t code=0xFF;
-
-    /* we search the first start code. If it is a packet start code,
-       then we decide it is mpeg ps. We do not send highest value to
-       give a chance to mpegts */
-    /* NOTE: the search range was restricted to avoid too many false
-       detections */
-
-    for (i = 0; i < size; i++) {
-        code = (code << 8) | p->buf[i];
-        if ((code & 0xffffff00) == 0x100) {
-            if (code == PACK_START_CODE ||
-                code == SYSTEM_HEADER_START_CODE ||
-                (code >= 0x1e0 && code <= 0x1ef) ||
-                (code >= 0x1c0 && code <= 0x1df) ||
-                code == PRIVATE_STREAM_2 ||
-                code == PROGRAM_STREAM_MAP ||
-                code == PRIVATE_STREAM_1 ||
-                code == PADDING_STREAM)
-                return AVPROBE_SCORE_MAX - 2;
-            else
-                return 0;
-        }
-    }
-    return 0;
-}
-
-
-typedef struct MpegDemuxContext {
-    int header_state;
-    unsigned char psm_es_type[256];
-} MpegDemuxContext;
-
-static int mpegps_read_header(AVFormatContext *s,
-                              AVFormatParameters *ap)
-{
-    MpegDemuxContext *m = s->priv_data;
-    m->header_state = 0xff;
-    s->ctx_flags |= AVFMTCTX_NOHEADER;
-
-    /* no need to do more */
-    return 0;
-}
-
-static int64_t get_pts(ByteIOContext *pb, int c)
-{
-    int64_t pts;
-    int val;
-
-    if (c < 0)
-        c = get_byte(pb);
-    pts = (int64_t)((c >> 1) & 0x07) << 30;
-    val = get_be16(pb);
-    pts |= (int64_t)(val >> 1) << 15;
-    val = get_be16(pb);
-    pts |= (int64_t)(val >> 1);
-    return pts;
-}
-
-static int find_next_start_code(ByteIOContext *pb, int *size_ptr, 
-                                uint32_t *header_state)
-{
-    unsigned int state, v;
-    int val, n;
-
-    state = *header_state;
-    n = *size_ptr;
-    while (n > 0) {
-        if (url_feof(pb))
-            break;
-        v = get_byte(pb);
-        n--;
-        if (state == 0x000001) {
-            state = ((state << 8) | v) & 0xffffff;
-            val = state;
-            goto found;
-        }
-        state = ((state << 8) | v) & 0xffffff;
-    }
-    val = -1;
- found:
-    *header_state = state;
-    *size_ptr = n;
-    return val;
-}
-
-#if 0 /* unused, remove? */
-/* XXX: optimize */
-static int find_prev_start_code(ByteIOContext *pb, int *size_ptr)
-{
-    int64_t pos, pos_start;
-    int max_size, start_code;
-
-    max_size = *size_ptr;
-    pos_start = url_ftell(pb);
-
-    /* in order to go faster, we fill the buffer */
-    pos = pos_start - 16386;
-    if (pos < 0)
-        pos = 0;
-    url_fseek(pb, pos, SEEK_SET);
-    get_byte(pb);
-
-    pos = pos_start;
-    for(;;) {
-        pos--;
-        if (pos < 0 || (pos_start - pos) >= max_size) {
-            start_code = -1;
-            goto the_end;
-        }
-        url_fseek(pb, pos, SEEK_SET);
-        start_code = get_be32(pb);
-        if ((start_code & 0xffffff00) == 0x100)
-            break;
-    }
- the_end:
-    *size_ptr = pos_start - pos;
-    return start_code;
-}
-#endif
-
-/**
- * Extracts stream types from a program stream map
- * According to ISO/IEC 13818-1 ('MPEG-2 Systems') table 2-35
- * 
- * @return number of bytes occupied by PSM in the bitstream
- */
-static long mpegps_psm_parse(MpegDemuxContext *m, ByteIOContext *pb)
-{
-    int psm_length, ps_info_length, es_map_length;
-
-    psm_length = get_be16(pb);
-    get_byte(pb);
-    get_byte(pb);
-    ps_info_length = get_be16(pb);
-
-    /* skip program_stream_info */
-    url_fskip(pb, ps_info_length);
-    es_map_length = get_be16(pb);
-
-    /* at least one es available? */
-    while (es_map_length >= 4){
-        unsigned char type = get_byte(pb);
-        unsigned char es_id = get_byte(pb);
-        uint16_t es_info_length = get_be16(pb);
-        /* remember mapping from stream id to stream type */
-        m->psm_es_type[es_id] = type;
-        /* skip program_stream_info */
-        url_fskip(pb, es_info_length);
-        es_map_length -= 4 + es_info_length;
-    }
-    get_be32(pb); /* crc32 */
-    return 2 + psm_length;
-}
-
-/* read the next PES header. Return its position in ppos 
-   (if not NULL), and its start code, pts and dts.
- */
-static int mpegps_read_pes_header(AVFormatContext *s,
-                                  int64_t *ppos, int *pstart_code, 
-                                  int64_t *ppts, int64_t *pdts)
-{
-    MpegDemuxContext *m = s->priv_data;
-    int len, size, startcode, c, flags, header_len;
-    int64_t pts, dts, last_pos;
-
-    last_pos = -1;
- redo:
-        /* next start code (should be immediately after) */
-        m->header_state = 0xff;
-        size = MAX_SYNC_SIZE;
-        startcode = find_next_start_code(&s->pb, &size, &m->header_state);
-    //printf("startcode=%x pos=0x%Lx\n", startcode, url_ftell(&s->pb));
-    if (startcode < 0)
-        return AVERROR_IO;
-    if (startcode == PACK_START_CODE)
-        goto redo;
-    if (startcode == SYSTEM_HEADER_START_CODE)
-        goto redo;
-    if (startcode == PADDING_STREAM ||
-        startcode == PRIVATE_STREAM_2) {
-        /* skip them */
-        len = get_be16(&s->pb);
-        url_fskip(&s->pb, len);
-        goto redo;
-    }
-    if (startcode == PROGRAM_STREAM_MAP) {
-        mpegps_psm_parse(m, &s->pb);
-        goto redo;
-    }
-    
-    /* find matching stream */
-    if (!((startcode >= 0x1c0 && startcode <= 0x1df) ||
-          (startcode >= 0x1e0 && startcode <= 0x1ef) ||
-          (startcode == 0x1bd)))
-        goto redo;
-    if (ppos) {
-        *ppos = url_ftell(&s->pb) - 4;
-    }
-    len = get_be16(&s->pb);
-    pts = AV_NOPTS_VALUE;
-    dts = AV_NOPTS_VALUE;
-    /* stuffing */
-    for(;;) {
-        if (len < 1)
-            goto redo;
-        c = get_byte(&s->pb);
-        len--;
-        /* XXX: for mpeg1, should test only bit 7 */
-        if (c != 0xff) 
-            break;
-    }
-    if ((c & 0xc0) == 0x40) {
-        /* buffer scale & size */
-        if (len < 2)
-            goto redo;
-        get_byte(&s->pb);
-        c = get_byte(&s->pb);
-        len -= 2;
-    }
-    if ((c & 0xf0) == 0x20) {
-        if (len < 4)
-            goto redo;
-        dts = pts = get_pts(&s->pb, c);
-        len -= 4;
-    } else if ((c & 0xf0) == 0x30) {
-        if (len < 9)
-            goto redo;
-        pts = get_pts(&s->pb, c);
-        dts = get_pts(&s->pb, -1);
-        len -= 9;
-    } else if ((c & 0xc0) == 0x80) {
-        /* mpeg 2 PES */
-        if ((c & 0x30) != 0) {
-            /* Encrypted multiplex not handled */
-            goto redo;
-        }
-        flags = get_byte(&s->pb);
-        header_len = get_byte(&s->pb);
-        len -= 2;
-        if (header_len > len)
-            goto redo;
-        if ((flags & 0xc0) == 0x80) {
-            dts = pts = get_pts(&s->pb, -1);
-            if (header_len < 5)
-                goto redo;
-            header_len -= 5;
-            len -= 5;
-        } if ((flags & 0xc0) == 0xc0) {
-            pts = get_pts(&s->pb, -1);
-            dts = get_pts(&s->pb, -1);
-            if (header_len < 10)
-                goto redo;
-            header_len -= 10;
-            len -= 10;
-        }
-        len -= header_len;
-        while (header_len > 0) {
-            get_byte(&s->pb);
-            header_len--;
-        }
-    }
-    else if( c!= 0xf )
-        goto redo;
-
-    if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) {
-        if (len < 1)
-            goto redo;
-        startcode = get_byte(&s->pb);
-        len--;
-        if (startcode >= 0x80 && startcode <= 0xbf) {
-            /* audio: skip header */
-            if (len < 3)
-                goto redo;
-            get_byte(&s->pb);
-            get_byte(&s->pb);
-            get_byte(&s->pb);
-            len -= 3;
-        }
-    }
-    if(dts != AV_NOPTS_VALUE && ppos){
-        int i;
-        for(i=0; i<s->nb_streams; i++){
-            if(startcode == s->streams[i]->id) {
-                av_add_index_entry(s->streams[i], *ppos, dts, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */);
-            }
-        }
-    }
-    
-    *pstart_code = startcode;
-    *ppts = pts;
-    *pdts = dts;
-    return len;
-}
-
-static int mpegps_read_packet(AVFormatContext *s,
-                              AVPacket *pkt)
-{
-    MpegDemuxContext *m = s->priv_data;
-    AVStream *st;
-    int len, startcode, i, type, codec_id = 0, es_type;
-    int64_t pts, dts, dummy_pos; //dummy_pos is needed for the index building to work
-
- redo:
-    len = mpegps_read_pes_header(s, &dummy_pos, &startcode, &pts, &dts);
-    if (len < 0)
-        return len;
-    
-    /* now find stream */
-    for(i=0;i<s->nb_streams;i++) {
-        st = s->streams[i];
-        if (st->id == startcode)
-            goto found;
-    }
-
-    es_type = m->psm_es_type[startcode & 0xff];
-    if(es_type > 0){
-        if(es_type == STREAM_TYPE_VIDEO_MPEG1){
-            codec_id = CODEC_ID_MPEG2VIDEO;
-            type = CODEC_TYPE_VIDEO;
-        } else if(es_type == STREAM_TYPE_VIDEO_MPEG2){
-            codec_id = CODEC_ID_MPEG2VIDEO;
-            type = CODEC_TYPE_VIDEO;
-        } else if(es_type == STREAM_TYPE_AUDIO_MPEG1 ||
-                  es_type == STREAM_TYPE_AUDIO_MPEG2){
-            codec_id = CODEC_ID_MP3;
-            type = CODEC_TYPE_AUDIO;
-        } else if(es_type == STREAM_TYPE_AUDIO_AAC){
-            codec_id = CODEC_ID_AAC;
-            type = CODEC_TYPE_AUDIO;
-        } else if(es_type == STREAM_TYPE_VIDEO_MPEG4){
-            codec_id = CODEC_ID_MPEG4;
-            type = CODEC_TYPE_VIDEO;
-        } else if(es_type == STREAM_TYPE_VIDEO_H264){
-            codec_id = CODEC_ID_H264;
-            type = CODEC_TYPE_VIDEO;
-        } else if(es_type == STREAM_TYPE_AUDIO_AC3){
-            codec_id = CODEC_ID_AC3;
-            type = CODEC_TYPE_AUDIO;
-        } else {
-            goto skip;
-        }
-    } else if (startcode >= 0x1e0 && startcode <= 0x1ef) {
-        type = CODEC_TYPE_VIDEO;
-        codec_id = CODEC_ID_MPEG2VIDEO;
-    } else if (startcode >= 0x1c0 && startcode <= 0x1df) {
-        type = CODEC_TYPE_AUDIO;
-        codec_id = CODEC_ID_MP2;
-    } else if (startcode >= 0x80 && startcode <= 0x87) {
-        type = CODEC_TYPE_AUDIO;
-        codec_id = CODEC_ID_AC3;
-    } else if (startcode >= 0x88 && startcode <= 0x9f) {
-        type = CODEC_TYPE_AUDIO;
-        codec_id = CODEC_ID_DTS;
-    } else if (startcode >= 0xa0 && startcode <= 0xbf) {
-        type = CODEC_TYPE_AUDIO;
-        codec_id = CODEC_ID_PCM_S16BE;
-    } else if (startcode >= 0x20 && startcode <= 0x3f) {
-        type = CODEC_TYPE_SUBTITLE;
-        codec_id = CODEC_ID_DVD_SUBTITLE;
-    } else {
-    skip:
-        /* skip packet */
-        url_fskip(&s->pb, len);
-        goto redo;
-    }
-    /* no stream found: add a new stream */
-    st = av_new_stream(s, startcode);
-    if (!st) 
-        goto skip;
-    st->codec->codec_type = type;
-    st->codec->codec_id = codec_id;
-    if (codec_id != CODEC_ID_PCM_S16BE)
-        st->need_parsing = 1;
- found:
-    if(st->discard >= AVDISCARD_ALL)
-        goto skip;
-    if (startcode >= 0xa0 && startcode <= 0xbf) {
-        int b1, freq;
-
-        /* for LPCM, we just skip the header and consider it is raw
-           audio data */
-        if (len <= 3)
-            goto skip;
-        get_byte(&s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */
-        b1 = get_byte(&s->pb); /* quant (2), freq(2), reserved(1), channels(3) */
-        get_byte(&s->pb); /* dynamic range control (0x80 = off) */
-        len -= 3;
-        freq = (b1 >> 4) & 3;
-        st->codec->sample_rate = lpcm_freq_tab[freq];
-        st->codec->channels = 1 + (b1 & 7);
-        st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * 2;
-    }
-    av_new_packet(pkt, len);
-    get_buffer(&s->pb, pkt->data, pkt->size);
-    pkt->pts = pts;
-    pkt->dts = dts;
-    pkt->stream_index = st->index;
-#if 0
-    av_log(s, AV_LOG_DEBUG, "%d: pts=%0.3f dts=%0.3f size=%d\n",
-           pkt->stream_index, pkt->pts / 90000.0, pkt->dts / 90000.0, pkt->size);
-#endif
-
-    return 0;
-}
-
-static int mpegps_read_close(AVFormatContext *s)
-{
-    return 0;
-}
-
-static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, 
-                               int64_t *ppos, int64_t pos_limit)
-{
-    int len, startcode;
-    int64_t pos, pts, dts;
-
-    pos = *ppos;
-#ifdef DEBUG_SEEK
-    printf("read_dts: pos=0x%llx next=%d -> ", pos, find_next);
-#endif
-    url_fseek(&s->pb, pos, SEEK_SET);
-    for(;;) {
-        len = mpegps_read_pes_header(s, &pos, &startcode, &pts, &dts);
-        if (len < 0) {
-#ifdef DEBUG_SEEK
-            printf("none (ret=%d)\n", len);
-#endif
-            return AV_NOPTS_VALUE;
-        }
-        if (startcode == s->streams[stream_index]->id && 
-            dts != AV_NOPTS_VALUE) {
-            break;
-        }
-        url_fskip(&s->pb, len);
-    }
-#ifdef DEBUG_SEEK
-    printf("pos=0x%llx dts=0x%llx %0.3f\n", pos, dts, dts / 90000.0);
-#endif
-    *ppos = pos;
-    return dts;
-}
-
-#ifdef CONFIG_ENCODERS
-static AVOutputFormat mpeg1system_mux = {
-    "mpeg",
-    "MPEG1 System format",
-    "video/mpeg",
-    "mpg,mpeg",
-    sizeof(MpegMuxContext),
-    CODEC_ID_MP2,
-    CODEC_ID_MPEG1VIDEO,
-    mpeg_mux_init,
-    mpeg_mux_write_packet,
-    mpeg_mux_end,
-};
-
-static AVOutputFormat mpeg1vcd_mux = {
-    "vcd",
-    "MPEG1 System format (VCD)",
-    "video/mpeg",
-    NULL,
-    sizeof(MpegMuxContext),
-    CODEC_ID_MP2,
-    CODEC_ID_MPEG1VIDEO,
-    mpeg_mux_init,
-    mpeg_mux_write_packet,
-    mpeg_mux_end,
-};
-
-static AVOutputFormat mpeg2vob_mux = {
-    "vob",
-    "MPEG2 PS format (VOB)",
-    "video/mpeg",
-    "vob",
-    sizeof(MpegMuxContext),
-    CODEC_ID_MP2,
-    CODEC_ID_MPEG2VIDEO,
-    mpeg_mux_init,
-    mpeg_mux_write_packet,
-    mpeg_mux_end,
-};
-
-/* Same as mpeg2vob_mux except that the pack size is 2324 */
-static AVOutputFormat mpeg2svcd_mux = {
-    "svcd",
-    "MPEG2 PS format (VOB)",
-    "video/mpeg",
-    "vob",
-    sizeof(MpegMuxContext),
-    CODEC_ID_MP2,
-    CODEC_ID_MPEG2VIDEO,
-    mpeg_mux_init,
-    mpeg_mux_write_packet,
-    mpeg_mux_end,
-};
-
-/*  Same as mpeg2vob_mux except the 'is_dvd' flag is set to produce NAV pkts */
-static AVOutputFormat mpeg2dvd_mux = {
-    "dvd",
-    "MPEG2 PS format (DVD VOB)",
-    "video/mpeg",
-    "dvd",
-    sizeof(MpegMuxContext),
-    CODEC_ID_MP2,
-    CODEC_ID_MPEG2VIDEO,
-    mpeg_mux_init,
-    mpeg_mux_write_packet,
-    mpeg_mux_end,
-};
-
-#endif //CONFIG_ENCODERS
-
-AVInputFormat mpegps_demux = {
-    "mpeg",
-    "MPEG PS format",
-    sizeof(MpegDemuxContext),
-    mpegps_probe,
-    mpegps_read_header,
-    mpegps_read_packet,
-    mpegps_read_close,
-    NULL, //mpegps_read_seek,
-    mpegps_read_dts,
-    .flags = AVFMT_SHOW_IDS,
-};
-
-int mpegps_init(void)
-{
-#ifdef CONFIG_ENCODERS
-    av_register_output_format(&mpeg1system_mux);
-    av_register_output_format(&mpeg1vcd_mux);
-    av_register_output_format(&mpeg2vob_mux);
-    av_register_output_format(&mpeg2svcd_mux);
-    av_register_output_format(&mpeg2dvd_mux);
-#endif //CONFIG_ENCODERS
-    av_register_input_format(&mpegps_demux);
-    return 0;
-}
diff --git a/ffmpeg.src/libavformat/mpegts.c b/ffmpeg.src/libavformat/mpegts.c
deleted file mode 100644
index e879da9..0000000
--- a/ffmpeg.src/libavformat/mpegts.c
+++ /dev/null
@@ -1,1505 +0,0 @@
-/*
- * MPEG2 transport stream (aka DVB) demux
- * Copyright (c) 2002-2003 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avformat.h"
-
-#include "mpegts.h"
-
-//#define DEBUG_SI
-//#define DEBUG_SEEK
-
-/* 1.0 second at 24Mbit/s */
-#define MAX_SCAN_PACKETS 32000
-
-/* maximum size in which we look for synchronisation if
-   synchronisation is lost */
-#define MAX_RESYNC_SIZE 4096
-
-typedef struct PESContext PESContext;
-
-static PESContext* add_pes_stream(MpegTSContext *ts, int pid, int stream_type);
-static AVStream* new_pes_av_stream(PESContext *pes, uint32_t code);
-
-enum MpegTSFilterType {
-    MPEGTS_PES,
-    MPEGTS_SECTION,
-};
-
-typedef void PESCallback(void *opaque, const uint8_t *buf, int len, int is_start);
-
-typedef struct MpegTSPESFilter {
-    PESCallback *pes_cb;
-    void *opaque;
-} MpegTSPESFilter;
-
-typedef void SectionCallback(void *opaque, const uint8_t *buf, int len);
-
-typedef void SetServiceCallback(void *opaque, int ret);
-
-typedef struct MpegTSSectionFilter {
-    int section_index;
-    int section_h_size;
-    uint8_t *section_buf;
-    int check_crc:1;
-    int end_of_section_reached:1;
-    SectionCallback *section_cb;
-    void *opaque;
-} MpegTSSectionFilter;
-
-typedef struct MpegTSFilter {
-    int pid;
-    int last_cc; /* last cc code (-1 if first packet) */
-    enum MpegTSFilterType type;
-    union {
-        MpegTSPESFilter pes_filter;
-        MpegTSSectionFilter section_filter;
-    } u;
-} MpegTSFilter;
-
-typedef struct MpegTSService {
-    int running:1;
-    int sid;
-    char *provider_name;
-    char *name;
-} MpegTSService;
-
-struct MpegTSContext {
-    /* user data */
-    AVFormatContext *stream;
-    int raw_packet_size; /* raw packet size, including FEC if present */
-    int auto_guess; /* if true, all pids are analized to find streams */
-    int set_service_ret;
-
-    int mpeg2ts_raw;  /* force raw MPEG2 transport stream output, if possible */
-    int mpeg2ts_compute_pcr; /* compute exact PCR for each transport stream packet */
-
-    /* used to estimate the exact PCR */
-    int64_t cur_pcr;
-    int pcr_incr;
-    int pcr_pid;
-    
-    /* data needed to handle file based ts */
-    int stop_parse; /* stop parsing loop */
-    AVPacket *pkt; /* packet containing av data */
-
-    /******************************************/
-    /* private mpegts data */
-    /* scan context */
-    MpegTSFilter *sdt_filter;
-    int nb_services;
-    MpegTSService **services;
-    
-    /* set service context (XXX: allocated it ?) */
-    SetServiceCallback *set_service_cb;
-    void *set_service_opaque;
-    MpegTSFilter *pat_filter;
-    MpegTSFilter *pmt_filter;
-    int req_sid;
-
-    MpegTSFilter *pids[NB_PID_MAX];
-};
-
-static void write_section_data(AVFormatContext *s, MpegTSFilter *tss1,
-                               const uint8_t *buf, int buf_size, int is_start)
-{
-    MpegTSSectionFilter *tss = &tss1->u.section_filter;
-    int len;
-    
-    if (is_start) {
-        memcpy(tss->section_buf, buf, buf_size);
-        tss->section_index = buf_size;
-        tss->section_h_size = -1;
-        tss->end_of_section_reached = 0;
-    } else {
-        if (tss->end_of_section_reached)
-            return;
-        len = 4096 - tss->section_index;
-        if (buf_size < len)
-            len = buf_size;
-        memcpy(tss->section_buf + tss->section_index, buf, len);
-        tss->section_index += len;
-    }
-
-    /* compute section length if possible */
-    if (tss->section_h_size == -1 && tss->section_index >= 3) {
-        len = (((tss->section_buf[1] & 0xf) << 8) | tss->section_buf[2]) + 3;
-        if (len > 4096)
-            return;
-        tss->section_h_size = len;
-    }
-
-    if (tss->section_h_size != -1 && tss->section_index >= tss->section_h_size) {
-        tss->end_of_section_reached = 1;
-        if (!tss->check_crc ||
-            mpegts_crc32(tss->section_buf, tss->section_h_size) == 0)
-            tss->section_cb(tss->opaque, tss->section_buf, tss->section_h_size);
-    }
-}
-
-MpegTSFilter *mpegts_open_section_filter(MpegTSContext *ts, unsigned int pid, 
-                                         SectionCallback *section_cb, void *opaque,
-                                         int check_crc)
-
-{
-    MpegTSFilter *filter;
-    MpegTSSectionFilter *sec;
-    
-#ifdef DEBUG_SI
-    printf("Filter: pid=0x%x\n", pid);
-#endif
-    if (pid >= NB_PID_MAX || ts->pids[pid])
-        return NULL;
-    filter = av_mallocz(sizeof(MpegTSFilter));
-    if (!filter) 
-        return NULL;
-    ts->pids[pid] = filter;
-    filter->type = MPEGTS_SECTION;
-    filter->pid = pid;
-    filter->last_cc = -1;
-    sec = &filter->u.section_filter;
-    sec->section_cb = section_cb;
-    sec->opaque = opaque;
-    sec->section_buf = av_malloc(MAX_SECTION_SIZE);
-    sec->check_crc = check_crc;
-    if (!sec->section_buf) {
-        av_free(filter);
-        return NULL;
-    }
-    return filter;
-}
-
-MpegTSFilter *mpegts_open_pes_filter(MpegTSContext *ts, unsigned int pid, 
-                                     PESCallback *pes_cb,
-                                     void *opaque)
-{
-    MpegTSFilter *filter;
-    MpegTSPESFilter *pes;
-
-    if (pid >= NB_PID_MAX || ts->pids[pid])
-        return NULL;
-    filter = av_mallocz(sizeof(MpegTSFilter));
-    if (!filter) 
-        return NULL;
-    ts->pids[pid] = filter;
-    filter->type = MPEGTS_PES;
-    filter->pid = pid;
-    filter->last_cc = -1;
-    pes = &filter->u.pes_filter;
-    pes->pes_cb = pes_cb;
-    pes->opaque = opaque;
-    return filter;
-}
-
-void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter)
-{
-    int pid;
-
-    pid = filter->pid;
-    if (filter->type == MPEGTS_SECTION)
-        av_freep(&filter->u.section_filter.section_buf);
-    else if (filter->type == MPEGTS_PES)
-        av_freep(&filter->u.pes_filter.opaque);
-
-    av_free(filter);
-    ts->pids[pid] = NULL;
-}
-
-static int analyze(const uint8_t *buf, int size, int packet_size, int *index){
-    int stat[packet_size];
-    int i;
-    int x=0;
-    int best_score=0;
-
-    memset(stat, 0, packet_size*sizeof(int));
-
-    for(x=i=0; i<size; i++){
-        if(buf[i] == 0x47){
-            stat[x]++;
-            if(stat[x] > best_score){
-                best_score= stat[x];
-                if(index) *index= x;
-            }
-        }
-
-        x++;
-        if(x == packet_size) x= 0;
-    }
-
-    return best_score;
-}
-
-/* autodetect fec presence. Must have at least 1024 bytes  */
-static int get_packet_size(const uint8_t *buf, int size)
-{
-    int score, fec_score;
-
-    if (size < (TS_FEC_PACKET_SIZE * 5 + 1))
-        return -1;
-        
-    score    = analyze(buf, size, TS_PACKET_SIZE, NULL);
-    fec_score= analyze(buf, size, TS_FEC_PACKET_SIZE, NULL);
-//    av_log(NULL, AV_LOG_DEBUG, "score: %d, fec_score: %d \n", score, fec_score);
-    
-    if     (score > fec_score) return TS_PACKET_SIZE;
-    else if(score < fec_score) return TS_FEC_PACKET_SIZE;
-    else                       return -1;
-}
-
-typedef struct SectionHeader {
-    uint8_t tid;
-    uint16_t id;
-    uint8_t version;
-    uint8_t sec_num;
-    uint8_t last_sec_num;
-} SectionHeader;
-
-static inline int get8(const uint8_t **pp, const uint8_t *p_end)
-{
-    const uint8_t *p;
-    int c;
-
-    p = *pp;
-    if (p >= p_end)
-        return -1;
-    c = *p++;
-    *pp = p;
-    return c;
-}
-
-static inline int get16(const uint8_t **pp, const uint8_t *p_end)
-{
-    const uint8_t *p;
-    int c;
-
-    p = *pp;
-    if ((p + 1) >= p_end)
-        return -1;
-    c = (p[0] << 8) | p[1];
-    p += 2;
-    *pp = p;
-    return c;
-}
-
-/* read and allocate a DVB string preceeded by its length */
-static char *getstr8(const uint8_t **pp, const uint8_t *p_end)
-{
-    int len;
-    const uint8_t *p;
-    char *str;
-
-    p = *pp;
-    len = get8(&p, p_end);
-    if (len < 0)
-        return NULL;
-    if ((p + len) > p_end)
-        return NULL;
-    str = av_malloc(len + 1);
-    if (!str)
-        return NULL;
-    memcpy(str, p, len);
-    str[len] = '\0';
-    p += len;
-    *pp = p;
-    return str;
-}
-
-static int parse_section_header(SectionHeader *h, 
-                                const uint8_t **pp, const uint8_t *p_end)
-{
-    int val;
-
-    val = get8(pp, p_end);
-    if (val < 0)
-        return -1;
-    h->tid = val;
-    *pp += 2;
-    val = get16(pp, p_end);
-    if (val < 0)
-        return -1;
-    h->id = val;
-    val = get8(pp, p_end);
-    if (val < 0)
-        return -1;
-    h->version = (val >> 1) & 0x1f;
-    val = get8(pp, p_end);
-    if (val < 0)
-        return -1;
-    h->sec_num = val;
-    val = get8(pp, p_end);
-    if (val < 0)
-        return -1;
-    h->last_sec_num = val;
-    return 0;
-}
-
-static MpegTSService *new_service(MpegTSContext *ts, int sid, 
-                                  char *provider_name, char *name)
-{
-    MpegTSService *service;
-
-#ifdef DEBUG_SI
-    printf("new_service: sid=0x%04x provider='%s' name='%s'\n", 
-           sid, provider_name, name);
-#endif
-
-    service = av_mallocz(sizeof(MpegTSService));
-    if (!service)
-        return NULL;
-    service->sid = sid;
-    service->provider_name = provider_name;
-    service->name = name;
-    dynarray_add(&ts->services, &ts->nb_services, service);
-    return service;
-}
-
-static void pmt_cb(void *opaque, const uint8_t *section, int section_len)
-{
-    MpegTSContext *ts = opaque;
-    SectionHeader h1, *h = &h1;
-    PESContext *pes;
-    AVStream *st;
-    const uint8_t *p, *p_end, *desc_list_end, *desc_end;
-    int program_info_length, pcr_pid, pid, stream_type;
-    int desc_list_len, desc_len, desc_tag;
-    int comp_page = 0, anc_page = 0; /* initialize to kill warnings */
-    char language[4];
-    
-#ifdef DEBUG_SI
-    printf("PMT:\n");
-    av_hex_dump(stdout, (uint8_t *)section, section_len);
-#endif
-    p_end = section + section_len - 4;
-    p = section;
-    if (parse_section_header(h, &p, p_end) < 0)
-        return;
-#ifdef DEBUG_SI
-    printf("sid=0x%x sec_num=%d/%d\n", h->id, h->sec_num, h->last_sec_num);
-#endif
-    if (h->tid != PMT_TID || (ts->req_sid >= 0 && h->id != ts->req_sid) )
-        return;
-
-    pcr_pid = get16(&p, p_end) & 0x1fff;
-    if (pcr_pid < 0)
-        return;
-    ts->pcr_pid = pcr_pid;
-#ifdef DEBUG_SI
-    printf("pcr_pid=0x%x\n", pcr_pid);
-#endif
-    program_info_length = get16(&p, p_end) & 0xfff;
-    if (program_info_length < 0)
-        return;
-    p += program_info_length;
-    if (p >= p_end)
-        return;
-    for(;;) {
-        language[0] = 0;
-        st = 0;
-        stream_type = get8(&p, p_end);
-        if (stream_type < 0)
-            break;
-        pid = get16(&p, p_end) & 0x1fff;
-        if (pid < 0)
-            break;
-        desc_list_len = get16(&p, p_end) & 0xfff;
-        if (desc_list_len < 0)
-            break;
-        desc_list_end = p + desc_list_len;
-        if (desc_list_end > p_end)
-            break;
-        for(;;) {
-            desc_tag = get8(&p, desc_list_end);
-            if (desc_tag < 0)
-                break;
-            desc_len = get8(&p, desc_list_end);
-            desc_end = p + desc_len;
-            if (desc_end > desc_list_end)
-                break;
-#ifdef DEBUG_SI
-            printf("tag: 0x%02x len=%d\n", desc_tag, desc_len);
-#endif
-            switch(desc_tag) {
-            case DVB_SUBT_DESCID:
-                if (stream_type == STREAM_TYPE_PRIVATE_DATA)
-                    stream_type = STREAM_TYPE_SUBTITLE_DVB;
-
-                language[0] = get8(&p, desc_end);
-                language[1] = get8(&p, desc_end);
-                language[2] = get8(&p, desc_end);
-                language[3] = 0;
-                get8(&p, desc_end);
-                comp_page = get16(&p, desc_end);
-                anc_page = get16(&p, desc_end);
-
-                break;
-            case 0x0a: /* ISO 639 language descriptor */
-                language[0] = get8(&p, desc_end);
-                language[1] = get8(&p, desc_end);
-                language[2] = get8(&p, desc_end);
-                language[3] = 0;
-                break;
-            default:
-                break;
-            }
-            p = desc_end;
-        }
-        p = desc_list_end;
-
-#ifdef DEBUG_SI
-        printf("stream_type=%d pid=0x%x\n", stream_type, pid);
-#endif
-
-        /* now create ffmpeg stream */
-        switch(stream_type) {
-        case STREAM_TYPE_AUDIO_MPEG1:
-        case STREAM_TYPE_AUDIO_MPEG2:
-        case STREAM_TYPE_VIDEO_MPEG1:
-        case STREAM_TYPE_VIDEO_MPEG2:
-        case STREAM_TYPE_VIDEO_MPEG4:
-        case STREAM_TYPE_VIDEO_H264:
-        case STREAM_TYPE_AUDIO_AAC:
-        case STREAM_TYPE_AUDIO_AC3:
-        case STREAM_TYPE_AUDIO_DTS:
-        case STREAM_TYPE_SUBTITLE_DVB:
-            pes = add_pes_stream(ts, pid, stream_type);
-            if (pes)
-                st = new_pes_av_stream(pes, 0);
-            break;
-        default:
-            /* we ignore the other streams */
-            break;
-        }
-
-        if (st) {
-            if (language[0] != 0) {
-                st->language[0] = language[0];
-                st->language[1] = language[1];
-                st->language[2] = language[2];
-                st->language[3] = language[3];
-            }
-
-            if (stream_type == STREAM_TYPE_SUBTITLE_DVB) {
-                st->codec->sub_id = (anc_page << 16) | comp_page;
-            }
-        }
-    }
-    /* all parameters are there */
-    ts->set_service_cb(ts->set_service_opaque, 0);
-    mpegts_close_filter(ts, ts->pmt_filter);
-    ts->pmt_filter = NULL;
-}
-
-static void pat_cb(void *opaque, const uint8_t *section, int section_len)
-{
-    MpegTSContext *ts = opaque;
-    SectionHeader h1, *h = &h1;
-    const uint8_t *p, *p_end;
-    int sid, pmt_pid;
-
-#ifdef DEBUG_SI
-    printf("PAT:\n");
-    av_hex_dump(stdout, (uint8_t *)section, section_len);
-#endif
-    p_end = section + section_len - 4;
-    p = section;
-    if (parse_section_header(h, &p, p_end) < 0)
-        return;
-    if (h->tid != PAT_TID)
-        return;
-
-    for(;;) {
-        sid = get16(&p, p_end);
-        if (sid < 0)
-            break;
-        pmt_pid = get16(&p, p_end) & 0x1fff;
-        if (pmt_pid < 0)
-            break;
-#ifdef DEBUG_SI
-        printf("sid=0x%x pid=0x%x\n", sid, pmt_pid);
-#endif
-        if (sid == 0x0000) {
-            /* NIT info */
-        } else {
-            if (ts->req_sid == sid) {
-                ts->pmt_filter = mpegts_open_section_filter(ts, pmt_pid, 
-                                                            pmt_cb, ts, 1);
-                goto found;
-            }
-        }
-    }
-    /* not found */
-    ts->set_service_cb(ts->set_service_opaque, -1);
-
- found:
-    mpegts_close_filter(ts, ts->pat_filter);
-    ts->pat_filter = NULL;
-}
-
-/* add all services found in the PAT */
-static void pat_scan_cb(void *opaque, const uint8_t *section, int section_len)
-{
-    MpegTSContext *ts = opaque;
-    SectionHeader h1, *h = &h1;
-    const uint8_t *p, *p_end;
-    int sid, pmt_pid;
-    char *provider_name, *name;
-    char buf[256];
-
-#ifdef DEBUG_SI
-    printf("PAT:\n");
-    av_hex_dump(stdout, (uint8_t *)section, section_len);
-#endif
-    p_end = section + section_len - 4;
-    p = section;
-    if (parse_section_header(h, &p, p_end) < 0)
-        return;
-    if (h->tid != PAT_TID)
-        return;
-
-    for(;;) {
-        sid = get16(&p, p_end);
-        if (sid < 0)
-            break;
-        pmt_pid = get16(&p, p_end) & 0x1fff;
-        if (pmt_pid < 0)
-            break;
-#ifdef DEBUG_SI
-        printf("sid=0x%x pid=0x%x\n", sid, pmt_pid);
-#endif
-        if (sid == 0x0000) {
-            /* NIT info */
-        } else {
-            /* add the service with a dummy name */
-            snprintf(buf, sizeof(buf), "Service %x\n", sid);
-            name = av_strdup(buf);
-            provider_name = av_strdup("");
-            if (name && provider_name) {
-                new_service(ts, sid, provider_name, name);
-            } else {
-                av_freep(&name);
-                av_freep(&provider_name);
-            }
-        }
-    }
-    ts->stop_parse = 1;
-
-    /* remove filter */
-    mpegts_close_filter(ts, ts->pat_filter);
-    ts->pat_filter = NULL;
-}
-
-void mpegts_set_service(MpegTSContext *ts, int sid,
-                        SetServiceCallback *set_service_cb, void *opaque)
-{
-    ts->set_service_cb = set_service_cb;
-    ts->set_service_opaque = opaque;
-    ts->req_sid = sid;
-    ts->pat_filter = mpegts_open_section_filter(ts, PAT_PID, 
-                                                pat_cb, ts, 1);
-}
-
-static void sdt_cb(void *opaque, const uint8_t *section, int section_len)
-{
-    MpegTSContext *ts = opaque;
-    SectionHeader h1, *h = &h1;
-    const uint8_t *p, *p_end, *desc_list_end, *desc_end;
-    int onid, val, sid, desc_list_len, desc_tag, desc_len, service_type;
-    char *name, *provider_name;
-
-#ifdef DEBUG_SI
-    printf("SDT:\n");
-    av_hex_dump(stdout, (uint8_t *)section, section_len);
-#endif
-
-    p_end = section + section_len - 4;
-    p = section;
-    if (parse_section_header(h, &p, p_end) < 0)
-        return;
-    if (h->tid != SDT_TID)
-        return;
-    onid = get16(&p, p_end);
-    if (onid < 0)
-        return;
-    val = get8(&p, p_end);
-    if (val < 0)
-        return;
-    for(;;) {
-        sid = get16(&p, p_end);
-        if (sid < 0)
-            break;
-        val = get8(&p, p_end);
-        if (val < 0)
-            break;
-        desc_list_len = get16(&p, p_end) & 0xfff;
-        if (desc_list_len < 0)
-            break;
-        desc_list_end = p + desc_list_len;
-        if (desc_list_end > p_end)
-            break;
-        for(;;) {
-            desc_tag = get8(&p, desc_list_end);
-            if (desc_tag < 0)
-                break;
-            desc_len = get8(&p, desc_list_end);
-            desc_end = p + desc_len;
-            if (desc_end > desc_list_end)
-                break;
-#ifdef DEBUG_SI
-            printf("tag: 0x%02x len=%d\n", desc_tag, desc_len);
-#endif
-            switch(desc_tag) {
-            case 0x48:
-                service_type = get8(&p, p_end);
-                if (service_type < 0)
-                    break;
-                provider_name = getstr8(&p, p_end);
-                if (!provider_name)
-                    break;
-                name = getstr8(&p, p_end);
-                if (!name)
-                    break;
-                new_service(ts, sid, provider_name, name);
-                break;
-            default:
-                break;
-            }
-            p = desc_end;
-        }
-        p = desc_list_end;
-    }
-    ts->stop_parse = 1;
-
-    /* remove filter */
-    mpegts_close_filter(ts, ts->sdt_filter);
-    ts->sdt_filter = NULL;
-}
-
-/* scan services in a transport stream by looking at the SDT */
-void mpegts_scan_sdt(MpegTSContext *ts)
-{
-    ts->sdt_filter = mpegts_open_section_filter(ts, SDT_PID, 
-                                                sdt_cb, ts, 1);
-}
-
-/* scan services in a transport stream by looking at the PAT (better
-   than nothing !) */
-void mpegts_scan_pat(MpegTSContext *ts)
-{
-    ts->pat_filter = mpegts_open_section_filter(ts, PAT_PID, 
-                                                pat_scan_cb, ts, 1);
-}
-
-/* TS stream handling */
-
-enum MpegTSState {
-    MPEGTS_HEADER = 0,
-    MPEGTS_PESHEADER_FILL,
-    MPEGTS_PAYLOAD,
-    MPEGTS_SKIP,
-};
-
-/* enough for PES header + length */
-#define PES_START_SIZE 9
-#define MAX_PES_HEADER_SIZE (9 + 255)
-
-struct PESContext {
-    int pid;
-    int stream_type;
-    MpegTSContext *ts;
-    AVFormatContext *stream;
-    AVStream *st;
-    enum MpegTSState state;
-    /* used to get the format */
-    int data_index;
-    int total_size;
-    int pes_header_size;
-    int64_t pts, dts;
-    uint8_t header[MAX_PES_HEADER_SIZE];
-};
-
-static int64_t get_pts(const uint8_t *p)
-{
-    int64_t pts;
-    int val;
-
-    pts = (int64_t)((p[0] >> 1) & 0x07) << 30;
-    val = (p[1] << 8) | p[2];
-    pts |= (int64_t)(val >> 1) << 15;
-    val = (p[3] << 8) | p[4];
-    pts |= (int64_t)(val >> 1);
-    return pts;
-}
-
-/* return non zero if a packet could be constructed */
-static void mpegts_push_data(void *opaque,
-                             const uint8_t *buf, int buf_size, int is_start)
-{
-    PESContext *pes = opaque;
-    MpegTSContext *ts = pes->ts;
-    const uint8_t *p;
-    int len, code;
-    
-    if (is_start) {
-        pes->state = MPEGTS_HEADER;
-        pes->data_index = 0;
-    }
-    p = buf;
-    while (buf_size > 0) {
-        switch(pes->state) {
-        case MPEGTS_HEADER:
-            len = PES_START_SIZE - pes->data_index;
-            if (len > buf_size)
-                len = buf_size;
-            memcpy(pes->header + pes->data_index, p, len);
-            pes->data_index += len;
-            p += len;
-            buf_size -= len;
-            if (pes->data_index == PES_START_SIZE) {
-                /* we got all the PES or section header. We can now
-                   decide */
-#if 0
-                av_hex_dump(pes->header, pes->data_index);
-#endif
-                if (pes->header[0] == 0x00 && pes->header[1] == 0x00 &&
-                    pes->header[2] == 0x01) {
-                    /* it must be an mpeg2 PES stream */
-                    code = pes->header[3] | 0x100;
-                    if (!((code >= 0x1c0 && code <= 0x1df) ||
-                          (code >= 0x1e0 && code <= 0x1ef) ||
-                          (code == 0x1bd)))
-                        goto skip;
-                    if (!pes->st) {
-                        /* allocate stream */
-                        new_pes_av_stream(pes, code);
-                    }
-                    pes->state = MPEGTS_PESHEADER_FILL;
-                    pes->total_size = (pes->header[4] << 8) | pes->header[5];
-                    /* NOTE: a zero total size means the PES size is
-                       unbounded */
-                    if (pes->total_size)
-                        pes->total_size += 6;
-                    pes->pes_header_size = pes->header[8] + 9;
-                } else {
-                    /* otherwise, it should be a table */
-                    /* skip packet */
-                skip:
-                    pes->state = MPEGTS_SKIP;
-                    continue;
-                }
-            }
-            break;
-            /**********************************************/
-            /* PES packing parsing */
-        case MPEGTS_PESHEADER_FILL:
-            len = pes->pes_header_size - pes->data_index;
-            if (len > buf_size)
-                len = buf_size;
-            memcpy(pes->header + pes->data_index, p, len);
-            pes->data_index += len;
-            p += len;
-            buf_size -= len;
-            if (pes->data_index == pes->pes_header_size) {
-                const uint8_t *r;
-                unsigned int flags;
-
-                flags = pes->header[7];
-                r = pes->header + 9;
-                pes->pts = AV_NOPTS_VALUE;
-                pes->dts = AV_NOPTS_VALUE;
-                if ((flags & 0xc0) == 0x80) {
-                    pes->pts = get_pts(r);
-                    r += 5;
-                } else if ((flags & 0xc0) == 0xc0) {
-                    pes->pts = get_pts(r);
-                    r += 5;
-                    pes->dts = get_pts(r);
-                    r += 5;
-                }
-                /* we got the full header. We parse it and get the payload */
-                pes->state = MPEGTS_PAYLOAD;
-            }
-            break;
-        case MPEGTS_PAYLOAD:
-            if (pes->total_size) {
-                len = pes->total_size - pes->data_index;
-                if (len > buf_size)
-                    len = buf_size;
-            } else {
-                len = buf_size;
-            }
-            if (len > 0) {
-                AVPacket *pkt = ts->pkt;
-                if (pes->st && av_new_packet(pkt, len) == 0) {
-                    memcpy(pkt->data, p, len);
-                    pkt->stream_index = pes->st->index;
-                    pkt->pts = pes->pts;
-                    pkt->dts = pes->dts;
-                    /* reset pts values */
-                    pes->pts = AV_NOPTS_VALUE;
-                    pes->dts = AV_NOPTS_VALUE;
-                    ts->stop_parse = 1;
-                    return;
-                }
-            }
-            buf_size = 0;
-            break;
-        case MPEGTS_SKIP:
-            buf_size = 0;
-            break;
-        }
-    }
-}
-
-static AVStream* new_pes_av_stream(PESContext *pes, uint32_t code)
-{
-    AVStream *st;
-    int codec_type, codec_id;
-
-    switch(pes->stream_type){
-    case STREAM_TYPE_AUDIO_MPEG1:
-    case STREAM_TYPE_AUDIO_MPEG2:
-        codec_type = CODEC_TYPE_AUDIO;
-        codec_id = CODEC_ID_MP3;
-        break;
-    case STREAM_TYPE_VIDEO_MPEG1:
-    case STREAM_TYPE_VIDEO_MPEG2:
-        codec_type = CODEC_TYPE_VIDEO;
-        codec_id = CODEC_ID_MPEG2VIDEO;
-        break;
-    case STREAM_TYPE_VIDEO_MPEG4:
-        codec_type = CODEC_TYPE_VIDEO;
-        codec_id = CODEC_ID_MPEG4;
-        break;
-    case STREAM_TYPE_VIDEO_H264:
-        codec_type = CODEC_TYPE_VIDEO;
-        codec_id = CODEC_ID_H264;
-        break;
-    case STREAM_TYPE_AUDIO_AAC:
-        codec_type = CODEC_TYPE_AUDIO;
-        codec_id = CODEC_ID_AAC;
-        break;
-    case STREAM_TYPE_AUDIO_AC3:
-        codec_type = CODEC_TYPE_AUDIO;
-        codec_id = CODEC_ID_AC3;
-        break;
-    case STREAM_TYPE_AUDIO_DTS:
-        codec_type = CODEC_TYPE_AUDIO;
-        codec_id = CODEC_ID_DTS;
-        break;
-    case STREAM_TYPE_SUBTITLE_DVB:
-        codec_type = CODEC_TYPE_SUBTITLE;
-        codec_id = CODEC_ID_DVB_SUBTITLE;
-        break;
-    default:
-        if (code >= 0x1c0 && code <= 0x1df) {
-            codec_type = CODEC_TYPE_AUDIO;
-            codec_id = CODEC_ID_MP2;
-        } else if (code == 0x1bd) {
-            codec_type = CODEC_TYPE_AUDIO;
-            codec_id = CODEC_ID_AC3;
-        } else {
-            codec_type = CODEC_TYPE_VIDEO;
-            codec_id = CODEC_ID_MPEG1VIDEO;
-        }
-        break;
-    }
-    st = av_new_stream(pes->stream, pes->pid);
-    if (st) {
-        av_set_pts_info(st, 33, 1, 90000);
-        st->priv_data = pes;
-        st->codec->codec_type = codec_type;
-        st->codec->codec_id = codec_id;
-        st->need_parsing = 1;
-        pes->st = st;
-    }
-    return st;
-}
-
-
-static PESContext *add_pes_stream(MpegTSContext *ts, int pid, int stream_type)
-{
-    MpegTSFilter *tss;
-    PESContext *pes;
-
-    /* if no pid found, then add a pid context */
-    pes = av_mallocz(sizeof(PESContext));
-    if (!pes)
-        return 0;
-    pes->ts = ts;
-    pes->stream = ts->stream;
-    pes->pid = pid;
-    pes->stream_type = stream_type;
-    tss = mpegts_open_pes_filter(ts, pid, mpegts_push_data, pes);
-    if (!tss) {
-        av_free(pes);
-        return 0;
-    }
-    return pes;
-}
-
-/* handle one TS packet */
-static void handle_packet(MpegTSContext *ts, const uint8_t *packet)
-{
-    AVFormatContext *s = ts->stream;
-    MpegTSFilter *tss;
-    int len, pid, cc, cc_ok, afc, is_start;
-    const uint8_t *p, *p_end;
-
-    pid = ((packet[1] & 0x1f) << 8) | packet[2];
-    is_start = packet[1] & 0x40;
-    tss = ts->pids[pid];
-    if (ts->auto_guess && tss == NULL && is_start) {
-        add_pes_stream(ts, pid, 0);
-        tss = ts->pids[pid];
-    }
-    if (!tss)
-        return;
-
-    /* continuity check (currently not used) */
-    cc = (packet[3] & 0xf);
-    cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc));
-    tss->last_cc = cc;
-    
-    /* skip adaptation field */
-    afc = (packet[3] >> 4) & 3;
-    p = packet + 4;
-    if (afc == 0) /* reserved value */
-        return;
-    if (afc == 2) /* adaptation field only */
-        return;
-    if (afc == 3) {
-        /* skip adapation field */
-        p += p[0] + 1;
-    }
-    /* if past the end of packet, ignore */
-    p_end = packet + TS_PACKET_SIZE;
-    if (p >= p_end)
-        return;
-    
-    if (tss->type == MPEGTS_SECTION) {
-        if (is_start) {
-            /* pointer field present */
-            len = *p++;
-            if (p + len > p_end)
-                return;
-            if (len && cc_ok) {
-                /* write remaining section bytes */
-                write_section_data(s, tss, 
-                                   p, len, 0);
-                /* check whether filter has been closed */
-                if (!ts->pids[pid])
-                    return;
-            }
-            p += len;
-            if (p < p_end) {
-                write_section_data(s, tss, 
-                                   p, p_end - p, 1);
-            }
-        } else {
-            if (cc_ok) {
-                write_section_data(s, tss, 
-                                   p, p_end - p, 0);
-            }
-        }
-    } else {
-        tss->u.pes_filter.pes_cb(tss->u.pes_filter.opaque, 
-                                 p, p_end - p, is_start);
-    }
-}
-
-/* XXX: try to find a better synchro over several packets (use
-   get_packet_size() ?) */
-static int mpegts_resync(ByteIOContext *pb)
-{
-    int c, i;
-
-    for(i = 0;i < MAX_RESYNC_SIZE; i++) {
-        c = url_fgetc(pb);
-        if (c < 0)
-            return -1;
-        if (c == 0x47) {
-            url_fseek(pb, -1, SEEK_CUR);
-            return 0;
-        }
-    }
-    /* no sync found */
-    return -1;
-}
-
-/* return -1 if error or EOF. Return 0 if OK. */
-static int read_packet(ByteIOContext *pb, uint8_t *buf, int raw_packet_size)
-{
-    int skip, len;
-
-    for(;;) {
-        len = get_buffer(pb, buf, TS_PACKET_SIZE);
-        if (len != TS_PACKET_SIZE)
-            return AVERROR_IO;
-        /* check paquet sync byte */
-        if (buf[0] != 0x47) {
-            /* find a new packet start */
-            url_fseek(pb, -TS_PACKET_SIZE, SEEK_CUR);
-            if (mpegts_resync(pb) < 0)
-                return AVERROR_INVALIDDATA;
-            else
-                continue;
-        } else {
-            skip = raw_packet_size - TS_PACKET_SIZE;
-            if (skip > 0)
-                url_fskip(pb, skip);
-            break;
-        }
-    }
-    return 0;
-}
-
-static int handle_packets(MpegTSContext *ts, int nb_packets)
-{
-    AVFormatContext *s = ts->stream;
-    ByteIOContext *pb = &s->pb;
-    uint8_t packet[TS_PACKET_SIZE];
-    int packet_num, ret;
-
-    ts->stop_parse = 0;
-    packet_num = 0;
-    for(;;) {
-        if (ts->stop_parse)
-            break;
-        packet_num++;
-        if (nb_packets != 0 && packet_num >= nb_packets)
-            break;
-        ret = read_packet(pb, packet, ts->raw_packet_size);
-        if (ret != 0)
-            return ret;
-        handle_packet(ts, packet);
-    }
-    return 0;
-}
-
-static int mpegts_probe(AVProbeData *p)
-{
-#if 1
-    const int size= p->buf_size;
-    int score, fec_score;
-#define CHECK_COUNT 10
-    
-    if (size < (TS_FEC_PACKET_SIZE * CHECK_COUNT))
-        return -1;
-    
-    score    = analyze(p->buf, TS_PACKET_SIZE    *CHECK_COUNT, TS_PACKET_SIZE, NULL);
-    fec_score= analyze(p->buf, TS_FEC_PACKET_SIZE*CHECK_COUNT, TS_FEC_PACKET_SIZE, NULL);
-//    av_log(NULL, AV_LOG_DEBUG, "score: %d, fec_score: %d \n", score, fec_score);
-  
-// we need a clear definition for the returned score otherwise things will become messy sooner or later
-    if     (score > fec_score && score > 6) return AVPROBE_SCORE_MAX + score     - CHECK_COUNT;
-    else if(                 fec_score > 6) return AVPROBE_SCORE_MAX + fec_score - CHECK_COUNT;
-    else                                    return -1;
-#else
-    /* only use the extension for safer guess */
-    if (match_ext(p->filename, "ts"))
-        return AVPROBE_SCORE_MAX;
-    else
-        return 0;
-#endif
-}
-
-void set_service_cb(void *opaque, int ret)
-{
-    MpegTSContext *ts = opaque;
-    ts->set_service_ret = ret;
-    ts->stop_parse = 1;
-}
-
-/* return the 90 kHz PCR and the extension for the 27 MHz PCR. return
-   (-1) if not available */
-static int parse_pcr(int64_t *ppcr_high, int *ppcr_low, 
-                     const uint8_t *packet)
-{
-    int afc, len, flags;
-    const uint8_t *p;
-    unsigned int v;
-
-    afc = (packet[3] >> 4) & 3;
-    if (afc <= 1)
-        return -1;
-    p = packet + 4;
-    len = p[0];
-    p++;
-    if (len == 0)
-        return -1;
-    flags = *p++;
-    len--;
-    if (!(flags & 0x10))
-        return -1;
-    if (len < 6)
-        return -1;
-    v = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
-    *ppcr_high = ((int64_t)v << 1) | (p[4] >> 7);
-    *ppcr_low = ((p[4] & 1) << 8) | p[5];
-    return 0;
-}
-
-static int mpegts_read_header(AVFormatContext *s,
-                              AVFormatParameters *ap)
-{
-    MpegTSContext *ts = s->priv_data;
-    ByteIOContext *pb = &s->pb;
-    uint8_t buf[1024];
-    int len, sid, i;
-    int64_t pos;
-    MpegTSService *service;
-
-    if (ap) {
-        ts->mpeg2ts_raw = ap->mpeg2ts_raw;
-        ts->mpeg2ts_compute_pcr = ap->mpeg2ts_compute_pcr;
-    }
-
-    /* read the first 1024 bytes to get packet size */
-    pos = url_ftell(pb);
-    len = get_buffer(pb, buf, sizeof(buf));
-    if (len != sizeof(buf))
-        goto fail;
-    ts->raw_packet_size = get_packet_size(buf, sizeof(buf));
-    if (ts->raw_packet_size <= 0)
-        goto fail;
-    ts->stream = s;
-    ts->auto_guess = 0;
-
-    if (!ts->mpeg2ts_raw) {
-        /* normal demux */
-
-        if (!ts->auto_guess) {
-            ts->set_service_ret = -1;
-
-            /* first do a scaning to get all the services */
-            url_fseek(pb, pos, SEEK_SET);
-            mpegts_scan_sdt(ts);
-            
-            handle_packets(ts, MAX_SCAN_PACKETS);
-            
-            if (ts->nb_services <= 0) {
-                /* no SDT found, we try to look at the PAT */
-                
-                /* First remove the SDT filters from each PID */
-                int i;
-                for (i=0; i < NB_PID_MAX; i++) {
-                    if (ts->pids[i])
-                        mpegts_close_filter(ts, ts->pids[i]);
-                }
-                url_fseek(pb, pos, SEEK_SET);
-                mpegts_scan_pat(ts);
-                
-                handle_packets(ts, MAX_SCAN_PACKETS);
-            }
-            
-            if (ts->nb_services <= 0) {
-                /* raw transport stream */
-                ts->auto_guess = 1;
-                s->ctx_flags |= AVFMTCTX_NOHEADER;
-                goto do_pcr;
-            }
-            
-            /* tune to first service found */
-            for(i=0; i<ts->nb_services && ts->set_service_ret; i++){
-                service = ts->services[i];
-                sid = service->sid;
-#ifdef DEBUG_SI
-                printf("tuning to '%s'\n", service->name);
-#endif
-            
-                /* now find the info for the first service if we found any,
-                otherwise try to filter all PATs */
-                
-                url_fseek(pb, pos, SEEK_SET);
-                mpegts_set_service(ts, sid, set_service_cb, ts);
-                
-                handle_packets(ts, MAX_SCAN_PACKETS);
-            }
-            /* if could not find service, exit */
-            
-            if (ts->set_service_ret != 0)
-                return -1;
-            
-#ifdef DEBUG_SI
-            printf("tuning done\n");
-#endif
-        }
-        s->ctx_flags |= AVFMTCTX_NOHEADER;
-    } else {
-        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];
-        
-        /* only read packets */
-        
-    do_pcr:
-        st = av_new_stream(s, 0);
-        if (!st)
-            goto fail;
-        av_set_pts_info(st, 60, 1, 27000000);
-        st->codec->codec_type = CODEC_TYPE_DATA;
-        st->codec->codec_id = CODEC_ID_MPEG2TS;
-        
-        /* we iterate until we find two PCRs to estimate the bitrate */
-        pcr_pid = -1;
-        nb_pcrs = 0;
-        nb_packets = 0;
-        for(;;) {
-            ret = read_packet(&s->pb, packet, ts->raw_packet_size);
-            if (ret < 0)
-                return -1;
-            pid = ((packet[1] & 0x1f) << 8) | packet[2];
-            if ((pcr_pid == -1 || pcr_pid == pid) &&
-                parse_pcr(&pcr_h, &pcr_l, packet) == 0) {
-                pcr_pid = pid;
-                packet_count[nb_pcrs] = nb_packets;
-                pcrs[nb_pcrs] = pcr_h * 300 + pcr_l;
-                nb_pcrs++;
-                if (nb_pcrs >= 2)
-                    break;
-            }
-            nb_packets++;
-        }
-        ts->pcr_pid = pcr_pid;
-
-        /* 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]) / (packet_count[1] - packet_count[0]);
-        ts->cur_pcr = pcrs[0] - ts->pcr_incr * packet_count[0];
-        s->bit_rate = (TS_PACKET_SIZE * 8) * 27e6 / ts->pcr_incr;
-        st->codec->bit_rate = s->bit_rate;
-        st->start_time = ts->cur_pcr;
-#if 0
-        printf("start=%0.3f pcr=%0.3f incr=%d\n",
-               st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr);
-#endif
-    }
-
-    url_fseek(pb, pos, SEEK_SET);
-    return 0;
- fail:
-    return -1;
-}
-
-#define MAX_PACKET_READAHEAD ((128 * 1024) / 188)
-
-static int mpegts_raw_read_packet(AVFormatContext *s,
-                                  AVPacket *pkt)
-{
-    MpegTSContext *ts = s->priv_data;
-    int ret, i;
-    int64_t pcr_h, next_pcr_h, pos;
-    int pcr_l, next_pcr_l;
-    uint8_t pcr_buf[12];
-
-    if (av_new_packet(pkt, TS_PACKET_SIZE) < 0)
-        return -ENOMEM;
-    pkt->pos= url_ftell(&s->pb);
-    ret = read_packet(&s->pb, pkt->data, ts->raw_packet_size);
-    if (ret < 0) {
-        av_free_packet(pkt);
-        return ret;
-    }
-    if (ts->mpeg2ts_compute_pcr) {
-        /* compute exact PCR for each packet */
-        if (parse_pcr(&pcr_h, &pcr_l, pkt->data) == 0) {
-            /* we read the next PCR (XXX: optimize it by using a bigger buffer */
-            pos = url_ftell(&s->pb);
-            for(i = 0; i < MAX_PACKET_READAHEAD; i++) {
-                url_fseek(&s->pb, pos + i * ts->raw_packet_size, SEEK_SET);
-                get_buffer(&s->pb, pcr_buf, 12);
-                if (parse_pcr(&next_pcr_h, &next_pcr_l, pcr_buf) == 0) {
-                    /* XXX: not precise enough */
-                    ts->pcr_incr = ((next_pcr_h - pcr_h) * 300 + (next_pcr_l - pcr_l)) / 
-                        (i + 1);
-                    break;
-                }
-            }
-            url_fseek(&s->pb, pos, SEEK_SET);
-            /* no next PCR found: we use previous increment */
-            ts->cur_pcr = pcr_h * 300 + pcr_l;
-        }
-        pkt->pts = ts->cur_pcr;
-        pkt->duration = ts->pcr_incr;
-        ts->cur_pcr += ts->pcr_incr;
-    }
-    pkt->stream_index = 0;
-    return 0;
-}
-
-static int mpegts_read_packet(AVFormatContext *s,
-                              AVPacket *pkt)
-{
-    MpegTSContext *ts = s->priv_data;
-
-    if (!ts->mpeg2ts_raw) {
-        ts->pkt = pkt;
-        return handle_packets(ts, 0);
-    } else {
-        return mpegts_raw_read_packet(s, pkt);
-    }
-}
-
-static int mpegts_read_close(AVFormatContext *s)
-{
-    MpegTSContext *ts = s->priv_data;
-    int i;
-    for(i=0;i<NB_PID_MAX;i++)
-        if (ts->pids[i]) mpegts_close_filter(ts, ts->pids[i]);
-    return 0;
-}
-
-static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index, 
-                              int64_t *ppos, int64_t pos_limit)
-{
-    MpegTSContext *ts = s->priv_data;
-    int64_t pos, timestamp;
-    uint8_t buf[TS_PACKET_SIZE];
-    int pcr_l, pid;
-    const int find_next= 1;
-    pos = ((*ppos  + ts->raw_packet_size - 1) / ts->raw_packet_size) * ts->raw_packet_size;
-    if (find_next) {
-        for(;;) {
-            url_fseek(&s->pb, pos, SEEK_SET);
-            if (get_buffer(&s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
-                return AV_NOPTS_VALUE;
-            pid = ((buf[1] & 0x1f) << 8) | buf[2];
-            if (pid == ts->pcr_pid &&
-                parse_pcr(&timestamp, &pcr_l, buf) == 0) {
-                break;
-            }
-            pos += ts->raw_packet_size;
-        }
-    } else {
-        for(;;) {
-            pos -= ts->raw_packet_size;
-            if (pos < 0)
-                return AV_NOPTS_VALUE;
-            url_fseek(&s->pb, pos, SEEK_SET);
-            if (get_buffer(&s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
-                return AV_NOPTS_VALUE;
-            pid = ((buf[1] & 0x1f) << 8) | buf[2];
-            if (pid == ts->pcr_pid &&
-                parse_pcr(&timestamp, &pcr_l, buf) == 0) {
-                break;
-            }
-        }
-    }
-    *ppos = pos;
-
-    return timestamp;
-}
-
-static int read_seek(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){
-    MpegTSContext *ts = s->priv_data;
-    uint8_t buf[TS_PACKET_SIZE];
-    int64_t pos;
-
-    if(av_seek_frame_binary(s, stream_index, target_ts, flags) < 0)
-        return -1;
-
-    pos= url_ftell(&s->pb);
-
-    for(;;) {
-        url_fseek(&s->pb, pos, SEEK_SET);
-        if (get_buffer(&s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
-            return -1;
-//        pid = ((buf[1] & 0x1f) << 8) | buf[2];
-        if(buf[1] & 0x40) break;
-        pos += ts->raw_packet_size;
-    }    
-    url_fseek(&s->pb, pos, SEEK_SET);
-
-    return 0;
-}
-
-/**************************************************************/
-/* parsing functions - called from other demuxers such as RTP */
-
-MpegTSContext *mpegts_parse_open(AVFormatContext *s)
-{
-    MpegTSContext *ts;
-    
-    ts = av_mallocz(sizeof(MpegTSContext));
-    if (!ts)
-        return NULL;
-    /* no stream case, currently used by RTP */
-    ts->raw_packet_size = TS_PACKET_SIZE;
-    ts->stream = s;
-    ts->auto_guess = 1;
-    return ts;
-}
-
-/* return the consumed length if a packet was output, or -1 if no
-   packet is output */
-int mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt,
-                        const uint8_t *buf, int len)
-{
-    int len1;
-
-    len1 = len;
-    ts->pkt = pkt;
-    ts->stop_parse = 0;
-    for(;;) {
-        if (ts->stop_parse)
-            break;
-        if (len < TS_PACKET_SIZE)
-            return -1;
-        if (buf[0] != 0x47) {
-            buf++;
-            len--;
-        } else {
-            handle_packet(ts, buf);
-            buf += TS_PACKET_SIZE;
-            len -= TS_PACKET_SIZE;
-        }
-    }
-    return len1 - len;
-}
-
-void mpegts_parse_close(MpegTSContext *ts)
-{
-    int i;
-
-    for(i=0;i<NB_PID_MAX;i++)
-        av_free(ts->pids[i]);
-    av_free(ts);
-}
-
-AVInputFormat mpegts_demux = {
-    "mpegts",
-    "MPEG2 transport stream format",
-    sizeof(MpegTSContext),
-    mpegts_probe,
-    mpegts_read_header,
-    mpegts_read_packet,
-    mpegts_read_close,
-    read_seek,
-    mpegts_get_pcr,
-    .flags = AVFMT_SHOW_IDS,
-};
-
-int mpegts_init(void)
-{
-    av_register_input_format(&mpegts_demux);
-#ifdef CONFIG_ENCODERS
-    av_register_output_format(&mpegts_mux);
-#endif
-    return 0;
-}
diff --git a/ffmpeg.src/libavformat/mpegts.h b/ffmpeg.src/libavformat/mpegts.h
deleted file mode 100644
index 848ecdb..0000000
--- a/ffmpeg.src/libavformat/mpegts.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * MPEG2 transport stream defines
- * Copyright (c) 2003 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#define TS_FEC_PACKET_SIZE 204
-#define TS_PACKET_SIZE 188
-#define NB_PID_MAX 8192
-#define MAX_SECTION_SIZE 4096
-
-/* pids */
-#define PAT_PID                 0x0000
-#define SDT_PID                 0x0011
-
-/* table ids */
-#define PAT_TID   0x00
-#define PMT_TID   0x02 
-#define SDT_TID   0x42
-
-/* descriptor ids */
-#define DVB_SUBT_DESCID             0x59
-
-#define STREAM_TYPE_VIDEO_MPEG1     0x01
-#define STREAM_TYPE_VIDEO_MPEG2     0x02
-#define STREAM_TYPE_AUDIO_MPEG1     0x03
-#define STREAM_TYPE_AUDIO_MPEG2     0x04
-#define STREAM_TYPE_PRIVATE_SECTION 0x05
-#define STREAM_TYPE_PRIVATE_DATA    0x06
-#define STREAM_TYPE_AUDIO_AAC       0x0f
-#define STREAM_TYPE_VIDEO_MPEG4     0x10
-#define STREAM_TYPE_VIDEO_H264      0x1b
-
-#define STREAM_TYPE_AUDIO_AC3       0x81
-#define STREAM_TYPE_AUDIO_DTS       0x8a
-
-#define STREAM_TYPE_SUBTITLE_DVB    0x100
-
-unsigned int mpegts_crc32(const uint8_t *data, int len);
-extern AVOutputFormat mpegts_mux;
-
-typedef struct MpegTSContext MpegTSContext;
-
-MpegTSContext *mpegts_parse_open(AVFormatContext *s);
-int mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt,
-                        const uint8_t *buf, int len);
-void mpegts_parse_close(MpegTSContext *ts);
diff --git a/ffmpeg.src/libavformat/mpegtsenc.c b/ffmpeg.src/libavformat/mpegtsenc.c
deleted file mode 100644
index 4fe8f3e..0000000
--- a/ffmpeg.src/libavformat/mpegtsenc.c
+++ /dev/null
@@ -1,731 +0,0 @@
-/*
- * MPEG2 transport stream (aka DVB) mux
- * Copyright (c) 2003 Fabrice Bellard.
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avformat.h"
-
-#include "mpegts.h"
-
-/* write DVB SI sections */
-
-static const uint32_t crc_table[256] = {
-	0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
-	0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
-	0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7,
-	0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
-	0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3,
-	0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
-	0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, 0xbaea46ef,
-	0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
-	0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb,
-	0xceb42022, 0xca753d95, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1,
-	0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0,
-	0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
-	0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4,
-	0x0808d07d, 0x0cc9cdca, 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde,
-	0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08,
-	0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
-	0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc,
-	0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6,
-	0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, 0xe0b41de7, 0xe4750050,
-	0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
-	0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34,
-	0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637,
-	0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0x4f040d56, 0x4bc510e1,
-	0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
-	0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5,
-	0x3f9b762c, 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
-	0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, 0xf5ee4bb9,
-	0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
-	0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd,
-	0xcda1f604, 0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7,
-	0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71,
-	0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
-	0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2,
-	0x470cdd2b, 0x43cdc09c, 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8,
-	0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e,
-	0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
-	0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a,
-	0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0,
-	0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676,
-	0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
-	0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662,
-	0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
-	0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
-};
-
-unsigned int mpegts_crc32(const uint8_t *data, int len)
-{
-    register int i;
-    unsigned int crc = 0xffffffff;
-    
-    for (i=0; i<len; i++)
-        crc = (crc << 8) ^ crc_table[((crc >> 24) ^ *data++) & 0xff];
-    
-    return crc;
-}
-
-/*********************************************/
-/* mpegts section writer */
-
-typedef struct MpegTSSection {
-    int pid;
-    int cc;
-    void (*write_packet)(struct MpegTSSection *s, const uint8_t *packet);
-    void *opaque;
-} MpegTSSection;
-
-/* NOTE: 4 bytes must be left at the end for the crc32 */
-void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len)
-{
-    unsigned int crc;
-    unsigned char packet[TS_PACKET_SIZE];
-    const unsigned char *buf_ptr;
-    unsigned char *q;
-    int first, b, len1, left;
-
-    crc = mpegts_crc32(buf, len - 4);
-    buf[len - 4] = (crc >> 24) & 0xff;
-    buf[len - 3] = (crc >> 16) & 0xff;
-    buf[len - 2] = (crc >> 8) & 0xff;
-    buf[len - 1] = (crc) & 0xff;
-    
-    /* send each packet */
-    buf_ptr = buf;
-    while (len > 0) {
-        first = (buf == buf_ptr);
-        q = packet;
-        *q++ = 0x47;
-        b = (s->pid >> 8);
-        if (first)
-            b |= 0x40;
-        *q++ = b;
-        *q++ = s->pid;
-        s->cc = (s->cc + 1) & 0xf;
-        *q++ = 0x10 | s->cc;
-        if (first)
-            *q++ = 0; /* 0 offset */
-        len1 = TS_PACKET_SIZE - (q - packet);
-        if (len1 > len) 
-            len1 = len;
-        memcpy(q, buf_ptr, len1);
-        q += len1;
-        /* add known padding data */
-        left = TS_PACKET_SIZE - (q - packet);
-        if (left > 0)
-            memset(q, 0xff, left);
-
-        s->write_packet(s, packet);
-
-        buf_ptr += len1;
-        len -= len1;
-    }
-}
-
-static inline void put16(uint8_t **q_ptr, int val)
-{
-    uint8_t *q;
-    q = *q_ptr;
-    *q++ = val >> 8;
-    *q++ = val;
-    *q_ptr = q;
-}
-
-int mpegts_write_section1(MpegTSSection *s, int tid, int id, 
-                          int version, int sec_num, int last_sec_num,
-                          uint8_t *buf, int len)
-{
-    uint8_t section[1024], *q;
-    unsigned int tot_len;
-    
-    tot_len = 3 + 5 + len + 4;
-    /* check if not too big */
-    if (tot_len > 1024)
-        return -1;
-
-    q = section;
-    *q++ = tid;
-    put16(&q, 0xb000 | (len + 5 + 4)); /* 5 byte header + 4 byte CRC */
-    put16(&q, id);
-    *q++ = 0xc1 | (version << 1); /* current_next_indicator = 1 */
-    *q++ = sec_num;
-    *q++ = last_sec_num;
-    memcpy(q, buf, len);
-    
-    mpegts_write_section(s, section, tot_len);
-    return 0;
-}
-
-/*********************************************/
-/* mpegts writer */
-
-#define DEFAULT_PMT_START_PID   0x1000
-#define DEFAULT_START_PID       0x0100
-#define DEFAULT_PROVIDER_NAME   "FFmpeg"
-#define DEFAULT_SERVICE_NAME    "Service01"
-
-/* default network id, transport stream and service identifiers */
-#define DEFAULT_ONID            0x0001
-#define DEFAULT_TSID            0x0001
-#define DEFAULT_SID             0x0001
-
-/* a PES packet header is generated every DEFAULT_PES_HEADER_FREQ packets */
-#define DEFAULT_PES_HEADER_FREQ 16
-#define DEFAULT_PES_PAYLOAD_SIZE ((DEFAULT_PES_HEADER_FREQ - 1) * 184 + 170)
-
-/* we retransmit the SI info at this rate */
-#define SDT_RETRANS_TIME 500
-#define PAT_RETRANS_TIME 100
-#define PCR_RETRANS_TIME 20
-
-typedef struct MpegTSWriteStream {
-    struct MpegTSService *service;
-    int pid; /* stream associated pid */
-    int cc;
-    int payload_index;
-    int64_t payload_pts;
-    uint8_t payload[DEFAULT_PES_PAYLOAD_SIZE];
-} MpegTSWriteStream;
-
-typedef struct MpegTSService {
-    MpegTSSection pmt; /* MPEG2 pmt table context */
-    int sid;           /* service ID */
-    char *name;
-    char *provider_name;
-    int pcr_pid;
-    int pcr_packet_count;
-    int pcr_packet_freq;
-} MpegTSService;
-
-typedef struct MpegTSWrite {
-    MpegTSSection pat; /* MPEG2 pat table */
-    MpegTSSection sdt; /* MPEG2 sdt table context */
-    MpegTSService **services;
-    int sdt_packet_count;
-    int sdt_packet_freq;
-    int pat_packet_count;
-    int pat_packet_freq;
-    int nb_services;
-    int onid;
-    int tsid;
-} MpegTSWrite;
-
-static void mpegts_write_pat(AVFormatContext *s)
-{
-    MpegTSWrite *ts = s->priv_data;
-    MpegTSService *service;
-    uint8_t data[1012], *q;
-    int i;
-    
-    q = data;
-    for(i = 0; i < ts->nb_services; i++) {
-        service = ts->services[i];
-        put16(&q, service->sid);
-        put16(&q, 0xe000 | service->pmt.pid);
-    }
-    mpegts_write_section1(&ts->pat, PAT_TID, ts->tsid, 0, 0, 0,
-                          data, q - data);
-}
-
-static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
-{
-    //    MpegTSWrite *ts = s->priv_data;
-    uint8_t data[1012], *q, *desc_length_ptr, *program_info_length_ptr;
-    int val, stream_type, i;
-
-    q = data;
-    put16(&q, 0xe000 | service->pcr_pid);
-
-    program_info_length_ptr = q;
-    q += 2; /* patched after */
-
-    /* put program info here */
-
-    val = 0xf000 | (q - program_info_length_ptr - 2);
-    program_info_length_ptr[0] = val >> 8;
-    program_info_length_ptr[1] = val;
-    
-    for(i = 0; i < s->nb_streams; i++) {
-        AVStream *st = s->streams[i];
-        MpegTSWriteStream *ts_st = st->priv_data;
-        switch(st->codec->codec_id) {
-        case CODEC_ID_MPEG1VIDEO:
-        case CODEC_ID_MPEG2VIDEO:
-            stream_type = STREAM_TYPE_VIDEO_MPEG2;
-            break;
-        case CODEC_ID_MPEG4:
-            stream_type = STREAM_TYPE_VIDEO_MPEG4;
-            break;
-        case CODEC_ID_H264:
-            stream_type = STREAM_TYPE_VIDEO_H264;
-            break;
-        case CODEC_ID_MP2:
-        case CODEC_ID_MP3:
-            stream_type = STREAM_TYPE_AUDIO_MPEG1;
-            break;
-        case CODEC_ID_AAC:
-            stream_type = STREAM_TYPE_AUDIO_AAC;
-            break;
-        case CODEC_ID_AC3:
-            stream_type = STREAM_TYPE_AUDIO_AC3;
-            break;
-        default:
-            stream_type = STREAM_TYPE_PRIVATE_DATA;
-            break;
-        }
-        *q++ = stream_type;
-        put16(&q, 0xe000 | ts_st->pid);
-        desc_length_ptr = q;
-        q += 2; /* patched after */
-
-        /* write optional descriptors here */
-        switch(st->codec->codec_type) {
-        case CODEC_TYPE_AUDIO:
-            if (strlen(st->language) == 3) {
-                *q++ = 0x0a; /* ISO 639 language descriptor */
-                *q++ = 4;
-                *q++ = st->language[0];
-                *q++ = st->language[1];
-                *q++ = st->language[2];
-                *q++ = 0; /* undefined type */
-            }
-            break;
-        case CODEC_TYPE_SUBTITLE:
-            {
-                const char *language;
-                language = st->language;
-                if (strlen(language) != 3)
-                    language = "eng";
-                *q++ = 0x59;
-                *q++ = 8;
-                *q++ = language[0];
-                *q++ = language[1];
-                *q++ = language[2];
-                *q++ = 0x10; /* normal subtitles (0x20 = if hearing pb) */
-                put16(&q, 1); /* page id */
-                put16(&q, 1); /* ancillary page id */
-            }
-            break;
-        }
-
-        val = 0xf000 | (q - desc_length_ptr - 2);
-        desc_length_ptr[0] = val >> 8;
-        desc_length_ptr[1] = val;
-    }
-    mpegts_write_section1(&service->pmt, PMT_TID, service->sid, 0, 0, 0,
-                          data, q - data);
-}   
-
-/* NOTE: str == NULL is accepted for an empty string */
-static void putstr8(uint8_t **q_ptr, const char *str)
-{
-    uint8_t *q;
-    int len;
-
-    q = *q_ptr;
-    if (!str)
-        len = 0;
-    else
-        len = strlen(str);
-    *q++ = len;
-    memcpy(q, str, len);
-    q += len;
-    *q_ptr = q;
-}
-
-static void mpegts_write_sdt(AVFormatContext *s)
-{
-    MpegTSWrite *ts = s->priv_data;
-    MpegTSService *service;
-    uint8_t data[1012], *q, *desc_list_len_ptr, *desc_len_ptr;
-    int i, running_status, free_ca_mode, val;
-    
-    q = data;
-    put16(&q, ts->onid);
-    *q++ = 0xff;
-    for(i = 0; i < ts->nb_services; i++) {
-        service = ts->services[i];
-        put16(&q, service->sid);
-        *q++ = 0xfc | 0x00; /* currently no EIT info */
-        desc_list_len_ptr = q;
-        q += 2;
-        running_status = 4; /* running */
-        free_ca_mode = 0;
-
-        /* write only one descriptor for the service name and provider */
-        *q++ = 0x48;
-        desc_len_ptr = q;
-        q++;
-        *q++ = 0x01; /* digital television service */
-        putstr8(&q, service->provider_name);
-        putstr8(&q, service->name);
-        desc_len_ptr[0] = q - desc_len_ptr - 1;
-
-        /* fill descriptor length */
-        val = (running_status << 13) | (free_ca_mode << 12) | 
-            (q - desc_list_len_ptr - 2);
-        desc_list_len_ptr[0] = val >> 8;
-        desc_list_len_ptr[1] = val;
-    }
-    mpegts_write_section1(&ts->sdt, SDT_TID, ts->tsid, 0, 0, 0,
-                          data, q - data);
-}
-
-static MpegTSService *mpegts_add_service(MpegTSWrite *ts, 
-                                         int sid, 
-                                         const char *provider_name, 
-                                         const char *name)
-{
-    MpegTSService *service;
-
-    service = av_mallocz(sizeof(MpegTSService));
-    if (!service)
-        return NULL;
-    service->pmt.pid = DEFAULT_PMT_START_PID + ts->nb_services - 1;
-    service->sid = sid;
-    service->provider_name = av_strdup(provider_name);
-    service->name = av_strdup(name);
-    service->pcr_pid = 0x1fff;
-    dynarray_add(&ts->services, &ts->nb_services, service);
-    return service;
-}
-
-static void section_write_packet(MpegTSSection *s, const uint8_t *packet)
-{
-    AVFormatContext *ctx = s->opaque;
-    put_buffer(&ctx->pb, packet, TS_PACKET_SIZE);
-}
-
-static int mpegts_write_header(AVFormatContext *s)
-{
-    MpegTSWrite *ts = s->priv_data;
-    MpegTSWriteStream *ts_st;
-    MpegTSService *service;
-    AVStream *st;
-    int i, total_bit_rate;
-    const char *service_name;
-    
-    ts->tsid = DEFAULT_TSID;
-    ts->onid = DEFAULT_ONID;
-    /* allocate a single DVB service */
-    service_name = s->title;
-    if (service_name[0] == '\0')
-        service_name = DEFAULT_SERVICE_NAME;
-    service = mpegts_add_service(ts, DEFAULT_SID, 
-                                 DEFAULT_PROVIDER_NAME, service_name);
-    service->pmt.write_packet = section_write_packet;
-    service->pmt.opaque = s;
-
-    ts->pat.pid = PAT_PID;
-    ts->pat.cc = 0;
-    ts->pat.write_packet = section_write_packet;
-    ts->pat.opaque = s;
-
-    ts->sdt.pid = SDT_PID;
-    ts->sdt.cc = 0;
-    ts->sdt.write_packet = section_write_packet;
-    ts->sdt.opaque = s;
-
-    /* assign pids to each stream */
-    total_bit_rate = 0;
-    for(i = 0;i < s->nb_streams; i++) {
-        st = s->streams[i];
-        ts_st = av_mallocz(sizeof(MpegTSWriteStream));
-        if (!ts_st)
-            goto fail;
-        st->priv_data = ts_st;
-        ts_st->service = service;
-        ts_st->pid = DEFAULT_START_PID + i;
-        ts_st->payload_pts = AV_NOPTS_VALUE;
-        /* update PCR pid by using the first video stream */
-        if (st->codec->codec_type == CODEC_TYPE_VIDEO && 
-            service->pcr_pid == 0x1fff)
-            service->pcr_pid = ts_st->pid;
-        total_bit_rate += st->codec->bit_rate;
-    }
-    
-    /* if no video stream, use the first stream as PCR */
-    if (service->pcr_pid == 0x1fff && s->nb_streams > 0) {
-        ts_st = s->streams[0]->priv_data;
-        service->pcr_pid = ts_st->pid;
-    }
-
-    if (total_bit_rate <= 8 * 1024)
-        total_bit_rate = 8 * 1024;
-    service->pcr_packet_freq = (total_bit_rate * PCR_RETRANS_TIME) / 
-        (TS_PACKET_SIZE * 8 * 1000);
-    ts->sdt_packet_freq = (total_bit_rate * SDT_RETRANS_TIME) / 
-        (TS_PACKET_SIZE * 8 * 1000);
-    ts->pat_packet_freq = (total_bit_rate * PAT_RETRANS_TIME) / 
-        (TS_PACKET_SIZE * 8 * 1000);
-#if 0
-    printf("%d %d %d\n", 
-           total_bit_rate, ts->sdt_packet_freq, ts->pat_packet_freq);
-#endif
-
-    /* write info at the start of the file, so that it will be fast to
-       find them */
-    mpegts_write_sdt(s);
-    mpegts_write_pat(s);
-    for(i = 0; i < ts->nb_services; i++) {
-        mpegts_write_pmt(s, ts->services[i]);
-    }
-    put_flush_packet(&s->pb);
-
-    return 0;
-
- fail:
-    for(i = 0;i < s->nb_streams; i++) {
-        st = s->streams[i];
-        av_free(st->priv_data);
-    }
-    return -1;
-}
-
-/* send SDT, PAT and PMT tables regulary */
-static void retransmit_si_info(AVFormatContext *s)
-{
-    MpegTSWrite *ts = s->priv_data;
-    int i;
-
-    if (++ts->sdt_packet_count == ts->sdt_packet_freq) {
-        ts->sdt_packet_count = 0;
-        mpegts_write_sdt(s);
-    }
-    if (++ts->pat_packet_count == ts->pat_packet_freq) {
-        ts->pat_packet_count = 0;
-        mpegts_write_pat(s);
-        for(i = 0; i < ts->nb_services; i++) {
-            mpegts_write_pmt(s, ts->services[i]);
-        }
-    }
-}
-
-/* NOTE: pes_data contains all the PES packet */
-static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
-                             const uint8_t *payload, int payload_size,
-                             int64_t pts)
-{
-    MpegTSWriteStream *ts_st = st->priv_data;
-    uint8_t buf[TS_PACKET_SIZE];
-    uint8_t *q;
-    int val, is_start, len, header_len, write_pcr, private_code;
-    int afc_len, stuffing_len;
-    int64_t pcr = -1; /* avoid warning */
-
-    is_start = 1;
-    while (payload_size > 0) {
-        retransmit_si_info(s);
-
-        write_pcr = 0;
-        if (ts_st->pid == ts_st->service->pcr_pid) {
-            ts_st->service->pcr_packet_count++;
-            if (ts_st->service->pcr_packet_count >= 
-                ts_st->service->pcr_packet_freq) {
-                ts_st->service->pcr_packet_count = 0;
-                write_pcr = 1;
-                /* XXX: this is incorrect, but at least we have a PCR
-                   value */
-                pcr = pts;
-            }
-        }
-
-        /* prepare packet header */
-        q = buf;
-        *q++ = 0x47;
-        val = (ts_st->pid >> 8);
-        if (is_start)
-            val |= 0x40;
-        *q++ = val;
-        *q++ = ts_st->pid;
-        *q++ = 0x10 | ts_st->cc | (write_pcr ? 0x20 : 0);
-        ts_st->cc = (ts_st->cc + 1) & 0xf;
-        if (write_pcr) {
-            *q++ = 7; /* AFC length */
-            *q++ = 0x10; /* flags: PCR present */
-            *q++ = pcr >> 25;
-            *q++ = pcr >> 17;
-            *q++ = pcr >> 9;
-            *q++ = pcr >> 1;
-            *q++ = (pcr & 1) << 7;
-            *q++ = 0;
-        }
-        if (is_start) {
-            /* write PES header */
-            *q++ = 0x00;
-            *q++ = 0x00;
-            *q++ = 0x01;
-            private_code = 0;
-            if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
-                *q++ = 0xe0;
-            } else if (st->codec->codec_type == CODEC_TYPE_AUDIO &&
-                       (st->codec->codec_id == CODEC_ID_MP2 ||
-                        st->codec->codec_id == CODEC_ID_MP3)) {
-                *q++ = 0xc0; 
-            } else {
-                *q++ = 0xbd;
-                if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) {
-                    private_code = 0x20;
-                }
-            }
-            if (pts != AV_NOPTS_VALUE)
-                header_len = 8;
-            else
-                header_len = 3;
-            if (private_code != 0)
-                header_len++;
-            len = payload_size + header_len;
-            *q++ = len >> 8;
-            *q++ = len;
-            val = 0x80;
-            /* data alignment indicator is required for subtitle data */
-            if (st->codec->codec_type == CODEC_TYPE_SUBTITLE)
-                val |= 0x04;
-            *q++ = val;
-            if (pts != AV_NOPTS_VALUE) {
-                *q++ = 0x80; /* PTS only */
-                *q++ = 0x05; /* header len */
-                val = (0x02 << 4) | 
-                    (((pts >> 30) & 0x07) << 1) | 1;
-                *q++ = val;
-                val = (((pts >> 15) & 0x7fff) << 1) | 1;
-                *q++ = val >> 8;
-                *q++ = val;
-                val = (((pts) & 0x7fff) << 1) | 1;
-                *q++ = val >> 8;
-                *q++ = val;
-            } else {
-                *q++ = 0x00;
-                *q++ = 0x00;
-            }
-            if (private_code != 0)
-                *q++ = private_code;
-            is_start = 0;
-        }
-        /* header size */
-        header_len = q - buf;
-        /* data len */
-        len = TS_PACKET_SIZE - header_len;
-        if (len > payload_size)
-            len = payload_size;
-        stuffing_len = TS_PACKET_SIZE - header_len - len;
-        if (stuffing_len > 0) {
-            /* add stuffing with AFC */
-            if (buf[3] & 0x20) {
-                /* stuffing already present: increase its size */
-                afc_len = buf[4] + 1;
-                memmove(buf + 4 + afc_len + stuffing_len,
-                        buf + 4 + afc_len, 
-                        header_len - (4 + afc_len));
-                buf[4] += stuffing_len;
-                memset(buf + 4 + afc_len, 0xff, stuffing_len);
-            } else {
-                /* add stuffing */
-                memmove(buf + 4 + stuffing_len, buf + 4, header_len - 4);
-                buf[3] |= 0x20;
-                buf[4] = stuffing_len - 1;
-                if (stuffing_len >= 2) {
-                    buf[5] = 0x00;
-                    memset(buf + 6, 0xff, stuffing_len - 2);
-                }
-            }
-        }
-        memcpy(buf + TS_PACKET_SIZE - len, payload, len);
-        payload += len;
-        payload_size -= len;
-        put_buffer(&s->pb, buf, TS_PACKET_SIZE);
-    }
-    put_flush_packet(&s->pb);
-}
-
-static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    AVStream *st = s->streams[pkt->stream_index];
-    int size= pkt->size;
-    uint8_t *buf= pkt->data;
-    MpegTSWriteStream *ts_st = st->priv_data;
-    int len, max_payload_size;
-
-    if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) {
-        /* for subtitle, a single PES packet must be generated */
-        mpegts_write_pes(s, st, buf, size, pkt->pts);
-        return 0;
-    }
-    
-    max_payload_size = DEFAULT_PES_PAYLOAD_SIZE;
-    while (size > 0) {
-        len = max_payload_size - ts_st->payload_index;
-        if (len > size)
-            len = size;
-        memcpy(ts_st->payload + ts_st->payload_index, buf, len);
-        buf += len;
-        size -= len;
-        ts_st->payload_index += len;
-        if (ts_st->payload_pts == AV_NOPTS_VALUE)
-            ts_st->payload_pts = pkt->pts;
-        if (ts_st->payload_index >= max_payload_size) {
-            mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index,
-                             ts_st->payload_pts);
-            ts_st->payload_pts = AV_NOPTS_VALUE;
-            ts_st->payload_index = 0;
-        }
-    }
-    return 0;
-}
-
-static int mpegts_write_end(AVFormatContext *s)
-{
-    MpegTSWrite *ts = s->priv_data;
-    MpegTSWriteStream *ts_st;
-    MpegTSService *service;
-    AVStream *st;
-    int i;
-
-    /* flush current packets */
-    for(i = 0; i < s->nb_streams; i++) {
-        st = s->streams[i];
-        ts_st = st->priv_data;
-        if (ts_st->payload_index > 0) {
-            mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index,
-                             ts_st->payload_pts);
-        }
-    }
-    put_flush_packet(&s->pb);
-        
-    for(i = 0; i < ts->nb_services; i++) {
-        service = ts->services[i];
-        av_freep(&service->provider_name);
-        av_freep(&service->name);
-        av_free(service);
-    }
-    av_free(ts->services);
-
-    return 0;
-}
-
-AVOutputFormat mpegts_mux = {
-    "mpegts",
-    "MPEG2 transport stream format",
-    "video/x-mpegts",
-    "ts",
-    sizeof(MpegTSWrite),
-    CODEC_ID_MP2,
-    CODEC_ID_MPEG2VIDEO,
-    mpegts_write_header,
-    mpegts_write_packet,
-    mpegts_write_end,
-};
diff --git a/ffmpeg.src/libavformat/os_support.c b/ffmpeg.src/libavformat/os_support.c
deleted file mode 100644
index 16b7d5d..0000000
--- a/ffmpeg.src/libavformat/os_support.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Various utilities for ffmpeg system
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "config.h"
-#include "avformat.h"
-#ifdef CONFIG_WIN32
-#include <sys/types.h>
-#include <sys/timeb.h>
-#elif defined(CONFIG_OS2)
-#include <string.h>
-#include <sys/time.h>
-#else
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/time.h>
-#endif
-#include <time.h>
-
-/**
- * gets the current time in micro seconds.
- */
-int64_t av_gettime(void)
-{
-#ifdef CONFIG_WIN32
-    struct timeb tb;
-    _ftime(&tb);
-    return ((int64_t)tb.time * int64_t_C(1000) + (int64_t)tb.millitm) * int64_t_C(1000);
-#else
-    struct timeval tv;
-    gettimeofday(&tv,NULL);
-    return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
-#endif
-}
-
-#if !defined(HAVE_LOCALTIME_R)
-struct tm *localtime_r(const time_t *t, struct tm *tp)
-{
-    struct tm *l;
-    
-    l = localtime(t);
-    if (!l)
-        return 0;
-    *tp = *l;
-    return tp;
-}
-#endif /* !defined(HAVE_LOCALTIME_R) */
diff --git a/ffmpeg.src/libavformat/os_support.h b/ffmpeg.src/libavformat/os_support.h
deleted file mode 100644
index 4dd80a5..0000000
--- a/ffmpeg.src/libavformat/os_support.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef _OS_SUPPORT_H
-#define _OS_SUPPORT_H
-
-/**
- * @file os_support.h
- * miscellaneous OS support macros and functions.
- *
- * - usleep() (Win32, BeOS, OS/2)
- * - floatf() (OS/2)
- * - strcasecmp() (OS/2)
- */
-
-#ifdef __MINGW32__
-__declspec(dllimport) void __stdcall Sleep(unsigned long dwMilliseconds);
-// #  include <windows.h>
-#  define usleep(t)    Sleep((t) / 1000)
-#endif
-
-#ifdef __BEOS__
-#  ifndef usleep
-#    include <OS.h>
-#    define usleep(t)  snooze((bigtime_t)(t))
-#  endif
-#endif
-
-#if defined(CONFIG_OS2)
-#include <stdlib.h>
-static inline int usleep(unsigned int t) { return _sleep2(t / 1000); }
-static inline int strcasecmp(const char* s1, const char* s2) { return stricmp(s1,s2); }
-#endif
-
-#endif /* _OS_SUPPORT_H */
diff --git a/ffmpeg.src/libavformat/utils.c b/ffmpeg.src/libavformat/utils.c
deleted file mode 100644
index 6cdab28..0000000
--- a/ffmpeg.src/libavformat/utils.c
+++ /dev/null
@@ -1,3240 +0,0 @@
-/*
- * Various utilities for ffmpeg system
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include "avformat.h"
-
-#undef NDEBUG
-#include <assert.h>
-
-/**
- * @file libavformat/utils.c
- * Various utility functions for using ffmpeg library.
- */
-
-/** head of registered input format linked list. */
-AVInputFormat *first_iformat = NULL;
-/** head of registered output format linked list. */
-AVOutputFormat *first_oformat = NULL;
-/** head of registered image format linked list. */
-AVImageFormat *first_image_format = NULL;
-
-void av_register_input_format(AVInputFormat *format)
-{
-    AVInputFormat **p;
-    p = &first_iformat;
-    while (*p != NULL) p = &(*p)->next;
-    *p = format;
-    format->next = NULL;
-}
-
-void av_register_output_format(AVOutputFormat *format)
-{
-    AVOutputFormat **p;
-    p = &first_oformat;
-    while (*p != NULL) p = &(*p)->next;
-    *p = format;
-    format->next = NULL;
-}
-
-int match_ext(const char *filename, const char *extensions)
-{
-    const char *ext, *p;
-    char ext1[32], *q;
-
-    if(!filename)
-        return 0;
-    
-    ext = strrchr(filename, '.');
-    if (ext) {
-        ext++;
-        p = extensions;
-        for(;;) {
-            q = ext1;
-            while (*p != '\0' && *p != ',' && q-ext1<sizeof(ext1)-1) 
-                *q++ = *p++;
-            *q = '\0';
-            if (!strcasecmp(ext1, ext)) 
-                return 1;
-            if (*p == '\0') 
-                break;
-            p++;
-        }
-    }
-    return 0;
-}
-
-AVOutputFormat *guess_format(const char *short_name, const char *filename, 
-                             const char *mime_type)
-{
-    AVOutputFormat *fmt, *fmt_found;
-    int score_max, score;
-
-    /* specific test for image sequences */
-//     if (!short_name && filename && 
-//         filename_number_test(filename) >= 0 &&
-//         av_guess_image2_codec(filename) != CODEC_ID_NONE) {
-//         return guess_format("image2", NULL, NULL);
-//     }
-//     if (!short_name && filename && 
-//         filename_number_test(filename) >= 0 &&
-//         guess_image_format(filename)) {
-//         return guess_format("image", NULL, NULL);
-//     }
-
-    /* find the proper file type */
-    fmt_found = NULL;
-    score_max = 0;
-    fmt = first_oformat;
-    while (fmt != NULL) {
-        score = 0;
-        if (fmt->name && short_name && !strcmp(fmt->name, short_name))
-            score += 100;
-        if (fmt->mime_type && mime_type && !strcmp(fmt->mime_type, mime_type))
-            score += 10;
-        if (filename && fmt->extensions && 
-            match_ext(filename, fmt->extensions)) {
-            score += 5;
-        }
-        if (score > score_max) {
-            score_max = score;
-            fmt_found = fmt;
-        }
-        fmt = fmt->next;
-    }
-    return fmt_found;
-}   
-
-AVOutputFormat *guess_stream_format(const char *short_name, const char *filename, 
-                             const char *mime_type)
-{
-    AVOutputFormat *fmt = guess_format(short_name, filename, mime_type);
-
-    if (fmt) {
-        AVOutputFormat *stream_fmt;
-        char stream_format_name[64];
-
-        snprintf(stream_format_name, sizeof(stream_format_name), "%s_stream", fmt->name);
-        stream_fmt = guess_format(stream_format_name, NULL, NULL);
-
-        if (stream_fmt)
-            fmt = stream_fmt;
-    }
-
-    return fmt;
-}
-
-/**
- * Guesses the codec id based upon muxer and filename.
- */
-enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, 
-                            const char *filename, const char *mime_type, enum CodecType type){
-    if(type == CODEC_TYPE_VIDEO){
-        enum CodecID codec_id= CODEC_ID_NONE;
-
-//         if(!strcmp(fmt->name, "image2") || !strcmp(fmt->name, "image2pipe")){
-//             codec_id= av_guess_image2_codec(filename);
-//         }
-        if(codec_id == CODEC_ID_NONE)
-            codec_id= fmt->video_codec;
-        return codec_id;
-    }else if(type == CODEC_TYPE_AUDIO)
-        return fmt->audio_codec;
-    else
-        return CODEC_ID_NONE;
-}
-
-/**
- * finds AVInputFormat based on input format's short name.
- */
-AVInputFormat *av_find_input_format(const char *short_name)
-{
-    AVInputFormat *fmt;
-    for(fmt = first_iformat; fmt != NULL; fmt = fmt->next) {
-        if (!strcmp(fmt->name, short_name))
-            return fmt;
-    }
-    return NULL;
-}
-
-/* memory handling */
-
-/**
- * Default packet destructor.
- */
-void av_destruct_packet(AVPacket *pkt)
-{
-    av_free(pkt->data);
-    pkt->data = NULL; pkt->size = 0;
-}
-
-/**
- * Allocate the payload of a packet and intialized its fields to default values.
- *
- * @param pkt packet
- * @param size wanted payload size
- * @return 0 if OK. AVERROR_xxx otherwise.
- */
-int av_new_packet(AVPacket *pkt, int size)
-{
-    void *data;
-    if((unsigned)size > (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
-        return AVERROR_NOMEM;        
-    data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
-    if (!data)
-        return AVERROR_NOMEM;
-    memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
-
-    av_init_packet(pkt);
-    pkt->data = data; 
-    pkt->size = size;
-    pkt->destruct = av_destruct_packet;
-    return 0;
-}
-
-/**
- * Allocate and read the payload of a packet and intialized its fields to default values.
- *
- * @param pkt packet
- * @param size wanted payload size
- * @return >0 (read size) if OK. AVERROR_xxx otherwise.
- */
-int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size)
-{
-    int ret= av_new_packet(pkt, size);
-
-    if(ret<0)
-        return ret;
-
-    pkt->pos= url_ftell(s);
-
-    ret= get_buffer(s, pkt->data, size);
-    if(ret<=0)
-        av_free_packet(pkt);
-    else
-        pkt->size= ret;
-
-    return ret;
-}
-
-/* This is a hack - the packet memory allocation stuff is broken. The
-   packet is allocated if it was not really allocated */
-int av_dup_packet(AVPacket *pkt)
-{
-    if (pkt->destruct != av_destruct_packet) {
-        uint8_t *data;
-        /* we duplicate the packet and don't forget to put the padding
-           again */
-        if((unsigned)pkt->size > (unsigned)pkt->size + FF_INPUT_BUFFER_PADDING_SIZE)
-            return AVERROR_NOMEM;        
-        data = av_malloc(pkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
-        if (!data) {
-            return AVERROR_NOMEM;
-        }
-        memcpy(data, pkt->data, pkt->size);
-        memset(data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
-        pkt->data = data;
-        pkt->destruct = av_destruct_packet;
-    }
-    return 0;
-}
-
-/* fifo handling */
-
-int fifo_init(FifoBuffer *f, int size)
-{
-    f->buffer = av_malloc(size);
-    if (!f->buffer)
-        return -1;
-    f->end = f->buffer + size;
-    f->wptr = f->rptr = f->buffer;
-    return 0;
-}
-
-void fifo_free(FifoBuffer *f)
-{
-    av_free(f->buffer);
-}
-
-int fifo_size(FifoBuffer *f, uint8_t *rptr)
-{
-    int size;
-    
-    if(!rptr)
-        rptr= f->rptr;
-
-    if (f->wptr >= rptr) {
-        size = f->wptr - rptr;
-    } else {
-        size = (f->end - rptr) + (f->wptr - f->buffer);
-    }
-    return size;
-}
-
-/**
- * Get data from the fifo (returns -1 if not enough data).
- */
-int fifo_read(FifoBuffer *f, uint8_t *buf, int buf_size, uint8_t **rptr_ptr)
-{
-    uint8_t *rptr;
-    int size, len;
-
-    if(!rptr_ptr)
-        rptr_ptr= &f->rptr;
-    rptr = *rptr_ptr;
-
-    if (f->wptr >= rptr) {
-        size = f->wptr - rptr;
-    } else {
-        size = (f->end - rptr) + (f->wptr - f->buffer);
-    }
-    
-    if (size < buf_size)
-        return -1;
-    while (buf_size > 0) {
-        len = f->end - rptr;
-        if (len > buf_size)
-            len = buf_size;
-        memcpy(buf, rptr, len);
-        buf += len;
-        rptr += len;
-        if (rptr >= f->end)
-            rptr = f->buffer;
-        buf_size -= len;
-    }
-    *rptr_ptr = rptr;
-    return 0;
-}
-
-/**
- * Resizes a FIFO.
- */
-void fifo_realloc(FifoBuffer *f, unsigned int new_size){
-    unsigned int old_size= f->end - f->buffer;
-    
-    if(old_size < new_size){
-        uint8_t *old= f->buffer;
-
-        f->buffer= av_realloc(f->buffer, new_size);
-
-        f->rptr += f->buffer - old;
-        f->wptr += f->buffer - old;
-
-        if(f->wptr < f->rptr){
-            memmove(f->rptr + new_size - old_size, f->rptr, f->buffer + old_size - f->rptr);
-            f->rptr += new_size - old_size;
-        }
-        f->end= f->buffer + new_size;
-    }
-}
-
-void fifo_write(FifoBuffer *f, uint8_t *buf, int size, uint8_t **wptr_ptr)
-{
-    int len;
-    uint8_t *wptr;
-
-    if(!wptr_ptr)
-        wptr_ptr= &f->wptr;
-    wptr = *wptr_ptr;
-
-    while (size > 0) {
-        len = f->end - wptr;
-        if (len > size)
-            len = size;
-        memcpy(wptr, buf, len);
-        wptr += len;
-        if (wptr >= f->end)
-            wptr = f->buffer;
-        buf += len;
-        size -= len;
-    }
-    *wptr_ptr = wptr;
-}
-
-/* get data from the fifo (return -1 if not enough data) */
-int put_fifo(ByteIOContext *pb, FifoBuffer *f, int buf_size, uint8_t **rptr_ptr)
-{
-    uint8_t *rptr = *rptr_ptr;
-    int size, len;
-
-    if (f->wptr >= rptr) {
-        size = f->wptr - rptr;
-    } else {
-        size = (f->end - rptr) + (f->wptr - f->buffer);
-    }
-    
-    if (size < buf_size)
-        return -1;
-    while (buf_size > 0) {
-        len = f->end - rptr;
-        if (len > buf_size)
-            len = buf_size;
-        put_buffer(pb, rptr, len);
-        rptr += len;
-        if (rptr >= f->end)
-            rptr = f->buffer;
-        buf_size -= len;
-    }
-    *rptr_ptr = rptr;
-    return 0;
-}
-
-int filename_number_test(const char *filename)
-{
-    char buf[1024];
-    if(!filename)
-        return -1;
-    return get_frame_filename(buf, sizeof(buf), filename, 1);
-}
-
-/**
- * Guess file format.
- */
-AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened)
-{
-    AVInputFormat *fmt1, *fmt;
-    int score, score_max;
-
-    fmt = NULL;
-    score_max = 0;
-    for(fmt1 = first_iformat; fmt1 != NULL; fmt1 = fmt1->next) {
-        if (!is_opened && !(fmt1->flags & AVFMT_NOFILE))
-            continue;
-        score = 0;
-        if (fmt1->read_probe) {
-            score = fmt1->read_probe(pd);
-        } else if (fmt1->extensions) {
-            if (match_ext(pd->filename, fmt1->extensions)) {
-                score = 50;
-            }
-        } 
-        if (score > score_max) {
-            score_max = score;
-            fmt = fmt1;
-        }
-    }
-    return fmt;
-}
-
-/************************************************************/
-/* input media file */
-
-/**
- * Open a media file from an IO stream. 'fmt' must be specified.
- */
-static const char* format_to_name(void* ptr)
-{
-    AVFormatContext* fc = (AVFormatContext*) ptr;
-    if(fc->iformat) return fc->iformat->name;
-    else if(fc->oformat) return fc->oformat->name;
-    else return "NULL";
-}
-
-static const AVClass av_format_context_class = { "AVFormatContext", format_to_name };
-
-AVFormatContext *av_alloc_format_context(void)
-{
-    AVFormatContext *ic;
-    ic = av_mallocz(sizeof(AVFormatContext));
-    if (!ic) return ic;
-    ic->av_class = &av_format_context_class;
-    return ic;
-}
-
-/**
- * Allocates all the structures needed to read an input stream.
- *        This does not open the needed codecs for decoding the stream[s].
- */
-int av_open_input_stream(AVFormatContext **ic_ptr, 
-                         ByteIOContext *pb, const char *filename, 
-                         AVInputFormat *fmt, AVFormatParameters *ap)
-{
-    int err;
-    AVFormatContext *ic;
-
-    ic = av_alloc_format_context();
-    if (!ic) {
-        err = AVERROR_NOMEM;
-        goto fail;
-    }
-    ic->iformat = fmt;
-    if (pb)
-        ic->pb = *pb;
-    ic->duration = AV_NOPTS_VALUE;
-    ic->start_time = AV_NOPTS_VALUE;
-    pstrcpy(ic->filename, sizeof(ic->filename), filename);
-
-    /* allocate private data */
-    if (fmt->priv_data_size > 0) {
-        ic->priv_data = av_mallocz(fmt->priv_data_size);
-        if (!ic->priv_data) {
-            err = AVERROR_NOMEM;
-            goto fail;
-        }
-    } else {
-        ic->priv_data = NULL;
-    }
-
-    err = ic->iformat->read_header(ic, ap);
-    if (err < 0)
-        goto fail;
-
-    if (pb)
-        ic->data_offset = url_ftell(&ic->pb);
-
-    *ic_ptr = ic;
-    return 0;
- fail:
-    if (ic) {
-        av_freep(&ic->priv_data);
-    }
-    av_free(ic);
-    *ic_ptr = NULL;
-    return err;
-}
-
-/** Size of probe buffer, for guessing file type from file contents. */
-#define PROBE_BUF_SIZE 2048
-
-/**
- * Open a media file as input. The codec are not opened. Only the file
- * header (if present) is read.
- *
- * @param ic_ptr the opened media file handle is put here
- * @param filename filename to open.
- * @param fmt if non NULL, force the file format to use
- * @param buf_size optional buffer size (zero if default is OK)
- * @param ap additionnal parameters needed when opening the file (NULL if default)
- * @return 0 if OK. AVERROR_xxx otherwise.
- */
-int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, 
-                       AVInputFormat *fmt,
-                       int buf_size,
-                       AVFormatParameters *ap)
-{
-    int err, must_open_file, file_opened;
-    uint8_t buf[PROBE_BUF_SIZE];
-    AVProbeData probe_data, *pd = &probe_data;
-    ByteIOContext pb1, *pb = &pb1;
-    
-    file_opened = 0;
-    pd->filename = "";
-    if (filename)
-        pd->filename = filename;
-    pd->buf = buf;
-    pd->buf_size = 0;
-
-    if (!fmt) {
-        /* guess format if no file can be opened  */
-        fmt = av_probe_input_format(pd, 0);
-    }
-
-    /* do not open file if the format does not need it. XXX: specific
-       hack needed to handle RTSP/TCP */
-    must_open_file = 1;
-    if (fmt && (fmt->flags & AVFMT_NOFILE)) {
-        must_open_file = 0;
-        pb= NULL; //FIXME this or memset(pb, 0, sizeof(ByteIOContext)); otherwise its uninitalized
-    }
-
-    if (!fmt || must_open_file) {
-        /* if no file needed do not try to open one */
-        if (url_fopen(pb, filename, URL_RDONLY) < 0) {
-            err = AVERROR_IO;
-            goto fail;
-        }
-        file_opened = 1;
-        if (buf_size > 0) {
-            url_setbufsize(pb, buf_size);
-        }
-        if (!fmt) {
-            /* read probe data */
-            pd->buf_size = get_buffer(pb, buf, PROBE_BUF_SIZE);
-            if (url_fseek(pb, 0, SEEK_SET) == (offset_t)-EPIPE) {
-                url_fclose(pb);
-                if (url_fopen(pb, filename, URL_RDONLY) < 0) {
-                    err = AVERROR_IO;
-                    goto fail;
-                }
-            }
-        }
-    }
-    
-    /* guess file format */
-    if (!fmt) {
-        fmt = av_probe_input_format(pd, 1);
-    }
-
-    /* if still no format found, error */
-    if (!fmt) {
-        err = AVERROR_NOFMT;
-        goto fail;
-    }
-        
-    /* XXX: suppress this hack for redirectors */
-#ifdef CONFIG_NETWORK
-    if (fmt == &redir_demux) {
-        err = redir_open(ic_ptr, pb);
-        url_fclose(pb);
-        return err;
-    }
-#endif
-
-    /* check filename in case of an image number is expected */
-    if (fmt->flags & AVFMT_NEEDNUMBER) {
-        if (filename_number_test(filename) < 0) { 
-            err = AVERROR_NUMEXPECTED;
-            goto fail;
-        }
-    }
-    err = av_open_input_stream(ic_ptr, pb, filename, fmt, ap);
-    if (err)
-        goto fail;
-    return 0;
- fail:
-    if (file_opened)
-        url_fclose(pb);
-    *ic_ptr = NULL;
-    return err;
-    
-}
-
-/*******************************************************/
-
-/**
- * Read a transport packet from a media file.
- *
- * This function is absolete and should never be used.
- * Use av_read_frame() instead.
- * 
- * @param s media file handle
- * @param pkt is filled 
- * @return 0 if OK. AVERROR_xxx if error.  
- */
-int av_read_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    return s->iformat->read_packet(s, pkt);
-}
-
-/**********************************************************/
-
-/**
- * Get the number of samples of an audio frame. Return (-1) if error.
- */
-static int get_audio_frame_size(AVCodecContext *enc, int size)
-{
-    int frame_size;
-
-    if (enc->frame_size <= 1) {
-        /* specific hack for pcm codecs because no frame size is
-           provided */
-        switch(enc->codec_id) {
-        case CODEC_ID_PCM_S32LE:
-        case CODEC_ID_PCM_S32BE:
-        case CODEC_ID_PCM_U32LE:
-        case CODEC_ID_PCM_U32BE:
-            if (enc->channels == 0)
-                return -1;
-            frame_size = size / (4 * enc->channels);
-            break;
-        case CODEC_ID_PCM_S24LE:
-        case CODEC_ID_PCM_S24BE:
-        case CODEC_ID_PCM_U24LE:
-        case CODEC_ID_PCM_U24BE:
-        case CODEC_ID_PCM_S24DAUD:
-            if (enc->channels == 0)
-                return -1;
-            frame_size = size / (3 * enc->channels);
-            break;
-        case CODEC_ID_PCM_S16LE:
-        case CODEC_ID_PCM_S16BE:
-        case CODEC_ID_PCM_U16LE:
-        case CODEC_ID_PCM_U16BE:
-            if (enc->channels == 0)
-                return -1;
-            frame_size = size / (2 * enc->channels);
-            break;
-        case CODEC_ID_PCM_S8:
-        case CODEC_ID_PCM_U8:
-        case CODEC_ID_PCM_MULAW:
-        case CODEC_ID_PCM_ALAW:
-            if (enc->channels == 0)
-                return -1;
-            frame_size = size / (enc->channels);
-            break;
-        default:
-            /* used for example by ADPCM codecs */
-            if (enc->bit_rate == 0)
-                return -1;
-            frame_size = (size * 8 * enc->sample_rate) / enc->bit_rate;
-            break;
-        }
-    } else {
-        frame_size = enc->frame_size;
-    }
-    return frame_size;
-}
-
-
-/**
- * Return the frame duration in seconds, return 0 if not available.
- */
-static void compute_frame_duration(int *pnum, int *pden, AVStream *st, 
-                                   AVCodecParserContext *pc, AVPacket *pkt)
-{
-    int frame_size;
-
-    *pnum = 0;
-    *pden = 0;
-    switch(st->codec->codec_type) {
-    case CODEC_TYPE_VIDEO:
-        if(st->time_base.num*1000LL > st->time_base.den){
-            *pnum = st->time_base.num;
-            *pden = st->time_base.den;
-        }else if(st->codec->time_base.num*1000LL > st->codec->time_base.den){
-            *pnum = st->codec->time_base.num;
-            *pden = st->codec->time_base.den;
-            if (pc && pc->repeat_pict) {
-                *pden *= 2;
-                *pnum = (*pnum) * (2 + pc->repeat_pict);
-            }
-        }
-        break;
-    case CODEC_TYPE_AUDIO:
-        frame_size = get_audio_frame_size(st->codec, pkt->size);
-        if (frame_size < 0)
-            break;
-        *pnum = frame_size;
-        *pden = st->codec->sample_rate;
-        break;
-    default:
-        break;
-    }
-}
-
-static int is_intra_only(AVCodecContext *enc){
-    if(enc->codec_type == CODEC_TYPE_AUDIO){
-        return 1;
-    }else if(enc->codec_type == CODEC_TYPE_VIDEO){
-        switch(enc->codec_id){
-        case CODEC_ID_MJPEG:
-        case CODEC_ID_MJPEGB:
-        case CODEC_ID_LJPEG:
-        case CODEC_ID_RAWVIDEO:
-        case CODEC_ID_DVVIDEO:
-        case CODEC_ID_HUFFYUV:
-        case CODEC_ID_FFVHUFF:
-        case CODEC_ID_ASV1:
-        case CODEC_ID_ASV2:
-        case CODEC_ID_VCR1:
-            return 1;
-        default: break;
-        }
-    }
-    return 0;
-}
-
-static int64_t lsb2full(int64_t lsb, int64_t last_ts, int lsb_bits){
-    int64_t mask = lsb_bits < 64 ? (1LL<<lsb_bits)-1 : -1LL;
-    int64_t delta= last_ts - mask/2;
-    return  ((lsb - delta)&mask) + delta;
-}
-
-static void compute_pkt_fields(AVFormatContext *s, AVStream *st, 
-                               AVCodecParserContext *pc, AVPacket *pkt)
-{
-    int num, den, presentation_delayed;
-    /* handle wrapping */
-    if(st->cur_dts != AV_NOPTS_VALUE){
-        if(pkt->pts != AV_NOPTS_VALUE)
-            pkt->pts= lsb2full(pkt->pts, st->cur_dts, st->pts_wrap_bits);
-        if(pkt->dts != AV_NOPTS_VALUE)
-            pkt->dts= lsb2full(pkt->dts, st->cur_dts, st->pts_wrap_bits);
-    }
-    
-    if (pkt->duration == 0) {
-        compute_frame_duration(&num, &den, st, pc, pkt);
-        if (den && num) {
-            pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num);
-        }
-    }
-
-    if(is_intra_only(st->codec))
-        pkt->flags |= PKT_FLAG_KEY;
-
-    /* do we have a video B frame ? */
-    presentation_delayed = 0;
-    if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
-        /* XXX: need has_b_frame, but cannot get it if the codec is
-           not initialized */
-        if ((   st->codec->codec_id == CODEC_ID_H264 
-             || st->codec->has_b_frames) && 
-            pc && pc->pict_type != FF_B_TYPE)
-            presentation_delayed = 1;
-        /* this may be redundant, but it shouldnt hurt */
-        if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts > pkt->dts)
-            presentation_delayed = 1;
-    }
-    
-    if(st->cur_dts == AV_NOPTS_VALUE){
-        if(presentation_delayed) st->cur_dts = -pkt->duration;
-        else                     st->cur_dts = 0;
-    }
-
-//    av_log(NULL, AV_LOG_DEBUG, "IN delayed:%d pts:%lld, dts:%lld cur_dts:%lld st:%d pc:%p\n", presentation_delayed, pkt->pts, pkt->dts, st->cur_dts, pkt->stream_index, pc);
-    /* interpolate PTS and DTS if they are not present */
-    if (presentation_delayed) {
-        /* DTS = decompression time stamp */
-        /* PTS = presentation time stamp */
-        if (pkt->dts == AV_NOPTS_VALUE) {
-            /* if we know the last pts, use it */
-            if(st->last_IP_pts != AV_NOPTS_VALUE)
-                st->cur_dts = pkt->dts = st->last_IP_pts;
-            else
-                pkt->dts = st->cur_dts;
-        } else {
-            st->cur_dts = pkt->dts;
-        }
-        /* this is tricky: the dts must be incremented by the duration
-           of the frame we are displaying, i.e. the last I or P frame */
-        if (st->last_IP_duration == 0)
-            st->cur_dts += pkt->duration;
-        else
-            st->cur_dts += st->last_IP_duration;
-        st->last_IP_duration  = pkt->duration;
-        st->last_IP_pts= pkt->pts;
-        /* cannot compute PTS if not present (we can compute it only
-           by knowing the futur */
-    } else if(pkt->pts != AV_NOPTS_VALUE || pkt->dts != AV_NOPTS_VALUE || pkt->duration){
-        if(pkt->pts != AV_NOPTS_VALUE && pkt->duration){
-            int64_t old_diff= ABS(st->cur_dts - pkt->duration - pkt->pts);
-            int64_t new_diff= ABS(st->cur_dts - pkt->pts);
-            if(old_diff < new_diff && old_diff < (pkt->duration>>3)){
-                pkt->pts += pkt->duration;
-//                av_log(NULL, AV_LOG_DEBUG, "id:%d old:%Ld new:%Ld dur:%d cur:%Ld size:%d\n", pkt->stream_index, old_diff, new_diff, pkt->duration, st->cur_dts, pkt->size);
-            }
-        }
-    
-        /* presentation is not delayed : PTS and DTS are the same */
-        if (pkt->pts == AV_NOPTS_VALUE) {
-            if (pkt->dts == AV_NOPTS_VALUE) {
-                pkt->pts = st->cur_dts;
-                pkt->dts = st->cur_dts;
-            }
-            else {
-                st->cur_dts = pkt->dts;
-                pkt->pts = pkt->dts;
-            }
-        } else {
-            st->cur_dts = pkt->pts;
-            pkt->dts = pkt->pts;
-        }
-        st->cur_dts += pkt->duration;
-    }
-//    av_log(NULL, AV_LOG_DEBUG, "OUTdelayed:%d pts:%lld, dts:%lld cur_dts:%lld\n", presentation_delayed, pkt->pts, pkt->dts, st->cur_dts);
-    
-    /* update flags */
-    if (pc) {
-        pkt->flags = 0;
-        /* key frame computation */
-        switch(st->codec->codec_type) {
-        case CODEC_TYPE_VIDEO:
-            if (pc->pict_type == FF_I_TYPE)
-                pkt->flags |= PKT_FLAG_KEY;
-            break;
-        case CODEC_TYPE_AUDIO:
-            pkt->flags |= PKT_FLAG_KEY;
-            break;
-        default:
-            break;
-        }
-    }
-}
-
-void av_destruct_packet_nofree(AVPacket *pkt)
-{
-    pkt->data = NULL; pkt->size = 0;
-}
-
-static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
-{
-    AVStream *st;
-    int len, ret, i;
-
-    for(;;) {
-        /* select current input stream component */
-        st = s->cur_st;
-        if (st) {
-            if (!st->need_parsing || !st->parser) {
-                /* no parsing needed: we just output the packet as is */
-                /* raw data support */
-                *pkt = s->cur_pkt;
-                compute_pkt_fields(s, st, NULL, pkt);
-                s->cur_st = NULL;
-                return 0;
-            } else if (s->cur_len > 0 && st->discard < AVDISCARD_ALL) {
-                len = av_parser_parse(st->parser, st->codec, &pkt->data, &pkt->size, 
-                                      s->cur_ptr, s->cur_len,
-                                      s->cur_pkt.pts, s->cur_pkt.dts);
-                s->cur_pkt.pts = AV_NOPTS_VALUE;
-                s->cur_pkt.dts = AV_NOPTS_VALUE;
-                /* increment read pointer */
-                s->cur_ptr += len;
-                s->cur_len -= len;
-                
-                /* return packet if any */
-                if (pkt->size) {
-                got_packet:
-                    pkt->duration = 0;
-                    pkt->stream_index = st->index;
-                    pkt->pts = st->parser->pts;
-                    pkt->dts = st->parser->dts;
-                    pkt->destruct = av_destruct_packet_nofree;
-                    compute_pkt_fields(s, st, st->parser, pkt);
-                    return 0;
-                }
-            } else {
-                /* free packet */
-                av_free_packet(&s->cur_pkt); 
-                s->cur_st = NULL;
-            }
-        } else {
-            /* read next packet */
-            ret = av_read_packet(s, &s->cur_pkt);
-            if (ret < 0) {
-                if (ret == -EAGAIN)
-                    return ret;
-                /* return the last frames, if any */
-                for(i = 0; i < s->nb_streams; i++) {
-                    st = s->streams[i];
-                    if (st->parser && st->need_parsing) {
-                        av_parser_parse(st->parser, st->codec, 
-                                        &pkt->data, &pkt->size, 
-                                        NULL, 0, 
-                                        AV_NOPTS_VALUE, AV_NOPTS_VALUE);
-                        if (pkt->size)
-                            goto got_packet;
-                    }
-                }
-                /* no more packets: really terminates parsing */
-                return ret;
-            }
-            
-            st = s->streams[s->cur_pkt.stream_index];
-
-            s->cur_st = st;
-            s->cur_ptr = s->cur_pkt.data;
-            s->cur_len = s->cur_pkt.size;
-            if (st->need_parsing && !st->parser) {
-                st->parser = av_parser_init(st->codec->codec_id);
-                if (!st->parser) {
-                    /* no parser available : just output the raw packets */
-                    st->need_parsing = 0;
-                }else if(st->need_parsing == 2){
-                    st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
-                }
-            }
-        }
-    }
-}
-
-/**
- * Return the next frame of a stream.
- *
- * The returned packet is valid
- * until the next av_read_frame() or until av_close_input_file() and
- * must be freed with av_free_packet. For video, the packet contains
- * exactly one frame. For audio, it contains an integer number of
- * frames if each frame has a known fixed size (e.g. PCM or ADPCM
- * data). If the audio frames have a variable size (e.g. MPEG audio),
- * then it contains one frame.
- * 
- * pkt->pts, pkt->dts and pkt->duration are always set to correct
- * values in AV_TIME_BASE unit (and guessed if the format cannot
- * provided them). pkt->pts can be AV_NOPTS_VALUE if the video format
- * has B frames, so it is better to rely on pkt->dts if you do not
- * decompress the payload.
- * 
- * @return 0 if OK, < 0 if error or end of file.
- */
-int av_read_frame(AVFormatContext *s, AVPacket *pkt)
-{
-    AVPacketList *pktl;
-    int eof=0;
-    const int genpts= s->flags & AVFMT_FLAG_GENPTS;
-
-    for(;;){
-        pktl = s->packet_buffer;
-        if (pktl) {
-            AVPacket *next_pkt= &pktl->pkt;
-
-            if(genpts && next_pkt->dts != AV_NOPTS_VALUE){
-                while(pktl && next_pkt->pts == AV_NOPTS_VALUE){
-                    if(   pktl->pkt.stream_index == next_pkt->stream_index 
-                       && next_pkt->dts < pktl->pkt.dts
-                       && pktl->pkt.pts != pktl->pkt.dts //not b frame
-                       /*&& pktl->pkt.dts != AV_NOPTS_VALUE*/){
-                        next_pkt->pts= pktl->pkt.dts;
-                    }
-                    pktl= pktl->next;
-                }
-                pktl = s->packet_buffer;
-            }
-            
-            if(   next_pkt->pts != AV_NOPTS_VALUE 
-               || next_pkt->dts == AV_NOPTS_VALUE 
-               || !genpts || eof){
-                /* read packet from packet buffer, if there is data */
-                *pkt = *next_pkt;
-                s->packet_buffer = pktl->next;
-                av_free(pktl);
-                return 0;
-            }
-        }
-        if(genpts){
-            AVPacketList **plast_pktl= &s->packet_buffer;
-            int ret= av_read_frame_internal(s, pkt);
-            if(ret<0){
-                if(pktl && ret != -EAGAIN){
-                    eof=1;
-                    continue;
-                }else
-                    return ret;
-            }
-            
-            /* duplicate the packet */
-            if (av_dup_packet(pkt) < 0)
-                return AVERROR_NOMEM;
-
-            while(*plast_pktl) plast_pktl= &(*plast_pktl)->next; //FIXME maybe maintain pointer to the last?
-            
-            pktl = av_mallocz(sizeof(AVPacketList));
-            if (!pktl)
-                return AVERROR_NOMEM;
-    
-            /* add the packet in the buffered packet list */
-            *plast_pktl = pktl;
-            pktl->pkt= *pkt;            
-        }else{
-            assert(!s->packet_buffer);
-            return av_read_frame_internal(s, pkt);
-        }
-    }
-}
-
-/* XXX: suppress the packet queue */
-static void flush_packet_queue(AVFormatContext *s)
-{
-    AVPacketList *pktl;
-
-    for(;;) {
-        pktl = s->packet_buffer;
-        if (!pktl) 
-            break;
-        s->packet_buffer = pktl->next;
-        av_free_packet(&pktl->pkt);
-        av_free(pktl);
-    }
-}
-
-/*******************************************************/
-/* seek support */
-
-int av_find_default_stream_index(AVFormatContext *s)
-{
-    int i;
-    AVStream *st;
-
-    if (s->nb_streams <= 0)
-        return -1;
-    for(i = 0; i < s->nb_streams; i++) {
-        st = s->streams[i];
-        if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
-            return i;
-        }
-    }
-    return 0;
-}
-
-/**
- * Flush the frame reader.
- */
-static void av_read_frame_flush(AVFormatContext *s)
-{
-    AVStream *st;
-    int i;
-
-    flush_packet_queue(s);
-
-    /* free previous packet */
-    if (s->cur_st) {
-        if (s->cur_st->parser)
-            av_free_packet(&s->cur_pkt);
-        s->cur_st = NULL;
-    }
-    /* fail safe */
-    s->cur_ptr = NULL;
-    s->cur_len = 0;
-    
-    /* for each stream, reset read state */
-    for(i = 0; i < s->nb_streams; i++) {
-        st = s->streams[i];
-        
-        if (st->parser) {
-            av_parser_close(st->parser);
-            st->parser = NULL;
-        }
-        st->last_IP_pts = AV_NOPTS_VALUE;
-        st->cur_dts = 0; /* we set the current DTS to an unspecified origin */
-    }
-}
-
-/**
- * Updates cur_dts of all streams based on given timestamp and AVStream.
- *
- * Stream ref_st unchanged, others set cur_dts in their native timebase
- * only needed for timestamp wrapping or if (dts not set and pts!=dts)
- * @param timestamp new dts expressed in time_base of param ref_st
- * @param ref_st reference stream giving time_base of param timestamp
- */
-static void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp){
-    int i;
-
-    for(i = 0; i < s->nb_streams; i++) {
-        AVStream *st = s->streams[i];
-
-        st->cur_dts = av_rescale(timestamp, 
-                                 st->time_base.den * (int64_t)ref_st->time_base.num,
-                                 st->time_base.num * (int64_t)ref_st->time_base.den);
-    }
-}
-
-/**
- * Add a index entry into a sorted list updateing if it is already there.
- *
- * @param timestamp timestamp in the timebase of the given stream
- */
-int av_add_index_entry(AVStream *st,
-                            int64_t pos, int64_t timestamp, int distance, int flags)
-{
-    AVIndexEntry *entries, *ie;
-    int index;
-    
-    if((unsigned)st->nb_index_entries + 1 >= UINT_MAX / sizeof(AVIndexEntry))
-        return -1;
-    
-    entries = av_fast_realloc(st->index_entries,
-                              &st->index_entries_allocated_size,
-                              (st->nb_index_entries + 1) * 
-                              sizeof(AVIndexEntry));
-    if(!entries)
-        return -1;
-
-    st->index_entries= entries;
-
-    index= av_index_search_timestamp(st, timestamp, AVSEEK_FLAG_ANY);
-
-    if(index<0){
-        index= st->nb_index_entries++;
-        ie= &entries[index];
-        assert(index==0 || ie[-1].timestamp < timestamp);
-    }else{
-        ie= &entries[index];
-        if(ie->timestamp != timestamp){
-            if(ie->timestamp <= timestamp)
-                return -1;
-            memmove(entries + index + 1, entries + index, sizeof(AVIndexEntry)*(st->nb_index_entries - index));
-            st->nb_index_entries++;
-        }else if(ie->pos == pos && distance < ie->min_distance) //dont reduce the distance
-            distance= ie->min_distance;
-    }
-
-    ie->pos = pos;
-    ie->timestamp = timestamp;
-    ie->min_distance= distance;
-    ie->flags = flags;
-    
-    return index;
-}
-
-/**
- * build an index for raw streams using a parser.
- */
-static void av_build_index_raw(AVFormatContext *s)
-{
-    AVPacket pkt1, *pkt = &pkt1;
-    int ret;
-    AVStream *st;
-
-    st = s->streams[0];
-    av_read_frame_flush(s);
-    url_fseek(&s->pb, s->data_offset, SEEK_SET);
-
-    for(;;) {
-        ret = av_read_frame(s, pkt);
-        if (ret < 0)
-            break;
-        if (pkt->stream_index == 0 && st->parser &&
-            (pkt->flags & PKT_FLAG_KEY)) {
-            av_add_index_entry(st, st->parser->frame_offset, pkt->dts, 
-                            0, AVINDEX_KEYFRAME);
-        }
-        av_free_packet(pkt);
-    }
-}
-
-/**
- * Returns TRUE if we deal with a raw stream.
- *
- * Raw codec data and parsing needed.
- */
-static int is_raw_stream(AVFormatContext *s)
-{
-    AVStream *st;
-
-    if (s->nb_streams != 1)
-        return 0;
-    st = s->streams[0];
-    if (!st->need_parsing)
-        return 0;
-    return 1;
-}
-
-/**
- * Gets the index for a specific timestamp.
- * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond to 
- *                 the timestamp which is <= the requested one, if backward is 0 
- *                 then it will be >=
- *              if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
- * @return < 0 if no such timestamp could be found
- */
-int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp,
-                              int flags)
-{
-    AVIndexEntry *entries= st->index_entries;
-    int nb_entries= st->nb_index_entries;
-    int a, b, m;
-    int64_t timestamp;
-
-    a = - 1;
-    b = nb_entries;
-
-    while (b - a > 1) {
-        m = (a + b) >> 1;
-        timestamp = entries[m].timestamp;
-        if(timestamp >= wanted_timestamp)
-            b = m;
-        if(timestamp <= wanted_timestamp)
-            a = m;
-    }
-    m= (flags & AVSEEK_FLAG_BACKWARD) ? a : b;
-    
-    if(!(flags & AVSEEK_FLAG_ANY)){
-        while(m>=0 && m<nb_entries && !(entries[m].flags & AVINDEX_KEYFRAME)){
-            m += (flags & AVSEEK_FLAG_BACKWARD) ? -1 : 1;
-        }
-    }
-
-    if(m == nb_entries) 
-        return -1;
-    return  m;
-}
-
-#define DEBUG_SEEK
-
-/**
- * Does a binary search using av_index_search_timestamp() and AVCodec.read_timestamp().
- * this isnt supposed to be called directly by a user application, but by demuxers
- * @param target_ts target timestamp in the time base of the given stream
- * @param stream_index stream number
- */
-int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){
-    AVInputFormat *avif= s->iformat;
-    int64_t pos_min, pos_max, pos, pos_limit;
-    int64_t ts_min, ts_max, ts;
-    int64_t start_pos, filesize;
-    int index, no_change;
-    AVStream *st;
-
-    if (stream_index < 0)
-        return -1;
-    
-#ifdef DEBUG_SEEK
-    av_log(s, AV_LOG_DEBUG, "read_seek: %d %lld\n", stream_index, target_ts);
-#endif
-
-    ts_max=
-    ts_min= AV_NOPTS_VALUE;
-    pos_limit= -1; //gcc falsely says it may be uninitalized
-
-    st= s->streams[stream_index];
-    if(st->index_entries){
-        AVIndexEntry *e;
-
-        index= av_index_search_timestamp(st, target_ts, flags | AVSEEK_FLAG_BACKWARD); //FIXME whole func must be checked for non keyframe entries in index case, especially read_timestamp()
-        index= FFMAX(index, 0);
-        e= &st->index_entries[index];
-
-        if(e->timestamp <= target_ts || e->pos == e->min_distance){
-            pos_min= e->pos;
-            ts_min= e->timestamp;
-#ifdef DEBUG_SEEK
-        av_log(s, AV_LOG_DEBUG, "using cached pos_min=0x%llx dts_min=%lld\n", 
-               pos_min,ts_min);
-#endif
-        }else{
-            assert(index==0);
-        }
-        
-        index= av_index_search_timestamp(st, target_ts, flags & ~AVSEEK_FLAG_BACKWARD); 
-        assert(index < st->nb_index_entries);
-        if(index >= 0){
-            e= &st->index_entries[index];
-            assert(e->timestamp >= target_ts);
-            pos_max= e->pos;
-            ts_max= e->timestamp;
-            pos_limit= pos_max - e->min_distance;
-#ifdef DEBUG_SEEK
-        av_log(s, AV_LOG_DEBUG, "using cached pos_max=0x%llx pos_limit=0x%llx dts_max=%lld\n", 
-               pos_max,pos_limit, ts_max);
-#endif
-        }
-    }
-
-    if(ts_min == AV_NOPTS_VALUE){
-        pos_min = s->data_offset;
-        ts_min = avif->read_timestamp(s, stream_index, &pos_min, INT64_MAX);
-        if (ts_min == AV_NOPTS_VALUE)
-            return -1;
-    }
-
-    if(ts_max == AV_NOPTS_VALUE){
-        int step= 1024;
-        filesize = url_fsize(&s->pb);
-        pos_max = filesize - 1;
-        do{
-            pos_max -= step;
-            ts_max = avif->read_timestamp(s, stream_index, &pos_max, pos_max + step);
-            step += step;
-        }while(ts_max == AV_NOPTS_VALUE && pos_max >= step);
-        if (ts_max == AV_NOPTS_VALUE)
-            return -1;
-        
-        for(;;){
-            int64_t tmp_pos= pos_max + 1;
-            int64_t tmp_ts= avif->read_timestamp(s, stream_index, &tmp_pos, INT64_MAX);
-            if(tmp_ts == AV_NOPTS_VALUE)
-                break;
-            ts_max= tmp_ts;
-            pos_max= tmp_pos;
-            if(tmp_pos >= filesize)
-                break;
-        }
-        pos_limit= pos_max;
-    }
-
-    no_change=0;
-    while (pos_min < pos_limit) {
-#ifdef DEBUG_SEEK
-        av_log(s, AV_LOG_DEBUG, "pos_min=0x%llx pos_max=0x%llx dts_min=%lld dts_max=%lld\n", 
-               pos_min, pos_max,
-               ts_min, ts_max);
-#endif
-        assert(pos_limit <= pos_max);
-
-        if(no_change==0){
-            int64_t approximate_keyframe_distance= pos_max - pos_limit;
-            // interpolate position (better than dichotomy)
-            pos = av_rescale(target_ts - ts_min, pos_max - pos_min, ts_max - ts_min)
-                + pos_min - approximate_keyframe_distance;
-        }else if(no_change==1){
-            // bisection, if interpolation failed to change min or max pos last time
-            pos = (pos_min + pos_limit)>>1;
-        }else{
-            // linear search if bisection failed, can only happen if there are very few or no keframes between min/max
-            pos=pos_min;
-        }
-        if(pos <= pos_min)
-            pos= pos_min + 1;
-        else if(pos > pos_limit)
-            pos= pos_limit;
-        start_pos= pos;
-
-        ts = avif->read_timestamp(s, stream_index, &pos, INT64_MAX); //may pass pos_limit instead of -1
-        if(pos == pos_max)
-            no_change++;
-        else
-            no_change=0;
-#ifdef DEBUG_SEEK
-av_log(s, AV_LOG_DEBUG, "%Ld %Ld %Ld / %Ld %Ld %Ld target:%Ld limit:%Ld start:%Ld noc:%d\n", pos_min, pos, pos_max, ts_min, ts, ts_max, target_ts, pos_limit, start_pos, no_change);
-#endif
-        assert(ts != AV_NOPTS_VALUE);
-        if (target_ts <= ts) {
-            pos_limit = start_pos - 1;
-            pos_max = pos;
-            ts_max = ts;
-        }
-        if (target_ts >= ts) {
-            pos_min = pos;
-            ts_min = ts;
-        }
-    }
-    
-    pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max;
-    ts  = (flags & AVSEEK_FLAG_BACKWARD) ?  ts_min :  ts_max;
-#ifdef DEBUG_SEEK
-    pos_min = pos;
-    ts_min = avif->read_timestamp(s, stream_index, &pos_min, INT64_MAX);
-    pos_min++;
-    ts_max = avif->read_timestamp(s, stream_index, &pos_min, INT64_MAX);
-    av_log(s, AV_LOG_DEBUG, "pos=0x%llx %lld<=%lld<=%lld\n", 
-           pos, ts_min, target_ts, ts_max);
-#endif
-    /* do the seek */
-    url_fseek(&s->pb, pos, SEEK_SET);
-
-    av_update_cur_dts(s, st, ts);
-
-    return 0;
-}
-
-static int av_seek_frame_byte(AVFormatContext *s, int stream_index, int64_t pos, int flags){
-    int64_t pos_min, pos_max;
-#if 0
-    AVStream *st;
-
-    if (stream_index < 0)
-        return -1;
-
-    st= s->streams[stream_index];
-#endif
-
-    pos_min = s->data_offset;
-    pos_max = url_fsize(&s->pb) - 1;
-
-    if     (pos < pos_min) pos= pos_min;
-    else if(pos > pos_max) pos= pos_max;
-
-    url_fseek(&s->pb, pos, SEEK_SET);
-
-#if 0
-    av_update_cur_dts(s, st, ts);
-#endif
-    return 0;
-}
-
-static int av_seek_frame_generic(AVFormatContext *s, 
-                                 int stream_index, int64_t timestamp, int flags)
-{
-    int index;
-    AVStream *st;
-    AVIndexEntry *ie;
-
-    if (!s->index_built) {
-        if (is_raw_stream(s)) {
-            av_build_index_raw(s);
-        } else {
-            return -1;
-        }
-        s->index_built = 1;
-    }
-
-    st = s->streams[stream_index];
-    index = av_index_search_timestamp(st, timestamp, flags);
-    if (index < 0)
-        return -1;
-
-    /* now we have found the index, we can seek */
-    ie = &st->index_entries[index];
-    av_read_frame_flush(s);
-    url_fseek(&s->pb, ie->pos, SEEK_SET);
-
-    av_update_cur_dts(s, st, ie->timestamp);
-
-    return 0;
-}
-
-/**
- * Seek to the key frame at timestamp.
- * 'timestamp' in 'stream_index'.
- * @param stream_index If stream_index is (-1), a default
- * stream is selected, and timestamp is automatically converted 
- * from AV_TIME_BASE units to the stream specific time_base.
- * @param timestamp timestamp in AVStream.time_base units
- *        or if there is no stream specified then in AV_TIME_BASE units
- * @param flags flags which select direction and seeking mode
- * @return >= 0 on success
- */
-int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
-{
-    int ret;
-    AVStream *st;
-    
-    av_read_frame_flush(s);
-    
-    if(flags & AVSEEK_FLAG_BYTE)
-        return av_seek_frame_byte(s, stream_index, timestamp, flags);
-    
-    if(stream_index < 0){
-        stream_index= av_find_default_stream_index(s);
-        if(stream_index < 0)
-            return -1;
-            
-        st= s->streams[stream_index];
-       /* timestamp for default must be expressed in AV_TIME_BASE units */
-        timestamp = av_rescale(timestamp, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num);
-    }
-    st= s->streams[stream_index];
-
-    /* first, we try the format specific seek */
-    if (s->iformat->read_seek)
-        ret = s->iformat->read_seek(s, stream_index, timestamp, flags);
-    else
-        ret = -1;
-    if (ret >= 0) {
-        return 0;
-    }
-
-    if(s->iformat->read_timestamp)
-        return av_seek_frame_binary(s, stream_index, timestamp, flags);
-    else
-        return av_seek_frame_generic(s, stream_index, timestamp, flags);
-}
-
-/*******************************************************/
-
-/**
- * Returns TRUE if the stream has accurate timings in any stream.
- *
- * @return TRUE if the stream has accurate timings for at least one component.
- */
-static int av_has_timings(AVFormatContext *ic)
-{
-    int i;
-    AVStream *st;
-
-    for(i = 0;i < ic->nb_streams; i++) {
-        st = ic->streams[i];
-        if (st->start_time != AV_NOPTS_VALUE &&
-            st->duration != AV_NOPTS_VALUE)
-            return 1;
-    }
-    return 0;
-}
-
-/**
- * Estimate the stream timings from the one of each components.
- *
- * Also computes the global bitrate if possible.
- */
-static void av_update_stream_timings(AVFormatContext *ic)
-{
-    int64_t start_time, start_time1, end_time, end_time1;
-    int i;
-    AVStream *st;
-
-    start_time = MAXINT64;
-    end_time = MININT64;
-    for(i = 0;i < ic->nb_streams; i++) {
-        st = ic->streams[i];
-        if (st->start_time != AV_NOPTS_VALUE) {
-            start_time1= av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q);
-            if (start_time1 < start_time)
-                start_time = start_time1;
-            if (st->duration != AV_NOPTS_VALUE) {
-                end_time1 = start_time1
-                          + av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q);
-                if (end_time1 > end_time)
-                    end_time = end_time1;
-            }
-        }
-    }
-    if (start_time != MAXINT64) {
-        ic->start_time = start_time;
-        if (end_time != MININT64) {
-            ic->duration = end_time - start_time;
-            if (ic->file_size > 0) {
-                /* compute the bit rate */
-                ic->bit_rate = (double)ic->file_size * 8.0 * AV_TIME_BASE / 
-                    (double)ic->duration;
-            }
-        }
-    }
-
-}
-
-static void fill_all_stream_timings(AVFormatContext *ic)
-{
-    int i;
-    AVStream *st;
-
-    av_update_stream_timings(ic);
-    for(i = 0;i < ic->nb_streams; i++) {
-        st = ic->streams[i];
-        if (st->start_time == AV_NOPTS_VALUE) {
-            if(ic->start_time != AV_NOPTS_VALUE)
-                st->start_time = av_rescale_q(ic->start_time, AV_TIME_BASE_Q, st->time_base);
-            if(ic->duration != AV_NOPTS_VALUE)
-                st->duration = av_rescale_q(ic->duration, AV_TIME_BASE_Q, st->time_base);
-        }
-    }
-}
-
-static void av_estimate_timings_from_bit_rate(AVFormatContext *ic)
-{
-    int64_t filesize, duration;
-    int bit_rate, i;
-    AVStream *st;
-
-    /* if bit_rate is already set, we believe it */
-    if (ic->bit_rate == 0) {
-        bit_rate = 0;
-        for(i=0;i<ic->nb_streams;i++) {
-            st = ic->streams[i];
-            bit_rate += st->codec->bit_rate;
-        }
-        ic->bit_rate = bit_rate;
-    }
-
-    /* if duration is already set, we believe it */
-    if (ic->duration == AV_NOPTS_VALUE && 
-        ic->bit_rate != 0 && 
-        ic->file_size != 0)  {
-        filesize = ic->file_size;
-        if (filesize > 0) {
-            for(i = 0; i < ic->nb_streams; i++) {
-                st = ic->streams[i];
-                duration= av_rescale(8*filesize, st->time_base.den, ic->bit_rate*(int64_t)st->time_base.num);
-                if (st->start_time == AV_NOPTS_VALUE ||
-                    st->duration == AV_NOPTS_VALUE) {
-                    st->start_time = 0;
-                    st->duration = duration;
-                }
-            }
-        }
-    }
-}
-
-#define DURATION_MAX_READ_SIZE 250000
-
-/* only usable for MPEG-PS streams */
-static void av_estimate_timings_from_pts(AVFormatContext *ic)
-{
-    AVPacket pkt1, *pkt = &pkt1;
-    AVStream *st;
-    int read_size, i, ret;
-    int64_t end_time;
-    int64_t filesize, offset, duration;
-    
-    /* free previous packet */
-    if (ic->cur_st && ic->cur_st->parser)
-        av_free_packet(&ic->cur_pkt); 
-    ic->cur_st = NULL;
-
-    /* flush packet queue */
-    flush_packet_queue(ic);
-
-    for(i=0;i<ic->nb_streams;i++) {
-        st = ic->streams[i];
-        if (st->parser) {
-            av_parser_close(st->parser);
-            st->parser= NULL;
-        }
-    }
-    
-    /* we read the first packets to get the first PTS (not fully
-       accurate, but it is enough now) */
-    url_fseek(&ic->pb, 0, SEEK_SET);
-    read_size = 0;
-    for(;;) {
-        if (read_size >= DURATION_MAX_READ_SIZE)
-            break;
-        /* if all info is available, we can stop */
-        for(i = 0;i < ic->nb_streams; i++) {
-            st = ic->streams[i];
-            if (st->start_time == AV_NOPTS_VALUE)
-                break;
-        }
-        if (i == ic->nb_streams)
-            break;
-
-        ret = av_read_packet(ic, pkt);
-        if (ret != 0)
-            break;
-        read_size += pkt->size;
-        st = ic->streams[pkt->stream_index];
-        if (pkt->pts != AV_NOPTS_VALUE) {
-            if (st->start_time == AV_NOPTS_VALUE)
-                st->start_time = pkt->pts;
-        }
-        av_free_packet(pkt);
-    }
-
-    /* estimate the end time (duration) */
-    /* XXX: may need to support wrapping */
-    filesize = ic->file_size;
-    offset = filesize - DURATION_MAX_READ_SIZE;
-    if (offset < 0)
-        offset = 0;
-
-    url_fseek(&ic->pb, offset, SEEK_SET);
-    read_size = 0;
-    for(;;) {
-        if (read_size >= DURATION_MAX_READ_SIZE)
-            break;
-        /* if all info is available, we can stop */
-        for(i = 0;i < ic->nb_streams; i++) {
-            st = ic->streams[i];
-            if (st->duration == AV_NOPTS_VALUE)
-                break;
-        }
-        if (i == ic->nb_streams)
-            break;
-        
-        ret = av_read_packet(ic, pkt);
-        if (ret != 0)
-            break;
-        read_size += pkt->size;
-        st = ic->streams[pkt->stream_index];
-        if (pkt->pts != AV_NOPTS_VALUE) {
-            end_time = pkt->pts;
-            duration = end_time - st->start_time;
-            if (duration > 0) {
-                if (st->duration == AV_NOPTS_VALUE ||
-                    st->duration < duration)
-                    st->duration = duration;
-            }
-        }
-        av_free_packet(pkt);
-    }
-    
-    fill_all_stream_timings(ic);
-
-    url_fseek(&ic->pb, 0, SEEK_SET);
-}
-
-static void av_estimate_timings(AVFormatContext *ic)
-{
-    int64_t file_size;
-
-    /* get the file size, if possible */
-    if (ic->iformat->flags & AVFMT_NOFILE) {
-        file_size = 0;
-    } else {
-        file_size = url_fsize(&ic->pb);
-        if (file_size < 0)
-            file_size = 0;
-    }
-    ic->file_size = file_size;
-
-    if ((ic->iformat == &mpegps_demux || ic->iformat == &mpegts_demux) && file_size && !ic->pb.is_streamed) {
-        /* get accurate estimate from the PTSes */
-        av_estimate_timings_from_pts(ic);
-    } else if (av_has_timings(ic)) {
-        /* at least one components has timings - we use them for all
-           the components */
-        fill_all_stream_timings(ic);
-    } else {
-        /* less precise: use bit rate info */
-        av_estimate_timings_from_bit_rate(ic);
-    }
-    av_update_stream_timings(ic);
-
-#if 0
-    {
-        int i;
-        AVStream *st;
-        for(i = 0;i < ic->nb_streams; i++) {
-            st = ic->streams[i];
-        printf("%d: start_time: %0.3f duration: %0.3f\n", 
-               i, (double)st->start_time / AV_TIME_BASE, 
-               (double)st->duration / AV_TIME_BASE);
-        }
-        printf("stream: start_time: %0.3f duration: %0.3f bitrate=%d kb/s\n", 
-               (double)ic->start_time / AV_TIME_BASE, 
-               (double)ic->duration / AV_TIME_BASE,
-               ic->bit_rate / 1000);
-    }
-#endif
-}
-
-static int has_codec_parameters(AVCodecContext *enc)
-{
-    int val;
-    switch(enc->codec_type) {
-    case CODEC_TYPE_AUDIO:
-        val = enc->sample_rate;
-        break;
-    case CODEC_TYPE_VIDEO:
-        val = enc->width && enc->pix_fmt != PIX_FMT_NONE;
-        break;
-    default:
-        val = 1;
-        break;
-    }
-    return (val != 0);
-}
-
-static int try_decode_frame(AVStream *st, const uint8_t *data, int size)
-{
-    int16_t *samples;
-    AVCodec *codec;
-    int got_picture, ret=0;
-    AVFrame picture;
-    
-  if(!st->codec->codec){
-    codec = avcodec_find_decoder(st->codec->codec_id);
-    if (!codec)
-        return -1;
-    ret = avcodec_open(st->codec, codec);
-    if (ret < 0)
-        return ret;
-  }
-
-  if(!has_codec_parameters(st->codec)){
-    switch(st->codec->codec_type) {
-    case CODEC_TYPE_VIDEO:
-        ret = avcodec_decode_video(st->codec, &picture, 
-                                   &got_picture, (uint8_t *)data, size);
-        break;
-    case CODEC_TYPE_AUDIO:
-        samples = av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);
-        if (!samples)
-            goto fail;
-        ret = avcodec_decode_audio(st->codec, samples, 
-                                   &got_picture, (uint8_t *)data, size);
-        av_free(samples);
-        break;
-    default:
-        break;
-    }
-  }
- fail:
-    return ret;
-}
-
-/* absolute maximum size we read until we abort */
-#define MAX_READ_SIZE        5000000
-
-/* maximum duration until we stop analysing the stream */
-#define MAX_STREAM_DURATION  ((int)(AV_TIME_BASE * 2.0))
-
-/**
- * Read the beginning of a media file to get stream information. This
- * is useful for file formats with no headers such as MPEG. This
- * function also compute the real frame rate in case of mpeg2 repeat
- * frame mode.
- *
- * @param ic media file handle
- * @return >=0 if OK. AVERROR_xxx if error.  
- * @todo let user decide somehow what information is needed so we dont waste time geting stuff the user doesnt need
- */
-int av_find_stream_info(AVFormatContext *ic)
-{
-    int i, count, ret, read_size;
-    AVStream *st;
-    AVPacket pkt1, *pkt;
-    AVPacketList *pktl=NULL, **ppktl;
-    int64_t last_dts[MAX_STREAMS];
-    int64_t duration_sum[MAX_STREAMS];
-    int duration_count[MAX_STREAMS]={0};
-
-    for(i=0;i<ic->nb_streams;i++) {
-        st = ic->streams[i];
-        if(st->codec->codec_type == CODEC_TYPE_VIDEO){
-/*            if(!st->time_base.num)
-                st->time_base= */
-            if(!st->codec->time_base.num)
-                st->codec->time_base= st->time_base;
-        }
-        //only for the split stuff
-        if (!st->parser) {
-            st->parser = av_parser_init(st->codec->codec_id);
-            if(st->need_parsing == 2 && st->parser){
-                st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
-            }
-        }
-    }
-
-    for(i=0;i<MAX_STREAMS;i++){
-        last_dts[i]= AV_NOPTS_VALUE;
-        duration_sum[i]= INT64_MAX;
-    }
-    
-    count = 0;
-    read_size = 0;
-    ppktl = &ic->packet_buffer;
-    for(;;) {
-        /* check if one codec still needs to be handled */
-        for(i=0;i<ic->nb_streams;i++) {
-            st = ic->streams[i];
-            if (!has_codec_parameters(st->codec))
-                break;
-            /* variable fps and no guess at the real fps */
-            if(   st->codec->time_base.den >= 1000LL*st->codec->time_base.num
-               && duration_count[i]<20 && st->codec->codec_type == CODEC_TYPE_VIDEO)
-                break;
-            if(st->parser && st->parser->parser->split && !st->codec->extradata)
-                break;
-        }
-        if (i == ic->nb_streams) {
-            /* NOTE: if the format has no header, then we need to read
-               some packets to get most of the streams, so we cannot
-               stop here */
-            if (!(ic->ctx_flags & AVFMTCTX_NOHEADER)) {
-                /* if we found the info for all the codecs, we can stop */
-                ret = count;
-                break;
-            }
-        } else {
-            /* we did not get all the codec info, but we read too much data */
-            if (read_size >= MAX_READ_SIZE) {
-                ret = count;
-                break;
-            }
-        }
-
-        /* NOTE: a new stream can be added there if no header in file
-           (AVFMTCTX_NOHEADER) */
-        ret = av_read_frame_internal(ic, &pkt1);
-        if (ret < 0) {
-            /* EOF or error */
-            ret = -1; /* we could not have all the codec parameters before EOF */
-            for(i=0;i<ic->nb_streams;i++) {
-                st = ic->streams[i];
-                if (!has_codec_parameters(st->codec))
-                    break;
-            }
-            if (i == ic->nb_streams)
-                ret = 0;
-            break;
-        }
-
-        pktl = av_mallocz(sizeof(AVPacketList));
-        if (!pktl) {
-            ret = AVERROR_NOMEM;
-            break;
-        }
-
-        /* add the packet in the buffered packet list */
-        *ppktl = pktl;
-        ppktl = &pktl->next;
-
-        pkt = &pktl->pkt;
-        *pkt = pkt1;
-        
-        /* duplicate the packet */
-        if (av_dup_packet(pkt) < 0) {
-                ret = AVERROR_NOMEM;
-                break;
-        }
-
-        read_size += pkt->size;
-
-        st = ic->streams[pkt->stream_index];
-        st->codec_info_duration += pkt->duration;
-        if (pkt->duration != 0)
-            st->codec_info_nb_frames++;
-
-        {
-            int index= pkt->stream_index;
-            int64_t last= last_dts[index];
-            int64_t duration= pkt->dts - last;
-
-            if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && duration>0){
-                if(duration*duration_count[index]*10/9 < duration_sum[index]){
-                    duration_sum[index]= duration;
-                    duration_count[index]=1;
-                }else{
-                    int factor= av_rescale(duration, duration_count[index], duration_sum[index]);
-                    duration_sum[index] += duration;
-                    duration_count[index]+= factor;
-                }
-                if(st->codec_info_nb_frames == 0 && 0)
-                    st->codec_info_duration += duration;
-            }
-            last_dts[pkt->stream_index]= pkt->dts;
-        }
-        if(st->parser && st->parser->parser->split && !st->codec->extradata){
-            int i= st->parser->parser->split(st->codec, pkt->data, pkt->size);
-            if(i){
-                st->codec->extradata_size= i;
-                st->codec->extradata= av_malloc(st->codec->extradata_size);
-                memcpy(st->codec->extradata, pkt->data, st->codec->extradata_size);
-            }
-        }
-        
-        /* if still no information, we try to open the codec and to
-           decompress the frame. We try to avoid that in most cases as
-           it takes longer and uses more memory. For MPEG4, we need to
-           decompress for Quicktime. */
-        if (!has_codec_parameters(st->codec) /*&&
-            (st->codec->codec_id == CODEC_ID_FLV1 ||
-             st->codec->codec_id == CODEC_ID_H264 ||
-             st->codec->codec_id == CODEC_ID_H263 ||
-             st->codec->codec_id == CODEC_ID_H261 ||
-             st->codec->codec_id == CODEC_ID_VORBIS ||
-             st->codec->codec_id == CODEC_ID_MJPEG ||
-             st->codec->codec_id == CODEC_ID_PNG ||
-             st->codec->codec_id == CODEC_ID_PAM ||
-             st->codec->codec_id == CODEC_ID_PGM ||
-             st->codec->codec_id == CODEC_ID_PGMYUV ||
-             st->codec->codec_id == CODEC_ID_PBM ||
-             st->codec->codec_id == CODEC_ID_PPM ||
-             st->codec->codec_id == CODEC_ID_SHORTEN ||
-             (st->codec->codec_id == CODEC_ID_MPEG4 && !st->need_parsing))*/)
-            try_decode_frame(st, pkt->data, pkt->size);
-        
-        if (av_rescale_q(st->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= MAX_STREAM_DURATION) {
-            break;
-        }
-        count++;
-    }
-
-    // close codecs which where opened in try_decode_frame()
-    for(i=0;i<ic->nb_streams;i++) {
-        st = ic->streams[i];
-        if(st->codec->codec)
-            avcodec_close(st->codec);
-    }
-    for(i=0;i<ic->nb_streams;i++) {
-        st = ic->streams[i];
-        if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
-            if(st->codec->codec_id == CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_sample)
-                st->codec->codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
-
-            if(duration_count[i] && st->codec->time_base.num*1000LL <= st->codec->time_base.den &&
-               st->time_base.num*duration_sum[i]/duration_count[i]*1000LL > st->time_base.den){
-                AVRational fps1;
-                int64_t num, den;
-
-                num= st->time_base.den*duration_count[i];
-                den= st->time_base.num*duration_sum[i];
-                
-                av_reduce(&fps1.num, &fps1.den, num*1001, den*1000, FFMAX(st->time_base.den, st->time_base.num)/4);
-                av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, num, den, FFMAX(st->time_base.den, st->time_base.num)/4);
-                if(fps1.num < st->r_frame_rate.num && fps1.den == 1 && (fps1.num==24 || fps1.num==30)){ //FIXME better decission
-                    st->r_frame_rate.num= fps1.num*1000;
-                    st->r_frame_rate.den= fps1.den*1001;
-                }
-            }
-
-            /* set real frame rate info */
-            /* compute the real frame rate for telecine */
-            if ((st->codec->codec_id == CODEC_ID_MPEG1VIDEO ||
-                 st->codec->codec_id == CODEC_ID_MPEG2VIDEO) &&
-                st->codec->sub_id == 2) {
-                if (st->codec_info_nb_frames >= 20) {
-                    float coded_frame_rate, est_frame_rate;
-                    est_frame_rate = ((double)st->codec_info_nb_frames * AV_TIME_BASE) / 
-                        (double)st->codec_info_duration ;
-                    coded_frame_rate = 1.0/av_q2d(st->codec->time_base);
-#if 0
-                    printf("telecine: coded_frame_rate=%0.3f est_frame_rate=%0.3f\n", 
-                           coded_frame_rate, est_frame_rate);
-#endif
-                    /* if we detect that it could be a telecine, we
-                       signal it. It would be better to do it at a
-                       higher level as it can change in a film */
-                    if (coded_frame_rate >= 24.97 && 
-                        (est_frame_rate >= 23.5 && est_frame_rate < 24.5)) {
-                        st->r_frame_rate = (AVRational){24000, 1001};
-                    }
-                }
-            }
-            /* if no real frame rate, use the codec one */
-            if (!st->r_frame_rate.num){
-                st->r_frame_rate.num = st->codec->time_base.den;
-                st->r_frame_rate.den = st->codec->time_base.num;
-            }
-        }
-    }
-
-    av_estimate_timings(ic);
-#if 0
-    /* correct DTS for b frame streams with no timestamps */
-    for(i=0;i<ic->nb_streams;i++) {
-        st = ic->streams[i];
-        if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
-            if(b-frames){
-                ppktl = &ic->packet_buffer;
-                while(ppkt1){
-                    if(ppkt1->stream_index != i)
-                        continue;
-                    if(ppkt1->pkt->dts < 0)
-                        break;
-                    if(ppkt1->pkt->pts != AV_NOPTS_VALUE)
-                        break;
-                    ppkt1->pkt->dts -= delta;
-                    ppkt1= ppkt1->next;
-                }
-                if(ppkt1)
-                    continue;
-                st->cur_dts -= delta;
-            }
-        }
-    }
-#endif
-    return ret;
-}
-
-/*******************************************************/
-
-/**
- * start playing a network based stream (e.g. RTSP stream) at the
- * current position 
- */
-int av_read_play(AVFormatContext *s)
-{
-    if (!s->iformat->read_play)
-        return AVERROR_NOTSUPP;
-    return s->iformat->read_play(s);
-}
-
-/**
- * Pause a network based stream (e.g. RTSP stream).
- *
- * Use av_read_play() to resume it.
- */
-int av_read_pause(AVFormatContext *s)
-{
-    if (!s->iformat->read_pause)
-        return AVERROR_NOTSUPP;
-    return s->iformat->read_pause(s);
-}
-
-/**
- * Close a media file (but not its codecs).
- *
- * @param s media file handle
- */
-void av_close_input_file(AVFormatContext *s)
-{
-    int i, must_open_file;
-    AVStream *st;
-
-    /* free previous packet */
-    if (s->cur_st && s->cur_st->parser)
-        av_free_packet(&s->cur_pkt); 
-
-    if (s->iformat->read_close)
-        s->iformat->read_close(s);
-    for(i=0;i<s->nb_streams;i++) {
-        /* free all data in a stream component */
-        st = s->streams[i];
-        if (st->parser) {
-            av_parser_close(st->parser);
-        }
-        av_free(st->index_entries);
-        av_free(st->codec);
-        av_free(st);
-    }
-    flush_packet_queue(s);
-    must_open_file = 1;
-    if (s->iformat->flags & AVFMT_NOFILE) {
-        must_open_file = 0;
-    }
-    if (must_open_file) {
-        url_fclose(&s->pb);
-    }
-    av_freep(&s->priv_data);
-    av_free(s);
-}
-
-/**
- * Add a new stream to a media file.
- *
- * Can only be called in the read_header() function. If the flag
- * AVFMTCTX_NOHEADER is in the format context, then new streams
- * can be added in read_packet too.
- *
- * @param s media file handle
- * @param id file format dependent stream id 
- */
-AVStream *av_new_stream(AVFormatContext *s, int id)
-{
-    AVStream *st;
-
-    if (s->nb_streams >= MAX_STREAMS)
-        return NULL;
-
-    st = av_mallocz(sizeof(AVStream));
-    if (!st)
-        return NULL;
-    
-    st->codec= avcodec_alloc_context();
-    if (s->iformat) {
-        /* no default bitrate if decoding */
-        st->codec->bit_rate = 0;
-    }
-    st->index = s->nb_streams;
-    st->id = id;
-    st->start_time = AV_NOPTS_VALUE;
-    st->duration = AV_NOPTS_VALUE;
-    st->cur_dts = AV_NOPTS_VALUE;
-
-    /* default pts settings is MPEG like */
-    av_set_pts_info(st, 33, 1, 90000);
-    st->last_IP_pts = AV_NOPTS_VALUE;
-
-    s->streams[s->nb_streams++] = st;
-    return st;
-}
-
-/************************************************************/
-/* output media file */
-
-int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap)
-{
-    int ret;
-    
-    if (s->oformat->priv_data_size > 0) {
-        s->priv_data = av_mallocz(s->oformat->priv_data_size);
-        if (!s->priv_data)
-            return AVERROR_NOMEM;
-    } else
-        s->priv_data = NULL;
-	
-    if (s->oformat->set_parameters) {
-        ret = s->oformat->set_parameters(s, ap);
-        if (ret < 0)
-            return ret;
-    }
-    return 0;
-}
-
-/**
- * allocate the stream private data and write the stream header to an
- * output media file
- *
- * @param s media file handle
- * @return 0 if OK. AVERROR_xxx if error.  
- */
-int av_write_header(AVFormatContext *s)
-{
-    int ret, i;
-    AVStream *st;
-
-    // some sanity checks
-    for(i=0;i<s->nb_streams;i++) {
-        st = s->streams[i];
-
-        switch (st->codec->codec_type) {
-        case CODEC_TYPE_AUDIO:
-            if(st->codec->sample_rate<=0){
-                av_log(s, AV_LOG_ERROR, "sample rate not set\n");
-                return -1;
-            }
-            break;
-        case CODEC_TYPE_VIDEO:
-            if(st->codec->time_base.num<=0 || st->codec->time_base.den<=0){ //FIXME audio too?
-                av_log(s, AV_LOG_ERROR, "time base not set\n");
-                return -1;
-            }
-            if(st->codec->width<=0 || st->codec->height<=0){
-                av_log(s, AV_LOG_ERROR, "dimensions not set\n");
-                return -1;
-            }
-            break;
-        }
-    }
-
-    ret = s->oformat->write_header(s);
-    if (ret < 0)
-        return ret;
-
-    /* init PTS generation */
-    for(i=0;i<s->nb_streams;i++) {
-        int64_t den = AV_NOPTS_VALUE;
-        st = s->streams[i];
-
-        switch (st->codec->codec_type) {
-        case CODEC_TYPE_AUDIO:
-            den = (int64_t)st->time_base.num * st->codec->sample_rate;
-            break;
-        case CODEC_TYPE_VIDEO:
-            den = (int64_t)st->time_base.num * st->codec->time_base.den;
-            break;
-        default:
-            break;
-        }
-        if (den != AV_NOPTS_VALUE) {
-            if (den <= 0)
-                return AVERROR_INVALIDDATA;
-            av_frac_init(&st->pts, 0, 0, den);
-        }
-    }
-    return 0;
-}
-
-//FIXME merge with compute_pkt_fields
-static int compute_pkt_fields2(AVStream *st, AVPacket *pkt){
-    int b_frames = FFMAX(st->codec->has_b_frames, st->codec->max_b_frames);
-    int num, den, frame_size;
-
-//    av_log(NULL, AV_LOG_DEBUG, "av_write_frame: pts:%lld dts:%lld cur_dts:%lld b:%d size:%d st:%d\n", pkt->pts, pkt->dts, st->cur_dts, b_frames, pkt->size, pkt->stream_index);
-    
-/*    if(pkt->pts == AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE)
-        return -1;*/
-            
-    /* duration field */
-    if (pkt->duration == 0) {
-        compute_frame_duration(&num, &den, st, NULL, pkt);
-        if (den && num) {
-            pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num);
-        }
-    }
-
-    //XXX/FIXME this is a temporary hack until all encoders output pts
-    if((pkt->pts == 0 || pkt->pts == AV_NOPTS_VALUE) && pkt->dts == AV_NOPTS_VALUE && !b_frames){
-        pkt->dts=
-//        pkt->pts= st->cur_dts;
-        pkt->pts= st->pts.val;
-    }
-
-    //calculate dts from pts    
-    if(pkt->pts != AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE){
-        if(b_frames){
-            if(st->last_IP_pts == AV_NOPTS_VALUE){
-                st->last_IP_pts= -pkt->duration;
-            }
-            if(st->last_IP_pts < pkt->pts){
-                pkt->dts= st->last_IP_pts;
-                st->last_IP_pts= pkt->pts;
-            }else
-                pkt->dts= pkt->pts;
-        }else
-            pkt->dts= pkt->pts;
-    }
-    
-    if(st->cur_dts && st->cur_dts != AV_NOPTS_VALUE && st->cur_dts >= pkt->dts){
-        av_log(NULL, AV_LOG_ERROR, "error, non monotone timestamps %Ld >= %Ld\n", st->cur_dts, pkt->dts);
-        return -1;
-    }
-    if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts < pkt->dts){
-        av_log(NULL, AV_LOG_ERROR, "error, pts < dts\n");
-        return -1;
-    }
-
-//    av_log(NULL, AV_LOG_DEBUG, "av_write_frame: pts2:%lld dts2:%lld\n", pkt->pts, pkt->dts);
-    st->cur_dts= pkt->dts;
-    st->pts.val= pkt->dts;
-
-    /* update pts */
-    switch (st->codec->codec_type) {
-    case CODEC_TYPE_AUDIO:
-        frame_size = get_audio_frame_size(st->codec, pkt->size);
-
-        /* HACK/FIXME, we skip the initial 0-size packets as they are most likely equal to the encoder delay,
-           but it would be better if we had the real timestamps from the encoder */
-        if (frame_size >= 0 && (pkt->size || st->pts.num!=st->pts.den>>1 || st->pts.val)) {
-            av_frac_add(&st->pts, (int64_t)st->time_base.den * frame_size);
-        }
-        break;
-    case CODEC_TYPE_VIDEO:
-        av_frac_add(&st->pts, (int64_t)st->time_base.den * st->codec->time_base.num);
-        break;
-    default:
-        break;
-    }
-    return 0;
-}
-
-static void truncate_ts(AVStream *st, AVPacket *pkt){
-    int64_t pts_mask = (2LL << (st->pts_wrap_bits-1)) - 1;
-    
-//    if(pkt->dts < 0)
-//        pkt->dts= 0;  //this happens for low_delay=0 and b frames, FIXME, needs further invstigation about what we should do here
-    
-    pkt->pts &= pts_mask;
-    pkt->dts &= pts_mask;
-}
-
-/**
- * Write a packet to an output media file.
- *
- * The packet shall contain one audio or video frame.
- *
- * @param s media file handle
- * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ...
- * @return < 0 if error, = 0 if OK, 1 if end of stream wanted.
- */
-int av_write_frame(AVFormatContext *s, AVPacket *pkt)
-{
-    int ret;
-
-    ret=compute_pkt_fields2(s->streams[pkt->stream_index], pkt);
-    if(ret<0)
-        return ret;
-    
-    truncate_ts(s->streams[pkt->stream_index], pkt);
-
-    ret= s->oformat->write_packet(s, pkt);
-    if(!ret)
-        ret= url_ferror(&s->pb);
-    return ret;
-}
-
-/**
- * interleave_packet implementation which will interleave per DTS.
- * packets with pkt->destruct == av_destruct_packet will be freed inside this function. 
- * so they cannot be used after it, note calling av_free_packet() on them is still safe
- */
-static int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){
-    AVPacketList *pktl, **next_point, *this_pktl;
-    int stream_count=0;
-    int streams[MAX_STREAMS];
-
-    if(pkt){
-        AVStream *st= s->streams[ pkt->stream_index];
-
-//        assert(pkt->destruct != av_destruct_packet); //FIXME
-
-        this_pktl = av_mallocz(sizeof(AVPacketList));
-        this_pktl->pkt= *pkt;
-        if(pkt->destruct == av_destruct_packet)
-            pkt->destruct= NULL; // non shared -> must keep original from being freed
-        else
-            av_dup_packet(&this_pktl->pkt);  //shared -> must dup
-
-        next_point = &s->packet_buffer;
-        while(*next_point){
-            AVStream *st2= s->streams[ (*next_point)->pkt.stream_index];
-            int64_t left=  st2->time_base.num * (int64_t)st ->time_base.den;
-            int64_t right= st ->time_base.num * (int64_t)st2->time_base.den;
-            if((*next_point)->pkt.dts * left > pkt->dts * right) //FIXME this can overflow
-                break;
-            next_point= &(*next_point)->next;
-        }
-        this_pktl->next= *next_point;
-        *next_point= this_pktl;
-    }
-    
-    memset(streams, 0, sizeof(streams));
-    pktl= s->packet_buffer;
-    while(pktl){
-//av_log(s, AV_LOG_DEBUG, "show st:%d dts:%lld\n", pktl->pkt.stream_index, pktl->pkt.dts);
-        if(streams[ pktl->pkt.stream_index ] == 0)
-            stream_count++;
-        streams[ pktl->pkt.stream_index ]++;
-        pktl= pktl->next;
-    }
-    
-    if(s->nb_streams == stream_count || (flush && stream_count)){
-        pktl= s->packet_buffer;
-        *out= pktl->pkt;
-        
-        s->packet_buffer= pktl->next;        
-        av_freep(&pktl);
-        return 1;
-    }else{
-        av_init_packet(out);
-        return 0;
-    }
-}
-
-/**
- * Interleaves a AVPacket correctly so it can be muxed.
- * @param out the interleaved packet will be output here
- * @param in the input packet
- * @param flush 1 if no further packets are available as input and all
- *              remaining packets should be output
- * @return 1 if a packet was output, 0 if no packet could be output, 
- *         < 0 if an error occured
- */
-static int av_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, int flush){
-    if(s->oformat->interleave_packet)
-        return s->oformat->interleave_packet(s, out, in, flush);
-    else
-        return av_interleave_packet_per_dts(s, out, in, flush);
-}
-
-/**
- * Writes a packet to an output media file ensuring correct interleaving.
- *
- * The packet must contain one audio or video frame.
- * If the packets are already correctly interleaved the application should
- * call av_write_frame() instead as its slightly faster, its also important
- * to keep in mind that completly non interleaved input will need huge amounts
- * of memory to interleave with this, so its prefereable to interleave at the
- * demuxer level
- *
- * @param s media file handle
- * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ...
- * @return < 0 if error, = 0 if OK, 1 if end of stream wanted.
- */
-int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){
-    AVStream *st= s->streams[ pkt->stream_index];
-
-    //FIXME/XXX/HACK drop zero sized packets
-    if(st->codec->codec_type == CODEC_TYPE_AUDIO && pkt->size==0)
-        return 0;
-
-//av_log(NULL, AV_LOG_DEBUG, "av_interleaved_write_frame %d %Ld %Ld\n", pkt->size, pkt->dts, pkt->pts);
-    if(compute_pkt_fields2(st, pkt) < 0)
-        return -1;
-    
-    if(pkt->dts == AV_NOPTS_VALUE)
-        return -1;
-
-    for(;;){
-        AVPacket opkt;
-        int ret= av_interleave_packet(s, &opkt, pkt, 0);
-        if(ret<=0) //FIXME cleanup needed for ret<0 ?
-            return ret;
-        
-        truncate_ts(s->streams[opkt.stream_index], &opkt);
-        ret= s->oformat->write_packet(s, &opkt);
-        
-        av_free_packet(&opkt);
-        pkt= NULL;
-        
-        if(ret<0)
-            return ret;
-        if(url_ferror(&s->pb))
-            return url_ferror(&s->pb);
-    }
-}
-
-/**
- * @brief Write the stream trailer to an output media file and
- *        free the file private data.
- *
- * @param s media file handle
- * @return 0 if OK. AVERROR_xxx if error.
- */
-int av_write_trailer(AVFormatContext *s)
-{
-    int ret, i;
-    
-    for(;;){
-        AVPacket pkt;
-        ret= av_interleave_packet(s, &pkt, NULL, 1);
-        if(ret<0) //FIXME cleanup needed for ret<0 ?
-            goto fail;
-        if(!ret)
-            break;
-        
-        truncate_ts(s->streams[pkt.stream_index], &pkt);
-        ret= s->oformat->write_packet(s, &pkt);
-        
-        av_free_packet(&pkt);
-        
-        if(ret<0)
-            goto fail;
-        if(url_ferror(&s->pb))
-            goto fail;
-    }
-
-    ret = s->oformat->write_trailer(s);
-fail:
-    if(ret == 0)
-       ret=url_ferror(&s->pb);
-    for(i=0;i<s->nb_streams;i++)
-        av_freep(&s->streams[i]->priv_data);
-    av_freep(&s->priv_data);
-    return ret;
-}
-
-/* "user interface" functions */
-
-void dump_format(AVFormatContext *ic,
-                 int index, 
-                 const char *url,
-                 int is_output)
-{
-    int i, flags;
-    char buf[256];
-
-    av_log(NULL, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n", 
-            is_output ? "Output" : "Input",
-            index, 
-            is_output ? ic->oformat->name : ic->iformat->name, 
-            is_output ? "to" : "from", url);
-    if (!is_output) {
-        av_log(NULL, AV_LOG_INFO, "  Duration: ");
-        if (ic->duration != AV_NOPTS_VALUE) {
-            int hours, mins, secs, us;
-            secs = ic->duration / AV_TIME_BASE;
-            us = ic->duration % AV_TIME_BASE;
-            mins = secs / 60;
-            secs %= 60;
-            hours = mins / 60;
-            mins %= 60;
-            av_log(NULL, AV_LOG_INFO, "%02d:%02d:%02d.%01d", hours, mins, secs, 
-                   (10 * us) / AV_TIME_BASE);
-        } else {
-            av_log(NULL, AV_LOG_INFO, "N/A");
-        }
-        if (ic->start_time != AV_NOPTS_VALUE) {
-            int secs, us;
-            av_log(NULL, AV_LOG_INFO, ", start: ");
-            secs = ic->start_time / AV_TIME_BASE;
-            us = ic->start_time % AV_TIME_BASE;
-            av_log(NULL, AV_LOG_INFO, "%d.%06d",
-                   secs, (int)av_rescale(us, 1000000, AV_TIME_BASE));
-        }
-        av_log(NULL, AV_LOG_INFO, ", bitrate: ");
-        if (ic->bit_rate) {
-            av_log(NULL, AV_LOG_INFO,"%d kb/s", ic->bit_rate / 1000);
-        } else {
-            av_log(NULL, AV_LOG_INFO, "N/A");
-        }
-        av_log(NULL, AV_LOG_INFO, "\n");
-    }
-    for(i=0;i<ic->nb_streams;i++) {
-        AVStream *st = ic->streams[i];
-        avcodec_string(buf, sizeof(buf), st->codec, is_output);
-        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 */
-        if (is_output)
-            flags = ic->oformat->flags;
-        else
-            flags = ic->iformat->flags;
-        if (flags & AVFMT_SHOW_IDS) {
-            av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id);
-        }
-        if (strlen(st->language) > 0) {
-            av_log(NULL, AV_LOG_INFO, "(%s)", st->language);
-        }
-        av_log(NULL, AV_LOG_INFO, ": %s\n", buf);
-    }
-}
-
-typedef struct {
-    const char *abv;
-    int width, height;
-    int frame_rate, frame_rate_base;
-} AbvEntry;
-
-static AbvEntry frame_abvs[] = {
-    { "ntsc",      720, 480, 30000, 1001 },
-    { "pal",       720, 576,    25,    1 },
-    { "qntsc",     352, 240, 30000, 1001 }, /* VCD compliant ntsc */
-    { "qpal",      352, 288,    25,    1 }, /* VCD compliant pal */
-    { "sntsc",     640, 480, 30000, 1001 }, /* square pixel ntsc */
-    { "spal",      768, 576,    25,    1 }, /* square pixel pal */
-    { "film",      352, 240,    24,    1 },
-    { "ntsc-film", 352, 240, 24000, 1001 },
-    { "sqcif",     128,  96,     0,    0 },
-    { "qcif",      176, 144,     0,    0 },
-    { "cif",       352, 288,     0,    0 },
-    { "4cif",      704, 576,     0,    0 },
-};
-
-/**
- * parses width and height out of string str.
- */
-int parse_image_size(int *width_ptr, int *height_ptr, const char *str)
-{
-    int i;
-    int n = sizeof(frame_abvs) / sizeof(AbvEntry);
-    const char *p;
-    int frame_width = 0, frame_height = 0;
-
-    for(i=0;i<n;i++) {
-        if (!strcmp(frame_abvs[i].abv, str)) {
-            frame_width = frame_abvs[i].width;
-            frame_height = frame_abvs[i].height;
-            break;
-        }
-    }
-    if (i == n) {
-        p = str;
-        frame_width = strtol(p, (char **)&p, 10);
-        if (*p)
-            p++;
-        frame_height = strtol(p, (char **)&p, 10);
-    }
-    if (frame_width <= 0 || frame_height <= 0)
-        return -1;
-    *width_ptr = frame_width;
-    *height_ptr = frame_height;
-    return 0;
-}
-
-/**
- * Converts frame rate from string to a fraction.
- *
- * First we try to get an exact integer or fractional frame rate.
- * If this fails we convert the frame rate to a double and return
- * an approximate fraction using the DEFAULT_FRAME_RATE_BASE.
- */
-int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg)
-{
-    int i;
-    char* cp;
-   
-    /* First, we check our abbreviation table */
-    for (i = 0; i < sizeof(frame_abvs)/sizeof(*frame_abvs); ++i)
-         if (!strcmp(frame_abvs[i].abv, arg)) {
-	     *frame_rate = frame_abvs[i].frame_rate;
-	     *frame_rate_base = frame_abvs[i].frame_rate_base;
-	     return 0;
-	 }
-
-    /* Then, we try to parse it as fraction */
-    cp = strchr(arg, '/');
-    if (!cp)
-        cp = strchr(arg, ':');
-    if (cp) {
-        char* cpp;
-	*frame_rate = strtol(arg, &cpp, 10);
-	if (cpp != arg || cpp == cp) 
-	    *frame_rate_base = strtol(cp+1, &cpp, 10);
-	else
-	   *frame_rate = 0;
-    } 
-    else {
-        /* Finally we give up and parse it as double */
-        *frame_rate_base = DEFAULT_FRAME_RATE_BASE; //FIXME use av_d2q()
-        *frame_rate = (int)(strtod(arg, 0) * (*frame_rate_base) + 0.5);
-    }
-    if (!*frame_rate || !*frame_rate_base)
-        return -1;
-    else
-        return 0;
-}
-
-/**
- * Converts date string to number of seconds since Jan 1st, 1970.
- *
- * @code
- * Syntax:
- * - If not a duration:
- *  [{YYYY-MM-DD|YYYYMMDD}]{T| }{HH[:MM[:SS[.m...]]][Z]|HH[MM[SS[.m...]]][Z]}
- * Time is localtime unless Z is suffixed to the end. In this case GMT
- * Return the date in micro seconds since 1970 
- *
- * - If a duration:
- *  HH[:MM[:SS[.m...]]]
- *  S+[.m...]
- * @endcode
- */
-int64_t parse_date(const char *datestr, int duration)
-{
-    const char *p;
-    int64_t t;
-    struct tm dt;
-    int i;
-    static const char *date_fmt[] = {
-        "%Y-%m-%d",
-        "%Y%m%d",
-    };
-    static const char *time_fmt[] = {
-        "%H:%M:%S",
-        "%H%M%S",
-    };
-    const char *q;
-    int is_utc, len;
-    char lastch;
-    int negative = 0;
-
-#undef time
-    time_t now = time(0);
-
-    len = strlen(datestr);
-    if (len > 0)
-        lastch = datestr[len - 1];
-    else
-        lastch = '\0';
-    is_utc = (lastch == 'z' || lastch == 'Z');
-
-    memset(&dt, 0, sizeof(dt));
-
-    p = datestr;
-    q = NULL;
-    if (!duration) {
-        for (i = 0; i < sizeof(date_fmt) / sizeof(date_fmt[0]); i++) {
-            q = small_strptime(p, date_fmt[i], &dt);
-            if (q) {
-                break;
-            }
-        }
-
-        if (!q) {
-            if (is_utc) {
-                dt = *gmtime(&now);
-            } else {
-                dt = *localtime(&now);
-            }
-            dt.tm_hour = dt.tm_min = dt.tm_sec = 0;
-        } else {
-            p = q;
-        }
-
-        if (*p == 'T' || *p == 't' || *p == ' ')
-            p++;
-
-        for (i = 0; i < sizeof(time_fmt) / sizeof(time_fmt[0]); i++) {
-            q = small_strptime(p, time_fmt[i], &dt);
-            if (q) {
-                break;
-            }
-        }
-    } else {
-	if (p[0] == '-') {
-	    negative = 1;
-	    ++p;
-	}
-        q = small_strptime(p, time_fmt[0], &dt);
-        if (!q) {
-            dt.tm_sec = strtol(p, (char **)&q, 10);
-            dt.tm_min = 0;
-            dt.tm_hour = 0;
-        }
-    }
-
-    /* Now we have all the fields that we can get */
-    if (!q) {
-        if (duration)
-            return 0;
-        else
-            return now * int64_t_C(1000000);
-    }
-
-    if (duration) {
-        t = dt.tm_hour * 3600 + dt.tm_min * 60 + dt.tm_sec;
-    } else {
-        dt.tm_isdst = -1;       /* unknown */
-        if (is_utc) {
-            t = mktimegm(&dt);
-        } else {
-            t = mktime(&dt);
-        }
-    }
-
-    t *= 1000000;
-
-    if (*q == '.') {
-        int val, n;
-        q++;
-        for (val = 0, n = 100000; n >= 1; n /= 10, q++) {
-            if (!isdigit(*q)) 
-                break;
-            val += n * (*q - '0');
-        }
-        t += val;
-    }
-    return negative ? -t : t;
-}
-
-/**
- * Attempts to find a specific tag in a URL.
- *
- * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
- * Return 1 if found.
- */
-int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
-{
-    const char *p;
-    char tag[128], *q;
-
-    p = info;
-    if (*p == '?')
-        p++;
-    for(;;) {
-        q = tag;
-        while (*p != '\0' && *p != '=' && *p != '&') {
-            if ((q - tag) < sizeof(tag) - 1)
-                *q++ = *p;
-            p++;
-        }
-        *q = '\0';
-        q = arg;
-        if (*p == '=') {
-            p++;
-            while (*p != '&' && *p != '\0') {
-                if ((q - arg) < arg_size - 1) {
-                    if (*p == '+')
-                        *q++ = ' ';
-                    else
-                        *q++ = *p;
-                }
-                p++;
-            }
-            *q = '\0';
-        }
-        if (!strcmp(tag, tag1)) 
-            return 1;
-        if (*p != '&')
-            break;
-        p++;
-    }
-    return 0;
-}
-
-/**
- * Returns in 'buf' the path with '%d' replaced by number.
- *
- * Also handles the '%0nd' format where 'n' is the total number
- * of digits and '%%'. Return 0 if OK, and -1 if format error.
- */
-int get_frame_filename(char *buf, int buf_size,
-                       const char *path, int number)
-{
-    const char *p;
-    char *q, buf1[20], c;
-    int nd, len, percentd_found;
-
-    q = buf;
-    p = path;
-    percentd_found = 0;
-    for(;;) {
-        c = *p++;
-        if (c == '\0')
-            break;
-        if (c == '%') {
-            do {
-                nd = 0;
-                while (isdigit(*p)) {
-                    nd = nd * 10 + *p++ - '0';
-                }
-                c = *p++;
-            } while (isdigit(c));
-
-            switch(c) {
-            case '%':
-                goto addchar;
-            case 'd':
-                if (percentd_found)
-                    goto fail;
-                percentd_found = 1;
-                snprintf(buf1, sizeof(buf1), "%0*d", nd, number);
-                len = strlen(buf1);
-                if ((q - buf + len) > buf_size - 1)
-                    goto fail;
-                memcpy(q, buf1, len);
-                q += len;
-                break;
-            default:
-                goto fail;
-            }
-        } else {
-        addchar:
-            if ((q - buf) < buf_size - 1)
-                *q++ = c;
-        }
-    }
-    if (!percentd_found)
-        goto fail;
-    *q = '\0';
-    return 0;
- fail:
-    *q = '\0';
-    return -1;
-}
-
-/**
- * Print  nice hexa dump of a buffer
- * @param f stream for output
- * @param buf buffer
- * @param size buffer size
- */
-void av_hex_dump(FILE *f, uint8_t *buf, int size)
-{
-    int len, i, j, c;
-
-    for(i=0;i<size;i+=16) {
-        len = size - i;
-        if (len > 16)
-            len = 16;
-        fprintf(f, "%08x ", i);
-        for(j=0;j<16;j++) {
-            if (j < len)
-                fprintf(f, " %02x", buf[i+j]);
-            else
-                fprintf(f, "   ");
-        }
-        fprintf(f, " ");
-        for(j=0;j<len;j++) {
-            c = buf[i+j];
-            if (c < ' ' || c > '~')
-                c = '.';
-            fprintf(f, "%c", c);
-        }
-        fprintf(f, "\n");
-    }
-}
-
-/**
- * Print on 'f' a nice dump of a packet
- * @param f stream for output
- * @param pkt packet to dump
- * @param dump_payload true if the payload must be displayed too
- */
- //FIXME needs to know the time_base
-void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload)
-{
-    fprintf(f, "stream #%d:\n", pkt->stream_index);
-    fprintf(f, "  keyframe=%d\n", ((pkt->flags & PKT_FLAG_KEY) != 0));
-    fprintf(f, "  duration=%0.3f\n", (double)pkt->duration / AV_TIME_BASE);
-    /* DTS is _always_ valid after av_read_frame() */
-    fprintf(f, "  dts=");
-    if (pkt->dts == AV_NOPTS_VALUE)
-        fprintf(f, "N/A");
-    else
-        fprintf(f, "%0.3f", (double)pkt->dts / AV_TIME_BASE);
-    /* PTS may be not known if B frames are present */
-    fprintf(f, "  pts=");
-    if (pkt->pts == AV_NOPTS_VALUE)
-        fprintf(f, "N/A");
-    else
-        fprintf(f, "%0.3f", (double)pkt->pts / AV_TIME_BASE);
-    fprintf(f, "\n");
-    fprintf(f, "  size=%d\n", pkt->size);
-    if (dump_payload)
-        av_hex_dump(f, pkt->data, pkt->size);
-}
-
-void url_split(char *proto, int proto_size,
-               char *authorization, int authorization_size,
-               char *hostname, int hostname_size,
-               int *port_ptr,
-               char *path, int path_size,
-               const char *url)
-{
-    const char *p;
-    char *q;
-    int port;
-
-    port = -1;
-
-    p = url;
-    q = proto;
-    while (*p != ':' && *p != '\0') {
-        if ((q - proto) < proto_size - 1)
-            *q++ = *p;
-        p++;
-    }
-    if (proto_size > 0)
-        *q = '\0';
-    if (authorization_size > 0)
-        authorization[0] = '\0';
-    if (*p == '\0') {
-        if (proto_size > 0)
-            proto[0] = '\0';
-        if (hostname_size > 0)
-            hostname[0] = '\0';
-        p = url;
-    } else {
-        char *at,*slash; // PETR: position of '@' character and '/' character
-
-        p++;
-        if (*p == '/')
-            p++;
-        if (*p == '/')
-            p++;
-        at = strchr(p,'@'); // PETR: get the position of '@'
-        slash = strchr(p,'/');  // PETR: get position of '/' - end of hostname
-        if (at && slash && at > slash) at = NULL; // PETR: not interested in '@' behind '/'
-
-        q = at ? authorization : hostname;  // PETR: if '@' exists starting with auth.
-
-         while ((at || *p != ':') && *p != '/' && *p != '?' && *p != '\0') { // PETR:
-            if (*p == '@') {    // PETR: passed '@'
-              if (authorization_size > 0)
-                  *q = '\0';
-              q = hostname;
-              at = NULL;
-            } else if (!at) {   // PETR: hostname
-              if ((q - hostname) < hostname_size - 1)
-                  *q++ = *p;
-            } else {
-              if ((q - authorization) < authorization_size - 1)
-                *q++ = *p;
-            }
-            p++;
-        }
-        if (hostname_size > 0)
-            *q = '\0';
-        if (*p == ':') {
-            p++;
-            port = strtoul(p, (char **)&p, 10);
-        }
-    }
-    if (port_ptr)
-        *port_ptr = port;
-    pstrcpy(path, path_size, p);
-}
-
-/**
- * Set the pts for a given stream.
- *
- * @param s stream 
- * @param pts_wrap_bits number of bits effectively used by the pts
- *        (used for wrap control, 33 is the value for MPEG) 
- * @param pts_num numerator to convert to seconds (MPEG: 1) 
- * @param pts_den denominator to convert to seconds (MPEG: 90000)
- */
-void av_set_pts_info(AVStream *s, int pts_wrap_bits,
-                     int pts_num, int pts_den)
-{
-    s->pts_wrap_bits = pts_wrap_bits;
-    s->time_base.num = pts_num;
-    s->time_base.den = pts_den;
-}
-
-/* fraction handling */
-
-/**
- * f = val + (num / den) + 0.5.
- *
- * 'num' is normalized so that it is such as 0 <= num < den.
- *
- * @param f fractional number
- * @param val integer value
- * @param num must be >= 0
- * @param den must be >= 1 
- */
-void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den)
-{
-    num += (den >> 1);
-    if (num >= den) {
-        val += num / den;
-        num = num % den;
-    }
-    f->val = val;
-    f->num = num;
-    f->den = den;
-}
-
-/**
- * Set f to (val + 0.5).
- */
-void av_frac_set(AVFrac *f, int64_t val)
-{
-    f->val = val;
-    f->num = f->den >> 1;
-}
-
-/**
- * Fractionnal addition to f: f = f + (incr / f->den).
- *
- * @param f fractional number
- * @param incr increment, can be positive or negative
- */
-void av_frac_add(AVFrac *f, int64_t incr)
-{
-    int64_t num, den;
-
-    num = f->num + incr;
-    den = f->den;
-    if (num < 0) {
-        f->val += num / den;
-        num = num % den;
-        if (num < 0) {
-            num += den;
-            f->val--;
-        }
-    } else if (num >= den) {
-        f->val += num / den;
-        num = num % den;
-    }
-    f->num = num;
-}
-
-/**
- * register a new image format
- * @param img_fmt Image format descriptor
- */
-void av_register_image_format(AVImageFormat *img_fmt)
-{
-    AVImageFormat **p;
-
-    p = &first_image_format;
-    while (*p != NULL) p = &(*p)->next;
-    *p = img_fmt;
-    img_fmt->next = NULL;
-}
-
-/**
- * Guesses image format based on data in the image.
- */
-AVImageFormat *av_probe_image_format(AVProbeData *pd)
-{
-    AVImageFormat *fmt1, *fmt;
-    int score, score_max;
-
-    fmt = NULL;
-    score_max = 0;
-    for(fmt1 = first_image_format; fmt1 != NULL; fmt1 = fmt1->next) {
-        if (fmt1->img_probe) {
-            score = fmt1->img_probe(pd);
-            if (score > score_max) {
-                score_max = score;
-                fmt = fmt1;
-            }
-        }
-    }
-    return fmt;
-}
-
-/**
- * Guesses image format based on file name extensions.
- */
-AVImageFormat *guess_image_format(const char *filename)
-{
-    AVImageFormat *fmt1;
-
-    for(fmt1 = first_image_format; fmt1 != NULL; fmt1 = fmt1->next) {
-        if (fmt1->extensions && match_ext(filename, fmt1->extensions))
-            return fmt1;
-    }
-    return NULL;
-}
-
-/**
- * Read an image from a stream. 
- * @param gb byte stream containing the image
- * @param fmt image format, NULL if probing is required
- */
-int av_read_image(ByteIOContext *pb, const char *filename,
-                  AVImageFormat *fmt,
-                  int (*alloc_cb)(void *, AVImageInfo *info), void *opaque)
-{
-    char buf[PROBE_BUF_SIZE];
-    AVProbeData probe_data, *pd = &probe_data;
-    offset_t pos;
-    int ret;
-
-    if (!fmt) {
-        pd->filename = filename;
-        pd->buf = buf;
-        pos = url_ftell(pb);
-        pd->buf_size = get_buffer(pb, buf, PROBE_BUF_SIZE);
-        url_fseek(pb, pos, SEEK_SET);
-        fmt = av_probe_image_format(pd);
-    }
-    if (!fmt)
-        return AVERROR_NOFMT;
-    ret = fmt->img_read(pb, alloc_cb, opaque);
-    return ret;
-}
-
-/**
- * Write an image to a stream.
- * @param pb byte stream for the image output
- * @param fmt image format
- * @param img image data and informations
- */
-int av_write_image(ByteIOContext *pb, AVImageFormat *fmt, AVImageInfo *img)
-{
-    return fmt->img_write(pb, img);
-}
-
diff --git a/ffmpeg.src/libavutil/Makefile b/ffmpeg.src/libavutil/Makefile
deleted file mode 100644
index 7594ab2..0000000
--- a/ffmpeg.src/libavutil/Makefile
+++ /dev/null
@@ -1,92 +0,0 @@
-#
-# libavutil Makefile
-#
-include ../config.mak
-
-VPATH=$(SRC_PATH)/libavutil
-
-# NOTE: -I.. is needed to include config.h
-CFLAGS=$(OPTFLAGS) -DHAVE_AV_CONFIG_H -I.. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE
-
-OBJS= mathematics.o \
-      integer.o \
-      rational.o \
-      intfloat_readwrite.o \
-
-
-ifeq ($(TARGET_ARCH_SPARC64),yes)
-CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc
-endif
-
-SRCS := $(OBJS:.o=.c)
-
-LIB= $(LIBPREF)avutil$(LIBSUF)
-ifeq ($(BUILD_SHARED),yes)
-SLIB= $(SLIBPREF)avutil$(SLIBSUF)
-endif
-
-all: $(LIB) $(SLIB)
-
-$(LIB): $(OBJS)
-	rm -f $@
-	$(AR) rc $@ $(OBJS)
-	$(RANLIB) $@
-
-$(SLIB): $(OBJS)
-ifeq ($(CONFIG_WIN32),yes)
-	$(CC) $(SHFLAGS) -Wl,--output-def,$(@:.dll=.def) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS)
-	-lib /machine:i386 /def:$(@:.dll=.def)
-else
-	$(CC) $(SHFLAGS) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS) $(LDFLAGS)
-endif
-
-%.o: %.c
-	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $< 
-
-depend: $(SRCS)
-	$(CC) -MM $(CFLAGS) $^ 1>.depend
-
-dep:	depend
-
-clean:
-	rm -f *.o *.d *~ .depend $(LIB) $(SLIB) *.so
-
-distclean: clean
-	rm -f Makefile.bak .depend
-
-
-ifeq ($(BUILD_SHARED),yes)
-install: all install-headers
-ifeq ($(CONFIG_WIN32),yes)
-	install $(INSTALLSTRIP) -m 755 $(SLIB) "$(prefix)"
-else
-	install -d $(libdir)
-	install $(INSTALLSTRIP) -m 755 $(SLIB) $(libdir)/libavutil-$(VERSION).so
-	ln -sf libavutil-$(VERSION).so $(libdir)/libavutil.so
-	$(LDCONFIG) || true
-endif
-else
-install:
-endif
-
-installlib: all install-headers
-	install -m 644 $(LIB) "$(libdir)"
-
-install-headers:
-	mkdir -p "$(prefix)/include/ffmpeg"
-	install -m 644 $(SRC_PATH)/libavutil/avutil.h \
-	               $(SRC_PATH)/libavutil/common.h \
-	               $(SRC_PATH)/libavutil/mathematics.h \
-	               $(SRC_PATH)/libavutil/integer.h \
-	               $(SRC_PATH)/libavutil/rational.h \
-	               $(SRC_PATH)/libavutil/intfloat_readwrite.h \
-                "$(prefix)/include/ffmpeg"
-	install -d $(libdir)/pkgconfig
-	install -m 644 ../libavutil.pc $(libdir)/pkgconfig
-
-#
-# include dependency files if they exist
-#
-ifneq ($(wildcard .depend),)
-include .depend
-endif
diff --git a/ffmpeg.src/libavutil/avutil.h b/ffmpeg.src/libavutil/avutil.h
deleted file mode 100644
index b9f930a..0000000
--- a/ffmpeg.src/libavutil/avutil.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef AVUTIL_H
-#define AVUTIL_H
-
-/**
- * @file avutil.h
- * external api header.
- */
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define AV_STRINGIFY(s)	AV_TOSTRING(s)
-#define AV_TOSTRING(s) #s
-
-#define LIBAVUTIL_VERSION_INT ((49<<16)+(0<<8)+0)
-#define LIBAVUTIL_VERSION     49.0.0
-#define LIBAVUTIL_BUILD       LIBAVUTIL_VERSION_INT
-
-#define LIBAVUTIL_IDENT       "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
-
-
-#include "common.h"
-#include "mathematics.h"
-#include "rational.h"
-#include "integer.h"
-#include "intfloat_readwrite.h"
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* AVUTIL_H */
diff --git a/ffmpeg.src/libavutil/bswap.h b/ffmpeg.src/libavutil/bswap.h
deleted file mode 100644
index 50fd571..0000000
--- a/ffmpeg.src/libavutil/bswap.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- * @file bswap.h
- * byte swap.
- */
-
-#ifndef __BSWAP_H__
-#define __BSWAP_H__
-
-#ifdef HAVE_BYTESWAP_H
-#include <byteswap.h>
-#else
-
-#ifdef ARCH_X86_64
-#  define LEGACY_REGS "=Q"
-#else
-#  define LEGACY_REGS "=q"
-#endif
-
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
-static always_inline uint16_t bswap_16(uint16_t x)
-{
-  __asm("rorw $8, %0"	:
-        LEGACY_REGS (x)	:
-        "0" (x));
-    return x;
-}
-
-static always_inline uint32_t bswap_32(uint32_t x)
-{
-#if __CPU__ > 386
- __asm("bswap	%0":
-      "=r" (x)     :
-#else
- __asm("xchgb	%b0,%h0\n"
-      "	rorl	$16,%0\n"
-      "	xchgb	%b0,%h0":
-      LEGACY_REGS (x)		:
-#endif
-      "0" (x));
-  return x;
-}
-
-static inline uint64_t bswap_64(uint64_t x)
-{
-#ifdef ARCH_X86_64
-  __asm("bswap	%0":
-        "=r" (x)     :
-        "0" (x));
-  return x;
-#else
-    union { 
-        uint64_t ll;
-        struct {
-           uint32_t l,h;
-        } l;
-    } r;
-    r.l.l = bswap_32 (x);
-    r.l.h = bswap_32 (x>>32);
-    return r.ll;
-#endif
-}
-
-#elif defined(ARCH_SH4)
-
-static always_inline uint16_t bswap_16(uint16_t x) {
-	__asm__("swap.b %0,%0":"=r"(x):"0"(x));
-	return x;
-}
-
-static always_inline uint32_t bswap_32(uint32_t x) {
-	__asm__(
-	"swap.b %0,%0\n"
-	"swap.w %0,%0\n"
-	"swap.b %0,%0\n"
-	:"=r"(x):"0"(x));
-	return x;
-}
-
-static inline uint64_t bswap_64(uint64_t x)
-{
-    union { 
-        uint64_t ll;
-        struct {
-           uint32_t l,h;
-        } l;
-    } r;
-    r.l.l = bswap_32 (x);
-    r.l.h = bswap_32 (x>>32);
-    return r.ll;
-}
-#else
-
-static always_inline uint16_t bswap_16(uint16_t x){
-    return (x>>8) | (x<<8);
-}
-
-#ifdef ARCH_ARM
-static always_inline uint32_t bswap_32(uint32_t x){
-    uint32_t t;
-    __asm__ (
-      "eor %1, %0, %0, ror #16 \n\t"
-      "bic %1, %1, #0xFF0000   \n\t"
-      "mov %0, %0, ror #8      \n\t"
-      "eor %0, %0, %1, lsr #8  \n\t"
-      : "+r"(x), "+r"(t));
-    return x;
-}
-#else
-static always_inline uint32_t bswap_32(uint32_t x){
-    x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
-    return (x>>16) | (x<<16);
-}
-#endif
-
-static inline uint64_t bswap_64(uint64_t x)
-{
-#if 0
-    x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL);
-    x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL);
-    return (x>>32) | (x<<32);
-#else
-    union { 
-        uint64_t ll;
-        uint32_t l[2]; 
-    } w, r;
-    w.ll = x;
-    r.l[0] = bswap_32 (w.l[1]);
-    r.l[1] = bswap_32 (w.l[0]);
-    return r.ll;
-#endif
-}
-#endif	/* !ARCH_X86 */
-
-#endif	/* !HAVE_BYTESWAP_H */
-
-// be2me ... BigEndian to MachineEndian
-// le2me ... LittleEndian to MachineEndian
-
-#ifdef WORDS_BIGENDIAN
-#define be2me_16(x) (x)
-#define be2me_32(x) (x)
-#define be2me_64(x) (x)
-#define le2me_16(x) bswap_16(x)
-#define le2me_32(x) bswap_32(x)
-#define le2me_64(x) bswap_64(x)
-#else
-#define be2me_16(x) bswap_16(x)
-#define be2me_32(x) bswap_32(x)
-#define be2me_64(x) bswap_64(x)
-#define le2me_16(x) (x)
-#define le2me_32(x) (x)
-#define le2me_64(x) (x)
-#endif
-
-#endif /* __BSWAP_H__ */
diff --git a/ffmpeg.src/libavutil/common.h b/ffmpeg.src/libavutil/common.h
deleted file mode 100644
index 8179ece..0000000
--- a/ffmpeg.src/libavutil/common.h
+++ /dev/null
@@ -1,548 +0,0 @@
-/**
- * @file common.h
- * common internal api header.
- */
-
-#ifndef COMMON_H
-#define COMMON_H
-
-#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
-#    define CONFIG_WIN32
-#endif
-
-#ifndef M_PI
-#define M_PI    3.14159265358979323846
-#endif
-
-#ifdef HAVE_AV_CONFIG_H
-/* only include the following when compiling package */
-#    include "config.h"
-
-#    include <stdlib.h>
-#    include <stdio.h>
-#    include <string.h>
-#    include <ctype.h>
-#    include <limits.h>
-#    ifndef __BEOS__
-#        include <errno.h>
-#    else
-#        include "berrno.h"
-#    endif
-#    include <math.h>
-
-#    ifndef ENODATA
-#        define ENODATA  61
-#    endif
-
-#include <stddef.h>
-#ifndef offsetof
-# define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F))
-#endif
-
-#define AVOPTION_CODEC_BOOL(name, help, field) \
-    { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_BOOL }
-#define AVOPTION_CODEC_DOUBLE(name, help, field, minv, maxv, defval) \
-    { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_DOUBLE, minv, maxv, defval }
-#define AVOPTION_CODEC_FLAG(name, help, field, flag, defval) \
-    { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_FLAG, flag, 0, defval }
-#define AVOPTION_CODEC_INT(name, help, field, minv, maxv, defval) \
-    { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_INT, minv, maxv, defval }
-#define AVOPTION_CODEC_STRING(name, help, field, str, val) \
-    { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_STRING, .defval = val, .defstr = str }
-#define AVOPTION_CODEC_RCOVERRIDE(name, help, field) \
-    { name, help, offsetof(AVCodecContext, field), FF_OPT_TYPE_RCOVERRIDE, .defval = 0, .defstr = NULL }
-#define AVOPTION_SUB(ptr) { .name = NULL, .help = (const char*)ptr }
-#define AVOPTION_END() AVOPTION_SUB(NULL)
-
-#endif /* HAVE_AV_CONFIG_H */
-
-/* Suppress restrict if it was not defined in config.h.  */
-#ifndef restrict
-#    define restrict
-#endif
-
-#ifndef always_inline
-#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
-#    define always_inline __attribute__((always_inline)) inline
-#else
-#    define always_inline inline
-#endif
-#endif
-
-#ifndef attribute_used
-#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
-#    define attribute_used __attribute__((used))
-#else
-#    define attribute_used
-#endif
-#endif
-
-#ifndef attribute_unused
-#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
-#    define attribute_unused __attribute__((unused))
-#else
-#    define attribute_unused
-#endif
-#endif
-
-#ifndef EMULATE_INTTYPES
-#   include <inttypes.h>
-#else
-    typedef signed char  int8_t;
-    typedef signed short int16_t;
-    typedef signed int   int32_t;
-    typedef unsigned char  uint8_t;
-    typedef unsigned short uint16_t;
-    typedef unsigned int   uint32_t;
-
-#   ifdef CONFIG_WIN32
-        typedef signed __int64   int64_t;
-        typedef unsigned __int64 uint64_t;
-#   else /* other OS */
-        typedef signed long long   int64_t;
-        typedef unsigned long long uint64_t;
-#   endif /* other OS */
-#endif /* EMULATE_INTTYPES */
-
-#ifndef INT16_MIN
-#define INT16_MIN       (-0x7fff-1)
-#endif
-
-#ifndef INT16_MAX
-#define INT16_MAX       0x7fff
-#endif
-
-#ifndef INT64_MIN
-#define INT64_MIN       (-0x7fffffffffffffffLL-1)
-#endif
-
-#ifndef INT64_MAX
-#define INT64_MAX int64_t_C(9223372036854775807)
-#endif
-
-#ifndef UINT64_MAX
-#define UINT64_MAX uint64_t_C(0xFFFFFFFFFFFFFFFF)
-#endif
-
-#ifdef EMULATE_FAST_INT
-typedef signed char int_fast8_t;
-typedef signed int  int_fast16_t;
-typedef signed int  int_fast32_t;
-typedef unsigned char uint_fast8_t;
-typedef unsigned int  uint_fast16_t;
-typedef unsigned int  uint_fast32_t;
-typedef uint64_t      uint_fast64_t;
-#endif
-
-#ifndef INT_BIT
-#    if INT_MAX != 2147483647
-#        define INT_BIT 64
-#    else
-#        define INT_BIT 32
-#    endif
-#endif
-
-#if defined(CONFIG_OS2) || defined(CONFIG_SUNOS)
-static inline float floorf(float f) { 
-    return floor(f); 
-}
-#endif
-
-#ifdef CONFIG_WIN32
-
-/* windows */
-
-#    if !defined(__MINGW32__) && !defined(__CYGWIN__)
-#        define int64_t_C(c)     (c ## i64)
-#        define uint64_t_C(c)    (c ## i64)
-
-#    ifdef HAVE_AV_CONFIG_H
-#            define inline __inline
-#    endif
-
-#    else
-#        define int64_t_C(c)     (c ## LL)
-#        define uint64_t_C(c)    (c ## ULL)
-#    endif /* __MINGW32__ */
-
-#    ifdef HAVE_AV_CONFIG_H
-#        ifdef _DEBUG
-#            define DEBUG
-#        endif
-
-#        define snprintf _snprintf
-#        define vsnprintf _vsnprintf
-#    endif
-
-/* CONFIG_WIN32 end */
-#elif defined (CONFIG_OS2)
-/* OS/2 EMX */
-
-#ifndef int64_t_C
-#define int64_t_C(c)     (c ## LL)
-#define uint64_t_C(c)    (c ## ULL)
-#endif
-
-#ifdef HAVE_AV_CONFIG_H
-
-#ifdef USE_FASTMEMCPY
-#include "fastmemcpy.h"
-#endif
-
-#include <float.h>
-
-#endif /* HAVE_AV_CONFIG_H */
-
-/* CONFIG_OS2 end */
-#else
-
-/* unix */
-
-#ifndef int64_t_C
-#define int64_t_C(c)     (c ## LL)
-#define uint64_t_C(c)    (c ## ULL)
-#endif
-
-#ifdef HAVE_AV_CONFIG_H
-
-#        ifdef USE_FASTMEMCPY
-#            include "fastmemcpy.h"
-#        endif
-#    endif /* HAVE_AV_CONFIG_H */
-
-#endif /* !CONFIG_WIN32 && !CONFIG_OS2 */
-
-#ifdef HAVE_AV_CONFIG_H
-
-#    include "bswap.h"
-
-// Use rip-relative addressing if compiling PIC code on x86-64.
-#    if defined(__MINGW32__) || defined(__CYGWIN__) || \
-        defined(__OS2__) || (defined (__OpenBSD__) && !defined(__ELF__))
-#        if defined(ARCH_X86_64) && defined(PIC)
-#            define MANGLE(a) "_" #a"(%%rip)"
-#        else
-#            define MANGLE(a) "_" #a
-#        endif
-#    else
-#        if defined(ARCH_X86_64) && defined(PIC)
-#            define MANGLE(a) #a"(%%rip)"
-#        else
-#            define MANGLE(a) #a
-#        endif
-#    endif
-
-/* debug stuff */
-
-#    ifndef DEBUG
-#        define NDEBUG
-#    endif
-#    include <assert.h>
-
-/* dprintf macros */
-#    if defined(CONFIG_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
-
-inline void dprintf(const char* fmt,...) {}
-
-#    else
-
-#        ifdef DEBUG
-#            define dprintf(fmt,...) av_log(NULL, AV_LOG_DEBUG, fmt, __VA_ARGS__)
-#        else
-#            define dprintf(fmt,...)
-#        endif
-
-#    endif /* !CONFIG_WIN32 */
-
-#    define av_abort()      do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0)
-
-//rounded divison & shift
-#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
-/* assume b>0 */
-#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
-#define ABS(a) ((a) >= 0 ? (a) : (-(a)))
-
-#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
-#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
-
-extern const uint32_t inverse[256];
-
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
-#    define FASTDIV(a,b) \
-    ({\
-        int ret,dmy;\
-        asm volatile(\
-            "mull %3"\
-            :"=d"(ret),"=a"(dmy)\
-            :"1"(a),"g"(inverse[b])\
-            );\
-        ret;\
-    })
-#elif defined(CONFIG_FASTDIV)
-#    define FASTDIV(a,b)   ((uint32_t)((((uint64_t)a)*inverse[b])>>32))
-#else
-#    define FASTDIV(a,b)   ((a)/(b))
-#endif
- 
-/* define it to include statistics code (useful only for optimizing
-   codec efficiency */
-//#define STATS
-
-#ifdef STATS
-
-enum {
-    ST_UNKNOWN,
-    ST_DC,
-    ST_INTRA_AC,
-    ST_INTER_AC,
-    ST_INTRA_MB,
-    ST_INTER_MB,
-    ST_MV,
-    ST_NB,
-};
-
-extern int st_current_index;
-extern unsigned int st_bit_counts[ST_NB];
-extern unsigned int st_out_bit_counts[ST_NB];
-
-void print_stats(void);
-#endif
-
-/* misc math functions */
-extern const uint8_t ff_log2_tab[256];
-
-static inline int av_log2(unsigned int v)
-{
-    int n;
-
-    n = 0;
-    if (v & 0xffff0000) {
-        v >>= 16;
-        n += 16;
-    }
-    if (v & 0xff00) {
-        v >>= 8;
-        n += 8;
-    }
-    n += ff_log2_tab[v];
-
-    return n;
-}
-
-static inline int av_log2_16bit(unsigned int v)
-{
-    int n;
-
-    n = 0;
-    if (v & 0xff00) {
-        v >>= 8;
-        n += 8;
-    }
-    n += ff_log2_tab[v];
-
-    return n;
-}
-
-/* median of 3 */
-static inline int mid_pred(int a, int b, int c)
-{
-#if 0
-    int t= (a-b)&((a-b)>>31);
-    a-=t;
-    b+=t;
-    b-= (b-c)&((b-c)>>31);
-    b+= (a-b)&((a-b)>>31);
-
-    return b;
-#else
-    if(a>b){
-        if(c>b){
-            if(c>a) b=a;
-            else    b=c;
-        }
-    }else{
-        if(b>c){
-            if(c>a) b=c;
-            else    b=a;
-        }
-    }
-    return b;
-#endif
-}
-
-static inline int clip(int a, int amin, int amax)
-{
-    if (a < amin)
-        return amin;
-    else if (a > amax)
-        return amax;
-    else
-        return a;
-}
-
-static inline int clip_uint8(int a)
-{
-    if (a&(~255)) return (-a)>>31;
-    else          return a;
-}
-
-/* math */
-extern const uint8_t ff_sqrt_tab[128];
-
-int64_t ff_gcd(int64_t a, int64_t b);
-
-static inline int ff_sqrt(int a)
-{
-    int ret=0;
-    int s;
-    int ret_sq=0;
-    
-    if(a<128) return ff_sqrt_tab[a];
-    
-    for(s=15; s>=0; s--){
-        int b= ret_sq + (1<<(s*2)) + (ret<<s)*2;
-        if(b<=a){
-            ret_sq=b;
-            ret+= 1<<s;
-        }
-    }
-    return ret;
-}
-
-/**
- * converts fourcc string to int
- */
-static inline int ff_get_fourcc(const char *s){
-    assert( strlen(s)==4 );
-
-    return (s[0]) + (s[1]<<8) + (s[2]<<16) + (s[3]<<24);
-}
-
-#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
-#define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))
-
-
-#if defined(ARCH_X86) || defined(ARCH_X86_64)
-#define MASK_ABS(mask, level)\
-            asm volatile(\
-		"cdq			\n\t"\
-		"xorl %1, %0		\n\t"\
-		"subl %1, %0		\n\t"\
-		: "+a" (level), "=&d" (mask)\
-	    );
-#else
-#define MASK_ABS(mask, level)\
-            mask= level>>31;\
-            level= (level^mask)-mask;
-#endif
-
-
-#if __CPU__ >= 686 && !defined(RUNTIME_CPUDETECT)
-#define COPY3_IF_LT(x,y,a,b,c,d)\
-asm volatile (\
-    "cmpl %0, %3	\n\t"\
-    "cmovl %3, %0	\n\t"\
-    "cmovl %4, %1	\n\t"\
-    "cmovl %5, %2	\n\t"\
-    : "+r" (x), "+r" (a), "+r" (c)\
-    : "r" (y), "r" (b), "r" (d)\
-);
-#else
-#define COPY3_IF_LT(x,y,a,b,c,d)\
-if((y)<(x)){\
-     (x)=(y);\
-     (a)=(b);\
-     (c)=(d);\
-}
-#endif
-
-#if defined(ARCH_X86) || defined(ARCH_X86_64) || defined(ARCH_POWERPC)
-#if defined(ARCH_X86_64)
-static inline uint64_t read_time(void)
-{
-	uint64_t a, d;
-	asm volatile(	"rdtsc\n\t"
-		: "=a" (a), "=d" (d)
-	);
-	return (d << 32) | (a & 0xffffffff);
-}
-#elif defined(ARCH_X86)
-static inline long long read_time(void)
-{
-	long long l;
-	asm volatile(	"rdtsc\n\t"
-		: "=A" (l)
-	);
-	return l;
-}
-#else //FIXME check ppc64
-static inline uint64_t read_time(void)
-{
-    uint32_t tbu, tbl, temp;
-
-     /* from section 2.2.1 of the 32-bit PowerPC PEM */
-     __asm__ __volatile__(
-         "1:\n"
-         "mftbu  %2\n"
-         "mftb   %0\n"
-         "mftbu  %1\n"
-         "cmpw   %2,%1\n"
-         "bne    1b\n"
-     : "=r"(tbl), "=r"(tbu), "=r"(temp)
-     :
-     : "cc");
-
-     return (((uint64_t)tbu)<<32) | (uint64_t)tbl;
-}
-#endif
-
-#define START_TIMER \
-uint64_t tend;\
-uint64_t tstart= read_time();\
-
-#define STOP_TIMER(id) \
-tend= read_time();\
-{\
-  static uint64_t tsum=0;\
-  static int tcount=0;\
-  static int tskip_count=0;\
-  if(tcount<2 || tend - tstart < 8*tsum/tcount){\
-      tsum+= tend - tstart;\
-      tcount++;\
-  }else\
-      tskip_count++;\
-  if(256*256*256*64%(tcount+tskip_count)==0){\
-      av_log(NULL, AV_LOG_DEBUG, "%Ld dezicycles in %s, %d runs, %d skips\n", tsum*10/tcount, id, tcount, tskip_count);\
-  }\
-}
-#else
-#define START_TIMER 
-#define STOP_TIMER(id) {}
-#endif
-
-/* avoid usage of various functions */
-#define malloc please_use_av_malloc
-#define free please_use_av_free
-#define realloc please_use_av_realloc
-#define time time_is_forbidden_due_to_security_issues
-#define rand rand_is_forbidden_due_to_state_trashing
-#define srand srand_is_forbidden_due_to_state_trashing
-#define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf
-#define strcat strcat_is_forbidden_due_to_security_issues_use_pstrcat
-#if !(defined(LIBAVFORMAT_BUILD) || defined(_FRAMEHOOK_H))
-#define printf please_use_av_log
-#define fprintf please_use_av_log
-#endif
-
-#define CHECKED_ALLOCZ(p, size)\
-{\
-    p= av_mallocz(size);\
-    if(p==NULL && (size)!=0){\
-        perror("malloc");\
-        goto fail;\
-    }\
-}
-
-#endif /* HAVE_AV_CONFIG_H */
-
-#endif /* COMMON_H */
diff --git a/ffmpeg.src/libavutil/eval.c b/ffmpeg.src/libavutil/eval.c
deleted file mode 100644
index 3307815..0000000
--- a/ffmpeg.src/libavutil/eval.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * simple arithmetic expression evaluator
- *
- * Copyright (c) 2002 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-/**
- * @file eval.c
- * simple arithmetic expression evaluator.
- *
- * see http://joe.hotchkiss.com/programming/eval/eval.html
- */
-
-#include "avcodec.h"
-#include "mpegvideo.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#ifndef NAN
-  #define NAN 0
-#endif
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-typedef struct Parser{
-    int stack_index;
-    char *s;
-    double *const_value;
-    const char **const_name;          // NULL terminated
-    double (**func1)(void *, double a); // NULL terminated
-    const char **func1_name;          // NULL terminated
-    double (**func2)(void *, double a, double b); // NULL terminated
-    char **func2_name;          // NULL terminated
-    void *opaque;
-} Parser;
-
-static double evalExpression(Parser *p);
-
-static int strmatch(const char *s, const char *prefix){
-    int i;
-    for(i=0; prefix[i]; i++){
-        if(prefix[i] != s[i]) return 0;
-    }
-    return 1;
-}
-
-static double evalPrimary(Parser *p){
-    double d, d2=NAN;
-    char *next= p->s;
-    int i;
-
-    /* number */
-    d= strtod(p->s, &next);
-    if(next != p->s){
-        p->s= next;
-        return d;
-    }
-    
-    /* named constants */
-    for(i=0; p->const_name && p->const_name[i]; i++){
-        if(strmatch(p->s, p->const_name[i])){
-            p->s+= strlen(p->const_name[i]);
-            return p->const_value[i];
-        }
-    }
-    
-    p->s= strchr(p->s, '(');
-    if(p->s==NULL){
-        av_log(NULL, AV_LOG_ERROR, "Parser: missing ( in \"%s\"\n", next);
-        return NAN;
-    }
-    p->s++; // "("
-    d= evalExpression(p);
-    if(p->s[0]== ','){
-        p->s++; // ","
-        d2= evalExpression(p);
-    }
-    if(p->s[0] != ')'){
-        av_log(NULL, AV_LOG_ERROR, "Parser: missing ) in \"%s\"\n", next);
-        return NAN;
-    }
-    p->s++; // ")"
-    
-         if( strmatch(next, "sinh"  ) ) d= sinh(d);
-    else if( strmatch(next, "cosh"  ) ) d= cosh(d);
-    else if( strmatch(next, "tanh"  ) ) d= tanh(d);
-    else if( strmatch(next, "sin"   ) ) d= sin(d);
-    else if( strmatch(next, "cos"   ) ) d= cos(d);
-    else if( strmatch(next, "tan"   ) ) d= tan(d);
-    else if( strmatch(next, "exp"   ) ) d= exp(d);
-    else if( strmatch(next, "log"   ) ) d= log(d);
-    else if( strmatch(next, "squish") ) d= 1/(1+exp(4*d));
-    else if( strmatch(next, "gauss" ) ) d= exp(-d*d/2)/sqrt(2*M_PI);
-    else if( strmatch(next, "abs"   ) ) d= fabs(d);
-    else if( strmatch(next, "max"   ) ) d= d > d2 ? d : d2;
-    else if( strmatch(next, "min"   ) ) d= d < d2 ? d : d2;
-    else if( strmatch(next, "gt"    ) ) d= d > d2 ? 1.0 : 0.0;
-    else if( strmatch(next, "gte"    ) ) d= d >= d2 ? 1.0 : 0.0;
-    else if( strmatch(next, "lt"    ) ) d= d > d2 ? 0.0 : 1.0;
-    else if( strmatch(next, "lte"    ) ) d= d >= d2 ? 0.0 : 1.0;
-    else if( strmatch(next, "eq"    ) ) d= d == d2 ? 1.0 : 0.0;
-    else if( strmatch(next, "("     ) ) d= d;
-//    else if( strmatch(next, "l1"    ) ) d= 1 + d2*(d - 1);
-//    else if( strmatch(next, "sq01"  ) ) d= (d >= 0.0 && d <=1.0) ? 1.0 : 0.0;
-    else{
-        for(i=0; p->func1_name && p->func1_name[i]; i++){
-            if(strmatch(next, p->func1_name[i])){
-                return p->func1[i](p->opaque, d);
-            }
-        }
-
-        for(i=0; p->func2_name && p->func2_name[i]; i++){
-            if(strmatch(next, p->func2_name[i])){
-                return p->func2[i](p->opaque, d, d2);
-            }
-        }
-
-        av_log(NULL, AV_LOG_ERROR, "Parser: unknown function in \"%s\"\n", next);
-        return NAN;
-    }
-
-    return d;
-}      
-
-static double evalPow(Parser *p){
-    int sign= (*p->s == '+') - (*p->s == '-');
-    p->s += sign&1;
-    return (sign|1) * evalPrimary(p);
-}
-
-static double evalFactor(Parser *p){
-    double ret= evalPow(p);
-    while(p->s[0]=='^'){
-        p->s++;
-        ret= pow(ret, evalPow(p));
-    }
-    return ret;
-}
-
-static double evalTerm(Parser *p){
-    double ret= evalFactor(p);
-    while(p->s[0]=='*' || p->s[0]=='/'){
-        if(*p->s++ == '*') ret*= evalFactor(p);
-        else               ret/= evalFactor(p);
-    }
-    return ret;
-}
-
-static double evalExpression(Parser *p){
-    double ret= 0;
-
-    if(p->stack_index <= 0) //protect against stack overflows
-        return NAN;
-    p->stack_index--;
-
-    do{
-        ret += evalTerm(p);
-    }while(*p->s == '+' || *p->s == '-');
-
-    p->stack_index++;
-
-    return ret;
-}
-
-double ff_eval(char *s, double *const_value, const char **const_name,
-               double (**func1)(void *, double), const char **func1_name,
-               double (**func2)(void *, double, double), char **func2_name,
-               void *opaque){
-    Parser p;
-    
-    p.stack_index=100;
-    p.s= s;
-    p.const_value= const_value;
-    p.const_name = const_name;
-    p.func1      = func1;
-    p.func1_name = func1_name;
-    p.func2      = func2;
-    p.func2_name = func2_name;
-    p.opaque     = opaque;
-    
-    return evalExpression(&p);
-}
-
-#ifdef TEST
-#undef printf 
-static double const_values[]={
-    M_PI,
-    M_E,
-    0
-};
-static const char *const_names[]={
-    "PI",
-    "E",
-    0
-};
-main(){
-    int i;
-    printf("%f == 12.7\n", ff_eval("1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_values, const_names, NULL, NULL, NULL, NULL, NULL));
-    
-    for(i=0; i<1050; i++){
-        START_TIMER
-            ff_eval("1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_values, const_names, NULL, NULL, NULL, NULL, NULL);
-        STOP_TIMER("ff_eval")
-    }
-}
-#endif
diff --git a/ffmpeg.src/libavutil/integer.c b/ffmpeg.src/libavutil/integer.c
deleted file mode 100644
index 38a826f..0000000
--- a/ffmpeg.src/libavutil/integer.c
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * arbitrary precision integers
- * Copyright (c) 2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
- 
-/**
- * @file integer.c
- * arbitrary precision integers.
- * @author Michael Niedermayer <michaelni at gmx.at>
- */
-
-#include "common.h"
-#include "integer.h"
-
-AVInteger av_add_i(AVInteger a, AVInteger b){
-    int i, carry=0;
-    
-    for(i=0; i<AV_INTEGER_SIZE; i++){
-        carry= (carry>>16) + a.v[i] + b.v[i];
-        a.v[i]= carry;
-    }
-    return a;
-}
-
-AVInteger av_sub_i(AVInteger a, AVInteger b){
-    int i, carry=0;
-    
-    for(i=0; i<AV_INTEGER_SIZE; i++){
-        carry= (carry>>16) + a.v[i] - b.v[i];
-        a.v[i]= carry;
-    }
-    return a;
-}
-
-/**
- * returns the rounded down value of the logarithm of base 2 of the given AVInteger.
- * this is simply the index of the most significant bit which is 1. Or 0 of all bits are 0
- */
-int av_log2_i(AVInteger a){
-    int i;
-
-    for(i=AV_INTEGER_SIZE-1; i>=0; i--){
-        if(a.v[i])
-            return av_log2_16bit(a.v[i]) + 16*i;
-    }
-    return -1;
-}
-
-AVInteger av_mul_i(AVInteger a, AVInteger b){
-    AVInteger out;
-    int i, j;
-    int na= (av_log2_i(a)+16) >> 4;
-    int nb= (av_log2_i(b)+16) >> 4;
-    
-    memset(&out, 0, sizeof(out));
-    
-    for(i=0; i<na; i++){
-        unsigned int carry=0;
-        
-        if(a.v[i])
-            for(j=i; j<AV_INTEGER_SIZE && j-i<=nb; j++){
-                carry= (carry>>16) + out.v[j] + a.v[i]*b.v[j-i];
-                out.v[j]= carry;
-            }
-    }
-
-    return out;
-}
-
-/**
- * returns 0 if a==b, 1 if a>b and -1 if a<b.
- */
-int av_cmp_i(AVInteger a, AVInteger b){
-    int i; 
-    int v= (int16_t)a.v[AV_INTEGER_SIZE-1] - (int16_t)b.v[AV_INTEGER_SIZE-1];
-    if(v) return (v>>16)|1;
-    
-    for(i=AV_INTEGER_SIZE-2; i>=0; i--){
-        int v= a.v[i] - b.v[i];
-        if(v) return (v>>16)|1;
-    }
-    return 0;
-}
-
-/**
- * bitwise shift.
- * @param s the number of bits by which the value should be shifted right, may be negative for shifting left
- */
-AVInteger av_shr_i(AVInteger a, int s){
-    AVInteger out;
-    int i;
-
-    for(i=0; i<AV_INTEGER_SIZE; i++){
-        int index= i + (s>>4);
-        unsigned int v=0;
-        if(index+1<AV_INTEGER_SIZE && index+1>=0) v = a.v[index+1]<<16;
-        if(index  <AV_INTEGER_SIZE && index  >=0) v+= a.v[index  ];
-        out.v[i]= v >> (s&15);
-    }
-    return out;
-}
-
-/**
- * returns a % b.
- * @param quot a/b will be stored here
- */
-AVInteger av_mod_i(AVInteger *quot, AVInteger a, AVInteger b){
-    int i= av_log2_i(a) - av_log2_i(b);
-    AVInteger quot_temp;
-    if(!quot) quot = &quot_temp;
-    
-    assert((int16_t)a[AV_INTEGER_SIZE-1] >= 0 && (int16_t)b[AV_INTEGER_SIZE-1] >= 0);
-    assert(av_log2(b)>=0);
-    
-    if(i > 0)
-        b= av_shr_i(b, -i);
-        
-    memset(quot, 0, sizeof(AVInteger));
-
-    while(i-- >= 0){
-        *quot= av_shr_i(*quot, -1);
-        if(av_cmp_i(a, b) >= 0){
-            a= av_sub_i(a, b);
-            quot->v[0] += 1;
-        }
-        b= av_shr_i(b, 1);
-    }
-    return a;
-}
-
-/**
- * returns a/b.
- */
-AVInteger av_div_i(AVInteger a, AVInteger b){
-    AVInteger quot;
-    av_mod_i(&quot, a, b);
-    return quot;
-}
-
-/**
- * converts the given int64_t to an AVInteger.
- */
-AVInteger av_int2i(int64_t a){
-    AVInteger out;
-    int i;
-    
-    for(i=0; i<AV_INTEGER_SIZE; i++){
-        out.v[i]= a;
-        a>>=16;
-    }
-    return out;
-}
-
-/**
- * converts the given AVInteger to an int64_t.
- * if the AVInteger is too large to fit into an int64_t, 
- * then only the least significant 64bit will be used
- */
-int64_t av_i2int(AVInteger a){
-    int i;
-    int64_t out=(int8_t)a.v[AV_INTEGER_SIZE-1];
-    
-    for(i= AV_INTEGER_SIZE-2; i>=0; i--){
-        out = (out<<16) + a.v[i];
-    }
-    return out;
-}
-
-#if 0
-#undef NDEBUG
-#include <assert.h>
-
-const uint8_t ff_log2_tab[256]={
-        0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
-        5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
-        6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
-        6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
-        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
-};
-
-main(){
-    int64_t a,b;
-
-    for(a=7; a<256*256*256; a+=13215){
-        for(b=3; b<256*256*256; b+=27118){
-            AVInteger ai= av_int2i(a);
-            AVInteger bi= av_int2i(b);
-            
-            assert(av_i2int(ai) == a);
-            assert(av_i2int(bi) == b);
-            assert(av_i2int(av_add_i(ai,bi)) == a+b);
-            assert(av_i2int(av_sub_i(ai,bi)) == a-b);
-            assert(av_i2int(av_mul_i(ai,bi)) == a*b);
-            assert(av_i2int(av_shr_i(ai, 9)) == a>>9);
-            assert(av_i2int(av_shr_i(ai,-9)) == a<<9);
-            assert(av_i2int(av_shr_i(ai, 17)) == a>>17);
-            assert(av_i2int(av_shr_i(ai,-17)) == a<<17);
-            assert(av_log2_i(ai) == av_log2(a));
-            assert(av_i2int(av_div_i(ai,bi)) == a/b);
-        }
-    }
-}
-#endif
diff --git a/ffmpeg.src/libavutil/integer.h b/ffmpeg.src/libavutil/integer.h
deleted file mode 100644
index ef1b2a0..0000000
--- a/ffmpeg.src/libavutil/integer.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * arbitrary precision integers
- * Copyright (c) 2004 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
- 
-/**
- * @file integer.h
- * arbitrary precision integers
- * @author Michael Niedermayer <michaelni at gmx.at>
- */
- 
-#ifndef INTEGER_H
-#define INTEGER_H
-
-#define AV_INTEGER_SIZE 8
-
-typedef struct AVInteger{
-    uint16_t v[AV_INTEGER_SIZE]; 
-} AVInteger;
-
-AVInteger av_add_i(AVInteger a, AVInteger b);
-AVInteger av_sub_i(AVInteger a, AVInteger b);
-int av_log2_i(AVInteger a);
-AVInteger av_mul_i(AVInteger a, AVInteger b);
-int av_cmp_i(AVInteger a, AVInteger b);
-AVInteger av_shr_i(AVInteger a, int s);
-AVInteger av_mod_i(AVInteger *quot, AVInteger a, AVInteger b);
-AVInteger av_div_i(AVInteger a, AVInteger b);
-AVInteger av_int2i(int64_t a);
-int64_t av_i2int(AVInteger a);
-
-#endif // INTEGER_H
diff --git a/ffmpeg.src/libavutil/intfloat_readwrite.c b/ffmpeg.src/libavutil/intfloat_readwrite.c
deleted file mode 100644
index 81d35da..0000000
--- a/ffmpeg.src/libavutil/intfloat_readwrite.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * portable IEEE float/double read/write functions
- *
- * Copyright (c) 2005 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-/**
- * @file intfloat_readwrite.c
- * Portable IEEE float/double read/write functions.
- */
- 
-#include "common.h"
-
-double av_int2dbl(int64_t v){
-    if(v+v > 0xFFELLU<<52)
-        return 0.0/0.0;
-    return ldexp(((v&((1LL<<52)-1)) + (1LL<<52)) * (v>>63|1), (v>>52&0x7FF)-1075);
-}
-
-float av_int2flt(int32_t v){
-    if(v+v > 0xFF000000U)
-        return 0.0/0.0;
-    return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150);
-}
-
-int64_t av_dbl2int(double d){
-    int e;
-    if     ( !d) return 0;
-    else if(d-d) return 0x7FF0000000000000LL + ((int64_t)(d<0)<<63) + (d!=d);
-    d= frexp(d, &e);
-    return (int64_t)(d<0)<<63 | (e+1022LL)<<52 | (int64_t)((fabs(d)-0.5)*(1LL<<53));
-}
-
-int32_t av_flt2int(float d){
-    int e;
-    if     ( !d) return 0;
-    else if(d-d) return 0x7F800000 + ((d<0)<<31) + (d!=d);
-    d= frexp(d, &e);
-    return (d<0)<<31 | (e+126)<<23 | (int64_t)((fabs(d)-0.5)*(1<<24));
-}
diff --git a/ffmpeg.src/libavutil/intfloat_readwrite.h b/ffmpeg.src/libavutil/intfloat_readwrite.h
deleted file mode 100644
index 22f40bb..0000000
--- a/ffmpeg.src/libavutil/intfloat_readwrite.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef INTFLOAT_READWRITE_H
-#define INTFLOAT_READWRITE_H
-
-#include "common.h"
-
-double av_int2dbl(int64_t v);
-float av_int2flt(int32_t v);
-int64_t av_dbl2int(double d);
-int32_t av_flt2int(float d);
-
-#endif /* INTFLOAT_READWRITE_H */
diff --git a/ffmpeg.src/libavutil/mathematics.c b/ffmpeg.src/libavutil/mathematics.c
deleted file mode 100644
index aa3fd74..0000000
--- a/ffmpeg.src/libavutil/mathematics.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2005 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-/**
- * @file mathematics.c
- * Miscellaneous math routines and tables.
- */
-
-#include "common.h"
-#include "integer.h"
-#include "mathematics.h"
-
-const uint8_t ff_sqrt_tab[128]={
-        0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5,
-        5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
-        9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11
-};
-
-const uint8_t ff_log2_tab[256]={
-        0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
-        5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
-        6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
-        6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
-        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
-};
-
-int64_t ff_gcd(int64_t a, int64_t b){
-    if(b) return ff_gcd(b, a%b);
-    else  return a;
-}
-
-int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){
-    AVInteger ai;
-    int64_t r=0;
-    assert(c > 0);
-    assert(b >=0);
-    assert(rnd >=0 && rnd<=5 && rnd!=4);
-    
-    if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1)); 
-    
-    if(rnd==AV_ROUND_NEAR_INF) r= c/2;
-    else if(rnd&1)             r= c-1;
-
-    if(b<=INT_MAX && c<=INT_MAX){
-        if(a<=INT_MAX)
-            return (a * b + r)/c;
-        else
-            return a/c*b + (a%c*b + r)/c;
-    }
-    
-    ai= av_mul_i(av_int2i(a), av_int2i(b));
-    ai= av_add_i(ai, av_int2i(r));
-    
-    return av_i2int(av_div_i(ai, av_int2i(c)));
-}
-
-int64_t av_rescale(int64_t a, int64_t b, int64_t c){
-    return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
-}
-
-int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq){
-    int64_t b= bq.num * (int64_t)cq.den;
-    int64_t c= cq.num * (int64_t)bq.den;
-    return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
-}
diff --git a/ffmpeg.src/libavutil/mathematics.h b/ffmpeg.src/libavutil/mathematics.h
deleted file mode 100644
index 0cf726c..0000000
--- a/ffmpeg.src/libavutil/mathematics.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef MATHEMATICS_H
-#define MATHEMATICS_H
-
-#include "rational.h"
-
-enum AVRounding {
-    AV_ROUND_ZERO     = 0, ///< round toward zero
-    AV_ROUND_INF      = 1, ///< round away from zero
-    AV_ROUND_DOWN     = 2, ///< round toward -infinity
-    AV_ROUND_UP       = 3, ///< round toward +infinity
-    AV_ROUND_NEAR_INF = 5, ///< round to nearest and halfway cases away from zero
-};
-
-/**
- * rescale a 64bit integer with rounding to nearest.
- * a simple a*b/c isn't possible as it can overflow
- */
-int64_t av_rescale(int64_t a, int64_t b, int64_t c);
-
-/**
- * rescale a 64bit integer with specified rounding.
- * a simple a*b/c isn't possible as it can overflow
- */
-int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding);
-
-/**
- * rescale a 64bit integer by 2 rational numbers.
- */
-int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq);
-
-#endif /* MATHEMATICS_H */
diff --git a/ffmpeg.src/libavutil/rational.c b/ffmpeg.src/libavutil/rational.c
deleted file mode 100644
index 1044999..0000000
--- a/ffmpeg.src/libavutil/rational.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Rational numbers
- * Copyright (c) 2003 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
- 
-/**
- * @file rational.c
- * Rational numbers
- * @author Michael Niedermayer <michaelni at gmx.at>
- */
-
-//#include <math.h>
-#include <limits.h>
- 
-#include "common.h"
-#include "mathematics.h"
-#include "rational.h"
-
-int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max){
-    AVRational a0={0,1}, a1={1,0};
-    int sign= (nom<0) ^ (den<0);
-    int64_t gcd= ff_gcd(ABS(nom), ABS(den));
-
-    nom = ABS(nom)/gcd;
-    den = ABS(den)/gcd;
-    if(nom<=max && den<=max){
-        a1= (AVRational){nom, den};
-        den=0;
-    }
-    
-    while(den){
-        int64_t x       = nom / den;
-        int64_t next_den= nom - den*x;
-        int64_t a2n= x*a1.num + a0.num;
-        int64_t a2d= x*a1.den + a0.den;
-
-        if(a2n > max || a2d > max) break;
-
-        a0= a1;
-        a1= (AVRational){a2n, a2d};
-        nom= den;
-        den= next_den;
-    }
-    assert(ff_gcd(a1.num, a1.den) == 1);
-    
-    *dst_nom = sign ? -a1.num : a1.num;
-    *dst_den = a1.den;
-    
-    return den==0;
-}
-
-/**
- * returns b*c.
- */
-AVRational av_mul_q(AVRational b, AVRational c){
-    av_reduce(&b.num, &b.den, b.num * (int64_t)c.num, b.den * (int64_t)c.den, INT_MAX);
-    return b;
-}
-
-/**
- * returns b/c.
- */
-AVRational av_div_q(AVRational b, AVRational c){
-    av_reduce(&b.num, &b.den, b.num * (int64_t)c.den, b.den * (int64_t)c.num, INT_MAX);
-    return b;
-}
-
-/**
- * returns b+c.
- */
-AVRational av_add_q(AVRational b, AVRational c){
-    av_reduce(&b.num, &b.den, b.num * (int64_t)c.den + c.num * (int64_t)b.den, b.den * (int64_t)c.den, INT_MAX);
-    return b;
-}
-
-/**
- * returns b-c.
- */
-AVRational av_sub_q(AVRational b, AVRational c){
-    av_reduce(&b.num, &b.den, b.num * (int64_t)c.den - c.num * (int64_t)b.den, b.den * (int64_t)c.den, INT_MAX);
-    return b;
-}
-
-/**
- * Converts a double precission floating point number to a AVRational.
- * @param max the maximum allowed numerator and denominator
- */
-AVRational av_d2q(double d, int max){
-    AVRational a;
-    int exponent= FFMAX( (int)(log(ABS(d) + 1e-20)/log(2)), 0);
-    int64_t den= 1LL << (61 - exponent);
-    av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max);
-
-    return a;
-}
diff --git a/ffmpeg.src/libavutil/rational.h b/ffmpeg.src/libavutil/rational.h
deleted file mode 100644
index e4bfe5f..0000000
--- a/ffmpeg.src/libavutil/rational.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Rational numbers
- * Copyright (c) 2003 Michael Niedermayer <michaelni at gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
- 
-/**
- * @file rational.h
- * Rational numbers.
- * @author Michael Niedermayer <michaelni at gmx.at>
- */
-
-#ifndef RATIONAL_H
-#define RATIONAL_H
-
-/**
- * Rational number num/den.
- */
-typedef struct AVRational{
-    int num; ///< numerator
-    int den; ///< denominator
-} AVRational;
-
-/**
- * returns 0 if a==b, 1 if a>b and -1 if a<b.
- */
-static inline int av_cmp_q(AVRational a, AVRational b){
-    const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den;
-
-    if(tmp) return (tmp>>63)|1;
-    else    return 0;
-}
-
-/**
- * converts the given AVRational to a double.
- */
-static inline double av_q2d(AVRational a){
-    return a.num / (double) a.den;
-}
-
-/**
- * reduce a fraction.
- * this is usefull for framerate calculations
- * @param max the maximum allowed for dst_nom & dst_den
- * @return 1 if exact, 0 otherwise
- */
-int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
-
-AVRational av_mul_q(AVRational b, AVRational c);
-AVRational av_div_q(AVRational b, AVRational c);
-AVRational av_add_q(AVRational b, AVRational c);
-AVRational av_sub_q(AVRational b, AVRational c);
-AVRational av_d2q(double d, int max);
-
-#endif // RATIONAL_H

-- 
dvbcut packaging



More information about the pkg-multimedia-commits mailing list