From a9a9970c7303c616abb61b56754746cd86167fd3 Mon Sep 17 00:00:00 2001 From: pabs Date: Wed, 7 Mar 2007 17:27:37 +0000 Subject: [PATCH] Fix building mod_libavcodec with recent libavcodec/libavformat and remove ancient ffmpeg headers and code from SVN. The mod_libavcodec plugin does crash when used though, that is something for a later commit. git-svn-id: http://svn.voria.com/code@271 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/config/configure.ac | 25 +- .../trunk/src/modules/mod_libavcodec/Makefile.am | 13 +- .../src/modules/mod_libavcodec/libavcodec/4xm.c | 752 --- .../src/modules/mod_libavcodec/libavcodec/Doxyfile | 1038 ---- .../src/modules/mod_libavcodec/libavcodec/Makefile | 254 - .../modules/mod_libavcodec/libavcodec/Makefile.am | 1 - .../src/modules/mod_libavcodec/libavcodec/a52dec.c | 256 - .../src/modules/mod_libavcodec/libavcodec/ac3.h | 61 - .../src/modules/mod_libavcodec/libavcodec/ac3dec.c | 183 - .../src/modules/mod_libavcodec/libavcodec/ac3enc.c | 1579 ------ .../src/modules/mod_libavcodec/libavcodec/ac3tab.h | 186 - .../src/modules/mod_libavcodec/libavcodec/adpcm.c | 698 --- .../modules/mod_libavcodec/libavcodec/allcodecs.c | 166 - .../src/modules/mod_libavcodec/libavcodec/amr.c | 460 -- .../modules/mod_libavcodec/libavcodec/apiexample.c | 516 -- .../src/modules/mod_libavcodec/libavcodec/asv1.c | 667 --- .../modules/mod_libavcodec/libavcodec/avcodec.c | 172 - .../modules/mod_libavcodec/libavcodec/avcodec.h | 1688 ------- .../src/modules/mod_libavcodec/libavcodec/bswap.h | 129 - .../src/modules/mod_libavcodec/libavcodec/cabac.c | 206 - .../src/modules/mod_libavcodec/libavcodec/cabac.h | 381 -- .../src/modules/mod_libavcodec/libavcodec/cljr.c | 168 - .../src/modules/mod_libavcodec/libavcodec/common.c | 421 -- .../src/modules/mod_libavcodec/libavcodec/common.h | 1142 ----- .../src/modules/mod_libavcodec/libavcodec/cyuv.c | 186 - .../modules/mod_libavcodec/libavcodec/dct-test.c | 501 -- .../src/modules/mod_libavcodec/libavcodec/dpcm.c | 245 - .../modules/mod_libavcodec/libavcodec/dsputil.c | 3055 ------------ .../modules/mod_libavcodec/libavcodec/dsputil.h | 501 -- .../src/modules/mod_libavcodec/libavcodec/dv.c | 802 --- .../src/modules/mod_libavcodec/libavcodec/dvdata.h | 1280 ----- .../mod_libavcodec/libavcodec/error_resilience.c | 1007 ---- .../src/modules/mod_libavcodec/libavcodec/eval.c | 255 - .../src/modules/mod_libavcodec/libavcodec/faad.c | 247 - .../modules/mod_libavcodec/libavcodec/fastmemcpy.h | 1 - .../modules/mod_libavcodec/libavcodec/fdctref.c | 158 - .../modules/mod_libavcodec/libavcodec/fft-test.c | 277 -- .../src/modules/mod_libavcodec/libavcodec/fft.c | 250 - .../src/modules/mod_libavcodec/libavcodec/ffv1.c | 940 ---- .../src/modules/mod_libavcodec/libavcodec/golomb.c | 154 - .../src/modules/mod_libavcodec/libavcodec/golomb.h | 394 -- .../src/modules/mod_libavcodec/libavcodec/h263.c | 5256 -------------------- .../modules/mod_libavcodec/libavcodec/h263data.h | 199 - .../modules/mod_libavcodec/libavcodec/h263dec.c | 842 ---- .../src/modules/mod_libavcodec/libavcodec/h264.c | 4420 ---------------- .../modules/mod_libavcodec/libavcodec/h264data.h | 530 -- .../modules/mod_libavcodec/libavcodec/huffyuv.c | 1142 ----- .../mod_libavcodec/libavcodec/i386/cputest.c | 130 - .../mod_libavcodec/libavcodec/i386/dsputil_mmx.c | 1796 ------- .../libavcodec/i386/dsputil_mmx_avg.h | 427 -- .../libavcodec/i386/dsputil_mmx_rnd.h | 570 --- .../mod_libavcodec/libavcodec/i386/fdct_mmx.c | 291 -- .../mod_libavcodec/libavcodec/i386/fft_sse.c | 140 - .../mod_libavcodec/libavcodec/i386/idct_mmx.c | 596 --- .../modules/mod_libavcodec/libavcodec/i386/mmx.h | 243 - .../libavcodec/i386/motion_est_mmx.c | 420 -- .../mod_libavcodec/libavcodec/i386/mpegvideo_mmx.c | 519 -- .../libavcodec/i386/mpegvideo_mmx_template.c | 339 -- .../libavcodec/i386/simple_idct_mmx.c | 1313 ----- .../modules/mod_libavcodec/libavcodec/imgconvert.c | 2174 -------- .../libavcodec/imgconvert_template.h | 852 ---- .../mod_libavcodec/libavcodec/imgresample.c | 775 --- .../src/modules/mod_libavcodec/libavcodec/indeo3.c | 1120 ----- .../modules/mod_libavcodec/libavcodec/indeo3data.h | 2315 --------- .../mod_libavcodec/libavcodec/interplayvideo.c | 976 ---- .../modules/mod_libavcodec/libavcodec/jfdctfst.c | 236 - .../modules/mod_libavcodec/libavcodec/jfdctint.c | 297 -- .../modules/mod_libavcodec/libavcodec/jrevdct.c | 1176 ----- .../modules/mod_libavcodec/libavcodec/liba52/a52.h | 73 - .../libavcodec/liba52/a52_internal.h | 162 - .../mod_libavcodec/libavcodec/liba52/a52_util.h | 32 - .../libavcodec/liba52/bit_allocate.c | 260 - .../mod_libavcodec/libavcodec/liba52/bitstream.c | 91 - .../mod_libavcodec/libavcodec/liba52/bitstream.h | 77 - .../modules/mod_libavcodec/libavcodec/liba52/crc.c | 73 - .../mod_libavcodec/libavcodec/liba52/downmix.c | 679 --- .../mod_libavcodec/libavcodec/liba52/imdct.c | 411 -- .../mod_libavcodec/libavcodec/liba52/mm_accel.h | 42 - .../mod_libavcodec/libavcodec/liba52/parse.c | 939 ---- .../mod_libavcodec/libavcodec/liba52/resample.c | 43 - .../mod_libavcodec/libavcodec/liba52/resample_c.c | 183 - .../libavcodec/liba52/resample_mmx.c | 518 -- .../mod_libavcodec/libavcodec/liba52/tables.h | 246 - .../mod_libavcodec/libavcodec/libpostproc/Makefile | 66 - .../mod_libavcodec/libavcodec/libpostproc/mangle.h | 19 - .../libavcodec/libpostproc/postprocess.c | 986 ---- .../libavcodec/libpostproc/postprocess.h | 75 - .../libavcodec/libpostproc/postprocess_internal.h | 160 - .../libavcodec/libpostproc/postprocess_template.c | 3244 ------------ .../src/modules/mod_libavcodec/libavcodec/mace.c | 451 -- .../src/modules/mod_libavcodec/libavcodec/mdct.c | 175 - .../src/modules/mod_libavcodec/libavcodec/mdec.c | 276 - .../src/modules/mod_libavcodec/libavcodec/mem.c | 100 - .../src/modules/mod_libavcodec/libavcodec/mjpeg.c | 2114 -------- .../modules/mod_libavcodec/libavcodec/motion_est.c | 1684 ------- .../libavcodec/motion_est_template.c | 1074 ---- .../mod_libavcodec/libavcodec/motion_test.c | 138 - .../mod_libavcodec/libavcodec/mp3lameaudio.c | 107 - .../src/modules/mod_libavcodec/libavcodec/mpeg12.c | 2594 ---------- .../modules/mod_libavcodec/libavcodec/mpeg12data.h | 426 -- .../modules/mod_libavcodec/libavcodec/mpeg4data.h | 397 -- .../modules/mod_libavcodec/libavcodec/mpegaudio.c | 793 --- .../modules/mod_libavcodec/libavcodec/mpegaudio.h | 30 - .../mod_libavcodec/libavcodec/mpegaudiodec.c | 2608 ---------- .../mod_libavcodec/libavcodec/mpegaudiodectab.h | 774 --- .../mod_libavcodec/libavcodec/mpegaudiotab.h | 98 - .../modules/mod_libavcodec/libavcodec/mpegvideo.c | 4718 ------------------ .../modules/mod_libavcodec/libavcodec/mpegvideo.h | 903 ---- .../modules/mod_libavcodec/libavcodec/msmpeg4.c | 2023 -------- .../mod_libavcodec/libavcodec/msmpeg4data.h | 2004 -------- .../modules/mod_libavcodec/libavcodec/oggvorbis.c | 245 - .../modules/mod_libavcodec/libavcodec/oggvorbis.h | 15 - .../src/modules/mod_libavcodec/libavcodec/opts.c | 208 - .../src/modules/mod_libavcodec/libavcodec/pcm.c | 383 -- .../src/modules/mod_libavcodec/libavcodec/ra144.c | 513 -- .../src/modules/mod_libavcodec/libavcodec/ra144.h | 2426 --------- .../src/modules/mod_libavcodec/libavcodec/ra288.c | 278 -- .../src/modules/mod_libavcodec/libavcodec/ra288.h | 203 - .../mod_libavcodec/libavcodec/ratecontrol.c | 835 ---- .../src/modules/mod_libavcodec/libavcodec/raw.c | 176 - .../modules/mod_libavcodec/libavcodec/resample.c | 351 -- .../modules/mod_libavcodec/libavcodec/roqvideo.c | 406 -- .../src/modules/mod_libavcodec/libavcodec/rv10.c | 541 -- .../mod_libavcodec/libavcodec/simple_idct.c | 585 --- .../mod_libavcodec/libavcodec/simple_idct.h | 36 - .../src/modules/mod_libavcodec/libavcodec/svq1.c | 842 ---- .../modules/mod_libavcodec/libavcodec/svq1_cb.h | 1512 ------ .../modules/mod_libavcodec/libavcodec/svq1_vlc.h | 283 -- .../src/modules/mod_libavcodec/libavcodec/svq3.c | 969 ---- .../src/modules/mod_libavcodec/libavcodec/utils.c | 699 --- .../src/modules/mod_libavcodec/libavcodec/vcr1.c | 200 - .../src/modules/mod_libavcodec/libavcodec/vp3.c | 2832 ----------- .../modules/mod_libavcodec/libavcodec/vp3data.h | 2812 ----------- .../modules/mod_libavcodec/libavcodec/wmadata.h | 1412 ------ .../src/modules/mod_libavcodec/libavcodec/wmadec.c | 1314 ----- .../src/modules/mod_libavcodec/libavcodec/wmv2.c | 850 ---- .../src/modules/mod_libavcodec/libavcodec/xan.c | 820 --- .../modules/mod_libavcodec/libavcodec/xvmcvideo.c | 287 -- .../src/modules/mod_libavcodec/libavformat/4xm.c | 345 -- .../modules/mod_libavcodec/libavformat/Makefile | 129 - .../modules/mod_libavcodec/libavformat/Makefile.am | 1 - .../mod_libavcodec/libavformat/allformats.c | 110 - .../src/modules/mod_libavcodec/libavformat/amr.c | 178 - .../src/modules/mod_libavcodec/libavformat/asf.c | 1288 ----- .../src/modules/mod_libavcodec/libavformat/au.c | 208 - .../src/modules/mod_libavcodec/libavformat/audio.c | 343 -- .../modules/mod_libavcodec/libavformat/avformat.h | 544 -- .../src/modules/mod_libavcodec/libavformat/avi.h | 40 - .../modules/mod_libavcodec/libavformat/avidec.c | 458 -- .../modules/mod_libavcodec/libavformat/avienc.c | 716 --- .../src/modules/mod_libavcodec/libavformat/avio.c | 188 - .../src/modules/mod_libavcodec/libavformat/avio.h | 169 - .../modules/mod_libavcodec/libavformat/aviobuf.c | 684 --- .../modules/mod_libavcodec/libavformat/barpainet.c | 25 - .../modules/mod_libavcodec/libavformat/barpainet.h | 25 - .../mod_libavcodec/libavformat/beosaudio.cpp | 463 -- .../src/modules/mod_libavcodec/libavformat/crc.c | 111 - .../modules/mod_libavcodec/libavformat/cutils.c | 239 - .../src/modules/mod_libavcodec/libavformat/dv.c | 164 - .../modules/mod_libavcodec/libavformat/dv1394.c | 313 -- .../modules/mod_libavcodec/libavformat/dv1394.h | 354 -- .../modules/mod_libavcodec/libavformat/dvcore.c | 668 --- .../modules/mod_libavcodec/libavformat/dvcore.h | 73 - .../src/modules/mod_libavcodec/libavformat/ffm.c | 685 --- .../src/modules/mod_libavcodec/libavformat/file.c | 132 - .../modules/mod_libavcodec/libavformat/flvdec.c | 156 - .../modules/mod_libavcodec/libavformat/flvenc.c | 383 -- .../modules/mod_libavcodec/libavformat/framehook.c | 119 - .../modules/mod_libavcodec/libavformat/framehook.h | 29 - .../src/modules/mod_libavcodec/libavformat/gif.c | 420 -- .../modules/mod_libavcodec/libavformat/gifdec.c | 634 --- .../src/modules/mod_libavcodec/libavformat/grab.c | 848 ---- .../src/modules/mod_libavcodec/libavformat/http.c | 289 -- .../src/modules/mod_libavcodec/libavformat/idroq.c | 301 -- .../src/modules/mod_libavcodec/libavformat/img.c | 414 -- .../modules/mod_libavcodec/libavformat/ipmovie.c | 627 --- .../src/modules/mod_libavcodec/libavformat/jpeg.c | 238 - .../src/modules/mod_libavcodec/libavformat/mov.c | 1686 ------- .../modules/mod_libavcodec/libavformat/movenc.c | 826 --- .../src/modules/mod_libavcodec/libavformat/mp3.c | 397 -- .../src/modules/mod_libavcodec/libavformat/mpeg.c | 710 --- .../modules/mod_libavcodec/libavformat/mpegts.c | 1052 ---- .../modules/mod_libavcodec/libavformat/mpegts.h | 44 - .../modules/mod_libavcodec/libavformat/mpegtsenc.c | 610 --- .../modules/mod_libavcodec/libavformat/mpjpeg.c | 108 - .../src/modules/mod_libavcodec/libavformat/nut.c | 599 --- .../src/modules/mod_libavcodec/libavformat/ogg.c | 263 - .../mod_libavcodec/libavformat/os_support.c | 57 - .../mod_libavcodec/libavformat/os_support.h | 33 - .../src/modules/mod_libavcodec/libavformat/png.c | 887 ---- .../src/modules/mod_libavcodec/libavformat/pnm.c | 476 -- .../modules/mod_libavcodec/libavformat/psxstr.c | 352 -- .../src/modules/mod_libavcodec/libavformat/raw.c | 527 -- .../src/modules/mod_libavcodec/libavformat/rm.c | 855 ---- .../src/modules/mod_libavcodec/libavformat/rtp.c | 702 --- .../src/modules/mod_libavcodec/libavformat/rtp.h | 40 - .../modules/mod_libavcodec/libavformat/rtpproto.c | 300 -- .../src/modules/mod_libavcodec/libavformat/rtsp.c | 1256 ----- .../src/modules/mod_libavcodec/libavformat/rtsp.h | 91 - .../modules/mod_libavcodec/libavformat/rtspcodes.h | 11 - .../src/modules/mod_libavcodec/libavformat/swf.c | 572 --- .../src/modules/mod_libavcodec/libavformat/tcp.c | 234 - .../src/modules/mod_libavcodec/libavformat/udp.c | 277 -- .../src/modules/mod_libavcodec/libavformat/utils.c | 1732 ------- .../src/modules/mod_libavcodec/libavformat/wav.c | 346 -- .../modules/mod_libavcodec/libavformat/wc3movie.c | 411 -- .../src/modules/mod_libavcodec/libavformat/yuv.c | 158 - .../modules/mod_libavcodec/libavformat/yuv4mpeg.c | 274 - .../trunk/src/modules/mod_libavcodec/trgt_av.cpp | 45 +- 209 files changed, 52 insertions(+), 133398 deletions(-) delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/4xm.c delete mode 100755 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/Doxyfile delete mode 100755 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/Makefile delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/Makefile.am delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/a52dec.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ac3.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ac3dec.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ac3enc.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ac3tab.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/adpcm.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/allcodecs.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/amr.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/apiexample.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/asv1.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/avcodec.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/avcodec.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/bswap.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/cabac.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/cabac.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/cljr.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/common.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/common.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/cyuv.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dct-test.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dpcm.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dsputil.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dsputil.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dv.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dvdata.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/error_resilience.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/eval.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/faad.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fastmemcpy.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fdctref.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fft-test.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fft.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ffv1.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/golomb.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/golomb.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h263.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h263data.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h263dec.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h264.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h264data.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/huffyuv.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/cputest.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/dsputil_mmx.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/dsputil_mmx_avg.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/dsputil_mmx_rnd.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/fdct_mmx.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/fft_sse.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/idct_mmx.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/mmx.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/motion_est_mmx.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/mpegvideo_mmx.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/mpegvideo_mmx_template.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/simple_idct_mmx.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/imgconvert.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/imgconvert_template.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/imgresample.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/indeo3.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/indeo3data.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/interplayvideo.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/jfdctfst.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/jfdctint.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/jrevdct.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/a52.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/a52_internal.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/a52_util.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/bit_allocate.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/bitstream.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/bitstream.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/crc.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/downmix.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/imdct.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/mm_accel.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/parse.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/resample.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/resample_c.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/resample_mmx.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/tables.h delete mode 100755 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/Makefile delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/mangle.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/postprocess.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/postprocess.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/postprocess_internal.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/postprocess_template.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mace.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mdct.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mdec.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mem.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mjpeg.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/motion_est.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/motion_est_template.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/motion_test.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mp3lameaudio.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mpeg12.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mpeg12data.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mpeg4data.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mpegaudio.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mpegaudio.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mpegaudiodec.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mpegaudiodectab.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mpegaudiotab.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mpegvideo.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/mpegvideo.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/msmpeg4.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/msmpeg4data.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/oggvorbis.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/oggvorbis.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/opts.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/pcm.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ra144.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ra144.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ra288.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ra288.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ratecontrol.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/raw.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/resample.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/roqvideo.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/rv10.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/simple_idct.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/simple_idct.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/svq1.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/svq1_cb.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/svq1_vlc.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/svq3.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/utils.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/vcr1.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/vp3.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/vp3data.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/wmadata.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/wmadec.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/wmv2.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/xan.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/xvmcvideo.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/4xm.c delete mode 100755 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/Makefile delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/Makefile.am delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/allformats.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/amr.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/asf.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/au.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/audio.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/avformat.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/avi.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/avidec.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/avienc.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/avio.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/avio.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/aviobuf.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/barpainet.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/barpainet.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/beosaudio.cpp delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/crc.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/cutils.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/dv.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/dv1394.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/dv1394.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/dvcore.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/dvcore.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/ffm.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/file.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/flvdec.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/flvenc.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/framehook.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/framehook.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/gif.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/gifdec.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/grab.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/http.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/idroq.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/img.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/ipmovie.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/jpeg.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/mov.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/movenc.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/mp3.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/mpeg.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/mpegts.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/mpegts.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/mpegtsenc.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/mpjpeg.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/nut.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/ogg.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/os_support.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/os_support.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/png.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/pnm.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/psxstr.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/raw.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/rm.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/rtp.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/rtp.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/rtpproto.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/rtsp.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/rtsp.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/rtspcodes.h delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/swf.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/tcp.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/udp.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/utils.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/wav.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/wc3movie.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/yuv.c delete mode 100644 synfig-core/trunk/src/modules/mod_libavcodec/libavformat/yuv4mpeg.c diff --git a/synfig-core/trunk/config/configure.ac b/synfig-core/trunk/config/configure.ac index b10a1d3..dae5009 100644 --- a/synfig-core/trunk/config/configure.ac +++ b/synfig-core/trunk/config/configure.ac @@ -197,26 +197,29 @@ if test $with_libdv = "no" ; then { +# LIBAVCODEC CHECK-------------------- AC_ARG_WITH(libavcodec,[ - --with-libavcodec Enable support for libavcodec (Default=auto)],[ + --without-libavcodec disable support for libavcodec (Default=auto)],[ ],[ - AC_CHECK_LIB(avcodec, avcodec_find_encoder,[ - with_libavcodec="yes" - ],[ - with_libavcodec="no" - ]) + with_libavcodec="yes" ]) -if test $with_libavcodec = "no" ; then { - AM_CONDITIONAL(WITH_LIBAVCODEC,false) -} else { + +if test $with_libavcodec != "no" ; then { + PKG_CHECK_MODULES(LIBAVCODEC, libavcodec,[with_libavcodec="yes"],[with_libavcodec="no"]) +} ; fi +if test $with_libavcodec != "no" ; then { + PKG_CHECK_MODULES(LIBAVFORMAT, libavformat,[with_libavcodec="yes"],[with_libavcodec="no"]) +} ; fi +if test $with_libavcodec = "yes" ; then { + AC_DEFINE(WITH_LIBAVCODEC,[],[enable libavcodec support]) AM_CONDITIONAL(WITH_LIBAVCODEC,true) +} else { + AM_CONDITIONAL(WITH_LIBAVCODEC,false) } ; fi - - # FREETYPE2 CHECK-------------------- AC_ARG_WITH(freetype,[ diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/Makefile.am b/synfig-core/trunk/src/modules/mod_libavcodec/Makefile.am index c84d9c0..bb159e6 100644 --- a/synfig-core/trunk/src/modules/mod_libavcodec/Makefile.am +++ b/synfig-core/trunk/src/modules/mod_libavcodec/Makefile.am @@ -2,19 +2,16 @@ MAINTAINERCLEANFILES=Makefile.in -INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/modules/mod_libavcodec/libavcodec -I$(top_srcdir)/src/modules/mod_libavcodec/libavformat +INCLUDES = -I$(top_srcdir)/src moduledir=@MODULE_DIR@ if WITH_LIBAVCODEC module_LTLIBRARIES = libmod_libavcodec.la - -# Add the filenames to the following line: libmod_libavcodec_la_SOURCES = main.cpp trgt_av.cpp trgt_av.h mptr.cpp mptr.h - -libmod_libavcodec_la_LDFLAGS = -module -no-undefined -lavcodec -lavformat -libmod_libavcodec_la_CXXFLAGS = @SYNFIG_CFLAGS@ -libmod_libavcodec_la_LIBADD = -L../../synfig -lsynfig @SYNFIG_LIBS@ +libmod_libavcodec_la_LDFLAGS = -module -no-undefined +libmod_libavcodec_la_CXXFLAGS = @SYNFIG_CFLAGS@ @LIBAVCODEC_CFLAGS@ @LIBAVFORMAT_CFLAGS@ +libmod_libavcodec_la_LIBADD = -L../../synfig -lsynfig @SYNFIG_LIBS@ @LIBAVCODEC_LIBS@ @LIBAVFORMAT_LIBS@ else endif -EXTRA_DIST= mod_libavcodec.nsh unmod_libavcodec.nsh libavcodec/ac3.h libavcodec/ac3tab.h libavcodec/avcodec.h libavcodec/bswap.h libavcodec/cabac.h libavcodec/common.h libavcodec/dsputil.h libavcodec/dvdata.h libavcodec/fastmemcpy.h libavcodec/golomb.h libavcodec/h263data.h libavcodec/h264data.h libavcodec/i386/dsputil_mmx_avg.h libavcodec/i386/dsputil_mmx_rnd.h libavcodec/i386/mmx.h libavcodec/imgconvert_template.h libavcodec/indeo3data.h libavcodec/liba52/a52.h libavcodec/liba52/a52_internal.h libavcodec/liba52/a52_util.h libavcodec/liba52/bitstream.h libavcodec/liba52/mm_accel.h libavcodec/liba52/tables.h libavcodec/libpostproc/mangle.h libavcodec/libpostproc/postprocess.h libavcodec/libpostproc/postprocess_internal.h libavcodec/mpeg12data.h libavcodec/mpeg4data.h libavcodec/mpegaudio.h libavcodec/mpegaudiodectab.h libavcodec/mpegaudiotab.h libavcodec/mpegvideo.h libavcodec/msmpeg4data.h libavcodec/oggvorbis.h libavcodec/ra144.h libavcodec/ra288.h libavcodec/simple_idct.h libavcodec/svq1_cb.h libavcodec/svq1_vlc.h libavcodec/vp3data.h libavcodec/wmadata.h libavformat/avformat.h libavformat/avi.h libavformat/avio.h libavformat/barpainet.h libavformat/dv1394.h libavformat/dvcore.h libavformat/framehook.h libavformat/mpegts.h libavformat/os_support.h libavformat/rtp.h libavformat/rtsp.h libavformat/rtspcodes.h +EXTRA_DIST= mod_libavcodec.nsh unmod_libavcodec.nsh diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/4xm.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/4xm.c deleted file mode 100644 index 6821433..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/4xm.c +++ /dev/null @@ -1,752 +0,0 @@ -/* - * 4XM 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 - */ - -/** - * @file 4xm.c - * 4XM codec. - */ - -#include "avcodec.h" -#include "dsputil.h" -#include "mpegvideo.h" - -//#undef NDEBUG -//#include - -#define BLOCK_TYPE_VLC_BITS 5 -#define ACDC_VLC_BITS 9 - -#define CFRAME_BUFFER_COUNT 100 - -static const uint8_t block_type_tab[4][8][2]={ - { //{8,4,2}x{8,4,2} - { 0,1}, { 2,2}, { 6,3}, {14,4}, {30,5}, {31,5}, { 0,0} - },{ //{8,4}x1 - { 0,1}, { 0,0}, { 2,2}, { 6,3}, {14,4}, {15,4}, { 0,0} - },{ //1x{8,4} - { 0,1}, { 2,2}, { 0,0}, { 6,3}, {14,4}, {15,4}, { 0,0} - },{ //1x2, 2x1 - { 0,1}, { 0,0}, { 0,0}, { 2,2}, { 6,3}, {14,4}, {15,4} - } -}; - -static const uint8_t size2index[4][4]={ - {-1, 3, 1, 1}, - { 3, 0, 0, 0}, - { 2, 0, 0, 0}, - { 2, 0, 0, 0}, -}; - -static const int8_t mv[256][2]={ -{ 0, 0},{ 0, -1},{ -1, 0},{ 1, 0},{ 0, 1},{ -1, -1},{ 1, -1},{ -1, 1}, -{ 1, 1},{ 0, -2},{ -2, 0},{ 2, 0},{ 0, 2},{ -1, -2},{ 1, -2},{ -2, -1}, -{ 2, -1},{ -2, 1},{ 2, 1},{ -1, 2},{ 1, 2},{ -2, -2},{ 2, -2},{ -2, 2}, -{ 2, 2},{ 0, -3},{ -3, 0},{ 3, 0},{ 0, 3},{ -1, -3},{ 1, -3},{ -3, -1}, -{ 3, -1},{ -3, 1},{ 3, 1},{ -1, 3},{ 1, 3},{ -2, -3},{ 2, -3},{ -3, -2}, -{ 3, -2},{ -3, 2},{ 3, 2},{ -2, 3},{ 2, 3},{ 0, -4},{ -4, 0},{ 4, 0}, -{ 0, 4},{ -1, -4},{ 1, -4},{ -4, -1},{ 4, -1},{ 4, 1},{ -1, 4},{ 1, 4}, -{ -3, -3},{ -3, 3},{ 3, 3},{ -2, -4},{ -4, -2},{ 4, -2},{ -4, 2},{ -2, 4}, -{ 2, 4},{ -3, -4},{ 3, -4},{ 4, -3},{ -5, 0},{ -4, 3},{ -3, 4},{ 3, 4}, -{ -1, -5},{ -5, -1},{ -5, 1},{ -1, 5},{ -2, -5},{ 2, -5},{ 5, -2},{ 5, 2}, -{ -4, -4},{ -4, 4},{ -3, -5},{ -5, -3},{ -5, 3},{ 3, 5},{ -6, 0},{ 0, 6}, -{ -6, -1},{ -6, 1},{ 1, 6},{ 2, -6},{ -6, 2},{ 2, 6},{ -5, -4},{ 5, 4}, -{ 4, 5},{ -6, -3},{ 6, 3},{ -7, 0},{ -1, -7},{ 5, -5},{ -7, 1},{ -1, 7}, -{ 4, -6},{ 6, 4},{ -2, -7},{ -7, 2},{ -3, -7},{ 7, -3},{ 3, 7},{ 6, -5}, -{ 0, -8},{ -1, -8},{ -7, -4},{ -8, 1},{ 4, 7},{ 2, -8},{ -2, 8},{ 6, 6}, -{ -8, 3},{ 5, -7},{ -5, 7},{ 8, -4},{ 0, -9},{ -9, -1},{ 1, 9},{ 7, -6}, -{ -7, 6},{ -5, -8},{ -5, 8},{ -9, 3},{ 9, -4},{ 7, -7},{ 8, -6},{ 6, 8}, -{ 10, 1},{-10, 2},{ 9, -5},{ 10, -3},{ -8, -7},{-10, -4},{ 6, -9},{-11, 0}, -{ 11, 1},{-11, -2},{ -2, 11},{ 7, -9},{ -7, 9},{ 10, 6},{ -4, 11},{ 8, -9}, -{ 8, 9},{ 5, 11},{ 7,-10},{ 12, -3},{ 11, 6},{ -9, -9},{ 8, 10},{ 5, 12}, -{-11, 7},{ 13, 2},{ 6,-12},{ 10, 9},{-11, 8},{ -7, 12},{ 0, 14},{ 14, -2}, -{ -9, 11},{ -6, 13},{-14, -4},{ -5,-14},{ 5, 14},{-15, -1},{-14, -6},{ 3,-15}, -{ 11,-11},{ -7, 14},{ -5, 15},{ 8,-14},{ 15, 6},{ 3, 16},{ 7,-15},{-16, 5}, -{ 0, 17},{-16, -6},{-10, 14},{-16, 7},{ 12, 13},{-16, 8},{-17, 6},{-18, 3}, -{ -7, 17},{ 15, 11},{ 16, 10},{ 2,-19},{ 3,-19},{-11,-16},{-18, 8},{-19, -6}, -{ 2,-20},{-17,-11},{-10,-18},{ 8, 19},{-21, -1},{-20, 7},{ -4, 21},{ 21, 5}, -{ 15, 16},{ 2,-22},{-10,-20},{-22, 5},{ 20,-11},{ -7,-22},{-12, 20},{ 23, -5}, -{ 13,-20},{ 24, -2},{-15, 19},{-11, 22},{ 16, 19},{ 23,-10},{-18,-18},{ -9,-24}, -{ 24,-10},{ -3, 26},{-23, 13},{-18,-20},{ 17, 21},{ -4, 27},{ 27, 6},{ 1,-28}, -{-11, 26},{-17,-23},{ 7, 28},{ 11,-27},{ 29, 5},{-23,-19},{-28,-11},{-21, 22}, -{-30, 7},{-17, 26},{-27, 16},{ 13, 29},{ 19,-26},{ 10,-31},{-14,-30},{ 20,-27}, -{-29, 18},{-16,-31},{-28,-22},{ 21,-30},{-25, 28},{ 26,-29},{ 25,-32},{-32,-32} -}; - -// this is simply the scaled down elementwise product of the standard jpeg quantizer table and the AAN premul table -static const uint8_t dequant_table[64]={ - 16, 15, 13, 19, 24, 31, 28, 17, - 17, 23, 25, 31, 36, 63, 45, 21, - 18, 24, 27, 37, 52, 59, 49, 20, - 16, 28, 34, 40, 60, 80, 51, 20, - 18, 31, 48, 66, 68, 86, 56, 21, - 19, 38, 56, 59, 64, 64, 48, 20, - 27, 48, 55, 55, 56, 51, 35, 15, - 20, 35, 34, 32, 31, 22, 15, 8, -}; - -static VLC block_type_vlc[4]; - - -typedef struct CFrameBuffer{ - int allocated_size; - int size; - int id; - uint8_t *data; -}CFrameBuffer; - -typedef struct FourXContext{ - AVCodecContext *avctx; - DSPContext dsp; - AVFrame current_picture, last_picture; - GetBitContext pre_gb; ///< ac/dc prefix - GetBitContext gb; - uint8_t *bytestream; - uint16_t *wordstream; - int mv[256]; - VLC pre_vlc; - int last_dc; - DCTELEM __align8 block[6][64]; - uint8_t *bitstream_buffer; - int bitstream_buffer_size; - CFrameBuffer cfrm[CFRAME_BUFFER_COUNT]; -} FourXContext; - - -#define FIX_1_082392200 70936 -#define FIX_1_414213562 92682 -#define FIX_1_847759065 121095 -#define FIX_2_613125930 171254 - -#define MULTIPLY(var,const) (((var)*(const)) >> 16) - -static void idct(DCTELEM block[64]){ - int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - int tmp10, tmp11, tmp12, tmp13; - int z5, z10, z11, z12, z13; - int i; - int temp[64]; - - for(i=0; i<8; i++){ - tmp10 = block[8*0 + i] + block[8*4 + i]; - tmp11 = block[8*0 + i] - block[8*4 + i]; - - tmp13 = block[8*2 + i] + block[8*6 + i]; - tmp12 = MULTIPLY(block[8*2 + i] - block[8*6 + i], FIX_1_414213562) - tmp13; - - tmp0 = tmp10 + tmp13; - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - z13 = block[8*5 + i] + block[8*3 + i]; - z10 = block[8*5 + i] - block[8*3 + i]; - z11 = block[8*1 + i] + block[8*7 + i]; - z12 = block[8*1 + i] - block[8*7 + i]; - - tmp7 = z11 + z13; - tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); - - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); - tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; - tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; - - tmp6 = tmp12 - tmp7; - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - temp[8*0 + i] = tmp0 + tmp7; - temp[8*7 + i] = tmp0 - tmp7; - temp[8*1 + i] = tmp1 + tmp6; - temp[8*6 + i] = tmp1 - tmp6; - temp[8*2 + i] = tmp2 + tmp5; - temp[8*5 + i] = tmp2 - tmp5; - temp[8*4 + i] = tmp3 + tmp4; - temp[8*3 + i] = tmp3 - tmp4; - } - - for(i=0; i<8*8; i+=8){ - tmp10 = temp[0 + i] + temp[4 + i]; - tmp11 = temp[0 + i] - temp[4 + i]; - - tmp13 = temp[2 + i] + temp[6 + i]; - tmp12 = MULTIPLY(temp[2 + i] - temp[6 + i], FIX_1_414213562) - tmp13; - - tmp0 = tmp10 + tmp13; - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - z13 = temp[5 + i] + temp[3 + i]; - z10 = temp[5 + i] - temp[3 + i]; - z11 = temp[1 + i] + temp[7 + i]; - z12 = temp[1 + i] - temp[7 + i]; - - tmp7 = z11 + z13; - tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); - - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); - tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; - tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; - - tmp6 = tmp12 - tmp7; - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - block[0 + i] = (tmp0 + tmp7)>>6; - block[7 + i] = (tmp0 - tmp7)>>6; - block[1 + i] = (tmp1 + tmp6)>>6; - block[6 + i] = (tmp1 - tmp6)>>6; - block[2 + i] = (tmp2 + tmp5)>>6; - block[5 + i] = (tmp2 - tmp5)>>6; - block[4 + i] = (tmp3 + tmp4)>>6; - block[3 + i] = (tmp3 - tmp4)>>6; - } -} - -static void init_vlcs(FourXContext *f){ - static int done = 0; - int i; - - if (!done) { - done = 1; - - for(i=0; i<4; i++){ - init_vlc(&block_type_vlc[i], BLOCK_TYPE_VLC_BITS, 7, - &block_type_tab[i][0][1], 2, 1, - &block_type_tab[i][0][0], 2, 1); - } - } -} - -static void init_mv(FourXContext *f){ - int i; - - for(i=0; i<256; i++){ - f->mv[i] = mv[i][0] + mv[i][1]*f->current_picture.linesize[0]/2; - } -} - -static inline void mcdc(uint16_t *dst, uint16_t *src, int log2w, int h, int stride, int scale, int dc){ - int i; - dc*= 0x10001; - - switch(log2w){ - case 0: - for(i=0; igb, block_type_vlc[index].table, BLOCK_TYPE_VLC_BITS, 1); - - assert(code>=0 && code<=6); - - if(code == 0){ - src += f->mv[ *f->bytestream++ ]; - mcdc(dst, src, log2w, h, stride, 1, 0); - }else if(code == 1){ - log2h--; - decode_p_block(f, dst , src , log2w, log2h, stride); - decode_p_block(f, dst + (stride<mv[ *f->bytestream++ ]; - mcdc(dst, src, log2w, h, stride, 1, le2me_16(*f->wordstream++)); - }else if(code == 5){ - mcdc(dst, src, log2w, h, stride, 0, le2me_16(*f->wordstream++)); - }else if(code == 6){ - if(log2w){ - dst[0] = le2me_16(*f->wordstream++); - dst[1] = le2me_16(*f->wordstream++); - }else{ - dst[0 ] = le2me_16(*f->wordstream++); - dst[stride] = le2me_16(*f->wordstream++); - } - } -} - -static int get32(void *p){ - return le2me_32(*(uint32_t*)p); -} - -static int decode_p_frame(FourXContext *f, uint8_t *buf, int length){ - int x, y; - const int width= f->avctx->width; - const int height= f->avctx->height; - uint16_t *src= (uint16_t*)f->last_picture.data[0]; - uint16_t *dst= (uint16_t*)f->current_picture.data[0]; - const int stride= f->current_picture.linesize[0]>>1; - const int bitstream_size= get32(buf+8); - const int bytestream_size= get32(buf+16); - const int wordstream_size= get32(buf+12); - - if(bitstream_size+ bytestream_size+ wordstream_size + 20 != length) - printf("lengths %d %d %d %d\n", bitstream_size, bytestream_size, wordstream_size, - bitstream_size+ bytestream_size+ wordstream_size - length); - - f->bitstream_buffer= av_fast_realloc(f->bitstream_buffer, &f->bitstream_buffer_size, bitstream_size + FF_INPUT_BUFFER_PADDING_SIZE); - f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (uint32_t*)(buf + 20), bitstream_size/4); - init_get_bits(&f->gb, f->bitstream_buffer, 8*bitstream_size); - - f->wordstream= (uint16_t*)(buf + 20 + bitstream_size); - f->bytestream= buf + 20 + bitstream_size + wordstream_size; - - init_mv(f); - - for(y=0; ygb)+31)/32*4) - printf(" %d %d %d bytes left\n", - bitstream_size - (get_bits_count(&f->gb)+31)/32*4, - bytestream_size - (f->bytestream - (buf + 20 + bitstream_size + wordstream_size)), - wordstream_size - (((uint8_t*)f->wordstream) - (buf + 20 + bitstream_size)) - ); - - return 0; -} - -/** - * decode block and dequantize. - * Note this is allmost identical to mjpeg - */ -static int decode_i_block(FourXContext *f, DCTELEM *block){ - int code, i, j, level, val; - - /* DC coef */ - val = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3); - if (val>>4){ - printf("error dc run != 0\n"); - } - - if(val) - val = get_xbits(&f->gb, val); - - val = val * dequant_table[0] + f->last_dc; - f->last_dc = - block[0] = val; - /* AC coefs */ - i = 1; - for(;;) { - code = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3); - - /* EOB */ - if (code == 0) - break; - if (code == 0xf0) { - i += 16; - } else { - level = get_xbits(&f->gb, code & 0xf); - i += code >> 4; - if (i >= 64) { - printf("run %d oveflow\n", i); - return 0; - } - - j= ff_zigzag_direct[i]; - block[j] = level * dequant_table[j]; - i++; - if (i >= 64) - break; - } - } - - return 0; -} - -static inline void idct_put(FourXContext *f, int x, int y){ - DCTELEM (*block)[64]= f->block; - int stride= f->current_picture.linesize[0]>>1; - int i; - uint16_t *dst = ((uint16_t*)f->current_picture.data[0]) + y * stride + x; - - for(i=0; i<4; i++){ - block[i][0] += 0x80*8*8; - idct(block[i]); - } - - if(!(f->avctx->flags&CODEC_FLAG_GRAY)){ - for(i=4; i<6; i++) idct(block[i]); - } - - for(y=0; y<8; y++){ - for(x=0; x<8; x++){ - DCTELEM *temp= block[(x>>2) + 2*(y>>2)] + 2*(x&3) + 2*8*(y&3); //FIXME optimize - int cb= block[4][x + 8*y]; - int cr= block[5][x + 8*y]; - int cg= (cb + cr)>>1; - int y; - - cb+=cb; - - y = temp[0]; - dst[0 ]= ((y+cb)>>3) + (((y-cg)&0xFC)<<3) + (((y+cr)&0xF8)<<8); - y = temp[1]; - dst[1 ]= ((y+cb)>>3) + (((y-cg)&0xFC)<<3) + (((y+cr)&0xF8)<<8); - y = temp[8]; - dst[ stride]= ((y+cb)>>3) + (((y-cg)&0xFC)<<3) + (((y+cr)&0xF8)<<8); - y = temp[9]; - dst[1+stride]= ((y+cb)>>3) + (((y-cg)&0xFC)<<3) + (((y+cr)&0xF8)<<8); - dst += 2; - } - dst += 2*stride - 2*8; - } -} - -static int decode_i_mb(FourXContext *f){ - int i; - - f->dsp.clear_blocks(f->block[0]); - - for(i=0; i<6; i++){ - if(decode_i_block(f, f->block[i]) < 0) - return -1; - } - - return 0; -} - -static uint8_t *read_huffman_tables(FourXContext *f, uint8_t * const buf){ - int frequency[512]; - uint8_t flag[512]; - int up[512]; - uint8_t len_tab[257]; - int bits_tab[257]; - int start, end; - uint8_t *ptr= buf; - int j; - - memset(frequency, 0, sizeof(frequency)); - memset(up, -1, sizeof(up)); - - start= *ptr++; - end= *ptr++; - for(;;){ - int i; - - for(i=start; i<=end; i++){ - frequency[i]= *ptr++; -// printf("%d %d %d\n", start, end, frequency[i]); - } - start= *ptr++; - if(start==0) break; - - end= *ptr++; - } - frequency[256]=1; - - while((ptr - buf)&3) ptr++; // 4byte align - -// for(j=0; j<16; j++) -// printf("%2X", ptr[j]); - - for(j=257; j<512; j++){ - int min_freq[2]= {256*256, 256*256}; - int smallest[2]= {0, 0}; - int i; - for(i=0; i 31) printf("vlc length overflow\n"); //can this happen at all ? - } - - bits_tab[j]= bits; - len_tab[j]= len; - } - - init_vlc(&f->pre_vlc, ACDC_VLC_BITS, 257, - len_tab , 1, 1, - bits_tab, 4, 4); - - return ptr; -} - -static int decode_i_frame(FourXContext *f, uint8_t *buf, int length){ - int x, y; - const int width= f->avctx->width; - const int height= f->avctx->height; - uint16_t *dst= (uint16_t*)f->current_picture.data[0]; - const int stride= f->current_picture.linesize[0]>>1; - const int bitstream_size= get32(buf); - const int token_count __attribute__((unused)) = get32(buf + bitstream_size + 8); - int prestream_size= 4*get32(buf + bitstream_size + 4); - uint8_t *prestream= buf + bitstream_size + 12; - - if(prestream_size + bitstream_size + 12 != length) - fprintf(stderr, "size missmatch %d %d %d\n", prestream_size, bitstream_size, length); - - prestream= read_huffman_tables(f, prestream); - - init_get_bits(&f->gb, buf + 4, 8*bitstream_size); - - prestream_size= length + buf - prestream; - - f->bitstream_buffer= av_fast_realloc(f->bitstream_buffer, &f->bitstream_buffer_size, prestream_size + FF_INPUT_BUFFER_PADDING_SIZE); - f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (uint32_t*)prestream, prestream_size/4); - init_get_bits(&f->pre_gb, f->bitstream_buffer, 8*prestream_size); - - f->last_dc= 0*128*8*8; - - for(y=0; ypre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3) != 256) - printf("end missmatch\n"); - - return 0; -} - -static int decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - FourXContext * const f = avctx->priv_data; - AVFrame *picture = data; - AVFrame *p, temp; - int i, frame_4cc, frame_size; - - *data_size = 0; - - /* special case for last picture */ - if (buf_size == 0) { - return 0; - } - - frame_4cc= get32(buf); - if(buf_size != get32(buf+4)+8){ - fprintf(stderr, "size missmatch %d %d\n", buf_size, get32(buf+4)); - } - - if(frame_4cc == ff_get_fourcc("cfrm")){ - int free_index=-1; - const int data_size= buf_size - 20; - const int id= get32(buf+12); - const int whole_size= get32(buf+16); - CFrameBuffer *cfrm; - - for(i=0; icfrm[i].id && f->cfrm[i].id < avctx->frame_number) - printf("lost c frame %d\n", f->cfrm[i].id); - } - - for(i=0; icfrm[i].id == id) break; - if(f->cfrm[i].size == 0 ) free_index= i; - } - - if(i>=CFRAME_BUFFER_COUNT){ - i= free_index; - f->cfrm[i].id= id; - } - cfrm= &f->cfrm[i]; - - cfrm->data= av_fast_realloc(cfrm->data, &cfrm->allocated_size, cfrm->size + data_size + FF_INPUT_BUFFER_PADDING_SIZE); - - memcpy(cfrm->data + cfrm->size, buf+20, data_size); - cfrm->size += data_size; - - if(cfrm->size >= whole_size){ - buf= cfrm->data; - frame_size= cfrm->size; - - if(id != avctx->frame_number){ - printf("cframe id missmatch %d %d\n", id, avctx->frame_number); - } - - cfrm->size= cfrm->id= 0; - frame_4cc= ff_get_fourcc("pfrm"); - }else - return buf_size; - }else{ - buf= buf + 12; - frame_size= buf_size - 12; - } - - temp= f->current_picture; - f->current_picture= f->last_picture; - f->last_picture= temp; - - p= &f->current_picture; - avctx->coded_frame= p; - - avctx->flags |= CODEC_FLAG_EMU_EDGE; // alternatively we would have to use our own buffer management - - if(p->data[0]) - avctx->release_buffer(avctx, p); - - p->reference= 1; - if(avctx->get_buffer(avctx, p) < 0){ - fprintf(stderr, "get_buffer() failed\n"); - return -1; - } - - if(frame_4cc == ff_get_fourcc("ifrm")){ - p->pict_type= I_TYPE; - if(decode_i_frame(f, buf, frame_size) < 0) - return -1; - }else if(frame_4cc == ff_get_fourcc("pfrm")){ - p->pict_type= P_TYPE; - if(decode_p_frame(f, buf, frame_size) < 0) - return -1; - }else if(frame_4cc == ff_get_fourcc("snd_")){ - printf("ignoring snd_ chunk length:%d\n", buf_size); - }else{ - printf("ignoring unknown chunk length:%d\n", buf_size); - } - -#if 0 -for(i=0; i<20; i++){ - printf("%2X %c ", buf[i], clip(buf[i],16,126)); -} -#endif - - p->key_frame= p->pict_type == I_TYPE; - - *picture= *p; - *data_size = sizeof(AVPicture); - - emms_c(); - - return buf_size; -} - - -static void common_init(AVCodecContext *avctx){ - FourXContext * const f = avctx->priv_data; - - dsputil_init(&f->dsp, avctx); - - f->avctx= avctx; -} - -static int decode_init(AVCodecContext *avctx){ - FourXContext * const f = avctx->priv_data; - - common_init(avctx); - init_vlcs(f); - - avctx->pix_fmt= PIX_FMT_RGB565; - - return 0; -} - - -static int decode_end(AVCodecContext *avctx){ - FourXContext * const f = avctx->priv_data; - int i; - - av_freep(&f->bitstream_buffer); - f->bitstream_buffer_size=0; - for(i=0; icfrm[i].data); - f->cfrm[i].allocated_size= 0; - } - free_vlc(&f->pre_vlc); - - avcodec_default_free_buffers(avctx); - - return 0; -} - -AVCodec fourxm_decoder = { - "4xm", - CODEC_TYPE_VIDEO, - CODEC_ID_4XM, - sizeof(FourXContext), - decode_init, - NULL, - decode_end, - decode_frame, - /*CODEC_CAP_DR1,*/ -}; - diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/Doxyfile b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/Doxyfile deleted file mode 100755 index 3e81cbb..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/Doxyfile +++ /dev/null @@ -1,1038 +0,0 @@ -# Doxyfile 1.3-rc1 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# General configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = libavcodec - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = doxy - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, -# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en -# (Japanese with english messages), Korean, Norwegian, Polish, Portuguese, -# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = YES - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these class will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited -# members of a class in the documentation of that class as if those members were -# ordinary class members. Constructors, destructors and assignment operators of -# the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. It is allowed to use relative paths in the argument list. - -STRIP_FROM_PATH = . - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower case letters. If set to YES upper case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# users are adviced to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explict @brief command for a brief description. - -JAVADOC_AUTOBRIEF = YES - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# reimplements. - -INHERIT_DOCS = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consist of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. -# For instance some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources -# only. Doxygen will then generate output that is more tailored for Java. -# For instance namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp -# *.h++ *.idl *.odl - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories -# that are symbolic links (a Unix filesystem feature) are excluded from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. - -EXCLUDE_PATTERNS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. - -INPUT_FILTER = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. - -SOURCE_BROWSER = YES - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output dir. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non empty doxygen will try to run -# the html help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the Html help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript and frames is required (for instance Mozilla, Netscape 4.0+, -# or Internet explorer 4.0+). Note that for large projects the tree generation -# can take a very long time. In such cases it is better to disable this feature. -# Windows users are probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = YES - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimised for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assigments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_XML = NO - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = YES - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_PREDEFINED tags. - -EXPAND_ONLY_PREDEF = YES - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. - -PREDEFINED = __attribute__(x)="" "RENAME(x)=x ## _TMPL" "DEF(x)=x ## _TMPL" \ - HAVE_BUILTIN_VECTOR HAVE_AV_CONFIG_H HAVE_MMX HAVE_MMX2 HAVE_3DNOW \ - ATTR_ALIGN(x)="" - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -#EXPAND_AS_DEFINED = FF_COMMON_FRAME -EXPAND_AS_DEFINED = declare_idct(idct, table, idct_row_head, idct_row, idct_row_tail, idct_row_mid) - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse the -# parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES tag can be used to specify one or more tagfiles. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in Html, RTF and LaTeX) for classes with base or -# super classes. Setting the tag to NO turns the diagrams off. Note that this -# option is superceded by the HAVE_DOT option below. This is only a fallback. It is -# recommended to install and use dot, since it yield more powerful graphs. - -CLASS_DIAGRAMS = YES - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found on the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_HEIGHT = 1024 - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermedate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO - -# The CGI_NAME tag should be the name of the CGI script that -# starts the search engine (doxysearch) with the correct parameters. -# A script with this name will be generated by doxygen. - -CGI_NAME = search.cgi - -# The CGI_URL tag should be the absolute URL to the directory where the -# cgi binaries are located. See the documentation of your http daemon for -# details. - -CGI_URL = - -# The DOC_URL tag should be the absolute URL to the directory where the -# documentation is located. If left blank the absolute path to the -# documentation, with file:// prepended to it, will be used. - -DOC_URL = - -# The DOC_ABSPATH tag should be the absolute path to the directory where the -# documentation is located. If left blank the directory on the local machine -# will be used. - -DOC_ABSPATH = - -# The BIN_ABSPATH tag must point to the directory where the doxysearch binary -# is installed. - -BIN_ABSPATH = /usr/local/bin/ - -# The EXT_DOC_PATHS tag can be used to specify one or more paths to -# documentation generated for other projects. This allows doxysearch to search -# the documentation for these projects as well. - -EXT_DOC_PATHS = diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/Makefile b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/Makefile deleted file mode 100755 index 8af210a..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/Makefile +++ /dev/null @@ -1,254 +0,0 @@ -# -# libavcodec Makefile -# (c) 2000-2003 Fabrice Bellard -# -include ../config.mak - -VPATH=$(SRC_PATH)/libavcodec - -# NOTE: -I.. is needed to include config.h -CFLAGS= $(OPTFLAGS) -Wall -DHAVE_AV_CONFIG_H -I.. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE - -OBJS= common.o utils.o mem.o allcodecs.o \ - mpegvideo.o jrevdct.o jfdctfst.o jfdctint.o\ - mpegaudio.o ac3enc.o mjpeg.o resample.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 dv.o error_resilience.o \ - fft.o mdct.o mace.o huffyuv.o cyuv.o opts.o raw.o h264.o golomb.o \ - vp3.o asv1.o 4xm.o cabac.o ffv1.o ra144.o ra288.o vcr1.o cljr.o \ - roqvideo.o dpcm.o interplayvideo.o xan.o - -ifeq ($(AMR_NB),yes) -ifeq ($(AMR_NB_FIXED),yes) -OBJS+= amr.o -AMREXTRALIBS+= amr/*.o -AMRLIBS=amrlibs -CLEANAMR=cleanamr -else -OBJS+= amr.o amr_float/sp_dec.o amr_float/sp_enc.o amr_float/interf_dec.o amr_float/interf_enc.o -CLEANAMR=cleanamrfloat -endif -endif - -ASM_OBJS= - -# codecs which are patented in some non free countries like the us -ifeq ($(CONFIG_RISKY),yes) -OBJS+= h263.o msmpeg4.o h263dec.o svq1.o rv10.o wmadec.o indeo3.o -endif - -ifeq ($(HAVE_XVMC_ACCEL),yes) -OBJS+= xvmcvideo.o -endif - -# 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 - -ifeq ($(CONFIG_FAAD),yes) -OBJS+= faad.o -ifeq ($(CONFIG_FAADBIN),yes) -# no libs needed -else -EXTRALIBS += -lfaad -endif -endif - -ifeq ($(CONFIG_PP),yes) -ifeq ($(SHARED_PP),yes) -EXTRALIBS += -lpostproc -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_VORBIS),yes) -OBJS += oggvorbis.o -EXTRALIBS += -lvorbis -lvorbisenc -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 -ifdef TARGET_BUILTIN_VECTOR -i386/fft_sse.o: CFLAGS+= -msse -endif -endif - -# armv4l specific stuff -ifeq ($(TARGET_ARCH_ARMV4L),yes) -ASM_OBJS += armv4l/jrevdct_arm.o armv4l/simple_idct_arm.o -OBJS += armv4l/dsputil_arm.o armv4l/mpegvideo_arm.o -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 - -# 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 -freduce-all-givs -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 -endif - -ifeq ($(TARGET_ARCH_SH4),yes) -OBJS+= sh4/idct_sh4.o sh4/dsputil_sh4.o sh4/dsputil_align.o -endif - - -SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) -OBJS := $(OBJS) $(ASM_OBJS) - -LIB= $(LIBPREF)avcodec$(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) -endif - -dsputil.o: dsputil.c dsputil.h - -libpostproc/libpostproc.a: - $(MAKE) -C libpostproc - -%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - -%.o: %.S - $(CC) $(CFLAGS) -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/*~ \ - liba52/*.o liba52/*~ \ - apiexample $(TESTS) - $(MAKE) -C libpostproc clean - -distclean: clean - rm -f Makefile.bak .depend - -cleanamr: - $(MAKE) -C amr clean - -cleanamrfloat: - rm -f amr_float/*.o - -# api example program -apiexample: apiexample.c $(LIB) - $(CC) $(CFLAGS) -o $@ $< $(LIB) $(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 - -motion-test: motion_test.o $(LIB) - $(CC) -o $@ $^ -lm - -fft-test: fft-test.o $(LIB) - $(CC) -o $@ $^ -lm - -ifeq ($(BUILD_SHARED),yes) -install: all install-headers -ifeq ($(CONFIG_WIN32),yes) - install -s -m 755 $(SLIB) "$(prefix)" -else - install -d $(prefix)/lib - install -s -m 755 $(SLIB) $(prefix)/lib/libavcodec-$(VERSION).so - ln -sf libavcodec-$(VERSION).so $(prefix)/lib/libavcodec.so - ldconfig || true -endif -else -install: -endif - -installlib: all install-headers - install -m 644 $(LIB) $(prefix)/lib - -install-headers: - mkdir -p "$(prefix)/include/ffmpeg" - install -m 644 $(SRC_PATH)/libavcodec/avcodec.h $(SRC_PATH)/libavcodec/common.h \ - "$(prefix)/include/ffmpeg" - -# -# include dependency files if they exist -# -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/Makefile.am b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/Makefile.am deleted file mode 100644 index 42548cd..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST= *.nsh diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/a52dec.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/a52dec.c deleted file mode 100644 index fb169c7..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/a52dec.c +++ /dev/null @@ -1,256 +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 -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) - fprintf(stderr, "A52 Decoder - function '%s' can't be resolved\n", symbol); - return f; -} -#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) - { - fprintf(stderr, "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 - }; - - *data_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 = 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) { - fprintf(stderr, "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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ac3.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ac3.h deleted file mode 100644 index 1e8a5ba..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ac3.h +++ /dev/null @@ -1,61 +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; - -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]; - -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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ac3dec.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ac3dec.c deleted file mode 100644 index 53bfa56..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ac3dec.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * AC3 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 ac3dec.c - * AC3 decoder. - */ - -//#define DEBUG - -#include "avcodec.h" -#include "libac3/ac3.h" - -/* currently, I use libac3 which is Copyright (C) Aaron Holtzman and - released under the GPL license. I may reimplement it someday... */ -typedef struct AC3DecodeState { - uint8_t inbuf[4096]; /* input buffer */ - uint8_t *inbuf_ptr; - int frame_size; - int flags; - int channels; - ac3_state_t state; -} AC3DecodeState; - -static int ac3_decode_init(AVCodecContext *avctx) -{ - AC3DecodeState *s = avctx->priv_data; - - ac3_init (); - s->inbuf_ptr = s->inbuf; - s->frame_size = 0; - return 0; -} - -stream_samples_t samples; - -/**** the following two functions comes from ac3dec */ -static inline int blah (int32_t i) -{ - if (i > 0x43c07fff) - return 32767; - else if (i < 0x43bf8000) - return -32768; - else - 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 ac3_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 - }; - - *data_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 = 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 = ac3_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 & AC3_LFE) - s->channels++; - if (avctx->channels == 0) - /* No specific number of channel requested */ - avctx->channels = s->channels; - else if (s->channels < avctx->channels) { - fprintf(stderr, "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 = AC3_MONO; - else if (avctx->channels == 2) - flags = AC3_STEREO; - else - flags |= AC3_ADJUST_LEVEL; - level = 1; - if (ac3_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 (ac3_block (&s->state)) - goto fail; - float_to_int (*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 ac3_decode_end(AVCodecContext *s) -{ - return 0; -} - -AVCodec ac3_decoder = { - "ac3", - CODEC_TYPE_AUDIO, - CODEC_ID_AC3, - sizeof(AC3DecodeState), - ac3_decode_init, - NULL, - ac3_decode_end, - ac3_decode_frame, -}; diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ac3enc.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ac3enc.c deleted file mode 100644 index 4093fb7..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ac3enc.c +++ /dev/null @@ -1,1579 +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 "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) end1=end; - for(i=j;i= 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> 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> 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> 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 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= 0 && exp_min <= 24); - for(j=1;j 15) - exp1[0] = 15; - - /* Iterate until the delta constraints between each groups are - satisfyed. I'm sure it is possible to find a better algorithm, - but I am lazy */ - do { - recurse = 0; - for(i=1;i<=nb_groups;i++) { - delta = exp1[i] - exp1[i-1]; - if (delta > 2) { - /* if delta too big, we encode a smaller exponent */ - exp1[i] = exp1[i-1] + 2; - } else if (delta < -2) { - /* if delta is too small, we must decrease the previous - exponent, which means we must recurse */ - recurse = 1; - exp1[i-1] = exp1[i] + 2; - } - } - } while (recurse); - - /* 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;jmant1_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;imant1_cnt = 0; - s->mant2_cnt = 0; - s->mant4_cnt = 0; - for(ch=0;chnb_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;chnb_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;inb_channels * 2 + 2; /* blksw * c, dithflag * c, dynrnge, cplstre */ - if (s->acmod == 2) - frame_bits++; /* rematstr */ - frame_bits += 2 * s->nb_channels; /* chexpstr[2] * c */ - if (s->lfe) - frame_bits++; /* lfeexpstr */ - for(ch=0;chnb_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); - - /* 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) { - fprintf(stderr, "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;chnb_all_channels;ch++) - s->fsnroffst[ch] = fsnroffst; -#if defined(DEBUG_BITALLOC) - { - int j; - - for(i=0;i<6;i++) { - for(ch=0;chnb_all_channels;ch++) { - printf("Block #%d Ch%d:\n", i, ch); - printf("bap="); - for(j=0;jnb_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;jsample_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;chnb_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;icoded_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, NULL, NULL); - - 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;chnb_channels;ch++) - put_bits(&s->pb, 1, 0); /* 512 point MDCT */ - for(ch=0;chnb_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; - printf("Block #%d (%d)\n", block_num, count++); - } -#endif - /* exponent strategy */ - for(ch=0;chnb_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;chnb_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;ipb, 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;chnb_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;inb_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;inb_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> 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 0) { - for(i=0;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; - short *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;chnb_all_channels;ch++) { - /* fixed mdct to the six sub blocks & exponent computation */ - for(i=0;ilast_samples[ch], N/2 * sizeof(int16_t)); - sinc = s->nb_all_channels; - sptr = samples + (sinc * (N/2) * i) + ch; - for(j=0;jlast_samples[ch][j] = v; - sptr += sinc; - } - - /* apply the MDCT window */ - for(j=0;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= 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;knb_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;icoded_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 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 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 -}; - -/* Those 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 -}; - -/* 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 */ -} ADPCMContext; - -/* XXX: implement encoding */ - -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: - fprintf(stderr, "ADPCM: codec admcp_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: - fprintf(stderr, "ADPCM: codec admcp_ms unsupported for encoding !\n"); - return -1; - 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 int adpcm_encode_frame(AVCodecContext *avctx, - unsigned char *frame, int buf_size, void *data) -{ - int n; - short *samples; - unsigned char *dst; - ADPCMContext *c = avctx->priv_data; - - dst = frame; - samples = (short *)data; -/* 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[0]; -/* 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; - default: - return -1; - } - return dst - frame; -} - -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) { - default: - break; - } - return 0; -} - -static inline short adpcm_ima_expand_nibble(ADPCMChannelStatus *c, char nibble) -{ - 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) >> 3; - 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_4xa_expand_nibble(ADPCMChannelStatus *c, char nibble) -{ - 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; - - diff = (delta*step + (step>>1))>>3; // difference to code above - - 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) / 256; - if (c->idelta < 16) c->idelta = 16; - - return (short)predictor; -} - -/* 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; - - 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) fprintf(stderr, "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++; - - *samples++ = cs->predictor; - samples += st; - - 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); - samples += avctx->channels; - *samples = adpcm_ima_expand_nibble(cs, (src[0] >> 4) & 0x0F); - 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 == 0) { /* wait for the other packet before outputing anything */ - *data_size = 0; - return src - buf; - } - } - break; - case CODEC_ID_ADPCM_IMA_WAV: - if (buf_size > BLKSIZE) { - if (avctx->block_align != 0) - buf_size = avctx->block_align; - else - buf_size = BLKSIZE; - } - // XXX: do as per-channel loop - cs = &(c->status[0]); - cs->predictor = (*src++) & 0x0FF; - cs->predictor |= ((*src++) << 8) & 0x0FF00; - 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++) fprintf(stderr, "unused byte should be null !!\n"); /* unused */ - - if (st) { - cs = &(c->status[1]); - cs->predictor = (*src++) & 0x0FF; - cs->predictor |= ((*src++) << 8) & 0x0FF00; - 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; - src++; /* if != 0 -> out-of-sync */ - } - - for(m=4; src < (buf + buf_size);) { - *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] & 0x0F); - if (st) - *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[4] & 0x0F); - *samples++ = adpcm_ima_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F); - if (st) { - *samples++ = adpcm_ima_expand_nibble(&c->status[1], (src[4] >> 4) & 0x0F); - 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; -//printf("%d %d %d %d\n", st, m, c->status[0].predictor, c->status[0].step_index); - //FIXME / XXX decode chanels individual & interleave samples - for(i=0; istatus[0], src[i] & 0x0F); - if (st) - *samples++ = adpcm_4xa_expand_nibble(&c->status[1], src[i+m] & 0x0F); - *samples++ = adpcm_4xa_expand_nibble(&c->status[0], src[i] >> 4); - if (st) - *samples++ = adpcm_4xa_expand_nibble(&c->status[1], src[i+m] >> 4); - } - - src += m< BLKSIZE) { - if (avctx->block_align != 0) - buf_size = avctx->block_align; - else - buf_size = BLKSIZE; - } - n = buf_size - 7 * avctx->channels; - if (n < 0) - return -1; - block_predictor[0] = (*src++); /* should be bound */ - block_predictor[0] = (block_predictor[0] < 0)?(0):((block_predictor[0] > 7)?(7):(block_predictor[0])); - block_predictor[1] = 0; - if (st) - block_predictor[1] = (*src++); - block_predictor[1] = (block_predictor[1] < 0)?(0):((block_predictor[1] > 7)?(7):(block_predictor[1])); - c->status[0].idelta = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); - if (c->status[0].idelta & 0x08000) - c->status[0].idelta -= 0x10000; - src+=2; - if (st) - c->status[1].idelta = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); - if (st && c->status[1].idelta & 0x08000) - c->status[1].idelta |= 0xFFFF0000; - if (st) - 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 (buf_size > BLKSIZE) { - if (avctx->block_align != 0) - buf_size = avctx->block_align; - else - buf_size = BLKSIZE; - } - c->status[0].predictor = (src[0] | (src[1] << 8)); - c->status[0].step_index = src[2]; - src += 4; - if(c->status[0].predictor & 0x8000) - c->status[0].predictor -= 0x10000; - *samples++ = c->status[0].predictor; - if (st) { - c->status[1].predictor = (src[0] | (src[1] << 8)); - c->status[1].step_index = src[2]; - src += 4; - if(c->status[1].predictor & 0x8000) - c->status[1].predictor -= 0x10000; - *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); - - /* 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); - else - *samples++ = adpcm_ima_expand_nibble(&c->status[0], - src[0] & 0x0F); - - src++; - } - break; - case CODEC_ID_ADPCM_IMA_DK3: - if (buf_size > BLKSIZE) { - if (avctx->block_align != 0) - buf_size = avctx->block_align; - else - buf_size = BLKSIZE; - } - c->status[0].predictor = (src[10] | (src[11] << 8)); - c->status[1].predictor = (src[12] | (src[13] << 8)); - c->status[0].step_index = src[14]; - c->status[1].step_index = src[15]; - /* sign extend the predictors */ - if(c->status[0].predictor & 0x8000) - c->status[0].predictor -= 0x10000; - if(c->status[1].predictor & 0x8000) - c->status[1].predictor -= 0x10000; - 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); - - /* process the diff channel predictor */ - DK3_GET_NEXT_NIBBLE(); - adpcm_ima_expand_nibble(&c->status[1], nibble); - - /* 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); - - /* 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; - default: - *data_size = 0; - return -1; - } - *data_size = (uint8_t *)samples - (uint8_t *)data; - return src - buf; -} - -#define ADPCM_CODEC(id, name) \ -AVCodec name ## _encoder = { \ - #name, \ - CODEC_TYPE_AUDIO, \ - id, \ - sizeof(ADPCMContext), \ - adpcm_encode_init, \ - adpcm_encode_frame, \ - adpcm_encode_close, \ - NULL, \ -}; \ -AVCodec name ## _decoder = { \ - #name, \ - CODEC_TYPE_AUDIO, \ - id, \ - sizeof(ADPCMContext), \ - adpcm_decode_init, \ - NULL, \ - NULL, \ - adpcm_decode_frame, \ -}; - -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_MS, adpcm_ms); -ADPCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm); - -#undef ADPCM_CODEC diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/allcodecs.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/allcodecs.c deleted file mode 100644 index 4e792ba..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/allcodecs.c +++ /dev/null @@ -1,166 +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; - - /* encoders */ -#ifdef CONFIG_ENCODERS - register_avcodec(&ac3_encoder); - register_avcodec(&mp2_encoder); -#ifdef CONFIG_MP3LAME - register_avcodec(&mp3lame_encoder); -#endif -#ifdef CONFIG_VORBIS - register_avcodec(&oggvorbis_encoder); - register_avcodec(&oggvorbis_decoder); -#endif - register_avcodec(&mpeg1video_encoder); -// register_avcodec(&h264_encoder); -#ifdef CONFIG_RISKY - register_avcodec(&mpeg2video_encoder); - register_avcodec(&h263_encoder); - register_avcodec(&h263p_encoder); - register_avcodec(&flv_encoder); - register_avcodec(&rv10_encoder); - register_avcodec(&mpeg4_encoder); - register_avcodec(&msmpeg4v1_encoder); - register_avcodec(&msmpeg4v2_encoder); - register_avcodec(&msmpeg4v3_encoder); - register_avcodec(&wmv1_encoder); - register_avcodec(&wmv2_encoder); -#endif - register_avcodec(&mjpeg_encoder); - register_avcodec(&ljpeg_encoder); - register_avcodec(&huffyuv_encoder); - register_avcodec(&asv1_encoder); - register_avcodec(&asv2_encoder); - register_avcodec(&ffv1_encoder); -#endif /* CONFIG_ENCODERS */ - register_avcodec(&rawvideo_encoder); - register_avcodec(&rawvideo_decoder); - - /* decoders */ -#ifdef CONFIG_DECODERS -#ifdef CONFIG_RISKY - register_avcodec(&h263_decoder); - register_avcodec(&mpeg4_decoder); - register_avcodec(&msmpeg4v1_decoder); - register_avcodec(&msmpeg4v2_decoder); - register_avcodec(&msmpeg4v3_decoder); - register_avcodec(&wmv1_decoder); - register_avcodec(&wmv2_decoder); - register_avcodec(&h263i_decoder); - register_avcodec(&flv_decoder); - register_avcodec(&rv10_decoder); - register_avcodec(&svq1_decoder); - register_avcodec(&svq3_decoder); - register_avcodec(&wmav1_decoder); - register_avcodec(&wmav2_decoder); - register_avcodec(&indeo3_decoder); -#ifdef CONFIG_FAAD - register_avcodec(&aac_decoder); - register_avcodec(&mpeg4aac_decoder); -#endif -#endif - register_avcodec(&mpeg1video_decoder); - register_avcodec(&mpeg2video_decoder); -#ifdef HAVE_XVMC - register_avcodec(&mpeg_xvmc_decoder); -#endif - register_avcodec(&dvvideo_decoder); - register_avcodec(&dvaudio_decoder); - register_avcodec(&mjpeg_decoder); - register_avcodec(&mjpegb_decoder); - register_avcodec(&mp2_decoder); - register_avcodec(&mp3_decoder); - register_avcodec(&mace3_decoder); - register_avcodec(&mace6_decoder); - register_avcodec(&huffyuv_decoder); - register_avcodec(&ffv1_decoder); - register_avcodec(&cyuv_decoder); - register_avcodec(&h264_decoder); - register_avcodec(&vp3_decoder); - register_avcodec(&asv1_decoder); - register_avcodec(&asv2_decoder); - register_avcodec(&vcr1_decoder); - register_avcodec(&cljr_decoder); - register_avcodec(&fourxm_decoder); - register_avcodec(&mdec_decoder); - register_avcodec(&roq_decoder); - register_avcodec(&interplay_video_decoder); - register_avcodec(&xan_wc3_decoder); -#ifdef CONFIG_AC3 - register_avcodec(&ac3_decoder); -#endif - register_avcodec(&ra_144_decoder); - register_avcodec(&ra_288_decoder); - register_avcodec(&roq_dpcm_decoder); - register_avcodec(&interplay_dpcm_decoder); - register_avcodec(&xan_dpcm_decoder); -#endif /* CONFIG_DECODERS */ - -#ifdef AMR_NB - register_avcodec(&amr_nb_decoder); - register_avcodec(&amr_nb_encoder); -#endif /* AMR_NB */ - /* pcm codecs */ - -#define PCM_CODEC(id, name) \ - register_avcodec(& name ## _encoder); \ - register_avcodec(& name ## _decoder); \ - -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_MS, adpcm_ms); -PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm); - -#undef PCM_CODEC -} - diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/amr.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/amr.c deleted file mode 100644 index 50fe003..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/amr.c +++ /dev/null @@ -1,460 +0,0 @@ -/* - * AMR Audio decoder stub - * 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 - */ - /* - This code implements amr-nb audio encoder/decoder through external reference - code from www.3gpp.org. The licence of the code from 3gpp is unclear so you - have to download the code separately. Two versions exists: One fixed-point - and one with floats. For some reason the float-encoder is significant faster - atleast on a P4 1.5GHz (0.9s instead of 9.9s on a 30s audio clip at MR102). - - The fixed-point (TS26.073) can be downloaded from: - http://www.3gpp.org/ftp/Specs/latest/Rel-5/26_series/26073-510.zip - Extract the soure into ffmpeg/libavcodec/amr - To use the float version run "./configure" with "--enable-amr-nb-fixed" - - The float version (default) can be downloaded from: - http://www.3gpp.org/ftp/Specs/latest/Rel-5/26_series/26104-510.zip - Extract the soure into ffmpeg/libavcodec/amr_float - - The specification for amr-nb can be found in TS 26.071 - (http://www.3gpp.org/ftp/Specs/html-info/26071.htm) and some other - info at http://www.3gpp.org/ftp/Specs/html-info/26-series.htm - - In the future support for AMR-WB might also be included here. - Reference code exist in TS26.173 and TS 26.204. - - */ -#define DEBUG -//#define AMR_NB_FIXED -#include "../config.h" -#include "avcodec.h" - -#ifdef AMR_NB_FIXED - -#define MMS_IO - -#include "amr/sp_dec.h" -#include "amr/d_homing.h" -#include "amr/typedef.h" -#include "amr/sp_enc.h" -#include "amr/sid_sync.h" -#include "amr/e_homing.h" - -#else -#include "amr_float/interf_dec.h" -#include "amr_float/interf_enc.h" -#endif - -/* Common code for fixed and float version*/ -typedef struct AMR_bitrates -{ - int startrate; - int stoprate; - enum Mode mode; - -} AMR_bitrates; - -/* Match desired bitrate with closest one*/ -static enum Mode getBitrateMode(int bitrate) -{ - /* Adjusted so that all bitrates can be used from commandline where - only a multiple of 1000 can be specified*/ - AMR_bitrates rates[]={ {0,4999,MR475}, //4 - {5000,5899,MR515},//5 - {5900,6699,MR59},//6 - {6700,7000,MR67},//7 - {7001,7949,MR74},//8 - {7950,9999,MR795},//9 - {10000,11999,MR102},//10 - {12000,64000,MR122},//12 - - }; - int i; - for(i=0;i=bitrate) - { - return(rates[i].mode); - } - } - /*Return highest possible*/ - return(MR122); -} - -#ifdef AMR_NB_FIXED -/* fixed point version*/ -/* frame size in serial bitstream file (frame type + serial stream + flags) */ -#define SERIAL_FRAMESIZE (1+MAX_SERIAL_SIZE+5) - -typedef struct AMRContext { - int frameCount; - Speech_Decode_FrameState *speech_decoder_state; - enum RXFrameType rx_type; - enum Mode mode; - Word16 reset_flag; - Word16 reset_flag_old; - - enum Mode enc_bitrate; - Speech_Encode_FrameState *enstate; - sid_syncState *sidstate; - enum TXFrameType tx_frametype; - - -} AMRContext; - -static int amr_nb_decode_init(AVCodecContext * avctx) -{ - AMRContext *s = avctx->priv_data; - s->frameCount=0; - s->speech_decoder_state=NULL; - s->rx_type = (enum RXFrameType)0; - s->mode= (enum Mode)0; - s->reset_flag=0; - s->reset_flag_old=1; - - if(Speech_Decode_Frame_init(&s->speech_decoder_state, "Decoder")) - { - printf("Speech_Decode_Frame_init error\n"); - return -1; - } - return 0; -} - -static int amr_nb_encode_init(AVCodecContext * avctx) -{ - AMRContext *s = avctx->priv_data; - s->frameCount=0; - s->speech_decoder_state=NULL; - s->rx_type = (enum RXFrameType)0; - s->mode= (enum Mode)0; - s->reset_flag=0; - s->reset_flag_old=1; - - if(avctx->sample_rate!=8000) - { -#ifdef DEBUG - printf("Only 8000Hz sample rate supported\n"); -#endif - return -1; - } - - if(avctx->channels!=1) - { -#ifdef DEBUG - printf("Only mono supported\n"); -#endif - return -1; - } - - avctx->frame_size=160; - avctx->coded_frame= avcodec_alloc_frame(); - - if(Speech_Encode_Frame_init(&s->enstate, 0, "encoder") || sid_sync_init (&s->sidstate)) - { -#ifdef DEBUG - printf("Speech_Encode_Frame_init error\n"); -#endif - return -1; - } - - s->enc_bitrate=getBitrateMode(avctx->bit_rate); - - return 0; -} - -static int amr_nb_encode_close(AVCodecContext * avctx) -{ - AMRContext *s = avctx->priv_data; - Speech_Encode_Frame_exit(&s->enstate); - sid_sync_exit (&s->sidstate); - av_freep(&avctx->coded_frame); - return 0; -} - -static int amr_nb_decode_close(AVCodecContext * avctx) -{ - AMRContext *s = avctx->priv_data; - Speech_Decode_Frame_exit(&s->speech_decoder_state); - return 0; -} - -static int amr_nb_decode_frame(AVCodecContext * avctx, - void *data, int *data_size, - uint8_t * buf, int buf_size) -{ - AMRContext *s = avctx->priv_data; - - uint8_t*amrData=buf; - int offset=0; - - UWord8 toc, q, ft; - - Word16 serial[SERIAL_FRAMESIZE]; /* coded bits */ - Word16 *synth; - UWord8 *packed_bits; - *data_size=0; - - static Word16 packed_size[16] = {12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0}; - int i; - - //printf("amr_decode_frame data_size=%i buf=0x%X buf_size=%d frameCount=%d!!\n",*data_size,buf,buf_size,s->frameCount); - - synth=data; - -// while(offset> 2) & 0x01; - ft = (toc >> 3) & 0x0F; - - //printf("offset=%d, packet_size=%d amrData= 0x%X %X %X %X\n",offset,packed_size[ft],amrData[offset],amrData[offset+1],amrData[offset+2],amrData[offset+3]); - - offset++; - - packed_bits=amrData+offset; - - offset+=packed_size[ft]; - - //Unsort and unpack bits - s->rx_type = UnpackBits(q, ft, packed_bits, &s->mode, &serial[1]); - - //We have a new frame - s->frameCount++; - - if (s->rx_type == RX_NO_DATA) - { - s->mode = s->speech_decoder_state->prev_mode; - } - else { - s->speech_decoder_state->prev_mode = s->mode; - } - - /* if homed: check if this frame is another homing frame */ - if (s->reset_flag_old == 1) - { - /* only check until end of first subframe */ - s->reset_flag = decoder_homing_frame_test_first(&serial[1], s->mode); - } - /* produce encoder homing frame if homed & input=decoder homing frame */ - if ((s->reset_flag != 0) && (s->reset_flag_old != 0)) - { - for (i = 0; i < L_FRAME; i++) - { - synth[i] = EHF_MASK; - } - } - else - { - /* decode frame */ - Speech_Decode_Frame(s->speech_decoder_state, s->mode, &serial[1], s->rx_type, synth); - } - - //Each AMR-frame results in 160 16-bit samples - *data_size+=160*2; - synth+=160; - - /* if not homed: check whether current frame is a homing frame */ - if (s->reset_flag_old == 0) - { - /* check whole frame */ - s->reset_flag = decoder_homing_frame_test(&serial[1], s->mode); - } - /* reset decoder if current frame is a homing frame */ - if (s->reset_flag != 0) - { - Speech_Decode_Frame_reset(s->speech_decoder_state); - } - s->reset_flag_old = s->reset_flag; - - } - return offset; -} - - -static int amr_nb_encode_frame(AVCodecContext *avctx, - unsigned char *frame/*out*/, int buf_size, void *data/*in*/) -{ - short serial_data[250] = {0}; - - AMRContext *s = avctx->priv_data; - int written; - - s->reset_flag = encoder_homing_frame_test(data); - - Speech_Encode_Frame(s->enstate, s->enc_bitrate, data, &serial_data[1], &s->mode); - - /* add frame type and mode */ - sid_sync (s->sidstate, s->mode, &s->tx_frametype); - - written = PackBits(s->mode, s->enc_bitrate, s->tx_frametype, &serial_data[1], frame); - - if (s->reset_flag != 0) - { - Speech_Encode_Frame_reset(s->enstate); - sid_sync_reset(s->sidstate); - } - return written; -} - - -#else /* Float point version*/ - -typedef struct AMRContext { - int frameCount; - void * decState; - int *enstate; - enum Mode enc_bitrate; -} AMRContext; - -static int amr_nb_decode_init(AVCodecContext * avctx) -{ - AMRContext *s = avctx->priv_data; - s->frameCount=0; - s->decState=Decoder_Interface_init(); - if(!s->decState) - { - printf("Decoder_Interface_init error\r\n"); - return -1; - } - return 0; -} - -static int amr_nb_encode_init(AVCodecContext * avctx) -{ - AMRContext *s = avctx->priv_data; - s->frameCount=0; - - if(avctx->sample_rate!=8000) - { -#ifdef DEBUG - printf("Only 8000Hz sample rate supported\n"); -#endif - return -1; - } - - if(avctx->channels!=1) - { -#ifdef DEBUG - printf("Only mono supported\n"); -#endif - return -1; - } - - avctx->frame_size=160; - avctx->coded_frame= avcodec_alloc_frame(); - - s->enstate=Encoder_Interface_init(0); - if(!s->enstate) - { - printf("Encoder_Interface_init error\n"); - return -1; - } - - s->enc_bitrate=getBitrateMode(avctx->bit_rate); - - return 0; -} - -static int amr_nb_decode_close(AVCodecContext * avctx) -{ - AMRContext *s = avctx->priv_data; - Decoder_Interface_exit(s->decState); - return 0; -} - -static int amr_nb_encode_close(AVCodecContext * avctx) -{ - AMRContext *s = avctx->priv_data; - Encoder_Interface_exit(s->enstate); - av_freep(&avctx->coded_frame); - return 0; -} - -static int amr_nb_decode_frame(AVCodecContext * avctx, - void *data, int *data_size, - uint8_t * buf, int buf_size) -{ - AMRContext *s = (AMRContext*)avctx->priv_data; - - uint8_t*amrData=buf; - int offset=0; - static short block_size[16]={ 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 }; - enum Mode dec_mode; - int packet_size; - *data_size=0; - - //printf("amr_decode_frame data_size=%i buf=0x%X buf_size=%d frameCount=%d!!\n",*data_size,buf,buf_size,s->frameCount); - - while(offset> 3) & 0x000F; - packet_size = block_size[dec_mode]; - - s->frameCount++; - //printf("offset=%d, packet_size=%d amrData= 0x%X %X %X %X\n",offset,packet_size,amrData[offset],amrData[offset+1],amrData[offset+2],amrData[offset+3]); - /* call decoder */ - Decoder_Interface_Decode(s->decState, &amrData[offset], data+*data_size, 0); - *data_size+=160*2; - - offset+=packet_size+1; - } - return buf_size; -} - -static int amr_nb_encode_frame(AVCodecContext *avctx, - unsigned char *frame/*out*/, int buf_size, void *data/*in*/) -{ - AMRContext *s = (AMRContext*)avctx->priv_data; - int written; - - written = Encoder_Interface_Encode(s->enstate, - s->enc_bitrate, - data, - frame, - 0); - - return written; -} - -#endif - -AVCodec amr_nb_decoder = -{ - "amr_nb", - CODEC_TYPE_AUDIO, - CODEC_ID_AMR_NB, - sizeof(AMRContext), - amr_nb_decode_init, - NULL, - amr_nb_decode_close, - amr_nb_decode_frame, -}; - -AVCodec amr_nb_encoder = -{ - "amr_nb", - CODEC_TYPE_AUDIO, - CODEC_ID_AMR_NB, - sizeof(AMRContext), - amr_nb_encode_init, - amr_nb_encode_frame, - amr_nb_encode_close, - NULL, -}; diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/apiexample.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/apiexample.c deleted file mode 100644 index dd4d6df..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/apiexample.c +++ /dev/null @@ -1,516 +0,0 @@ -/** - * @file apiexample.c - * avcodec API use example. - * - * Note that this library only handles codecs (mpeg, mpeg4, etc...), - * not file formats (avi, vob, etc...). See library 'libavformat' for the - * format handling - */ - -#include -#include -#include -#include - -#ifdef HAVE_AV_CONFIG_H -#undef HAVE_AV_CONFIG_H -#endif - -#include "avcodec.h" - -#define INBUF_SIZE 4096 - -/* - * Audio encoding example - */ -void audio_encode_example(const char *filename) -{ - AVCodec *codec; - AVCodecContext *c= NULL; - int frame_size, i, j, out_size, outbuf_size; - FILE *f; - short *samples; - float t, tincr; - uint8_t *outbuf; - - printf("Audio encoding\n"); - - /* find the MP2 encoder */ - codec = avcodec_find_encoder(CODEC_ID_MP2); - if (!codec) { - fprintf(stderr, "codec not found\n"); - exit(1); - } - - c= avcodec_alloc_context(); - - /* put sample parameters */ - c->bit_rate = 64000; - c->sample_rate = 44100; - c->channels = 2; - - /* open it */ - if (avcodec_open(c, codec) < 0) { - fprintf(stderr, "could not open codec\n"); - exit(1); - } - - /* the codec gives us the frame size, in samples */ - frame_size = c->frame_size; - samples = malloc(frame_size * 2 * c->channels); - outbuf_size = 10000; - outbuf = malloc(outbuf_size); - - f = fopen(filename, "w"); - if (!f) { - fprintf(stderr, "could not open %s\n", filename); - exit(1); - } - - /* encode a single tone sound */ - t = 0; - tincr = 2 * M_PI * 440.0 / c->sample_rate; - for(i=0;i<200;i++) { - for(j=0;j 0) { - len = avcodec_decode_audio(c, (short *)outbuf, &out_size, - inbuf_ptr, size); - if (len < 0) { - fprintf(stderr, "Error while decoding\n"); - exit(1); - } - if (out_size > 0) { - /* if a frame has been decoded, output it */ - fwrite(outbuf, 1, out_size, outfile); - } - size -= len; - inbuf_ptr += len; - } - } - - fclose(outfile); - fclose(f); - free(outbuf); - - avcodec_close(c); - free(c); -} - -/* - * Video encoding example - */ -void video_encode_example(const char *filename) -{ - AVCodec *codec; - AVCodecContext *c= NULL; - int i, out_size, size, x, y, outbuf_size; - FILE *f; - AVFrame *picture; - uint8_t *outbuf, *picture_buf; - - printf("Video encoding\n"); - - /* find the mpeg1 video encoder */ - codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO); - if (!codec) { - fprintf(stderr, "codec not found\n"); - exit(1); - } - - c= avcodec_alloc_context(); - picture= avcodec_alloc_frame(); - - /* put sample parameters */ - c->bit_rate = 400000; - /* resolution must be a multiple of two */ - c->width = 352; - c->height = 288; - /* frames per second */ - c->frame_rate = 25; - c->frame_rate_base= 1; - c->gop_size = 10; /* emit one intra frame every ten frames */ - c->max_b_frames=1; - - /* open it */ - if (avcodec_open(c, codec) < 0) { - fprintf(stderr, "could not open codec\n"); - exit(1); - } - - /* the codec gives us the frame size, in samples */ - - f = fopen(filename, "w"); - if (!f) { - fprintf(stderr, "could not open %s\n", filename); - exit(1); - } - - /* alloc image and output buffer */ - outbuf_size = 100000; - outbuf = malloc(outbuf_size); - size = c->width * c->height; - picture_buf = malloc((size * 3) / 2); /* size for YUV 420 */ - - picture->data[0] = picture_buf; - picture->data[1] = picture->data[0] + size; - picture->data[2] = picture->data[1] + size / 4; - picture->linesize[0] = c->width; - picture->linesize[1] = c->width / 2; - picture->linesize[2] = c->width / 2; - - /* encode 1 second of video */ - for(i=0;i<25;i++) { - fflush(stdout); - /* prepare a dummy image */ - /* Y */ - for(y=0;yheight;y++) { - for(x=0;xwidth;x++) { - picture->data[0][y * picture->linesize[0] + x] = x + y + i * 3; - } - } - - /* Cb and Cr */ - for(y=0;yheight/2;y++) { - for(x=0;xwidth/2;x++) { - picture->data[1][y * picture->linesize[1] + x] = 128 + y + i * 2; - picture->data[2][y * picture->linesize[2] + x] = 64 + x + i * 5; - } - } - - /* encode the image */ - out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture); - printf("encoding frame %3d (size=%5d)\n", i, out_size); - fwrite(outbuf, 1, out_size, f); - } - - /* get the delayed frames */ - for(; out_size; i++) { - fflush(stdout); - - out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL); - printf("write frame %3d (size=%5d)\n", i, out_size); - fwrite(outbuf, 1, out_size, f); - } - - /* add sequence end code to have a real mpeg file */ - outbuf[0] = 0x00; - outbuf[1] = 0x00; - outbuf[2] = 0x01; - outbuf[3] = 0xb7; - fwrite(outbuf, 1, 4, f); - fclose(f); - free(picture_buf); - free(outbuf); - - avcodec_close(c); - free(c); - free(picture); - printf("\n"); -} - -/* - * Video decoding example - */ - -void pgm_save(unsigned char *buf,int wrap, int xsize,int ysize,char *filename) -{ - FILE *f; - int i; - - f=fopen(filename,"w"); - fprintf(f,"P5\n%d %d\n%d\n",xsize,ysize,255); - for(i=0;icapabilities&CODEC_CAP_TRUNCATED) - c->flags|= CODEC_FLAG_TRUNCATED; /* we dont send complete frames */ - - /* for some codecs, such as msmpeg4 and mpeg4, width and height - MUST be initialized there because these info are not available - in the bitstream */ - - /* open it */ - if (avcodec_open(c, codec) < 0) { - fprintf(stderr, "could not open codec\n"); - exit(1); - } - - /* the codec gives us the frame size, in samples */ - - f = fopen(filename, "r"); - if (!f) { - fprintf(stderr, "could not open %s\n", filename); - exit(1); - } - - frame = 0; - for(;;) { - size = fread(inbuf, 1, INBUF_SIZE, f); - if (size == 0) - break; - - /* NOTE1: some codecs are stream based (mpegvideo, mpegaudio) - and this is the only method to use them because you cannot - know the compressed data size before analysing it. - - BUT some other codecs (msmpeg4, mpeg4) are inherently frame - based, so you must call them with all the data for one - frame exactly. You must also initialize 'width' and - 'height' before initializing them. */ - - /* NOTE2: some codecs allow the raw parameters (frame size, - sample rate) to be changed at any frame. We handle this, so - you should also take care of it */ - - /* here, we use a stream based decoder (mpeg1video), so we - feed decoder and see if it could decode a frame */ - inbuf_ptr = inbuf; - while (size > 0) { - len = avcodec_decode_video(c, picture, &got_picture, - inbuf_ptr, size); - if (len < 0) { - fprintf(stderr, "Error while decoding frame %d\n", frame); - exit(1); - } - if (got_picture) { - printf("saving frame %3d\n", frame); - fflush(stdout); - - /* the picture is allocated by the decoder. no need to - free it */ - snprintf(buf, sizeof(buf), outfilename, frame); - pgm_save(picture->data[0], picture->linesize[0], - c->width, c->height, buf); - frame++; - } - size -= len; - inbuf_ptr += len; - } - } - - /* some codecs, such as MPEG, transmit the I and P frame with a - latency of one frame. You must do the following to have a - chance to get the last frame of the video */ - len = avcodec_decode_video(c, picture, &got_picture, - NULL, 0); - if (got_picture) { - printf("saving last frame %3d\n", frame); - fflush(stdout); - - /* the picture is allocated by the decoder. no need to - free it */ - snprintf(buf, sizeof(buf), outfilename, frame); - pgm_save(picture->data[0], picture->linesize[0], - c->width, c->height, buf); - frame++; - } - - fclose(f); - - avcodec_close(c); - free(c); - free(picture); - printf("\n"); -} - -// simple example how the options could be used -int options_example(int argc, char* argv[]) -{ - AVCodec* codec = avcodec_find_encoder_by_name((argc > 1) ? argv[2] : "mpeg4"); - const AVOption* c; - AVCodecContext* avctx; - char* def = av_malloc(5000); - const char* col = ""; - int i = 0; - - if (!codec) - return -1; - c = codec->options; - avctx = avcodec_alloc_context(); - *def = 0; - - if (c) { - const AVOption *stack[FF_OPT_MAX_DEPTH]; - int depth = 0; - for (;;) { - if (!c->name) { - if (c->help) { - stack[depth++] = c; - c = (const AVOption*)c->help; - } else { - if (depth == 0) - break; // finished - c = stack[--depth]; - c++; - } - } else { - int t = c->type & FF_OPT_TYPE_MASK; - printf("Config %s %s\n", - t == FF_OPT_TYPE_BOOL ? "bool " : - t == FF_OPT_TYPE_DOUBLE ? "double " : - t == FF_OPT_TYPE_INT ? "integer" : - t == FF_OPT_TYPE_STRING ? "string " : - "unknown??", c->name); - switch (t) { - case FF_OPT_TYPE_BOOL: - i += sprintf(def + i, "%s%s=%s", - col, c->name, - c->defval != 0. ? "on" : "off"); - break; - case FF_OPT_TYPE_DOUBLE: - i += sprintf(def + i, "%s%s=%f", - col, c->name, c->defval); - break; - case FF_OPT_TYPE_INT: - i += sprintf(def + i, "%s%s=%d", - col, c->name, (int) c->defval); - break; - case FF_OPT_TYPE_STRING: - if (c->defstr) { - char* d = av_strdup(c->defstr); - char* f = strchr(d, ','); - if (f) - *f = 0; - i += sprintf(def + i, "%s%s=%s", - col, c->name, d); - av_free(d); - } - break; - } - col = ":"; - c++; - } - } - } - printf("Default Options: %s\n", def); - av_free(def); - return 0; -} - - -int main(int argc, char **argv) -{ - const char *filename; - - /* must be called before using avcodec lib */ - avcodec_init(); - - /* register all the codecs (you can also register only the codec - you wish to have smaller code */ - avcodec_register_all(); - -#ifdef OPT_TEST - options_example(argc, argv); -#else - if (argc <= 1) { - audio_encode_example("/tmp/test.mp2"); - audio_decode_example("/tmp/test.sw", "/tmp/test.mp2"); - - video_encode_example("/tmp/test.mpg"); - filename = "/tmp/test.mpg"; - } else { - filename = argv[1]; - } - - // audio_decode_example("/tmp/test.sw", filename); - video_decode_example("/tmp/test%d.pgm", filename); -#endif - - return 0; -} diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/asv1.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/asv1.c deleted file mode 100644 index 87db7f3..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/asv1.c +++ /dev/null @@ -1,667 +0,0 @@ -/* - * ASUS V1/V2 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 - */ - -/** - * @file asv1.c - * ASUS V1/V2 codec. - */ - -#include "avcodec.h" -#include "dsputil.h" -#include "mpegvideo.h" - -//#undef NDEBUG -//#include - -#define VLC_BITS 6 -#define ASV2_LEVEL_VLC_BITS 10 - -typedef struct ASV1Context{ - AVCodecContext *avctx; - DSPContext dsp; - AVFrame picture; - PutBitContext pb; - GetBitContext gb; - ScanTable scantable; - int inv_qscale; - int mb_width; - int mb_height; - int mb_width2; - int mb_height2; - 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; -} ASV1Context; - -static const uint8_t scantab[64]={ - 0x00,0x08,0x01,0x09,0x10,0x18,0x11,0x19, - 0x02,0x0A,0x03,0x0B,0x12,0x1A,0x13,0x1B, - 0x04,0x0C,0x05,0x0D,0x20,0x28,0x21,0x29, - 0x06,0x0E,0x07,0x0F,0x14,0x1C,0x15,0x1D, - 0x22,0x2A,0x23,0x2B,0x30,0x38,0x31,0x39, - 0x16,0x1E,0x17,0x1F,0x24,0x2C,0x25,0x2D, - 0x32,0x3A,0x33,0x3B,0x26,0x2E,0x27,0x2F, - 0x34,0x3C,0x35,0x3D,0x36,0x3E,0x37,0x3F, -}; - - -static const uint8_t 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 const uint8_t ccp_tab[17][2]={ - {0x2,2}, {0x7,5}, {0xB,5}, {0x3,5}, - {0xD,5}, {0x5,5}, {0x9,5}, {0x1,5}, - {0xE,5}, {0x6,5}, {0xA,5}, {0x2,5}, - {0xC,5}, {0x4,5}, {0x8,5}, {0x3,2}, - {0xF,5}, //EOB -}; - -static const uint8_t level_tab[7][2]={ - {3,4}, {3,3}, {3,2}, {0,3}, {2,2}, {2,3}, {2,4} -}; - -static const uint8_t dc_ccp_tab[8][2]={ - {0x1,2}, {0xD,4}, {0xF,4}, {0xC,4}, - {0x5,3}, {0xE,4}, {0x4,3}, {0x0,2}, -}; - -static const uint8_t ac_ccp_tab[16][2]={ - {0x00,2}, {0x3B,6}, {0x0A,4}, {0x3A,6}, - {0x02,3}, {0x39,6}, {0x3C,6}, {0x38,6}, - {0x03,3}, {0x3D,6}, {0x08,4}, {0x1F,5}, - {0x09,4}, {0x0B,4}, {0x0D,4}, {0x0C,4}, -}; - -static const uint8_t asv2_level_tab[63][2]={ - {0x3F,10},{0x2F,10},{0x37,10},{0x27,10},{0x3B,10},{0x2B,10},{0x33,10},{0x23,10}, - {0x3D,10},{0x2D,10},{0x35,10},{0x25,10},{0x39,10},{0x29,10},{0x31,10},{0x21,10}, - {0x1F, 8},{0x17, 8},{0x1B, 8},{0x13, 8},{0x1D, 8},{0x15, 8},{0x19, 8},{0x11, 8}, - {0x0F, 6},{0x0B, 6},{0x0D, 6},{0x09, 6}, - {0x07, 4},{0x05, 4}, - {0x03, 2}, - {0x00, 5}, - {0x02, 2}, - {0x04, 4},{0x06, 4}, - {0x08, 6},{0x0C, 6},{0x0A, 6},{0x0E, 6}, - {0x10, 8},{0x18, 8},{0x14, 8},{0x1C, 8},{0x12, 8},{0x1A, 8},{0x16, 8},{0x1E, 8}, - {0x20,10},{0x30,10},{0x28,10},{0x38,10},{0x24,10},{0x34,10},{0x2C,10},{0x3C,10}, - {0x22,10},{0x32,10},{0x2A,10},{0x3A,10},{0x26,10},{0x36,10},{0x2E,10},{0x3E,10}, -}; - - -static VLC ccp_vlc; -static VLC level_vlc; -static VLC dc_ccp_vlc; -static VLC ac_ccp_vlc; -static VLC asv2_level_vlc; - -static void init_vlcs(ASV1Context *a){ - static int done = 0; - - if (!done) { - done = 1; - - init_vlc(&ccp_vlc, VLC_BITS, 17, - &ccp_tab[0][1], 2, 1, - &ccp_tab[0][0], 2, 1); - init_vlc(&dc_ccp_vlc, VLC_BITS, 8, - &dc_ccp_tab[0][1], 2, 1, - &dc_ccp_tab[0][0], 2, 1); - init_vlc(&ac_ccp_vlc, VLC_BITS, 16, - &ac_ccp_tab[0][1], 2, 1, - &ac_ccp_tab[0][0], 2, 1); - init_vlc(&level_vlc, VLC_BITS, 7, - &level_tab[0][1], 2, 1, - &level_tab[0][0], 2, 1); - init_vlc(&asv2_level_vlc, ASV2_LEVEL_VLC_BITS, 63, - &asv2_level_tab[0][1], 2, 1, - &asv2_level_tab[0][0], 2, 1); - } -} - -//FIXME write a reversed bitstream reader to avoid the double reverse -static inline int asv2_get_bits(GetBitContext *gb, int n){ - return reverse[ get_bits(gb, n) << (8-n) ]; -} - -static inline void asv2_put_bits(PutBitContext *pb, int n, int v){ - put_bits(pb, n, reverse[ v << (8-n) ]); -} - -static inline int asv1_get_level(GetBitContext *gb){ - int code= get_vlc2(gb, level_vlc.table, VLC_BITS, 1); - - if(code==3) return get_sbits(gb, 8); - else return code - 3; -} - -static inline int asv2_get_level(GetBitContext *gb){ - int code= get_vlc2(gb, asv2_level_vlc.table, ASV2_LEVEL_VLC_BITS, 1); - - if(code==31) return (int8_t)asv2_get_bits(gb, 8); - else return code - 31; -} - -static inline void asv1_put_level(PutBitContext *pb, int level){ - unsigned int index= level + 3; - - if(index <= 6) put_bits(pb, level_tab[index][1], level_tab[index][0]); - else{ - put_bits(pb, level_tab[3][1], level_tab[3][0]); - put_bits(pb, 8, level&0xFF); - } -} - -static inline void asv2_put_level(PutBitContext *pb, int level){ - unsigned int index= level + 31; - - if(index <= 62) put_bits(pb, asv2_level_tab[index][1], asv2_level_tab[index][0]); - else{ - put_bits(pb, asv2_level_tab[31][1], asv2_level_tab[31][0]); - asv2_put_bits(pb, 8, level&0xFF); - } -} - -static inline int asv1_decode_block(ASV1Context *a, DCTELEM block[64]){ - int i; - - block[0]= 8*get_bits(&a->gb, 8); - - for(i=0; i<11; i++){ - const int ccp= get_vlc2(&a->gb, ccp_vlc.table, VLC_BITS, 1); - - if(ccp){ - if(ccp == 16) break; - if(ccp < 0 || i>=10){ - printf("coded coeff pattern damaged\n"); - return -1; - } - - if(ccp&8) block[a->scantable.permutated[4*i+0]]= (asv1_get_level(&a->gb) * a->intra_matrix[4*i+0])>>4; - if(ccp&4) block[a->scantable.permutated[4*i+1]]= (asv1_get_level(&a->gb) * a->intra_matrix[4*i+1])>>4; - if(ccp&2) block[a->scantable.permutated[4*i+2]]= (asv1_get_level(&a->gb) * a->intra_matrix[4*i+2])>>4; - if(ccp&1) block[a->scantable.permutated[4*i+3]]= (asv1_get_level(&a->gb) * a->intra_matrix[4*i+3])>>4; - } - } - - return 0; -} - -static inline int asv2_decode_block(ASV1Context *a, DCTELEM block[64]){ - int i, count, ccp; - - count= asv2_get_bits(&a->gb, 4); - - block[0]= 8*asv2_get_bits(&a->gb, 8); - - ccp= get_vlc2(&a->gb, dc_ccp_vlc.table, VLC_BITS, 1); - if(ccp){ - if(ccp&4) block[a->scantable.permutated[1]]= (asv2_get_level(&a->gb) * a->intra_matrix[1])>>4; - if(ccp&2) block[a->scantable.permutated[2]]= (asv2_get_level(&a->gb) * a->intra_matrix[2])>>4; - if(ccp&1) block[a->scantable.permutated[3]]= (asv2_get_level(&a->gb) * a->intra_matrix[3])>>4; - } - - for(i=1; igb, ac_ccp_vlc.table, VLC_BITS, 1); - - if(ccp){ - if(ccp&8) block[a->scantable.permutated[4*i+0]]= (asv2_get_level(&a->gb) * a->intra_matrix[4*i+0])>>4; - if(ccp&4) block[a->scantable.permutated[4*i+1]]= (asv2_get_level(&a->gb) * a->intra_matrix[4*i+1])>>4; - if(ccp&2) block[a->scantable.permutated[4*i+2]]= (asv2_get_level(&a->gb) * a->intra_matrix[4*i+2])>>4; - if(ccp&1) block[a->scantable.permutated[4*i+3]]= (asv2_get_level(&a->gb) * a->intra_matrix[4*i+3])>>4; - } - } - - return 0; -} - -static inline void asv1_encode_block(ASV1Context *a, DCTELEM block[64]){ - int i; - int nc_count=0; - - put_bits(&a->pb, 8, (block[0] + 32)>>6); - block[0]= 0; - - for(i=0; i<10; i++){ - const int index= scantab[4*i]; - int ccp=0; - - if( (block[index + 0] = (block[index + 0]*a->q_intra_matrix[index + 0] + (1<<15))>>16) ) ccp |= 8; - if( (block[index + 8] = (block[index + 8]*a->q_intra_matrix[index + 8] + (1<<15))>>16) ) ccp |= 4; - if( (block[index + 1] = (block[index + 1]*a->q_intra_matrix[index + 1] + (1<<15))>>16) ) ccp |= 2; - if( (block[index + 9] = (block[index + 9]*a->q_intra_matrix[index + 9] + (1<<15))>>16) ) ccp |= 1; - - if(ccp){ - for(;nc_count; nc_count--) - put_bits(&a->pb, ccp_tab[0][1], ccp_tab[0][0]); - - put_bits(&a->pb, ccp_tab[ccp][1], ccp_tab[ccp][0]); - - if(ccp&8) asv1_put_level(&a->pb, block[index + 0]); - if(ccp&4) asv1_put_level(&a->pb, block[index + 8]); - if(ccp&2) asv1_put_level(&a->pb, block[index + 1]); - if(ccp&1) asv1_put_level(&a->pb, block[index + 9]); - }else{ - nc_count++; - } - } - put_bits(&a->pb, ccp_tab[16][1], ccp_tab[16][0]); -} - -static inline void asv2_encode_block(ASV1Context *a, DCTELEM block[64]){ - int i; - int count=0; - - for(count=63; count>3; count--){ - const int index= scantab[count]; - - if( (block[index]*a->q_intra_matrix[index] + (1<<15))>>16 ) - break; - } - - count >>= 2; - - asv2_put_bits(&a->pb, 4, count); - asv2_put_bits(&a->pb, 8, (block[0] + 32)>>6); - block[0]= 0; - - for(i=0; i<=count; i++){ - const int index= scantab[4*i]; - int ccp=0; - - if( (block[index + 0] = (block[index + 0]*a->q_intra_matrix[index + 0] + (1<<15))>>16) ) ccp |= 8; - if( (block[index + 8] = (block[index + 8]*a->q_intra_matrix[index + 8] + (1<<15))>>16) ) ccp |= 4; - if( (block[index + 1] = (block[index + 1]*a->q_intra_matrix[index + 1] + (1<<15))>>16) ) ccp |= 2; - if( (block[index + 9] = (block[index + 9]*a->q_intra_matrix[index + 9] + (1<<15))>>16) ) ccp |= 1; - - if(i) put_bits(&a->pb, ac_ccp_tab[ccp][1], ac_ccp_tab[ccp][0]); - else put_bits(&a->pb, dc_ccp_tab[ccp][1], dc_ccp_tab[ccp][0]); - - if(ccp){ - if(ccp&8) asv2_put_level(&a->pb, block[index + 0]); - if(ccp&4) asv2_put_level(&a->pb, block[index + 8]); - if(ccp&2) asv2_put_level(&a->pb, block[index + 1]); - if(ccp&1) asv2_put_level(&a->pb, block[index + 9]); - } - } -} - -static inline int decode_mb(ASV1Context *a, DCTELEM block[6][64]){ - int i; - - a->dsp.clear_blocks(block[0]); - - if(a->avctx->codec_id == CODEC_ID_ASV1){ - for(i=0; i<6; i++){ - if( asv1_decode_block(a, block[i]) < 0) - return -1; - } - }else{ - for(i=0; i<6; i++){ - if( asv2_decode_block(a, block[i]) < 0) - return -1; - } - } - return 0; -} - -static inline void encode_mb(ASV1Context *a, DCTELEM block[6][64]){ - int i; - - if(a->avctx->codec_id == CODEC_ID_ASV1){ - for(i=0; i<6; i++) - asv1_encode_block(a, block[i]); - }else{ - for(i=0; i<6; i++) - asv2_encode_block(a, block[i]); - } -} - -static inline void idct_put(ASV1Context *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 inline void dct_get(ASV1Context *a, int mb_x, int mb_y){ - DCTELEM (*block)[64]= a->block; - int linesize= a->picture.linesize[0]; - int i; - - uint8_t *ptr_y = a->picture.data[0] + (mb_y * 16* linesize ) + mb_x * 16; - uint8_t *ptr_cb = a->picture.data[1] + (mb_y * 8 * a->picture.linesize[1]) + mb_x * 8; - uint8_t *ptr_cr = a->picture.data[2] + (mb_y * 8 * a->picture.linesize[2]) + mb_x * 8; - - a->dsp.get_pixels(block[0], ptr_y , linesize); - a->dsp.get_pixels(block[1], ptr_y + 8, linesize); - a->dsp.get_pixels(block[2], ptr_y + 8*linesize , linesize); - a->dsp.get_pixels(block[3], ptr_y + 8*linesize + 8, linesize); - for(i=0; i<4; i++) - a->dsp.fdct(block[i]); - - if(!(a->avctx->flags&CODEC_FLAG_GRAY)){ - a->dsp.get_pixels(block[4], ptr_cb, a->picture.linesize[1]); - a->dsp.get_pixels(block[5], ptr_cr, a->picture.linesize[2]); - for(i=4; i<6; i++) - a->dsp.fdct(block[i]); - } -} - -static int decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - ASV1Context * const a = avctx->priv_data; - AVFrame *picture = data; - AVFrame * const p= (AVFrame*)&a->picture; - int mb_x, mb_y; - - *data_size = 0; - - /* special case for last picture */ - if (buf_size == 0) { - return 0; - } - - if(p->data[0]) - avctx->release_buffer(avctx, p); - - p->reference= 0; - if(avctx->get_buffer(avctx, p) < 0){ - fprintf(stderr, "get_buffer() failed\n"); - return -1; - } - p->pict_type= I_TYPE; - p->key_frame= 1; - - a->bitstream_buffer= av_fast_realloc(a->bitstream_buffer, &a->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); - - if(avctx->codec_id == CODEC_ID_ASV1) - a->dsp.bswap_buf((uint32_t*)a->bitstream_buffer, (uint32_t*)buf, buf_size/4); - else{ - int i; - for(i=0; ibitstream_buffer[i]= reverse[ buf[i] ]; - } - - init_get_bits(&a->gb, a->bitstream_buffer, buf_size*8); - - for(mb_y=0; mb_ymb_height2; mb_y++){ - for(mb_x=0; mb_xmb_width2; mb_x++){ - if( decode_mb(a, a->block) <0) - return -1; - - idct_put(a, mb_x, mb_y); - } - } - - if(a->mb_width2 != a->mb_width){ - mb_x= a->mb_width2; - for(mb_y=0; mb_ymb_height2; mb_y++){ - if( decode_mb(a, a->block) <0) - return -1; - - idct_put(a, mb_x, mb_y); - } - } - - if(a->mb_height2 != a->mb_height){ - mb_y= a->mb_height2; - for(mb_x=0; mb_xmb_width; mb_x++){ - if( decode_mb(a, a->block) <0) - return -1; - - idct_put(a, mb_x, mb_y); - } - } -#if 0 -int i; -printf("%d %d\n", 8*buf_size, get_bits_count(&a->gb)); -for(i=get_bits_count(&a->gb); i<8*buf_size; i++){ - printf("%d", get_bits1(&a->gb)); -} - -for(i=0; iavctx->extradata_size; i++){ - printf("%c\n", ((uint8_t*)s->avctx->extradata)[i]); -} -#endif - - *picture= *(AVFrame*)&a->picture; - *data_size = sizeof(AVPicture); - - emms_c(); - - return (get_bits_count(&a->gb)+31)/32*4; -} - -static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ - ASV1Context * const a = avctx->priv_data; - AVFrame *pict = data; - AVFrame * const p= (AVFrame*)&a->picture; - int size; - int mb_x, mb_y; - - init_put_bits(&a->pb, buf, buf_size, NULL, NULL); - - *p = *pict; - p->pict_type= I_TYPE; - p->key_frame= 1; - - for(mb_y=0; mb_ymb_height2; mb_y++){ - for(mb_x=0; mb_xmb_width2; mb_x++){ - dct_get(a, mb_x, mb_y); - encode_mb(a, a->block); - } - } - - if(a->mb_width2 != a->mb_width){ - mb_x= a->mb_width2; - for(mb_y=0; mb_ymb_height2; mb_y++){ - dct_get(a, mb_x, mb_y); - encode_mb(a, a->block); - } - } - - if(a->mb_height2 != a->mb_height){ - mb_y= a->mb_height2; - for(mb_x=0; mb_xmb_width; mb_x++){ - dct_get(a, mb_x, mb_y); - encode_mb(a, a->block); - } - } - emms_c(); - - align_put_bits(&a->pb); - while(get_bit_count(&a->pb)&31) - put_bits(&a->pb, 8, 0); - - size= get_bit_count(&a->pb)/32; - - if(avctx->codec_id == CODEC_ID_ASV1) - a->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, size); - else{ - int i; - for(i=0; i<4*size; i++) - buf[i]= reverse[ buf[i] ]; - } - - return size*4; -} - -static void common_init(AVCodecContext *avctx){ - ASV1Context * const a = avctx->priv_data; - - dsputil_init(&a->dsp, avctx); - - a->mb_width = (avctx->width + 15) / 16; - a->mb_height = (avctx->height + 15) / 16; - a->mb_width2 = (avctx->width + 0) / 16; - a->mb_height2 = (avctx->height + 0) / 16; - - avctx->coded_frame= (AVFrame*)&a->picture; - a->avctx= avctx; -} - -static int decode_init(AVCodecContext *avctx){ - ASV1Context * const a = avctx->priv_data; - AVFrame *p= (AVFrame*)&a->picture; - int i; - const int scale= avctx->codec_id == CODEC_ID_ASV1 ? 1 : 2; - - common_init(avctx); - init_vlcs(a); - ff_init_scantable(a->dsp.idct_permutation, &a->scantable, scantab); - - a->inv_qscale= ((uint8_t*)avctx->extradata)[0]; - if(a->inv_qscale == 0){ - printf("illegal qscale 0\n"); - if(avctx->codec_id == CODEC_ID_ASV1) - a->inv_qscale= 6; - else - a->inv_qscale= 10; - } - - for(i=0; i<64; i++){ - int index= scantab[i]; - - a->intra_matrix[i]= 64*scale*ff_mpeg1_default_intra_matrix[index] / a->inv_qscale; - } - - p->qstride= a->mb_width; - p->qscale_table= av_mallocz( p->qstride * a->mb_height); - p->quality= (32*scale + a->inv_qscale/2)/a->inv_qscale; - memset(p->qscale_table, p->quality, p->qstride*a->mb_height); - - return 0; -} - -static int encode_init(AVCodecContext *avctx){ - ASV1Context * const a = avctx->priv_data; - int i; - const int scale= avctx->codec_id == CODEC_ID_ASV1 ? 1 : 2; - - common_init(avctx); - - if(avctx->global_quality == 0) avctx->global_quality= 4*FF_QUALITY_SCALE; - - a->inv_qscale= (32*scale*FF_QUALITY_SCALE + avctx->global_quality/2) / avctx->global_quality; - - avctx->extradata= av_mallocz(8); - avctx->extradata_size=8; - ((uint32_t*)avctx->extradata)[0]= le2me_32(a->inv_qscale); - ((uint32_t*)avctx->extradata)[1]= le2me_32(ff_get_fourcc("ASUS")); - - for(i=0; i<64; i++){ - int q= 32*scale*ff_mpeg1_default_intra_matrix[i]; - a->q_intra_matrix[i]= ((a->inv_qscale<<16) + q/2) / q; - } - - return 0; -} - -static int decode_end(AVCodecContext *avctx){ - ASV1Context * const a = avctx->priv_data; - - av_freep(&a->bitstream_buffer); - av_freep(&a->picture.qscale_table); - a->bitstream_buffer_size=0; - - avcodec_default_free_buffers(avctx); - - return 0; -} - -AVCodec asv1_decoder = { - "asv1", - CODEC_TYPE_VIDEO, - CODEC_ID_ASV1, - sizeof(ASV1Context), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, -}; - -AVCodec asv2_decoder = { - "asv2", - CODEC_TYPE_VIDEO, - CODEC_ID_ASV2, - sizeof(ASV1Context), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, -}; - -#ifdef CONFIG_ENCODERS - -AVCodec asv1_encoder = { - "asv1", - CODEC_TYPE_VIDEO, - CODEC_ID_ASV1, - sizeof(ASV1Context), - encode_init, - encode_frame, - //encode_end, -}; - -AVCodec asv2_encoder = { - "asv2", - CODEC_TYPE_VIDEO, - CODEC_ID_ASV2, - sizeof(ASV1Context), - encode_init, - encode_frame, - //encode_end, -}; - -#endif //CONFIG_ENCODERS diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/avcodec.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/avcodec.c deleted file mode 100644 index 4f68756..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/avcodec.c +++ /dev/null @@ -1,172 +0,0 @@ -/** - * @file avcodec.c - * avcodec. - */ - -#include "errno.h" -#include "avcodec.h" - -#ifndef MKTAG -#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) -#endif - -// private structure used to hide all internal memory allocations -// and structures used for de/encoding - end user should -// never see any complicated structure -typedef struct private_handle -{ - AVCodec* avcodec; - AVCodecContext avcontext; - struct private_handle* next; - struct private_handle* prev; -} private_handle_t; - -static private_handle_t* handle_first = 0; - -static AVCodec* avcodec_find_by_fcc(uint32_t fcc) -{ - // translation table - static const struct fcc_to_avcodecid { - enum CodecID codec; - uint32_t list[4]; // maybe we could map more fcc to same codec - } lc[] = { - { CODEC_ID_H263, { MKTAG('U', '2', '6', '3'), 0 } }, - { CODEC_ID_H263I, { MKTAG('I', '2', '6', '3'), 0 } }, - { CODEC_ID_MSMPEG4V3, { MKTAG('D', 'I', 'V', '3'), 0 } }, - { CODEC_ID_MPEG4, { MKTAG('D', 'I', 'V', 'X'), MKTAG('D', 'X', '5', '0'), 0 } }, - { CODEC_ID_MSMPEG4V2, { MKTAG('M', 'P', '4', '2'), 0 } }, - { CODEC_ID_MJPEG, { MKTAG('M', 'J', 'P', 'G'), 0 } }, - { CODEC_ID_MPEG1VIDEO, { MKTAG('P', 'I', 'M', '1'), 0 } }, - { CODEC_ID_AC3, { 0x2000, 0 } }, - { CODEC_ID_MP2, { 0x50, 0x55, 0 } }, - { CODEC_ID_FLV1, { MKTAG('F', 'L', 'V', '1'), 0 } }, - - { CODEC_ID_NONE, {0}} - }; - const struct fcc_to_avcodecid* c; - - for (c = lc; c->codec != CODEC_ID_NONE; c++) - { - int i = 0; - while (c->list[i] != 0) - if (c->list[i++] == fcc) - return avcodec_find_decoder(c->codec); - } - - return NULL; -} - -static private_handle_t* create_handle(void) -{ - private_handle_t* t = av_malloc(sizeof(private_handle_t)); - if (!t) - return NULL; - memset(t, 0, sizeof(*t)); - - // register and fill - if (!handle_first) - { - avcodec_init(); - avcodec_register_all(); - handle_first = t; - } - else - { - t->prev = handle_first->next; - handle_first->next = t; - t->next = handle_first; - } - - return t; -} - -static void destroy_handle(private_handle_t* handle) -{ - if (handle) - { - if (handle->avcodec) - { - avcodec_close(&handle->avcontext); - } - av_free(handle); - - // count referencies - } -} - -int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout) -{ - AVCodecContext* ctx = handle; - switch (cmd) - { - case AVC_OPEN_BY_NAME: - { - // pin char* codec name - private_handle_t* h = create_handle(); - (private_handle_t**)pout = h; - if (!h) - return -ENOMEM; - if (!h->avcodec) - { - destroy_handle(h); - (private_handle_t**)pout = NULL; - return -1;// better error - } - return 0; - } - case AVC_OPEN_BY_CODEC_ID: - { - // pin uint32_t codec fourcc - private_handle_t* h = create_handle(); - (private_handle_t**)pout = h; - if (!h) - return -ENOMEM; - - if (!h->avcodec) - { - destroy_handle(h); - (private_handle_t**)pout = NULL; - return -1;// better error - } - return 0; - } - case AVC_OPEN_BY_FOURCC: - { - // pin uint32_t codec fourcc - private_handle_t* h = create_handle(); - (private_handle_t**)pout = h; - if (!h) - return -ENOMEM; - h->avcodec = avcodec_find_by_fcc((uint32_t) pin); - if (!h->avcodec) - { - destroy_handle(h); - (private_handle_t**)pout = NULL; - return -1;// better error - } - return 0; - } - case AVC_CLOSE: - // uninit part - // eventually close all allocated space if this was last - // instance - destroy_handle(handle); - break; - - case AVC_FLUSH: - break; - - case AVC_DECODE: - break; - - case AVC_ENCODE: - break; - - case AVC_GET_VERSION: - (int*) pout = 500; - default: - return -1; - - } - return 0; -} diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/avcodec.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/avcodec.h deleted file mode 100644 index 45874ac..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/avcodec.h +++ /dev/null @@ -1,1688 +0,0 @@ -#ifndef AVCODEC_H -#define AVCODEC_H - -/** - * @file avcodec.h - * external api header. - */ - - -#ifdef __cplusplus -extern "C" { -#endif - -#include "common.h" - -#define FFMPEG_VERSION_INT 0x000408 -#define FFMPEG_VERSION "0.4.8" -#define LIBAVCODEC_BUILD 4680 - -#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT -#define LIBAVCODEC_VERSION FFMPEG_VERSION - -#define AV_STRINGIFY(s) AV_TOSTRING(s) -#define AV_TOSTRING(s) #s -#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" AV_STRINGIFY(LIBAVCODEC_BUILD) - -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_H263, - CODEC_ID_RV10, - CODEC_ID_MP2, - CODEC_ID_MP3, /* prefered ID for MPEG Audio layer 1, 2 or3 decoding */ - CODEC_ID_VORBIS, - CODEC_ID_AC3, - CODEC_ID_MJPEG, - CODEC_ID_MJPEGB, - CODEC_ID_LJPEG, - 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_DVAUDIO, - CODEC_ID_WMAV1, - CODEC_ID_WMAV2, - CODEC_ID_MACE3, - CODEC_ID_MACE6, - CODEC_ID_HUFFYUV, - CODEC_ID_CYUV, - CODEC_ID_H264, - CODEC_ID_INDEO3, - CODEC_ID_VP3, - CODEC_ID_AAC, - CODEC_ID_MPEG4AAC, - 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, - - /* various pcm "codecs" */ - CODEC_ID_PCM_S16LE, - 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, - - /* various adpcm codecs */ - CODEC_ID_ADPCM_IMA_QT, - CODEC_ID_ADPCM_IMA_WAV, - CODEC_ID_ADPCM_IMA_DK3, - CODEC_ID_ADPCM_IMA_DK4, - CODEC_ID_ADPCM_MS, - CODEC_ID_ADPCM_4XM, - - /* AMR */ - CODEC_ID_AMR_NB, - /* RealAudio codecs*/ - CODEC_ID_RA_144, - CODEC_ID_RA_288, - - /* various DPCM codecs */ - CODEC_ID_ROQ_DPCM, - CODEC_ID_INTERPLAY_DPCM, - CODEC_ID_XAN_DPCM -}; - -/* CODEC_ID_MP3LAME is absolete */ -#define CODEC_ID_MP3LAME CODEC_ID_MP3 - -enum CodecType { - CODEC_TYPE_UNKNOWN = -1, - CODEC_TYPE_VIDEO, - CODEC_TYPE_AUDIO -}; - -/** - * 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). - */ -enum PixelFormat { - PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples) - PIX_FMT_YUV422, - 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_NB -}; - -/* currently unused, may be used if 24/32 bits samples ever supported */ -enum SampleFormat { - SAMPLE_FMT_S16 = 0 ///< signed 16 bits -}; - -/* 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
- * 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 - -/* motion estimation type, EPZS by default */ -enum Motion_Est_ID { - ME_ZERO = 1, - ME_FULL, - ME_LOG, - ME_PHODS, - ME_EPZS, - ME_X1 -}; - -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; - -/* ME algos sorted by quality */ -static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, - ME_X1, ME_EPZS, ME_FULL }; - - -#define FF_MAX_B_FRAMES 8 - -/* encoding support - these flags can be passed in AVCodecContext.flags before initing - Note: note not everything is supported yet -*/ - -#define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale -#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed -#define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC -#define CODEC_FLAG_GMC 0x0020 ///< use GMC -#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///< dont 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 ///< Advanced intra coding -#define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector -/* For advanced prediction mode, we reuse the 4MV flag */ -/* Unsupported options : - * Syntax Arithmetic coding (SAC) - * Deblocking filter internal loop - * Slice structured - * Reference Picture Selection - * Independant Segment Decoding - * Alternative Inter * VLC - * Modified Quantization */ -/* /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 - -#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 isnt 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 micro seconds (time when frame should be shown to user)\ - * if 0 then the frame_rate will be used as reference\ - * - 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 31 (bad)) \ - * - encoding: set by lavc for coded_picture (and set by user for input)\ - * - decoding: set by lavc\ - */\ - float quality; \ -\ - /**\ - * buffer age (1->was last buffer and dint change, 2->..., ...).\ - * set to something large 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;\ -\ - /**\ - * 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;\ - -#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 somewher else, dont dealloc image (data/base) -#define FF_BUFFER_TYPE_COPY 8 ///< just a (modified) copy of some other buffer, dont 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 - -/** - * Audio Video Frame. - */ -typedef struct AVFrame { - FF_COMMON_FRAME -} AVFrame; - -#define DEFAULT_FRAME_RATE_BASE 1001000 - -/** - * main external api structure. - */ -typedef struct AVCodecContext { - /** - * 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) - * - encoding: set/allocated/freed by lavc. - * - decoding: set/allocated/freed by user. - */ - void *extradata; - int extradata_size; - - /* video only */ - /** - * frames per sec multiplied by frame_rate_base. - * for variable fps this is the precission, so if the timestamps - * can be specified in msec precssion then this is 1000*frame_rate_base - * - encoding: MUST be set by user - * - decoding: set by lavc. 0 or the frame_rate if available - */ - int frame_rate; - - /** - * width / height. - * - encoding: MUST be set by user. - * - decoding: set by user, some codecs might override / change it during playback - */ - int width, height; - -#define FF_ASPECT_SQUARE 1 -#define FF_ASPECT_4_3_625 2 -#define FF_ASPECT_4_3_525 3 -#define FF_ASPECT_16_9_625 4 -#define FF_ASPECT_16_9_525 5 -#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: FIXME: used by ffmpeg to decide whether an pix_fmt - * conversion is in order. This only works for - * codecs with one supported pix_fmt, we should - * do something for a generic case as well. - * - 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, - AVFrame *src, int offset[4], - int y, int type, int height); - - /* audio only */ - int sample_rate; ///< samples per sec - int channels; - int sample_fmt; ///< sample format, currenly unused - - /* the following data should not be initialized */ - int frame_size; ///< in samples, initialized when calling 'init' - 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. - * - 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; - - /* The following data is for RTP friendly coding */ - /* By now only H.263/H.263+/MPEG4 coder honours this */ - int rtp_mode; /* 1 for activate RTP friendly-mode */ - /* highers numbers represent more error-prone */ - /* enviroments, by now just "1" exist */ - - 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 callcack: This function is called */ - /* every time the encoder as a packet to send */ - /* Depends on the encoder if the data starts */ - /* with a Start Code (it should) H.263 does */ - void (*rtp_callback)(void *data, int size, int packet_number); - - /* 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: unused - * - 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_AC_VLC 32 -#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_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; - - /** - * 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_CAREFULL 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 - * width and height should 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); - - /** - * is 1 if the decoded stream contains b frames, 0 otherwise. - * - encoding: unused - * - decoding: set by lavc - */ - int has_b_frames; - - int block_align; ///< used by some WAV based audio codecs - - 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. - * - encoding: set by user. - * - decoding: unused - */ - float i_quant_factor; - - /** - * qscale offset 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_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 - - /** - * 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 - - /** - * 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 */ -#endif /* HAVE_MMX */ - - /** - * 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 - - /** - * aspect ratio (0 if unknown). - * - encoding: set by user. - * - decoding: set by lavc. - */ - float 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_VIS_MV 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 - - /** - * error. - * - encoding: set by lavc if flags&CODEC_FLAG_PSNR - * - decoding: unused - */ - uint64_t error[4]; - - /** - * minimum MB quantizer. - * - encoding: set by user. - * - decoding: unused - */ - int mb_qmin; - - /** - * maximum MB quantizer. - * - encoding: set by user. - * - 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; -#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_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, 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; - - /** - * frame_rate_base. - * for variable fps this is 1 - * - encoding: set by user. - * - decoding: set by lavc. - * @todo move this after frame_rate - */ - - int frame_rate_base; - /** - * 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. - * Dont touch, used by lavc default_get_buffer() - */ - int internal_buffer_count; - - /** - * internal_buffers. - * Dont touch, used by lavc default_get_buffer() - */ - void *internal_buffer; - -#define FF_QUALITY_SCALE 256 - /** - * 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; -} AVCodecContext; - - -/** - * AVOption. - */ -typedef struct AVOption { - /** options' name */ - const char *name; /* if name is NULL, it indicates a link to next */ - /** short English text help or const struct AVOption* subpointer */ - const char *help; // const struct AVOption* sub; - /** offset to context structure where the parsed value should be stored */ - int offset; - /** options' type */ - int type; -#define FF_OPT_TYPE_BOOL 1 ///< boolean - true,1,on (or simply presence) -#define FF_OPT_TYPE_DOUBLE 2 ///< double -#define FF_OPT_TYPE_INT 3 ///< integer -#define FF_OPT_TYPE_STRING 4 ///< string (finished with \0) -#define FF_OPT_TYPE_MASK 0x1f ///< mask for types - upper bits are various flags -//#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option -#define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40) -#define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80) - /** min value (min == max -> no limits) */ - double min; - /** maximum value for double/int */ - double max; - /** default boo [0,1]l/double/int value */ - double defval; - /** - * default string value (with optional semicolon delimited extra option-list - * i.e. option1;option2;option3 - * defval might select other then first argument as default - */ - const char *defstr; -#define FF_OPT_MAX_DEPTH 10 -} AVOption; - -/** - * Parse option(s) and sets fields in passed structure - * @param strct structure where the parsed results will be written - * @param list list with AVOptions - * @param opts string with options for parsing - */ -int avoption_parse(void* strct, const AVOption* list, const char* opts); - - -/** - * AVCodec. - */ -typedef struct AVCodec { - const char *name; - enum CodecType type; - int 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; - const AVOption *options; - struct AVCodec *next; - void (*flush)(AVCodecContext *); -} 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. - */ -typedef struct AVPaletteControl { - - /* demuxer sets this to 1 to indicate the palette has changed; - * decoder resets to 0 */ - int palette_changed; - - /* 256 3-byte RGB palette entries; the components should be - * formatted in the buffer as "RGBRGB..." and should be scaled to - * 8 bits if they originally represented 6-bit VGA palette - * components */ - unsigned char palette[256 * 3]; - -} AVPaletteControl; - -extern AVCodec ac3_encoder; -extern AVCodec mp2_encoder; -extern AVCodec mp3lame_encoder; -extern AVCodec oggvorbis_encoder; -extern AVCodec mpeg1video_encoder; -extern AVCodec mpeg2video_encoder; -extern AVCodec h263_encoder; -extern AVCodec h263p_encoder; -extern AVCodec flv_encoder; -extern AVCodec rv10_encoder; -extern AVCodec mjpeg_encoder; -extern AVCodec ljpeg_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 h264_encoder; -extern AVCodec asv1_encoder; -extern AVCodec asv2_encoder; -extern AVCodec vcr1_encoder; -extern AVCodec ffv1_encoder; -extern AVCodec mdec_encoder; - -extern AVCodec h263_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 mpeg1video_decoder; -extern AVCodec mpeg2video_decoder; -extern AVCodec mpeg_xvmc_decoder; -extern AVCodec h263i_decoder; -extern AVCodec flv_decoder; -extern AVCodec rv10_decoder; -extern AVCodec svq1_decoder; -extern AVCodec svq3_decoder; -extern AVCodec dvvideo_decoder; -extern AVCodec dvaudio_decoder; -extern AVCodec wmav1_decoder; -extern AVCodec wmav2_decoder; -extern AVCodec mjpeg_decoder; -extern AVCodec mjpegb_decoder; -extern AVCodec mp2_decoder; -extern AVCodec mp3_decoder; -extern AVCodec mace3_decoder; -extern AVCodec mace6_decoder; -extern AVCodec huffyuv_decoder; -extern AVCodec oggvorbis_decoder; -extern AVCodec cyuv_decoder; -extern AVCodec h264_decoder; -extern AVCodec indeo3_decoder; -extern AVCodec vp3_decoder; -extern AVCodec amr_nb_decoder; -extern AVCodec amr_nb_encoder; -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 fourxm_decoder; -extern AVCodec mdec_decoder; -extern AVCodec roq_decoder; -extern AVCodec interplay_video_decoder; -extern AVCodec xan_wc3_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; - -/* pcm codecs */ -#define PCM_CODEC(id, name) \ -extern AVCodec name ## _decoder; \ -extern AVCodec name ## _encoder - -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_MS, adpcm_ms); -PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm); - -#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; - -/* resample.c */ - -struct ReSampleContext; - -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); - -/* 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); - -void img_resample(ImgReSampleContext *s, - AVPicture *output, AVPicture *input); - -void img_resample_close(ImgReSampleContext *s); - -int avpicture_fill(AVPicture *picture, uint8_t *ptr, - int pix_fmt, int width, int height); -int avpicture_layout(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); -enum PixelFormat avcodec_get_pix_fmt(const char* name); - -#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(AVPicture *src, int pix_fmt, int width, int height); - -/* convert among pixel formats */ -int img_convert(AVPicture *dst, int dst_pix_fmt, - AVPicture *src, int pix_fmt, - int width, int height); - -/* deinterlace a picture */ -int avpicture_deinterlace(AVPicture *dst, 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); -AVFrame *avcodec_alloc_frame(void); - -int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic); -void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic); -void avcodec_default_free_buffers(AVCodecContext *s); - -/** - * 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_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_close(AVCodecContext *avctx); - -void avcodec_register_all(void); - -void avcodec_flush_buffers(AVCodecContext *avctx); - -/* misc usefull functions */ - -/** - * returns a single letter to describe the picture type - */ -char av_get_pict_type_char(int pict_type); - -/** - * 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); - -/** - * rescale a 64bit integer. - * a simple a*b/c isnt possible as it can overflow - */ -int64_t av_rescale(int64_t a, int b, int c); - - -/** - * Interface for 0.5.0 version - * - * do not even think about it's usage for this moment - */ - -typedef struct { - /// compressed size used from given memory buffer - int size; - /// I/P/B frame type - int frame_type; -} avc_enc_result_t; - -/** - * Commands - * order can't be changed - once it was defined - */ -typedef enum { - // general commands - AVC_OPEN_BY_NAME = 0xACA000, - AVC_OPEN_BY_CODEC_ID, - AVC_OPEN_BY_FOURCC, - AVC_CLOSE, - - AVC_FLUSH, - // pin - struct { uint8_t* src, uint_t src_size } - // pout - struct { AVPicture* img, consumed_bytes, - AVC_DECODE, - // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size } - // pout - uint_t used_from_dest_size - AVC_ENCODE, - - // query/get video commands - AVC_GET_VERSION = 0xACB000, - AVC_GET_WIDTH, - AVC_GET_HEIGHT, - AVC_GET_DELAY, - AVC_GET_QUANT_TABLE, - // ... - - // query/get audio commands - AVC_GET_FRAME_SIZE = 0xABC000, - - // maybe define some simple structure which - // might be passed to the user - but they can't - // contain any codec specific parts and these - // calls are usualy necessary only few times - - // set video commands - AVC_SET_WIDTH = 0xACD000, - AVC_SET_HEIGHT, - - // set video encoding commands - AVC_SET_FRAME_RATE = 0xACD800, - AVC_SET_QUALITY, - AVC_SET_HURRY_UP, - - // set audio commands - AVC_SET_SAMPLE_RATE = 0xACE000, - AVC_SET_CHANNELS - -} avc_cmd_t; - -/** - * \param handle allocated private structure by libavcodec - * for initialization pass NULL - will be returned pout - * user is supposed to know nothing about its structure - * \param cmd type of operation to be performed - * \param pint input parameter - * \param pout output parameter - * - * \returns command status - eventually for query command it might return - * integer resulting value - */ -int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout); - -/* 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); -#define av_freep(p) __av_freep((void **)(p)) -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(void** location, unsigned int size); -#define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s) - -#ifdef __cplusplus -} -#endif - -#endif /* AVCODEC_H */ diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/bswap.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/bswap.h deleted file mode 100644 index 460f7ab..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/bswap.h +++ /dev/null @@ -1,129 +0,0 @@ -/** - * @file bswap.h - * byte swap. - */ - -#ifndef __BSWAP_H__ -#define __BSWAP_H__ - -#ifdef HAVE_BYTESWAP_H -#include -#else - -#ifdef ARCH_X86 -static inline unsigned short ByteSwap16(unsigned short x) -{ - __asm("xchgb %b0,%h0" : - "=q" (x) : - "0" (x)); - return x; -} -#define bswap_16(x) ByteSwap16(x) - -static inline unsigned int ByteSwap32(unsigned int x) -{ -#if __CPU__ > 386 - __asm("bswap %0": - "=r" (x) : -#else - __asm("xchgb %b0,%h0\n" - " rorl $16,%0\n" - " xchgb %b0,%h0": - "=q" (x) : -#endif - "0" (x)); - return x; -} -#define bswap_32(x) ByteSwap32(x) - -static inline unsigned long long int ByteSwap64(unsigned long long int x) -{ - register union { __extension__ uint64_t __ll; - uint32_t __l[2]; } __x; - asm("xchgl %0,%1": - "=r"(__x.__l[0]),"=r"(__x.__l[1]): - "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32)))); - return __x.__ll; -} -#define bswap_64(x) ByteSwap64(x) - -#elif defined(ARCH_SH4) - -static inline uint16_t ByteSwap16(uint16_t x) { - __asm__("swap.b %0,%0":"=r"(x):"0"(x)); - return x; -} - -static inline uint32_t ByteSwap32(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; -} - -#define bswap_16(x) ByteSwap16(x) -#define bswap_32(x) ByteSwap32(x) - -static inline uint64_t ByteSwap64(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; -} -#define bswap_64(x) ByteSwap64(x) - -#else - -#define bswap_16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8) - - -// code from bits/byteswap.h (C) 1997, 1998 Free Software Foundation, Inc. -#define bswap_32(x) \ - ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ - (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) - -static inline uint64_t ByteSwap64(uint64_t x) -{ - 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; -} -#define bswap_64(x) ByteSwap64(x) - -#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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/cabac.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/cabac.c deleted file mode 100644 index 3e50dc8..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/cabac.c +++ /dev/null @@ -1,206 +0,0 @@ -/* - * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder - * 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 - * - */ - -/** - * @file cabac.c - * Context Adaptive Binary Arithmetic Coder. - */ - -#include - -#include "common.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, -}; - -/** - * - * @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, NULL, NULL); - - 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, uint8_t *buf, int buf_size){ - c->bytestream_start= - c->bytestream= buf; - - c->low= *c->bytestream++; - c->low= (c->low<<9) + ((*c->bytestream++)<<1); - c->range= 0x1FE00; - c->bits_left= 7; -} - -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; ilps_range[2*i+0][j]= - c->lps_range[2*i+1][j]= 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(lps_state[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 -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 - * - * 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 - -typedef struct CABACContext{ - int low; - int range; - int outstanding_count; -#ifdef STRICT_LIMITS - int symCount; -#endif - uint8_t lps_range[2*64][4]; ///< rangeTabLPS - uint8_t lps_state[2*64]; ///< transIdxLPS - uint8_t mps_state[2*64]; ///< transIdxMPS - uint8_t *bytestream_start; - uint8_t *bytestream; - int bits_left; ///< - 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]; - -void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size); -void ff_init_cabac_decoder(CABACContext *c, 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)&3]; - - 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 (get_bit_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= 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 inline void renorm_cabac_decoder(CABACContext *c){ - while(c->range < 0x10000){ - c->range+= c->range; - c->low+= c->low; - if(--c->bits_left == 0){ - c->low+= *c->bytestream++; - c->bits_left= 8; - } - } -} - -static inline int get_cabac(CABACContext *c, uint8_t * const state){ - int RangeLPS= c->lps_range[*state][((c->range)>>14)&3]<<8; - int bit; - - c->range -= RangeLPS; - if(c->low < c->range){ - bit= (*state)&1; - *state= c->mps_state[*state]; - }else{ - bit= ((*state)&1)^1; - c->low -= c->range; - c->range = RangeLPS; - *state= c->lps_state[*state]; - } - renorm_cabac_decoder(c); - - return bit; -} - -static inline int get_cabac_static(CABACContext *c, int RangeLPS){ - int bit; - - c->range -= RangeLPS; - if(c->low < c->range){ - bit= 0; - }else{ - bit= 1; - c->low -= c->range; - c->range = RangeLPS; - } - renorm_cabac_decoder(c); - - return bit; -} - -static inline int get_cabac_bypass(CABACContext *c){ - c->low += c->low; - - if(--c->bits_left == 0){ - c->low+= *c->bytestream++; - c->bits_left= 8; - } - - 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 -= 2<<8; - if(c->low < c->range){ - renorm_cabac_decoder(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>=1){ - v+= v + get_cabac_bypass(c); - } - i += v; - - if(is_signed && get_cabac_bypass(c)){ - return -i; - }else - return i; -} diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/cljr.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/cljr.c deleted file mode 100644 index c7c614e..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/cljr.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Cirrus Logic AccuPak (CLJR) codec - * Copyright (c) 2003 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 cljr.c - * Cirrus Logic AccuPak codec. - */ - -#include "avcodec.h" -#include "mpegvideo.h" - -typedef struct CLJRContext{ - AVCodecContext *avctx; - AVFrame picture; - int delta[16]; - int offset[4]; - GetBitContext gb; -} CLJRContext; - -static int decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - CLJRContext * const a = avctx->priv_data; - AVFrame *picture = data; - AVFrame * const p= (AVFrame*)&a->picture; - int x, y; - - *data_size = 0; - - /* special case for last picture */ - if (buf_size == 0) { - return 0; - } - - if(p->data[0]) - avctx->release_buffer(avctx, p); - - p->reference= 0; - if(avctx->get_buffer(avctx, p) < 0){ - fprintf(stderr, "get_buffer() failed\n"); - return -1; - } - p->pict_type= I_TYPE; - p->key_frame= 1; - - init_get_bits(&a->gb, buf, buf_size); - - for(y=0; yheight; y++){ - uint8_t *luma= &a->picture.data[0][ y*a->picture.linesize[0] ]; - uint8_t *cb= &a->picture.data[1][ y*a->picture.linesize[1] ]; - uint8_t *cr= &a->picture.data[2][ y*a->picture.linesize[2] ]; - for(x=0; xwidth; x+=4){ - luma[3] = get_bits(&a->gb, 5) << 3; - luma[2] = get_bits(&a->gb, 5) << 3; - luma[1] = get_bits(&a->gb, 5) << 3; - luma[0] = get_bits(&a->gb, 5) << 3; - luma+= 4; - *(cb++) = get_bits(&a->gb, 6) << 2; - *(cr++) = get_bits(&a->gb, 6) << 2; - } - } - - *picture= *(AVFrame*)&a->picture; - *data_size = sizeof(AVPicture); - - emms_c(); - - return buf_size; -} - -#if 0 -static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ - CLJRContext * const a = avctx->priv_data; - AVFrame *pict = data; - AVFrame * const p= (AVFrame*)&a->picture; - int size; - int mb_x, mb_y; - - *p = *pict; - p->pict_type= I_TYPE; - p->key_frame= 1; - - emms_c(); - - align_put_bits(&a->pb); - while(get_bit_count(&a->pb)&31) - put_bits(&a->pb, 8, 0); - - size= get_bit_count(&a->pb)/32; - - return size*4; -} -#endif - -static void common_init(AVCodecContext *avctx){ - CLJRContext * const a = avctx->priv_data; - - avctx->coded_frame= (AVFrame*)&a->picture; - a->avctx= avctx; -} - -static int decode_init(AVCodecContext *avctx){ - - common_init(avctx); - - avctx->pix_fmt= PIX_FMT_YUV411P; - - return 0; -} - -static int encode_init(AVCodecContext *avctx){ - - common_init(avctx); - - return 0; -} - -static int decode_end(AVCodecContext *avctx){ - - avcodec_default_free_buffers(avctx); - - return 0; -} - -AVCodec cljr_decoder = { - "cljr", - CODEC_TYPE_VIDEO, - CODEC_ID_CLJR, - sizeof(CLJRContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1, -}; -#if 0 -#ifdef CONFIG_ENCODERS - -AVCodec cljr_encoder = { - "cljr", - CODEC_TYPE_VIDEO, - CODEC_ID_cljr, - sizeof(CLJRContext), - encode_init, - encode_frame, - //encode_end, -}; - -#endif //CONFIG_ENCODERS -#endif diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/common.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/common.c deleted file mode 100644 index 6f1892a..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/common.c +++ /dev/null @@ -1,421 +0,0 @@ -/* - * Common bit i/o 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 - * - * alternative bitstream reader & writer by Michael Niedermayer - */ - -/** - * @file common.c - * common internal api. - */ - -#include "avcodec.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 -}; - -void init_put_bits(PutBitContext *s, - uint8_t *buffer, int buffer_size, - void *opaque, - void (*write_data)(void *, uint8_t *, int)) -{ - s->buf = buffer; - s->buf_end = s->buf + buffer_size; - s->data_out_size = 0; - if(write_data!=NULL) - { - fprintf(stderr, "write Data callback is not supported\n"); - } -#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 -} - -#ifdef CONFIG_ENCODERS - -/* return the number of bits output */ -int64_t get_bit_count(PutBitContext *s) -{ -#ifdef ALT_BITSTREAM_WRITER - return s->data_out_size * 8 + s->index; -#else - return (s->buf_ptr - s->buf + s->data_out_size) * 8 + 32 - (int64_t)s->bit_left; -#endif -} - -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 -} - -#endif //CONFIG_ENCODERS - -/* pad the end of the output stream with zeros */ -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 -} - -#ifdef CONFIG_ENCODERS - -void put_string(PutBitContext * pbc, char *s) -{ - while(*s){ - put_bits(pbc, 8, *s); - s++; - } - put_bits(pbc, 8, 0); -} - -/* bit input functions */ - -#endif //CONFIG_ENCODERS - -/** - * 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 - */ -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 -} - -/** - * 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) printf("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 index; - index = vlc->table_size; - vlc->table_size += size; - if (vlc->table_size > vlc->table_allocated) { - vlc->table_allocated += (1 << vlc->bits); - 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 i, j, k, n, table_size, table_index, nb, n1, index; - uint32_t code; - VLC_TYPE (*table)[2]; - - table_size = 1 << table_nb_bits; - table_index = alloc_table(vlc, table_size); -#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 0 && (code >> n) == 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> 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_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, - (code_prefix << table_nb_bits) | i, - n_prefix + table_nb_bits); - 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. -*/ -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) -{ - vlc->bits = nb_bits; - vlc->table = NULL; - vlc->table_allocated = 0; - vlc->table_size = 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) < 0) { - av_free(vlc->table); - return -1; - } - return 0; -} - - -void free_vlc(VLC *vlc) -{ - av_free(vlc->table); -} - -int64_t ff_gcd(int64_t a, int64_t b){ - if(b) return ff_gcd(b, a%b); - else return a; -} - -void ff_float2fraction(int *nom_arg, int *denom_arg, double f, int max){ - double best_diff=1E10, diff; - int best_denom=1, best_nom=1; - int nom, denom, gcd; - - //brute force here, perhaps we should try continued fractions if we need large max ... - for(denom=1; denom<=max; denom++){ - nom= (int)(f*denom + 0.5); - if(nom<=0 || nom>max) continue; - - diff= ABS( f - (double)nom / (double)denom ); - if(diff < best_diff){ - best_diff= diff; - best_nom= nom; - best_denom= denom; - } - } - - gcd= ff_gcd(best_nom, best_denom); - best_nom /= gcd; - best_denom /= gcd; - - *nom_arg= best_nom; - *denom_arg= best_denom; -} diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/common.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/common.h deleted file mode 100644 index c1b1d47..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/common.h +++ /dev/null @@ -1,1142 +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 - -//#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 - -#ifdef HAVE_AV_CONFIG_H -/* only include the following when compiling package */ -# include "config.h" - -# include -# include -# include -# include -# ifndef __BEOS__ -# include -# else -# include "berrno.h" -# endif -# include - -# ifndef ENODATA -# define ENODATA 61 -# endif - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#include -#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) - -struct AVOption; -#ifdef HAVE_MMX -extern const struct AVOption avoptions_common[3 + 5]; -#else -extern const struct AVOption avoptions_common[3]; -#endif -extern const struct AVOption avoptions_workaround_bug[11]; - -#endif /* HAVE_AV_CONFIG_H */ - -/* Suppress restrict if it was not defined in config.h. */ -#ifndef restrict -# define restrict -#endif - -#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) -# define always_inline __attribute__((always_inline)) inline -#else -# define always_inline inline -#endif - -#ifdef CONFIG_WIN32 - -/* windows */ - -typedef unsigned short uint16_t; -typedef signed short int16_t; -typedef unsigned char uint8_t; -typedef unsigned int uint32_t; -typedef unsigned __int64 uint64_t; -typedef signed char int8_t; -typedef signed int int32_t; -typedef signed __int64 int64_t; - -# ifndef __MINGW32__ -# define int64_t_C(c) (c ## i64) -# define uint64_t_C(c) (c ## i64) - -# define inline __inline - -# else -# define int64_t_C(c) (c ## LL) -# define uint64_t_C(c) (c ## ULL) -# endif /* __MINGW32__ */ - -# ifdef _DEBUG -# define DEBUG -# endif - -# define snprintf _snprintf -# define vsnprintf _vsnprintf - -/* CONFIG_WIN32 end */ -#elif defined (CONFIG_OS2) -/* OS/2 EMX */ - -#include - -#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 - -#endif /* HAVE_AV_CONFIG_H */ - -/* CONFIG_OS2 end */ -#else - -/* unix */ - -#include - -#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" - -# if defined(__MINGW32__) || defined(__CYGWIN__) || \ - defined(__OS2__) || (defined (__OpenBSD__) && !defined(__ELF__)) -# define MANGLE(a) "_" #a -# else -# define MANGLE(a) #a -# endif - -/* debug stuff */ - -# ifndef DEBUG -# define NDEBUG -# endif -# include - -/* dprintf macros */ -# if defined(CONFIG_WIN32) && !defined(__MINGW32__) - -inline void dprintf(const char* fmt,...) {} - -# else - -# ifdef DEBUG -# define dprintf(fmt,args...) printf(fmt, ## args) -# else -# define dprintf(fmt,args...) -# endif - -# endif /* !CONFIG_WIN32 */ - -# define av_abort() do { fprintf(stderr, "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]; - -#ifdef ARCH_X86 -# 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 - -#ifdef ARCH_X86 -// 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 */ - -struct PutBitContext; - -typedef void (*WriteDataFunc)(void *, uint8_t *, int); - -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 - int64_t data_out_size; /* in bytes */ -} PutBitContext; - -void init_put_bits(PutBitContext *s, - uint8_t *buffer, int buffer_size, - void *opaque, - void (*write_data)(void *, uint8_t *, int)); - -int64_t get_bit_count(PutBitContext *s); /* XXX: change function name */ -void align_put_bits(PutBitContext *s); -void flush_put_bits(PutBitContext *s); -void put_string(PutBitContext * pbc, char *s); - -/* bit input */ - -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; - -static inline int get_bits_count(GetBitContext *s); - -#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; - -#ifdef ARCH_SPARC64 -#define UNALIGNED_STORES_ARE_BAD -#endif - -/* used to avoid missaligned exceptions on some archs (alpha, ...) */ -#ifdef ARCH_X86 -# define unaligned32(a) (*(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 - bit_left); -#ifdef UNALIGNED_STORES_ARE_BAD - if (3 & (int) 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 -# ifdef ARCH_X86 - 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 -# ifdef ARCH_X86 - 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 -} - -/* 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 nest num bits - -SHOW_SBITS(name, gb, num) - will return the nest num bits and do sign extension - -SKIP_BITS(name, gb, num) - will skip over the next num bits - note, this is equinvalent 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 equinvalent 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 -} - -#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;\ - -# define UPDATE_CACHE(name, gb)\ - name##_cache= unaligned32_be( ((uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\ - -# define SKIP_CACHE(name, gb, num)\ - name##_cache <<= (num);\ - -// 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) ; - -# 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->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;\ - ((uint16_t*)name##_buffer_ptr)++;\ - 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<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<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 ]; - result<<= (index&0x07); - result>>= 8 - 1; - 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); -} - -void init_get_bits(GetBitContext *s, - const uint8_t *buffer, int buffer_size); - -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); -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)\ -{\ - 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){\ - LAST_SKIP_BITS(name, gb, bits)\ - 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 - -static inline void print_bin(int bits, int n){ - int i; - - for(i=n-1; i>=0; i--){ - printf("%d", (bits>>i)&1); - } - for(i=n; i<24; i++) - printf(" "); -} - -static inline int get_bits_trace(GetBitContext *s, int n, char *file, char *func, int line){ - int r= get_bits(s, n); - - print_bin(r, n); - printf("%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, 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); - - printf("%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, char *func, int line){ - int show= show_bits(s, n); - int r= get_xbits(s, n); - - print_bin(show, n); - printf("%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 printf - -#else //TRACE -#define tprintf(_arg...) {} -#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) -{ - int vmin, vmax; - vmax = vmin = a; - if (b < vmin) - vmin = b; - else - vmax = b; - - if (c < vmin) - vmin = c; - else if (c > vmax) - vmax = c; - - return a + b + c - vmin - vmax; -} - -static inline int clip(int a, int amin, int amax) -{ - if (a < amin) - return amin; - else if (a > amax) - return amax; - 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<>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 - -#ifdef ARCH_X86 -static inline long long rdtsc() -{ - long long l; - asm volatile( "rdtsc\n\t" - : "=A" (l) - ); - return l; -} - -#define START_TIMER \ -static uint64_t tsum=0;\ -static int tcount=0;\ -static int tskip_count=0;\ -uint64_t tend;\ -uint64_t tstart= rdtsc();\ - -#define STOP_TIMER(id) \ -tend= rdtsc();\ -if(tcount<2 || tend - tstart < 4*tsum/tcount){\ - tsum+= tend - tstart;\ - tcount++;\ -}else\ - tskip_count++;\ -if(256*256*256*64%(tcount+tskip_count)==0){\ - fprintf(stderr, "%Ld dezicycles in %s, %d runs, %d skips\n", tsum*10/tcount, id, tcount, tskip_count);\ -} -#endif - -#define CLAMP_TO_8BIT(d) ((d > 0xff) ? 0xff : (d < 0) ? 0 : d) - -/* avoid usage of various functions */ -#define malloc please_use_av_malloc -#define free please_use_av_free -#define realloc please_use_av_realloc - -#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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/cyuv.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/cyuv.c deleted file mode 100644 index d1a6eab..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/cyuv.c +++ /dev/null @@ -1,186 +0,0 @@ -/* - * - * 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 - * - * Creative YUV (CYUV) Video Decoder - * by Mike Melanson (melanson@pcisys.net) - * based on "Creative YUV (CYUV) stream format for AVI": - * http://www.csse.monash.edu.au/~timf/videocodec/cyuv.txt - * - */ - -/** - * @file cyuv.c - * Creative YUV (CYUV) Video Decoder. - */ - -#include -#include -#include -#include - -#include "common.h" -#include "avcodec.h" -#include "dsputil.h" -#include "mpegvideo.h" - - -typedef struct CyuvDecodeContext { - AVCodecContext *avctx; - int width, height; - AVFrame frame; -} CyuvDecodeContext; - -static int cyuv_decode_init(AVCodecContext *avctx) -{ - CyuvDecodeContext *s = avctx->priv_data; - - s->avctx = avctx; - s->width = avctx->width; - s->height = avctx->height; - avctx->pix_fmt = PIX_FMT_YUV411P; - avctx->has_b_frames = 0; - - return 0; -} - -static int cyuv_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - CyuvDecodeContext *s=avctx->priv_data; - - unsigned char *y_plane; - unsigned char *u_plane; - unsigned char *v_plane; - int y_ptr; - int u_ptr; - int v_ptr; - - /* prediction error tables (make it clear that they are signed values) */ - signed char *y_table = buf + 0; - signed char *u_table = buf + 16; - signed char *v_table = buf + 32; - - unsigned char y_pred, u_pred, v_pred; - int stream_ptr; - unsigned char cur_byte; - int pixel_groups; - - *data_size = 0; - - /* sanity check the buffer size: A buffer has 3x16-bytes tables - * followed by (height) lines each with 3 bytes to represent groups - * of 4 pixels. Thus, the total size of the buffer ought to be: - * (3 * 16) + height * (width * 3 / 4) */ - if (buf_size != 48 + s->height * (s->width * 3 / 4)) { - printf ("ffmpeg: cyuv: got a buffer with %d bytes when %d were expected\n", - buf_size, - 48 + s->height * (s->width * 3 / 4)); - return -1; - } - - /* pixel data starts 48 bytes in, after 3x16-byte tables */ - stream_ptr = 48; - - if(s->frame.data[0]) - avctx->release_buffer(avctx, &s->frame); - - s->frame.reference = 0; - if(avctx->get_buffer(avctx, &s->frame) < 0) { - fprintf(stderr, "get_buffer() failed\n"); - return -1; - } - - y_plane = s->frame.data[0]; - u_plane = s->frame.data[1]; - v_plane = s->frame.data[2]; - - /* iterate through each line in the height */ - for (y_ptr = 0, u_ptr = 0, v_ptr = 0; - y_ptr < (s->height * s->frame.linesize[0]); - y_ptr += s->frame.linesize[0] - s->width, - u_ptr += s->frame.linesize[1] - s->width / 4, - v_ptr += s->frame.linesize[2] - s->width / 4) { - - /* reset predictors */ - cur_byte = buf[stream_ptr++]; - u_plane[u_ptr++] = u_pred = cur_byte & 0xF0; - y_plane[y_ptr++] = y_pred = (cur_byte & 0x0F) << 4; - - cur_byte = buf[stream_ptr++]; - v_plane[v_ptr++] = v_pred = cur_byte & 0xF0; - y_pred += y_table[cur_byte & 0x0F]; - y_plane[y_ptr++] = y_pred; - - cur_byte = buf[stream_ptr++]; - y_pred += y_table[cur_byte & 0x0F]; - y_plane[y_ptr++] = y_pred; - y_pred += y_table[(cur_byte & 0xF0) >> 4]; - y_plane[y_ptr++] = y_pred; - - /* iterate through the remaining pixel groups (4 pixels/group) */ - pixel_groups = s->width / 4 - 1; - while (pixel_groups--) { - - cur_byte = buf[stream_ptr++]; - u_pred += u_table[(cur_byte & 0xF0) >> 4]; - u_plane[u_ptr++] = u_pred; - y_pred += y_table[cur_byte & 0x0F]; - y_plane[y_ptr++] = y_pred; - - cur_byte = buf[stream_ptr++]; - v_pred += v_table[(cur_byte & 0xF0) >> 4]; - v_plane[v_ptr++] = v_pred; - y_pred += y_table[cur_byte & 0x0F]; - y_plane[y_ptr++] = y_pred; - - cur_byte = buf[stream_ptr++]; - y_pred += y_table[cur_byte & 0x0F]; - y_plane[y_ptr++] = y_pred; - y_pred += y_table[(cur_byte & 0xF0) >> 4]; - y_plane[y_ptr++] = y_pred; - - } - } - - *data_size=sizeof(AVFrame); - *(AVFrame*)data= s->frame; - - return buf_size; -} - -static int cyuv_decode_end(AVCodecContext *avctx) -{ -/* CyuvDecodeContext *s = avctx->priv_data;*/ - - return 0; -} - -AVCodec cyuv_decoder = { - "cyuv", - CODEC_TYPE_VIDEO, - CODEC_ID_CYUV, - sizeof(CyuvDecodeContext), - cyuv_decode_init, - NULL, - cyuv_decode_end, - cyuv_decode_frame, - 0, - NULL -}; - diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dct-test.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dct-test.c deleted file mode 100644 index 5f8473a..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dct-test.c +++ /dev/null @@ -1,501 +0,0 @@ -/** - * @file dct-test.c - * DCT test. (c) 2001 Fabrice Bellard. - * Started from sample code by Juan J. Sierralta P. - */ - -#include -#include -#include -#include -#include - -#include "dsputil.h" - -#include "i386/mmx.h" -#include "simple_idct.h" - -#ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -/* reference fdct/idct */ -extern void fdct(DCTELEM *block); -extern void idct(DCTELEM *block); -extern void init_fdct(); - -extern void j_rev_dct(DCTELEM *data); -extern void ff_mmx_idct(DCTELEM *data); -extern void ff_mmxext_idct(DCTELEM *data); - -extern void odivx_idct_c (short *block); - -#define AANSCALE_BITS 12 -static const unsigned short 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 -}; - -uint8_t cropTbl[256 + 2 * MAX_NEG_CROP]; - -int64_t gettime(void) -{ - struct timeval tv; - gettimeofday(&tv,NULL); - return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; -} - -#define NB_ITS 20000 -#define NB_ITS_SPEED 50000 - -static short idct_mmx_perm[64]; - -static short idct_simple_mmx_perm[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, -}; - -void idct_mmx_init(void) -{ - int i; - - /* the mmx/mmxext idct uses a reordered input, so we patch scan tables */ - for (i = 0; i < 64; i++) { - idct_mmx_perm[i] = (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2); -// idct_simple_mmx_perm[i] = simple_block_permute_op(i); - } -} - -static DCTELEM block[64] __attribute__ ((aligned (8))); -static DCTELEM block1[64] __attribute__ ((aligned (8))); -static DCTELEM block_org[64] __attribute__ ((aligned (8))); - -void dct_error(const char *name, int is_idct, - void (*fdct_func)(DCTELEM *block), - void (*fdct_ref)(DCTELEM *block), int test) -{ - int it, i, scale; - int err_inf, v; - int64_t err2, ti, ti1, it1; - int64_t sysErr[64], sysErrMax=0; - int maxout=0; - int blockSumErrMax=0, blockSumErr; - - srandom(0); - - err_inf = 0; - err2 = 0; - for(i=0; i<64; i++) sysErr[i]=0; - for(it=0;it>=3; - } - break; - case 1:{ - int num= (random()%10)+1; - for(i=0;i> AANSCALE_BITS; - } - } - - fdct_ref(block1); - - blockSumErr=0; - for(i=0;i<64;i++) { - v = abs(block[i] - block1[i]); - if (v > err_inf) - err_inf = v; - err2 += v * v; - sysErr[i] += block[i] - block1[i]; - blockSumErr += v; - if( abs(block[i])>maxout) maxout=abs(block[i]); - } - if(blockSumErrMax < blockSumErr) blockSumErrMax= blockSumErr; -#if 0 // print different matrix pairs - if(blockSumErr){ - printf("\n"); - for(i=0; i<64; i++){ - if((i&7)==0) printf("\n"); - printf("%4d ", block_org[i]); - } - for(i=0; i<64; i++){ - if((i&7)==0) printf("\n"); - printf("%4d ", block[i] - block1[i]); - } - } -#endif - } - for(i=0; i<64; i++) sysErrMax= MAX(sysErrMax, ABS(sysErr[i])); - -#if 1 // dump systematic errors - for(i=0; i<64; i++){ - if(i%8==0) printf("\n"); - printf("%5d ", (int)sysErr[i]); - } - printf("\n"); -#endif - - printf("%s %s: err_inf=%d err2=%0.8f syserr=%0.8f maxout=%d blockSumErr=%d\n", - is_idct ? "IDCT" : "DCT", - name, err_inf, (double)err2 / NB_ITS / 64.0, (double)sysErrMax / NB_ITS, maxout, blockSumErrMax); -#if 1 //Speed test - /* speed test */ - for(i=0;i<64;i++) - block1[i] = 0; - switch(test){ - case 0: - for(i=0;i<64;i++) - block1[i] = (random() % 512) -256; - if (is_idct){ - fdct(block1); - - for(i=0;i<64;i++) - block1[i]>>=3; - } - break; - case 1:{ - case 2: - block1[0] = (random() % 512) -256; - block1[1] = (random() % 512) -256; - block1[2] = (random() % 512) -256; - block1[3] = (random() % 512) -256; - }break; - } - - if (fdct_func == ff_mmx_idct || - fdct_func == j_rev_dct || fdct_func == ff_mmxext_idct) { - for(i=0;i<64;i++) - block[idct_mmx_perm[i]] = block1[i]; - } else if(fdct_func == ff_simple_idct_mmx ) { - for(i=0;i<64;i++) - block[idct_simple_mmx_perm[i]] = block1[i]; - } else { - for(i=0; i<64; i++) - block[i]= block1[i]; - } - - ti = gettime(); - it1 = 0; - do { - for(it=0;it 255) - v = 255; - dest[i * linesize + j] = (int)rint(v); - } - } -} - -void idct248_error(const char *name, - void (*idct248_put)(uint8_t *dest, int line_size, int16_t *block)) -{ - int it, i, it1, ti, ti1, err_max, v; - - srandom(0); - - /* just one test to see if code is correct (precision is less - important here) */ - err_max = 0; - for(it=0;it err_max) - err_max = v; - } -#if 0 - printf("ref=\n"); - for(i=0;i<8;i++) { - int j; - for(j=0;j<8;j++) { - printf(" %3d", img_dest1[i*8+j]); - } - printf("\n"); - } - - printf("out=\n"); - for(i=0;i<8;i++) { - int j; - for(j=0;j<8;j++) { - printf(" %3d", img_dest[i*8+j]); - } - printf("\n"); - } -#endif - } - printf("%s %s: err_inf=%d\n", - 1 ? "IDCT248" : "DCT248", - name, err_max); - - ti = gettime(); - it1 = 0; - do { - for(it=0;it]\n" - "test-number 0 -> test with random matrixes\n" - " 1 -> test with random sparse matrixes\n" - " 2 -> do 3. test from mpeg4 std\n" - "-i test IDCT implementations\n" - "-4 test IDCT248 implementations\n"); - exit(1); -} - -int main(int argc, char **argv) -{ - int test_idct = 0, test_248_dct = 0; - int c,i; - int test=1; - - init_fdct(); - idct_mmx_init(); - - for(i=0;i<256;i++) cropTbl[i + MAX_NEG_CROP] = i; - for(i=0;i 32767) x = 32767; -#define SE_16BIT(x) if (x & 0x8000) x -= 0x10000; -#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]) - -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 dpcm_decode_init(AVCodecContext *avctx) -{ - DPCMContext *s = avctx->priv_data; - int i; - short square; - - s->channels = avctx->channels; - - 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; - - 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; - - 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; - } - - *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, -}; diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dsputil.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dsputil.c deleted file mode 100644 index 9e7cca7..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dsputil.c +++ /dev/null @@ -1,3055 +0,0 @@ -/* - * 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 - * - * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer - */ - -/** - * @file dsputil.c - * DSP utils - */ - -#include "avcodec.h" -#include "dsputil.h" -#include "mpegvideo.h" -#include "simple_idct.h" - - -uint8_t cropTbl[256 + 2 * MAX_NEG_CROP]; -uint32_t squareTbl[512]; - -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 -}; - -/* not permutated inverse zigzag_direct + 1 for MMX quantizer */ -uint16_t __align8 inv_zigzag_direct16[64]; - -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>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>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>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>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>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>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>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>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>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>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>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>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 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>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<>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=0 && y>=0);\ -\ - for(i=0; i=0 && y>=0);\ -\ - for(i=0; i>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>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>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; - int i; - - for(i=0; i>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>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 inline int pix_abs16x16_c(uint8_t *pix1, uint8_t *pix2, int line_size) -{ - int s, i; - - s = 0; - for(i=0;i<16;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_abs16x16_x2_c(uint8_t *pix1, uint8_t *pix2, int line_size) -{ - int s, i; - - s = 0; - for(i=0;i<16;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_abs16x16_y2_c(uint8_t *pix1, uint8_t *pix2, int line_size) -{ - int s, i; - uint8_t *pix3 = pix2 + line_size; - - s = 0; - for(i=0;i<16;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_abs16x16_xy2_c(uint8_t *pix1, uint8_t *pix2, int line_size) -{ - int s, i; - uint8_t *pix3 = pix2 + line_size; - - s = 0; - for(i=0;i<16;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_abs8x8_c(uint8_t *pix1, uint8_t *pix2, int line_size) -{ - int s, i; - - s = 0; - for(i=0;i<8;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_abs8x8_x2_c(uint8_t *pix1, uint8_t *pix2, int line_size) -{ - int s, i; - - s = 0; - for(i=0;i<8;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_abs8x8_y2_c(uint8_t *pix1, uint8_t *pix2, int line_size) -{ - int s, i; - uint8_t *pix3 = pix2 + line_size; - - s = 0; - for(i=0;i<8;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_abs8x8_xy2_c(uint8_t *pix1, uint8_t *pix2, int line_size) -{ - int s, i; - uint8_t *pix3 = pix2 + line_size; - - s = 0; - for(i=0;i<8;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 sad16x16_c(void *s, uint8_t *a, uint8_t *b, int stride){ - return pix_abs16x16_c(a,b,stride); -} - -static int sad8x8_c(void *s, uint8_t *a, uint8_t *b, int stride){ - return pix_abs8x8_c(a,b,stride); -} - -/** - * 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]; - } -} - -/** - * 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+7maxi){ - maxi=sum; - printf("MAX:%d\n", maxi); -} -#endif - return sum; -} - -static int hadamard8_abs_c(uint8_t *src, int stride, int mean){ - int i; - int temp[64]; - int sum=0; -//FIXME OOOPS ignore 0 term instead of mean mess - for(i=0; i<8; i++){ - //FIXME try pointer walks - BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0]-mean,src[stride*i+1]-mean); - BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2]-mean,src[stride*i+3]-mean); - BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4]-mean,src[stride*i+5]-mean); - BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6]-mean,src[stride*i+7]-mean); - - 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]); - } - - return sum; -} - -static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride){ - MpegEncContext * const s= (MpegEncContext *)c; - uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8]; - DCTELEM * const temp= (DCTELEM*)aligned_temp; - int sum=0, i; - - s->dsp.diff_pixels(temp, src1, src2, stride); - s->dsp.fdct(temp); - - for(i=0; i<64; i++) - 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){ - 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; - - 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(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){ - 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; - - 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=0){ - s->dct_unquantize(s, temp, 0, s->qscale); - } - - s->dsp.idct_add(bak, stride, temp); - - distoration= s->dsp.sse[1](NULL, bak, src1, stride); - - 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){ - 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; - - 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; idct_algo==FF_DCT_FASTINT) - c->fdct = fdct_ifast; - else - c->fdct = ff_jpeg_fdct_islow; //slow/accurate/default -#endif //CONFIG_ENCODERS - - 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{ //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->get_pixels = get_pixels_c; - c->diff_pixels = diff_pixels_c; - c->put_pixels_clamped = put_pixels_clamped_c; - c->add_pixels_clamped = add_pixels_clamped_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; - c->sse[0]= sse16_c; - c->sse[1]= sse8_c; - - /* TODO [0] 16 [1] 8 */ - c->pix_abs16x16 = pix_abs16x16_c; - c->pix_abs16x16_x2 = pix_abs16x16_x2_c; - c->pix_abs16x16_y2 = pix_abs16x16_y2_c; - c->pix_abs16x16_xy2 = pix_abs16x16_xy2_c; - c->pix_abs8x8 = pix_abs8x8_c; - c->pix_abs8x8_x2 = pix_abs8x8_x2_c; - c->pix_abs8x8_y2 = pix_abs8x8_y2_c; - c->pix_abs8x8_xy2 = pix_abs8x8_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_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->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->hadamard8_diff[0]= hadamard8_diff16_c; - c->hadamard8_diff[1]= hadamard8_diff_c; - c->hadamard8_abs = hadamard8_abs_c; - - c->dct_sad[0]= dct_sad16x16_c; - c->dct_sad[1]= dct_sad8x8_c; - - c->sad[0]= sad16x16_c; - c->sad[1]= sad8x8_c; - - c->quant_psnr[0]= quant_psnr16x16_c; - c->quant_psnr[1]= quant_psnr8x8_c; - - c->rd[0]= rd16x16_c; - c->rd[1]= rd8x8_c; - - c->bit[0]= bit16x16_c; - c->bit[1]= bit8x8_c; - - c->add_bytes= add_bytes_c; - c->diff_bytes= diff_bytes_c; - c->bswap_buf= bswap_buf; - -#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_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; - default: - fprintf(stderr, "Internal error, IDCT permutation not set\n"); - } -} - diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dsputil.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dsputil.h deleted file mode 100644 index 402b990..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dsputil.h +++ /dev/null @@ -1,501 +0,0 @@ -/* - * DSP utils - * 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 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 ff_jpeg_fdct_islow (DCTELEM *data); - -void j_rev_dct (DCTELEM *data); - -void ff_fdct_mmx(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]; - -/* pixel operations */ -#define MAX_NEG_CROP 384 - -/* temporary */ -extern uint32_t squareTbl[512]; -extern uint8_t cropTbl[256 + 2 * MAX_NEG_CROP]; - - -/* 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 -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); - -#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 */ - -typedef int (*op_pixels_abs_func)(uint8_t *blk1/*align width (8 or 16)*/, uint8_t *blk2/*align 1*/, int line_size)/* __attribute__ ((const))*/; - -typedef int (*me_cmp_func)(void /*MpegEncContext*/ *s, uint8_t *blk1/*align width (8 or 16)*/, uint8_t *blk2/*align 1*/, int line_size)/* __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 (*add_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, 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); - me_cmp_func sad[2]; /* identical to pix_absAxA except additional void * */ - me_cmp_func sse[2]; - me_cmp_func hadamard8_diff[2]; - me_cmp_func dct_sad[2]; - me_cmp_func quant_psnr[2]; - me_cmp_func bit[2]; - me_cmp_func rd[2]; - int (*hadamard8_abs )(uint8_t *src, int stride, int mean); - - me_cmp_func me_pre_cmp[11]; - me_cmp_func me_cmp[11]; - me_cmp_func me_sub_cmp[11]; - me_cmp_func mb_cmp[11]; - - /* maybe create an array for 16/8/4/2 functions */ - /** - * Halfpel motion compensation with rounding (a+b+1)>>1. - * this is an array[4][4] of motion compensation funcions for 4 - * horizontal blocksizes (2,4,8,16) and the 4 halfpel positions
- * *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 (2,4,8,16) and the 4 halfpel positions
- * *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
- * *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[2][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
- * *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[2][4]; - - /** - * Thirdpel motion compensation with rounding (a+b+1)>>1. - * this is an array[12] of motion compensation funcions for the 9 thirdpel positions
- * *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]; - - op_pixels_abs_func pix_abs16x16; - op_pixels_abs_func pix_abs16x16_x2; - op_pixels_abs_func pix_abs16x16_y2; - op_pixels_abs_func pix_abs16x16_xy2; - op_pixels_abs_func pix_abs8x8; - op_pixels_abs_func pix_abs8x8_x2; - op_pixels_abs_func pix_abs8x8_y2; - op_pixels_abs_func pix_abs8x8_xy2; - - /* 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); - void (*bswap_buf)(uint32_t *dst, uint32_t *src, int w); - - /* (I)DCT */ - void (*fdct)(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
- * 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 - -} 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); - -#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); -} - -/** - * 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); - -#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 */ - -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); - -static inline void emms(void) -{ - __asm __volatile ("emms;":::"memory"); -} - - -#define emms_c() \ -{\ - if (mm_flags & MM_MMX)\ - emms();\ -} - -#define __align8 __attribute__ ((aligned (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 ptimizations */ -#define __align8 __attribute__ ((aligned (4))) - -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))) - -void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx); - -#elif defined(ARCH_ALPHA) - -#define __align8 __attribute__ ((aligned (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) -#include -#endif - -#define __align8 __attribute__ ((aligned (16))) - -void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx); - -#elif defined(HAVE_MMI) - -#define __align8 __attribute__ ((aligned (16))) - -void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx); - -#elif defined(ARCH_SH4) - -#define __align8 __attribute__ ((aligned (8))) - -void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx); - -#else - -#define __align8 - -#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 fft_init(FFTContext *s, int nbits, int inverse); -void fft_permute(FFTContext *s, FFTComplex *z); -void fft_calc_c(FFTContext *s, FFTComplex *z); -void fft_calc_sse(FFTContext *s, FFTComplex *z); -void fft_calc_altivec(FFTContext *s, FFTComplex *z); - -static inline void fft_calc(FFTContext *s, FFTComplex *z) -{ - s->fft_calc(s, z); -} -void 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 WARPER88_1616(name8, name16)\ -static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride){\ - return name8(s, dst , src , stride)\ - +name8(s, dst+8 , src+8 , stride)\ - +name8(s, dst +8*stride, src +8*stride, stride)\ - +name8(s, dst+8+8*stride, src+8+8*stride, stride);\ -} - -#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 inline long int lrintf(float x) -{ -#ifdef CONFIG_WIN32 - /* XXX: incorrect, but make it compile */ - return (int)(x); -#else - return (int)(rint(x)); -#endif -} -#endif - -#if defined(CONFIG_OS2) || defined(CONFIG_SUNOS) -static inline float floorf(float f) { - return floor(f); -} -#endif - -#endif diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dv.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dv.c deleted file mode 100644 index 75fd26e..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dv.c +++ /dev/null @@ -1,802 +0,0 @@ -/* - * DV decoder - * 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 dv.c - * DV decoder. - */ -#include "avcodec.h" -#include "dsputil.h" -#include "mpegvideo.h" -#include "simple_idct.h" - -#define NTSC_FRAME_SIZE 120000 -#define PAL_FRAME_SIZE 144000 - -#define TEX_VLC_BITS 9 - -typedef struct DVVideoDecodeContext { - AVCodecContext *avctx; - GetBitContext gb; - VLC *vlc; - int sampling_411; /* 0 = 420, 1 = 411 */ - int width, height; - uint8_t *current_picture[3]; /* picture structure */ - AVFrame picture; - int linesize[3]; - DCTELEM block[5*6][64] __align8; - uint8_t dv_zigzag[2][64]; - uint8_t idct_permutation[64]; - /* XXX: move it to static storage ? */ - uint8_t dv_shift[2][22][64]; - void (*idct_put[2])(uint8_t *dest, int line_size, DCTELEM *block); -} DVVideoDecodeContext; - -#include "dvdata.h" - -static VLC dv_vlc; -/* XXX: also include quantization */ -static RL_VLC_ELEM *dv_rl_vlc[1]; - -static void dv_build_unquantize_tables(DVVideoDecodeContext *s) -{ - int i, q, j; - - /* NOTE: max left shift is 6 */ - for(q = 0; q < 22; q++) { - /* 88 unquant */ - for(i = 1; i < 64; i++) { - /* 88 table */ - j = s->idct_permutation[i]; - s->dv_shift[0][q][j] = - dv_quant_shifts[q][dv_88_areas[i]] + 1; - } - - /* 248 unquant */ - for(i = 1; i < 64; i++) { - /* 248 table */ - s->dv_shift[1][q][i] = - dv_quant_shifts[q][dv_248_areas[i]] + 1; - } - } -} - -static int dvvideo_decode_init(AVCodecContext *avctx) -{ - DVVideoDecodeContext *s = avctx->priv_data; - MpegEncContext s2; - static int done=0; - - if (!done) { - int i; - - done = 1; - - /* NOTE: as a trick, we use the fact the no codes are unused - to accelerate the parsing of partial codes */ - init_vlc(&dv_vlc, TEX_VLC_BITS, NB_DV_VLC, - dv_vlc_len, 1, 1, dv_vlc_bits, 2, 2); - - dv_rl_vlc[0] = av_malloc(dv_vlc.table_size * sizeof(RL_VLC_ELEM)); - for(i = 0; i < dv_vlc.table_size; i++){ - int code= dv_vlc.table[i][0]; - int len = dv_vlc.table[i][1]; - int level, run; - - if(len<0){ //more bits needed - run= 0; - level= code; - } else if (code == (NB_DV_VLC - 1)) { - /* EOB */ - run = 0; - level = 256; - } else { - run= dv_vlc_run[code] + 1; - level= dv_vlc_level[code]; - } - dv_rl_vlc[0][i].len = len; - dv_rl_vlc[0][i].level = level; - dv_rl_vlc[0][i].run = run; - } - } - - /* ugly way to get the idct & scantable */ - /* XXX: fix it */ - memset(&s2, 0, sizeof(MpegEncContext)); - s2.avctx = avctx; - dsputil_init(&s2.dsp, avctx); - if (DCT_common_init(&s2) < 0) - return -1; - - s->idct_put[0] = s2.dsp.idct_put; - memcpy(s->idct_permutation, s2.dsp.idct_permutation, 64); - memcpy(s->dv_zigzag[0], s2.intra_scantable.permutated, 64); - - /* XXX: use MMX also for idct248 */ - s->idct_put[1] = simple_idct248_put; - memcpy(s->dv_zigzag[1], dv_248_zigzag, 64); - - /* XXX: do it only for constant case */ - dv_build_unquantize_tables(s); - - return 0; -} - -//#define VLC_DEBUG - -typedef struct BlockInfo { - const uint8_t *shift_table; - const uint8_t *scan_table; - uint8_t pos; /* position in block */ - uint8_t eob_reached; /* true if EOB has been reached */ - uint8_t dct_mode; - uint8_t partial_bit_count; - uint16_t partial_bit_buffer; - int shift_offset; -} BlockInfo; - -/* block size in bits */ -static const uint16_t block_sizes[6] = { - 112, 112, 112, 112, 80, 80 -}; - -#ifndef ALT_BITSTREAM_READER -#warning only works with ALT_BITSTREAM_READER -#endif - -/* decode ac coefs */ -static void dv_decode_ac(DVVideoDecodeContext *s, - BlockInfo *mb, DCTELEM *block, int last_index) -{ - int last_re_index; - int shift_offset = mb->shift_offset; - const uint8_t *scan_table = mb->scan_table; - const uint8_t *shift_table = mb->shift_table; - int pos = mb->pos; - int level, pos1, sign, run; - int partial_bit_count; -#ifndef ALT_BITSTREAM_READER //FIXME - int re_index=0; - int re1_index=0; -#endif - OPEN_READER(re, &s->gb); - -#ifdef VLC_DEBUG - printf("start\n"); -#endif - - /* if we must parse a partial vlc, we do it here */ - partial_bit_count = mb->partial_bit_count; - if (partial_bit_count > 0) { - uint8_t buf[4]; - uint32_t v; - int l, l1; - GetBitContext gb1; - - /* build the dummy bit buffer */ - l = 16 - partial_bit_count; - UPDATE_CACHE(re, &s->gb); -#ifdef VLC_DEBUG - printf("show=%04x\n", SHOW_UBITS(re, &s->gb, 16)); -#endif - v = (mb->partial_bit_buffer << l) | SHOW_UBITS(re, &s->gb, l); - buf[0] = v >> 8; - buf[1] = v; -#ifdef VLC_DEBUG - printf("v=%04x cnt=%d %04x\n", - v, partial_bit_count, (mb->partial_bit_buffer << l)); -#endif - /* try to read the codeword */ - init_get_bits(&gb1, buf, 4*8); - { - OPEN_READER(re1, &gb1); - UPDATE_CACHE(re1, &gb1); - GET_RL_VLC(level, run, re1, &gb1, dv_rl_vlc[0], - TEX_VLC_BITS, 2); - l = re1_index; - CLOSE_READER(re1, &gb1); - } -#ifdef VLC_DEBUG - printf("****run=%d level=%d size=%d\n", run, level, l); -#endif - /* compute codeword length */ - l1 = (level != 256 && level != 0); - /* if too long, we cannot parse */ - l -= partial_bit_count; - if ((re_index + l + l1) > last_index) - return; - /* skip read bits */ - last_re_index = 0; /* avoid warning */ - re_index += l; - /* by definition, if we can read the vlc, all partial bits - will be read (otherwise we could have read the vlc before) */ - mb->partial_bit_count = 0; - UPDATE_CACHE(re, &s->gb); - goto handle_vlc; - } - - /* get the AC coefficients until last_index is reached */ - for(;;) { - UPDATE_CACHE(re, &s->gb); -#ifdef VLC_DEBUG - printf("%2d: bits=%04x index=%d\n", - pos, SHOW_UBITS(re, &s->gb, 16), re_index); -#endif - last_re_index = re_index; - GET_RL_VLC(level, run, re, &s->gb, dv_rl_vlc[0], - TEX_VLC_BITS, 2); - handle_vlc: -#ifdef VLC_DEBUG - printf("run=%d level=%d\n", run, level); -#endif - if (level == 256) { - if (re_index > last_index) { - cannot_read: - /* put position before read code */ - re_index = last_re_index; - mb->eob_reached = 0; - break; - } - /* EOB */ - mb->eob_reached = 1; - break; - } else if (level != 0) { - if ((re_index + 1) > last_index) - goto cannot_read; - sign = SHOW_SBITS(re, &s->gb, 1); - level = (level ^ sign) - sign; - LAST_SKIP_BITS(re, &s->gb, 1); - pos += run; - /* error */ - if (pos >= 64) { - goto read_error; - } - pos1 = scan_table[pos]; - level = level << (shift_table[pos1] + shift_offset); - block[pos1] = level; - // printf("run=%d level=%d shift=%d\n", run, level, shift_table[pos1]); - } else { - if (re_index > last_index) - goto cannot_read; - /* level is zero: means run without coding. No - sign is coded */ - pos += run; - /* error */ - if (pos >= 64) { - read_error: -#if defined(VLC_DEBUG) || 1 - fprintf(stderr, "error pos=%d\n", pos); -#endif - /* for errors, we consider the eob is reached */ - mb->eob_reached = 1; - break; - } - } - } - CLOSE_READER(re, &s->gb); - mb->pos = pos; -} - -static inline void bit_copy(PutBitContext *pb, GetBitContext *gb, int bits_left) -{ - while (bits_left >= 16) { - put_bits(pb, 16, get_bits(gb, 16)); - bits_left -= 16; - } - if (bits_left > 0) { - put_bits(pb, bits_left, get_bits(gb, bits_left)); - } -} - -/* mb_x and mb_y are in units of 8 pixels */ -static inline void dv_decode_video_segment(DVVideoDecodeContext *s, - uint8_t *buf_ptr1, - const uint16_t *mb_pos_ptr) -{ - int quant, dc, dct_mode, class1, j; - int mb_index, mb_x, mb_y, v, last_index; - DCTELEM *block, *block1; - int c_offset, bits_left; - uint8_t *y_ptr; - BlockInfo mb_data[5 * 6], *mb, *mb1; - void (*idct_put)(uint8_t *dest, int line_size, DCTELEM *block); - uint8_t *buf_ptr; - PutBitContext pb, vs_pb; - uint8_t mb_bit_buffer[80 + 4]; /* allow some slack */ - int mb_bit_count; - uint8_t vs_bit_buffer[5 * 80 + 4]; /* allow some slack */ - int vs_bit_count; - - memset(s->block, 0, sizeof(s->block)); - - /* pass 1 : read DC and AC coefficients in blocks */ - buf_ptr = buf_ptr1; - block1 = &s->block[0][0]; - mb1 = mb_data; - init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80, NULL, NULL); - vs_bit_count = 0; - for(mb_index = 0; mb_index < 5; mb_index++) { - /* skip header */ - quant = buf_ptr[3] & 0x0f; - buf_ptr += 4; - init_put_bits(&pb, mb_bit_buffer, 80, NULL, NULL); - mb_bit_count = 0; - mb = mb1; - block = block1; - for(j = 0;j < 6; j++) { - /* NOTE: size is not important here */ - init_get_bits(&s->gb, buf_ptr, 14*8); - - /* get the dc */ - dc = get_bits(&s->gb, 9); - dc = (dc << (32 - 9)) >> (32 - 9); - dct_mode = get_bits1(&s->gb); - mb->dct_mode = dct_mode; - mb->scan_table = s->dv_zigzag[dct_mode]; - class1 = get_bits(&s->gb, 2); - mb->shift_offset = (class1 == 3); - mb->shift_table = s->dv_shift[dct_mode] - [quant + dv_quant_offset[class1]]; - dc = dc << 2; - /* convert to unsigned because 128 is not added in the - standard IDCT */ - dc += 1024; - block[0] = dc; - last_index = block_sizes[j]; - buf_ptr += last_index >> 3; - mb->pos = 0; - mb->partial_bit_count = 0; - - dv_decode_ac(s, mb, block, last_index); - - /* write the remaining bits in a new buffer only if the - block is finished */ - bits_left = last_index - get_bits_count(&s->gb); - if (mb->eob_reached) { - mb->partial_bit_count = 0; - mb_bit_count += bits_left; - bit_copy(&pb, &s->gb, bits_left); - } else { - /* should be < 16 bits otherwise a codeword could have - been parsed */ - mb->partial_bit_count = bits_left; - mb->partial_bit_buffer = get_bits(&s->gb, bits_left); - } - block += 64; - mb++; - } - - flush_put_bits(&pb); - - /* pass 2 : we can do it just after */ -#ifdef VLC_DEBUG - printf("***pass 2 size=%d\n", mb_bit_count); -#endif - block = block1; - mb = mb1; - init_get_bits(&s->gb, mb_bit_buffer, 80*8); - for(j = 0;j < 6; j++) { - if (!mb->eob_reached && get_bits_count(&s->gb) < mb_bit_count) { - dv_decode_ac(s, mb, block, mb_bit_count); - /* if still not finished, no need to parse other blocks */ - if (!mb->eob_reached) { - /* we could not parse the current AC coefficient, - so we add the remaining bytes */ - bits_left = mb_bit_count - get_bits_count(&s->gb); - if (bits_left > 0) { - mb->partial_bit_count += bits_left; - mb->partial_bit_buffer = - (mb->partial_bit_buffer << bits_left) | - get_bits(&s->gb, bits_left); - } - goto next_mb; - } - } - block += 64; - mb++; - } - /* all blocks are finished, so the extra bytes can be used at - the video segment level */ - bits_left = mb_bit_count - get_bits_count(&s->gb); - vs_bit_count += bits_left; - bit_copy(&vs_pb, &s->gb, bits_left); - next_mb: - mb1 += 6; - block1 += 6 * 64; - } - - /* we need a pass other the whole video segment */ - flush_put_bits(&vs_pb); - -#ifdef VLC_DEBUG - printf("***pass 3 size=%d\n", vs_bit_count); -#endif - block = &s->block[0][0]; - mb = mb_data; - init_get_bits(&s->gb, vs_bit_buffer, 5 * 80*8); - for(mb_index = 0; mb_index < 5; mb_index++) { - for(j = 0;j < 6; j++) { - if (!mb->eob_reached) { -#ifdef VLC_DEBUG - printf("start %d:%d\n", mb_index, j); -#endif - dv_decode_ac(s, mb, block, vs_bit_count); - } - block += 64; - mb++; - } - } - - /* compute idct and place blocks */ - block = &s->block[0][0]; - mb = mb_data; - for(mb_index = 0; mb_index < 5; mb_index++) { - v = *mb_pos_ptr++; - mb_x = v & 0xff; - mb_y = v >> 8; - y_ptr = s->current_picture[0] + (mb_y * s->linesize[0] * 8) + (mb_x * 8); - if (s->sampling_411) - c_offset = (mb_y * s->linesize[1] * 8) + ((mb_x >> 2) * 8); - else - c_offset = ((mb_y >> 1) * s->linesize[1] * 8) + ((mb_x >> 1) * 8); - for(j = 0;j < 6; j++) { - idct_put = s->idct_put[mb->dct_mode]; - if (j < 4) { - if (s->sampling_411 && mb_x < (704 / 8)) { - /* NOTE: at end of line, the macroblock is handled as 420 */ - idct_put(y_ptr + (j * 8), s->linesize[0], block); - } else { - idct_put(y_ptr + ((j & 1) * 8) + ((j >> 1) * 8 * s->linesize[0]), - s->linesize[0], block); - } - } else { - if (s->sampling_411 && mb_x >= (704 / 8)) { - uint8_t pixels[64], *c_ptr, *c_ptr1, *ptr; - int y, linesize; - /* NOTE: at end of line, the macroblock is handled as 420 */ - idct_put(pixels, 8, block); - linesize = s->linesize[6 - j]; - c_ptr = s->current_picture[6 - j] + c_offset; - ptr = pixels; - for(y = 0;y < 8; y++) { - /* convert to 411P */ - c_ptr1 = c_ptr + 8*linesize; - c_ptr[0]= ptr[0]; c_ptr1[0]= ptr[4]; - c_ptr[1]= ptr[1]; c_ptr1[1]= ptr[5]; - c_ptr[2]= ptr[2]; c_ptr1[2]= ptr[6]; - c_ptr[3]= ptr[3]; c_ptr1[3]= ptr[7]; - c_ptr += linesize; - ptr += 8; - } - } else { - /* don't ask me why they inverted Cb and Cr ! */ - idct_put(s->current_picture[6 - j] + c_offset, - s->linesize[6 - j], block); - } - } - block += 64; - mb++; - } - } -} - - -/* NOTE: exactly one frame must be given (120000 bytes for NTSC, - 144000 bytes for PAL) */ -static int dvvideo_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - DVVideoDecodeContext *s = avctx->priv_data; - int sct, dsf, apt, ds, nb_dif_segs, vs, width, height, i, packet_size; - uint8_t *buf_ptr; - const uint16_t *mb_pos_ptr; - - /* parse id */ - init_get_bits(&s->gb, buf, buf_size*8); - sct = get_bits(&s->gb, 3); - if (sct != 0) - return -1; - skip_bits(&s->gb, 5); - get_bits(&s->gb, 4); /* dsn (sequence number */ - get_bits(&s->gb, 1); /* fsc (channel number) */ - skip_bits(&s->gb, 3); - get_bits(&s->gb, 8); /* dbn (diff block number 0-134) */ - - dsf = get_bits(&s->gb, 1); /* 0 = NTSC 1 = PAL */ - if (get_bits(&s->gb, 1) != 0) - return -1; - skip_bits(&s->gb, 11); - apt = get_bits(&s->gb, 3); /* apt */ - - get_bits(&s->gb, 1); /* tf1 */ - skip_bits(&s->gb, 4); - get_bits(&s->gb, 3); /* ap1 */ - - get_bits(&s->gb, 1); /* tf2 */ - skip_bits(&s->gb, 4); - get_bits(&s->gb, 3); /* ap2 */ - - get_bits(&s->gb, 1); /* tf3 */ - skip_bits(&s->gb, 4); - get_bits(&s->gb, 3); /* ap3 */ - - /* init size */ - width = 720; - if (dsf) { - avctx->frame_rate = 25; - avctx->frame_rate_base = 1; - packet_size = PAL_FRAME_SIZE; - height = 576; - nb_dif_segs = 12; - } else { - avctx->frame_rate = 30000; - avctx->frame_rate_base = 1001; - packet_size = NTSC_FRAME_SIZE; - height = 480; - nb_dif_segs = 10; - } - /* NOTE: we only accept several full frames */ - if (buf_size < packet_size) - return -1; - - /* NTSC[dsf == 0] is always 720x480, 4:1:1 - * PAL[dsf == 1] is always 720x576, 4:2:0 for IEC 68134[apt == 0] - * but for the SMPTE 314M[apt == 1] it is 720x576, 4:1:1 - */ - s->sampling_411 = !dsf || apt; - if (s->sampling_411) { - mb_pos_ptr = dsf ? dv_place_411P : dv_place_411; - avctx->pix_fmt = PIX_FMT_YUV411P; - } else { - mb_pos_ptr = dv_place_420; - avctx->pix_fmt = PIX_FMT_YUV420P; - } - - avctx->width = width; - avctx->height = height; - - /* Once again, this is pretty complicated by the fact that the same - * field is used differently by IEC 68134[apt == 0] and - * SMPTE 314M[apt == 1]. - */ - if (buf[VAUX_TC61_OFFSET] == 0x61 && - ((apt == 0 && (buf[VAUX_TC61_OFFSET + 2] & 0x07) == 0x07) || - (apt == 1 && (buf[VAUX_TC61_OFFSET + 2] & 0x07) == 0x02))) - avctx->aspect_ratio = 16.0 / 9.0; - else - avctx->aspect_ratio = 4.0 / 3.0; - - if(s->picture.data[0]) - avctx->release_buffer(avctx, &s->picture); - - s->picture.reference= 0; - if(avctx->get_buffer(avctx, &s->picture) < 0) { - fprintf(stderr, "get_buffer() failed\n"); - return -1; - } - - for(i=0;i<3;i++) { - s->current_picture[i] = s->picture.data[i]; - s->linesize[i] = s->picture.linesize[i]; - if (!s->current_picture[i]) - return -1; - } - s->width = width; - s->height = height; - - /* for each DIF segment */ - buf_ptr = buf; - for (ds = 0; ds < nb_dif_segs; ds++) { - buf_ptr += 6 * 80; /* skip DIF segment header */ - - for(vs = 0; vs < 27; vs++) { - if ((vs % 3) == 0) { - /* skip audio block */ - buf_ptr += 80; - } - dv_decode_video_segment(s, buf_ptr, mb_pos_ptr); - buf_ptr += 5 * 80; - mb_pos_ptr += 5; - } - } - - emms_c(); - - /* return image */ - *data_size = sizeof(AVFrame); - *(AVFrame*)data= s->picture; - - return packet_size; -} - -static int dvvideo_decode_end(AVCodecContext *avctx) -{ - avcodec_default_free_buffers(avctx); - - return 0; -} - -AVCodec dvvideo_decoder = { - "dvvideo", - CODEC_TYPE_VIDEO, - CODEC_ID_DVVIDEO, - sizeof(DVVideoDecodeContext), - dvvideo_decode_init, - NULL, - dvvideo_decode_end, - dvvideo_decode_frame, - CODEC_CAP_DR1, - NULL -}; - -typedef struct DVAudioDecodeContext { - AVCodecContext *avctx; - GetBitContext gb; -} DVAudioDecodeContext; - -static int dvaudio_decode_init(AVCodecContext *avctx) -{ - // DVAudioDecodeContext *s = avctx->priv_data; - return 0; -} - -static uint16_t dv_audio_12to16(uint16_t sample) -{ - uint16_t shift, result; - - sample = (sample < 0x800) ? sample : sample | 0xf000; - shift = (sample & 0xf00) >> 8; - - if (shift < 0x2 || shift > 0xd) { - result = sample; - } else if (shift < 0x8) { - shift--; - result = (sample - (256 * shift)) << shift; - } else { - shift = 0xe - shift; - result = ((sample + ((256 * shift) + 1)) << shift) - 1; - } - - return result; -} - -/* NOTE: exactly one frame must be given (120000 bytes for NTSC, - 144000 bytes for PAL) - - There's a couple of assumptions being made here: - 1. By default we silence erroneous (0x8000/16bit 0x800/12bit) - audio samples. We can pass them upwards when ffmpeg will be ready - to deal with them. - 2. We don't do software emphasis. - 3. Audio is always returned as 16bit linear samples: 12bit - nonlinear samples are converted into 16bit linear ones. -*/ -static int dvaudio_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - DVVideoDecodeContext *s = avctx->priv_data; - const uint16_t (*unshuffle)[9]; - int smpls, freq, quant, sys, stride, difseg, ad, dp, nb_dif_segs, i; - uint16_t lc, rc; - uint8_t *buf_ptr; - - /* parse id */ - init_get_bits(&s->gb, &buf[AAUX_AS_OFFSET], 5*8); - i = get_bits(&s->gb, 8); - if (i != 0x50) { /* No audio ? */ - *data_size = 0; - return buf_size; - } - - get_bits(&s->gb, 1); /* 0 - locked audio, 1 - unlocked audio */ - skip_bits(&s->gb, 1); - smpls = get_bits(&s->gb, 6); /* samples in this frame - min. samples */ - - skip_bits(&s->gb, 8); - - skip_bits(&s->gb, 2); - sys = get_bits(&s->gb, 1); /* 0 - 60 fields, 1 = 50 fields */ - skip_bits(&s->gb, 5); - - get_bits(&s->gb, 1); /* 0 - emphasis on, 1 - emphasis off */ - get_bits(&s->gb, 1); /* 0 - reserved, 1 - emphasis time constant 50/15us */ - freq = get_bits(&s->gb, 3); /* 0 - 48KHz, 1 - 44,1kHz, 2 - 32 kHz */ - quant = get_bits(&s->gb, 3); /* 0 - 16bit linear, 1 - 12bit nonlinear */ - - if (quant > 1) - return -1; /* Unsupported quantization */ - - avctx->sample_rate = dv_audio_frequency[freq]; - avctx->channels = 2; - avctx->bit_rate = avctx->channels * avctx->sample_rate * 16; - // What about: - // avctx->frame_size = - - *data_size = (dv_audio_min_samples[sys][freq] + smpls) * - avctx->channels * 2; - - if (sys) { - nb_dif_segs = 12; - stride = 108; - unshuffle = dv_place_audio50; - } else { - nb_dif_segs = 10; - stride = 90; - unshuffle = dv_place_audio60; - } - - /* for each DIF segment */ - buf_ptr = buf; - for (difseg = 0; difseg < nb_dif_segs; difseg++) { - buf_ptr += 6 * 80; /* skip DIF segment header */ - for (ad = 0; ad < 9; ad++) { - - for (dp = 8; dp < 80; dp+=2) { - if (quant == 0) { /* 16bit quantization */ - i = unshuffle[difseg][ad] + (dp - 8)/2 * stride; - ((short *)data)[i] = (buf_ptr[dp] << 8) | buf_ptr[dp+1]; - if (((unsigned short *)data)[i] == 0x8000) - ((short *)data)[i] = 0; - } else { /* 12bit quantization */ - if (difseg >= nb_dif_segs/2) - goto out; /* We're not doing 4ch at this time */ - - lc = ((uint16_t)buf_ptr[dp] << 4) | - ((uint16_t)buf_ptr[dp+2] >> 4); - rc = ((uint16_t)buf_ptr[dp+1] << 4) | - ((uint16_t)buf_ptr[dp+2] & 0x0f); - lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc)); - rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc)); - - i = unshuffle[difseg][ad] + (dp - 8)/3 * stride; - ((short *)data)[i] = lc; - i = unshuffle[difseg+nb_dif_segs/2][ad] + (dp - 8)/3 * stride; - ((short *)data)[i] = rc; - ++dp; - } - } - - buf_ptr += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */ - } - } - -out: - return buf_size; -} - -static int dvaudio_decode_end(AVCodecContext *avctx) -{ - // DVAudioDecodeContext *s = avctx->priv_data; - return 0; -} - -AVCodec dvaudio_decoder = { - "dvaudio", - CODEC_TYPE_AUDIO, - CODEC_ID_DVAUDIO, - sizeof(DVAudioDecodeContext), - dvaudio_decode_init, - NULL, - dvaudio_decode_end, - dvaudio_decode_frame, - 0, - NULL -}; diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dvdata.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dvdata.h deleted file mode 100644 index bab6913..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/dvdata.h +++ /dev/null @@ -1,1280 +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. - */ - -#define NB_DV_VLC 409 -#define AAUX_AS_OFFSET (80*6 + 80*16*3 + 3) -#define AAUX_ASC_OFFSET (80*6 + 80*16*4 + 3) -#define VAUX_TC61_OFFSET (80*5 + 48 + 5) - -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, - 0, -}; - -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, -}; - -/* Specific zigzag scan for 248 idct. NOTE that unlike the - specification, we interleave the fields */ -static const uint8_t dv_248_zigzag[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, -}; - -/* 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 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_place_audio60[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_place_audio50[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 int dv_audio_frequency[3] = { - 48000, 44100, 32000, -}; - -static const int dv_audio_min_samples[2][3] = { - { 1580, 1452, 1053 }, /* 60 fields */ - { 1896, 1742, 1264 }, /* 50 fileds */ -}; diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/error_resilience.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/error_resilience.c deleted file mode 100644 index 5ac2190..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/error_resilience.c +++ /dev/null @@ -1,1007 +0,0 @@ -/* - * Error resilience / concealment - * - * 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 - */ - -/** - * @file error_resilience.c - * Error resilience / concealment. - */ - -#include - -#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+1 + (i&1) + (mb_y*2+1 + (i>>1))*(s->mb_width*2+2)]; - 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+1 + (mb_y+1)*(s->mb_width+2)]; - dcv = s->dc_val[2][mb_x+1 + (mb_y+1)*(s->mb_width+2)]; - 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>16; - prev_dc= data[x + y*stride]; - data[x + y*stride]= dc; - } - } - - /* vertical filter */ - for(x=1; x>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>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>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>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_yerror_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->motion_val[s->block_wrap[0]*((b_y<<(1-is_luma)) + 1) + ( b_x <<(1-is_luma))]; - int16_t *right_mv= s->motion_val[s->block_wrap[0]*((b_y<<(1-is_luma)) + 1) + ((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_yerror_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->motion_val[s->block_wrap[0]*(( b_y <<(1-is_luma)) + 1) + (b_x<<(1-is_luma))]; - int16_t *bottom_mv= s->motion_val[s->block_wrap[0]*(((b_y+1)<<(1-is_luma)) + 1) + (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; imb_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_ymb_height; mb_y++){ - for(mb_x=0; mb_xmb_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_skiped=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_ymb_height; mb_y++){ - for(mb_x=0; mb_xmb_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= mb_width*2+2; - const int mot_index= mb_x*2 + 1 + (mb_y*2+1)*mot_stride; - int prev_x= s->motion_val[mot_index][0]; - int prev_y= s->motion_val[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+10 && fixed[mb_xy-mb_stride]==MV_FROZEN) j=1; - if(mb_y+10 && fixed[mb_xy-1 ]==MV_CHANGED) j=1; - if(mb_x+10 && fixed[mb_xy-mb_stride]==MV_CHANGED) j=1; - if(mb_y+11) continue; - - none_left=0; - - if(mb_x>0 && fixed[mb_xy-1]){ - mv_predictor[pred_count][0]= s->motion_val[mot_index - 2][0]; - mv_predictor[pred_count][1]= s->motion_val[mot_index - 2][1]; - pred_count++; - } - if(mb_x+1motion_val[mot_index + 2][0]; - mv_predictor[pred_count][1]= s->motion_val[mot_index + 2][1]; - pred_count++; - } - if(mb_y>0 && fixed[mb_xy-mb_stride]){ - mv_predictor[pred_count][0]= s->motion_val[mot_index - mot_stride*2][0]; - mv_predictor[pred_count][1]= s->motion_val[mot_index - mot_stride*2][1]; - pred_count++; - } - if(mb_y+1motion_val[mot_index + mot_stride*2][0]; - mv_predictor[pred_count][1]= s->motion_val[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=3){ - min_y= min_x= 99999; - max_y= max_x=-99999; - }else{ - min_x=min_y=max_x=max_y=0; - } - for(j=0; jmotion_val[mot_index][0]; - mv_predictor[pred_count][1]= s->motion_val[mot_index][1]; - pred_count++; - - s->mv_dir = MV_DIR_FORWARD; - s->mb_intra=0; - s->mv_type = MV_TYPE_16X16; - s->mb_skiped=0; - - s->dsp.clear_blocks(s->block[0]); - - s->mb_x= mb_x; - s->mb_y= mb_y; - - for(j=0; jcurrent_picture.data[0] + mb_x*16 + mb_y*16*s->linesize; - - s->motion_val[mot_index][0]= s->mv[0][0][0]= mv_predictor[j][0]; - s->motion_val[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+1linesize+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+1linesize*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->motion_val[mot_index][0] explicit - s->motion_val[mot_index][0]= s->mv[0][0][0]= mv_predictor[best_pred][0]; - s->motion_val[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; imb_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; imb_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_ymb_height-1; mb_y++){ - for(mb_x= 0; mb_xmb_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.pix_abs16x16(last_mb_ptr, mb_ptr , s->linesize); - is_intra_likely -= s->dsp.pix_abs16x16(last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize); - }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; ierror_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){ - 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; - int distance; - int threshold_part[4]= {100,100,100}; - int threshold= 50; - int is_intra_likely; - - if(!s->error_resilience || s->error_count==0) return; - - fprintf(stderr, "concealing errors\n"); - - if(s->motion_val == NULL){ - int size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); - - fprintf(stderr, "Warning MVs not available\n"); - - s->motion_val= av_mallocz(size * 2 * sizeof(int16_t)); - } - - if(s->avctx->debug&FF_DEBUG_ER){ - for(mb_y=0; mb_ymb_height; mb_y++){ - for(mb_x=0; mb_xmb_width; mb_x++){ - int status= s->error_status_table[mb_x + mb_y*s->mb_stride]; - - printf("%2X ", status); - } - printf("\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_status_table[mb_xy]|= 1<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<partitioned_frame){ - if(distance < threshold_part[error_type-1]) - s->error_status_table[mb_xy]|= 1<error_status_table[mb_xy]|= 1<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; imb_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 - is_intra_likely= is_intra_more_likely(s); - - /* set unknown mb-type to most likely */ - for(i=0; imb_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_ymb_height; mb_y++){ - for(mb_x=0; mb_xmb_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_skiped=0; - if(IS_8X8(mb_type)){ - int mb_index= mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0]; - int j; - s->mv_type = MV_TYPE_8X8; - for(j=0; j<4; j++){ - s->mv[0][j][0] = s->motion_val[ mb_index + (j&1) + (j>>1)*s->block_wrap[0] ][0]; - s->mv[0][j][1] = s->motion_val[ mb_index + (j&1) + (j>>1)*s->block_wrap[0] ][1]; - } - }else{ - s->mv_type = MV_TYPE_16X16; - s->mv[0][0][0] = s->motion_val[ mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0] ][0]; - s->mv[0][0][1] = s->motion_val[ mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0] ][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_ymb_height; mb_y++){ - for(mb_x=0; mb_xmb_width; mb_x++){ - int xy= mb_x*2+1 + (mb_y*2+1)*s->block_wrap[0]; - 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_skiped=0; - - if(s->pp_time){ - int time_pp= s->pp_time; - int time_pb= s->pb_time; - - s->mv[0][0][0] = s->motion_val[xy][0]*time_pb/time_pp; - s->mv[0][0][1] = s->motion_val[xy][1]*time_pb/time_pp; - s->mv[1][0][0] = s->motion_val[xy][0]*(time_pb - time_pp)/time_pp; - s->mv[1][0][1] = s->motion_val[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_ymb_height; mb_y++){ - for(mb_x=0; mb_xmb_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+1 + (mb_y*2+1)*(s->mb_width*2+2)]; - 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->mb_width*2+2)]= (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+1 + (mb_y+1)*(s->mb_width+2)]= (dcu+4)>>3; - s->dc_val[2][mb_x+1 + (mb_y+1)*(s->mb_width+2)]= (dcv+4)>>3; - } - } -#if 1 - /* guess DC for damaged blocks */ - guess_dc(s, s->dc_val[0] + s->mb_width*2+3, s->mb_width*2, s->mb_height*2, s->mb_width*2+2, 1); - guess_dc(s, s->dc_val[1] + s->mb_width +3, s->mb_width , s->mb_height , s->mb_width +2, 0); - guess_dc(s, s->dc_val[2] + s->mb_width +3, s->mb_width , s->mb_height , s->mb_width +2, 0); -#endif - /* filter luma DC */ - filter181(s->dc_val[0] + s->mb_width*2+3, s->mb_width*2, s->mb_height*2, s->mb_width*2+2); - -#if 1 - /* render DC only intra */ - for(mb_y=0; mb_ymb_height; mb_y++){ - for(mb_x=0; mb_xmb_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; imb_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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/eval.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/eval.c deleted file mode 100644 index 28a492c..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/eval.c +++ /dev/null @@ -1,255 +0,0 @@ -/* - * simple arithmetic expression evaluator - * - * 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 - * - */ - -/** - * @file eval.c - * simple arithmetic expression evaluator. - * - * see http://joe.hotchkiss.com/programming/eval/eval.html - */ - -#include "avcodec.h" -#include "mpegvideo.h" - -#include -#include -#include -#include - -#ifndef NAN - #define NAN 0 -#endif - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#define STACK_SIZE 100 - -typedef struct Parser{ - double stack[STACK_SIZE]; - 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 void evalExpression(Parser *p); - -static void push(Parser *p, double d){ - if(p->stack_index+1>= STACK_SIZE){ - fprintf(stderr, "stack overflow in the parser\n"); - return; - } - p->stack[ p->stack_index++ ]= d; -//printf("push %f\n", d); fflush(stdout); -} - -static double pop(Parser *p){ - if(p->stack_index<=0){ - fprintf(stderr, "stack underflow in the parser\n"); - return NAN; - } -//printf("pop\n"); fflush(stdout); - return p->stack[ --p->stack_index ]; -} - -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 void evalPrimary(Parser *p){ - double d, d2=NAN; - char *next= p->s; - int i; - - /* number */ - d= strtod(p->s, &next); - if(next != p->s){ - push(p, d); - p->s= next; - return; - } - - /* named constants */ - for(i=0; p->const_name[i]; i++){ - if(strmatch(p->s, p->const_name[i])){ - push(p, p->const_value[i]); - p->s+= strlen(p->const_name[i]); - return; - } - } - - p->s= strchr(p->s, '('); - if(p->s==NULL){ - fprintf(stderr, "Parser: missing ( in \"%s\"\n", next); - return; - } - p->s++; // "(" - evalExpression(p); - d= pop(p); - p->s++; // ")" or "," - if(p->s[-1]== ','){ - evalExpression(p); - d2= pop(p); - 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, "lt" ) ) d= d > d2 ? 0.0 : 1.0; - else if( strmatch(next, "eq" ) ) d= d == d2 ? 1.0 : 0.0; -// 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{ - int error=1; - for(i=0; p->func1_name && p->func1_name[i]; i++){ - if(strmatch(next, p->func1_name[i])){ - d= p->func1[i](p->opaque, d); - error=0; - break; - } - } - - for(i=0; p->func2_name && p->func2_name[i]; i++){ - if(strmatch(next, p->func2_name[i])){ - d= p->func2[i](p->opaque, d, d2); - error=0; - break; - } - } - - if(error){ - fprintf(stderr, "Parser: unknown function in \"%s\"\n", next); - return; - } - } - - if(p->s[-1]!= ')'){ - fprintf(stderr, "Parser: missing ) in \"%s\"\n", next); - return; - } - push(p, d); -} - -static void evalPow(Parser *p){ - int neg= 0; - if(p->s[0]=='+') p->s++; - - if(p->s[0]=='-'){ - neg= 1; - p->s++; - } - - if(p->s[0]=='('){ - p->s++;; - evalExpression(p); - - if(p->s[0]!=')') - fprintf(stderr, "Parser: missing )\n"); - p->s++; - }else{ - evalPrimary(p); - } - - if(neg) push(p, -pop(p)); -} - -static void evalFactor(Parser *p){ - evalPow(p); - while(p->s[0]=='^'){ - double d; - - p->s++; - evalPow(p); - d= pop(p); - push(p, pow(pop(p), d)); - } -} - -static void evalTerm(Parser *p){ - evalFactor(p); - while(p->s[0]=='*' || p->s[0]=='/'){ - int inv= p->s[0]=='/'; - double d; - - p->s++; - evalFactor(p); - d= pop(p); - if(inv) d= 1.0/d; - push(p, d * pop(p)); - } -} - -static void evalExpression(Parser *p){ - evalTerm(p); - while(p->s[0]=='+' || p->s[0]=='-'){ - int sign= p->s[0]=='-'; - double d; - - p->s++; - evalTerm(p); - d= pop(p); - if(sign) d= -d; - push(p, d + pop(p)); - } -} - -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=0; - 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; - - evalExpression(&p); - return pop(&p); -} diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/faad.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/faad.c deleted file mode 100644 index 6dfffd8..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/faad.c +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Faad decoder - * Copyright (c) 2003 Zdenek Kabelac. - * - * 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 faad.c - * AAC decoder. - * - * still a bit unfinished - but it plays something - */ - -#include "avcodec.h" -#include "faad.h" - -/* - * when CONFIG_FAADBIN is defined the libfaad will be opened at runtime - */ -//#undef CONFIG_FAADBIN -//#define CONFIG_FAADBIN - -#ifdef CONFIG_FAADBIN -#include -static const char* libfaadname = "libfaad.so.0"; -#else -#define dlopen(a) -#define dlclose(a) -#endif - -typedef struct { - void* handle; /* dlopen handle */ - void* faac_handle; /* FAAD library handle */ - int frame_size; - int sample_size; - int flags; - - /* faad calls */ - faacDecHandle FAADAPI (*faacDecOpen)(void); - faacDecConfigurationPtr FAADAPI (*faacDecGetCurrentConfiguration)(faacDecHandle hDecoder); - unsigned char FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder, - faacDecConfigurationPtr config); - long FAADAPI (*faacDecInit)(faacDecHandle hDecoder, - unsigned char *buffer, - unsigned long *samplerate, - unsigned char *channels); - char FAADAPI (*faacDecInit2)(faacDecHandle hDecoder, unsigned char *pBuffer, - unsigned long SizeOfDecoderSpecificInfo, - unsigned long *samplerate, unsigned char *channels); - void FAADAPI (*faacDecClose)(faacDecHandle hDecoder); - void* FAADAPI (*faacDecDecode)(faacDecHandle hDecoder, - faacDecFrameInfo *hInfo, - unsigned char *buffer); - unsigned char* FAADAPI (*faacDecGetErrorMessage)(unsigned char errcode); -} FAACContext; - -static const unsigned long faac_srates[] = -{ - 96000, 88200, 64000, 48000, 44100, 32000, - 24000, 22050, 16000, 12000, 11025, 8000 -}; - -static int faac_init_mp4(AVCodecContext *avctx) -{ - FAACContext *s = (FAACContext *) avctx->priv_data; - unsigned long samplerate; - unsigned char channels; - int r = 0; - - if (avctx->extradata) - r = s->faacDecInit2(s->faac_handle, (uint8_t*) avctx->extradata, - avctx->extradata_size, - &samplerate, &channels); - // else r = s->faacDecInit(s->faac_handle ... ); - - if (r < 0) - fprintf(stderr, "faacDecInit2 failed r:%d sr:%ld ch:%d s:%d\n", - r, samplerate, channels, avctx->extradata_size); - - return r; -} - -static int faac_init_aac(AVCodecContext *avctx) -{ - FAACContext *s = (FAACContext *) avctx->priv_data; - return 0; -} - -static int faac_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - FAACContext *s = (FAACContext *) avctx->priv_data; - faacDecFrameInfo frame_info; - void* out = s->faacDecDecode(s->faac_handle, &frame_info, (unsigned char*)buf); - //printf("DECODE FRAME %d, %d, %d - %p\n", buf_size, frame_info.samples, frame_info.bytesconsumed, out); - - if (frame_info.error > 0) { - fprintf(stderr, "faac: frame decodinf failed: %s\n", - s->faacDecGetErrorMessage(frame_info.error)); - return 0; - } - - frame_info.samples *= s->sample_size; - memcpy(data, out, frame_info.samples); // CHECKME - can we cheat this one - - if (data_size) - *data_size = frame_info.samples; - - return (buf_size < (int)frame_info.bytesconsumed) - ? buf_size : (int)frame_info.bytesconsumed; -} - -static int faac_decode_end(AVCodecContext *avctx) -{ - FAACContext *s = (FAACContext *) avctx->priv_data; - - if (s->faacDecClose) - s->faacDecClose(s->faac_handle); - - dlclose(s->handle); - return 0; -} - -static int faac_decode_init(AVCodecContext *avctx) -{ - FAACContext *s = (FAACContext *) avctx->priv_data; - faacDecConfigurationPtr faac_cfg; - -#ifdef CONFIG_FAADBIN - const char* err = 0; - - s->handle = dlopen(libfaadname, RTLD_LAZY); - if (!s->handle) - { - fprintf(stderr, "FAAD library: %s could not be opened! \n%s\n", - libfaadname, dlerror()); - return -1; - } -#define dfaac(a, b) \ - do { static const char* n = "faacDec" #a; \ - if ((s->faacDec ## a = b dlsym( s->handle, n )) == NULL) { err = n; break; } } while(0) - for(;;) { -#else /* !CONFIG_FAADBIN */ -#define dfaac(a, b) s->faacDec ## a = faacDec ## a -#endif /* CONFIG_FAADBIN */ - - // resolve all needed function calls - dfaac(Open, (faacDecHandle FAADAPI (*)(void))); - dfaac(GetCurrentConfiguration, (faacDecConfigurationPtr - FAADAPI (*)(faacDecHandle))); - dfaac(SetConfiguration, (unsigned char FAADAPI (*)(faacDecHandle, - faacDecConfigurationPtr))); - - dfaac(Init, (long FAADAPI (*)(faacDecHandle, unsigned char*, - unsigned long*, unsigned char*))); - dfaac(Init2, (char FAADAPI (*)(faacDecHandle, unsigned char*, - unsigned long, unsigned long*, - unsigned char*))); - dfaac(Close, (void FAADAPI (*)(faacDecHandle hDecoder))); - dfaac(Decode, (void* FAADAPI (*)(faacDecHandle, faacDecFrameInfo*, - unsigned char*))); - - dfaac(GetErrorMessage, (unsigned char* FAADAPI (*)(unsigned char))); -#undef dfacc - -#ifdef CONFIG_FAADBIN - break; - } - if (err) { - dlclose(s->handle); - fprintf(stderr, "FAAD library: cannot resolve %s in %s!\n", - err, libfaadname); - return -1; - } -#endif - - s->faac_handle = s->faacDecOpen(); - if (!s->faac_handle) { - fprintf(stderr, "FAAD library: cannot create handler!\n"); - faac_decode_end(avctx); - return -1; - } - - - faac_cfg = s->faacDecGetCurrentConfiguration(s->faac_handle); - - if (faac_cfg) { - switch (avctx->bits_per_sample) { - case 8: fprintf(stderr, "FAADlib unsupported bps %d\n", avctx->bits_per_sample); break; - default: - case 16: - faac_cfg->outputFormat = FAAD_FMT_16BIT; - s->sample_size = 2; - break; - case 24: - faac_cfg->outputFormat = FAAD_FMT_24BIT; - s->sample_size = 3; - break; - case 32: - faac_cfg->outputFormat = FAAD_FMT_32BIT; - s->sample_size = 4; - break; - } - - faac_cfg->defSampleRate = (!avctx->sample_rate) ? 44100 : avctx->sample_rate; - faac_cfg->defObjectType = LC; - } - - s->faacDecSetConfiguration(s->faac_handle, faac_cfg); - - faac_init_mp4(avctx); - - return 0; -} - -#define AAC_CODEC(id, name) \ -AVCodec name ## _decoder = { \ - #name, \ - CODEC_TYPE_AUDIO, \ - id, \ - sizeof(FAACContext), \ - faac_decode_init, \ - NULL, \ - faac_decode_end, \ - faac_decode_frame, \ -} - -// FIXME - raw AAC files - maybe just one entry will be enough -AAC_CODEC(CODEC_ID_AAC, aac); -// If it's mp4 file - usually embeded into Qt Mov -AAC_CODEC(CODEC_ID_MPEG4AAC, mpeg4aac); - -#undef AAC_CODEC diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fastmemcpy.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fastmemcpy.h deleted file mode 100644 index 2a6f5c8..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fastmemcpy.h +++ /dev/null @@ -1 +0,0 @@ -#include "../libvo/fastmemcpy.h" diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fdctref.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fdctref.c deleted file mode 100644 index d728727..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fdctref.c +++ /dev/null @@ -1,158 +0,0 @@ -/** - * @file fdctref.c - * forward discrete cosine transform, double precision. - */ - -/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ - -/* - * Disclaimer of Warranty - * - * These software programs are available to the user without any license fee or - * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims - * any and all warranties, whether express, implied, or statuary, including any - * implied warranties or merchantability or of fitness for a particular - * purpose. In no event shall the copyright-holder be liable for any - * incidental, punitive, or consequential damages of any kind whatsoever - * arising from the use of these programs. - * - * This disclaimer of warranty extends to the user of these programs and user's - * customers, employees, agents, transferees, successors, and assigns. - * - * The MPEG Software Simulation Group does not represent or warrant that the - * programs furnished hereunder are free of infringement of any third-party - * patents. - * - * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, - * are subject to royalty fees to patent holders. Many of these patents are - * general enough such that they are unavoidable regardless of implementation - * design. - * - */ - -#include - -#ifndef PI -# ifdef M_PI -# define PI M_PI -# else -# define PI 3.14159265358979323846 -# endif -#endif - -/* global declarations */ -void init_fdct (void); -void fdct (short *block); - -/* private data */ -static double c[8][8]; /* transform coefficients */ - -void init_fdct() -{ - int i, j; - double s; - - for (i=0; i<8; i++) - { - s = (i==0) ? sqrt(0.125) : 0.5; - - for (j=0; j<8; j++) - c[i][j] = s * cos((PI/8.0)*i*(j+0.5)); - } -} - -void fdct(block) -short *block; -{ - register int i, j; - double s; - double tmp[64]; - - for(i = 0; i < 8; i++) - for(j = 0; j < 8; j++) - { - s = 0.0; - -/* - * for(k = 0; k < 8; k++) - * s += c[j][k] * block[8 * i + k]; - */ - s += c[j][0] * block[8 * i + 0]; - s += c[j][1] * block[8 * i + 1]; - s += c[j][2] * block[8 * i + 2]; - s += c[j][3] * block[8 * i + 3]; - s += c[j][4] * block[8 * i + 4]; - s += c[j][5] * block[8 * i + 5]; - s += c[j][6] * block[8 * i + 6]; - s += c[j][7] * block[8 * i + 7]; - - tmp[8 * i + j] = s; - } - - for(j = 0; j < 8; j++) - for(i = 0; i < 8; i++) - { - s = 0.0; - -/* - * for(k = 0; k < 8; k++) - * s += c[i][k] * tmp[8 * k + j]; - */ - s += c[i][0] * tmp[8 * 0 + j]; - s += c[i][1] * tmp[8 * 1 + j]; - s += c[i][2] * tmp[8 * 2 + j]; - s += c[i][3] * tmp[8 * 3 + j]; - s += c[i][4] * tmp[8 * 4 + j]; - s += c[i][5] * tmp[8 * 5 + j]; - s += c[i][6] * tmp[8 * 6 + j]; - s += c[i][7] * tmp[8 * 7 + j]; - s*=8.0; - - block[8 * i + j] = (short)floor(s + 0.499999); -/* - * reason for adding 0.499999 instead of 0.5: - * s is quite often x.5 (at least for i and/or j = 0 or 4) - * and setting the rounding threshold exactly to 0.5 leads to an - * extremely high arithmetic implementation dependency of the result; - * s being between x.5 and x.500001 (which is now incorrectly rounded - * downwards instead of upwards) is assumed to occur less often - * (if at all) - */ - } -} - -/* perform IDCT matrix multiply for 8x8 coefficient block */ - -void idct(block) -short *block; -{ - int i, j, k, v; - double partial_product; - double tmp[64]; - - for (i=0; i<8; i++) - for (j=0; j<8; j++) - { - partial_product = 0.0; - - for (k=0; k<8; k++) - partial_product+= c[k][j]*block[8*i+k]; - - tmp[8*i+j] = partial_product; - } - - /* Transpose operation is integrated into address mapping by switching - loop order of i and j */ - - for (j=0; j<8; j++) - for (i=0; i<8; i++) - { - partial_product = 0.0; - - for (k=0; k<8; k++) - partial_product+= c[k][i]*tmp[8*k+j]; - - v = (int) floor(partial_product+0.5); - block[8*i+j] = v; - } -} diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fft-test.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fft-test.c deleted file mode 100644 index 4a3ac9f..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fft-test.c +++ /dev/null @@ -1,277 +0,0 @@ -/** - * @file fft-test.c - * FFT and MDCT tests. - */ - -#include "dsputil.h" -#include -#include -#include - -int mm_flags; - -/* reference fft */ - -#define MUL16(a,b) ((a) * (b)) - -#define CMAC(pre, pim, are, aim, bre, bim) \ -{\ - pre += (MUL16(are, bre) - MUL16(aim, bim));\ - pim += (MUL16(are, bim) + MUL16(bre, aim));\ -} - -FFTComplex *exptab; - -void fft_ref_init(int nbits, int inverse) -{ - int n, i; - float c1, s1, alpha; - - n = 1 << nbits; - exptab = av_malloc((n / 2) * sizeof(FFTComplex)); - - for(i=0;i<(n/2);i++) { - alpha = 2 * M_PI * (float)i / (float)n; - c1 = cos(alpha); - s1 = sin(alpha); - if (!inverse) - s1 = -s1; - exptab[i].re = c1; - exptab[i].im = s1; - } -} - -void fft_ref(FFTComplex *tabr, FFTComplex *tab, int nbits) -{ - int n, i, j, k, n2; - float tmp_re, tmp_im, s, c; - FFTComplex *q; - - n = 1 << nbits; - n2 = n >> 1; - for(i=0;i= n2) { - c = -exptab[k - n2].re; - s = -exptab[k - n2].im; - } else { - c = exptab[k].re; - s = exptab[k].im; - } - CMAC(tmp_re, tmp_im, c, s, q->re, q->im); - q++; - } - tabr[i].re = tmp_re; - tabr[i].im = tmp_im; - } -} - -void imdct_ref(float *out, float *in, int n) -{ - int k, i, a; - float sum, f; - - for(i=0;i= 1e-3) { - printf("ERROR %d: %f %f\n", - i, tab1[i], tab2[i]); - } - } -} - - -void help(void) -{ - printf("usage: fft-test [-h] [-s] [-i] [-n b]\n" - "-h print this help\n" - "-s speed test\n" - "-m (I)MDCT test\n" - "-i inverse transform test\n" - "-n b set the transform size to 2^b\n" - ); - exit(1); -} - - - -int main(int argc, char **argv) -{ - FFTComplex *tab, *tab1, *tab_ref; - FFTSample *tabtmp, *tab2; - int it, i, c; - int do_speed = 0; - int do_mdct = 0; - int do_inverse = 0; - FFTContext s1, *s = &s1; - MDCTContext m1, *m = &m1; - int fft_nbits, fft_size; - - mm_flags = 0; - fft_nbits = 9; - for(;;) { - c = getopt(argc, argv, "hsimn:"); - if (c == -1) - break; - switch(c) { - case 'h': - help(); - break; - case 's': - do_speed = 1; - break; - case 'i': - do_inverse = 1; - break; - case 'm': - do_mdct = 1; - break; - case 'n': - fft_nbits = atoi(optarg); - break; - } - } - - fft_size = 1 << fft_nbits; - tab = av_malloc(fft_size * sizeof(FFTComplex)); - tab1 = av_malloc(fft_size * sizeof(FFTComplex)); - tab_ref = av_malloc(fft_size * sizeof(FFTComplex)); - tabtmp = av_malloc(fft_size / 2 * sizeof(FFTSample)); - tab2 = av_malloc(fft_size * sizeof(FFTSample)); - - if (do_mdct) { - if (do_inverse) - printf("IMDCT"); - else - printf("MDCT"); - ff_mdct_init(m, fft_nbits, do_inverse); - } else { - if (do_inverse) - printf("IFFT"); - else - printf("FFT"); - fft_init(s, fft_nbits, do_inverse); - fft_ref_init(fft_nbits, do_inverse); - } - printf(" %d test\n", fft_size); - - /* generate random data */ - - for(i=0;i= 1000000) - break; - nb_its *= 2; - } - printf("time: %0.1f us/transform [total time=%0.2f s its=%d]\n", - (double)duration / nb_its, - (double)duration / 1000000.0, - nb_its); - } - - if (do_mdct) { - ff_mdct_end(m); - } else { - fft_end(s); - } - return 0; -} diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fft.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/fft.c deleted file mode 100644 index 3b5244a..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/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 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 = 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 = fft_calc_sse; -#else - s->fft_calc = fft_calc_altivec; -#endif - } - } -#endif - - /* compute bit reverse table */ - - for(i=0;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 fft_init(). The - * input data must be permuted before with s->revtab table. No - * 1.0/sqrt(n) normalization is done. - */ -void 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 fft_calc() - */ -void 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;jrevtab); - av_freep(&s->exptab); - av_freep(&s->exptab1); -} - diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ffv1.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ffv1.c deleted file mode 100644 index c8520a4..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/ffv1.c +++ /dev/null @@ -1,940 +0,0 @@ -/* - * FFV1 codec for libavcodec - * - * 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 - * - */ - -/** - * @file ffv1.c - * FF Video Codec 1 (a experimental lossless codec) - */ - -#include "common.h" -#include "avcodec.h" -#include "dsputil.h" -#include "cabac.h" -#include "golomb.h" - -#define MAX_PLANES 4 -#define CONTEXT_SIZE 32 - -static const int8_t quant3[256]={ - 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, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, --1,-1,-1,-1,-1,-1,-1,-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, -}; -static const int8_t quant5[256]={ - 0, 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, 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,-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,-1,-1,-1, -}; -static const int8_t quant7[256]={ - 0, 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, 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,-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,-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,-1,-1, -}; -static const int8_t quant9[256]={ - 0, 1, 1, 2, 2, 2, 2, 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, 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,-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,-3,-3,-3,-3, --3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-2,-1,-1, -}; -static const int8_t quant11[256]={ - 0, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, - 4, 4, 4, 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, 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,-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,-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,-4,-4, --4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4, --4,-4,-4,-4,-4,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-1, -}; -static const int8_t quant13[256]={ - 0, 1, 2, 2, 3, 3, 3, 3, 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, 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, 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,-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,-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, --4,-4,-4,-4,-4,-4,-4,-4,-4,-3,-3,-3,-3,-2,-2,-1, -}; - -static const uint8_t log2_run[32]={ - 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, - 4, 4, 5, 5, 6, 6, 7, 7, - 8, 9,10,11,12,13,14,15, -}; - -typedef struct VlcState{ - int16_t drift; - uint16_t error_sum; - int8_t bias; - uint8_t count; -} VlcState; - -typedef struct PlaneContext{ - int context_count; - uint8_t (*state)[CONTEXT_SIZE]; - VlcState *vlc_state; - uint8_t interlace_bit_state[2]; -} PlaneContext; - -typedef struct FFV1Context{ - AVCodecContext *avctx; - CABACContext c; - GetBitContext gb; - PutBitContext pb; - int version; - int width, height; - int chroma_h_shift, chroma_v_shift; - int flags; - int picture_number; - AVFrame picture; - int plane_count; - int ac; ///< 1-> CABAC 0-> golomb rice - PlaneContext plane[MAX_PLANES]; - int16_t quant_table[5][256]; - - DSPContext dsp; -}FFV1Context; - -static inline int predict(uint8_t *src, uint8_t *last){ - const int LT= last[-1]; - const int T= last[ 0]; - const int L = src[-1]; - - return mid_pred(L, L + T - LT, T); -} - -static inline int get_context(FFV1Context *f, uint8_t *src, uint8_t *last, uint8_t *last2){ - const int LT= last[-1]; - const int T= last[ 0]; - const int RT= last[ 1]; - const int L = src[-1]; - - if(f->quant_table[3][127]){ - const int TT= last2[0]; - const int LL= src[-2]; - return f->quant_table[0][(L-LT) & 0xFF] + f->quant_table[1][(LT-T) & 0xFF] + f->quant_table[2][(T-RT) & 0xFF] - +f->quant_table[3][(LL-L) & 0xFF] + f->quant_table[4][(TT-T) & 0xFF]; - }else - return f->quant_table[0][(L-LT) & 0xFF] + f->quant_table[1][(LT-T) & 0xFF] + f->quant_table[2][(T-RT) & 0xFF]; -} - -/** - * put - */ -static inline void put_symbol(CABACContext *c, uint8_t *state, int v, int is_signed, int max_exp){ - int i; - - if(v){ - const int a= ABS(v); - const int e= av_log2(a); - - put_cabac(c, state+0, 0); - - for(i=0; i=0; i--){ - put_cabac(c, state+16+e+i, (a>>i)&1); //17..29 - } - if(is_signed) - put_cabac(c, state+9 + e, v < 0); //9..16 - } - }else{ - put_cabac(c, state+0, 1); - } -} - -static inline int get_symbol(CABACContext *c, uint8_t *state, int is_signed, int max_exp){ - if(get_cabac(c, state+0)) - return 0; - else{ - int i, e; - - for(e=0; e=0; i--){ - a += get_cabac(c, state+16+e+i)<drift; - int count= state->count; - state->error_sum += ABS(v); - drift += v; - - if(count == 128){ //FIXME variable - count >>= 1; - drift >>= 1; - state->error_sum >>= 1; - } - count++; - - if(drift <= -count){ - if(state->bias > -128) state->bias--; - - drift += count; - if(drift <= -count) - drift= -count + 1; - }else if(drift > 0){ - if(state->bias < 127) state->bias++; - - drift -= count; - if(drift > 0) - drift= 0; - } - - state->drift= drift; - state->count= count; -} - -static inline void put_vlc_symbol(PutBitContext *pb, VlcState * const state, int v){ - int i, k, code; -//printf("final: %d ", v); - v = (int8_t)(v - state->bias); - - i= state->count; - k=0; - while(i < state->error_sum){ //FIXME optimize - k++; - i += i; - } - - assert(k<=8); - -#if 0 // JPEG LS - if(k==0 && 2*state->drift <= - state->count) code= v ^ (-1); - else code= v; -#else - code= v ^ ((2*state->drift + state->count)>>31); -#endif - - code = -2*code-1; - code^= (code>>31); -//printf("v:%d/%d bias:%d error:%d drift:%d count:%d k:%d\n", v, code, state->bias, state->error_sum, state->drift, state->count, k); - set_ur_golomb(pb, code, k, 12, 8); - - update_vlc_state(state, v); -} - -static inline int get_vlc_symbol(GetBitContext *gb, VlcState * const state){ - int k, i, v, ret; - - i= state->count; - k=0; - while(i < state->error_sum){ //FIXME optimize - k++; - i += i; - } - - assert(k<=8); - - v= get_ur_golomb(gb, k, 12, 8); -//printf("v:%d bias:%d error:%d drift:%d count:%d k:%d", v, state->bias, state->error_sum, state->drift, state->count, k); - - v++; - if(v&1) v= (v>>1); - else v= -(v>>1); - -#if 0 // JPEG LS - if(k==0 && 2*state->drift <= - state->count) v ^= (-1); -#else - v ^= ((2*state->drift + state->count)>>31); -#endif - - ret= (int8_t)(v + state->bias); - - update_vlc_state(state, v); -//printf("final: %d\n", ret); - return ret; -} - - - -static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index){ - PlaneContext * const p= &s->plane[plane_index]; - CABACContext * const c= &s->c; - int x,y; - uint8_t sample_buffer[2][w+6]; - uint8_t *sample[2]= {sample_buffer[0]+3, sample_buffer[1]+3}; - int run_index=0; - - memset(sample_buffer, 0, sizeof(sample_buffer)); - - for(y=0; yac){ - put_symbol(c, p->state[context], diff, 1, 7); - }else{ - if(context == 0) run_mode=1; - - if(run_mode){ - - if(diff){ - while(run_count >= 1<pb, 1, 1); - } - - put_bits(&s->pb, 1 + log2_run[run_index], run_count); - if(run_index) run_index--; - run_count=0; - run_mode=0; - if(diff>0) diff--; - }else{ - run_count++; - } - } - -// printf("count:%d index:%d, mode:%d, x:%d y:%d pos:%d\n", run_count, run_index, run_mode, x, y, (int)get_bit_count(&s->pb)); - - if(run_mode == 0) - put_vlc_symbol(&s->pb, &p->vlc_state[context], diff); - } - - sample[1][x]= temp_src[0]; - } - if(run_mode){ - while(run_count >= 1<pb, 1, 1); - } - - if(run_count) - put_bits(&s->pb, 1, 1); - } - } -} - -static void write_quant_table(CABACContext *c, int16_t *quant_table){ - int last=0; - int i; - uint8_t state[CONTEXT_SIZE]={0}; - - for(i=1; i<128 ; i++){ - if(quant_table[i] != quant_table[i-1]){ - put_symbol(c, state, i-last-1, 0, 7); - last= i; - } - } - put_symbol(c, state, i-last-1, 0, 7); -} - -static void write_header(FFV1Context *f){ - uint8_t state[CONTEXT_SIZE]={0}; - int i; - CABACContext * const c= &f->c; - - put_symbol(c, state, f->version, 0, 7); - put_symbol(c, state, f->avctx->coder_type, 0, 7); - put_symbol(c, state, 0, 0, 7); //YUV cs type - put_cabac(c, state, 1); //chroma planes - put_symbol(c, state, f->chroma_h_shift, 0, 7); - put_symbol(c, state, f->chroma_v_shift, 0, 7); - put_cabac(c, state, 0); //no transparency plane - - for(i=0; i<5; i++) - write_quant_table(c, f->quant_table[i]); -} - -static int common_init(AVCodecContext *avctx){ - FFV1Context *s = avctx->priv_data; - int width, height; - - s->avctx= avctx; - s->flags= avctx->flags; - - dsputil_init(&s->dsp, avctx); - - width= s->width= avctx->width; - height= s->height= avctx->height; - - assert(width && height); - - return 0; -} - -static int encode_init(AVCodecContext *avctx) -{ - FFV1Context *s = avctx->priv_data; - int i; - - common_init(avctx); - - s->version=0; - s->ac= avctx->coder_type; - - s->plane_count=2; - for(i=0; i<256; i++){ - s->quant_table[0][i]= quant11[i]; - s->quant_table[1][i]= 11*quant11[i]; - if(avctx->context_model==0){ - s->quant_table[2][i]= 11*11*quant11[i]; - s->quant_table[3][i]= - s->quant_table[4][i]=0; - }else{ - s->quant_table[2][i]= 11*11*quant5 [i]; - s->quant_table[3][i]= 5*11*11*quant5 [i]; - s->quant_table[4][i]= 5*5*11*11*quant5 [i]; - } - } - - for(i=0; iplane_count; i++){ - PlaneContext * const p= &s->plane[i]; - - if(avctx->context_model==0){ - p->context_count= (11*11*11+1)/2; - }else{ - p->context_count= (11*11*5*5*5+1)/2; - } - - if(s->ac){ - if(!p->state) p->state= av_malloc(CONTEXT_SIZE*p->context_count*sizeof(uint8_t)); - }else{ - if(!p->vlc_state) p->vlc_state= av_malloc(p->context_count*sizeof(VlcState)); - } - } - - avctx->coded_frame= &s->picture; - switch(avctx->pix_fmt){ - case PIX_FMT_YUV444P: - case PIX_FMT_YUV422P: - case PIX_FMT_YUV420P: - case PIX_FMT_YUV411P: - case PIX_FMT_YUV410P: - avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_h_shift, &s->chroma_v_shift); - break; - default: - fprintf(stderr, "format not supported\n"); - return -1; - } - - - s->picture_number=0; - - return 0; -} - - -static void clear_state(FFV1Context *f){ - int i, j; - - for(i=0; iplane_count; i++){ - PlaneContext *p= &f->plane[i]; - - p->interlace_bit_state[0]= 0; - p->interlace_bit_state[1]= 0; - - for(j=0; jcontext_count; j++){ - if(f->ac){ - memset(p->state[j], 0, sizeof(uint8_t)*CONTEXT_SIZE); - p->state[j][7] = 2*62; - }else{ - p->vlc_state[j].drift= 0; - p->vlc_state[j].error_sum= 4; //FFMAX((RANGE + 32)/64, 2); - p->vlc_state[j].bias= 0; - p->vlc_state[j].count= 1; - } - } - } -} - -static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ - FFV1Context *f = avctx->priv_data; - CABACContext * const c= &f->c; - AVFrame *pict = data; - const int width= f->width; - const int height= f->height; - AVFrame * const p= &f->picture; - int used_count= 0; - - if(avctx->strict_std_compliance >= 0){ - printf("this codec is under development, files encoded with it wont be decodeable with future versions!!!\n" - "use vstrict=-1 to use it anyway\n"); - return -1; - } - - ff_init_cabac_encoder(c, buf, buf_size); - ff_init_cabac_states(c, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64); - - *p = *pict; - p->pict_type= FF_I_TYPE; - - if(avctx->gop_size==0 || f->picture_number % avctx->gop_size == 0){ - put_cabac_bypass(c, 1); - p->key_frame= 1; - write_header(f); - clear_state(f); - }else{ - put_cabac_bypass(c, 0); - p->key_frame= 0; - } - - if(!f->ac){ - used_count += put_cabac_terminate(c, 1); -//printf("pos=%d\n", used_count); - init_put_bits(&f->pb, buf + used_count, buf_size - used_count, NULL, NULL); - } - - if(1){ - const int chroma_width = -((-width )>>f->chroma_h_shift); - const int chroma_height= -((-height)>>f->chroma_v_shift); - - encode_plane(f, p->data[0], width, height, p->linesize[0], 0); - - encode_plane(f, p->data[1], chroma_width, chroma_height, p->linesize[1], 1); - encode_plane(f, p->data[2], chroma_width, chroma_height, p->linesize[2], 1); - } - emms_c(); - - f->picture_number++; - - if(f->ac){ - return put_cabac_terminate(c, 1); - }else{ - flush_put_bits(&f->pb); //nicer padding FIXME - return used_count + (get_bit_count(&f->pb)+7)/8; - } -} - -static void common_end(FFV1Context *s){ - int i; - - for(i=0; iplane_count; i++){ - PlaneContext *p= &s->plane[i]; - - av_freep(&p->state); - } -} - -static int encode_end(AVCodecContext *avctx) -{ - FFV1Context *s = avctx->priv_data; - - common_end(s); - - return 0; -} - -static void decode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index){ - PlaneContext * const p= &s->plane[plane_index]; - CABACContext * const c= &s->c; - int x,y; - uint8_t sample_buffer[2][w+6]; - uint8_t *sample[2]= {sample_buffer[0]+3, sample_buffer[1]+3}; - int run_index=0; - - memset(sample_buffer, 0, sizeof(sample_buffer)); - - for(y=0; yac) - diff= get_symbol(c, p->state[context], 1, 7); - else{ - if(context == 0 && run_mode==0) run_mode=1; - - if(run_mode){ - if(run_count==0 && run_mode==1){ - if(get_bits1(&s->gb)){ - run_count = 1<gb, log2_run[run_index]); - else run_count=0; - if(run_index) run_index--; - run_mode=2; - } - } - run_count--; - if(run_count < 0){ - run_mode=0; - run_count=0; - diff= get_vlc_symbol(&s->gb, &p->vlc_state[context]); - if(diff>=0) diff++; - }else - diff=0; - }else - diff= get_vlc_symbol(&s->gb, &p->vlc_state[context]); - -// printf("count:%d index:%d, mode:%d, x:%d y:%d pos:%d\n", run_count, run_index, run_mode, x, y, get_bits_count(&s->gb)); - } - - if(sign) diff= (int8_t)(-diff); //FIXME remove cast - - sample[1][x]= - temp_src[0] = predict(sample[1] + x, sample[0] + x) + diff; - - assert(diff>= -128 && diff <= 127); - } - } -} - -static int read_quant_table(CABACContext *c, int16_t *quant_table, int scale){ - int v; - int i=0; - uint8_t state[CONTEXT_SIZE]={0}; - - for(v=0; i<128 ; v++){ - int len= get_symbol(c, state, 0, 7) + 1; - - if(len + i > 128) return -1; - - while(len--){ - quant_table[i] = scale*v; - i++; -//printf("%2d ",v); -//if(i%16==0) printf("\n"); - } - } - - for(i=1; i<128; i++){ - quant_table[256-i]= -quant_table[i]; - } - quant_table[128]= -quant_table[127]; - - return 2*v - 1; -} - -static int read_header(FFV1Context *f){ - uint8_t state[CONTEXT_SIZE]={0}; - int i, context_count; - CABACContext * const c= &f->c; - - f->version= get_symbol(c, state, 0, 7); - f->ac= f->avctx->coder_type= get_symbol(c, state, 0, 7); - get_symbol(c, state, 0, 7); //YUV cs type - get_cabac(c, state); //no chroma = false - f->chroma_h_shift= get_symbol(c, state, 0, 7); - f->chroma_v_shift= get_symbol(c, state, 0, 7); - get_cabac(c, state); //transparency plane - f->plane_count= 2; - - switch(16*f->chroma_h_shift + f->chroma_v_shift){ - case 0x00: f->avctx->pix_fmt= PIX_FMT_YUV444P; break; - case 0x10: f->avctx->pix_fmt= PIX_FMT_YUV422P; break; - case 0x11: f->avctx->pix_fmt= PIX_FMT_YUV420P; break; - case 0x20: f->avctx->pix_fmt= PIX_FMT_YUV411P; break; - case 0x33: f->avctx->pix_fmt= PIX_FMT_YUV410P; break; - default: - fprintf(stderr, "format not supported\n"); - return -1; - } -//printf("%d %d %d\n", f->chroma_h_shift, f->chroma_v_shift,f->avctx->pix_fmt); - - context_count=1; - for(i=0; i<5; i++){ - context_count*= read_quant_table(c, f->quant_table[i], context_count); - if(context_count < 0){ - printf("read_quant_table error\n"); - return -1; - } - } - context_count= (context_count+1)/2; - - for(i=0; iplane_count; i++){ - PlaneContext * const p= &f->plane[i]; - - p->context_count= context_count; - - if(f->ac){ - if(!p->state) p->state= av_malloc(CONTEXT_SIZE*p->context_count*sizeof(uint8_t)); - }else{ - if(!p->vlc_state) p->vlc_state= av_malloc(p->context_count*sizeof(VlcState)); - } - } - - return 0; -} - -static int decode_init(AVCodecContext *avctx) -{ -// FFV1Context *s = avctx->priv_data; - - common_init(avctx); - -#if 0 - switch(s->bitstream_bpp){ - case 12: - avctx->pix_fmt = PIX_FMT_YUV420P; - break; - case 16: - avctx->pix_fmt = PIX_FMT_YUV422P; - break; - case 24: - case 32: - if(s->bgr32){ - avctx->pix_fmt = PIX_FMT_RGBA32; - }else{ - avctx->pix_fmt = PIX_FMT_BGR24; - } - break; - default: - assert(0); - } -#endif - - return 0; -} - -static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size){ - FFV1Context *f = avctx->priv_data; - CABACContext * const c= &f->c; - const int width= f->width; - const int height= f->height; - AVFrame * const p= &f->picture; - int bytes_read; - - AVFrame *picture = data; - - *data_size = 0; - - /* no supplementary picture */ - if (buf_size == 0) - return 0; - - ff_init_cabac_decoder(c, buf, buf_size); - ff_init_cabac_states(c, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64); - - p->pict_type= FF_I_TYPE; //FIXME I vs. P - if(get_cabac_bypass(c)){ - p->key_frame= 1; - read_header(f); - clear_state(f); - }else{ - p->key_frame= 0; - } - - p->reference= 0; - if(avctx->get_buffer(avctx, p) < 0){ - fprintf(stderr, "get_buffer() failed\n"); - return -1; - } - - if(avctx->debug&FF_DEBUG_PICT_INFO) - printf("keyframe:%d coder:%d\n", p->key_frame, f->ac); - - if(!f->ac){ - bytes_read = get_cabac_terminate(c); - if(bytes_read ==0) printf("error at end of AC stream\n"); -//printf("pos=%d\n", bytes_read); - init_get_bits(&f->gb, buf + bytes_read, buf_size - bytes_read); - } else { - bytes_read = 0; /* avoid warning */ - } - - if(1){ - const int chroma_width = -((-width )>>f->chroma_h_shift); - const int chroma_height= -((-height)>>f->chroma_v_shift); - decode_plane(f, p->data[0], width, height, p->linesize[0], 0); - - decode_plane(f, p->data[1], chroma_width, chroma_height, p->linesize[1], 1); - decode_plane(f, p->data[2], chroma_width, chroma_height, p->linesize[2], 1); - } - - emms_c(); - - f->picture_number++; - - *picture= *p; - - avctx->release_buffer(avctx, p); //FIXME - - *data_size = sizeof(AVFrame); - - if(f->ac){ - bytes_read= get_cabac_terminate(c); - if(bytes_read ==0) printf("error at end of frame\n"); - }else{ - bytes_read+= (get_bits_count(&f->gb)+7)/8; - } - - return bytes_read; -} - -static int decode_end(AVCodecContext *avctx) -{ - FFV1Context *s = avctx->priv_data; - int i; - - if(avctx->get_buffer == avcodec_default_get_buffer){ - for(i=0; i<4; i++){ - av_freep(&s->picture.base[i]); - s->picture.data[i]= NULL; - } - av_freep(&s->picture.opaque); - } - - return 0; -} - -AVCodec ffv1_decoder = { - "ffv1", - CODEC_TYPE_VIDEO, - CODEC_ID_FFV1, - sizeof(FFV1Context), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/, - NULL -}; - -#ifdef CONFIG_ENCODERS -AVCodec ffv1_encoder = { - "ffv1", - CODEC_TYPE_VIDEO, - CODEC_ID_FFV1, - sizeof(FFV1Context), - encode_init, - encode_frame, - encode_end, -}; -#endif diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/golomb.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/golomb.c deleted file mode 100644 index a696b2a..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/golomb.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * exp golomb vlc stuff - * 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 - * - */ - -/** - * @file golomb.c - * @brief - * exp golomb vlc stuff - * @author Michael Niedermayer - */ - -#include - -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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/golomb.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/golomb.h deleted file mode 100644 index 5ebebe9..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/golomb.h +++ /dev/null @@ -1,394 +0,0 @@ -/* - * exp golomb vlc stuff - * 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 - * - */ - -/** - * @file golomb.h - * @brief - * exp golomb vlc stuff - * @author Michael Niedermayer - */ - -#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{ - buf|=1; - 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); - 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{ - buf |=1; - 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); - 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)<>= 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)<>(24-len); - - print_bin(bits, len); - - printf("%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, 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); - - printf("%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, 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); - - printf("%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=0); - - e= (i>>k) + 1; - if(e - */ - -/** - * @file h263.c - * h263/mpeg4 codec. - */ - -//#define DEBUG -#include "common.h" -#include "dsputil.h" -#include "avcodec.h" -#include "mpegvideo.h" -#include "h263data.h" -#include "mpeg4data.h" - -//#undef NDEBUG -//#include - -#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 - -#ifdef CONFIG_ENCODERS -static void h263_encode_block(MpegEncContext * s, DCTELEM * block, - int n); -static void h263_encode_motion(MpegEncContext * s, int val, int fcode); -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 h263_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr); -#ifdef CONFIG_ENCODERS -static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n, - int dir); -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); -static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr, int *dir_ptr); - -#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]; -//#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 tis 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 float_aspect_to_info(MpegEncContext * s, float aspect){ - int i; - - aspect*= s->height/(double)s->width; -//printf("%f\n", aspect); - - if(aspect==0) aspect= 1.0; - - ff_float2fraction(&s->aspected_width, &s->aspected_height, aspect, 255); - -//printf("%d %d\n", s->aspected_width, s->aspected_height); - for(i=1; i<6; i++){ - if(s->aspected_width == pixel_aspect[i][0] && s->aspected_height== pixel_aspect[i][1]){ - 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->frame_rate_base) / - s->avctx->frame_rate) & 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= h263_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; - - align_put_bits(&s->pb); - - /* Update the pointer to last GOB */ - s->ptr_lastgob = pbBufPtr(&s->pb); - s->gob_number = 0; - - put_bits(&s->pb, 22, 0x20); /* PSC */ - put_bits(&s->pb, 8, (((int64_t)s->picture_number * 30 * s->avctx->frame_rate_base) / - s->avctx->frame_rate) & 0xff); - - 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, 0); /* advanced prediction mode: off */ - put_bits(&s->pb, 1, 0); /* not PB frame */ - put_bits(&s->pb, 5, s->qscale); - put_bits(&s->pb, 1, 0); /* Continuous Presence Multipoint mode: off */ - } else { - /* H.263v2 */ - /* H.263 Plus PTYPE */ - put_bits(&s->pb, 3, 7); - put_bits(&s->pb,3,1); /* 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,0); /* Custom PCF: off */ - s->umvplus = s->unrestricted_mv; - put_bits(&s->pb, 1, s->umvplus); /* Unrestricted Motion Vector */ - put_bits(&s->pb,1,0); /* SAC: off */ - put_bits(&s->pb,1,0); /* Advanced Prediction Mode: off */ - put_bits(&s->pb,1,s->h263_aic); /* Advanced Intra Coding */ - put_bits(&s->pb,1,0); /* Deblocking Filter: off */ - put_bits(&s->pb,1,0); /* Slice Structured: off */ - 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,0); /* Alternative Inter VLC: off */ - put_bits(&s->pb,1,0); /* Modified Quantization: off */ - 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) */ - float_aspect_to_info(s, s->avctx->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->aspected_width); - put_bits(&s->pb, 8, s->aspected_height); - } - } - - /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */ - if (s->umvplus) -// put_bits(&s->pb,1,1); /* Limited according tables of Annex D */ - put_bits(&s->pb,2,1); /* unlimited */ - - put_bits(&s->pb, 5, s->qscale); - } - - put_bits(&s->pb, 1, 0); /* no PEI */ - - if(s->h263_aic){ - s->y_dc_scale_table= - s->c_dc_scale_table= h263_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. - */ -int h263_encode_gob_header(MpegEncContext * s, int mb_line) -{ - align_put_bits(&s->pb); - flush_put_bits(&s->pb); - /* Call the RTP callback to send the last GOB */ - if (s->rtp_callback) { - int pdif = pbBufPtr(&s->pb) - s->ptr_lastgob; - s->rtp_callback(s->ptr_lastgob, pdif, s->gob_number); - } - put_bits(&s->pb, 17, 1); /* GBSC */ - s->gob_number = mb_line / s->gob_index; - put_bits(&s->pb, 5, s->gob_number); /* GN */ - put_bits(&s->pb, 2, s->pict_type == I_TYPE); /* GFID */ - put_bits(&s->pb, 5, s->qscale); /* GQUANT */ - //fprintf(stderr,"\nGOB: %2d size: %d", s->gob_number - 1, pdif); - return 0; -} - -static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int dir[6]) -{ - int score0=0, score1=0; - int i, n; - int8_t * const qscale_table= s->current_picture.qscale_table; - - for(n=0; n<6; n++){ - int16_t *ac_val, *ac_val1; - - 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 ]]; - score0+= ABS(level); - score1+= ABS(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 ]]; - score0+= ABS(level); - score1+= ABS(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; - } - } - }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]]; - score0+= ABS(level); - score1+= ABS(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]]; - score0+= ABS(level); - score1+= ABS(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 ]]; - } - } - } - } - - return score0 > score1 ? 1 : 0; -} - -/** - * 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; imb_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; - } -} - -/** - * 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); - - for(i=1; imb_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]&MB_TYPE_INTER4V)){ - s->mb_type[mb_xy]&= ~MB_TYPE_INTER4V; - s->mb_type[mb_xy]|= MB_TYPE_INTER; - } - } - - if(s->pict_type== B_TYPE){ - int odd=0; - /* ok, come on, this isnt funny anymore, theres more code for handling this mpeg4 mess than - for the actual adaptive quantization */ - - for(i=0; imb_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; imb_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; imb_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]&MB_TYPE_DIRECT)){ - s->mb_type[mb_xy]&= ~MB_TYPE_DIRECT; - s->mb_type[mb_xy]|= 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]; //FIXME or next? - 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->motion_val[xy][0]*time_pb/time_pp + mx; - s->mv[0][i][1] = s->motion_val[xy][1]*time_pb/time_pp + my; - s->mv[1][i][0] = mx ? s->mv[0][i][0] - s->motion_val[xy][0] - : s->motion_val[xy][0]*(time_pb - time_pp)/time_pp; - s->mv[1][i][1] = my ? s->mv[0][i][1] - s->motion_val[xy][1] - : s->motion_val[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++){ - if(s->top_field_first){ - time_pp= s->pp_field_time - s->field_select_table[mb_index][i] + i; - time_pb= s->pb_field_time - s->field_select_table[mb_index][i] + i; - }else{ - time_pp= s->pp_field_time + s->field_select_table[mb_index][i] - i; - time_pb= s->pb_field_time + s->field_select_table[mb_index][i] - i; - } - s->mv[0][i][0] = s->field_mv_table[mb_index][i][0]*time_pb/time_pp + mx; - s->mv[0][i][1] = s->field_mv_table[mb_index][i][1]*time_pb/time_pp + my; - s->mv[1][i][0] = mx ? s->mv[0][i][0] - s->field_mv_table[mb_index][i][0] - : s->field_mv_table[mb_index][i][0]*(time_pb - time_pp)/time_pp; - s->mv[1][i][1] = my ? s->mv[0][i][1] - s->field_mv_table[mb_index][i][1] - : s->field_mv_table[mb_index][i][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->motion_val[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->motion_val[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->motion_val[xy][0] - : s->motion_val[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->motion_val[xy][1] - : s->motion_val[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 thet is only needed for !low_delay - const int wrap = s->block_wrap[0]; - const int xy = s->block_index[0]; - - s->current_picture.mbskip_table[mb_xy]= s->mb_skiped; - - 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->field_mv_table[mb_xy][i][0]= s->mv[0][i][0]; - s->field_mv_table[mb_xy][i][1]= s->mv[0][i][1]; - s->field_select_table[mb_xy][i]= s->field_select[0][i]; - } - } - - /* no update if 8X8 because it has been done during parsing */ - s->motion_val[xy][0] = motion_x; - s->motion_val[xy][1] = motion_y; - s->motion_val[xy + 1][0] = motion_x; - s->motion_val[xy + 1][1] = motion_y; - s->motion_val[xy + wrap][0] = motion_x; - s->motion_val[xy + wrap][1] = motion_y; - s->motion_val[xy + 1 + wrap][0] = motion_x; - s->motion_val[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 - s->current_picture.mb_type[mb_xy]= MB_TYPE_L0 | MB_TYPE_16x16; - } -} - -#ifdef CONFIG_ENCODERS -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) { - /* compute cbp */ - int i, cbp = 0; - for (i = 0; i < 6; i++) { - if (s->block_last_index[i] >= 0) - cbp |= 1 << (5 - i); - } - - 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){ - 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; - } - - assert(s->dquant>=-2 && s->dquant<=2); - assert((s->dquant&1)==0); - assert(mb_type>=0); - - /* nothing to do if this MB was skiped 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; //doesnt matter - s->qscale -= s->dquant; -// s->mb_skiped=1; - - return; - } - - 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 dont 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 diect mode - put_bits(&s->pb, 1, 0); // no interlaced ME yet - } - - if(interleaved_stats){ - s->misc_bits+= get_bits_diff(s); - } - - switch(mb_type) - { - case 0: /* direct */ - h263_encode_motion(s, motion_x, 1); - h263_encode_motion(s, motion_y, 1); - s->b_count++; - s->f_count++; - break; - case 1: /* bidir */ - h263_encode_motion(s, s->mv[0][0][0] - s->last_mv[0][0][0], s->f_code); - h263_encode_motion(s, s->mv[0][0][1] - s->last_mv[0][0][1], s->f_code); - h263_encode_motion(s, s->mv[1][0][0] - s->last_mv[1][0][0], s->b_code); - h263_encode_motion(s, s->mv[1][0][1] - s->last_mv[1][0][1], s->b_code); - s->last_mv[0][0][0]= s->mv[0][0][0]; - s->last_mv[0][0][1]= s->mv[0][0][1]; - s->last_mv[1][0][0]= s->mv[1][0][0]; - s->last_mv[1][0][1]= s->mv[1][0][1]; - s->b_count++; - s->f_count++; - break; - case 2: /* backward */ - h263_encode_motion(s, motion_x - s->last_mv[1][0][0], s->b_code); - h263_encode_motion(s, motion_y - s->last_mv[1][0][1], s->b_code); - s->last_mv[1][0][0]= motion_x; - s->last_mv[1][0][1]= motion_y; - s->b_count++; - break; - case 3: /* forward */ - h263_encode_motion(s, motion_x - s->last_mv[0][0][0], s->f_code); - h263_encode_motion(s, motion_y - s->last_mv[0][0][1], s->f_code); - s->last_mv[0][0][0]= motion_x; - s->last_mv[0][0][1]= motion_y; - s->f_count++; - break; - default: - printf("unknown mb type\n"); - return; - } - - if(interleaved_stats){ - s->mv_bits+= get_bits_diff(s); - } - - /* encode each block */ - for (i = 0; i < 6; i++) { - mpeg4_encode_block(s, block[i], i, 0, s->intra_scantable.permutated, NULL, &s->pb); - } - - if(interleaved_stats){ - s->p_tex_bits+= get_bits_diff(s); - } - }else{ /* s->pict_type==B_TYPE */ - 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 didnt 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_skiped=1; - for(i=0; imax_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.pix_abs16x16(p_pic, b_pic, s->linesize); - if(diff>s->qscale*70){ //FIXME check that 70 is optimal - s->mb_skiped=0; - break; - } - } - }else - s->mb_skiped=1; - - if(s->mb_skiped==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 */ - if(s->mv_type==MV_TYPE_16X16){ - cbpc = cbp & 3; - if(s->dquant) cbpc+= 8; - put_bits(&s->pb, - inter_MCBPC_bits[cbpc], - inter_MCBPC_code[cbpc]); - - cbpy = cbp >> 2; - cbpy ^= 0xf; - 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); // no interlaced ME yet - } - - if(interleaved_stats){ - s->misc_bits+= get_bits_diff(s); - } - - /* motion vectors: 16x16 mode */ - h263_pred_motion(s, 0, &pred_x, &pred_y); - - h263_encode_motion(s, motion_x - pred_x, s->f_code); - h263_encode_motion(s, motion_y - pred_y, s->f_code); - }else{ - cbpc = (cbp & 3)+16; - put_bits(&s->pb, - inter_MCBPC_bits[cbpc], - inter_MCBPC_code[cbpc]); - cbpy = cbp >> 2; - cbpy ^= 0xf; - 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, &pred_x, &pred_y); - - h263_encode_motion(s, s->motion_val[ s->block_index[i] ][0] - pred_x, s->f_code); - h263_encode_motion(s, s->motion_val[ s->block_index[i] ][1] - pred_y, s->f_code); - } - } - - if(interleaved_stats){ - s->mv_bits+= get_bits_diff(s); - } - - /* encode each block */ - for (i = 0; i < 6; i++) { - mpeg4_encode_block(s, block[i], i, 0, s->intra_scantable.permutated, 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++){ - const int level= block[i][0]; - uint16_t *dc_ptr; - - dc_diff[i]= level - ff_mpeg4_pred_dc(s, i, &dc_ptr, &dir[i]); - if (i < 4) { - *dc_ptr = level * s->y_dc_scale; - } else { - *dc_ptr = level * s->c_dc_scale; - } - } - - s->ac_pred= decide_ac_pred(s, block, dir); - - if(s->ac_pred){ - for(i=0; i<6; i++){ - uint8_t *st; - int last_index; - - mpeg4_inv_pred_ac(s, block[i], i, dir[i]); - if (dir[i]==0) st = s->intra_v_scantable.permutated; /* left */ - else st = s->intra_h_scantable.permutated; /* top */ - - for(last_index=63; last_index>=0; last_index--) //FIXME optimize - if(block[i][st[last_index]]) break; - zigzag_last_index[i]= s->block_last_index[i]; - s->block_last_index[i]= last_index; - scan_table[i]= st; - } - }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); - } - - /* encode each block */ - for (i = 0; i < 6; i++) { - mpeg4_encode_block(s, block[i], i, dc_diff[i], scan_table[i], 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){ - for(i=0; i<6; i++){ - int j; - int16_t *ac_val; - - ac_val = s->ac_val[0][0] + s->block_index[i] * 16; - - if(dir[i]){ - for(j=1; j<8; j++) - block[i][s->dsp.idct_permutation[j ]]= ac_val[j+8]; - }else{ - for(j=1; j<8; j++) - block[i][s->dsp.idct_permutation[j<<3]]= ac_val[j ]; - } - s->block_last_index[i]= zigzag_last_index[i]; - } - } - } -} - -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 = 0; - for (i = 0; i < 6; i++) { - if (s->block_last_index[i] >= 0) - cbp |= 1 << (5 - i); - } - if ((cbp | motion_x | motion_y | s->dquant) == 0) { - /* skip macroblock */ - put_bits(&s->pb, 1, 1); - if(interleaved_stats){ - s->misc_bits++; - s->last_bits++; - } - return; - } - put_bits(&s->pb, 1, 0); /* mb coded */ - cbpc = cbp & 3; - if(s->dquant) cbpc+= 8; - put_bits(&s->pb, - inter_MCBPC_bits[cbpc], - inter_MCBPC_code[cbpc]); - cbpy = cbp >> 2; - cbpy ^= 0xf; - 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 only now */ - h263_pred_motion(s, 0, &pred_x, &pred_y); - - if (!s->umvplus) { - h263_encode_motion(s, motion_x - pred_x, s->f_code); - h263_encode_motion(s, motion_y - pred_y, s->f_code); - } - 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 { - int li = s->h263_aic ? 0 : 1; - - cbp = 0; - for(i=0; i<6; i++) { - /* Predict DC */ - if (s->h263_aic && s->mb_intra) { - int16_t level = block[i][0]; - - pred_dc = h263_pred_dc(s, i, &dc_ptr[i]); - level -= pred_dc; - /* Quant */ - if (level < 0) - level = (level + (s->qscale >> 1))/(s->y_dc_scale); - else - level = (level - (s->qscale >> 1))/(s->y_dc_scale); - - /* AIC can change CBP */ - if (level == 0 && s->block_last_index[i] == 0) - s->block_last_index[i] = -1; - else if (level < -127) - level = -127; - else if (level > 127) - level = 127; - - block[i][0] = level; - /* Reconstruction */ - rec_intradc[i] = (s->y_dc_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]; - } - /* compute cbp */ - if (s->block_last_index[i] >= li) - 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 - -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 + 1 + (n & 1); - y = 2 * s->mb_y + 1 + ((n & 2) >> 1); - wrap = s->mb_width * 2 + 2; - dc_val = s->dc_val[0]; - ac_val = s->ac_val[0][0]; - scale = s->y_dc_scale; - } else { - x = s->mb_x + 1; - y = s->mb_y + 1; - wrap = s->mb_width + 2; - 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 < 2) || (n > 3))) - c = 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 + 1 + (n & 1); - y = 2 * s->mb_y + 1 + ((n & 2) >> 1); - wrap = s->mb_width * 2 + 2; - dc_val = s->dc_val[0]; - ac_val = s->ac_val[0][0]; - scale = s->y_dc_scale; - } else { - x = s->mb_x + 1; - y = s->mb_y + 1; - wrap = s->mb_width + 2; - 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 < 2) || (n > 3))) - c = 1024; - pred_dc = 1024; - if (s->ac_pred) { - 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 if (!(block[0] & 1)) - block[0]++; - - /* 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 *px, int *py) -{ - int xy, wrap; - int16_t *A, *B, *C, *mot_val; - static const int off[4]= {2, 1, 1, -1}; - - wrap = s->block_wrap[0]; - xy = s->block_index[block]; - - mot_val = s->motion_val[xy]; - - A = s->motion_val[xy - 1]; - /* special case for first (slice) line */ - if (s->first_slice_line && block<3) { - // we cant 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){ //rare - C = s->motion_val[xy + 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){ //rare - C = s->motion_val[xy + 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 = s->motion_val[xy - wrap]; - C = s->motion_val[xy + 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 = s->motion_val[xy - wrap]; - C = s->motion_val[xy + 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 -static void 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 = range * 32; -#if 1 - val+= l; - val&= 2*l-1; - val-= l; - sign = val>>31; - val= (val^sign)-sign; - sign&=1; -#else - if (val < -l) { - val += 2*l; - } else if (val >= l) { - val -= 2*l; - } - - assert(val>=-l && val= 0) { - sign = 0; - } else { - val = -val; - sign = 1; - } -#endif - 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 = s->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<>= 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; - } - } - } - } -} - -void h263_encode_init(MpegEncContext *s) -{ - static int done = 0; - - if (!done) { - done = 1; - - init_uni_dc_tab(); - - init_rl(&rl_inter); - init_rl(&rl_intra); - init_rl(&rl_intra_aic); - - 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_mv_penalty_and_fcode(s); - } - s->me.mv_penalty= mv_penalty; //FIXME exact table for msmpeg4 & h263p - - // 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; - - if(s->flags & CODEC_FLAG_GLOBAL_HEADER){ - - s->avctx->extradata= av_malloc(1024); - init_put_bits(&s->pb, s->avctx->extradata, 1024, NULL, NULL); - - 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= (get_bit_count(&s->pb)+7)>>3; - } - - break; - case CODEC_ID_H263P: - s->fcode_tab= umv_fcode_tab; - 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 allready 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 & 0xff); - i = 1; - } else { - i = 0; - if (s->h263_aic && s->mb_intra) - 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(slevel < 128 && slevel > -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(slevel < 64 && slevel > -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= (-get_bit_count(pbc))&7; - if(length) put_bits(pbc, length, (1<current_picture.pts) - s->time= (s->current_picture.pts*s->time_increment_resolution + 500*1000)/(1000*1000); - else - s->time= av_rescale(picture_number*(int64_t)s->avctx->frame_rate_base, s->time_increment_resolution, s->avctx->frame_rate); - time_div= s->time/s->time_increment_resolution; - time_mod= s->time%s->time_increment_resolution; - - if(s->pict_type==B_TYPE){ - s->pb_time= s->pp_time - (s->last_non_b_time - s->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; - } -} - -static void mpeg4_encode_gop_header(MpegEncContext * s){ - int hours, minutes, seconds; - - put_bits(&s->pb, 16, 0); - put_bits(&s->pb, 16, GOP_STARTCODE); - - seconds= s->time/s->time_increment_resolution; - 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, 0); //closed gov == NO - put_bits(&s->pb, 1, 0); //broken link == NO - - 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->max_b_frames || s->quarter_sample){ - profile_and_level_indication= 0xF1; // adv simple level 1 - vo_ver_id= 5; - }else{ - profile_and_level_indication= 0x01; // simple level 1 - 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 */ - 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 */ - - float_aspect_to_info(s, s->avctx->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->aspected_width); - put_bits(&s->pb, 8, s->aspected_height); - } - - if(s->low_delay){ - 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 */ - }else{ - put_bits(&s->pb, 1, 0); /* vol control 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->time_increment_resolution); - 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=0); /* sprite enable */ - }else{ - put_bits(&s->pb, 2, s->vol_sprite_usage=0); /* sprite enable */ - } - - s->quant_precision=5; - 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); - ff_mpeg4_stuffing(&s->pb); - } -} - -/* 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 < 2) //HACK, the reference sw is buggy - mpeg4_encode_visual_object_header(s); - if(s->strict_std_compliance < 2 || picture_number==0) //HACK, the reference sw is buggy - mpeg4_encode_vol_header(s, 0, 0); - } - 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->frame_rate, 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 */ - - time_div= s->time/s->time_increment_resolution; - time_mod= s->time%s->time_increment_resolution; - time_incr= time_div - s->last_time_base; - 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->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); - - 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; -} - -#endif //CONFIG_ENCODERS - -/** - * change qscale by given dquant and update qscale dependant variables. - */ -static void change_qscale(MpegEncContext * s, int dquant) -{ - s->qscale += dquant; - - if (s->qscale < 1) - s->qscale = 1; - else if (s->qscale > 31) - s->qscale = 31; - - s->y_dc_scale= s->y_dc_scale_table[ s->qscale ]; - s->c_dc_scale= s->c_dc_scale_table[ s->qscale ]; -} - -/** - * predicts the dc. - * @param n block index (0-3 are luma, 4-5 are chroma) - * @param dc_val_ptr a pointer to the dc_val entry for the current MB will be stored here - * @param dir_ptr pointer to an integer where the prediction direction will be stored - * @return the quantized predicted dc - */ -static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr, int *dir_ptr) -{ - int a, b, c, wrap, pred, scale; - 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 cant 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); - - /* prepare address for prediction update */ - *dc_val_ptr = &dc_val[0]; - - return pred; -} - -/** - * 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 - -static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n, - int dir) -{ - int i; - int16_t *ac_val; - int8_t * const qscale_table= s->current_picture.qscale_table; - - /* find prediction */ - ac_val = s->ac_val[0][0] + s->block_index[n] * 16; - - 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); - } - } - } -} - -/** - * 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 -} - -/** - * 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 inline 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 */ - //mpeg4_encode_dc(dc_pb, intra_dc, n); //FIXME - 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; - -void init_vlc_rl(RLTable *rl) -{ - int i, q; - - init_vlc(&rl->vlc, 9, rl->n + 1, - &rl->table_vlc[0][1], 4, 2, - &rl->table_vlc[0][0], 4, 2); - - - for(q=0; q<32; q++){ - int qmul= q*2; - int qadd= (q-1)|1; - - if(q==0){ - qmul=1; - qadd=0; - } - - rl->rl_vlc[q]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM)); - for(i=0; ivlc.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); - init_vlc(&inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 28, - inter_MCBPC_bits, 1, 1, - inter_MCBPC_code, 1, 1); - init_vlc(&cbpy_vlc, CBPY_VLC_BITS, 16, - &cbpy_tab[0][1], 2, 1, - &cbpy_tab[0][0], 2, 1); - init_vlc(&mv_vlc, MV_VLC_BITS, 33, - &mvtab[0][1], 2, 1, - &mvtab[0][0], 2, 1); - init_rl(&rl_inter); - init_rl(&rl_intra); - init_rl(&rvlc_rl_inter); - init_rl(&rvlc_rl_intra); - init_rl(&rl_intra_aic); - init_vlc_rl(&rl_inter); - init_vlc_rl(&rl_intra); - init_vlc_rl(&rvlc_rl_inter); - init_vlc_rl(&rvlc_rl_intra); - init_vlc_rl(&rl_intra_aic); - init_vlc(&dc_lum, DC_VLC_BITS, 10 /* 13 */, - &DCtab_lum[0][1], 2, 1, - &DCtab_lum[0][0], 2, 1); - init_vlc(&dc_chrom, DC_VLC_BITS, 10 /* 13 */, - &DCtab_chrom[0][1], 2, 1, - &DCtab_chrom[0][0], 2, 1); - init_vlc(&sprite_trajectory, SPRITE_TRAJ_VLC_BITS, 15, - &sprite_trajectory_tab[0][1], 4, 2, - &sprite_trajectory_tab[0][0], 4, 2); - 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); - } -} - -/** - * 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; -} - -/** - * decodes the group of blocks header. - * @return <0 if an error occured - */ -static int h263_decode_gob_header(MpegEncContext *s) -{ - unsigned int val, gfid; - 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; - -#ifdef DEBUG - fprintf(stderr,"\nGOB Start Code at MB %d\n", (s->mb_y * s->mb_width) + s->mb_x); -#endif - s->gob_number = get_bits(&s->gb, 5); /* GN */ - gfid = get_bits(&s->gb, 2); /* GFID */ - s->qscale = get_bits(&s->gb, 5); /* GQUANT */ - if(s->qscale==0) - return -1; - s->mb_x= 0; - s->mb_y= s->gob_index* s->gob_number; - if(s->mb_y >= s->mb_height) - return -1; -#ifdef DEBUG - fprintf(stderr, "\nGN: %u GFID: %u Quant: %u\n", s->gob_number, gfid, s->qscale); -#endif - return 0; -} - -static inline void memsetw(short *tab, int val, int n) -{ - int i; - for(i=0;itex_pb, s->tex_pb_buffer, PB_BUFFER_SIZE, NULL, NULL); - init_put_bits(&s->pb2 , s->pb2_buffer , PB_BUFFER_SIZE, NULL, NULL); -} - -void ff_mpeg4_merge_partitions(MpegEncContext *s) -{ - const int pb2_len = get_bit_count(&s->pb2 ); - const int tex_pb_len= get_bit_count(&s->tex_pb); - const int bits= get_bit_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); - - ff_copy_bits(&s->pb, s->pb2_buffer , pb2_len); - ff_copy_bits(&s->pb, s->tex_pb_buffer, tex_pb_len); - s->last_bits= get_bit_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; - - ff_mpeg4_stuffing(&s->pb); - 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)){ - printf("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){ - fprintf(stderr, "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 skiped 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->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 dont just ignore everything - if(s->pict_type == S_TYPE && s->vol_sprite_usage==GMC_SPRITE){ - mpeg4_decode_sprite_trajectory(s); - fprintf(stderr, "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){ - printf("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){ - printf("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->block_wrap[0]; - l_xy= s->mb_y*l_wrap*2 + s->mb_x*2; - c_wrap= s->block_wrap[4]; - c_xy= s->mb_y*c_wrap + s->mb_x; - -#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 cant 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, its 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->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]<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_ymb_height; s->mb_y++){ - ff_init_block_index(s); - for(; s->mb_xmb_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; - - if(show_bits_long(&s->gb, 19)==DC_MARKER){ - return mb_num-1; - } - - do{ - cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2); - if (cbpc < 0){ - fprintf(stderr, "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) { - change_qscale(s, 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){ - fprintf(stderr, "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->motion_val[s->block_index[0]]; - const int stride= s->block_wrap[0]*2; - -// do{ //FIXME - 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){ - fprintf(stderr, "cbpc corrupted at %d %d\n", s->mb_x, s->mb_y); - return -1; - } -// }while(cbpc == 20); - - 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, &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, &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_xmb_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){ - fprintf(stderr, "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){ - fprintf(stderr, "I cbpy corrupted at %d %d\n", s->mb_x, s->mb_y); - return -1; - } - - if(s->cbp_table[xy] & 8) { - change_qscale(s, 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){ - fprintf(stderr, "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){ - fprintf(stderr, "P cbpy corrupted at %d %d\n", s->mb_x, s->mb_y); - return -1; - } - - if(s->cbp_table[xy] & 8) { - change_qscale(s, 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){ - fprintf(stderr, "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){ - if(get_bits_long(&s->gb, 19)!=DC_MARKER){ - fprintf(stderr, "marker missing after first I partition at %d %d\n", s->mb_x, s->mb_y); - return -1; - } - }else{ - if(get_bits(&s->gb, 17)!=MOTION_MARKER){ - fprintf(stderr, "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){ - s->qscale= s->current_picture.qscale_table[xy]; - s->y_dc_scale= s->y_dc_scale_table[ s->qscale ]; - s->c_dc_scale= s->c_dc_scale_table[ s->qscale ]; - } - - 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->motion_val[ s->block_index[i] ][0]; - s->mv[0][i][1] = s->motion_val[ 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_skiped = 0; - }else{ - s->mcsel=0; - s->mb_skiped = 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; - /* 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){ - fprintf(stderr, "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; - } -} - -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; - static int8_t quant_tab[4] = { -1, -2, 1, 2 }; - const int xy= s->mb_x + s->mb_y * s->mb_stride; - - 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_skiped = 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_skiped = 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){ - fprintf(stderr, "cbpc damaged at %d %d\n", s->mb_x, s->mb_y); - return -1; - } - }while(cbpc == 20); - - 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); - cbp = (cbpc & 3) | ((cbpy ^ 0xf) << 2); - if (dquant) { - change_qscale(s, 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, &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, &pred_x, &pred_y); - if (s->umvplus) - mx = h263p_decode_umotion(s, pred_x); - else - mx = h263_decode_motion(s, pred_x, s->f_code); - - if (mx >= 0xffff) - return -1; - - if (s->umvplus) - my = h263p_decode_umotion(s, pred_y); - else - 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; - - 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, &pred_x, &pred_y); - if (s->umvplus) - mx = h263p_decode_umotion(s, pred_x); - else - mx = h263_decode_motion(s, pred_x, s->f_code); - if (mx >= 0xffff) - return -1; - - if (s->umvplus) - my = h263p_decode_umotion(s, pred_y); - else - 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; - 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; - } - } - } 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_skiped= s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]; // Note, skiptab=0 if last was GMC - - if(s->mb_skiped){ - /* 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){ - printf("illegal MB_type\n"); - return -1; - } - mb_type= mb_type_b_map[ mb_type ]; - if(modb2) cbp= 0; - else cbp= get_bits(&s->gb, 6); - - if ((!IS_DIRECT(mb_type)) && cbp) { - if(get_bits1(&s->gb)){ - change_qscale(s, 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){ - fprintf(stderr, "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->current_picture.mb_type[xy]= MB_TYPE_INTRA; - if (s->h263_pred || 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; - - if (s->h263_aic) - 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){ - fprintf(stderr, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y); - return -1; - } - cbp = (cbpc & 3) | (cbpy << 2); - if (dquant) { - change_qscale(s, quant_tab[get_bits(&s->gb, 2)]); - } - - if(!s->progressive_sequence) - s->interlaced_dct= get_bits1(&s->gb); - - /* decode each block */ - if (s->h263_pred) { - for (i = 0; i < 6; i++) { - if (mpeg4_decode_block(s, block[i], i, cbp&32, 1, 0) < 0) - return -1; - cbp+=cbp; - } - } else { - for (i = 0; i < 6; i++) { - if (h263_decode_block(s, block[i], i, cbp&32) < 0) - return -1; - cbp+=cbp; - } - } - goto end; - } - - /* decode each block */ - if (s->h263_pred) { - for (i = 0; i < 6; i++) { - if (mpeg4_decode_block(s, block[i], i, cbp&32, 0, 0) < 0) - return -1; - cbp+=cbp; - } - } else { - 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 */ - 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; - } - }else{ - 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; -} - -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 = 1 << (f_code + 4); - val = ((val + l)&(l*2-1)) - 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 - fprintf(stderr,"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; - - 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->h263_rv10){ - 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); - } - }else{ - level = get_bits(&s->gb, 8); - if((level&0x7F) == 0){ - fprintf(stderr, "illegal dc %d at %d %d\n", level, s->mb_x, s->mb_y); - 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; - } - - for(;;) { - code = get_vlc2(&s->gb, rl->vlc.table, TEX_VLC_BITS, 2); - if (code < 0){ - fprintf(stderr, "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->h263_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){ - fprintf(stderr, "run overflow at %dx%d\n", s->mb_x, s->mb_y); - 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, pred, code; - uint16_t *dc_val; - - 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 */){ - fprintf(stderr, "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){ - fprintf(stderr, "dc marker bit missing\n"); - return -1; - } - } - } - } - pred = ff_mpeg4_pred_dc(s, n, &dc_val, dir_ptr); - level += pred; - if (level < 0){ - if(s->error_resilience>=3){ - fprintf(stderr, "dc<0 at %dx%d\n", s->mb_x, s->mb_y); - return -1; - } - level = 0; - } - if (n < 4) { - *dc_val = level * s->y_dc_scale; - } else { - *dc_val = level * s->c_dc_scale; - } - if(IS_3IV1) - *dc_val = level * 8; - - if(s->error_resilience>=3){ - if(*dc_val > 2048 + s->y_dc_scale + s->c_dc_scale){ - fprintf(stderr, "dc overflow at %dx%d\n", s->mb_x, s->mb_y); - return -1; - } - } - return level; -} - -/** - * 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) { - /* 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]<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); - if (level==0) { - /* escape */ - if(rvlc){ - if(SHOW_UBITS(re, &s->gb, 1)==0){ - fprintf(stderr, "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){ - fprintf(stderr, "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){ - fprintf(stderr, "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){ - fprintf(stderr, "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){ - fprintf(stderr, "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(level*s->qscale>1024 || level*s->qscale<-1024){ - fprintf(stderr, "|level| overflow in 3. esc, qp=%d\n", s->qscale); - return -1; - } -#if 1 - { - const int abs_level= ABS(level); - if(abs_level<=MAX_LEVEL && run<=MAX_RUN && !(s->workaround_bugs&FF_BUG_AC_VLC)){ - const int run1= run - rl->max_run[last][abs_level] - 1; - if(abs_level <= rl->max_level[last][run]){ - fprintf(stderr, "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){ - fprintf(stderr, "illegal 3. esc, esc 1 encoding possible\n"); - return -1; - } - if(run1 >= 0 && abs_level <= rl->max_level[last][run1]){ - fprintf(stderr, "illegal 3. esc, esc 2 encoding possible\n"); - return -1; - } - } - } - } -#endif - if (level>0) level= level * qmul + qadd; - else level= level * qmul - qadd; - - 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); - 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); - 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)){ - fprintf(stderr, "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 */ - } - } - 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) { - fprintf(stderr, "Bad picture start code\n"); - return -1; - } - /* temporal reference */ - s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */ - - /* PTYPE starts here */ - if (get_bits1(&s->gb) != 1) { - /* marker */ - fprintf(stderr, "Bad marker\n"); - return -1; - } - if (get_bits1(&s->gb) != 0) { - fprintf(stderr, "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 */ - - /* Reset GOB number */ - s->gob_number = 0; - - 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->unrestricted_mv = get_bits1(&s->gb); - s->h263_long_vectors = s->unrestricted_mv; - - if (get_bits1(&s->gb) != 0) { - fprintf(stderr, "H263 SAC not supported\n"); - return -1; /* SAC: off */ - } - if (get_bits1(&s->gb) != 0) { - s->mv_type = MV_TYPE_8X8; /* Advanced prediction mode */ - } - - if (get_bits1(&s->gb) != 0) { - fprintf(stderr, "H263 PB frame not supported\n"); - return -1; /* not PB frame */ - } - s->qscale = get_bits(&s->gb, 5); - skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */ - - s->width = width; - s->height = height; - } 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); - skip_bits(&s->gb,1); /* Custom PCF */ - s->umvplus = get_bits(&s->gb, 1); /* Unrestricted Motion Vector */ - skip_bits1(&s->gb); /* Syntax-based Arithmetic Coding (SAC) */ - if (get_bits1(&s->gb) != 0) { - s->mv_type = MV_TYPE_8X8; /* Advanced prediction mode */ - } - if (get_bits1(&s->gb) != 0) { /* Advanced Intra Coding (AIC) */ - s->h263_aic = 1; - } - - if (get_bits1(&s->gb) != 0) { - fprintf(stderr, "Deblocking Filter not supported\n"); - } - if (get_bits1(&s->gb) != 0) { - fprintf(stderr, "Slice Structured not supported\n"); - } - if (get_bits1(&s->gb) != 0) { - fprintf(stderr, "Reference Picture Selection not supported\n"); - } - if (get_bits1(&s->gb) != 0) { - fprintf(stderr, "Independent Segment Decoding not supported\n"); - } - if (get_bits1(&s->gb) != 0) { - fprintf(stderr, "Alternative Inter VLC not supported\n"); - } - if (get_bits1(&s->gb) != 0) { - fprintf(stderr, "Modified Quantization not supported\n"); - } - - skip_bits(&s->gb, 1); /* Prevent start code emulation */ - - skip_bits(&s->gb, 3); /* Reserved */ - } else if (ufep != 0) { - fprintf(stderr, "Bad UFEP type (%d)\n", ufep); - return -1; - } - - /* MPPTYPE */ - s->pict_type = get_bits(&s->gb, 3) + I_TYPE; - dprintf("pict_type: %d\n", s->pict_type); - if (s->pict_type != I_TYPE && - s->pict_type != P_TYPE) - return -1; - skip_bits(&s->gb, 2); - s->no_rounding = get_bits1(&s->gb); - dprintf("RTYPE: %d\n", s->no_rounding); - 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->aspected_width = get_bits(&s->gb, 8); - s->aspected_height = get_bits(&s->gb, 8); - }else{ - s->aspected_width = pixel_aspect[s->aspect_ratio_info][0]; - s->aspected_height= pixel_aspect[s->aspect_ratio_info][1]; - } - } else { - width = h263_format[format][0]; - height = h263_format[format][1]; - } - if ((width == 0) || (height == 0)) - return -1; - s->width = width; - s->height = height; - if (s->umvplus) { - if(get_bits1(&s->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */ - skip_bits1(&s->gb); - } - } - - s->qscale = get_bits(&s->gb, 5); - } - /* PEI */ - while (get_bits1(&s->gb) != 0) { - skip_bits(&s->gb, 8); - } - s->f_code = 1; - - if(s->h263_aic){ - s->y_dc_scale_table= - s->c_dc_scale_table= h263_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){ - printf("qp:%d %c size:%d rnd:%d %s %s %s %s\n", - s->qscale, av_get_pict_type_char(s->pict_type), - s->gb.size_in_bits, 1-s->no_rounding, - s->mv_type == MV_TYPE_8X8 ? "ADV" : "", - s->umvplus ? "UMV" : "", - s->h263_long_vectors ? "LONG" : "", - s->h263_plus ? "+" : "" - ); - } - - - return 0; -} - -static void mpeg4_decode_sprite_trajectory(MpegEncContext * s) -{ - int i; - int a= 2<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; inum_sprite_warping_points; i++){ - int length; - int x=0, y=0; - - length= get_vlc(&s->gb, &sprite_trajectory); - if(length){ - x= get_xbits(&s->gb, length); - } - if(!(s->divx_version==500 && s->divx_build==413)) skip_bits1(&s->gb); /* marker bit */ - - length= get_vlc(&s->gb, &sprite_trajectory); - if(length){ - y=get_xbits(&s->gb, length); - } - skip_bits1(&s->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<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<sprite_shift[0] - && s->sprite_delta[0][1] == 0 - && s->sprite_delta[1][0] == 0 - && s->sprite_delta[1][1] == a<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->aspected_width = get_bits(gb, 8); // par_width - s->aspected_height = get_bits(gb, 8); // par_height - }else{ - s->aspected_width = pixel_aspect[s->aspect_ratio_info][0]; - s->aspected_height= pixel_aspect[s->aspect_ratio_info][1]; - } - - if ((s->vol_control_parameters=get_bits1(gb))) { /* vol control parameter */ - int chroma_format= get_bits(gb, 2); - if(chroma_format!=1){ - printf("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 so the smart? low delay detection wont be overriden - if(s->picture_number==0) - s->low_delay=0; - } - - s->shape = get_bits(gb, 2); /* vol shape */ - if(s->shape != RECT_SHAPE) printf("only rectangular vol supported\n"); - if(s->shape == GRAY_SHAPE && vo_ver_id != 1){ - printf("Gray shape not supported\n"); - skip_bits(gb, 4); //video_object_layer_shape_extension - } - - check_marker(gb, "before time_increment_resolution"); - - s->time_increment_resolution = get_bits(gb, 16); - - s->time_increment_bits = av_log2(s->time_increment_resolution - 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 */ - skip_bits(gb, s->time_increment_bits); - } - - 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){ /* 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= get_bits1(gb)^1; - if(!get_bits1(gb) && (s->avctx->debug & FF_DEBUG_PICT_INFO)) - printf("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) printf("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) printf("N-bit not supported\n"); /* bits_per_pixel */ - if(s->quant_precision!=5) printf("quant precission %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)) printf("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){ - printf("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) printf("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 - printf("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; - - buf[0]= show_bits(gb, 8); - for(i=1; i<256; i++){ - buf[i]= show_bits(gb, 16)&0xFF; - if(buf[i]==0) break; - skip_bits(gb, 8); - } - buf[255]=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, "FFmpeg%d.%d.%db%d", &ver, &ver2, &ver3, &build); - if(e!=4) - e=sscanf(buf, "FFmpeg v%d.%d.%d / libavcodec build: %d", &ver, &ver2, &ver3, &build); - if(e!=4){ - if(strcmp(buf, "ffmpeg")==0){ - s->ffmpeg_version= 0x000406; - s->lavc_build= 4600; - } - } - if(e==4){ - s->ffmpeg_version= ver*256*256 + ver2*256 + ver3; - 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)){ - printf("low_delay flag set, but shouldnt, 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_h263_decode_mb; - - if(s->time_increment_resolution==0){ - s->time_increment_resolution=1; -// fprintf(stderr, "time_increment_resolution is illegal\n"); - } - time_incr=0; - while (get_bits1(gb) != 0) - time_incr++; - - check_marker(gb, "before time_increment"); - - if(s->time_increment_bits==0){ - printf("hmm, seems the headers arnt 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; - } - - printf("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); -//printf(" type:%d modulo_time_base:%d increment:%d\n", s->pict_type, time_incr, time_increment); - if(s->pict_type!=B_TYPE){ - s->last_time_base= s->time_base; - s->time_base+= time_incr; - s->time= s->time_base*s->time_increment_resolution + 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->time_increment_resolution; - } - } - 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->time_increment_resolution + 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, seeking?, skiping current b frame\n"); - return FRAME_SKIPED; - } - - if(s->t_frame==0) s->t_frame= s->time - s->last_time_base; - if(s->t_frame==0) s->t_frame=1; // 1/0 protection -//printf("%Ld %Ld %d %d\n", s->last_non_b_time, s->time, s->pp_time, s->t_frame); fflush(stdout); - 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; - } - - s->current_picture.pts= s->time*1000LL*1000LL / s->time_increment_resolution; - if(s->avctx->debug&FF_DEBUG_PTS) - printf("MPEG4 PTS: %f\n", s->current_picture.pts/(1000.0*1000.0)); - - check_marker(gb, "before vop_coded"); - - /* vop coded */ - if (get_bits1(gb) != 1){ - printf("vop not coded\n"); - return FRAME_SKIPED; - } -//printf("time %d %d %d || %Ld %Ld %Ld\n", s->time_increment_bits, s->time_increment_resolution, 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) { - int t; - t=get_bits(gb, 3); /* intra dc VLC threshold */ -//printf("threshold %d\n", t); - 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); - if(s->sprite_brightness_change) printf("sprite_brightness_change not supported\n"); - if(s->vol_sprite_usage==STATIC_SPRITE) printf("static sprite not supported\n"); - } - - if (s->shape != BIN_ONLY_SHAPE) { - s->qscale = get_bits(gb, s->quant_precision); - if(s->qscale==0){ - printf("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){ - printf("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){ - printf("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\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" : " "); - } - - 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){ - printf("load backward shape isnt supported\n"); - } - } - skip_bits(gb, 2); //ref_select_code - } - } - /* detect buggy encoders which dont set the low_delay flag (divx4/xvid/opendivx)*/ - // note we cannot detect divx5 without b-frames easyly (allthough its buggy too) - if(s->vo_type==0 && s->vol_control_parameters==0 && s->divx_version==0 && s->picture_number==0){ - printf("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 allways ;) - - 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); - 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){ - printf("frame skip %d\n", gb->size_in_bits); - return FRAME_SKIPED; //divx bug - }else - return -1; //end of stream - } - - if((startcode&0xFFFFFF00) != 0x100) - continue; //no startcode - - if(s->avctx->debug&FF_DEBUG_STARTCODE){ - printf("startcode: %3X ", startcode); - if (startcode<=0x11F) printf("Video Object Start"); - else if(startcode<=0x12F) printf("Video Object Layer Start"); - else if(startcode<=0x13F) printf("Reserved"); - else if(startcode<=0x15F) printf("FGS bp start"); - else if(startcode<=0x1AF) printf("Reserved"); - else if(startcode==0x1B0) printf("Visual Object Seq Start"); - else if(startcode==0x1B1) printf("Visual Object Seq End"); - else if(startcode==0x1B2) printf("User Data"); - else if(startcode==0x1B3) printf("Group of VOP start"); - else if(startcode==0x1B4) printf("Video Session Error"); - else if(startcode==0x1B5) printf("Visual Object Start"); - else if(startcode==0x1B6) printf("Video Object Plane start"); - else if(startcode==0x1B7) printf("slice start"); - else if(startcode==0x1B8) printf("extension start"); - else if(startcode==0x1B9) printf("fgs start"); - else if(startcode==0x1BA) printf("FBA Object start"); - else if(startcode==0x1BB) printf("FBA Object Plane start"); - else if(startcode==0x1BC) printf("Mesh Object start"); - else if(startcode==0x1BD) printf("Mesh Object Plane start"); - else if(startcode==0x1BE) printf("Still Textutre Object start"); - else if(startcode==0x1BF) printf("Textutre Spatial Layer start"); - else if(startcode==0x1C0) printf("Textutre SNR Layer start"); - else if(startcode==0x1C1) printf("Textutre Tile start"); - else if(startcode==0x1C2) printf("Textutre Shape Layer start"); - else if(startcode==0x1C3) printf("stuffing start"); - else if(startcode<=0x1C5) printf("reserved"); - else if(startcode<=0x1FF) printf("System start"); - printf(" at %d\n", get_bits_count(gb)); - } - - switch(startcode){ - case 0x120: - if(decode_vol_header(s, gb) < 0) - return -1; - break; - case USER_DATA_STARTCODE: - decode_user_data(s, gb); - break; - case GOP_STARTCODE: - mpeg4_decode_gop_header(s, gb); - break; - case VOP_STARTCODE: - return decode_vop_header(s, gb); - default: - break; - } - - 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) { - fprintf(stderr, "Bad picture start code\n"); - return -1; - } - s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */ - - if (get_bits1(&s->gb) != 1) { - fprintf(stderr, "Bad marker\n"); - return -1; /* marker */ - } - if (get_bits1(&s->gb) != 0) { - fprintf(stderr, "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) { - fprintf(stderr, "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) { - fprintf(stderr, "SAC not supported\n"); - return -1; /* SAC: off */ - } - if (get_bits1(&s->gb) != 0) { - fprintf(stderr, "Advanced Prediction Mode not supported\n"); - return -1; /* advanced prediction mode: off */ - } - if (get_bits1(&s->gb) != 0) { - fprintf(stderr, "PB frame mode no supported\n"); - return -1; /* PB frame mode */ - } - - /* skip unknown header garbage */ - skip_bits(&s->gb, 41); - - 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) { - fprintf(stderr, "Bad picture start code\n"); - return -1; - } - format = get_bits(&s->gb, 5); - if (format != 0 && format != 1) { - fprintf(stderr, "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 ((width == 0) || (height == 0)) - return -1; - s->width = width; - s->height = height; - - s->pict_type = I_TYPE + get_bits(&s->gb, 2); - if (s->pict_type > P_TYPE) - s->pict_type = P_TYPE; - skip_bits1(&s->gb); /* deblocking flag */ - 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){ - printf("%c esc_type:%d, qp:%d num:%d\n", - 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h263data.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h263data.h deleted file mode 100644 index 809b10d..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h263data.h +++ /dev/null @@ -1,199 +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*/ -}; - -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 uint16_t h263_format[8][2] = { - { 0, 0 }, - { 128, 96 }, - { 176, 144 }, - { 352, 288 }, - { 704, 576 }, - { 1408, 1152 }, -}; - -static uint8_t h263_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 -}; - diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h263dec.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h263dec.c deleted file mode 100644 index 4778851..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h263dec.c +++ /dev/null @@ -1,842 +0,0 @@ -/* - * H.263 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 h263dec.c - * H.263 decoder. - */ - -#include "avcodec.h" -#include "dsputil.h" -#include "mpegvideo.h" - -//#define DEBUG -//#define PRINT_FRAME_TIME -#ifdef PRINT_FRAME_TIME -static inline long long rdtsc() -{ - long long l; - asm volatile( "rdtsc\n\t" - : "=A" (l) - ); -// printf("%d\n", int(l/1000)); - return l; -} -#endif - -int ff_h263_decode_init(AVCodecContext *avctx) -{ - MpegEncContext *s = avctx->priv_data; - - s->avctx = avctx; - s->out_format = FMT_H263; - - s->width = avctx->width; - s->height = avctx->height; - s->workaround_bugs= avctx->workaround_bugs; - - // set defaults - s->quant_precision=5; - s->progressive_sequence=1; - s->decode_mb= ff_h263_decode_mb; - s->low_delay= 1; - avctx->pix_fmt= PIX_FMT_YUV420P; - - /* select sub codec */ - switch(avctx->codec->id) { - case CODEC_ID_H263: - s->gob_number = 0; - break; - case CODEC_ID_MPEG4: - 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_H263I: - s->h263_intel = 1; - 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; -} - -/** - * retunrs 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; - 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; - - s->y_dc_scale= s->y_dc_scale_table[ s->qscale ]; - s->c_dc_scale= s->c_dc_scale_table[ 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; - s->qscale= qscale; - s->y_dc_scale= s->y_dc_scale_table[ s->qscale ]; - s->c_dc_scale= s->c_dc_scale_table[ 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->dsp.clear_blocks(s->block[0]); - - s->mv_dir = MV_DIR_FORWARD; - s->mv_type = MV_TYPE_16X16; -// s->mb_skiped = 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); - -//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*16, 16); - s->mb_y++; - } - return 0; - }else if(ret==SLICE_NOEND){ - fprintf(stderr,"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; - } - fprintf(stderr,"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); - } - - ff_draw_horiz_band(s, s->mb_y*16, 16); - - 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>8){ - s->padding_bug_score++; - } else if(bits_left != 1){ - int v= show_bits(&s->gb, 8); - v|= 0x7F >> (7-(bits_count&7)); - - if(v==0x7F) - s->padding_bug_score--; - else - s->padding_bug_score++; - } - } - - // handle formats which dont 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){ - fprintf(stderr, "discarding %d junk bits at end, next would be %X\n", left, show_bits(&s->gb, 24)); - } - else if(left<0){ - fprintf(stderr, "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; - } - - fprintf(stderr, "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 - */ -static int mpeg4_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){ - ParseContext *pc= &s->parse_context; - int vop_found, i; - uint32_t state; - - vop_found= pc->frame_start_found; - state= pc->state; - - i=0; - if(!vop_found){ - for(i=0; iframe_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(MpegEncContext *s, uint8_t *buf, int buf_size){ - ParseContext *pc= &s->parse_context; - 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>(32-22) == 0x20){ - i++; - vop_found=1; - break; - } - } - } - - if(vop_found){ - for(; i>(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; -} - -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; - float new_aspect; - -#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; - - *data_size = 0; - - /* 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= mpeg4_find_frame_end(s, buf, buf_size); - }else if(s->codec_id==CODEC_ID_H263){ - next= h263_find_frame_end(s, buf, buf_size); - }else{ - fprintf(stderr, "this codec doesnt support truncated bitstreams\n"); - return -1; - } - - if( ff_combine_frame(s, next, &buf, &buf_size) < 0 ) - return buf_size; - } - -retry: - - if(s->bitstream_buffer_size && buf_size<20){ //divx 5.01+ 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; - } - - /* 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->h263_intel) { - 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_SKIPED) return get_consumed_bytes(s, buf_size); - - /* skip if the header was thrashed */ - if (ret < 0){ - fprintf(stderr, "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->workaround_bugs&FF_BUG_AUTODETECT){ - s->workaround_bugs &= ~FF_BUG_NO_PADDING; - - if(s->padding_bug_score > -2 && !s->data_partitioning && (s->divx_version || !s->resync_marker)) - s->workaround_bugs |= FF_BUG_NO_PADDING; - - 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; - s->workaround_bugs|= FF_BUG_AC_VLC; - } - - 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; - -#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<4618){ - s->workaround_bugs|= FF_BUG_EDGE; - } - - 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 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) - printf("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 - - /* 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->aspected_height) - new_aspect= s->aspected_width*s->width / (float)(s->height*s->aspected_height); - else - new_aspect=0; - - if ( s->width != avctx->width || s->height != avctx->height - || ABS(new_aspect - avctx->aspect_ratio) > 0.001) { - /* H.263 could change picture size any time */ - MPV_common_end(s); - } - if (!s->context_initialized) { - avctx->width = s->width; - avctx->height = s->height; - avctx->aspect_ratio= new_aspect; - - 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 dont have reference frames */ - if(s->last_picture_ptr==NULL && s->pict_type==B_TYPE) 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); - /* 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_ymb_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; - - if( buf_size - current_pos > 5 - && buf_size - current_pos < BITSTREAM_BUFFER_SIZE){ - int i; - int startcode_found=0; - for(i=current_pos; ibitstream_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, s->current_picture_ptr); - } else { - *pict= *(AVFrame*)&s->last_picture; - ff_print_debug_info(s, s->last_picture_ptr); - } - - /* 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; - - /* dont 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); -} - -static const AVOption mpeg4_decoptions[] = -{ - AVOPTION_SUB(avoptions_workaround_bug), - AVOPTION_END() -}; - -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, - .options = mpeg4_decoptions, - .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, - .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, - mpeg4_decoptions, -}; - -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, - mpeg4_decoptions, -}; - -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, - .options = mpeg4_decoptions, -}; - -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, - mpeg4_decoptions, -}; - -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, - mpeg4_decoptions, -}; - -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 -}; diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h264.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h264.c deleted file mode 100644 index 96bba62..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h264.c +++ /dev/null @@ -1,4420 +0,0 @@ -/* - * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder - * 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 - * - */ - -/** - * @file h264.c - * H.264 / AVC / MPEG4 part10 codec. - * @author Michael Niedermayer - */ - -#include "common.h" -#include "dsputil.h" -#include "avcodec.h" -#include "mpegvideo.h" -#include "h264data.h" -#include "golomb.h" - -#undef NDEBUG -#include - -#define interlaced_dct interlaced_dct_is_a_bad_name -#define mb_intra mb_intra_isnt_initalized_see_mb_type - -#define LUMA_DC_BLOCK_INDEX 25 -#define CHROMA_DC_BLOCK_INDEX 26 - -#define CHROMA_DC_COEFF_TOKEN_VLC_BITS 8 -#define COEFF_TOKEN_VLC_BITS 8 -#define TOTAL_ZEROS_VLC_BITS 9 -#define CHROMA_DC_TOTAL_ZEROS_VLC_BITS 3 -#define RUN_VLC_BITS 3 -#define RUN7_VLC_BITS 6 - -#define MAX_SPS_COUNT 32 -#define MAX_PPS_COUNT 256 - -#define MAX_MMCO_COUNT 66 - -/** - * Sequence parameter set - */ -typedef struct SPS{ - - int profile_idc; - int level_idc; - int log2_max_frame_num; ///< log2_max_frame_num_minus4 + 4 - int poc_type; ///< pic_order_cnt_type - int log2_max_poc_lsb; ///< log2_max_pic_order_cnt_lsb_minus4 - int delta_pic_order_always_zero_flag; - int offset_for_non_ref_pic; - int offset_for_top_to_bottom_field; - int poc_cycle_length; ///< num_ref_frames_in_pic_order_cnt_cycle - int ref_frame_count; ///< num_ref_frames - int gaps_in_frame_num_allowed_flag; - int mb_width; ///< frame_width_in_mbs_minus1 + 1 - int mb_height; ///< frame_height_in_mbs_minus1 + 1 - int frame_mbs_only_flag; - int mb_aff; ///no) do we need that? - - int slice_num; - uint8_t *slice_table_base; - uint8_t *slice_table; ///< slice_table_base + mb_stride + 1 - int slice_type; - int slice_type_fixed; - - //interlacing specific flags - int mb_field_decoding_flag; - - int sub_mb_type[4]; - - //POC stuff - int poc_lsb; - int poc_msb; - int delta_poc_bottom; - int delta_poc[2]; - int frame_num; - int prev_poc_msb; ///< poc_msb of the last reference pic for POC type 0 - int prev_poc_lsb; ///< poc_lsb of the last reference pic for POC type 0 - int frame_num_offset; ///< for POC type 2 - int prev_frame_num_offset; ///< for POC type 2 - int prev_frame_num; ///< frame_num of the last pic for POC type 1/2 - - /** - * frame_num for frames or 2*frame_num for field pics. - */ - int curr_pic_num; - - /** - * max_frame_num or 2*max_frame_num for field pics. - */ - int max_pic_num; - - //Weighted pred stuff - int luma_log2_weight_denom; - int chroma_log2_weight_denom; - int luma_weight[2][16]; - int luma_offset[2][16]; - int chroma_weight[2][16][2]; - int chroma_offset[2][16][2]; - - //deblock - int disable_deblocking_filter_idc; - int slice_alpha_c0_offset_div2; - int slice_beta_offset_div2; - - int redundant_pic_count; - - int direct_spatial_mv_pred; - - /** - * num_ref_idx_l0/1_active_minus1 + 1 - */ - int ref_count[2];// FIXME split for AFF - Picture *short_ref[16]; - Picture *long_ref[16]; - Picture default_ref_list[2][32]; - Picture ref_list[2][32]; //FIXME size? - Picture field_ref_list[2][32]; //FIXME size? - - /** - * memory management control operations buffer. - */ - MMCO mmco[MAX_MMCO_COUNT]; - int mmco_index; - - int long_ref_count; ///< number of actual long term references - int short_ref_count; ///< number of actual short term references - - //data partitioning - GetBitContext intra_gb; - GetBitContext inter_gb; - GetBitContext *intra_gb_ptr; - GetBitContext *inter_gb_ptr; - - DCTELEM mb[16*24] __align8; -}H264Context; - -static VLC coeff_token_vlc[4]; -static VLC chroma_dc_coeff_token_vlc; - -static VLC total_zeros_vlc[15]; -static VLC chroma_dc_total_zeros_vlc[3]; - -static VLC run_vlc[6]; -static VLC run7_vlc; - -static void svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp); -static void svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc); - -static inline uint32_t pack16to32(int a, int b){ -#ifdef WORDS_BIGENDIAN - return (b&0xFFFF) + (a<<16); -#else - return (a&0xFFFF) + (b<<16); -#endif -} - -/** - * fill a rectangle. - * @param h height of the recatangle, should be a constant - * @param w width of the recatangle, should be a constant - * @param size the size of val (1 or 4), should be a constant - */ -static inline void fill_rectangle(void *vp, int w, int h, int stride, uint32_t val, int size){ //FIXME ensure this IS inlined - uint8_t *p= (uint8_t*)vp; - assert(size==1 || size==4); - - w *= size; - stride *= size; - -//FIXME check what gcc generates for 64 bit on x86 and possible write a 32 bit ver of it - if(w==2 && h==2){ - *(uint16_t*)(p + 0)= - *(uint16_t*)(p + stride)= size==4 ? val : val*0x0101; - }else if(w==2 && h==4){ - *(uint16_t*)(p + 0*stride)= - *(uint16_t*)(p + 1*stride)= - *(uint16_t*)(p + 2*stride)= - *(uint16_t*)(p + 3*stride)= size==4 ? val : val*0x0101; - }else if(w==4 && h==1){ - *(uint32_t*)(p + 0*stride)= size==4 ? val : val*0x01010101; - }else if(w==4 && h==2){ - *(uint32_t*)(p + 0*stride)= - *(uint32_t*)(p + 1*stride)= size==4 ? val : val*0x01010101; - }else if(w==4 && h==4){ - *(uint32_t*)(p + 0*stride)= - *(uint32_t*)(p + 1*stride)= - *(uint32_t*)(p + 2*stride)= - *(uint32_t*)(p + 3*stride)= size==4 ? val : val*0x01010101; - }else if(w==8 && h==1){ - *(uint32_t*)(p + 0)= - *(uint32_t*)(p + 4)= size==4 ? val : val*0x01010101; - }else if(w==8 && h==2){ - *(uint32_t*)(p + 0 + 0*stride)= - *(uint32_t*)(p + 4 + 0*stride)= - *(uint32_t*)(p + 0 + 1*stride)= - *(uint32_t*)(p + 4 + 1*stride)= size==4 ? val : val*0x01010101; - }else if(w==8 && h==4){ - *(uint64_t*)(p + 0*stride)= - *(uint64_t*)(p + 1*stride)= - *(uint64_t*)(p + 2*stride)= - *(uint64_t*)(p + 3*stride)= size==4 ? val*0x0100000001ULL : val*0x0101010101010101ULL; - }else if(w==16 && h==2){ - *(uint64_t*)(p + 0+0*stride)= - *(uint64_t*)(p + 8+0*stride)= - *(uint64_t*)(p + 0+1*stride)= - *(uint64_t*)(p + 8+1*stride)= size==4 ? val*0x0100000001ULL : val*0x0101010101010101ULL; - }else if(w==16 && h==4){ - *(uint64_t*)(p + 0+0*stride)= - *(uint64_t*)(p + 8+0*stride)= - *(uint64_t*)(p + 0+1*stride)= - *(uint64_t*)(p + 8+1*stride)= - *(uint64_t*)(p + 0+2*stride)= - *(uint64_t*)(p + 8+2*stride)= - *(uint64_t*)(p + 0+3*stride)= - *(uint64_t*)(p + 8+3*stride)= size==4 ? val*0x0100000001ULL : val*0x0101010101010101ULL; - }else - assert(0); -} - -static inline void fill_caches(H264Context *h, int mb_type){ - MpegEncContext * const s = &h->s; - const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; - int topleft_xy, top_xy, topright_xy, left_xy[2]; - int topleft_type, top_type, topright_type, left_type[2]; - int left_block[4]; - int i; - - //wow what a mess, why didnt they simplify the interlacing&intra stuff, i cant imagine that these complex rules are worth it - - if(h->sps.mb_aff){ - //FIXME - topleft_xy = 0; /* avoid warning */ - top_xy = 0; /* avoid warning */ - topright_xy = 0; /* avoid warning */ - }else{ - topleft_xy = mb_xy-1 - s->mb_stride; - top_xy = mb_xy - s->mb_stride; - topright_xy= mb_xy+1 - s->mb_stride; - left_xy[0] = mb_xy-1; - left_xy[1] = mb_xy-1; - left_block[0]= 0; - left_block[1]= 1; - left_block[2]= 2; - left_block[3]= 3; - } - - topleft_type = h->slice_table[topleft_xy ] == h->slice_num ? s->current_picture.mb_type[topleft_xy] : 0; - top_type = h->slice_table[top_xy ] == h->slice_num ? s->current_picture.mb_type[top_xy] : 0; - topright_type= h->slice_table[topright_xy] == h->slice_num ? s->current_picture.mb_type[topright_xy]: 0; - left_type[0] = h->slice_table[left_xy[0] ] == h->slice_num ? s->current_picture.mb_type[left_xy[0]] : 0; - left_type[1] = h->slice_table[left_xy[1] ] == h->slice_num ? s->current_picture.mb_type[left_xy[1]] : 0; - - if(IS_INTRA(mb_type)){ - h->topleft_samples_available= - h->top_samples_available= - h->left_samples_available= 0xFFFF; - h->topright_samples_available= 0xEEEA; - - if(!IS_INTRA(top_type) && (top_type==0 || h->pps.constrained_intra_pred)){ - h->topleft_samples_available= 0xB3FF; - h->top_samples_available= 0x33FF; - h->topright_samples_available= 0x26EA; - } - for(i=0; i<2; i++){ - if(!IS_INTRA(left_type[i]) && (left_type[i]==0 || h->pps.constrained_intra_pred)){ - h->topleft_samples_available&= 0xDF5F; - h->left_samples_available&= 0x5F5F; - } - } - - if(!IS_INTRA(topleft_type) && (topleft_type==0 || h->pps.constrained_intra_pred)) - h->topleft_samples_available&= 0x7FFF; - - if(!IS_INTRA(topright_type) && (topright_type==0 || h->pps.constrained_intra_pred)) - h->topright_samples_available&= 0xFBFF; - - if(IS_INTRA4x4(mb_type)){ - if(IS_INTRA4x4(top_type)){ - h->intra4x4_pred_mode_cache[4+8*0]= h->intra4x4_pred_mode[top_xy][4]; - h->intra4x4_pred_mode_cache[5+8*0]= h->intra4x4_pred_mode[top_xy][5]; - h->intra4x4_pred_mode_cache[6+8*0]= h->intra4x4_pred_mode[top_xy][6]; - h->intra4x4_pred_mode_cache[7+8*0]= h->intra4x4_pred_mode[top_xy][3]; - }else{ - int pred; - if(IS_INTRA16x16(top_type) || (IS_INTER(top_type) && !h->pps.constrained_intra_pred)) - pred= 2; - else{ - pred= -1; - } - h->intra4x4_pred_mode_cache[4+8*0]= - h->intra4x4_pred_mode_cache[5+8*0]= - h->intra4x4_pred_mode_cache[6+8*0]= - h->intra4x4_pred_mode_cache[7+8*0]= pred; - } - for(i=0; i<2; i++){ - if(IS_INTRA4x4(left_type[i])){ - h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= h->intra4x4_pred_mode[left_xy[i]][left_block[0+2*i]]; - h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= h->intra4x4_pred_mode[left_xy[i]][left_block[1+2*i]]; - }else{ - int pred; - if(IS_INTRA16x16(left_type[i]) || (IS_INTER(left_type[i]) && !h->pps.constrained_intra_pred)) - pred= 2; - else{ - pred= -1; - } - h->intra4x4_pred_mode_cache[3+8*1 + 2*8*i]= - h->intra4x4_pred_mode_cache[3+8*2 + 2*8*i]= pred; - } - } - } - } - - -/* -0 . T T. T T T T -1 L . .L . . . . -2 L . .L . . . . -3 . T TL . . . . -4 L . .L . . . . -5 L . .. . . . . -*/ -//FIXME constraint_intra_pred & partitioning & nnz (lets hope this is just a typo in the spec) - if(top_type){ - h->non_zero_count_cache[4+8*0]= h->non_zero_count[top_xy][0]; - h->non_zero_count_cache[5+8*0]= h->non_zero_count[top_xy][1]; - h->non_zero_count_cache[6+8*0]= h->non_zero_count[top_xy][2]; - h->non_zero_count_cache[7+8*0]= h->non_zero_count[top_xy][3]; - - h->non_zero_count_cache[1+8*0]= h->non_zero_count[top_xy][7]; - h->non_zero_count_cache[2+8*0]= h->non_zero_count[top_xy][8]; - - h->non_zero_count_cache[1+8*3]= h->non_zero_count[top_xy][10]; - h->non_zero_count_cache[2+8*3]= h->non_zero_count[top_xy][11]; - }else{ - h->non_zero_count_cache[4+8*0]= - h->non_zero_count_cache[5+8*0]= - h->non_zero_count_cache[6+8*0]= - h->non_zero_count_cache[7+8*0]= - - h->non_zero_count_cache[1+8*0]= - h->non_zero_count_cache[2+8*0]= - - h->non_zero_count_cache[1+8*3]= - h->non_zero_count_cache[2+8*3]= 64; - } - - if(left_type[0]){ - h->non_zero_count_cache[3+8*1]= h->non_zero_count[left_xy[0]][6]; - h->non_zero_count_cache[3+8*2]= h->non_zero_count[left_xy[0]][5]; - h->non_zero_count_cache[0+8*1]= h->non_zero_count[left_xy[0]][9]; //FIXME left_block - h->non_zero_count_cache[0+8*4]= h->non_zero_count[left_xy[0]][12]; - }else{ - h->non_zero_count_cache[3+8*1]= - h->non_zero_count_cache[3+8*2]= - h->non_zero_count_cache[0+8*1]= - h->non_zero_count_cache[0+8*4]= 64; - } - - if(left_type[1]){ - h->non_zero_count_cache[3+8*3]= h->non_zero_count[left_xy[1]][4]; - h->non_zero_count_cache[3+8*4]= h->non_zero_count[left_xy[1]][3]; - h->non_zero_count_cache[0+8*2]= h->non_zero_count[left_xy[1]][8]; - h->non_zero_count_cache[0+8*5]= h->non_zero_count[left_xy[1]][11]; - }else{ - h->non_zero_count_cache[3+8*3]= - h->non_zero_count_cache[3+8*4]= - h->non_zero_count_cache[0+8*2]= - h->non_zero_count_cache[0+8*5]= 64; - } - -#if 1 - if(IS_INTER(mb_type)){ - int list; - for(list=0; list<2; list++){ - if((!IS_8X8(mb_type)) && !USES_LIST(mb_type, list)){ - /*if(!h->mv_cache_clean[list]){ - memset(h->mv_cache [list], 0, 8*5*2*sizeof(int16_t)); //FIXME clean only input? clean at all? - memset(h->ref_cache[list], PART_NOT_AVAILABLE, 8*5*sizeof(int8_t)); - h->mv_cache_clean[list]= 1; - }*/ - continue; //FIXME direct mode ... - } - h->mv_cache_clean[list]= 0; - - if(IS_INTER(topleft_type)){ - const int b_xy = h->mb2b_xy[topleft_xy] + 3 + 3*h->b_stride; - const int b8_xy= h->mb2b8_xy[topleft_xy] + 1 + h->b8_stride; - *(uint32_t*)h->mv_cache[list][scan8[0] - 1 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy]; - h->ref_cache[list][scan8[0] - 1 - 1*8]= s->current_picture.ref_index[list][b8_xy]; - }else{ - *(uint32_t*)h->mv_cache[list][scan8[0] - 1 - 1*8]= 0; - h->ref_cache[list][scan8[0] - 1 - 1*8]= topleft_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; - } - - if(IS_INTER(top_type)){ - const int b_xy= h->mb2b_xy[top_xy] + 3*h->b_stride; - const int b8_xy= h->mb2b8_xy[top_xy] + h->b8_stride; - *(uint32_t*)h->mv_cache[list][scan8[0] + 0 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 0]; - *(uint32_t*)h->mv_cache[list][scan8[0] + 1 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 1]; - *(uint32_t*)h->mv_cache[list][scan8[0] + 2 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 2]; - *(uint32_t*)h->mv_cache[list][scan8[0] + 3 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + 3]; - h->ref_cache[list][scan8[0] + 0 - 1*8]= - h->ref_cache[list][scan8[0] + 1 - 1*8]= s->current_picture.ref_index[list][b8_xy + 0]; - h->ref_cache[list][scan8[0] + 2 - 1*8]= - h->ref_cache[list][scan8[0] + 3 - 1*8]= s->current_picture.ref_index[list][b8_xy + 1]; - }else{ - *(uint32_t*)h->mv_cache [list][scan8[0] + 0 - 1*8]= - *(uint32_t*)h->mv_cache [list][scan8[0] + 1 - 1*8]= - *(uint32_t*)h->mv_cache [list][scan8[0] + 2 - 1*8]= - *(uint32_t*)h->mv_cache [list][scan8[0] + 3 - 1*8]= 0; - *(uint32_t*)&h->ref_cache[list][scan8[0] + 0 - 1*8]= ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE)&0xFF)*0x01010101; - } - - if(IS_INTER(topright_type)){ - const int b_xy= h->mb2b_xy[topright_xy] + 3*h->b_stride; - const int b8_xy= h->mb2b8_xy[topright_xy] + h->b8_stride; - *(uint32_t*)h->mv_cache[list][scan8[0] + 4 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy]; - h->ref_cache[list][scan8[0] + 4 - 1*8]= s->current_picture.ref_index[list][b8_xy]; - }else{ - *(uint32_t*)h->mv_cache [list][scan8[0] + 4 - 1*8]= 0; - h->ref_cache[list][scan8[0] + 4 - 1*8]= topright_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; - } - - //FIXME unify cleanup or sth - if(IS_INTER(left_type[0])){ - const int b_xy= h->mb2b_xy[left_xy[0]] + 3; - const int b8_xy= h->mb2b8_xy[left_xy[0]] + 1; - *(uint32_t*)h->mv_cache[list][scan8[0] - 1 + 0*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[0]]; - *(uint32_t*)h->mv_cache[list][scan8[0] - 1 + 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[1]]; - h->ref_cache[list][scan8[0] - 1 + 0*8]= - h->ref_cache[list][scan8[0] - 1 + 1*8]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[0]>>1)]; - }else{ - *(uint32_t*)h->mv_cache [list][scan8[0] - 1 + 0*8]= - *(uint32_t*)h->mv_cache [list][scan8[0] - 1 + 1*8]= 0; - h->ref_cache[list][scan8[0] - 1 + 0*8]= - h->ref_cache[list][scan8[0] - 1 + 1*8]= left_type[0] ? LIST_NOT_USED : PART_NOT_AVAILABLE; - } - - if(IS_INTER(left_type[1])){ - const int b_xy= h->mb2b_xy[left_xy[1]] + 3; - const int b8_xy= h->mb2b8_xy[left_xy[1]] + 1; - *(uint32_t*)h->mv_cache[list][scan8[0] - 1 + 2*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[2]]; - *(uint32_t*)h->mv_cache[list][scan8[0] - 1 + 3*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[3]]; - h->ref_cache[list][scan8[0] - 1 + 2*8]= - h->ref_cache[list][scan8[0] - 1 + 3*8]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[2]>>1)]; - }else{ - *(uint32_t*)h->mv_cache [list][scan8[0] - 1 + 2*8]= - *(uint32_t*)h->mv_cache [list][scan8[0] - 1 + 3*8]= 0; - h->ref_cache[list][scan8[0] - 1 + 2*8]= - h->ref_cache[list][scan8[0] - 1 + 3*8]= left_type[0] ? LIST_NOT_USED : PART_NOT_AVAILABLE; - } - - h->ref_cache[list][scan8[5 ]+1] = - h->ref_cache[list][scan8[7 ]+1] = - h->ref_cache[list][scan8[13]+1] = //FIXME remove past 3 (init somewher else) - h->ref_cache[list][scan8[4 ]] = - h->ref_cache[list][scan8[12]] = PART_NOT_AVAILABLE; - *(uint32_t*)h->mv_cache [list][scan8[5 ]+1]= - *(uint32_t*)h->mv_cache [list][scan8[7 ]+1]= - *(uint32_t*)h->mv_cache [list][scan8[13]+1]= //FIXME remove past 3 (init somewher else) - *(uint32_t*)h->mv_cache [list][scan8[4 ]]= - *(uint32_t*)h->mv_cache [list][scan8[12]]= 0; - } -//FIXME - - } -#endif -} - -static inline void write_back_intra_pred_mode(H264Context *h){ - MpegEncContext * const s = &h->s; - const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; - - h->intra4x4_pred_mode[mb_xy][0]= h->intra4x4_pred_mode_cache[7+8*1]; - h->intra4x4_pred_mode[mb_xy][1]= h->intra4x4_pred_mode_cache[7+8*2]; - h->intra4x4_pred_mode[mb_xy][2]= h->intra4x4_pred_mode_cache[7+8*3]; - h->intra4x4_pred_mode[mb_xy][3]= h->intra4x4_pred_mode_cache[7+8*4]; - h->intra4x4_pred_mode[mb_xy][4]= h->intra4x4_pred_mode_cache[4+8*4]; - h->intra4x4_pred_mode[mb_xy][5]= h->intra4x4_pred_mode_cache[5+8*4]; - h->intra4x4_pred_mode[mb_xy][6]= h->intra4x4_pred_mode_cache[6+8*4]; -} - -/** - * checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks. - */ -static inline int check_intra4x4_pred_mode(H264Context *h){ - MpegEncContext * const s = &h->s; - static const int8_t top [12]= {-1, 0,LEFT_DC_PRED,-1,-1,-1,-1,-1, 0}; - static const int8_t left[12]= { 0,-1, TOP_DC_PRED, 0,-1,-1,-1, 0,-1,DC_128_PRED}; - int i; - - if(!(h->top_samples_available&0x8000)){ - for(i=0; i<4; i++){ - int status= top[ h->intra4x4_pred_mode_cache[scan8[0] + i] ]; - if(status<0){ - fprintf(stderr, "top block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y); - return -1; - } else if(status){ - h->intra4x4_pred_mode_cache[scan8[0] + i]= status; - } - } - } - - if(!(h->left_samples_available&0x8000)){ - for(i=0; i<4; i++){ - int status= left[ h->intra4x4_pred_mode_cache[scan8[0] + 8*i] ]; - if(status<0){ - fprintf(stderr, "left block unavailable for requested intra4x4 mode %d at %d %d\n", status, s->mb_x, s->mb_y); - return -1; - } else if(status){ - h->intra4x4_pred_mode_cache[scan8[0] + 8*i]= status; - } - } - } - - return 0; -} //FIXME cleanup like next - -/** - * checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks. - */ -static inline int check_intra_pred_mode(H264Context *h, int mode){ - MpegEncContext * const s = &h->s; - static const int8_t top [7]= {LEFT_DC_PRED8x8, 1,-1,-1}; - static const int8_t left[7]= { TOP_DC_PRED8x8,-1, 2,-1,DC_128_PRED8x8}; - - if(!(h->top_samples_available&0x8000)){ - mode= top[ mode ]; - if(mode<0){ - fprintf(stderr, "top block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y); - return -1; - } - } - - if(!(h->left_samples_available&0x8000)){ - mode= left[ mode ]; - if(mode<0){ - fprintf(stderr, "left block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y); - return -1; - } - } - - return mode; -} - -/** - * gets the predicted intra4x4 prediction mode. - */ -static inline int pred_intra_mode(H264Context *h, int n){ - const int index8= scan8[n]; - const int left= h->intra4x4_pred_mode_cache[index8 - 1]; - const int top = h->intra4x4_pred_mode_cache[index8 - 8]; - const int min= FFMIN(left, top); - - tprintf("mode:%d %d min:%d\n", left ,top, min); - - if(min<0) return DC_PRED; - else return min; -} - -static inline void write_back_non_zero_count(H264Context *h){ - MpegEncContext * const s = &h->s; - const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; - - h->non_zero_count[mb_xy][0]= h->non_zero_count_cache[4+8*4]; - h->non_zero_count[mb_xy][1]= h->non_zero_count_cache[5+8*4]; - h->non_zero_count[mb_xy][2]= h->non_zero_count_cache[6+8*4]; - h->non_zero_count[mb_xy][3]= h->non_zero_count_cache[7+8*4]; - h->non_zero_count[mb_xy][4]= h->non_zero_count_cache[7+8*3]; - h->non_zero_count[mb_xy][5]= h->non_zero_count_cache[7+8*2]; - h->non_zero_count[mb_xy][6]= h->non_zero_count_cache[7+8*1]; - - h->non_zero_count[mb_xy][7]= h->non_zero_count_cache[1+8*2]; - h->non_zero_count[mb_xy][8]= h->non_zero_count_cache[2+8*2]; - h->non_zero_count[mb_xy][9]= h->non_zero_count_cache[2+8*1]; - - h->non_zero_count[mb_xy][10]=h->non_zero_count_cache[1+8*5]; - h->non_zero_count[mb_xy][11]=h->non_zero_count_cache[2+8*5]; - h->non_zero_count[mb_xy][12]=h->non_zero_count_cache[2+8*4]; -} - -/** - * gets the predicted number of non zero coefficients. - * @param n block index - */ -static inline int pred_non_zero_count(H264Context *h, int n){ - const int index8= scan8[n]; - const int left= h->non_zero_count_cache[index8 - 1]; - const int top = h->non_zero_count_cache[index8 - 8]; - int i= left + top; - - if(i<64) i= (i+1)>>1; - - tprintf("pred_nnz L%X T%X n%d s%d P%X\n", left, top, n, scan8[n], i&31); - - return i&31; -} - -static inline int fetch_diagonal_mv(H264Context *h, const int16_t **C, int i, int list, int part_width){ - const int topright_ref= h->ref_cache[list][ i - 8 + part_width ]; - - if(topright_ref != PART_NOT_AVAILABLE){ - *C= h->mv_cache[list][ i - 8 + part_width ]; - return topright_ref; - }else{ - tprintf("topright MV not available\n"); - - *C= h->mv_cache[list][ i - 8 - 1 ]; - return h->ref_cache[list][ i - 8 - 1 ]; - } -} - -/** - * gets the predicted MV. - * @param n the block index - * @param part_width the width of the partition (4, 8,16) -> (1, 2, 4) - * @param mx the x component of the predicted motion vector - * @param my the y component of the predicted motion vector - */ -static inline void pred_motion(H264Context * const h, int n, int part_width, int list, int ref, int * const mx, int * const my){ - const int index8= scan8[n]; - const int top_ref= h->ref_cache[list][ index8 - 8 ]; - const int left_ref= h->ref_cache[list][ index8 - 1 ]; - const int16_t * const A= h->mv_cache[list][ index8 - 1 ]; - const int16_t * const B= h->mv_cache[list][ index8 - 8 ]; - const int16_t * C; - int diagonal_ref, match_count; - - assert(part_width==1 || part_width==2 || part_width==4); - -/* mv_cache - B . . A T T T T - U . . L . . , . - U . . L . . . . - U . . L . . , . - . . . L . . . . -*/ - - diagonal_ref= fetch_diagonal_mv(h, &C, index8, list, part_width); - match_count= (diagonal_ref==ref) + (top_ref==ref) + (left_ref==ref); - if(match_count > 1){ //most common - *mx= mid_pred(A[0], B[0], C[0]); - *my= mid_pred(A[1], B[1], C[1]); - }else if(match_count==1){ - if(left_ref==ref){ - *mx= A[0]; - *my= A[1]; - }else if(top_ref==ref){ - *mx= B[0]; - *my= B[1]; - }else{ - *mx= C[0]; - *my= C[1]; - } - }else{ - if(top_ref == PART_NOT_AVAILABLE && diagonal_ref == PART_NOT_AVAILABLE && left_ref != PART_NOT_AVAILABLE){ - *mx= A[0]; - *my= A[1]; - }else{ - *mx= mid_pred(A[0], B[0], C[0]); - *my= mid_pred(A[1], B[1], C[1]); - } - } - - tprintf("pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\n", top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref, A[0], A[1], ref, *mx, *my, h->s.mb_x, h->s.mb_y, n, list); -} - -/** - * gets the directionally predicted 16x8 MV. - * @param n the block index - * @param mx the x component of the predicted motion vector - * @param my the y component of the predicted motion vector - */ -static inline void pred_16x8_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){ - if(n==0){ - const int top_ref= h->ref_cache[list][ scan8[0] - 8 ]; - const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ]; - - tprintf("pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d", top_ref, B[0], B[1], h->s.mb_x, h->s.mb_y, n, list); - - if(top_ref == ref){ - *mx= B[0]; - *my= B[1]; - return; - } - }else{ - const int left_ref= h->ref_cache[list][ scan8[8] - 1 ]; - const int16_t * const A= h->mv_cache[list][ scan8[8] - 1 ]; - - tprintf("pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d", left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list); - - if(left_ref == ref){ - *mx= A[0]; - *my= A[1]; - return; - } - } - - //RARE - pred_motion(h, n, 4, list, ref, mx, my); -} - -/** - * gets the directionally predicted 8x16 MV. - * @param n the block index - * @param mx the x component of the predicted motion vector - * @param my the y component of the predicted motion vector - */ -static inline void pred_8x16_motion(H264Context * const h, int n, int list, int ref, int * const mx, int * const my){ - if(n==0){ - const int left_ref= h->ref_cache[list][ scan8[0] - 1 ]; - const int16_t * const A= h->mv_cache[list][ scan8[0] - 1 ]; - - tprintf("pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d", left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list); - - if(left_ref == ref){ - *mx= A[0]; - *my= A[1]; - return; - } - }else{ - const int16_t * C; - int diagonal_ref; - - diagonal_ref= fetch_diagonal_mv(h, &C, scan8[4], list, 2); - - tprintf("pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d", diagonal_ref, C[0], C[1], h->s.mb_x, h->s.mb_y, n, list); - - if(diagonal_ref == ref){ - *mx= C[0]; - *my= C[1]; - return; - } - } - - //RARE - pred_motion(h, n, 2, list, ref, mx, my); -} - -static inline void pred_pskip_motion(H264Context * const h, int * const mx, int * const my){ - const int top_ref = h->ref_cache[0][ scan8[0] - 8 ]; - const int left_ref= h->ref_cache[0][ scan8[0] - 1 ]; - - tprintf("pred_pskip: (%d) (%d) at %2d %2d", top_ref, left_ref, h->s.mb_x, h->s.mb_y); - - if(top_ref == PART_NOT_AVAILABLE || left_ref == PART_NOT_AVAILABLE - || (top_ref == 0 && *(uint32_t*)h->mv_cache[0][ scan8[0] - 8 ] == 0) - || (left_ref == 0 && *(uint32_t*)h->mv_cache[0][ scan8[0] - 1 ] == 0)){ - - *mx = *my = 0; - return; - } - - pred_motion(h, 0, 4, 0, 0, mx, my); - - return; -} - -static inline void write_back_motion(H264Context *h, int mb_type){ - MpegEncContext * const s = &h->s; - const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride; - const int b8_xy= 2*s->mb_x + 2*s->mb_y*h->b8_stride; - int list; - - for(list=0; list<2; list++){ - int y; - if((!IS_8X8(mb_type)) && !USES_LIST(mb_type, list)){ - if(1){ //FIXME skip or never read if mb_type doesnt use it - for(y=0; y<4; y++){ - *(uint64_t*)s->current_picture.motion_val[list][b_xy + 0 + y*h->b_stride]= - *(uint64_t*)s->current_picture.motion_val[list][b_xy + 2 + y*h->b_stride]= 0; - } - for(y=0; y<2; y++){ - *(uint16_t*)s->current_picture.motion_val[list][b8_xy + y*h->b8_stride]= (LIST_NOT_USED&0xFF)*0x0101; - } - } - continue; //FIXME direct mode ... - } - - for(y=0; y<4; y++){ - *(uint64_t*)s->current_picture.motion_val[list][b_xy + 0 + y*h->b_stride]= *(uint64_t*)h->mv_cache[list][scan8[0]+0 + 8*y]; - *(uint64_t*)s->current_picture.motion_val[list][b_xy + 2 + y*h->b_stride]= *(uint64_t*)h->mv_cache[list][scan8[0]+2 + 8*y]; - } - for(y=0; y<2; y++){ - s->current_picture.ref_index[list][b8_xy + 0 + y*h->b8_stride]= h->ref_cache[list][scan8[0]+0 + 16*y]; - s->current_picture.ref_index[list][b8_xy + 1 + y*h->b8_stride]= h->ref_cache[list][scan8[0]+2 + 16*y]; - } - } -} - -/** - * Decodes a network abstraction layer unit. - * @param consumed is the number of bytes used as input - * @param length is the length of the array - * @param dst_length is the number of decoded bytes FIXME here or a decode rbsp ttailing? - * @returns decoded bytes, might be src+1 if no escapes - */ -static uint8_t *decode_nal(H264Context *h, uint8_t *src, int *dst_length, int *consumed, int length){ - int i, si, di; - uint8_t *dst; - -// src[0]&0x80; //forbidden bit - h->nal_ref_idc= src[0]>>5; - h->nal_unit_type= src[0]&0x1F; - - src++; length--; -#if 0 - for(i=0; i0 && src[i-1]==0) i--; - if(i+2=length-1){ //no escaped 0 - *dst_length= length; - *consumed= length+1; //+1 for the header - return src; - } - - h->rbsp_buffer= av_fast_realloc(h->rbsp_buffer, &h->rbsp_buffer_size, length); - dst= h->rbsp_buffer; - -//printf("deoding esc\n"); - si=di=0; - while(si=0); - assert(dst_length>0); - - dst[0]= (h->nal_ref_idc<<5) + h->nal_unit_type; - - if(length==0) return 1; - - escape_count= 0; - for(i=0; i0 && src[i-1]==0) - i--; - if(i+2 dst_length) - return -1; - - //this should be damn rare (hopefully) - - h->rbsp_buffer= av_fast_realloc(h->rbsp_buffer, &h->rbsp_buffer_size, length + escape_count); - temp= h->rbsp_buffer; -//printf("encoding esc\n"); - - si= 0; - di= 0; - while(si < length){ - if(si+2>=1; - } - return 0; -} - -/** - * idct tranforms the 16 dc values and dequantize them. - * @param qp quantization parameter - */ -static void h264_luma_dc_dequant_idct_c(DCTELEM *block, int qp){ - const int qmul= dequant_coeff[qp][0]; -#define stride 16 - int i; - int temp[16]; //FIXME check if this is a good idea - static const int x_offset[4]={0, 1*stride, 4* stride, 5*stride}; - static const int y_offset[4]={0, 2*stride, 8* stride, 10*stride}; - -//memset(block, 64, 2*256); -//return; - for(i=0; i<4; i++){ - const int offset= y_offset[i]; - const int z0= block[offset+stride*0] + block[offset+stride*4]; - const int z1= block[offset+stride*0] - block[offset+stride*4]; - const int z2= block[offset+stride*1] - block[offset+stride*5]; - const int z3= block[offset+stride*1] + block[offset+stride*5]; - - temp[4*i+0]= z0+z3; - temp[4*i+1]= z1+z2; - temp[4*i+2]= z1-z2; - temp[4*i+3]= z0-z3; - } - - for(i=0; i<4; i++){ - const int offset= x_offset[i]; - const int z0= temp[4*0+i] + temp[4*2+i]; - const int z1= temp[4*0+i] - temp[4*2+i]; - const int z2= temp[4*1+i] - temp[4*3+i]; - const int z3= temp[4*1+i] + temp[4*3+i]; - - block[stride*0 +offset]= ((z0 + z3)*qmul + 2)>>2; //FIXME think about merging this into decode_resdual - block[stride*2 +offset]= ((z1 + z2)*qmul + 2)>>2; - block[stride*8 +offset]= ((z1 - z2)*qmul + 2)>>2; - block[stride*10+offset]= ((z0 - z3)*qmul + 2)>>2; - } -} - -/** - * dct tranforms the 16 dc values. - * @param qp quantization parameter ??? FIXME - */ -static void h264_luma_dc_dct_c(DCTELEM *block/*, int qp*/){ -// const int qmul= dequant_coeff[qp][0]; - int i; - int temp[16]; //FIXME check if this is a good idea - static const int x_offset[4]={0, 1*stride, 4* stride, 5*stride}; - static const int y_offset[4]={0, 2*stride, 8* stride, 10*stride}; - - for(i=0; i<4; i++){ - const int offset= y_offset[i]; - const int z0= block[offset+stride*0] + block[offset+stride*4]; - const int z1= block[offset+stride*0] - block[offset+stride*4]; - const int z2= block[offset+stride*1] - block[offset+stride*5]; - const int z3= block[offset+stride*1] + block[offset+stride*5]; - - temp[4*i+0]= z0+z3; - temp[4*i+1]= z1+z2; - temp[4*i+2]= z1-z2; - temp[4*i+3]= z0-z3; - } - - for(i=0; i<4; i++){ - const int offset= x_offset[i]; - const int z0= temp[4*0+i] + temp[4*2+i]; - const int z1= temp[4*0+i] - temp[4*2+i]; - const int z2= temp[4*1+i] - temp[4*3+i]; - const int z3= temp[4*1+i] + temp[4*3+i]; - - block[stride*0 +offset]= (z0 + z3)>>1; - block[stride*2 +offset]= (z1 + z2)>>1; - block[stride*8 +offset]= (z1 - z2)>>1; - block[stride*10+offset]= (z0 - z3)>>1; - } -} -#undef xStride -#undef stride - -static void chroma_dc_dequant_idct_c(DCTELEM *block, int qp){ - const int qmul= dequant_coeff[qp][0]; - const int stride= 16*2; - const int xStride= 16; - int a,b,c,d,e; - - a= block[stride*0 + xStride*0]; - b= block[stride*0 + xStride*1]; - c= block[stride*1 + xStride*0]; - d= block[stride*1 + xStride*1]; - - e= a-b; - a= a+b; - b= c-d; - c= c+d; - - block[stride*0 + xStride*0]= ((a+c)*qmul + 0)>>1; - block[stride*0 + xStride*1]= ((e+b)*qmul + 0)>>1; - block[stride*1 + xStride*0]= ((a-c)*qmul + 0)>>1; - block[stride*1 + xStride*1]= ((e-b)*qmul + 0)>>1; -} - -static void chroma_dc_dct_c(DCTELEM *block){ - const int stride= 16*2; - const int xStride= 16; - int a,b,c,d,e; - - a= block[stride*0 + xStride*0]; - b= block[stride*0 + xStride*1]; - c= block[stride*1 + xStride*0]; - d= block[stride*1 + xStride*1]; - - e= a-b; - a= a+b; - b= c-d; - c= c+d; - - block[stride*0 + xStride*0]= (a+c); - block[stride*0 + xStride*1]= (e+b); - block[stride*1 + xStride*0]= (a-c); - block[stride*1 + xStride*1]= (e-b); -} - -/** - * gets the chroma qp. - */ -static inline int get_chroma_qp(H264Context *h, int qscale){ - - return chroma_qp[clip(qscale + h->pps.chroma_qp_index_offset, 0, 51)]; -} - - -/** - * - */ -static void h264_add_idct_c(uint8_t *dst, DCTELEM *block, int stride){ - int i; - uint8_t *cm = cropTbl + MAX_NEG_CROP; - - block[0] += 32; -#if 1 - for(i=0; i<4; i++){ - const int z0= block[i + 4*0] + block[i + 4*2]; - const int z1= block[i + 4*0] - block[i + 4*2]; - const int z2= (block[i + 4*1]>>1) - block[i + 4*3]; - const int z3= block[i + 4*1] + (block[i + 4*3]>>1); - - block[i + 4*0]= z0 + z3; - block[i + 4*1]= z1 + z2; - block[i + 4*2]= z1 - z2; - block[i + 4*3]= z0 - z3; - } - - for(i=0; i<4; i++){ - const int z0= block[0 + 4*i] + block[2 + 4*i]; - const int z1= block[0 + 4*i] - block[2 + 4*i]; - const int z2= (block[1 + 4*i]>>1) - block[3 + 4*i]; - const int z3= block[1 + 4*i] + (block[3 + 4*i]>>1); - - dst[0 + i*stride]= cm[ dst[0 + i*stride] + ((z0 + z3) >> 6) ]; - dst[1 + i*stride]= cm[ dst[1 + i*stride] + ((z1 + z2) >> 6) ]; - dst[2 + i*stride]= cm[ dst[2 + i*stride] + ((z1 - z2) >> 6) ]; - dst[3 + i*stride]= cm[ dst[3 + i*stride] + ((z0 - z3) >> 6) ]; - } -#else - for(i=0; i<4; i++){ - const int z0= block[0 + 4*i] + block[2 + 4*i]; - const int z1= block[0 + 4*i] - block[2 + 4*i]; - const int z2= (block[1 + 4*i]>>1) - block[3 + 4*i]; - const int z3= block[1 + 4*i] + (block[3 + 4*i]>>1); - - block[0 + 4*i]= z0 + z3; - block[1 + 4*i]= z1 + z2; - block[2 + 4*i]= z1 - z2; - block[3 + 4*i]= z0 - z3; - } - - for(i=0; i<4; i++){ - const int z0= block[i + 4*0] + block[i + 4*2]; - const int z1= block[i + 4*0] - block[i + 4*2]; - const int z2= (block[i + 4*1]>>1) - block[i + 4*3]; - const int z3= block[i + 4*1] + (block[i + 4*3]>>1); - - dst[i + 0*stride]= cm[ dst[i + 0*stride] + ((z0 + z3) >> 6) ]; - dst[i + 1*stride]= cm[ dst[i + 1*stride] + ((z1 + z2) >> 6) ]; - dst[i + 2*stride]= cm[ dst[i + 2*stride] + ((z1 - z2) >> 6) ]; - dst[i + 3*stride]= cm[ dst[i + 3*stride] + ((z0 - z3) >> 6) ]; - } -#endif -} - -static void h264_diff_dct_c(DCTELEM *block, uint8_t *src1, uint8_t *src2, int stride){ - int i; - //FIXME try int temp instead of block - - for(i=0; i<4; i++){ - const int d0= src1[0 + i*stride] - src2[0 + i*stride]; - const int d1= src1[1 + i*stride] - src2[1 + i*stride]; - const int d2= src1[2 + i*stride] - src2[2 + i*stride]; - const int d3= src1[3 + i*stride] - src2[3 + i*stride]; - const int z0= d0 + d3; - const int z3= d0 - d3; - const int z1= d1 + d2; - const int z2= d1 - d2; - - block[0 + 4*i]= z0 + z1; - block[1 + 4*i]= 2*z3 + z2; - block[2 + 4*i]= z0 - z1; - block[3 + 4*i]= z3 - 2*z2; - } - - for(i=0; i<4; i++){ - const int z0= block[0*4 + i] + block[3*4 + i]; - const int z3= block[0*4 + i] - block[3*4 + i]; - const int z1= block[1*4 + i] + block[2*4 + i]; - const int z2= block[1*4 + i] - block[2*4 + i]; - - block[0*4 + i]= z0 + z1; - block[1*4 + i]= 2*z3 + z2; - block[2*4 + i]= z0 - z1; - block[3*4 + i]= z3 - 2*z2; - } -} - -//FIXME need to check that this doesnt overflow signed 32 bit for low qp, iam not sure, its very close -//FIXME check that gcc inlines this (and optimizes intra & seperate_dc stuff away) -static inline int quantize_c(DCTELEM *block, uint8_t *scantable, int qscale, int intra, int seperate_dc){ - int i; - const int * const quant_table= quant_coeff[qscale]; - const int bias= intra ? (1<dc_threshold2){ - if(level>0){ - level= (dc_bias + level)>>(QUANT_SHIFT-2); - block[0]= level; - }else{ - level= (dc_bias - level)>>(QUANT_SHIFT-2); - block[0]= -level; - } -// last_non_zero = i; - }else{ - block[0]=0; - } - }else{ - const int dc_bias= intra ? (1<<(QUANT_SHIFT+1))/3 : (1<<(QUANT_SHIFT+1))/6; - const unsigned int dc_threshold1= (1<<(QUANT_SHIFT+1)) - dc_bias - 1; - const unsigned int dc_threshold2= (dc_threshold1<<1); - - int level= block[0]*quant_table[0]; - if(((unsigned)(level+dc_threshold1))>dc_threshold2){ - if(level>0){ - level= (dc_bias + level)>>(QUANT_SHIFT+1); - block[0]= level; - }else{ - level= (dc_bias - level)>>(QUANT_SHIFT+1); - block[0]= -level; - } -// last_non_zero = i; - }else{ - block[0]=0; - } - } - last_non_zero= 0; - i=1; - }else{ - last_non_zero= -1; - i=0; - } - - for(; i<16; i++){ - const int j= scantable[i]; - int level= block[j]*quant_table[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)>>QUANT_SHIFT; - block[j]= level; - }else{ - level= (bias - level)>>QUANT_SHIFT; - block[j]= -level; - } - last_non_zero = i; - }else{ - block[j]=0; - } - } - - return last_non_zero; -} - -static void pred4x4_vertical_c(uint8_t *src, uint8_t *topright, int stride){ - const uint32_t a= ((uint32_t*)(src-stride))[0]; - ((uint32_t*)(src+0*stride))[0]= a; - ((uint32_t*)(src+1*stride))[0]= a; - ((uint32_t*)(src+2*stride))[0]= a; - ((uint32_t*)(src+3*stride))[0]= a; -} - -static void pred4x4_horizontal_c(uint8_t *src, uint8_t *topright, int stride){ - ((uint32_t*)(src+0*stride))[0]= src[-1+0*stride]*0x01010101; - ((uint32_t*)(src+1*stride))[0]= src[-1+1*stride]*0x01010101; - ((uint32_t*)(src+2*stride))[0]= src[-1+2*stride]*0x01010101; - ((uint32_t*)(src+3*stride))[0]= src[-1+3*stride]*0x01010101; -} - -static void pred4x4_dc_c(uint8_t *src, uint8_t *topright, int stride){ - const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride] - + src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 4) >>3; - - ((uint32_t*)(src+0*stride))[0]= - ((uint32_t*)(src+1*stride))[0]= - ((uint32_t*)(src+2*stride))[0]= - ((uint32_t*)(src+3*stride))[0]= dc* 0x01010101; -} - -static void pred4x4_left_dc_c(uint8_t *src, uint8_t *topright, int stride){ - const int dc= ( src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 2) >>2; - - ((uint32_t*)(src+0*stride))[0]= - ((uint32_t*)(src+1*stride))[0]= - ((uint32_t*)(src+2*stride))[0]= - ((uint32_t*)(src+3*stride))[0]= dc* 0x01010101; -} - -static void pred4x4_top_dc_c(uint8_t *src, uint8_t *topright, int stride){ - const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride] + 2) >>2; - - ((uint32_t*)(src+0*stride))[0]= - ((uint32_t*)(src+1*stride))[0]= - ((uint32_t*)(src+2*stride))[0]= - ((uint32_t*)(src+3*stride))[0]= dc* 0x01010101; -} - -static void pred4x4_128_dc_c(uint8_t *src, uint8_t *topright, int stride){ - ((uint32_t*)(src+0*stride))[0]= - ((uint32_t*)(src+1*stride))[0]= - ((uint32_t*)(src+2*stride))[0]= - ((uint32_t*)(src+3*stride))[0]= 128U*0x01010101U; -} - - -#define LOAD_TOP_RIGHT_EDGE\ - const int t4= topright[0];\ - const int t5= topright[1];\ - const int t6= topright[2];\ - const int t7= topright[3];\ - -#define LOAD_LEFT_EDGE\ - const int l0= src[-1+0*stride];\ - const int l1= src[-1+1*stride];\ - const int l2= src[-1+2*stride];\ - const int l3= src[-1+3*stride];\ - -#define LOAD_TOP_EDGE\ - const int t0= src[ 0-1*stride];\ - const int t1= src[ 1-1*stride];\ - const int t2= src[ 2-1*stride];\ - const int t3= src[ 3-1*stride];\ - -static void pred4x4_down_right_c(uint8_t *src, uint8_t *topright, int stride){ - const int lt= src[-1-1*stride]; - LOAD_TOP_EDGE - LOAD_LEFT_EDGE - - src[0+3*stride]=(l3 + 2*l2 + l1 + 2)>>2; - src[0+2*stride]= - src[1+3*stride]=(l2 + 2*l1 + l0 + 2)>>2; - src[0+1*stride]= - src[1+2*stride]= - src[2+3*stride]=(l1 + 2*l0 + lt + 2)>>2; - src[0+0*stride]= - src[1+1*stride]= - src[2+2*stride]= - src[3+3*stride]=(l0 + 2*lt + t0 + 2)>>2; - src[1+0*stride]= - src[2+1*stride]= - src[3+2*stride]=(lt + 2*t0 + t1 + 2)>>2; - src[2+0*stride]= - src[3+1*stride]=(t0 + 2*t1 + t2 + 2)>>2; - src[3+0*stride]=(t1 + 2*t2 + t3 + 2)>>2; -} - -static void pred4x4_down_left_c(uint8_t *src, uint8_t *topright, int stride){ - LOAD_TOP_EDGE - LOAD_TOP_RIGHT_EDGE -// LOAD_LEFT_EDGE - - src[0+0*stride]=(t0 + t2 + 2*t1 + 2)>>2; - src[1+0*stride]= - src[0+1*stride]=(t1 + t3 + 2*t2 + 2)>>2; - src[2+0*stride]= - src[1+1*stride]= - src[0+2*stride]=(t2 + t4 + 2*t3 + 2)>>2; - src[3+0*stride]= - src[2+1*stride]= - src[1+2*stride]= - src[0+3*stride]=(t3 + t5 + 2*t4 + 2)>>2; - src[3+1*stride]= - src[2+2*stride]= - src[1+3*stride]=(t4 + t6 + 2*t5 + 2)>>2; - src[3+2*stride]= - src[2+3*stride]=(t5 + t7 + 2*t6 + 2)>>2; - src[3+3*stride]=(t6 + 3*t7 + 2)>>2; -} - -static void pred4x4_vertical_right_c(uint8_t *src, uint8_t *topright, int stride){ - const int lt= src[-1-1*stride]; - LOAD_TOP_EDGE - LOAD_LEFT_EDGE - const __attribute__((unused)) int unu= l3; - - src[0+0*stride]= - src[1+2*stride]=(lt + t0 + 1)>>1; - src[1+0*stride]= - src[2+2*stride]=(t0 + t1 + 1)>>1; - src[2+0*stride]= - src[3+2*stride]=(t1 + t2 + 1)>>1; - src[3+0*stride]=(t2 + t3 + 1)>>1; - src[0+1*stride]= - src[1+3*stride]=(l0 + 2*lt + t0 + 2)>>2; - src[1+1*stride]= - src[2+3*stride]=(lt + 2*t0 + t1 + 2)>>2; - src[2+1*stride]= - src[3+3*stride]=(t0 + 2*t1 + t2 + 2)>>2; - src[3+1*stride]=(t1 + 2*t2 + t3 + 2)>>2; - src[0+2*stride]=(lt + 2*l0 + l1 + 2)>>2; - src[0+3*stride]=(l0 + 2*l1 + l2 + 2)>>2; -} - -static void pred4x4_vertical_left_c(uint8_t *src, uint8_t *topright, int stride){ - LOAD_TOP_EDGE - LOAD_TOP_RIGHT_EDGE - const __attribute__((unused)) int unu= t7; - - src[0+0*stride]=(t0 + t1 + 1)>>1; - src[1+0*stride]= - src[0+2*stride]=(t1 + t2 + 1)>>1; - src[2+0*stride]= - src[1+2*stride]=(t2 + t3 + 1)>>1; - src[3+0*stride]= - src[2+2*stride]=(t3 + t4+ 1)>>1; - src[3+2*stride]=(t4 + t5+ 1)>>1; - src[0+1*stride]=(t0 + 2*t1 + t2 + 2)>>2; - src[1+1*stride]= - src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2; - src[2+1*stride]= - src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2; - src[3+1*stride]= - src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2; - src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2; -} - -static void pred4x4_horizontal_up_c(uint8_t *src, uint8_t *topright, int stride){ - LOAD_LEFT_EDGE - - src[0+0*stride]=(l0 + l1 + 1)>>1; - src[1+0*stride]=(l0 + 2*l1 + l2 + 2)>>2; - src[2+0*stride]= - src[0+1*stride]=(l1 + l2 + 1)>>1; - src[3+0*stride]= - src[1+1*stride]=(l1 + 2*l2 + l3 + 2)>>2; - src[2+1*stride]= - src[0+2*stride]=(l2 + l3 + 1)>>1; - src[3+1*stride]= - src[1+2*stride]=(l2 + 2*l3 + l3 + 2)>>2; - src[3+2*stride]= - src[1+3*stride]= - src[0+3*stride]= - src[2+2*stride]= - src[2+3*stride]= - src[3+3*stride]=l3; -} - -static void pred4x4_horizontal_down_c(uint8_t *src, uint8_t *topright, int stride){ - const int lt= src[-1-1*stride]; - LOAD_TOP_EDGE - LOAD_LEFT_EDGE - const __attribute__((unused)) int unu= t3; - - src[0+0*stride]= - src[2+1*stride]=(lt + l0 + 1)>>1; - src[1+0*stride]= - src[3+1*stride]=(l0 + 2*lt + t0 + 2)>>2; - src[2+0*stride]=(lt + 2*t0 + t1 + 2)>>2; - src[3+0*stride]=(t0 + 2*t1 + t2 + 2)>>2; - src[0+1*stride]= - src[2+2*stride]=(l0 + l1 + 1)>>1; - src[1+1*stride]= - src[3+2*stride]=(lt + 2*l0 + l1 + 2)>>2; - src[0+2*stride]= - src[2+3*stride]=(l1 + l2+ 1)>>1; - src[1+2*stride]= - src[3+3*stride]=(l0 + 2*l1 + l2 + 2)>>2; - src[0+3*stride]=(l2 + l3 + 1)>>1; - src[1+3*stride]=(l1 + 2*l2 + l3 + 2)>>2; -} - -static void pred16x16_vertical_c(uint8_t *src, int stride){ - int i; - const uint32_t a= ((uint32_t*)(src-stride))[0]; - const uint32_t b= ((uint32_t*)(src-stride))[1]; - const uint32_t c= ((uint32_t*)(src-stride))[2]; - const uint32_t d= ((uint32_t*)(src-stride))[3]; - - for(i=0; i<16; i++){ - ((uint32_t*)(src+i*stride))[0]= a; - ((uint32_t*)(src+i*stride))[1]= b; - ((uint32_t*)(src+i*stride))[2]= c; - ((uint32_t*)(src+i*stride))[3]= d; - } -} - -static void pred16x16_horizontal_c(uint8_t *src, int stride){ - int i; - - for(i=0; i<16; i++){ - ((uint32_t*)(src+i*stride))[0]= - ((uint32_t*)(src+i*stride))[1]= - ((uint32_t*)(src+i*stride))[2]= - ((uint32_t*)(src+i*stride))[3]= src[-1+i*stride]*0x01010101; - } -} - -static void pred16x16_dc_c(uint8_t *src, int stride){ - int i, dc=0; - - for(i=0;i<16; i++){ - dc+= src[-1+i*stride]; - } - - for(i=0;i<16; i++){ - dc+= src[i-stride]; - } - - dc= 0x01010101*((dc + 16)>>5); - - for(i=0; i<16; i++){ - ((uint32_t*)(src+i*stride))[0]= - ((uint32_t*)(src+i*stride))[1]= - ((uint32_t*)(src+i*stride))[2]= - ((uint32_t*)(src+i*stride))[3]= dc; - } -} - -static void pred16x16_left_dc_c(uint8_t *src, int stride){ - int i, dc=0; - - for(i=0;i<16; i++){ - dc+= src[-1+i*stride]; - } - - dc= 0x01010101*((dc + 8)>>4); - - for(i=0; i<16; i++){ - ((uint32_t*)(src+i*stride))[0]= - ((uint32_t*)(src+i*stride))[1]= - ((uint32_t*)(src+i*stride))[2]= - ((uint32_t*)(src+i*stride))[3]= dc; - } -} - -static void pred16x16_top_dc_c(uint8_t *src, int stride){ - int i, dc=0; - - for(i=0;i<16; i++){ - dc+= src[i-stride]; - } - dc= 0x01010101*((dc + 8)>>4); - - for(i=0; i<16; i++){ - ((uint32_t*)(src+i*stride))[0]= - ((uint32_t*)(src+i*stride))[1]= - ((uint32_t*)(src+i*stride))[2]= - ((uint32_t*)(src+i*stride))[3]= dc; - } -} - -static void pred16x16_128_dc_c(uint8_t *src, int stride){ - int i; - - for(i=0; i<16; i++){ - ((uint32_t*)(src+i*stride))[0]= - ((uint32_t*)(src+i*stride))[1]= - ((uint32_t*)(src+i*stride))[2]= - ((uint32_t*)(src+i*stride))[3]= 0x01010101U*128U; - } -} - -static inline void pred16x16_plane_compat_c(uint8_t *src, int stride, const int svq3){ - int i, j, k; - int a; - uint8_t *cm = cropTbl + MAX_NEG_CROP; - const uint8_t * const src0 = src+7-stride; - const uint8_t *src1 = src+8*stride-1; - const uint8_t *src2 = src1-2*stride; // == src+6*stride-1; - int H = src0[1] - src0[-1]; - int V = src1[0] - src2[ 0]; - for(k=2; k<=8; ++k) { - src1 += stride; src2 -= stride; - H += k*(src0[k] - src0[-k]); - V += k*(src1[0] - src2[ 0]); - } - if(svq3){ - H = ( 5*(H/4) ) / 16; - V = ( 5*(V/4) ) / 16; - - /* required for 100% accuracy */ - i = H; H = V; V = i; - }else{ - H = ( 5*H+32 ) >> 6; - V = ( 5*V+32 ) >> 6; - } - - a = 16*(src1[0] + src2[16] + 1) - 7*(V+H); - for(j=16; j>0; --j) { - int b = a; - a += V; - for(i=-16; i<0; i+=4) { - src[16+i] = cm[ (b ) >> 5 ]; - src[17+i] = cm[ (b+ H) >> 5 ]; - src[18+i] = cm[ (b+2*H) >> 5 ]; - src[19+i] = cm[ (b+3*H) >> 5 ]; - b += 4*H; - } - src += stride; - } -} - -static void pred16x16_plane_c(uint8_t *src, int stride){ - pred16x16_plane_compat_c(src, stride, 0); -} - -static void pred8x8_vertical_c(uint8_t *src, int stride){ - int i; - const uint32_t a= ((uint32_t*)(src-stride))[0]; - const uint32_t b= ((uint32_t*)(src-stride))[1]; - - for(i=0; i<8; i++){ - ((uint32_t*)(src+i*stride))[0]= a; - ((uint32_t*)(src+i*stride))[1]= b; - } -} - -static void pred8x8_horizontal_c(uint8_t *src, int stride){ - int i; - - for(i=0; i<8; i++){ - ((uint32_t*)(src+i*stride))[0]= - ((uint32_t*)(src+i*stride))[1]= src[-1+i*stride]*0x01010101; - } -} - -static void pred8x8_128_dc_c(uint8_t *src, int stride){ - int i; - - for(i=0; i<4; i++){ - ((uint32_t*)(src+i*stride))[0]= - ((uint32_t*)(src+i*stride))[1]= 0x01010101U*128U; - } - for(i=4; i<8; i++){ - ((uint32_t*)(src+i*stride))[0]= - ((uint32_t*)(src+i*stride))[1]= 0x01010101U*128U; - } -} - -static void pred8x8_left_dc_c(uint8_t *src, int stride){ - int i; - int dc0, dc2; - - dc0=dc2=0; - for(i=0;i<4; i++){ - dc0+= src[-1+i*stride]; - dc2+= src[-1+(i+4)*stride]; - } - dc0= 0x01010101*((dc0 + 2)>>2); - dc2= 0x01010101*((dc2 + 2)>>2); - - for(i=0; i<4; i++){ - ((uint32_t*)(src+i*stride))[0]= - ((uint32_t*)(src+i*stride))[1]= dc0; - } - for(i=4; i<8; i++){ - ((uint32_t*)(src+i*stride))[0]= - ((uint32_t*)(src+i*stride))[1]= dc2; - } -} - -static void pred8x8_top_dc_c(uint8_t *src, int stride){ - int i; - int dc0, dc1; - - dc0=dc1=0; - for(i=0;i<4; i++){ - dc0+= src[i-stride]; - dc1+= src[4+i-stride]; - } - dc0= 0x01010101*((dc0 + 2)>>2); - dc1= 0x01010101*((dc1 + 2)>>2); - - for(i=0; i<4; i++){ - ((uint32_t*)(src+i*stride))[0]= dc0; - ((uint32_t*)(src+i*stride))[1]= dc1; - } - for(i=4; i<8; i++){ - ((uint32_t*)(src+i*stride))[0]= dc0; - ((uint32_t*)(src+i*stride))[1]= dc1; - } -} - - -static void pred8x8_dc_c(uint8_t *src, int stride){ - int i; - int dc0, dc1, dc2, dc3; - - dc0=dc1=dc2=0; - for(i=0;i<4; i++){ - dc0+= src[-1+i*stride] + src[i-stride]; - dc1+= src[4+i-stride]; - dc2+= src[-1+(i+4)*stride]; - } - dc3= 0x01010101*((dc1 + dc2 + 4)>>3); - dc0= 0x01010101*((dc0 + 4)>>3); - dc1= 0x01010101*((dc1 + 2)>>2); - dc2= 0x01010101*((dc2 + 2)>>2); - - for(i=0; i<4; i++){ - ((uint32_t*)(src+i*stride))[0]= dc0; - ((uint32_t*)(src+i*stride))[1]= dc1; - } - for(i=4; i<8; i++){ - ((uint32_t*)(src+i*stride))[0]= dc2; - ((uint32_t*)(src+i*stride))[1]= dc3; - } -} - -static void pred8x8_plane_c(uint8_t *src, int stride){ - int j, k; - int a; - uint8_t *cm = cropTbl + MAX_NEG_CROP; - const uint8_t * const src0 = src+3-stride; - const uint8_t *src1 = src+4*stride-1; - const uint8_t *src2 = src1-2*stride; // == src+2*stride-1; - int H = src0[1] - src0[-1]; - int V = src1[0] - src2[ 0]; - for(k=2; k<=4; ++k) { - src1 += stride; src2 -= stride; - H += k*(src0[k] - src0[-k]); - V += k*(src1[0] - src2[ 0]); - } - H = ( 17*H+16 ) >> 5; - V = ( 17*V+16 ) >> 5; - - a = 16*(src1[0] + src2[8]+1) - 3*(V+H); - for(j=8; j>0; --j) { - int b = a; - a += V; - src[0] = cm[ (b ) >> 5 ]; - src[1] = cm[ (b+ H) >> 5 ]; - src[2] = cm[ (b+2*H) >> 5 ]; - src[3] = cm[ (b+3*H) >> 5 ]; - src[4] = cm[ (b+4*H) >> 5 ]; - src[5] = cm[ (b+5*H) >> 5 ]; - src[6] = cm[ (b+6*H) >> 5 ]; - src[7] = cm[ (b+7*H) >> 5 ]; - src += stride; - } -} - -static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square, int chroma_height, int delta, int list, - uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, - int src_x_offset, int src_y_offset, - qpel_mc_func *qpix_op, h264_chroma_mc_func chroma_op){ - MpegEncContext * const s = &h->s; - const int mx= h->mv_cache[list][ scan8[n] ][0] + src_x_offset*8; - const int my= h->mv_cache[list][ scan8[n] ][1] + src_y_offset*8; - const int luma_xy= (mx&3) + ((my&3)<<2); - uint8_t * src_y = pic->data[0] + (mx>>2) + (my>>2)*s->linesize; - uint8_t * src_cb= pic->data[1] + (mx>>3) + (my>>3)*s->uvlinesize; - uint8_t * src_cr= pic->data[2] + (mx>>3) + (my>>3)*s->uvlinesize; - int extra_width= (s->flags&CODEC_FLAG_EMU_EDGE) ? 0 : 16; //FIXME increase edge?, IMHO not worth it - int extra_height= extra_width; - int emu=0; - const int full_mx= mx>>2; - const int full_my= my>>2; - - assert(pic->data[0]); - - if(mx&7) extra_width -= 3; - if(my&7) extra_height -= 3; - - if( full_mx < 0-extra_width - || full_my < 0-extra_height - || full_mx + 16/*FIXME*/ > s->width + extra_width - || full_my + 16/*FIXME*/ > s->height + extra_height){ - ff_emulated_edge_mc(s->edge_emu_buffer, src_y - 2 - 2*s->linesize, s->linesize, 16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, s->width, s->height); - src_y= s->edge_emu_buffer + 2 + 2*s->linesize; - emu=1; - } - - qpix_op[luma_xy](dest_y, src_y, s->linesize); //FIXME try variable height perhaps? - if(!square){ - qpix_op[luma_xy](dest_y + delta, src_y + delta, s->linesize); - } - - if(s->flags&CODEC_FLAG_GRAY) return; - - if(emu){ - ff_emulated_edge_mc(s->edge_emu_buffer, src_cb, s->uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), s->width>>1, s->height>>1); - src_cb= s->edge_emu_buffer; - } - chroma_op(dest_cb, src_cb, s->uvlinesize, chroma_height, mx&7, my&7); - - if(emu){ - ff_emulated_edge_mc(s->edge_emu_buffer, src_cr, s->uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), s->width>>1, s->height>>1); - src_cr= s->edge_emu_buffer; - } - chroma_op(dest_cr, src_cr, s->uvlinesize, chroma_height, mx&7, my&7); -} - -static inline void mc_part(H264Context *h, int n, int square, int chroma_height, int delta, - uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, - int x_offset, int y_offset, - qpel_mc_func *qpix_put, h264_chroma_mc_func chroma_put, - qpel_mc_func *qpix_avg, h264_chroma_mc_func chroma_avg, - int list0, int list1){ - MpegEncContext * const s = &h->s; - qpel_mc_func *qpix_op= qpix_put; - h264_chroma_mc_func chroma_op= chroma_put; - - dest_y += 2*x_offset + 2*y_offset*s-> linesize; - dest_cb += x_offset + y_offset*s->uvlinesize; - dest_cr += x_offset + y_offset*s->uvlinesize; - x_offset += 8*s->mb_x; - y_offset += 8*s->mb_y; - - if(list0){ - Picture *ref= &h->ref_list[0][ h->ref_cache[0][ scan8[n] ] ]; - mc_dir_part(h, ref, n, square, chroma_height, delta, 0, - dest_y, dest_cb, dest_cr, x_offset, y_offset, - qpix_op, chroma_op); - - qpix_op= qpix_avg; - chroma_op= chroma_avg; - } - - if(list1){ - Picture *ref= &h->ref_list[1][ h->ref_cache[1][ scan8[n] ] ]; - mc_dir_part(h, ref, n, square, chroma_height, delta, 1, - dest_y, dest_cb, dest_cr, x_offset, y_offset, - qpix_op, chroma_op); - } -} - -static void hl_motion(H264Context *h, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, - qpel_mc_func (*qpix_put)[16], h264_chroma_mc_func (*chroma_put), - qpel_mc_func (*qpix_avg)[16], h264_chroma_mc_func (*chroma_avg)){ - MpegEncContext * const s = &h->s; - const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; - const int mb_type= s->current_picture.mb_type[mb_xy]; - - assert(IS_INTER(mb_type)); - - if(IS_16X16(mb_type)){ - mc_part(h, 0, 1, 8, 0, dest_y, dest_cb, dest_cr, 0, 0, - qpix_put[0], chroma_put[0], qpix_avg[0], chroma_avg[0], - IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1)); - }else if(IS_16X8(mb_type)){ - mc_part(h, 0, 0, 4, 8, dest_y, dest_cb, dest_cr, 0, 0, - qpix_put[1], chroma_put[0], qpix_avg[1], chroma_avg[0], - IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1)); - mc_part(h, 8, 0, 4, 8, dest_y, dest_cb, dest_cr, 0, 4, - qpix_put[1], chroma_put[0], qpix_avg[1], chroma_avg[0], - IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1)); - }else if(IS_8X16(mb_type)){ - mc_part(h, 0, 0, 8, 8*s->linesize, dest_y, dest_cb, dest_cr, 0, 0, - qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1], - IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1)); - mc_part(h, 4, 0, 8, 8*s->linesize, dest_y, dest_cb, dest_cr, 4, 0, - qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1], - IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1)); - }else{ - int i; - - assert(IS_8X8(mb_type)); - - for(i=0; i<4; i++){ - const int sub_mb_type= h->sub_mb_type[i]; - const int n= 4*i; - int x_offset= (i&1)<<2; - int y_offset= (i&2)<<1; - - if(IS_SUB_8X8(sub_mb_type)){ - mc_part(h, n, 1, 4, 0, dest_y, dest_cb, dest_cr, x_offset, y_offset, - qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1], - IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1)); - }else if(IS_SUB_8X4(sub_mb_type)){ - mc_part(h, n , 0, 2, 4, dest_y, dest_cb, dest_cr, x_offset, y_offset, - qpix_put[2], chroma_put[1], qpix_avg[2], chroma_avg[1], - IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1)); - mc_part(h, n+2, 0, 2, 4, dest_y, dest_cb, dest_cr, x_offset, y_offset+2, - qpix_put[2], chroma_put[1], qpix_avg[2], chroma_avg[1], - IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1)); - }else if(IS_SUB_4X8(sub_mb_type)){ - mc_part(h, n , 0, 4, 4*s->linesize, dest_y, dest_cb, dest_cr, x_offset, y_offset, - qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2], - IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1)); - mc_part(h, n+1, 0, 4, 4*s->linesize, dest_y, dest_cb, dest_cr, x_offset+2, y_offset, - qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2], - IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1)); - }else{ - int j; - assert(IS_SUB_4X4(sub_mb_type)); - for(j=0; j<4; j++){ - int sub_x_offset= x_offset + 2*(j&1); - int sub_y_offset= y_offset + (j&2); - mc_part(h, n+j, 1, 2, 0, dest_y, dest_cb, dest_cr, sub_x_offset, sub_y_offset, - qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2], - IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1)); - } - } - } - } -} - -static void decode_init_vlc(H264Context *h){ - static int done = 0; - - if (!done) { - int i; - done = 1; - - init_vlc(&chroma_dc_coeff_token_vlc, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 4*5, - &chroma_dc_coeff_token_len [0], 1, 1, - &chroma_dc_coeff_token_bits[0], 1, 1); - - for(i=0; i<4; i++){ - init_vlc(&coeff_token_vlc[i], COEFF_TOKEN_VLC_BITS, 4*17, - &coeff_token_len [i][0], 1, 1, - &coeff_token_bits[i][0], 1, 1); - } - - for(i=0; i<3; i++){ - init_vlc(&chroma_dc_total_zeros_vlc[i], CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 4, - &chroma_dc_total_zeros_len [i][0], 1, 1, - &chroma_dc_total_zeros_bits[i][0], 1, 1); - } - for(i=0; i<15; i++){ - init_vlc(&total_zeros_vlc[i], TOTAL_ZEROS_VLC_BITS, 16, - &total_zeros_len [i][0], 1, 1, - &total_zeros_bits[i][0], 1, 1); - } - - for(i=0; i<6; i++){ - init_vlc(&run_vlc[i], RUN_VLC_BITS, 7, - &run_len [i][0], 1, 1, - &run_bits[i][0], 1, 1); - } - init_vlc(&run7_vlc, RUN7_VLC_BITS, 16, - &run_len [6][0], 1, 1, - &run_bits[6][0], 1, 1); - } -} - -/** - * Sets the intra prediction function pointers. - */ -static void init_pred_ptrs(H264Context *h){ -// MpegEncContext * const s = &h->s; - - h->pred4x4[VERT_PRED ]= pred4x4_vertical_c; - h->pred4x4[HOR_PRED ]= pred4x4_horizontal_c; - h->pred4x4[DC_PRED ]= pred4x4_dc_c; - h->pred4x4[DIAG_DOWN_LEFT_PRED ]= pred4x4_down_left_c; - h->pred4x4[DIAG_DOWN_RIGHT_PRED]= pred4x4_down_right_c; - h->pred4x4[VERT_RIGHT_PRED ]= pred4x4_vertical_right_c; - h->pred4x4[HOR_DOWN_PRED ]= pred4x4_horizontal_down_c; - h->pred4x4[VERT_LEFT_PRED ]= pred4x4_vertical_left_c; - h->pred4x4[HOR_UP_PRED ]= pred4x4_horizontal_up_c; - h->pred4x4[LEFT_DC_PRED ]= pred4x4_left_dc_c; - h->pred4x4[TOP_DC_PRED ]= pred4x4_top_dc_c; - h->pred4x4[DC_128_PRED ]= pred4x4_128_dc_c; - - h->pred8x8[DC_PRED8x8 ]= pred8x8_dc_c; - h->pred8x8[VERT_PRED8x8 ]= pred8x8_vertical_c; - h->pred8x8[HOR_PRED8x8 ]= pred8x8_horizontal_c; - h->pred8x8[PLANE_PRED8x8 ]= pred8x8_plane_c; - h->pred8x8[LEFT_DC_PRED8x8]= pred8x8_left_dc_c; - h->pred8x8[TOP_DC_PRED8x8 ]= pred8x8_top_dc_c; - h->pred8x8[DC_128_PRED8x8 ]= pred8x8_128_dc_c; - - h->pred16x16[DC_PRED8x8 ]= pred16x16_dc_c; - h->pred16x16[VERT_PRED8x8 ]= pred16x16_vertical_c; - h->pred16x16[HOR_PRED8x8 ]= pred16x16_horizontal_c; - h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_c; - h->pred16x16[LEFT_DC_PRED8x8]= pred16x16_left_dc_c; - h->pred16x16[TOP_DC_PRED8x8 ]= pred16x16_top_dc_c; - h->pred16x16[DC_128_PRED8x8 ]= pred16x16_128_dc_c; -} - -static void free_tables(H264Context *h){ - av_freep(&h->intra4x4_pred_mode); - av_freep(&h->non_zero_count); - av_freep(&h->slice_table_base); - h->slice_table= NULL; - - av_freep(&h->mb2b_xy); - av_freep(&h->mb2b8_xy); -} - -/** - * allocates tables. - * needs widzh/height - */ -static int alloc_tables(H264Context *h){ - MpegEncContext * const s = &h->s; - const int big_mb_num= s->mb_stride * (s->mb_height+1); - int x,y; - - CHECKED_ALLOCZ(h->intra4x4_pred_mode, big_mb_num * 8 * sizeof(uint8_t)) - CHECKED_ALLOCZ(h->non_zero_count , big_mb_num * 16 * sizeof(uint8_t)) - CHECKED_ALLOCZ(h->slice_table_base , big_mb_num * sizeof(uint8_t)) - - memset(h->slice_table_base, -1, big_mb_num * sizeof(uint8_t)); - h->slice_table= h->slice_table_base + s->mb_stride + 1; - - CHECKED_ALLOCZ(h->mb2b_xy , big_mb_num * sizeof(uint16_t)); - CHECKED_ALLOCZ(h->mb2b8_xy , big_mb_num * sizeof(uint16_t)); - for(y=0; ymb_height; y++){ - for(x=0; xmb_width; x++){ - const int mb_xy= x + y*s->mb_stride; - const int b_xy = 4*x + 4*y*h->b_stride; - const int b8_xy= 2*x + 2*y*h->b8_stride; - - h->mb2b_xy [mb_xy]= b_xy; - h->mb2b8_xy[mb_xy]= b8_xy; - } - } - - return 0; -fail: - free_tables(h); - return -1; -} - -static void common_init(H264Context *h){ - MpegEncContext * const s = &h->s; - - s->width = s->avctx->width; - s->height = s->avctx->height; - s->codec_id= s->avctx->codec->id; - - init_pred_ptrs(h); - - s->decode=1; //FIXME -} - -static int decode_init(AVCodecContext *avctx){ - H264Context *h= avctx->priv_data; - MpegEncContext * const s = &h->s; - - s->avctx = avctx; - common_init(h); - - s->out_format = FMT_H264; - s->workaround_bugs= avctx->workaround_bugs; - - // set defaults - s->progressive_sequence=1; -// s->decode_mb= ff_h263_decode_mb; - s->low_delay= 1; - avctx->pix_fmt= PIX_FMT_YUV420P; - - decode_init_vlc(h); - - return 0; -} - -static void frame_start(H264Context *h){ - MpegEncContext * const s = &h->s; - int i; - - MPV_frame_start(s, s->avctx); - ff_er_frame_start(s); - h->mmco_index=0; - - assert(s->linesize && s->uvlinesize); - - for(i=0; i<16; i++){ - h->block_offset[i]= 4*((scan8[i] - scan8[0])&7) + 4*s->linesize*((scan8[i] - scan8[0])>>3); - h->chroma_subblock_offset[i]= 2*((scan8[i] - scan8[0])&7) + 2*s->uvlinesize*((scan8[i] - scan8[0])>>3); - } - for(i=0; i<4; i++){ - h->block_offset[16+i]= - h->block_offset[20+i]= 4*((scan8[i] - scan8[0])&7) + 4*s->uvlinesize*((scan8[i] - scan8[0])>>3); - } - -// s->decode= (s->flags&CODEC_FLAG_PSNR) || !s->encoding || s->current_picture.reference /*|| h->contains_intra*/ || 1; -} - -static void hl_decode_mb(H264Context *h){ - MpegEncContext * const s = &h->s; - const int mb_x= s->mb_x; - const int mb_y= s->mb_y; - const int mb_xy= mb_x + mb_y*s->mb_stride; - const int mb_type= s->current_picture.mb_type[mb_xy]; - uint8_t *dest_y, *dest_cb, *dest_cr; - int linesize, uvlinesize /*dct_offset*/; - int i; - - if(!s->decode) - return; - - if(s->mb_skiped){ - } - - dest_y = s->current_picture.data[0] + (mb_y * 16* s->linesize ) + mb_x * 16; - dest_cb = s->current_picture.data[1] + (mb_y * 8 * s->uvlinesize) + mb_x * 8; - dest_cr = s->current_picture.data[2] + (mb_y * 8 * s->uvlinesize) + mb_x * 8; - - if (h->mb_field_decoding_flag) { - linesize = s->linesize * 2; - uvlinesize = s->uvlinesize * 2; - if(mb_y&1){ //FIXME move out of this func? - dest_y -= s->linesize*15; - dest_cb-= s->linesize*7; - dest_cr-= s->linesize*7; - } - } else { - linesize = s->linesize; - uvlinesize = s->uvlinesize; -// dct_offset = s->linesize * 16; - } - - if(IS_INTRA(mb_type)){ - if(!(s->flags&CODEC_FLAG_GRAY)){ - h->pred8x8[ h->chroma_pred_mode ](dest_cb, uvlinesize); - h->pred8x8[ h->chroma_pred_mode ](dest_cr, uvlinesize); - } - - if(IS_INTRA4x4(mb_type)){ - if(!s->encoding){ - for(i=0; i<16; i++){ - uint8_t * const ptr= dest_y + h->block_offset[i]; - uint8_t *topright= ptr + 4 - linesize; - const int topright_avail= (h->topright_samples_available<intra4x4_pred_mode_cache[ scan8[i] ]; - int tr; - - if(!topright_avail){ - tr= ptr[3 - linesize]*0x01010101; - topright= (uint8_t*) &tr; - } - - h->pred4x4[ dir ](ptr, topright, linesize); - if(h->non_zero_count_cache[ scan8[i] ]){ - if(s->codec_id == CODEC_ID_H264) - h264_add_idct_c(ptr, h->mb + i*16, linesize); - else - svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, 0); - } - } - } - }else{ - h->pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize); - if(s->codec_id == CODEC_ID_H264) - h264_luma_dc_dequant_idct_c(h->mb, s->qscale); - else - svq3_luma_dc_dequant_idct_c(h->mb, s->qscale); - } - }else if(s->codec_id == CODEC_ID_H264){ - hl_motion(h, dest_y, dest_cb, dest_cr, - s->dsp.put_h264_qpel_pixels_tab, s->dsp.put_h264_chroma_pixels_tab, - s->dsp.avg_h264_qpel_pixels_tab, s->dsp.avg_h264_chroma_pixels_tab); - } - - - if(!IS_INTRA4x4(mb_type)){ - if(s->codec_id == CODEC_ID_H264){ - for(i=0; i<16; i++){ - if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below - uint8_t * const ptr= dest_y + h->block_offset[i]; - h264_add_idct_c(ptr, h->mb + i*16, linesize); - } - } - }else{ - for(i=0; i<16; i++){ - if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below - uint8_t * const ptr= dest_y + h->block_offset[i]; - svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, IS_INTRA(mb_type) ? 1 : 0); - } - } - } - } - - if(!(s->flags&CODEC_FLAG_GRAY)){ - chroma_dc_dequant_idct_c(h->mb + 16*16, h->chroma_qp); - chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->chroma_qp); - if(s->codec_id == CODEC_ID_H264){ - for(i=16; i<16+4; i++){ - if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ - uint8_t * const ptr= dest_cb + h->block_offset[i]; - h264_add_idct_c(ptr, h->mb + i*16, uvlinesize); - } - } - for(i=20; i<20+4; i++){ - if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ - uint8_t * const ptr= dest_cr + h->block_offset[i]; - h264_add_idct_c(ptr, h->mb + i*16, uvlinesize); - } - } - }else{ - for(i=16; i<16+4; i++){ - if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ - uint8_t * const ptr= dest_cb + h->block_offset[i]; - svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, chroma_qp[s->qscale + 12] - 12, 2); - } - } - for(i=20; i<20+4; i++){ - if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ - uint8_t * const ptr= dest_cr + h->block_offset[i]; - svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, chroma_qp[s->qscale + 12] - 12, 2); - } - } - } - } -} - -static void decode_mb_cabac(H264Context *h){ -// MpegEncContext * const s = &h->s; -} - -/** - * fills the default_ref_list. - */ -static int fill_default_ref_list(H264Context *h){ - MpegEncContext * const s = &h->s; - int i; - Picture sorted_short_ref[16]; - - if(h->slice_type==B_TYPE){ - int out_i; - int limit= -1; - - for(out_i=0; out_ishort_ref_count; out_i++){ - int best_i=-1; - int best_poc=-1; - - for(i=0; ishort_ref_count; i++){ - const int poc= h->short_ref[i]->poc; - if(poc > limit && poc < best_poc){ - best_poc= poc; - best_i= i; - } - } - - assert(best_i != -1); - - limit= best_poc; - sorted_short_ref[out_i]= *h->short_ref[best_i]; - } - } - - if(s->picture_structure == PICT_FRAME){ - if(h->slice_type==B_TYPE){ - const int current_poc= s->current_picture_ptr->poc; - int list; - - for(list=0; list<2; list++){ - int index=0; - - for(i=0; ishort_ref_count && index < h->ref_count[list]; i++){ - const int i2= list ? h->short_ref_count - i - 1 : i; - const int poc= sorted_short_ref[i2].poc; - - if(sorted_short_ref[i2].reference != 3) continue; //FIXME refernce field shit - - if((list==1 && poc > current_poc) || (list==0 && poc < current_poc)){ - h->default_ref_list[list][index ]= sorted_short_ref[i2]; - h->default_ref_list[list][index++].pic_id= sorted_short_ref[i2].frame_num; - } - } - - for(i=0; ilong_ref_count && index < h->ref_count[ list ]; i++){ - if(h->long_ref[i]->reference != 3) continue; - - h->default_ref_list[ list ][index ]= *h->long_ref[i]; - h->default_ref_list[ list ][index++].pic_id= i;; - } - - if(h->long_ref_count > 1 && h->short_ref_count==0){ - Picture temp= h->default_ref_list[1][0]; - h->default_ref_list[1][0] = h->default_ref_list[1][1]; - h->default_ref_list[1][0] = temp; - } - - if(index < h->ref_count[ list ]) - memset(&h->default_ref_list[list][index], 0, sizeof(Picture)*(h->ref_count[ list ] - index)); - } - }else{ - int index=0; - for(i=0; ishort_ref_count && index < h->ref_count[0]; i++){ - if(h->short_ref[i]->reference != 3) continue; //FIXME refernce field shit - h->default_ref_list[0][index ]= *h->short_ref[i]; - h->default_ref_list[0][index++].pic_id= h->short_ref[i]->frame_num; - } - for(i=0; ilong_ref_count && index < h->ref_count[0]; i++){ - if(h->long_ref[i]->reference != 3) continue; - h->default_ref_list[0][index ]= *h->long_ref[i]; - h->default_ref_list[0][index++].pic_id= i;; - } - if(index < h->ref_count[0]) - memset(&h->default_ref_list[0][index], 0, sizeof(Picture)*(h->ref_count[0] - index)); - } - }else{ //FIELD - if(h->slice_type==B_TYPE){ - }else{ - //FIXME second field balh - } - } - return 0; -} - -static int decode_ref_pic_list_reordering(H264Context *h){ - MpegEncContext * const s = &h->s; - int list; - - if(h->slice_type==I_TYPE || h->slice_type==SI_TYPE) return 0; //FIXME move beofre func - - for(list=0; list<2; list++){ - memcpy(h->ref_list[list], h->default_ref_list[list], sizeof(Picture)*h->ref_count[list]); - - if(get_bits1(&s->gb)){ - int pred= h->curr_pic_num; - int index; - - for(index=0; ; index++){ - int reordering_of_pic_nums_idc= get_ue_golomb(&s->gb); - int pic_id; - int i; - - - if(index >= h->ref_count[list]){ - fprintf(stderr, "reference count overflow\n"); - return -1; - } - - if(reordering_of_pic_nums_idc<3){ - if(reordering_of_pic_nums_idc<2){ - const int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1; - - if(abs_diff_pic_num >= h->max_pic_num){ - fprintf(stderr, "abs_diff_pic_num overflow\n"); - return -1; - } - - if(reordering_of_pic_nums_idc == 0) pred-= abs_diff_pic_num; - else pred+= abs_diff_pic_num; - pred &= h->max_pic_num - 1; - - for(i= h->ref_count[list]-1; i>=index; i--){ - if(h->ref_list[list][i].pic_id == pred && h->ref_list[list][i].long_ref==0) - break; - } - }else{ - pic_id= get_ue_golomb(&s->gb); //long_term_pic_idx - - for(i= h->ref_count[list]-1; i>=index; i--){ - if(h->ref_list[list][i].pic_id == pic_id && h->ref_list[list][i].long_ref==1) - break; - } - } - - if(i < index){ - fprintf(stderr, "reference picture missing during reorder\n"); - memset(&h->ref_list[list][index], 0, sizeof(Picture)); //FIXME - }else if(i > index){ - Picture tmp= h->ref_list[list][i]; - for(; i>index; i--){ - h->ref_list[list][i]= h->ref_list[list][i-1]; - } - h->ref_list[list][index]= tmp; - } - }else if(reordering_of_pic_nums_idc==3) - break; - else{ - fprintf(stderr, "illegal reordering_of_pic_nums_idc\n"); - return -1; - } - } - } - - if(h->slice_type!=B_TYPE) break; - } - return 0; -} - -static int pred_weight_table(H264Context *h){ - MpegEncContext * const s = &h->s; - int list, i; - - h->luma_log2_weight_denom= get_ue_golomb(&s->gb); - h->chroma_log2_weight_denom= get_ue_golomb(&s->gb); - - for(list=0; list<2; list++){ - for(i=0; iref_count[list]; i++){ - int luma_weight_flag, chroma_weight_flag; - - luma_weight_flag= get_bits1(&s->gb); - if(luma_weight_flag){ - h->luma_weight[list][i]= get_se_golomb(&s->gb); - h->luma_offset[list][i]= get_se_golomb(&s->gb); - } - - chroma_weight_flag= get_bits1(&s->gb); - if(chroma_weight_flag){ - int j; - for(j=0; j<2; j++){ - h->chroma_weight[list][i][j]= get_se_golomb(&s->gb); - h->chroma_offset[list][i][j]= get_se_golomb(&s->gb); - } - } - } - if(h->slice_type != B_TYPE) break; - } - return 0; -} - -/** - * instantaneos decoder refresh. - */ -static void idr(H264Context *h){ - int i; - - for(i=0; ilong_ref_count; i++){ - h->long_ref[i]->reference=0; - h->long_ref[i]= NULL; - } - h->long_ref_count=0; - - for(i=0; ishort_ref_count; i++){ - h->short_ref[i]->reference=0; - h->short_ref[i]= NULL; - } - h->short_ref_count=0; -} - -/** - * - * @return the removed picture or NULL if an error occures - */ -static Picture * remove_short(H264Context *h, int frame_num){ - MpegEncContext * const s = &h->s; - int i; - - if(s->avctx->debug&FF_DEBUG_MMCO) - printf("remove short %d count %d\n", frame_num, h->short_ref_count); - - for(i=0; ishort_ref_count; i++){ - Picture *pic= h->short_ref[i]; - if(s->avctx->debug&FF_DEBUG_MMCO) - printf("%d %d %p\n", i, pic->frame_num, pic); - if(pic->frame_num == frame_num){ - h->short_ref[i]= NULL; - memmove(&h->short_ref[i], &h->short_ref[i+1], (h->short_ref_count - i - 1)*sizeof(Picture*)); - h->short_ref_count--; - return pic; - } - } - return NULL; -} - -/** - * - * @return the removed picture or NULL if an error occures - */ -static Picture * remove_long(H264Context *h, int i){ - Picture *pic; - - if(i >= h->long_ref_count) return NULL; - pic= h->long_ref[i]; - if(pic==NULL) return NULL; - - h->long_ref[i]= NULL; - memmove(&h->long_ref[i], &h->long_ref[i+1], (h->long_ref_count - i - 1)*sizeof(Picture*)); - h->long_ref_count--; - - return pic; -} - -/** - * Executes the reference picture marking (memory management control operations). - */ -static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ - MpegEncContext * const s = &h->s; - int i; - int current_is_long=0; - Picture *pic; - - if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0) - printf("no mmco here\n"); - - for(i=0; iavctx->debug&FF_DEBUG_MMCO) - printf("mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_frame_num, h->mmco[i].long_index); - - switch(mmco[i].opcode){ - case MMCO_SHORT2UNUSED: - pic= remove_short(h, mmco[i].short_frame_num); - if(pic==NULL) return -1; - pic->reference= 0; - break; - case MMCO_SHORT2LONG: - pic= remove_long(h, mmco[i].long_index); - if(pic) pic->reference=0; - - h->long_ref[ mmco[i].long_index ]= remove_short(h, mmco[i].short_frame_num); - h->long_ref[ mmco[i].long_index ]->long_ref=1; - break; - case MMCO_LONG2UNUSED: - pic= remove_long(h, mmco[i].long_index); - if(pic==NULL) return -1; - pic->reference= 0; - break; - case MMCO_LONG: - pic= remove_long(h, mmco[i].long_index); - if(pic) pic->reference=0; - - h->long_ref[ mmco[i].long_index ]= s->current_picture_ptr; - h->long_ref[ mmco[i].long_index ]->long_ref=1; - h->long_ref_count++; - - current_is_long=1; - break; - case MMCO_SET_MAX_LONG: - assert(mmco[i].long_index <= 16); - while(mmco[i].long_index < h->long_ref_count){ - pic= remove_long(h, mmco[i].long_index); - pic->reference=0; - } - while(mmco[i].long_index > h->long_ref_count){ - h->long_ref[ h->long_ref_count++ ]= NULL; - } - break; - case MMCO_RESET: - while(h->short_ref_count){ - pic= remove_short(h, h->short_ref[0]->frame_num); - pic->reference=0; - } - while(h->long_ref_count){ - pic= remove_long(h, h->long_ref_count-1); - pic->reference=0; - } - break; - default: assert(0); - } - } - - if(!current_is_long){ - pic= remove_short(h, s->current_picture_ptr->frame_num); - if(pic){ - pic->reference=0; - fprintf(stderr, "illegal short term buffer state detected\n"); - } - - if(h->short_ref_count) - memmove(&h->short_ref[1], &h->short_ref[0], h->short_ref_count*sizeof(Picture*)); - - h->short_ref[0]= s->current_picture_ptr; - h->short_ref[0]->long_ref=0; - h->short_ref_count++; - } - - return 0; -} - -static int decode_ref_pic_marking(H264Context *h){ - MpegEncContext * const s = &h->s; - int i; - - if(h->nal_unit_type == NAL_IDR_SLICE){ //FIXME fields - s->broken_link= get_bits1(&s->gb) -1; - h->mmco[0].long_index= get_bits1(&s->gb) - 1; // current_long_term_idx - if(h->mmco[0].long_index == -1) - h->mmco_index= 0; - else{ - h->mmco[0].opcode= MMCO_LONG; - h->mmco_index= 1; - } - }else{ - if(get_bits1(&s->gb)){ // adaptive_ref_pic_marking_mode_flag - for(i= h->mmco_index; igb);; - - h->mmco[i].opcode= opcode; - if(opcode==MMCO_SHORT2UNUSED || opcode==MMCO_SHORT2LONG){ - h->mmco[i].short_frame_num= (h->frame_num - get_ue_golomb(&s->gb) - 1) & ((1<sps.log2_max_frame_num)-1); //FIXME fields -/* if(h->mmco[i].short_frame_num >= h->short_ref_count || h->short_ref[ h->mmco[i].short_frame_num ] == NULL){ - fprintf(stderr, "illegal short ref in memory management control operation %d\n", mmco); - return -1; - }*/ - } - if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){ - h->mmco[i].long_index= get_ue_golomb(&s->gb); - if(/*h->mmco[i].long_index >= h->long_ref_count || h->long_ref[ h->mmco[i].long_index ] == NULL*/ h->mmco[i].long_index >= 16){ - fprintf(stderr, "illegal long ref in memory management control operation %d\n", opcode); - return -1; - } - } - - if(opcode > MMCO_LONG){ - fprintf(stderr, "illegal memory management control operation %d\n", opcode); - return -1; - } - } - h->mmco_index= i; - }else{ - assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count); - - if(h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count){ //FIXME fields - h->mmco[0].opcode= MMCO_SHORT2UNUSED; - h->mmco[0].short_frame_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num; - h->mmco_index= 1; - }else - h->mmco_index= 0; - } - } - - return 0; -} - -static int init_poc(H264Context *h){ - MpegEncContext * const s = &h->s; - const int max_frame_num= 1<sps.log2_max_frame_num; - int field_poc[2]; - - if(h->nal_unit_type == NAL_IDR_SLICE){ - h->frame_num_offset= 0; - }else{ - if(h->frame_num < h->prev_frame_num) - h->frame_num_offset= h->prev_frame_num_offset + max_frame_num; - else - h->frame_num_offset= h->prev_frame_num_offset; - } - - if(h->sps.poc_type==0){ - const int max_poc_lsb= 1<sps.log2_max_poc_lsb; - - if (h->poc_lsb < h->prev_poc_lsb && h->prev_poc_lsb - h->poc_lsb >= max_poc_lsb/2) - h->poc_msb = h->prev_poc_msb + max_poc_lsb; - else if(h->poc_lsb > h->prev_poc_lsb && h->prev_poc_lsb - h->poc_lsb < -max_poc_lsb/2) - h->poc_msb = h->prev_poc_msb - max_poc_lsb; - else - h->poc_msb = h->prev_poc_msb; -//printf("poc: %d %d\n", h->poc_msb, h->poc_lsb); - field_poc[0] = - field_poc[1] = h->poc_msb + h->poc_lsb; - if(s->picture_structure == PICT_FRAME) - field_poc[1] += h->delta_poc_bottom; - }else if(h->sps.poc_type==1){ - int abs_frame_num, expected_delta_per_poc_cycle, expectedpoc; - int i; - - if(h->sps.poc_cycle_length != 0) - abs_frame_num = h->frame_num_offset + h->frame_num; - else - abs_frame_num = 0; - - if(h->nal_ref_idc==0 && abs_frame_num > 0) - abs_frame_num--; - - expected_delta_per_poc_cycle = 0; - for(i=0; i < h->sps.poc_cycle_length; i++) - expected_delta_per_poc_cycle += h->sps.offset_for_ref_frame[ i ]; //FIXME integrate during sps parse - - if(abs_frame_num > 0){ - int poc_cycle_cnt = (abs_frame_num - 1) / h->sps.poc_cycle_length; - int frame_num_in_poc_cycle = (abs_frame_num - 1) % h->sps.poc_cycle_length; - - expectedpoc = poc_cycle_cnt * expected_delta_per_poc_cycle; - for(i = 0; i <= frame_num_in_poc_cycle; i++) - expectedpoc = expectedpoc + h->sps.offset_for_ref_frame[ i ]; - } else - expectedpoc = 0; - - if(h->nal_ref_idc == 0) - expectedpoc = expectedpoc + h->sps.offset_for_non_ref_pic; - - field_poc[0] = expectedpoc + h->delta_poc[0]; - field_poc[1] = field_poc[0] + h->sps.offset_for_top_to_bottom_field; - - if(s->picture_structure == PICT_FRAME) - field_poc[1] += h->delta_poc[1]; - }else{ - int poc; - if(h->nal_unit_type == NAL_IDR_SLICE){ - poc= 0; - }else{ - if(h->nal_ref_idc) poc= 2*(h->frame_num_offset + h->frame_num); - else poc= 2*(h->frame_num_offset + h->frame_num) - 1; - } - field_poc[0]= poc; - field_poc[1]= poc; - } - - if(s->picture_structure != PICT_BOTTOM_FIELD) - s->current_picture_ptr->field_poc[0]= field_poc[0]; - if(s->picture_structure != PICT_TOP_FIELD) - s->current_picture_ptr->field_poc[1]= field_poc[1]; - if(s->picture_structure == PICT_FRAME) // FIXME field pix? - s->current_picture_ptr->poc= FFMIN(field_poc[0], field_poc[1]); - - return 0; -} - -/** - * decodes a slice header. - * this will allso call MPV_common_init() and frame_start() as needed - */ -static int decode_slice_header(H264Context *h){ - MpegEncContext * const s = &h->s; - int first_mb_in_slice, pps_id; - int num_ref_idx_active_override_flag; - static const uint8_t slice_type_map[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE}; - float new_aspect; - - s->current_picture.reference= h->nal_ref_idc != 0; - - first_mb_in_slice= get_ue_golomb(&s->gb); - - h->slice_type= get_ue_golomb(&s->gb); - if(h->slice_type > 9){ - fprintf(stderr, "slice type too large (%d) at %d %d\n", h->slice_type, s->mb_x, s->mb_y); - } - if(h->slice_type > 4){ - h->slice_type -= 5; - h->slice_type_fixed=1; - }else - h->slice_type_fixed=0; - - h->slice_type= slice_type_map[ h->slice_type ]; - - s->pict_type= h->slice_type; // to make a few old func happy, its wrong though - - pps_id= get_ue_golomb(&s->gb); - if(pps_id>255){ - fprintf(stderr, "pps_id out of range\n"); - return -1; - } - h->pps= h->pps_buffer[pps_id]; - if(h->pps.slice_group_count == 0){ - fprintf(stderr, "non existing PPS referenced\n"); - return -1; - } - - h->sps= h->sps_buffer[ h->pps.sps_id ]; - if(h->sps.log2_max_frame_num == 0){ - fprintf(stderr, "non existing SPS referenced\n"); - return -1; - } - - s->mb_width= h->sps.mb_width; - s->mb_height= h->sps.mb_height; - - h->b_stride= s->mb_width*4; - h->b8_stride= s->mb_width*2; - - s->mb_x = first_mb_in_slice % s->mb_width; - s->mb_y = first_mb_in_slice / s->mb_width; //FIXME AFFW - - s->width = 16*s->mb_width - 2*(h->sps.crop_left + h->sps.crop_right ); - if(h->sps.frame_mbs_only_flag) - s->height= 16*s->mb_height - 2*(h->sps.crop_top + h->sps.crop_bottom); - else - s->height= 16*s->mb_height - 4*(h->sps.crop_top + h->sps.crop_bottom); //FIXME recheck - - if(s->aspected_height) //FIXME emms at end of slice ? - new_aspect= h->sps.sar_width*s->width / (float)(s->height*h->sps.sar_height); - else - new_aspect=0; - - if (s->context_initialized - && ( s->width != s->avctx->width || s->height != s->avctx->height - || ABS(new_aspect - s->avctx->aspect_ratio) > 0.001)) { - free_tables(h); - MPV_common_end(s); - } - if (!s->context_initialized) { - if (MPV_common_init(s) < 0) - return -1; - - alloc_tables(h); - - s->avctx->width = s->width; - s->avctx->height = s->height; - s->avctx->aspect_ratio= new_aspect; - } - - if(first_mb_in_slice == 0){ - frame_start(h); - } - - s->current_picture_ptr->frame_num= //FIXME frame_num cleanup - h->frame_num= get_bits(&s->gb, h->sps.log2_max_frame_num); - - if(h->sps.frame_mbs_only_flag){ - s->picture_structure= PICT_FRAME; - }else{ - if(get_bits1(&s->gb)) //field_pic_flag - s->picture_structure= PICT_TOP_FIELD + get_bits1(&s->gb); //bottom_field_flag - else - s->picture_structure= PICT_FRAME; - } - - if(s->picture_structure==PICT_FRAME){ - h->curr_pic_num= h->frame_num; - h->max_pic_num= 1<< h->sps.log2_max_frame_num; - }else{ - h->curr_pic_num= 2*h->frame_num; - h->max_pic_num= 1<<(h->sps.log2_max_frame_num + 1); - } - - if(h->nal_unit_type == NAL_IDR_SLICE){ - get_ue_golomb(&s->gb); /* idr_pic_id */ - } - - if(h->sps.poc_type==0){ - h->poc_lsb= get_bits(&s->gb, h->sps.log2_max_poc_lsb); - - if(h->pps.pic_order_present==1 && s->picture_structure==PICT_FRAME){ - h->delta_poc_bottom= get_se_golomb(&s->gb); - } - } - - if(h->sps.poc_type==1 && !h->sps.delta_pic_order_always_zero_flag){ - h->delta_poc[0]= get_se_golomb(&s->gb); - - if(h->pps.pic_order_present==1 && s->picture_structure==PICT_FRAME) - h->delta_poc[1]= get_se_golomb(&s->gb); - } - - init_poc(h); - - if(h->pps.redundant_pic_cnt_present){ - h->redundant_pic_count= get_ue_golomb(&s->gb); - } - - //set defaults, might be overriden a few line later - h->ref_count[0]= h->pps.ref_count[0]; - h->ref_count[1]= h->pps.ref_count[1]; - - if(h->slice_type == P_TYPE || h->slice_type == SP_TYPE || h->slice_type == B_TYPE){ - if(h->slice_type == B_TYPE){ - h->direct_spatial_mv_pred= get_bits1(&s->gb); - } - num_ref_idx_active_override_flag= get_bits1(&s->gb); - - if(num_ref_idx_active_override_flag){ - h->ref_count[0]= get_ue_golomb(&s->gb) + 1; - if(h->slice_type==B_TYPE) - h->ref_count[1]= get_ue_golomb(&s->gb) + 1; - - if(h->ref_count[0] > 32 || h->ref_count[1] > 32){ - fprintf(stderr, "reference overflow\n"); - return -1; - } - } - } - - if(first_mb_in_slice == 0){ - fill_default_ref_list(h); - } - - decode_ref_pic_list_reordering(h); - - if( (h->pps.weighted_pred && (h->slice_type == P_TYPE || h->slice_type == SP_TYPE )) - || (h->pps.weighted_bipred_idc==1 && h->slice_type==B_TYPE ) ) - pred_weight_table(h); - - if(s->current_picture.reference) - decode_ref_pic_marking(h); - //FIXME CABAC stuff - - s->qscale = h->pps.init_qp + get_se_golomb(&s->gb); //slice_qp_delta - //FIXME qscale / qp ... stuff - if(h->slice_type == SP_TYPE){ - get_bits1(&s->gb); /* sp_for_switch_flag */ - } - if(h->slice_type==SP_TYPE || h->slice_type == SI_TYPE){ - get_se_golomb(&s->gb); /* slice_qs_delta */ - } - - if( h->pps.deblocking_filter_parameters_present ) { - h->disable_deblocking_filter_idc= get_ue_golomb(&s->gb); - if( h->disable_deblocking_filter_idc != 1 ) { - h->slice_alpha_c0_offset_div2= get_se_golomb(&s->gb); - h->slice_beta_offset_div2= get_se_golomb(&s->gb); - } - }else - h->disable_deblocking_filter_idc= 0; - -#if 0 //FMO - if( h->pps.num_slice_groups > 1 && h->pps.mb_slice_group_map_type >= 3 && h->pps.mb_slice_group_map_type <= 5) - slice_group_change_cycle= get_bits(&s->gb, ?); -#endif - - if(s->avctx->debug&FF_DEBUG_PICT_INFO){ - printf("mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d\n", - first_mb_in_slice, - av_get_pict_type_char(h->slice_type), - pps_id, h->frame_num, - s->current_picture_ptr->field_poc[0], s->current_picture_ptr->field_poc[1], - h->ref_count[0], h->ref_count[1], - s->qscale, - h->disable_deblocking_filter_idc - ); - } - - return 0; -} - -/** - * - */ -static inline int get_level_prefix(GetBitContext *gb){ - unsigned int buf; - int log; - - OPEN_READER(re, gb); - UPDATE_CACHE(re, gb); - buf=GET_CACHE(re, gb); - - log= 32 - av_log2(buf); -#ifdef TRACE - print_bin(buf>>(32-log), log); - printf("%5d %2d %3d lpr @%5d in %s get_level_prefix\n", buf>>(32-log), log, log-1, get_bits_count(gb), __FILE__); -#endif - - LAST_SKIP_BITS(re, gb, log); - CLOSE_READER(re, gb); - - return log-1; -} - -/** - * decodes a residual block. - * @param n block index - * @param scantable scantable - * @param max_coeff number of coefficients in the block - * @return <0 if an error occured - */ -static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, int n, const uint8_t *scantable, int qp, int max_coeff){ - MpegEncContext * const s = &h->s; - const uint16_t *qmul= dequant_coeff[qp]; - static const int coeff_token_table_index[17]= {0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3}; - int level[16], run[16]; - int suffix_length, zeros_left, coeff_num, coeff_token, total_coeff, i, trailing_ones; - - //FIXME put trailing_onex into the context - - if(n == CHROMA_DC_BLOCK_INDEX){ - coeff_token= get_vlc2(gb, chroma_dc_coeff_token_vlc.table, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 1); - total_coeff= coeff_token>>2; - }else{ - if(n == LUMA_DC_BLOCK_INDEX){ - total_coeff= pred_non_zero_count(h, 0); - coeff_token= get_vlc2(gb, coeff_token_vlc[ coeff_token_table_index[total_coeff] ].table, COEFF_TOKEN_VLC_BITS, 2); - total_coeff= coeff_token>>2; - }else{ - total_coeff= pred_non_zero_count(h, n); - coeff_token= get_vlc2(gb, coeff_token_vlc[ coeff_token_table_index[total_coeff] ].table, COEFF_TOKEN_VLC_BITS, 2); - total_coeff= coeff_token>>2; - h->non_zero_count_cache[ scan8[n] ]= total_coeff; - } - } - - //FIXME set last_non_zero? - - if(total_coeff==0) - return 0; - - trailing_ones= coeff_token&3; - tprintf("trailing:%d, total:%d\n", trailing_ones, total_coeff); - assert(total_coeff<=16); - - for(i=0; i 10 && trailing_ones < 3; - - for(; imb_x, s->mb_y); - return -1; - } - - if(i==trailing_ones && i<3) level_code+= 2; //FIXME split first iteration - - mask= -(level_code&1); - level[i]= (((2+level_code)>>1) ^ mask) - mask; - - if(suffix_length==0) suffix_length=1; //FIXME split first iteration - -#if 1 - if(ABS(level[i]) > (3<<(suffix_length-1)) && suffix_length<6) suffix_length++; -#else - if((2+level_code)>>1) > (3<<(suffix_length-1)) && suffix_length<6) suffix_length++; - ? == prefix > 2 or sth -#endif - tprintf("level: %d suffix_length:%d\n", level[i], suffix_length); - } - - if(total_coeff == max_coeff) - zeros_left=0; - else{ - if(n == CHROMA_DC_BLOCK_INDEX) - zeros_left= get_vlc2(gb, chroma_dc_total_zeros_vlc[ total_coeff-1 ].table, CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 1); - else - zeros_left= get_vlc2(gb, total_zeros_vlc[ total_coeff-1 ].table, TOTAL_ZEROS_VLC_BITS, 1); - } - - for(i=0; imb_x, s->mb_y); - return -1; - } - - for(; i 24){ - for(i=total_coeff-1; i>=0; i--){ //FIXME merge into rundecode? - int j; - - coeff_num += run[i] + 1; //FIXME add 1 earlier ? - j= scantable[ coeff_num ]; - - block[j]= level[i]; - } - }else{ - for(i=total_coeff-1; i>=0; i--){ //FIXME merge into rundecode? - int j; - - coeff_num += run[i] + 1; //FIXME add 1 earlier ? - j= scantable[ coeff_num ]; - - block[j]= level[i] * qmul[j]; -// printf("%d %d ", block[j], qmul[j]); - } - } - return 0; -} - -/** - * decodes a macroblock - * @returns 0 if ok, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed - */ -static int decode_mb(H264Context *h){ - MpegEncContext * const s = &h->s; - const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; - int mb_type, partition_count, cbp; - - s->dsp.clear_blocks(h->mb); //FIXME avoid if allready clear (move after skip handlong? - - tprintf("pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y); - cbp = 0; /* avoid warning. FIXME: find a solution without slowing - down the code */ - if(h->slice_type != I_TYPE && h->slice_type != SI_TYPE){ - if(s->mb_skip_run==-1) - s->mb_skip_run= get_ue_golomb(&s->gb); - - if (s->mb_skip_run--) { - int mx, my; - /* skip mb */ -//FIXME b frame - mb_type= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P1L0; - - memset(h->non_zero_count[mb_xy], 0, 16); - memset(h->non_zero_count_cache + 8, 0, 8*5); //FIXME ugly, remove pfui - - if(h->sps.mb_aff && s->mb_skip_run==0 && (s->mb_y&1)==0){ - h->mb_field_decoding_flag= get_bits1(&s->gb); - } - - if(h->mb_field_decoding_flag) - mb_type|= MB_TYPE_INTERLACED; - - fill_caches(h, mb_type); //FIXME check what is needed and what not ... - pred_pskip_motion(h, &mx, &my); - fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1); - fill_rectangle( h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx,my), 4); - write_back_motion(h, mb_type); - - s->current_picture.mb_type[mb_xy]= mb_type; //FIXME SKIP type - h->slice_table[ mb_xy ]= h->slice_num; - - h->prev_mb_skiped= 1; - return 0; - } - } - if(h->sps.mb_aff /* && !field pic FIXME needed? */){ - if((s->mb_y&1)==0) - h->mb_field_decoding_flag = get_bits1(&s->gb); - }else - h->mb_field_decoding_flag=0; //FIXME som ed note ?! - - h->prev_mb_skiped= 0; - - mb_type= get_ue_golomb(&s->gb); - if(h->slice_type == B_TYPE){ - if(mb_type < 23){ - partition_count= b_mb_type_info[mb_type].partition_count; - mb_type= b_mb_type_info[mb_type].type; - }else{ - mb_type -= 23; - goto decode_intra_mb; - } - }else if(h->slice_type == P_TYPE /*|| h->slice_type == SP_TYPE */){ - if(mb_type < 5){ - partition_count= p_mb_type_info[mb_type].partition_count; - mb_type= p_mb_type_info[mb_type].type; - }else{ - mb_type -= 5; - goto decode_intra_mb; - } - }else{ - assert(h->slice_type == I_TYPE); -decode_intra_mb: - if(mb_type > 25){ - fprintf(stderr, "mb_type %d in %c slice to large at %d %d\n", mb_type, av_get_pict_type_char(h->slice_type), s->mb_x, s->mb_y); - return -1; - } - partition_count=0; - cbp= i_mb_type_info[mb_type].cbp; - h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode; - mb_type= i_mb_type_info[mb_type].type; - } - - if(h->mb_field_decoding_flag) - mb_type |= MB_TYPE_INTERLACED; - - s->current_picture.mb_type[mb_xy]= mb_type; - h->slice_table[ mb_xy ]= h->slice_num; - - if(IS_INTRA_PCM(mb_type)){ - const uint8_t *ptr; - int x, y; - - // we assume these blocks are very rare so we dont optimize it - align_get_bits(&s->gb); - - ptr= s->gb.buffer + get_bits_count(&s->gb); - - for(y=0; y<16; y++){ - const int index= 4*(y&3) + 64*(y>>2); - for(x=0; x<16; x++){ - h->mb[index + (x&3) + 16*(x>>2)]= *(ptr++); - } - } - for(y=0; y<8; y++){ - const int index= 256 + 4*(y&3) + 32*(y>>2); - for(x=0; x<8; x++){ - h->mb[index + (x&3) + 16*(x>>2)]= *(ptr++); - } - } - for(y=0; y<8; y++){ - const int index= 256 + 64 + 4*(y&3) + 32*(y>>2); - for(x=0; x<8; x++){ - h->mb[index + (x&3) + 16*(x>>2)]= *(ptr++); - } - } - - skip_bits(&s->gb, 384); //FIXME check /fix the bitstream readers - - memset(h->non_zero_count[mb_xy], 16, 16); - - return 0; - } - - fill_caches(h, mb_type); - - //mb_pred - if(IS_INTRA(mb_type)){ -// init_top_left_availability(h); - if(IS_INTRA4x4(mb_type)){ - int i; - -// fill_intra4x4_pred_table(h); - for(i=0; i<16; i++){ - const int mode_coded= !get_bits1(&s->gb); - const int predicted_mode= pred_intra_mode(h, i); - int mode; - - if(mode_coded){ - const int rem_mode= get_bits(&s->gb, 3); - if(rem_modeintra4x4_pred_mode_cache[ scan8[i] ] = mode; - } - write_back_intra_pred_mode(h); - if( check_intra4x4_pred_mode(h) < 0) - return -1; - }else{ - h->intra16x16_pred_mode= check_intra_pred_mode(h, h->intra16x16_pred_mode); - if(h->intra16x16_pred_mode < 0) - return -1; - } - h->chroma_pred_mode= get_ue_golomb(&s->gb); - - h->chroma_pred_mode= check_intra_pred_mode(h, h->chroma_pred_mode); - if(h->chroma_pred_mode < 0) - return -1; - }else if(partition_count==4){ - int i, j, sub_partition_count[4], list, ref[2][4]; - - if(h->slice_type == B_TYPE){ - for(i=0; i<4; i++){ - h->sub_mb_type[i]= get_ue_golomb(&s->gb); - if(h->sub_mb_type[i] >=13){ - fprintf(stderr, "B sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y); - return -1; - } - sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count; - h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type; - } - }else{ - assert(h->slice_type == P_TYPE || h->slice_type == SP_TYPE); //FIXME SP correct ? - for(i=0; i<4; i++){ - h->sub_mb_type[i]= get_ue_golomb(&s->gb); - if(h->sub_mb_type[i] >=4){ - fprintf(stderr, "P sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y); - return -1; - } - sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count; - h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type; - } - } - - for(list=0; list<2; list++){ - const int ref_count= IS_REF0(mb_type) ? 1 : h->ref_count[list]; - if(ref_count == 0) continue; - for(i=0; i<4; i++){ - if(IS_DIR(h->sub_mb_type[i], 0, list) && !IS_DIRECT(h->sub_mb_type[i])){ - ref[list][i] = get_te0_golomb(&s->gb, ref_count); //FIXME init to 0 before and skip? - }else{ - //FIXME - ref[list][i] = -1; - } - } - } - - for(list=0; list<2; list++){ - const int ref_count= IS_REF0(mb_type) ? 1 : h->ref_count[list]; - if(ref_count == 0) continue; - - for(i=0; i<4; i++){ - h->ref_cache[list][ scan8[4*i] ]=h->ref_cache[list][ scan8[4*i]+1 ]= - h->ref_cache[list][ scan8[4*i]+8 ]=h->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i]; - - if(IS_DIR(h->sub_mb_type[i], 0, list) && !IS_DIRECT(h->sub_mb_type[i])){ - const int sub_mb_type= h->sub_mb_type[i]; - const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1; - for(j=0; jmv_cache[list][ scan8[index] ]; - pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mx, &my); - mx += get_se_golomb(&s->gb); - my += get_se_golomb(&s->gb); - tprintf("final mv:%d %d\n", mx, my); - - if(IS_SUB_8X8(sub_mb_type)){ - mv_cache[ 0 ][0]= mv_cache[ 1 ][0]= - mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx; - mv_cache[ 0 ][1]= mv_cache[ 1 ][1]= - mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my; - }else if(IS_SUB_8X4(sub_mb_type)){ - mv_cache[ 0 ][0]= mv_cache[ 1 ][0]= mx; - mv_cache[ 0 ][1]= mv_cache[ 1 ][1]= my; - }else if(IS_SUB_4X8(sub_mb_type)){ - mv_cache[ 0 ][0]= mv_cache[ 8 ][0]= mx; - mv_cache[ 0 ][1]= mv_cache[ 8 ][1]= my; - }else{ - assert(IS_SUB_4X4(sub_mb_type)); - mv_cache[ 0 ][0]= mx; - mv_cache[ 0 ][1]= my; - } - } - }else{ - uint32_t *p= (uint32_t *)&h->mv_cache[list][ scan8[4*i] ][0]; - p[0] = p[1]= - p[8] = p[9]= 0; - } - } - } - }else if(!IS_DIRECT(mb_type)){ - int list, mx, my, i; - //FIXME we should set ref_idx_l? to 0 if we use that later ... - if(IS_16X16(mb_type)){ - for(list=0; list<2; list++){ - if(h->ref_count[0]>0){ - if(IS_DIR(mb_type, 0, list)){ - const int val= get_te0_golomb(&s->gb, h->ref_count[list]); - fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1); - } - } - } - for(list=0; list<2; list++){ - if(IS_DIR(mb_type, 0, list)){ - pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mx, &my); - mx += get_se_golomb(&s->gb); - my += get_se_golomb(&s->gb); - tprintf("final mv:%d %d\n", mx, my); - - fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4); - } - } - } - else if(IS_16X8(mb_type)){ - for(list=0; list<2; list++){ - if(h->ref_count[list]>0){ - for(i=0; i<2; i++){ - if(IS_DIR(mb_type, i, list)){ - const int val= get_te0_golomb(&s->gb, h->ref_count[list]); - fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1); - } - } - } - } - for(list=0; list<2; list++){ - for(i=0; i<2; i++){ - if(IS_DIR(mb_type, i, list)){ - pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mx, &my); - mx += get_se_golomb(&s->gb); - my += get_se_golomb(&s->gb); - tprintf("final mv:%d %d\n", mx, my); - - fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx,my), 4); - } - } - } - }else{ - assert(IS_8X16(mb_type)); - for(list=0; list<2; list++){ - if(h->ref_count[list]>0){ - for(i=0; i<2; i++){ - if(IS_DIR(mb_type, i, list)){ //FIXME optimize - const int val= get_te0_golomb(&s->gb, h->ref_count[list]); - fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1); - } - } - } - } - for(list=0; list<2; list++){ - for(i=0; i<2; i++){ - if(IS_DIR(mb_type, i, list)){ - pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mx, &my); - mx += get_se_golomb(&s->gb); - my += get_se_golomb(&s->gb); - tprintf("final mv:%d %d\n", mx, my); - - fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx,my), 4); - } - } - } - } - } - - if(IS_INTER(mb_type)) - write_back_motion(h, mb_type); - - if(!IS_INTRA16x16(mb_type)){ - cbp= get_ue_golomb(&s->gb); - if(cbp > 47){ - fprintf(stderr, "cbp too large (%d) at %d %d\n", cbp, s->mb_x, s->mb_y); - return -1; - } - - if(IS_INTRA4x4(mb_type)) - cbp= golomb_to_intra4x4_cbp[cbp]; - else - cbp= golomb_to_inter_cbp[cbp]; - } - - if(cbp || IS_INTRA16x16(mb_type)){ - int i8x8, i4x4, chroma_idx; - int chroma_qp, dquant; - GetBitContext *gb= IS_INTRA(mb_type) ? h->intra_gb_ptr : h->inter_gb_ptr; - const uint8_t *scan, *dc_scan; - -// fill_non_zero_count_cache(h); - - if(IS_INTERLACED(mb_type)){ - scan= field_scan; - dc_scan= luma_dc_field_scan; - }else{ - scan= zigzag_scan; - dc_scan= luma_dc_zigzag_scan; - } - - dquant= get_se_golomb(&s->gb); - - if( dquant > 25 || dquant < -26 ){ - fprintf(stderr, "dquant out of range (%d) at %d %d\n", dquant, s->mb_x, s->mb_y); - return -1; - } - - s->qscale += dquant; - if(((unsigned)s->qscale) > 51){ - if(s->qscale<0) s->qscale+= 52; - else s->qscale-= 52; - } - - h->chroma_qp= chroma_qp= get_chroma_qp(h, s->qscale); - if(IS_INTRA16x16(mb_type)){ - if( decode_residual(h, h->intra_gb_ptr, h->mb, LUMA_DC_BLOCK_INDEX, dc_scan, s->qscale, 16) < 0){ - return -1; //FIXME continue if partotioned and other retirn -1 too - } - - assert((cbp&15) == 0 || (cbp&15) == 15); - - if(cbp&15){ - for(i8x8=0; i8x8<4; i8x8++){ - for(i4x4=0; i4x4<4; i4x4++){ - const int index= i4x4 + 4*i8x8; - if( decode_residual(h, h->intra_gb_ptr, h->mb + 16*index, index, scan + 1, s->qscale, 15) < 0 ){ - return -1; - } - } - } - }else{ - memset(&h->non_zero_count_cache[8], 0, 8*4); //FIXME stupid & slow - } - }else{ - for(i8x8=0; i8x8<4; i8x8++){ - if(cbp & (1<mb + 16*index, index, scan, s->qscale, 16) <0 ){ - return -1; - } - } - }else{ - uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ]; - nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0; - } - } - } - - if(cbp&0x30){ - for(chroma_idx=0; chroma_idx<2; chroma_idx++) - if( decode_residual(h, gb, h->mb + 256 + 16*4*chroma_idx, CHROMA_DC_BLOCK_INDEX, chroma_dc_scan, chroma_qp, 4) < 0){ - return -1; - } - } - - if(cbp&0x20){ - for(chroma_idx=0; chroma_idx<2; chroma_idx++){ - for(i4x4=0; i4x4<4; i4x4++){ - const int index= 16 + 4*chroma_idx + i4x4; - if( decode_residual(h, gb, h->mb + 16*index, index, scan + 1, chroma_qp, 15) < 0){ - return -1; - } - } - } - }else{ - uint8_t * const nnz= &h->non_zero_count_cache[0]; - nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] = - nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0; - } - }else{ - memset(&h->non_zero_count_cache[8], 0, 8*5); - } - write_back_non_zero_count(h); - - return 0; -} - -static int decode_slice(H264Context *h){ - MpegEncContext * const s = &h->s; - const int part_mask= s->partitioned_frame ? (AC_END|AC_ERROR) : 0x7F; - - s->mb_skip_run= -1; - -#if 1 - for(;;){ - int ret= decode_mb(h); - - hl_decode_mb(h); - - if(ret>=0 && h->sps.mb_aff){ //FIXME optimal? or let mb_decode decode 16x32 ? - s->mb_y++; - ret= decode_mb(h); - - hl_decode_mb(h); - s->mb_y--; - } - - if(ret<0){ - fprintf(stderr, "error while decoding MB %d %d\n", s->mb_x, s->mb_y); - 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; - } - - if(++s->mb_x >= s->mb_width){ - s->mb_x=0; - ff_draw_horiz_band(s, 16*s->mb_y, 16); - if(++s->mb_y >= s->mb_height){ - tprintf("slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits); - - if(get_bits_count(&s->gb) == s->gb.size_in_bits){ - 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 0; - }else{ - 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; - } - } - } - - if(get_bits_count(&s->gb) >= s->gb.size_in_bits && s->mb_skip_run<=0){ - if(get_bits_count(&s->gb) == s->gb.size_in_bits){ - 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 0; - }else{ - 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; - } - } - } -#endif -#if 0 - for(;s->mb_y < s->mb_height; s->mb_y++){ - for(;s->mb_x < s->mb_width; s->mb_x++){ - int ret= decode_mb(h); - - hl_decode_mb(h); - - if(ret<0){ - fprintf(stderr, "error while decoding MB %d %d\n", s->mb_x, s->mb_y); - 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; - } - - if(++s->mb_x >= s->mb_width){ - s->mb_x=0; - if(++s->mb_y >= s->mb_height){ - if(get_bits_count(s->gb) == s->gb.size_in_bits){ - 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 0; - }else{ - 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; - } - } - } - - if(get_bits_count(s->?gb) >= s->gb?.size_in_bits){ - if(get_bits_count(s->gb) == s->gb.size_in_bits){ - 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 0; - }else{ - 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; - } - } - } - s->mb_x=0; - ff_draw_horiz_band(s, 16*s->mb_y, 16); - } -#endif - return -1; //not reached -} - -static inline int decode_vui_parameters(H264Context *h, SPS *sps){ - MpegEncContext * const s = &h->s; - int aspect_ratio_info_present_flag, aspect_ratio_idc; - - aspect_ratio_info_present_flag= get_bits1(&s->gb); - - if( aspect_ratio_info_present_flag ) { - aspect_ratio_idc= get_bits(&s->gb, 8); - if( aspect_ratio_idc == EXTENDED_SAR ) { - sps->sar_width= get_bits(&s->gb, 16); - sps->sar_height= get_bits(&s->gb, 16); - }else if(aspect_ratio_idc < 16){ - sps->sar_width= pixel_aspect[aspect_ratio_idc][0]; - sps->sar_height= pixel_aspect[aspect_ratio_idc][1]; - }else{ - fprintf(stderr, "illegal aspect ratio\n"); - return -1; - } - }else{ - sps->sar_width= - sps->sar_height= 0; - } -// s->avctx->aspect_ratio= sar_width*s->width / (float)(s->height*sar_height); -#if 0 -| overscan_info_present_flag |0 |u(1) | -| if( overscan_info_present_flag ) | | | -| overscan_appropriate_flag |0 |u(1) | -| video_signal_type_present_flag |0 |u(1) | -| if( video_signal_type_present_flag ) { | | | -| video_format |0 |u(3) | -| video_full_range_flag |0 |u(1) | -| colour_description_present_flag |0 |u(1) | -| if( colour_description_present_flag ) { | | | -| colour_primaries |0 |u(8) | -| transfer_characteristics |0 |u(8) | -| matrix_coefficients |0 |u(8) | -| } | | | -| } | | | -| chroma_location_info_present_flag |0 |u(1) | -| if ( chroma_location_info_present_flag ) { | | | -| chroma_sample_location_type_top_field |0 |ue(v) | -| chroma_sample_location_type_bottom_field |0 |ue(v) | -| } | | | -| timing_info_present_flag |0 |u(1) | -| if( timing_info_present_flag ) { | | | -| num_units_in_tick |0 |u(32) | -| time_scale |0 |u(32) | -| fixed_frame_rate_flag |0 |u(1) | -| } | | | -| nal_hrd_parameters_present_flag |0 |u(1) | -| if( nal_hrd_parameters_present_flag = = 1) | | | -| hrd_parameters( ) | | | -| vcl_hrd_parameters_present_flag |0 |u(1) | -| if( vcl_hrd_parameters_present_flag = = 1) | | | -| hrd_parameters( ) | | | -| if( ( nal_hrd_parameters_present_flag = = 1 | || | | -| | | | -|( vcl_hrd_parameters_present_flag = = 1 ) ) | | | -| low_delay_hrd_flag |0 |u(1) | -| bitstream_restriction_flag |0 |u(1) | -| if( bitstream_restriction_flag ) { |0 |u(1) | -| motion_vectors_over_pic_boundaries_flag |0 |u(1) | -| max_bytes_per_pic_denom |0 |ue(v) | -| max_bits_per_mb_denom |0 |ue(v) | -| log2_max_mv_length_horizontal |0 |ue(v) | -| log2_max_mv_length_vertical |0 |ue(v) | -| num_reorder_frames |0 |ue(v) | -| max_dec_frame_buffering |0 |ue(v) | -| } | | | -|} | | | -#endif - return 0; -} - -static inline int decode_seq_parameter_set(H264Context *h){ - MpegEncContext * const s = &h->s; - int profile_idc, level_idc; - int sps_id, i; - SPS *sps; - - profile_idc= get_bits(&s->gb, 8); - get_bits1(&s->gb); //constraint_set0_flag - get_bits1(&s->gb); //constraint_set1_flag - get_bits1(&s->gb); //constraint_set2_flag - get_bits(&s->gb, 5); // reserved - level_idc= get_bits(&s->gb, 8); - sps_id= get_ue_golomb(&s->gb); - - sps= &h->sps_buffer[ sps_id ]; - sps->profile_idc= profile_idc; - sps->level_idc= level_idc; - - sps->log2_max_frame_num= get_ue_golomb(&s->gb) + 4; - sps->poc_type= get_ue_golomb(&s->gb); - - if(sps->poc_type == 0){ //FIXME #define - sps->log2_max_poc_lsb= get_ue_golomb(&s->gb) + 4; - } else if(sps->poc_type == 1){//FIXME #define - sps->delta_pic_order_always_zero_flag= get_bits1(&s->gb); - sps->offset_for_non_ref_pic= get_se_golomb(&s->gb); - sps->offset_for_top_to_bottom_field= get_se_golomb(&s->gb); - sps->poc_cycle_length= get_ue_golomb(&s->gb); - - for(i=0; ipoc_cycle_length; i++) - sps->offset_for_ref_frame[i]= get_se_golomb(&s->gb); - } - if(sps->poc_type > 2){ - fprintf(stderr, "illegal POC type %d\n", sps->poc_type); - return -1; - } - - sps->ref_frame_count= get_ue_golomb(&s->gb); - sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb); - sps->mb_width= get_ue_golomb(&s->gb) + 1; - sps->mb_height= get_ue_golomb(&s->gb) + 1; - sps->frame_mbs_only_flag= get_bits1(&s->gb); - if(!sps->frame_mbs_only_flag) - sps->mb_aff= get_bits1(&s->gb); - else - sps->mb_aff= 0; - - sps->direct_8x8_inference_flag= get_bits1(&s->gb); - - sps->crop= get_bits1(&s->gb); - if(sps->crop){ - sps->crop_left = get_ue_golomb(&s->gb); - sps->crop_right = get_ue_golomb(&s->gb); - sps->crop_top = get_ue_golomb(&s->gb); - sps->crop_bottom= get_ue_golomb(&s->gb); - if(sps->crop_left || sps->crop_top){ - fprintf(stderr, "insane croping not completly supported, this could look slightly wrong ...\n"); - } - }else{ - sps->crop_left = - sps->crop_right = - sps->crop_top = - sps->crop_bottom= 0; - } - - sps->vui_parameters_present_flag= get_bits1(&s->gb); - if( sps->vui_parameters_present_flag ) - decode_vui_parameters(h, sps); - - if(s->avctx->debug&FF_DEBUG_PICT_INFO){ - printf("sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n", - sps_id, sps->profile_idc, sps->level_idc, - sps->poc_type, - sps->ref_frame_count, - sps->mb_width, sps->mb_height, - sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"), - sps->direct_8x8_inference_flag ? "8B8" : "", - sps->crop_left, sps->crop_right, - sps->crop_top, sps->crop_bottom, - sps->vui_parameters_present_flag ? "VUI" : "" - ); - } - return 0; -} - -static inline int decode_picture_parameter_set(H264Context *h){ - MpegEncContext * const s = &h->s; - int pps_id= get_ue_golomb(&s->gb); - PPS *pps= &h->pps_buffer[pps_id]; - - pps->sps_id= get_ue_golomb(&s->gb); - pps->cabac= get_bits1(&s->gb); - pps->pic_order_present= get_bits1(&s->gb); - pps->slice_group_count= get_ue_golomb(&s->gb) + 1; - if(pps->slice_group_count > 1 ){ - pps->mb_slice_group_map_type= get_ue_golomb(&s->gb); -fprintf(stderr, "FMO not supported\n"); - switch(pps->mb_slice_group_map_type){ - case 0: -#if 0 -| for( i = 0; i <= num_slice_groups_minus1; i++ ) | | | -| run_length[ i ] |1 |ue(v) | -#endif - break; - case 2: -#if 0 -| for( i = 0; i < num_slice_groups_minus1; i++ ) | | | -|{ | | | -| top_left_mb[ i ] |1 |ue(v) | -| bottom_right_mb[ i ] |1 |ue(v) | -| } | | | -#endif - break; - case 3: - case 4: - case 5: -#if 0 -| slice_group_change_direction_flag |1 |u(1) | -| slice_group_change_rate_minus1 |1 |ue(v) | -#endif - break; - case 6: -#if 0 -| slice_group_id_cnt_minus1 |1 |ue(v) | -| for( i = 0; i <= slice_group_id_cnt_minus1; i++ | | | -|) | | | -| slice_group_id[ i ] |1 |u(v) | -#endif - break; - } - } - pps->ref_count[0]= get_ue_golomb(&s->gb) + 1; - pps->ref_count[1]= get_ue_golomb(&s->gb) + 1; - if(pps->ref_count[0] > 32 || pps->ref_count[1] > 32){ - fprintf(stderr, "reference overflow (pps)\n"); - return -1; - } - - pps->weighted_pred= get_bits1(&s->gb); - pps->weighted_bipred_idc= get_bits(&s->gb, 2); - pps->init_qp= get_se_golomb(&s->gb) + 26; - pps->init_qs= get_se_golomb(&s->gb) + 26; - pps->chroma_qp_index_offset= get_se_golomb(&s->gb); - pps->deblocking_filter_parameters_present= get_bits1(&s->gb); - pps->constrained_intra_pred= get_bits1(&s->gb); - pps->redundant_pic_cnt_present = get_bits1(&s->gb); - - if(s->avctx->debug&FF_DEBUG_PICT_INFO){ - printf("pps:%d sps:%d %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d %s %s %s\n", - pps_id, pps->sps_id, - pps->cabac ? "CABAC" : "CAVLC", - pps->slice_group_count, - pps->ref_count[0], pps->ref_count[1], - pps->weighted_pred ? "weighted" : "", - pps->init_qp, pps->init_qs, pps->chroma_qp_index_offset, - pps->deblocking_filter_parameters_present ? "LPAR" : "", - pps->constrained_intra_pred ? "CONSTR" : "", - pps->redundant_pic_cnt_present ? "REDU" : "" - ); - } - - 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(MpegEncContext *s, uint8_t *buf, int buf_size){ - ParseContext *pc= &s->parse_context; - int i; - uint32_t state; -//printf("first %02X%02X%02X%02X\n", buf[0], buf[1],buf[2],buf[3]); -// mb_addr= pc->mb_addr - 1; - state= pc->state; - //FIXME this will fail with slices - for(i=0; iframe_start_found){ - pc->state=-1; - pc->frame_start_found= 0; - return i-3; - } - pc->frame_start_found= 1; - } - } - - pc->state= state; - return END_NOT_FOUND; -} - -static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){ - MpegEncContext * const s = &h->s; - AVCodecContext * const avctx= s->avctx; - int buf_index=0; -#if 0 - int i; - for(i=0; i<32; i++){ - printf("%X ", buf[i]); - } -#endif - for(;;){ - int consumed; - int dst_length; - int bit_length; - uint8_t *ptr; - - // start code prefix search - for(; buf_index + 3 < buf_size; buf_index++){ - // this should allways succeed in the first iteration - if(buf[buf_index] == 0 && buf[buf_index+1] == 0 && buf[buf_index+2] == 1) - break; - } - - if(buf_index+3 >= buf_size) break; - - buf_index+=3; - - ptr= decode_nal(h, buf + buf_index, &dst_length, &consumed, buf_size - buf_index); - if(ptr[dst_length - 1] == 0) dst_length--; - bit_length= 8*dst_length - decode_rbsp_trailing(ptr + dst_length - 1); - - if(s->avctx->debug&FF_DEBUG_STARTCODE){ - printf("NAL %d at %d length %d\n", h->nal_unit_type, buf_index, dst_length); - } - - buf_index += consumed; - - if(h->nal_ref_idc < s->hurry_up) - continue; - - switch(h->nal_unit_type){ - case NAL_IDR_SLICE: - idr(h); //FIXME ensure we dont loose some frames if there is reordering - case NAL_SLICE: - init_get_bits(&s->gb, ptr, bit_length); - h->intra_gb_ptr= - h->inter_gb_ptr= &s->gb; - s->data_partitioning = 0; - - if(decode_slice_header(h) < 0) return -1; - if(h->redundant_pic_count==0) - decode_slice(h); - break; - case NAL_DPA: - init_get_bits(&s->gb, ptr, bit_length); - h->intra_gb_ptr= - h->inter_gb_ptr= NULL; - s->data_partitioning = 1; - - if(decode_slice_header(h) < 0) return -1; - break; - case NAL_DPB: - init_get_bits(&h->intra_gb, ptr, bit_length); - h->intra_gb_ptr= &h->intra_gb; - break; - case NAL_DPC: - init_get_bits(&h->inter_gb, ptr, bit_length); - h->inter_gb_ptr= &h->inter_gb; - - if(h->redundant_pic_count==0 && h->intra_gb_ptr && s->data_partitioning) - decode_slice(h); - break; - case NAL_SEI: - break; - case NAL_SPS: - init_get_bits(&s->gb, ptr, bit_length); - decode_seq_parameter_set(h); - - if(s->flags& CODEC_FLAG_LOW_DELAY) - s->low_delay=1; - - avctx->has_b_frames= !s->low_delay; - break; - case NAL_PPS: - init_get_bits(&s->gb, ptr, bit_length); - - decode_picture_parameter_set(h); - - break; - case NAL_PICTURE_DELIMITER: - break; - case NAL_FILTER_DATA: - break; - } - - //FIXME move after where irt is set - s->current_picture.pict_type= s->pict_type; - s->current_picture.key_frame= s->pict_type == I_TYPE; - } - - if(!s->current_picture_ptr) return buf_index; //no frame - - h->prev_frame_num_offset= h->frame_num_offset; - h->prev_frame_num= h->frame_num; - if(s->current_picture_ptr->reference){ - h->prev_poc_msb= h->poc_msb; - h->prev_poc_lsb= h->poc_lsb; - } - if(s->current_picture_ptr->reference) - execute_ref_pic_marking(h, h->mmco, h->mmco_index); - else - assert(h->mmco_index==0); - - ff_er_frame_end(s); - MPV_frame_end(s); - - return buf_index; -} - -/** - * retunrs the number of bytes consumed for building the current frame - */ -static int get_consumed_bytes(MpegEncContext *s, int pos, int buf_size){ - if(s->flags&CODEC_FLAG_TRUNCATED){ - pos -= s->parse_context.last_index; - if(pos<0) pos=0; // FIXME remove (uneeded?) - - 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_frame(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - H264Context *h = avctx->priv_data; - MpegEncContext *s = &h->s; - AVFrame *pict = data; - int buf_index; - - s->flags= avctx->flags; - - *data_size = 0; - - /* no supplementary picture */ - if (buf_size == 0) { - return 0; - } - - if(s->flags&CODEC_FLAG_TRUNCATED){ - int next= find_frame_end(s, buf, buf_size); - - if( ff_combine_frame(s, next, &buf, &buf_size) < 0 ) - return buf_size; -//printf("next:%d buf_size:%d last_index:%d\n", next, buf_size, s->parse_context.last_index); - } - - if(s->avctx->extradata_size && s->picture_number==0){ - if(0 < decode_nal_units(h, s->avctx->extradata, s->avctx->extradata_size) ) - return -1; - } - - buf_index=decode_nal_units(h, buf, buf_size); - if(buf_index < 0) - return -1; - - //FIXME do something with unavailable reference frames - -// if(ret==FRAME_SKIPED) return get_consumed_bytes(s, buf_index, buf_size); -#if 0 - if(s->pict_type==B_TYPE || s->low_delay){ - *pict= *(AVFrame*)&s->current_picture; - } else { - *pict= *(AVFrame*)&s->last_picture; - } -#endif - if(!s->current_picture_ptr){ - fprintf(stderr, "error, NO frame\n"); - return -1; - } - - *pict= *(AVFrame*)&s->current_picture; //FIXME - ff_print_debug_info(s, s->current_picture_ptr); - assert(pict->data[0]); -//printf("out %d\n", (int)pict->data[0]); -#if 0 //? - - /* 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; -#endif -#if 0 - /* dont output the last pic after seeking */ - if(s->last_picture_ptr || s->low_delay) - //Note this isnt a issue as a IDR pic should flush teh buffers -#endif - *data_size = sizeof(AVFrame); - return get_consumed_bytes(s, buf_index, buf_size); -} -#if 0 -static inline void fill_mb_avail(H264Context *h){ - MpegEncContext * const s = &h->s; - const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; - - if(s->mb_y){ - h->mb_avail[0]= s->mb_x && h->slice_table[mb_xy - s->mb_stride - 1] == h->slice_num; - h->mb_avail[1]= h->slice_table[mb_xy - s->mb_stride ] == h->slice_num; - h->mb_avail[2]= s->mb_x+1 < s->mb_width && h->slice_table[mb_xy - s->mb_stride + 1] == h->slice_num; - }else{ - h->mb_avail[0]= - h->mb_avail[1]= - h->mb_avail[2]= 0; - } - h->mb_avail[3]= s->mb_x && h->slice_table[mb_xy - 1] == h->slice_num; - h->mb_avail[4]= 1; //FIXME move out - h->mb_avail[5]= 0; //FIXME move out -} -#endif - -#if 0 //selftest -#define COUNT 8000 -#define SIZE (COUNT*40) -int main(){ - int i; - uint8_t temp[SIZE]; - PutBitContext pb; - GetBitContext gb; -// int int_temp[10000]; - DSPContext dsp; - AVCodecContext avctx; - - dsputil_init(&dsp, &avctx); - - init_put_bits(&pb, temp, SIZE, NULL, NULL); - printf("testing unsigned exp golomb\n"); - for(i=0; ipriv_data; - MpegEncContext *s = &h->s; - - free_tables(h); //FIXME cleanup init stuff perhaps - MPV_common_end(s); - -// memset(h, 0, sizeof(H264Context)); - - return 0; -} - - -AVCodec h264_decoder = { - "h264", - CODEC_TYPE_VIDEO, - CODEC_ID_H264, - sizeof(H264Context), - decode_init, - NULL, - decode_end, - decode_frame, - /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED, -}; - -#include "svq3.c" diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h264data.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h264data.h deleted file mode 100644 index 0a7ad50..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/h264data.h +++ /dev/null @@ -1,530 +0,0 @@ -/* - * H26L/H264/AVC/JVT/14496-10/... encoder/decoder - * 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 - * - */ - -/** - * @file h264data.h - * @brief - * H264 / AVC / MPEG4 part10 codec data table - * @author Michael Niedermayer - */ - -#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 uint16_t pixel_aspect[16][2]={ - {0, 0}, - {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 -}; - -#define MB_TYPE_REF0 MB_TYPE_ACPRED //dirty but it fits in 16bit -#define IS_REF0(a) ((a)&MB_TYPE_REF0) - -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 , 4}, -{MB_TYPE_8x8 |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 , 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, }, -}; - -#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,}, -}; diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/huffyuv.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/huffyuv.c deleted file mode 100644 index 7970cd3..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/huffyuv.c +++ /dev/null @@ -1,1142 +0,0 @@ -/* - * huffyuv codec for libavcodec - * - * Copyright (c) 2002-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 - * - * see http://www.pcisys.net/~melanson/codecs/huffyuv.txt for a description of - * the algorithm used - */ - -/** - * @file huffyuv.c - * huffyuv codec for libavcodec. - */ - -#include "common.h" -#include "avcodec.h" -#include "dsputil.h" - -#ifndef INT64_MAX -#define INT64_MAX 9223372036854775807LL -#endif - -#define VLC_BITS 11 - -typedef enum Predictor{ - LEFT= 0, - PLANE, - MEDIAN, -} Predictor; - -typedef struct HYuvContext{ - AVCodecContext *avctx; - Predictor predictor; - GetBitContext gb; - PutBitContext pb; - int interlaced; - int decorrelate; - int bitstream_bpp; - int version; - int yuy2; //use yuy2 instead of 422P - int bgr32; //use bgr32 instead of bgr24 - int width, height; - int flags; - int picture_number; - int last_slice_end; - uint8_t __align8 temp[3][2500]; - uint64_t stats[3][256]; - uint8_t len[3][256]; - uint32_t bits[3][256]; - VLC vlc[3]; - AVFrame picture; - uint8_t __align8 bitstream_buffer[1024*1024*3]; //FIXME dynamic alloc or some other solution - DSPContext dsp; -}HYuvContext; - -static const unsigned char classic_shift_luma[] = { - 34,36,35,69,135,232,9,16,10,24,11,23,12,16,13,10,14,8,15,8, - 16,8,17,20,16,10,207,206,205,236,11,8,10,21,9,23,8,8,199,70, - 69,68, 0 -}; - -static const unsigned char classic_shift_chroma[] = { - 66,36,37,38,39,40,41,75,76,77,110,239,144,81,82,83,84,85,118,183, - 56,57,88,89,56,89,154,57,58,57,26,141,57,56,58,57,58,57,184,119, - 214,245,116,83,82,49,80,79,78,77,44,75,41,40,39,38,37,36,34, 0 -}; - -static const unsigned char classic_add_luma[256] = { - 3, 9, 5, 12, 10, 35, 32, 29, 27, 50, 48, 45, 44, 41, 39, 37, - 73, 70, 68, 65, 64, 61, 58, 56, 53, 50, 49, 46, 44, 41, 38, 36, - 68, 65, 63, 61, 58, 55, 53, 51, 48, 46, 45, 43, 41, 39, 38, 36, - 35, 33, 32, 30, 29, 27, 26, 25, 48, 47, 46, 44, 43, 41, 40, 39, - 37, 36, 35, 34, 32, 31, 30, 28, 27, 26, 24, 23, 22, 20, 19, 37, - 35, 34, 33, 31, 30, 29, 27, 26, 24, 23, 21, 20, 18, 17, 15, 29, - 27, 26, 24, 22, 21, 19, 17, 16, 14, 26, 25, 23, 21, 19, 18, 16, - 15, 27, 25, 23, 21, 19, 17, 16, 14, 26, 25, 23, 21, 18, 17, 14, - 12, 17, 19, 13, 4, 9, 2, 11, 1, 7, 8, 0, 16, 3, 14, 6, - 12, 10, 5, 15, 18, 11, 10, 13, 15, 16, 19, 20, 22, 24, 27, 15, - 18, 20, 22, 24, 26, 14, 17, 20, 22, 24, 27, 15, 18, 20, 23, 25, - 28, 16, 19, 22, 25, 28, 32, 36, 21, 25, 29, 33, 38, 42, 45, 49, - 28, 31, 34, 37, 40, 42, 44, 47, 49, 50, 52, 54, 56, 57, 59, 60, - 62, 64, 66, 67, 69, 35, 37, 39, 40, 42, 43, 45, 47, 48, 51, 52, - 54, 55, 57, 59, 60, 62, 63, 66, 67, 69, 71, 72, 38, 40, 42, 43, - 46, 47, 49, 51, 26, 28, 30, 31, 33, 34, 18, 19, 11, 13, 7, 8, -}; - -static const unsigned char classic_add_chroma[256] = { - 3, 1, 2, 2, 2, 2, 3, 3, 7, 5, 7, 5, 8, 6, 11, 9, - 7, 13, 11, 10, 9, 8, 7, 5, 9, 7, 6, 4, 7, 5, 8, 7, - 11, 8, 13, 11, 19, 15, 22, 23, 20, 33, 32, 28, 27, 29, 51, 77, - 43, 45, 76, 81, 46, 82, 75, 55, 56,144, 58, 80, 60, 74,147, 63, - 143, 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, 27, 30, 21, 22, - 17, 14, 5, 6,100, 54, 47, 50, 51, 53,106,107,108,109,110,111, - 112,113,114,115, 4,117,118, 92, 94,121,122, 3,124,103, 2, 1, - 0,129,130,131,120,119,126,125,136,137,138,139,140,141,142,134, - 135,132,133,104, 64,101, 62, 57,102, 95, 93, 59, 61, 28, 97, 96, - 52, 49, 48, 29, 32, 25, 24, 46, 23, 98, 45, 44, 43, 20, 42, 41, - 19, 18, 99, 40, 15, 39, 38, 16, 13, 12, 11, 37, 10, 9, 8, 36, - 7,128,127,105,123,116, 35, 34, 33,145, 31, 79, 42,146, 78, 26, - 83, 48, 49, 50, 44, 47, 26, 31, 30, 18, 17, 19, 21, 24, 25, 13, - 14, 16, 17, 18, 20, 21, 12, 14, 15, 9, 10, 6, 9, 6, 5, 8, - 6, 12, 8, 10, 7, 9, 6, 4, 6, 2, 2, 3, 3, 3, 3, 2, -}; - -static inline int add_left_prediction(uint8_t *dst, uint8_t *src, int w, int acc){ - int i; - - for(i=0; idsp.diff_bytes(dst+16, src+16, src+15, w-16); - return src[w-1]; - } -} - -static void read_len_table(uint8_t *dst, GetBitContext *gb){ - int i, val, repeat; - - for(i=0; i<256;){ - repeat= get_bits(gb, 3); - val = get_bits(gb, 5); - if(repeat==0) - repeat= get_bits(gb, 8); -//printf("%d %d\n", val, repeat); - while (repeat--) - dst[i++] = val; - } -} - -static int generate_bits_table(uint32_t *dst, uint8_t *len_table){ - int len, index; - uint32_t bits=0; - - for(len=32; len>0; len--){ - for(index=0; index<256; index++){ - if(len_table[index]==len) - dst[index]= bits++; - } - if(bits & 1){ - fprintf(stderr, "Error generating huffman table\n"); - return -1; - } - bits >>= 1; - } - return 0; -} - -static void generate_len_table(uint8_t *dst, uint64_t *stats, int size){ - uint64_t counts[2*size]; - int up[2*size]; - int offset, i, next; - - for(offset=1; ; offset<<=1){ - for(i=0; i counts[i]){ - if(min1 > counts[i]){ - min2= min1; - min2_i= min1_i; - min1= counts[i]; - min1_i= i; - }else{ - min2= counts[i]; - min2_i= i; - } - } - } - - if(min2==INT64_MAX) break; - - counts[next]= min1 + min2; - counts[min1_i]= - counts[min2_i]= INT64_MAX; - up[min1_i]= - up[min2_i]= next; - up[next]= -1; - } - - for(i=0; i 32) break; - - dst[i]= len; - } - if(i==size) break; - } -} - -static int read_huffman_tables(HYuvContext *s, uint8_t *src, int length){ - GetBitContext gb; - int i; - - init_get_bits(&gb, src, length*8); - - for(i=0; i<3; i++){ - read_len_table(s->len[i], &gb); - - if(generate_bits_table(s->bits[i], s->len[i])<0){ - return -1; - } -#if 0 -for(j=0; j<256; j++){ -printf("%6X, %2d, %3d\n", s->bits[i][j], s->len[i][j], j); -} -#endif - init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4); - } - - return 0; -} - -static int read_old_huffman_tables(HYuvContext *s){ -#if 1 - GetBitContext gb; - int i; - - init_get_bits(&gb, classic_shift_luma, sizeof(classic_shift_luma)*8); - read_len_table(s->len[0], &gb); - init_get_bits(&gb, classic_shift_chroma, sizeof(classic_shift_chroma)*8); - read_len_table(s->len[1], &gb); - - for(i=0; i<256; i++) s->bits[0][i] = classic_add_luma [i]; - for(i=0; i<256; i++) s->bits[1][i] = classic_add_chroma[i]; - - if(s->bitstream_bpp >= 24){ - memcpy(s->bits[1], s->bits[0], 256*sizeof(uint32_t)); - memcpy(s->len[1] , s->len [0], 256*sizeof(uint8_t)); - } - memcpy(s->bits[2], s->bits[1], 256*sizeof(uint32_t)); - memcpy(s->len[2] , s->len [1], 256*sizeof(uint8_t)); - - for(i=0; i<3; i++) - init_vlc(&s->vlc[i], VLC_BITS, 256, s->len[i], 1, 1, s->bits[i], 4, 4); - - return 0; -#else - fprintf(stderr, "v1 huffyuv is not supported \n"); - return -1; -#endif -} - -static int decode_init(AVCodecContext *avctx) -{ - HYuvContext *s = avctx->priv_data; - int width, height; - - s->avctx= avctx; - s->flags= avctx->flags; - - dsputil_init(&s->dsp, avctx); - - width= s->width= avctx->width; - height= s->height= avctx->height; - avctx->coded_frame= &s->picture; - -s->bgr32=1; - assert(width && height); -//if(avctx->extradata) -// printf("extradata:%X, extradata_size:%d\n", *(uint32_t*)avctx->extradata, avctx->extradata_size); - if(avctx->extradata_size){ - if((avctx->bits_per_sample&7) && avctx->bits_per_sample != 12) - s->version=1; // do such files exist at all? - else - s->version=2; - }else - s->version=0; - - if(s->version==2){ - int method; - - method= ((uint8_t*)avctx->extradata)[0]; - s->decorrelate= method&64 ? 1 : 0; - s->predictor= method&63; - s->bitstream_bpp= ((uint8_t*)avctx->extradata)[1]; - if(s->bitstream_bpp==0) - s->bitstream_bpp= avctx->bits_per_sample&~7; - - if(read_huffman_tables(s, ((uint8_t*)avctx->extradata)+4, avctx->extradata_size) < 0) - return -1; - }else{ - switch(avctx->bits_per_sample&7){ - case 1: - s->predictor= LEFT; - s->decorrelate= 0; - break; - case 2: - s->predictor= LEFT; - s->decorrelate= 1; - break; - case 3: - s->predictor= PLANE; - s->decorrelate= avctx->bits_per_sample >= 24; - break; - case 4: - s->predictor= MEDIAN; - s->decorrelate= 0; - break; - default: - s->predictor= LEFT; //OLD - s->decorrelate= 0; - break; - } - s->bitstream_bpp= avctx->bits_per_sample & ~7; - - if(read_old_huffman_tables(s) < 0) - return -1; - } - - s->interlaced= height > 288; - - switch(s->bitstream_bpp){ - case 12: - avctx->pix_fmt = PIX_FMT_YUV420P; - break; - case 16: - if(s->yuy2){ - avctx->pix_fmt = PIX_FMT_YUV422; - }else{ - avctx->pix_fmt = PIX_FMT_YUV422P; - } - break; - case 24: - case 32: - if(s->bgr32){ - avctx->pix_fmt = PIX_FMT_RGBA32; - }else{ - avctx->pix_fmt = PIX_FMT_BGR24; - } - break; - default: - assert(0); - } - -// printf("pred:%d bpp:%d hbpp:%d il:%d\n", s->predictor, s->bitstream_bpp, avctx->bits_per_sample, s->interlaced); - - return 0; -} - -static void store_table(HYuvContext *s, uint8_t *len){ - int i; - int index= s->avctx->extradata_size; - - for(i=0; i<256;){ - int cur=i; - int val= len[i]; - int repeat; - - for(; i<256 && len[i]==val; i++); - - repeat= i - cur; - - if(repeat>7){ - ((uint8_t*)s->avctx->extradata)[index++]= val; - ((uint8_t*)s->avctx->extradata)[index++]= repeat; - }else{ - ((uint8_t*)s->avctx->extradata)[index++]= val | (repeat<<5); - } - } - - s->avctx->extradata_size= index; -} - -static int encode_init(AVCodecContext *avctx) -{ - HYuvContext *s = avctx->priv_data; - int i, j, width, height; - - s->avctx= avctx; - s->flags= avctx->flags; - - dsputil_init(&s->dsp, avctx); - - width= s->width= avctx->width; - height= s->height= avctx->height; - - assert(width && height); - - avctx->extradata= av_mallocz(1024*10); - avctx->stats_out= av_mallocz(1024*10); - s->version=2; - - avctx->coded_frame= &s->picture; - - switch(avctx->pix_fmt){ - case PIX_FMT_YUV420P: - if(avctx->strict_std_compliance>=0){ - fprintf(stderr, "YV12-huffyuv is experimental, there WILL be no compatbility! (use (v)strict=-1)\n"); - return -1; - } - s->bitstream_bpp= 12; - break; - case PIX_FMT_YUV422P: - s->bitstream_bpp= 16; - break; - default: - fprintf(stderr, "format not supported\n"); - return -1; - } - avctx->bits_per_sample= s->bitstream_bpp; - s->decorrelate= s->bitstream_bpp >= 24; - s->predictor= avctx->prediction_method; - - ((uint8_t*)avctx->extradata)[0]= s->predictor; - ((uint8_t*)avctx->extradata)[1]= s->bitstream_bpp; - ((uint8_t*)avctx->extradata)[2]= - ((uint8_t*)avctx->extradata)[3]= 0; - s->avctx->extradata_size= 4; - - if(avctx->stats_in){ - char *p= avctx->stats_in; - - for(i=0; i<3; i++) - for(j=0; j<256; j++) - s->stats[i][j]= 1; - - for(;;){ - for(i=0; i<3; i++){ - char *next; - - for(j=0; j<256; j++){ - s->stats[i][j]+= strtol(p, &next, 0); - if(next==p) return -1; - p=next; - } - } - if(p[0]==0 || p[1]==0 || p[2]==0) break; - } - }else{ - for(i=0; i<3; i++) - for(j=0; j<256; j++){ - int d= FFMIN(j, 256-j); - - s->stats[i][j]= 100000000/(d+1); - } - } - - for(i=0; i<3; i++){ - generate_len_table(s->len[i], s->stats[i], 256); - - if(generate_bits_table(s->bits[i], s->len[i])<0){ - return -1; - } - - store_table(s, s->len[i]); - } - - for(i=0; i<3; i++) - for(j=0; j<256; j++) - s->stats[i][j]= 0; - - s->interlaced= height > 288; - -// printf("pred:%d bpp:%d hbpp:%d il:%d\n", s->predictor, s->bitstream_bpp, avctx->bits_per_sample, s->interlaced); - - s->picture_number=0; - - return 0; -} - -static void decode_422_bitstream(HYuvContext *s, int count){ - int i; - - count/=2; - - for(i=0; itemp[0][2*i ]= get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3); - s->temp[1][ i ]= get_vlc2(&s->gb, s->vlc[1].table, VLC_BITS, 3); - s->temp[0][2*i+1]= get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3); - s->temp[2][ i ]= get_vlc2(&s->gb, s->vlc[2].table, VLC_BITS, 3); - } -} - -static void decode_gray_bitstream(HYuvContext *s, int count){ - int i; - - count/=2; - - for(i=0; itemp[0][2*i ]= get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3); - s->temp[0][2*i+1]= get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3); - } -} - -static void encode_422_bitstream(HYuvContext *s, int count){ - int i; - - count/=2; - if(s->flags&CODEC_FLAG_PASS1){ - for(i=0; istats[0][ s->temp[0][2*i ] ]++; - s->stats[1][ s->temp[1][ i ] ]++; - s->stats[0][ s->temp[0][2*i+1] ]++; - s->stats[2][ s->temp[2][ i ] ]++; - } - }else{ - for(i=0; ipb, s->len[0][ s->temp[0][2*i ] ], s->bits[0][ s->temp[0][2*i ] ]); - put_bits(&s->pb, s->len[1][ s->temp[1][ i ] ], s->bits[1][ s->temp[1][ i ] ]); - put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]); - put_bits(&s->pb, s->len[2][ s->temp[2][ i ] ], s->bits[2][ s->temp[2][ i ] ]); - } - } -} - -static void encode_gray_bitstream(HYuvContext *s, int count){ - int i; - - count/=2; - if(s->flags&CODEC_FLAG_PASS1){ - for(i=0; istats[0][ s->temp[0][2*i ] ]++; - s->stats[0][ s->temp[0][2*i+1] ]++; - } - }else{ - for(i=0; ipb, s->len[0][ s->temp[0][2*i ] ], s->bits[0][ s->temp[0][2*i ] ]); - put_bits(&s->pb, s->len[0][ s->temp[0][2*i+1] ], s->bits[0][ s->temp[0][2*i+1] ]); - } - } -} - -static void decode_bgr_bitstream(HYuvContext *s, int count){ - int i; - - if(s->decorrelate){ - if(s->bitstream_bpp==24){ - for(i=0; itemp[0][4*i+1]= get_vlc2(&s->gb, s->vlc[1].table, VLC_BITS, 3); - s->temp[0][4*i ]= get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3) + s->temp[0][4*i+1]; - s->temp[0][4*i+2]= get_vlc2(&s->gb, s->vlc[2].table, VLC_BITS, 3) + s->temp[0][4*i+1]; - } - }else{ - for(i=0; itemp[0][4*i+1]= get_vlc2(&s->gb, s->vlc[1].table, VLC_BITS, 3); - s->temp[0][4*i ]= get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3) + s->temp[0][4*i+1]; - s->temp[0][4*i+2]= get_vlc2(&s->gb, s->vlc[2].table, VLC_BITS, 3) + s->temp[0][4*i+1]; - get_vlc2(&s->gb, s->vlc[2].table, VLC_BITS, 3); //?! - } - } - }else{ - if(s->bitstream_bpp==24){ - for(i=0; itemp[0][4*i ]= get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3); - s->temp[0][4*i+1]= get_vlc2(&s->gb, s->vlc[1].table, VLC_BITS, 3); - s->temp[0][4*i+2]= get_vlc2(&s->gb, s->vlc[2].table, VLC_BITS, 3); - } - }else{ - for(i=0; itemp[0][4*i ]= get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3); - s->temp[0][4*i+1]= get_vlc2(&s->gb, s->vlc[1].table, VLC_BITS, 3); - s->temp[0][4*i+2]= get_vlc2(&s->gb, s->vlc[2].table, VLC_BITS, 3); - get_vlc2(&s->gb, s->vlc[2].table, VLC_BITS, 3); //?! - } - } - } -} - -static void draw_slice(HYuvContext *s, int y){ - int h, cy; - int offset[4]; - - if(s->avctx->draw_horiz_band==NULL) - return; - - h= y - s->last_slice_end; - y -= h; - - if(s->bitstream_bpp==12){ - cy= y>>1; - }else{ - cy= y; - } - - offset[0] = s->picture.linesize[0]*y; - offset[1] = s->picture.linesize[1]*cy; - offset[2] = s->picture.linesize[2]*cy; - offset[3] = 0; - emms_c(); - - s->avctx->draw_horiz_band(s->avctx, &s->picture, offset, y, 3, h); - - s->last_slice_end= y + h; -} - -static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size){ - HYuvContext *s = avctx->priv_data; - const int width= s->width; - const int width2= s->width>>1; - const int height= s->height; - int fake_ystride, fake_ustride, fake_vstride; - AVFrame * const p= &s->picture; - - AVFrame *picture = data; - - *data_size = 0; - - /* no supplementary picture */ - if (buf_size == 0) - return 0; - - s->dsp.bswap_buf((uint32_t*)s->bitstream_buffer, (uint32_t*)buf, buf_size/4); - - init_get_bits(&s->gb, s->bitstream_buffer, buf_size*8); - - if(p->data[0]) - avctx->release_buffer(avctx, p); - - p->reference= 0; - if(avctx->get_buffer(avctx, p) < 0){ - fprintf(stderr, "get_buffer() failed\n"); - return -1; - } - - fake_ystride= s->interlaced ? p->linesize[0]*2 : p->linesize[0]; - fake_ustride= s->interlaced ? p->linesize[1]*2 : p->linesize[1]; - fake_vstride= s->interlaced ? p->linesize[2]*2 : p->linesize[2]; - - s->last_slice_end= 0; - - if(s->bitstream_bpp<24){ - int y, cy; - int lefty, leftu, leftv; - int lefttopy, lefttopu, lefttopv; - - if(s->yuy2){ - p->data[0][3]= get_bits(&s->gb, 8); - p->data[0][2]= get_bits(&s->gb, 8); - p->data[0][1]= get_bits(&s->gb, 8); - p->data[0][0]= get_bits(&s->gb, 8); - - fprintf(stderr, "YUY2 output isnt implemenetd yet\n"); - return -1; - }else{ - - leftv= p->data[2][0]= get_bits(&s->gb, 8); - lefty= p->data[0][1]= get_bits(&s->gb, 8); - leftu= p->data[1][0]= get_bits(&s->gb, 8); - p->data[0][0]= get_bits(&s->gb, 8); - - switch(s->predictor){ - case LEFT: - case PLANE: - decode_422_bitstream(s, width-2); - lefty= add_left_prediction(p->data[0] + 2, s->temp[0], width-2, lefty); - if(!(s->flags&CODEC_FLAG_GRAY)){ - leftu= add_left_prediction(p->data[1] + 1, s->temp[1], width2-1, leftu); - leftv= add_left_prediction(p->data[2] + 1, s->temp[2], width2-1, leftv); - } - - for(cy=y=1; yheight; y++,cy++){ - uint8_t *ydst, *udst, *vdst; - - if(s->bitstream_bpp==12){ - decode_gray_bitstream(s, width); - - ydst= p->data[0] + p->linesize[0]*y; - - lefty= add_left_prediction(ydst, s->temp[0], width, lefty); - if(s->predictor == PLANE){ - if(y>s->interlaced) - s->dsp.add_bytes(ydst, ydst - fake_ystride, width); - } - y++; - if(y>=s->height) break; - } - - draw_slice(s, y); - - ydst= p->data[0] + p->linesize[0]*y; - udst= p->data[1] + p->linesize[1]*cy; - vdst= p->data[2] + p->linesize[2]*cy; - - decode_422_bitstream(s, width); - lefty= add_left_prediction(ydst, s->temp[0], width, lefty); - if(!(s->flags&CODEC_FLAG_GRAY)){ - leftu= add_left_prediction(udst, s->temp[1], width2, leftu); - leftv= add_left_prediction(vdst, s->temp[2], width2, leftv); - } - if(s->predictor == PLANE){ - if(cy>s->interlaced){ - s->dsp.add_bytes(ydst, ydst - fake_ystride, width); - if(!(s->flags&CODEC_FLAG_GRAY)){ - s->dsp.add_bytes(udst, udst - fake_ustride, width2); - s->dsp.add_bytes(vdst, vdst - fake_vstride, width2); - } - } - } - } - draw_slice(s, height); - - break; - case MEDIAN: - /* first line except first 2 pixels is left predicted */ - decode_422_bitstream(s, width-2); - lefty= add_left_prediction(p->data[0] + 2, s->temp[0], width-2, lefty); - if(!(s->flags&CODEC_FLAG_GRAY)){ - leftu= add_left_prediction(p->data[1] + 1, s->temp[1], width2-1, leftu); - leftv= add_left_prediction(p->data[2] + 1, s->temp[2], width2-1, leftv); - } - - cy=y=1; - - /* second line is left predicted for interlaced case */ - if(s->interlaced){ - decode_422_bitstream(s, width); - lefty= add_left_prediction(p->data[0] + p->linesize[0], s->temp[0], width, lefty); - if(!(s->flags&CODEC_FLAG_GRAY)){ - leftu= add_left_prediction(p->data[1] + p->linesize[2], s->temp[1], width2, leftu); - leftv= add_left_prediction(p->data[2] + p->linesize[1], s->temp[2], width2, leftv); - } - y++; cy++; - } - - /* next 4 pixels are left predicted too */ - decode_422_bitstream(s, 4); - lefty= add_left_prediction(p->data[0] + fake_ystride, s->temp[0], 4, lefty); - if(!(s->flags&CODEC_FLAG_GRAY)){ - leftu= add_left_prediction(p->data[1] + fake_ustride, s->temp[1], 2, leftu); - leftv= add_left_prediction(p->data[2] + fake_vstride, s->temp[2], 2, leftv); - } - - /* next line except the first 4 pixels is median predicted */ - lefttopy= p->data[0][3]; - decode_422_bitstream(s, width-4); - add_median_prediction(p->data[0] + fake_ystride+4, p->data[0]+4, s->temp[0], width-4, &lefty, &lefttopy); - if(!(s->flags&CODEC_FLAG_GRAY)){ - lefttopu= p->data[1][1]; - lefttopv= p->data[2][1]; - add_median_prediction(p->data[1] + fake_ustride+2, p->data[1]+2, s->temp[1], width2-2, &leftu, &lefttopu); - add_median_prediction(p->data[2] + fake_vstride+2, p->data[2]+2, s->temp[2], width2-2, &leftv, &lefttopv); - } - y++; cy++; - - for(; ybitstream_bpp==12){ - while(2*cy > y){ - decode_gray_bitstream(s, width); - ydst= p->data[0] + p->linesize[0]*y; - add_median_prediction(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy); - y++; - } - if(y>=height) break; - } - draw_slice(s, y); - - decode_422_bitstream(s, width); - - ydst= p->data[0] + p->linesize[0]*y; - udst= p->data[1] + p->linesize[1]*cy; - vdst= p->data[2] + p->linesize[2]*cy; - - add_median_prediction(ydst, ydst - fake_ystride, s->temp[0], width, &lefty, &lefttopy); - if(!(s->flags&CODEC_FLAG_GRAY)){ - add_median_prediction(udst, udst - fake_ustride, s->temp[1], width2, &leftu, &lefttopu); - add_median_prediction(vdst, vdst - fake_vstride, s->temp[2], width2, &leftv, &lefttopv); - } - } - - draw_slice(s, height); - break; - } - } - }else{ - int y; - int leftr, leftg, leftb; - const int last_line= (height-1)*p->linesize[0]; - - if(s->bitstream_bpp==32){ - p->data[0][last_line+3]= get_bits(&s->gb, 8); - leftr= p->data[0][last_line+2]= get_bits(&s->gb, 8); - leftg= p->data[0][last_line+1]= get_bits(&s->gb, 8); - leftb= p->data[0][last_line+0]= get_bits(&s->gb, 8); - }else{ - leftr= p->data[0][last_line+2]= get_bits(&s->gb, 8); - leftg= p->data[0][last_line+1]= get_bits(&s->gb, 8); - leftb= p->data[0][last_line+0]= get_bits(&s->gb, 8); - skip_bits(&s->gb, 8); - } - - if(s->bgr32){ - switch(s->predictor){ - case LEFT: - case PLANE: - decode_bgr_bitstream(s, width-1); - add_left_prediction_bgr32(p->data[0] + last_line+4, s->temp[0], width-1, &leftr, &leftg, &leftb); - - for(y=s->height-2; y>=0; y--){ //yes its stored upside down - decode_bgr_bitstream(s, width); - - add_left_prediction_bgr32(p->data[0] + p->linesize[0]*y, s->temp[0], width, &leftr, &leftg, &leftb); - if(s->predictor == PLANE){ - if((y&s->interlaced)==0){ - s->dsp.add_bytes(p->data[0] + p->linesize[0]*y, - p->data[0] + p->linesize[0]*y + fake_ystride, fake_ystride); - } - } - } - draw_slice(s, height); // just 1 large slice as this isnt possible in reverse order - break; - default: - fprintf(stderr, "prediction type not supported!\n"); - } - }else{ - - fprintf(stderr, "BGR24 output isnt implemenetd yet\n"); - return -1; - } - } - emms_c(); - - *picture= *p; - *data_size = sizeof(AVFrame); - - return (get_bits_count(&s->gb)+31)/32*4; -} - -static int decode_end(AVCodecContext *avctx) -{ - HYuvContext *s = avctx->priv_data; - int i; - - for(i=0; i<3; i++){ - free_vlc(&s->vlc[i]); - } - - avcodec_default_free_buffers(avctx); - - return 0; -} - -static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ - HYuvContext *s = avctx->priv_data; - AVFrame *pict = data; - const int width= s->width; - const int width2= s->width>>1; - const int height= s->height; - const int fake_ystride= s->interlaced ? pict->linesize[0]*2 : pict->linesize[0]; - const int fake_ustride= s->interlaced ? pict->linesize[1]*2 : pict->linesize[1]; - const int fake_vstride= s->interlaced ? pict->linesize[2]*2 : pict->linesize[2]; - AVFrame * const p= &s->picture; - int i, size; - - init_put_bits(&s->pb, buf, buf_size, NULL, NULL); - - *p = *pict; - p->pict_type= FF_I_TYPE; - p->key_frame= 1; - - if(avctx->pix_fmt == PIX_FMT_YUV422P || avctx->pix_fmt == PIX_FMT_YUV420P){ - int lefty, leftu, leftv, y, cy; - - put_bits(&s->pb, 8, leftv= p->data[2][0]); - put_bits(&s->pb, 8, lefty= p->data[0][1]); - put_bits(&s->pb, 8, leftu= p->data[1][0]); - put_bits(&s->pb, 8, p->data[0][0]); - - lefty= sub_left_prediction(s, s->temp[0], p->data[0]+2, width-2 , lefty); - leftu= sub_left_prediction(s, s->temp[1], p->data[1]+1, width2-1, leftu); - leftv= sub_left_prediction(s, s->temp[2], p->data[2]+1, width2-1, leftv); - - encode_422_bitstream(s, width-2); - - if(s->predictor==MEDIAN){ - int lefttopy, lefttopu, lefttopv; - cy=y=1; - if(s->interlaced){ - lefty= sub_left_prediction(s, s->temp[0], p->data[0]+p->linesize[0], width , lefty); - leftu= sub_left_prediction(s, s->temp[1], p->data[1]+p->linesize[1], width2, leftu); - leftv= sub_left_prediction(s, s->temp[2], p->data[2]+p->linesize[2], width2, leftv); - - encode_422_bitstream(s, width); - y++; cy++; - } - - lefty= sub_left_prediction(s, s->temp[0], p->data[0]+fake_ystride, 4, lefty); - leftu= sub_left_prediction(s, s->temp[1], p->data[1]+fake_ystride, 2, leftu); - leftv= sub_left_prediction(s, s->temp[2], p->data[2]+fake_ystride, 2, leftv); - - encode_422_bitstream(s, 4); - - lefttopy= p->data[0][3]; - lefttopu= p->data[1][1]; - lefttopv= p->data[2][1]; - sub_median_prediction(s->temp[0], p->data[0]+4, p->data[0] + fake_ystride+4, width-4 , &lefty, &lefttopy); - sub_median_prediction(s->temp[1], p->data[1]+2, p->data[1] + fake_ustride+2, width2-2, &leftu, &lefttopu); - sub_median_prediction(s->temp[2], p->data[2]+2, p->data[2] + fake_vstride+2, width2-2, &leftv, &lefttopv); - encode_422_bitstream(s, width-4); - y++; cy++; - - for(; ybitstream_bpp==12){ - while(2*cy > y){ - ydst= p->data[0] + p->linesize[0]*y; - sub_median_prediction(s->temp[0], ydst - fake_ystride, ydst, width , &lefty, &lefttopy); - encode_gray_bitstream(s, width); - y++; - } - if(y>=height) break; - } - ydst= p->data[0] + p->linesize[0]*y; - udst= p->data[1] + p->linesize[1]*cy; - vdst= p->data[2] + p->linesize[2]*cy; - - sub_median_prediction(s->temp[0], ydst - fake_ystride, ydst, width , &lefty, &lefttopy); - sub_median_prediction(s->temp[1], udst - fake_ustride, udst, width2, &leftu, &lefttopu); - sub_median_prediction(s->temp[2], vdst - fake_vstride, vdst, width2, &leftv, &lefttopv); - - encode_422_bitstream(s, width); - } - }else{ - for(cy=y=1; ybitstream_bpp==12){ - ydst= p->data[0] + p->linesize[0]*y; - - if(s->predictor == PLANE && s->interlaced < y){ - s->dsp.diff_bytes(s->temp[1], ydst, ydst - fake_ystride, width); - - lefty= sub_left_prediction(s, s->temp[0], s->temp[1], width , lefty); - }else{ - lefty= sub_left_prediction(s, s->temp[0], ydst, width , lefty); - } - encode_gray_bitstream(s, width); - y++; - if(y>=height) break; - } - - ydst= p->data[0] + p->linesize[0]*y; - udst= p->data[1] + p->linesize[1]*cy; - vdst= p->data[2] + p->linesize[2]*cy; - - if(s->predictor == PLANE && s->interlaced < cy){ - s->dsp.diff_bytes(s->temp[1], ydst, ydst - fake_ystride, width); - s->dsp.diff_bytes(s->temp[2], udst, udst - fake_ustride, width2); - s->dsp.diff_bytes(s->temp[3], vdst, vdst - fake_vstride, width2); - - lefty= sub_left_prediction(s, s->temp[0], s->temp[1], width , lefty); - leftu= sub_left_prediction(s, s->temp[1], s->temp[2], width2, leftu); - leftv= sub_left_prediction(s, s->temp[2], s->temp[3], width2, leftv); - }else{ - lefty= sub_left_prediction(s, s->temp[0], ydst, width , lefty); - leftu= sub_left_prediction(s, s->temp[1], udst, width2, leftu); - leftv= sub_left_prediction(s, s->temp[2], vdst, width2, leftv); - } - - encode_422_bitstream(s, width); - } - } - }else{ - fprintf(stderr, "Format not supported!\n"); - } - emms_c(); - - size= (get_bit_count(&s->pb)+31)/32; - - if((s->flags&CODEC_FLAG_PASS1) && (s->picture_number&31)==0){ - int j; - char *p= avctx->stats_out; - for(i=0; i<3; i++){ - for(j=0; j<256; j++){ - sprintf(p, "%llu ", s->stats[i][j]); - p+= strlen(p); - s->stats[i][j]= 0; - } - sprintf(p, "\n"); - p++; - } - }else{ - flush_put_bits(&s->pb); - s->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, size); - } - - s->picture_number++; - - return size*4; -} - -static int encode_end(AVCodecContext *avctx) -{ -// HYuvContext *s = avctx->priv_data; - - av_freep(&avctx->extradata); - av_freep(&avctx->stats_out); - - return 0; -} - -static const AVOption huffyuv_options[] = -{ - AVOPTION_CODEC_INT("prediction_method", "prediction_method", prediction_method, 0, 2, 0), - AVOPTION_END() -}; - -AVCodec huffyuv_decoder = { - "huffyuv", - CODEC_TYPE_VIDEO, - CODEC_ID_HUFFYUV, - sizeof(HYuvContext), - decode_init, - NULL, - decode_end, - decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND, - NULL -}; - -#ifdef CONFIG_ENCODERS - -AVCodec huffyuv_encoder = { - "huffyuv", - CODEC_TYPE_VIDEO, - CODEC_ID_HUFFYUV, - sizeof(HYuvContext), - encode_init, - encode_frame, - encode_end, - .options = huffyuv_options, -}; - -#endif //CONFIG_ENCODERS diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/cputest.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/cputest.c deleted file mode 100644 index b50d653..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/cputest.c +++ /dev/null @@ -1,130 +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 -#include "../dsputil.h" - -/* ebx saving is necessary for PIC. gcc seems unable to see it alone */ -#define cpuid(index,eax,ebx,ecx,edx)\ - __asm __volatile\ - ("movl %%ebx, %%esi\n\t"\ - "cpuid\n\t"\ - "xchgl %%ebx, %%esi"\ - : "=a" (eax), "=S" (ebx),\ - "=c" (ecx), "=d" (edx)\ - : "0" (index)); - -/* Function to test if multimedia instructions are supported... */ -int mm_support(void) -{ - int rval; - int eax, ebx, ecx, edx; - - __asm__ __volatile__ ( - /* See if CPUID instruction is supported ... */ - /* ... Get copies of EFLAGS into eax and ecx */ - "pushf\n\t" - "popl %0\n\t" - "movl %0, %1\n\t" - - /* ... Toggle the ID bit in one copy and store */ - /* to the EFLAGS reg */ - "xorl $0x200000, %0\n\t" - "push %0\n\t" - "popf\n\t" - - /* ... Get the (hopefully modified) EFLAGS */ - "pushf\n\t" - "popl %0\n\t" - : "=a" (eax), "=c" (ecx) - : - : "cc" - ); - - if (eax == ecx) - return 0; /* CPUID not supported */ - - cpuid(0, eax, ebx, ecx, edx); - - if (ebx == 0x756e6547 && - edx == 0x49656e69 && - ecx == 0x6c65746e) { - - /* intel */ - inteltest: - cpuid(1, eax, ebx, ecx, edx); - if ((edx & 0x00800000) == 0) - return 0; - rval = MM_MMX; - if (edx & 0x02000000) - rval |= MM_MMXEXT | MM_SSE; - if (edx & 0x04000000) - rval |= MM_SSE2; - return rval; - } else if (ebx == 0x68747541 && - edx == 0x69746e65 && - ecx == 0x444d4163) { - /* AMD */ - cpuid(0x80000000, eax, ebx, ecx, edx); - if ((unsigned)eax < 0x80000001) - goto inteltest; - cpuid(0x80000001, eax, ebx, ecx, edx); - if ((edx & 0x00800000) == 0) - return 0; - rval = MM_MMX; - if (edx & 0x80000000) - rval |= MM_3DNOW; - if (edx & 0x00400000) - rval |= MM_MMXEXT; - return rval; - } else if (ebx == 0x746e6543 && - edx == 0x48727561 && - ecx == 0x736c7561) { /* "CentaurHauls" */ - /* VIA C3 */ - cpuid(0x80000000, eax, ebx, ecx, edx); - if ((unsigned)eax < 0x80000001) - goto inteltest; - cpuid(0x80000001, eax, ebx, ecx, edx); - rval = 0; - if( edx & ( 1 << 31) ) - rval |= MM_3DNOW; - if( edx & ( 1 << 23) ) - rval |= MM_MMX; - if( edx & ( 1 << 24) ) - rval |= MM_MMXEXT; - return rval; - } 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) - goto inteltest; - cpuid(0x80000001, eax, ebx, ecx, edx); - if ((eax & 0x00800000) == 0) - return 0; - rval = MM_MMX; - if (eax & 0x01000000) - rval |= MM_MMXEXT; - return rval; - } else { - return 0; - } -} - -#ifdef __TEST__ -int main ( void ) -{ - int mm_flags; - mm_flags = mm_support(); - printf("mm_support = 0x%08u\n",mm_flags); - return 0; -} -#endif diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/dsputil_mmx.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/dsputil_mmx.c deleted file mode 100644 index adf27d4..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/dsputil_mmx.c +++ /dev/null @@ -1,1796 +0,0 @@ -/* - * MMX 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 - * - * MMX optimization by Nick Kurshev - */ - -#include "../dsputil.h" -#include "../simple_idct.h" - -int mm_flags; /* multimedia extension flags */ - -/* pixel operations */ -static const uint64_t mm_bone __attribute__ ((aligned(8))) = 0x0101010101010101ULL; -static const uint64_t mm_wone __attribute__ ((aligned(8))) = 0x0001000100010001ULL; -static const uint64_t mm_wtwo __attribute__ ((aligned(8))) = 0x0002000200020002ULL; - -static const uint64_t ff_pw_20 __attribute__ ((aligned(8))) = 0x0014001400140014ULL; -static const uint64_t ff_pw_3 __attribute__ ((aligned(8))) = 0x0003000300030003ULL; -static const uint64_t ff_pw_16 __attribute__ ((aligned(8))) = 0x0010001000100010ULL; -static const uint64_t ff_pw_15 __attribute__ ((aligned(8))) = 0x000F000F000F000FULL; - -#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 */ - -static void get_pixels_mmx(DCTELEM *block, const uint8_t *pixels, int line_size) -{ - asm volatile( - "movl $-128, %%eax \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, %%eax)\n\t" - "movq %%mm1, 8(%1, %%eax)\n\t" - "movq %%mm2, 16(%1, %%eax)\n\t" - "movq %%mm3, 24(%1, %%eax)\n\t" - "addl %3, %0 \n\t" - "addl $32, %%eax \n\t" - "js 1b \n\t" - : "+r" (pixels) - : "r" (block+64), "r" (line_size), "r" (line_size*2) - : "%eax" - ); -} - -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" - "movl $-128, %%eax \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, %%eax)\n\t" - "movq %%mm1, 8(%2, %%eax)\n\t" - "addl %3, %0 \n\t" - "addl %3, %1 \n\t" - "addl $16, %%eax \n\t" - "jnz 1b \n\t" - : "+r" (s1), "+r" (s2) - : "r" (block+64), "r" (stride) - : "%eax" - ); -} - -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" (line_size), "r" (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" (line_size), "r" (line_size*3), "r"(p) - :"memory"); -} - -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_pixels8_mmx(uint8_t *block, const uint8_t *pixels, int line_size, int h) -{ - __asm __volatile( - "lea (%3, %3), %%eax \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" - "addl %%eax, %1 \n\t" - "addl %%eax, %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" - "addl %%eax, %1 \n\t" - "addl %%eax, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - : "+g"(h), "+r" (pixels), "+r" (block) - : "r"(line_size) - : "%eax", "memory" - ); -} - -static void put_pixels16_mmx(uint8_t *block, const uint8_t *pixels, int line_size, int h) -{ - __asm __volatile( - "lea (%3, %3), %%eax \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" - "addl %%eax, %1 \n\t" - "addl %%eax, %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" - "addl %%eax, %1 \n\t" - "addl %%eax, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - : "+g"(h), "+r" (pixels), "+r" (block) - : "r"(line_size) - : "%eax", "memory" - ); -} - -static void clear_blocks_mmx(DCTELEM *blocks) -{ - __asm __volatile( - "pxor %%mm7, %%mm7 \n\t" - "movl $-128*6, %%eax \n\t" - "1: \n\t" - "movq %%mm7, (%0, %%eax) \n\t" - "movq %%mm7, 8(%0, %%eax) \n\t" - "movq %%mm7, 16(%0, %%eax) \n\t" - "movq %%mm7, 24(%0, %%eax) \n\t" - "addl $32, %%eax \n\t" - " js 1b \n\t" - : : "r" (((int)blocks)+128*6) - : "%eax" - ); -} - -static int pix_sum16_mmx(uint8_t * pix, int line_size){ - const int h=16; - int sum; - int 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" - "addl %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" (line_size) - ); - - return sum; -} - -static void add_bytes_mmx(uint8_t *dst, uint8_t *src, int w){ - int 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" - "addl $16, %0 \n\t" - "cmpl %3, %0 \n\t" - " jb 1b \n\t" - : "+r" (i) - : "r"(src), "r"(dst), "r"(w-15) - ); - for(; iput_ ## postfix1 = put_ ## postfix2;\ - c->put_no_rnd_ ## postfix1 = put_no_rnd_ ## postfix2;\ - c->avg_ ## postfix1 = avg_ ## postfix2; - -/* external functions, from idct_mmx.c */ -void ff_mmx_idct(DCTELEM *block); -void ff_mmxext_idct(DCTELEM *block); - -/* 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); -} - -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 - fprintf(stderr, "libavcodec: CPU flags:"); - if (mm_flags & MM_MMX) - fprintf(stderr, " mmx"); - if (mm_flags & MM_MMXEXT) - fprintf(stderr, " mmxext"); - if (mm_flags & MM_3DNOW) - fprintf(stderr, " 3dnow"); - if (mm_flags & MM_SSE) - fprintf(stderr, " sse"); - if (mm_flags & MM_SSE2) - fprintf(stderr, " sse2"); - fprintf(stderr, "\n"); -#endif - - if (mm_flags & MM_MMX) { - const int dct_algo = avctx->dct_algo; - const int idct_algo= avctx->idct_algo; - -#ifdef CONFIG_ENCODERS - if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX) - c->fdct = ff_fdct_mmx; -#endif //CONFIG_ENCODERS - - 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; - } - - c->get_pixels = get_pixels_mmx; - c->diff_pixels = diff_pixels_mmx; - c->put_pixels_clamped = put_pixels_clamped_mmx; - c->add_pixels_clamped = add_pixels_clamped_mmx; - c->clear_blocks = clear_blocks_mmx; - c->pix_sum = pix_sum16_mmx; - - 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; - 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; - - 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; - - c->hadamard8_diff[0]= hadamard8_diff16_mmx2; - c->hadamard8_diff[1]= hadamard8_diff_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; - } - -#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 - } 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) - } - } - - dsputil_init_pix_mmx(c, avctx); -#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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/dsputil_mmx_avg.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/dsputil_mmx_avg.h deleted file mode 100644 index 8418123..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/dsputil_mmx_avg.h +++ /dev/null @@ -1,427 +0,0 @@ -/* - * DSP utils : average functions are compiled twice for 3dnow/mmx2 - * Copyright (c) 2000, 2001 Fabrice Bellard. - * 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 - * - * MMX optimization by Nick Kurshev - * mostly rewritten by Michael Niedermayer - * and improved by Zdenek Kabelac - */ - -/* 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), %%eax \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" - "addl %%eax, %1 \n\t" - "addl %%eax, %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" - "addl %%eax, %1 \n\t" - "movq %%mm0, (%2) \n\t" - "movq %%mm1, (%2, %3) \n\t" - "addl %%eax, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels), "+D"(block) - :"r" (line_size) - :"%eax", "memory"); -} - -static void DEF(put_pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h) -{ - __asm __volatile( - "1: \n\t" - "movq (%1), %%mm0 \n\t" - "addl %4, %1 \n\t" - "movq (%1), %%mm1 \n\t" - "addl %4, %1 \n\t" - PAVGB" (%2), %%mm0 \n\t" - PAVGB" 8(%2), %%mm1 \n\t" - "movq %%mm0, (%3) \n\t" - "addl %5, %3 \n\t" - "movq %%mm1, (%3) \n\t" - "addl %5, %3 \n\t" - "movq (%1), %%mm0 \n\t" - "addl %4, %1 \n\t" - "movq (%1), %%mm1 \n\t" - "addl %4, %1 \n\t" - PAVGB" 16(%2), %%mm0 \n\t" - PAVGB" 24(%2), %%mm1 \n\t" - "movq %%mm0, (%3) \n\t" - "addl %5, %3 \n\t" - "movq %%mm1, (%3) \n\t" - "addl %5, %3 \n\t" - "addl $32, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - :"+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), %%eax \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" - "addl %%eax, %1 \n\t" - "addl %%eax, %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" - "addl %%eax, %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" - "addl %%eax, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels), "+D"(block) - :"r" (line_size) - :"%eax", "memory"); -} - -static void DEF(put_pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h) -{ - __asm __volatile( - "1: \n\t" - "movq (%1), %%mm0 \n\t" - "movq 8(%1), %%mm1 \n\t" - "addl %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" - "addl %5, %3 \n\t" - "movq (%1), %%mm0 \n\t" - "movq 8(%1), %%mm1 \n\t" - "addl %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" - "addl %5, %3 \n\t" - "addl $32, %2 \n\t" - "subl $2, %0 \n\t" - "jnz 1b \n\t" - :"+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), %%eax \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" - "addl %%eax, %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" - "addl %%eax, %2 \n\t" - "addl %%eax, %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" - "addl %%eax, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels), "+D"(block) - :"r" (line_size) - :"%eax", "memory"); -} - -static void DEF(put_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h) -{ - __asm __volatile( - "lea (%3, %3), %%eax \n\t" - "movq (%1), %%mm0 \n\t" - "subl %3, %2 \n\t" - "1: \n\t" - "movq (%1, %3), %%mm1 \n\t" - "movq (%1, %%eax), %%mm2 \n\t" - "addl %%eax, %1 \n\t" - PAVGB" %%mm1, %%mm0 \n\t" - PAVGB" %%mm2, %%mm1 \n\t" - "movq %%mm0, (%2, %3) \n\t" - "movq %%mm1, (%2, %%eax) \n\t" - "movq (%1, %3), %%mm1 \n\t" - "movq (%1, %%eax), %%mm0 \n\t" - "addl %%eax, %2 \n\t" - "addl %%eax, %1 \n\t" - PAVGB" %%mm1, %%mm2 \n\t" - PAVGB" %%mm0, %%mm1 \n\t" - "movq %%mm2, (%2, %3) \n\t" - "movq %%mm1, (%2, %%eax) \n\t" - "addl %%eax, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels), "+D" (block) - :"r" (line_size) - :"%eax", "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), %%eax \n\t" - "movq (%1), %%mm0 \n\t" - "subl %3, %2 \n\t" - "1: \n\t" - "movq (%1, %3), %%mm1 \n\t" - "movq (%1, %%eax), %%mm2 \n\t" - "addl %%eax, %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, %%eax) \n\t" - "movq (%1, %3), %%mm1 \n\t" - "movq (%1, %%eax), %%mm0 \n\t" - "addl %%eax, %2 \n\t" - "addl %%eax, %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, %%eax) \n\t" - "addl %%eax, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels), "+D" (block) - :"r" (line_size) - :"%eax", "memory"); -} - -static void DEF(avg_pixels8)(uint8_t *block, const uint8_t *pixels, int line_size, int h) -{ - __asm __volatile( - "lea (%3, %3), %%eax \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" - "addl %%eax, %1 \n\t" - "addl %%eax, %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" - "addl %%eax, %1 \n\t" - "movq %%mm0, (%2) \n\t" - "movq %%mm1, (%2, %3) \n\t" - "addl %%eax, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels), "+D"(block) - :"r" (line_size) - :"%eax", "memory"); -} - -static void DEF(avg_pixels8_x2)(uint8_t *block, const uint8_t *pixels, int line_size, int h) -{ - __asm __volatile( - "lea (%3, %3), %%eax \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" - "addl %%eax, %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" - "addl %%eax, %2 \n\t" - "addl %%eax, %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" - "addl %%eax, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels), "+D"(block) - :"r" (line_size) - :"%eax", "memory"); -} - -static void DEF(avg_pixels8_y2)(uint8_t *block, const uint8_t *pixels, int line_size, int h) -{ - __asm __volatile( - "lea (%3, %3), %%eax \n\t" - "movq (%1), %%mm0 \n\t" - "subl %3, %2 \n\t" - "1: \n\t" - "movq (%1, %3), %%mm1 \n\t" - "movq (%1, %%eax), %%mm2 \n\t" - "addl %%eax, %1 \n\t" - PAVGB" %%mm1, %%mm0 \n\t" - PAVGB" %%mm2, %%mm1 \n\t" - "movq (%2, %3), %%mm3 \n\t" - "movq (%2, %%eax), %%mm4 \n\t" - PAVGB" %%mm3, %%mm0 \n\t" - PAVGB" %%mm4, %%mm1 \n\t" - "movq %%mm0, (%2, %3) \n\t" - "movq %%mm1, (%2, %%eax) \n\t" - "movq (%1, %3), %%mm1 \n\t" - "movq (%1, %%eax), %%mm0 \n\t" - PAVGB" %%mm1, %%mm2 \n\t" - PAVGB" %%mm0, %%mm1 \n\t" - "addl %%eax, %2 \n\t" - "addl %%eax, %1 \n\t" - "movq (%2, %3), %%mm3 \n\t" - "movq (%2, %%eax), %%mm4 \n\t" - PAVGB" %%mm3, %%mm2 \n\t" - PAVGB" %%mm4, %%mm1 \n\t" - "movq %%mm2, (%2, %3) \n\t" - "movq %%mm1, (%2, %%eax) \n\t" - "addl %%eax, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels), "+D"(block) - :"r" (line_size) - :"%eax", "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), %%eax \n\t" - "movq (%1), %%mm0 \n\t" - PAVGB" 1(%1), %%mm0 \n\t" - ".balign 8 \n\t" - "1: \n\t" - "movq (%1, %%eax), %%mm2 \n\t" - "movq (%1, %3), %%mm1 \n\t" - "psubusb %%mm6, %%mm2 \n\t" - PAVGB" 1(%1, %3), %%mm1 \n\t" - PAVGB" 1(%1, %%eax), %%mm2 \n\t" - "addl %%eax, %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, %%eax), %%mm0 \n\t" - PAVGB" 1(%1, %3), %%mm1 \n\t" - PAVGB" 1(%1, %%eax), %%mm0 \n\t" - "addl %%eax, %2 \n\t" - "addl %%eax, %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" - "addl %%eax, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels), "+D"(block) - :"r" (line_size) - :"%eax", "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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/dsputil_mmx_rnd.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/dsputil_mmx_rnd.h deleted file mode 100644 index bbd5aec..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/dsputil_mmx_rnd.h +++ /dev/null @@ -1,570 +0,0 @@ -/* - * DSP utils mmx functions are compiled twice for rnd/no_rnd - * 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 - * - * MMX optimization by Nick Kurshev - * mostly rewritten by Michael Niedermayer - * and improved by Zdenek Kabelac - */ - -// 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), %%eax \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" - "addl %%eax, %1 \n\t" - "addl %%eax, %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" - "addl %%eax, %1 \n\t" - "addl %%eax, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels), "+D"(block) - :"r"(line_size) - :"eax", "memory"); -} - -static void 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" - "addl %4, %1 \n\t" - "addl $8, %2 \n\t" - PAVGB(%%mm0, %%mm1, %%mm4, %%mm6) - "movq %%mm4, (%3) \n\t" - "addl %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" - "addl %4, %1 \n\t" - "movq (%1), %%mm2 \n\t" - "movq 8(%2), %%mm3 \n\t" - "addl %4, %1 \n\t" - PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5) - "movq %%mm4, (%3) \n\t" - "addl %5, %3 \n\t" - "movq %%mm5, (%3) \n\t" - "addl %5, %3 \n\t" - "movq (%1), %%mm0 \n\t" - "movq 16(%2), %%mm1 \n\t" - "addl %4, %1 \n\t" - "movq (%1), %%mm2 \n\t" - "movq 24(%2), %%mm3 \n\t" - "addl %4, %1 \n\t" - "addl $32, %2 \n\t" - PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5) - "movq %%mm4, (%3) \n\t" - "addl %5, %3 \n\t" - "movq %%mm5, (%3) \n\t" - "addl %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"(src1Stride), "D"(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), %%eax \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" - "addl %%eax, %1 \n\t" - "addl %%eax, %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" - "addl %%eax, %1 \n\t" - "addl %%eax, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels), "+D"(block) - :"r"(line_size) - :"eax", "memory"); -} - -static void 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" - "addl %4, %1 \n\t" - "addl $16, %2 \n\t" - PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5) - "movq %%mm4, (%3) \n\t" - "movq %%mm5, 8(%3) \n\t" - "addl %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" - "addl %4, %1 \n\t" - PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5) - "movq %%mm4, (%3) \n\t" - "movq %%mm5, 8(%3) \n\t" - "addl %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" - "addl %4, %1 \n\t" - PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5) - "movq %%mm4, (%3) \n\t" - "movq %%mm5, 8(%3) \n\t" - "addl %5, %3 \n\t" - "addl $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"(src1Stride), "D"(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), %%eax \n\t" - "movq (%1), %%mm0 \n\t" - ".balign 8 \n\t" - "1: \n\t" - "movq (%1, %3), %%mm1 \n\t" - "movq (%1, %%eax),%%mm2 \n\t" - PAVGBP(%%mm1, %%mm0, %%mm4, %%mm2, %%mm1, %%mm5) - "movq %%mm4, (%2) \n\t" - "movq %%mm5, (%2, %3) \n\t" - "addl %%eax, %1 \n\t" - "addl %%eax, %2 \n\t" - "movq (%1, %3), %%mm1 \n\t" - "movq (%1, %%eax),%%mm0 \n\t" - PAVGBP(%%mm1, %%mm2, %%mm4, %%mm0, %%mm1, %%mm5) - "movq %%mm4, (%2) \n\t" - "movq %%mm5, (%2, %3) \n\t" - "addl %%eax, %1 \n\t" - "addl %%eax, %2 \n\t" - "subl $4, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels), "+D"(block) - :"r"(line_size) - :"eax", "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" - "xorl %%eax, %%eax \n\t" - "addl %3, %1 \n\t" - ".balign 8 \n\t" - "1: \n\t" - "movq (%1, %%eax), %%mm0 \n\t" - "movq 1(%1, %%eax), %%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, %%eax) \n\t" - "addl %3, %%eax \n\t" - - "movq (%1, %%eax), %%mm2 \n\t" // 0 <-> 2 1 <-> 3 - "movq 1(%1, %%eax), %%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, %%eax) \n\t" - "addl %3, %%eax \n\t" - - "subl $2, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels) - :"D"(block), "r"(line_size) - :"eax", "memory"); -} - -// avg_pixels -// 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 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 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), %%eax \n\t" - "movq (%1), %%mm0 \n\t" - ".balign 8 \n\t" - "1: \n\t" - "movq (%1, %3), %%mm1 \n\t" - "movq (%1, %%eax), %%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" - "addl %%eax, %1 \n\t" - "addl %%eax, %2 \n\t" - - "movq (%1, %3), %%mm1 \n\t" - "movq (%1, %%eax), %%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" - "addl %%eax, %1 \n\t" - "addl %%eax, %2 \n\t" - - "subl $4, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels), "+D"(block) - :"r"(line_size) - :"eax", "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" - "xorl %%eax, %%eax \n\t" - "addl %3, %1 \n\t" - ".balign 8 \n\t" - "1: \n\t" - "movq (%1, %%eax), %%mm0 \n\t" - "movq 1(%1, %%eax), %%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, %%eax), %%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, %%eax) \n\t" - "addl %3, %%eax \n\t" - - "movq (%1, %%eax), %%mm2 \n\t" // 0 <-> 2 1 <-> 3 - "movq 1(%1, %%eax), %%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, %%eax), %%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, %%eax) \n\t" - "addl %3, %%eax \n\t" - - "subl $2, %0 \n\t" - "jnz 1b \n\t" - :"+g"(h), "+S"(pixels) - :"D"(block), "r"(line_size) - :"eax", "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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/fdct_mmx.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/fdct_mmx.c deleted file mode 100644 index 8d3552d..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/fdct_mmx.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * MMX optimized forward DCT - * The gcc porting is Copyright (c) 2001 Fabrice Bellard. - * - * 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 - */ -#include "../common.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 (262144 * (BITS_FRW_ACC - 1)) //; 1 << (SHIFT_FRW_ROW-1) -#define RND_FRW_ROW (1 << (SHIFT_FRW_ROW-1)) -//#define RND_FRW_COL (2 * (BITS_FRW_ACC - 1)) //; 1 << (SHIFT_FRW_COL-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 cos_4_16[4] ATTR_ALIGN(8) = { - -19195, -19195, -19195, -19195, //cos * (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 long long fdct_one_corr ATTR_ALIGN(8) = 0x0001000100010001LL; -static const long fdct_r_row[2] ATTR_ALIGN(8) = {RND_FRW_ROW, RND_FRW_ROW }; - -static const int16_t tab_frw_01234567[] ATTR_ALIGN(8) = { // forward_dct coeff table - //row0 - 16384, 16384, 21407, -8867, // w09 w01 w08 w00 - 16384, 16384, 8867, -21407, // w13 w05 w12 w04 - 16384, -16384, 8867, 21407, // w11 w03 w10 w02 - -16384, 16384, -21407, -8867, // w15 w07 w14 w06 - 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 - - //row1 - 22725, 22725, 29692, -12299, // w09 w01 w08 w00 - 22725, 22725, 12299, -29692, // w13 w05 w12 w04 - 22725, -22725, 12299, 29692, // w11 w03 w10 w02 - -22725, 22725, -29692, -12299, // w15 w07 w14 w06 - 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 - - //row2 - 21407, 21407, 27969, -11585, // w09 w01 w08 w00 - 21407, 21407, 11585, -27969, // w13 w05 w12 w04 - 21407, -21407, 11585, 27969, // w11 w03 w10 w02 - -21407, 21407, -27969, -11585, // w15 w07 w14 w06 - 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 - - //row3 - 19266, 19266, 25172, -10426, // w09 w01 w08 w00 - 19266, 19266, 10426, -25172, // w13 w05 w12 w04 - 19266, -19266, 10426, 25172, // w11 w03 w10 w02 - -19266, 19266, -25172, -10426, // w15 w07 w14 w06, - 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, - - //row4 - 16384, 16384, 21407, -8867, // w09 w01 w08 w00 - 16384, 16384, 8867, -21407, // w13 w05 w12 w04 - 16384, -16384, 8867, 21407, // w11 w03 w10 w02 - -16384, 16384, -21407, -8867, // w15 w07 w14 w06 - 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 - - //row5 - 19266, 19266, 25172, -10426, // w09 w01 w08 w00 - 19266, 19266, 10426, -25172, // w13 w05 w12 w04 - 19266, -19266, 10426, 25172, // w11 w03 w10 w02 - -19266, 19266, -25172, -10426, // w15 w07 w14 w06 - 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 - - //row6 - 21407, 21407, 27969, -11585, // w09 w01 w08 w00 - 21407, 21407, 11585, -27969, // w13 w05 w12 w04 - 21407, -21407, 11585, 27969, // w11 w03 w10 w02 - -21407, 21407, -27969, -11585, // w15 w07 w14 w06, - 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, - - //row7 - 22725, 22725, 29692, -12299, // w09 w01 w08 w00 - 22725, 22725, 12299, -29692, // w13 w05 w12 w04 - 22725, -22725, 12299, 29692, // w11 w03 w10 w02 - -22725, 22725, -29692, -12299, // w15 w07 w14 w06, - 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 -}; - - -static 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 inline void fdct_row(const int16_t *in, int16_t *out, const int16_t *table) -{ - movd_m2r(*(in + 6), mm5); - punpcklwd_m2r(*(in + 4), mm5); - movq_r2r(mm5, mm2); - psrlq_i2r(0x20, mm5); - movq_m2r(*(in + 0), mm0); - punpcklwd_r2r(mm2, mm5); - movq_r2r(mm0, mm1); - paddsw_r2r(mm5, mm0); - psubsw_r2r(mm5, mm1); - movq_r2r(mm0, mm2); - punpcklwd_r2r(mm1, mm0); - punpckhwd_r2r(mm1, mm2); - movq_r2r(mm2, mm1); - movq_r2r(mm0, mm2); - movq_m2r(*(table + 0), mm3); - punpcklwd_r2r(mm1, mm0); - movq_r2r(mm0, mm5); - punpckldq_r2r(mm0, mm0); - movq_m2r(*(table + 4), mm4); - punpckhwd_r2r(mm1, mm2); - pmaddwd_r2r(mm0, mm3); - movq_r2r(mm2, mm6); - movq_m2r(*(table + 16), mm1); - punpckldq_r2r(mm2, mm2); - pmaddwd_r2r(mm2, mm4); - punpckhdq_r2r(mm5, mm5); - pmaddwd_m2r(*(table + 8), mm0); - punpckhdq_r2r(mm6, mm6); - movq_m2r(*(table + 20), mm7); - pmaddwd_r2r(mm5, mm1); - paddd_m2r(*fdct_r_row, mm3); - pmaddwd_r2r(mm6, mm7); - pmaddwd_m2r(*(table + 12), mm2); - paddd_r2r(mm4, mm3); - pmaddwd_m2r(*(table + 24), mm5); - pmaddwd_m2r(*(table + 28), mm6); - paddd_r2r(mm7, mm1); - paddd_m2r(*fdct_r_row, mm0); - psrad_i2r(SHIFT_FRW_ROW, mm3); - paddd_m2r(*fdct_r_row, mm1); - paddd_r2r(mm2, mm0); - paddd_m2r(*fdct_r_row, mm5); - psrad_i2r(SHIFT_FRW_ROW, mm1); - paddd_r2r(mm6, mm5); - psrad_i2r(SHIFT_FRW_ROW, mm0); - psrad_i2r(SHIFT_FRW_ROW, mm5); - packssdw_r2r(mm0, mm3); - packssdw_r2r(mm5, mm1); - movq_r2r(mm3, mm6); - punpcklwd_r2r(mm1, mm3); - punpckhwd_r2r(mm1, mm6); - movq_r2m(mm3, *(out + 0)); - movq_r2m(mm6, *(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(block1, out, table); - block1 += 8; - table += 32; - out += 8; - } -} diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/fft_sse.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/fft_sse.c deleted file mode 100644 index 175cea5..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/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 - -#ifdef HAVE_BUILTIN_VECTOR - -#include - -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 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/idct_mmx.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/idct_mmx.c deleted file mode 100644 index 298c8a8..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/idct_mmx.c +++ /dev/null @@ -1,596 +0,0 @@ -/* - * Note: For libavcodec, this code can also be used under the LGPL license - */ -/* - * idct_mmx.c - * Copyright (C) 1999-2001 Aaron Holtzman - * - * 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 "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; - 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, 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 (int16_t * table, 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, 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, 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 (int16_t * table, 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, 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 short _T1[] ATTR_ALIGN(8) = {T1,T1,T1,T1}; - static short _T2[] ATTR_ALIGN(8) = {T2,T2,T2,T2}; - static short _T3[] ATTR_ALIGN(8) = {T3,T3,T3,T3}; - static 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 int32_t rounder0[] ATTR_ALIGN(8) = - rounder ((1 << (COL_SHIFT - 1)) - 0.5); -static int32_t rounder4[] ATTR_ALIGN(8) = rounder (0); -static int32_t rounder1[] ATTR_ALIGN(8) = - rounder (1.25683487303); /* C1*(C1/C4+C1+C7)/2 */ -static int32_t rounder7[] ATTR_ALIGN(8) = - rounder (-0.25); /* C1*(C7/C4+C7-C1)/2 */ -static int32_t rounder2[] ATTR_ALIGN(8) = - rounder (0.60355339059); /* C2 * (C6+C2)/2 */ -static int32_t rounder6[] ATTR_ALIGN(8) = - rounder (-0.25); /* C2 * (C6-C2)/2 */ -static int32_t rounder3[] ATTR_ALIGN(8) = - rounder (0.087788325588); /* C3*(-C3/C4+C3+C5)/2 */ -static 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 int16_t table04[] ATTR_ALIGN(16) = \ - table (22725, 21407, 19266, 16384, 12873, 8867, 4520); \ - static int16_t table17[] ATTR_ALIGN(16) = \ - table (31521, 29692, 26722, 22725, 17855, 12299, 6270); \ - static int16_t table26[] ATTR_ALIGN(16) = \ - table (29692, 27969, 25172, 21407, 16819, 11585, 5906); \ - static 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); \ -} - - -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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/mmx.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/mmx.h deleted file mode 100644 index 7e94cfd..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/mmx.h +++ /dev/null @@ -1,243 +0,0 @@ -/* - * mmx.h - * Copyright (C) 1997-2001 H. Dietz and R. Fisher - */ -#ifndef AVCODEC_I386MMX_H -#define AVCODEC_I386MMX_H - -/* - * 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") - -#endif /* AVCODEC_I386MMX_H */ diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/motion_est_mmx.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/motion_est_mmx.c deleted file mode 100644 index 9e88ce2..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/motion_est_mmx.c +++ /dev/null @@ -1,420 +0,0 @@ -/* - * MMX optimized motion estimation - * 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 - * - * mostly by Michael Niedermayer - */ -#include "../dsputil.h" - -static const __attribute__ ((aligned(8))) uint64_t round_tab[3]={ -0x0000000000000000, -0x0001000100010001, -0x0002000200020002, -}; - -static __attribute__ ((aligned(8), unused)) uint64_t bone= 0x0101010101010101LL; - -static inline void sad8_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h) -{ - int len= -(stride<pix_abs16x16 = pix_abs16x16_mmx; - c->pix_abs16x16_x2 = pix_abs16x16_x2_mmx; - c->pix_abs16x16_y2 = pix_abs16x16_y2_mmx; - c->pix_abs16x16_xy2 = pix_abs16x16_xy2_mmx; - c->pix_abs8x8 = pix_abs8x8_mmx; - c->pix_abs8x8_x2 = pix_abs8x8_x2_mmx; - c->pix_abs8x8_y2 = pix_abs8x8_y2_mmx; - c->pix_abs8x8_xy2 = pix_abs8x8_xy2_mmx; - - c->sad[0]= sad16x16_mmx; - c->sad[1]= sad8x8_mmx; - } - if (mm_flags & MM_MMXEXT) { - c->pix_abs16x16 = pix_abs16x16_mmx2; - c->pix_abs8x8 = pix_abs8x8_mmx2; - - c->sad[0]= sad16x16_mmx2; - c->sad[1]= sad8x8_mmx2; - - if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ - c->pix_abs16x16_x2 = pix_abs16x16_x2_mmx2; - c->pix_abs16x16_y2 = pix_abs16x16_y2_mmx2; - c->pix_abs16x16_xy2 = pix_abs16x16_xy2_mmx2; - c->pix_abs8x8_x2 = pix_abs8x8_x2_mmx2; - c->pix_abs8x8_y2 = pix_abs8x8_y2_mmx2; - c->pix_abs8x8_xy2 = pix_abs8x8_xy2_mmx2; - } - } -} diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/mpegvideo_mmx.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/mpegvideo_mmx.c deleted file mode 100644 index d2f477b..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/mpegvideo_mmx.c +++ /dev/null @@ -1,519 +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 - * h263, mpeg1, mpeg2 dequantizer & draw_edges by Michael Niedermayer - */ - -#include "../dsputil.h" -#include "../mpegvideo.h" -#include "../avcodec.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_mmx(MpegEncContext *s, - DCTELEM *block, int n, int qscale) -{ - int level, qmul, qadd, nCoeffs; - - qmul = qscale << 1; - qadd = (qscale - 1) | 1; - - assert(s->block_last_index[n]>=0); - - 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; - } else { - nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ]; - level = 0;/* keep gcc quiet */ - } -//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" - - "addl $16, %3 \n\t" - "jng 1b \n\t" - ::"r" (block+nCoeffs), "g"(qmul), "g" (qadd), "r" (2*(-nCoeffs)) - : "memory" - ); - if(s->mb_intra) - block[0]= level; -} - - -/* - 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_mmx(MpegEncContext *s, - DCTELEM *block, int n, int qscale) -{ - int 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; - - if (s->mb_intra) { - int block0; - 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" - "movl %3, %%eax \n\t" - ".balign 16\n\t" - "1: \n\t" - "movq (%0, %%eax), %%mm0 \n\t" - "movq 8(%0, %%eax), %%mm1 \n\t" - "movq (%1, %%eax), %%mm4 \n\t" - "movq 8(%1, %%eax), %%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, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 - "pcmpeqw 8(%0, %%eax), %%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, %%eax) \n\t" - "movq %%mm5, 8(%0, %%eax) \n\t" - - "addl $16, %%eax \n\t" - "js 1b \n\t" - ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs) - : "%eax", "memory" - ); - block[0]= block0; - - } else { - 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" - "movl %3, %%eax \n\t" - ".balign 16\n\t" - "1: \n\t" - "movq (%0, %%eax), %%mm0 \n\t" - "movq 8(%0, %%eax), %%mm1 \n\t" - "movq (%1, %%eax), %%mm4 \n\t" - "movq 8(%1, %%eax), %%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, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 - "pcmpeqw 8(%0, %%eax), %%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, %%eax) \n\t" - "movq %%mm5, 8(%0, %%eax) \n\t" - - "addl $16, %%eax \n\t" - "js 1b \n\t" - ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs) - : "%eax", "memory" - ); - } - -} - -static void dct_unquantize_mpeg2_mmx(MpegEncContext *s, - DCTELEM *block, int n, int qscale) -{ - int 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] ]; - - if (s->mb_intra) { - int block0; - 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" - "movl %3, %%eax \n\t" - ".balign 16\n\t" - "1: \n\t" - "movq (%0, %%eax), %%mm0 \n\t" - "movq 8(%0, %%eax), %%mm1 \n\t" - "movq (%1, %%eax), %%mm4 \n\t" - "movq 8(%1, %%eax), %%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, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 - "pcmpeqw 8(%0, %%eax), %%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, %%eax) \n\t" - "movq %%mm5, 8(%0, %%eax) \n\t" - - "addl $16, %%eax \n\t" - "jng 1b \n\t" - ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs) - : "%eax", "memory" - ); - block[0]= block0; - //Note, we dont do mismatch control for intra as errors cannot accumulate - - } else { - 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" - "movl %3, %%eax \n\t" - ".balign 16\n\t" - "1: \n\t" - "movq (%0, %%eax), %%mm0 \n\t" - "movq 8(%0, %%eax), %%mm1 \n\t" - "movq (%1, %%eax), %%mm4 \n\t" - "movq 8(%1, %%eax), %%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, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 - "pcmpeqw 8(%0, %%eax), %%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, %%eax) \n\t" - "movq %%mm5, 8(%0, %%eax) \n\t" - - "addl $16, %%eax \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) - : "%eax", "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" - "addl %1, %0 \n\t" - "cmpl %3, %0 \n\t" - " jb 1b \n\t" - : "+r" (ptr) - : "r" (wrap), "r" (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" - "addl %1, %0 \n\t" - "cmpl %3, %0 \n\t" - " jb 1b \n\t" - : "+r" (ptr) - : "r" (wrap), "r" (width), "r" (ptr + wrap*height) - ); - } - - for(i=0;iavctx->dct_algo; - - s->dct_unquantize_h263 = dct_unquantize_h263_mmx; - s->dct_unquantize_mpeg1 = dct_unquantize_mpeg1_mmx; - s->dct_unquantize_mpeg2 = dct_unquantize_mpeg2_mmx; - - draw_edges = draw_edges_mmx; - - if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX){ - if(mm_flags & MM_MMXEXT){ - s->dct_quantize= dct_quantize_MMX2; - } else { - s->dct_quantize= dct_quantize_MMX; - } - } - } -} diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/mpegvideo_mmx_template.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/mpegvideo_mmx_template.c deleted file mode 100644 index 706211e..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/i386/mpegvideo_mmx_template.c +++ /dev/null @@ -1,339 +0,0 @@ -/* - * MPEG video MMX templates - * - * 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 - */ -#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) -{ - int level=0, last_non_zero_p1, 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); - ff_fdct_mmx (block); //cant be anything else ... - - 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 ( - "imul %%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_bias[qscale]; - qmat = s->q_intra_matrix16[qscale]; - } else { - last_non_zero_p1 = 0; - bias = s->q_inter_matrix16_bias[qscale]; - qmat = s->q_inter_matrix16[qscale]; - } - - if(s->out_format == FMT_H263 && s->mpeg_quant==0){ - - asm volatile( - "movd %%eax, %%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] - "movl $-128, %%eax \n\t" - ".balign 16 \n\t" - "1: \n\t" - "pxor %%mm1, %%mm1 \n\t" // 0 - "movq (%1, %%eax), %%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, %%eax) \n\t" - "pcmpeqw %%mm7, %%mm0 \n\t" // out==0 ? 0xFF : 0x00 - "movq (%4, %%eax), %%mm1 \n\t" - "movq %%mm7, (%1, %%eax) \n\t" // 0 - "pandn %%mm1, %%mm0 \n\t" - PMAXW(%%mm0, %%mm3) - "addl $8, %%eax \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, %%eax \n\t" - "movzbl %%al, %%eax \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 %%eax, %%mm3 \n\t" // last_non_zero_p1 - SPREADW(%%mm3) - "pxor %%mm7, %%mm7 \n\t" // 0 - "pxor %%mm4, %%mm4 \n\t" // 0 - "movl $-128, %%eax \n\t" - ".balign 16 \n\t" - "1: \n\t" - "pxor %%mm1, %%mm1 \n\t" // 0 - "movq (%1, %%eax), %%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, %%eax), %%mm6 \n\t" // bias[0] - "paddusw %%mm6, %%mm0 \n\t" // ABS(block[i]) + bias[0] - "movq (%2, %%eax), %%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, %%eax) \n\t" - "pcmpeqw %%mm7, %%mm0 \n\t" // out==0 ? 0xFF : 0x00 - "movq (%4, %%eax), %%mm1 \n\t" - "movq %%mm7, (%1, %%eax) \n\t" // 0 - "pandn %%mm1, %%mm0 \n\t" - PMAXW(%%mm0, %%mm3) - "addl $8, %%eax \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, %%eax \n\t" - "movzbl %%al, %%eax \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 - * - * 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" - -/* -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__((aligned(8))) wm1010= 0xFFFF0000FFFF0000ULL; -static const uint64_t __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)<> 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/imgconvert.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/imgconvert.c deleted file mode 100644 index 6324576..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/imgconvert.c +++ /dev/null @@ -1,2174 +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_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, - }, - [PIX_FMT_BGR24] = { - .name = "bgr24", - .nb_channels = 3, - .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, - .depth = 8, - }, - [PIX_FMT_RGBA32] = { - .name = "rgba32", - .nb_channels = 4, .is_alpha = 1, - .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, - .depth = 8, - }, - [PIX_FMT_RGB565] = { - .name = "rgb565", - .nb_channels = 3, - .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, - .depth = 5, - }, - [PIX_FMT_RGB555] = { - .name = "rgb555", - .nb_channels = 4, .is_alpha = 1, - .color_type = FF_COLOR_RGB, - .pixel_type = FF_PIXEL_PACKED, - .depth = 5, - }, - - /* 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, - }, -}; - -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; - - 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_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: - picture->data[0] = NULL; - picture->data[1] = NULL; - picture->data[2] = NULL; - picture->data[3] = NULL; - return -1; - } -} - -int avpicture_layout(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; - unsigned char* s; - int size = avpicture_get_size(pix_fmt, width, height); - - if (size > dest_size) - 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_RGB565 || - pix_fmt == PIX_FMT_RGB555) - w = 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; - h = height; - } - - for (i=0; i> pf->x_chroma_shift; - h = height >> pf->y_chroma_shift; - } - s = src->data[i]; - for(j=0; jlinesize[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_RGB565: - case PIX_FMT_RGB555: - bits = 16; - 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) -{ - for(;height > 0; height--) { - memcpy(dst, src, width); - dst += dst_wrap; - src += src_wrap; - } -} - -/** - * Copy image 'src' to 'dst'. - */ -void img_copy(AVPicture *dst, 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_RGB565: - case PIX_FMT_RGB555: - bits = 16; - 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, 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 yuv422_to_yuv422p(AVPicture *dst, 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, 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]; - } -} - -#define SCALEBITS 10 -#define ONE_HALF (1 << (SCALEBITS - 1)) -#define FIX(x) ((int) ((x) * (1<> 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, 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= 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, AVPicture *src, - int width, int height) -{ - mono_to_gray(dst, src, width, height, 0xff); -} - -static void monoblack_to_gray(AVPicture *dst, AVPicture *src, - int width, int height) -{ - mono_to_gray(dst, src, width, height, 0x00); -} - -static void gray_to_mono(AVPicture *dst, 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= 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, AVPicture *src, - int width, int height) -{ - gray_to_mono(dst, src, width, height, 0xff); -} - -static void gray_to_monoblack(AVPicture *dst, AVPicture *src, - int width, int height) -{ - gray_to_mono(dst, src, width, height, 0x00); -} - -typedef struct ConvertEntry { - void (*convert)(AVPicture *dst, 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_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_YUV422P] = { - [PIX_FMT_YUV422] = { - .convert = yuv422p_to_yuv422, - }, - }, - [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_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 - }, - }, -}; - -static 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); - 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; -} - -static 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, - 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 convertion 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->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(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> 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(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, 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; - 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, - uint8_t *src1, int src_wrap, - int width, int height) -{ - 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, 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(src->data[i], src->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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/imgconvert_template.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/imgconvert_template.h deleted file mode 100644 index 015b74f..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/imgconvert_template.h +++ /dev/null @@ -1,852 +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, AVPicture *src, - int width, int height) -{ - uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *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, AVPicture *src, - int width, int height) -{ - uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr, *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, 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, 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;ydata[0]; - src_wrap = src->linesize[0] - width; - - q = dst->data[0]; - dst_wrap = dst->linesize[0] - BPP * width; - - for(y=0;ydata[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> 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, 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> 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, 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;ydata[0]; - src_wrap = src->linesize[0] - width * 3; - - d = dst->data[0]; - dst_wrap = dst->linesize[0] - width * BPP; - - for(y=0;ydata[0]; - src_wrap = src->linesize[0] - width * BPP; - - d = dst->data[0]; - dst_wrap = dst->linesize[0] - width * 3; - - for(y=0;ydata[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, AVPicture *src, - int width, int height) -{ - uint8_t *y1_ptr, *cb_ptr, *cr_ptr, *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, 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;ylinesize[0] - width; - cb += dst->linesize[1] - width; - cr += dst->linesize[2] - width; - } -} - -static void rgb24_to_yuvj420p(AVPicture *dst, 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, 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;ylinesize[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, 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;ydata[1], has_alpha); -} - -#endif /* defined(FMT_RGB24) || defined(FMT_RGBA32) */ - -#ifdef RGBA_IN - -static int glue(get_alpha_info_, RGB_NAME)(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> (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, uint8_t *src, int src_width, - int src_start, int src_incr, int16_t *filters) -{ - int src_pos, phase, sum, i; - uint8_t *s; - int16_t *filter; - - src_pos = src_start; - for(i=0;i> 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> 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, uint8_t *src, int wrap, - int16_t *filter) -{ - int sum, i; - uint8_t *s; - - s = src; - for(i=0;i> 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, uint8_t *src, int src_width, - int src_start, int src_incr, int16_t *filters) -{ - int src_pos, phase; - 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, uint8_t *src, int wrap, - int16_t *filter) -{ - int sum, i, v; - 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, uint8_t *src, int wrap, - int16_t *filter) -{ - int sum, i; - 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, uint8_t *src, int src_width, - int src_start, int src_incr, int16_t *filters) -{ - int src_pos, phase, sum, j, v, i; - uint8_t *s, *src_end; - int16_t *filter; - - src_end = src + src_width; - src_pos = src_start; - for(i=0;i> POS_FRAC_BITS); - phase = get_phase(src_pos); - filter = filters + phase * NB_TAPS; - sum = 0; - for(j=0;j= 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, 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> 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; - } -} - -/* XXX: the following filter is quite naive, but it seems to suffice - for 4 taps */ -static void build_filter(int16_t *filter, float factor) -{ - int ph, i, v; - float x, y, tab[NB_TAPS], norm, mult; - - /* if upsampling, only need to interpolate, no filter */ - if (factor > 1.0) - factor = 1.0; - - for(ph=0;phline_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->h_incr = ((iwidth - leftBand - rightBand) * POS_FRAC) / owidth; - s->v_incr = ((iheight - topBand - bottomBand) * POS_FRAC) / oheight; - - build_filter(&s->h_filters[0][0], (float) owidth / (float) (iwidth - leftBand - rightBand)); - build_filter(&s->v_filters[0][0], (float) oheight / (float) (iheight - topBand - bottomBand)); - - return s; - fail: - av_free(s); - return NULL; -} - -void img_resample(ImgReSampleContext *s, - AVPicture *output, AVPicture *input) -{ - int i, shift; - - for(i=0;i<3;i++) { - shift = (i == 0) ? 0 : 1; - component_resample(s, output->data[i], output->linesize[i], - s->owidth >> shift, s->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 - -void *av_mallocz(int size) -{ - void *ptr; - ptr = malloc(size); - memset(ptr, 0, size); - return ptr; -} - -void av_free(void *ptr) -{ - /* XXX: this test should not be needed on most libcs */ - if (ptr) - free(ptr); -} - -/* 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) -{ - 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); -} - -static void dump_filter(int16_t *filter) -{ - int i, ph; - - for(ph=0;phh_filters[0][0]); - component_resample(s, img1, xsize, xsize, ysize, - img + 50 * XSIZE, XSIZE, XSIZE, YSIZE - 100); - img_resample_close(s); - - sprintf(buf, "/tmp/out%d.pgm", i); - save_pgm(buf, img1, xsize, ysize); - } - - /* mmx test */ -#ifdef HAVE_MMX - printf("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) { - fprintf(stderr, "mmx error\n"); - exit(1); - } - printf("MMX OK\n"); -#endif - return 0; -} - -#endif diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/indeo3.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/indeo3.c deleted file mode 100644 index d377eb9..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/indeo3.c +++ /dev/null @@ -1,1120 +0,0 @@ -/* - * Intel Indeo 3 (IV31, IV32, etc.) video decoder for ffmpeg - * written, produced, and directed by Alan Smithee - * - * 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 -#include -#include -#include - -#include "common.h" -#include "avcodec.h" -#include "dsputil.h" -#include "mpegvideo.h" - -#include "indeo3data.h" - -typedef struct -{ - unsigned char *Ybuf; - unsigned char *Ubuf; - unsigned char *Vbuf; - unsigned char *the_buf; - unsigned int the_buf_size; - unsigned short y_w, y_h; - unsigned short uv_w, uv_h; -} YUVBufs; - -typedef struct Indeo3DecodeContext { - AVCodecContext *avctx; - int width, height; - AVFrame frame; - - YUVBufs iv_frame[2]; - YUVBufs *cur_frame; - YUVBufs *ref_frame; - - unsigned char *ModPred; - unsigned short *corrector_type; -} Indeo3DecodeContext; - -static int corrector_type_0[24] = { - 195, 159, 133, 115, 101, 93, 87, 77, - 195, 159, 133, 115, 101, 93, 87, 77, - 128, 79, 79, 79, 79, 79, 79, 79 -}; - -static int corrector_type_2[8] = { 9, 7, 6, 8, 5, 4, 3, 2 }; - -static void build_modpred(Indeo3DecodeContext *s) -{ - int i, j; - - s->ModPred = (unsigned char *) av_malloc (8 * 128); - - for (i=0; i < 128; ++i) { - s->ModPred[i+0*128] = (i > 126) ? 254 : 2*((i + 1) - ((i + 1) % 2)); - s->ModPred[i+1*128] = (i == 7) ? 20 : ((i == 119 || i == 120) - ? 236 : 2*((i + 2) - ((i + 1) % 3))); - s->ModPred[i+2*128] = (i > 125) ? 248 : 2*((i + 2) - ((i + 2) % 4)); - s->ModPred[i+3*128] = 2*((i + 1) - ((i - 3) % 5)); - s->ModPred[i+4*128] = (i == 8) ? 20 : 2*((i + 1) - ((i - 3) % 6)); - s->ModPred[i+5*128] = 2*((i + 4) - ((i + 3) % 7)); - s->ModPred[i+6*128] = (i > 123) ? 240 : 2*((i + 4) - ((i + 4) % 8)); - s->ModPred[i+7*128] = 2*((i + 5) - ((i + 4) % 9)); - } - - s->corrector_type = (unsigned short *) av_malloc (24 * 256 * sizeof(unsigned short)); - - for (i=0; i < 24; ++i) { - for (j=0; j < 256; ++j) { - s->corrector_type[i*256+j] = (j < corrector_type_0[i]) - ? 1 : ((j < 248 || (i == 16 && j == 248)) - ? 0 : corrector_type_2[j - 248]); - } - } -} - -static void iv_Decode_Chunk(Indeo3DecodeContext *s, unsigned char *cur, - unsigned char *ref, int width, int height, unsigned char *buf1, - long fflags2, unsigned char *hdr, - unsigned char *buf2, int min_width_160); - -#define min(a,b) ((a) < (b) ? (a) : (b)) - -/* ---------------------------------------------------------------------- */ -static void iv_alloc_frames(Indeo3DecodeContext *s) -{ - int luma_width, luma_height, luma_pixels, chroma_width, chroma_height, - chroma_pixels, bufsize, i; - - luma_width = (s->width + 3) & (~3); - luma_height = (s->height + 3) & (~3); - - s->iv_frame[0].y_w = s->iv_frame[0].y_h = - s->iv_frame[0].the_buf_size = 0; - s->iv_frame[1].y_w = s->iv_frame[1].y_h = - s->iv_frame[1].the_buf_size = 0; - s->iv_frame[1].the_buf = NULL; - - chroma_width = ((luma_width >> 2) + 3) & (~3); - chroma_height = ((luma_height>> 2) + 3) & (~3); - luma_pixels = luma_width * luma_height; - chroma_pixels = chroma_width * chroma_height; - - bufsize = luma_pixels * 2 + luma_width * 3 + - (chroma_pixels + chroma_width) * 4; - - if((s->iv_frame[0].the_buf = - (s->iv_frame[0].the_buf_size == 0 ? av_malloc(bufsize) : - av_realloc(s->iv_frame[0].the_buf, bufsize))) == NULL) - return; - s->iv_frame[0].y_w = s->iv_frame[1].y_w = luma_width; - s->iv_frame[0].y_h = s->iv_frame[1].y_h = luma_height; - s->iv_frame[0].uv_w = s->iv_frame[1].uv_w = chroma_width; - s->iv_frame[0].uv_h = s->iv_frame[1].uv_h = chroma_height; - s->iv_frame[0].the_buf_size = bufsize; - - s->iv_frame[0].Ybuf = s->iv_frame[0].the_buf + luma_width; - i = luma_pixels + luma_width * 2; - s->iv_frame[1].Ybuf = s->iv_frame[0].the_buf + i; - i += (luma_pixels + luma_width); - s->iv_frame[0].Ubuf = s->iv_frame[0].the_buf + i; - i += (chroma_pixels + chroma_width); - s->iv_frame[1].Ubuf = s->iv_frame[0].the_buf + i; - i += (chroma_pixels + chroma_width); - s->iv_frame[0].Vbuf = s->iv_frame[0].the_buf + i; - i += (chroma_pixels + chroma_width); - s->iv_frame[1].Vbuf = s->iv_frame[0].the_buf + i; - - for(i = 1; i <= luma_width; i++) - s->iv_frame[0].Ybuf[-i] = s->iv_frame[1].Ybuf[-i] = - s->iv_frame[0].Ubuf[-i] = 0x80; - - for(i = 1; i <= chroma_width; i++) { - s->iv_frame[1].Ubuf[-i] = 0x80; - s->iv_frame[0].Vbuf[-i] = 0x80; - s->iv_frame[1].Vbuf[-i] = 0x80; - s->iv_frame[1].Vbuf[chroma_pixels+i-1] = 0x80; - } -} - -/* ---------------------------------------------------------------------- */ -static void iv_free_func(Indeo3DecodeContext *s) -{ - int i; - - for(i = 0 ; i < 2 ; i++) { - if(s->iv_frame[i].the_buf != NULL) - av_free(s->iv_frame[i].the_buf); - s->iv_frame[i].Ybuf = s->iv_frame[i].Ubuf = - s->iv_frame[i].Vbuf = NULL; - s->iv_frame[i].the_buf = NULL; - s->iv_frame[i].the_buf_size = 0; - s->iv_frame[i].y_w = s->iv_frame[i].y_h = 0; - s->iv_frame[i].uv_w = s->iv_frame[i].uv_h = 0; - } - - av_free(s->ModPred); - av_free(s->corrector_type); -} - -/* ---------------------------------------------------------------------- */ -static unsigned long iv_decode_frame(Indeo3DecodeContext *s, - unsigned char *buf, int buf_size) -{ - unsigned int hdr_width, hdr_height, - chroma_width, chroma_height; - unsigned long fflags1, fflags2, fflags3, offs1, offs2, offs3, offs; - unsigned char *hdr_pos, *buf_pos; - - buf_pos = buf; - buf_pos += 18; - - fflags1 = le2me_16(*(uint16_t *)buf_pos); - buf_pos += 2; - fflags3 = le2me_32(*(uint32_t *)buf_pos); - buf_pos += 4; - fflags2 = *buf_pos++; - buf_pos += 3; - hdr_height = le2me_16(*(uint16_t *)buf_pos); - buf_pos += 2; - hdr_width = le2me_16(*(uint16_t *)buf_pos); - buf_pos += 2; - chroma_height = ((hdr_height >> 2) + 3) & 0x7ffc; - chroma_width = ((hdr_width >> 2) + 3) & 0x7ffc; - offs1 = le2me_32(*(uint32_t *)buf_pos); - buf_pos += 4; - offs2 = le2me_32(*(uint32_t *)buf_pos); - buf_pos += 4; - offs3 = le2me_32(*(uint32_t *)buf_pos); - buf_pos += 8; - hdr_pos = buf_pos; - if(fflags3 == 0x80) return 4; - - if(fflags1 & 0x200) { - s->cur_frame = s->iv_frame + 1; - s->ref_frame = s->iv_frame; - } else { - s->cur_frame = s->iv_frame; - s->ref_frame = s->iv_frame + 1; - } - - buf_pos = buf + 16 + offs1; - offs = le2me_32(*(uint32_t *)buf_pos); - buf_pos += 4; - - iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, hdr_width, - hdr_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, - min(hdr_width, 160)); - - buf_pos = buf + 16 + offs2; - offs = le2me_32(*(uint32_t *)buf_pos); - buf_pos += 4; - - iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width, - chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, - min(chroma_width, 40)); - - buf_pos = buf + 16 + offs3; - offs = le2me_32(*(uint32_t *)buf_pos); - buf_pos += 4; - - iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width, - chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, - min(chroma_width, 40)); - - return 8; -} - -typedef struct { - long xpos; - long ypos; - long width; - long height; - long split_flag; - long split_direction; - long usl7; -} ustr_t; - -/* ---------------------------------------------------------------------- */ - -#define LV1_CHECK(buf1,rle_v3,lv1,lp2) \ - if((lv1 & 0x80) != 0) { \ - if(rle_v3 != 0) \ - rle_v3 = 0; \ - else { \ - rle_v3 = 1; \ - buf1 -= 2; \ - } \ - } \ - lp2 = 4; - - -#define RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) \ - if(rle_v3 == 0) { \ - rle_v2 = *buf1; \ - rle_v1 = 1; \ - if(rle_v2 > 32) { \ - rle_v2 -= 32; \ - rle_v1 = 0; \ - } \ - rle_v3 = 1; \ - } \ - buf1--; - - -#define LP2_CHECK(buf1,rle_v3,lp2) \ - if(lp2 == 0 && rle_v3 != 0) \ - rle_v3 = 0; \ - else { \ - buf1--; \ - rle_v3 = 1; \ - } - - -#define RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) \ - rle_v2--; \ - if(rle_v2 == 0) { \ - rle_v3 = 0; \ - buf1 += 2; \ - } \ - lp2 = 4; - -static void iv_Decode_Chunk(Indeo3DecodeContext *s, - unsigned char *cur, unsigned char *ref, int width, int height, - unsigned char *buf1, long fflags2, unsigned char *hdr, - unsigned char *buf2, int min_width_160) -{ - unsigned char bit_buf; - unsigned long bit_pos, lv, lv1, lv2; - long *width_tbl, width_tbl_arr[10]; - char *ref_vectors; - unsigned char *cur_frm_pos, *ref_frm_pos, *cp, *cp2; - uint32_t *cur_lp, *ref_lp; - const uint32_t *correction_lp[2], *correctionloworder_lp[2], *correctionhighorder_lp[2]; - unsigned short *correction_type_sp[2]; - ustr_t strip_tbl[20], *strip; - int i, j, k, lp1, lp2, flag1, cmd, blks_width, blks_height, region_160_width, - rle_v1, rle_v2, rle_v3; - - bit_buf = 0; - ref_vectors = NULL; - - width_tbl = width_tbl_arr + 1; - i = (width < 0 ? width + 3 : width)/4; - for(j = -1; j < 8; j++) - width_tbl[j] = i * j; - - strip = strip_tbl; - - for(region_160_width = 0; region_160_width < (width - min_width_160); region_160_width += min_width_160); - - strip->ypos = strip->xpos = 0; - for(strip->width = min_width_160; width > strip->width; strip->width *= 2); - strip->height = height; - strip->split_direction = 0; - strip->split_flag = 0; - strip->usl7 = 0; - - bit_pos = 0; - - rle_v1 = rle_v2 = rle_v3 = 0; - - while(strip >= strip_tbl) { - if(bit_pos <= 0) { - bit_pos = 8; - bit_buf = *buf1++; - } - - bit_pos -= 2; - cmd = (bit_buf >> bit_pos) & 0x03; - - if(cmd == 0) { - strip++; - memcpy(strip, strip-1, sizeof(ustr_t)); - strip->split_flag = 1; - strip->split_direction = 0; - strip->height = (strip->height > 8 ? ((strip->height+8)>>4)<<3 : 4); - continue; - } else if(cmd == 1) { - strip++; - memcpy(strip, strip-1, sizeof(ustr_t)); - strip->split_flag = 1; - strip->split_direction = 1; - strip->width = (strip->width > 8 ? ((strip->width+8)>>4)<<3 : 4); - continue; - } else if(cmd == 2) { - if(strip->usl7 == 0) { - strip->usl7 = 1; - ref_vectors = NULL; - continue; - } - } else if(cmd == 3) { - if(strip->usl7 == 0) { - strip->usl7 = 1; - ref_vectors = buf2 + (*buf1 * 2); - buf1++; - continue; - } - } - - cur_frm_pos = cur + width * strip->ypos + strip->xpos; - - if((blks_width = strip->width) < 0) - blks_width += 3; - blks_width >>= 2; - blks_height = strip->height; - - if(ref_vectors != NULL) { - ref_frm_pos = ref + (ref_vectors[0] + strip->ypos) * width + - ref_vectors[1] + strip->xpos; - } else - ref_frm_pos = cur_frm_pos - width_tbl[4]; - - if(cmd == 2) { - if(bit_pos <= 0) { - bit_pos = 8; - bit_buf = *buf1++; - } - - bit_pos -= 2; - cmd = (bit_buf >> bit_pos) & 0x03; - - if(cmd == 0 || ref_vectors != NULL) { - for(lp1 = 0; lp1 < blks_width; lp1++) { - for(i = 0, j = 0; i < blks_height; i++, j += width_tbl[1]) - ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j]; - cur_frm_pos += 4; - ref_frm_pos += 4; - } - } else if(cmd != 1) - return; - } else { - k = *buf1 >> 4; - j = *buf1 & 0x0f; - buf1++; - lv = j + fflags2; - - if((lv - 8) <= 7 && (k == 0 || k == 3 || k == 10)) { - cp2 = s->ModPred + ((lv - 8) << 7); - cp = ref_frm_pos; - for(i = 0; i < blks_width << 2; i++) { - int v = *cp >> 1; - *(cp++) = cp2[v]; - } - } - - if(k == 1 || k == 4) { - lv = (hdr[j] & 0xf) + fflags2; - correction_type_sp[0] = s->corrector_type + (lv << 8); - correction_lp[0] = correction + (lv << 8); - lv = (hdr[j] >> 4) + fflags2; - correction_lp[1] = correction + (lv << 8); - correction_type_sp[1] = s->corrector_type + (lv << 8); - } else { - correctionloworder_lp[0] = correctionloworder_lp[1] = correctionloworder + (lv << 8); - correctionhighorder_lp[0] = correctionhighorder_lp[1] = correctionhighorder + (lv << 8); - correction_type_sp[0] = correction_type_sp[1] = s->corrector_type + (lv << 8); - correction_lp[0] = correction_lp[1] = correction + (lv << 8); - } - - switch(k) { - case 1: - case 0: /********** CASE 0 **********/ - for( ; blks_height > 0; blks_height -= 4) { - for(lp1 = 0; lp1 < blks_width; lp1++) { - for(lp2 = 0; lp2 < 4; ) { - k = *buf1++; - cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2]; - ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2]; - - switch(correction_type_sp[0][k]) { - case 0: - *cur_lp = ((*ref_lp >> 1) + correction_lp[lp2 & 0x01][k]) << 1; - lp2++; - break; - case 1: - ((unsigned short *)cur_lp)[0] = ((((unsigned short *)(ref_lp))[0] >> 1) - + correction_lp[lp2 & 0x01][*buf1++]) << 1; - ((unsigned short *)cur_lp)[1] = ((((unsigned short *)(ref_lp))[1] >> 1) - + correction_lp[lp2 & 0x01][k]) << 1; - lp2++; - break; - case 2: - if(lp2 == 0) { - for(i = 0, j = 0; i < 2; i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - lp2 += 2; - } - break; - case 3: - if(lp2 < 2) { - for(i = 0, j = 0; i < (3 - lp2); i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - lp2 = 3; - } - break; - case 8: - if(lp2 == 0) { - RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) - - if(rle_v1 == 1 || ref_vectors != NULL) { - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - } - - RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) - break; - } else { - rle_v1 = 1; - rle_v2 = *buf1 - 1; - } - case 5: - LP2_CHECK(buf1,rle_v3,lp2) - case 4: - for(i = 0, j = 0; i < (4 - lp2); i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - lp2 = 4; - break; - - case 7: - if(rle_v3 != 0) - rle_v3 = 0; - else { - buf1--; - rle_v3 = 1; - } - case 6: - if(ref_vectors != NULL) { - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - } - lp2 = 4; - break; - - case 9: - lv1 = *buf1++; - lv = (lv1 & 0x7F) << 1; - lv += (lv << 8); - lv += (lv << 16); - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) - cur_lp[j] = lv; - - LV1_CHECK(buf1,rle_v3,lv1,lp2) - break; - default: - return; - } - } - - cur_frm_pos += 4; - ref_frm_pos += 4; - } - - cur_frm_pos += ((width - blks_width) * 4); - ref_frm_pos += ((width - blks_width) * 4); - } - break; - - case 4: - case 3: /********** CASE 3 **********/ - if(ref_vectors != NULL) - return; - flag1 = 1; - - for( ; blks_height > 0; blks_height -= 8) { - for(lp1 = 0; lp1 < blks_width; lp1++) { - for(lp2 = 0; lp2 < 4; ) { - k = *buf1++; - - cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; - ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1]; - - switch(correction_type_sp[lp2 & 0x01][k]) { - case 0: - cur_lp[width_tbl[1]] = ((*ref_lp >> 1) + correction_lp[lp2 & 0x01][k]) << 1; - if(lp2 > 0 || flag1 == 0 || strip->ypos != 0) - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - else - cur_lp[0] = ((*ref_lp >> 1) + correction_lp[lp2 & 0x01][k]) << 1; - lp2++; - break; - - case 1: - ((unsigned short *)cur_lp)[width_tbl[2]] = - ((((unsigned short *)ref_lp)[0] >> 1) + correction_lp[lp2 & 0x01][*buf1++]) << 1; - ((unsigned short *)cur_lp)[width_tbl[2]+1] = - ((((unsigned short *)ref_lp)[1] >> 1) + correction_lp[lp2 & 0x01][k]) << 1; - if(lp2 > 0 || flag1 == 0 || strip->ypos != 0) - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - else - cur_lp[0] = cur_lp[width_tbl[1]]; - lp2++; - break; - - case 2: - if(lp2 == 0) { - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) - cur_lp[j] = *ref_lp; - lp2 += 2; - } - break; - - case 3: - if(lp2 < 2) { - for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) - cur_lp[j] = *ref_lp; - lp2 = 3; - } - break; - - case 6: - lp2 = 4; - break; - - case 7: - if(rle_v3 != 0) - rle_v3 = 0; - else { - buf1--; - rle_v3 = 1; - } - lp2 = 4; - break; - - case 8: - if(lp2 == 0) { - RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) - - if(rle_v1 == 1) { - for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - } - - RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) - break; - } else { - rle_v2 = (*buf1) - 1; - rle_v1 = 1; - } - case 5: - LP2_CHECK(buf1,rle_v3,lp2) - case 4: - for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) - cur_lp[j] = *ref_lp; - lp2 = 4; - break; - - case 9: - fprintf(stderr, "UNTESTED.\n"); - lv1 = *buf1++; - lv = (lv1 & 0x7F) << 1; - lv += (lv << 8); - lv += (lv << 16); - - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) - cur_lp[j] = lv; - - LV1_CHECK(buf1,rle_v3,lv1,lp2) - break; - - default: - return; - } - } - - cur_frm_pos += 4; - } - - cur_frm_pos += (((width * 2) - blks_width) * 4); - flag1 = 0; - } - break; - - case 10: /********** CASE 10 **********/ - if(ref_vectors == NULL) { - flag1 = 1; - - for( ; blks_height > 0; blks_height -= 8) { - for(lp1 = 0; lp1 < blks_width; lp1 += 2) { - for(lp2 = 0; lp2 < 4; ) { - k = *buf1++; - cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; - ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1]; - lv1 = ref_lp[0]; - lv2 = ref_lp[1]; - if(lp2 == 0 && flag1 != 0) { - lv1 = lv1 & 0x00FF00FF; - lv1 = (lv1 << 8) | lv1; - lv2 = lv2 & 0x00FF00FF; - lv2 = (lv2 << 8) | lv2; - } - - switch(correction_type_sp[lp2 & 0x01][k]) { - case 0: - cur_lp[width_tbl[1]] = ((lv1 >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1; - cur_lp[width_tbl[1]+1] = ((lv2 >> 1) + correctionhighorder_lp[lp2 & 0x01][k]) << 1; - if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) { - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; - } else { - cur_lp[0] = cur_lp[width_tbl[1]]; - cur_lp[1] = cur_lp[width_tbl[1]+1]; - } - lp2++; - break; - - case 1: - cur_lp[width_tbl[1]] = ((lv1 >> 1) + correctionloworder_lp[lp2 & 0x01][*buf1++]) << 1; - cur_lp[width_tbl[1]+1] = ((lv2 >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1; - if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) { - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; - } else { - cur_lp[0] = cur_lp[width_tbl[1]]; - cur_lp[1] = cur_lp[width_tbl[1]+1]; - } - lp2++; - break; - - case 2: - if(lp2 == 0) { - if(flag1 != 0) { - for(i = 0, j = width_tbl[1]; i < 3; i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; - } else { - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - } - lp2 += 2; - } - break; - - case 3: - if(lp2 < 2) { - if(lp2 == 0 && flag1 != 0) { - for(i = 0, j = width_tbl[1]; i < 5; i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; - } else { - for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - } - lp2 = 3; - } - break; - - case 8: - if(lp2 == 0) { - RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) - if(rle_v1 == 1) { - if(flag1 != 0) { - for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; - } else { - for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - } - } - RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) - break; - } else { - rle_v1 = 1; - rle_v2 = (*buf1) - 1; - } - case 5: - LP2_CHECK(buf1,rle_v3,lp2) - case 4: - if(lp2 == 0 && flag1 != 0) { - for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; - } else { - for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - } - lp2 = 4; - break; - - case 6: - lp2 = 4; - break; - - case 7: - if(lp2 == 0) { - if(rle_v3 != 0) - rle_v3 = 0; - else { - buf1--; - rle_v3 = 1; - } - lp2 = 4; - } - break; - - case 9: - fprintf(stderr, "UNTESTED.\n"); - lv1 = *buf1; - lv = (lv1 & 0x7F) << 1; - lv += (lv << 8); - lv += (lv << 16); - for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) - cur_lp[j] = lv; - LV1_CHECK(buf1,rle_v3,lv1,lp2) - break; - - default: - return; - } - } - - cur_frm_pos += 8; - } - - cur_frm_pos += (((width * 2) - blks_width) * 4); - flag1 = 0; - } - } else { - for( ; blks_height > 0; blks_height -= 8) { - for(lp1 = 0; lp1 < blks_width; lp1 += 2) { - for(lp2 = 0; lp2 < 4; ) { - k = *buf1++; - cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; - ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2]; - - switch(correction_type_sp[lp2 & 0x01][k]) { - case 0: - lv1 = correctionloworder_lp[lp2 & 0x01][k]; - lv2 = correctionhighorder_lp[lp2 & 0x01][k]; - cur_lp[0] = ((ref_lp[0] >> 1) + lv1) << 1; - cur_lp[1] = ((ref_lp[1] >> 1) + lv2) << 1; - cur_lp[width_tbl[1]] = ((ref_lp[width_tbl[1]] >> 1) + lv1) << 1; - cur_lp[width_tbl[1]+1] = ((ref_lp[width_tbl[1]+1] >> 1) + lv2) << 1; - lp2++; - break; - - case 1: - lv1 = correctionloworder_lp[lp2 & 0x01][*buf1++]; - lv2 = correctionloworder_lp[lp2 & 0x01][k]; - cur_lp[0] = ((ref_lp[0] >> 1) + lv1) << 1; - cur_lp[1] = ((ref_lp[1] >> 1) + lv2) << 1; - cur_lp[width_tbl[1]] = ((ref_lp[width_tbl[1]] >> 1) + lv1) << 1; - cur_lp[width_tbl[1]+1] = ((ref_lp[width_tbl[1]+1] >> 1) + lv2) << 1; - lp2++; - break; - - case 2: - if(lp2 == 0) { - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) { - cur_lp[j] = ref_lp[j]; - cur_lp[j+1] = ref_lp[j+1]; - } - lp2 += 2; - } - break; - - case 3: - if(lp2 < 2) { - for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) { - cur_lp[j] = ref_lp[j]; - cur_lp[j+1] = ref_lp[j+1]; - } - lp2 = 3; - } - break; - - case 8: - if(lp2 == 0) { - RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) - for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) { - ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j]; - ((uint32_t *)cur_frm_pos)[j+1] = ((uint32_t *)ref_frm_pos)[j+1]; - } - RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) - break; - } else { - rle_v1 = 1; - rle_v2 = (*buf1) - 1; - } - case 5: - case 7: - LP2_CHECK(buf1,rle_v3,lp2) - case 6: - case 4: - for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) { - cur_lp[j] = ref_lp[j]; - cur_lp[j+1] = ref_lp[j+1]; - } - lp2 = 4; - break; - - case 9: - fprintf(stderr, "UNTESTED.\n"); - lv1 = *buf1; - lv = (lv1 & 0x7F) << 1; - lv += (lv << 8); - lv += (lv << 16); - for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) - ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)cur_frm_pos)[j+1] = lv; - LV1_CHECK(buf1,rle_v3,lv1,lp2) - break; - - default: - return; - } - } - - cur_frm_pos += 8; - ref_frm_pos += 8; - } - - cur_frm_pos += (((width * 2) - blks_width) * 4); - ref_frm_pos += (((width * 2) - blks_width) * 4); - } - } - break; - - case 11: /********** CASE 11 **********/ - if(ref_vectors == NULL) - return; - - for( ; blks_height > 0; blks_height -= 8) { - for(lp1 = 0; lp1 < blks_width; lp1++) { - for(lp2 = 0; lp2 < 4; ) { - k = *buf1++; - cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; - ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2]; - - switch(correction_type_sp[lp2 & 0x01][k]) { - case 0: - cur_lp[0] = ((*ref_lp >> 1) + correction_lp[lp2 & 0x01][k]) << 1; - cur_lp[width_tbl[1]] = ((ref_lp[width_tbl[1]] >> 1) + correction_lp[lp2 & 0x01][k]) << 1; - lp2++; - break; - - case 1: - lv1 = (unsigned short)(correction_lp[lp2 & 0x01][*buf1++]); - lv2 = (unsigned short)(correction_lp[lp2 & 0x01][k]); - ((unsigned short *)cur_lp)[0] = ((((unsigned short *)ref_lp)[0] >> 1) + lv1) << 1; - ((unsigned short *)cur_lp)[1] = ((((unsigned short *)ref_lp)[1] >> 1) + lv2) << 1; - ((unsigned short *)cur_lp)[width_tbl[2]] = ((((unsigned short *)ref_lp)[width_tbl[2]] >> 1) + lv1) << 1; - ((unsigned short *)cur_lp)[width_tbl[2]+1] = ((((unsigned short *)ref_lp)[width_tbl[2]+1] >> 1) + lv2) << 1; - lp2++; - break; - - case 2: - if(lp2 == 0) { - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - lp2 += 2; - } - break; - - case 3: - if(lp2 < 2) { - for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - lp2 = 3; - } - break; - - case 8: - if(lp2 == 0) { - RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) - - for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - - RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) - break; - } else { - rle_v1 = 1; - rle_v2 = (*buf1) - 1; - } - case 5: - case 7: - LP2_CHECK(buf1,rle_v3,lp2) - case 4: - case 6: - for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - lp2 = 4; - break; - - case 9: - fprintf(stderr, "UNTESTED.\n"); - lv1 = *buf1++; - lv = (lv1 & 0x7F) << 1; - lv += (lv << 8); - lv += (lv << 16); - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) - cur_lp[j] = lv; - LV1_CHECK(buf1,rle_v3,lv1,lp2) - break; - - default: - return; - } - } - - cur_frm_pos += 4; - ref_frm_pos += 4; - } - - cur_frm_pos += (((width * 2) - blks_width) * 4); - ref_frm_pos += (((width * 2) - blks_width) * 4); - } - break; - - default: - return; - } - } - - if(strip < strip_tbl) - return; - - for( ; strip >= strip_tbl; strip--) { - if(strip->split_flag != 0) { - strip->split_flag = 0; - strip->usl7 = (strip-1)->usl7; - - if(strip->split_direction) { - strip->xpos += strip->width; - strip->width = (strip-1)->width - strip->width; - if(region_160_width <= strip->xpos && width < strip->width + strip->xpos) - strip->width = width - strip->xpos; - } else { - strip->ypos += strip->height; - strip->height = (strip-1)->height - strip->height; - } - break; - } - } - } -} - -static int indeo3_decode_init(AVCodecContext *avctx) -{ - Indeo3DecodeContext *s = avctx->priv_data; - - s->avctx = avctx; - s->width = avctx->width; - s->height = avctx->height; - avctx->pix_fmt = PIX_FMT_YUV410P; - avctx->has_b_frames = 0; - - build_modpred(s); - iv_alloc_frames(s); - - return 0; -} - -static int indeo3_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - unsigned char *buf, int buf_size) -{ - Indeo3DecodeContext *s=avctx->priv_data; - unsigned char *src, *dest; - int y; - - iv_decode_frame(s, buf, buf_size); - - if(s->frame.data[0]) - avctx->release_buffer(avctx, &s->frame); - - s->frame.reference = 0; - if(avctx->get_buffer(avctx, &s->frame) < 0) { - fprintf(stderr, "get_buffer() failed\n"); - return -1; - } - - src = s->cur_frame->Ybuf; - dest = s->frame.data[0]; - for (y = 0; y < s->height; y++) { - memcpy(dest, src, s->cur_frame->y_w); - src += s->cur_frame->y_w; - dest += s->frame.linesize[0]; - } - - src = s->cur_frame->Ubuf; - dest = s->frame.data[1]; - for (y = 0; y < s->height / 4; y++) { - memcpy(dest, src, s->cur_frame->uv_w); - src += s->cur_frame->uv_w; - dest += s->frame.linesize[1]; - } - - src = s->cur_frame->Vbuf; - dest = s->frame.data[2]; - for (y = 0; y < s->height / 4; y++) { - memcpy(dest, src, s->cur_frame->uv_w); - src += s->cur_frame->uv_w; - dest += s->frame.linesize[2]; - } - - *data_size=sizeof(AVFrame); - *(AVFrame*)data= s->frame; - - return buf_size; -} - -static int indeo3_decode_end(AVCodecContext *avctx) -{ - Indeo3DecodeContext *s = avctx->priv_data; - - iv_free_func(s); - - return 0; -} - -AVCodec indeo3_decoder = { - "indeo3", - CODEC_TYPE_VIDEO, - CODEC_ID_INDEO3, - sizeof(Indeo3DecodeContext), - indeo3_decode_init, - NULL, - indeo3_decode_end, - indeo3_decode_frame, - 0, - NULL -}; diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/indeo3data.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/indeo3data.h deleted file mode 100644 index 4754926..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/indeo3data.h +++ /dev/null @@ -1,2315 +0,0 @@ - -static const uint32_t correction[] = { - 0x00000000, 0x00000202, 0xfffffdfe, 0x000002ff, 0xfffffd01, 0xffffff03, 0x000000fd, 0x00000404, - 0xfffffbfc, 0x00000501, 0xfffffaff, 0x00000105, 0xfffffefb, 0x000003fc, 0xfffffc04, 0x000005fe, - 0xfffffa02, 0xfffffe06, 0x000001fa, 0x00000904, 0xfffff6fc, 0x00000409, 0xfffffbf7, 0x00000909, - 0xfffff6f7, 0x00000a01, 0xfffff5ff, 0x0000010a, 0xfffffef6, 0x000007fb, 0xfffff805, 0xfffffb08, - 0x000004f8, 0x00000f09, 0xfffff0f7, 0x0000090f, 0xfffff6f1, 0x00000bfd, 0xfffff403, 0xfffffd0c, - 0x000002f4, 0x00001004, 0xffffeffc, 0x00000410, 0xfffffbf0, 0x00001010, 0xffffeff0, 0x00001200, - 0xffffee00, 0x00000012, 0xffffffee, 0x00000bf4, 0xfffff40c, 0x00000ff7, 0xfffff009, 0xfffff710, - 0x000008f0, 0x00001b0b, 0xffffe4f5, 0x00000b1b, 0xfffff4e5, 0x00001c13, 0xffffe3ed, 0x0000131c, - 0xffffece4, 0x000015fa, 0xffffea06, 0xfffffa16, 0x000005ea, 0x00001d04, 0xffffe2fc, 0x0000041d, - 0xfffffbe3, 0x00001e1e, 0xffffe1e2, 0x000020fe, 0xffffdf02, 0xfffffe21, 0x000001df, 0x000016ee, - 0xffffe912, 0xffffee17, 0x000011e9, 0x00001df1, 0xffffe20f, 0xfffff11e, 0x00000ee2, 0x00002e16, - 0xffffd1ea, 0x0000162e, 0xffffe9d2, 0x00002f0d, 0xffffd0f3, 0x00000d2f, 0xfffff2d1, 0x00003123, - 0xffffcedd, 0x00002331, 0xffffdccf, 0x000028f5, 0xffffd70b, 0xfffff529, 0x00000ad7, 0x00003304, - 0xffffccfc, 0x00000433, 0xfffffbcd, 0x00003636, 0xffffc9ca, 0x000021de, 0xffffde22, 0x000029e3, - 0xffffd61d, 0xffffe32a, 0x00001cd6, 0x00003bfa, 0xffffc406, 0xfffffa3c, 0x000005c4, 0x00004c1b, - 0xffffb3e5, 0x00001b4c, 0xffffe4b4, 0x00004d2b, 0xffffb2d5, 0x00002b4d, 0xffffd4b3, 0x000036e8, - 0xffffc918, 0xffffe837, 0x000017c9, 0x00004f0e, 0xffffb0f2, 0x00000e4f, 0xfffff1b1, 0x0000533f, - 0xffffacc1, 0x00003f53, 0xffffc0ad, 0x000049ec, 0xffffb614, 0xffffec4a, 0x000013b6, 0x00005802, - 0xffffa7fe, 0x00000258, 0xfffffda8, 0x00005d5d, 0xffffa2a3, 0x00003ccc, 0xffffc334, 0xffffcc3d, - 0x000033c3, 0x00007834, 0xffff87cc, 0x00003478, 0xffffcb88, 0x00004ad3, 0xffffb52d, 0xffffd34b, - 0x00002cb5, 0x00007d4b, 0xffff82b5, 0x00004b7d, 0xffffb483, 0x00007a21, 0xffff85df, 0x0000217a, - 0xffffde86, 0x000066f3, 0xffff990d, 0xfffff367, 0x00000c99, 0x00005fd8, 0xffffa028, 0xffffd860, - 0x000027a0, 0x00007ede, 0xffff8122, 0xffffde7f, 0x00002181, 0x000058a7, 0xffffa759, 0x000068b2, - 0xffff974e, 0xffffb269, 0x00004d97, 0x00000c0c, 0xfffff3f4, 0x00001717, 0xffffe8e9, 0x00002a2a, - 0xffffd5d6, 0x00004949, 0xffffb6b7, 0x00000000, 0x02020000, 0xfdfe0000, 0x02ff0000, 0xfd010000, - 0xff030000, 0x00fd0000, 0x00000202, 0x02020202, 0xfdfe0202, 0x02ff0202, 0xfd010202, 0xff030202, - 0x00fd0202, 0xfffffdfe, 0x0201fdfe, 0xfdfdfdfe, 0x02fefdfe, 0xfd00fdfe, 0xff02fdfe, 0x00fcfdfe, - 0x000002ff, 0x020202ff, 0xfdfe02ff, 0x02ff02ff, 0xfd0102ff, 0xff0302ff, 0x00fd02ff, 0xfffffd01, - 0x0201fd01, 0xfdfdfd01, 0x02fefd01, 0xfd00fd01, 0xff02fd01, 0x00fcfd01, 0xffffff03, 0x0201ff03, - 0xfdfdff03, 0x02feff03, 0xfd00ff03, 0xff02ff03, 0x00fcff03, 0x000000fd, 0x020200fd, 0xfdfe00fd, - 0x02ff00fd, 0xfd0100fd, 0xff0300fd, 0x00fd00fd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000303, 0xfffffcfd, 0x000003ff, 0xfffffc01, 0xffffff04, 0x000000fc, 0x00000707, - 0xfffff8f9, 0x00000802, 0xfffff7fe, 0x00000208, 0xfffffdf8, 0x000008fe, 0xfffff702, 0xfffffe09, - 0x000001f7, 0x000005fa, 0xfffffa06, 0x00000d06, 0xfffff2fa, 0x0000060d, 0xfffff9f3, 0x00000d0d, - 0xfffff2f3, 0x00000e01, 0xfffff1ff, 0x0000010e, 0xfffffef2, 0x00000bf8, 0xfffff408, 0xfffff80c, - 0x000007f4, 0x0000170e, 0xffffe8f2, 0x00000e17, 0xfffff1e9, 0x000011fb, 0xffffee05, 0xfffffb12, - 0x000004ee, 0x00001806, 0xffffe7fa, 0x00000618, 0xfffff9e8, 0x00001818, 0xffffe7e8, 0x00001aff, - 0xffffe501, 0xffffff1b, 0x000000e5, 0x000010ef, 0xffffef11, 0x000016f3, 0xffffe90d, 0xfffff317, - 0x00000ce9, 0x00002810, 0xffffd7f0, 0x00001028, 0xffffefd8, 0x0000291c, 0xffffd6e4, 0x00001c29, - 0xffffe3d7, 0x000020f7, 0xffffdf09, 0xfffff721, 0x000008df, 0x00002b06, 0xffffd4fa, 0x0000062b, - 0xfffff9d5, 0x00002e2e, 0xffffd1d2, 0x000031fc, 0xffffce04, 0xfffffc32, 0x000003ce, 0x000021e5, - 0xffffde1b, 0xffffe522, 0x00001ade, 0x00002cea, 0xffffd316, 0xffffea2d, 0x000015d3, 0x00004522, - 0xffffbade, 0x00002245, 0xffffddbb, 0x00004613, 0xffffb9ed, 0x00001346, 0xffffecba, 0x00004935, - 0xffffb6cb, 0x00003549, 0xffffcab7, 0x00003def, 0xffffc211, 0xffffef3e, 0x000010c2, 0x00004d05, - 0xffffb2fb, 0x0000054d, 0xfffffab3, 0x00005252, 0xffffadae, 0x000032cd, 0xffffcd33, 0x00003fd5, - 0xffffc02b, 0xffffd540, 0x00002ac0, 0x000059f6, 0xffffa60a, 0xfffff65a, 0x000009a6, 0x00007229, - 0xffff8dd7, 0x00002972, 0xffffd68e, 0x00007440, 0xffff8bc0, 0x00004074, 0xffffbf8c, 0x000051db, - 0xffffae25, 0xffffdb52, 0x000024ae, 0x00007716, 0xffff88ea, 0x00001677, 0xffffe989, 0x00007c5f, - 0xffff83a1, 0x00005f7c, 0xffffa084, 0x00006ee2, 0xffff911e, 0xffffe26f, 0x00001d91, 0x00005bb2, - 0xffffa44e, 0xffffb25c, 0x00004da4, 0x000070bc, 0xffff8f44, 0xffffbc71, 0x0000438f, 0x00001212, - 0xffffedee, 0x00002222, 0xffffddde, 0x00003f3f, 0xffffc0c1, 0x00006d6d, 0xffff9293, 0x00000000, - 0x03030000, 0xfcfd0000, 0x03ff0000, 0xfc010000, 0xff040000, 0x00fc0000, 0x07070000, 0xf8f90000, - 0x00000303, 0x03030303, 0xfcfd0303, 0x03ff0303, 0xfc010303, 0xff040303, 0x00fc0303, 0x07070303, - 0xf8f90303, 0xfffffcfd, 0x0302fcfd, 0xfcfcfcfd, 0x03fefcfd, 0xfc00fcfd, 0xff03fcfd, 0x00fbfcfd, - 0x0706fcfd, 0xf8f8fcfd, 0x000003ff, 0x030303ff, 0xfcfd03ff, 0x03ff03ff, 0xfc0103ff, 0xff0403ff, - 0x00fc03ff, 0x070703ff, 0xf8f903ff, 0xfffffc01, 0x0302fc01, 0xfcfcfc01, 0x03fefc01, 0xfc00fc01, - 0xff03fc01, 0x00fbfc01, 0x0706fc01, 0xf8f8fc01, 0xffffff04, 0x0302ff04, 0xfcfcff04, 0x03feff04, - 0xfc00ff04, 0xff03ff04, 0x00fbff04, 0x0706ff04, 0xf8f8ff04, 0x000000fc, 0x030300fc, 0xfcfd00fc, - 0x03ff00fc, 0xfc0100fc, 0xff0400fc, 0x00fc00fc, 0x070700fc, 0xf8f900fc, 0x00000707, 0x03030707, - 0xfcfd0707, 0x03ff0707, 0xfc010707, 0xff040707, 0x00fc0707, 0x07070707, 0xf8f90707, 0xfffff8f9, - 0x0302f8f9, 0xfcfcf8f9, 0x03fef8f9, 0xfc00f8f9, 0xff03f8f9, 0x00fbf8f9, 0x0706f8f9, 0xf8f8f8f9, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000404, 0xfffffbfc, 0x000004ff, 0xfffffb01, 0xffffff05, 0x000000fb, 0x00000a03, - 0xfffff5fd, 0x0000030a, 0xfffffcf6, 0x00000909, 0xfffff6f7, 0x000006f9, 0xfffff907, 0x00000bfd, - 0xfffff403, 0xfffffd0c, 0x000002f4, 0x00001108, 0xffffeef8, 0x00000811, 0xfffff7ef, 0x00001111, - 0xffffeeef, 0x00001301, 0xffffecff, 0x00000113, 0xfffffeed, 0x00000ff5, 0xfffff00b, 0xfffff510, - 0x00000af0, 0x000016fa, 0xffffe906, 0xfffffa17, 0x000005e9, 0x00001f12, 0xffffe0ee, 0x0000121f, - 0xffffede1, 0x00002008, 0xffffdff8, 0x00000820, 0xfffff7e0, 0x00002121, 0xffffdedf, 0x000023ff, - 0xffffdc01, 0xffffff24, 0x000000dc, 0x000016e9, 0xffffe917, 0x00001eef, 0xffffe111, 0xffffef1f, - 0x000010e1, 0x00003615, 0xffffc9eb, 0x00001536, 0xffffeaca, 0x00003725, 0xffffc8db, 0x00002537, - 0xffffdac9, 0x00002bf4, 0xffffd40c, 0xfffff42c, 0x00000bd4, 0x00003908, 0xffffc6f8, 0x00000839, - 0xfffff7c7, 0x00003d3d, 0xffffc2c3, 0x000041fb, 0xffffbe05, 0xfffffb42, 0x000004be, 0x00002cdc, - 0xffffd324, 0xffffdc2d, 0x000023d3, 0x00003be3, 0xffffc41d, 0xffffe33c, 0x00001cc4, 0x00005c2d, - 0xffffa3d3, 0x00002d5c, 0xffffd2a4, 0x00005d19, 0xffffa2e7, 0x0000195d, 0xffffe6a3, 0x00006147, - 0xffff9eb9, 0x00004761, 0xffffb89f, 0x000052ea, 0xffffad16, 0xffffea53, 0x000015ad, 0x00006607, - 0xffff99f9, 0x00000766, 0xfffff89a, 0x00006d6d, 0xffff9293, 0x000043bc, 0xffffbc44, 0x000054c7, - 0xffffab39, 0xffffc755, 0x000038ab, 0x000077f3, 0xffff880d, 0xfffff378, 0x00000c88, 0x00006dcf, - 0xffff9231, 0xffffcf6e, 0x00003092, 0x00007a98, 0xffff8568, 0xffff987b, 0x00006785, 0x00001818, - 0xffffe7e8, 0x00002e2e, 0xffffd1d2, 0x00005454, 0xffffabac, 0x00000000, 0x04040000, 0xfbfc0000, - 0x04ff0000, 0xfb010000, 0xff050000, 0x00fb0000, 0x0a030000, 0xf5fd0000, 0x030a0000, 0x00000404, - 0x04040404, 0xfbfc0404, 0x04ff0404, 0xfb010404, 0xff050404, 0x00fb0404, 0x0a030404, 0xf5fd0404, - 0x030a0404, 0xfffffbfc, 0x0403fbfc, 0xfbfbfbfc, 0x04fefbfc, 0xfb00fbfc, 0xff04fbfc, 0x00fafbfc, - 0x0a02fbfc, 0xf5fcfbfc, 0x0309fbfc, 0x000004ff, 0x040404ff, 0xfbfc04ff, 0x04ff04ff, 0xfb0104ff, - 0xff0504ff, 0x00fb04ff, 0x0a0304ff, 0xf5fd04ff, 0x030a04ff, 0xfffffb01, 0x0403fb01, 0xfbfbfb01, - 0x04fefb01, 0xfb00fb01, 0xff04fb01, 0x00fafb01, 0x0a02fb01, 0xf5fcfb01, 0x0309fb01, 0xffffff05, - 0x0403ff05, 0xfbfbff05, 0x04feff05, 0xfb00ff05, 0xff04ff05, 0x00faff05, 0x0a02ff05, 0xf5fcff05, - 0x0309ff05, 0x000000fb, 0x040400fb, 0xfbfc00fb, 0x04ff00fb, 0xfb0100fb, 0xff0500fb, 0x00fb00fb, - 0x0a0300fb, 0xf5fd00fb, 0x030a00fb, 0x00000a03, 0x04040a03, 0xfbfc0a03, 0x04ff0a03, 0xfb010a03, - 0xff050a03, 0x00fb0a03, 0x0a030a03, 0xf5fd0a03, 0x030a0a03, 0xfffff5fd, 0x0403f5fd, 0xfbfbf5fd, - 0x04fef5fd, 0xfb00f5fd, 0xff04f5fd, 0x00faf5fd, 0x0a02f5fd, 0xf5fcf5fd, 0x0309f5fd, 0x0000030a, - 0x0404030a, 0xfbfc030a, 0x04ff030a, 0xfb01030a, 0xff05030a, 0x00fb030a, 0x0a03030a, 0xf5fd030a, - 0x030a030a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000505, 0xfffffafb, 0x000006fe, 0xfffff902, 0xfffffe07, 0x000001f9, 0x00000b0b, - 0xfffff4f5, 0x00000d03, 0xfffff2fd, 0x0000030d, 0xfffffcf3, 0x000008f7, 0xfffff709, 0x00000efc, - 0xfffff104, 0xfffffc0f, 0x000003f1, 0x0000160b, 0xffffe9f5, 0x00000b16, 0xfffff4ea, 0x00001515, - 0xffffeaeb, 0x00001802, 0xffffe7fe, 0x00000218, 0xfffffde8, 0x000013f2, 0xffffec0e, 0xfffff214, - 0x00000dec, 0x00002617, 0xffffd9e9, 0x00001726, 0xffffe8da, 0x00001cf8, 0xffffe308, 0xfffff81d, - 0x000007e3, 0x0000270b, 0xffffd8f5, 0x00000b27, 0xfffff4d9, 0x00002929, 0xffffd6d7, 0x00002cff, - 0xffffd301, 0xffffff2d, 0x000000d3, 0x00001ce3, 0xffffe31d, 0x000026ea, 0xffffd916, 0xffffea27, - 0x000015d9, 0x0000431b, 0xffffbce5, 0x00001b43, 0xffffe4bd, 0x0000452f, 0xffffbad1, 0x00002f45, - 0xffffd0bb, 0x000037f1, 0xffffc80f, 0xfffff138, 0x00000ec8, 0x0000470b, 0xffffb8f5, 0x00000b47, - 0xfffff4b9, 0x00004c4c, 0xffffb3b4, 0x000052fa, 0xffffad06, 0xfffffa53, 0x000005ad, 0x000038d3, - 0xffffc72d, 0xffffd339, 0x00002cc7, 0x00004adc, 0xffffb524, 0xffffdc4b, 0x000023b5, 0x00007338, - 0xffff8cc8, 0x00003873, 0xffffc78d, 0x0000751f, 0xffff8ae1, 0x00001f75, 0xffffe08b, 0x00007a58, - 0xffff85a8, 0x0000587a, 0xffffa786, 0x000067e4, 0xffff981c, 0xffffe468, 0x00001b98, 0x000054ab, - 0xffffab55, 0x000069b8, 0xffff9648, 0xffffb86a, 0x00004796, 0x00001e1e, 0xffffe1e2, 0x00003a3a, - 0xffffc5c6, 0x00006969, 0xffff9697, 0x00000000, 0x05050000, 0xfafb0000, 0x06fe0000, 0xf9020000, - 0xfe070000, 0x01f90000, 0x0b0b0000, 0xf4f50000, 0x0d030000, 0xf2fd0000, 0x00000505, 0x05050505, - 0xfafb0505, 0x06fe0505, 0xf9020505, 0xfe070505, 0x01f90505, 0x0b0b0505, 0xf4f50505, 0x0d030505, - 0xf2fd0505, 0xfffffafb, 0x0504fafb, 0xfafafafb, 0x06fdfafb, 0xf901fafb, 0xfe06fafb, 0x01f8fafb, - 0x0b0afafb, 0xf4f4fafb, 0x0d02fafb, 0xf2fcfafb, 0x000006fe, 0x050506fe, 0xfafb06fe, 0x06fe06fe, - 0xf90206fe, 0xfe0706fe, 0x01f906fe, 0x0b0b06fe, 0xf4f506fe, 0x0d0306fe, 0xf2fd06fe, 0xfffff902, - 0x0504f902, 0xfafaf902, 0x06fdf902, 0xf901f902, 0xfe06f902, 0x01f8f902, 0x0b0af902, 0xf4f4f902, - 0x0d02f902, 0xf2fcf902, 0xfffffe07, 0x0504fe07, 0xfafafe07, 0x06fdfe07, 0xf901fe07, 0xfe06fe07, - 0x01f8fe07, 0x0b0afe07, 0xf4f4fe07, 0x0d02fe07, 0xf2fcfe07, 0x000001f9, 0x050501f9, 0xfafb01f9, - 0x06fe01f9, 0xf90201f9, 0xfe0701f9, 0x01f901f9, 0x0b0b01f9, 0xf4f501f9, 0x0d0301f9, 0xf2fd01f9, - 0x00000b0b, 0x05050b0b, 0xfafb0b0b, 0x06fe0b0b, 0xf9020b0b, 0xfe070b0b, 0x01f90b0b, 0x0b0b0b0b, - 0xf4f50b0b, 0x0d030b0b, 0xf2fd0b0b, 0xfffff4f5, 0x0504f4f5, 0xfafaf4f5, 0x06fdf4f5, 0xf901f4f5, - 0xfe06f4f5, 0x01f8f4f5, 0x0b0af4f5, 0xf4f4f4f5, 0x0d02f4f5, 0xf2fcf4f5, 0x00000d03, 0x05050d03, - 0xfafb0d03, 0x06fe0d03, 0xf9020d03, 0xfe070d03, 0x01f90d03, 0x0b0b0d03, 0xf4f50d03, 0x0d030d03, - 0xf2fd0d03, 0xfffff2fd, 0x0504f2fd, 0xfafaf2fd, 0x06fdf2fd, 0xf901f2fd, 0xfe06f2fd, 0x01f8f2fd, - 0x0b0af2fd, 0xf4f4f2fd, 0x0d02f2fd, 0xf2fcf2fd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000606, 0xfffff9fa, 0x000007fe, 0xfffff802, 0xfffffe08, 0x000001f8, 0x00000d0d, - 0xfffff2f3, 0x00000f04, 0xfffff0fc, 0x0000040f, 0xfffffbf1, 0x00000af5, 0xfffff50b, 0x000011fb, - 0xffffee05, 0xfffffb12, 0x000004ee, 0x00001a0d, 0xffffe5f3, 0x00000d1a, 0xfffff2e6, 0x00001a1a, - 0xffffe5e6, 0x00001d02, 0xffffe2fe, 0x0000021d, 0xfffffde3, 0x000017f0, 0xffffe810, 0xfffff018, - 0x00000fe8, 0x00002e1c, 0xffffd1e4, 0x00001c2e, 0xffffe3d2, 0x000022f7, 0xffffdd09, 0xfffff723, - 0x000008dd, 0x00002f0d, 0xffffd0f3, 0x00000d2f, 0xfffff2d1, 0x00003131, 0xffffcecf, 0x000035ff, - 0xffffca01, 0xffffff36, 0x000000ca, 0x000022dd, 0xffffdd23, 0x00002ee6, 0xffffd11a, 0xffffe62f, - 0x000019d1, 0x00005120, 0xffffaee0, 0x00002051, 0xffffdfaf, 0x00005338, 0xffffacc8, 0x00003853, - 0xffffc7ad, 0x000042ee, 0xffffbd12, 0xffffee43, 0x000011bd, 0x0000560d, 0xffffa9f3, 0x00000d56, - 0xfffff2aa, 0x00005b5b, 0xffffa4a5, 0x000062f9, 0xffff9d07, 0xfffff963, 0x0000069d, 0x000043ca, - 0xffffbc36, 0xffffca44, 0x000035bc, 0x000059d4, 0xffffa62c, 0xffffd45a, 0x00002ba6, 0x00007bdf, - 0xffff8421, 0xffffdf7c, 0x00002084, 0x00006699, 0xffff9967, 0x00007eaa, 0xffff8156, 0xffffaa7f, - 0x00005581, 0x00002525, 0xffffdadb, 0x00004545, 0xffffbabb, 0x00000000, 0x06060000, 0xf9fa0000, - 0x07fe0000, 0xf8020000, 0xfe080000, 0x01f80000, 0x0d0d0000, 0xf2f30000, 0x0f040000, 0xf0fc0000, - 0x040f0000, 0x00000606, 0x06060606, 0xf9fa0606, 0x07fe0606, 0xf8020606, 0xfe080606, 0x01f80606, - 0x0d0d0606, 0xf2f30606, 0x0f040606, 0xf0fc0606, 0x040f0606, 0xfffff9fa, 0x0605f9fa, 0xf9f9f9fa, - 0x07fdf9fa, 0xf801f9fa, 0xfe07f9fa, 0x01f7f9fa, 0x0d0cf9fa, 0xf2f2f9fa, 0x0f03f9fa, 0xf0fbf9fa, - 0x040ef9fa, 0x000007fe, 0x060607fe, 0xf9fa07fe, 0x07fe07fe, 0xf80207fe, 0xfe0807fe, 0x01f807fe, - 0x0d0d07fe, 0xf2f307fe, 0x0f0407fe, 0xf0fc07fe, 0x040f07fe, 0xfffff802, 0x0605f802, 0xf9f9f802, - 0x07fdf802, 0xf801f802, 0xfe07f802, 0x01f7f802, 0x0d0cf802, 0xf2f2f802, 0x0f03f802, 0xf0fbf802, - 0x040ef802, 0xfffffe08, 0x0605fe08, 0xf9f9fe08, 0x07fdfe08, 0xf801fe08, 0xfe07fe08, 0x01f7fe08, - 0x0d0cfe08, 0xf2f2fe08, 0x0f03fe08, 0xf0fbfe08, 0x040efe08, 0x000001f8, 0x060601f8, 0xf9fa01f8, - 0x07fe01f8, 0xf80201f8, 0xfe0801f8, 0x01f801f8, 0x0d0d01f8, 0xf2f301f8, 0x0f0401f8, 0xf0fc01f8, - 0x040f01f8, 0x00000d0d, 0x06060d0d, 0xf9fa0d0d, 0x07fe0d0d, 0xf8020d0d, 0xfe080d0d, 0x01f80d0d, - 0x0d0d0d0d, 0xf2f30d0d, 0x0f040d0d, 0xf0fc0d0d, 0x040f0d0d, 0xfffff2f3, 0x0605f2f3, 0xf9f9f2f3, - 0x07fdf2f3, 0xf801f2f3, 0xfe07f2f3, 0x01f7f2f3, 0x0d0cf2f3, 0xf2f2f2f3, 0x0f03f2f3, 0xf0fbf2f3, - 0x040ef2f3, 0x00000f04, 0x06060f04, 0xf9fa0f04, 0x07fe0f04, 0xf8020f04, 0xfe080f04, 0x01f80f04, - 0x0d0d0f04, 0xf2f30f04, 0x0f040f04, 0xf0fc0f04, 0x040f0f04, 0xfffff0fc, 0x0605f0fc, 0xf9f9f0fc, - 0x07fdf0fc, 0xf801f0fc, 0xfe07f0fc, 0x01f7f0fc, 0x0d0cf0fc, 0xf2f2f0fc, 0x0f03f0fc, 0xf0fbf0fc, - 0x040ef0fc, 0x0000040f, 0x0606040f, 0xf9fa040f, 0x07fe040f, 0xf802040f, 0xfe08040f, 0x01f8040f, - 0x0d0d040f, 0xf2f3040f, 0x0f04040f, 0xf0fc040f, 0x040f040f, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000707, 0xfffff8f9, 0x000009fd, 0xfffff603, 0xfffffd0a, 0x000002f6, 0x00001010, - 0xffffeff0, 0x00001205, 0xffffedfb, 0x00000512, 0xfffffaee, 0x00000cf3, 0xfffff30d, 0x000014fa, - 0xffffeb06, 0xfffffa15, 0x000005eb, 0x00001e0f, 0xffffe1f1, 0x00000f1e, 0xfffff0e2, 0x00001e1e, - 0xffffe1e2, 0x00002202, 0xffffddfe, 0x00000222, 0xfffffdde, 0x00001bed, 0xffffe413, 0xffffed1c, - 0x000012e4, 0x00003620, 0xffffc9e0, 0x00002036, 0xffffdfca, 0x000028f5, 0xffffd70b, 0xfffff529, - 0x00000ad7, 0x0000370f, 0xffffc8f1, 0x00000f37, 0xfffff0c9, 0x00003939, 0xffffc6c7, 0x00003eff, - 0xffffc101, 0xffffff3f, 0x000000c1, 0x000027d8, 0xffffd828, 0x000036e2, 0xffffc91e, 0xffffe237, - 0x00001dc9, 0x00005e25, 0xffffa1db, 0x0000255e, 0xffffdaa2, 0x00006041, 0xffff9fbf, 0x00004160, - 0xffffbea0, 0x00004deb, 0xffffb215, 0xffffeb4e, 0x000014b2, 0x0000640f, 0xffff9bf1, 0x00000f64, - 0xfffff09c, 0x00006a6a, 0xffff9596, 0x000073f8, 0xffff8c08, 0xfffff874, 0x0000078c, 0x00004ec1, - 0xffffb13f, 0xffffc14f, 0x00003eb1, 0x000068cd, 0xffff9733, 0xffffcd69, 0x00003297, 0x00007788, - 0xffff8878, 0x00002b2b, 0xffffd4d5, 0x00005050, 0xffffafb0, 0x00000000, 0x07070000, 0xf8f90000, - 0x09fd0000, 0xf6030000, 0xfd0a0000, 0x02f60000, 0x10100000, 0xeff00000, 0x12050000, 0xedfb0000, - 0x05120000, 0x00000707, 0x07070707, 0xf8f90707, 0x09fd0707, 0xf6030707, 0xfd0a0707, 0x02f60707, - 0x10100707, 0xeff00707, 0x12050707, 0xedfb0707, 0x05120707, 0xfffff8f9, 0x0706f8f9, 0xf8f8f8f9, - 0x09fcf8f9, 0xf602f8f9, 0xfd09f8f9, 0x02f5f8f9, 0x100ff8f9, 0xefeff8f9, 0x1204f8f9, 0xedfaf8f9, - 0x0511f8f9, 0x000009fd, 0x070709fd, 0xf8f909fd, 0x09fd09fd, 0xf60309fd, 0xfd0a09fd, 0x02f609fd, - 0x101009fd, 0xeff009fd, 0x120509fd, 0xedfb09fd, 0x051209fd, 0xfffff603, 0x0706f603, 0xf8f8f603, - 0x09fcf603, 0xf602f603, 0xfd09f603, 0x02f5f603, 0x100ff603, 0xefeff603, 0x1204f603, 0xedfaf603, - 0x0511f603, 0xfffffd0a, 0x0706fd0a, 0xf8f8fd0a, 0x09fcfd0a, 0xf602fd0a, 0xfd09fd0a, 0x02f5fd0a, - 0x100ffd0a, 0xefeffd0a, 0x1204fd0a, 0xedfafd0a, 0x0511fd0a, 0x000002f6, 0x070702f6, 0xf8f902f6, - 0x09fd02f6, 0xf60302f6, 0xfd0a02f6, 0x02f602f6, 0x101002f6, 0xeff002f6, 0x120502f6, 0xedfb02f6, - 0x051202f6, 0x00001010, 0x07071010, 0xf8f91010, 0x09fd1010, 0xf6031010, 0xfd0a1010, 0x02f61010, - 0x10101010, 0xeff01010, 0x12051010, 0xedfb1010, 0x05121010, 0xffffeff0, 0x0706eff0, 0xf8f8eff0, - 0x09fceff0, 0xf602eff0, 0xfd09eff0, 0x02f5eff0, 0x100feff0, 0xefefeff0, 0x1204eff0, 0xedfaeff0, - 0x0511eff0, 0x00001205, 0x07071205, 0xf8f91205, 0x09fd1205, 0xf6031205, 0xfd0a1205, 0x02f61205, - 0x10101205, 0xeff01205, 0x12051205, 0xedfb1205, 0x05121205, 0xffffedfb, 0x0706edfb, 0xf8f8edfb, - 0x09fcedfb, 0xf602edfb, 0xfd09edfb, 0x02f5edfb, 0x100fedfb, 0xefefedfb, 0x1204edfb, 0xedfaedfb, - 0x0511edfb, 0x00000512, 0x07070512, 0xf8f90512, 0x09fd0512, 0xf6030512, 0xfd0a0512, 0x02f60512, - 0x10100512, 0xeff00512, 0x12050512, 0xedfb0512, 0x05120512, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000808, 0xfffff7f8, 0x00000afd, 0xfffff503, 0xfffffd0b, 0x000002f5, 0x00001212, - 0xffffedee, 0x00001405, 0xffffebfb, 0x00000514, 0xfffffaec, 0x00000ef1, 0xfffff10f, 0x000017f9, - 0xffffe807, 0xfffff918, 0x000006e8, 0x00002311, 0xffffdcef, 0x00001123, 0xffffeedd, 0x00002222, - 0xffffddde, 0x00002603, 0xffffd9fd, 0x00000326, 0xfffffcda, 0x00001fea, 0xffffe016, 0xffffea20, - 0x000015e0, 0x00003d25, 0xffffc2db, 0x0000253d, 0xffffdac3, 0x00002ef3, 0xffffd10d, 0xfffff32f, - 0x00000cd1, 0x00003f11, 0xffffc0ef, 0x0000113f, 0xffffeec1, 0x00004141, 0xffffbebf, 0x000047ff, - 0xffffb801, 0xffffff48, 0x000000b8, 0x00002dd2, 0xffffd22e, 0x00003edd, 0xffffc123, 0xffffdd3f, - 0x000022c1, 0x00006b2b, 0xffff94d5, 0x00002b6b, 0xffffd495, 0x00006e4b, 0xffff91b5, 0x00004b6e, - 0xffffb492, 0x000058e8, 0xffffa718, 0xffffe859, 0x000017a7, 0x00007211, 0xffff8def, 0x00001172, - 0xffffee8e, 0x00007979, 0xffff8687, 0x00005ab8, 0xffffa548, 0xffffb85b, 0x000047a5, 0x000077c6, - 0xffff883a, 0xffffc678, 0x00003988, 0x00003131, 0xffffcecf, 0x00005c5c, 0xffffa3a4, 0x00000000, - 0x08080000, 0xf7f80000, 0x0afd0000, 0xf5030000, 0xfd0b0000, 0x02f50000, 0x12120000, 0xedee0000, - 0x14050000, 0xebfb0000, 0x05140000, 0x00000808, 0x08080808, 0xf7f80808, 0x0afd0808, 0xf5030808, - 0xfd0b0808, 0x02f50808, 0x12120808, 0xedee0808, 0x14050808, 0xebfb0808, 0x05140808, 0xfffff7f8, - 0x0807f7f8, 0xf7f7f7f8, 0x0afcf7f8, 0xf502f7f8, 0xfd0af7f8, 0x02f4f7f8, 0x1211f7f8, 0xededf7f8, - 0x1404f7f8, 0xebfaf7f8, 0x0513f7f8, 0x00000afd, 0x08080afd, 0xf7f80afd, 0x0afd0afd, 0xf5030afd, - 0xfd0b0afd, 0x02f50afd, 0x12120afd, 0xedee0afd, 0x14050afd, 0xebfb0afd, 0x05140afd, 0xfffff503, - 0x0807f503, 0xf7f7f503, 0x0afcf503, 0xf502f503, 0xfd0af503, 0x02f4f503, 0x1211f503, 0xededf503, - 0x1404f503, 0xebfaf503, 0x0513f503, 0xfffffd0b, 0x0807fd0b, 0xf7f7fd0b, 0x0afcfd0b, 0xf502fd0b, - 0xfd0afd0b, 0x02f4fd0b, 0x1211fd0b, 0xededfd0b, 0x1404fd0b, 0xebfafd0b, 0x0513fd0b, 0x000002f5, - 0x080802f5, 0xf7f802f5, 0x0afd02f5, 0xf50302f5, 0xfd0b02f5, 0x02f502f5, 0x121202f5, 0xedee02f5, - 0x140502f5, 0xebfb02f5, 0x051402f5, 0x00001212, 0x08081212, 0xf7f81212, 0x0afd1212, 0xf5031212, - 0xfd0b1212, 0x02f51212, 0x12121212, 0xedee1212, 0x14051212, 0xebfb1212, 0x05141212, 0xffffedee, - 0x0807edee, 0xf7f7edee, 0x0afcedee, 0xf502edee, 0xfd0aedee, 0x02f4edee, 0x1211edee, 0xedededee, - 0x1404edee, 0xebfaedee, 0x0513edee, 0x00001405, 0x08081405, 0xf7f81405, 0x0afd1405, 0xf5031405, - 0xfd0b1405, 0x02f51405, 0x12121405, 0xedee1405, 0x14051405, 0xebfb1405, 0x05141405, 0xffffebfb, - 0x0807ebfb, 0xf7f7ebfb, 0x0afcebfb, 0xf502ebfb, 0xfd0aebfb, 0x02f4ebfb, 0x1211ebfb, 0xededebfb, - 0x1404ebfb, 0xebfaebfb, 0x0513ebfb, 0x00000514, 0x08080514, 0xf7f80514, 0x0afd0514, 0xf5030514, - 0xfd0b0514, 0x02f50514, 0x12120514, 0xedee0514, 0x14050514, 0xebfb0514, 0x05140514, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000909, 0xfffff6f7, 0x00000bfd, 0xfffff403, 0xfffffd0c, 0x000002f4, 0x00001414, - 0xffffebec, 0x00001706, 0xffffe8fa, 0x00000617, 0xfffff9e9, 0x000010ef, 0xffffef11, 0x00001af9, - 0xffffe507, 0xfffff91b, 0x000006e5, 0x00002713, 0xffffd8ed, 0x00001327, 0xffffecd9, 0x00002727, - 0xffffd8d9, 0x00002b03, 0xffffd4fd, 0x0000032b, 0xfffffcd5, 0x000023e8, 0xffffdc18, 0xffffe824, - 0x000017dc, 0x0000452a, 0xffffbad6, 0x00002a45, 0xffffd5bb, 0x000034f2, 0xffffcb0e, 0xfffff235, - 0x00000dcb, 0x00004713, 0xffffb8ed, 0x00001347, 0xffffecb9, 0x00004949, 0xffffb6b7, 0x00004ffe, - 0xffffb002, 0xfffffe50, 0x000001b0, 0x000033cc, 0xffffcc34, 0x000045d9, 0xffffba27, 0xffffd946, - 0x000026ba, 0x00007930, 0xffff86d0, 0x00003079, 0xffffcf87, 0x00007c54, 0xffff83ac, 0x0000547c, - 0xffffab84, 0x000063e5, 0xffff9c1b, 0xffffe564, 0x00001a9c, 0x000065af, 0xffff9a51, 0xffffaf66, - 0x0000509a, 0x00003737, 0xffffc8c9, 0x00006868, 0xffff9798, 0x00000000, 0x09090000, 0xf6f70000, - 0x0bfd0000, 0xf4030000, 0xfd0c0000, 0x02f40000, 0x14140000, 0xebec0000, 0x17060000, 0xe8fa0000, - 0x06170000, 0xf9e90000, 0x00000909, 0x09090909, 0xf6f70909, 0x0bfd0909, 0xf4030909, 0xfd0c0909, - 0x02f40909, 0x14140909, 0xebec0909, 0x17060909, 0xe8fa0909, 0x06170909, 0xf9e90909, 0xfffff6f7, - 0x0908f6f7, 0xf6f6f6f7, 0x0bfcf6f7, 0xf402f6f7, 0xfd0bf6f7, 0x02f3f6f7, 0x1413f6f7, 0xebebf6f7, - 0x1705f6f7, 0xe8f9f6f7, 0x0616f6f7, 0xf9e8f6f7, 0x00000bfd, 0x09090bfd, 0xf6f70bfd, 0x0bfd0bfd, - 0xf4030bfd, 0xfd0c0bfd, 0x02f40bfd, 0x14140bfd, 0xebec0bfd, 0x17060bfd, 0xe8fa0bfd, 0x06170bfd, - 0xf9e90bfd, 0xfffff403, 0x0908f403, 0xf6f6f403, 0x0bfcf403, 0xf402f403, 0xfd0bf403, 0x02f3f403, - 0x1413f403, 0xebebf403, 0x1705f403, 0xe8f9f403, 0x0616f403, 0xf9e8f403, 0xfffffd0c, 0x0908fd0c, - 0xf6f6fd0c, 0x0bfcfd0c, 0xf402fd0c, 0xfd0bfd0c, 0x02f3fd0c, 0x1413fd0c, 0xebebfd0c, 0x1705fd0c, - 0xe8f9fd0c, 0x0616fd0c, 0xf9e8fd0c, 0x000002f4, 0x090902f4, 0xf6f702f4, 0x0bfd02f4, 0xf40302f4, - 0xfd0c02f4, 0x02f402f4, 0x141402f4, 0xebec02f4, 0x170602f4, 0xe8fa02f4, 0x061702f4, 0xf9e902f4, - 0x00001414, 0x09091414, 0xf6f71414, 0x0bfd1414, 0xf4031414, 0xfd0c1414, 0x02f41414, 0x14141414, - 0xebec1414, 0x17061414, 0xe8fa1414, 0x06171414, 0xf9e91414, 0xffffebec, 0x0908ebec, 0xf6f6ebec, - 0x0bfcebec, 0xf402ebec, 0xfd0bebec, 0x02f3ebec, 0x1413ebec, 0xebebebec, 0x1705ebec, 0xe8f9ebec, - 0x0616ebec, 0xf9e8ebec, 0x00001706, 0x09091706, 0xf6f71706, 0x0bfd1706, 0xf4031706, 0xfd0c1706, - 0x02f41706, 0x14141706, 0xebec1706, 0x17061706, 0xe8fa1706, 0x06171706, 0xf9e91706, 0xffffe8fa, - 0x0908e8fa, 0xf6f6e8fa, 0x0bfce8fa, 0xf402e8fa, 0xfd0be8fa, 0x02f3e8fa, 0x1413e8fa, 0xebebe8fa, - 0x1705e8fa, 0xe8f9e8fa, 0x0616e8fa, 0xf9e8e8fa, 0x00000617, 0x09090617, 0xf6f70617, 0x0bfd0617, - 0xf4030617, 0xfd0c0617, 0x02f40617, 0x14140617, 0xebec0617, 0x17060617, 0xe8fa0617, 0x06170617, - 0xf9e90617, 0xfffff9e9, 0x0908f9e9, 0xf6f6f9e9, 0x0bfcf9e9, 0xf402f9e9, 0xfd0bf9e9, 0x02f3f9e9, - 0x1413f9e9, 0xebebf9e9, 0x1705f9e9, 0xe8f9f9e9, 0x0616f9e9, 0xf9e8f9e9, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000202, 0xfffffdfe, 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000404, - 0xfffffbfc, 0x00000400, 0xfffffc00, 0x00000004, 0xfffffffc, 0x000003fc, 0xfffffc04, 0x000005fe, - 0xfffffa02, 0xfffffe06, 0x000001fa, 0x00000804, 0xfffff7fc, 0x00000408, 0xfffffbf8, 0x00000808, - 0xfffff7f8, 0x00000a00, 0xfffff600, 0x0000000a, 0xfffffff6, 0x000007fc, 0xfffff804, 0xfffffc08, - 0x000003f8, 0x00000e08, 0xfffff1f8, 0x0000080e, 0xfffff7f2, 0x00000bfe, 0xfffff402, 0xfffffe0c, - 0x000001f4, 0x00001004, 0xffffeffc, 0x00000410, 0xfffffbf0, 0x00001010, 0xffffeff0, 0x00001200, - 0xffffee00, 0x00000012, 0xffffffee, 0x00000bf4, 0xfffff40c, 0x00000ff8, 0xfffff008, 0xfffff810, - 0x000007f0, 0x00001a0a, 0xffffe5f6, 0x00000a1a, 0xfffff5e6, 0x00001c12, 0xffffe3ee, 0x0000121c, - 0xffffede4, 0x000015fa, 0xffffea06, 0xfffffa16, 0x000005ea, 0x00001c04, 0xffffe3fc, 0x0000041c, - 0xfffffbe4, 0x00001e1e, 0xffffe1e2, 0x00001ffe, 0xffffe002, 0xfffffe20, 0x000001e0, 0x000015ee, - 0xffffea12, 0xffffee16, 0x000011ea, 0x00001df2, 0xffffe20e, 0xfffff21e, 0x00000de2, 0x00002e16, - 0xffffd1ea, 0x0000162e, 0xffffe9d2, 0x00002e0c, 0xffffd1f4, 0x00000c2e, 0xfffff3d2, 0x00003022, - 0xffffcfde, 0x00002230, 0xffffddd0, 0x000027f6, 0xffffd80a, 0xfffff628, 0x000009d8, 0x00003204, - 0xffffcdfc, 0x00000432, 0xfffffbce, 0x00003636, 0xffffc9ca, 0x000021de, 0xffffde22, 0x000029e4, - 0xffffd61c, 0xffffe42a, 0x00001bd6, 0x00003bfa, 0xffffc406, 0xfffffa3c, 0x000005c4, 0x00004c1a, - 0xffffb3e6, 0x00001a4c, 0xffffe5b4, 0x00004c2a, 0xffffb3d6, 0x00002a4c, 0xffffd5b4, 0x000035e8, - 0xffffca18, 0xffffe836, 0x000017ca, 0x00004e0e, 0xffffb1f2, 0x00000e4e, 0xfffff1b2, 0x0000523e, - 0xffffadc2, 0x00003e52, 0xffffc1ae, 0x000049ec, 0xffffb614, 0xffffec4a, 0x000013b6, 0x00005802, - 0xffffa7fe, 0x00000258, 0xfffffda8, 0x00005c5c, 0xffffa3a4, 0x00003bcc, 0xffffc434, 0xffffcc3c, - 0x000033c4, 0x00007634, 0xffff89cc, 0x00003476, 0xffffcb8a, 0x000049d4, 0xffffb62c, 0xffffd44a, - 0x00002bb6, 0x0000764a, 0xffff89b6, 0x00004a76, 0xffffb58a, 0x00007620, 0xffff89e0, 0x00002076, - 0xffffdf8a, 0x000065f4, 0xffff9a0c, 0xfffff466, 0x00000b9a, 0x00005fd8, 0xffffa028, 0xffffd860, - 0x000027a0, 0x000075de, 0xffff8a22, 0xffffde76, 0x0000218a, 0x000057a8, 0xffffa858, 0x000067b2, - 0xffff984e, 0xffffb268, 0x00004d98, 0x00000c0c, 0xfffff3f4, 0x00001616, 0xffffe9ea, 0x00002a2a, - 0xffffd5d6, 0x00004848, 0xffffb7b8, 0x00000000, 0x02020000, 0xfdfe0000, 0x02000000, 0xfe000000, - 0x00020000, 0xfffe0000, 0x00000202, 0x02020202, 0xfdfe0202, 0x02000202, 0xfe000202, 0x00020202, - 0xfffe0202, 0xfffffdfe, 0x0201fdfe, 0xfdfdfdfe, 0x01fffdfe, 0xfdfffdfe, 0x0001fdfe, 0xfffdfdfe, - 0x00000200, 0x02020200, 0xfdfe0200, 0x02000200, 0xfe000200, 0x00020200, 0xfffe0200, 0xfffffe00, - 0x0201fe00, 0xfdfdfe00, 0x01fffe00, 0xfdfffe00, 0x0001fe00, 0xfffdfe00, 0x00000002, 0x02020002, - 0xfdfe0002, 0x02000002, 0xfe000002, 0x00020002, 0xfffe0002, 0xfffffffe, 0x0201fffe, 0xfdfdfffe, - 0x01fffffe, 0xfdfffffe, 0x0001fffe, 0xfffdfffe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000303, 0xfffffcfd, 0x00000300, 0xfffffd00, 0x00000003, 0xfffffffd, 0x00000606, - 0xfffff9fa, 0x00000903, 0xfffff6fd, 0x00000309, 0xfffffcf7, 0x000008fd, 0xfffff703, 0xfffffd09, - 0x000002f7, 0x000005fa, 0xfffffa06, 0x00000c06, 0xfffff3fa, 0x0000060c, 0xfffff9f4, 0x00000c0c, - 0xfffff3f4, 0x00000f00, 0xfffff100, 0x0000000f, 0xfffffff1, 0x00000bf7, 0xfffff409, 0xfffff70c, - 0x000008f4, 0x0000180f, 0xffffe7f1, 0x00000f18, 0xfffff0e8, 0x000011fa, 0xffffee06, 0xfffffa12, - 0x000005ee, 0x00001806, 0xffffe7fa, 0x00000618, 0xfffff9e8, 0x00001818, 0xffffe7e8, 0x00001b00, - 0xffffe500, 0x0000001b, 0xffffffe5, 0x000011ee, 0xffffee12, 0x000017f4, 0xffffe80c, 0xfffff418, - 0x00000be8, 0x0000270f, 0xffffd8f1, 0x00000f27, 0xfffff0d9, 0x00002a1b, 0xffffd5e5, 0x00001b2a, - 0xffffe4d6, 0x000020f7, 0xffffdf09, 0xfffff721, 0x000008df, 0x00002a06, 0xffffd5fa, 0x0000062a, - 0xfffff9d6, 0x00002d2d, 0xffffd2d3, 0x000032fd, 0xffffcd03, 0xfffffd33, 0x000002cd, 0x000020e5, - 0xffffdf1b, 0xffffe521, 0x00001adf, 0x00002ceb, 0xffffd315, 0xffffeb2d, 0x000014d3, 0x00004521, - 0xffffbadf, 0x00002145, 0xffffdebb, 0x00004512, 0xffffbaee, 0x00001245, 0xffffedbb, 0x00004836, - 0xffffb7ca, 0x00003648, 0xffffc9b8, 0x00003eee, 0xffffc112, 0xffffee3f, 0x000011c1, 0x00004e06, - 0xffffb1fa, 0x0000064e, 0xfffff9b2, 0x00005151, 0xffffaeaf, 0x000032cd, 0xffffcd33, 0x00003ed6, - 0xffffc12a, 0xffffd63f, 0x000029c1, 0x000059f7, 0xffffa609, 0xfffff75a, 0x000008a6, 0x0000722a, - 0xffff8dd6, 0x00002a72, 0xffffd58e, 0x0000753f, 0xffff8ac1, 0x00003f75, 0xffffc08b, 0x000050dc, - 0xffffaf24, 0xffffdc51, 0x000023af, 0x00007815, 0xffff87eb, 0x00001578, 0xffffea88, 0x00007b60, - 0xffff84a0, 0x0000607b, 0xffff9f85, 0x00006ee2, 0xffff911e, 0xffffe26f, 0x00001d91, 0x00005cb2, - 0xffffa34e, 0xffffb25d, 0x00004da3, 0x000071bb, 0xffff8e45, 0xffffbb72, 0x0000448e, 0x00001212, - 0xffffedee, 0x00002121, 0xffffdedf, 0x00003f3f, 0xffffc0c1, 0x00006c6c, 0xffff9394, 0x00000000, - 0x03030000, 0xfcfd0000, 0x03000000, 0xfd000000, 0x00030000, 0xfffd0000, 0x06060000, 0xf9fa0000, - 0x00000303, 0x03030303, 0xfcfd0303, 0x03000303, 0xfd000303, 0x00030303, 0xfffd0303, 0x06060303, - 0xf9fa0303, 0xfffffcfd, 0x0302fcfd, 0xfcfcfcfd, 0x02fffcfd, 0xfcfffcfd, 0x0002fcfd, 0xfffcfcfd, - 0x0605fcfd, 0xf9f9fcfd, 0x00000300, 0x03030300, 0xfcfd0300, 0x03000300, 0xfd000300, 0x00030300, - 0xfffd0300, 0x06060300, 0xf9fa0300, 0xfffffd00, 0x0302fd00, 0xfcfcfd00, 0x02fffd00, 0xfcfffd00, - 0x0002fd00, 0xfffcfd00, 0x0605fd00, 0xf9f9fd00, 0x00000003, 0x03030003, 0xfcfd0003, 0x03000003, - 0xfd000003, 0x00030003, 0xfffd0003, 0x06060003, 0xf9fa0003, 0xfffffffd, 0x0302fffd, 0xfcfcfffd, - 0x02fffffd, 0xfcfffffd, 0x0002fffd, 0xfffcfffd, 0x0605fffd, 0xf9f9fffd, 0x00000606, 0x03030606, - 0xfcfd0606, 0x03000606, 0xfd000606, 0x00030606, 0xfffd0606, 0x06060606, 0xf9fa0606, 0xfffff9fa, - 0x0302f9fa, 0xfcfcf9fa, 0x02fff9fa, 0xfcfff9fa, 0x0002f9fa, 0xfffcf9fa, 0x0605f9fa, 0xf9f9f9fa, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000404, 0xfffffbfc, 0x00000400, 0xfffffc00, 0x00000004, 0xfffffffc, 0x00000804, - 0xfffff7fc, 0x00000408, 0xfffffbf8, 0x00000808, 0xfffff7f8, 0x000007f8, 0xfffff808, 0x00000bfc, - 0xfffff404, 0xfffffc0c, 0x000003f4, 0x00001008, 0xffffeff8, 0x00000810, 0xfffff7f0, 0x00001010, - 0xffffeff0, 0x00001400, 0xffffec00, 0x00000014, 0xffffffec, 0x00000ff4, 0xfffff00c, 0xfffff410, - 0x00000bf0, 0x000017fc, 0xffffe804, 0xfffffc18, 0x000003e8, 0x00002010, 0xffffdff0, 0x00001020, - 0xffffefe0, 0x00002008, 0xffffdff8, 0x00000820, 0xfffff7e0, 0x00002020, 0xffffdfe0, 0x00002400, - 0xffffdc00, 0x00000024, 0xffffffdc, 0x000017e8, 0xffffe818, 0x00001ff0, 0xffffe010, 0xfffff020, - 0x00000fe0, 0x00003414, 0xffffcbec, 0x00001434, 0xffffebcc, 0x00003824, 0xffffc7dc, 0x00002438, - 0xffffdbc8, 0x00002bf4, 0xffffd40c, 0xfffff42c, 0x00000bd4, 0x00003808, 0xffffc7f8, 0x00000838, - 0xfffff7c8, 0x00003c3c, 0xffffc3c4, 0x00003ffc, 0xffffc004, 0xfffffc40, 0x000003c0, 0x00002bdc, - 0xffffd424, 0xffffdc2c, 0x000023d4, 0x00003be4, 0xffffc41c, 0xffffe43c, 0x00001bc4, 0x00005c2c, - 0xffffa3d4, 0x00002c5c, 0xffffd3a4, 0x00005c18, 0xffffa3e8, 0x0000185c, 0xffffe7a4, 0x00006048, - 0xffff9fb8, 0x00004860, 0xffffb7a0, 0x000053ec, 0xffffac14, 0xffffec54, 0x000013ac, 0x00006408, - 0xffff9bf8, 0x00000864, 0xfffff79c, 0x00006c6c, 0xffff9394, 0x000043bc, 0xffffbc44, 0x000053c8, - 0xffffac38, 0xffffc854, 0x000037ac, 0x000077f4, 0xffff880c, 0xfffff478, 0x00000b88, 0x00006bd0, - 0xffff9430, 0xffffd06c, 0x00002f94, 0x00007b98, 0xffff8468, 0xffff987c, 0x00006784, 0x00001818, - 0xffffe7e8, 0x00002c2c, 0xffffd3d4, 0x00005454, 0xffffabac, 0x00000000, 0x04040000, 0xfbfc0000, - 0x04000000, 0xfc000000, 0x00040000, 0xfffc0000, 0x08040000, 0xf7fc0000, 0x04080000, 0x00000404, - 0x04040404, 0xfbfc0404, 0x04000404, 0xfc000404, 0x00040404, 0xfffc0404, 0x08040404, 0xf7fc0404, - 0x04080404, 0xfffffbfc, 0x0403fbfc, 0xfbfbfbfc, 0x03fffbfc, 0xfbfffbfc, 0x0003fbfc, 0xfffbfbfc, - 0x0803fbfc, 0xf7fbfbfc, 0x0407fbfc, 0x00000400, 0x04040400, 0xfbfc0400, 0x04000400, 0xfc000400, - 0x00040400, 0xfffc0400, 0x08040400, 0xf7fc0400, 0x04080400, 0xfffffc00, 0x0403fc00, 0xfbfbfc00, - 0x03fffc00, 0xfbfffc00, 0x0003fc00, 0xfffbfc00, 0x0803fc00, 0xf7fbfc00, 0x0407fc00, 0x00000004, - 0x04040004, 0xfbfc0004, 0x04000004, 0xfc000004, 0x00040004, 0xfffc0004, 0x08040004, 0xf7fc0004, - 0x04080004, 0xfffffffc, 0x0403fffc, 0xfbfbfffc, 0x03fffffc, 0xfbfffffc, 0x0003fffc, 0xfffbfffc, - 0x0803fffc, 0xf7fbfffc, 0x0407fffc, 0x00000804, 0x04040804, 0xfbfc0804, 0x04000804, 0xfc000804, - 0x00040804, 0xfffc0804, 0x08040804, 0xf7fc0804, 0x04080804, 0xfffff7fc, 0x0403f7fc, 0xfbfbf7fc, - 0x03fff7fc, 0xfbfff7fc, 0x0003f7fc, 0xfffbf7fc, 0x0803f7fc, 0xf7fbf7fc, 0x0407f7fc, 0x00000408, - 0x04040408, 0xfbfc0408, 0x04000408, 0xfc000408, 0x00040408, 0xfffc0408, 0x08040408, 0xf7fc0408, - 0x04080408, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000505, 0xfffffafb, 0x00000500, 0xfffffb00, 0x00000005, 0xfffffffb, 0x00000a0a, - 0xfffff5f6, 0x00000f05, 0xfffff0fb, 0x0000050f, 0xfffffaf1, 0x000009f6, 0xfffff60a, 0x00000efb, - 0xfffff105, 0xfffffb0f, 0x000004f1, 0x0000140a, 0xffffebf6, 0x00000a14, 0xfffff5ec, 0x00001414, - 0xffffebec, 0x00001900, 0xffffe700, 0x00000019, 0xffffffe7, 0x000013f1, 0xffffec0f, 0xfffff114, - 0x00000eec, 0x00002819, 0xffffd7e7, 0x00001928, 0xffffe6d8, 0x00001df6, 0xffffe20a, 0xfffff61e, - 0x000009e2, 0x0000280a, 0xffffd7f6, 0x00000a28, 0xfffff5d8, 0x00002828, 0xffffd7d8, 0x00002d00, - 0xffffd300, 0x0000002d, 0xffffffd3, 0x00001de2, 0xffffe21e, 0x000027ec, 0xffffd814, 0xffffec28, - 0x000013d8, 0x00004119, 0xffffbee7, 0x00001941, 0xffffe6bf, 0x0000462d, 0xffffb9d3, 0x00002d46, - 0xffffd2ba, 0x000036f1, 0xffffc90f, 0xfffff137, 0x00000ec9, 0x0000460a, 0xffffb9f6, 0x00000a46, - 0xfffff5ba, 0x00004b4b, 0xffffb4b5, 0x000054fb, 0xffffab05, 0xfffffb55, 0x000004ab, 0x000036d3, - 0xffffc92d, 0xffffd337, 0x00002cc9, 0x00004add, 0xffffb523, 0xffffdd4b, 0x000022b5, 0x00007337, - 0xffff8cc9, 0x00003773, 0xffffc88d, 0x0000731e, 0xffff8ce2, 0x00001e73, 0xffffe18d, 0x0000785a, - 0xffff87a6, 0x00005a78, 0xffffa588, 0x000068e2, 0xffff971e, 0xffffe269, 0x00001d97, 0x000054ab, - 0xffffab55, 0x000068ba, 0xffff9746, 0xffffba69, 0x00004597, 0x00001e1e, 0xffffe1e2, 0x00003c3c, - 0xffffc3c4, 0x00006969, 0xffff9697, 0x00000000, 0x05050000, 0xfafb0000, 0x05000000, 0xfb000000, - 0x00050000, 0xfffb0000, 0x0a0a0000, 0xf5f60000, 0x0f050000, 0xf0fb0000, 0x00000505, 0x05050505, - 0xfafb0505, 0x05000505, 0xfb000505, 0x00050505, 0xfffb0505, 0x0a0a0505, 0xf5f60505, 0x0f050505, - 0xf0fb0505, 0xfffffafb, 0x0504fafb, 0xfafafafb, 0x04fffafb, 0xfafffafb, 0x0004fafb, 0xfffafafb, - 0x0a09fafb, 0xf5f5fafb, 0x0f04fafb, 0xf0fafafb, 0x00000500, 0x05050500, 0xfafb0500, 0x05000500, - 0xfb000500, 0x00050500, 0xfffb0500, 0x0a0a0500, 0xf5f60500, 0x0f050500, 0xf0fb0500, 0xfffffb00, - 0x0504fb00, 0xfafafb00, 0x04fffb00, 0xfafffb00, 0x0004fb00, 0xfffafb00, 0x0a09fb00, 0xf5f5fb00, - 0x0f04fb00, 0xf0fafb00, 0x00000005, 0x05050005, 0xfafb0005, 0x05000005, 0xfb000005, 0x00050005, - 0xfffb0005, 0x0a0a0005, 0xf5f60005, 0x0f050005, 0xf0fb0005, 0xfffffffb, 0x0504fffb, 0xfafafffb, - 0x04fffffb, 0xfafffffb, 0x0004fffb, 0xfffafffb, 0x0a09fffb, 0xf5f5fffb, 0x0f04fffb, 0xf0fafffb, - 0x00000a0a, 0x05050a0a, 0xfafb0a0a, 0x05000a0a, 0xfb000a0a, 0x00050a0a, 0xfffb0a0a, 0x0a0a0a0a, - 0xf5f60a0a, 0x0f050a0a, 0xf0fb0a0a, 0xfffff5f6, 0x0504f5f6, 0xfafaf5f6, 0x04fff5f6, 0xfafff5f6, - 0x0004f5f6, 0xfffaf5f6, 0x0a09f5f6, 0xf5f5f5f6, 0x0f04f5f6, 0xf0faf5f6, 0x00000f05, 0x05050f05, - 0xfafb0f05, 0x05000f05, 0xfb000f05, 0x00050f05, 0xfffb0f05, 0x0a0a0f05, 0xf5f60f05, 0x0f050f05, - 0xf0fb0f05, 0xfffff0fb, 0x0504f0fb, 0xfafaf0fb, 0x04fff0fb, 0xfafff0fb, 0x0004f0fb, 0xfffaf0fb, - 0x0a09f0fb, 0xf5f5f0fb, 0x0f04f0fb, 0xf0faf0fb, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000606, 0xfffff9fa, 0x00000600, 0xfffffa00, 0x00000006, 0xfffffffa, 0x00000c0c, - 0xfffff3f4, 0x00000c06, 0xfffff3fa, 0x0000060c, 0xfffff9f4, 0x00000bf4, 0xfffff40c, 0x000011fa, - 0xffffee06, 0xfffffa12, 0x000005ee, 0x0000180c, 0xffffe7f4, 0x00000c18, 0xfffff3e8, 0x00001818, - 0xffffe7e8, 0x00001e00, 0xffffe200, 0x0000001e, 0xffffffe2, 0x000017ee, 0xffffe812, 0xffffee18, - 0x000011e8, 0x0000301e, 0xffffcfe2, 0x00001e30, 0xffffe1d0, 0x000023fa, 0xffffdc06, 0xfffffa24, - 0x000005dc, 0x0000300c, 0xffffcff4, 0x00000c30, 0xfffff3d0, 0x00003030, 0xffffcfd0, 0x00003600, - 0xffffca00, 0x00000036, 0xffffffca, 0x000023dc, 0xffffdc24, 0x00002fe8, 0xffffd018, 0xffffe830, - 0x000017d0, 0x00004e1e, 0xffffb1e2, 0x00001e4e, 0xffffe1b2, 0x00005436, 0xffffabca, 0x00003654, - 0xffffc9ac, 0x000041ee, 0xffffbe12, 0xffffee42, 0x000011be, 0x0000540c, 0xffffabf4, 0x00000c54, - 0xfffff3ac, 0x00005a5a, 0xffffa5a6, 0x00005ffa, 0xffffa006, 0xfffffa60, 0x000005a0, 0x000041ca, - 0xffffbe36, 0xffffca42, 0x000035be, 0x000059d6, 0xffffa62a, 0xffffd65a, 0x000029a6, 0x00007de2, - 0xffff821e, 0xffffe27e, 0x00001d82, 0x0000659a, 0xffff9a66, 0x00007dac, 0xffff8254, 0xffffac7e, - 0x00005382, 0x00002424, 0xffffdbdc, 0x00004242, 0xffffbdbe, 0x00000000, 0x06060000, 0xf9fa0000, - 0x06000000, 0xfa000000, 0x00060000, 0xfffa0000, 0x0c0c0000, 0xf3f40000, 0x0c060000, 0xf3fa0000, - 0x060c0000, 0x00000606, 0x06060606, 0xf9fa0606, 0x06000606, 0xfa000606, 0x00060606, 0xfffa0606, - 0x0c0c0606, 0xf3f40606, 0x0c060606, 0xf3fa0606, 0x060c0606, 0xfffff9fa, 0x0605f9fa, 0xf9f9f9fa, - 0x05fff9fa, 0xf9fff9fa, 0x0005f9fa, 0xfff9f9fa, 0x0c0bf9fa, 0xf3f3f9fa, 0x0c05f9fa, 0xf3f9f9fa, - 0x060bf9fa, 0x00000600, 0x06060600, 0xf9fa0600, 0x06000600, 0xfa000600, 0x00060600, 0xfffa0600, - 0x0c0c0600, 0xf3f40600, 0x0c060600, 0xf3fa0600, 0x060c0600, 0xfffffa00, 0x0605fa00, 0xf9f9fa00, - 0x05fffa00, 0xf9fffa00, 0x0005fa00, 0xfff9fa00, 0x0c0bfa00, 0xf3f3fa00, 0x0c05fa00, 0xf3f9fa00, - 0x060bfa00, 0x00000006, 0x06060006, 0xf9fa0006, 0x06000006, 0xfa000006, 0x00060006, 0xfffa0006, - 0x0c0c0006, 0xf3f40006, 0x0c060006, 0xf3fa0006, 0x060c0006, 0xfffffffa, 0x0605fffa, 0xf9f9fffa, - 0x05fffffa, 0xf9fffffa, 0x0005fffa, 0xfff9fffa, 0x0c0bfffa, 0xf3f3fffa, 0x0c05fffa, 0xf3f9fffa, - 0x060bfffa, 0x00000c0c, 0x06060c0c, 0xf9fa0c0c, 0x06000c0c, 0xfa000c0c, 0x00060c0c, 0xfffa0c0c, - 0x0c0c0c0c, 0xf3f40c0c, 0x0c060c0c, 0xf3fa0c0c, 0x060c0c0c, 0xfffff3f4, 0x0605f3f4, 0xf9f9f3f4, - 0x05fff3f4, 0xf9fff3f4, 0x0005f3f4, 0xfff9f3f4, 0x0c0bf3f4, 0xf3f3f3f4, 0x0c05f3f4, 0xf3f9f3f4, - 0x060bf3f4, 0x00000c06, 0x06060c06, 0xf9fa0c06, 0x06000c06, 0xfa000c06, 0x00060c06, 0xfffa0c06, - 0x0c0c0c06, 0xf3f40c06, 0x0c060c06, 0xf3fa0c06, 0x060c0c06, 0xfffff3fa, 0x0605f3fa, 0xf9f9f3fa, - 0x05fff3fa, 0xf9fff3fa, 0x0005f3fa, 0xfff9f3fa, 0x0c0bf3fa, 0xf3f3f3fa, 0x0c05f3fa, 0xf3f9f3fa, - 0x060bf3fa, 0x0000060c, 0x0606060c, 0xf9fa060c, 0x0600060c, 0xfa00060c, 0x0006060c, 0xfffa060c, - 0x0c0c060c, 0xf3f4060c, 0x0c06060c, 0xf3fa060c, 0x060c060c, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000707, 0xfffff8f9, 0x00000700, 0xfffff900, 0x00000007, 0xfffffff9, 0x00000e0e, - 0xfffff1f2, 0x00001507, 0xffffeaf9, 0x00000715, 0xfffff8eb, 0x00000df2, 0xfffff20e, 0x000014f9, - 0xffffeb07, 0xfffff915, 0x000006eb, 0x00001c0e, 0xffffe3f2, 0x00000e1c, 0xfffff1e4, 0x00001c1c, - 0xffffe3e4, 0x00002300, 0xffffdd00, 0x00000023, 0xffffffdd, 0x00001beb, 0xffffe415, 0xffffeb1c, - 0x000014e4, 0x00003823, 0xffffc7dd, 0x00002338, 0xffffdcc8, 0x000029f2, 0xffffd60e, 0xfffff22a, - 0x00000dd6, 0x0000380e, 0xffffc7f2, 0x00000e38, 0xfffff1c8, 0x00003838, 0xffffc7c8, 0x00003f00, - 0xffffc100, 0x0000003f, 0xffffffc1, 0x000029d6, 0xffffd62a, 0x000037e4, 0xffffc81c, 0xffffe438, - 0x00001bc8, 0x00005b23, 0xffffa4dd, 0x0000235b, 0xffffdca5, 0x0000623f, 0xffff9dc1, 0x00003f62, - 0xffffc09e, 0x00004ceb, 0xffffb315, 0xffffeb4d, 0x000014b3, 0x0000620e, 0xffff9df2, 0x00000e62, - 0xfffff19e, 0x00006969, 0xffff9697, 0x000076f9, 0xffff8907, 0xfffff977, 0x00000689, 0x00004cc1, - 0xffffb33f, 0xffffc14d, 0x00003eb3, 0x000068cf, 0xffff9731, 0xffffcf69, 0x00003097, 0x00007689, - 0xffff8977, 0x00002a2a, 0xffffd5d6, 0x00004d4d, 0xffffb2b3, 0x00000000, 0x07070000, 0xf8f90000, - 0x07000000, 0xf9000000, 0x00070000, 0xfff90000, 0x0e0e0000, 0xf1f20000, 0x15070000, 0xeaf90000, - 0x07150000, 0x00000707, 0x07070707, 0xf8f90707, 0x07000707, 0xf9000707, 0x00070707, 0xfff90707, - 0x0e0e0707, 0xf1f20707, 0x15070707, 0xeaf90707, 0x07150707, 0xfffff8f9, 0x0706f8f9, 0xf8f8f8f9, - 0x06fff8f9, 0xf8fff8f9, 0x0006f8f9, 0xfff8f8f9, 0x0e0df8f9, 0xf1f1f8f9, 0x1506f8f9, 0xeaf8f8f9, - 0x0714f8f9, 0x00000700, 0x07070700, 0xf8f90700, 0x07000700, 0xf9000700, 0x00070700, 0xfff90700, - 0x0e0e0700, 0xf1f20700, 0x15070700, 0xeaf90700, 0x07150700, 0xfffff900, 0x0706f900, 0xf8f8f900, - 0x06fff900, 0xf8fff900, 0x0006f900, 0xfff8f900, 0x0e0df900, 0xf1f1f900, 0x1506f900, 0xeaf8f900, - 0x0714f900, 0x00000007, 0x07070007, 0xf8f90007, 0x07000007, 0xf9000007, 0x00070007, 0xfff90007, - 0x0e0e0007, 0xf1f20007, 0x15070007, 0xeaf90007, 0x07150007, 0xfffffff9, 0x0706fff9, 0xf8f8fff9, - 0x06fffff9, 0xf8fffff9, 0x0006fff9, 0xfff8fff9, 0x0e0dfff9, 0xf1f1fff9, 0x1506fff9, 0xeaf8fff9, - 0x0714fff9, 0x00000e0e, 0x07070e0e, 0xf8f90e0e, 0x07000e0e, 0xf9000e0e, 0x00070e0e, 0xfff90e0e, - 0x0e0e0e0e, 0xf1f20e0e, 0x15070e0e, 0xeaf90e0e, 0x07150e0e, 0xfffff1f2, 0x0706f1f2, 0xf8f8f1f2, - 0x06fff1f2, 0xf8fff1f2, 0x0006f1f2, 0xfff8f1f2, 0x0e0df1f2, 0xf1f1f1f2, 0x1506f1f2, 0xeaf8f1f2, - 0x0714f1f2, 0x00001507, 0x07071507, 0xf8f91507, 0x07001507, 0xf9001507, 0x00071507, 0xfff91507, - 0x0e0e1507, 0xf1f21507, 0x15071507, 0xeaf91507, 0x07151507, 0xffffeaf9, 0x0706eaf9, 0xf8f8eaf9, - 0x06ffeaf9, 0xf8ffeaf9, 0x0006eaf9, 0xfff8eaf9, 0x0e0deaf9, 0xf1f1eaf9, 0x1506eaf9, 0xeaf8eaf9, - 0x0714eaf9, 0x00000715, 0x07070715, 0xf8f90715, 0x07000715, 0xf9000715, 0x00070715, 0xfff90715, - 0x0e0e0715, 0xf1f20715, 0x15070715, 0xeaf90715, 0x07150715, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000808, 0xfffff7f8, 0x00000800, 0xfffff800, 0x00000008, 0xfffffff8, 0x00001010, - 0xffffeff0, 0x00001008, 0xffffeff8, 0x00000810, 0xfffff7f0, 0x00000ff0, 0xfffff010, 0x000017f8, - 0xffffe808, 0xfffff818, 0x000007e8, 0x00002010, 0xffffdff0, 0x00001020, 0xffffefe0, 0x00002020, - 0xffffdfe0, 0x00002800, 0xffffd800, 0x00000028, 0xffffffd8, 0x00001fe8, 0xffffe018, 0xffffe820, - 0x000017e0, 0x00004028, 0xffffbfd8, 0x00002840, 0xffffd7c0, 0x00002ff0, 0xffffd010, 0xfffff030, - 0x00000fd0, 0x00004010, 0xffffbff0, 0x00001040, 0xffffefc0, 0x00004040, 0xffffbfc0, 0x00004800, - 0xffffb800, 0x00000048, 0xffffffb8, 0x00002fd0, 0xffffd030, 0x00003fe0, 0xffffc020, 0xffffe040, - 0x00001fc0, 0x00006828, 0xffff97d8, 0x00002868, 0xffffd798, 0x00007048, 0xffff8fb8, 0x00004870, - 0xffffb790, 0x000057e8, 0xffffa818, 0xffffe858, 0x000017a8, 0x00007010, 0xffff8ff0, 0x00001070, - 0xffffef90, 0x00007878, 0xffff8788, 0x000057b8, 0xffffa848, 0xffffb858, 0x000047a8, 0x000077c8, - 0xffff8838, 0xffffc878, 0x00003788, 0x00003030, 0xffffcfd0, 0x00005858, 0xffffa7a8, 0x00000000, - 0x08080000, 0xf7f80000, 0x08000000, 0xf8000000, 0x00080000, 0xfff80000, 0x10100000, 0xeff00000, - 0x10080000, 0xeff80000, 0x08100000, 0x00000808, 0x08080808, 0xf7f80808, 0x08000808, 0xf8000808, - 0x00080808, 0xfff80808, 0x10100808, 0xeff00808, 0x10080808, 0xeff80808, 0x08100808, 0xfffff7f8, - 0x0807f7f8, 0xf7f7f7f8, 0x07fff7f8, 0xf7fff7f8, 0x0007f7f8, 0xfff7f7f8, 0x100ff7f8, 0xefeff7f8, - 0x1007f7f8, 0xeff7f7f8, 0x080ff7f8, 0x00000800, 0x08080800, 0xf7f80800, 0x08000800, 0xf8000800, - 0x00080800, 0xfff80800, 0x10100800, 0xeff00800, 0x10080800, 0xeff80800, 0x08100800, 0xfffff800, - 0x0807f800, 0xf7f7f800, 0x07fff800, 0xf7fff800, 0x0007f800, 0xfff7f800, 0x100ff800, 0xefeff800, - 0x1007f800, 0xeff7f800, 0x080ff800, 0x00000008, 0x08080008, 0xf7f80008, 0x08000008, 0xf8000008, - 0x00080008, 0xfff80008, 0x10100008, 0xeff00008, 0x10080008, 0xeff80008, 0x08100008, 0xfffffff8, - 0x0807fff8, 0xf7f7fff8, 0x07fffff8, 0xf7fffff8, 0x0007fff8, 0xfff7fff8, 0x100ffff8, 0xefeffff8, - 0x1007fff8, 0xeff7fff8, 0x080ffff8, 0x00001010, 0x08081010, 0xf7f81010, 0x08001010, 0xf8001010, - 0x00081010, 0xfff81010, 0x10101010, 0xeff01010, 0x10081010, 0xeff81010, 0x08101010, 0xffffeff0, - 0x0807eff0, 0xf7f7eff0, 0x07ffeff0, 0xf7ffeff0, 0x0007eff0, 0xfff7eff0, 0x100feff0, 0xefefeff0, - 0x1007eff0, 0xeff7eff0, 0x080feff0, 0x00001008, 0x08081008, 0xf7f81008, 0x08001008, 0xf8001008, - 0x00081008, 0xfff81008, 0x10101008, 0xeff01008, 0x10081008, 0xeff81008, 0x08101008, 0xffffeff8, - 0x0807eff8, 0xf7f7eff8, 0x07ffeff8, 0xf7ffeff8, 0x0007eff8, 0xfff7eff8, 0x100feff8, 0xefefeff8, - 0x1007eff8, 0xeff7eff8, 0x080feff8, 0x00000810, 0x08080810, 0xf7f80810, 0x08000810, 0xf8000810, - 0x00080810, 0xfff80810, 0x10100810, 0xeff00810, 0x10080810, 0xeff80810, 0x08100810, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000909, 0xfffff6f7, 0x00000900, 0xfffff700, 0x00000009, 0xfffffff7, 0x00001212, - 0xffffedee, 0x00001b09, 0xffffe4f7, 0x0000091b, 0xfffff6e5, 0x000011ee, 0xffffee12, 0x00001af7, - 0xffffe509, 0xfffff71b, 0x000008e5, 0x00002412, 0xffffdbee, 0x00001224, 0xffffeddc, 0x00002424, - 0xffffdbdc, 0x00002d00, 0xffffd300, 0x0000002d, 0xffffffd3, 0x000023e5, 0xffffdc1b, 0xffffe524, - 0x00001adc, 0x0000482d, 0xffffb7d3, 0x00002d48, 0xffffd2b8, 0x000035ee, 0xffffca12, 0xffffee36, - 0x000011ca, 0x00004812, 0xffffb7ee, 0x00001248, 0xffffedb8, 0x00004848, 0xffffb7b8, 0x00005100, - 0xffffaf00, 0x00000051, 0xffffffaf, 0x000035ca, 0xffffca36, 0x000047dc, 0xffffb824, 0xffffdc48, - 0x000023b8, 0x0000752d, 0xffff8ad3, 0x00002d75, 0xffffd28b, 0x00007e51, 0xffff81af, 0x0000517e, - 0xffffae82, 0x000062e5, 0xffff9d1b, 0xffffe563, 0x00001a9d, 0x000062af, 0xffff9d51, 0xffffaf63, - 0x0000509d, 0x00003636, 0xffffc9ca, 0x00006c6c, 0xffff9394, 0x00000000, 0x09090000, 0xf6f70000, - 0x09000000, 0xf7000000, 0x00090000, 0xfff70000, 0x12120000, 0xedee0000, 0x1b090000, 0xe4f70000, - 0x091b0000, 0xf6e50000, 0x00000909, 0x09090909, 0xf6f70909, 0x09000909, 0xf7000909, 0x00090909, - 0xfff70909, 0x12120909, 0xedee0909, 0x1b090909, 0xe4f70909, 0x091b0909, 0xf6e50909, 0xfffff6f7, - 0x0908f6f7, 0xf6f6f6f7, 0x08fff6f7, 0xf6fff6f7, 0x0008f6f7, 0xfff6f6f7, 0x1211f6f7, 0xededf6f7, - 0x1b08f6f7, 0xe4f6f6f7, 0x091af6f7, 0xf6e4f6f7, 0x00000900, 0x09090900, 0xf6f70900, 0x09000900, - 0xf7000900, 0x00090900, 0xfff70900, 0x12120900, 0xedee0900, 0x1b090900, 0xe4f70900, 0x091b0900, - 0xf6e50900, 0xfffff700, 0x0908f700, 0xf6f6f700, 0x08fff700, 0xf6fff700, 0x0008f700, 0xfff6f700, - 0x1211f700, 0xededf700, 0x1b08f700, 0xe4f6f700, 0x091af700, 0xf6e4f700, 0x00000009, 0x09090009, - 0xf6f70009, 0x09000009, 0xf7000009, 0x00090009, 0xfff70009, 0x12120009, 0xedee0009, 0x1b090009, - 0xe4f70009, 0x091b0009, 0xf6e50009, 0xfffffff7, 0x0908fff7, 0xf6f6fff7, 0x08fffff7, 0xf6fffff7, - 0x0008fff7, 0xfff6fff7, 0x1211fff7, 0xededfff7, 0x1b08fff7, 0xe4f6fff7, 0x091afff7, 0xf6e4fff7, - 0x00001212, 0x09091212, 0xf6f71212, 0x09001212, 0xf7001212, 0x00091212, 0xfff71212, 0x12121212, - 0xedee1212, 0x1b091212, 0xe4f71212, 0x091b1212, 0xf6e51212, 0xffffedee, 0x0908edee, 0xf6f6edee, - 0x08ffedee, 0xf6ffedee, 0x0008edee, 0xfff6edee, 0x1211edee, 0xedededee, 0x1b08edee, 0xe4f6edee, - 0x091aedee, 0xf6e4edee, 0x00001b09, 0x09091b09, 0xf6f71b09, 0x09001b09, 0xf7001b09, 0x00091b09, - 0xfff71b09, 0x12121b09, 0xedee1b09, 0x1b091b09, 0xe4f71b09, 0x091b1b09, 0xf6e51b09, 0xffffe4f7, - 0x0908e4f7, 0xf6f6e4f7, 0x08ffe4f7, 0xf6ffe4f7, 0x0008e4f7, 0xfff6e4f7, 0x1211e4f7, 0xedede4f7, - 0x1b08e4f7, 0xe4f6e4f7, 0x091ae4f7, 0xf6e4e4f7, 0x0000091b, 0x0909091b, 0xf6f7091b, 0x0900091b, - 0xf700091b, 0x0009091b, 0xfff7091b, 0x1212091b, 0xedee091b, 0x1b09091b, 0xe4f7091b, 0x091b091b, - 0xf6e5091b, 0xfffff6e5, 0x0908f6e5, 0xf6f6f6e5, 0x08fff6e5, 0xf6fff6e5, 0x0008f6e5, 0xfff6f6e5, - 0x1211f6e5, 0xededf6e5, 0x1b08f6e5, 0xe4f6f6e5, 0x091af6e5, 0xf6e4f6e5, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000202, 0xfffffdfe, 0x00000300, 0xfffffd00, 0x00000003, 0xfffffffd, 0x00000606, - 0xfffff9fa, 0x00000700, 0xfffff900, 0x00000007, 0xfffffff9, 0x000004fb, 0xfffffb05, 0xfffffb05, - 0x000004fb, 0x00000b06, 0xfffff4fa, 0x0000060b, 0xfffff9f5, 0x00000800, 0xfffff800, 0x00000008, - 0xfffffff8, 0x00000b0b, 0xfffff4f5, 0x00000c00, 0xfffff400, 0x0000000c, 0xfffffff4, 0x0000110c, - 0xffffeef4, 0x00000c11, 0xfffff3ef, 0x00001111, 0xffffeeef, 0x00001206, 0xffffedfa, 0x00000612, - 0xfffff9ee, 0x00000af8, 0xfffff508, 0xfffff80b, 0x000007f5, 0x00000f00, 0xfffff100, 0x0000000f, - 0xfffffff1, 0x00001400, 0xffffec00, 0x00000014, 0xffffffec, 0x00001912, 0xffffe6ee, 0x00001219, - 0xffffede7, 0x0000190b, 0xffffe6f5, 0x00000b19, 0xfffff4e7, 0x00001919, 0xffffe6e7, 0x00000df2, - 0xfffff20e, 0xfffff20e, 0x00000df2, 0x00001a00, 0xffffe600, 0x0000001a, 0xffffffe6, 0x000011f5, - 0xffffee0b, 0xfffff512, 0x00000aee, 0x000015f9, 0xffffea07, 0xfffff916, 0x000006ea, 0x0000221a, - 0xffffdde6, 0x00001a22, 0xffffe5de, 0x00002212, 0xffffddee, 0x00001222, 0xffffedde, 0x00002222, - 0xffffddde, 0x0000230b, 0xffffdcf5, 0x00000b23, 0xfffff4dd, 0x00001d00, 0xffffe300, 0x0000001d, - 0xffffffe3, 0x000015ed, 0xffffea13, 0xffffed16, 0x000012ea, 0x000019f1, 0xffffe60f, 0xfffff11a, - 0x00000ee6, 0x00002500, 0xffffdb00, 0x00000025, 0xffffffdb, 0x00002c1b, 0xffffd3e5, 0x00001b2c, - 0xffffe4d4, 0x00002c24, 0xffffd3dc, 0x0000242c, 0xffffdbd4, 0x00002c12, 0xffffd3ee, 0x0000122c, - 0xffffedd4, 0x000020f6, 0xffffdf0a, 0xfffff621, 0x000009df, 0x00002d2d, 0xffffd2d3, 0x00000000, - 0x00000000, 0x00000202, 0xfffffdfe, 0x00000300, 0xfffffd00, 0x00000003, 0xfffffffd, 0x00000606, - 0xfffff9fa, 0x00000700, 0xfffff900, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020300, 0x0201fd00, - 0x02020003, 0x0201fffd, 0x02020606, 0x0201f9fa, 0x02020700, 0x0201f900, 0xfdfe0000, 0xfdfe0202, - 0xfdfdfdfe, 0xfdfe0300, 0xfdfdfd00, 0xfdfe0003, 0xfdfdfffd, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0700, - 0xfdfdf900, 0x03000000, 0x03000202, 0x02fffdfe, 0x03000300, 0x02fffd00, 0x03000003, 0x02fffffd, - 0x03000606, 0x02fff9fa, 0x03000700, 0x02fff900, 0xfd000000, 0xfd000202, 0xfcfffdfe, 0xfd000300, - 0xfcfffd00, 0xfd000003, 0xfcfffffd, 0xfd000606, 0xfcfff9fa, 0xfd000700, 0xfcfff900, 0x00030000, - 0x00030202, 0x0002fdfe, 0x00030300, 0x0002fd00, 0x00030003, 0x0002fffd, 0x00030606, 0x0002f9fa, - 0x00030700, 0x0002f900, 0xfffd0000, 0xfffd0202, 0xfffcfdfe, 0xfffd0300, 0xfffcfd00, 0xfffd0003, - 0xfffcfffd, 0xfffd0606, 0xfffcf9fa, 0xfffd0700, 0xfffcf900, 0x06060000, 0x06060202, 0x0605fdfe, - 0x06060300, 0x0605fd00, 0x06060003, 0x0605fffd, 0x06060606, 0x0605f9fa, 0x06060700, 0x0605f900, - 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0300, 0xf9f9fd00, 0xf9fa0003, 0xf9f9fffd, 0xf9fa0606, - 0xf9f9f9fa, 0xf9fa0700, 0xf9f9f900, 0x07000000, 0x07000202, 0x06fffdfe, 0x07000300, 0x06fffd00, - 0x07000003, 0x06fffffd, 0x07000606, 0x06fff9fa, 0x07000700, 0x06fff900, 0xf9000000, 0xf9000202, - 0xf8fffdfe, 0xf9000300, 0xf8fffd00, 0xf9000003, 0xf8fffffd, 0xf9000606, 0xf8fff9fa, 0xf9000700, - 0xf8fff900, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000202, 0xfffffdfe, 0x00000606, - 0xfffff9fa, 0x00000600, 0xfffffa00, 0x00000006, 0xfffffffa, 0x000003fc, 0xfffffc04, 0xfffffa0a, - 0x000005f6, 0xfffff400, 0x00000c00, 0xfffff3fa, 0xfffff406, 0x00000bfa, 0x00000c06, 0xfffffff2, - 0x0000000e, 0x00000c0c, 0xfffff3f4, 0xffffee00, 0x00001200, 0xfffff40e, 0x00000bf2, 0xfffff9ee, - 0xfffffa12, 0x000005ee, 0x00000612, 0xffffedf6, 0xffffee0a, 0x000011f6, 0x0000120a, 0xffffffea, - 0x00000016, 0xffffe800, 0x00001800, 0xfffff3ea, 0xfffff416, 0x00000bea, 0x00000c16, 0xffffe7f8, - 0xffffe808, 0x000017f8, 0x00001808, 0xfffff9e6, 0xfffffa1a, 0x000005e6, 0x0000061a, 0xffffffe4, - 0x0000001c, 0x00001414, 0xffffebec, 0xffffe5f2, 0x00001a0e, 0xfffff3e2, 0x00000c1e, 0xffffdff6, - 0x0000200a, 0xffffdfee, 0x00002012, 0xffffe5e6, 0x00001a1a, 0xffffebde, 0x00001422, 0xfffff3da, - 0x00000c26, 0xffffdfe0, 0x00002020, 0x00002020, 0xffffd7ea, 0xffffddde, 0x00002222, 0x00000000, - 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, - 0x00000600, 0xfffffa00, 0x00000006, 0xfffffffa, 0x02000000, 0x02000200, 0x01fffe00, 0x02000002, - 0x01fffffe, 0x02000202, 0x01fffdfe, 0x02000606, 0x01fff9fa, 0x02000600, 0x01fffa00, 0x02000006, - 0x01fffffa, 0xfe000000, 0xfe000200, 0xfdfffe00, 0xfe000002, 0xfdfffffe, 0xfe000202, 0xfdfffdfe, - 0xfe000606, 0xfdfff9fa, 0xfe000600, 0xfdfffa00, 0xfe000006, 0xfdfffffa, 0x00020000, 0x00020200, - 0x0001fe00, 0x00020002, 0x0001fffe, 0x00020202, 0x0001fdfe, 0x00020606, 0x0001f9fa, 0x00020600, - 0x0001fa00, 0x00020006, 0x0001fffa, 0xfffe0000, 0xfffe0200, 0xfffdfe00, 0xfffe0002, 0xfffdfffe, - 0xfffe0202, 0xfffdfdfe, 0xfffe0606, 0xfffdf9fa, 0xfffe0600, 0xfffdfa00, 0xfffe0006, 0xfffdfffa, - 0x02020000, 0x02020200, 0x0201fe00, 0x02020002, 0x0201fffe, 0x02020202, 0x0201fdfe, 0x02020606, - 0x0201f9fa, 0x02020600, 0x0201fa00, 0x02020006, 0x0201fffa, 0xfdfe0000, 0xfdfe0200, 0xfdfdfe00, - 0xfdfe0002, 0xfdfdfffe, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0600, 0xfdfdfa00, - 0xfdfe0006, 0xfdfdfffa, 0x06060000, 0x06060200, 0x0605fe00, 0x06060002, 0x0605fffe, 0x06060202, - 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060600, 0x0605fa00, 0x06060006, 0x0605fffa, 0xf9fa0000, - 0xf9fa0200, 0xf9f9fe00, 0xf9fa0002, 0xf9f9fffe, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, - 0xf9fa0600, 0xf9f9fa00, 0xf9fa0006, 0xf9f9fffa, 0x06000000, 0x06000200, 0x05fffe00, 0x06000002, - 0x05fffffe, 0x06000202, 0x05fffdfe, 0x06000606, 0x05fff9fa, 0x06000600, 0x05fffa00, 0x06000006, - 0x05fffffa, 0xfa000000, 0xfa000200, 0xf9fffe00, 0xfa000002, 0xf9fffffe, 0xfa000202, 0xf9fffdfe, - 0xfa000606, 0xf9fff9fa, 0xfa000600, 0xf9fffa00, 0xfa000006, 0xf9fffffa, 0x00060000, 0x00060200, - 0x0005fe00, 0x00060002, 0x0005fffe, 0x00060202, 0x0005fdfe, 0x00060606, 0x0005f9fa, 0x00060600, - 0x0005fa00, 0x00060006, 0x0005fffa, 0xfffa0000, 0xfffa0200, 0xfff9fe00, 0xfffa0002, 0xfff9fffe, - 0xfffa0202, 0xfff9fdfe, 0xfffa0606, 0xfff9f9fa, 0xfffa0600, 0xfff9fa00, 0xfffa0006, 0xfff9fffa, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000404, 0xfffffbfc, 0x00000a0a, - 0xfffff5f6, 0x00000a00, 0xfffff600, 0x0000000a, 0xfffffff6, 0x000005fa, 0xfffffa06, 0xfffff80e, - 0x000007f2, 0xffffffee, 0x00000012, 0xfffff00a, 0x00000ff6, 0xffffe800, 0x00001800, 0xfffff7e8, - 0xfffff818, 0x000007e8, 0x00000818, 0x00001212, 0xffffedee, 0xfffff014, 0x00000fec, 0xffffe5f2, - 0xffffe60e, 0x000019f2, 0x00001a0e, 0xffffffe2, 0x0000001e, 0xffffde00, 0x00002200, 0xfffff7de, - 0xfffff822, 0x000007de, 0x00000822, 0xffffede2, 0xffffee1e, 0x000011e2, 0x0000121e, 0xffffddf6, - 0xffffde0a, 0x000021f6, 0x0000220a, 0xffffddec, 0x00002214, 0xffffffd8, 0x00000028, 0x00001e1e, - 0xffffe1e2, 0xffffedd8, 0x00001228, 0xffffd400, 0x00002c00, 0xffffd3f0, 0x00002c10, 0xffffdbdc, - 0xffffdbdc, 0x00002424, 0xffffd3e6, 0x00002c1a, 0xffffe5d2, 0x00001a2e, 0xffffedcc, 0x00001234, - 0xffffc9ec, 0xffffd3d4, 0x00002c2c, 0xffffc9e0, 0xffffd1d2, 0xffffd1d2, 0x00002e2e, 0x00000000, - 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000404, 0xfffffbfc, 0x00000a0a, 0xfffff5f6, - 0x00000a00, 0xfffff600, 0x0000000a, 0xfffffff6, 0x02000000, 0x02000200, 0x01fffe00, 0x02000002, - 0x01fffffe, 0x02000404, 0x01fffbfc, 0x02000a0a, 0x01fff5f6, 0x02000a00, 0x01fff600, 0x0200000a, - 0x01fffff6, 0xfe000000, 0xfe000200, 0xfdfffe00, 0xfe000002, 0xfdfffffe, 0xfe000404, 0xfdfffbfc, - 0xfe000a0a, 0xfdfff5f6, 0xfe000a00, 0xfdfff600, 0xfe00000a, 0xfdfffff6, 0x00020000, 0x00020200, - 0x0001fe00, 0x00020002, 0x0001fffe, 0x00020404, 0x0001fbfc, 0x00020a0a, 0x0001f5f6, 0x00020a00, - 0x0001f600, 0x0002000a, 0x0001fff6, 0xfffe0000, 0xfffe0200, 0xfffdfe00, 0xfffe0002, 0xfffdfffe, - 0xfffe0404, 0xfffdfbfc, 0xfffe0a0a, 0xfffdf5f6, 0xfffe0a00, 0xfffdf600, 0xfffe000a, 0xfffdfff6, - 0x04040000, 0x04040200, 0x0403fe00, 0x04040002, 0x0403fffe, 0x04040404, 0x0403fbfc, 0x04040a0a, - 0x0403f5f6, 0x04040a00, 0x0403f600, 0x0404000a, 0x0403fff6, 0xfbfc0000, 0xfbfc0200, 0xfbfbfe00, - 0xfbfc0002, 0xfbfbfffe, 0xfbfc0404, 0xfbfbfbfc, 0xfbfc0a0a, 0xfbfbf5f6, 0xfbfc0a00, 0xfbfbf600, - 0xfbfc000a, 0xfbfbfff6, 0x0a0a0000, 0x0a0a0200, 0x0a09fe00, 0x0a0a0002, 0x0a09fffe, 0x0a0a0404, - 0x0a09fbfc, 0x0a0a0a0a, 0x0a09f5f6, 0x0a0a0a00, 0x0a09f600, 0x0a0a000a, 0x0a09fff6, 0xf5f60000, - 0xf5f60200, 0xf5f5fe00, 0xf5f60002, 0xf5f5fffe, 0xf5f60404, 0xf5f5fbfc, 0xf5f60a0a, 0xf5f5f5f6, - 0xf5f60a00, 0xf5f5f600, 0xf5f6000a, 0xf5f5fff6, 0x0a000000, 0x0a000200, 0x09fffe00, 0x0a000002, - 0x09fffffe, 0x0a000404, 0x09fffbfc, 0x0a000a0a, 0x09fff5f6, 0x0a000a00, 0x09fff600, 0x0a00000a, - 0x09fffff6, 0xf6000000, 0xf6000200, 0xf5fffe00, 0xf6000002, 0xf5fffffe, 0xf6000404, 0xf5fffbfc, - 0xf6000a0a, 0xf5fff5f6, 0xf6000a00, 0xf5fff600, 0xf600000a, 0xf5fffff6, 0x000a0000, 0x000a0200, - 0x0009fe00, 0x000a0002, 0x0009fffe, 0x000a0404, 0x0009fbfc, 0x000a0a0a, 0x0009f5f6, 0x000a0a00, - 0x0009f600, 0x000a000a, 0x0009fff6, 0xfff60000, 0xfff60200, 0xfff5fe00, 0xfff60002, 0xfff5fffe, - 0xfff60404, 0xfff5fbfc, 0xfff60a0a, 0xfff5f5f6, 0xfff60a00, 0xfff5f600, 0xfff6000a, 0xfff5fff6, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000400, 0xfffffc00, 0x00000004, 0xfffffffc, 0x00000404, 0xfffffbfc, 0x00000c0c, - 0xfffff3f4, 0x00000c00, 0xfffff400, 0x0000000c, 0xfffffff4, 0x000007f8, 0xfffff808, 0xfffff008, - 0x00000ff8, 0xffffe800, 0x00001800, 0xfffff7e8, 0xfffff818, 0x000007e8, 0x00000818, 0xfffff014, - 0x00000fec, 0xffffffe4, 0x0000001c, 0xffffe7f0, 0xffffe810, 0x000017f0, 0x00001810, 0xffffe000, - 0x00002000, 0xffffefe4, 0xfffff01c, 0x00000fe4, 0x0000101c, 0xffffdff8, 0xffffe008, 0xfffff7e0, - 0xfffff820, 0x000007e0, 0x00000820, 0x00001ff8, 0x00002008, 0x00001818, 0xffffe7e8, 0xffffe818, - 0x000017e8, 0xffffdfec, 0x00002014, 0xffffffd8, 0x00000028, 0xffffefd8, 0x00001028, 0xffffd400, - 0xffffd400, 0xffffffd4, 0x0000002c, 0x00002c00, 0x00002c00, 0xffffdfe0, 0x00002020, 0xffffd3f0, - 0x00002c10, 0xffffd3e8, 0xffffe7d4, 0x0000182c, 0x00002c18, 0xffffefd0, 0x00001030, 0xffffdbdc, - 0xffffdbdc, 0x00002424, 0x00002424, 0xffffcbec, 0x00002828, 0xffffd7d8, 0xffffcbe0, 0x00000000, - 0x00000400, 0xfffffc00, 0x00000004, 0xfffffffc, 0x00000404, 0xfffffbfc, 0x00000c0c, 0xfffff3f4, - 0x00000c00, 0xfffff400, 0x0000000c, 0xfffffff4, 0x04000000, 0x04000400, 0x03fffc00, 0x04000004, - 0x03fffffc, 0x04000404, 0x03fffbfc, 0x04000c0c, 0x03fff3f4, 0x04000c00, 0x03fff400, 0x0400000c, - 0x03fffff4, 0xfc000000, 0xfc000400, 0xfbfffc00, 0xfc000004, 0xfbfffffc, 0xfc000404, 0xfbfffbfc, - 0xfc000c0c, 0xfbfff3f4, 0xfc000c00, 0xfbfff400, 0xfc00000c, 0xfbfffff4, 0x00040000, 0x00040400, - 0x0003fc00, 0x00040004, 0x0003fffc, 0x00040404, 0x0003fbfc, 0x00040c0c, 0x0003f3f4, 0x00040c00, - 0x0003f400, 0x0004000c, 0x0003fff4, 0xfffc0000, 0xfffc0400, 0xfffbfc00, 0xfffc0004, 0xfffbfffc, - 0xfffc0404, 0xfffbfbfc, 0xfffc0c0c, 0xfffbf3f4, 0xfffc0c00, 0xfffbf400, 0xfffc000c, 0xfffbfff4, - 0x04040000, 0x04040400, 0x0403fc00, 0x04040004, 0x0403fffc, 0x04040404, 0x0403fbfc, 0x04040c0c, - 0x0403f3f4, 0x04040c00, 0x0403f400, 0x0404000c, 0x0403fff4, 0xfbfc0000, 0xfbfc0400, 0xfbfbfc00, - 0xfbfc0004, 0xfbfbfffc, 0xfbfc0404, 0xfbfbfbfc, 0xfbfc0c0c, 0xfbfbf3f4, 0xfbfc0c00, 0xfbfbf400, - 0xfbfc000c, 0xfbfbfff4, 0x0c0c0000, 0x0c0c0400, 0x0c0bfc00, 0x0c0c0004, 0x0c0bfffc, 0x0c0c0404, - 0x0c0bfbfc, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c0c00, 0x0c0bf400, 0x0c0c000c, 0x0c0bfff4, 0xf3f40000, - 0xf3f40400, 0xf3f3fc00, 0xf3f40004, 0xf3f3fffc, 0xf3f40404, 0xf3f3fbfc, 0xf3f40c0c, 0xf3f3f3f4, - 0xf3f40c00, 0xf3f3f400, 0xf3f4000c, 0xf3f3fff4, 0x0c000000, 0x0c000400, 0x0bfffc00, 0x0c000004, - 0x0bfffffc, 0x0c000404, 0x0bfffbfc, 0x0c000c0c, 0x0bfff3f4, 0x0c000c00, 0x0bfff400, 0x0c00000c, - 0x0bfffff4, 0xf4000000, 0xf4000400, 0xf3fffc00, 0xf4000004, 0xf3fffffc, 0xf4000404, 0xf3fffbfc, - 0xf4000c0c, 0xf3fff3f4, 0xf4000c00, 0xf3fff400, 0xf400000c, 0xf3fffff4, 0x000c0000, 0x000c0400, - 0x000bfc00, 0x000c0004, 0x000bfffc, 0x000c0404, 0x000bfbfc, 0x000c0c0c, 0x000bf3f4, 0x000c0c00, - 0x000bf400, 0x000c000c, 0x000bfff4, 0xfff40000, 0xfff40400, 0xfff3fc00, 0xfff40004, 0xfff3fffc, - 0xfff40404, 0xfff3fbfc, 0xfff40c0c, 0xfff3f3f4, 0xfff40c00, 0xfff3f400, 0xfff4000c, 0xfff3fff4, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, - 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, - 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020606, - 0x0201f9fa, 0x02020c0c, 0x0201f3f4, 0x02021414, 0x0201ebec, 0x02022020, 0x0201dfe0, 0x02022e2e, - 0x0201d1d2, 0xfdfe0000, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0c0c, 0xfdfdf3f4, - 0xfdfe1414, 0xfdfdebec, 0xfdfe2020, 0xfdfddfe0, 0xfdfe2e2e, 0xfdfdd1d2, 0x06060000, 0x06060202, - 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060c0c, 0x0605f3f4, 0x06061414, 0x0605ebec, 0x06062020, - 0x0605dfe0, 0x06062e2e, 0x0605d1d2, 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, - 0xf9fa0c0c, 0xf9f9f3f4, 0xf9fa1414, 0xf9f9ebec, 0xf9fa2020, 0xf9f9dfe0, 0xf9fa2e2e, 0xf9f9d1d2, - 0x0c0c0000, 0x0c0c0202, 0x0c0bfdfe, 0x0c0c0606, 0x0c0bf9fa, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c1414, - 0x0c0bebec, 0x0c0c2020, 0x0c0bdfe0, 0x0c0c2e2e, 0x0c0bd1d2, 0xf3f40000, 0xf3f40202, 0xf3f3fdfe, - 0xf3f40606, 0xf3f3f9fa, 0xf3f40c0c, 0xf3f3f3f4, 0xf3f41414, 0xf3f3ebec, 0xf3f42020, 0xf3f3dfe0, - 0xf3f42e2e, 0xf3f3d1d2, 0x14140000, 0x14140202, 0x1413fdfe, 0x14140606, 0x1413f9fa, 0x14140c0c, - 0x1413f3f4, 0x14141414, 0x1413ebec, 0x14142020, 0x1413dfe0, 0x14142e2e, 0x1413d1d2, 0xebec0000, - 0xebec0202, 0xebebfdfe, 0xebec0606, 0xebebf9fa, 0xebec0c0c, 0xebebf3f4, 0xebec1414, 0xebebebec, - 0xebec2020, 0xebebdfe0, 0xebec2e2e, 0xebebd1d2, 0x20200000, 0x20200202, 0x201ffdfe, 0x20200606, - 0x201ff9fa, 0x20200c0c, 0x201ff3f4, 0x20201414, 0x201febec, 0x20202020, 0x201fdfe0, 0x20202e2e, - 0x201fd1d2, 0xdfe00000, 0xdfe00202, 0xdfdffdfe, 0xdfe00606, 0xdfdff9fa, 0xdfe00c0c, 0xdfdff3f4, - 0xdfe01414, 0xdfdfebec, 0xdfe02020, 0xdfdfdfe0, 0xdfe02e2e, 0xdfdfd1d2, 0x2e2e0000, 0x2e2e0202, - 0x2e2dfdfe, 0x2e2e0606, 0x2e2df9fa, 0x2e2e0c0c, 0x2e2df3f4, 0x2e2e1414, 0x2e2debec, 0x2e2e2020, - 0x2e2ddfe0, 0x2e2e2e2e, 0x2e2dd1d2, 0xd1d20000, 0xd1d20202, 0xd1d1fdfe, 0xd1d20606, 0xd1d1f9fa, - 0xd1d20c0c, 0xd1d1f3f4, 0xd1d21414, 0xd1d1ebec, 0xd1d22020, 0xd1d1dfe0, 0xd1d22e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, - 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, - 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020606, - 0x0201f9fa, 0x02020c0c, 0x0201f3f4, 0x02021414, 0x0201ebec, 0x02022020, 0x0201dfe0, 0x02022e2e, - 0x0201d1d2, 0xfdfe0000, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0c0c, 0xfdfdf3f4, - 0xfdfe1414, 0xfdfdebec, 0xfdfe2020, 0xfdfddfe0, 0xfdfe2e2e, 0xfdfdd1d2, 0x06060000, 0x06060202, - 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060c0c, 0x0605f3f4, 0x06061414, 0x0605ebec, 0x06062020, - 0x0605dfe0, 0x06062e2e, 0x0605d1d2, 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, - 0xf9fa0c0c, 0xf9f9f3f4, 0xf9fa1414, 0xf9f9ebec, 0xf9fa2020, 0xf9f9dfe0, 0xf9fa2e2e, 0xf9f9d1d2, - 0x0c0c0000, 0x0c0c0202, 0x0c0bfdfe, 0x0c0c0606, 0x0c0bf9fa, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c1414, - 0x0c0bebec, 0x0c0c2020, 0x0c0bdfe0, 0x0c0c2e2e, 0x0c0bd1d2, 0xf3f40000, 0xf3f40202, 0xf3f3fdfe, - 0xf3f40606, 0xf3f3f9fa, 0xf3f40c0c, 0xf3f3f3f4, 0xf3f41414, 0xf3f3ebec, 0xf3f42020, 0xf3f3dfe0, - 0xf3f42e2e, 0xf3f3d1d2, 0x14140000, 0x14140202, 0x1413fdfe, 0x14140606, 0x1413f9fa, 0x14140c0c, - 0x1413f3f4, 0x14141414, 0x1413ebec, 0x14142020, 0x1413dfe0, 0x14142e2e, 0x1413d1d2, 0xebec0000, - 0xebec0202, 0xebebfdfe, 0xebec0606, 0xebebf9fa, 0xebec0c0c, 0xebebf3f4, 0xebec1414, 0xebebebec, - 0xebec2020, 0xebebdfe0, 0xebec2e2e, 0xebebd1d2, 0x20200000, 0x20200202, 0x201ffdfe, 0x20200606, - 0x201ff9fa, 0x20200c0c, 0x201ff3f4, 0x20201414, 0x201febec, 0x20202020, 0x201fdfe0, 0x20202e2e, - 0x201fd1d2, 0xdfe00000, 0xdfe00202, 0xdfdffdfe, 0xdfe00606, 0xdfdff9fa, 0xdfe00c0c, 0xdfdff3f4, - 0xdfe01414, 0xdfdfebec, 0xdfe02020, 0xdfdfdfe0, 0xdfe02e2e, 0xdfdfd1d2, 0x2e2e0000, 0x2e2e0202, - 0x2e2dfdfe, 0x2e2e0606, 0x2e2df9fa, 0x2e2e0c0c, 0x2e2df3f4, 0x2e2e1414, 0x2e2debec, 0x2e2e2020, - 0x2e2ddfe0, 0x2e2e2e2e, 0x2e2dd1d2, 0xd1d20000, 0xd1d20202, 0xd1d1fdfe, 0xd1d20606, 0xd1d1f9fa, - 0xd1d20c0c, 0xd1d1f3f4, 0xd1d21414, 0xd1d1ebec, 0xd1d22020, 0xd1d1dfe0, 0xd1d22e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, - 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, - 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020606, - 0x0201f9fa, 0x02020c0c, 0x0201f3f4, 0x02021414, 0x0201ebec, 0x02022020, 0x0201dfe0, 0x02022e2e, - 0x0201d1d2, 0xfdfe0000, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0c0c, 0xfdfdf3f4, - 0xfdfe1414, 0xfdfdebec, 0xfdfe2020, 0xfdfddfe0, 0xfdfe2e2e, 0xfdfdd1d2, 0x06060000, 0x06060202, - 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060c0c, 0x0605f3f4, 0x06061414, 0x0605ebec, 0x06062020, - 0x0605dfe0, 0x06062e2e, 0x0605d1d2, 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, - 0xf9fa0c0c, 0xf9f9f3f4, 0xf9fa1414, 0xf9f9ebec, 0xf9fa2020, 0xf9f9dfe0, 0xf9fa2e2e, 0xf9f9d1d2, - 0x0c0c0000, 0x0c0c0202, 0x0c0bfdfe, 0x0c0c0606, 0x0c0bf9fa, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c1414, - 0x0c0bebec, 0x0c0c2020, 0x0c0bdfe0, 0x0c0c2e2e, 0x0c0bd1d2, 0xf3f40000, 0xf3f40202, 0xf3f3fdfe, - 0xf3f40606, 0xf3f3f9fa, 0xf3f40c0c, 0xf3f3f3f4, 0xf3f41414, 0xf3f3ebec, 0xf3f42020, 0xf3f3dfe0, - 0xf3f42e2e, 0xf3f3d1d2, 0x14140000, 0x14140202, 0x1413fdfe, 0x14140606, 0x1413f9fa, 0x14140c0c, - 0x1413f3f4, 0x14141414, 0x1413ebec, 0x14142020, 0x1413dfe0, 0x14142e2e, 0x1413d1d2, 0xebec0000, - 0xebec0202, 0xebebfdfe, 0xebec0606, 0xebebf9fa, 0xebec0c0c, 0xebebf3f4, 0xebec1414, 0xebebebec, - 0xebec2020, 0xebebdfe0, 0xebec2e2e, 0xebebd1d2, 0x20200000, 0x20200202, 0x201ffdfe, 0x20200606, - 0x201ff9fa, 0x20200c0c, 0x201ff3f4, 0x20201414, 0x201febec, 0x20202020, 0x201fdfe0, 0x20202e2e, - 0x201fd1d2, 0xdfe00000, 0xdfe00202, 0xdfdffdfe, 0xdfe00606, 0xdfdff9fa, 0xdfe00c0c, 0xdfdff3f4, - 0xdfe01414, 0xdfdfebec, 0xdfe02020, 0xdfdfdfe0, 0xdfe02e2e, 0xdfdfd1d2, 0x2e2e0000, 0x2e2e0202, - 0x2e2dfdfe, 0x2e2e0606, 0x2e2df9fa, 0x2e2e0c0c, 0x2e2df3f4, 0x2e2e1414, 0x2e2debec, 0x2e2e2020, - 0x2e2ddfe0, 0x2e2e2e2e, 0x2e2dd1d2, 0xd1d20000, 0xd1d20202, 0xd1d1fdfe, 0xd1d20606, 0xd1d1f9fa, - 0xd1d20c0c, 0xd1d1f3f4, 0xd1d21414, 0xd1d1ebec, 0xd1d22020, 0xd1d1dfe0, 0xd1d22e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, - 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, - 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020606, - 0x0201f9fa, 0x02020c0c, 0x0201f3f4, 0x02021414, 0x0201ebec, 0x02022020, 0x0201dfe0, 0x02022e2e, - 0x0201d1d2, 0xfdfe0000, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0c0c, 0xfdfdf3f4, - 0xfdfe1414, 0xfdfdebec, 0xfdfe2020, 0xfdfddfe0, 0xfdfe2e2e, 0xfdfdd1d2, 0x06060000, 0x06060202, - 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060c0c, 0x0605f3f4, 0x06061414, 0x0605ebec, 0x06062020, - 0x0605dfe0, 0x06062e2e, 0x0605d1d2, 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, - 0xf9fa0c0c, 0xf9f9f3f4, 0xf9fa1414, 0xf9f9ebec, 0xf9fa2020, 0xf9f9dfe0, 0xf9fa2e2e, 0xf9f9d1d2, - 0x0c0c0000, 0x0c0c0202, 0x0c0bfdfe, 0x0c0c0606, 0x0c0bf9fa, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c1414, - 0x0c0bebec, 0x0c0c2020, 0x0c0bdfe0, 0x0c0c2e2e, 0x0c0bd1d2, 0xf3f40000, 0xf3f40202, 0xf3f3fdfe, - 0xf3f40606, 0xf3f3f9fa, 0xf3f40c0c, 0xf3f3f3f4, 0xf3f41414, 0xf3f3ebec, 0xf3f42020, 0xf3f3dfe0, - 0xf3f42e2e, 0xf3f3d1d2, 0x14140000, 0x14140202, 0x1413fdfe, 0x14140606, 0x1413f9fa, 0x14140c0c, - 0x1413f3f4, 0x14141414, 0x1413ebec, 0x14142020, 0x1413dfe0, 0x14142e2e, 0x1413d1d2, 0xebec0000, - 0xebec0202, 0xebebfdfe, 0xebec0606, 0xebebf9fa, 0xebec0c0c, 0xebebf3f4, 0xebec1414, 0xebebebec, - 0xebec2020, 0xebebdfe0, 0xebec2e2e, 0xebebd1d2, 0x20200000, 0x20200202, 0x201ffdfe, 0x20200606, - 0x201ff9fa, 0x20200c0c, 0x201ff3f4, 0x20201414, 0x201febec, 0x20202020, 0x201fdfe0, 0x20202e2e, - 0x201fd1d2, 0xdfe00000, 0xdfe00202, 0xdfdffdfe, 0xdfe00606, 0xdfdff9fa, 0xdfe00c0c, 0xdfdff3f4, - 0xdfe01414, 0xdfdfebec, 0xdfe02020, 0xdfdfdfe0, 0xdfe02e2e, 0xdfdfd1d2, 0x2e2e0000, 0x2e2e0202, - 0x2e2dfdfe, 0x2e2e0606, 0x2e2df9fa, 0x2e2e0c0c, 0x2e2df3f4, 0x2e2e1414, 0x2e2debec, 0x2e2e2020, - 0x2e2ddfe0, 0x2e2e2e2e, 0x2e2dd1d2, 0xd1d20000, 0xd1d20202, 0xd1d1fdfe, 0xd1d20606, 0xd1d1f9fa, - 0xd1d20c0c, 0xd1d1f3f4, 0xd1d21414, 0xd1d1ebec, 0xd1d22020, 0xd1d1dfe0, 0xd1d22e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 -}; - - -static const uint32_t correctionloworder[] = { - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x04040404, - 0xfbfbfbfc, 0x05050101, 0xfafafeff, 0x01010505, 0xfefefafb, 0x0403fbfc, 0xfbfc0404, 0x0605fdfe, - 0xf9fa0202, 0xfdfe0606, 0x0201f9fa, 0x09090404, 0xf6f6fbfc, 0x04040909, 0xfbfbf6f7, 0x09090909, - 0xf6f6f6f7, 0x0a0a0101, 0xf5f5feff, 0x01010a0a, 0xfefef5f6, 0x0807fafb, 0xf7f80505, 0xfafb0808, - 0x0504f7f8, 0x0f0f0909, 0xf0f0f6f7, 0x09090f0f, 0xf6f6f0f1, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, - 0x0302f3f4, 0x10100404, 0xefeffbfc, 0x04041010, 0xfbfbeff0, 0x10101010, 0xefefeff0, 0x12120000, - 0xedee0000, 0x00001212, 0xffffedee, 0x0c0bf3f4, 0xf3f40c0c, 0x100ff6f7, 0xeff00909, 0xf6f71010, - 0x0908eff0, 0x1b1b0b0b, 0xe4e4f4f5, 0x0b0b1b1b, 0xf4f4e4e5, 0x1c1c1313, 0xe3e3eced, 0x13131c1c, - 0xecece3e4, 0x1615f9fa, 0xe9ea0606, 0xf9fa1616, 0x0605e9ea, 0x1d1d0404, 0xe2e2fbfc, 0x04041d1d, - 0xfbfbe2e3, 0x1e1e1e1e, 0xe1e1e1e2, 0x2120fdfe, 0xdedf0202, 0xfdfe2121, 0x0201dedf, 0x1716edee, - 0xe8e91212, 0xedee1717, 0x1211e8e9, 0x1e1df0f1, 0xe1e20f0f, 0xf0f11e1e, 0x0f0ee1e2, 0x2e2e1616, - 0xd1d1e9ea, 0x16162e2e, 0xe9e9d1d2, 0x2f2f0d0d, 0xd0d0f2f3, 0x0d0d2f2f, 0xf2f2d0d1, 0x31312323, - 0xcecedcdd, 0x23233131, 0xdcdccecf, 0x2928f4f5, 0xd6d70b0b, 0xf4f52929, 0x0b0ad6d7, 0x33330404, - 0xccccfbfc, 0x04043333, 0xfbfbcccd, 0x36363636, 0xc9c9c9ca, 0x2221ddde, 0xddde2222, 0x2a29e2e3, - 0xd5d61d1d, 0xe2e32a2a, 0x1d1cd5d6, 0x3c3bf9fa, 0xc3c40606, 0xf9fa3c3c, 0x0605c3c4, 0x4c4c1b1b, - 0xb3b3e4e5, 0x1b1b4c4c, 0xe4e4b3b4, 0x4d4d2b2b, 0xb2b2d4d5, 0x2b2b4d4d, 0xd4d4b2b3, 0x3736e7e8, - 0xc8c91818, 0xe7e83737, 0x1817c8c9, 0x4f4f0e0e, 0xb0b0f1f2, 0x0e0e4f4f, 0xf1f1b0b1, 0x53533f3f, - 0xacacc0c1, 0x3f3f5353, 0xc0c0acad, 0x4a49ebec, 0xb5b61414, 0xebec4a4a, 0x1413b5b6, 0x58580202, - 0xa7a7fdfe, 0x02025858, 0xfdfda7a8, 0x5d5d5d5d, 0xa2a2a2a3, 0x3d3ccbcc, 0xc2c33434, 0xcbcc3d3d, - 0x3433c2c3, 0x78783434, 0x8787cbcc, 0x34347878, 0xcbcb8788, 0x4b4ad2d3, 0xb4b52d2d, 0xd2d34b4b, - 0x2d2cb4b5, 0x7d7d4b4b, 0x8282b4b5, 0x4b4b7d7d, 0xb4b48283, 0x7a7a2121, 0x8585dedf, 0x21217a7a, - 0xdede8586, 0x6766f2f3, 0x98990d0d, 0xf2f36767, 0x0d0c9899, 0x605fd7d8, 0x9fa02828, 0xd7d86060, - 0x28279fa0, 0x7f7eddde, 0x80812222, 0xddde7f7f, 0x22218081, 0x5958a6a7, 0xa6a75959, 0x6968b1b2, - 0x96974e4e, 0xb1b26969, 0x4e4d9697, 0x0c0c0c0c, 0xf3f3f3f4, 0x17171717, 0xe8e8e8e9, 0x2a2a2a2a, - 0xd5d5d5d6, 0x49494949, 0xb6b6b6b7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0x0302feff, 0x0302feff, 0x0302feff, 0x0302feff, 0x0302feff, 0x0302feff, 0x0302feff, 0xfcfd0101, - 0xfcfd0101, 0xfcfd0101, 0xfcfd0101, 0xfcfd0101, 0xfcfd0101, 0xfcfd0101, 0xfeff0303, 0xfeff0303, - 0xfeff0303, 0xfeff0303, 0xfeff0303, 0xfeff0303, 0xfeff0303, 0x0100fcfd, 0x0100fcfd, 0x0100fcfd, - 0x0100fcfd, 0x0100fcfd, 0x0100fcfd, 0x0100fcfd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, - 0xf8f8f8f9, 0x08080202, 0xf7f7fdfe, 0x02020808, 0xfdfdf7f8, 0x0908fdfe, 0xf6f70202, 0xfdfe0909, - 0x0201f6f7, 0x0605f9fa, 0xf9fa0606, 0x0d0d0606, 0xf2f2f9fa, 0x06060d0d, 0xf9f9f2f3, 0x0d0d0d0d, - 0xf2f2f2f3, 0x0e0e0101, 0xf1f1feff, 0x01010e0e, 0xfefef1f2, 0x0c0bf7f8, 0xf3f40808, 0xf7f80c0c, - 0x0807f3f4, 0x17170e0e, 0xe8e8f1f2, 0x0e0e1717, 0xf1f1e8e9, 0x1211fafb, 0xedee0505, 0xfafb1212, - 0x0504edee, 0x18180606, 0xe7e7f9fa, 0x06061818, 0xf9f9e7e8, 0x18181818, 0xe7e7e7e8, 0x1b1afeff, - 0xe4e50101, 0xfeff1b1b, 0x0100e4e5, 0x1110eeef, 0xeeef1111, 0x1716f2f3, 0xe8e90d0d, 0xf2f31717, - 0x0d0ce8e9, 0x28281010, 0xd7d7eff0, 0x10102828, 0xefefd7d8, 0x29291c1c, 0xd6d6e3e4, 0x1c1c2929, - 0xe3e3d6d7, 0x2120f6f7, 0xdedf0909, 0xf6f72121, 0x0908dedf, 0x2b2b0606, 0xd4d4f9fa, 0x06062b2b, - 0xf9f9d4d5, 0x2e2e2e2e, 0xd1d1d1d2, 0x3231fbfc, 0xcdce0404, 0xfbfc3232, 0x0403cdce, 0x2221e4e5, - 0xddde1b1b, 0xe4e52222, 0x1b1addde, 0x2d2ce9ea, 0xd2d31616, 0xe9ea2d2d, 0x1615d2d3, 0x45452222, - 0xbabaddde, 0x22224545, 0xddddbabb, 0x46461313, 0xb9b9eced, 0x13134646, 0xececb9ba, 0x49493535, - 0xb6b6cacb, 0x35354949, 0xcacab6b7, 0x3e3deeef, 0xc1c21111, 0xeeef3e3e, 0x1110c1c2, 0x4d4d0505, - 0xb2b2fafb, 0x05054d4d, 0xfafab2b3, 0x52525252, 0xadadadae, 0x3332cccd, 0xcccd3333, 0x403fd4d5, - 0xbfc02b2b, 0xd4d54040, 0x2b2abfc0, 0x5a59f5f6, 0xa5a60a0a, 0xf5f65a5a, 0x0a09a5a6, 0x72722929, - 0x8d8dd6d7, 0x29297272, 0xd6d68d8e, 0x74744040, 0x8b8bbfc0, 0x40407474, 0xbfbf8b8c, 0x5251dadb, - 0xadae2525, 0xdadb5252, 0x2524adae, 0x77771616, 0x8888e9ea, 0x16167777, 0xe9e98889, 0x7c7c5f5f, - 0x8383a0a1, 0x5f5f7c7c, 0xa0a08384, 0x6f6ee1e2, 0x90911e1e, 0xe1e26f6f, 0x1e1d9091, 0x5c5bb1b2, - 0xa3a44e4e, 0xb1b25c5c, 0x4e4da3a4, 0x7170bbbc, 0x8e8f4444, 0xbbbc7171, 0x44438e8f, 0x12121212, - 0xedededee, 0x22222222, 0xddddddde, 0x3f3f3f3f, 0xc0c0c0c1, 0x6d6d6d6d, 0x92929293, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, - 0x03030303, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, - 0xfcfcfcfd, 0xfcfcfcfd, 0x0403feff, 0x0403feff, 0x0403feff, 0x0403feff, 0x0403feff, 0x0403feff, - 0x0403feff, 0x0403feff, 0x0403feff, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, - 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfeff0404, 0xfeff0404, 0xfeff0404, 0xfeff0404, - 0xfeff0404, 0xfeff0404, 0xfeff0404, 0xfeff0404, 0xfeff0404, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, - 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x07070707, 0x07070707, - 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0xf8f8f8f9, - 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, - 0xf5f5fcfd, 0x03030a0a, 0xfcfcf5f6, 0x09090909, 0xf6f6f6f7, 0x0706f8f9, 0xf8f90707, 0x0c0bfcfd, - 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x11110808, 0xeeeef7f8, 0x08081111, 0xf7f7eeef, 0x11111111, - 0xeeeeeeef, 0x13130101, 0xececfeff, 0x01011313, 0xfefeeced, 0x100ff4f5, 0xeff00b0b, 0xf4f51010, - 0x0b0aeff0, 0x1716f9fa, 0xe8e90606, 0xf9fa1717, 0x0605e8e9, 0x1f1f1212, 0xe0e0edee, 0x12121f1f, - 0xedede0e1, 0x20200808, 0xdfdff7f8, 0x08082020, 0xf7f7dfe0, 0x21212121, 0xdedededf, 0x2423feff, - 0xdbdc0101, 0xfeff2424, 0x0100dbdc, 0x1716e8e9, 0xe8e91717, 0x1f1eeeef, 0xe0e11111, 0xeeef1f1f, - 0x1110e0e1, 0x36361515, 0xc9c9eaeb, 0x15153636, 0xeaeac9ca, 0x37372525, 0xc8c8dadb, 0x25253737, - 0xdadac8c9, 0x2c2bf3f4, 0xd3d40c0c, 0xf3f42c2c, 0x0c0bd3d4, 0x39390808, 0xc6c6f7f8, 0x08083939, - 0xf7f7c6c7, 0x3d3d3d3d, 0xc2c2c2c3, 0x4241fafb, 0xbdbe0505, 0xfafb4242, 0x0504bdbe, 0x2d2cdbdc, - 0xd2d32424, 0xdbdc2d2d, 0x2423d2d3, 0x3c3be2e3, 0xc3c41d1d, 0xe2e33c3c, 0x1d1cc3c4, 0x5c5c2d2d, - 0xa3a3d2d3, 0x2d2d5c5c, 0xd2d2a3a4, 0x5d5d1919, 0xa2a2e6e7, 0x19195d5d, 0xe6e6a2a3, 0x61614747, - 0x9e9eb8b9, 0x47476161, 0xb8b89e9f, 0x5352e9ea, 0xacad1616, 0xe9ea5353, 0x1615acad, 0x66660707, - 0x9999f8f9, 0x07076666, 0xf8f8999a, 0x6d6d6d6d, 0x92929293, 0x4443bbbc, 0xbbbc4444, 0x5554c6c7, - 0xaaab3939, 0xc6c75555, 0x3938aaab, 0x7877f2f3, 0x87880d0d, 0xf2f37878, 0x0d0c8788, 0x6e6dcecf, - 0x91923131, 0xcecf6e6e, 0x31309192, 0x7b7a9798, 0x84856868, 0x97987b7b, 0x68678485, 0x18181818, - 0xe7e7e7e8, 0x2e2e2e2e, 0xd1d1d1d2, 0x54545454, 0xabababac, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040404, - 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, - 0x04040404, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, - 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, - 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, 0xfafb0101, 0xfafb0101, 0xfafb0101, - 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfeff0505, - 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, - 0xfeff0505, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, - 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, - 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, - 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0x03030a0a, - 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, - 0x03030a0a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, - 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x03030d0d, 0xfcfcf2f3, 0x0908f6f7, 0xf6f70909, 0x0f0efbfc, - 0xf0f10404, 0xfbfc0f0f, 0x0403f0f1, 0x16160b0b, 0xe9e9f4f5, 0x0b0b1616, 0xf4f4e9ea, 0x15151515, - 0xeaeaeaeb, 0x18180202, 0xe7e7fdfe, 0x02021818, 0xfdfde7e8, 0x1413f1f2, 0xebec0e0e, 0xf1f21414, - 0x0e0debec, 0x26261717, 0xd9d9e8e9, 0x17172626, 0xe8e8d9da, 0x1d1cf7f8, 0xe2e30808, 0xf7f81d1d, - 0x0807e2e3, 0x27270b0b, 0xd8d8f4f5, 0x0b0b2727, 0xf4f4d8d9, 0x29292929, 0xd6d6d6d7, 0x2d2cfeff, - 0xd2d30101, 0xfeff2d2d, 0x0100d2d3, 0x1d1ce2e3, 0xe2e31d1d, 0x2726e9ea, 0xd8d91616, 0xe9ea2727, - 0x1615d8d9, 0x43431b1b, 0xbcbce4e5, 0x1b1b4343, 0xe4e4bcbd, 0x45452f2f, 0xbabad0d1, 0x2f2f4545, - 0xd0d0babb, 0x3837f0f1, 0xc7c80f0f, 0xf0f13838, 0x0f0ec7c8, 0x47470b0b, 0xb8b8f4f5, 0x0b0b4747, - 0xf4f4b8b9, 0x4c4c4c4c, 0xb3b3b3b4, 0x5352f9fa, 0xacad0606, 0xf9fa5353, 0x0605acad, 0x3938d2d3, - 0xc6c72d2d, 0xd2d33939, 0x2d2cc6c7, 0x4b4adbdc, 0xb4b52424, 0xdbdc4b4b, 0x2423b4b5, 0x73733838, - 0x8c8cc7c8, 0x38387373, 0xc7c78c8d, 0x75751f1f, 0x8a8ae0e1, 0x1f1f7575, 0xe0e08a8b, 0x7a7a5858, - 0x8585a7a8, 0x58587a7a, 0xa7a78586, 0x6867e3e4, 0x97981c1c, 0xe3e46868, 0x1c1b9798, 0x5554aaab, - 0xaaab5555, 0x6a69b7b8, 0x95964848, 0xb7b86a6a, 0x48479596, 0x1e1e1e1e, 0xe1e1e1e2, 0x3a3a3a3a, - 0xc5c5c5c6, 0x69696969, 0x96969697, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x05050505, 0x05050505, - 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, - 0x05050505, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, - 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, - 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0xf8f90202, - 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, - 0xf8f90202, 0xf8f90202, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, - 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, - 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, - 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, - 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, - 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0x0d0d0303, 0x0d0d0303, - 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, - 0x0d0d0303, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, - 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, - 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0xfbfbf0f1, 0x0b0af4f5, 0xf4f50b0b, 0x1211fafb, - 0xedee0505, 0xfafb1212, 0x0504edee, 0x1a1a0d0d, 0xe5e5f2f3, 0x0d0d1a1a, 0xf2f2e5e6, 0x1a1a1a1a, - 0xe5e5e5e6, 0x1d1d0202, 0xe2e2fdfe, 0x02021d1d, 0xfdfde2e3, 0x1817eff0, 0xe7e81010, 0xeff01818, - 0x100fe7e8, 0x2e2e1c1c, 0xd1d1e3e4, 0x1c1c2e2e, 0xe3e3d1d2, 0x2322f6f7, 0xdcdd0909, 0xf6f72323, - 0x0908dcdd, 0x2f2f0d0d, 0xd0d0f2f3, 0x0d0d2f2f, 0xf2f2d0d1, 0x31313131, 0xcecececf, 0x3635feff, - 0xc9ca0101, 0xfeff3636, 0x0100c9ca, 0x2322dcdd, 0xdcdd2323, 0x2f2ee5e6, 0xd0d11a1a, 0xe5e62f2f, - 0x1a19d0d1, 0x51512020, 0xaeaedfe0, 0x20205151, 0xdfdfaeaf, 0x53533838, 0xacacc7c8, 0x38385353, - 0xc7c7acad, 0x4342edee, 0xbcbd1212, 0xedee4343, 0x1211bcbd, 0x56560d0d, 0xa9a9f2f3, 0x0d0d5656, - 0xf2f2a9aa, 0x5b5b5b5b, 0xa4a4a4a5, 0x6362f8f9, 0x9c9d0707, 0xf8f96363, 0x07069c9d, 0x4443c9ca, - 0xbbbc3636, 0xc9ca4444, 0x3635bbbc, 0x5a59d3d4, 0xa5a62c2c, 0xd3d45a5a, 0x2c2ba5a6, 0x7c7bdedf, - 0x83842121, 0xdedf7c7c, 0x21208384, 0x67669899, 0x98996767, 0x7f7ea9aa, 0x80815656, 0xa9aa7f7f, - 0x56558081, 0x25252525, 0xdadadadb, 0x45454545, 0xbabababb, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, - 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0xf7f80202, 0xf7f80202, 0xf7f80202, - 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, - 0xf7f80202, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, - 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, - 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, - 0x0201f7f8, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, - 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, - 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, - 0xf2f2f2f3, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, - 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, - 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, - 0xf0f0fbfc, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, - 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, - 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0xfafaedee, 0x0d0cf2f3, 0xf2f30d0d, 0x1514f9fa, - 0xeaeb0606, 0xf9fa1515, 0x0605eaeb, 0x1e1e0f0f, 0xe1e1f0f1, 0x0f0f1e1e, 0xf0f0e1e2, 0x1e1e1e1e, - 0xe1e1e1e2, 0x22220202, 0xddddfdfe, 0x02022222, 0xfdfdddde, 0x1c1beced, 0xe3e41313, 0xeced1c1c, - 0x1312e3e4, 0x36362020, 0xc9c9dfe0, 0x20203636, 0xdfdfc9ca, 0x2928f4f5, 0xd6d70b0b, 0xf4f52929, - 0x0b0ad6d7, 0x37370f0f, 0xc8c8f0f1, 0x0f0f3737, 0xf0f0c8c9, 0x39393939, 0xc6c6c6c7, 0x3f3efeff, - 0xc0c10101, 0xfeff3f3f, 0x0100c0c1, 0x2827d7d8, 0xd7d82828, 0x3736e1e2, 0xc8c91e1e, 0xe1e23737, - 0x1e1dc8c9, 0x5e5e2525, 0xa1a1dadb, 0x25255e5e, 0xdadaa1a2, 0x60604141, 0x9f9fbebf, 0x41416060, - 0xbebe9fa0, 0x4e4deaeb, 0xb1b21515, 0xeaeb4e4e, 0x1514b1b2, 0x64640f0f, 0x9b9bf0f1, 0x0f0f6464, - 0xf0f09b9c, 0x6a6a6a6a, 0x95959596, 0x7473f7f8, 0x8b8c0808, 0xf7f87474, 0x08078b8c, 0x4f4ec0c1, - 0xb0b13f3f, 0xc0c14f4f, 0x3f3eb0b1, 0x6968cccd, 0x96973333, 0xcccd6969, 0x33329697, 0x78778788, - 0x87887878, 0x2b2b2b2b, 0xd4d4d4d5, 0x50505050, 0xafafafb0, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, - 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, - 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, - 0xf8f8f8f9, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, - 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0xf5f60303, 0xf5f60303, 0xf5f60303, - 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, - 0xf5f60303, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, - 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, - 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, - 0x0302f5f6, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, - 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0xefefeff0, 0xefefeff0, 0xefefeff0, - 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, - 0xefefeff0, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, - 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0xededfafb, 0xededfafb, 0xededfafb, - 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, - 0xededfafb, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, - 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, - 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0xfafaebec, 0x0f0ef0f1, 0xf0f10f0f, 0x1817f8f9, - 0xe7e80707, 0xf8f91818, 0x0706e7e8, 0x23231111, 0xdcdceeef, 0x11112323, 0xeeeedcdd, 0x22222222, - 0xddddddde, 0x26260303, 0xd9d9fcfd, 0x03032626, 0xfcfcd9da, 0x201fe9ea, 0xdfe01616, 0xe9ea2020, - 0x1615dfe0, 0x3d3d2525, 0xc2c2dadb, 0x25253d3d, 0xdadac2c3, 0x2f2ef2f3, 0xd0d10d0d, 0xf2f32f2f, - 0x0d0cd0d1, 0x3f3f1111, 0xc0c0eeef, 0x11113f3f, 0xeeeec0c1, 0x41414141, 0xbebebebf, 0x4847feff, - 0xb7b80101, 0xfeff4848, 0x0100b7b8, 0x2e2dd1d2, 0xd1d22e2e, 0x3f3edcdd, 0xc0c12323, 0xdcdd3f3f, - 0x2322c0c1, 0x6b6b2b2b, 0x9494d4d5, 0x2b2b6b6b, 0xd4d49495, 0x6e6e4b4b, 0x9191b4b5, 0x4b4b6e6e, - 0xb4b49192, 0x5958e7e8, 0xa6a71818, 0xe7e85959, 0x1817a6a7, 0x72721111, 0x8d8deeef, 0x11117272, - 0xeeee8d8e, 0x79797979, 0x86868687, 0x5b5ab7b8, 0xa4a54848, 0xb7b85b5b, 0x4847a4a5, 0x7877c5c6, - 0x87883a3a, 0xc5c67878, 0x3a398788, 0x31313131, 0xcecececf, 0x5c5c5c5c, 0xa3a3a3a4, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, - 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0xf7f7f7f8, - 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, - 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, - 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0xf4f50303, - 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, - 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, - 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0x0302f4f5, - 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, - 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, - 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0xedededee, - 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, - 0xedededee, 0xedededee, 0xedededee, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, - 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0xebebfafb, - 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, - 0xebebfafb, 0xebebfafb, 0xebebfafb, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, - 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, - 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x1110eeef, 0xeeef1111, 0x1b1af8f9, - 0xe4e50707, 0xf8f91b1b, 0x0706e4e5, 0x27271313, 0xd8d8eced, 0x13132727, 0xececd8d9, 0x27272727, - 0xd8d8d8d9, 0x2b2b0303, 0xd4d4fcfd, 0x03032b2b, 0xfcfcd4d5, 0x2423e7e8, 0xdbdc1818, 0xe7e82424, - 0x1817dbdc, 0x45452a2a, 0xbabad5d6, 0x2a2a4545, 0xd5d5babb, 0x3534f1f2, 0xcacb0e0e, 0xf1f23535, - 0x0e0dcacb, 0x47471313, 0xb8b8eced, 0x13134747, 0xececb8b9, 0x49494949, 0xb6b6b6b7, 0x504ffdfe, - 0xafb00202, 0xfdfe5050, 0x0201afb0, 0x3433cbcc, 0xcbcc3434, 0x4645d8d9, 0xb9ba2727, 0xd8d94646, - 0x2726b9ba, 0x79793030, 0x8686cfd0, 0x30307979, 0xcfcf8687, 0x7c7c5454, 0x8383abac, 0x54547c7c, - 0xabab8384, 0x6463e4e5, 0x9b9c1b1b, 0xe4e56464, 0x1b1a9b9c, 0x6665aeaf, 0x999a5151, 0xaeaf6666, - 0x5150999a, 0x37373737, 0xc8c8c8c9, 0x68686868, 0x97979798, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, - 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0xf6f6f6f7, - 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, - 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, - 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, - 0x0c0bfcfd, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, - 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xfcfd0c0c, 0xfcfd0c0c, - 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, - 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, - 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, - 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, - 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, 0xebebebec, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, - 0xebebebec, 0xebebebec, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, - 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0xe8e8f9fa, - 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, - 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0x06061717, 0x06061717, 0x06061717, 0x06061717, - 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, - 0x06061717, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, - 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, - 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x0403fbfc, 0xfbfc0404, 0x0605fdfe, - 0xf9fa0202, 0xfdfe0606, 0x0201f9fa, 0x08080404, 0xf7f7fbfc, 0x04040808, 0xfbfbf7f8, 0x08080808, - 0xf7f7f7f8, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x0807fbfc, 0xf7f80404, 0xfbfc0808, - 0x0403f7f8, 0x0e0e0808, 0xf1f1f7f8, 0x08080e0e, 0xf7f7f1f2, 0x0c0bfdfe, 0xf3f40202, 0xfdfe0c0c, - 0x0201f3f4, 0x10100404, 0xefeffbfc, 0x04041010, 0xfbfbeff0, 0x10101010, 0xefefeff0, 0x12120000, - 0xedee0000, 0x00001212, 0xffffedee, 0x0c0bf3f4, 0xf3f40c0c, 0x100ff7f8, 0xeff00808, 0xf7f81010, - 0x0807eff0, 0x1a1a0a0a, 0xe5e5f5f6, 0x0a0a1a1a, 0xf5f5e5e6, 0x1c1c1212, 0xe3e3edee, 0x12121c1c, - 0xedede3e4, 0x1615f9fa, 0xe9ea0606, 0xf9fa1616, 0x0605e9ea, 0x1c1c0404, 0xe3e3fbfc, 0x04041c1c, - 0xfbfbe3e4, 0x1e1e1e1e, 0xe1e1e1e2, 0x201ffdfe, 0xdfe00202, 0xfdfe2020, 0x0201dfe0, 0x1615edee, - 0xe9ea1212, 0xedee1616, 0x1211e9ea, 0x1e1df1f2, 0xe1e20e0e, 0xf1f21e1e, 0x0e0de1e2, 0x2e2e1616, - 0xd1d1e9ea, 0x16162e2e, 0xe9e9d1d2, 0x2e2e0c0c, 0xd1d1f3f4, 0x0c0c2e2e, 0xf3f3d1d2, 0x30302222, - 0xcfcfddde, 0x22223030, 0xddddcfd0, 0x2827f5f6, 0xd7d80a0a, 0xf5f62828, 0x0a09d7d8, 0x32320404, - 0xcdcdfbfc, 0x04043232, 0xfbfbcdce, 0x36363636, 0xc9c9c9ca, 0x2221ddde, 0xddde2222, 0x2a29e3e4, - 0xd5d61c1c, 0xe3e42a2a, 0x1c1bd5d6, 0x3c3bf9fa, 0xc3c40606, 0xf9fa3c3c, 0x0605c3c4, 0x4c4c1a1a, - 0xb3b3e5e6, 0x1a1a4c4c, 0xe5e5b3b4, 0x4c4c2a2a, 0xb3b3d5d6, 0x2a2a4c4c, 0xd5d5b3b4, 0x3635e7e8, - 0xc9ca1818, 0xe7e83636, 0x1817c9ca, 0x4e4e0e0e, 0xb1b1f1f2, 0x0e0e4e4e, 0xf1f1b1b2, 0x52523e3e, - 0xadadc1c2, 0x3e3e5252, 0xc1c1adae, 0x4a49ebec, 0xb5b61414, 0xebec4a4a, 0x1413b5b6, 0x58580202, - 0xa7a7fdfe, 0x02025858, 0xfdfda7a8, 0x5c5c5c5c, 0xa3a3a3a4, 0x3c3bcbcc, 0xc3c43434, 0xcbcc3c3c, - 0x3433c3c4, 0x76763434, 0x8989cbcc, 0x34347676, 0xcbcb898a, 0x4a49d3d4, 0xb5b62c2c, 0xd3d44a4a, - 0x2c2bb5b6, 0x76764a4a, 0x8989b5b6, 0x4a4a7676, 0xb5b5898a, 0x76762020, 0x8989dfe0, 0x20207676, - 0xdfdf898a, 0x6665f3f4, 0x999a0c0c, 0xf3f46666, 0x0c0b999a, 0x605fd7d8, 0x9fa02828, 0xd7d86060, - 0x28279fa0, 0x7675ddde, 0x898a2222, 0xddde7676, 0x2221898a, 0x5857a7a8, 0xa7a85858, 0x6867b1b2, - 0x97984e4e, 0xb1b26868, 0x4e4d9798, 0x0c0c0c0c, 0xf3f3f3f4, 0x16161616, 0xe9e9e9ea, 0x2a2a2a2a, - 0xd5d5d5d6, 0x48484848, 0xb7b7b7b8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0xfdfe0000, - 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0x00000202, 0x00000202, - 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, - 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, - 0xf9f9f9fa, 0x09090303, 0xf6f6fcfd, 0x03030909, 0xfcfcf6f7, 0x0908fcfd, 0xf6f70303, 0xfcfd0909, - 0x0302f6f7, 0x0605f9fa, 0xf9fa0606, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0xf9f9f3f4, 0x0c0c0c0c, - 0xf3f3f3f4, 0x0f0f0000, 0xf0f10000, 0x00000f0f, 0xfffff0f1, 0x0c0bf6f7, 0xf3f40909, 0xf6f70c0c, - 0x0908f3f4, 0x18180f0f, 0xe7e7f0f1, 0x0f0f1818, 0xf0f0e7e8, 0x1211f9fa, 0xedee0606, 0xf9fa1212, - 0x0605edee, 0x18180606, 0xe7e7f9fa, 0x06061818, 0xf9f9e7e8, 0x18181818, 0xe7e7e7e8, 0x1b1b0000, - 0xe4e50000, 0x00001b1b, 0xffffe4e5, 0x1211edee, 0xedee1212, 0x1817f3f4, 0xe7e80c0c, 0xf3f41818, - 0x0c0be7e8, 0x27270f0f, 0xd8d8f0f1, 0x0f0f2727, 0xf0f0d8d9, 0x2a2a1b1b, 0xd5d5e4e5, 0x1b1b2a2a, - 0xe4e4d5d6, 0x2120f6f7, 0xdedf0909, 0xf6f72121, 0x0908dedf, 0x2a2a0606, 0xd5d5f9fa, 0x06062a2a, - 0xf9f9d5d6, 0x2d2d2d2d, 0xd2d2d2d3, 0x3332fcfd, 0xcccd0303, 0xfcfd3333, 0x0302cccd, 0x2120e4e5, - 0xdedf1b1b, 0xe4e52121, 0x1b1adedf, 0x2d2ceaeb, 0xd2d31515, 0xeaeb2d2d, 0x1514d2d3, 0x45452121, - 0xbabadedf, 0x21214545, 0xdedebabb, 0x45451212, 0xbabaedee, 0x12124545, 0xededbabb, 0x48483636, - 0xb7b7c9ca, 0x36364848, 0xc9c9b7b8, 0x3f3eedee, 0xc0c11212, 0xedee3f3f, 0x1211c0c1, 0x4e4e0606, - 0xb1b1f9fa, 0x06064e4e, 0xf9f9b1b2, 0x51515151, 0xaeaeaeaf, 0x3332cccd, 0xcccd3333, 0x3f3ed5d6, - 0xc0c12a2a, 0xd5d63f3f, 0x2a29c0c1, 0x5a59f6f7, 0xa5a60909, 0xf6f75a5a, 0x0908a5a6, 0x72722a2a, - 0x8d8dd5d6, 0x2a2a7272, 0xd5d58d8e, 0x75753f3f, 0x8a8ac0c1, 0x3f3f7575, 0xc0c08a8b, 0x5150dbdc, - 0xaeaf2424, 0xdbdc5151, 0x2423aeaf, 0x78781515, 0x8787eaeb, 0x15157878, 0xeaea8788, 0x7b7b6060, - 0x84849fa0, 0x60607b7b, 0x9f9f8485, 0x6f6ee1e2, 0x90911e1e, 0xe1e26f6f, 0x1e1d9091, 0x5d5cb1b2, - 0xa2a34e4e, 0xb1b25d5d, 0x4e4da2a3, 0x7271babb, 0x8d8e4545, 0xbabb7272, 0x45448d8e, 0x12121212, - 0xedededee, 0x21212121, 0xdedededf, 0x3f3f3f3f, 0xc0c0c0c1, 0x6c6c6c6c, 0x93939394, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, - 0x03030303, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, - 0xfcfcfcfd, 0xfcfcfcfd, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, - 0x03030000, 0x03030000, 0x03030000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, - 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0x00000303, 0x00000303, 0x00000303, 0x00000303, - 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, - 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, - 0xf7f7fbfc, 0x04040808, 0xfbfbf7f8, 0x08080808, 0xf7f7f7f8, 0x0807f7f8, 0xf7f80808, 0x0c0bfbfc, - 0xf3f40404, 0xfbfc0c0c, 0x0403f3f4, 0x10100808, 0xefeff7f8, 0x08081010, 0xf7f7eff0, 0x10101010, - 0xefefeff0, 0x14140000, 0xebec0000, 0x00001414, 0xffffebec, 0x100ff3f4, 0xeff00c0c, 0xf3f41010, - 0x0c0beff0, 0x1817fbfc, 0xe7e80404, 0xfbfc1818, 0x0403e7e8, 0x20201010, 0xdfdfeff0, 0x10102020, - 0xefefdfe0, 0x20200808, 0xdfdff7f8, 0x08082020, 0xf7f7dfe0, 0x20202020, 0xdfdfdfe0, 0x24240000, - 0xdbdc0000, 0x00002424, 0xffffdbdc, 0x1817e7e8, 0xe7e81818, 0x201feff0, 0xdfe01010, 0xeff02020, - 0x100fdfe0, 0x34341414, 0xcbcbebec, 0x14143434, 0xebebcbcc, 0x38382424, 0xc7c7dbdc, 0x24243838, - 0xdbdbc7c8, 0x2c2bf3f4, 0xd3d40c0c, 0xf3f42c2c, 0x0c0bd3d4, 0x38380808, 0xc7c7f7f8, 0x08083838, - 0xf7f7c7c8, 0x3c3c3c3c, 0xc3c3c3c4, 0x403ffbfc, 0xbfc00404, 0xfbfc4040, 0x0403bfc0, 0x2c2bdbdc, - 0xd3d42424, 0xdbdc2c2c, 0x2423d3d4, 0x3c3be3e4, 0xc3c41c1c, 0xe3e43c3c, 0x1c1bc3c4, 0x5c5c2c2c, - 0xa3a3d3d4, 0x2c2c5c5c, 0xd3d3a3a4, 0x5c5c1818, 0xa3a3e7e8, 0x18185c5c, 0xe7e7a3a4, 0x60604848, - 0x9f9fb7b8, 0x48486060, 0xb7b79fa0, 0x5453ebec, 0xabac1414, 0xebec5454, 0x1413abac, 0x64640808, - 0x9b9bf7f8, 0x08086464, 0xf7f79b9c, 0x6c6c6c6c, 0x93939394, 0x4443bbbc, 0xbbbc4444, 0x5453c7c8, - 0xabac3838, 0xc7c85454, 0x3837abac, 0x7877f3f4, 0x87880c0c, 0xf3f47878, 0x0c0b8788, 0x6c6bcfd0, - 0x93943030, 0xcfd06c6c, 0x302f9394, 0x7c7b9798, 0x83846868, 0x97987c7c, 0x68678384, 0x18181818, - 0xe7e7e7e8, 0x2c2c2c2c, 0xd3d3d3d4, 0x54545454, 0xabababac, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040404, - 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, - 0x04040404, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, - 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, - 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, - 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0x00000404, - 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, - 0x00000404, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, - 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0x08080404, 0x08080404, 0x08080404, 0x08080404, 0x08080404, - 0x08080404, 0x08080404, 0x08080404, 0x08080404, 0x08080404, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, - 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0x04040808, - 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x04040808, - 0x04040808, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, - 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x05050f0f, 0xfafaf0f1, 0x0a09f5f6, 0xf5f60a0a, 0x0f0efafb, - 0xf0f10505, 0xfafb0f0f, 0x0504f0f1, 0x14140a0a, 0xebebf5f6, 0x0a0a1414, 0xf5f5ebec, 0x14141414, - 0xebebebec, 0x19190000, 0xe6e70000, 0x00001919, 0xffffe6e7, 0x1413f0f1, 0xebec0f0f, 0xf0f11414, - 0x0f0eebec, 0x28281919, 0xd7d7e6e7, 0x19192828, 0xe6e6d7d8, 0x1e1df5f6, 0xe1e20a0a, 0xf5f61e1e, - 0x0a09e1e2, 0x28280a0a, 0xd7d7f5f6, 0x0a0a2828, 0xf5f5d7d8, 0x28282828, 0xd7d7d7d8, 0x2d2d0000, - 0xd2d30000, 0x00002d2d, 0xffffd2d3, 0x1e1de1e2, 0xe1e21e1e, 0x2827ebec, 0xd7d81414, 0xebec2828, - 0x1413d7d8, 0x41411919, 0xbebee6e7, 0x19194141, 0xe6e6bebf, 0x46462d2d, 0xb9b9d2d3, 0x2d2d4646, - 0xd2d2b9ba, 0x3736f0f1, 0xc8c90f0f, 0xf0f13737, 0x0f0ec8c9, 0x46460a0a, 0xb9b9f5f6, 0x0a0a4646, - 0xf5f5b9ba, 0x4b4b4b4b, 0xb4b4b4b5, 0x5554fafb, 0xaaab0505, 0xfafb5555, 0x0504aaab, 0x3736d2d3, - 0xc8c92d2d, 0xd2d33737, 0x2d2cc8c9, 0x4b4adcdd, 0xb4b52323, 0xdcdd4b4b, 0x2322b4b5, 0x73733737, - 0x8c8cc8c9, 0x37377373, 0xc8c88c8d, 0x73731e1e, 0x8c8ce1e2, 0x1e1e7373, 0xe1e18c8d, 0x78785a5a, - 0x8787a5a6, 0x5a5a7878, 0xa5a58788, 0x6968e1e2, 0x96971e1e, 0xe1e26969, 0x1e1d9697, 0x5554aaab, - 0xaaab5555, 0x6968b9ba, 0x96974646, 0xb9ba6969, 0x46459697, 0x1e1e1e1e, 0xe1e1e1e2, 0x3c3c3c3c, - 0xc3c3c3c4, 0x69696969, 0x96969697, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x05050505, 0x05050505, - 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, - 0x05050505, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, - 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0x05050000, 0x05050000, 0x05050000, 0x05050000, - 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0xfafb0000, - 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, - 0xfafb0000, 0xfafb0000, 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0x00000505, - 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0xfffffafb, 0xfffffafb, 0xfffffafb, - 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, - 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, - 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, - 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0x0f0f0505, 0x0f0f0505, - 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, - 0x0f0f0505, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, - 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, - 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0xf9f9f3f4, 0x0c0bf3f4, 0xf3f40c0c, 0x1211f9fa, - 0xedee0606, 0xf9fa1212, 0x0605edee, 0x18180c0c, 0xe7e7f3f4, 0x0c0c1818, 0xf3f3e7e8, 0x18181818, - 0xe7e7e7e8, 0x1e1e0000, 0xe1e20000, 0x00001e1e, 0xffffe1e2, 0x1817edee, 0xe7e81212, 0xedee1818, - 0x1211e7e8, 0x30301e1e, 0xcfcfe1e2, 0x1e1e3030, 0xe1e1cfd0, 0x2423f9fa, 0xdbdc0606, 0xf9fa2424, - 0x0605dbdc, 0x30300c0c, 0xcfcff3f4, 0x0c0c3030, 0xf3f3cfd0, 0x30303030, 0xcfcfcfd0, 0x36360000, - 0xc9ca0000, 0x00003636, 0xffffc9ca, 0x2423dbdc, 0xdbdc2424, 0x302fe7e8, 0xcfd01818, 0xe7e83030, - 0x1817cfd0, 0x4e4e1e1e, 0xb1b1e1e2, 0x1e1e4e4e, 0xe1e1b1b2, 0x54543636, 0xababc9ca, 0x36365454, - 0xc9c9abac, 0x4241edee, 0xbdbe1212, 0xedee4242, 0x1211bdbe, 0x54540c0c, 0xababf3f4, 0x0c0c5454, - 0xf3f3abac, 0x5a5a5a5a, 0xa5a5a5a6, 0x605ff9fa, 0x9fa00606, 0xf9fa6060, 0x06059fa0, 0x4241c9ca, - 0xbdbe3636, 0xc9ca4242, 0x3635bdbe, 0x5a59d5d6, 0xa5a62a2a, 0xd5d65a5a, 0x2a29a5a6, 0x7e7de1e2, - 0x81821e1e, 0xe1e27e7e, 0x1e1d8182, 0x6665999a, 0x999a6666, 0x7e7dabac, 0x81825454, 0xabac7e7e, - 0x54538182, 0x24242424, 0xdbdbdbdc, 0x42424242, 0xbdbdbdbe, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, - 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, - 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, - 0xf9fa0000, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, - 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, - 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, - 0xfffff9fa, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, - 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, - 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, - 0xf3f3f9fa, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, - 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, - 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0xf8f8eaeb, 0x0e0df1f2, 0xf1f20e0e, 0x1514f8f9, - 0xeaeb0707, 0xf8f91515, 0x0706eaeb, 0x1c1c0e0e, 0xe3e3f1f2, 0x0e0e1c1c, 0xf1f1e3e4, 0x1c1c1c1c, - 0xe3e3e3e4, 0x23230000, 0xdcdd0000, 0x00002323, 0xffffdcdd, 0x1c1beaeb, 0xe3e41515, 0xeaeb1c1c, - 0x1514e3e4, 0x38382323, 0xc7c7dcdd, 0x23233838, 0xdcdcc7c8, 0x2a29f1f2, 0xd5d60e0e, 0xf1f22a2a, - 0x0e0dd5d6, 0x38380e0e, 0xc7c7f1f2, 0x0e0e3838, 0xf1f1c7c8, 0x38383838, 0xc7c7c7c8, 0x3f3f0000, - 0xc0c10000, 0x00003f3f, 0xffffc0c1, 0x2a29d5d6, 0xd5d62a2a, 0x3837e3e4, 0xc7c81c1c, 0xe3e43838, - 0x1c1bc7c8, 0x5b5b2323, 0xa4a4dcdd, 0x23235b5b, 0xdcdca4a5, 0x62623f3f, 0x9d9dc0c1, 0x3f3f6262, - 0xc0c09d9e, 0x4d4ceaeb, 0xb2b31515, 0xeaeb4d4d, 0x1514b2b3, 0x62620e0e, 0x9d9df1f2, 0x0e0e6262, - 0xf1f19d9e, 0x69696969, 0x96969697, 0x7776f8f9, 0x88890707, 0xf8f97777, 0x07068889, 0x4d4cc0c1, - 0xb2b33f3f, 0xc0c14d4d, 0x3f3eb2b3, 0x6968cecf, 0x96973131, 0xcecf6969, 0x31309697, 0x77768889, - 0x88897777, 0x2a2a2a2a, 0xd5d5d5d6, 0x4d4d4d4d, 0xb2b2b2b3, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, - 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, - 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, - 0xf8f8f8f9, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, - 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0xf8f90000, 0xf8f90000, 0xf8f90000, - 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, - 0xf8f90000, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, - 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, - 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, - 0xfffff8f9, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, - 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, - 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, - 0xf1f1f1f2, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, - 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, - 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, - 0xeaeaf8f9, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, - 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, - 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0xf7f7eff0, 0x100feff0, 0xeff01010, 0x1817f7f8, - 0xe7e80808, 0xf7f81818, 0x0807e7e8, 0x20201010, 0xdfdfeff0, 0x10102020, 0xefefdfe0, 0x20202020, - 0xdfdfdfe0, 0x28280000, 0xd7d80000, 0x00002828, 0xffffd7d8, 0x201fe7e8, 0xdfe01818, 0xe7e82020, - 0x1817dfe0, 0x40402828, 0xbfbfd7d8, 0x28284040, 0xd7d7bfc0, 0x302feff0, 0xcfd01010, 0xeff03030, - 0x100fcfd0, 0x40401010, 0xbfbfeff0, 0x10104040, 0xefefbfc0, 0x40404040, 0xbfbfbfc0, 0x48480000, - 0xb7b80000, 0x00004848, 0xffffb7b8, 0x302fcfd0, 0xcfd03030, 0x403fdfe0, 0xbfc02020, 0xdfe04040, - 0x201fbfc0, 0x68682828, 0x9797d7d8, 0x28286868, 0xd7d79798, 0x70704848, 0x8f8fb7b8, 0x48487070, - 0xb7b78f90, 0x5857e7e8, 0xa7a81818, 0xe7e85858, 0x1817a7a8, 0x70701010, 0x8f8feff0, 0x10107070, - 0xefef8f90, 0x78787878, 0x87878788, 0x5857b7b8, 0xa7a84848, 0xb7b85858, 0x4847a7a8, 0x7877c7c8, - 0x87883838, 0xc7c87878, 0x38378788, 0x30303030, 0xcfcfcfd0, 0x58585858, 0xa7a7a7a8, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, - 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0xf7f7f7f8, - 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, - 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, - 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0xf7f80000, - 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, - 0xf7f80000, 0xf7f80000, 0xf7f80000, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, - 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0xfffff7f8, - 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, - 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, - 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0xefefeff0, - 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, - 0xefefeff0, 0xefefeff0, 0xefefeff0, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, - 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0xefeff7f8, - 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, - 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, - 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, - 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x1211edee, 0xedee1212, 0x1b1af6f7, - 0xe4e50909, 0xf6f71b1b, 0x0908e4e5, 0x24241212, 0xdbdbedee, 0x12122424, 0xededdbdc, 0x24242424, - 0xdbdbdbdc, 0x2d2d0000, 0xd2d30000, 0x00002d2d, 0xffffd2d3, 0x2423e4e5, 0xdbdc1b1b, 0xe4e52424, - 0x1b1adbdc, 0x48482d2d, 0xb7b7d2d3, 0x2d2d4848, 0xd2d2b7b8, 0x3635edee, 0xc9ca1212, 0xedee3636, - 0x1211c9ca, 0x48481212, 0xb7b7edee, 0x12124848, 0xededb7b8, 0x48484848, 0xb7b7b7b8, 0x51510000, - 0xaeaf0000, 0x00005151, 0xffffaeaf, 0x3635c9ca, 0xc9ca3636, 0x4847dbdc, 0xb7b82424, 0xdbdc4848, - 0x2423b7b8, 0x75752d2d, 0x8a8ad2d3, 0x2d2d7575, 0xd2d28a8b, 0x7e7e5151, 0x8181aeaf, 0x51517e7e, - 0xaeae8182, 0x6362e4e5, 0x9c9d1b1b, 0xe4e56363, 0x1b1a9c9d, 0x6362aeaf, 0x9c9d5151, 0xaeaf6363, - 0x51509c9d, 0x36363636, 0xc9c9c9ca, 0x6c6c6c6c, 0x93939394, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, - 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0xf6f6f6f7, - 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, - 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0x09090000, 0x09090000, 0x09090000, 0x09090000, - 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, - 0x09090000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, - 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0x00000909, 0x00000909, - 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, - 0x00000909, 0x00000909, 0x00000909, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, - 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, - 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, - 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0xedededee, 0xedededee, 0xedededee, - 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, - 0xedededee, 0xedededee, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, - 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0xe4e4f6f7, - 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, - 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, - 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, - 0x09091b1b, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, - 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, - 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0504fafb, 0xfafb0505, 0xfafb0505, - 0x0504fafb, 0x0b0b0606, 0xf4f4f9fa, 0x06060b0b, 0xf9f9f4f5, 0x08080000, 0xf7f80000, 0x00000808, - 0xfffff7f8, 0x0b0b0b0b, 0xf4f4f4f5, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x11110c0c, - 0xeeeef3f4, 0x0c0c1111, 0xf3f3eeef, 0x11111111, 0xeeeeeeef, 0x12120606, 0xededf9fa, 0x06061212, - 0xf9f9edee, 0x0b0af7f8, 0xf4f50808, 0xf7f80b0b, 0x0807f4f5, 0x0f0f0000, 0xf0f10000, 0x00000f0f, - 0xfffff0f1, 0x14140000, 0xebec0000, 0x00001414, 0xffffebec, 0x19191212, 0xe6e6edee, 0x12121919, - 0xedede6e7, 0x19190b0b, 0xe6e6f4f5, 0x0b0b1919, 0xf4f4e6e7, 0x19191919, 0xe6e6e6e7, 0x0e0df1f2, - 0xf1f20e0e, 0xf1f20e0e, 0x0e0df1f2, 0x1a1a0000, 0xe5e60000, 0x00001a1a, 0xffffe5e6, 0x1211f4f5, - 0xedee0b0b, 0xf4f51212, 0x0b0aedee, 0x1615f8f9, 0xe9ea0707, 0xf8f91616, 0x0706e9ea, 0x22221a1a, - 0xdddde5e6, 0x1a1a2222, 0xe5e5ddde, 0x22221212, 0xddddedee, 0x12122222, 0xededddde, 0x22222222, - 0xddddddde, 0x23230b0b, 0xdcdcf4f5, 0x0b0b2323, 0xf4f4dcdd, 0x1d1d0000, 0xe2e30000, 0x00001d1d, - 0xffffe2e3, 0x1615eced, 0xe9ea1313, 0xeced1616, 0x1312e9ea, 0x1a19f0f1, 0xe5e60f0f, 0xf0f11a1a, - 0x0f0ee5e6, 0x25250000, 0xdadb0000, 0x00002525, 0xffffdadb, 0x2c2c1b1b, 0xd3d3e4e5, 0x1b1b2c2c, - 0xe4e4d3d4, 0x2c2c2424, 0xd3d3dbdc, 0x24242c2c, 0xdbdbd3d4, 0x2c2c1212, 0xd3d3edee, 0x12122c2c, - 0xededd3d4, 0x2120f5f6, 0xdedf0a0a, 0xf5f62121, 0x0a09dedf, 0x2d2d2d2d, 0xd2d2d2d3, 0x00000000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, - 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, - 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, - 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, - 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, - 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, - 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, - 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, - 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, - 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, - 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, - 0xf8f90000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0403fbfc, 0xfbfc0404, 0xf9fa0a0a, - 0x0605f5f6, 0xf3f40000, 0x0c0c0000, 0xf3f3f9fa, 0xf3f40606, 0x0c0bf9fa, 0x0c0c0606, 0xfffff1f2, - 0x00000e0e, 0x0c0c0c0c, 0xf3f3f3f4, 0xedee0000, 0x12120000, 0xf3f40e0e, 0x0c0bf1f2, 0xf9f9edee, - 0xf9fa1212, 0x0605edee, 0x06061212, 0xededf5f6, 0xedee0a0a, 0x1211f5f6, 0x12120a0a, 0xffffe9ea, - 0x00001616, 0xe7e80000, 0x18180000, 0xf3f3e9ea, 0xf3f41616, 0x0c0be9ea, 0x0c0c1616, 0xe7e7f7f8, - 0xe7e80808, 0x1817f7f8, 0x18180808, 0xf9f9e5e6, 0xf9fa1a1a, 0x0605e5e6, 0x06061a1a, 0xffffe3e4, - 0x00001c1c, 0x14141414, 0xebebebec, 0xe5e5f1f2, 0x1a1a0e0e, 0xf3f3e1e2, 0x0c0c1e1e, 0xdfdff5f6, - 0x20200a0a, 0xdfdfedee, 0x20201212, 0xe5e5e5e6, 0x1a1a1a1a, 0xebebddde, 0x14142222, 0xf3f3d9da, - 0x0c0c2626, 0xdfdfdfe0, 0x20202020, 0x20202020, 0xd7d7e9ea, 0xddddddde, 0x22222222, 0x00000000, - 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, - 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, - 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, - 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, - 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, - 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, - 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, - 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, - 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, - 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, - 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, - 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, - 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, - 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, - 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x0605f9fa, 0xf9fa0606, 0xf7f80e0e, - 0x0807f1f2, 0xffffedee, 0x00001212, 0xeff00a0a, 0x100ff5f6, 0xe7e80000, 0x18180000, 0xf7f7e7e8, - 0xf7f81818, 0x0807e7e8, 0x08081818, 0x12121212, 0xedededee, 0xeff01414, 0x100febec, 0xe5e5f1f2, - 0xe5e60e0e, 0x1a19f1f2, 0x1a1a0e0e, 0xffffe1e2, 0x00001e1e, 0xddde0000, 0x22220000, 0xf7f7ddde, - 0xf7f82222, 0x0807ddde, 0x08082222, 0xedede1e2, 0xedee1e1e, 0x1211e1e2, 0x12121e1e, 0xddddf5f6, - 0xddde0a0a, 0x2221f5f6, 0x22220a0a, 0xddddebec, 0x22221414, 0xffffd7d8, 0x00002828, 0x1e1e1e1e, - 0xe1e1e1e2, 0xededd7d8, 0x12122828, 0xd3d40000, 0x2c2c0000, 0xd3d3eff0, 0x2c2c1010, 0xdbdbdbdc, - 0xdbdbdbdc, 0x24242424, 0xd3d3e5e6, 0x2c2c1a1a, 0xe5e5d1d2, 0x1a1a2e2e, 0xededcbcc, 0x12123434, - 0xc9c9ebec, 0xd3d3d3d4, 0x2c2c2c2c, 0xc9c9dfe0, 0xd1d1d1d2, 0xd1d1d1d2, 0x2e2e2e2e, 0x00000000, - 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, - 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, - 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, - 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, - 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, - 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, - 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, - 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, - 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, - 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, - 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, - 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, - 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, - 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, - 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, - 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, - 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, - 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, - 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, - 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, - 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, - 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x0807f7f8, 0xf7f80808, 0xeff00808, - 0x100ff7f8, 0xe7e80000, 0x18180000, 0xf7f7e7e8, 0xf7f81818, 0x0807e7e8, 0x08081818, 0xeff01414, - 0x100febec, 0xffffe3e4, 0x00001c1c, 0xe7e7eff0, 0xe7e81010, 0x1817eff0, 0x18181010, 0xdfe00000, - 0x20200000, 0xefefe3e4, 0xeff01c1c, 0x100fe3e4, 0x10101c1c, 0xdfdff7f8, 0xdfe00808, 0xf7f7dfe0, - 0xf7f82020, 0x0807dfe0, 0x08082020, 0x201ff7f8, 0x20200808, 0x18181818, 0xe7e7e7e8, 0xe7e81818, - 0x1817e7e8, 0xdfdfebec, 0x20201414, 0xffffd7d8, 0x00002828, 0xefefd7d8, 0x10102828, 0xd3d40000, - 0xd3d40000, 0xffffd3d4, 0x00002c2c, 0x2c2c0000, 0x2c2c0000, 0xdfdfdfe0, 0x20202020, 0xd3d3eff0, - 0x2c2c1010, 0xd3d3e7e8, 0xe7e7d3d4, 0x18182c2c, 0x2c2c1818, 0xefefcfd0, 0x10103030, 0xdbdbdbdc, - 0xdbdbdbdc, 0x24242424, 0x24242424, 0xcbcbebec, 0x28282828, 0xd7d7d7d8, 0xcbcbdfe0, 0x00000000, - 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, - 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, - 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, - 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, - 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, - 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, - 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, - 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, - 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, - 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, - 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, - 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, - 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, - 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, - 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, - 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, - 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, - 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, - 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, - 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, - 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, - 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, - 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, - 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, - 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, - 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, - 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, - 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, - 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, - 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, - 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 -}; - - -static const uint32_t correctionhighorder[] = { - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, - 0xfeff0303, 0x0100fcfd, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, - 0x0100fcfd, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, 0x02020202, 0xfdfdfdfe, - 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, - 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, - 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, - 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, - 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, - 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, - 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, - 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, - 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, - 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x04040404, 0xfbfbfbfc, - 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, - 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, - 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, - 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, - 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, - 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, - 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, - 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, - 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, - 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, - 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, - 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, - 0x03030a0a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, - 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, - 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, - 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, - 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, - 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, - 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, - 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, - 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, - 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, - 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, - 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, - 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, - 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, - 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, - 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, - 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, - 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, - 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, - 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, - 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, - 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, - 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, - 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, - 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, - 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, - 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, - 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, - 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, - 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, - 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, - 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, - 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, - 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, - 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, - 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, - 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, - 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, - 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, - 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, - 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, - 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, - 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, - 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, - 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, - 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, - 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, - 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, - 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, - 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, - 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, - 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x09090909, 0xf6f6f6f7, - 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, - 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, - 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, - 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, - 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, - 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, - 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, - 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, - 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, - 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, - 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, - 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, - 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, - 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, - 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, - 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, - 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, - 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, - 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, - 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, - 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, - 0x00000202, 0xfffffdfe, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, - 0xfffffdfe, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, 0x02020202, 0xfdfdfdfe, - 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, - 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, - 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, - 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, - 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, - 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, - 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, - 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, - 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, - 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x04040404, 0xfbfbfbfc, - 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, - 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, - 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, - 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, - 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, - 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, - 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, - 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, - 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, - 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, - 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, - 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, - 0x04040808, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, - 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, - 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, - 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, - 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, - 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, - 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, - 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, - 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, - 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, - 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, - 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, - 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, - 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, - 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, - 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, - 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, - 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, - 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, - 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, - 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, - 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, - 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, - 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, - 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, - 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, - 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, - 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, - 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, - 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, - 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, - 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, - 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, - 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, - 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, - 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, - 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, - 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, - 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, - 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, - 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, - 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, - 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, - 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, - 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, - 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x09090909, 0xf6f6f6f7, - 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, - 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, - 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, - 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, - 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, - 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, - 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, - 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, - 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, - 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, - 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, - 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, - 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, - 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, - 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, - 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, - 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, - 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, - 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, - 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, - 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, - 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, - 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0x00000303, - 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, - 0x00000303, 0x00000303, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, - 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, - 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0xf8f90000, 0xf8f90000, - 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, - 0xf8f90000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, - 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, - 0x02020000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, - 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0x00000202, 0x00000202, - 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, - 0x00000202, 0x00000202, 0x00000202, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, - 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, - 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0x06060000, 0x06060000, 0x06060000, 0x06060000, - 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, - 0x06060000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, - 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0x00000606, 0x00000606, - 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, - 0x00000606, 0x00000606, 0x00000606, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, - 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, - 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, - 0x02020000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, - 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0x00000202, 0x00000202, - 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, - 0x00000202, 0x00000202, 0x00000202, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, - 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, - 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, - 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, - 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, - 0xfbfbfbfc, 0xfbfbfbfc, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, - 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0xf5f5f5f6, - 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, - 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, - 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, - 0x0a0a0000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, - 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0x00000a0a, 0x00000a0a, - 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, - 0x00000a0a, 0x00000a0a, 0x00000a0a, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, - 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, - 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, - 0x04040000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, - 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0x00000404, 0x00000404, - 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, - 0x00000404, 0x00000404, 0x00000404, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, - 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, - 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, - 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, - 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, - 0xfbfbfbfc, 0xfbfbfbfc, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, - 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, - 0x0c0c0000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, - 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0x00000c0c, 0x00000c0c, - 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, - 0x00000c0c, 0x00000c0c, 0x00000c0c, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, - 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, - 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, - 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, - 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, - 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, - 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, - 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, - 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, - 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 -}; diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/interplayvideo.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/interplayvideo.c deleted file mode 100644 index 7f54e5d..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/interplayvideo.c +++ /dev/null @@ -1,976 +0,0 @@ -/* - * Interplay MVE Video Decoder - * 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 interplayvideo.c - * Interplay MVE Video Decoder by Mike Melanson (melanson@pcisys.net) - * For more information about the Interplay MVE format, visit: - * http://www.pcisys.net/~melanson/codecs/interplay-mve.txt - * This code is written in such a way that the identifiers match up - * with the encoding descriptions in the document. - * - * This decoder presently only supports a PAL8 output colorspace. - * - * An Interplay video frame consists of 2 parts: The decoding map and - * the video data. A demuxer must load these 2 parts together in a single - * buffer before sending it through the stream to this decoder. - */ - -#include -#include -#include -#include - -#include "common.h" -#include "avcodec.h" -#include "dsputil.h" - -#define PALETTE_COUNT 256 - -/* debugging support */ -#define DEBUG_INTERPLAY 0 -#if DEBUG_INTERPLAY -#define debug_interplay printf -#else -static inline void debug_interplay(const char *format, ...) { } -#endif - -typedef struct IpvideoContext { - - AVCodecContext *avctx; - DSPContext dsp; - AVFrame second_last_frame; - AVFrame last_frame; - AVFrame current_frame; - unsigned char *decoding_map; - int decoding_map_size; - - unsigned char *buf; - int size; - - unsigned char palette[PALETTE_COUNT * 4]; - - unsigned char *stream_ptr; - unsigned char *stream_end; - unsigned char *pixel_ptr; - int line_inc; - int stride; - int upper_motion_limit_offset; - -} IpvideoContext; - -#define CHECK_STREAM_PTR(n) \ - if ((s->stream_ptr + n) > s->stream_end) { \ - printf ("Interplay video warning: stream_ptr out of bounds (%p >= %p)\n", \ - s->stream_ptr + n, s->stream_end); \ - return -1; \ - } - -static void ipvideo_new_palette(IpvideoContext *s, unsigned char *palette) { - - int i; - unsigned char r, g, b; - unsigned int *palette32; - - palette32 = (unsigned int *)s->palette; - for (i = 0; i < PALETTE_COUNT; i++) { - r = *palette++; - g = *palette++; - b = *palette++; - palette32[i] = (r << 16) | (g << 8) | (b); - } -} - -#define COPY_FROM_CURRENT() \ - motion_offset = current_offset; \ - motion_offset += y * s->stride; \ - motion_offset += x; \ - if (motion_offset < 0) { \ - printf (" Interplay video: motion offset < 0 (%d)\n", motion_offset); \ - return -1; \ - } else if (motion_offset > s->upper_motion_limit_offset) { \ - printf (" Interplay video: motion offset above limit (%d >= %d)\n", \ - motion_offset, s->upper_motion_limit_offset); \ - return -1; \ - } \ - s->dsp.put_pixels_tab[0][0](s->pixel_ptr, \ - s->current_frame.data[0] + motion_offset, s->stride, 8); - -#define COPY_FROM_PREVIOUS() \ - motion_offset = current_offset; \ - motion_offset += y * s->stride; \ - motion_offset += x; \ - if (motion_offset < 0) { \ - printf (" Interplay video: motion offset < 0 (%d)\n", motion_offset); \ - return -1; \ - } else if (motion_offset > s->upper_motion_limit_offset) { \ - printf (" Interplay video: motion offset above limit (%d >= %d)\n", \ - motion_offset, s->upper_motion_limit_offset); \ - return -1; \ - } \ - s->dsp.put_pixels_tab[0][0](s->pixel_ptr, \ - s->last_frame.data[0] + motion_offset, s->stride, 8); - -#define COPY_FROM_SECOND_LAST() \ - motion_offset = current_offset; \ - motion_offset += y * s->stride; \ - motion_offset += x; \ - if (motion_offset < 0) { \ - printf (" Interplay video: motion offset < 0 (%d)\n", motion_offset); \ - return -1; \ - } else if (motion_offset > s->upper_motion_limit_offset) { \ - printf (" Interplay video: motion offset above limit (%d >= %d)\n", \ - motion_offset, s->upper_motion_limit_offset); \ - return -1; \ - } \ - s->dsp.put_pixels_tab[0][0](s->pixel_ptr, \ - s->second_last_frame.data[0] + motion_offset, s->stride, 8); - -static int ipvideo_decode_block_opcode_0x0(IpvideoContext *s) -{ - int x, y; - int motion_offset; - int current_offset = s->pixel_ptr - s->current_frame.data[0]; - - /* copy a block from the previous frame */ - x = y = 0; - COPY_FROM_PREVIOUS(); - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0x1(IpvideoContext *s) -{ - int x, y; - int motion_offset; - int current_offset = s->pixel_ptr - s->current_frame.data[0]; - - /* copy block from 2 frames ago */ - x = y = 0; - COPY_FROM_SECOND_LAST(); - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0x2(IpvideoContext *s) -{ - unsigned char B; - int x, y; - int motion_offset; - int current_offset = s->pixel_ptr - s->current_frame.data[0]; - - /* copy block from 2 frames ago using a motion vector; need 1 more byte */ - CHECK_STREAM_PTR(1); - B = *s->stream_ptr++; - - if (B < 56) { - x = 8 + (B % 7); - y = B / 7; - } else { - x = -14 + ((B - 56) % 29); - y = 8 + ((B - 56) / 29); - } - - debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y); - COPY_FROM_SECOND_LAST(); - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0x3(IpvideoContext *s) -{ - unsigned char B; - int x, y; - int motion_offset; - int current_offset = s->pixel_ptr - s->current_frame.data[0]; - - /* copy 8x8 block from current frame from an up/left block */ - - /* need 1 more byte for motion */ - CHECK_STREAM_PTR(1); - B = *s->stream_ptr++; - - if (B < 56) { - x = -(8 + (B % 7)); - y = -(B / 7); - } else { - x = -(-14 + ((B - 56) % 29)); - y = -( 8 + ((B - 56) / 29)); - } - - debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y); - COPY_FROM_CURRENT(); - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0x4(IpvideoContext *s) -{ - int x, y; - unsigned char B, BL, BH; - int motion_offset; - int current_offset = s->pixel_ptr - s->current_frame.data[0]; - - /* copy a block from the previous frame; need 1 more byte */ - CHECK_STREAM_PTR(1); - - B = *s->stream_ptr++; - BL = B & 0x0F; - BH = (B >> 4) & 0x0F; - x = -8 + BL; - y = -8 + BH; - - debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y); - COPY_FROM_PREVIOUS(); - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0x5(IpvideoContext *s) -{ - signed char x, y; - int motion_offset; - int current_offset = s->pixel_ptr - s->current_frame.data[0]; - - /* copy a block from the previous frame using an expanded range; - * need 2 more bytes */ - CHECK_STREAM_PTR(2); - - x = *s->stream_ptr++; - y = *s->stream_ptr++; - - debug_interplay (" motion bytes = %d, %d\n", x, y); - COPY_FROM_PREVIOUS(); - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0x6(IpvideoContext *s) -{ - /* mystery opcode? skip multiple blocks? */ - printf (" Interplay video: Help! Mystery opcode 0x6 seen\n"); - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0x7(IpvideoContext *s) -{ - int x, y; - unsigned char P0, P1; - unsigned char B[8]; - unsigned int flags; - int bitmask; - - /* 2-color encoding */ - CHECK_STREAM_PTR(2); - - P0 = *s->stream_ptr++; - P1 = *s->stream_ptr++; - - if (P0 <= P1) { - - /* need 8 more bytes from the stream */ - CHECK_STREAM_PTR(8); - for (y = 0; y < 8; y++) - B[y] = *s->stream_ptr++; - - for (y = 0; y < 8; y++) { - flags = B[y]; - for (x = 0x01; x <= 0x80; x <<= 1) { - if (flags & x) - *s->pixel_ptr++ = P1; - else - *s->pixel_ptr++ = P0; - } - s->pixel_ptr += s->line_inc; - } - - } else { - - /* need 2 more bytes from the stream */ - CHECK_STREAM_PTR(2); - B[0] = *s->stream_ptr++; - B[1] = *s->stream_ptr++; - - flags = (B[1] << 8) | B[0]; - bitmask = 0x0001; - for (y = 0; y < 8; y += 2) { - for (x = 0; x < 8; x += 2, bitmask <<= 1) { - if (flags & bitmask) { - *(s->pixel_ptr + x) = P1; - *(s->pixel_ptr + x + 1) = P1; - *(s->pixel_ptr + s->stride + x) = P1; - *(s->pixel_ptr + s->stride + x + 1) = P1; - } else { - *(s->pixel_ptr + x) = P0; - *(s->pixel_ptr + x + 1) = P0; - *(s->pixel_ptr + s->stride + x) = P0; - *(s->pixel_ptr + s->stride + x + 1) = P0; - } - } - s->pixel_ptr += s->stride * 2; - } - } - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0x8(IpvideoContext *s) -{ - int x, y; - unsigned char P[8]; - unsigned char B[8]; - unsigned int flags = 0; - unsigned int bitmask = 0; - unsigned char P0 = 0, P1 = 0; - int lower_half = 0; - - /* 2-color encoding for each 4x4 quadrant, or 2-color encoding on - * either top and bottom or left and right halves */ - CHECK_STREAM_PTR(2); - - P[0] = *s->stream_ptr++; - P[1] = *s->stream_ptr++; - - if (P[0] <= P[1]) { - - /* need 12 more bytes */ - CHECK_STREAM_PTR(12); - B[0] = *s->stream_ptr++; B[1] = *s->stream_ptr++; - P[2] = *s->stream_ptr++; P[3] = *s->stream_ptr++; - B[2] = *s->stream_ptr++; B[3] = *s->stream_ptr++; - P[4] = *s->stream_ptr++; P[5] = *s->stream_ptr++; - B[4] = *s->stream_ptr++; B[5] = *s->stream_ptr++; - P[6] = *s->stream_ptr++; P[7] = *s->stream_ptr++; - B[6] = *s->stream_ptr++; B[7] = *s->stream_ptr++; - - for (y = 0; y < 8; y++) { - - /* time to reload flags? */ - if (y == 0) { - flags = - ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) | - ((B[0] & 0x0F) ) | ((B[4] & 0x0F) << 4) | - ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) | - ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20); - bitmask = 0x00000001; - lower_half = 0; /* still on top half */ - } else if (y == 4) { - flags = - ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) | - ((B[2] & 0x0F) ) | ((B[6] & 0x0F) << 4) | - ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) | - ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20); - bitmask = 0x00000001; - lower_half = 2; - } - - for (x = 0; x < 8; x++, bitmask <<= 1) { - /* get the pixel values ready for this quadrant */ - if (x == 0) { - P0 = P[lower_half + 0]; - P1 = P[lower_half + 1]; - } else if (x == 4) { - P0 = P[lower_half + 4]; - P1 = P[lower_half + 5]; - } - - if (flags & bitmask) - *s->pixel_ptr++ = P1; - else - *s->pixel_ptr++ = P0; - } - s->pixel_ptr += s->line_inc; - } - - } else { - - /* need 10 more bytes */ - CHECK_STREAM_PTR(10); - B[0] = *s->stream_ptr++; B[1] = *s->stream_ptr++; - B[2] = *s->stream_ptr++; B[3] = *s->stream_ptr++; - P[2] = *s->stream_ptr++; P[3] = *s->stream_ptr++; - B[4] = *s->stream_ptr++; B[5] = *s->stream_ptr++; - B[6] = *s->stream_ptr++; B[7] = *s->stream_ptr++; - - if (P[2] <= P[3]) { - - /* vertical split; left & right halves are 2-color encoded */ - - for (y = 0; y < 8; y++) { - - /* time to reload flags? */ - if (y == 0) { - flags = - ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) | - ((B[0] & 0x0F) ) | ((B[4] & 0x0F) << 4) | - ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) | - ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20); - bitmask = 0x00000001; - } else if (y == 4) { - flags = - ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) | - ((B[2] & 0x0F) ) | ((B[6] & 0x0F) << 4) | - ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) | - ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20); - bitmask = 0x00000001; - } - - for (x = 0; x < 8; x++, bitmask <<= 1) { - /* get the pixel values ready for this half */ - if (x == 0) { - P0 = P[0]; - P1 = P[1]; - } else if (x == 4) { - P0 = P[2]; - P1 = P[3]; - } - - if (flags & bitmask) - *s->pixel_ptr++ = P1; - else - *s->pixel_ptr++ = P0; - } - s->pixel_ptr += s->line_inc; - } - - } else { - - /* horizontal split; top & bottom halves are 2-color encoded */ - - for (y = 0; y < 8; y++) { - - flags = B[y]; - if (y == 0) { - P0 = P[0]; - P1 = P[1]; - } else if (y == 4) { - P0 = P[2]; - P1 = P[3]; - } - - for (bitmask = 0x01; bitmask <= 0x80; bitmask <<= 1) { - - if (flags & bitmask) - *s->pixel_ptr++ = P1; - else - *s->pixel_ptr++ = P0; - } - s->pixel_ptr += s->line_inc; - } - } - } - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0x9(IpvideoContext *s) -{ - int x, y; - unsigned char P[4]; - unsigned char B[4]; - unsigned int flags = 0; - int shifter = 0; - unsigned char pix; - - /* 4-color encoding */ - CHECK_STREAM_PTR(4); - - for (y = 0; y < 4; y++) - P[y] = *s->stream_ptr++; - - if ((P[0] <= P[1]) && (P[2] <= P[3])) { - - /* 1 of 4 colors for each pixel, need 16 more bytes */ - CHECK_STREAM_PTR(16); - - for (y = 0; y < 8; y++) { - /* get the next set of 8 2-bit flags */ - flags = (s->stream_ptr[1] << 8) | s->stream_ptr[0]; - s->stream_ptr += 2; - for (x = 0, shifter = 0; x < 8; x++, shifter += 2) { - *s->pixel_ptr++ = P[(flags >> shifter) & 0x03]; - } - s->pixel_ptr += s->line_inc; - } - - } else if ((P[0] <= P[1]) && (P[2] > P[3])) { - - /* 1 of 4 colors for each 2x2 block, need 4 more bytes */ - CHECK_STREAM_PTR(4); - - B[0] = *s->stream_ptr++; - B[1] = *s->stream_ptr++; - B[2] = *s->stream_ptr++; - B[3] = *s->stream_ptr++; - flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; - shifter = 0; - - for (y = 0; y < 8; y += 2) { - for (x = 0; x < 8; x += 2, shifter += 2) { - pix = P[(flags >> shifter) & 0x03]; - *(s->pixel_ptr + x) = pix; - *(s->pixel_ptr + x + 1) = pix; - *(s->pixel_ptr + s->stride + x) = pix; - *(s->pixel_ptr + s->stride + x + 1) = pix; - } - s->pixel_ptr += s->stride * 2; - } - - } else if ((P[0] > P[1]) && (P[2] <= P[3])) { - - /* 1 of 4 colors for each 2x1 block, need 8 more bytes */ - CHECK_STREAM_PTR(8); - - for (y = 0; y < 8; y++) { - /* time to reload flags? */ - if ((y == 0) || (y == 4)) { - B[0] = *s->stream_ptr++; - B[1] = *s->stream_ptr++; - B[2] = *s->stream_ptr++; - B[3] = *s->stream_ptr++; - flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; - shifter = 0; - } - for (x = 0; x < 8; x += 2, shifter += 2) { - pix = P[(flags >> shifter) & 0x03]; - *(s->pixel_ptr + x) = pix; - *(s->pixel_ptr + x + 1) = pix; - } - s->pixel_ptr += s->stride; - } - - } else { - - /* 1 of 4 colors for each 1x2 block, need 8 more bytes */ - CHECK_STREAM_PTR(8); - - for (y = 0; y < 8; y += 2) { - /* time to reload flags? */ - if ((y == 0) || (y == 4)) { - B[0] = *s->stream_ptr++; - B[1] = *s->stream_ptr++; - B[2] = *s->stream_ptr++; - B[3] = *s->stream_ptr++; - flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0]; - shifter = 0; - } - for (x = 0; x < 8; x++, shifter += 2) { - pix = P[(flags >> shifter) & 0x03]; - *(s->pixel_ptr + x) = pix; - *(s->pixel_ptr + s->stride + x) = pix; - } - s->pixel_ptr += s->stride * 2; - } - } - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0xA(IpvideoContext *s) -{ - int x, y; - unsigned char P[16]; - unsigned char B[16]; - int flags = 0; - int shifter = 0; - int index; - int split; - int lower_half; - - /* 4-color encoding for each 4x4 quadrant, or 4-color encoding on - * either top and bottom or left and right halves */ - CHECK_STREAM_PTR(4); - - for (y = 0; y < 4; y++) - P[y] = *s->stream_ptr++; - - if (P[0] <= P[1]) { - - /* 4-color encoding for each quadrant; need 28 more bytes */ - CHECK_STREAM_PTR(28); - - for (y = 0; y < 4; y++) - B[y] = *s->stream_ptr++; - for (y = 4; y < 16; y += 4) { - for (x = y; x < y + 4; x++) - P[x] = *s->stream_ptr++; - for (x = y; x < y + 4; x++) - B[x] = *s->stream_ptr++; - } - - for (y = 0; y < 8; y++) { - - lower_half = (y >= 4) ? 4 : 0; - flags = (B[y + 8] << 8) | B[y]; - - for (x = 0, shifter = 0; x < 8; x++, shifter += 2) { - split = (x >= 4) ? 8 : 0; - index = split + lower_half + ((flags >> shifter) & 0x03); - *s->pixel_ptr++ = P[index]; - } - - s->pixel_ptr += s->line_inc; - } - - } else { - - /* 4-color encoding for either left and right or top and bottom - * halves; need 20 more bytes */ - CHECK_STREAM_PTR(20); - - for (y = 0; y < 8; y++) - B[y] = *s->stream_ptr++; - for (y = 4; y < 8; y++) - P[y] = *s->stream_ptr++; - for (y = 8; y < 16; y++) - B[y] = *s->stream_ptr++; - - if (P[4] <= P[5]) { - - /* block is divided into left and right halves */ - for (y = 0; y < 8; y++) { - - flags = (B[y + 8] << 8) | B[y]; - split = 0; - - for (x = 0, shifter = 0; x < 8; x++, shifter += 2) { - if (x == 4) - split = 4; - *s->pixel_ptr++ = P[split + ((flags >> shifter) & 0x03)]; - } - - s->pixel_ptr += s->line_inc; - } - - } else { - - /* block is divided into top and bottom halves */ - split = 0; - for (y = 0; y < 8; y++) { - - flags = (B[y * 2 + 1] << 8) | B[y * 2]; - if (y == 4) - split = 4; - - for (x = 0, shifter = 0; x < 8; x++, shifter += 2) - *s->pixel_ptr++ = P[split + ((flags >> shifter) & 0x03)]; - - s->pixel_ptr += s->line_inc; - } - } - } - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0xB(IpvideoContext *s) -{ - int x, y; - - /* 64-color encoding (each pixel in block is a different color) */ - CHECK_STREAM_PTR(64); - - for (y = 0; y < 8; y++) { - for (x = 0; x < 8; x++) { - *s->pixel_ptr++ = *s->stream_ptr++; - } - s->pixel_ptr += s->line_inc; - } - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0xC(IpvideoContext *s) -{ - int x, y; - unsigned char pix; - - /* 16-color block encoding: each 2x2 block is a different color */ - CHECK_STREAM_PTR(16); - - for (y = 0; y < 8; y += 2) { - for (x = 0; x < 8; x += 2) { - pix = *s->stream_ptr++; - *(s->pixel_ptr + x) = pix; - *(s->pixel_ptr + x + 1) = pix; - *(s->pixel_ptr + s->stride + x) = pix; - *(s->pixel_ptr + s->stride + x + 1) = pix; - } - s->pixel_ptr += s->stride * 2; - } - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0xD(IpvideoContext *s) -{ - int x, y; - unsigned char P[4]; - unsigned char index = 0; - - /* 4-color block encoding: each 4x4 block is a different color */ - CHECK_STREAM_PTR(4); - - for (y = 0; y < 4; y++) - P[y] = *s->stream_ptr++; - - for (y = 0; y < 8; y++) { - if (y < 4) - index = 0; - else - index = 2; - - for (x = 0; x < 8; x++) { - if (x == 4) - index++; - *s->pixel_ptr++ = P[index]; - } - s->pixel_ptr += s->line_inc; - } - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0xE(IpvideoContext *s) -{ - int x, y; - unsigned char pix; - - /* 1-color encoding: the whole block is 1 solid color */ - CHECK_STREAM_PTR(1); - pix = *s->stream_ptr++; - - for (y = 0; y < 8; y++) { - for (x = 0; x < 8; x++) { - *s->pixel_ptr++ = pix; - } - s->pixel_ptr += s->line_inc; - } - - /* report success */ - return 0; -} - -static int ipvideo_decode_block_opcode_0xF(IpvideoContext *s) -{ - int x, y; - unsigned char sample0, sample1; - - /* dithered encoding */ - CHECK_STREAM_PTR(2); - sample0 = *s->stream_ptr++; - sample1 = *s->stream_ptr++; - - for (y = 0; y < 8; y++) { - for (x = 0; x < 8; x += 2) { - if (y & 1) { - *s->pixel_ptr++ = sample1; - *s->pixel_ptr++ = sample0; - } else { - *s->pixel_ptr++ = sample0; - *s->pixel_ptr++ = sample1; - } - } - s->pixel_ptr += s->line_inc; - } - - /* report success */ - return 0; -} - -static int (*ipvideo_decode_block[16])(IpvideoContext *s); - -static void ipvideo_decode_opcodes(IpvideoContext *s) -{ - int x, y; - int index = 0; - unsigned char opcode; - int ret; - int code_counts[16]; - static int frame = 0; - - debug_interplay("------------------ frame %d\n", frame); - frame++; - - for (x = 0; x < 16; x++) - code_counts[x] = 0; - - /* this is PAL8, so make the palette available */ - memcpy(s->current_frame.data[1], s->palette, PALETTE_COUNT * 4); - - s->stride = s->current_frame.linesize[0]; - s->stream_ptr = s->buf + 14; /* data starts 14 bytes in */ - s->stream_end = s->buf + s->size; - s->line_inc = s->stride - 8; - s->upper_motion_limit_offset = (s->avctx->height - 8) * s->stride - + s->avctx->width - 8; - s->dsp = s->dsp; - - for (y = 0; y < (s->stride * s->avctx->height); y += s->stride * 8) { - for (x = y; x < y + s->avctx->width; x += 8) { - /* bottom nibble first, then top nibble (which makes it - * hard to use a GetBitcontext) */ - if (index & 1) - opcode = s->decoding_map[index >> 1] >> 4; - else - opcode = s->decoding_map[index >> 1] & 0xF; - index++; - - debug_interplay(" block @ (%3d, %3d): encoding 0x%X, data ptr @ %p\n", - x - y, y / s->stride, opcode, s->stream_ptr); - code_counts[opcode]++; - - s->pixel_ptr = s->current_frame.data[0] + x; - ret = ipvideo_decode_block[opcode](s); - if (ret != 0) { - printf(" Interplay video: decode problem on frame %d, @ block (%d, %d)\n", - frame, x - y, y / s->stride); - return; - } - } - } - if ((s->stream_ptr != s->stream_end) && - (s->stream_ptr + 1 != s->stream_end)) { - printf (" Interplay video: decode finished with %d bytes left over\n", - s->stream_end - s->stream_ptr); - } -} - -static int ipvideo_decode_init(AVCodecContext *avctx) -{ - IpvideoContext *s = avctx->priv_data; - - s->avctx = avctx; - - if (s->avctx->extradata_size != sizeof(AVPaletteControl)) { - printf (" Interplay video: expected extradata_size of %d\n", - sizeof(AVPaletteControl)); - return -1; - } - - avctx->pix_fmt = PIX_FMT_PAL8; - avctx->has_b_frames = 0; - dsputil_init(&s->dsp, avctx); - - /* decoding map contains 4 bits of information per 8x8 block */ - s->decoding_map_size = avctx->width * avctx->height / (8 * 8 * 2); - - /* assign block decode functions */ - ipvideo_decode_block[0x0] = ipvideo_decode_block_opcode_0x0; - ipvideo_decode_block[0x1] = ipvideo_decode_block_opcode_0x1; - ipvideo_decode_block[0x2] = ipvideo_decode_block_opcode_0x2; - ipvideo_decode_block[0x3] = ipvideo_decode_block_opcode_0x3; - ipvideo_decode_block[0x4] = ipvideo_decode_block_opcode_0x4; - ipvideo_decode_block[0x5] = ipvideo_decode_block_opcode_0x5; - ipvideo_decode_block[0x6] = ipvideo_decode_block_opcode_0x6; - ipvideo_decode_block[0x7] = ipvideo_decode_block_opcode_0x7; - ipvideo_decode_block[0x8] = ipvideo_decode_block_opcode_0x8; - ipvideo_decode_block[0x9] = ipvideo_decode_block_opcode_0x9; - ipvideo_decode_block[0xA] = ipvideo_decode_block_opcode_0xA; - ipvideo_decode_block[0xB] = ipvideo_decode_block_opcode_0xB; - ipvideo_decode_block[0xC] = ipvideo_decode_block_opcode_0xC; - ipvideo_decode_block[0xD] = ipvideo_decode_block_opcode_0xD; - ipvideo_decode_block[0xE] = ipvideo_decode_block_opcode_0xE; - ipvideo_decode_block[0xF] = ipvideo_decode_block_opcode_0xF; - - s->current_frame.data[0] = s->last_frame.data[0] = - s->second_last_frame.data[0] = NULL; - - return 0; -} - -static int ipvideo_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - IpvideoContext *s = avctx->priv_data; - AVPaletteControl *palette_control = (AVPaletteControl *)avctx->extradata; - - if (palette_control->palette_changed) { - /* load the new palette and reset the palette control */ - ipvideo_new_palette(s, palette_control->palette); - palette_control->palette_changed = 0; - } - - s->decoding_map = buf; - s->buf = buf + s->decoding_map_size; - s->size = buf_size - s->decoding_map_size; - - s->current_frame.reference = 3; - if (avctx->get_buffer(avctx, &s->current_frame)) { - printf (" Interplay Video: get_buffer() failed\n"); - return -1; - } - - ipvideo_decode_opcodes(s); - - *data_size = sizeof(AVFrame); - *(AVFrame*)data = s->current_frame; - - /* shuffle frames */ - if (s->second_last_frame.data[0]) - avctx->release_buffer(avctx, &s->second_last_frame); - s->second_last_frame = s->last_frame; - s->last_frame = s->current_frame; - s->current_frame.data[0] = NULL; /* catch any access attempts */ - - /* report that the buffer was completely consumed */ - return buf_size; -} - -static int ipvideo_decode_end(AVCodecContext *avctx) -{ - IpvideoContext *s = avctx->priv_data; - - /* release the last frame */ - if (s->last_frame.data[0]) - avctx->release_buffer(avctx, &s->last_frame); - if (s->second_last_frame.data[0]) - avctx->release_buffer(avctx, &s->second_last_frame); - - return 0; -} - -AVCodec interplay_video_decoder = { - "interplayvideo", - CODEC_TYPE_VIDEO, - CODEC_ID_INTERPLAY_VIDEO, - sizeof(IpvideoContext), - ipvideo_decode_init, - NULL, - ipvideo_decode_end, - ipvideo_decode_frame, - CODEC_CAP_DR1, -}; diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/jfdctfst.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/jfdctfst.c deleted file mode 100644 index 899768d..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/jfdctfst.c +++ /dev/null @@ -1,236 +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 -#include -#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)) - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -fdct_ifast (DCTELEM * data) -{ - DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - DCTELEM tmp10, tmp11, tmp12, tmp13; - DCTELEM 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 */ - } - - /* 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 */ - } -} - - -#undef GLOBAL -#undef CONST_BITS -#undef DESCALE -#undef FIX_0_541196100 -#undef FIX_1_306562965 diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/jfdctint.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/jfdctint.c deleted file mode 100644 index 702d0a9..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/jfdctint.c +++ /dev/null @@ -1,297 +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 -#include -#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 - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -ff_jpeg_fdct_islow (DCTELEM * data) -{ - int32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - int32_t tmp10, tmp11, tmp12, tmp13; - int32_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 */ - } - - /* 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 */ - } -} diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/jrevdct.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/jrevdct.c deleted file mode 100644 index 3bd78c1..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/jrevdct.c +++ /dev/null @@ -1,1176 +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 (d4) { - if (d2) { - if (d0) { - /* 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 */ - z1 = MULTIPLY(d2 + d6, FIX_0_541196100); - tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); - tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); - - tmp0 = d4 << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp2 - tmp0; - tmp12 = -(tmp0 + tmp2); - } - } else { - if (d0) { - /* 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 { - /* d0 == 0, d2 == 0, d4 != 0, d6 != 0 */ - tmp2 = MULTIPLY(-d6, FIX_1_306562965); - tmp3 = MULTIPLY(d6, FIX_0_541196100); - - tmp0 = d4 << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp2 - tmp0; - tmp12 = -(tmp0 + tmp2); - } - } - } else { - if (d2) { - if (d0) { - /* 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 << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - } else { - /* 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); - - tmp10 = tmp3; - tmp13 = -tmp3; - tmp11 = tmp2; - tmp12 = -tmp2; - } - } else { - if (d0) { - /* d0 != 0, d2 == 0, d4 == 0, d6 != 0 */ - tmp2 = MULTIPLY(-d6, FIX_1_306562965); - tmp3 = MULTIPLY(d6, FIX_0_541196100); - - tmp0 = d0 << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - } else { - /* d0 == 0, d2 == 0, d4 == 0, d6 != 0 */ - tmp2 = MULTIPLY(-d6, FIX_1_306562965); - tmp3 = MULTIPLY(d6, FIX_0_541196100); - - tmp10 = tmp3; - tmp13 = -tmp3; - tmp11 = tmp2; - tmp12 = -tmp2; - } - } - } - } else { - if (d4) { - if (d2) { - if (d0) { - /* 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 */ - tmp2 = MULTIPLY(d2, FIX_0_541196100); - tmp3 = MULTIPLY(d2, FIX_1_306562965); - - tmp0 = d4 << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp2 - tmp0; - tmp12 = -(tmp0 + tmp2); - } - } else { - if (d0) { - /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */ - tmp10 = tmp13 = (d0 + d4) << CONST_BITS; - tmp11 = tmp12 = (d0 - d4) << CONST_BITS; - } else { - /* d0 == 0, d2 == 0, d4 != 0, d6 == 0 */ - tmp10 = tmp13 = d4 << CONST_BITS; - tmp11 = tmp12 = -tmp10; - } - } - } else { - if (d2) { - if (d0) { - /* d0 != 0, d2 != 0, d4 == 0, d6 == 0 */ - tmp2 = MULTIPLY(d2, FIX_0_541196100); - tmp3 = MULTIPLY(d2, FIX_1_306562965); - - tmp0 = d0 << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - } else { - /* d0 == 0, d2 != 0, d4 == 0, d6 == 0 */ - tmp2 = MULTIPLY(d2, FIX_0_541196100); - tmp3 = MULTIPLY(d2, FIX_1_306562965); - - tmp10 = tmp3; - tmp13 = -tmp3; - tmp11 = tmp2; - tmp12 = -tmp2; - } - } else { - if (d0) { - /* d0 != 0, d2 == 0, d4 == 0, d6 == 0 */ - tmp10 = tmp13 = tmp11 = tmp12 = d0 << CONST_BITS; - } else { - /* d0 == 0, d2 == 0, d4 == 0, d6 == 0 */ - tmp10 = tmp13 = tmp11 = tmp12 = 0; - } - } - } - } - - /* 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 (d4) { - if (d2) { - if (d0) { - /* 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 */ - z1 = MULTIPLY(d2 + d6, FIX_0_541196100); - tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); - tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); - - tmp0 = d4 << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp2 - tmp0; - tmp12 = -(tmp0 + tmp2); - } - } else { - if (d0) { - /* 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 { - /* d0 == 0, d2 == 0, d4 != 0, d6 != 0 */ - tmp2 = MULTIPLY(-d6, FIX_1_306562965); - tmp3 = MULTIPLY(d6, FIX_0_541196100); - - tmp0 = d4 << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp2 - tmp0; - tmp12 = -(tmp0 + tmp2); - } - } - } else { - if (d2) { - if (d0) { - /* 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 << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - } else { - /* 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); - - tmp10 = tmp3; - tmp13 = -tmp3; - tmp11 = tmp2; - tmp12 = -tmp2; - } - } else { - if (d0) { - /* d0 != 0, d2 == 0, d4 == 0, d6 != 0 */ - tmp2 = MULTIPLY(-d6, FIX_1_306562965); - tmp3 = MULTIPLY(d6, FIX_0_541196100); - - tmp0 = d0 << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - } else { - /* d0 == 0, d2 == 0, d4 == 0, d6 != 0 */ - tmp2 = MULTIPLY(-d6, FIX_1_306562965); - tmp3 = MULTIPLY(d6, FIX_0_541196100); - - tmp10 = tmp3; - tmp13 = -tmp3; - tmp11 = tmp2; - tmp12 = -tmp2; - } - } - } - } else { - if (d4) { - if (d2) { - if (d0) { - /* 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 */ - tmp2 = MULTIPLY(d2, FIX_0_541196100); - tmp3 = MULTIPLY(d2, FIX_1_306562965); - - tmp0 = d4 << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp2 - tmp0; - tmp12 = -(tmp0 + tmp2); - } - } else { - if (d0) { - /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */ - tmp10 = tmp13 = (d0 + d4) << CONST_BITS; - tmp11 = tmp12 = (d0 - d4) << CONST_BITS; - } else { - /* d0 == 0, d2 == 0, d4 != 0, d6 == 0 */ - tmp10 = tmp13 = d4 << CONST_BITS; - tmp11 = tmp12 = -tmp10; - } - } - } else { - if (d2) { - if (d0) { - /* d0 != 0, d2 != 0, d4 == 0, d6 == 0 */ - tmp2 = MULTIPLY(d2, FIX_0_541196100); - tmp3 = MULTIPLY(d2, FIX_1_306562965); - - tmp0 = d0 << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - } else { - /* d0 == 0, d2 != 0, d4 == 0, d6 == 0 */ - tmp2 = MULTIPLY(d2, FIX_0_541196100); - tmp3 = MULTIPLY(d2, FIX_1_306562965); - - tmp10 = tmp3; - tmp13 = -tmp3; - tmp11 = tmp2; - tmp12 = -tmp2; - } - } else { - if (d0) { - /* d0 != 0, d2 == 0, d4 == 0, d6 == 0 */ - tmp10 = tmp13 = tmp11 = tmp12 = d0 << CONST_BITS; - } else { - /* d0 == 0, d2 == 0, d4 == 0, d6 == 0 */ - tmp10 = tmp13 = tmp11 = tmp12 = 0; - } - } - } - } - - /* 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 FIX -#undef CONST_BITS diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/a52.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/a52.h deleted file mode 100644 index d3346ec..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/a52.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * a52.h - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/a52_internal.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/a52_internal.h deleted file mode 100644 index 5235704..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/a52_internal.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * a52_internal.h - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/a52_util.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/a52_util.h deleted file mode 100644 index 121393e..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/a52_util.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * a52_util.h - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/bit_allocate.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/bit_allocate.c deleted file mode 100644 index 7b595a0..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/bit_allocate.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * bit_allocate.c - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/bitstream.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/bitstream.c deleted file mode 100644 index 89b69cf..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/bitstream.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * bitstream.c - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/bitstream.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/bitstream.h deleted file mode 100644 index f559fbf..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/bitstream.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * bitstream.h - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/crc.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/crc.c deleted file mode 100644 index 6698155..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/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 -#include -#include - -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>8)] ^ (state<<8); - - return state; -} diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/downmix.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/downmix.c deleted file mode 100644 index a4ce747..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/downmix.c +++ /dev/null @@ -1,679 +0,0 @@ -/* - * downmix.c - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/imdct.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/imdct.c deleted file mode 100644 index 7a1690b..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/imdct.c +++ /dev/null @@ -1,411 +0,0 @@ -/* - * imdct.c - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/mm_accel.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/mm_accel.h deleted file mode 100644 index 8afbd35..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/mm_accel.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * mm_accel.h - * Copyright (C) 2000-2002 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/parse.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/parse.c deleted file mode 100644 index d3e6914..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/parse.c +++ /dev/null @@ -1,939 +0,0 @@ -/* - * parse.c - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/resample.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/resample.c deleted file mode 100644 index bb7de91..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/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) fprintf(stderr, "Using MMX optimized resampler\n"); - a52_resample=tmp; - return tmp; - } - } -#endif - - tmp=a52_resample_C(flags,chans); - if(tmp){ - if(a52_resample==NULL) fprintf(stderr, "No accelerated resampler found\n"); - a52_resample=tmp; - return tmp; - } - - fprintf(stderr, "Unimplemented resampler for mode 0x%X -> %d channels conversion - Contact MPlayer developers!\n", flags, chans); - return NULL; -} diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/resample_c.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/resample_c.c deleted file mode 100644 index a618ec6..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/resample_mmx.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/resample_mmx.c deleted file mode 100644 index a407979..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/resample_mmx.c +++ /dev/null @@ -1,518 +0,0 @@ - -// MMX optimizations from Michael Niedermayer (michaelni@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))) magicF2W= 0x43c0000043c00000LL; -static uint64_t __attribute__((aligned(8))) wm1010= 0xFFFF0000FFFF0000LL; -static uint64_t __attribute__((aligned(8))) wm0101= 0x0000FFFF0000FFFFLL; -static uint64_t __attribute__((aligned(8))) 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/tables.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/tables.h deleted file mode 100644 index b067c63..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/liba52/tables.h +++ /dev/null @@ -1,246 +0,0 @@ -/* - * tables.h - * Copyright (C) 2000-2003 Michel Lespinasse - * Copyright (C) 1999-2000 Aaron Holtzman - * - * 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/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/Makefile b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/Makefile deleted file mode 100755 index 3733f3a..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/Makefile +++ /dev/null @@ -1,66 +0,0 @@ - -include ../../config.mak - -ifeq ($(SHARED_PP),yes) -SPPLIB = libpostproc.so -SPPVERSION = 0.0.1 -endif -PPLIB = libpostproc.a - -PPOBJS=postprocess.o -SPPOBJS=postprocess_pic.o - -CFLAGS = $(OPTFLAGS) $(MLIB_INC) -I. -I.. $(EXTRA_INC) -# -I/usr/X11R6/include/ - -.SUFFIXES: .c .o - -# .PHONY: all clean - -.c.o: - $(CC) -c $(CFLAGS) -I.. -I../.. -o $@ $< - -all: $(SWSLIB) $(PPLIB) $(SPPLIB) - -clean: - rm -f *.o *.a *~ *.so - -distclean: - rm -f Makefile.bak *.o *.a *~ *.so .depend - -dep: depend - -depend: - $(CC) -MM $(CFLAGS) postprocess.c 1>.depend - -ifeq ($(SHARED_PP),yes) -postprocess_pic.o: postprocess.c - $(CC) -c $(CFLAGS) -fomit-frame-pointer -fPIC -DPIC -I.. -I../.. -o $@ $< - -$(SPPLIB): $(SPPOBJS) - $(CC) -shared -Wl,-soname,$(SPPLIB).0 \ - -o $(SPPLIB) $(SPPOBJS) -endif - -$(PPLIB): $(PPOBJS) - rm -f $@ - $(AR) rc $@ $(PPOBJS) - $(RANLIB) $@ - -install: all -ifeq ($(SHARED_PP),yes) - install -d $(prefix)/lib - install -s -m 755 $(SPPLIB) $(prefix)/lib/$(SPPLIB).$(SPPVERSION) - ln -sf $(SPPLIB).$(SPPVERSION) $(prefix)/lib/$(SPPLIB) - ldconfig || true - mkdir -p $(prefix)/include/postproc - install -m 644 postprocess.h $(prefix)/include/postproc/postprocess.h -endif - - -# -# include dependency files if they exist -# -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/mangle.h b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/mangle.h deleted file mode 100644 index f3894cc..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/mangle.h +++ /dev/null @@ -1,19 +0,0 @@ -/* mangle.h - This file has some CPP macros to deal with different symbol - * mangling across binary formats. - * (c)2002 by Felix Buenemann - * 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 */ -#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__OS2__) || \ - (defined(__OpenBSD__) && !defined(__ELF__)) -#define MANGLE(a) "_" #a -#else -#define MANGLE(a) #a -#endif - -#endif /* !__MANGLE_H */ - diff --git a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/postprocess.c b/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/postprocess.c deleted file mode 100644 index b7e9fea..0000000 --- a/synfig-core/trunk/src/modules/mod_libavcodec/libavcodec/libpostproc/postprocess.c +++ /dev/null @@ -1,986 +0,0 @@ -/* - Copyright (C) 2001-2003 Michael Niedermayer (michaelni@gmx.at) - - 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 -*/ - -/** - * @file postprocess.c - * postprocessing. - */ - -/* - C MMX MMX2 3DNow -isVertDC Ec Ec -isVertMinMaxOk Ec Ec -doVertLowPass E e e -doVertDefFilter Ec Ec e e -isHorizDC Ec Ec -isHorizMinMaxOk a E -doHorizLowPass E e e -doHorizDefFilter Ec Ec e e -deRing E e e* -Vertical RKAlgo1 E a a -Horizontal RKAlgo1 a a -Vertical X1# a E E -Horizontal X1# a E E -LinIpolDeinterlace e E E* -CubicIpolDeinterlace a e e* -LinBlendDeinterlace e E E* -MedianDeinterlace# E Ec Ec -TempDeNoiser# E e e - -* i dont have a 3dnow CPU -> its untested, but noone said it doesnt work so it seems to work -# more or less selfinvented filters so the exactness isnt too meaningfull -E = Exact implementation -e = allmost exact implementation (slightly different rounding,...) -a = alternative / approximate impl -c = checked against the other implementations (-vo md5) -*/ - -/* -TODO: -reduce the time wasted on the mem transfer -unroll stuff if instructions depend too much on the prior one -move YScale thing to the end instead of fixing QP -write a faster and higher quality deblocking filter :) -make the mainloop more flexible (variable number of blocks at once - (the if/else stuff per block is slowing things down) -compare the quality & speed of all filters -split this huge file -optimize c versions -try to unroll inner for(x=0 ... loop to avoid these damn if(x ... checks -... -*/ - -//Changelog: use the CVS log - -#include "config.h" -#include -#include -#include -#include -#ifdef HAVE_MALLOC_H -#include -#endif -//#undef HAVE_MMX2 -//#define HAVE_3DNOW -//#undef HAVE_MMX -//#undef ARCH_X86 -//#define DEBUG_BRIGHTNESS -#ifdef USE_FASTMEMCPY -#include "../fastmemcpy.h" -#endif -#include "postprocess.h" -#include "postprocess_internal.h" - -#include "mangle.h" //FIXME should be supressed - -#ifndef HAVE_MEMALIGN -#define memalign(a,b) malloc(b) -#endif - -#define MIN(a,b) ((a) > (b) ? (b) : (a)) -#define MAX(a,b) ((a) < (b) ? (b) : (a)) -#define ABS(a) ((a) > 0 ? (a) : (-(a))) -#define SIGN(a) ((a) > 0 ? 1 : -1) - -#define GET_MODE_BUFFER_SIZE 500 -#define OPTIONS_ARRAY_SIZE 10 -#define BLOCK_SIZE 8 -#define TEMP_STRIDE 8 -//#define NUM_BLOCKS_AT_ONCE 16 //not used yet - -#ifdef ARCH_X86 -static uint64_t __attribute__((aligned(8))) w05= 0x0005000500050005LL; -static uint64_t __attribute__((aligned(8))) w20= 0x0020002000200020LL; -static uint64_t __attribute__((aligned(8))) b00= 0x0000000000000000LL; -static uint64_t __attribute__((aligned(8))) b01= 0x0101010101010101LL; -static uint64_t __attribute__((aligned(8))) b02= 0x0202020202020202LL; -static uint64_t __attribute__((aligned(8))) b08= 0x0808080808080808LL; -static uint64_t __attribute__((aligned(8))) b80= 0x8080808080808080LL; -#endif - - -static uint8_t clip_table[3*256]; -static uint8_t * const clip_tab= clip_table + 256; - -static int verbose= 0; - -static const int deringThreshold= 20; - - -static struct PPFilter filters[]= -{ - {"hb", "hdeblock", 1, 1, 3, H_DEBLOCK}, - {"vb", "vdeblock", 1, 2, 4, V_DEBLOCK}, -/* {"hr", "rkhdeblock", 1, 1, 3, H_RK1_FILTER}, - {"vr", "rkvdeblock", 1, 2, 4, V_RK1_FILTER},*/ - {"h1", "x1hdeblock", 1, 1, 3, H_X1_FILTER}, - {"v1", "x1vdeblock", 1, 2, 4, V_X1_FILTER}, - {"dr", "dering", 1, 5, 6, DERING}, - {"al", "autolevels", 0, 1, 2, LEVEL_FIX}, - {"lb", "linblenddeint", 1, 1, 4, INTERPOLATION_LINEAR_BLEND_DEINT_FILTER}, - {"li", "linipoldeint", 1, 1, 4, INTERPOLATION_LINEAR_IPOL_DEINT_FILTER}, - {"ci", "cubicipoldeint", 1, 1, 4, CUBIC_IPOL_DEINT_FILTER}, - {"md", "mediandeint", 1, 1, 4, MEDIAN_DEINT_FILTER}, - {"fd", "ffmpegdeint", 1, 1, 4, FFMPEG_DEINT_FILTER}, - {"l5", "lowpass5", 1, 1, 4, LOWPASS5_DEINT_FILTER}, - {"tn", "tmpnoise", 1, 7, 8, TEMP_NOISE_FILTER}, - {"fq", "forcequant", 1, 0, 0, FORCE_QUANT}, - {NULL, NULL,0,0,0,0} //End Marker -}; - -static char *replaceTable[]= -{ - "default", "hdeblock:a,vdeblock:a,dering:a,autolevels,tmpnoise:a:150:200:400", - "de", "hdeblock:a,vdeblock:a,dering:a,autolevels,tmpnoise:a:150:200:400", - "fast", "x1hdeblock:a,x1vdeblock:a,dering:a,autolevels,tmpnoise:a:150:200:400", - "fa", "x1hdeblock:a,x1vdeblock:a,dering:a,autolevels,tmpnoise:a:150:200:400", - NULL //End Marker -}; - -#ifdef ARCH_X86 -static inline void unusedVariableWarningFixer() -{ - if(w05 + w20 + b00 + b01 + b02 + b08 + b80 == 0) b00=0; -} -#endif - - -#ifdef ARCH_X86 -static inline void prefetchnta(void *p) -{ - asm volatile( "prefetchnta (%0)\n\t" - : : "r" (p) - ); -} - -static inline void prefetcht0(void *p) -{ - asm volatile( "prefetcht0 (%0)\n\t" - : : "r" (p) - ); -} - -static inline void prefetcht1(void *p) -{ - asm volatile( "prefetcht1 (%0)\n\t" - : : "r" (p) - ); -} - -static inline void prefetcht2(void *p) -{ - asm volatile( "prefetcht2 (%0)\n\t" - : : "r" (p) - ); -} -#endif - -// The horizontal Functions exist only in C cuz the MMX code is faster with vertical filters and transposing - -/** - * Check if the given 8x8 Block is mostly "flat" - */ -static inline int isHorizDC(uint8_t src[], int stride, PPContext *c) -{ - int numEq= 0; - int y; - const int dcOffset= ((c->nonBQP*c->ppMode.baseDcDiff)>>8) + 1; - const int dcThreshold= dcOffset*2 + 1; - - for(y=0; y c->ppMode.flatnessThreshold; -} - -/** - * Check if the middle 8x8 Block in the given 8x16 block is flat - */ -static inline int isVertDC_C(uint8_t src[], int stride, PPContext *c){ - int numEq= 0; - int y; - const int dcOffset= ((c->nonBQP*c->ppMode.baseDcDiff)>>8) + 1; - const int dcThreshold= dcOffset*2 + 1; - - src+= stride*4; // src points to begin of the 8x8 Block - for(y=0; y c->ppMode.flatnessThreshold; -} - -static inline int isHorizMinMaxOk(uint8_t src[], int stride, int QP) -{ - int i; -#if 1 - for(i=0; i<2; i++){ - if((unsigned)(src[0] - src[5] + 2*QP) > 4*QP) return 0; - src += stride; - if((unsigned)(src[2] - src[7] + 2*QP) > 4*QP) return 0; - src += stride; - if((unsigned)(src[4] - src[1] + 2*QP) > 4*QP) return 0; - src += stride; - if((unsigned)(src[6] - src[3] + 2*QP) > 4*QP) return 0; - src += stride; - } -#else - for(i=0; i<8; i++){ - if((unsigned)(src[0] - src[7] + 2*QP) > 4*QP) return 0; - src += stride; - } -#endif - return 1; -} - -static inline int isVertMinMaxOk_C(uint8_t src[], int stride, int QP) -{ -#if 1 -#if 1 - int x; - src+= stride*4; - for(x=0; x 4*QP) return 0; - if((unsigned)(src[1+x + 2*stride] - src[1+x + 7*stride] + 2*QP) > 4*QP) return 0; - if((unsigned)(src[2+x + 4*stride] - src[2+x + 1*stride] + 2*QP) > 4*QP) return 0; - if((unsigned)(src[3+x + 6*stride] - src[3+x + 3*stride] + 2*QP) > 4*QP) return 0; - } -#else - int x; - src+= stride*3; - for(x=0; x 4*QP) return 0; - } -#endif - return 1; -#else - int x; - src+= stride*4; - for(x=0; xmax) max=v; - if(v 2*QP) return 0; - } - return 1; -#endif -} - -static inline int vertClassify_C(uint8_t src[], int stride, PPContext *c){ - if( isVertDC_C(src, stride, c) ){ - if( isVertMinMaxOk_C(src, stride, c->QP) ) - return 1; - else - return 0; - }else{ - return 2; - } -} - -static inline void doHorizDefFilter(uint8_t dst[], int stride, int QP) -{ - int y; - for(y=0; y> 6; - d*= SIGN(-middleEnergy); - - if(q>0) - { - d= d<0 ? 0 : d; - d= d>q ? q : d; - } - else - { - d= d>0 ? 0 : d; - d= d>4; - dst[1]= ((dst[1]<<2) + ((first + sums[0] + sums[3])<<1) + sums[5] + 8)>>4; - dst[2]= ((dst[2]<<2) + ((first + sums[1] + sums[4])<<1) + sums[6] + 8)>>4; - dst[3]= ((dst[3]<<2) + ((sums[2] + sums[5])<<1) + sums[0] + sums[7] + 8)>>4; - dst[4]= ((dst[4]<<2) + ((sums[3] + sums[6])<<1) + sums[1] + sums[8] + 8)>>4; - dst[5]= ((dst[5]<<2) + ((last + sums[7] + sums[4])<<1) + sums[2] + 8)>>4; - dst[6]= (((last + dst[6])<<2) + ((dst[7] + sums[5])<<1) + sums[3] + 8)>>4; - dst[7]= ((sums[8]<<2) + ((last + sums[6])<<1) + sums[4] + 8)>>4; - - dst+= stride; - } -} - -/** - * Experimental Filter 1 (Horizontal) - * will not damage linear gradients - * Flat blocks should look like they where passed through the (1,1,2,2,4,2,2,1,1) 9-Tap filter - * can only smooth blocks at the expected locations (it cant smooth them if they did move) - * MMX2 version does correct clipping C version doesnt - * not identical with the vertical one - */ -static inline void horizX1Filter(uint8_t *src, int stride, int QP) -{ - int y; - static uint64_t *lut= NULL; - if(lut==NULL) - { - int i; - lut= (uint64_t*)memalign(8, 256*8); - for(i=0; i<256; i++) - { - int v= i < 128 ? 2*i : 2*(i-256); -/* -//Simulate 112242211 9-Tap filter - uint64_t a= (v/16) & 0xFF; - uint64_t b= (v/8) & 0xFF; - uint64_t c= (v/4) & 0xFF; - uint64_t d= (3*v/8) & 0xFF; -*/ -//Simulate piecewise linear interpolation - uint64_t a= (v/16) & 0xFF; - uint64_t b= (v*3/16) & 0xFF; - uint64_t c= (v*5/16) & 0xFF; - uint64_t d= (7*v/16) & 0xFF; - uint64_t A= (0x100 - a)&0xFF; - uint64_t B= (0x100 - b)&0xFF; - uint64_t C= (0x100 - c)&0xFF; - uint64_t D= (0x100 - c)&0xFF; - - lut[i] = (a<<56) | (b<<48) | (c<<40) | (d<<32) | - (D<<24) | (C<<16) | (B<<8) | (A); - //lut[i] = (v<<32) | (v<<24); - } - } - - for(y=0; yppMode= *ppMode; //FIXME - - // useing ifs here as they are faster than function pointers allthough the - // difference wouldnt be messureable here but its much better because - // someone might exchange the cpu whithout restarting mplayer ;) -#ifdef RUNTIME_CPUDETECT -#ifdef ARCH_X86 - // ordered per speed fasterst first - if(c->cpuCaps & PP_CPU_CAPS_MMX2) - postProcess_MMX2(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); - else if(c->cpuCaps & PP_CPU_CAPS_3DNOW) - postProcess_3DNow(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); - else if(c->cpuCaps & PP_CPU_CAPS_MMX) - postProcess_MMX(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); - else - postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); -#else - postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); -#endif -#else //RUNTIME_CPUDETECT -#ifdef HAVE_MMX2 - postProcess_MMX2(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); -#elif defined (HAVE_3DNOW) - postProcess_3DNow(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); -#elif defined (HAVE_MMX) - postProcess_MMX(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); -#else - postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c); -#endif -#endif //!RUNTIME_CPUDETECT -} - -//static void postProcess(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, -// QP_STORE_T QPs[], int QPStride, int isColor, struct PPMode *ppMode); - -/* -pp Command line Help -*/ -char *pp_help= -"[: