From d955718bfced1427f43980c2a69d02de797a59ca Mon Sep 17 00:00:00 2001 From: theuni Date: Wed, 14 Jul 2010 06:12:20 +0000 Subject: [PATCH] updated ffmpeg to r24229, libswscale 31722 git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@31787 568bbfeb-2a22-0410-94d2-cc84cf5bfa90 --- xbmc/cores/dvdplayer/Codecs/ffmpeg/Changelog | 11 + xbmc/cores/dvdplayer/Codecs/ffmpeg/Doxyfile | 806 ++++++-- .../cores/dvdplayer/Codecs/ffmpeg/MAINTAINERS | 9 +- xbmc/cores/dvdplayer/Codecs/ffmpeg/Makefile | 158 +- .../dvdplayer/Codecs/ffmpeg/build_xbmc.sh | 30 - .../Codecs/ffmpeg/build_xbmc_win32.sh | 55 - xbmc/cores/dvdplayer/Codecs/ffmpeg/cmdutils.c | 3 +- xbmc/cores/dvdplayer/Codecs/ffmpeg/cmdutils.h | 44 +- xbmc/cores/dvdplayer/Codecs/ffmpeg/common.mak | 13 +- xbmc/cores/dvdplayer/Codecs/ffmpeg/configure | 411 ++-- .../dvdplayer/Codecs/ffmpeg/doc/APIchanges | 69 +- xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/TODO | 8 - .../dvdplayer/Codecs/ffmpeg/doc/faq.texi | 2 - .../Codecs/ffmpeg/doc/ffmpeg-doc.texi | 69 +- ...g_powerpc_performance_evaluation_howto.txt | 172 -- .../Codecs/ffmpeg/doc/ffplay-doc.texi | 31 +- .../Codecs/ffmpeg/doc/ffprobe-doc.texi | 23 +- .../Codecs/ffmpeg/doc/ffserver-doc.texi | 19 +- .../dvdplayer/Codecs/ffmpeg/doc/ffserver.conf | 21 + .../ffmpeg/doc/fftools-common-opts.texi | 17 + .../dvdplayer/Codecs/ffmpeg/doc/filters.texi | 258 +++ .../dvdplayer/Codecs/ffmpeg/doc/general.texi | 29 +- .../Codecs/ffmpeg/doc/libavfilter.texi | 240 +-- .../dvdplayer/Codecs/ffmpeg/doc/tablegen.txt | 8 +- .../dvdplayer/Codecs/ffmpeg/doc/texi2pod.pl | 34 +- xbmc/cores/dvdplayer/Codecs/ffmpeg/ffmpeg.c | 128 +- xbmc/cores/dvdplayer/Codecs/ffmpeg/ffplay.c | 42 +- .../ffpresets/libx264-superfast.ffpreset | 1 + .../libx264-superfast_firstpass.ffpreset | 1 + .../ffpresets/libx264-ultrafast.ffpreset | 1 + .../libx264-ultrafast_firstpass.ffpreset | 1 + .../ffpresets/libx264-veryfast.ffpreset | 3 +- .../libx264-veryfast_firstpass.ffpreset | 3 +- xbmc/cores/dvdplayer/Codecs/ffmpeg/ffserver.c | 105 +- .../Codecs/ffmpeg/include/dxva2/dxva2api.h | 501 ----- .../ffmpeg/include/libavutil/avconfig.h | 5 - .../dvdplayer/Codecs/ffmpeg/libavcodec/4xm.c | 12 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/8bps.c | 2 +- .../Codecs/ffmpeg/libavcodec/Makefile | 42 +- .../ffmpeg/libavcodec/aac_adtstoasc_bsf.c | 2 +- .../Codecs/ffmpeg/libavcodec/aac_parser.c | 47 +- .../Codecs/ffmpeg/libavcodec/aac_tablegen.c | 37 + .../Codecs/ffmpeg/libavcodec/aac_tablegen.h | 42 + .../ffmpeg/libavcodec/aac_tablegen_decl.h | 34 + .../Codecs/ffmpeg/libavcodec/aacadtsdec.c | 70 + .../libavcodec/{aac_parser.h => aacadtsdec.h} | 17 +- .../Codecs/ffmpeg/libavcodec/aaccoder.c | 4 +- .../Codecs/ffmpeg/libavcodec/aacdec.c | 102 +- .../Codecs/ffmpeg/libavcodec/aacenc.c | 30 +- .../Codecs/ffmpeg/libavcodec/aacps.c | 1037 ++++++++++ .../Codecs/ffmpeg/libavcodec/aacps.h | 82 + .../Codecs/ffmpeg/libavcodec/aacps_tablegen.c | 93 + .../Codecs/ffmpeg/libavcodec/aacps_tablegen.h | 212 ++ .../Codecs/ffmpeg/libavcodec/aacpsdata.c | 163 ++ .../Codecs/ffmpeg/libavcodec/aacpsy.c | 15 +- .../Codecs/ffmpeg/libavcodec/aacsbr.c | 67 +- .../Codecs/ffmpeg/libavcodec/aactab.c | 127 +- .../Codecs/ffmpeg/libavcodec/aactab.h | 7 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/ac3.c | 4 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/ac3.h | 6 +- .../Codecs/ffmpeg/libavcodec/ac3_parser.c | 4 +- .../Codecs/ffmpeg/libavcodec/ac3_parser.h | 16 +- .../Codecs/ffmpeg/libavcodec/ac3enc.c | 4 +- .../Codecs/ffmpeg/libavcodec/ac3tab.c | 4 +- .../ffmpeg/libavcodec/acelp_pitch_delay.h | 17 +- .../Codecs/ffmpeg/libavcodec/acelp_vectors.h | 10 +- .../Codecs/ffmpeg/libavcodec/adpcm.c | 140 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/alac.c | 10 +- .../Codecs/ffmpeg/libavcodec/alacenc.c | 3 +- .../Codecs/ffmpeg/libavcodec/allcodecs.c | 13 +- .../libavcodec/alpha/dsputil_alpha_asm.S | 15 - .../libavcodec/alpha/motion_est_mvi_asm.S | 5 - .../Codecs/ffmpeg/libavcodec/alsdec.c | 145 +- .../Codecs/ffmpeg/libavcodec/apedec.c | 2 +- .../Codecs/ffmpeg/libavcodec/arm/Makefile | 7 +- .../ffmpeg/libavcodec/arm/asm-offsets.h | 2 +- .../Codecs/ffmpeg/libavcodec/arm/asm.S | 36 +- .../ffmpeg/libavcodec/arm/dsputil_init_neon.c | 6 +- .../Codecs/ffmpeg/libavcodec/arm/fft_neon.S | 4 +- .../ffmpeg/libavcodec/arm/h264pred_init_arm.c | 7 +- .../Codecs/ffmpeg/libavcodec/arm/mdct_neon.S | 18 +- .../ffmpeg/libavcodec/arm/simple_idct_neon.S | 1 - .../dvdplayer/Codecs/ffmpeg/libavcodec/asv1.c | 4 +- .../Codecs/ffmpeg/libavcodec/atrac3.c | 6 +- .../Codecs/ffmpeg/libavcodec/avcodec.h | 179 +- .../Codecs/ffmpeg/libavcodec/avfft.c | 16 +- .../Codecs/ffmpeg/libavcodec/avfft.h | 2 +- .../Codecs/ffmpeg/libavcodec/beosthread.c | 183 -- .../ffmpeg/libavcodec/bfin/dsputil_bfin.c | 12 - .../Codecs/ffmpeg/libavcodec/bfin/vp3_bfin.c | 4 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/bgmc.c | 12 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/bink.c | 18 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/bmp.c | 3 +- .../Codecs/ffmpeg/libavcodec/cavsdata.h | 6 +- .../Codecs/ffmpeg/libavcodec/cbrt_tablegen.c | 4 +- .../Codecs/ffmpeg/libavcodec/cdgraphics.c | 1 + .../Codecs/ffmpeg/libavcodec/celp_math.h | 2 +- .../Codecs/ffmpeg/libavcodec/cga_data.c | 11 + .../Codecs/ffmpeg/libavcodec/cga_data.h | 1 + .../Codecs/ffmpeg/libavcodec/chomp_bsf.c | 2 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/cook.c | 28 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/dca.c | 540 +++-- .../dvdplayer/Codecs/ffmpeg/libavcodec/dct.c | 16 + .../Codecs/ffmpeg/libavcodec/dct32.c | 267 +++ .../Codecs/ffmpeg/libavcodec/dirac.h | 2 +- .../Codecs/ffmpeg/libavcodec/dirac_parser.c | 2 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/dpcm.c | 2 +- .../Codecs/ffmpeg/libavcodec/dsputil.c | 35 +- .../Codecs/ffmpeg/libavcodec/dsputil.h | 4 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/dv.c | 1 + .../Codecs/ffmpeg/libavcodec/dv_tablegen.c | 6 +- .../Codecs/ffmpeg/libavcodec/dv_tablegen.h | 4 +- .../Codecs/ffmpeg/libavcodec/dvbsub.c | 2 +- .../Codecs/ffmpeg/libavcodec/dvbsubdec.c | 93 +- .../Codecs/ffmpeg/libavcodec/dvdsubdec.c | 101 +- .../Codecs/ffmpeg/libavcodec/eamad.c | 2 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/elbg.c | 40 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/fft.c | 96 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/fft.h | 20 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/ffv1.c | 35 +- .../Codecs/ffmpeg/libavcodec/flacenc.c | 115 +- .../Codecs/ffmpeg/libavcodec/flvdec.c | 1 + .../Codecs/ffmpeg/libavcodec/fraps.c | 2 +- .../Codecs/ffmpeg/libavcodec/get_bits.h | 4 +- .../Codecs/ffmpeg/libavcodec/gsmdec.c | 316 +++ .../Codecs/ffmpeg/libavcodec/h261dec.c | 1 + .../Codecs/ffmpeg/libavcodec/h261enc.c | 2 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/h263.h | 6 +- .../Codecs/ffmpeg/libavcodec/h263dec.c | 1 + .../dvdplayer/Codecs/ffmpeg/libavcodec/h264.c | 9 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/h264.h | 26 +- .../ffmpeg/libavcodec/h264_mp4toannexb_bsf.c | 76 +- .../Codecs/ffmpeg/libavcodec/h264_refs.c | 34 +- .../Codecs/ffmpeg/libavcodec/h264idct.c | 8 +- .../Codecs/ffmpeg/libavcodec/h264pred.c | 178 +- .../Codecs/ffmpeg/libavcodec/h264pred.h | 5 +- .../Codecs/ffmpeg/libavcodec/huffyuv.c | 13 +- .../Codecs/ffmpeg/libavcodec/idcinvideo.c | 2 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/iff.c | 36 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/imc.c | 2 +- .../Codecs/ffmpeg/libavcodec/imgconvert.c | 2 +- .../Codecs/ffmpeg/libavcodec/indeo3.c | 66 +- .../Codecs/ffmpeg/libavcodec/indeo5.c | 59 +- .../Codecs/ffmpeg/libavcodec/indeo5data.h | 108 +- .../Codecs/ffmpeg/libavcodec/internal.h | 4 +- .../Codecs/ffmpeg/libavcodec/ituh263enc.c | 4 +- .../Codecs/ffmpeg/libavcodec/ivi_common.c | 9 +- .../Codecs/ffmpeg/libavcodec/ivi_common.h | 55 +- .../Codecs/ffmpeg/libavcodec/ivi_dsp.h | 6 +- .../Codecs/ffmpeg/libavcodec/kgv1dec.c | 1 + .../Codecs/ffmpeg/libavcodec/latm_parser.c | 118 -- .../Codecs/ffmpeg/libavcodec/latmaac.c | 391 ---- .../Codecs/ffmpeg/libavcodec/lcldec.c | 2 +- .../Codecs/ffmpeg/libavcodec/libfaad.c | 333 --- .../Codecs/ffmpeg/libavcodec/libgsm.c | 4 +- .../Codecs/ffmpeg/libavcodec/libopenjpeg.c | 1 + .../Codecs/ffmpeg/libavcodec/libtheoraenc.c | 2 +- .../Codecs/ffmpeg/libavcodec/libvorbis.c | 28 +- .../Codecs/ffmpeg/libavcodec/libvpxenc.c | 15 +- .../ffmpeg/libavcodec/libxvid_internal.h | 2 +- .../Codecs/ffmpeg/libavcodec/libxvid_rc.c | 2 +- .../Codecs/ffmpeg/libavcodec/libxvidff.c | 62 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/lpc.c | 14 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/lpc.h | 5 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/lsp.c | 6 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/lsp.h | 11 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/lzw.c | 4 +- .../Codecs/ffmpeg/libavcodec/mathops.h | 32 + .../dvdplayer/Codecs/ffmpeg/libavcodec/mdct.c | 4 +- .../Codecs/ffmpeg/libavcodec/mdct_tablegen.h | 4 +- .../Codecs/ffmpeg/libavcodec/mjpegbdec.c | 1 + .../Codecs/ffmpeg/libavcodec/mjpegdec.c | 6 +- .../Codecs/ffmpeg/libavcodec/mlpdec.c | 4 +- .../Codecs/ffmpeg/libavcodec/motion_est.c | 25 +- .../ffmpeg/libavcodec/motionpixels_tablegen.c | 2 +- .../Codecs/ffmpeg/libavcodec/mpeg12.c | 9 +- .../Codecs/ffmpeg/libavcodec/mpeg12enc.c | 2 +- .../Codecs/ffmpeg/libavcodec/mpeg4audio.c | 8 + .../Codecs/ffmpeg/libavcodec/mpeg4videodec.c | 1 + .../Codecs/ffmpeg/libavcodec/mpeg4videoenc.c | 6 +- .../Codecs/ffmpeg/libavcodec/mpegaudio.h | 12 +- .../ffmpeg/libavcodec/mpegaudio_tablegen.c | 29 +- .../ffmpeg/libavcodec/mpegaudio_tablegen.h | 2 - .../Codecs/ffmpeg/libavcodec/mpegaudiodec.c | 423 +--- .../ffmpeg/libavcodec/mpegaudiodec_float.c | 58 + .../Codecs/ffmpeg/libavcodec/mpegaudioenc.c | 5 - .../Codecs/ffmpeg/libavcodec/mpegvideo.c | 30 +- .../ffmpeg/libavcodec/mpegvideo_common.h | 28 +- .../Codecs/ffmpeg/libavcodec/mpegvideo_enc.c | 2 +- .../Codecs/ffmpeg/libavcodec/mpegvideo_xvmc.c | 12 +- .../Codecs/ffmpeg/libavcodec/msmpeg4.c | 4 + .../Codecs/ffmpeg/libavcodec/msrledec.h | 2 +- .../Codecs/ffmpeg/libavcodec/nellymoserdec.c | 25 +- .../Codecs/ffmpeg/libavcodec/nellymoserenc.c | 2 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/opt.h | 4 +- .../Codecs/ffmpeg/libavcodec/options.c | 17 +- .../Codecs/ffmpeg/libavcodec/os2thread.c | 148 -- .../Codecs/ffmpeg/libavcodec/parser.c | 2 +- .../Codecs/ffmpeg/libavcodec/parser.h | 2 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/pcm.c | 4 + .../Codecs/ffmpeg/libavcodec/pcm_tablegen.c | 9 +- .../Codecs/ffmpeg/libavcodec/pcm_tablegen.h | 2 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/pcx.c | 18 +- .../Codecs/ffmpeg/libavcodec/pgssubdec.c | 14 +- .../Codecs/ffmpeg/libavcodec/pictordec.c | 250 +++ .../Codecs/ffmpeg/libavcodec/pngdec.c | 3 +- .../Codecs/ffmpeg/libavcodec/pngenc.c | 2 +- .../Codecs/ffmpeg/libavcodec/pnmdec.c | 7 +- .../Codecs/ffmpeg/libavcodec/ppc/Makefile | 13 +- .../Codecs/ffmpeg/libavcodec/ppc/asm.S | 120 ++ .../ffmpeg/libavcodec/ppc/check_altivec.c | 2 +- .../ffmpeg/libavcodec/ppc/dsputil_altivec.c | 42 - .../ffmpeg/libavcodec/ppc/dsputil_ppc.c | 79 - .../ffmpeg/libavcodec/ppc/dsputil_ppc.h | 154 -- .../ffmpeg/libavcodec/ppc/fdct_altivec.c | 7 - .../ffmpeg/libavcodec/ppc/fft_altivec.c | 210 +- .../ffmpeg/libavcodec/ppc/fft_altivec_s.S | 445 ++++ .../ffmpeg/libavcodec/ppc/gmc_altivec.c | 8 - .../ffmpeg/libavcodec/ppc/h264_altivec.c | 1 - .../libavcodec/ppc/h264_template_altivec.c | 16 - .../ffmpeg/libavcodec/ppc/idct_altivec.c | 14 - .../ffmpeg/libavcodec/ppc/int_altivec.c | 4 +- .../libavcodec/ppc/mpegaudiodec_altivec.c | 130 ++ .../ffmpeg/libavcodec/ppc/mpegvideo_altivec.c | 5 - .../Codecs/ffmpeg/libavcodec/ppc/regs.h | 37 + .../ffmpeg/libavcodec/ppc/types_altivec.h | 1 + .../ffmpeg/libavcodec/ppc/util_altivec.h | 13 + .../ffmpeg/libavcodec/ppc/vp8dsp_altivec.c | 295 +++ .../Codecs/ffmpeg/libavcodec/psymodel.c | 1 + .../Codecs/ffmpeg/libavcodec/put_bits.h | 34 +- .../Codecs/ffmpeg/libavcodec/qcelpdec.c | 14 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/qdm2.c | 5 +- .../Codecs/ffmpeg/libavcodec/qdm2_tablegen.c | 23 +- .../Codecs/ffmpeg/libavcodec/qdm2_tablegen.h | 2 +- .../Codecs/ffmpeg/libavcodec/qtrleenc.c | 4 +- .../Codecs/ffmpeg/libavcodec/r210dec.c | 2 +- .../Codecs/ffmpeg/libavcodec/ra144.c | 1822 ++++++++++++++--- .../Codecs/ffmpeg/libavcodec/ra144.h | 1536 +------------- .../Codecs/ffmpeg/libavcodec/ra144dec.c | 128 ++ .../Codecs/ffmpeg/libavcodec/ra144enc.c | 511 +++++ .../Codecs/ffmpeg/libavcodec/ra288.c | 12 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/raw.c | 2 + .../Codecs/ffmpeg/libavcodec/rawdec.c | 2 +- .../Codecs/ffmpeg/libavcodec/resample2.c | 24 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/rl2.c | 2 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/rle.h | 2 +- .../Codecs/ffmpeg/libavcodec/roqvideoenc.c | 10 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/rv10.c | 2 + .../dvdplayer/Codecs/ffmpeg/libavcodec/rv34.c | 8 +- .../Codecs/ffmpeg/libavcodec/rv34vlc.h | 1 + .../dvdplayer/Codecs/ffmpeg/libavcodec/rv40.c | 2 +- .../Codecs/ffmpeg/libavcodec/rv40data.h | 2 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/sbr.h | 6 +- .../Codecs/ffmpeg/libavcodec/shorten.c | 22 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/sipr.c | 6 +- .../Codecs/ffmpeg/libavcodec/smacker.c | 2 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/snow.c | 7 +- .../Codecs/ffmpeg/libavcodec/sp5xdec.c | 1 + .../Codecs/ffmpeg/libavcodec/svq1dec.c | 15 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/svq3.c | 4 +- .../Codecs/ffmpeg/libavcodec/tableprint.c | 18 +- .../Codecs/ffmpeg/libavcodec/tableprint.h | 52 +- .../Codecs/ffmpeg/libavcodec/truespeech.c | 5 + .../dvdplayer/Codecs/ffmpeg/libavcodec/tta.c | 53 +- .../Codecs/ffmpeg/libavcodec/twinvq.c | 28 +- .../Codecs/ffmpeg/libavcodec/utils.c | 70 +- .../Codecs/ffmpeg/libavcodec/v210dec.c | 6 +- .../Codecs/ffmpeg/libavcodec/v210x.c | 8 +- .../Codecs/ffmpeg/libavcodec/vaapi_h264.c | 18 +- .../Codecs/ffmpeg/libavcodec/vaapi_mpeg4.c | 1 + .../Codecs/ffmpeg/libavcodec/vaapi_vc1.c | 10 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/vc1.c | 2 +- .../Codecs/ffmpeg/libavcodec/vc1dec.c | 65 +- .../Codecs/ffmpeg/libavcodec/vc1dsp.c | 60 +- .../Codecs/ffmpeg/libavcodec/vdpau.c | 2 - .../Codecs/ffmpeg/libavcodec/vdpau.h | 3 - .../Codecs/ffmpeg/libavcodec/vorbis.h | 1 + .../Codecs/ffmpeg/libavcodec/vorbis_data.c | 27 +- .../Codecs/ffmpeg/libavcodec/vorbis_dec.c | 44 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/vp3.c | 6 +- .../Codecs/ffmpeg/libavcodec/vp3dsp.c | 18 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/vp56.h | 121 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/vp6.c | 3 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/vp8.c | 1478 +++++++++++++ .../Codecs/ffmpeg/libavcodec/vp8data.h | 762 +++++++ .../Codecs/ffmpeg/libavcodec/vp8dsp.c | 471 +++++ .../Codecs/ffmpeg/libavcodec/vp8dsp.h | 72 + .../Codecs/ffmpeg/libavcodec/w32thread.c | 6 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/wma.c | 2 +- .../Codecs/ffmpeg/libavcodec/wmadec.c | 4 +- .../Codecs/ffmpeg/libavcodec/wmavoice.c | 9 +- .../Codecs/ffmpeg/libavcodec/wmv2dec.c | 1 + .../Codecs/ffmpeg/libavcodec/x86/Makefile | 13 + .../ffmpeg/libavcodec/x86/cavsdsp_mmx.c | 2 +- .../Codecs/ffmpeg/libavcodec/x86/dct32_sse.c | 294 +++ .../x86/dsputil_h264_template_ssse3.c | 2 +- .../ffmpeg/libavcodec/x86/dsputil_mmx.c | 18 +- .../ffmpeg/libavcodec/x86/dsputil_mmx.h | 4 +- .../ffmpeg/libavcodec/x86/dsputil_yasm.asm | 22 +- .../Codecs/ffmpeg/libavcodec/x86/fft.c | 10 + .../Codecs/ffmpeg/libavcodec/x86/fft.h | 1 + .../Codecs/ffmpeg/libavcodec/x86/fft_mmx.asm | 24 +- .../libavcodec/x86/h264_deblock_sse2.asm | 20 +- .../ffmpeg/libavcodec/x86/h264_idct_sse2.asm | 2 +- .../ffmpeg/libavcodec/x86/h264_intrapred.asm | 602 ++++++ .../ffmpeg/libavcodec/x86/h264dsp_mmx.c | 83 + .../ffmpeg/libavcodec/x86/mpegaudiodec_mmx.c | 157 ++ .../Codecs/ffmpeg/libavcodec/x86/vc1dsp_mmx.c | 66 +- .../ffmpeg/libavcodec/x86/vc1dsp_yasm.asm | 330 +++ .../ffmpeg/libavcodec/x86/vp8dsp-init.c | 318 +++ .../Codecs/ffmpeg/libavcodec/x86/vp8dsp.asm | 1371 +++++++++++++ .../Codecs/ffmpeg/libavcodec/x86/x86inc.asm | 113 +- .../Codecs/ffmpeg/libavcodec/x86/x86util.asm | 331 ++- .../dvdplayer/Codecs/ffmpeg/libavcodec/xiph.h | 2 +- .../Codecs/ffmpeg/libavcodec/xsubenc.c | 4 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/xvmc.h | 2 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/yop.c | 8 +- .../dvdplayer/Codecs/ffmpeg/libavcodec/zmbv.c | 3 - .../Codecs/ffmpeg/libavdevice/Makefile | 3 - .../Codecs/ffmpeg/libavdevice/alldevices.c | 1 - .../Codecs/ffmpeg/libavdevice/alsa-audio.h | 6 +- .../Codecs/ffmpeg/libavdevice/avdevice.h | 6 +- .../Codecs/ffmpeg/libavdevice/beosaudio.cpp | 467 ----- .../Codecs/ffmpeg/libavdevice/x11grab.c | 14 +- .../Codecs/ffmpeg/libavfilter/Makefile | 1 + .../Codecs/ffmpeg/libavfilter/allfilters.c | 1 + .../Codecs/ffmpeg/libavfilter/avfilter.c | 6 +- .../Codecs/ffmpeg/libavfilter/avfilter.h | 77 +- .../Codecs/ffmpeg/libavfilter/avfiltergraph.h | 14 +- .../Codecs/ffmpeg/libavfilter/defaults.c | 6 +- .../Codecs/ffmpeg/libavfilter/graphparser.c | 7 + .../Codecs/ffmpeg/libavfilter/graphparser.h | 2 +- .../Codecs/ffmpeg/libavfilter/parseutils.c | 76 +- .../Codecs/ffmpeg/libavfilter/parseutils.h | 22 +- .../Codecs/ffmpeg/libavfilter/vf_pad.c | 192 +- .../ffmpeg/libavfilter/vf_pixdesctest.c | 128 ++ .../Codecs/ffmpeg/libavfilter/vf_scale.c | 7 +- .../Codecs/ffmpeg/libavfilter/vf_unsharp.c | 4 +- .../Codecs/ffmpeg/libavfilter/vsrc_buffer.c | 3 +- .../Codecs/ffmpeg/libavfilter/vsrc_buffer.h | 2 + .../Codecs/ffmpeg/libavformat/Makefile | 18 +- .../Codecs/ffmpeg/libavformat/adtsenc.c | 23 +- .../Codecs/ffmpeg/libavformat/allformats.c | 2 +- .../Codecs/ffmpeg/libavformat/asfcrypt.c | 2 +- .../Codecs/ffmpeg/libavformat/asfdec.c | 45 +- .../Codecs/ffmpeg/libavformat/assdec.c | 2 +- .../Codecs/ffmpeg/libavformat/assenc.c | 2 +- .../Codecs/ffmpeg/libavformat/avformat.h | 167 +- .../Codecs/ffmpeg/libavformat/avidec.c | 77 +- .../Codecs/ffmpeg/libavformat/avienc.c | 5 +- .../Codecs/ffmpeg/libavformat/avio.c | 94 +- .../Codecs/ffmpeg/libavformat/avio.h | 66 +- .../Codecs/ffmpeg/libavformat/aviobuf.c | 32 +- .../Codecs/ffmpeg/libavformat/avlanguage.h | 4 +- .../ffmpeg/libavformat/electronicarts.c | 2 +- .../Codecs/ffmpeg/libavformat/file.c | 43 +- .../Codecs/ffmpeg/libavformat/flacdec.c | 4 +- .../Codecs/ffmpeg/libavformat/flvdec.c | 5 +- .../Codecs/ffmpeg/libavformat/gopher.c | 2 +- .../dvdplayer/Codecs/ffmpeg/libavformat/gxf.c | 22 +- .../Codecs/ffmpeg/libavformat/http.c | 114 +- .../Codecs/ffmpeg/libavformat/http.h | 64 + .../Codecs/ffmpeg/libavformat/id3v2.c | 13 +- .../Codecs/ffmpeg/libavformat/id3v2.h | 19 +- .../Codecs/ffmpeg/libavformat/img2.c | 3 +- .../Codecs/ffmpeg/libavformat/internal.h | 48 +- .../Codecs/ffmpeg/libavformat/isom.c | 3 +- .../Codecs/ffmpeg/libavformat/librtmp.c | 11 +- .../Codecs/ffmpeg/libavformat/matroska.h | 3 +- .../Codecs/ffmpeg/libavformat/matroskadec.c | 60 +- .../Codecs/ffmpeg/libavformat/matroskaenc.c | 11 +- .../ffmpeg/libavformat/metadata_compat.c | 5 +- .../Codecs/ffmpeg/libavformat/mmst.c | 10 +- .../dvdplayer/Codecs/ffmpeg/libavformat/mov.c | 26 +- .../Codecs/ffmpeg/libavformat/movenc.c | 21 + .../dvdplayer/Codecs/ffmpeg/libavformat/mp3.c | 17 +- .../dvdplayer/Codecs/ffmpeg/libavformat/mpc.c | 6 +- .../Codecs/ffmpeg/libavformat/mpeg.c | 21 +- .../Codecs/ffmpeg/libavformat/mpeg.h | 1 - .../Codecs/ffmpeg/libavformat/mpegts.c | 116 +- .../Codecs/ffmpeg/libavformat/mpegts.h | 1 - .../Codecs/ffmpeg/libavformat/mpegtsenc.c | 43 +- .../dvdplayer/Codecs/ffmpeg/libavformat/mtv.c | 2 +- .../dvdplayer/Codecs/ffmpeg/libavformat/mxf.c | 41 + .../dvdplayer/Codecs/ffmpeg/libavformat/mxf.h | 9 + .../Codecs/ffmpeg/libavformat/mxfdec.c | 70 +- .../Codecs/ffmpeg/libavformat/mxfenc.c | 68 +- .../Codecs/ffmpeg/libavformat/nutdec.c | 4 +- .../Codecs/ffmpeg/libavformat/nutenc.c | 153 +- .../dvdplayer/Codecs/ffmpeg/libavformat/nuv.c | 84 - .../Codecs/ffmpeg/libavformat/oggdec.c | 2 +- .../Codecs/ffmpeg/libavformat/oggenc.c | 150 +- .../dvdplayer/Codecs/ffmpeg/libavformat/oma.c | 49 +- .../Codecs/ffmpeg/libavformat/options.c | 2 +- .../Codecs/ffmpeg/libavformat/os_support.c | 6 +- .../Codecs/ffmpeg/libavformat/os_support.h | 17 - .../ffmpeg/libavformat/output-example.c | 1 + .../dvdplayer/Codecs/ffmpeg/libavformat/raw.c | 13 +- .../dvdplayer/Codecs/ffmpeg/libavformat/rdt.c | 12 +- .../dvdplayer/Codecs/ffmpeg/libavformat/rdt.h | 2 +- .../Codecs/ffmpeg/libavformat/rmdec.c | 11 +- .../Codecs/ffmpeg/libavformat/rtmppkt.h | 30 +- .../Codecs/ffmpeg/libavformat/rtmpproto.c | 37 +- .../Codecs/ffmpeg/libavformat/rtpdec.c | 126 +- .../Codecs/ffmpeg/libavformat/rtpdec.h | 38 +- .../Codecs/ffmpeg/libavformat/rtpdec_amr.c | 82 +- .../Codecs/ffmpeg/libavformat/rtpdec_asf.c | 10 +- .../Codecs/ffmpeg/libavformat/rtpdec_asf.h | 3 +- .../Codecs/ffmpeg/libavformat/rtpdec_h264.c | 27 +- .../Codecs/ffmpeg/libavformat/rtpdec_mpeg4.c | 280 +++ .../Codecs/ffmpeg/libavformat/rtpdec_mpeg4.h | 39 + .../Codecs/ffmpeg/libavformat/rtpdec_svq3.c | 138 ++ .../Codecs/ffmpeg/libavformat/rtpdec_svq3.h | 33 + .../Codecs/ffmpeg/libavformat/rtpdec_xiph.c | 33 +- .../Codecs/ffmpeg/libavformat/rtpenc.c | 8 +- .../Codecs/ffmpeg/libavformat/rtpenc.h | 6 + .../Codecs/ffmpeg/libavformat/rtpproto.c | 12 +- .../Codecs/ffmpeg/libavformat/rtsp.c | 302 ++- .../Codecs/ffmpeg/libavformat/rtsp.h | 19 +- .../Codecs/ffmpeg/libavformat/rtspenc.c | 2 +- .../dvdplayer/Codecs/ffmpeg/libavformat/sdp.c | 15 +- .../Codecs/ffmpeg/libavformat/smacker.c | 10 +- .../dvdplayer/Codecs/ffmpeg/libavformat/sol.c | 2 +- .../Codecs/ffmpeg/libavformat/spdif.c | 53 +- .../dvdplayer/Codecs/ffmpeg/libavformat/tcp.c | 2 +- .../dvdplayer/Codecs/ffmpeg/libavformat/tta.c | 4 +- .../dvdplayer/Codecs/ffmpeg/libavformat/udp.c | 12 +- .../Codecs/ffmpeg/libavformat/utils.c | 132 +- .../Codecs/ffmpeg/libavformat/vorbiscomment.h | 2 +- .../Codecs/ffmpeg/libavutil/Makefile | 3 + .../Codecs/ffmpeg/libavutil/adler32.h | 12 + .../dvdplayer/Codecs/ffmpeg/libavutil/aes.c | 83 +- .../dvdplayer/Codecs/ffmpeg/libavutil/aes.h | 4 +- .../Codecs/ffmpeg/libavutil/arm/bswap.h | 16 +- .../Codecs/ffmpeg/libavutil/arm/intmath.h | 55 +- .../Codecs/ffmpeg/libavutil/avr32/bswap.h | 8 +- .../ffmpeg/libavutil/avr32/intreadwrite.h | 4 +- .../Codecs/ffmpeg/libavutil/avutil.h | 8 +- .../Codecs/ffmpeg/libavutil/base64.h | 26 +- .../Codecs/ffmpeg/libavutil/bfin/bswap.h | 4 +- .../dvdplayer/Codecs/ffmpeg/libavutil/bswap.h | 76 +- .../{libavcodec => libavutil}/colorspace.h | 6 +- .../Codecs/ffmpeg/libavutil/common.h | 133 +- .../dvdplayer/Codecs/ffmpeg/libavutil/crc.c | 14 +- .../dvdplayer/Codecs/ffmpeg/libavutil/des.c | 8 +- .../dvdplayer/Codecs/ffmpeg/libavutil/error.h | 4 +- .../dvdplayer/Codecs/ffmpeg/libavutil/eval.c | 54 +- .../dvdplayer/Codecs/ffmpeg/libavutil/eval.h | 10 +- .../dvdplayer/Codecs/ffmpeg/libavutil/fifo.h | 18 +- .../Codecs/ffmpeg/libavutil/integer.h | 12 +- .../Codecs/ffmpeg/libavutil/internal.h | 37 +- .../Codecs/ffmpeg/libavutil/intmath.h | 37 +- .../Codecs/ffmpeg/libavutil/intreadwrite.h | 32 +- .../dvdplayer/Codecs/ffmpeg/libavutil/lfg.c | 2 + .../dvdplayer/Codecs/ffmpeg/libavutil/lfg.h | 8 +- .../dvdplayer/Codecs/ffmpeg/libavutil/log.c | 48 +- .../dvdplayer/Codecs/ffmpeg/libavutil/log.h | 10 +- .../Codecs/ffmpeg/libavutil/mathematics.c | 9 +- .../Codecs/ffmpeg/libavutil/mathematics.h | 21 +- .../dvdplayer/Codecs/ffmpeg/libavutil/md5.c | 6 +- .../dvdplayer/Codecs/ffmpeg/libavutil/mem.h | 21 +- .../Codecs/ffmpeg/libavutil/pixdesc.c | 10 +- .../Codecs/ffmpeg/libavutil/pixdesc.h | 20 +- .../Codecs/ffmpeg/libavutil/random_seed.c | 65 +- .../Codecs/ffmpeg/libavutil/random_seed.h | 2 +- .../Codecs/ffmpeg/libavutil/rational.h | 18 +- .../Codecs/ffmpeg/libavutil/sh4/bswap.h | 8 +- .../dvdplayer/Codecs/ffmpeg/libavutil/sha.c | 6 +- .../dvdplayer/Codecs/ffmpeg/libavutil/sha.h | 6 +- .../dvdplayer/Codecs/ffmpeg/libavutil/sha1.h | 6 +- .../dvdplayer/Codecs/ffmpeg/libavutil/tree.h | 6 +- .../Codecs/ffmpeg/libavutil/x86/bswap.h | 12 +- .../Codecs/ffmpeg/libpostproc/postprocess.h | 6 +- .../ffmpeg/libpostproc/postprocess_template.c | 18 +- .../Codecs/ffmpeg/libswscale/rgb2rgb.c | 2 +- .../Codecs/ffmpeg/libswscale/swscale.c | 8 +- .../Codecs/ffmpeg/libswscale/yuv2rgb.c | 7 +- .../Codecs/ffmpeg/tests/codec-regression.sh | 6 +- .../dvdplayer/Codecs/ffmpeg/tests/fate-run.sh | 30 +- .../dvdplayer/Codecs/ffmpeg/tests/fate.mak | 34 + .../dvdplayer/Codecs/ffmpeg/tests/fate2.mak | 104 + .../Codecs/ffmpeg/tests/lavfi-regression.sh | 20 + .../ffmpeg/tests/ref/acodec/adpcm_ima_qt | 2 +- .../ffmpeg/tests/ref/acodec/adpcm_ima_wav | 2 +- .../Codecs/ffmpeg/tests/ref/acodec/adpcm_ms | 2 +- .../Codecs/ffmpeg/tests/ref/acodec/adpcm_swf | 2 +- .../Codecs/ffmpeg/tests/ref/acodec/adpcm_yam | 2 +- .../Codecs/ffmpeg/tests/ref/acodec/alac | 2 +- .../Codecs/ffmpeg/tests/ref/acodec/flac | 2 +- .../Codecs/ffmpeg/tests/ref/acodec/g726 | 2 +- .../Codecs/ffmpeg/tests/ref/acodec/mp2 | 4 +- .../Codecs/ffmpeg/tests/ref/acodec/pcm | 36 +- .../Codecs/ffmpeg/tests/ref/acodec/wmav1 | 4 +- .../Codecs/ffmpeg/tests/ref/acodec/wmav2 | 4 +- .../ffmpeg/tests/ref/fate/mpeg2-field-enc | 39 + .../Codecs/ffmpeg/tests/ref/fate/pictor | 1 + .../Codecs/ffmpeg/tests/ref/fate/vc1 | 15 +- .../ffmpeg/tests/ref/fate/vp8-test-vector-001 | 29 + .../ffmpeg/tests/ref/fate/vp8-test-vector-002 | 49 + .../ffmpeg/tests/ref/fate/vp8-test-vector-003 | 49 + .../ffmpeg/tests/ref/fate/vp8-test-vector-004 | 29 + .../ffmpeg/tests/ref/fate/vp8-test-vector-005 | 49 + .../ffmpeg/tests/ref/fate/vp8-test-vector-006 | 48 + .../ffmpeg/tests/ref/fate/vp8-test-vector-007 | 29 + .../ffmpeg/tests/ref/fate/vp8-test-vector-008 | 2 + .../ffmpeg/tests/ref/fate/vp8-test-vector-009 | 49 + .../ffmpeg/tests/ref/fate/vp8-test-vector-010 | 57 + .../ffmpeg/tests/ref/fate/vp8-test-vector-011 | 29 + .../ffmpeg/tests/ref/fate/vp8-test-vector-012 | 29 + .../ffmpeg/tests/ref/fate/vp8-test-vector-013 | 29 + .../ffmpeg/tests/ref/fate/vp8-test-vector-014 | 49 + .../ffmpeg/tests/ref/fate/vp8-test-vector-015 | 260 +++ .../ffmpeg/tests/ref/fate/vp8-test-vector-016 | 29 + .../ffmpeg/tests/ref/fate/vp8-test-vector-017 | 29 + .../Codecs/ffmpeg/tests/ref/fate/yop | 7 + .../Codecs/ffmpeg/tests/ref/lavf/mxf | 2 +- .../Codecs/ffmpeg/tests/ref/lavfi/crop_scale | 2 +- .../ffmpeg/tests/ref/lavfi/crop_scale_vflip | 2 +- .../Codecs/ffmpeg/tests/ref/lavfi/scale200 | 2 +- .../Codecs/ffmpeg/tests/ref/lavfi/scale500 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/asv1 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/asv2 | 2 +- .../ffmpeg/tests/ref/vsynth1/dnxhd_1080i | 2 +- .../ffmpeg/tests/ref/vsynth1/dnxhd_720p | 2 +- .../ffmpeg/tests/ref/vsynth1/dnxhd_720p_rd | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/dv | 4 +- .../Codecs/ffmpeg/tests/ref/vsynth1/dv50 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/error | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/ffv1 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/flashsv | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/flv | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/h261 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/h263 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/h263p | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/huffyuv | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/jpegls | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/ljpeg | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/mjpeg | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/mpeg | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/mpeg1b | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/mpeg2 | 10 +- .../ffmpeg/tests/ref/vsynth1/mpeg2thread | 6 +- .../Codecs/ffmpeg/tests/ref/vsynth1/mpeg4 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/mpeg4adv | 8 +- .../Codecs/ffmpeg/tests/ref/vsynth1/mpeg4nr | 2 +- .../ffmpeg/tests/ref/vsynth1/mpeg4thread | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/msmpeg4 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/msmpeg4v2 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/rc | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/roq | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/rv10 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/rv20 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/snow | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/snowll | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/svq1 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/wmv1 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth1/wmv2 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/asv1 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/asv2 | 2 +- .../ffmpeg/tests/ref/vsynth2/dnxhd_1080i | 2 +- .../ffmpeg/tests/ref/vsynth2/dnxhd_720p | 2 +- .../ffmpeg/tests/ref/vsynth2/dnxhd_720p_rd | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/dv | 4 +- .../Codecs/ffmpeg/tests/ref/vsynth2/dv50 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/error | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/ffv1 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/flashsv | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/flv | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/h261 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/h263 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/h263p | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/huffyuv | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/jpegls | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/ljpeg | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/mjpeg | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/mpeg | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/mpeg1b | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/mpeg2 | 10 +- .../ffmpeg/tests/ref/vsynth2/mpeg2thread | 6 +- .../Codecs/ffmpeg/tests/ref/vsynth2/mpeg4 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/mpeg4adv | 8 +- .../Codecs/ffmpeg/tests/ref/vsynth2/mpeg4nr | 2 +- .../ffmpeg/tests/ref/vsynth2/mpeg4thread | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/msmpeg4 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/msmpeg4v2 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/rc | 2 +- .../ref/vsynth2/rgb/rgb.vsynth2.regression | 4 - .../Codecs/ffmpeg/tests/ref/vsynth2/roq | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/rv10 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/rv20 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/snow | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/snowll | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/svq1 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/wmv1 | 2 +- .../Codecs/ffmpeg/tests/ref/vsynth2/wmv2 | 2 +- .../ref/vsynth2/yuv/yuv.vsynth2.regression | 4 - .../Codecs/ffmpeg/tests/regression-funcs.sh | 4 +- .../Codecs/ffmpeg/tests/seek-regression.sh | 5 +- .../dvdplayer/Codecs/ffmpeg/tests/tiny_psnr.c | 37 +- .../dvdplayer/Codecs/ffmpeg/tools/patcheck | 4 +- .../Codecs/ffmpeg/tools/qt-faststart.c | 6 + 601 files changed, 20837 insertions(+), 10234 deletions(-) delete mode 100755 xbmc/cores/dvdplayer/Codecs/ffmpeg/build_xbmc.sh delete mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/build_xbmc_win32.sh delete mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffmpeg_powerpc_performance_evaluation_howto.txt create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/filters.texi delete mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/include/dxva2/dxva2api.h delete mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/include/libavutil/avconfig.h create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_tablegen.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_tablegen.h create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_tablegen_decl.h create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacadtsdec.c rename xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/{aac_parser.h => aacadtsdec.h} (79%) create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacps.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacps.h create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacps_tablegen.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacps_tablegen.h create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacpsdata.c delete mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/beosthread.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dct32.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/gsmdec.c delete mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/latm_parser.c delete mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/latmaac.c delete mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libfaad.c delete mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/os2thread.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pictordec.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/asm.S delete mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/dsputil_ppc.h create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/fft_altivec_s.S create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/mpegaudiodec_altivec.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/regs.h create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144dec.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144enc.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8data.h create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8dsp.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8dsp.h create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dct32_sse.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264_intrapred.asm create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/mpegaudiodec_mmx.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vc1dsp_yasm.asm create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vp8dsp-init.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vp8dsp.asm delete mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/beosaudio.cpp create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_pixdesctest.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/http.h create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_mpeg4.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_mpeg4.h create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_svq3.c create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_svq3.h rename xbmc/cores/dvdplayer/Codecs/ffmpeg/{libavcodec => libavutil}/colorspace.h (97%) create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/fate2.mak create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/mpeg2-field-enc create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/pictor create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-001 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-002 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-003 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-004 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-005 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-006 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-007 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-008 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-009 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-010 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-011 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-012 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-013 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-014 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-015 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-016 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-017 create mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/yop delete mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rgb/rgb.vsynth2.regression delete mode 100644 xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/yuv/yuv.vsynth2.regression diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/Changelog b/xbmc/cores/dvdplayer/Codecs/ffmpeg/Changelog index d3f32481a..9966e3688 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/Changelog +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/Changelog @@ -10,6 +10,16 @@ version : - VP8 de/encoding via libvpx - CODEC_CAP_EXPERIMENTAL added - Demuxer for On2's IVF format +- Pictor/PC Paint decoder +- HE-AAC v2 decoder +- libfaad2 wrapper removed +- DTS-ES extension (XCh) decoding support +- native VP8 decoder +- RTSP tunneling over HTTP +- RTP depacketization of SVQ3 +- -strict inofficial replaced by -strict unofficial +- ffplay -exitonkeydown and -exitonmousedown options added +- native GSM / GSM MS decoder @@ -88,6 +98,7 @@ version 0.6: - 35% faster VP3/Theora decoding - faster AAC decoding - faster H.264 decoding +- RealAudio 1.0 (14.4K) encoder diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/Doxyfile b/xbmc/cores/dvdplayer/Codecs/ffmpeg/Doxyfile index ee233b9d0..1173836cb 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/Doxyfile +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.3-rc1 +# Doxyfile 1.5.6 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project @@ -11,9 +11,17 @@ # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- -# General configuration options +# Project related configuration options #--------------------------------------------------------------------------- +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. @@ -32,17 +40,238 @@ PROJECT_NUMBER = OUTPUT_DIRECTORY = doxy +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + # 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. +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, +# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, +# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, +# and Ukrainian. OUTPUT_LANGUAGE = English +# 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 + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# 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. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = . + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# 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 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 regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = YES + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# 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 +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = 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 + +# 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 = + +# 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 OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = 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 + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + # 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 @@ -66,6 +295,21 @@ EXTRACT_STATIC = YES EXTRACT_LOCAL_CLASSES = YES +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + # 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 @@ -76,7 +320,7 @@ 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 +# If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO @@ -95,46 +339,6 @@ HIDE_FRIEND_COMPOUNDS = NO 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. @@ -143,66 +347,25 @@ STRIP_FROM_PATH = . 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 +# 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. +# and Mac users are advised 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 +# will put a 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. @@ -215,17 +378,28 @@ INLINE_INFO = YES 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. +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. -DISTRIBUTE_GROUP_DOC = NO +SORT_BRIEF_DOCS = 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. +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. -TAB_SIZE = 8 +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo @@ -251,22 +425,13 @@ GENERATE_BUGLIST = YES 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 initial value of a variable or define consists 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 @@ -275,26 +440,40 @@ ENABLED_SECTIONS = 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 +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- @@ -302,7 +481,7 @@ SHOW_USED_FILES = YES # 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 +QUIET = YES # 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 @@ -316,10 +495,27 @@ WARNINGS = YES WARN_IF_UNDOCUMENTED = YES +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + # 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. +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" @@ -340,12 +536,20 @@ WARN_LOGFILE = INPUT = +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + # 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 +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 FILE_PATTERNS = @@ -361,16 +565,27 @@ RECURSIVE = YES 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. +# 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. +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = *.svn *.git *.d -EXCLUDE_PATTERNS = *.svn *.git +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see @@ -403,10 +618,20 @@ IMAGE_PATH = # 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. +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. INPUT_FILTER = +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + # 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). @@ -419,6 +644,8 @@ FILTER_SOURCE_FILES = NO # 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. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES @@ -433,18 +660,39 @@ INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES -# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# If the REFERENCED_BY_RELATION tag is set to YES # 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) +# If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentstion. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = 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 + #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- @@ -501,10 +749,12 @@ HTML_HEADER = HTML_FOOTER = -# The HTML_STYLESHEET tag can be used to specify a user defined cascading +# 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 +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = @@ -516,22 +766,55 @@ 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) +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = 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. +# written to the html output directory. 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. +# 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 = @@ -541,6 +824,12 @@ HHC_LOCATION = GENERATE_CHI = NO +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + # 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. @@ -548,7 +837,7 @@ GENERATE_CHI = NO 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. +# to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO @@ -563,13 +852,20 @@ DISABLE_INDEX = NO 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 +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to FRAME, 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. +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. Other possible values +# for this tag are: HIERARCHIES, which will generate the Groups, Directories, +# and Class Hiererachy pages using a tree view instead of an ordered list; +# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which +# disables this behavior completely. For backwards compatibility with previous +# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE +# respectively. GENERATE_TREEVIEW = NO @@ -579,6 +875,14 @@ GENERATE_TREEVIEW = NO TREEVIEW_WIDTH = 250 +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- @@ -586,7 +890,7 @@ TREEVIEW_WIDTH = 250 # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. -GENERATE_LATEX = YES +GENERATE_LATEX = NO # 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 @@ -649,6 +953,12 @@ USE_PDFLATEX = NO LATEX_BATCHMODE = NO +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- @@ -681,7 +991,7 @@ COMPACT_RTF = NO 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 +# config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = @@ -725,12 +1035,16 @@ MAN_LINKS = NO # 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. +# the code including all documentation. GENERATE_XML = NO +# The XML_OUTPUT tag is used to specify where the XML 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 `xml' will be used as the default path. + +XML_OUTPUT = xml + # 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. @@ -743,6 +1057,13 @@ XML_SCHEMA = XML_DTD = +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- @@ -807,7 +1128,7 @@ 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. +# PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = YES @@ -833,7 +1154,9 @@ INCLUDE_FILE_PATTERNS = # 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. +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. PREDEFINED = __attribute__(x)="" "RENAME(x)=x ## _TMPL" "DEF(x)=x ## _TMPL" \ HAVE_AV_CONFIG_H HAVE_MMX HAVE_MMX2 HAVE_AMD3DNOW \ @@ -849,16 +1172,29 @@ EXPAND_AS_DEFINED = declare_idct(idct, table, idct_row_head, idct_row, idct # 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. +# 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 +# Configuration::additions related to external references #--------------------------------------------------------------------------- -# The TAGFILES tag can be used to specify one or more tagfiles. +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. TAGFILES = @@ -889,13 +1225,23 @@ PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # 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. +# 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 superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. CLASS_DIAGRAMS = YES +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + # 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. @@ -909,6 +1255,24 @@ HIDE_UNDOC_RELATIONS = YES HAVE_DOT = NO +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + # 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 @@ -923,6 +1287,17 @@ CLASS_GRAPH = YES COLLABORATION_GRAPH = YES +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. @@ -942,11 +1317,34 @@ INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + # 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 +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = 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. @@ -954,7 +1352,7 @@ GRAPHICAL_HIERARCHY = YES 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. +# found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = @@ -964,21 +1362,40 @@ DOT_PATH = 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. +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. -MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_DEPTH = 0 -# 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. +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is enabled by default, which results in a transparent +# background. Warning: Depending on the platform used, enabling this option +# may lead to badly anti-aliased labels on the edges of a graph (i.e. they +# become hard to read). -MAX_DOT_GRAPH_HEIGHT = 1024 +DOT_TRANSPARENT = YES + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO # 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 @@ -987,51 +1404,16 @@ MAX_DOT_GRAPH_HEIGHT = 1024 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 +# remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine +# Configuration::additions 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/xbmc/cores/dvdplayer/Codecs/ffmpeg/MAINTAINERS b/xbmc/cores/dvdplayer/Codecs/ffmpeg/MAINTAINERS index 2cd0b3909..eadd59fb7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/MAINTAINERS +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/MAINTAINERS @@ -34,7 +34,7 @@ QuickTime faststart: Miscellaneous Areas =================== -documentation Mike Melanson, Diego Biurrun +documentation Mike Melanson website Robert Swain build system (configure,Makefiles) Diego Biurrun, Mans Rullgard project server Diego Biurrun, Mans Rullgard @@ -98,6 +98,8 @@ Generic Parts: simple_idct.c, simple_idct.h Michael Niedermayer postprocessing: libpostproc/* Michael Niedermayer + table generation: + tableprint.c, tableprint.h Reimar Doeffinger Codecs: 4xm.c Michael Niedermayer @@ -205,10 +207,11 @@ Codecs: vcr1.c Michael Niedermayer vmnc.c Kostya Shishkov vorbis_enc.c Oded Shimon - vorbis_dec.c Denes Balatoni + vorbis_dec.c Denes Balatoni, David Conrad vp3* Mike Melanson vp5 Aurelien Jacobs vp6 Aurelien Jacobs + vp8 David Conrad vqavideo.c Mike Melanson wavpack.c Kostya Shishkov wmaprodec.c Sascha Sommer @@ -293,6 +296,7 @@ Muxers/Demuxers: oggdec.c, oggdec.h David Conrad oggenc.c Baptiste Coudurier oggparse*.c David Conrad + oma.c Maxim Poliakovski psxstr.c Mike Melanson pva.c Ivo van Poorten r3d.c Baptiste Coudurier @@ -330,7 +334,6 @@ Alpha Mans Rullgard, Falk Hueffner ARM Mans Rullgard AVR32 Mans Rullgard MIPS Mans Rullgard -BeOS Francois Revol Mac OS X / PowerPC Romain Dolbeau, Guillaume Poirier Amiga / PowerPC Colin Ward Linux / PowerPC Luca Barbato diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/Makefile b/xbmc/cores/dvdplayer/Codecs/ffmpeg/Makefile index 4b945f439..fa521efb7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/Makefile +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/Makefile @@ -13,6 +13,7 @@ PROGS := $(addsuffix $(EXESUF), $(PROGS-yes)) PROGS_G = $(addsuffix _g$(EXESUF), $(PROGS-yes)) OBJS = $(addsuffix .o, $(PROGS-yes)) cmdutils.o MANPAGES = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes))) +HTMLPAGES = $(addprefix doc/, $(addsuffix -doc.html, $(PROGS-yes))) TOOLS = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws pktdumper probetest qt-faststart trasher)) HOSTPROGS = $(addprefix tests/, audiogen videogen rotozoom tiny_psnr) @@ -20,6 +21,7 @@ BASENAMES = ffmpeg ffplay ffprobe ffserver ALLPROGS = $(addsuffix $(EXESUF), $(BASENAMES)) ALLPROGS_G = $(addsuffix _g$(EXESUF), $(BASENAMES)) ALLMANPAGES = $(addsuffix .1, $(BASENAMES)) +ALLHTMLPAGES= $(addsuffix -doc.html, $(BASENAMES)) FFLIBS-$(CONFIG_AVDEVICE) += avdevice FFLIBS-$(CONFIG_AVFILTER) += avfilter @@ -101,9 +103,13 @@ version.h .version: alltools: $(TOOLS) -documentation: $(addprefix doc/, developer.html faq.html ffmpeg-doc.html \ - ffplay-doc.html ffprobe-doc.html ffserver-doc.html \ - general.html libavfilter.html $(ALLMANPAGES)) +documentation: $(addprefix doc/, developer.html faq.html general.html libavfilter.html \ + $(ALLHTMLPAGES) $(ALLMANPAGES)) + +$(HTMLPAGES) $(MANPAGES): doc/fftools-common-opts.texi + +doc/ffmpeg.pod doc/ffmpeg-doc.html: doc/filters.texi +doc/ffplay.pod doc/ffplay-doc.html: doc/filters.texi doc/%.html: TAG = HTML doc/%.html: doc/%.texi @@ -170,87 +176,6 @@ fulltest test: codectest lavftest seektest FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref SEEK_REFFILE = $(SRC_PATH)/tests/seek.regression.ref -ENCDEC = $(and $(CONFIG_$(1)_ENCODER),$(CONFIG_$(1)_DECODER)) -MUXDEM = $(and $(CONFIG_$(1)_MUXER),$(CONFIG_$(or $(2),$(1))_DEMUXER)) - -VCODEC_TESTS = -VCODEC_TESTS-$(call ENCDEC,ASV1) += asv1 -VCODEC_TESTS-$(call ENCDEC,ASV2) += asv2 -VCODEC_TESTS-$(call ENCDEC,DNXHD) += dnxhd_1080i dnxhd_720p dnxhd_720p_rd -VCODEC_TESTS-$(call ENCDEC,DVVIDEO) += dv dv50 -VCODEC_TESTS-$(call ENCDEC,FFV1) += ffv1 -VCODEC_TESTS-$(call ENCDEC,FLASHSV) += flashsv -VCODEC_TESTS-$(call ENCDEC,FLV) += flv -VCODEC_TESTS-$(call ENCDEC,H261) += h261 -VCODEC_TESTS-$(call ENCDEC,H263) += h263 h263p -VCODEC_TESTS-$(call ENCDEC,HUFFYUV) += huffyuv -VCODEC_TESTS-$(call ENCDEC,JPEGLS) += jpegls -VCODEC_TESTS-$(call ENCDEC,MJPEG) += mjpeg ljpeg -VCODEC_TESTS-$(call ENCDEC,MPEG1VIDEO) += mpeg mpeg1b -VCODEC_TESTS-$(call ENCDEC,MPEG2VIDEO) += mpeg2 mpeg2thread -VCODEC_TESTS-$(call ENCDEC,MPEG4) += mpeg4 mpeg4adv mpeg4nr mpeg4thread error rc -VCODEC_TESTS-$(call ENCDEC,MSMPEG4V1) += msmpeg4 -VCODEC_TESTS-$(call ENCDEC,MSMPEG4V2) += msmpeg4v2 -VCODEC_TESTS-$(call ENCDEC,RAWVIDEO) += rgb yuv -VCODEC_TESTS-$(call ENCDEC,ROQ) += roq -VCODEC_TESTS-$(call ENCDEC,RV10) += rv10 -VCODEC_TESTS-$(call ENCDEC,RV20) += rv20 -VCODEC_TESTS-$(call ENCDEC,SNOW) += snow snowll -VCODEC_TESTS-$(call ENCDEC,SVQ1) += svq1 -VCODEC_TESTS-$(call ENCDEC,WMV1) += wmv1 -VCODEC_TESTS-$(call ENCDEC,WMV2) += wmv2 - -ACODEC_TESTS = -ACODEC_TESTS-$(call ENCDEC,AC3) += ac3 -ACODEC_TESTS-$(call ENCDEC,ADPCM_G726) += g726 -ACODEC_TESTS-$(call ENCDEC,ADPCM_IMA_QT) += adpcm_ima_qt -ACODEC_TESTS-$(call ENCDEC,ADPCM_IMA_WAV) += adpcm_ima_wav -ACODEC_TESTS-$(call ENCDEC,ADPCM_MS) += adpcm_ms -ACODEC_TESTS-$(call ENCDEC,ADPCM_SWF) += adpcm_swf -ACODEC_TESTS-$(call ENCDEC,ADPCM_YAMAHA) += adpcm_yam -ACODEC_TESTS-$(call ENCDEC,ALAC) += alac -ACODEC_TESTS-$(call ENCDEC,FLAC) += flac -ACODEC_TESTS-$(call ENCDEC,MP2) += mp2 -ACODEC_TESTS-$(call ENCDEC,PCM_S16LE) += pcm # fixme -ACODEC_TESTS-$(call ENCDEC,WMAV1) += wmav1 -ACODEC_TESTS-$(call ENCDEC,WMAV1) += wmav2 - -LAVF_TESTS = -LAVF_TESTS-$(call MUXDEM,AIFF) += aiff -LAVF_TESTS-$(call MUXDEM,PCM_ALAW) += alaw -LAVF_TESTS-$(call MUXDEM,ASF) += asf -LAVF_TESTS-$(call MUXDEM,AU) += au -LAVF_TESTS-$(call MUXDEM,AVI) += avi -LAVF_TESTS-$(call ENCDEC,BMP) += bmp -LAVF_TESTS-$(call MUXDEM,DV) += dv_fmt -LAVF_TESTS-$(call MUXDEM,FFM) += ffm -LAVF_TESTS-$(call MUXDEM,FLV) += flv_fmt -LAVF_TESTS-$(call ENCDEC,GIF) += gif -LAVF_TESTS-$(call MUXDEM,GXF) += gxf -LAVF_TESTS-$(call ENCDEC,MJPEG) += jpg -LAVF_TESTS-$(call MUXDEM,MATROSKA) += mkv -LAVF_TESTS-$(call MUXDEM,MMF) += mmf -LAVF_TESTS-$(call MUXDEM,MOV) += mov -LAVF_TESTS-$(call MUXDEM,MPEG1SYSTEM,MPEGPS) += mpg -LAVF_TESTS-$(call MUXDEM,PCM_MULAW) += mulaw -LAVF_TESTS-$(call MUXDEM,MXF) += mxf -LAVF_TESTS-$(call MUXDEM,NUT) += nut -LAVF_TESTS-$(call MUXDEM,OGG) += ogg -LAVF_TESTS-$(call ENCDEC,PBM) += pbmpipe -LAVF_TESTS-$(call ENCDEC,PCX) += pcx -LAVF_TESTS-$(call ENCDEC,PGM) += pgm pgmpipe -LAVF_TESTS-$(call MUXDEM,RAWVIDEO) += pixfmt -LAVF_TESTS-$(call ENCDEC,PPM) += ppm ppmpipe -LAVF_TESTS-$(call MUXDEM,RM) += rm -LAVF_TESTS-$(call ENCDEC,SGI) += sgi -LAVF_TESTS-$(call MUXDEM,SWF) += swf -LAVF_TESTS-$(call ENCDEC,TARGA) += tga -LAVF_TESTS-$(call ENCDEC,TIFF) += tiff -LAVF_TESTS-$(call MUXDEM,MPEGTS) += ts -LAVF_TESTS-$(call MUXDEM,VOC) += voc -LAVF_TESTS-$(call MUXDEM,WAV) += wav -LAVF_TESTS-$(call MUXDEM,YUV4MPEGPIPE) += yuv4mpeg - LAVFI_TESTS = \ crop \ crop_scale \ @@ -262,6 +187,7 @@ LAVFI_TESTS = \ vflip \ vflip_crop \ vflip_vflip \ + lavfi_pixdesc \ # lavfi_pix_fmts \ ACODEC_TESTS := $(addprefix regtest-, $(ACODEC_TESTS) $(ACODEC_TESTS-yes)) @@ -275,35 +201,41 @@ codectest: $(CODEC_TESTS) lavftest: $(LAVF_TESTS) lavfitest: $(LAVFI_TESTS) -$(ACODEC_TESTS): regtest-aref -$(VCODEC_TESTS): regtest-vref -$(LAVF_TESTS) $(LAVFI_TESTS): regtest-ref +AREF = tests/data/acodec.ref.wav +VREF = tests/data/vsynth1.ref.yuv +REFS = $(AREF) $(VREF) + +$(ACODEC_TESTS): $(AREF) +$(VCODEC_TESTS): $(VREF) +$(LAVF_TESTS) $(LAVFI_TESTS): $(REFS) REFFILE = $(SRC_PATH)/tests/ref/$(1)/$(2:regtest-%=%) -RESFILE = tests/data/$(2:regtest-%=%).$(1).regression +RESFILE = tests/data/regression/$(1)/$(2:regtest-%=%) -define CODECTEST_CMD - $(SRC_PATH)/tests/codec-regression.sh $@ vsynth1 tests/vsynth1 "$(TARGET_EXEC)" "$(TARGET_PATH)" - $(SRC_PATH)/tests/codec-regression.sh $@ vsynth2 tests/vsynth2 "$(TARGET_EXEC)" "$(TARGET_PATH)" +define VCODECTEST + @echo "TEST VCODEC $(1:regtest-%=%)" + $(SRC_PATH)/tests/codec-regression.sh $(1) vsynth1 tests/vsynth1 "$(TARGET_EXEC)" "$(TARGET_PATH)" + $(SRC_PATH)/tests/codec-regression.sh $(1) vsynth2 tests/vsynth2 "$(TARGET_EXEC)" "$(TARGET_PATH)" endef -regtest-ref: regtest-aref regtest-vref +define ACODECTEST + @echo "TEST ACODEC $(1:regtest-%=%)" + $(SRC_PATH)/tests/codec-regression.sh $(1) acodec tests/acodec "$(TARGET_EXEC)" "$(TARGET_PATH)" +endef -regtest-vref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm - $(CODECTEST_CMD) +$(VREF): ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm + @$(call VCODECTEST,vref) -regtest-aref: ffmpeg$(EXESUF) tests/data/asynth1.sw - @$(SRC_PATH)/tests/codec-regression.sh $@ acodec tests/acodec "$(TARGET_EXEC)" "$(TARGET_PATH)" +$(AREF): ffmpeg$(EXESUF) tests/data/asynth1.sw + @$(call ACODECTEST,aref) $(VCODEC_TESTS): tests/tiny_psnr$(HOSTEXESUF) - @echo "TEST VCODEC $(@:regtest-%=%)" - @$(CODECTEST_CMD) + @$(call VCODECTEST,$@) @diff -u -w $(call REFFILE,vsynth1,$@) $(call RESFILE,vsynth1,$@) @diff -u -w $(call REFFILE,vsynth2,$@) $(call RESFILE,vsynth2,$@) $(ACODEC_TESTS): tests/tiny_psnr$(HOSTEXESUF) - @echo "TEST ACODEC $(@:regtest-%=%)" - @$(SRC_PATH)/tests/codec-regression.sh $@ acodec tests/acodec "$(TARGET_EXEC)" "$(TARGET_PATH)" + @$(call ACODECTEST,$@) @diff -u -w $(call REFFILE,acodec,$@) $(call RESFILE,acodec,$@) $(LAVF_TESTS): @@ -327,30 +259,36 @@ ffservertest: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/data/asynth1.sw $(SRC_PATH)/tests/ffserver-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/ffserver.conf tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF) - mkdir -p tests/vsynth1 - $(BUILD_ROOT)/$< 'tests/vsynth1/' + @mkdir -p tests/vsynth1 + $(M)$(BUILD_ROOT)/$< 'tests/vsynth1/' tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF) - mkdir -p tests/vsynth2 - $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm + @mkdir -p tests/vsynth2 + $(M)$(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF) - mkdir -p tests/data - $(BUILD_ROOT)/$< $@ + @mkdir -p tests/data + $(M)$(BUILD_ROOT)/$< $@ + +tests/data/asynth1.sw tests/vsynth%/00.pgm: TAG = GEN tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS) $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS) include $(SRC_PATH_BARE)/tests/fate.mak +include $(SRC_PATH_BARE)/tests/fate2.mak + +FATE_TESTS += $(FATE2_TESTS) ifdef SAMPLES fate: $(FATE_TESTS) -$(FATE_TESTS): ffmpeg$(EXESUF) +fate2: $(FATE2_TESTS) +$(FATE_TESTS): ffmpeg$(EXESUF) tests/tiny_psnr$(HOSTEXESUF) @echo "TEST FATE $(@:fate-%=%)" - @$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' + @$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' else -fate $(FATE_TESTS): +fate fate2 $(FATE_TESTS): @echo "SAMPLES not specified, cannot run FATE" endif -.PHONY: documentation *test regtest-* zlib-error alltools check config +.PHONY: documentation *test regtest-* alltools check config diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/build_xbmc.sh b/xbmc/cores/dvdplayer/Codecs/ffmpeg/build_xbmc.sh deleted file mode 100755 index 069503a26..000000000 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/build_xbmc.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -if [ "$XBMC_ROOT" == "" ]; then - echo you must define XBMC_ROOT to the root source folder - exit 1 -fi - -./configure --extra-cflags="--enable-shared --enable-postproc --enable-gpl --disable-static --disable-vhook --enable-swscale --enable-protocol=http --disable-altivec --disable-ipv6 --enable-pthreads --disable-debug" - -make - -echo wrapping libavutil -gcc -shared -fPIC --soname,avutil-51-i486-linux.so -o avutil-51-i486-linux.so -rdynamic libavutil/*.o - -echo wrapping libavcodec -gcc -o avcodec-51-i486-linux.so --soname,avcodec-51-i486-linux.so -shared -fPIC -rdynamic /usr/lib/libfaac.a libavcodec/*.o libavcodec/i386/*.o `cat $XBMC_ROOT/xbmc/cores/DllLoader/exports/wrapper.def` $XBMC_ROOT/xbmc/cores/DllLoader/exports/wrapper.o - -echo wrapping libavformat -gcc -o avformat-51-i486-linux.so --soname,avformat-51-i486-linux.so -shared -fPIC -rdynamic libavformat/*.o `cat $XBMC_ROOT/xbmc/cores/DllLoader/exports/wrapper.def`,-export-all-symbols $XBMC_ROOT/xbmc/cores/DllLoader/exports/wrapper.o - -echo wrapping libswscale -gcc -o swscale-51-i486-linux.so --soname,swscale-51-i486-linux.so -shared -fPIC -rdynamic libswscale/*.o `cat $XBMC_ROOT/xbmc/cores/DllLoader/exports/wrapper.def` $XBMC_ROOT/xbmc/cores/DllLoader/exports/wrapper.o - -echo wrapping libpostproc -gcc -o postproc-51-i486-linux.so --soname,postproc-51-i486-linux.so -shared -fPIC -rdynamic libpostproc/*.o `cat $XBMC_ROOT/xbmc/cores/DllLoader/exports/wrapper.def` $XBMC_ROOT/xbmc/cores/DllLoader/exports/wrapper.o - -echo copying libs -cp -v avcodec-51-i486-linux.so avformat-51-i486-linux.so avutil-51-i486-linux.so swscale-51-i486-linux.so postproc-51-i486-linux.so $XBMC_ROOT/system/players/dvdplayer - - diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/build_xbmc_win32.sh b/xbmc/cores/dvdplayer/Codecs/ffmpeg/build_xbmc_win32.sh deleted file mode 100644 index 8efebccc5..000000000 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/build_xbmc_win32.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -if [ -d .libs ] -then -rm -r .libs -fi - -make distclean - -OPTIONS=" ---enable-shared \ ---enable-memalign-hack \ ---enable-gpl \ ---enable-w32threads \ ---enable-postproc \ ---enable-zlib \ ---enable-libfaad \ ---disable-static \ ---disable-altivec \ ---disable-muxers \ ---disable-encoders \ ---disable-debug \ ---enable-muxer=spdif \ ---enable-muxer=adts \ ---enable-encoder=ac3 \ ---enable-encoder=aac" - -if [ -d ../libvpx ] -then -echo Building libvpx ... -echo -cd ../libvpx -./configure --disable-examples --enable-vp8 --target=x86-win32-gcc && make -cd ../ffmpeg -fi - -if [ -f ../libvpx/libvpx.a ] -then -echo Building ffmpeg with libvpx ... -echo -OPTIONS="$OPTIONS --enable-libvpx" -fi - -./configure --extra-cflags="-fno-common -I../libfaad2/include -Iinclude/dxva2 -I../libvpx/" --extra-ldflags="-L../../../../../system/players/dvdplayer -L../libvpx" ${OPTIONS} && - -make -j3 && -mkdir .libs && -cp lib*/*.dll .libs/ && -mv .libs/swscale-0.dll .libs/swscale-0.6.1.dll && -cp .libs/avcodec-52.dll ../../../../../system/players/dvdplayer/ && -cp .libs/avformat-52.dll ../../../../../system/players/dvdplayer/ && -cp .libs/avutil-50.dll ../../../../../system/players/dvdplayer/ && -cp .libs/postproc-51.dll ../../../../../system/players/dvdplayer/ && -cp .libs/swscale-0.6.1.dll ../../../../../system/players/dvdplayer/ && -cp libavutil/avconfig.h include/libavutil/ - diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/cmdutils.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/cmdutils.c index 2349b7052..fcdebb200 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/cmdutils.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/cmdutils.c @@ -36,6 +36,7 @@ #include "libpostproc/postprocess.h" #include "libavutil/avstring.h" #include "libavutil/pixdesc.h" +#include "libavutil/eval.h" #include "libavcodec/opt.h" #include "cmdutils.h" #include "version.h" @@ -58,7 +59,7 @@ double parse_number_or_die(const char *context, const char *numstr, int type, do { char *tail; const char *error; - double d = strtod(numstr, &tail); + double d = av_strtod(numstr, &tail); if (*tail) error= "Expected number for %s but found: %s\n"; else if (d < min || d > max) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/cmdutils.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/cmdutils.h index 565637061..d48abab30 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/cmdutils.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/cmdutils.h @@ -51,7 +51,7 @@ extern struct SwsContext *sws_opts; int opt_default(const char *opt, const char *arg); /** - * Sets the libav* libraries log level. + * Set the libav* libraries log level. */ int opt_loglevel(const char *opt, const char *arg); @@ -61,8 +61,8 @@ int opt_loglevel(const char *opt, const char *arg); int opt_timelimit(const char *opt, const char *arg); /** - * Parses a string and returns its corresponding value as a double. - * Exits from the application if the string cannot be correctly + * Parse a string and return its corresponding value as a double. + * Exit from the application if the string cannot be correctly * parsed or the corresponding value is invalid. * * @param context the context of the value to be set (e.g. the @@ -76,8 +76,8 @@ int opt_timelimit(const char *opt, const char *arg); double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max); /** - * Parses a string specifying a time and returns its corresponding - * value as a number of microseconds. Exits from the application if + * Parse a string specifying a time and return its corresponding + * value as a number of microseconds. Exit from the application if * the string cannot be correctly parsed. * * @param context the context of the value to be set (e.g. the @@ -122,9 +122,9 @@ typedef struct { void show_help_options(const OptionDef *options, const char *msg, int mask, int value); /** - * Parses the command line arguments. + * Parse the command line arguments. * @param options Array with the definitions required to interpret every - * option of the form: - [] + * option of the form: -option_name [argument] * @param parse_arg_function Name of the function called to process every * argument without a leading option name flag. NULL if such arguments do * not have to be processed. @@ -135,7 +135,7 @@ void parse_options(int argc, char **argv, const OptionDef *options, void set_context_opts(void *ctx, void *opts_ctx, int flags); /** - * Prints an error message to stderr, indicating filename and a human + * Print an error message to stderr, indicating filename and a human * readable description of the error code err. * * If strerror_r() is not available the use of this function in a @@ -148,73 +148,73 @@ void print_error(const char *filename, int err); void list_fmts(void (*get_fmt_string)(char *buf, int buf_size, int fmt), int nb_fmts); /** - * Prints the program banner to stderr. The banner contents depend on the + * Print the program banner to stderr. The banner contents depend on the * current version of the repository and of the libav* libraries used by * the program. */ void show_banner(void); /** - * Prints the version of the program to stdout. The version message + * Print the version of the program to stdout. The version message * depends on the current versions of the repository and of the libav* * libraries. */ void show_version(void); /** - * Prints the license of the program to stdout. The license depends on + * Print the license of the program to stdout. The license depends on * the license of the libraries compiled into the program. */ void show_license(void); /** - * Prints a listing containing all the formats supported by the + * Print a listing containing all the formats supported by the * program. */ void show_formats(void); /** - * Prints a listing containing all the codecs supported by the + * Print a listing containing all the codecs supported by the * program. */ void show_codecs(void); /** - * Prints a listing containing all the filters supported by the + * Print a listing containing all the filters supported by the * program. */ void show_filters(void); /** - * Prints a listing containing all the bit stream filters supported by the + * Print a listing containing all the bit stream filters supported by the * program. */ void show_bsfs(void); /** - * Prints a listing containing all the protocols supported by the + * Print a listing containing all the protocols supported by the * program. */ void show_protocols(void); /** - * Prints a listing containing all the pixel formats supported by the + * Print a listing containing all the pixel formats supported by the * program. */ void show_pix_fmts(void); /** - * Returns a positive value if reads from standard input a line - * starting with [yY], otherwise returns 0. + * Return a positive value if a line read from standard input + * starts with [yY], otherwise return 0. */ int read_yesno(void); /** - * Reads the file with name filename, and puts its content in a newly + * Read the file with name filename, and put its content in a newly * allocated 0-terminated buffer. * - * @param bufptr puts here the pointer to the newly allocated buffer - * @param size puts here the size of the newly allocated buffer + * @param bufptr location where pointer to buffer is returned + * @param size location where size of buffer is returned * @return 0 in case of success, a negative value corresponding to an * AVERROR error code in case of failure. */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/common.mak b/xbmc/cores/dvdplayer/Codecs/ffmpeg/common.mak index 25a5d81b6..cc10c205d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/common.mak +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/common.mak @@ -26,16 +26,19 @@ SILENT = DEPCC YASMDEP RM RANLIB MSG = $@ M = @$(call ECHO,$(TAG),$@); $(foreach VAR,$(BRIEF), \ - $(eval $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR)))) -$(foreach VAR,$(SILENT),$(eval $(VAR) = @$($(VAR)))) + $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR)))) +$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR)))) $(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL)) endif ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale -CPPFLAGS := -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(CPPFLAGS) +IFLAGS := -I$(BUILD_ROOT_REL) -I$(SRC_PATH) +CPPFLAGS := $(IFLAGS) $(CPPFLAGS) CFLAGS += $(ECFLAGS) +HOSTCFLAGS += $(IFLAGS) + %.o: %.c $(CCDEP) $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $< @@ -54,6 +57,10 @@ CFLAGS += $(ECFLAGS) %.c %.h: TAG = GEN +# Dummy rule to stop make trying to rebuild removed or renamed headers +%.h: + @: + install: install-libs install-headers install-libs: install-libs-yes diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/configure b/xbmc/cores/dvdplayer/Codecs/ffmpeg/configure index c87194e01..2a1d520e1 100755 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/configure +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/configure @@ -61,7 +61,7 @@ Options: [defaults in brackets after descriptions] Standard options: --help print this message - --logfile=FILE log tests and output to FILE [config.err] + --logfile=FILE log tests and output to FILE [config.log] --disable-logging do not log configure debug information --prefix=PREFIX install in PREFIX [$prefix] --bindir=DIR install binaries in DIR [PREFIX/bin] @@ -91,9 +91,7 @@ Configuration options: --enable-postproc enable GPLed postprocessing support [no] --disable-avfilter disable video filter support [no] --enable-avfilter-lavf video filters dependent on avformat [no] - --enable-beosthreads use BeOS threads [no] - --enable-os2threads use OS/2 threads [no] - --enable-pthreads use pthreads [no] + --disable-pthreads disable pthreads [auto] --enable-w32threads use Win32 threads [no] --enable-x11grab enable X11 grabbing [no] --disable-network disable network support [no] @@ -115,7 +113,6 @@ Configuration options: --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary) --enable-hardcoded-tables use hardcoded tables instead of runtime generation --enable-memalign-hack emulate memalign, interferes with memory debuggers - --enable-beos-netserver enable BeOS netserver --disable-everything disable all components listed below --disable-encoder=NAME disable encoder NAME --enable-encoder=NAME enable encoder NAME @@ -170,8 +167,6 @@ External library support: and libraw1394 [no] --enable-libdirac enable Dirac support via libdirac [no] --enable-libfaac enable FAAC support via libfaac [no] - --enable-libfaad enable FAAD support via libfaad [no] - --enable-libfaadbin open libfaad.so.0 at runtime [no] --enable-libgsm enable GSM support via libgsm [no] --enable-libmp3lame enable MP3 encoding via libmp3lame [no] --enable-libnut enable NUT (de)muxing via libnut, @@ -216,8 +211,6 @@ Advanced options (experts only): --arch=ARCH select architecture [$arch] --cpu=CPU select the minimum required CPU (affects instruction selection, may crash on older CPUs) - --enable-powerpc-perf enable performance report on PPC - (requires enabling PMC) --disable-asm disable all assembler optimizations --disable-altivec disable AltiVec optimizations --disable-amd3dnow disable 3DNow! optimizations @@ -242,7 +235,6 @@ Advanced options (experts only): Developer options (useful when working on FFmpeg itself): --disable-debug disable debugging symbols --enable-debug=LEVEL set the debug level [$debuglevel] - --enable-gprof enable profiling with gprof [$gprof] --disable-optimizations disable compiler optimizations --enable-extra-warnings enable more compiler warnings --disable-stripping disable stripping of executables and shared libraries @@ -253,6 +245,8 @@ EOF exit 0 } +quotes='""' + log(){ echo "$@" >> $logfile } @@ -268,6 +262,11 @@ echolog(){ echo "$@" } +warn(){ + log "WARNING: $*" + WARNINGS="${WARNINGS}WARNING: $*\n" +} + die(){ echolog "$@" cat < /dev/null -} - -save_flags(){ - flags_saved && return - SAVE_CFLAGS="$CFLAGS" - SAVE_LDFLAGS="$LDFLAGS" - SAVE_extralibs="$extralibs" -} - -restore_flags(){ - flags_saved || return - CFLAGS="$SAVE_CFLAGS" - LDFLAGS="$SAVE_LDFLAGS" - extralibs="$SAVE_extralibs" - unset SAVE_CFLAGS - unset SAVE_LDFLAGS - unset SAVE_extralibs -} - -temp_cflags(){ - save_flags - CFLAGS="$CFLAGS $*" -} - -temp_ldflags(){ - save_flags - LDFLAGS="$LDFLAGS $*" -} - -temp_extralibs(){ - save_flags - extralibs="$extralibs $*" +print_enabled(){ + test "$1" = -n && end=" " && shift || end="\n" + suf=$1 + shift + for v; do + enabled $v && printf "%s$end" ${v%$suf}; + done } append(){ var=$1 shift - flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\"" eval "$var=\"\$$var $*\"" } +prepend(){ + var=$1 + shift + eval "$var=\"$* \$$var\"" +} + add_cppflags(){ append CPPFLAGS $($filter_cppflags "$@") } @@ -571,7 +548,7 @@ add_ldflags(){ } add_extralibs(){ - append extralibs "$@" + prepend extralibs "$@" } check_cmd(){ @@ -729,11 +706,7 @@ check_lib(){ header="$1" func="$2" shift 2 - temp_extralibs "$@" - check_header $header && check_func $func && add_extralibs "$@" - err=$? - restore_flags - return $err + check_header $header && check_func $func "$@" && add_extralibs "$@" } check_lib2(){ @@ -825,23 +798,6 @@ require2(){ check_lib2 "$headers" $func "$@" || die "ERROR: $name not found" } -check_foo_config(){ - cfg=$1 - pkg=$2 - header=$3 - func=$4 - shift 4 - disable $cfg - check_cmd ${pkg}-config --version - err=$? - if test "$err" = 0; then - temp_cflags $(${pkg}-config --cflags) - temp_extralibs $(${pkg}-config --libs) - check_lib "$@" $header $func && enable $cfg - fi - return $err -} - check_host_cc(){ log check_host_cc "$@" cat > $TMPC @@ -894,7 +850,6 @@ CONFIG_LIST=" avfilter_lavf avformat avisynth - beos_netserver bzlib dct doc @@ -908,15 +863,12 @@ CONFIG_LIST=" fft golomb gpl - gprof gray h264dsp hardcoded_tables libdc1394 libdirac libfaac - libfaad - libfaadbin libgsm libmp3lame libnut @@ -941,7 +893,6 @@ CONFIG_LIST=" nonfree pic postproc - powerpc_perf rdft runtime_cpudetect shared @@ -958,8 +909,6 @@ CONFIG_LIST=" " THREADS_LIST=' - beosthreads - os2threads pthreads w32threads ' @@ -1009,6 +958,7 @@ ARCH_EXT_LIST=' HAVE_LIST_PUB=' bigendian + fast_unaligned ' HAVE_LIST=" @@ -1040,14 +990,16 @@ HAVE_LIST=" fast_64bit fast_clz fast_cmov - fast_unaligned + fcntl fork getaddrinfo gethrtime GetProcessMemoryInfo GetProcessTimes getrusage + gnu_as struct_rusage_ru_maxrss + ibm_asm inet_aton inline_asm isatty @@ -1086,6 +1038,9 @@ HAVE_LIST=" struct_sockaddr_in6 struct_sockaddr_sa_len struct_sockaddr_storage + symver + symver_gnu_asm + symver_asm_label sys_mman_h sys_resource_h sys_select_h @@ -1200,12 +1155,14 @@ fast_unaligned_if_any="armv6 ppc x86" need_memalign="altivec neon sse" inline_asm_deps="!tms470" +symver_if_any="symver_asm_label symver_gnu_asm" + # subsystems mdct_select="fft" rdft_select="fft" # decoders / encoders / hardware accelerators -aac_decoder_select="mdct rdft aac_parser" +aac_decoder_select="mdct rdft" aac_encoder_select="mdct" ac3_decoder_select="mdct ac3_parser" alac_encoder_select="lpc" @@ -1249,6 +1206,11 @@ ljpeg_encoder_select="aandct" loco_decoder_select="golomb" mjpeg_encoder_select="aandct" mlp_decoder_select="mlp_parser" +mp1float_decoder_select="dct" +mp2float_decoder_select="dct" +mp3adufloat_decoder_select="dct" +mp3float_decoder_select="dct" +mp3on4float_decoder_select="dct" mpeg1video_encoder_select="aandct" mpeg2video_encoder_select="aandct" mpeg4_decoder_select="h263_decoder mpeg4video_parser" @@ -1259,7 +1221,6 @@ mpeg2_dxva2_hwaccel_deps="dxva2api_h" mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder" mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder" mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder" -mpeg4_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h vdpau_mpeg4_support" mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder" mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h" mpeg_xvmc_decoder_select="mpegvideo_decoder" @@ -1275,6 +1236,7 @@ png_decoder_select="zlib" png_encoder_select="zlib" qcelp_decoder_select="lsp" qdm2_decoder_select="mdct rdft" +ra_144_encoder_select="lpc" rv10_decoder_select="h263_decoder" rv10_encoder_select="h263_encoder" rv20_decoder_select="h263_decoder" @@ -1306,12 +1268,13 @@ vorbis_decoder_select="mdct" vorbis_encoder_select="mdct" vp6a_decoder_select="vp6_decoder" vp6f_decoder_select="vp6_decoder" +vp8_decoder_select="h264dsp" wmapro_decoder_select="mdct" wmav1_decoder_select="mdct" wmav1_encoder_select="mdct" wmav2_decoder_select="mdct" wmav2_encoder_select="mdct" -wmavoice_decoder_select="lsp rdft dct" +wmavoice_decoder_select="lsp rdft dct mdct" wmv1_decoder_select="h263_decoder" wmv1_encoder_select="h263_encoder" wmv2_decoder_select="h263_decoder" @@ -1330,19 +1293,11 @@ vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h" # parsers h264_parser_select="golomb h264dsp" -latm_parser_deps="libfaad" - -# bitstream_filters -aac_adtstoasc_bsf_select="aac_parser" # external libraries libdirac_decoder_deps="libdirac !libschroedinger" libdirac_encoder_deps="libdirac" libfaac_encoder_deps="libfaac" -libfaad_decoder_deps="libfaad" -libfaad_latm_decoder_deps="libfaad" -libfaadbin_decoder_extralibs='$ldl' -libfaadbin_extralibs='$ldl' libgsm_decoder_deps="libgsm" libgsm_encoder_deps="libgsm" libgsm_ms_decoder_deps="libgsm" @@ -1395,10 +1350,6 @@ alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp" alsa_indev_extralibs="-lasound" alsa_outdev_deps="alsa_asoundlib_h" alsa_outdev_extralibs="-lasound" -audio_beos_indev_deps="audio_beos" -audio_beos_indev_extralibs="-lmedia -lbe" -audio_beos_outdev_deps="audio_beos" -audio_beos_outdev_extralibs="-lmedia -lbe" bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h" dv1394_indev_deps="dv1394 dv_demuxer" jack_indev_deps="jack_jack_h" @@ -1408,7 +1359,7 @@ oss_indev_deps_any="soundcard_h sys_soundcard_h" oss_outdev_deps_any="soundcard_h sys_soundcard_h" v4l_indev_deps="linux_videodev_h" v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h" -vfwcap_indev_deps="capCreateCaptureWindow" +vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines" vfwcap_indev_extralibs="-lavicap32" x11_grab_device_indev_deps="x11grab XShmCreateImage" x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes" @@ -1442,9 +1393,99 @@ ffserver_extralibs='$ldl' doc_deps="texi2html" +# tests + +test_deps(){ + suf1=$1 + suf2=$2 + shift 2 + for v; do + dep=${v%=*} + tests=${v#*=} + for name in ${tests}; do + eval ${name}_test_deps="'${dep}$suf1 ${dep}$suf2'" + done + done +} + +test_deps _encoder _decoder \ + ac3 \ + adpcm_g726=g726 \ + adpcm_ima_qt \ + adpcm_ima_wav \ + adpcm_ms \ + adpcm_swf \ + adpcm_yamaha=adpcm_yam \ + alac \ + asv1 \ + asv2 \ + bmp \ + dnxhd="hdxhd_1080i dnxhd_720p dnxhd_720p_rd" \ + dvvideo="dv dv50" \ + ffv1 \ + flac \ + flashsv \ + flv \ + gif \ + h261 \ + h263="h263 h263p" \ + huffyuv \ + jpegls \ + mjpeg="jpg mjpeg ljpeg" \ + mp2 \ + mpeg1video="mpeg mpeg1b" \ + mpeg2video="mpeg2 mpeg2thread" \ + mpeg4="mpeg4 mpeg4adv mpeg4nr mpeg4thread error rc" \ + msmpeg4v1=msmpeg4 \ + msmpeg4v2 \ + pbm=pbmpipe \ + pcx \ + pgm="pgm pgmpipe" \ + ppm="ppm ppmpipe" \ + rawvideo="rgb yuv" \ + roq \ + rv10 \ + rv20 \ + sgi \ + snow="snow snowll" \ + svq1 \ + targa=tga \ + tiff \ + wmav1 \ + wmav2 \ + wmv1 \ + wmv2 \ + +test_deps _muxer _demuxer \ + aiff \ + pcm_alaw=alaw \ + asf \ + au \ + avi \ + dv=dv_fmt \ + ffm \ + flv=flv_fmt \ + gxf \ + matroska=mkv \ + mmf \ + mov \ + pcm_mulaw=mulaw \ + mxf \ + nut \ + ogg \ + rawvideo=pixfmt \ + rm \ + swf \ + mpegts=ts \ + voc \ + wav \ + yuv4mpegpipe=yuv4mpeg \ + +mpg_test_deps="mpeg1system_muxer mpegps_demuxer" + # default parameters -logfile="config.err" +logfile="config.log" # installation paths prefix_default="/usr/local" @@ -1466,6 +1507,7 @@ objformat="elf" ranlib="ranlib" strip_default="strip" yasmexe="yasm" +nogas=":" nm_opts='-g' @@ -1521,8 +1563,8 @@ host_libs='-lm' target_path='$(CURDIR)' -# gcc stupidly only outputs the basename of targets with -MM, but we need the -# full relative path for objects in subdirectories for non-recursive Make. +# since the object filename is not given with the -MM flag, the compiler +# is only able to print the basename, and we must add the path ourselves DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)' DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM' @@ -1566,13 +1608,23 @@ INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c) PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c) FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c) +find_tests(){ + map 'echo ${v}_test' $(ls "$source_path"/tests/ref/$1 | grep -v '[^-a-z0-9_]') +} + +ACODEC_TESTS=$(find_tests acodec) +VCODEC_TESTS=$(find_tests vsynth1) +LAVF_TESTS=$(find_tests lavf) + +pcm_test_deps=$(map 'echo ${v%_*}_decoder $v' $(filter pcm_* $ENCODER_LIST)) + for n in $COMPONENT_LIST; do v=$(toupper ${n%s})_LIST eval enable \$$v eval ${n}_if_any="\$$v" done -enable $ARCH_EXT_LIST +enable $ARCH_EXT_LIST $ACODEC_TESTS $VCODEC_TESTS $LAVF_TESTS die_unknown(){ echo "Unknown option \"$1\"." @@ -1599,7 +1651,7 @@ for opt do --enable-debug=*) debuglevel="$optval" ;; --disable-everything) - map 'eval disable \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST + map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST ;; --enable-*=*|--disable-*=*) eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/') @@ -1815,7 +1867,8 @@ elif $cc -version 2>/dev/null | grep -q TMS470; then } elif $cc -v 2>&1 | grep -q clang; then cc_type=clang - cc_version=__VERSION__ + $cc -dM -E $TMPC | grep -q __clang_version__ && + cc_version=__clang_version__ || cc_version=__VERSION__ CC_DEPFLAGS='-MMD' AS_DEPFLAGS='-MMD' speed_cflags='-O3' @@ -1863,7 +1916,8 @@ elif $cc -V 2>&1 | grep -q Sun; then } fi -test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc" +test -n "$cc_type" && enable $cc_type || + warn "Unknown C compiler $cc, unable to select optimal CFLAGS" : ${as_default:=$cc} : ${dep_cc_default:=$cc} @@ -1954,7 +2008,7 @@ case "$arch" in ;; esac -is_in $arch $ARCH_LIST || echo "WARNING: unknown arch $arch" +is_in $arch $ARCH_LIST || warn "unknown architecture $arch" enable $arch # Add processor-specific flags @@ -2015,7 +2069,7 @@ elif enabled x86; then disable cmov ;; # targets that do support conditional mov (cmov) - i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10) + i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10|barcelona) cpuflags="-march=$cpu" enable cmov enable fast_cmov @@ -2133,30 +2187,10 @@ enabled spic && enable pic # OS specific case $target_os in - beos|haiku|zeta) - prefix_default="$HOME/config" - # 3 gcc releases known for BeOS, each with ugly bugs - gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)" - case "$gcc_version" in - 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc" - disable mmx - ;; - *20010315*) echo "BeBits gcc" - add_cflags -fno-expensive-optimizations - ;; - esac - SHFLAGS=-nostart - # enable BeOS things - enable audio_beos - # no need for libm, but the inet stuff - # Check for BONE - # XXX: actually should check for NOT net_server - if echo $BEINCLUDES | grep -q 'headers/be/bone'; then - network_extralibs="-lbind -lsocket" - else - enable beos_netserver - network_extralibs="-lnet" - fi ;; + haiku) + prefix_default="/boot/common" + network_extralibs="-lnetwork" + ;; sunos) FFSERVERLDFLAGS="" SHFLAGS='-shared -Wl,-h,$$(@F)' @@ -2186,14 +2220,16 @@ case $target_os in enable malloc_aligned ;; bsd/os) - osextralibs="-lpoll -lgnugetopt" + add_extralibs -lpoll -lgnugetopt strip="strip -d" ;; darwin) enable malloc_aligned + gas="gas-preprocessor.pl $cc" + enabled ppc && add_asflags -force_cpusubtype_ALL SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress' - strip="strip -x" - FFLDFLAGS="-Wl,-dynamic,-search_paths_first" + strip="${strip} -x" + add_ldflags -Wl,-dynamic,-search_paths_first SLIBSUF=".dylib" SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)' SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)' @@ -2232,13 +2268,9 @@ case $target_os in objformat="win32" enable dos_paths check_cflags -fno-common - if ! enabled x86_64; then - check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" || + check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) \ + || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" || die "ERROR: MinGW runtime version must be >= 3.15." - enabled_any avisynth vfwcap_indev && - { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" || - die "ERROR: avisynth and vfwcap_indev require w32api version 3.13 or later."; } - fi ;; cygwin*) target_os=cygwin @@ -2269,7 +2301,7 @@ case $target_os in os/2*) strip="lxlite" ln_s="cp -f" - FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap" + add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf' FFSERVERLDFLAGS="" LIBSUF="_s.a" @@ -2304,11 +2336,6 @@ check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PI set_default $PATHS_LIST -add_extralibs $osextralibs - -# Combine FFLDFLAGS and the LDFLAGS environment variable. -LDFLAGS="$FFLDFLAGS $LDFLAGS" - # we need to build at least one lib type if ! enabled_any static shared; then cat < -#ifndef FAAD2_VERSION -ok faad1 -#endif -int main(void) { return 0; } -EOF - test $? = 0 && enable libfaad2 - else - die "FAAD test failed." - fi -fi - - die_license_disabled() { enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; } } -die_license_disabled gpl libfaad2 die_license_disabled gpl libx264 die_license_disabled gpl libxvid die_license_disabled gpl postproc @@ -2405,6 +2415,7 @@ if enabled alpha; then elif enabled arm; then check_cflags -marm + nogas=die check_ld <= 2.2.f"; } enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) && require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0) enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg -enabled libvpx && require2 libvpx "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_dec_init_ver" -lvpx && - require2 libvpx "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver" -lvpx -enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 -lm && +enabled libvpx && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx && + check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_enc_init_ver -lvpx || + die "ERROR: libvpx version must be >=0.9.1"; } +enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 && { check_cpp_condition x264.h "X264_BUILD >= 98" || die "ERROR: libx264 version must be >= 0.98."; } enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore @@ -2691,6 +2714,9 @@ check_header linux/videodev2.h check_header sys/videoio.h check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs" +# check that WM_CAP_DRIVER_CONNECT is defined to the proper value +# w32api 3.12 had it defined wrong +check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines # check for ioctl_meteor.h, ioctl_bt848.h and alternatives { check_header dev/bktr/ioctl_meteor.h && @@ -2737,8 +2763,7 @@ check_cflags -Wcast-qual check_cflags -Wwrite-strings check_cflags -Wtype-limits check_cflags -Wundef -# some gcc compilers (mingw 4.2.1-sjlj) are b0rk so for now skip this -# check_cflags -Wmissing-prototypes +check_cflags -Wmissing-prototypes enabled extra_warnings && check_cflags -Winline # add some linker flags @@ -2748,8 +2773,17 @@ check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUI check_ldflags -Wl,-Bsymbolic echo "X{};" > $TMPV -test_ldflags -Wl,--version-script,$TMPV && +if test_ldflags -Wl,--version-script,$TMPV; then append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver' + check_cc <>config.mak <> $TMPH echo "endif # FFMPEG_CONFIG_MAK" >> config.mak @@ -3115,6 +3146,8 @@ echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH cp_if_changed $TMPH libavutil/avconfig.h +test -n "$WARNINGS" && printf "\n$WARNINGS" + # build pkg-config files pkgconfig_generate(){ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/APIchanges b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/APIchanges index 2337f33a2..215022534 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/APIchanges +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/APIchanges @@ -12,26 +12,68 @@ libavutil: 2009-03-08 API changes, most recent first: +2010-07-11 - r24199 - lavc 52.83.0 + Add AVCodecContext.lpc_type and AVCodecContext.lpc_passes fields. + Add AVLPCType enum. + Deprecate AVCodecContext.use_lpc. + +2010-07-11 - r24185 - lavc 52.82.0 - avsubtitle_free() + Add a function for free the contents of a AVSubtitle generated by + avcodec_decode_subtitle. + +2010-07-11 - r24174 - lavu 50.22.0 - bswap.h and intreadwrite.h + Make the bswap.h and intreadwrite.h API public. + +2010-07-08 - r24101 - lavu 50.21.0 - pixdesc.h + Rename read/write_line() to av_read/write_image_line(). + +2010-07-07 - r24091 - lavfi 1.21.0 - avfilter_copy_picref_props() + Add avfilter_copy_picref_props(). + +2010-07-03 - r24021 - lavc 52.79.0 + Add FF_COMPLIANCE_UNOFFICIAL and change all instances of + FF_COMPLIANCE_INOFFICIAL to use FF_COMPLIANCE_UNOFFICIAL. + +2010-07-02 - r23985 - lavu 50.20.0 - lfg.h + Export av_lfg_init(), av_lfg_get(), av_mlfg_get(), and av_bmg_get() through + lfg.h. + +2010-06-28 - r23835 - lavfi 1.20.1 - av_parse_color() + Extend av_parse_color() syntax, make it accept an alpha value specifier and + set the alpha value to 255 by default. + +2010-06-22 - r23706 - lavf 52.71.0 - URLProtocol.priv_data_size, priv_data_class + Add priv_data_size and priv_data_class to URLProtocol. + +2010-06-22 - r23704 - lavf 52.70.0 - url_alloc(), url_connect() + Add url_alloc() and url_connect(). + +2010-06-22 - r23702 - lavf 52.69.0 - av_register_protocol2() + Add av_register_protocol2(), deprecating av_register_protocol(). + +2010-06-09 - r23551 - lavu 50.19.0 - av_compare_mod() + Add av_compare_mod() to libavutil/mathematics.h. + 2010-06-05 - r23485 - lavu 50.18.0 - eval API Make the eval API public. 2010-06-04 - r23461 - lavu 50.17.0 - AV_BASE64_SIZE Add AV_BASE64_SIZE() macro. -2010-06-02 - r23421 - lavc 52.73.0 - av_get_codec_tag_string +2010-06-02 - r23421 - lavc 52.73.0 - av_get_codec_tag_string() Add av_get_codec_tag_string(). 2010-06-01 - r31301 - lsws 0.11.0 - convertPalette API - Add sws_convertPalette8ToPacked32 and sws_convertPalette8ToPacked24 + Add sws_convertPalette8ToPacked32() and sws_convertPalette8ToPacked24(). 2010-05-26 - r23334 - lavc 52.72.0 - CODEC_CAP_EXPERIMENTAL Add CODEC_CAP_EXPERIMENTAL flag. -2010-05-23 - r23255 - lavu 50.16.0 - av_get_random_seed - Add av_get_random_seed() +2010-05-23 - r23255 - lavu 50.16.0 - av_get_random_seed() + Add av_get_random_seed(). 2010-05-18 - r23161 - lavf 52.63.0 - AVFMT_FLAG_RTP_HINT - Add AVFMT_FLAG_RTP_HINT as possible value for AVFormatContext.flags + Add AVFMT_FLAG_RTP_HINT as possible value for AVFormatContext.flags. 2010-05-09 - r23066 - lavfi 1.20.0 - AVFilterPicRef Add interlaced and top_field_first fields to AVFilterPicRef. @@ -45,7 +87,7 @@ API changes, most recent first: existing tags. 2010-04-01 - r22753 - lavc 52.66.0 - Add avcodec_get_edge_width() + Add avcodec_get_edge_width(). 2010-03-31 - r22750 - lavc 52.65.0 Add avcodec_copy_context(). @@ -64,7 +106,7 @@ API changes, most recent first: Implement av_strerror(). 2010-03-23 - r22649 - lavc 52.60.0 - av_dct_init() - Support DCT-I and DST-I + Support DCT-I and DST-I. 2010-03-15 - r22540 - lavf 52.56.0 - AVFormatContext.start_time_realtime Add AVFormatContext.start_time_realtime field. @@ -98,13 +140,13 @@ API changes, most recent first: 2010-01-30 - r21545 - lavu 50.8.0 - av_get_pix_fmt() Add av_get_pix_fmt(). -2010-01-21 - r30381 - lsws 0.9.0 - sws_scale +2010-01-21 - r30381 - lsws 0.9.0 - sws_scale() Change constness attributes of sws_scale() parameters. 2010-01-10 - r21121 - lavfi 1.15.0 - avfilter_graph_config_links() Add a log_ctx parameter to avfilter_graph_config_links(). -2010-01-07 - r30236 - lsws 0.8.0 - sws_isSupported{In,Out}put +2010-01-07 - r30236 - lsws 0.8.0 - sws_isSupported{In,Out}put() Add sws_isSupportedInput() and sws_isSupportedOutput() functions. 2010-01-06 - r21035 - lavfi 1.14.0 - avfilter_add_colorspace() @@ -121,7 +163,8 @@ API changes, most recent first: Add av_guess_format(), it should be used in place of guess_format(). 2009-12-13 - r20834 - lavf 52.43.0 - metadata API - Add av_metadata_set2(), AV_METADATA_DONT_STRDUP_KEY and AV_METADATA_DONT_STRDUP_VAL. + Add av_metadata_set2(), AV_METADATA_DONT_STRDUP_KEY and + AV_METADATA_DONT_STRDUP_VAL. 2009-12-13 - r20829 - lavu 50.7.0 - avstring.h API Add av_d2str(). @@ -187,10 +230,10 @@ API changes, most recent first: When the lock manager is registered, FFmpeg is guaranteed to behave correctly in a multi-threaded application. -2009-04-30 - r18719 - lavc 52.28.0 - av_free_packet +2009-04-30 - r18719 - lavc 52.28.0 - av_free_packet() av_free_packet() is no longer an inline function. It is now exported. -2009-04-11 - r18431 - lavc 52.25.0 - deprecate av_destruct_packet_nofree +2009-04-11 - r18431 - lavc 52.25.0 - deprecate av_destruct_packet_nofree() Please use NULL instead. This has been supported since r16506 (lavf > 52.23.1, lavc > 52.10.0). @@ -200,7 +243,7 @@ API changes, most recent first: avcodec_decode_subtitle2(). These new functions take an AVPacket *pkt argument instead of a const uint8_t *buf / int buf_size pair. -2009-04-03 - r18321 - lavu 50.3.0 - av_fifo_space +2009-04-03 - r18321 - lavu 50.3.0 - av_fifo_space() Introduce the av_fifo_space() function. 2009-04-02 - r18317 - lavc 52.23.0 - AVPacket diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/TODO b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/TODO index f03270ec1..747eee4ab 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/TODO +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/TODO @@ -29,14 +29,6 @@ Michael's TODO list: (unordered) (if anyone wanna help with sth, just ask) - more optimizations - simper rate control -Francois' TODO list: (unordered, without any timeframe) -------------------- -- test MACE decoder against the openquicktime one as suggested by A'rpi -- BeOS audio input grabbing backend -- BeOS video input grabbing backend -- publish my BeOS libposix on BeBits so I can officially support ffserver :) -- check the whole code for thread-safety (global and init stuff) - Philip'a TODO list: (alphabetically ordered) (please help) ------------------ - Add a multi-ffm filetype so that feeds can be recorded into multiple files rather diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/faq.texi b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/faq.texi index ec01b9ee9..3f1773894 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/faq.texi +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/faq.texi @@ -286,8 +286,6 @@ material, and try '-top 0/1' if the result looks really messed-up. If you have built FFmpeg with @code{./configure --enable-avisynth} (only possible on MinGW/Cygwin platforms), then you may use any file that DirectShow can read as input. -(Be aware that this feature has been recently added, -so you will need to help yourself in case of problems.) Just create an "input.avs" text file with this single line ... @example diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffmpeg-doc.texi b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffmpeg-doc.texi index c783695f3..7e3abadbb 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffmpeg-doc.texi +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffmpeg-doc.texi @@ -7,6 +7,16 @@ @sp 3 @end titlepage +@chapter Synopsis + +The generic syntax is: + +@example +@c man begin SYNOPSIS +ffmpeg [[infile options][@option{-i} @var{infile}]]... @{[outfile options] @var{outfile}@}... +@c man end +@end example + @chapter Description @c man begin DESCRIPTION @@ -50,18 +60,7 @@ specified for the inputs. @c man end DESCRIPTION -@chapter Invocation - -@section Syntax - -The generic syntax is: - -@example -@c man begin SYNOPSIS -ffmpeg [[infile options][@option{-i} @var{infile}]]... @{[outfile options] @var{outfile}@}... -@c man end -@end example - +@chapter Options @c man begin OPTIONS @include fftools-common-opts.texi @@ -100,7 +99,16 @@ Specifying a positive offset means that the corresponding streams are delayed by 'offset' seconds. @item -timestamp @var{time} -Set the timestamp. +Set the recording timestamp in the container. +The syntax for @var{time} is: +@example +now|([(YYYY-MM-DD|YYYYMMDD)[T|t| ]]((HH[:MM[:SS[.m...]]])|(HH[MM[SS[.m...]]]))[Z|z]) +@end example +If the value is "now" it takes the current time. +Time is local time unless 'Z' or 'z' is appended, in which case it is +interpreted as UTC. +If the year-month-day part is not specified it takes the current +year-month-day. @item -metadata @var{key}=@var{value} Set a metadata key/value pair. @@ -218,27 +226,21 @@ The following abbreviations are recognized: @item -aspect @var{aspect} Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777). -@item -croptop @var{size} +@item -croptop @var{size} (deprecated - use -vf crop=x:y:width:height instead) Set top crop band size (in pixels). -@item -cropbottom @var{size} +@item -cropbottom @var{size} (deprecated - use -vf crop=x:y:width:height instead) Set bottom crop band size (in pixels). -@item -cropleft @var{size} +@item -cropleft @var{size} (deprecated - use -vf crop=x:y:width:height instead) Set left crop band size (in pixels). -@item -cropright @var{size} +@item -cropright @var{size} (deprecated - use -vf crop=x:y:width:height instead) Set right crop band size (in pixels). @item -padtop @var{size} -Set top pad band size (in pixels). @item -padbottom @var{size} -Set bottom pad band size (in pixels). @item -padleft @var{size} -Set left pad band size (in pixels). @item -padright @var{size} -Set right pad band size (in pixels). @item -padcolor @var{hex_color} -Set color of padded bands. The value for padcolor is expressed -as a six digit hexadecimal number where the first two digits -represent red, the middle two digits green and last two digits -blue (default = 000000 (black)). +All the pad options have been removed. Use -vf +pad=width:height:x:y:color instead. @item -vn Disable video recording. @item -bt @var{tolerance} @@ -291,6 +293,12 @@ Add a new video stream to the current output stream. @item -vlang @var{code} Set the ISO 639 language code (3 letters) of the current video stream. +@item -vf @var{filter_graph} +@var{filter_graph} is a description of the filter graph to apply to +the input video. +Use the option "-filters" to show all the available filters (including +also sources and sinks). + @end table @section Advanced Video Options @@ -624,6 +632,15 @@ Timestamp discontinuity delta threshold. Set the maximum demux-decode delay. @item -muxpreload @var{seconds} Set the initial demux-decode delay. +@item -streamid @var{output-stream-index}:@var{new-value} +Assign a new value to a stream's stream-id field in the next output file. +All stream-id fields are reset to default for each output file. + +For example, to set the stream 0 PID to 33 and the stream 1 PID to 36 for +an output mpegts file: +@example +ffmpeg -i infile -streamid 0:33 -streamid 1:36 out.ts +@end example @end table @section Preset files @@ -947,6 +964,8 @@ options have to be specified immediately after the name of the output file to which you want to add them. @c man end EXAMPLES +@include filters.texi + @ignore @setfilename ffmpeg diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffmpeg_powerpc_performance_evaluation_howto.txt b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffmpeg_powerpc_performance_evaluation_howto.txt deleted file mode 100644 index 2eb4ee71a..000000000 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffmpeg_powerpc_performance_evaluation_howto.txt +++ /dev/null @@ -1,172 +0,0 @@ -FFmpeg & evaluating performance on the PowerPC Architecture HOWTO - -(c) 2003-2004 Romain Dolbeau - - - -I - Introduction - -The PowerPC architecture and its SIMD extension AltiVec offer some -interesting tools to evaluate performance and improve the code. -This document tries to explain how to use those tools with FFmpeg. - -The architecture itself offers two ways to evaluate the performance of -a given piece of code: - -1) The Time Base Registers (TBL) -2) The Performance Monitor Counter Registers (PMC) - -The first ones are always available, always active, but they're not very -accurate: the registers increment by one every four *bus* cycles. On -my 667 Mhz tiBook (ppc7450), this means once every twenty *processor* -cycles. So we won't use that. - -The PMC are much more useful: not only can they report cycle-accurate -timing, but they can also be used to monitor many other parameters, -such as the number of AltiVec stalls for every kind of instruction, -or instruction cache misses. The downside is that not all processors -support the PMC (all G3, all G4 and the 970 do support them), and -they're inactive by default - you need to activate them with a -dedicated tool. Also, the number of available PMC depends on the -procesor: the various 604 have 2, the various 75x (aka. G3) have 4, -and the various 74xx (aka G4) have 6. - -*WARNING*: The PowerPC 970 is not very well documented, and its PMC -registers are 64 bits wide. To properly notify the code, you *must* -tune for the 970 (using --tune=970), or the code will assume 32 bit -registers. - - -II - Enabling FFmpeg PowerPC performance support - -This needs to be done by hand. First, you need to configure FFmpeg as -usual, but add the "--powerpc-perf-enable" option. For instance: - -##### -./configure --prefix=/usr/local/ffmpeg-svn --cc=gcc-3.3 --tune=7450 --powerpc-perf-enable -##### - -This will configure FFmpeg to install inside /usr/local/ffmpeg-svn, -compiling with gcc-3.3 (you should try to use this one or a newer -gcc), and tuning for the PowerPC 7450 (i.e. the newer G4; as a rule of -thumb, those at 550Mhz and more). It will also enable the PMC. - -You may also edit the file "config.h" to enable the following line: - -##### -// #define ALTIVEC_USE_REFERENCE_C_CODE 1 -##### - -If you enable this line, then the code will not make use of AltiVec, -but will use the reference C code instead. This is useful to compare -performance between two versions of the code. - -Also, the number of enabled PMC is defined in "libavcodec/ppc/dsputil_ppc.h": - -##### -#define POWERPC_NUM_PMC_ENABLED 4 -##### - -If you have a G4 CPU, you can enable all 6 PMC. DO NOT enable more -PMC than available on your CPU! - -Then, simply compile FFmpeg as usual (make && make install). - - - -III - Using FFmpeg PowerPC performance support - -This FFmeg can be used exactly as usual. But before exiting, FFmpeg -will dump a per-function report that looks like this: - -##### -PowerPC performance report - Values are from the PMC registers, and represent whatever the - registers are set to record. - Function "gmc1_altivec" (pmc1): - min: 231 - max: 1339867 - avg: 558.25 (255302) - Function "gmc1_altivec" (pmc2): - min: 93 - max: 2164 - avg: 267.31 (255302) - Function "gmc1_altivec" (pmc3): - min: 72 - max: 1987 - avg: 276.20 (255302) -(...) -##### - -In this example, PMC1 was set to record CPU cycles, PMC2 was set to -record AltiVec Permute Stall Cycles, and PMC3 was set to record AltiVec -Issue Stalls. - -The function "gmc1_altivec" was monitored 255302 times, and the -minimum execution time was 231 processor cycles. The max and average -aren't much use, as it's very likely the OS interrupted execution for -reasons of its own :-( - -With the exact same settings and source file, but using the reference C -code we get: - -##### -PowerPC performance report - Values are from the PMC registers, and represent whatever the - registers are set to record. - Function "gmc1_altivec" (pmc1): - min: 592 - max: 2532235 - avg: 962.88 (255302) - Function "gmc1_altivec" (pmc2): - min: 0 - max: 33 - avg: 0.00 (255302) - Function "gmc1_altivec" (pmc3): - min: 0 - max: 350 - avg: 0.03 (255302) -(...) -##### - -592 cycles, so the fastest AltiVec execution is about 2.5x faster than -the fastest C execution in this example. It's not perfect but it's not -bad (well I wrote this function so I can't say otherwise :-). - -Once you have that kind of report, you can try to improve things by -finding what goes wrong and fixing it; in the example above, one -should try to diminish the number of AltiVec stalls, as this *may* -improve performance. - - - -IV) Enabling the PMC in Mac OS X - -This is easy. Use "Monster" and "monster". Those tools come from -Apple's CHUD package, and can be found hidden in the developer web -site & FTP site. "MONster" is the graphical application, use it to -generate a config file specifying what each register should -monitor. Then use the command-line application "monster" to use that -config file, and enjoy the results. - -Note that "MONster" can be used for many other things, but it's -documented by Apple, it's not my subject. - -If you are using CHUD 4.4.2 or later, you'll notice that MONster is -no longer available. It's been superseeded by Shark, where -configuration of PMCs is available as a plugin. - - - -V) Enabling the PMC on Linux - -On linux you may use oprofile from http://oprofile.sf.net, depending on the -version and the cpu you may need to apply a patch[1] to access a set of the -possibile counters from the userspace application. You can always define them -using the kernel interface /dev/oprofile/* . - -[1] http://dev.gentoo.org/~lu_zero/development/oprofile-g4-20060423.patch - --- -Romain Dolbeau -Luca Barbato diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffplay-doc.texi b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffplay-doc.texi index 9510726d1..5e8032fb5 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffplay-doc.texi +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffplay-doc.texi @@ -7,6 +7,13 @@ @sp 3 @end titlepage +@chapter Synopsis + +@example +@c man begin SYNOPSIS +ffplay [options] @file{input_file} +@c man end +@end example @chapter Description @c man begin DESCRIPTION @@ -16,15 +23,7 @@ libraries and the SDL library. It is mostly used as a testbed for the various FFmpeg APIs. @c man end -@chapter Invocation - -@section Syntax -@example -@c man begin SYNOPSIS -ffplay [options] @file{input_file} -@c man end -@end example - +@chapter Options @c man begin OPTIONS @include fftools-common-opts.texi @@ -57,6 +56,12 @@ Force format. Set window title (default is the input filename). @item -loop @var{number} Loops movie playback times. 0 means forever. +@item -vf @var{filter_graph} +@var{filter_graph} is a description of the filter graph to apply to +the input video. +Use the option "-filters" to show all the available filters (including +also sources and sinks). + @end table @section Advanced options @@ -103,6 +108,12 @@ Select the desired subtitle stream number, counting from 0. The number refers to the list of all the input subtitle streams. If it is greater than the number of subtitle streams minus one, then the last one is selected, if it is negative the subtitle rendering is disabled. +@item -autoexit +Exit when video is done playing. +@item -exitonkeydown +Exit if any key is pressed. +@item -exitonmousedown +Exit if any mouse button is pressed. @end table @section While playing @@ -142,6 +153,8 @@ Seek to percentage in file corresponding to fraction of width. @c man end +@include filters.texi + @ignore @setfilename ffplay diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffprobe-doc.texi b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffprobe-doc.texi index f8a16b280..a1a11c16f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffprobe-doc.texi +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffprobe-doc.texi @@ -7,6 +7,16 @@ @sp 3 @end titlepage +@chapter Synopsis + +The generic syntax is: + +@example +@c man begin SYNOPSIS +ffprobe [options] [@file{input_file}] +@c man end +@end example + @chapter Description @c man begin DESCRIPTION @@ -45,18 +55,7 @@ are prefixed by the string ``TAG:''. @c man end -@chapter Invocation - -@section Syntax - -The generic syntax is: - -@example -@c man begin SYNOPSIS -ffprobe [options] [@file{input_file}] -@c man end -@end example - +@chapter Options @c man begin OPTIONS @include fftools-common-opts.texi diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffserver-doc.texi b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffserver-doc.texi index cebb289f2..77deb8531 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffserver-doc.texi +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffserver-doc.texi @@ -7,6 +7,15 @@ @sp 3 @end titlepage +@chapter Synopsys + +The generic syntax is: + +@example +@c man begin SYNOPSIS +ffserver [options] +@c man end +@end example @chapter Description @c man begin DESCRIPTION @@ -226,15 +235,7 @@ You use this by adding the ?date= to the end of the URL for the stream. For example: @samp{http://localhost:8080/test.asf?date=2002-07-26T23:05:00}. @c man end -@chapter Invocation -@section Syntax -@example -@c man begin SYNOPSIS -ffserver [options] -@c man end -@end example - -@section Options +@chapter Options @c man begin OPTIONS @include fftools-common-opts.texi diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffserver.conf b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffserver.conf index 2fbfecd68..217117005 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffserver.conf +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/ffserver.conf @@ -306,6 +306,27 @@ StartSendOnKey # +# Transcode an incoming live feed to another live feed, +# using libx264 and video presets + +# +#Format rtp +#Feed feed1.ffm +#VideoCodec libx264 +#VideoFrameRate 24 +#VideoBitRate 100 +#VideoSize 480x272 +#AVPresetVideo default +#AVPresetVideo baseline +#AVOptionVideo flags +global_header +# +#AudioCodec libfaac +#AudioBitRate 32 +#AudioChannels 2 +#AudioSampleRate 22050 +#AVOptionAudio flags +global_header +# + ################################################################## # SDP/multicast examples # diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/fftools-common-opts.texi b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/fftools-common-opts.texi index 4fc271d3e..618441e04 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/fftools-common-opts.texi +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/fftools-common-opts.texi @@ -1,3 +1,16 @@ +All the numerical options, if not specified otherwise, accept in input +a string representing a number, which may contain one of the +International System number postfixes, for example 'K', 'M', 'G'. +If 'i' is appended after the postfix, powers of 2 are used instead of +powers of 10. The 'B' postfix multiplies the value for 8, and can be +appended after another postfix or used alone. This allows using for +example 'KB', 'MiB', 'G' and 'B' as postfix. + +Options which do not take arguments are boolean options, and set the +corresponding value to true. They can be set to false by prefixing +with "no" the option name, for example using "-nofoo" in the +commandline will set to false the boolean option with name "foo". + @section Generic options These options are shared amongst the ff* tools. @@ -69,4 +82,8 @@ Set the logging level used by the library. @item debug @end table +By default the program logs to stderr, if coloring is supported by the +terminal, colors are used to mark errors and warnings. Log coloring +can be disabled setting the environment variable @env{NO_COLOR}. + @end table diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/filters.texi b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/filters.texi new file mode 100644 index 000000000..cd4364a78 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/filters.texi @@ -0,0 +1,258 @@ +@chapter Video Filters +@c man begin VIDEO FILTERS + +When you configure your FFmpeg build, you can disable any of the +existing filters using --disable-filters. +The configure output will show the video filters included in your +build. + +Below is a description of the currently available video filters. + +@section crop + +Crop the input video to @var{x}:@var{y}:@var{width}:@var{height}. + +@example +./ffmpeg -i in.avi -vf "crop=0:0:0:240" out.avi +@end example + +@var{x} and @var{y} specify the position of the top-left corner of the +output (non-cropped) area. + +The default value of @var{x} and @var{y} is 0. + +The @var{width} and @var{height} parameters specify the width and height +of the output (non-cropped) area. + +A value of 0 is interpreted as the maximum possible size contained in +the area delimited by the top-left corner at position x:y. + +For example the parameters: + +@example +"crop=100:100:0:0" +@end example + +will delimit the rectangle with the top-left corner placed at position +100:100 and the right-bottom corner corresponding to the right-bottom +corner of the input image. + +The default value of @var{width} and @var{height} is 0. + +@section format + +Convert the input video to one of the specified pixel formats. +Libavfilter will try to pick one that is supported for the input to +the next filter. + +The filter accepts a list of pixel format names, separated by ``:'', +for example ``yuv420p:monow:rgb24''. + +The following command: + +@example +./ffmpeg -i in.avi -vf "format=yuv420p" out.avi +@end example + +will convert the input video to the format ``yuv420p''. + +@section noformat + +Force libavfilter not to use any of the specified pixel formats for the +input to the next filter. + +The filter accepts a list of pixel format names, separated by ``:'', +for example ``yuv420p:monow:rgb24''. + +The following command: + +@example +./ffmpeg -i in.avi -vf "noformat=yuv420p, vflip" out.avi +@end example + +will make libavfilter use a format different from ``yuv420p'' for the +input to the vflip filter. + +@section null + +Pass the source unchanged to the output. + +@section pad + +Add paddings to the input image, and places the original input at the +given coordinates @var{x}, @var{y}. + +It accepts the following parameters: +@var{width}:@var{height}:@var{x}:@var{y}:@var{color}. + +Follows the description of the accepted parameters. + +@table @option +@item width, height + +Specify the size of the output image with the paddings added. If the +value for @var{width} or @var{height} is 0, the corresponding input size +is used for the output. + +The default value of @var{width} and @var{height} is 0. + +@item x, y + +Specify the offsets where to place the input image in the padded area +with respect to the top/left border of the output image. + +The default value of @var{x} and @var{y} is 0. + +@item color + +Specify the color of the padded area, it can be the name of a color +(case insensitive match) or a 0xRRGGBB[AA] sequence. + +The default value of @var{color} is ``black''. + +@end table + +@section pixdesctest + +Pixel format descriptor test filter, mainly useful for internal +testing. The output video should be equal to the input video. + +For example: +@example +format=monow, pixdesctest +@end example + +can be used to test the monowhite pixel format descriptor definition. + +@section scale + +Scale the input video to @var{width}:@var{height} and/or convert the image format. + +For example the command: + +@example +./ffmpeg -i in.avi -vf "scale=200:100" out.avi +@end example + +will scale the input video to a size of 200x100. + +If the input image format is different from the format requested by +the next filter, the scale filter will convert the input to the +requested format. + +If the value for @var{width} or @var{height} is 0, the respective input +size is used for the output. + +If the value for @var{width} or @var{height} is -1, the scale filter will +use, for the respective output size, a value that maintains the aspect +ratio of the input image. + +The default value of @var{width} and @var{height} is 0. + +@section slicify + +Pass the images of input video on to next video filter as multiple +slices. + +@example +./ffmpeg -i in.avi -vf "slicify=32" out.avi +@end example + +The filter accepts the slice height as parameter. If the parameter is +not specified it will use the default value of 16. + +Adding this in the beginning of filter chains should make filtering +faster due to better use of the memory cache. + +@section unsharp + +Sharpen or blur the input video. + +It accepts the following parameters: +@var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount} + +Negative values for the amount will blur the input video, while positive +values will sharpen. All parameters are optional and default to the +equivalent of the string '5:5:1.0:0:0:0.0'. + +@table @option + +@item luma_msize_x +Set the luma matrix horizontal size. It can be an integer between 3 +and 13, default value is 5. + +@item luma_msize_y +Set the luma matrix vertical size. It can be an integer between 3 +and 13, default value is 5. + +@item luma_amount +Set the luma effect strength. It can be a float number between -2.0 +and 5.0, default value is 1.0. + +@item chroma_msize_x +Set the chroma matrix horizontal size. It can be an integer between 3 +and 13, default value is 0. + +@item chroma_msize_y +Set the chroma matrix vertical size. It can be an integer between 3 +and 13, default value is 0. + +@item luma_amount +Set the chroma effect strength. It can be a float number between -2.0 +and 5.0, default value is 0.0. + +@end table + +@example +# Strong luma sharpen effect parameters +unsharp=7:7:2.5 + +# Strong blur of both luma and chroma parameters +unsharp=7:7:-2:7:7:-2 + +# Use the default values with @command{ffmpeg} +./ffmpeg -i in.avi -vf "unsharp" out.mp4 +@end example + +@section vflip + +Flip the input video vertically. + +@example +./ffmpeg -i in.avi -vf "vflip" out.avi +@end example + +@c man end VIDEO FILTERS + +@chapter Video Sources +@c man begin VIDEO SOURCES + +Below is a description of the currently available video sources. + +@section nullsrc + +Null video source, never return images. It is mainly useful as a +template and to be employed in analysis / debugging tools. + +It accepts as optional parameter a string of the form +@var{width}:@var{height}, where @var{width} and @var{height} specify the size of +the configured source. + +The default values of @var{width} and @var{height} are respectively 352 +and 288 (corresponding to the CIF size format). + +@c man end VIDEO SOURCES + +@chapter Video Sinks +@c man begin VIDEO SINKS + +Below is a description of the currently available video sinks. + +@section nullsink + +Null video sink, do absolutely nothing with the input video. It is +mainly useful as a template and to be employed in analysis / debugging +tools. + +@c man end VIDEO SINKS + diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/general.texi b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/general.texi index a9208a671..3a1fb7c0f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/general.texi +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/general.texi @@ -281,6 +281,8 @@ following image formats are supported: @tab Portable GrayMap image @item PGMYUV @tab X @tab X @tab PGM with U and V components in YUV 4:2:0 +@item PIC @tab @tab X + @tab Pictor/PC Paint @item PNG @tab X @tab X @tab 2/4 bpp not supported yet @item PPM @tab X @tab X @@ -439,8 +441,8 @@ following image formats are supported: @tab fourcc: VP50 @item On2 VP6 @tab @tab X @tab fourcc: VP60,VP61,VP62 -@item VP8 @tab X @tab X - @tab fourcc: VP80, de/encoding supported through external library libvpx +@item VP8 @tab E @tab X + @tab fourcc: VP80, encoding supported through external library libvpx @item planar RGB @tab @tab X @tab fourcc: 8BPS @item Q-team QPEG @tab @tab X @@ -587,10 +589,10 @@ following image formats are supported: @item Enhanced AC-3 @tab @tab X @item FLAC (Free Lossless Audio Codec) @tab X @tab IX @item G.729 @tab @tab X -@item GSM @tab E @tab E - @tab supported through external library libgsm -@item GSM Microsoft variant @tab E @tab E - @tab supported through external library libgsm +@item GSM @tab E @tab X + @tab encoding supported through external library libgsm +@item GSM Microsoft variant @tab E @tab X + @tab encoding supported through external library libgsm @item IMC (Intel Music Coder) @tab @tab X @item MACE (Macintosh Audio Compression/Expansion) 3:1 @tab @tab X @item MACE (Macintosh Audio Compression/Expansion) 6:1 @tab @tab X @@ -633,7 +635,7 @@ following image formats are supported: @item QCELP / PureVoice @tab @tab X @item QDesign Music Codec 2 @tab @tab X @tab There are still some distortions. -@item RealAudio 1.0 (14.4K) @tab @tab X +@item RealAudio 1.0 (14.4K) @tab X @tab X @tab Real 14400 bit/s codec @item RealAudio 2.0 (28.8K) @tab @tab X @tab Real 28800 bit/s codec @@ -706,7 +708,6 @@ performance on systems without hardware floating point support). @multitable @columnfractions .4 .1 .1 @item Name @tab Input @tab Output @item ALSA @tab X @tab X -@item BEOS audio @tab X @tab X @item BKTR @tab X @tab @item DV1394 @tab X @tab @item JACK @tab X @tab @@ -723,10 +724,6 @@ performance on systems without hardware floating point support). @chapter Platform Specific information -@section BeOS - -BeOS support is broken in mysterious ways. - @section DOS Using a cross-compiler is preferred for various reasons. @@ -785,6 +782,12 @@ bash directly to work around this: bash ./configure @end example +@subsection Darwin (MacOS X, iPhone) + +MacOS X on PowerPC or ARM (iPhone) requires a preprocessor from +@url{http://github.com/yuvi/gas-preprocessor} to build the optimized +assembler functions. + @section Windows To get help and instructions for building FFmpeg under Windows, check out @@ -1028,7 +1031,7 @@ These library packages are only available from Cygwin Ports (@url{http://sourceware.org/cygwinports/}) : @example -yasm, libSDL-devel, libdirac-devel, libfaac-devel, libfaad-devel, libgsm-devel, +yasm, libSDL-devel, libdirac-devel, libfaac-devel, libgsm-devel, libmp3lame-devel, libschroedinger1.0-devel, speex-devel, libtheora-devel, libxvidcore-devel @end example diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/libavfilter.texi b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/libavfilter.texi index 1de27d917..8745928d4 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/libavfilter.texi +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/libavfilter.texi @@ -99,244 +99,6 @@ display graph.png can be used to create and display an image representing the graph described by the @var{GRAPH_DESCRIPTION} string. -@chapter Available video filters - -When you configure your FFmpeg build, you can disable any of the -existing video filters. -The configure output will show the video filters included in your -build. - -Below is a description of the currently available video filters. - -@section crop - -Crop the input video to @var{x}:@var{y}:@var{width}:@var{height}. - -@example -./ffmpeg -i in.avi -vf "crop=0:0:0:240" out.avi -@end example - -@var{x} and @var{y} specify the position of the top-left corner of the -output (non-cropped) area. - -The default value of @var{x} and @var{y} is 0. - -The @var{width} and @var{height} parameters specify the width and height -of the output (non-cropped) area. - -A value of 0 is interpreted as the maximum possible size contained in -the area delimited by the top-left corner at position x:y. - -For example the parameters: - -@example -"crop=100:100:0:0" -@end example - -will delimit the rectangle with the top-left corner placed at position -100:100 and the right-bottom corner corresponding to the right-bottom -corner of the input image. - -The default value of @var{width} and @var{height} is 0. - -@section format - -Convert the input video to one of the specified pixel formats. -Libavfilter will try to pick one that is supported for the input to -the next filter. - -The filter accepts a list of pixel format names, separated by ``:'', -for example ``yuv420p:monow:rgb24''. - -The following command: - -@example -./ffmpeg -i in.avi -vf "format=yuv420p" out.avi -@end example - -will convert the input video to the format ``yuv420p''. - -@section noformat - -Force libavfilter not to use any of the specified pixel formats for the -input to the next filter. - -The filter accepts a list of pixel format names, separated by ``:'', -for example ``yuv420p:monow:rgb24''. - -The following command: - -@example -./ffmpeg -i in.avi -vf "noformat=yuv420p, vflip" out.avi -@end example - -will make libavfilter use a format different from ``yuv420p'' for the -input to the vflip filter. - -@section null - -Pass the source unchanged to the output. - -@section pad - -Add paddings to the input image, and places the original input at the -given coordinates @var{x}, @var{y}. - -It accepts the following parameters: -@var{width}:@var{height}:@var{x}:@var{y}:@var{color}. - -Follows the description of the accepted parameters. - -@table @option -@item width, height - -Specify the size of the output image with the paddings added. If the -value for @var{width} or @var{height} is 0, the corresponding input size -is used for the output. - -The default value of @var{width} and @var{height} is 0. - -@item x, y - -Specify the offsets where to place the input image in the padded area -with respect to the top/left border of the output image. - -The default value of @var{x} and @var{y} is 0. - -@item color - -Specify the color of the padded area, it can be the name of a color -(case insensitive match) or a 0xRRGGBB[AA] sequence. - -The default value of @var{color} is ``black''. - -@end table - -@section scale - -Scale the input video to @var{width}:@var{height} and/or convert the image format. - -For example the command: - -@example -./ffmpeg -i in.avi -vf "scale=200:100" out.avi -@end example - -will scale the input video to a size of 200x100. - -If the input image format is different from the format requested by -the next filter, the scale filter will convert the input to the -requested format. - -If the value for @var{width} or @var{height} is 0, the respective input -size is used for the output. - -If the value for @var{width} or @var{height} is -1, the scale filter will -use, for the respective output size, a value that maintains the aspect -ratio of the input image. - -The default value of @var{width} and @var{height} is 0. - -@section slicify - -Pass the images of input video on to next video filter as multiple -slices. - -@example -./ffmpeg -i in.avi -vf "slicify=32" out.avi -@end example - -The filter accepts the slice height as parameter. If the parameter is -not specified it will use the default value of 16. - -Adding this in the beginning of filter chains should make filtering -faster due to better use of the memory cache. - -@section unsharp - -Sharpen or blur the input video. It accepts the following parameters: - -@multitable @columnfractions .2 .5 .1 .1 .1 -@headitem Name @tab Description @tab Min @tab Max @tab Default -@item @var{luma_msize_x} -@tab Luma matrix horizontal size -@tab 3 -@tab 13 -@tab 5 -@item @var{luma_msize_y} -@tab Luma matrix vertical size -@tab 3 -@tab 13 -@tab 5 -@item @var{luma_amount} -@tab Luma effect strength -@tab -2.0 -@tab 5.0 -@tab 1.0 -@item @var{chroma_msize_x} -@tab Chroma matrix horizontal size -@tab 3 -@tab 13 -@tab 0 -@item @var{chroma_msize_y} -@tab Chroma matrix vertical size -@tab 3 -@tab 13 -@tab 0 -@item @var{chroma_amount} -@tab Chroma effect strength -@tab -2.0 -@tab 5.0 -@tab 0.0 -@end multitable - -Negative values for the amount will blur the input video, while positive -values will sharpen. All parameters are optional and default to the -equivalent of the string '5:5:1.0:0:0:0.0'. - -@example -# Strong luma sharpen effect parameters -unsharp=7:7:2.5 - -# Strong blur of both luma and chroma parameters -unsharp=7:7:-2:7:7:-2 - -# Use the default values with @command{ffmpeg} -./ffmpeg -i in.avi -vf "unsharp" out.mp4 -@end example - -@section vflip - -Flip the input video vertically. - -@example -./ffmpeg -i in.avi -vf "vflip" out.avi -@end example - -@chapter Available video sources - -Below is a description of the currently available video sources. - -@section nullsrc - -Null video source, never return images. It is mainly useful as a -template and to be employed in analysis / debugging tools. - -It accepts as optional parameter a string of the form -@var{width}:@var{height}, where @var{width} and @var{height} specify the size of -the configured source. - -The default values of @var{width} and @var{height} are respectively 352 -and 288 (corresponding to the CIF size format). - -@chapter Available video sinks - -Below is a description of the currently available video sinks. - -@section nullsink - -Null video sink, do absolutely nothing with the input video. It is -mainly useful as a template and to be employed in analysis / debugging -tools. +@include filters.texi @bye diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/tablegen.txt b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/tablegen.txt index 8dfcd7d35..4c4f036e6 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/tablegen.txt +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/tablegen.txt @@ -12,6 +12,7 @@ the tables as a header file using the tableprint.h helpers. Both of these files will be compiled for the host system, so to avoid breakage with cross-compilation neither of them may include, directly or indirectly, config.h or avconfig.h. +This means that e.g. libavutil/mathematics.h is ok but libavutil/libm.h is not. Due to this, the .c file or Makefile may have to provide additional defines or stubs, though if possible this should be avoided. In particular, CONFIG_HARDCODED_TABLES should always be defined to 0. @@ -27,9 +28,14 @@ them. The printing code typically looks like this: write_fileheader(); printf("static const uint8_t my_array[100] = {\n"); - write_uint8_array(my_array, 100); + write_uint8_t_array(my_array, 100); printf("};\n"); +This is the more generic form, in case you need to do something special. +Usually you should instead use the short form: + write_fileheader(); + WRITE_ARRAY("static const", uint8_t, my_array); + write_fileheader() adds some minor things like a "this is a generated file" comment and some standard includes. tablegen.h defines some write functions for one- and two-dimensional arrays diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/texi2pod.pl b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/texi2pod.pl index e0bc615c8..fd3f02059 100755 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/texi2pod.pl +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/doc/texi2pod.pl @@ -26,6 +26,7 @@ $output = 0; $skipping = 0; %sects = (); +@sects_sequence = (); $section = ""; @icstack = (); @endwstack = (); @@ -99,15 +100,21 @@ next; }; + /^\@include\s+(.+)$/ and do { + push @instack, $inf; + $inf = gensym(); + + # Try cwd and $ibase. + open($inf, "<" . $1) + or open($inf, "<" . $ibase . "/" . $1) + or die "cannot open $1 or $ibase/$1: $!\n"; + next; + }; + # Look for blocks surrounded by @c man begin SECTION ... @c man end. # This really oughta be @ifman ... @end ifman and the like, but such # would require rev'ing all other Texinfo translators. - /^\@c\s+man\s+begin\s+([A-Z]+)\s+([A-Za-z0-9-]+)/ and do { - $output = 1 if exists $defs{$2}; - $sect = $1; - next; - }; - /^\@c\s+man\s+begin\s+([A-Z]+)/ and $sect = $1, $output = 1, next; + /^\@c\s+man\s+begin\s+([A-Za-z ]+)/ and $sect = $1, push (@sects_sequence, $sect), $output = 1, next; /^\@c\s+man\s+end/ and do { $sects{$sect} = "" unless exists $sects{$sect}; $sects{$sect} .= postprocess($section); @@ -224,17 +231,6 @@ # Single line command handlers. - /^\@include\s+(.+)$/ and do { - push @instack, $inf; - $inf = gensym(); - - # Try cwd and $ibase. - open($inf, "<" . $1) - or open($inf, "<" . $ibase . "/" . $1) - or die "cannot open $1 or $ibase/$1: $!\n"; - next; - }; - /^\@(?:section|unnumbered|unnumberedsec|center)\s+(.+)$/ and $_ = "\n=head2 $1\n"; /^\@subsection\s+(.+)$/ @@ -303,8 +299,8 @@ $sects{NAME} = "$fn \- $tl\n"; $sects{FOOTNOTES} .= "=back\n" if exists $sects{FOOTNOTES}; -for $sect (qw(NAME SYNOPSIS DESCRIPTION OPTIONS EXAMPLES ENVIRONMENT FILES - BUGS NOTES FOOTNOTES SEEALSO AUTHORS COPYRIGHT)) { +unshift @sects_sequence, "NAME"; +for $sect (@sects_sequence) { if(exists $sects{$sect}) { $head = $sect; $head =~ s/SEEALSO/SEE ALSO/; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffmpeg.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffmpeg.c index b0722a414..d5fd6a04b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffmpeg.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffmpeg.c @@ -36,7 +36,7 @@ #include "libswscale/swscale.h" #include "libavcodec/opt.h" #include "libavcodec/audioconvert.h" -#include "libavcodec/colorspace.h" +#include "libavutil/colorspace.h" #include "libavutil/fifo.h" #include "libavutil/pixdesc.h" #include "libavutil/avstring.h" @@ -121,6 +121,9 @@ static int nb_stream_maps; static AVMetaDataMap meta_data_maps[MAX_FILES]; static int nb_meta_data_maps; +/* indexed by output file stream index */ +static int streamid_map[MAX_STREAMS]; + static int frame_width = 0; static int frame_height = 0; static float frame_aspect_ratio = 0; @@ -175,7 +178,7 @@ static float mux_max_delay= 0.7; static int64_t recording_time = INT64_MAX; static int64_t start_time = 0; -static int64_t rec_timestamp = 0; +static int64_t recording_timestamp = 0; static int64_t input_ts_offset = 0; static int file_overwrite = 0; static int metadata_count; @@ -457,6 +460,9 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost) avfilter_graph_add_filter(graph, last_filter); } + snprintf(args, sizeof(args), "flags=0x%X", (int)av_get_int(sws_opts, "sws_flags", NULL)); + graph->scale_sws_opts = av_strdup(args); + if (vfilters) { AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut)); AVFilterInOut *inputs = av_malloc(sizeof(AVFilterInOut)); @@ -479,9 +485,6 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost) return -1; } - snprintf(args, sizeof(args), "flags=0x%X", (int)av_get_int(sws_opts, "sws_flags", NULL)); - graph->scale_sws_opts = av_strdup(args); - /* configure all the filter links */ if (avfilter_graph_check_validity(graph, NULL)) return -1; @@ -540,10 +543,6 @@ static void term_init(void) #ifdef SIGXCPU signal(SIGXCPU, sigterm_handler); #endif - -#if CONFIG_BEOS_NETSERVER - fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK); -#endif } /* read a key without blocking */ @@ -552,7 +551,6 @@ static int read_key(void) #if HAVE_TERMIOS_H int n = 1; unsigned char ch; -#if !CONFIG_BEOS_NETSERVER struct timeval tv; fd_set rfds; @@ -561,7 +559,6 @@ static int read_key(void) tv.tv_sec = 0; tv.tv_usec = 0; n = select(1, &rfds, NULL, NULL, &tv); -#endif if (n > 0) { n = read(0, &ch, 1); if (n == 1) @@ -624,11 +621,6 @@ static int av_exit(int ret) av_free(video_standard); -#if CONFIG_POWERPC_PERF - void powerpc_display_perf_report(void); - powerpc_display_perf_report(); -#endif /* CONFIG_POWERPC_PERF */ - for (i=0;isupported_samplerates){ const int *p= codec->supported_samplerates; - int best; + int best=0; int best_dist=INT_MAX; for(; *p; p++){ int dist= abs(st->codec->sample_rate - *p); @@ -696,7 +688,7 @@ static void choose_pixel_fmt(AVStream *st, AVCodec *codec) } if(*p == -1 && !( st->codec->codec_id==CODEC_ID_MJPEG - && st->codec->strict_std_compliance <= FF_COMPLIANCE_INOFFICIAL + && st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL && ( st->codec->pix_fmt == PIX_FMT_YUV420P || st->codec->pix_fmt == PIX_FMT_YUV422P))) st->codec->pix_fmt = codec->pix_fmts[0]; @@ -819,6 +811,7 @@ static void do_audio_out(AVFormatContext *s, audio_buf_size= (allocated_for_size + isize*dec->channels - 1) / (isize*dec->channels); audio_buf_size= (audio_buf_size*enc->sample_rate + dec->sample_rate) / dec->sample_rate; audio_buf_size= audio_buf_size*2 + 10000; //safety factors for the deprecated resampling API + audio_buf_size= FFMAX(audio_buf_size, enc->frame_size); audio_buf_size*= osize*enc->channels; audio_out_size= FFMAX(audio_buf_size, enc->frame_size * osize * enc->channels); @@ -1519,7 +1512,6 @@ static int output_packet(AVInputStream *ist, int ist_index, void *buffer_to_free; static unsigned int samples_size= 0; AVSubtitle subtitle, *subtitle_to_free; - int got_subtitle; #if CONFIG_AVFILTER int frame_available; #endif @@ -1614,10 +1606,10 @@ static int output_packet(AVInputStream *ist, int ist_index, break; case AVMEDIA_TYPE_SUBTITLE: ret = avcodec_decode_subtitle2(ist->st->codec, - &subtitle, &got_subtitle, &avpkt); + &subtitle, &got_picture, &avpkt); if (ret < 0) goto fail_decode; - if (!got_subtitle) { + if (!got_picture) { goto discard_packet; } subtitle_to_free = &subtitle; @@ -1781,13 +1773,11 @@ static int output_packet(AVInputStream *ist, int ist_index, av_free_packet(&opkt); } } -#if CONFIG_AVFILTER - frame_available = (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) && - ist->out_video_filter && avfilter_poll_frame(ist->out_video_filter->inputs[0]); -#endif } #if CONFIG_AVFILTER + frame_available = (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) && + ist->out_video_filter && avfilter_poll_frame(ist->out_video_filter->inputs[0]); if(ist->picref) avfilter_unref_pic(ist->picref); } @@ -1838,17 +1828,17 @@ static int output_packet(AVInputStream *ist, int ist_index, int osize = av_get_bits_per_sample_format(enc->sample_fmt) >> 3; int fs_tmp = enc->frame_size; - av_fifo_generic_read(ost->fifo, samples, fifo_bytes, NULL); + av_fifo_generic_read(ost->fifo, audio_buf, fifo_bytes, NULL); if (enc->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) { enc->frame_size = fifo_bytes / (osize * enc->channels); } else { /* pad */ int frame_bytes = enc->frame_size*osize*enc->channels; - if (samples_size < frame_bytes) + if (allocated_audio_buf_size < frame_bytes) av_exit(1); - memset((uint8_t*)samples+fifo_bytes, 0, frame_bytes - fifo_bytes); + memset(audio_buf+fifo_bytes, 0, frame_bytes - fifo_bytes); } - ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, samples); + ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, (short *)audio_buf); pkt.duration = av_rescale((int64_t)enc->frame_size*ost->st->time_base.den, ost->st->time_base.num, enc->sample_rate); enc->frame_size = fs_tmp; @@ -2156,6 +2146,11 @@ static int av_transcode(AVFormatContext **output_files, codec->chroma_sample_location = icodec->chroma_sample_location; if (ost->st->stream_copy) { + uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; + + if (extra_size > INT_MAX) + goto fail; + /* if stream_copy is selected, no need to decode or encode */ codec->codec_id = icodec->codec_id; codec->codec_type = icodec->codec_type; @@ -2168,11 +2163,16 @@ static int av_transcode(AVFormatContext **output_files, } codec->bit_rate = icodec->bit_rate; - codec->extradata= icodec->extradata; + codec->extradata= av_mallocz(extra_size); + if (!codec->extradata) + goto fail; + memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); codec->extradata_size= icodec->extradata_size; if(av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/1000){ codec->time_base = icodec->time_base; codec->time_base.num *= icodec->ticks_per_frame; + av_reduce(&codec->time_base.num, &codec->time_base.den, + codec->time_base.num, codec->time_base.den, INT_MAX); }else codec->time_base = ist->st->time_base; switch(codec->codec_type) { @@ -2682,6 +2682,8 @@ static int av_transcode(AVFormatContext **output_files, for(i=0;ist->stream_copy) + av_freep(&ost->st->codec->extradata); if (ost->logfile) { fclose(ost->logfile); ost->logfile = NULL; @@ -2765,6 +2767,7 @@ static void opt_frame_crop_top(const char *arg) fprintf(stderr, "Vertical crop dimensions are outside the range of the original image.\nRemember to crop first and scale second.\n"); av_exit(1); } + fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n"); frame_height -= frame_topBand; } @@ -2779,6 +2782,7 @@ static void opt_frame_crop_bottom(const char *arg) fprintf(stderr, "Vertical crop dimensions are outside the range of the original image.\nRemember to crop first and scale second.\n"); av_exit(1); } + fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n"); frame_height -= frame_bottomBand; } @@ -2793,6 +2797,7 @@ static void opt_frame_crop_left(const char *arg) fprintf(stderr, "Horizontal crop dimensions are outside the range of the original image.\nRemember to crop first and scale second.\n"); av_exit(1); } + fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n"); frame_width -= frame_leftBand; } @@ -2807,6 +2812,7 @@ static void opt_frame_crop_right(const char *arg) fprintf(stderr, "Horizontal crop dimensions are outside the range of the original image.\nRemember to crop first and scale second.\n"); av_exit(1); } + fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n"); frame_width -= frame_rightBand; } @@ -2818,9 +2824,9 @@ static void opt_frame_size(const char *arg) } } -static void opt_pad(const char *arg) { - fprintf(stderr, "Please use vf=pad\n"); - av_exit(1); +static int opt_pad(const char *opt, const char *arg) { + fprintf(stderr, "Option '%s' has been removed, use the pad filter instead\n", opt); + return -1; } static void opt_frame_pix_fmt(const char *arg) @@ -3056,9 +3062,9 @@ static int opt_start_time(const char *opt, const char *arg) return 0; } -static int opt_rec_timestamp(const char *opt, const char *arg) +static int opt_recording_timestamp(const char *opt, const char *arg) { - rec_timestamp = parse_time_or_die(opt, arg, 0) / 1000000; + recording_timestamp = parse_time_or_die(opt, arg, 0) / 1000000; return 0; } @@ -3345,7 +3351,7 @@ static void new_video_stream(AVFormatContext *oc) AVCodecContext *video_enc; enum CodecID codec_id; - st = av_new_stream(oc, oc->nb_streams); + st = av_new_stream(oc, streamid_map[oc->nb_streams]); if (!st) { fprintf(stderr, "Could not alloc stream\n"); av_exit(1); @@ -3483,7 +3489,7 @@ static void new_audio_stream(AVFormatContext *oc) AVCodecContext *audio_enc; enum CodecID codec_id; - st = av_new_stream(oc, oc->nb_streams); + st = av_new_stream(oc, streamid_map[oc->nb_streams]); if (!st) { fprintf(stderr, "Could not alloc stream\n"); av_exit(1); @@ -3556,7 +3562,7 @@ static void new_subtitle_stream(AVFormatContext *oc) AVStream *st; AVCodecContext *subtitle_enc; - st = av_new_stream(oc, oc->nb_streams); + st = av_new_stream(oc, streamid_map[oc->nb_streams]); if (!st) { fprintf(stderr, "Could not alloc stream\n"); av_exit(1); @@ -3625,6 +3631,27 @@ static void opt_new_subtitle_stream(void) new_subtitle_stream(oc); } +/* arg format is "output-stream-index:streamid-value". */ +static void opt_streamid(const char *opt, const char *arg) +{ + int idx; + char *p; + char idx_str[16]; + + strncpy(idx_str, arg, sizeof(idx_str)); + idx_str[sizeof(idx_str)-1] = '\0'; + p = strchr(idx_str, ':'); + if (!p) { + fprintf(stderr, + "Invalid value '%s' for option '%s', required syntax is 'index:value'\n", + arg, opt); + av_exit(1); + } + *p++ = '\0'; + idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1); + streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX); +} + static void opt_output_file(const char *filename) { AVFormatContext *oc; @@ -3711,7 +3738,7 @@ static void opt_output_file(const char *filename) new_subtitle_stream(oc); } - oc->timestamp = rec_timestamp; + oc->timestamp = recording_timestamp; for(; metadata_count>0; metadata_count--){ av_metadata_set2(&oc->metadata, metadata[metadata_count-1].key, @@ -3772,6 +3799,8 @@ static void opt_output_file(const char *filename) oc->flags |= AVFMT_FLAG_NONBLOCK; set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM); + + memset(streamid_map, 0, sizeof(streamid_map)); } /* same option as mencoder */ @@ -4158,7 +4187,7 @@ static const OptionDef options[] = { { "ss", OPT_FUNC2 | HAS_ARG, {(void*)opt_start_time}, "set the start time offset", "time_off" }, { "itsoffset", OPT_FUNC2 | HAS_ARG, {(void*)opt_input_ts_offset}, "set the input ts offset", "time_off" }, { "itsscale", HAS_ARG, {(void*)opt_input_ts_scale}, "set the input ts scale", "stream:scale" }, - { "timestamp", OPT_FUNC2 | HAS_ARG, {(void*)opt_rec_timestamp}, "set the timestamp ('now' to set the current time)", "time" }, + { "timestamp", OPT_FUNC2 | HAS_ARG, {(void*)opt_recording_timestamp}, "set the recording timestamp ('now' to set the current time)", "time" }, { "metadata", OPT_FUNC2 | HAS_ARG, {(void*)opt_metadata}, "add metadata", "string=string" }, { "dframes", OPT_INT | HAS_ARG, {(void*)&max_frames[AVMEDIA_TYPE_DATA]}, "set the number of data frames to record", "number" }, { "benchmark", OPT_BOOL | OPT_EXPERT, {(void*)&do_benchmark}, @@ -4193,15 +4222,15 @@ static const OptionDef options[] = { { "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" }, { "aspect", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_aspect_ratio}, "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" }, { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_frame_pix_fmt}, "set pixel format, 'list' as argument shows all the pixel formats supported", "format" }, - { "croptop", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_top}, "set top crop band size (in pixels)", "size" }, - { "cropbottom", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_bottom}, "set bottom crop band size (in pixels)", "size" }, - { "cropleft", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_left}, "set left crop band size (in pixels)", "size" }, - { "cropright", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_right}, "set right crop band size (in pixels)", "size" }, - { "padtop", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "set top pad band size (in pixels)", "size" }, - { "padbottom", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "set bottom pad band size (in pixels)", "size" }, - { "padleft", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "set left pad band size (in pixels)", "size" }, - { "padright", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "set right pad band size (in pixels)", "size" }, - { "padcolor", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "set color of pad bands (Hex 000000 thru FFFFFF)", "color" }, + { "croptop", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_top}, "Deprecated, please use the crop avfilter", "size" }, + { "cropbottom", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_bottom}, "Deprecated, please use the crop avfilter", "size" }, + { "cropleft", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_left}, "Deprecated, please use the crop avfilter", "size" }, + { "cropright", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_right}, "Deprecated, please use the crop avfilter", "size" }, + { "padtop", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" }, + { "padbottom", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" }, + { "padleft", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" }, + { "padright", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" }, + { "padcolor", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "color" }, { "intra", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_only}, "use only intra frames"}, { "vn", OPT_BOOL | OPT_VIDEO, {(void*)&video_disable}, "disable video" }, { "vdt", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_discard}, "discard threshold", "n" }, @@ -4230,6 +4259,7 @@ static const OptionDef options[] = { { "vlang", HAS_ARG | OPT_STRING | OPT_VIDEO, {(void *)&video_language}, "set the ISO 639 language code (3 letters) of the current video stream" , "code" }, { "qphist", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, { (void *)&qp_hist }, "show QP histogram" }, { "force_fps", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&force_fps}, "force the selected framerate, disable the best supported framerate selection" }, + { "streamid", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_streamid}, "set the value of an outfile streamid", "streamIndex:value" }, /* audio options */ { "ab", OPT_FUNC2 | HAS_ARG | OPT_AUDIO, {(void*)opt_bitrate}, "set bitrate (in bits/s)", "bitrate" }, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffplay.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffplay.c index 129cd2887..4f254dfc8 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffplay.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffplay.c @@ -24,12 +24,12 @@ #include #include #include "libavutil/avstring.h" +#include "libavutil/colorspace.h" #include "libavutil/pixdesc.h" #include "libavformat/avformat.h" #include "libavdevice/avdevice.h" #include "libswscale/swscale.h" #include "libavcodec/audioconvert.h" -#include "libavcodec/colorspace.h" #include "libavcodec/opt.h" #include "libavcodec/avfft.h" @@ -168,6 +168,7 @@ typedef struct VideoState { int last_i_start; RDFTContext *rdft; int rdft_bits; + FFTSample *rdft_data; int xpos; SDL_Thread *subtitle_tid; @@ -259,6 +260,8 @@ static int error_recognition = FF_ER_CAREFUL; static int error_concealment = 3; static int decoder_reorder_pts= -1; static int autoexit; +static int exit_on_keydown; +static int exit_on_mousedown; static int loop=1; static int framedrop=1; @@ -674,18 +677,7 @@ static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw, static void free_subpicture(SubPicture *sp) { - int i; - - for (i = 0; i < sp->sub.num_rects; i++) - { - av_freep(&sp->sub.rects[i]->pict.data[0]); - av_freep(&sp->sub.rects[i]->pict.data[1]); - av_freep(&sp->sub.rects[i]); - } - - av_free(sp->sub.rects); - - memset(&sp->sub, 0, sizeof(AVSubtitle)); + avsubtitle_free(&sp->sub); } static void video_image_display(VideoState *is) @@ -917,12 +909,15 @@ static void video_audio_display(VideoState *s) nb_display_channels= FFMIN(nb_display_channels, 2); if(rdft_bits != s->rdft_bits){ av_rdft_end(s->rdft); + av_free(s->rdft_data); s->rdft = av_rdft_init(rdft_bits, DFT_R2C); s->rdft_bits= rdft_bits; + s->rdft_data= av_malloc(4*nb_freq*sizeof(*s->rdft_data)); } { - FFTSample data[2][2*nb_freq]; + FFTSample *data[2]; for(ch = 0;ch < nb_display_channels; ch++) { + data[ch] = s->rdft_data + 2*nb_freq*ch; i = i_start + ch; for(x = 0; x < 2*nb_freq; x++) { double w= (x-nb_freq)*(1.0/nb_freq); @@ -937,7 +932,8 @@ static void video_audio_display(VideoState *s) for(y=0; yheight; y++){ double w= 1/sqrt(nb_freq); int a= sqrt(w*sqrt(data[0][2*y+0]*data[0][2*y+0] + data[0][2*y+1]*data[0][2*y+1])); - int b= sqrt(w*sqrt(data[1][2*y+0]*data[1][2*y+0] + data[1][2*y+1]*data[1][2*y+1])); + int b= (nb_display_channels == 2 ) ? sqrt(w*sqrt(data[1][2*y+0]*data[1][2*y+0] + + data[1][2*y+1]*data[1][2*y+1])) : a; a= FFMIN(a,255); b= FFMIN(b,255); fgcolor = SDL_MapRGB(screen->format, a, b, (a+b)/2); @@ -1587,9 +1583,9 @@ static int input_get_buffer(AVCodecContext *codec, AVFrame *pic) ref->w = codec->width; ref->h = codec->height; - for(i = 0; i < 3; i ++) { - unsigned hshift = i == 0 ? 0 : av_pix_fmt_descriptors[ref->pic->format].log2_chroma_w; - unsigned vshift = i == 0 ? 0 : av_pix_fmt_descriptors[ref->pic->format].log2_chroma_h; + for(i = 0; i < 4; i ++) { + unsigned hshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->pic->format].log2_chroma_w : 0; + unsigned vshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->pic->format].log2_chroma_h : 0; if (ref->data[i]) { ref->data[i] += (edge >> hshift) + ((edge * ref->linesize[i]) >> vshift); @@ -2815,6 +2811,10 @@ static void event_loop(void) SDL_WaitEvent(&event); switch(event.type) { case SDL_KEYDOWN: + if (exit_on_keydown) { + do_exit(); + break; + } switch(event.key.keysym.sym) { case SDLK_ESCAPE: case SDLK_q: @@ -2883,6 +2883,10 @@ static void event_loop(void) } break; case SDL_MOUSEBUTTONDOWN: + if (exit_on_mousedown) { + do_exit(); + break; + } case SDL_MOUSEMOTION: if(event.type ==SDL_MOUSEBUTTONDOWN){ x= event.button.x; @@ -3064,6 +3068,8 @@ static const OptionDef options[] = { { "sync", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_sync}, "set audio-video sync. type (type=audio/video/ext)", "type" }, { "threads", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" }, { "autoexit", OPT_BOOL | OPT_EXPERT, {(void*)&autoexit}, "exit at the end", "" }, + { "exitonkeydown", OPT_BOOL | OPT_EXPERT, {(void*)&exit_on_keydown}, "exit on key down", "" }, + { "exitonmousedown", OPT_BOOL | OPT_EXPERT, {(void*)&exit_on_mousedown}, "exit on mouse down", "" }, { "loop", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&loop}, "set number of times the playback shall be looped", "loop count" }, { "framedrop", OPT_BOOL | OPT_EXPERT, {(void*)&framedrop}, "drop frames when cpu is too slow", "" }, { "window_title", OPT_STRING | HAS_ARG, {(void*)&window_title}, "set window title", "window title" }, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-superfast.ffpreset b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-superfast.ffpreset index e2cb95931..bcd459930 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-superfast.ffpreset +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-superfast.ffpreset @@ -20,3 +20,4 @@ directpred=1 trellis=0 flags2=+bpyramid-mixed_refs+wpred+dct8x8+fastpskip-mbtree wpredp=0 +rc_lookahead=0 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-superfast_firstpass.ffpreset b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-superfast_firstpass.ffpreset index 5f44bea24..ef06b1d56 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-superfast_firstpass.ffpreset +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-superfast_firstpass.ffpreset @@ -20,3 +20,4 @@ directpred=1 trellis=0 flags2=+bpyramid-mixed_refs+wpred-dct8x8+fastpskip-mbtree wpredp=0 +rc_lookahead=0 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-ultrafast.ffpreset b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-ultrafast.ffpreset index 70acb009a..b6d208080 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-ultrafast.ffpreset +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-ultrafast.ffpreset @@ -21,3 +21,4 @@ trellis=0 flags2=-bpyramid-mixed_refs-wpred-dct8x8+fastpskip-mbtree wpredp=0 aq_mode=0 +rc_lookahead=0 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-ultrafast_firstpass.ffpreset b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-ultrafast_firstpass.ffpreset index 70acb009a..b6d208080 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-ultrafast_firstpass.ffpreset +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-ultrafast_firstpass.ffpreset @@ -21,3 +21,4 @@ trellis=0 flags2=-bpyramid-mixed_refs-wpred-dct8x8+fastpskip-mbtree wpredp=0 aq_mode=0 +rc_lookahead=0 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-veryfast.ffpreset b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-veryfast.ffpreset index a29b1154f..16ca594ab 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-veryfast.ffpreset +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-veryfast.ffpreset @@ -18,5 +18,6 @@ bf=3 refs=1 directpred=1 trellis=0 -flags2=+bpyramid-mixed_refs+wpred+dct8x8+fastpskip-mbtree +flags2=+bpyramid-mixed_refs+wpred+dct8x8+fastpskip wpredp=0 +rc_lookahead=10 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-veryfast_firstpass.ffpreset b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-veryfast_firstpass.ffpreset index bab5d9bfe..39eaf3e24 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-veryfast_firstpass.ffpreset +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffpresets/libx264-veryfast_firstpass.ffpreset @@ -18,5 +18,6 @@ bf=3 refs=1 directpred=1 trellis=0 -flags2=+bpyramid-mixed_refs+wpred-dct8x8+fastpskip-mbtree +flags2=+bpyramid-mixed_refs+wpred-dct8x8+fastpskip wpredp=0 +rc_lookahead=10 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffserver.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffserver.c index 6d1e710c6..8f073fe36 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffserver.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/ffserver.c @@ -740,7 +740,7 @@ static void http_send_too_busy_reply(int fd) { char buffer[300]; int len = snprintf(buffer, sizeof(buffer), - "HTTP/1.0 200 Server too busy\r\n" + "HTTP/1.0 503 Server too busy\r\n" "Content-type: text/html\r\n" "\r\n" "Too busy\r\n" @@ -1589,10 +1589,10 @@ static int http_parse_request(HTTPContext *c) } if (c->post == 0 && max_bandwidth < current_bandwidth) { - c->http_error = 200; + c->http_error = 503; q = c->buffer; q += snprintf(q, c->buffer_size, - "HTTP/1.0 200 Server too busy\r\n" + "HTTP/1.0 503 Server too busy\r\n" "Content-type: text/html\r\n" "\r\n" "Too busy\r\n" @@ -2306,12 +2306,16 @@ static int http_prepare_data(HTTPContext *c) else { AVPacket pkt; redo: - if (av_read_frame(c->fmt_in, &pkt) < 0) { - if (c->stream->feed && c->stream->feed->feed_opened) { + ret = av_read_frame(c->fmt_in, &pkt); + if (ret < 0) { + if (c->stream->feed) { /* if coming from feed, it means we reached the end of the ffm file, so must wait for more data */ c->state = HTTPSTATE_WAIT_FEED; return 1; /* state changed */ + } else if (ret == AVERROR(EAGAIN)) { + /* input not ready, come back later */ + return 0; } else { if (c->stream->loop) { av_close_input_file(c->fmt_in); @@ -2744,14 +2748,7 @@ static int http_receive_data(HTTPContext *c) for (i = 0; i < s->nb_streams; i++) { AVStream *fst = feed->streams[i]; AVStream *st = s->streams[i]; - memcpy(fst->codec, st->codec, sizeof(AVCodecContext)); - if (fst->codec->extradata_size) { - fst->codec->extradata = av_malloc(fst->codec->extradata_size); - if (!fst->codec->extradata) - goto fail; - memcpy(fst->codec->extradata, st->codec->extradata, - fst->codec->extradata_size); - } + avcodec_copy_context(fst->codec, st->codec); } av_close_input_stream(s); @@ -2981,7 +2978,7 @@ static void rtsp_cmd_describe(HTTPContext *c, const char *url) struct sockaddr_in my_addr; /* find which url is asked */ - ff_url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url); + av_url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url); path = path1; if (*path == '/') path++; @@ -3058,7 +3055,7 @@ static void rtsp_cmd_setup(HTTPContext *c, const char *url, RTSPActionServerSetup setup; /* find which url is asked */ - ff_url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url); + av_url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url); path = path1; if (*path == '/') path++; @@ -3201,7 +3198,7 @@ static HTTPContext *find_rtp_session_with_url(const char *url, return NULL; /* find which url is asked */ - ff_url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url); + av_url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url); path = path1; if (*path == '/') path++; @@ -3949,6 +3946,65 @@ static int ffserver_opt_default(const char *opt, const char *arg, return ret; } +static int ffserver_opt_preset(const char *arg, + AVCodecContext *avctx, int type, + enum CodecID *audio_id, enum CodecID *video_id) +{ + FILE *f=NULL; + char filename[1000], tmp[1000], tmp2[1000], line[1000]; + int i, ret = 0; + const char *base[3]= { getenv("FFMPEG_DATADIR"), + getenv("HOME"), + FFMPEG_DATADIR, + }; + + for(i=0; i<3 && !f; i++){ + if(!base[i]) + continue; + snprintf(filename, sizeof(filename), "%s%s/%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", arg); + f= fopen(filename, "r"); + if(!f){ + AVCodec *codec = avcodec_find_encoder(avctx->codec_id); + if (codec) { + snprintf(filename, sizeof(filename), "%s%s/%s-%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", codec->name, arg); + f= fopen(filename, "r"); + } + } + } + + if(!f){ + fprintf(stderr, "File for preset '%s' not found\n", arg); + return 1; + } + + while(!feof(f)){ + int e= fscanf(f, "%999[^\n]\n", line) - 1; + if(line[0] == '#' && !e) + continue; + e|= sscanf(line, "%999[^=]=%999[^\n]\n", tmp, tmp2) - 2; + if(e){ + fprintf(stderr, "%s: Invalid syntax: '%s'\n", filename, line); + ret = 1; + break; + } + if(!strcmp(tmp, "acodec")){ + *audio_id = opt_audio_codec(tmp2); + }else if(!strcmp(tmp, "vcodec")){ + *video_id = opt_video_codec(tmp2); + }else if(!strcmp(tmp, "scodec")){ + /* opt_subtitle_codec(tmp2); */ + }else if(ffserver_opt_default(tmp, tmp2, avctx, type) < 0){ + fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", filename, line, tmp, tmp2); + ret = 1; + break; + } + } + + fclose(f); + + return ret; +} + static AVOutputFormat *ffserver_guess_format(const char *short_name, const char *filename, const char *mime_type) { @@ -4403,6 +4459,23 @@ static int parse_ffconfig(const char *filename) if (ffserver_opt_default(arg, arg2, avctx, type|AV_OPT_FLAG_ENCODING_PARAM)) { ERROR("AVOption error: %s %s\n", arg, arg2); } + } else if (!strcasecmp(cmd, "AVPresetVideo") || + !strcasecmp(cmd, "AVPresetAudio")) { + AVCodecContext *avctx; + int type; + get_arg(arg, sizeof(arg), &p); + if (!strcasecmp(cmd, "AVPresetVideo")) { + avctx = &video_enc; + video_enc.codec_id = video_id; + type = AV_OPT_FLAG_VIDEO_PARAM; + } else { + avctx = &audio_enc; + audio_enc.codec_id = audio_id; + type = AV_OPT_FLAG_AUDIO_PARAM; + } + if (ffserver_opt_preset(arg, avctx, type|AV_OPT_FLAG_ENCODING_PARAM, &audio_id, &video_id)) { + ERROR("AVPreset error: %s\n", arg); + } } else if (!strcasecmp(cmd, "VideoTag")) { get_arg(arg, sizeof(arg), &p); if ((strlen(arg) == 4) && stream) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/include/dxva2/dxva2api.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/include/dxva2/dxva2api.h deleted file mode 100644 index 1b83e8fd1..000000000 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/include/dxva2/dxva2api.h +++ /dev/null @@ -1,501 +0,0 @@ -/***************************************************************************** - * dxva2api.h: DXVA 2 interface - ***************************************************************************** - * Copyright (C) 2009 Geoffroy Couprie - * Copyright (C) 2009 Laurent Aimar - * $Id$ - * - * Authors: Geoffroy Couprie - * Laurent Aimar - * - * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. - *****************************************************************************/ - -#ifndef _DXVA2API_H -#define _DXVA2API_H - -#define MINGW_DXVA2API_H_VERSION (1) - -#if __GNUC__ >=3 -#pragma GCC system_header -#endif - -#include -#include - -/* Define it to allow using nameless struct/union (non C99 compliant) to match - * the official documentation. */ -//#define DXVA2API_USE_BITFIELDS - -/****************STRUCTURES******************/ -#pragma pack(push, 1) - -typedef struct _DXVA2_ExtendedFormat { -#ifdef DXVA2API_USE_BITFIELDS - union { - struct { - UINT SampleFormat : 8; - UINT VideoChromaSubsampling : 4; - UINT NominalRange : 3; - UINT VideoTransferMatrix : 3; - UINT VideoLighting : 4; - UINT VideoPrimaries : 5; - UINT VideoTransferFunction : 5; - }; - UINT value; - }; -#else - UINT value; -#endif -} DXVA2_ExtendedFormat; - -typedef struct _DXVA2_Frequency { - UINT Numerator; - UINT Denominator; -} DXVA2_Frequency; - -typedef struct _DXVA2_VideoDesc { - UINT SampleWidth; - UINT SampleHeight; - DXVA2_ExtendedFormat SampleFormat; - D3DFORMAT Format; - DXVA2_Frequency InputSampleFreq; - DXVA2_Frequency OutputFrameFreq; - UINT UABProtectionLevel; - UINT Reserved; -} DXVA2_VideoDesc; - -typedef struct _DXVA2_ConfigPictureDecode { - GUID guidConfigBitstreamEncryption; - GUID guidConfigMBcontrolEncryption; - GUID guidConfigResidDiffEncryption; - UINT ConfigBitstreamRaw; - UINT ConfigMBcontrolRasterOrder; - UINT ConfigResidDiffHost; - UINT ConfigSpatialResid8; - UINT ConfigResid8Subtraction; - UINT ConfigSpatialHost8or9Clipping; - UINT ConfigSpatialResidInterleaved; - UINT ConfigIntraResidUnsigned; - UINT ConfigResidDiffAccelerator; - UINT ConfigHostInverseScan; - UINT ConfigSpecificIDCT; - UINT Config4GroupedCoefs; - USHORT ConfigMinRenderTargetBuffCount; - USHORT ConfigDecoderSpecific; -} DXVA2_ConfigPictureDecode; - -typedef struct _DXVA2_DecodeBufferDesc { - DWORD CompressedBufferType; - UINT BufferIndex; - UINT DataOffset; - UINT DataSize; - UINT FirstMBaddress; - UINT NumMBsInBuffer; - UINT Width; - UINT Height; - UINT Stride; - UINT ReservedBits; - PVOID pvPVPState; -} DXVA2_DecodeBufferDesc; - -typedef struct _DXVA2_DecodeExtensionData { - UINT Function; - PVOID pPrivateInputData; - UINT PrivateInputDataSize; - PVOID pPrivateOutputData; - UINT PrivateOutputDataSize; -} DXVA2_DecodeExtensionData; - -typedef struct _DXVA2_DecodeExecuteParams { - UINT NumCompBuffers; - DXVA2_DecodeBufferDesc *pCompressedBuffers; - DXVA2_DecodeExtensionData *pExtensionData; -} DXVA2_DecodeExecuteParams; - -enum { - DXVA2_VideoDecoderRenderTarget = 0, - DXVA2_VideoProcessorRenderTarget = 1, - DXVA2_VideoSoftwareRenderTarget = 2 -}; - -enum { - DXVA2_PictureParametersBufferType = 0, - DXVA2_MacroBlockControlBufferType = 1, - DXVA2_ResidualDifferenceBufferType = 2, - DXVA2_DeblockingControlBufferType = 3, - DXVA2_InverseQuantizationMatrixBufferType = 4, - DXVA2_SliceControlBufferType = 5, - DXVA2_BitStreamDateBufferType = 6, - DXVA2_MotionVectorBuffer = 7, - DXVA2_FilmGrainBuffer = 8 -}; - -/* DXVA MPEG-I/II and VC-1 */ -typedef struct _DXVA_PictureParameters { - USHORT wDecodedPictureIndex; - USHORT wDeblockedPictureIndex; - USHORT wForwardRefPictureIndex; - USHORT wBackwardRefPictureIndex; - USHORT wPicWidthInMBminus1; - USHORT wPicHeightInMBminus1; - UCHAR bMacroblockWidthMinus1; - UCHAR bMacroblockHeightMinus1; - UCHAR bBlockWidthMinus1; - UCHAR bBlockHeightMinus1; - UCHAR bBPPminus1; - UCHAR bPicStructure; - UCHAR bSecondField; - UCHAR bPicIntra; - UCHAR bPicBackwardPrediction; - UCHAR bBidirectionalAveragingMode; - UCHAR bMVprecisionAndChromaRelation; - UCHAR bChromaFormat; - UCHAR bPicScanFixed; - UCHAR bPicScanMethod; - UCHAR bPicReadbackRequests; - UCHAR bRcontrol; - UCHAR bPicSpatialResid8; - UCHAR bPicOverflowBlocks; - UCHAR bPicExtrapolation; - UCHAR bPicDeblocked; - UCHAR bPicDeblockConfined; - UCHAR bPic4MVallowed; - UCHAR bPicOBMC; - UCHAR bPicBinPB; - UCHAR bMV_RPS; - UCHAR bReservedBits; - USHORT wBitstreamFcodes; - USHORT wBitstreamPCEelements; - UCHAR bBitstreamConcealmentNeed; - UCHAR bBitstreamConcealmentMethod; -} DXVA_PictureParameters, *LPDXVA_PictureParameters; - -typedef struct _DXVA_SliceInfo { - USHORT wHorizontalPosition; - USHORT wVerticalPosition; - UINT dwSliceBitsInBuffer; - UINT dwSliceDataLocation; - UCHAR bStartCodeBitOffset; - UCHAR bReservedBits; - USHORT wMBbitOffset; - USHORT wNumberMBsInSlice; - USHORT wQuantizerScaleCode; - USHORT wBadSliceChopping; -} DXVA_SliceInfo, *LPDXVA_SliceInfo; - -/* DXVA H264 */ -typedef struct { -#ifdef DXVA2API_USE_BITFIELDS - union { - struct { - UCHAR Index7Bits : 7; - UCHAR AssociatedFlag : 1; - }; - UCHAR bPicEntry; - }; -#else - UCHAR bPicEntry; -#endif -} DXVA_PicEntry_H264; - - -typedef struct { - USHORT wFrameWidthInMbsMinus1; - USHORT wFrameHeightInMbsMinus1; - DXVA_PicEntry_H264 CurrPic; - UCHAR num_ref_frames; -#ifdef DXVA2API_USE_BITFIELDS - union { - struct { - USHORT field_pic_flag : 1; - USHORT MbaffFrameFlag : 1; - USHORT residual_colour_transform_flag : 1; - USHORT sp_for_switch_flag : 1; - USHORT chroma_format_idc : 2; - USHORT RefPicFlag : 1; - USHORT constrained_intra_pred_flag : 1; - USHORT weighted_pred_flag : 1; - USHORT weighted_bipred_idc : 2; - USHORT MbsConsecutiveFlag : 1; - USHORT frame_mbs_only_flag : 1; - USHORT transform_8x8_mode_flag : 1; - USHORT MinLumaBipredSize8x8Flag : 1; - USHORT IntraPicFlag : 1; - }; - USHORT wBitFields; - }; -#else - USHORT wBitFields; -#endif - UCHAR bit_depth_luma_minus8; - UCHAR bit_depth_chroma_minus8; - USHORT Reserved16Bits; - UINT StatusReportFeedbackNumber; - DXVA_PicEntry_H264 RefFrameList[16]; - INT CurrFieldOrderCnt[2]; - INT FieldOrderCntList[16][2]; - CHAR pic_init_qs_minus26; - CHAR chroma_qp_index_offset; - CHAR second_chroma_qp_index_offset; - UCHAR ContinuationFlag; - CHAR pic_init_qp_minus26; - UCHAR num_ref_idx_l0_active_minus1; - UCHAR num_ref_idx_l1_active_minus1; - UCHAR Reserved8BitsA; - USHORT FrameNumList[16]; - - UINT UsedForReferenceFlags; - USHORT NonExistingFrameFlags; - USHORT frame_num; - UCHAR log2_max_frame_num_minus4; - UCHAR pic_order_cnt_type; - UCHAR log2_max_pic_order_cnt_lsb_minus4; - UCHAR delta_pic_order_always_zero_flag; - UCHAR direct_8x8_inference_flag; - UCHAR entropy_coding_mode_flag; - UCHAR pic_order_present_flag; - UCHAR num_slice_groups_minus1; - UCHAR slice_group_map_type; - UCHAR deblocking_filter_control_present_flag; - UCHAR redundant_pic_cnt_present_flag; - UCHAR Reserved8BitsB; - USHORT slice_group_change_rate_minus1; - UCHAR SliceGroupMap[810]; -} DXVA_PicParams_H264; - -typedef struct { - UCHAR bScalingLists4x4[6][16]; - UCHAR bScalingLists8x8[2][64]; -} DXVA_Qmatrix_H264; -/* DXVA Mpeg2*/ -typedef struct { - BYTE bNewQmatrix[4]; /* intra Y, inter Y, intra chroma, inter chroma */ - WORD Qmatrix[4][8 * 8]; -} DXVA_QmatrixData; - -typedef struct { - UINT BSNALunitDataLocation; - UINT SliceBytesInBuffer; - USHORT wBadSliceChopping; - USHORT first_mb_in_slice; - USHORT NumMbsForSlice; - USHORT BitOffsetToSliceData; - UCHAR slice_type; - UCHAR luma_log2_weight_denom; - UCHAR chroma_log2_weight_denom; - - UCHAR num_ref_idx_l0_active_minus1; - UCHAR num_ref_idx_l1_active_minus1; - CHAR slice_alpha_c0_offset_div2; - CHAR slice_beta_offset_div2; - UCHAR Reserved8Bits; - DXVA_PicEntry_H264 RefPicList[2][32]; - SHORT Weights[2][32][3][2]; - CHAR slice_qs_delta; - CHAR slice_qp_delta; - UCHAR redundant_pic_cnt; - UCHAR direct_spatial_mv_pred_flag; - UCHAR cabac_init_idc; - UCHAR disable_deblocking_filter_idc; - USHORT slice_id; -} DXVA_Slice_H264_Long; - -typedef struct { - UINT BSNALunitDataLocation; - UINT SliceBytesInBuffer; - USHORT wBadSliceChopping; -} DXVA_Slice_H264_Short; - -typedef struct { - USHORT wFrameWidthInMbsMinus1; - USHORT wFrameHeightInMbsMinus1; - DXVA_PicEntry_H264 InPic; - DXVA_PicEntry_H264 OutPic; - USHORT PicOrderCnt_offset; - INT CurrPicOrderCnt; - UINT StatusReportFeedbackNumber; - UCHAR model_id; - UCHAR separate_colour_description_present_flag; - UCHAR film_grain_bit_depth_luma_minus8; - UCHAR film_grain_bit_depth_chroma_minus8; - UCHAR film_grain_full_range_flag; - UCHAR film_grain_colour_primaries; - UCHAR film_grain_transfer_characteristics; - UCHAR film_grain_matrix_coefficients; - UCHAR blending_mode_id; - UCHAR log2_scale_factor; - UCHAR comp_model_present_flag[4]; - UCHAR num_intensity_intervals_minus1[4]; - UCHAR num_model_values_minus1[4]; - UCHAR intensity_interval_lower_bound[3][16]; - UCHAR intensity_interval_upper_bound[3][16]; - SHORT comp_model_value[3][16][8]; -} DXVA_FilmGrainChar_H264; - -#pragma pack(pop) - -/*************INTERFACES************/ -#ifdef __cplusplus -extern "C" { -#endif - -typedef _COM_interface IDirectXVideoDecoderService IDirectXVideoDecoderService; -typedef _COM_interface IDirectXVideoDecoder IDirectXVideoDecoder; - -#undef INTERFACE -#define INTERFACE IDirectXVideoDecoder -DECLARE_INTERFACE_(IDirectXVideoDecoder,IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - STDMETHOD(GetVideoDecoderService)(THIS_ IDirectXVideoDecoderService**) PURE; - STDMETHOD(GetCreationParameters)(THIS_ GUID*,DXVA2_VideoDesc*,DXVA2_ConfigPictureDecode*,IDirect3DSurface9***,UINT*) PURE; - STDMETHOD(GetBuffer)(THIS_ UINT,void**,UINT*) PURE; - STDMETHOD(ReleaseBuffer)(THIS_ UINT) PURE; - STDMETHOD(BeginFrame)(THIS_ IDirect3DSurface9 *,void*) PURE; - STDMETHOD(EndFrame)(THIS_ HANDLE *) PURE; - STDMETHOD(Execute)(THIS_ const DXVA2_DecodeExecuteParams*) PURE; - - -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectXVideoDecoder_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectXVideoDecoder_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectXVideoDecoder_Release(p) (p)->lpVtbl->Release(p) -#define IDirectXVideoDecoder_BeginFrame(p,a,b) (p)->lpVtbl->BeginFrame(p,a,b) -#define IDirectXVideoDecoder_EndFrame(p,a) (p)->lpVtbl->EndFrame(p,a) -#define IDirectXVideoDecoder_Execute(p,a) (p)->lpVtbl->Execute(p,a) -#define IDirectXVideoDecoder_GetBuffer(p,a,b,c) (p)->lpVtbl->GetBuffer(p,a,b,c) -#define IDirectXVideoDecoder_GetCreationParameters(p,a,b,c,d,e) (p)->lpVtbl->GetCreationParameters(p,a,b,c,d,e) -#define IDirectXVideoDecoder_GetVideoDecoderService(p,a) (p)->lpVtbl->GetVideoDecoderService(p,a) -#define IDirectXVideoDecoder_ReleaseBuffer(p,a) (p)->lpVtbl->ReleaseBuffer(p,a) -#else -#define IDirectXVideoDecoder_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectXVideoDecoder_AddRef(p) (p)->AddRef() -#define IDirectXVideoDecoder_Release(p) (p)->Release() -#define IDirectXVideoDecoder_BeginFrame(p,a,b) (p)->BeginFrame(a,b) -#define IDirectXVideoDecoder_EndFrame(p,a) (p)->EndFrame(a) -#define IDirectXVideoDecoder_Execute(p,a) (p)->Execute(a) -#define IDirectXVideoDecoder_GetBuffer(p,a,b,c) (p)->GetBuffer(a,b,c) -#define IDirectXVideoDecoder_GetCreationParameters(p,a,b,c,d,e) (p)->GetCreationParameters(a,b,c,d,e) -#define IDirectXVideoDecoder_GetVideoDecoderService(p,a) (p)->GetVideoDecoderService(a) -#define IDirectXVideoDecoder_ReleaseBuffer(p,a) (p)->ReleaseBuffer(a) -#endif - -#undef INTERFACE -#define INTERFACE IDirectXVideoAccelerationService -DECLARE_INTERFACE_(IDirectXVideoAccelerationService,IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - STDMETHOD(CreateSurface)(THIS_ UINT,UINT,UINT,D3DFORMAT,D3DPOOL,DWORD,DWORD,IDirect3DSurface9**,HANDLE*) PURE; - -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectXVideoAccelerationService_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectXVideoAccelerationService_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectXVideoAccelerationService_Release(p) (p)->lpVtbl->Release(p) -#define IDirectXVideoAccelerationService_CreateSurface(p,a,b,c,d,e,f,g,h,i) (p)->lpVtbl->CreateSurface(p,a,b,c,d,e,f,g,h,i) -#else -#define IDirectXVideoAccelerationService_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectXVideoAccelerationService_AddRef(p) (p)->AddRef() -#define IDirectXVideoAccelerationService_Release(p) (p)->Release() -#define IDirectXVideoAccelerationService_CreateSurface(p,a,b,c,d,e,f,g,h,i) (p)->CreateSurface(a,b,c,d,e,f,g,h,i) -#endif - -#undef INTERFACE -#define INTERFACE IDirectXVideoDecoderService -DECLARE_INTERFACE_(IDirectXVideoDecoderService,IDirectXVideoAccelerationService) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - STDMETHOD(CreateSurface)(THIS_ UINT,UINT,UINT,D3DFORMAT,D3DPOOL,DWORD,DWORD,IDirect3DSurface9**,HANDLE*) PURE; - STDMETHOD(GetDecoderDeviceGuids)(THIS_ UINT*,GUID **) PURE; - STDMETHOD(GetDecoderRenderTargets)(THIS_ REFGUID,UINT*,D3DFORMAT**) PURE; - STDMETHOD(GetDecoderConfigurations)(THIS_ REFGUID,const DXVA2_VideoDesc*,IUnknown*,UINT*,DXVA2_ConfigPictureDecode**) PURE; - STDMETHOD(CreateVideoDecoder)(THIS_ REFGUID,const DXVA2_VideoDesc*,DXVA2_ConfigPictureDecode*,IDirect3DSurface9**,UINT,IDirectXVideoDecoder**) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectXVideoDecoderService_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectXVideoDecoderService_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectXVideoDecoderService_Release(p) (p)->lpVtbl->Release(p) -#define IDirectXVideoDecoderService_CreateSurface(p,a,b,c,d,e,f,g,h,i) (p)->lpVtbl->CreateSurface(p,a,b,c,d,e,f,g,h,i) -#define IDirectXVideoDecoderService_CreateVideoDecoder(p,a,b,c,d,e,f) (p)->lpVtbl->CreateVideoDecoder(p,a,b,c,d,e,f) -#define IDirectXVideoDecoderService_GetDecoderConfigurations(p,a,b,c,d,e) (p)->lpVtbl->GetDecoderConfigurations(p,a,b,c,d,e) -#define IDirectXVideoDecoderService_GetDecoderDeviceGuids(p,a,b) (p)->lpVtbl->GetDecoderDeviceGuids(p,a,b) -#define IDirectXVideoDecoderService_GetDecoderRenderTargets(p,a,b,c) (p)->lpVtbl->GetDecoderRenderTargets(p,a,b,c) -#else -#define IDirectXVideoDecoderService_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectXVideoDecoderService_AddRef(p) (p)->AddRef() -#define IDirectXVideoDecoderService_Release(p) (p)->Release() -#define IDirectXVideoDecoderService_CreateSurface(p,a,b,c,d,e,f,g,h,i) (p)->CreateSurface(a,b,c,d,e,f,g,h,i) -#define IDirectXVideoDecoderService_CreateVideoDecoder(p,a,b,c,d,e,f) (p)->CreateVideoDecoder(a,b,c,d,e,f) -#define IDirectXVideoDecoderService_GetDecoderConfigurations(p,a,b,c,d,e) (p)->GetDecoderConfigurations(a,b,c,d,e) -#define IDirectXVideoDecoderService_GetDecoderDeviceGuids(p,a,b) (p)->GetDecoderDeviceGuids(a,b) -#define IDirectXVideoDecoderService_GetDecoderRenderTargets(p,a,b,c) (p)->GetDecoderRenderTargets(a,b,c) -#endif - -#undef INTERFACE -#define INTERFACE IDirect3DDeviceManager9 -DECLARE_INTERFACE_(IDirect3DDeviceManager9,IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - STDMETHOD(ResetDevice)(THIS_ IDirect3DDevice9*,UINT) PURE; - STDMETHOD(OpenDeviceHandle)(THIS_ HANDLE*) PURE; - STDMETHOD(CloseDeviceHandle)( THIS_ HANDLE) PURE; - STDMETHOD(TestDevice)( THIS_ HANDLE) PURE; - STDMETHOD(LockDevice)( THIS_ HANDLE,IDirect3DDevice9**,BOOL) PURE; - STDMETHOD(UnlockDevice)( THIS_ HANDLE,BOOL) PURE; - STDMETHOD(GetVideoService)( THIS_ HANDLE,REFIID,void**) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DDeviceManager9_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DDeviceManager9_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DDeviceManager9_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DDeviceManager9_ResetDevice(p,a,b) (p)->lpVtbl->ResetDevice(p,a,b) -#define IDirect3DDeviceManager9_OpenDeviceHandle(p,a) (p)->lpVtbl->OpenDeviceHandle(p,a) -#define IDirect3DDeviceManager9_CloseDeviceHandle(p,a) (p)->lpVtbl->CloseDeviceHandle(p,a) -#define IDirect3DDeviceManager9_TestDevice(p,a) (p)->lpVtbl->TestDevice(p,a) -#define IDirect3DDeviceManager9_LockDevice(p,a,b,c) (p)->lpVtbl->LockDevice(p,a,b,c) -#define IDirect3DDeviceManager9_UnlockDevice(p,a,b) (p)->lpVtbl->UnlockDevice(p,a,b) -#define IDirect3DDeviceManager9_GetVideoService(p,a,b,c) (p)->lpVtbl->GetVideoService(p,a,b,c) -#else -#define IDirect3DDeviceManager9_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DDeviceManager9_AddRef(p) (p)->AddRef() -#define IDirect3DDeviceManager9_Release(p) (p)->Release() -#define IDirect3DDeviceManager9_ResetDevice(p,a,b) (p)->ResetDevice(a,b) -#define IDirect3DDeviceManager9_OpenDeviceHandle(p,a) (p)->OpenDeviceHandle(a) -#define IDirect3DDeviceManager9_CloseDeviceHandle(p,a) (p)->CloseDeviceHandle(a) -#define IDirect3DDeviceManager9_TestDevice(p,a) (p)->TestDevice(a) -#define IDirect3DDeviceManager9_LockDevice(p,a,b,c) (p)->LockDevice(a,b,c) -#define IDirect3DDeviceManager9_UnlockDevice(p,a,b) (p)->UnlockDevice(a,b) -#define IDirect3DDeviceManager9_GetVideoService(p,a,b,c) (p)->GetVideoService(a,b,c) -#endif - -#ifdef __cplusplus -}; -#endif - -#endif //_DXVA2API_H diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/include/libavutil/avconfig.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/include/libavutil/avconfig.h deleted file mode 100644 index b028bb4f7..000000000 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/include/libavutil/avconfig.h +++ /dev/null @@ -1,5 +0,0 @@ -/* Generated by ffconf */ -#ifndef AVUTIL_AVCONFIG_H -#define AVUTIL_AVCONFIG_H -#define AV_HAVE_BIGENDIAN 0 -#endif /* AVUTIL_AVCONFIG_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/4xm.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/4xm.c index 219850302..b6a97aa18 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/4xm.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/4xm.c @@ -333,16 +333,16 @@ static void decode_p_block(FourXContext *f, uint16_t *dst, uint16_t *src, int lo av_log(f->avctx, AV_LOG_ERROR, "mv out of pic\n"); return; } - mcdc(dst, src, log2w, h, stride, 1, le2me_16(*f->wordstream++)); + mcdc(dst, src, log2w, h, stride, 1, av_le2ne16(*f->wordstream++)); }else if(code == 5){ - mcdc(dst, src, log2w, h, stride, 0, le2me_16(*f->wordstream++)); + mcdc(dst, src, log2w, h, stride, 0, av_le2ne16(*f->wordstream++)); }else if(code == 6){ if(log2w){ - dst[0] = le2me_16(*f->wordstream++); - dst[1] = le2me_16(*f->wordstream++); + dst[0] = av_le2ne16(*f->wordstream++); + dst[1] = av_le2ne16(*f->wordstream++); }else{ - dst[0 ] = le2me_16(*f->wordstream++); - dst[stride] = le2me_16(*f->wordstream++); + dst[0 ] = av_le2ne16(*f->wordstream++); + dst[stride] = av_le2ne16(*f->wordstream++); } } } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/8bps.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/8bps.c index ff5795533..292c739c1 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/8bps.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/8bps.c @@ -100,7 +100,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac for(row = 0; row < height; row++) { pixptr = c->pic.data[0] + row * c->pic.linesize[0] + planemap[p]; pixptr_end = pixptr + c->pic.linesize[0]; - dlen = be2me_16(*(const unsigned short *)(lp+row*2)); + dlen = av_be2ne16(*(const unsigned short *)(lp+row*2)); /* Decode a row of this plane */ while(dlen > 0) { if(dp + 1 >= buf+buf_size) return -1; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/Makefile b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/Makefile index 55b763601..545c355ce 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/Makefile +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/Makefile @@ -42,7 +42,8 @@ OBJS-$(CONFIG_VAAPI) += vaapi.o OBJS-$(CONFIG_VDPAU) += vdpau.o # decoders/encoders/hardware accelerators -OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o +OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o \ + aacadtsdec.o mpeg4audio.o OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \ aacpsy.o aactab.o \ psymodel.o iirfilter.o \ @@ -130,6 +131,8 @@ OBJS-$(CONFIG_FRAPS_DECODER) += fraps.o huffman.o OBJS-$(CONFIG_FRWU_DECODER) += frwu.o OBJS-$(CONFIG_GIF_DECODER) += gifdec.o lzw.o OBJS-$(CONFIG_GIF_ENCODER) += gif.o lzwenc.o +OBJS-$(CONFIG_GSM_DECODER) += gsmdec.o +OBJS-$(CONFIG_GSM_MS_DECODER) += gsmdec.o OBJS-$(CONFIG_H261_DECODER) += h261dec.o h261.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_H261_ENCODER) += h261enc.o h261.o \ @@ -265,6 +268,7 @@ OBJS-$(CONFIG_PGM_ENCODER) += pnmenc.o pnm.o OBJS-$(CONFIG_PGMYUV_DECODER) += pnmdec.o pnm.o OBJS-$(CONFIG_PGMYUV_ENCODER) += pnmenc.o pnm.o OBJS-$(CONFIG_PGSSUB_DECODER) += pgssubdec.o +OBJS-$(CONFIG_PICTOR_DECODER) += pictordec.o cga_data.o OBJS-$(CONFIG_PNG_DECODER) += png.o pngdec.o OBJS-$(CONFIG_PNG_ENCODER) += png.o pngenc.o OBJS-$(CONFIG_PPM_DECODER) += pnmdec.o pnm.o @@ -281,7 +285,8 @@ OBJS-$(CONFIG_QPEG_DECODER) += qpeg.o OBJS-$(CONFIG_QTRLE_DECODER) += qtrle.o OBJS-$(CONFIG_QTRLE_ENCODER) += qtrleenc.o OBJS-$(CONFIG_R210_DECODER) += r210dec.o -OBJS-$(CONFIG_RA_144_DECODER) += ra144.o celp_filters.o +OBJS-$(CONFIG_RA_144_DECODER) += ra144dec.o ra144.o celp_filters.o +OBJS-$(CONFIG_RA_144_ENCODER) += ra144enc.o ra144.o celp_filters.o OBJS-$(CONFIG_RA_288_DECODER) += ra288.o celp_math.o celp_filters.o OBJS-$(CONFIG_RAWVIDEO_DECODER) += rawdec.o OBJS-$(CONFIG_RAWVIDEO_ENCODER) += rawenc.o @@ -370,9 +375,11 @@ OBJS-$(CONFIG_VORBIS_ENCODER) += vorbis_enc.o vorbis.o \ vorbis_data.o OBJS-$(CONFIG_VP3_DECODER) += vp3.o vp3dsp.o OBJS-$(CONFIG_VP5_DECODER) += vp5.o vp56.o vp56data.o vp56dsp.o \ - vp3dsp.o + vp3dsp.o cabac.o OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o vp56dsp.o \ - vp3dsp.o vp6dsp.o huffman.o + vp3dsp.o vp6dsp.o huffman.o cabac.o +OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp8dsp.o vp56.o vp56data.o \ + h264pred.o cabac.o OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o OBJS-$(CONFIG_WMAPRO_DECODER) += wmaprodec.o wma.o @@ -519,8 +526,6 @@ OBJS-$(CONFIG_WEBM_MUXER) += xiph.o mpeg4audio.o \ OBJS-$(CONFIG_LIBDIRAC_DECODER) += libdiracdec.o OBJS-$(CONFIG_LIBDIRAC_ENCODER) += libdiracenc.o libdirac_libschro.o OBJS-$(CONFIG_LIBFAAC_ENCODER) += libfaac.o -OBJS-$(CONFIG_LIBFAAD_DECODER) += libfaad.o -OBJS-$(CONFIG_LIBFAAD_LATM_DECODER) += latmaac.o OBJS-$(CONFIG_LIBGSM_DECODER) += libgsm.o OBJS-$(CONFIG_LIBGSM_ENCODER) += libgsm.o OBJS-$(CONFIG_LIBGSM_MS_DECODER) += libgsm.o @@ -538,15 +543,15 @@ OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER) += libschroedingerenc.o \ libdirac_libschro.o OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o -OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o +OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o vorbis_data.o OBJS-$(CONFIG_LIBVPX_DECODER) += libvpxdec.o OBJS-$(CONFIG_LIBVPX_ENCODER) += libvpxenc.o OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o -OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvidff.o libxvid_rc.o +OBJS-$(CONFIG_LIBXVID) += libxvidff.o libxvid_rc.o # parsers OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o \ - mpeg4audio.o + aacadtsdec.o mpeg4audio.o OBJS-$(CONFIG_AC3_PARSER) += ac3_parser.o ac3tab.o \ aac_ac3_parser.o OBJS-$(CONFIG_CAVSVIDEO_PARSER) += cavs_parser.o @@ -563,7 +568,6 @@ OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264.o \ h264_loopfilter.o h264_cabac.o \ h264_cavlc.o h264_ps.o \ mpegvideo.o error_resilience.o -OBJS-$(CONFIG_LATM_PARSER) += latm_parser.o OBJS-$(CONFIG_MJPEG_PARSER) += mjpeg_parser.o OBJS-$(CONFIG_MLP_PARSER) += mlp_parser.o mlp.o OBJS-$(CONFIG_MPEG4VIDEO_PARSER) += mpeg4video_parser.o h263.o \ @@ -583,7 +587,8 @@ OBJS-$(CONFIG_VP3_PARSER) += vp3_parser.o OBJS-$(CONFIG_VP8_PARSER) += vp8_parser.o # bitstream filters -OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o +OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o aacadtsdec.o \ + mpeg4audio.o OBJS-$(CONFIG_CHOMP_BSF) += chomp_bsf.o OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF) += h264_mp4toannexb_bsf.o @@ -598,8 +603,6 @@ OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += remove_extradata_bsf.o OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += movsub_bsf.o # thread libraries -OBJS-$(HAVE_BEOSTHREADS) += beosthread.o -OBJS-$(HAVE_OS2THREADS) += os2thread.o OBJS-$(HAVE_PTHREADS) += pthread.o OBJS-$(HAVE_W32THREADS) += w32thread.o @@ -653,14 +656,21 @@ else $(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=0 endif -$(SUBDIR)%_tablegen$(HOSTEXESUF): $(SUBDIR)%_tablegen.c $(SUBDIR)tableprint.c - $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS) +$(SUBDIR)%_tablegen$(HOSTEXESUF): $(SUBDIR)%_tablegen.c $(SUBDIR)%_tablegen.h $(SUBDIR)tableprint.c + $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $(filter %.c,$^) $(HOSTLIBS) + +GEN_HEADERS = cbrt_tables.h aacps_tables.h aac_tables.h dv_tables.h \ + mdct_tables.h mpegaudio_tables.h motionpixels_tables.h \ + pcm_tables.h qdm2_tables.h +GEN_HEADERS := $(addprefix $(SUBDIR), $(GEN_HEADERS)) -$(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF) +$(GEN_HEADERS): $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF) $(M)./$< > $@ ifdef CONFIG_HARDCODED_TABLES $(SUBDIR)aacdec.o: $(SUBDIR)cbrt_tables.h +$(SUBDIR)aacps.o: $(SUBDIR)aacps_tables.h +$(SUBDIR)aactab.o: $(SUBDIR)aac_tables.h $(SUBDIR)dv.o: $(SUBDIR)dv_tables.h $(SUBDIR)mdct.o: $(SUBDIR)mdct_tables.h $(SUBDIR)mpegaudiodec.o: $(SUBDIR)mpegaudio_tables.h diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_adtstoasc_bsf.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_adtstoasc_bsf.c index 9d53a011c..9b615e65d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_adtstoasc_bsf.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_adtstoasc_bsf.c @@ -20,7 +20,7 @@ */ #include "avcodec.h" -#include "aac_parser.h" +#include "aacadtsdec.h" #include "put_bits.h" #include "get_bits.h" #include "mpeg4audio.h" diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_parser.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_parser.c index 30ce04d4a..3ad4610e9 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_parser.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_parser.c @@ -22,53 +22,10 @@ #include "parser.h" #include "aac_ac3_parser.h" -#include "aac_parser.h" +#include "aacadtsdec.h" #include "get_bits.h" #include "mpeg4audio.h" -int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr) -{ - int size, rdb, ch, sr; - int aot, crc_abs; - - if(get_bits(gbc, 12) != 0xfff) - return AAC_AC3_PARSE_ERROR_SYNC; - - skip_bits1(gbc); /* id */ - skip_bits(gbc, 2); /* layer */ - crc_abs = get_bits1(gbc); /* protection_absent */ - aot = get_bits(gbc, 2); /* profile_objecttype */ - sr = get_bits(gbc, 4); /* sample_frequency_index */ - if(!ff_mpeg4audio_sample_rates[sr]) - return AAC_AC3_PARSE_ERROR_SAMPLE_RATE; - skip_bits1(gbc); /* private_bit */ - ch = get_bits(gbc, 3); /* channel_configuration */ - - skip_bits1(gbc); /* original/copy */ - skip_bits1(gbc); /* home */ - - /* adts_variable_header */ - skip_bits1(gbc); /* copyright_identification_bit */ - skip_bits1(gbc); /* copyright_identification_start */ - size = get_bits(gbc, 13); /* aac_frame_length */ - if(size < AAC_ADTS_HEADER_SIZE) - return AAC_AC3_PARSE_ERROR_FRAME_SIZE; - - skip_bits(gbc, 11); /* adts_buffer_fullness */ - rdb = get_bits(gbc, 2); /* number_of_raw_data_blocks_in_frame */ - - hdr->object_type = aot + 1; - hdr->chan_config = ch; - hdr->crc_absent = crc_abs; - hdr->num_aac_frames = rdb + 1; - hdr->sampling_index = sr; - hdr->sample_rate = ff_mpeg4audio_sample_rates[sr]; - hdr->samples = (rdb + 1) * 1024; - hdr->bit_rate = size * 8 * hdr->sample_rate / hdr->samples; - - return size; -} - static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info, int *need_next_header, int *new_frame_start) { @@ -80,7 +37,7 @@ static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info, uint8_t u8[8]; } tmp; - tmp.u64 = be2me_64(state); + tmp.u64 = av_be2ne64(state); init_get_bits(&bits, tmp.u8+8-AAC_ADTS_HEADER_SIZE, AAC_ADTS_HEADER_SIZE * 8); if ((size = ff_aac_parse_header(&bits, &hdr)) < 0) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_tablegen.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_tablegen.c new file mode 100644 index 000000000..33a179f51 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_tablegen.c @@ -0,0 +1,37 @@ +/* + * Generate a header file for hardcoded AAC tables + * + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#define CONFIG_HARDCODED_TABLES 0 +#include "aac_tablegen.h" +#include "tableprint.h" + +int main(void) +{ + ff_aac_tableinit(); + + write_fileheader(); + + WRITE_ARRAY("const", float, ff_aac_pow2sf_tab); + + return 0; +} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_tablegen.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_tablegen.h new file mode 100644 index 000000000..3a820ba67 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_tablegen.h @@ -0,0 +1,42 @@ +/* + * Header file for hardcoded AAC tables + * + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AAC_TABLEGEN_H +#define AAC_TABLEGEN_H + +#include "aac_tablegen_decl.h" + +#if CONFIG_HARDCODED_TABLES +#include "libavcodec/aac_tables.h" +#else +#include "libavutil/mathematics.h" +float ff_aac_pow2sf_tab[428]; + +void ff_aac_tableinit(void) +{ + int i; + for (i = 0; i < 428; i++) + ff_aac_pow2sf_tab[i] = pow(2, (i - 200) / 4.); +} +#endif /* CONFIG_HARDCODED_TABLES */ + +#endif /* AAC_TABLEGEN_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_tablegen_decl.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_tablegen_decl.h new file mode 100644 index 000000000..7157c8046 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_tablegen_decl.h @@ -0,0 +1,34 @@ +/* + * Header file for hardcoded AAC tables + * + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AAC_TABLEGEN_INIT_H +#define AAC_TABLEGEN_INIT_H + +#if CONFIG_HARDCODED_TABLES +#define ff_aac_tableinit() +extern const float ff_aac_pow2sf_tab[428]; +#else +void ff_aac_tableinit(void); +extern float ff_aac_pow2sf_tab[428]; +#endif /* CONFIG_HARDCODED_TABLES */ + +#endif /* AAC_TABLEGEN_INIT_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacadtsdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacadtsdec.c new file mode 100644 index 000000000..fd86d288a --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacadtsdec.c @@ -0,0 +1,70 @@ +/* + * Audio and Video frame extraction + * Copyright (c) 2003 Fabrice Bellard + * Copyright (c) 2003 Michael Niedermayer + * Copyright (c) 2009 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "aac_ac3_parser.h" +#include "aacadtsdec.h" +#include "get_bits.h" +#include "mpeg4audio.h" + +int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr) +{ + int size, rdb, ch, sr; + int aot, crc_abs; + + if(get_bits(gbc, 12) != 0xfff) + return AAC_AC3_PARSE_ERROR_SYNC; + + skip_bits1(gbc); /* id */ + skip_bits(gbc, 2); /* layer */ + crc_abs = get_bits1(gbc); /* protection_absent */ + aot = get_bits(gbc, 2); /* profile_objecttype */ + sr = get_bits(gbc, 4); /* sample_frequency_index */ + if(!ff_mpeg4audio_sample_rates[sr]) + return AAC_AC3_PARSE_ERROR_SAMPLE_RATE; + skip_bits1(gbc); /* private_bit */ + ch = get_bits(gbc, 3); /* channel_configuration */ + + skip_bits1(gbc); /* original/copy */ + skip_bits1(gbc); /* home */ + + /* adts_variable_header */ + skip_bits1(gbc); /* copyright_identification_bit */ + skip_bits1(gbc); /* copyright_identification_start */ + size = get_bits(gbc, 13); /* aac_frame_length */ + if(size < AAC_ADTS_HEADER_SIZE) + return AAC_AC3_PARSE_ERROR_FRAME_SIZE; + + skip_bits(gbc, 11); /* adts_buffer_fullness */ + rdb = get_bits(gbc, 2); /* number_of_raw_data_blocks_in_frame */ + + hdr->object_type = aot + 1; + hdr->chan_config = ch; + hdr->crc_absent = crc_abs; + hdr->num_aac_frames = rdb + 1; + hdr->sampling_index = sr; + hdr->sample_rate = ff_mpeg4audio_sample_rates[sr]; + hdr->samples = (rdb + 1) * 1024; + hdr->bit_rate = size * 8 * hdr->sample_rate / hdr->samples; + + return size; +} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_parser.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacadtsdec.h similarity index 79% rename from xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_parser.h rename to xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacadtsdec.h index 8dd575bb3..bdc577179 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aac_parser.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacadtsdec.h @@ -1,5 +1,5 @@ /* - * AAC parser prototypes + * AAC ADTS header decoding prototypes and structures * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2003 Michael Niedermayer * @@ -20,11 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef AVCODEC_AAC_PARSER_H -#define AVCODEC_AAC_PARSER_H +#ifndef AVCODEC_AACADTSDEC_H +#define AVCODEC_AACADTSDEC_H #include -#include "aac_ac3_parser.h" #include "get_bits.h" #define AAC_ADTS_HEADER_SIZE 7 @@ -41,15 +40,15 @@ typedef struct { } AACADTSHeaderInfo; /** - * Parses AAC frame header. - * Parses the ADTS frame header to the end of the variable header, which is + * Parse AAC frame header. + * Parse the ADTS frame header to the end of the variable header, which is * the first 54 bits. - * @param gbc[in] BitContext containing the first 54 bits of the frame. - * @param hdr[out] Pointer to struct where header info is written. + * @param gbc BitContext containing the first 54 bits of the frame. + * @param hdr Pointer to struct where header info is written. * @return Returns 0 on success, -1 if there is a sync word mismatch, * -2 if the version element is invalid, -3 if the sample rate * element is invalid, or -4 if the bit rate element is invalid. */ int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr); -#endif /* AVCODEC_AAC_PARSER_H */ +#endif /* AVCODEC_AACADTSDEC_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aaccoder.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aaccoder.c index f3193cddf..81ece4b23 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aaccoder.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aaccoder.c @@ -704,7 +704,6 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, } minscaler = FFMIN(minscaler, sce->sf_idx[w*16+g]); cb = find_min_book(find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled), sce->sf_idx[w*16+g]); - sce->band_type[w*16+g] = cb; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { int b; dist += quantize_band_cost(s, coefs + w2*128, @@ -748,12 +747,15 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, start = w*128; for (g = 0; g < sce->ics.num_swb; g++) { int prevsc = sce->sf_idx[w*16+g]; + const float *scaled = s->scoefs + start; if (dists[w*16+g] > uplims[w*16+g] && sce->sf_idx[w*16+g] > 60) sce->sf_idx[w*16+g]--; sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler, minscaler + SCALE_MAX_DIFF); sce->sf_idx[w*16+g] = FFMIN(sce->sf_idx[w*16+g], 219); if (sce->sf_idx[w*16+g] != prevsc) fflag = 1; + sce->band_type[w*16+g] = find_min_book(find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled), sce->sf_idx[w*16+g]); + start += sce->ics.swb_sizes[g]; } } its++; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacdec.c index ba84678aa..a30287617 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacdec.c @@ -67,7 +67,7 @@ * Y (not in this code) Layer-2 * Y (not in this code) Layer-3 * N SinuSoidal Coding (Transient, Sinusoid, Noise) - * N (planned) Parametric Stereo + * Y Parametric Stereo * N Direct Stream Transfer * * Note: - HE AAC v1 comprises LC AAC with Spectral Band Replication. @@ -90,7 +90,7 @@ #include "sbr.h" #include "aacsbr.h" #include "mpeg4audio.h" -#include "aac_parser.h" +#include "aacadtsdec.h" #include #include @@ -200,7 +200,8 @@ static av_cold int che_configure(AACContext *ac, ff_aac_sbr_ctx_init(&ac->che[type][id]->sbr); if (type != TYPE_CCE) { ac->output_data[(*channels)++] = ac->che[type][id]->ch[0].ret; - if (type == TYPE_CPE) { + if (type == TYPE_CPE || + (type == TYPE_SCE && ac->m4ac.ps == 1)) { ac->output_data[(*channels)++] = ac->che[type][id]->ch[1].ret; } } @@ -228,6 +229,7 @@ static av_cold int output_configure(AACContext *ac, AVCodecContext *avctx = ac->avctx; int i, type, channels = 0, ret; + if (new_che_pos != che_pos) memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); if (channel_config) { @@ -471,6 +473,8 @@ static int decode_audio_specific_config(AACContext *ac, void *data, av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index); return -1; } + if (ac->m4ac.sbr == 1 && ac->m4ac.ps == -1) + ac->m4ac.ps = 1; skip_bits_long(&gb, i); @@ -533,7 +537,6 @@ static void reset_predictor_group(PredictorState *ps, int group_num) static av_cold int aac_decode_init(AVCodecContext *avctx) { AACContext *ac = avctx->priv_data; - int i; ac->avctx = avctx; ac->m4ac.sample_rate = avctx->sample_rate; @@ -577,10 +580,7 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) ac->sf_offset = 60; } -#if !CONFIG_HARDCODED_TABLES - for (i = 0; i < 428; i++) - ff_aac_pow2sf_tab[i] = pow(2, (i - 200) / 4.); -#endif /* CONFIG_HARDCODED_TABLES */ + ff_aac_tableinit(); INIT_VLC_STATIC(&vlc_scalefactors,7,FF_ARRAY_ELEMS(ff_aac_scalefactor_code), ff_aac_scalefactor_bits, sizeof(ff_aac_scalefactor_bits[0]), sizeof(ff_aac_scalefactor_bits[0]), @@ -995,7 +995,6 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], const int c = 1024 / ics->num_windows; const uint16_t *offsets = ics->swb_offset; float *coef_base = coef; - int err_idx; for (g = 0; g < ics->num_windows; g++) memset(coef + g * 128 + offsets[ics->max_sfb], 0, sizeof(float) * (c - offsets[ics->max_sfb])); @@ -1031,7 +1030,6 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], const float *vq = ff_aac_codebook_vector_vals[cbt_m1]; const uint16_t *cb_vector_idx = ff_aac_codebook_vector_idx[cbt_m1]; VLC_TYPE (*vlc_tab)[2] = vlc_spectral[cbt_m1].table; - const int cb_size = ff_aac_spectral_sizes[cbt_m1]; OPEN_READER(re, gb); switch (cbt_m1 >> 1) { @@ -1046,12 +1044,6 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], UPDATE_CACHE(re, gb); GET_VLC(code, re, gb, vlc_tab, 8, 2); - - if (code >= cb_size) { - err_idx = code; - goto err_cb_overflow; - } - cb_idx = cb_vector_idx[code]; cf = VMUL4(cf, vq, cb_idx, sf + idx); } while (len -= 4); @@ -1071,12 +1063,6 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], UPDATE_CACHE(re, gb); GET_VLC(code, re, gb, vlc_tab, 8, 2); - - if (code >= cb_size) { - err_idx = code; - goto err_cb_overflow; - } - #if MIN_CACHE_BITS < 20 UPDATE_CACHE(re, gb); #endif @@ -1100,12 +1086,6 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], UPDATE_CACHE(re, gb); GET_VLC(code, re, gb, vlc_tab, 8, 2); - - if (code >= cb_size) { - err_idx = code; - goto err_cb_overflow; - } - cb_idx = cb_vector_idx[code]; cf = VMUL2(cf, vq, cb_idx, sf + idx); } while (len -= 2); @@ -1126,12 +1106,6 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], UPDATE_CACHE(re, gb); GET_VLC(code, re, gb, vlc_tab, 8, 2); - - if (code >= cb_size) { - err_idx = code; - goto err_cb_overflow; - } - cb_idx = cb_vector_idx[code]; nnz = cb_idx >> 8 & 15; sign = SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12); @@ -1163,11 +1137,6 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], continue; } - if (code >= cb_size) { - err_idx = code; - goto err_cb_overflow; - } - cb_idx = cb_vector_idx[code]; nnz = cb_idx >> 12; nzt = cb_idx >> 8; @@ -1236,12 +1205,6 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024], } } return 0; - -err_cb_overflow: - av_log(ac->avctx, AV_LOG_ERROR, - "Read beyond end of ff_aac_codebook_vectors[%d][]. index %d >= %d\n", - band_type[idx], err_idx, ff_aac_spectral_sizes[band_type[idx]]); - return -1; } static av_always_inline float flt16_round(float pf) @@ -1288,9 +1251,9 @@ static av_always_inline void predict(AACContext *ac, PredictorState *ps, float * e1 = e0 - k1 * ps->r0; ps->cor1 = flt16_trunc(alpha * ps->cor1 + ps->r1 * e1); - ps->var1 = flt16_trunc(alpha * ps->var1 + 0.5 * (ps->r1 * ps->r1 + e1 * e1)); + ps->var1 = flt16_trunc(alpha * ps->var1 + 0.5f * (ps->r1 * ps->r1 + e1 * e1)); ps->cor0 = flt16_trunc(alpha * ps->cor0 + ps->r0 * e0); - ps->var0 = flt16_trunc(alpha * ps->var0 + 0.5 * (ps->r0 * ps->r0 + e0 * e0)); + ps->var0 = flt16_trunc(alpha * ps->var0 + 0.5f * (ps->r0 * ps->r0 + e0 * e0)); ps->r1 = flt16_trunc(a * (ps->r0 - k1 * e0)); ps->r0 = flt16_trunc(a * e0); @@ -1453,8 +1416,6 @@ static void apply_intensity_stereo(ChannelElement *cpe, int ms_present) /** * Decode a channel_pair_element; reference: table 4.4. * - * @param elem_id Identifies the instance of a syntax element. - * * @return Returns error status. 0 - OK, !0 - error */ static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe) @@ -1493,11 +1454,16 @@ static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe) return 0; } +static const float cce_scale[] = { + 1.09050773266525765921, //2^(1/8) + 1.18920711500272106672, //2^(1/4) + M_SQRT2, + 2, +}; + /** * Decode coupling_channel_element; reference: table 4.8. * - * @param elem_id Identifies the instance of a syntax element. - * * @return Returns error status. 0 - OK, !0 - error */ static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che) @@ -1525,7 +1491,7 @@ static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che) coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1); sign = get_bits(gb, 1); - scale = pow(2., pow(2., (int)get_bits(gb, 2) - 3)); + scale = cce_scale[get_bits(gb, 2)]; if ((ret = decode_ics(ac, sce, gb, 0, 0))) return ret; @@ -1538,7 +1504,7 @@ static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che) if (c) { cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb); gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0; - gain_cache = pow(scale, -gain); + gain_cache = powf(scale, -gain); } if (coup->coupling_point == AFTER_IMDCT) { coup->gain[c][0] = gain_cache; @@ -1555,7 +1521,7 @@ static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che) s -= 2 * (t & 0x1); t >>= 1; } - gain_cache = pow(scale, -t) * s; + gain_cache = powf(scale, -t) * s; } } coup->gain[c][idx] = gain_cache; @@ -1667,6 +1633,10 @@ static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt, av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n"); skip_bits_long(gb, 8 * cnt - 4); return res; + } else if (ac->m4ac.ps == -1 && ac->output_configured < OC_LOCKED && ac->avctx->channels == 1) { + ac->m4ac.sbr = 1; + ac->m4ac.ps = 1; + output_configure(ac, ac->che_pos, ac->che_pos, ac->m4ac.chan_config, ac->output_configured); } else { ac->m4ac.sbr = 1; } @@ -1749,10 +1719,6 @@ static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce, float // imdct if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { - if (ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) - av_log(ac->avctx, AV_LOG_WARNING, - "Transition from an ONLY_LONG or LONG_STOP to an EIGHT_SHORT sequence detected. " - "If you heard an audible artifact, please submit the sample to the FFmpeg developers.\n"); for (i = 0; i < 1024; i += 128) ff_imdct_half(&ac->mdct_small, buf + i, in + i); } else @@ -1860,7 +1826,6 @@ static void apply_independent_coupling(AACContext *ac, /** * channel coupling transformation interface * - * @param index index into coupling gain array * @param apply_coupling_method pointer to (in)dependent coupling function */ static void apply_channel_coupling(AACContext *ac, ChannelElement *cc, @@ -1946,8 +1911,10 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) } else if (ac->output_configured != OC_LOCKED) { ac->output_configured = OC_NONE; } - if (ac->output_configured != OC_LOCKED) + if (ac->output_configured != OC_LOCKED) { ac->m4ac.sbr = -1; + ac->m4ac.ps = -1; + } ac->m4ac.sample_rate = hdr_info.sample_rate; ac->m4ac.sampling_index = hdr_info.sampling_index; ac->m4ac.object_type = hdr_info.object_type; @@ -1975,7 +1942,7 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data, enum RawDataBlockType elem_type, elem_type_prev = TYPE_END; int err, elem_id, data_size_tmp; int buf_consumed; - int samples = 1024, multiplier; + int samples = 0, multiplier; int buf_offset; init_get_bits(&gb, buf, buf_size * 8); @@ -1996,9 +1963,13 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data, while ((elem_type = get_bits(&gb, 3)) != TYPE_END) { elem_id = get_bits(&gb, 4); - if (elem_type < TYPE_DSE && !(che=get_che(ac, elem_type, elem_id))) { - av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", elem_type, elem_id); - return -1; + if (elem_type < TYPE_DSE) { + if (!(che=get_che(ac, elem_type, elem_id))) { + av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", + elem_type, elem_id); + return -1; + } + samples = 1024; } switch (elem_type) { @@ -2083,7 +2054,8 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data, } *data_size = data_size_tmp; - ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avctx->channels); + if (samples) + ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avctx->channels); if (ac->output_configured) ac->output_configured = OC_LOCKED; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacenc.c index 219a4c1e3..f122fe11a 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacenc.c @@ -41,6 +41,8 @@ #include "psymodel.h" +#define AAC_MAX_CHANNELS 6 + static const uint8_t swb_size_1024_96[] = { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 16, 16, 24, 28, 36, 44, @@ -166,7 +168,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n", avctx->sample_rate); return -1; } - if (avctx->channels > 6) { + if (avctx->channels > AAC_MAX_CHANNELS) { av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %d\n", avctx->channels); return -1; } @@ -191,7 +193,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) s->samples = av_malloc(2 * 1024 * avctx->channels * sizeof(s->samples[0])); s->cpe = av_mallocz(sizeof(ChannelElement) * aac_chan_configs[avctx->channels-1][0]); - avctx->extradata = av_malloc(2); + avctx->extradata = av_mallocz(2 + FF_INPUT_BUFFER_PADDING_SIZE); avctx->extradata_size = 2; put_audio_specific_config(avctx); @@ -204,14 +206,8 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) s->coder = &ff_aac_coders[2]; s->lambda = avctx->global_quality ? avctx->global_quality : 120; -#if !CONFIG_HARDCODED_TABLES - for (i = 0; i < 428; i++) - ff_aac_pow2sf_tab[i] = pow(2, (i - 200)/4.); -#endif /* CONFIG_HARDCODED_TABLES */ - if (avctx->channels > 5) - av_log(avctx, AV_LOG_ERROR, "This encoder does not yet enforce the restrictions on LFEs. " - "The output will most likely be an illegal bitstream.\n"); + ff_aac_tableinit(); return 0; } @@ -488,7 +484,7 @@ static int aac_encode_frame(AVCodecContext *avctx, int i, j, chans, tag, start_ch; const uint8_t *chan_map = aac_chan_configs[avctx->channels-1]; int chan_el_counter[4]; - FFPsyWindowInfo windows[avctx->channels]; + FFPsyWindowInfo windows[AAC_MAX_CHANNELS]; if (s->last_frame) return 0; @@ -521,20 +517,28 @@ static int aac_encode_frame(AVCodecContext *avctx, chans = tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; samples2 = samples + start_ch; - la = samples2 + 1024 * avctx->channels + start_ch; + la = samples2 + (448+64) * avctx->channels + start_ch; if (!data) la = NULL; for (j = 0; j < chans; j++) { IndividualChannelStream *ics = &cpe->ch[j].ics; int k; - wi[j] = ff_psy_suggest_window(&s->psy, samples2, la, start_ch + j, ics->window_sequence[0]); + if (tag == TYPE_LFE) { + wi[j].window_type[0] = ONLY_LONG_SEQUENCE; + wi[j].window_shape = 0; + wi[j].num_windows = 1; + wi[j].grouping[0] = 1; + } else { + wi[j] = ff_psy_suggest_window(&s->psy, samples2, la, start_ch + j, + ics->window_sequence[0]); + } ics->window_sequence[1] = ics->window_sequence[0]; ics->window_sequence[0] = wi[j].window_type[0]; ics->use_kb_window[1] = ics->use_kb_window[0]; ics->use_kb_window[0] = wi[j].window_shape; ics->num_windows = wi[j].num_windows; ics->swb_sizes = s->psy.bands [ics->num_windows == 8]; - ics->num_swb = s->psy.num_bands[ics->num_windows == 8]; + ics->num_swb = tag == TYPE_LFE ? 12 : s->psy.num_bands[ics->num_windows == 8]; for (k = 0; k < ics->num_windows; k++) ics->group_len[k] = wi[j].grouping[k]; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacps.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacps.c new file mode 100644 index 000000000..fc124d197 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacps.c @@ -0,0 +1,1037 @@ +/* + * MPEG-4 Parametric Stereo decoding functions + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "libavutil/common.h" +#include "libavutil/mathematics.h" +#include "avcodec.h" +#include "get_bits.h" +#include "aacps.h" +#include "aacps_tablegen.h" +#include "aacpsdata.c" + +#define PS_BASELINE 0 //< Operate in Baseline PS mode + //< Baseline implies 10 or 20 stereo bands, + //< mixing mode A, and no ipd/opd + +#define numQMFSlots 32 //numTimeSlots * RATE + +static const int8_t num_env_tab[2][4] = { + { 0, 1, 2, 4, }, + { 1, 2, 3, 4, }, +}; + +static const int8_t nr_iidicc_par_tab[] = { + 10, 20, 34, 10, 20, 34, +}; + +static const int8_t nr_iidopd_par_tab[] = { + 5, 11, 17, 5, 11, 17, +}; + +enum { + huff_iid_df1, + huff_iid_dt1, + huff_iid_df0, + huff_iid_dt0, + huff_icc_df, + huff_icc_dt, + huff_ipd_df, + huff_ipd_dt, + huff_opd_df, + huff_opd_dt, +}; + +static const int huff_iid[] = { + huff_iid_df0, + huff_iid_df1, + huff_iid_dt0, + huff_iid_dt1, +}; + +static VLC vlc_ps[10]; + +/** + * Read Inter-channel Intensity Difference/Inter-Channel Coherence/ + * Inter-channel Phase Difference/Overall Phase Difference parameters from the + * bitstream. + * + * @param avctx contains the current codec context + * @param gb pointer to the input bitstream + * @param ps pointer to the Parametric Stereo context + * @param par pointer to the parameter to be read + * @param e envelope to decode + * @param dt 1: time delta-coded, 0: frequency delta-coded + */ +#define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION) \ +static int read_ ## PAR ## _data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, \ + int8_t (*PAR)[PS_MAX_NR_IIDICC], int table_idx, int e, int dt) \ +{ \ + int b, num = ps->nr_ ## PAR ## _par; \ + VLC_TYPE (*vlc_table)[2] = vlc_ps[table_idx].table; \ + if (dt) { \ + int e_prev = e ? e - 1 : ps->num_env_old - 1; \ + e_prev = FFMAX(e_prev, 0); \ + for (b = 0; b < num; b++) { \ + int val = PAR[e_prev][b] + get_vlc2(gb, vlc_table, 9, 3) - OFFSET; \ + if (MASK) val &= MASK; \ + PAR[e][b] = val; \ + if (ERR_CONDITION) \ + goto err; \ + } \ + } else { \ + int val = 0; \ + for (b = 0; b < num; b++) { \ + val += get_vlc2(gb, vlc_table, 9, 3) - OFFSET; \ + if (MASK) val &= MASK; \ + PAR[e][b] = val; \ + if (ERR_CONDITION) \ + goto err; \ + } \ + } \ + return 0; \ +err: \ + av_log(avctx, AV_LOG_ERROR, "illegal "#PAR"\n"); \ + return -1; \ +} + +READ_PAR_DATA(iid, huff_offset[table_idx], 0, FFABS(ps->iid_par[e][b]) > 7 + 8 * ps->iid_quant) +READ_PAR_DATA(icc, huff_offset[table_idx], 0, ps->icc_par[e][b] > 7U) +READ_PAR_DATA(ipdopd, 0, 0x07, 0) + +static int ps_read_extension_data(GetBitContext *gb, PSContext *ps, int ps_extension_id) +{ + int e; + int count = get_bits_count(gb); + + if (ps_extension_id) + return 0; + + ps->enable_ipdopd = get_bits1(gb); + if (ps->enable_ipdopd) { + for (e = 0; e < ps->num_env; e++) { + int dt = get_bits1(gb); + read_ipdopd_data(NULL, gb, ps, ps->ipd_par, dt ? huff_ipd_dt : huff_ipd_df, e, dt); + dt = get_bits1(gb); + read_ipdopd_data(NULL, gb, ps, ps->opd_par, dt ? huff_opd_dt : huff_opd_df, e, dt); + } + } + skip_bits1(gb); //reserved_ps + return get_bits_count(gb) - count; +} + +static void ipdopd_reset(int8_t *opd_hist, int8_t *ipd_hist) +{ + int i; + for (i = 0; i < PS_MAX_NR_IPDOPD; i++) { + opd_hist[i] = 0; + ipd_hist[i] = 0; + } +} + +int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left) +{ + int e; + int bit_count_start = get_bits_count(gb_host); + int header; + int bits_consumed; + GetBitContext gbc = *gb_host, *gb = &gbc; + + header = get_bits1(gb); + if (header) { //enable_ps_header + ps->enable_iid = get_bits1(gb); + if (ps->enable_iid) { + int iid_mode = get_bits(gb, 3); + if (iid_mode > 5) { + av_log(avctx, AV_LOG_ERROR, "iid_mode %d is reserved.\n", + iid_mode); + goto err; + } + ps->nr_iid_par = nr_iidicc_par_tab[iid_mode]; + ps->iid_quant = iid_mode > 2; + ps->nr_ipdopd_par = nr_iidopd_par_tab[iid_mode]; + } + ps->enable_icc = get_bits1(gb); + if (ps->enable_icc) { + ps->icc_mode = get_bits(gb, 3); + if (ps->icc_mode > 5) { + av_log(avctx, AV_LOG_ERROR, "icc_mode %d is reserved.\n", + ps->icc_mode); + goto err; + } + ps->nr_icc_par = nr_iidicc_par_tab[ps->icc_mode]; + } + ps->enable_ext = get_bits1(gb); + } + + ps->frame_class = get_bits1(gb); + ps->num_env_old = ps->num_env; + ps->num_env = num_env_tab[ps->frame_class][get_bits(gb, 2)]; + + ps->border_position[0] = -1; + if (ps->frame_class) { + for (e = 1; e <= ps->num_env; e++) + ps->border_position[e] = get_bits(gb, 5); + } else + for (e = 1; e <= ps->num_env; e++) + ps->border_position[e] = (e * numQMFSlots >> ff_log2_tab[ps->num_env]) - 1; + + if (ps->enable_iid) { + for (e = 0; e < ps->num_env; e++) { + int dt = get_bits1(gb); + if (read_iid_data(avctx, gb, ps, ps->iid_par, huff_iid[2*dt+ps->iid_quant], e, dt)) + goto err; + } + } else + memset(ps->iid_par, 0, sizeof(ps->iid_par)); + + if (ps->enable_icc) + for (e = 0; e < ps->num_env; e++) { + int dt = get_bits1(gb); + if (read_icc_data(avctx, gb, ps, ps->icc_par, dt ? huff_icc_dt : huff_icc_df, e, dt)) + goto err; + } + else + memset(ps->icc_par, 0, sizeof(ps->icc_par)); + + if (ps->enable_ext) { + int cnt = get_bits(gb, 4); + if (cnt == 15) { + cnt += get_bits(gb, 8); + } + cnt *= 8; + while (cnt > 7) { + int ps_extension_id = get_bits(gb, 2); + cnt -= 2 + ps_read_extension_data(gb, ps, ps_extension_id); + } + if (cnt < 0) { + av_log(avctx, AV_LOG_ERROR, "ps extension overflow %d", cnt); + goto err; + } + skip_bits(gb, cnt); + } + + ps->enable_ipdopd &= !PS_BASELINE; + + //Fix up envelopes + if (!ps->num_env || ps->border_position[ps->num_env] < numQMFSlots - 1) { + //Create a fake envelope + int source = ps->num_env ? ps->num_env - 1 : ps->num_env_old - 1; + if (source >= 0 && source != ps->num_env) { + if (ps->enable_iid) { + memcpy(ps->iid_par+ps->num_env, ps->iid_par+source, sizeof(ps->iid_par[0])); + } + if (ps->enable_icc) { + memcpy(ps->icc_par+ps->num_env, ps->icc_par+source, sizeof(ps->icc_par[0])); + } + if (ps->enable_ipdopd) { + memcpy(ps->ipd_par+ps->num_env, ps->ipd_par+source, sizeof(ps->ipd_par[0])); + memcpy(ps->opd_par+ps->num_env, ps->opd_par+source, sizeof(ps->opd_par[0])); + } + } + ps->num_env++; + ps->border_position[ps->num_env] = numQMFSlots - 1; + } + + + ps->is34bands_old = ps->is34bands; + if (!PS_BASELINE && (ps->enable_iid || ps->enable_icc)) + ps->is34bands = (ps->enable_iid && ps->nr_iid_par == 34) || + (ps->enable_icc && ps->nr_icc_par == 34); + + //Baseline + if (!ps->enable_ipdopd) { + memset(ps->ipd_par, 0, sizeof(ps->ipd_par)); + memset(ps->opd_par, 0, sizeof(ps->opd_par)); + } + + if (header) + ps->start = 1; + + bits_consumed = get_bits_count(gb) - bit_count_start; + if (bits_consumed <= bits_left) { + skip_bits_long(gb_host, bits_consumed); + return bits_consumed; + } + av_log(avctx, AV_LOG_ERROR, "Expected to read %d PS bits actually read %d.\n", bits_left, bits_consumed); +err: + ps->start = 0; + skip_bits_long(gb_host, bits_left); + return bits_left; +} + +/** Split one subband into 2 subsubbands with a symmetric real filter. + * The filter must have its non-center even coefficients equal to zero. */ +static void hybrid2_re(float (*in)[2], float (*out)[32][2], const float filter[7], int len, int reverse) +{ + int i, j; + for (i = 0; i < len; i++, in++) { + float re_in = filter[6] * in[6][0]; //real inphase + float re_op = 0.0f; //real out of phase + float im_in = filter[6] * in[6][1]; //imag inphase + float im_op = 0.0f; //imag out of phase + for (j = 0; j < 6; j += 2) { + re_op += filter[j+1] * (in[j+1][0] + in[12-j-1][0]); + im_op += filter[j+1] * (in[j+1][1] + in[12-j-1][1]); + } + out[ reverse][i][0] = re_in + re_op; + out[ reverse][i][1] = im_in + im_op; + out[!reverse][i][0] = re_in - re_op; + out[!reverse][i][1] = im_in - im_op; + } +} + +/** Split one subband into 6 subsubbands with a complex filter */ +static void hybrid6_cx(float (*in)[2], float (*out)[32][2], const float (*filter)[7][2], int len) +{ + int i, j, ssb; + int N = 8; + float temp[8][2]; + + for (i = 0; i < len; i++, in++) { + for (ssb = 0; ssb < N; ssb++) { + float sum_re = filter[ssb][6][0] * in[6][0], sum_im = filter[ssb][6][0] * in[6][1]; + for (j = 0; j < 6; j++) { + float in0_re = in[j][0]; + float in0_im = in[j][1]; + float in1_re = in[12-j][0]; + float in1_im = in[12-j][1]; + sum_re += filter[ssb][j][0] * (in0_re + in1_re) - filter[ssb][j][1] * (in0_im - in1_im); + sum_im += filter[ssb][j][0] * (in0_im + in1_im) + filter[ssb][j][1] * (in0_re - in1_re); + } + temp[ssb][0] = sum_re; + temp[ssb][1] = sum_im; + } + out[0][i][0] = temp[6][0]; + out[0][i][1] = temp[6][1]; + out[1][i][0] = temp[7][0]; + out[1][i][1] = temp[7][1]; + out[2][i][0] = temp[0][0]; + out[2][i][1] = temp[0][1]; + out[3][i][0] = temp[1][0]; + out[3][i][1] = temp[1][1]; + out[4][i][0] = temp[2][0] + temp[5][0]; + out[4][i][1] = temp[2][1] + temp[5][1]; + out[5][i][0] = temp[3][0] + temp[4][0]; + out[5][i][1] = temp[3][1] + temp[4][1]; + } +} + +static void hybrid4_8_12_cx(float (*in)[2], float (*out)[32][2], const float (*filter)[7][2], int N, int len) +{ + int i, j, ssb; + + for (i = 0; i < len; i++, in++) { + for (ssb = 0; ssb < N; ssb++) { + float sum_re = filter[ssb][6][0] * in[6][0], sum_im = filter[ssb][6][0] * in[6][1]; + for (j = 0; j < 6; j++) { + float in0_re = in[j][0]; + float in0_im = in[j][1]; + float in1_re = in[12-j][0]; + float in1_im = in[12-j][1]; + sum_re += filter[ssb][j][0] * (in0_re + in1_re) - filter[ssb][j][1] * (in0_im - in1_im); + sum_im += filter[ssb][j][0] * (in0_im + in1_im) + filter[ssb][j][1] * (in0_re - in1_re); + } + out[ssb][i][0] = sum_re; + out[ssb][i][1] = sum_im; + } + } +} + +static void hybrid_analysis(float out[91][32][2], float in[5][44][2], float L[2][38][64], int is34, int len) +{ + int i, j; + for (i = 0; i < 5; i++) { + for (j = 0; j < 38; j++) { + in[i][j+6][0] = L[0][j][i]; + in[i][j+6][1] = L[1][j][i]; + } + } + if (is34) { + hybrid4_8_12_cx(in[0], out, f34_0_12, 12, len); + hybrid4_8_12_cx(in[1], out+12, f34_1_8, 8, len); + hybrid4_8_12_cx(in[2], out+20, f34_2_4, 4, len); + hybrid4_8_12_cx(in[3], out+24, f34_2_4, 4, len); + hybrid4_8_12_cx(in[4], out+28, f34_2_4, 4, len); + for (i = 0; i < 59; i++) { + for (j = 0; j < len; j++) { + out[i+32][j][0] = L[0][j][i+5]; + out[i+32][j][1] = L[1][j][i+5]; + } + } + } else { + hybrid6_cx(in[0], out, f20_0_8, len); + hybrid2_re(in[1], out+6, g1_Q2, len, 1); + hybrid2_re(in[2], out+8, g1_Q2, len, 0); + for (i = 0; i < 61; i++) { + for (j = 0; j < len; j++) { + out[i+10][j][0] = L[0][j][i+3]; + out[i+10][j][1] = L[1][j][i+3]; + } + } + } + //update in_buf + for (i = 0; i < 5; i++) { + memcpy(in[i], in[i]+32, 6 * sizeof(in[i][0])); + } +} + +static void hybrid_synthesis(float out[2][38][64], float in[91][32][2], int is34, int len) +{ + int i, n; + if (is34) { + for (n = 0; n < len; n++) { + memset(out[0][n], 0, 5*sizeof(out[0][n][0])); + memset(out[1][n], 0, 5*sizeof(out[1][n][0])); + for (i = 0; i < 12; i++) { + out[0][n][0] += in[ i][n][0]; + out[1][n][0] += in[ i][n][1]; + } + for (i = 0; i < 8; i++) { + out[0][n][1] += in[12+i][n][0]; + out[1][n][1] += in[12+i][n][1]; + } + for (i = 0; i < 4; i++) { + out[0][n][2] += in[20+i][n][0]; + out[1][n][2] += in[20+i][n][1]; + out[0][n][3] += in[24+i][n][0]; + out[1][n][3] += in[24+i][n][1]; + out[0][n][4] += in[28+i][n][0]; + out[1][n][4] += in[28+i][n][1]; + } + } + for (i = 0; i < 59; i++) { + for (n = 0; n < len; n++) { + out[0][n][i+5] = in[i+32][n][0]; + out[1][n][i+5] = in[i+32][n][1]; + } + } + } else { + for (n = 0; n < len; n++) { + out[0][n][0] = in[0][n][0] + in[1][n][0] + in[2][n][0] + + in[3][n][0] + in[4][n][0] + in[5][n][0]; + out[1][n][0] = in[0][n][1] + in[1][n][1] + in[2][n][1] + + in[3][n][1] + in[4][n][1] + in[5][n][1]; + out[0][n][1] = in[6][n][0] + in[7][n][0]; + out[1][n][1] = in[6][n][1] + in[7][n][1]; + out[0][n][2] = in[8][n][0] + in[9][n][0]; + out[1][n][2] = in[8][n][1] + in[9][n][1]; + } + for (i = 0; i < 61; i++) { + for (n = 0; n < len; n++) { + out[0][n][i+3] = in[i+10][n][0]; + out[1][n][i+3] = in[i+10][n][1]; + } + } + } +} + +/// All-pass filter decay slope +#define DECAY_SLOPE 0.05f +/// Number of frequency bands that can be addressed by the parameter index, b(k) +static const int NR_PAR_BANDS[] = { 20, 34 }; +/// Number of frequency bands that can be addressed by the sub subband index, k +static const int NR_BANDS[] = { 71, 91 }; +/// Start frequency band for the all-pass filter decay slope +static const int DECAY_CUTOFF[] = { 10, 32 }; +/// Number of all-pass filer bands +static const int NR_ALLPASS_BANDS[] = { 30, 50 }; +/// First stereo band using the short one sample delay +static const int SHORT_DELAY_BAND[] = { 42, 62 }; + +/** Table 8.46 */ +static void map_idx_10_to_20(int8_t *par_mapped, const int8_t *par, int full) +{ + int b; + if (full) + b = 9; + else { + b = 4; + par_mapped[10] = 0; + } + for (; b >= 0; b--) { + par_mapped[2*b+1] = par_mapped[2*b] = par[b]; + } +} + +static void map_idx_34_to_20(int8_t *par_mapped, const int8_t *par, int full) +{ + par_mapped[ 0] = (2*par[ 0] + par[ 1]) / 3; + par_mapped[ 1] = ( par[ 1] + 2*par[ 2]) / 3; + par_mapped[ 2] = (2*par[ 3] + par[ 4]) / 3; + par_mapped[ 3] = ( par[ 4] + 2*par[ 5]) / 3; + par_mapped[ 4] = ( par[ 6] + par[ 7]) / 2; + par_mapped[ 5] = ( par[ 8] + par[ 9]) / 2; + par_mapped[ 6] = par[10]; + par_mapped[ 7] = par[11]; + par_mapped[ 8] = ( par[12] + par[13]) / 2; + par_mapped[ 9] = ( par[14] + par[15]) / 2; + par_mapped[10] = par[16]; + if (full) { + par_mapped[11] = par[17]; + par_mapped[12] = par[18]; + par_mapped[13] = par[19]; + par_mapped[14] = ( par[20] + par[21]) / 2; + par_mapped[15] = ( par[22] + par[23]) / 2; + par_mapped[16] = ( par[24] + par[25]) / 2; + par_mapped[17] = ( par[26] + par[27]) / 2; + par_mapped[18] = ( par[28] + par[29] + par[30] + par[31]) / 4; + par_mapped[19] = ( par[32] + par[33]) / 2; + } +} + +static void map_val_34_to_20(float par[PS_MAX_NR_IIDICC]) +{ + par[ 0] = (2*par[ 0] + par[ 1]) * 0.33333333f; + par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333f; + par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333f; + par[ 3] = ( par[ 4] + 2*par[ 5]) * 0.33333333f; + par[ 4] = ( par[ 6] + par[ 7]) * 0.5f; + par[ 5] = ( par[ 8] + par[ 9]) * 0.5f; + par[ 6] = par[10]; + par[ 7] = par[11]; + par[ 8] = ( par[12] + par[13]) * 0.5f; + par[ 9] = ( par[14] + par[15]) * 0.5f; + par[10] = par[16]; + par[11] = par[17]; + par[12] = par[18]; + par[13] = par[19]; + par[14] = ( par[20] + par[21]) * 0.5f; + par[15] = ( par[22] + par[23]) * 0.5f; + par[16] = ( par[24] + par[25]) * 0.5f; + par[17] = ( par[26] + par[27]) * 0.5f; + par[18] = ( par[28] + par[29] + par[30] + par[31]) * 0.25f; + par[19] = ( par[32] + par[33]) * 0.5f; +} + +static void map_idx_10_to_34(int8_t *par_mapped, const int8_t *par, int full) +{ + if (full) { + par_mapped[33] = par[9]; + par_mapped[32] = par[9]; + par_mapped[31] = par[9]; + par_mapped[30] = par[9]; + par_mapped[29] = par[9]; + par_mapped[28] = par[9]; + par_mapped[27] = par[8]; + par_mapped[26] = par[8]; + par_mapped[25] = par[8]; + par_mapped[24] = par[8]; + par_mapped[23] = par[7]; + par_mapped[22] = par[7]; + par_mapped[21] = par[7]; + par_mapped[20] = par[7]; + par_mapped[19] = par[6]; + par_mapped[18] = par[6]; + par_mapped[17] = par[5]; + par_mapped[16] = par[5]; + } else { + par_mapped[16] = 0; + } + par_mapped[15] = par[4]; + par_mapped[14] = par[4]; + par_mapped[13] = par[4]; + par_mapped[12] = par[4]; + par_mapped[11] = par[3]; + par_mapped[10] = par[3]; + par_mapped[ 9] = par[2]; + par_mapped[ 8] = par[2]; + par_mapped[ 7] = par[2]; + par_mapped[ 6] = par[2]; + par_mapped[ 5] = par[1]; + par_mapped[ 4] = par[1]; + par_mapped[ 3] = par[1]; + par_mapped[ 2] = par[0]; + par_mapped[ 1] = par[0]; + par_mapped[ 0] = par[0]; +} + +static void map_idx_20_to_34(int8_t *par_mapped, const int8_t *par, int full) +{ + if (full) { + par_mapped[33] = par[19]; + par_mapped[32] = par[19]; + par_mapped[31] = par[18]; + par_mapped[30] = par[18]; + par_mapped[29] = par[18]; + par_mapped[28] = par[18]; + par_mapped[27] = par[17]; + par_mapped[26] = par[17]; + par_mapped[25] = par[16]; + par_mapped[24] = par[16]; + par_mapped[23] = par[15]; + par_mapped[22] = par[15]; + par_mapped[21] = par[14]; + par_mapped[20] = par[14]; + par_mapped[19] = par[13]; + par_mapped[18] = par[12]; + par_mapped[17] = par[11]; + } + par_mapped[16] = par[10]; + par_mapped[15] = par[ 9]; + par_mapped[14] = par[ 9]; + par_mapped[13] = par[ 8]; + par_mapped[12] = par[ 8]; + par_mapped[11] = par[ 7]; + par_mapped[10] = par[ 6]; + par_mapped[ 9] = par[ 5]; + par_mapped[ 8] = par[ 5]; + par_mapped[ 7] = par[ 4]; + par_mapped[ 6] = par[ 4]; + par_mapped[ 5] = par[ 3]; + par_mapped[ 4] = (par[ 2] + par[ 3]) / 2; + par_mapped[ 3] = par[ 2]; + par_mapped[ 2] = par[ 1]; + par_mapped[ 1] = (par[ 0] + par[ 1]) / 2; + par_mapped[ 0] = par[ 0]; +} + +static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC]) +{ + par[33] = par[19]; + par[32] = par[19]; + par[31] = par[18]; + par[30] = par[18]; + par[29] = par[18]; + par[28] = par[18]; + par[27] = par[17]; + par[26] = par[17]; + par[25] = par[16]; + par[24] = par[16]; + par[23] = par[15]; + par[22] = par[15]; + par[21] = par[14]; + par[20] = par[14]; + par[19] = par[13]; + par[18] = par[12]; + par[17] = par[11]; + par[16] = par[10]; + par[15] = par[ 9]; + par[14] = par[ 9]; + par[13] = par[ 8]; + par[12] = par[ 8]; + par[11] = par[ 7]; + par[10] = par[ 6]; + par[ 9] = par[ 5]; + par[ 8] = par[ 5]; + par[ 7] = par[ 4]; + par[ 6] = par[ 4]; + par[ 5] = par[ 3]; + par[ 4] = (par[ 2] + par[ 3]) * 0.5f; + par[ 3] = par[ 2]; + par[ 2] = par[ 1]; + par[ 1] = (par[ 0] + par[ 1]) * 0.5f; + par[ 0] = par[ 0]; +} + +static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[32][2], int is34) +{ + float power[34][PS_QMF_TIME_SLOTS] = {{0}}; + float transient_gain[34][PS_QMF_TIME_SLOTS]; + float *peak_decay_nrg = ps->peak_decay_nrg; + float *power_smooth = ps->power_smooth; + float *peak_decay_diff_smooth = ps->peak_decay_diff_smooth; + float (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay; + float (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay; + const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; + const float peak_decay_factor = 0.76592833836465f; + const float transient_impact = 1.5f; + const float a_smooth = 0.25f; //< Smoothing coefficient + int i, k, m, n; + int n0 = 0, nL = 32; + static const int link_delay[] = { 3, 4, 5 }; + static const float a[] = { 0.65143905753106f, + 0.56471812200776f, + 0.48954165955695f }; + + if (is34 != ps->is34bands_old) { + memset(ps->peak_decay_nrg, 0, sizeof(ps->peak_decay_nrg)); + memset(ps->power_smooth, 0, sizeof(ps->power_smooth)); + memset(ps->peak_decay_diff_smooth, 0, sizeof(ps->peak_decay_diff_smooth)); + memset(ps->delay, 0, sizeof(ps->delay)); + memset(ps->ap_delay, 0, sizeof(ps->ap_delay)); + } + + for (n = n0; n < nL; n++) { + for (k = 0; k < NR_BANDS[is34]; k++) { + int i = k_to_i[k]; + power[i][n] += s[k][n][0] * s[k][n][0] + s[k][n][1] * s[k][n][1]; + } + } + + //Transient detection + for (i = 0; i < NR_PAR_BANDS[is34]; i++) { + for (n = n0; n < nL; n++) { + float decayed_peak = peak_decay_factor * peak_decay_nrg[i]; + float denom; + peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]); + power_smooth[i] += a_smooth * (power[i][n] - power_smooth[i]); + peak_decay_diff_smooth[i] += a_smooth * (peak_decay_nrg[i] - power[i][n] - peak_decay_diff_smooth[i]); + denom = transient_impact * peak_decay_diff_smooth[i]; + transient_gain[i][n] = (denom > power_smooth[i]) ? + power_smooth[i] / denom : 1.0f; + } + } + + //Decorrelation and transient reduction + // PS_AP_LINKS - 1 + // ----- + // | | Q_fract_allpass[k][m]*z^-link_delay[m] - a[m]*g_decay_slope[k] + //H[k][z] = z^-2 * phi_fract[k] * | | ---------------------------------------------------------------- + // | | 1 - a[m]*g_decay_slope[k]*Q_fract_allpass[k][m]*z^-link_delay[m] + // m = 0 + //d[k][z] (out) = transient_gain_mapped[k][z] * H[k][z] * s[k][z] + for (k = 0; k < NR_ALLPASS_BANDS[is34]; k++) { + int b = k_to_i[k]; + float g_decay_slope = 1.f - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]); + float ag[PS_AP_LINKS]; + g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f); + memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0])); + memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0])); + for (m = 0; m < PS_AP_LINKS; m++) { + memcpy(ap_delay[k][m], ap_delay[k][m]+numQMFSlots, 5*sizeof(ap_delay[k][m][0])); + ag[m] = a[m] * g_decay_slope; + } + for (n = n0; n < nL; n++) { + float in_re = delay[k][n+PS_MAX_DELAY-2][0] * phi_fract[is34][k][0] - + delay[k][n+PS_MAX_DELAY-2][1] * phi_fract[is34][k][1]; + float in_im = delay[k][n+PS_MAX_DELAY-2][0] * phi_fract[is34][k][1] + + delay[k][n+PS_MAX_DELAY-2][1] * phi_fract[is34][k][0]; + for (m = 0; m < PS_AP_LINKS; m++) { + float a_re = ag[m] * in_re; + float a_im = ag[m] * in_im; + float link_delay_re = ap_delay[k][m][n+5-link_delay[m]][0]; + float link_delay_im = ap_delay[k][m][n+5-link_delay[m]][1]; + float fractional_delay_re = Q_fract_allpass[is34][k][m][0]; + float fractional_delay_im = Q_fract_allpass[is34][k][m][1]; + ap_delay[k][m][n+5][0] = in_re; + ap_delay[k][m][n+5][1] = in_im; + in_re = link_delay_re * fractional_delay_re - link_delay_im * fractional_delay_im - a_re; + in_im = link_delay_re * fractional_delay_im + link_delay_im * fractional_delay_re - a_im; + ap_delay[k][m][n+5][0] += ag[m] * in_re; + ap_delay[k][m][n+5][1] += ag[m] * in_im; + } + out[k][n][0] = transient_gain[b][n] * in_re; + out[k][n][1] = transient_gain[b][n] * in_im; + } + } + for (; k < SHORT_DELAY_BAND[is34]; k++) { + memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0])); + memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0])); + for (n = n0; n < nL; n++) { + //H = delay 14 + out[k][n][0] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-14][0]; + out[k][n][1] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-14][1]; + } + } + for (; k < NR_BANDS[is34]; k++) { + memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0])); + memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0])); + for (n = n0; n < nL; n++) { + //H = delay 1 + out[k][n][0] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-1][0]; + out[k][n][1] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-1][1]; + } + } +} + +static void remap34(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC], + int8_t (*par)[PS_MAX_NR_IIDICC], + int num_par, int num_env, int full) +{ + int8_t (*par_mapped)[PS_MAX_NR_IIDICC] = *p_par_mapped; + int e; + if (num_par == 20 || num_par == 11) { + for (e = 0; e < num_env; e++) { + map_idx_20_to_34(par_mapped[e], par[e], full); + } + } else if (num_par == 10 || num_par == 5) { + for (e = 0; e < num_env; e++) { + map_idx_10_to_34(par_mapped[e], par[e], full); + } + } else { + *p_par_mapped = par; + } +} + +static void remap20(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC], + int8_t (*par)[PS_MAX_NR_IIDICC], + int num_par, int num_env, int full) +{ + int8_t (*par_mapped)[PS_MAX_NR_IIDICC] = *p_par_mapped; + int e; + if (num_par == 34 || num_par == 17) { + for (e = 0; e < num_env; e++) { + map_idx_34_to_20(par_mapped[e], par[e], full); + } + } else if (num_par == 10 || num_par == 5) { + for (e = 0; e < num_env; e++) { + map_idx_10_to_20(par_mapped[e], par[e], full); + } + } else { + *p_par_mapped = par; + } +} + +static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2], int is34) +{ + int e, b, k, n; + + float (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11; + float (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12; + float (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21; + float (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22; + int8_t *opd_hist = ps->opd_hist; + int8_t *ipd_hist = ps->ipd_hist; + int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; + int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf; + int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf; + int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf; + int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf; + const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20; + const float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB; + + //Remapping + memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0])); + memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0])); + memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0])); + memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0])); + memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0])); + memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0])); + memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0])); + memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0])); + if (is34) { + remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); + remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); + if (ps->enable_ipdopd) { + remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0); + remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0); + } + if (!ps->is34bands_old) { + map_val_20_to_34(H11[0][0]); + map_val_20_to_34(H11[1][0]); + map_val_20_to_34(H12[0][0]); + map_val_20_to_34(H12[1][0]); + map_val_20_to_34(H21[0][0]); + map_val_20_to_34(H21[1][0]); + map_val_20_to_34(H22[0][0]); + map_val_20_to_34(H22[1][0]); + ipdopd_reset(ipd_hist, opd_hist); + } + } else { + remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1); + remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1); + if (ps->enable_ipdopd) { + remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0); + remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0); + } + if (ps->is34bands_old) { + map_val_34_to_20(H11[0][0]); + map_val_34_to_20(H11[1][0]); + map_val_34_to_20(H12[0][0]); + map_val_34_to_20(H12[1][0]); + map_val_34_to_20(H21[0][0]); + map_val_34_to_20(H21[1][0]); + map_val_34_to_20(H22[0][0]); + map_val_34_to_20(H22[1][0]); + ipdopd_reset(ipd_hist, opd_hist); + } + } + + //Mixing + for (e = 0; e < ps->num_env; e++) { + for (b = 0; b < NR_PAR_BANDS[is34]; b++) { + float h11, h12, h21, h22; + h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0]; + h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1]; + h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2]; + h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3]; + if (!PS_BASELINE && ps->enable_ipdopd && b < ps->nr_ipdopd_par) { + //The spec say says to only run this smoother when enable_ipdopd + //is set but the reference decoder appears to run it constantly + float h11i, h12i, h21i, h22i; + float ipd_adj_re, ipd_adj_im; + int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b]; + int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b]; + float opd_re = pd_re_smooth[opd_idx]; + float opd_im = pd_im_smooth[opd_idx]; + float ipd_re = pd_re_smooth[ipd_idx]; + float ipd_im = pd_im_smooth[ipd_idx]; + opd_hist[b] = opd_idx & 0x3F; + ipd_hist[b] = ipd_idx & 0x3F; + + ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im; + ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im; + h11i = h11 * opd_im; + h11 = h11 * opd_re; + h12i = h12 * ipd_adj_im; + h12 = h12 * ipd_adj_re; + h21i = h21 * opd_im; + h21 = h21 * opd_re; + h22i = h22 * ipd_adj_im; + h22 = h22 * ipd_adj_re; + H11[1][e+1][b] = h11i; + H12[1][e+1][b] = h12i; + H21[1][e+1][b] = h21i; + H22[1][e+1][b] = h22i; + } + H11[0][e+1][b] = h11; + H12[0][e+1][b] = h12; + H21[0][e+1][b] = h21; + H22[0][e+1][b] = h22; + } + for (k = 0; k < NR_BANDS[is34]; k++) { + float h11r, h12r, h21r, h22r; + float h11i, h12i, h21i, h22i; + float h11r_step, h12r_step, h21r_step, h22r_step; + float h11i_step, h12i_step, h21i_step, h22i_step; + int start = ps->border_position[e]; + int stop = ps->border_position[e+1]; + float width = 1.f / (stop - start); + b = k_to_i[k]; + h11r = H11[0][e][b]; + h12r = H12[0][e][b]; + h21r = H21[0][e][b]; + h22r = H22[0][e][b]; + if (!PS_BASELINE && ps->enable_ipdopd) { + //Is this necessary? ps_04_new seems unchanged + if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) { + h11i = -H11[1][e][b]; + h12i = -H12[1][e][b]; + h21i = -H21[1][e][b]; + h22i = -H22[1][e][b]; + } else { + h11i = H11[1][e][b]; + h12i = H12[1][e][b]; + h21i = H21[1][e][b]; + h22i = H22[1][e][b]; + } + } + //Interpolation + h11r_step = (H11[0][e+1][b] - h11r) * width; + h12r_step = (H12[0][e+1][b] - h12r) * width; + h21r_step = (H21[0][e+1][b] - h21r) * width; + h22r_step = (H22[0][e+1][b] - h22r) * width; + if (!PS_BASELINE && ps->enable_ipdopd) { + h11i_step = (H11[1][e+1][b] - h11i) * width; + h12i_step = (H12[1][e+1][b] - h12i) * width; + h21i_step = (H21[1][e+1][b] - h21i) * width; + h22i_step = (H22[1][e+1][b] - h22i) * width; + } + for (n = start + 1; n <= stop; n++) { + //l is s, r is d + float l_re = l[k][n][0]; + float l_im = l[k][n][1]; + float r_re = r[k][n][0]; + float r_im = r[k][n][1]; + h11r += h11r_step; + h12r += h12r_step; + h21r += h21r_step; + h22r += h22r_step; + if (!PS_BASELINE && ps->enable_ipdopd) { + h11i += h11i_step; + h12i += h12i_step; + h21i += h21i_step; + h22i += h22i_step; + + l[k][n][0] = h11r*l_re + h21r*r_re - h11i*l_im - h21i*r_im; + l[k][n][1] = h11r*l_im + h21r*r_im + h11i*l_re + h21i*r_re; + r[k][n][0] = h12r*l_re + h22r*r_re - h12i*l_im - h22i*r_im; + r[k][n][1] = h12r*l_im + h22r*r_im + h12i*l_re + h22i*r_re; + } else { + l[k][n][0] = h11r*l_re + h21r*r_re; + l[k][n][1] = h11r*l_im + h21r*r_im; + r[k][n][0] = h12r*l_re + h22r*r_re; + r[k][n][1] = h12r*l_im + h22r*r_im; + } + } + } + } +} + +int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top) +{ + float Lbuf[91][32][2]; + float Rbuf[91][32][2]; + const int len = 32; + int is34 = ps->is34bands; + + top += NR_BANDS[is34] - 64; + memset(ps->delay+top, 0, (NR_BANDS[is34] - top)*sizeof(ps->delay[0])); + if (top < NR_ALLPASS_BANDS[is34]) + memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*sizeof(ps->ap_delay[0])); + + hybrid_analysis(Lbuf, ps->in_buf, L, is34, len); + decorrelation(ps, Rbuf, Lbuf, is34); + stereo_processing(ps, Lbuf, Rbuf, is34); + hybrid_synthesis(L, Lbuf, is34, len); + hybrid_synthesis(R, Rbuf, is34, len); + + return 0; +} + +#define PS_INIT_VLC_STATIC(num, size) \ + INIT_VLC_STATIC(&vlc_ps[num], 9, ps_tmp[num].table_size / ps_tmp[num].elem_size, \ + ps_tmp[num].ps_bits, 1, 1, \ + ps_tmp[num].ps_codes, ps_tmp[num].elem_size, ps_tmp[num].elem_size, \ + size); + +#define PS_VLC_ROW(name) \ + { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) } + +av_cold void ff_ps_init(void) { + // Syntax initialization + static const struct { + const void *ps_codes, *ps_bits; + const unsigned int table_size, elem_size; + } ps_tmp[] = { + PS_VLC_ROW(huff_iid_df1), + PS_VLC_ROW(huff_iid_dt1), + PS_VLC_ROW(huff_iid_df0), + PS_VLC_ROW(huff_iid_dt0), + PS_VLC_ROW(huff_icc_df), + PS_VLC_ROW(huff_icc_dt), + PS_VLC_ROW(huff_ipd_df), + PS_VLC_ROW(huff_ipd_dt), + PS_VLC_ROW(huff_opd_df), + PS_VLC_ROW(huff_opd_dt), + }; + + PS_INIT_VLC_STATIC(0, 1544); + PS_INIT_VLC_STATIC(1, 832); + PS_INIT_VLC_STATIC(2, 1024); + PS_INIT_VLC_STATIC(3, 1036); + PS_INIT_VLC_STATIC(4, 544); + PS_INIT_VLC_STATIC(5, 544); + PS_INIT_VLC_STATIC(6, 512); + PS_INIT_VLC_STATIC(7, 512); + PS_INIT_VLC_STATIC(8, 512); + PS_INIT_VLC_STATIC(9, 512); + + ps_tableinit(); +} + +av_cold void ff_ps_ctx_init(PSContext *ps) +{ +} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacps.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacps.h new file mode 100644 index 000000000..5fc211a98 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacps.h @@ -0,0 +1,82 @@ +/* + * MPEG-4 Parametric Stereo definitions and declarations + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_PS_H +#define AVCODEC_PS_H + +#include + +#include "avcodec.h" +#include "get_bits.h" + +#define PS_MAX_NUM_ENV 5 +#define PS_MAX_NR_IIDICC 34 +#define PS_MAX_NR_IPDOPD 17 +#define PS_MAX_SSB 91 +#define PS_MAX_AP_BANDS 50 +#define PS_QMF_TIME_SLOTS 32 +#define PS_MAX_DELAY 14 +#define PS_AP_LINKS 3 +#define PS_MAX_AP_DELAY 5 + +typedef struct { + int start; + int enable_iid; + int iid_quant; + int nr_iid_par; + int nr_ipdopd_par; + int enable_icc; + int icc_mode; + int nr_icc_par; + int enable_ext; + int frame_class; + int num_env_old; + int num_env; + int enable_ipdopd; + int border_position[PS_MAX_NUM_ENV+1]; + int8_t iid_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; // + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#define CONFIG_HARDCODED_TABLES 0 +#include "aacps_tablegen.h" +#include "tableprint.h" + +void write_float_3d_array (const void *p, int b, int c, int d) +{ + int i; + const float *f = p; + for (i = 0; i < b; i++) { + printf("{\n"); + write_float_2d_array(f, c, d); + printf("},\n"); + f += c * d; + } +} + +void write_float_4d_array (const void *p, int a, int b, int c, int d) +{ + int i; + const float *f = p; + for (i = 0; i < a; i++) { + printf("{\n"); + write_float_3d_array(f, b, c, d); + printf("},\n"); + f += b * c * d; + } +} + +int main(void) +{ + ps_tableinit(); + + write_fileheader(); + + printf("static const float pd_re_smooth[8*8*8] = {\n"); + write_float_array(pd_re_smooth, 8*8*8); + printf("};\n"); + printf("static const float pd_im_smooth[8*8*8] = {\n"); + write_float_array(pd_im_smooth, 8*8*8); + printf("};\n"); + + printf("static const float HA[46][8][4] = {\n"); + write_float_3d_array(HA, 46, 8, 4); + printf("};\n"); + printf("static const float HB[46][8][4] = {\n"); + write_float_3d_array(HB, 46, 8, 4); + printf("};\n"); + + printf("static const float f20_0_8[8][7][2] = {\n"); + write_float_3d_array(f20_0_8, 8, 7, 2); + printf("};\n"); + printf("static const float f34_0_12[12][7][2] = {\n"); + write_float_3d_array(f34_0_12, 12, 7, 2); + printf("};\n"); + printf("static const float f34_1_8[8][7][2] = {\n"); + write_float_3d_array(f34_1_8, 8, 7, 2); + printf("};\n"); + printf("static const float f34_2_4[4][7][2] = {\n"); + write_float_3d_array(f34_2_4, 4, 7, 2); + printf("};\n"); + + printf("static const float Q_fract_allpass[2][50][3][2] = {\n"); + write_float_4d_array(Q_fract_allpass, 2, 50, 3, 2); + printf("};\n"); + printf("static const float phi_fract[2][50][2] = {\n"); + write_float_3d_array(phi_fract, 2, 50, 2); + printf("};\n"); + + return 0; +} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacps_tablegen.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacps_tablegen.h new file mode 100644 index 000000000..c7e062bdb --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacps_tablegen.h @@ -0,0 +1,212 @@ +/* + * Header file for hardcoded Parametric Stereo tables + * + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AACPS_TABLEGEN_H +#define AACPS_TABLEGEN_H + +#include + +#if CONFIG_HARDCODED_TABLES +#define ps_tableinit() +#include "libavcodec/aacps_tables.h" +#else +#include "libavutil/common.h" +#include "libavutil/mathematics.h" +#define NR_ALLPASS_BANDS20 30 +#define NR_ALLPASS_BANDS34 50 +#define PS_AP_LINKS 3 +static float pd_re_smooth[8*8*8]; +static float pd_im_smooth[8*8*8]; +static float HA[46][8][4]; +static float HB[46][8][4]; +static float f20_0_8 [ 8][7][2]; +static float f34_0_12[12][7][2]; +static float f34_1_8 [ 8][7][2]; +static float f34_2_4 [ 4][7][2]; +static float Q_fract_allpass[2][50][3][2]; +static float phi_fract[2][50][2]; + +static const float g0_Q8[] = { + 0.00746082949812f, 0.02270420949825f, 0.04546865930473f, 0.07266113929591f, + 0.09885108575264f, 0.11793710567217f, 0.125f +}; + +static const float g0_Q12[] = { + 0.04081179924692f, 0.03812810994926f, 0.05144908135699f, 0.06399831151592f, + 0.07428313801106f, 0.08100347892914f, 0.08333333333333f +}; + +static const float g1_Q8[] = { + 0.01565675600122f, 0.03752716391991f, 0.05417891378782f, 0.08417044116767f, + 0.10307344158036f, 0.12222452249753f, 0.125f +}; + +static const float g2_Q4[] = { + -0.05908211155639f, -0.04871498374946f, 0.0f, 0.07778723915851f, + 0.16486303567403f, 0.23279856662996f, 0.25f +}; + +static void make_filters_from_proto(float (*filter)[7][2], const float *proto, int bands) +{ + int q, n; + for (q = 0; q < bands; q++) { + for (n = 0; n < 7; n++) { + double theta = 2 * M_PI * (q + 0.5) * (n - 6) / bands; + filter[q][n][0] = proto[n] * cos(theta); + filter[q][n][1] = proto[n] * -sin(theta); + } + } +} + +static void ps_tableinit(void) +{ + static const float ipdopd_sin[] = { 0, M_SQRT1_2, 1, M_SQRT1_2, 0, -M_SQRT1_2, -1, -M_SQRT1_2 }; + static const float ipdopd_cos[] = { 1, M_SQRT1_2, 0, -M_SQRT1_2, -1, -M_SQRT1_2, 0, M_SQRT1_2 }; + int pd0, pd1, pd2; + + static const float iid_par_dequant[] = { + //iid_par_dequant_default + 0.05623413251903, 0.12589254117942, 0.19952623149689, 0.31622776601684, + 0.44668359215096, 0.63095734448019, 0.79432823472428, 1, + 1.25892541179417, 1.58489319246111, 2.23872113856834, 3.16227766016838, + 5.01187233627272, 7.94328234724282, 17.7827941003892, + //iid_par_dequant_fine + 0.00316227766017, 0.00562341325190, 0.01, 0.01778279410039, + 0.03162277660168, 0.05623413251903, 0.07943282347243, 0.11220184543020, + 0.15848931924611, 0.22387211385683, 0.31622776601684, 0.39810717055350, + 0.50118723362727, 0.63095734448019, 0.79432823472428, 1, + 1.25892541179417, 1.58489319246111, 1.99526231496888, 2.51188643150958, + 3.16227766016838, 4.46683592150963, 6.30957344480193, 8.91250938133745, + 12.5892541179417, 17.7827941003892, 31.6227766016838, 56.2341325190349, + 100, 177.827941003892, 316.227766016837, + }; + static const float icc_invq[] = { + 1, 0.937, 0.84118, 0.60092, 0.36764, 0, -0.589, -1 + }; + static const float acos_icc_invq[] = { + 0, 0.35685527, 0.57133466, 0.92614472, 1.1943263, M_PI/2, 2.2006171, M_PI + }; + int iid, icc; + + int k, m; + static const int8_t f_center_20[] = { + -3, -1, 1, 3, 5, 7, 10, 14, 18, 22, + }; + static const int8_t f_center_34[] = { + 2, 6, 10, 14, 18, 22, 26, 30, + 34,-10, -6, -2, 51, 57, 15, 21, + 27, 33, 39, 45, 54, 66, 78, 42, + 102, 66, 78, 90,102,114,126, 90, + }; + static const float fractional_delay_links[] = { 0.43f, 0.75f, 0.347f }; + const float fractional_delay_gain = 0.39f; + + for (pd0 = 0; pd0 < 8; pd0++) { + float pd0_re = ipdopd_cos[pd0]; + float pd0_im = ipdopd_sin[pd0]; + for (pd1 = 0; pd1 < 8; pd1++) { + float pd1_re = ipdopd_cos[pd1]; + float pd1_im = ipdopd_sin[pd1]; + for (pd2 = 0; pd2 < 8; pd2++) { + float pd2_re = ipdopd_cos[pd2]; + float pd2_im = ipdopd_sin[pd2]; + float re_smooth = 0.25f * pd0_re + 0.5f * pd1_re + pd2_re; + float im_smooth = 0.25f * pd0_im + 0.5f * pd1_im + pd2_im; + float pd_mag = 1 / sqrt(im_smooth * im_smooth + re_smooth * re_smooth); + pd_re_smooth[pd0*64+pd1*8+pd2] = re_smooth * pd_mag; + pd_im_smooth[pd0*64+pd1*8+pd2] = im_smooth * pd_mag; + } + } + } + + for (iid = 0; iid < 46; iid++) { + float c = iid_par_dequant[iid]; //icc_mode < 3)*/ { + float alpha = 0.5f * acos_icc_invq[icc]; + float beta = alpha * (c1 - c2) * (float)M_SQRT1_2; + HA[iid][icc][0] = c2 * cosf(beta + alpha); + HA[iid][icc][1] = c1 * cosf(beta - alpha); + HA[iid][icc][2] = c2 * sinf(beta + alpha); + HA[iid][icc][3] = c1 * sinf(beta - alpha); + } /* else */ { + float alpha, gamma, mu, rho; + float alpha_c, alpha_s, gamma_c, gamma_s; + rho = FFMAX(icc_invq[icc], 0.05f); + alpha = 0.5f * atan2f(2.0f * c * rho, c*c - 1.0f); + mu = c + 1.0f / c; + mu = sqrtf(1 + (4 * rho * rho - 4)/(mu * mu)); + gamma = atanf(sqrtf((1.0f - mu)/(1.0f + mu))); + if (alpha < 0) alpha += M_PI/2; + alpha_c = cosf(alpha); + alpha_s = sinf(alpha); + gamma_c = cosf(gamma); + gamma_s = sinf(gamma); + HB[iid][icc][0] = M_SQRT2 * alpha_c * gamma_c; + HB[iid][icc][1] = M_SQRT2 * alpha_s * gamma_c; + HB[iid][icc][2] = -M_SQRT2 * alpha_s * gamma_s; + HB[iid][icc][3] = M_SQRT2 * alpha_c * gamma_s; + } + } + } + + for (k = 0; k < NR_ALLPASS_BANDS20; k++) { + double f_center, theta; + if (k < FF_ARRAY_ELEMS(f_center_20)) + f_center = f_center_20[k] * 0.125; + else + f_center = k - 6.5f; + for (m = 0; m < PS_AP_LINKS; m++) { + theta = -M_PI * fractional_delay_links[m] * f_center; + Q_fract_allpass[0][k][m][0] = cos(theta); + Q_fract_allpass[0][k][m][1] = sin(theta); + } + theta = -M_PI*fractional_delay_gain*f_center; + phi_fract[0][k][0] = cos(theta); + phi_fract[0][k][1] = sin(theta); + } + for (k = 0; k < NR_ALLPASS_BANDS34; k++) { + double f_center, theta; + if (k < FF_ARRAY_ELEMS(f_center_34)) + f_center = f_center_34[k] / 24.; + else + f_center = k - 26.5f; + for (m = 0; m < PS_AP_LINKS; m++) { + theta = -M_PI * fractional_delay_links[m] * f_center; + Q_fract_allpass[1][k][m][0] = cos(theta); + Q_fract_allpass[1][k][m][1] = sin(theta); + } + theta = -M_PI*fractional_delay_gain*f_center; + phi_fract[1][k][0] = cos(theta); + phi_fract[1][k][1] = sin(theta); + } + + make_filters_from_proto(f20_0_8, g0_Q8, 8); + make_filters_from_proto(f34_0_12, g0_Q12, 12); + make_filters_from_proto(f34_1_8, g1_Q8, 8); + make_filters_from_proto(f34_2_4, g2_Q4, 4); +} +#endif /* CONFIG_HARDCODED_TABLES */ + +#endif /* AACPS_TABLEGEN_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacpsdata.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacpsdata.c new file mode 100644 index 000000000..7431caebc --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacpsdata.c @@ -0,0 +1,163 @@ +/* + * MPEG-4 Parametric Stereo data tables + * Copyright (c) 2010 Alex Converse + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +static const uint8_t huff_iid_df1_bits[] = { + 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 18, 17, 17, 16, 16, 15, 14, 14, + 13, 12, 12, 11, 10, 10, 8, 7, 6, 5, 4, 3, 1, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 16, 17, 17, 18, 17, 18, 18, + 18, 18, 18, 18, 18, 18, 18, +}; + +static const uint32_t huff_iid_df1_codes[] = { + 0x01FEB4, 0x01FEB5, 0x01FD76, 0x01FD77, 0x01FD74, 0x01FD75, 0x01FE8A, + 0x01FE8B, 0x01FE88, 0x00FE80, 0x01FEB6, 0x00FE82, 0x00FEB8, 0x007F42, + 0x007FAE, 0x003FAF, 0x001FD1, 0x001FE9, 0x000FE9, 0x0007EA, 0x0007FB, + 0x0003FB, 0x0001FB, 0x0001FF, 0x00007C, 0x00003C, 0x00001C, 0x00000C, + 0x000000, 0x000001, 0x000001, 0x000002, 0x000001, 0x00000D, 0x00001D, + 0x00003D, 0x00007D, 0x0000FC, 0x0001FC, 0x0003FC, 0x0003F4, 0x0007EB, + 0x000FEA, 0x001FEA, 0x001FD6, 0x003FD0, 0x007FAF, 0x007F43, 0x00FEB9, + 0x00FE83, 0x01FEB7, 0x00FE81, 0x01FE89, 0x01FE8E, 0x01FE8F, 0x01FE8C, + 0x01FE8D, 0x01FEB2, 0x01FEB3, 0x01FEB0, 0x01FEB1, +}; + +static const uint8_t huff_iid_dt1_bits[] = { + 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 13, + 13, 13, 12, 12, 11, 10, 9, 9, 7, 6, 5, 3, 1, 2, 5, 6, 7, 8, + 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, +}; + +static const uint16_t huff_iid_dt1_codes[] = { + 0x004ED4, 0x004ED5, 0x004ECE, 0x004ECF, 0x004ECC, 0x004ED6, 0x004ED8, + 0x004F46, 0x004F60, 0x002718, 0x002719, 0x002764, 0x002765, 0x00276D, + 0x0027B1, 0x0013B7, 0x0013D6, 0x0009C7, 0x0009E9, 0x0009ED, 0x0004EE, + 0x0004F7, 0x000278, 0x000139, 0x00009A, 0x00009F, 0x000020, 0x000011, + 0x00000A, 0x000003, 0x000001, 0x000000, 0x00000B, 0x000012, 0x000021, + 0x00004C, 0x00009B, 0x00013A, 0x000279, 0x000270, 0x0004EF, 0x0004E2, + 0x0009EA, 0x0009D8, 0x0013D7, 0x0013D0, 0x0027B2, 0x0027A2, 0x00271A, + 0x00271B, 0x004F66, 0x004F67, 0x004F61, 0x004F47, 0x004ED9, 0x004ED7, + 0x004ECD, 0x004ED2, 0x004ED3, 0x004ED0, 0x004ED1, +}; + +static const uint8_t huff_iid_df0_bits[] = { + 17, 17, 17, 17, 16, 15, 13, 10, 9, 7, 6, 5, 4, 3, 1, 3, 4, 5, + 6, 6, 8, 11, 13, 14, 14, 15, 17, 18, 18, +}; + +static const uint32_t huff_iid_df0_codes[] = { + 0x01FFFB, 0x01FFFC, 0x01FFFD, 0x01FFFA, 0x00FFFC, 0x007FFC, 0x001FFD, + 0x0003FE, 0x0001FE, 0x00007E, 0x00003C, 0x00001D, 0x00000D, 0x000005, + 0x000000, 0x000004, 0x00000C, 0x00001C, 0x00003D, 0x00003E, 0x0000FE, + 0x0007FE, 0x001FFC, 0x003FFC, 0x003FFD, 0x007FFD, 0x01FFFE, 0x03FFFE, + 0x03FFFF, +}; + +static const uint8_t huff_iid_dt0_bits[] = { + 19, 19, 19, 20, 20, 20, 17, 15, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, + 9, 11, 13, 14, 17, 19, 20, 20, 20, 20, 20, +}; + +static const uint32_t huff_iid_dt0_codes[] = { + 0x07FFF9, 0x07FFFA, 0x07FFFB, 0x0FFFF8, 0x0FFFF9, 0x0FFFFA, 0x01FFFD, + 0x007FFE, 0x000FFE, 0x0003FE, 0x0000FE, 0x00003E, 0x00000E, 0x000002, + 0x000000, 0x000006, 0x00001E, 0x00007E, 0x0001FE, 0x0007FE, 0x001FFE, + 0x003FFE, 0x01FFFC, 0x07FFF8, 0x0FFFFB, 0x0FFFFC, 0x0FFFFD, 0x0FFFFE, + 0x0FFFFF, +}; + +static const uint8_t huff_icc_df_bits[] = { + 14, 14, 12, 10, 7, 5, 3, 1, 2, 4, 6, 8, 9, 11, 13, +}; + +static const uint16_t huff_icc_df_codes[] = { + 0x3FFF, 0x3FFE, 0x0FFE, 0x03FE, 0x007E, 0x001E, 0x0006, 0x0000, + 0x0002, 0x000E, 0x003E, 0x00FE, 0x01FE, 0x07FE, 0x1FFE, +}; + +static const uint8_t huff_icc_dt_bits[] = { + 14, 13, 11, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, +}; + +static const uint16_t huff_icc_dt_codes[] = { + 0x3FFE, 0x1FFE, 0x07FE, 0x01FE, 0x007E, 0x001E, 0x0006, 0x0000, + 0x0002, 0x000E, 0x003E, 0x00FE, 0x03FE, 0x0FFE, 0x3FFF, +}; + +static const uint8_t huff_ipd_df_bits[] = { + 1, 3, 4, 4, 4, 4, 4, 4, +}; + +static const uint8_t huff_ipd_df_codes[] = { + 0x01, 0x00, 0x06, 0x04, 0x02, 0x03, 0x05, 0x07, +}; + +static const uint8_t huff_ipd_dt_bits[] = { + 1, 3, 4, 5, 5, 4, 4, 3, +}; + +static const uint8_t huff_ipd_dt_codes[] = { + 0x01, 0x02, 0x02, 0x03, 0x02, 0x00, 0x03, 0x03, +}; + +static const uint8_t huff_opd_df_bits[] = { + 1, 3, 4, 4, 5, 5, 4, 3, +}; + +static const uint8_t huff_opd_df_codes[] = { + 0x01, 0x01, 0x06, 0x04, 0x0F, 0x0E, 0x05, 0x00, +}; + +static const uint8_t huff_opd_dt_bits[] = { + 1, 3, 4, 5, 5, 4, 4, 3, +}; + +static const uint8_t huff_opd_dt_codes[] = { + 0x01, 0x02, 0x01, 0x07, 0x06, 0x00, 0x02, 0x03, +}; + +static const int8_t huff_offset[] = { + 30, 30, + 14, 14, + 7, 7, + 0, 0, + 0, 0, +}; + +///Table 8.48 +static const int8_t k_to_i_20[] = { + 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, 15, + 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19 +}; +///Table 8.49 +static const int8_t k_to_i_34[] = { + 0, 1, 2, 3, 4, 5, 6, 6, 7, 2, 1, 0, 10, 10, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 9, 14, 11, 12, 13, 14, 15, 16, 13, 16, 17, 18, 19, 20, 21, + 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, + 30, 30, 30, 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 +}; + +static const float g1_Q2[] = { + 0.0f, 0.01899487526049f, 0.0f, -0.07293139167538f, + 0.0f, 0.30596630545168f, 0.5f +}; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacpsy.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacpsy.c index 4d0c73876..466b0e9a1 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacpsy.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacpsy.c @@ -185,6 +185,7 @@ static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx, Psy3gppContext *pctx = (Psy3gppContext*) ctx->model_priv_data; Psy3gppChannel *pch = &pctx->ch[channel]; uint8_t grouping = 0; + int next_type = pch->next_window_seq; FFPsyWindowInfo wi; memset(&wi, 0, sizeof(wi)); @@ -193,6 +194,7 @@ static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx, int switch_to_eight = 0; float sum = 0.0, sum2 = 0.0; int attack_n = 0; + int stay_short = 0; for (i = 0; i < 8; i++) { for (j = 0; j < 128; j++) { v = iir_filter(la[(i*128+j)*ctx->avctx->channels], pch->iir_state); @@ -214,20 +216,27 @@ static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx, switch (prev_type) { case ONLY_LONG_SEQUENCE: wi.window_type[0] = switch_to_eight ? LONG_START_SEQUENCE : ONLY_LONG_SEQUENCE; + next_type = switch_to_eight ? EIGHT_SHORT_SEQUENCE : ONLY_LONG_SEQUENCE; break; case LONG_START_SEQUENCE: wi.window_type[0] = EIGHT_SHORT_SEQUENCE; grouping = pch->next_grouping; + next_type = switch_to_eight ? EIGHT_SHORT_SEQUENCE : LONG_STOP_SEQUENCE; break; case LONG_STOP_SEQUENCE: - wi.window_type[0] = ONLY_LONG_SEQUENCE; + wi.window_type[0] = switch_to_eight ? LONG_START_SEQUENCE : ONLY_LONG_SEQUENCE; + next_type = switch_to_eight ? EIGHT_SHORT_SEQUENCE : ONLY_LONG_SEQUENCE; break; case EIGHT_SHORT_SEQUENCE: - wi.window_type[0] = switch_to_eight ? EIGHT_SHORT_SEQUENCE : LONG_STOP_SEQUENCE; - grouping = switch_to_eight ? pch->next_grouping : 0; + stay_short = next_type == EIGHT_SHORT_SEQUENCE || switch_to_eight; + wi.window_type[0] = stay_short ? EIGHT_SHORT_SEQUENCE : LONG_STOP_SEQUENCE; + grouping = next_type == EIGHT_SHORT_SEQUENCE ? pch->next_grouping : 0; + next_type = switch_to_eight ? EIGHT_SHORT_SEQUENCE : LONG_STOP_SEQUENCE; break; } + pch->next_grouping = window_grouping[attack_n]; + pch->next_window_seq = next_type; } else { for (i = 0; i < 3; i++) wi.window_type[i] = prev_type; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacsbr.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacsbr.c index 540c30a5a..050305a3f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacsbr.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aacsbr.c @@ -31,6 +31,7 @@ #include "aacsbr.h" #include "aacsbrdata.h" #include "fft.h" +#include "aacps.h" #include #include @@ -84,7 +85,7 @@ static const DECLARE_ALIGNED(16, float, zero64)[64]; av_cold void ff_aac_sbr_init(void) { - int n, k; + int n; static const struct { const void *sbr_codes, *sbr_bits; const unsigned int table_size, elem_size; @@ -120,6 +121,8 @@ av_cold void ff_aac_sbr_init(void) for (n = 0; n < 320; n++) sbr_qmf_window_ds[n] = sbr_qmf_window_us[2*n]; + + ff_ps_init(); } av_cold void ff_aac_sbr_ctx_init(SpectralBandReplication *sbr) @@ -130,6 +133,7 @@ av_cold void ff_aac_sbr_ctx_init(SpectralBandReplication *sbr) sbr->data[1].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); ff_mdct_init(&sbr->mdct, 7, 1, 1.0/64); ff_mdct_init(&sbr->mdct_ana, 7, 1, -2.0); + ff_ps_ctx_init(&sbr->ps); } av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr) @@ -375,8 +379,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, } if (!spectrum->bs_freq_scale) { - unsigned int dk; - int k2diff; + int dk, k2diff; dk = spectrum->bs_alter_scale + 1; sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1; @@ -389,7 +392,7 @@ static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr, k2diff = sbr->k[2] - sbr->k[0] - sbr->n_master * dk; if (k2diff < 0) { sbr->f_master[1]--; - sbr->f_master[2]-= (k2diff < 1); + sbr->f_master[2]-= (k2diff < -1); } else if (k2diff) { sbr->f_master[sbr->n_master]++; } @@ -890,7 +893,6 @@ static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb, int bs_extension_id, int *num_bits_left) { -//TODO - implement ps_data for parametric stereo parsing switch (bs_extension_id) { case EXTENSION_ID_PS: if (!ac->m4ac.ps) { @@ -898,8 +900,8 @@ static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, skip_bits_long(gb, *num_bits_left); // bs_fill_bits *num_bits_left = 0; } else { -#if 0 - *num_bits_left -= ff_ps_data(gb, ps); +#if 1 + *num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps, *num_bits_left); #else av_log_missing_feature(ac->avctx, "Parametric Stereo is", 0); skip_bits_long(gb, *num_bits_left); // bs_fill_bits @@ -1008,6 +1010,11 @@ static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr, num_bits_left -= 2; read_sbr_extension(ac, sbr, gb, get_bits(gb, 2), &num_bits_left); // bs_extension_id } + if (num_bits_left < 0) { + av_log(ac->avctx, AV_LOG_ERROR, "SBR Extension over read.\n"); + } + if (num_bits_left > 0) + skip_bits(gb, num_bits_left); } return get_bits_count(gb) - cnt; @@ -1126,7 +1133,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) * @param x pointer to the beginning of the first sample window * @param W array of complex-valued samples split into subbands */ -static void sbr_qmf_analysis(DSPContext *dsp, RDFTContext *mdct, const float *in, float *x, +static void sbr_qmf_analysis(DSPContext *dsp, FFTContext *mdct, const float *in, float *x, float z[320], float W[2][32][32][2], float scale) { @@ -1139,7 +1146,6 @@ static void sbr_qmf_analysis(DSPContext *dsp, RDFTContext *mdct, const float *in memcpy(x+288, in, 1024*sizeof(*x)); for (i = 0; i < 32; i++) { // numTimeSlots*RATE = 16*2 as 960 sample frames // are not supported - float re, im; dsp->vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320); for (k = 0; k < 64; k++) { float f = z[k] + z[k + 64] + z[k + 128] + z[k + 192] + z[k + 256]; @@ -1167,7 +1173,7 @@ static void sbr_qmf_analysis(DSPContext *dsp, RDFTContext *mdct, const float *in * (14496-3 sp04 p206) */ static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct, - float *out, float X[2][32][64], + float *out, float X[2][38][64], float mdct_buf[2][64], float *v0, int *v_off, const unsigned int div, float bias, float scale) @@ -1185,21 +1191,22 @@ static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct, *v_off -= 128 >> div; } v = v0 + *v_off; - for (n = 1; n < 64 >> div; n+=2) { - X[1][i][n] = -X[1][i][n]; - } - if (div) { - memset(X[0][i]+32, 0, 32*sizeof(float)); - memset(X[1][i]+32, 0, 32*sizeof(float)); - } - ff_imdct_half(mdct, mdct_buf[0], X[0][i]); - ff_imdct_half(mdct, mdct_buf[1], X[1][i]); if (div) { for (n = 0; n < 32; n++) { - v[ n] = -mdct_buf[0][63 - 2*n] + mdct_buf[1][2*n ]; - v[ 63 - n] = mdct_buf[0][62 - 2*n] + mdct_buf[1][2*n + 1]; + X[0][i][ n] = -X[0][i][n]; + X[0][i][32+n] = X[1][i][31-n]; + } + ff_imdct_half(mdct, mdct_buf[0], X[0][i]); + for (n = 0; n < 32; n++) { + v[ n] = mdct_buf[0][63 - 2*n]; + v[63 - n] = -mdct_buf[0][62 - 2*n]; } } else { + for (n = 1; n < 64; n+=2) { + X[1][i][n] = -X[1][i][n]; + } + ff_imdct_half(mdct, mdct_buf[0], X[0][i]); + ff_imdct_half(mdct, mdct_buf[1], X[1][i]); for (n = 0; n < 64; n++) { v[ n] = -mdct_buf[0][63 - n] + mdct_buf[1][ n ]; v[127 - n] = mdct_buf[0][63 - n] + mdct_buf[1][ n ]; @@ -1402,7 +1409,7 @@ static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr, } /// Generate the subband filtered lowband -static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][32][64], +static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][38][64], const float X_low[32][40][2], const float Y[2][38][64][2], int ch) { @@ -1424,7 +1431,7 @@ static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][32][64], } for (k = 0; k < sbr->kx[1]; k++) { - for (i = i_Temp; i < i_f; i++) { + for (i = i_Temp; i < 38; i++) { X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0]; X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1]; } @@ -1573,7 +1580,7 @@ static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr, sum[1] += sbr->e_curr[e][m]; } gain_max = limgain[sbr->bs_limiter_gains] * sqrtf((FLT_EPSILON + sum[0]) / (FLT_EPSILON + sum[1])); - gain_max = FFMIN(100000, gain_max); + gain_max = FFMIN(100000.f, gain_max); for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { float q_m_max = sbr->q_m[e][m] * gain_max / sbr->gain[e][m]; sbr->q_m[e][m] = FFMIN(sbr->q_m[e][m], q_m_max); @@ -1587,7 +1594,7 @@ static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr, + (delta && !sbr->s_m[e][m]) * sbr->q_m[e][m] * sbr->q_m[e][m]; } gain_boost = sqrtf((FLT_EPSILON + sum[0]) / (FLT_EPSILON + sum[1])); - gain_boost = FFMIN(1.584893192, gain_boost); + gain_boost = FFMIN(1.584893192f, gain_boost); for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { sbr->gain[e][m] *= gain_boost; sbr->q_m[e][m] *= gain_boost; @@ -1740,6 +1747,16 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, /* synthesis */ sbr_x_gen(sbr, sbr->X[ch], sbr->X_low, sbr->data[ch].Y, ch); } + + if (ac->m4ac.ps == 1) { + if (sbr->ps.start) { + ff_ps_apply(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]); + } else { + memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0])); + } + nch = 2; + } + sbr_qmf_synthesis(&ac->dsp, &sbr->mdct, L, sbr->X[0], sbr->qmf_filter_scratch, sbr->data[0].synthesis_filterbank_samples, &sbr->data[0].synthesis_filterbank_samples_offset, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aactab.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aactab.c index eaa548682..17102a66f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aactab.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aactab.c @@ -29,6 +29,7 @@ #include "libavutil/mem.h" #include "aac.h" +#include "aac_tablegen.h" #include @@ -1204,129 +1205,3 @@ const uint8_t ff_tns_max_bands_128[] = { 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 }; // @} - - -#if CONFIG_HARDCODED_TABLES - -/** - * Table of pow(2, (i - 200)/4.) used for different purposes depending on the - * range of indices to the table: - * [ 0, 255] scale factor decoding when using C dsp.float_to_int16 - * [60, 315] scale factor decoding when using SIMD dsp.float_to_int16 - * [45, 300] intensity stereo position decoding mapped in reverse order i.e. 0->300, 1->299, ..., 254->46, 255->45 - */ -const float ff_aac_pow2sf_tab[428] = { - 8.88178420e-16, 1.05622810e-15, 1.25607397e-15, 1.49373210e-15, - 1.77635684e-15, 2.11245619e-15, 2.51214793e-15, 2.98746420e-15, - 3.55271368e-15, 4.22491238e-15, 5.02429587e-15, 5.97492839e-15, - 7.10542736e-15, 8.44982477e-15, 1.00485917e-14, 1.19498568e-14, - 1.42108547e-14, 1.68996495e-14, 2.00971835e-14, 2.38997136e-14, - 2.84217094e-14, 3.37992991e-14, 4.01943669e-14, 4.77994272e-14, - 5.68434189e-14, 6.75985982e-14, 8.03887339e-14, 9.55988543e-14, - 1.13686838e-13, 1.35197196e-13, 1.60777468e-13, 1.91197709e-13, - 2.27373675e-13, 2.70394393e-13, 3.21554936e-13, 3.82395417e-13, - 4.54747351e-13, 5.40788785e-13, 6.43109871e-13, 7.64790834e-13, - 9.09494702e-13, 1.08157757e-12, 1.28621974e-12, 1.52958167e-12, - 1.81898940e-12, 2.16315514e-12, 2.57243948e-12, 3.05916334e-12, - 3.63797881e-12, 4.32631028e-12, 5.14487897e-12, 6.11832668e-12, - 7.27595761e-12, 8.65262056e-12, 1.02897579e-11, 1.22366534e-11, - 1.45519152e-11, 1.73052411e-11, 2.05795159e-11, 2.44733067e-11, - 2.91038305e-11, 3.46104823e-11, 4.11590317e-11, 4.89466134e-11, - 5.82076609e-11, 6.92209645e-11, 8.23180635e-11, 9.78932268e-11, - 1.16415322e-10, 1.38441929e-10, 1.64636127e-10, 1.95786454e-10, - 2.32830644e-10, 2.76883858e-10, 3.29272254e-10, 3.91572907e-10, - 4.65661287e-10, 5.53767716e-10, 6.58544508e-10, 7.83145814e-10, - 9.31322575e-10, 1.10753543e-09, 1.31708902e-09, 1.56629163e-09, - 1.86264515e-09, 2.21507086e-09, 2.63417803e-09, 3.13258326e-09, - 3.72529030e-09, 4.43014173e-09, 5.26835606e-09, 6.26516652e-09, - 7.45058060e-09, 8.86028346e-09, 1.05367121e-08, 1.25303330e-08, - 1.49011612e-08, 1.77205669e-08, 2.10734243e-08, 2.50606661e-08, - 2.98023224e-08, 3.54411338e-08, 4.21468485e-08, 5.01213321e-08, - 5.96046448e-08, 7.08822677e-08, 8.42936970e-08, 1.00242664e-07, - 1.19209290e-07, 1.41764535e-07, 1.68587394e-07, 2.00485328e-07, - 2.38418579e-07, 2.83529071e-07, 3.37174788e-07, 4.00970657e-07, - 4.76837158e-07, 5.67058141e-07, 6.74349576e-07, 8.01941314e-07, - 9.53674316e-07, 1.13411628e-06, 1.34869915e-06, 1.60388263e-06, - 1.90734863e-06, 2.26823256e-06, 2.69739830e-06, 3.20776526e-06, - 3.81469727e-06, 4.53646513e-06, 5.39479661e-06, 6.41553051e-06, - 7.62939453e-06, 9.07293026e-06, 1.07895932e-05, 1.28310610e-05, - 1.52587891e-05, 1.81458605e-05, 2.15791864e-05, 2.56621220e-05, - 3.05175781e-05, 3.62917210e-05, 4.31583729e-05, 5.13242441e-05, - 6.10351562e-05, 7.25834421e-05, 8.63167458e-05, 1.02648488e-04, - 1.22070312e-04, 1.45166884e-04, 1.72633492e-04, 2.05296976e-04, - 2.44140625e-04, 2.90333768e-04, 3.45266983e-04, 4.10593953e-04, - 4.88281250e-04, 5.80667537e-04, 6.90533966e-04, 8.21187906e-04, - 9.76562500e-04, 1.16133507e-03, 1.38106793e-03, 1.64237581e-03, - 1.95312500e-03, 2.32267015e-03, 2.76213586e-03, 3.28475162e-03, - 3.90625000e-03, 4.64534029e-03, 5.52427173e-03, 6.56950324e-03, - 7.81250000e-03, 9.29068059e-03, 1.10485435e-02, 1.31390065e-02, - 1.56250000e-02, 1.85813612e-02, 2.20970869e-02, 2.62780130e-02, - 3.12500000e-02, 3.71627223e-02, 4.41941738e-02, 5.25560260e-02, - 6.25000000e-02, 7.43254447e-02, 8.83883476e-02, 1.05112052e-01, - 1.25000000e-01, 1.48650889e-01, 1.76776695e-01, 2.10224104e-01, - 2.50000000e-01, 2.97301779e-01, 3.53553391e-01, 4.20448208e-01, - 5.00000000e-01, 5.94603558e-01, 7.07106781e-01, 8.40896415e-01, - 1.00000000e+00, 1.18920712e+00, 1.41421356e+00, 1.68179283e+00, - 2.00000000e+00, 2.37841423e+00, 2.82842712e+00, 3.36358566e+00, - 4.00000000e+00, 4.75682846e+00, 5.65685425e+00, 6.72717132e+00, - 8.00000000e+00, 9.51365692e+00, 1.13137085e+01, 1.34543426e+01, - 1.60000000e+01, 1.90273138e+01, 2.26274170e+01, 2.69086853e+01, - 3.20000000e+01, 3.80546277e+01, 4.52548340e+01, 5.38173706e+01, - 6.40000000e+01, 7.61092554e+01, 9.05096680e+01, 1.07634741e+02, - 1.28000000e+02, 1.52218511e+02, 1.81019336e+02, 2.15269482e+02, - 2.56000000e+02, 3.04437021e+02, 3.62038672e+02, 4.30538965e+02, - 5.12000000e+02, 6.08874043e+02, 7.24077344e+02, 8.61077929e+02, - 1.02400000e+03, 1.21774809e+03, 1.44815469e+03, 1.72215586e+03, - 2.04800000e+03, 2.43549617e+03, 2.89630938e+03, 3.44431172e+03, - 4.09600000e+03, 4.87099234e+03, 5.79261875e+03, 6.88862343e+03, - 8.19200000e+03, 9.74198469e+03, 1.15852375e+04, 1.37772469e+04, - 1.63840000e+04, 1.94839694e+04, 2.31704750e+04, 2.75544937e+04, - 3.27680000e+04, 3.89679387e+04, 4.63409500e+04, 5.51089875e+04, - 6.55360000e+04, 7.79358775e+04, 9.26819000e+04, 1.10217975e+05, - 1.31072000e+05, 1.55871755e+05, 1.85363800e+05, 2.20435950e+05, - 2.62144000e+05, 3.11743510e+05, 3.70727600e+05, 4.40871900e+05, - 5.24288000e+05, 6.23487020e+05, 7.41455200e+05, 8.81743800e+05, - 1.04857600e+06, 1.24697404e+06, 1.48291040e+06, 1.76348760e+06, - 2.09715200e+06, 2.49394808e+06, 2.96582080e+06, 3.52697520e+06, - 4.19430400e+06, 4.98789616e+06, 5.93164160e+06, 7.05395040e+06, - 8.38860800e+06, 9.97579232e+06, 1.18632832e+07, 1.41079008e+07, - 1.67772160e+07, 1.99515846e+07, 2.37265664e+07, 2.82158016e+07, - 3.35544320e+07, 3.99031693e+07, 4.74531328e+07, 5.64316032e+07, - 6.71088640e+07, 7.98063385e+07, 9.49062656e+07, 1.12863206e+08, - 1.34217728e+08, 1.59612677e+08, 1.89812531e+08, 2.25726413e+08, - 2.68435456e+08, 3.19225354e+08, 3.79625062e+08, 4.51452825e+08, - 5.36870912e+08, 6.38450708e+08, 7.59250125e+08, 9.02905651e+08, - 1.07374182e+09, 1.27690142e+09, 1.51850025e+09, 1.80581130e+09, - 2.14748365e+09, 2.55380283e+09, 3.03700050e+09, 3.61162260e+09, - 4.29496730e+09, 5.10760567e+09, 6.07400100e+09, 7.22324521e+09, - 8.58993459e+09, 1.02152113e+10, 1.21480020e+10, 1.44464904e+10, - 1.71798692e+10, 2.04304227e+10, 2.42960040e+10, 2.88929808e+10, - 3.43597384e+10, 4.08608453e+10, 4.85920080e+10, 5.77859616e+10, - 6.87194767e+10, 8.17216907e+10, 9.71840160e+10, 1.15571923e+11, - 1.37438953e+11, 1.63443381e+11, 1.94368032e+11, 2.31143847e+11, - 2.74877907e+11, 3.26886763e+11, 3.88736064e+11, 4.62287693e+11, - 5.49755814e+11, 6.53773525e+11, 7.77472128e+11, 9.24575386e+11, - 1.09951163e+12, 1.30754705e+12, 1.55494426e+12, 1.84915077e+12, - 2.19902326e+12, 2.61509410e+12, 3.10988851e+12, 3.69830155e+12, - 4.39804651e+12, 5.23018820e+12, 6.21977702e+12, 7.39660309e+12, - 8.79609302e+12, 1.04603764e+13, 1.24395540e+13, 1.47932062e+13, - 1.75921860e+13, 2.09207528e+13, 2.48791081e+13, 2.95864124e+13, - 3.51843721e+13, 4.18415056e+13, 4.97582162e+13, 5.91728247e+13, - 7.03687442e+13, 8.36830112e+13, 9.95164324e+13, 1.18345649e+14, - 1.40737488e+14, 1.67366022e+14, 1.99032865e+14, 2.36691299e+14, - 2.81474977e+14, 3.34732045e+14, 3.98065730e+14, 4.73382598e+14, - 5.62949953e+14, 6.69464090e+14, 7.96131459e+14, 9.46765196e+14, - 1.12589991e+15, 1.33892818e+15, 1.59226292e+15, 1.89353039e+15, - 2.25179981e+15, 2.67785636e+15, 3.18452584e+15, 3.78706078e+15, - 4.50359963e+15, 5.35571272e+15, 6.36905167e+15, 7.57412156e+15, - 9.00719925e+15, 1.07114254e+16, 1.27381033e+16, 1.51482431e+16, - 1.80143985e+16, 2.14228509e+16, 2.54762067e+16, 3.02964863e+16, - 3.60287970e+16, 4.28457018e+16, 5.09524134e+16, 6.05929725e+16, - 7.20575940e+16, 8.56914035e+16, 1.01904827e+17, 1.21185945e+17, -}; - -#else - -float ff_aac_pow2sf_tab[428]; - -#endif /* CONFIG_HARDCODED_TABLES */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aactab.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aactab.h index 283d6c3a2..c6213999b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aactab.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/aactab.h @@ -32,6 +32,7 @@ #include "libavutil/mem.h" #include "aac.h" +#include "aac_tablegen_decl.h" #include @@ -73,10 +74,4 @@ extern const uint16_t * const ff_swb_offset_128 [13]; extern const uint8_t ff_tns_max_bands_1024[13]; extern const uint8_t ff_tns_max_bands_128 [13]; -#if CONFIG_HARDCODED_TABLES -extern const float ff_aac_pow2sf_tab[428]; -#else -extern float ff_aac_pow2sf_tab[428]; -#endif /* CONFIG_HARDCODED_TABLES */ - #endif /* AVCODEC_AACTAB_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3.c index 3fce5bcfb..1f5ab32eb 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3.c @@ -42,7 +42,7 @@ static const uint8_t band_start_tab[51] = { }; /** - * Maps each frequency coefficient bin to the critical band that contains it. + * Map each frequency coefficient bin to the critical band that contains it. */ static const uint8_t bin_to_band_tab[253] = { 0, @@ -261,7 +261,7 @@ void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap, } /** - * Initializes some tables. + * Initialize some tables. * note: This function must remain thread safe because it is called by the * AVParser init code. */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3.h index 0def3b06c..9c8dc4870 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3.h @@ -114,7 +114,7 @@ typedef enum { void ac3_common_init(void); /** - * Calculates the log power-spectral density of the input signal. + * Calculate the log power-spectral density of the input signal. * This gives a rough estimate of signal power in the frequency domain by using * the spectral envelope (exponents). The psd is also separately grouped * into critical bands for use in the calculating the masking curve. @@ -131,7 +131,7 @@ void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd, int16_t *band_psd); /** - * Calculates the masking curve. + * Calculate the masking curve. * First, the excitation is calculated using parameters in s and the signal * power in each critical band. The excitation is compared with a predefined * hearing threshold table to produce the masking curve. If delta bit @@ -159,7 +159,7 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd, int16_t *mask); /** - * Calculates bit allocation pointers. + * Calculate bit allocation pointers. * The SNR is the difference between the masking curve and the signal. AC-3 * uses this value for each frequency bin to allocate bits. The snroffset * parameter is a global adjustment to the SNR for all bins. diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3_parser.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3_parser.c index 856f97aaf..b844ec36c 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3_parser.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3_parser.c @@ -164,7 +164,7 @@ static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info, union { uint64_t u64; uint8_t u8[8]; - } tmp = { be2me_64(state) }; + } tmp = { av_be2ne64(state) }; AC3HeaderInfo hdr; GetBitContext gbc; @@ -181,7 +181,7 @@ static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info, hdr_info->samples = hdr.num_blocks * 256; if(hdr.bitstream_id>10) hdr_info->codec_id = CODEC_ID_EAC3; - else + else if (hdr_info->codec_id == CODEC_ID_NONE) hdr_info->codec_id = CODEC_ID_AC3; *need_next_header = (hdr.frame_type != EAC3_FRAME_TYPE_AC3_CONVERT); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3_parser.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3_parser.h index 766c68b2b..9226c9021 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3_parser.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3_parser.h @@ -27,11 +27,11 @@ #include "get_bits.h" /** - * Parses AC-3 frame header. - * Parses the header up to the lfeon element, which is the first 52 or 54 bits + * Parse AC-3 frame header. + * Parse the header up to the lfeon element, which is the first 52 or 54 bits * depending on the audio coding mode. - * @param gbc[in] BitContext containing the first 54 bits of the frame. - * @param hdr[out] Pointer to struct where header info is written. + * @param gbc BitContext containing the first 54 bits of the frame. + * @param hdr Pointer to struct where header info is written. * @return Returns 0 on success, -1 if there is a sync word mismatch, * -2 if the bsid (version) element is invalid, -3 if the fscod (sample rate) * element is invalid, or -4 if the frmsizecod (bit rate) element is invalid. @@ -39,12 +39,12 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr); /** - * Parses AC-3 frame header and sets channel_map - * Parses the header up to the lfeon (channel_map in E-AC-3) + * Parse AC-3 frame header and sets channel_map + * Parse the header up to the lfeon (channel_map in E-AC-3) * element, which is the first 52, 54 or 104 bits depending * on the audio coding mode. - * @param gbc[in] BitContext containing the first 54 bits of the frame. - * @param hdr[out] Pointer to struct where header info is written. + * @param gbc BitContext containing the first 54 bits of the frame. + * @param hdr Pointer to struct where header info is written. * @return value returned by ff_ac3_parse_header */ int ff_ac3_parse_header_full(GetBitContext *gbc, AC3HeaderInfo *hdr); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3enc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3enc.c index e30e1bdbb..edae9a92b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3enc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3enc.c @@ -1161,14 +1161,14 @@ static int output_frame_end(AC3EncodeContext *s) /* 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 = bswap_16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, + crc1 = av_bswap16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, frame + 4, 2 * frame_size_58 - 4)); /* 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); AV_WB16(frame+2,crc1); - crc2 = bswap_16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, + crc2 = av_bswap16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, frame + 2 * frame_size_58, (frame_size - frame_size_58) * 2 - 2)); AV_WB16(frame+2*frame_size-2,crc2); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3tab.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3tab.c index 4f28fb3d3..76f6245ba 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3tab.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ac3tab.c @@ -73,7 +73,7 @@ const uint16_t ff_ac3_frame_size_tab[38][3] = { }; /** - * Maps audio coding mode (acmod) to number of full-bandwidth channels. + * Map audio coding mode (acmod) to number of full-bandwidth channels. * from ATSC A/52 Table 5.8 Audio Coding Mode */ const uint8_t ff_ac3_channels_tab[8] = { @@ -81,7 +81,7 @@ const uint8_t ff_ac3_channels_tab[8] = { }; /** - * Maps audio coding mode (acmod) to channel layout mask. + * Map audio coding mode (acmod) to channel layout mask. */ const uint16_t ff_ac3_channel_layout_tab[8] = { CH_LAYOUT_STEREO, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/acelp_pitch_delay.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/acelp_pitch_delay.h index 2413145be..04be17338 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/acelp_pitch_delay.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/acelp_pitch_delay.h @@ -54,8 +54,8 @@ int ff_acelp_decode_8bit_to_1st_delay3(int ac_index); * Pitch delay is coded: * with 1/3 resolution, -6 < pitch_delay - int(prev_pitch_delay) < 5 * - * \remark The routine is used in G.729 @8k, AMR @10.2k, AMR @7.95k, - * AMR @7.4k for the second subframe. + * \remark The routine is used in G.729 @@8k, AMR @@10.2k, AMR @@7.95k, + * AMR @@7.4k for the second subframe. */ int ff_acelp_decode_5_6_bit_to_2nd_delay3( int ac_index, @@ -74,8 +74,8 @@ int ff_acelp_decode_5_6_bit_to_2nd_delay3( * with 1/3 resolution, -2 < pitch_delay - int(prev_pitch_delay) < 1 * integers only, 1 <= pitch_delay - int(prev_pitch_delay) < 5 * - * \remark The routine is used in G.729 @6.4k, AMR @6.7k, AMR @5.9k, - * AMR @5.15k, AMR @4.75k for the second subframe. + * \remark The routine is used in G.729 @@6.4k, AMR @@6.7k, AMR @@5.9k, + * AMR @@5.15k, AMR @@4.75k for the second subframe. */ int ff_acelp_decode_4bit_to_2nd_delay3( int ac_index, @@ -85,8 +85,6 @@ int ff_acelp_decode_4bit_to_2nd_delay3( * \brief Decode pitch delay of the first subframe encoded by 9 bits * with 1/6 precision. * \param ac_index adaptive codebook index (9 bits) - * \param pitch_delay_min lower bound (integer) of pitch delay interval for - * second subframe * * \return pitch delay in 1/6 units * @@ -94,7 +92,7 @@ int ff_acelp_decode_4bit_to_2nd_delay3( * with 1/6 resolution, 17 < pitch_delay < 95 * integers only, 95 <= pitch_delay <= 143 * - * \remark The routine is used in AMR @12.2k for the first and third subframes. + * \remark The routine is used in AMR @@12.2k for the first and third subframes. */ int ff_acelp_decode_9bit_to_1st_delay6(int ac_index); @@ -110,7 +108,7 @@ int ff_acelp_decode_9bit_to_1st_delay6(int ac_index); * Pitch delay is coded: * with 1/6 resolution, -6 < pitch_delay - int(prev_pitch_delay) < 5 * - * \remark The routine is used in AMR @12.2k for the second and fourth subframes. + * \remark The routine is used in AMR @@12.2k for the second and fourth subframes. */ int ff_acelp_decode_6bit_to_2nd_delay6( int ac_index, @@ -147,7 +145,6 @@ void ff_acelp_update_past_gain( * \param mr_energy mean innovation energy and fixed-point correction (7.13) * \param quant_energy [in/out] past quantized energies (5.10) * \param subframe_size length of subframe - * \param ma_pred_order MA prediction order * * \return quantized fixed-codebook gain (14.1) * @@ -224,7 +221,7 @@ int16_t ff_acelp_decode_gain_code( * Calculate fixed gain (part of section 6.1.3 of AMR spec) * * @param fixed_gain_factor gain correction factor - * @param fixed_energy decoded algebraic codebook vector energy + * @param fixed_mean_energy mean decoded algebraic codebook vector energy * @param prediction_error vector of the quantified predictor errors of * the four previous subframes. It is updated by this function. * @param energy_mean desired mean innovation energy diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/acelp_vectors.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/acelp_vectors.h index ba3437fc1..9e3e7a8db 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/acelp_vectors.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/acelp_vectors.h @@ -47,7 +47,7 @@ typedef struct { * * Table contains only first the pulse indexes. * - * Used in G.729 @8k, G.729 @4.4k, AMR @7.95k, AMR @7.40k + * Used in G.729 @@8k, G.729 @@4.4k, AMR @@7.95k, AMR @@7.40k */ extern const uint8_t ff_fc_4pulses_8bits_tracks_13[16]; @@ -60,7 +60,7 @@ extern const uint8_t ff_fc_4pulses_8bits_tracks_13[16]; * * @remark Track in the table should be read top-to-bottom, left-to-right. * - * Used in G.729 @8k, G.729 @4.4k, AMR @7.95k, AMR @7.40k + * Used in G.729 @@8k, G.729 @@4.4k, AMR @@7.95k, AMR @@7.40k */ extern const uint8_t ff_fc_4pulses_8bits_track_4[32]; @@ -76,7 +76,7 @@ extern const uint8_t ff_fc_4pulses_8bits_track_4[32]; * @note (EE) Reference G.729D code also uses gray decoding for each * pulse index before looking up the value in the table. * - * Used in G.729 @6.4k (with gray coding), AMR @5.9k (without gray coding) + * Used in G.729 @@6.4k (with gray coding), AMR @@5.9k (without gray coding) */ extern const uint8_t ff_fc_2pulses_9bits_track1[16]; extern const uint8_t ff_fc_2pulses_9bits_track1_gray[16]; @@ -108,7 +108,7 @@ extern const uint8_t ff_fc_2pulses_9bits_track1_gray[16]; * @note (EE.2) Reference G.729D code also uses gray decoding for each * pulse index before looking up the value in the table. * - * Used in G.729 @6.4k (with gray coding) + * Used in G.729 @@6.4k (with gray coding) */ extern const uint8_t ff_fc_2pulses_9bits_track2_gray[32]; @@ -144,7 +144,7 @@ extern const float ff_pow_0_55[10]; * @param pulse_count number of pulses decoded using first table * @param bits length of one pulse index in bits * - * Used in G.729 @8k, G.729 @4.4k, G.729 @6.4k, AMR @7.95k, AMR @7.40k + * Used in G.729 @@8k, G.729 @@4.4k, G.729 @@6.4k, AMR @@7.95k, AMR @@7.40k */ void ff_acelp_fc_pulse_per_track(int16_t* fc_v, const uint8_t *tab1, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/adpcm.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/adpcm.c index 68bd656aa..eb044ba4b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/adpcm.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/adpcm.c @@ -145,15 +145,34 @@ typedef struct ADPCMChannelStatus { int idelta; } ADPCMChannelStatus; +typedef struct TrellisPath { + int nibble; + int prev; +} TrellisPath; + +typedef struct TrellisNode { + uint32_t ssd; + int path; + int sample1; + int sample2; + int step; +} TrellisNode; + typedef struct ADPCMContext { ADPCMChannelStatus status[6]; + TrellisPath *paths; + TrellisNode *node_buf; + TrellisNode **nodep_buf; } ADPCMContext; +#define FREEZE_INTERVAL 128 + /* XXX: implement encoding */ #if CONFIG_ENCODERS static av_cold int adpcm_encode_init(AVCodecContext *avctx) { + ADPCMContext *s = avctx->priv_data; uint8_t *extradata; int i; if (avctx->channels > 2) @@ -164,6 +183,14 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) return -1; } + if (avctx->trellis) { + int frontier = 1 << avctx->trellis; + int max_paths = frontier * FREEZE_INTERVAL; + FF_ALLOC_OR_GOTO(avctx, s->paths, max_paths * sizeof(*s->paths), error); + FF_ALLOC_OR_GOTO(avctx, s->node_buf, 2 * frontier * sizeof(*s->node_buf), error); + FF_ALLOC_OR_GOTO(avctx, s->nodep_buf, 2 * frontier * sizeof(*s->nodep_buf), error); + } + switch(avctx->codec->id) { 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 */ @@ -199,23 +226,32 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) avctx->sample_rate != 22050 && avctx->sample_rate != 44100) { av_log(avctx, AV_LOG_ERROR, "Sample rate must be 11025, 22050 or 44100\n"); - return -1; + goto error; } avctx->frame_size = 512 * (avctx->sample_rate / 11025); break; default: - return -1; + goto error; } avctx->coded_frame= avcodec_alloc_frame(); avctx->coded_frame->key_frame= 1; return 0; +error: + av_freep(&s->paths); + av_freep(&s->node_buf); + av_freep(&s->nodep_buf); + return -1; } static av_cold int adpcm_encode_close(AVCodecContext *avctx) { + ADPCMContext *s = avctx->priv_data; av_freep(&avctx->coded_frame); + av_freep(&s->paths); + av_freep(&s->node_buf); + av_freep(&s->nodep_buf); return 0; } @@ -276,39 +312,23 @@ static inline unsigned char adpcm_yamaha_compress_sample(ADPCMChannelStatus *c, return nibble; } -typedef struct TrellisPath { - int nibble; - int prev; -} TrellisPath; - -typedef struct TrellisNode { - uint32_t ssd; - int path; - int sample1; - int sample2; - int step; -} TrellisNode; - static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples, uint8_t *dst, ADPCMChannelStatus *c, int n) { -#define FREEZE_INTERVAL 128 //FIXME 6% faster if frontier is a compile-time constant + ADPCMContext *s = avctx->priv_data; const int frontier = 1 << avctx->trellis; const int stride = avctx->channels; const int version = avctx->codec->id; - const int max_paths = frontier*FREEZE_INTERVAL; - TrellisPath paths[max_paths], *p; - TrellisNode node_buf[2][frontier]; - TrellisNode *nodep_buf[2][frontier]; - TrellisNode **nodes = nodep_buf[0]; // nodes[] is always sorted by .ssd - TrellisNode **nodes_next = nodep_buf[1]; + TrellisPath *paths = s->paths, *p; + TrellisNode *node_buf = s->node_buf; + TrellisNode **nodep_buf = s->nodep_buf; + TrellisNode **nodes = nodep_buf; // nodes[] is always sorted by .ssd + TrellisNode **nodes_next = nodep_buf + frontier; int pathn = 0, froze = -1, i, j, k; - assert(!(max_paths&(max_paths-1))); - - memset(nodep_buf, 0, sizeof(nodep_buf)); - nodes[0] = &node_buf[1][0]; + memset(nodep_buf, 0, 2 * frontier * sizeof(*nodep_buf)); + nodes[0] = node_buf + frontier; nodes[0]->ssd = 0; nodes[0]->path = 0; nodes[0]->step = c->step_index; @@ -329,7 +349,7 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples, } for(i=0; issd) {\ TrellisNode *u = nodes_next[frontier-1];\ if(!u) {\ - assert(pathn < max_paths);\ + assert(pathn < FREEZE_INTERVAL<trellis);\ u = t++;\ u->path = pathn++;\ }\ @@ -454,6 +474,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, short *samples; unsigned char *dst; ADPCMContext *c = avctx->priv_data; + uint8_t *buf; dst = frame; samples = (short *)data; @@ -480,22 +501,24 @@ static int adpcm_encode_frame(AVCodecContext *avctx, /* stereo: 4 bytes (8 samples) for left, 4 bytes for right, 4 bytes left, ... */ if(avctx->trellis > 0) { - uint8_t buf[2][n*8]; - adpcm_compress_trellis(avctx, samples, buf[0], &c->status[0], n*8); + FF_ALLOC_OR_GOTO(avctx, buf, 2*n*8, error); + adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n*8); if(avctx->channels == 2) - adpcm_compress_trellis(avctx, samples+1, buf[1], &c->status[1], n*8); + adpcm_compress_trellis(avctx, samples+1, buf + n*8, &c->status[1], n*8); for(i=0; ichannels == 2) { - *dst++ = buf[1][8*i+0] | (buf[1][8*i+1] << 4); - *dst++ = buf[1][8*i+2] | (buf[1][8*i+3] << 4); - *dst++ = buf[1][8*i+4] | (buf[1][8*i+5] << 4); - *dst++ = buf[1][8*i+6] | (buf[1][8*i+7] << 4); + uint8_t *buf1 = buf + n*8; + *dst++ = buf1[8*i+0] | (buf1[8*i+1] << 4); + *dst++ = buf1[8*i+2] | (buf1[8*i+3] << 4); + *dst++ = buf1[8*i+4] | (buf1[8*i+5] << 4); + *dst++ = buf1[8*i+6] | (buf1[8*i+7] << 4); } } + av_free(buf); } else for (; n>0; n--) { *dst = adpcm_ima_compress_sample(&c->status[0], samples[0]); @@ -578,15 +601,16 @@ static int adpcm_encode_frame(AVCodecContext *avctx, } if(avctx->trellis > 0) { - uint8_t buf[2][n]; - adpcm_compress_trellis(avctx, samples+2, buf[0], &c->status[0], n); + FF_ALLOC_OR_GOTO(avctx, buf, 2*n, error); + adpcm_compress_trellis(avctx, samples+2, buf, &c->status[0], n); if (avctx->channels == 2) - adpcm_compress_trellis(avctx, samples+3, buf[1], &c->status[1], n); + adpcm_compress_trellis(avctx, samples+3, buf+n, &c->status[1], n); for(i=0; ichannels == 2) - put_bits(&pb, 4, buf[1][i]); + put_bits(&pb, 4, buf[n+i]); } + av_free(buf); } else { for (i=1; iframe_size; i++) { put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels*i])); @@ -625,18 +649,18 @@ static int adpcm_encode_frame(AVCodecContext *avctx, if(avctx->trellis > 0) { int n = avctx->block_align - 7*avctx->channels; - uint8_t buf[2][n]; + FF_ALLOC_OR_GOTO(avctx, buf, 2*n, error); if(avctx->channels == 1) { - n *= 2; - adpcm_compress_trellis(avctx, samples, buf[0], &c->status[0], n); + adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n); for(i=0; istatus[0], n); - adpcm_compress_trellis(avctx, samples+1, buf[1], &c->status[1], n); + adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n); + adpcm_compress_trellis(avctx, samples+1, buf+n, &c->status[1], n); for(i=0; ichannels; iblock_align; i++) { int nibble; @@ -648,18 +672,19 @@ static int adpcm_encode_frame(AVCodecContext *avctx, case CODEC_ID_ADPCM_YAMAHA: n = avctx->frame_size / 2; if(avctx->trellis > 0) { - uint8_t buf[2][n*2]; + FF_ALLOC_OR_GOTO(avctx, buf, 2*n*2, error); n *= 2; if(avctx->channels == 1) { - adpcm_compress_trellis(avctx, samples, buf[0], &c->status[0], n); + adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n); for(i=0; istatus[0], n); - adpcm_compress_trellis(avctx, samples+1, buf[1], &c->status[1], n); + adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n); + adpcm_compress_trellis(avctx, samples+1, buf+n, &c->status[1], n); for(i=0; ichannels; n>0; n--) { int nibble; @@ -669,6 +694,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, } break; default: + error: return -1; } return dst - frame; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alac.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alac.c index 50fc7a1a3..07b03c126 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alac.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alac.c @@ -547,11 +547,11 @@ static int alac_decode_frame(AVCodecContext *avctx, if (!isnotcompressed) { /* so it is compressed */ - int16_t predictor_coef_table[channels][32]; - int predictor_coef_num[channels]; - int prediction_type[channels]; - int prediction_quantitization[channels]; - int ricemodifier[channels]; + int16_t predictor_coef_table[MAX_CHANNELS][32]; + int predictor_coef_num[MAX_CHANNELS]; + int prediction_type[MAX_CHANNELS]; + int prediction_quantitization[MAX_CHANNELS]; + int ricemodifier[MAX_CHANNELS]; int i, chan; interlacing_shift = get_bits(&alac->gb, 8); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alacenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alacenc.c index 0876633cb..ee6acc071 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alacenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alacenc.c @@ -145,7 +145,8 @@ static void calc_predictor_params(AlacEncodeContext *s, int ch) s->avctx->frame_size, s->min_prediction_order, s->max_prediction_order, - ALAC_MAX_LPC_PRECISION, coefs, shift, 1, + ALAC_MAX_LPC_PRECISION, coefs, shift, + AV_LPC_TYPE_LEVINSON, 0, ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1); s->lpc[ch].lpc_order = opt_order; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/allcodecs.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/allcodecs.c index 1b166653d..f17d03a87 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/allcodecs.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/allcodecs.c @@ -1,5 +1,5 @@ /* - * Provides registration of all codecs, parsers and bitstream filters for libavcodec. + * Provide registration of all codecs, parsers and bitstream filters for libavcodec. * Copyright (c) 2002 Fabrice Bellard * * This file is part of FFmpeg. @@ -21,7 +21,7 @@ /** * @file - * Provides registration of all codecs, parsers and bitstream filters for libavcodec. + * Provide registration of all codecs, parsers and bitstream filters for libavcodec. */ #include "avcodec.h" @@ -153,6 +153,7 @@ void avcodec_register_all(void) REGISTER_ENCDEC (PCX, pcx); REGISTER_ENCDEC (PGM, pgm); REGISTER_ENCDEC (PGMYUV, pgmyuv); + REGISTER_DECODER (PICTOR, pictor); REGISTER_ENCDEC (PNG, png); REGISTER_ENCDEC (PPM, ppm); REGISTER_DECODER (PTX, ptx); @@ -200,6 +201,7 @@ void avcodec_register_all(void) REGISTER_DECODER (VP6, vp6); REGISTER_DECODER (VP6A, vp6a); REGISTER_DECODER (VP6F, vp6f); + REGISTER_DECODER (VP8, vp8); REGISTER_DECODER (VQA, vqa); REGISTER_ENCDEC (WMV1, wmv1); REGISTER_ENCDEC (WMV2, wmv2); @@ -228,6 +230,8 @@ void avcodec_register_all(void) REGISTER_DECODER (DSICINAUDIO, dsicinaudio); REGISTER_DECODER (EAC3, eac3); REGISTER_ENCDEC (FLAC, flac); + REGISTER_DECODER (GSM, gsm); + REGISTER_DECODER (GSM_MS, gsm_ms); REGISTER_DECODER (IMC, imc); REGISTER_DECODER (MACE3, mace3); REGISTER_DECODER (MACE6, mace6); @@ -247,7 +251,7 @@ void avcodec_register_all(void) REGISTER_ENCDEC (NELLYMOSER, nellymoser); REGISTER_DECODER (QCELP, qcelp); REGISTER_DECODER (QDM2, qdm2); - REGISTER_DECODER (RA_144, ra_144); + REGISTER_ENCDEC (RA_144, ra_144); REGISTER_DECODER (RA_288, ra_288); REGISTER_DECODER (SHORTEN, shorten); REGISTER_DECODER (SIPR, sipr); @@ -339,8 +343,6 @@ void avcodec_register_all(void) /* external libraries */ REGISTER_ENCDEC (LIBDIRAC, libdirac); REGISTER_ENCODER (LIBFAAC, libfaac); - REGISTER_DECODER (LIBFAAD, libfaad); - REGISTER_DECODER (LIBFAAD_LATM, libfaad_latm); REGISTER_ENCDEC (LIBGSM, libgsm); REGISTER_ENCDEC (LIBGSM_MS, libgsm_ms); REGISTER_ENCODER (LIBMP3LAME, libmp3lame); @@ -367,7 +369,6 @@ void avcodec_register_all(void) REGISTER_PARSER (H261, h261); REGISTER_PARSER (H263, h263); REGISTER_PARSER (H264, h264); - REGISTER_PARSER (LATM, latm); REGISTER_PARSER (MJPEG, mjpeg); REGISTER_PARSER (MLP, mlp); REGISTER_PARSER (MPEG4VIDEO, mpeg4video); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alpha/dsputil_alpha_asm.S b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alpha/dsputil_alpha_asm.S index 57b21fca1..32a8bc956 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alpha/dsputil_alpha_asm.S +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alpha/dsputil_alpha_asm.S @@ -53,11 +53,6 @@ put_pixels_axp_asm: .frame sp, 0, ra .prologue 0 -#if CONFIG_GPROF - lda AT, _mcount - jsr AT, (AT), _mcount -#endif - and a1, 7, t0 beq t0, $aligned @@ -150,11 +145,6 @@ put_pixels_clamped_mvi_asm: .frame sp, 0, ra .prologue 0 -#if CONFIG_GPROF - lda AT, _mcount - jsr AT, (AT), _mcount -#endif - lda t8, -1 lda t9, 8 # loop counter zap t8, 0xaa, t8 # 00ff00ff00ff00ff @@ -205,11 +195,6 @@ add_pixels_clamped_mvi_asm: .frame sp, 0, ra .prologue 0 -#if CONFIG_GPROF - lda AT, _mcount - jsr AT, (AT), _mcount -#endif - lda t1, -1 lda th, 8 zap t1, 0x33, tg diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alpha/motion_est_mvi_asm.S b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alpha/motion_est_mvi_asm.S index 2a08b07b0..2399085bc 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alpha/motion_est_mvi_asm.S +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alpha/motion_est_mvi_asm.S @@ -55,11 +55,6 @@ pix_abs16x16_mvi_asm: .frame sp, 0, ra, 0 .prologue 0 -#if CONFIG_GPROF - lda AT, _mcount - jsr AT, (AT), _mcount -#endif - and a2, 7, t0 clr v0 beq t0, $aligned diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alsdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alsdec.c index 2058a8538..bbcbb7065 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alsdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/alsdec.c @@ -35,6 +35,8 @@ #include "mpeg4audio.h" #include "bytestream.h" #include "bgmc.h" +#include "dsputil.h" +#include "libavutil/crc.h" #include @@ -154,6 +156,7 @@ typedef struct { uint32_t samples; ///< number of samples, 0xFFFFFFFF if unknown int resolution; ///< 000 = 8-bit; 001 = 16-bit; 010 = 24-bit; 011 = 32-bit int floating; ///< 1 = IEEE 32-bit floating-point, 0 = integer + int msb_first; ///< 1 = original CRC calculated on big-endian system, 0 = little-endian int frame_length; ///< frame length for each frame (last frame may differ) int ra_distance; ///< distance between RA frames (in frames, 0...255) enum RA_Flag ra_flag; ///< indicates where the size of ra units is stored @@ -171,6 +174,7 @@ typedef struct { int rlslms; ///< use "Recursive Least Square-Least Mean Square" predictor: 1 = on, 0 = off int chan_config_info; ///< mapping of channels to loudspeaker locations. Unused until setting channel configuration is implemented. int *chan_pos; ///< original channel positions + int crc_enabled; ///< enable Cyclic Redundancy Checksum } ALSSpecificConfig; @@ -188,6 +192,10 @@ typedef struct { AVCodecContext *avctx; ALSSpecificConfig sconf; GetBitContext gb; + DSPContext dsp; + const AVCRC *crc_table; + uint32_t crc_org; ///< CRC value of the original input data + uint32_t crc; ///< CRC value calculated from decoded data unsigned int cur_frame_length; ///< length of the current frame to decode unsigned int frame_id; ///< the frame ID / number of the current frame unsigned int js_switch; ///< if true, joint-stereo decoding is enforced @@ -211,6 +219,7 @@ typedef struct { int32_t *prev_raw_samples; ///< contains unshifted raw samples from the previous block int32_t **raw_samples; ///< decoded raw samples for each channel int32_t *raw_buffer; ///< contains all decoded raw samples including carryover samples + uint8_t *crc_buffer; ///< buffer of byte order corrected samples used for CRC check } ALSDecContext; @@ -262,13 +271,13 @@ static av_cold void dprint_specific_config(ALSDecContext *ctx) } -/** Reads an ALSSpecificConfig from a buffer into the output struct. +/** Read an ALSSpecificConfig from a buffer into the output struct. */ static av_cold int read_specific_config(ALSDecContext *ctx) { GetBitContext gb; uint64_t ht_size; - int i, config_offset, crc_enabled; + int i, config_offset; MPEG4AudioConfig m4ac; ALSSpecificConfig *sconf = &ctx->sconf; AVCodecContext *avctx = ctx->avctx; @@ -297,7 +306,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx) skip_bits(&gb, 3); // skip file_type sconf->resolution = get_bits(&gb, 3); sconf->floating = get_bits1(&gb); - skip_bits1(&gb); // skip msb_first + sconf->msb_first = get_bits1(&gb); sconf->frame_length = get_bits(&gb, 16) + 1; sconf->ra_distance = get_bits(&gb, 8); sconf->ra_flag = get_bits(&gb, 2); @@ -312,7 +321,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx) sconf->mc_coding = get_bits1(&gb); sconf->chan_config = get_bits1(&gb); sconf->chan_sort = get_bits1(&gb); - crc_enabled = get_bits1(&gb); + sconf->crc_enabled = get_bits1(&gb); sconf->rlslms = get_bits1(&gb); skip_bits(&gb, 5); // skip 5 reserved bits skip_bits1(&gb); // skip aux_data_enabled @@ -375,12 +384,17 @@ static av_cold int read_specific_config(ALSDecContext *ctx) skip_bits_long(&gb, ht_size); - // skip the crc data - if (crc_enabled) { + // initialize CRC calculation + if (sconf->crc_enabled) { if (get_bits_left(&gb) < 32) return -1; - skip_bits_long(&gb, 32); + if (avctx->error_recognition >= FF_ER_CAREFUL) { + ctx->crc_table = av_crc_get_table(AV_CRC_32_IEEE_LE); + ctx->crc = 0xFFFFFFFF; + ctx->crc_org = ~get_bits_long(&gb, 32); + } else + skip_bits_long(&gb, 32); } @@ -392,7 +406,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx) } -/** Checks the ALSSpecificConfig for unsupported features. +/** Check the ALSSpecificConfig for unsupported features. */ static int check_specific_config(ALSDecContext *ctx) { @@ -416,7 +430,7 @@ static int check_specific_config(ALSDecContext *ctx) } -/** Parses the bs_info field to extract the block partitioning used in +/** Parse the bs_info field to extract the block partitioning used in * block switching mode, refer to ISO/IEC 14496-3, section 11.6.2. */ static void parse_bs_info(const uint32_t bs_info, unsigned int n, @@ -440,7 +454,7 @@ static void parse_bs_info(const uint32_t bs_info, unsigned int n, } -/** Reads and decodes a Rice codeword. +/** Read and decode a Rice codeword. */ static int32_t decode_rice(GetBitContext *gb, unsigned int k) { @@ -458,7 +472,7 @@ static int32_t decode_rice(GetBitContext *gb, unsigned int k) } -/** Converts PARCOR coefficient k to direct filter coefficient. +/** Convert PARCOR coefficient k to direct filter coefficient. */ static void parcor_to_lpc(unsigned int k, const int32_t *par, int32_t *cof) { @@ -476,8 +490,8 @@ static void parcor_to_lpc(unsigned int k, const int32_t *par, int32_t *cof) } -/** Reads block switching field if necessary and sets actual block sizes. - * Also assures that the block sizes of the last frame correspond to the +/** Read block switching field if necessary and set actual block sizes. + * Also assure that the block sizes of the last frame correspond to the * actual number of samples. */ static void get_block_sizes(ALSDecContext *ctx, unsigned int *div_blocks, @@ -531,7 +545,7 @@ static void get_block_sizes(ALSDecContext *ctx, unsigned int *div_blocks, } -/** Reads the block data for a constant block +/** Read the block data for a constant block */ static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd) { @@ -556,7 +570,7 @@ static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd) } -/** Decodes the block data for a constant block +/** Decode the block data for a constant block */ static void decode_const_block_data(ALSDecContext *ctx, ALSBlockData *bd) { @@ -570,7 +584,7 @@ static void decode_const_block_data(ALSDecContext *ctx, ALSBlockData *bd) } -/** Reads the block data for a non-constant block +/** Read the block data for a non-constant block */ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd) { @@ -734,8 +748,8 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd) // read all residuals if (sconf->bgmc) { - unsigned int delta[sub_blocks]; - unsigned int k [sub_blocks]; + unsigned int delta[8]; + unsigned int k [8]; unsigned int b = av_clip((av_ceil_log2(bd->block_length) - 3) >> 1, 0, 5); unsigned int i = start; @@ -817,7 +831,7 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd) } -/** Decodes the block data for a non-constant block +/** Decode the block data for a non-constant block */ static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd) { @@ -926,7 +940,7 @@ static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd) } -/** Reads the block data. +/** Read the block data. */ static int read_block(ALSDecContext *ctx, ALSBlockData *bd) { @@ -944,7 +958,7 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd) } -/** Decodes the block data. +/** Decode the block data. */ static int decode_block(ALSDecContext *ctx, ALSBlockData *bd) { @@ -966,7 +980,7 @@ static int decode_block(ALSDecContext *ctx, ALSBlockData *bd) } -/** Reads and decodes block data successively. +/** Read and decode block data successively. */ static int read_decode_block(ALSDecContext *ctx, ALSBlockData *bd) { @@ -983,7 +997,7 @@ static int read_decode_block(ALSDecContext *ctx, ALSBlockData *bd) } -/** Computes the number of samples left to decode for the current frame and +/** Compute the number of samples left to decode for the current frame and * sets these samples to zero. */ static void zero_remaining(unsigned int b, unsigned int b_max, @@ -999,7 +1013,7 @@ static void zero_remaining(unsigned int b, unsigned int b_max, } -/** Decodes blocks independently. +/** Decode blocks independently. */ static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame, unsigned int c, const unsigned int *div_blocks, @@ -1037,7 +1051,7 @@ static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame, } -/** Decodes blocks dependently. +/** Decode blocks dependently. */ static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame, unsigned int c, const unsigned int *div_blocks, @@ -1118,7 +1132,7 @@ static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame, } -/** Reads the channel data. +/** Read the channel data. */ static int read_channel_data(ALSDecContext *ctx, ALSChannelData *cd, int c) { @@ -1246,7 +1260,7 @@ static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd, } -/** Reads the frame data. +/** Read the frame data. */ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) { @@ -1375,7 +1389,7 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame) } -/** Decodes an ALS frame. +/** Decode an ALS frame. */ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, @@ -1437,6 +1451,59 @@ static int decode_frame(AVCodecContext *avctx, INTERLEAVE_OUTPUT(32) } + // update CRC + if (sconf->crc_enabled && avctx->error_recognition >= FF_ER_CAREFUL) { + int swap = HAVE_BIGENDIAN != sconf->msb_first; + + if (ctx->avctx->bits_per_raw_sample == 24) { + int32_t *src = data; + + for (sample = 0; + sample < ctx->cur_frame_length * avctx->channels; + sample++) { + int32_t v; + + if (swap) + v = av_bswap32(src[sample]); + else + v = src[sample]; + if (!HAVE_BIGENDIAN) + v >>= 8; + + ctx->crc = av_crc(ctx->crc_table, ctx->crc, (uint8_t*)(&v), 3); + } + } else { + uint8_t *crc_source; + + if (swap) { + if (ctx->avctx->bits_per_raw_sample <= 16) { + int16_t *src = (int16_t*) data; + int16_t *dest = (int16_t*) ctx->crc_buffer; + for (sample = 0; + sample < ctx->cur_frame_length * avctx->channels; + sample++) + *dest++ = av_bswap16(src[sample]); + } else { + ctx->dsp.bswap_buf((uint32_t*)ctx->crc_buffer, data, + ctx->cur_frame_length * avctx->channels); + } + crc_source = ctx->crc_buffer; + } else { + crc_source = data; + } + + ctx->crc = av_crc(ctx->crc_table, ctx->crc, crc_source, size); + } + + + // check CRC sums if this is the last frame + if (ctx->cur_frame_length != sconf->frame_length && + ctx->crc_org != ctx->crc) { + av_log(avctx, AV_LOG_ERROR, "CRC error.\n"); + } + } + + bytes_read = invalid_frame ? buffer_size : (get_bits_count(&ctx->gb) + 7) >> 3; @@ -1444,7 +1511,7 @@ static int decode_frame(AVCodecContext *avctx, } -/** Uninitializes the ALS decoder. +/** Uninitialize the ALS decoder. */ static av_cold int decode_end(AVCodecContext *avctx) { @@ -1474,7 +1541,7 @@ static av_cold int decode_end(AVCodecContext *avctx) } -/** Initializes the ALS decoder. +/** Initialize the ALS decoder. */ static av_cold int decode_init(AVCodecContext *avctx) { @@ -1606,11 +1673,27 @@ static av_cold int decode_init(AVCodecContext *avctx) for (c = 1; c < avctx->channels; c++) ctx->raw_samples[c] = ctx->raw_samples[c - 1] + channel_size; + // allocate crc buffer + if (HAVE_BIGENDIAN != sconf->msb_first && sconf->crc_enabled && + avctx->error_recognition >= FF_ER_CAREFUL) { + ctx->crc_buffer = av_malloc(sizeof(*ctx->crc_buffer) * + ctx->cur_frame_length * + avctx->channels * + (av_get_bits_per_sample_format(avctx->sample_fmt) >> 3)); + if (!ctx->crc_buffer) { + av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n"); + decode_end(avctx); + return AVERROR(ENOMEM); + } + } + + dsputil_init(&ctx->dsp, avctx); + return 0; } -/** Flushes (resets) the frame ID after seeking. +/** Flush (reset) the frame ID after seeking. */ static av_cold void flush(AVCodecContext *avctx) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/apedec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/apedec.c index 03f910905..dd372e275 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/apedec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/apedec.c @@ -893,6 +893,6 @@ AVCodec ape_decoder = { ape_decode_close, ape_decode_frame, .capabilities = CODEC_CAP_SUBFRAMES, - .flush= ape_flush, + .flush = ape_flush, .long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"), }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/Makefile b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/Makefile index 0f2466ff8..bab4b875c 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/Makefile +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/Makefile @@ -43,8 +43,11 @@ NEON-OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_neon.o \ NEON-OBJS-$(CONFIG_VP3_DECODER) += arm/vp3dsp_neon.o -NEON-OBJS-$(CONFIG_VP5_DECODER) += arm/vp56dsp_neon.o -NEON-OBJS-$(CONFIG_VP6_DECODER) += arm/vp56dsp_neon.o +NEON-OBJS-$(CONFIG_VP5_DECODER) += arm/vp56dsp_neon.o \ + arm/vp3dsp_neon.o \ + +NEON-OBJS-$(CONFIG_VP6_DECODER) += arm/vp56dsp_neon.o \ + arm/vp3dsp_neon.o \ OBJS-$(HAVE_NEON) += arm/dsputil_init_neon.o \ arm/dsputil_neon.o \ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/asm-offsets.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/asm-offsets.h index 43e638d3a..c7285ac39 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/asm-offsets.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/asm-offsets.h @@ -29,7 +29,7 @@ #endif /* MpegEncContext */ -#ifdef __ARM_EABI__ +#if defined(__ARM_EABI__) || defined(__eabi__) #define Y_DC_SCALE 0xa54 #define C_DC_SCALE 0xa58 #define AC_PRED 0xa80 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/asm.S b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/asm.S index 17139b4aa..f364a24f9 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/asm.S +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/asm.S @@ -26,37 +26,49 @@ # define ELF @ #endif - .macro require8, val=1 +.macro require8 val=1 ELF .eabi_attribute 24, \val - .endm +.endm - .macro preserve8, val=1 +.macro preserve8 val=1 ELF .eabi_attribute 25, \val - .endm +.endm - .macro function name, export=0 - .macro endfunc +.macro function name, export=0 + .macro endfunc ELF .size \name, . - \name .endfunc .purgem endfunc - .endm -.if \export + .endm + .text + .if \export .global EXTERN_ASM\name EXTERN_ASM\name: -.endif + .endif ELF .type \name, %function .func \name \name: - .endm +.endm - .macro movrel rd, val +.macro mov32 rd, val +#if HAVE_ARMV6T2 + movw \rd, #(\val) & 0xffff + .if (\val) >> 16 + movt \rd, #(\val) >> 16 + .endif +#else + ldr \rd, =\val +#endif +.endm + +.macro movrel rd, val #if HAVE_ARMV6T2 && !CONFIG_PIC movw \rd, #:lower16:\val movt \rd, #:upper16:\val #else ldr \rd, =\val #endif - .endm +.endm #if HAVE_VFP_ARGS .eabi_attribute 28, 1 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/dsputil_init_neon.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/dsputil_init_neon.c index ff1967248..04ebb0057 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/dsputil_init_neon.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/dsputil_init_neon.c @@ -168,10 +168,10 @@ void ff_float_to_int16_interleave_neon(int16_t *, const float **, long, int); void ff_vorbis_inverse_coupling_neon(float *mag, float *ang, int blocksize); -int32_t ff_scalarproduct_int16_neon(int16_t *v1, int16_t *v2, int len, +int32_t ff_scalarproduct_int16_neon(const int16_t *v1, const int16_t *v2, int len, int shift); -int32_t ff_scalarproduct_and_madd_int16_neon(int16_t *v1, int16_t *v2, - int16_t *v3, int len, int mul); +int32_t ff_scalarproduct_and_madd_int16_neon(int16_t *v1, const int16_t *v2, + const int16_t *v3, int len, int mul); void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/fft_neon.S b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/fft_neon.S index 08589db09..72431535d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/fft_neon.S +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/fft_neon.S @@ -320,7 +320,7 @@ function ff_fft_permute_neon, export=1 push {r4,lr} mov r12, #1 ldr r2, [r0] @ nbits - ldr r3, [r0, #20] @ tmp_buf + ldr r3, [r0, #12] @ tmp_buf ldr r0, [r0, #8] @ revtab lsl r12, r12, r2 mov r2, r12 @@ -364,7 +364,7 @@ fft_tab_neon: .word fft16384_neon .word fft32768_neon .word fft65536_neon - .size fft_tab_neon, . - fft_tab_neon +ELF .size fft_tab_neon, . - fft_tab_neon .align 4 pmmp: .float +1.0, -1.0, -1.0, +1.0 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/h264pred_init_arm.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/h264pred_init_arm.c index a56759a8c..87cc558eb 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/h264pred_init_arm.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/h264pred_init_arm.c @@ -46,9 +46,10 @@ static void ff_h264_pred_init_neon(H264PredContext *h, int codec_id) { h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vert_neon; h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_hor_neon; - h->pred8x8[PLANE_PRED8x8 ] = ff_pred8x8_plane_neon; + if (codec_id != CODEC_ID_VP8) + h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon; h->pred8x8[DC_128_PRED8x8 ] = ff_pred8x8_128_dc_neon; - if (codec_id != CODEC_ID_RV40) { + if (codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8) { h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_neon; h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon; h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon; @@ -64,7 +65,7 @@ static void ff_h264_pred_init_neon(H264PredContext *h, int codec_id) h->pred16x16[LEFT_DC_PRED8x8] = ff_pred16x16_left_dc_neon; h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon; h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_neon; - if (codec_id != CODEC_ID_SVQ3 && codec_id != CODEC_ID_RV40) + if (codec_id != CODEC_ID_SVQ3 && codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8) h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/mdct_neon.S b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/mdct_neon.S index fac75be8e..fcf802275 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/mdct_neon.S +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/mdct_neon.S @@ -31,8 +31,8 @@ function ff_imdct_half_neon, export=1 push {r4-r8,lr} mov r12, #1 - ldr lr, [r0, #28] @ mdct_bits - ldr r4, [r0, #32] @ tcos + ldr lr, [r0, #20] @ mdct_bits + ldr r4, [r0, #24] @ tcos ldr r3, [r0, #8] @ revtab lsl r12, r12, lr @ n = 1 << nbits lsr lr, r12, #2 @ n4 = n >> 2 @@ -76,8 +76,8 @@ function ff_imdct_half_neon, export=1 bl ff_fft_calc_neon mov r12, #1 - ldr lr, [r4, #28] @ mdct_bits - ldr r4, [r4, #32] @ tcos + ldr lr, [r4, #20] @ mdct_bits + ldr r4, [r4, #24] @ tcos lsl r12, r12, lr @ n = 1 << nbits lsr lr, r12, #3 @ n8 = n >> 3 @@ -127,7 +127,7 @@ endfunc function ff_imdct_calc_neon, export=1 push {r4-r6,lr} - ldr r3, [r0, #28] + ldr r3, [r0, #20] mov r4, #1 mov r5, r1 lsl r4, r4, r3 @@ -164,8 +164,8 @@ function ff_mdct_calc_neon, export=1 push {r4-r10,lr} mov r12, #1 - ldr lr, [r0, #28] @ mdct_bits - ldr r4, [r0, #32] @ tcos + ldr lr, [r0, #20] @ mdct_bits + ldr r4, [r0, #24] @ tcos ldr r3, [r0, #8] @ revtab lsl lr, r12, lr @ n = 1 << nbits add r7, r2, lr @ in4u @@ -253,8 +253,8 @@ function ff_mdct_calc_neon, export=1 bl ff_fft_calc_neon mov r12, #1 - ldr lr, [r4, #28] @ mdct_bits - ldr r4, [r4, #32] @ tcos + ldr lr, [r4, #20] @ mdct_bits + ldr r4, [r4, #24] @ tcos lsl r12, r12, lr @ n = 1 << nbits lsr lr, r12, #3 @ n8 = n >> 3 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/simple_idct_neon.S b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/simple_idct_neon.S index f27208e46..17cde5835 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/simple_idct_neon.S +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/arm/simple_idct_neon.S @@ -243,7 +243,6 @@ endfunc .align 4 idct_coeff_neon: .short W1, W2, W3, W4, W5, W6, W7, W4c - .previous .macro idct_start data push {r4-r7, lr} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/asv1.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/asv1.c index 211a13faf..6b1a0935a 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/asv1.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/asv1.c @@ -588,8 +588,8 @@ static av_cold int encode_init(AVCodecContext *avctx){ 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(AV_RL32("ASUS")); + ((uint32_t*)avctx->extradata)[0]= av_le2ne32(a->inv_qscale); + ((uint32_t*)avctx->extradata)[1]= av_le2ne32(AV_RL32("ASUS")); for(i=0; i<64; i++){ int q= 32*scale*ff_mpeg1_default_intra_matrix[i]; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/atrac3.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/atrac3.c index 5179c345c..c29fb1925 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/atrac3.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/atrac3.c @@ -166,9 +166,9 @@ static void IMLT(float *pInput, float *pOutput, int odd_band) /** * Atrac 3 indata descrambling, only used for data coming from the rm container * - * @param in pointer to 8 bit array of indata - * @param bits amount of bits + * @param inbuffer pointer to 8 bit array of indata * @param out pointer to 8 bit array of outdata + * @param bytes amount of bytes */ static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){ @@ -179,7 +179,7 @@ static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){ off = (intptr_t)inbuffer & 3; buf = (const uint32_t*) (inbuffer - off); - c = be2me_32((0x537F6103 >> (off*8)) | (0x537F6103 << (32-(off*8)))); + c = av_be2ne32((0x537F6103 >> (off*8)) | (0x537F6103 << (32-(off*8)))); bytes += 3 + off; for (i = 0; i < bytes/4; i++) obuf[i] = c ^ buf[i]; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/avcodec.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/avcodec.h index 0180f68bd..48666f997 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/avcodec.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/avcodec.h @@ -30,8 +30,8 @@ #include "libavutil/avutil.h" #define LIBAVCODEC_VERSION_MAJOR 52 -#define LIBAVCODEC_VERSION_MINOR 74 -#define LIBAVCODEC_VERSION_MICRO 1 +#define LIBAVCODEC_VERSION_MINOR 83 +#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ @@ -48,7 +48,7 @@ #define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE} /** - * Identifies the syntax and semantics of the bitstream. + * Identify the syntax and semantics of the bitstream. * The principle is roughly: * Two decoders with the same ID can decode the same streams. * Two encoders with the same ID can encode compatible streams. @@ -211,6 +211,7 @@ enum CodecID { CODEC_ID_KGV1, CODEC_ID_YOP, CODEC_ID_VP8, + CODEC_ID_PICTOR, /* various PCM "codecs" */ CODEC_ID_PCM_S16LE= 0x10000, @@ -287,7 +288,6 @@ enum CodecID { CODEC_ID_MP2= 0x15000, CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 CODEC_ID_AAC, - CODEC_ID_AAC_LATM, CODEC_ID_AC3, CODEC_ID_DTS, CODEC_ID_VORBIS, @@ -348,10 +348,6 @@ enum CodecID { CODEC_ID_HDMV_PGS_SUBTITLE, CODEC_ID_DVB_TELETEXT, - /* data codecs */ - CODEC_ID_VBI_DATA= 0x17500, - CODEC_ID_VBI_TELETEXT, - /* other specific kind of codecs (generally used for attachments) */ CODEC_ID_TTF= 0x18000, @@ -530,6 +526,18 @@ enum AVChromaLocation{ AVCHROMA_LOC_NB , ///< Not part of ABI }; +/** + * LPC analysis type + */ +enum AVLPCType { + AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type + AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients + AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients + AV_LPC_TYPE_LEVINSON = 2, ///< Levinson-Durbin recursion + AV_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization + AV_LPC_TYPE_NB , ///< Not part of ABI +}; + typedef struct RcOverride{ int start_frame; int end_frame; @@ -999,6 +1007,8 @@ typedef struct AVPacket { * the very first frame or from this keyframe. * Is AV_NOPTS_VALUE if unknown. * This field is not the display duration of the current packet. + * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY + * set. * * The purpose of this field is to allow seeking in streams that have no * keyframes in the conventional sense. It corresponds to the @@ -1125,8 +1135,10 @@ typedef struct AVCodecContext { /** * Pixel format, see PIX_FMT_xxx. + * May be set by the demuxer if known from headers. + * May be overriden by the decoder if it knows better. * - encoding: Set by user. - * - decoding: Set by libavcodec. + * - decoding: Set by user if known, overridden by libavcodec if known */ enum PixelFormat pix_fmt; @@ -1352,10 +1364,10 @@ typedef struct AVCodecContext { * - encoding: Set by user. * - decoding: Set by user. * Setting this to STRICT or higher means the encoder and decoder will - * generally do stupid things, whereas setting it to inofficial or lower + * generally do stupid things, whereas setting it to unofficial or lower * will mean the encoder might produce output that is not supported by all * spec-compliant decoders. Decoders don't differentiate between normal, - * inofficial and experimental (that is, they always try to decode things + * unofficial and experimental (that is, they always try to decode things * when they can) unless they are explicitly asked to behave stupidly * (=strictly conform to the specs) */ @@ -1363,7 +1375,10 @@ typedef struct AVCodecContext { #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software. #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences. #define FF_COMPLIANCE_NORMAL 0 -#define FF_COMPLIANCE_INOFFICIAL -1 ///< Allow inofficial extensions. +#if LIBAVCODEC_VERSION_MAJOR < 53 +#define FF_COMPLIANCE_INOFFICIAL -1 ///< Allow inofficial extensions (deprecated - use FF_COMPLIANCE_UNOFFICIAL instead). +#endif +#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things. /** @@ -1394,7 +1409,7 @@ typedef struct AVCodecContext { * avcodec_default_get_buffer() instead of providing buffers allocated by * some other means. * - encoding: unused - * - decoding: Set by libavcodec., user can override. + * - decoding: Set by libavcodec, user can override. */ int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic); @@ -1403,7 +1418,7 @@ typedef struct AVCodecContext { * A released buffer can be reused in get_buffer(). * pic.data[*] must be set to NULL. * - encoding: unused - * - decoding: Set by libavcodec., user can override. + * - decoding: Set by libavcodec, user can override. */ void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic); @@ -2026,7 +2041,7 @@ typedef struct AVCodecContext { * avcodec_default_reget_buffer() instead of providing buffers allocated by * some other means. * - encoding: unused - * - decoding: Set by libavcodec., user can override + * - decoding: Set by libavcodec, user can override. */ int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic); @@ -2410,12 +2425,15 @@ typedef struct AVCodecContext { int compression_level; #define FF_COMPRESSION_DEFAULT -1 +#if LIBAVCODEC_VERSION_MAJOR < 53 /** * Sets whether to use LPC mode - used by FLAC encoder. * - encoding: Set by user. * - decoding: unused + * @deprecated Deprecated in favor of lpc_type and lpc_passes. */ int use_lpc; +#endif /** * LPC coefficient precision - used by FLAC encoder @@ -2669,6 +2687,20 @@ typedef struct AVCodecContext { float crf_max; int log_level_offset; + + /** + * Determines which LPC analysis algorithm to use. + * - encoding: Set by user + * - decoding: unused + */ + enum AVLPCType lpc_type; + + /** + * Number of passes to use for Cholesky factorization during LPC analysis + * - encoding: Set by user + * - decoding: unused + */ + int lpc_passes; } AVCodecContext; /** @@ -2710,6 +2742,7 @@ typedef struct AVCodec { const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 const enum SampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 const int64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 + uint8_t max_lowres; ///< maximum value for lowres supported by the decoder } AVCodec; /** @@ -2953,7 +2986,7 @@ attribute_deprecated ReSampleContext *audio_resample_init(int output_channels, i int output_rate, int input_rate); #endif /** - * Initializes audio resampling context + * Initialize audio resampling context * * @param output_channels number of output channels * @param input_channels number of input channels @@ -2980,7 +3013,7 @@ void audio_resample_close(ReSampleContext *s); /** - * Initializes an audio resampler. + * Initialize an audio resampler. * Note, if either rate is not an integer then simply scale both rates up so they are. * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq * @param log2_phase_count log2 of the number of entries in the polyphase filterbank @@ -2991,7 +3024,7 @@ void audio_resample_close(ReSampleContext *s); struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff); /** - * resamples. + * Resample an array of samples using a previously configured context. * @param src an array of unconsumed samples * @param consumed the number of samples of src which have been consumed are returned here * @param src_size the number of unconsumed samples available @@ -3003,7 +3036,7 @@ int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consum /** - * Compensates samplerate/timestamp drift. The compensation is done by changing + * Compensate samplerate/timestamp drift. The compensation is done by changing * the resampler parameters, so no audible clicks or similar distortions occur * @param compensation_distance distance in output samples over which the compensation should be performed * @param sample_delta number of output samples which should be output less @@ -3076,15 +3109,15 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height); #if LIBAVCODEC_VERSION_MAJOR < 53 /** - * Returns the pixel format corresponding to the name name. + * Return the pixel format corresponding to the name name. * - * If there is no pixel format with name name, then looks for a + * If there is no pixel format with name name, then look for a * pixel format with the name corresponding to the native endian * format of name. - * For example in a little-endian system, first looks for "gray16", + * For example in a little-endian system, first look for "gray16", * then for "gray16le". * - * Finally if no pixel format has been found, returns PIX_FMT_NONE. + * Finally if no pixel format has been found, return PIX_FMT_NONE. * * @deprecated Deprecated in favor of av_get_pix_fmt(). */ @@ -3092,14 +3125,14 @@ attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name); #endif /** - * Returns a value representing the fourCC code associated to the + * Return a value representing the fourCC code associated to the * pixel format pix_fmt, or 0 if no associated fourCC code can be * found. */ unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt); /** - * Puts a string representing the codec tag codec_tag in buf. + * Put a string representing the codec tag codec_tag in buf. * * @param buf_size size in bytes of buf * @return the length of the string that would have been generated if @@ -3115,7 +3148,7 @@ size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_ta #define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */ /** - * Computes what kind of losses will occur when converting from one specific + * Compute what kind of losses will occur when converting from one specific * pixel format to another. * When converting from one pixel format to another, information loss may occur. * For example, when converting from RGB24 to GRAY, the color information will @@ -3135,7 +3168,7 @@ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_ int has_alpha); /** - * Finds the best pixel format to convert to given a certain source pixel + * Find the best pixel format to convert to given a certain source pixel * format. When converting from one pixel format to another, information loss * may occur. For example, when converting from RGB24 to GRAY, the color * information will be lost. Similarly, other losses occur when converting from @@ -3197,22 +3230,22 @@ int avpicture_deinterlace(AVPicture *dst, const AVPicture *src, AVCodec *av_codec_next(AVCodec *c); /** - * Returns the LIBAVCODEC_VERSION_INT constant. + * Return the LIBAVCODEC_VERSION_INT constant. */ unsigned avcodec_version(void); /** - * Returns the libavcodec build-time configuration. + * Return the libavcodec build-time configuration. */ const char *avcodec_configuration(void); /** - * Returns the libavcodec license. + * Return the libavcodec license. */ const char *avcodec_license(void); /** - * Initializes libavcodec. + * Initialize libavcodec. * * @warning This function must be called before any other libavcodec * function. @@ -3234,7 +3267,7 @@ attribute_deprecated void register_avcodec(AVCodec *codec); void avcodec_register(AVCodec *codec); /** - * Finds a registered encoder with a matching codec ID. + * Find a registered encoder with a matching codec ID. * * @param id CodecID of the requested encoder * @return An encoder if one was found, NULL otherwise. @@ -3242,7 +3275,7 @@ void avcodec_register(AVCodec *codec); AVCodec *avcodec_find_encoder(enum CodecID id); /** - * Finds a registered encoder with the specified name. + * Find a registered encoder with the specified name. * * @param name name of the requested encoder * @return An encoder if one was found, NULL otherwise. @@ -3250,7 +3283,7 @@ AVCodec *avcodec_find_encoder(enum CodecID id); AVCodec *avcodec_find_encoder_by_name(const char *name); /** - * Finds a registered decoder with a matching codec ID. + * Find a registered decoder with a matching codec ID. * * @param id CodecID of the requested decoder * @return A decoder if one was found, NULL otherwise. @@ -3258,7 +3291,7 @@ AVCodec *avcodec_find_encoder_by_name(const char *name); AVCodec *avcodec_find_decoder(enum CodecID id); /** - * Finds a registered decoder with the specified name. + * Find a registered decoder with the specified name. * * @param name name of the requested decoder * @return A decoder if one was found, NULL otherwise. @@ -3267,7 +3300,7 @@ AVCodec *avcodec_find_decoder_by_name(const char *name); void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); /** - * Sets the fields of the given AVCodecContext to default values. + * Set the fields of the given AVCodecContext to default values. * * @param s The AVCodecContext of which the fields should be set to default values. */ @@ -3278,7 +3311,7 @@ void avcodec_get_context_defaults(AVCodecContext *s); void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType); /** - * Allocates an AVCodecContext and sets its fields to default values. The + * Allocate an AVCodecContext and set its fields to default values. The * resulting struct can be deallocated by simply calling av_free(). * * @return An AVCodecContext filled with default values or NULL on failure. @@ -3304,14 +3337,14 @@ AVCodecContext *avcodec_alloc_context2(enum AVMediaType); int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); /** - * Sets the fields of the given AVFrame to default values. + * Set the fields of the given AVFrame to default values. * * @param pic The AVFrame of which the fields should be set to default values. */ void avcodec_get_frame_defaults(AVFrame *pic); /** - * Allocates an AVFrame and sets its fields to default values. The resulting + * Allocate an AVFrame and set its fields to default values. The resulting * struct can be deallocated by simply calling av_free(). * * @return An AVFrame filled with default values or NULL on failure. @@ -3324,7 +3357,7 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic); int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic); /** - * Returns the amount of padding in pixels which the get_buffer callback must + * Return the amount of padding in pixels which the get_buffer callback must * provide around the edge of the image for codecs which do not have the * CODEC_FLAG_EMU_EDGE flag. * @@ -3332,7 +3365,7 @@ int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic); */ unsigned avcodec_get_edge_width(void); /** - * Modifies width and height values so that they will result in a memory + * Modify width and height values so that they will result in a memory * buffer that is acceptable for the codec if you do not use any horizontal * padding. * @@ -3342,7 +3375,7 @@ unsigned avcodec_get_edge_width(void); */ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); /** - * Modifies width and height values so that they will result in a memory + * Modify width and height values so that they will result in a memory * buffer that is acceptable for the codec if you also ensure that all * line sizes are a multiple of the respective linesize_align[i]. * @@ -3354,7 +3387,7 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]); /** - * Checks if the given dimension of a picture is valid, meaning that all + * Check if the given dimension of a picture is valid, meaning that all * bytes of the picture can be addressed with a signed int. * * @param[in] w Width of the picture. @@ -3371,7 +3404,7 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, //FIXME func typedef /** - * Initializes the AVCodecContext to use the given AVCodec. Prior to using this + * Initialize the AVCodecContext to use the given AVCodec. Prior to using this * function the context has to be allocated. * * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), @@ -3401,7 +3434,7 @@ int avcodec_open(AVCodecContext *avctx, AVCodec *codec); #if LIBAVCODEC_VERSION_MAJOR < 53 /** - * Decodes an audio frame from buf into samples. + * Decode an audio frame from buf into samples. * Wrapper function which calls avcodec_decode_audio3. * * @deprecated Use avcodec_decode_audio3 instead. @@ -3419,7 +3452,7 @@ attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *s #endif /** - * Decodes the audio frame of size avpkt->size from avpkt->data into samples. + * Decode the audio frame of size avpkt->size from avpkt->data into samples. * Some decoders may support multiple frames in a single AVPacket, such * decoders would then just decode the first frame. In this case, * avcodec_decode_audio3 has to be called again with an AVPacket that contains @@ -3463,7 +3496,7 @@ int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, #if LIBAVCODEC_VERSION_MAJOR < 53 /** - * Decodes a video frame from buf into picture. + * Decode a video frame from buf into picture. * Wrapper function which calls avcodec_decode_video2. * * @deprecated Use avcodec_decode_video2 instead. @@ -3481,7 +3514,7 @@ attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *pi #endif /** - * Decodes the video frame of size avpkt->size from avpkt->data into picture. + * Decode the video frame of size avpkt->size from avpkt->data into picture. * Some decoders may support multiple frames in a single AVPacket, such * decoders would then just decode the first frame. * @@ -3534,25 +3567,38 @@ attribute_deprecated int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtit #endif /** - * Decodes a subtitle message. - * Returns a negative value on error, otherwise returns the number of bytes used. + * Decode a subtitle message. + * Return a negative value on error, otherwise return the number of bytes used. * If no subtitle could be decompressed, got_sub_ptr is zero. * Otherwise, the subtitle is stored in *sub. + * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for + * simplicity, because the performance difference is expect to be negligible + * and reusing a get_buffer written for video codecs would probably perform badly + * due to a potentially very different allocation pattern. * * @param avctx the codec context - * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored. + * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be + freed with avsubtitle_free if *got_sub_ptr is set. * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero. * @param[in] avpkt The input AVPacket containing the input buffer. */ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt); + +/** + * Frees all allocated data in the given subtitle struct. + * + * @param sub AVSubtitle to free. + */ +void avsubtitle_free(AVSubtitle *sub); + int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, int *data_size_ptr, uint8_t *buf, int buf_size); /** - * Encodes an audio frame from samples into buf. + * Encode an audio frame from samples into buf. * * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large. * However, for PCM audio the user will know how much space is needed @@ -3574,7 +3620,7 @@ int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples); /** - * Encodes a video frame from pict into buf. + * Encode a video frame from pict into buf. * The input picture should be * stored using a specific format, namely avctx.pix_fmt. * @@ -3614,7 +3660,7 @@ void avcodec_default_free_buffers(AVCodecContext *s); /* misc useful functions */ /** - * Returns a single letter to describe the given picture type pict_type. + * Return a single letter to describe the given picture type pict_type. * * @param[in] pict_type the picture type * @return A single character representing the picture type. @@ -3622,7 +3668,7 @@ void avcodec_default_free_buffers(AVCodecContext *s); char av_get_pict_type_char(int pict_type); /** - * Returns codec bits per sample. + * Return codec bits per sample. * * @param[in] codec_id the codec * @return Number of bits per sample or zero if unknown for the given codec. @@ -3630,7 +3676,7 @@ char av_get_pict_type_char(int pict_type); int av_get_bits_per_sample(enum CodecID codec_id); /** - * Returns sample format bits per sample. + * Return sample format bits per sample. * * @param[in] sample_fmt the sample format * @return Number of bits per sample or zero if unknown for the given sample format. @@ -3694,6 +3740,8 @@ typedef struct AVCodecParserContext { * the very first frame or from this keyframe. * Is AV_NOPTS_VALUE if unknown. * This field is not the display duration of the current frame. + * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY + * set. * * The purpose of this field is to allow seeking in streams that have no * keyframes in the conventional sense. It corresponds to the @@ -3863,15 +3911,14 @@ AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f); /* memory */ /** - * Reallocates the given block if it is not large enough, otherwise it - * does nothing. + * Reallocate the given block if it is not large enough, otherwise do nothing. * * @see av_realloc */ void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size); /** - * Allocates a buffer, reusing the given one if large enough. + * Allocate a buffer, reusing the given one if large enough. * * Contrary to av_fast_realloc the current buffer contents might not be * preserved and on error the old buffer is freed, thus no special @@ -3903,7 +3950,7 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, int padtop, int padbottom, int padleft, int padright, int *color); /** - * Encodes extradata length to a buffer. Used by xiph codecs. + * Encode extradata length to a buffer. Used by xiph codecs. * * @param s buffer to write to; must be at least (v/255+1) bytes long * @param v size of extradata in bytes @@ -3912,11 +3959,11 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, unsigned int av_xiphlacing(unsigned char *s, unsigned int v); /** - * Parses str and put in width_ptr and height_ptr the detected values. + * Parse str and put in width_ptr and height_ptr the detected values. * * @return 0 in case of a successful parsing, a negative value otherwise * @param[in] str the string to parse: it has to be a string in the format - * x or a valid video frame size abbreviation. + * width x height or a valid video frame size abbreviation. * @param[in,out] width_ptr pointer to the variable which will contain the detected * frame width value * @param[in,out] height_ptr pointer to the variable which will contain the detected @@ -3925,11 +3972,11 @@ unsigned int av_xiphlacing(unsigned char *s, unsigned int v); int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str); /** - * Parses str and put in frame_rate the detected values. + * Parse str and store the detected values in *frame_rate. * * @return 0 in case of a successful parsing, a negative value otherwise * @param[in] str the string to parse: it has to be a string in the format - * /, a float number or a valid video rate abbreviation + * frame_rate_num / frame_rate_den, a float number or a valid video rate abbreviation * @param[in,out] frame_rate pointer to the AVRational which will contain the detected * frame rate */ @@ -3950,7 +3997,7 @@ int av_parse_video_frame_rate(AVRational *frame_rate, const char *str); void av_log_missing_feature(void *avc, const char *feature, int want_sample); /** - * Logs a generic warning message asking for a sample. This function is + * Log a generic warning message asking for a sample. This function is * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.) * only, and would normally not be used by applications. * @param[in] avc a pointer to an arbitrary struct of which the first field is @@ -3960,7 +4007,7 @@ void av_log_missing_feature(void *avc, const char *feature, int want_sample); void av_log_ask_for_sample(void *avc, const char *msg); /** - * Registers the hardware accelerator hwaccel. + * Register the hardware accelerator hwaccel. */ void av_register_hwaccel(AVHWAccel *hwaccel); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/avfft.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/avfft.c index 25fc4e095..7d5d08390 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/avfft.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/avfft.c @@ -26,8 +26,8 @@ FFTContext *av_fft_init(int nbits, int inverse) { FFTContext *s = av_malloc(sizeof(*s)); - if (s) - ff_fft_init(s, nbits, inverse); + if (s && ff_fft_init(s, nbits, inverse)) + av_freep(&s); return s; } @@ -56,8 +56,8 @@ FFTContext *av_mdct_init(int nbits, int inverse, double scale) { FFTContext *s = av_malloc(sizeof(*s)); - if (s) - ff_mdct_init(s, nbits, inverse, scale); + if (s && ff_mdct_init(s, nbits, inverse, scale)) + av_freep(&s); return s; } @@ -93,8 +93,8 @@ RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans) { RDFTContext *s = av_malloc(sizeof(*s)); - if (s) - ff_rdft_init(s, nbits, trans); + if (s && ff_rdft_init(s, nbits, trans)) + av_freep(&s); return s; } @@ -120,8 +120,8 @@ DCTContext *av_dct_init(int nbits, enum DCTTransformType inverse) { DCTContext *s = av_malloc(sizeof(*s)); - if (s) - ff_dct_init(s, nbits, inverse); + if (s && ff_dct_init(s, nbits, inverse)) + av_freep(&s); return s; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/avfft.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/avfft.h index 623f0a33b..be2d9c7e1 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/avfft.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/avfft.h @@ -85,7 +85,7 @@ enum DCTTransformType { }; /** - * Sets up DCT. + * Set up DCT. * @param nbits size of the input array: * (1 << nbits) for DCT-II, DCT-III and DST-I * (1 << nbits) + 1 for DCT-I diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/beosthread.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/beosthread.c deleted file mode 100644 index 44fe492c4..000000000 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/beosthread.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2004 François Revol - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -//#define DEBUG - -#include "avcodec.h" - -#include - -typedef struct ThreadContext{ - AVCodecContext *avctx; - thread_id thread; - sem_id work_sem; - sem_id done_sem; - int (*func)(AVCodecContext *c, void *arg); - void *arg; - int ret; -}ThreadContext; - -// it's odd Be never patented that :D -struct benaphore { - vint32 atom; - sem_id sem; -}; -static inline int lock_ben(struct benaphore *ben) -{ - if (atomic_add(&ben->atom, 1) > 0) - return acquire_sem(ben->sem); - return B_OK; -} -static inline int unlock_ben(struct benaphore *ben) -{ - if (atomic_add(&ben->atom, -1) > 1) - return release_sem(ben->sem); - return B_OK; -} - -static struct benaphore av_thread_lib_ben; - -static int32 ff_thread_func(void *v){ - ThreadContext *c= v; - - for(;;){ -//printf("thread_func %X enter wait\n", (int)v); fflush(stdout); - acquire_sem(c->work_sem); -//printf("thread_func %X after wait (func=%X)\n", (int)v, (int)c->func); fflush(stdout); - if(c->func) - c->ret= c->func(c->avctx, c->arg); - else - return 0; -//printf("thread_func %X signal complete\n", (int)v); fflush(stdout); - release_sem(c->done_sem); - } - - return B_OK; -} - -/** - * Free what has been allocated by avcodec_thread_init(). - * Must be called after decoding has finished, especially do not call while avcodec_thread_execute() is running. - */ -void avcodec_thread_free(AVCodecContext *s){ - ThreadContext *c= s->thread_opaque; - int i; - int32 ret; - - for(i=0; ithread_count; i++){ - - c[i].func= NULL; - release_sem(c[i].work_sem); - wait_for_thread(c[i].thread, &ret); - if(c[i].work_sem > B_OK) delete_sem(c[i].work_sem); - if(c[i].done_sem > B_OK) delete_sem(c[i].done_sem); - } - - av_freep(&s->thread_opaque); -} - -static int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size){ - ThreadContext *c= s->thread_opaque; - int i; - - assert(s == c->avctx); - assert(count <= s->thread_count); - - /* note, we can be certain that this is not called with the same AVCodecContext by different threads at the same time */ - - for(i=0; ithread_count= thread_count; - - if (thread_count <= 1) - return 0; - - assert(!s->thread_opaque); - c= av_mallocz(sizeof(ThreadContext)*thread_count); - s->thread_opaque= c; - - for(i=0; iexecute= avcodec_thread_execute; - - return 0; -fail: - avcodec_thread_free(s); - return -1; -} - -/* provide a mean to serialize calls to avcodec_*() for thread safety. */ - -int avcodec_thread_lock_lib(void) -{ - return lock_ben(&av_thread_lib_ben); -} - -int avcodec_thread_unlock_lib(void) -{ - return unlock_ben(&av_thread_lib_ben); -} - -/* our versions of _init and _fini (which are called by those actually from crt.o) */ - -void initialize_after(void) -{ - av_thread_lib_ben.atom = 0; - av_thread_lib_ben.sem = create_sem(0, "libavcodec benaphore"); -} - -void uninitialize_before(void) -{ - delete_sem(av_thread_lib_ben.sem); -} - - - diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bfin/dsputil_bfin.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bfin/dsputil_bfin.c index 161d2daf3..a667deb5f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bfin/dsputil_bfin.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bfin/dsputil_bfin.c @@ -228,18 +228,6 @@ void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx ) c->sse[1] = ff_bfin_sse8; c->sse[2] = ff_bfin_sse4; - - /** - * Halfpel motion compensation with rounding (a+b+1)>>1. - * This is an array[4][4] of motion compensation functions for 4 - * horizontal blocksizes (8,16) and the 4 halfpel positions - * *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 - */ - c->put_pixels_tab[0][0] = bfin_put_pixels16; c->put_pixels_tab[0][1] = bfin_put_pixels16_x2; c->put_pixels_tab[0][2] = bfin_put_pixels16_y2; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bfin/vp3_bfin.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bfin/vp3_bfin.c index b0101785c..dfe34c5b3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bfin/vp3_bfin.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bfin/vp3_bfin.c @@ -25,14 +25,14 @@ /* Intra iDCT offset 128 */ void ff_bfin_vp3_idct_put (uint8_t *dest, int line_size, DCTELEM *block) { - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP + 128; int i,j; ff_bfin_vp3_idct (block); for (i=0;i<8;i++) for (j=0;j<8;j++) - dest[line_size*i+j]=cm[128+block[i*8+j]]; + dest[line_size*i+j]=cm[block[i*8+j]]; } /* Inter iDCT */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bgmc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bgmc.c index 86b807bc2..ffe3cea4a 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bgmc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bgmc.c @@ -424,7 +424,7 @@ static const uint16_t * const cf_table[16] = { }; -/** Initializes a given lookup table using a given delta +/** Initialize a given lookup table using a given delta */ static void bgmc_lut_fillp(uint8_t *lut, unsigned int *lut_status, unsigned int delta) @@ -446,7 +446,7 @@ static void bgmc_lut_fillp(uint8_t *lut, unsigned int *lut_status, } -/** Retunes the index of a suitable lookup table for a given delta +/** Retune the index of a suitable lookup table for a given delta */ static uint8_t* bgmc_lut_getp(uint8_t *lut, unsigned int *lut_status, unsigned int delta) @@ -462,7 +462,7 @@ static uint8_t* bgmc_lut_getp(uint8_t *lut, unsigned int *lut_status, } -/** Initializes the lookup table arrays +/** Initialize the lookup table arrays */ int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, unsigned int **cf_lut_status) { @@ -479,7 +479,7 @@ int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, unsigned int **cf_lut_ } -/** Releases the lookup table arrays +/** Release the lookup table arrays */ void ff_bgmc_end(uint8_t **cf_lut, unsigned int **cf_lut_status) { @@ -488,7 +488,7 @@ void ff_bgmc_end(uint8_t **cf_lut, unsigned int **cf_lut_status) } -/** Initializes decoding and reads the first value +/** Initialize decoding and reads the first value */ void ff_bgmc_decode_init(GetBitContext *gb, unsigned int *h, unsigned int *l, unsigned int *v) @@ -507,7 +507,7 @@ void ff_bgmc_decode_end(GetBitContext *gb) } -/** Reads and decodes a block Gilbert-Moore coded symbol +/** Read and decode a block Gilbert-Moore coded symbol */ void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst, unsigned int delta, unsigned int sx, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bink.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bink.c index b5921f9f4..0a0b5bc91 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bink.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bink.c @@ -106,7 +106,7 @@ enum BlockTypes { }; /** - * Initializes length length in all bundles. + * Initialize length length in all bundles. * * @param c decoder context * @param width plane width @@ -131,7 +131,7 @@ static void init_lengths(BinkContext *c, int width, int bw) } /** - * Allocates memory for bundles. + * Allocate memory for bundles. * * @param c decoder context */ @@ -151,7 +151,7 @@ static av_cold void init_bundles(BinkContext *c) } /** - * Frees memory used by bundles. + * Free memory used by bundles. * * @param c decoder context */ @@ -163,7 +163,7 @@ static av_cold void free_bundles(BinkContext *c) } /** - * Merges two consequent lists of equal size depending on bits read. + * Merge two consequent lists of equal size depending on bits read. * * @param gb context for reading bits * @param dst buffer where merged list will be written to @@ -192,7 +192,7 @@ static void merge(GetBitContext *gb, uint8_t *dst, uint8_t *src, int size) } /** - * Reads information about Huffman tree used to decode data. + * Read information about Huffman tree used to decode data. * * @param gb context for reading bits * @param tree pointer for storing tree data @@ -233,7 +233,7 @@ static void read_tree(GetBitContext *gb, Tree *tree) } /** - * Prepares bundle for decoding data. + * Prepare bundle for decoding data. * * @param gb context for reading bits * @param c decoder context @@ -462,7 +462,7 @@ static int read_dcs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b, } /** - * Retrieves next value from bundle. + * Retrieve next value from bundle. * * @param c decoder context * @param bundle bundle number @@ -481,7 +481,7 @@ static inline int get_value(BinkContext *c, int bundle) } /** - * Reads 8x8 block of DCT coefficients. + * Read 8x8 block of DCT coefficients. * * @param gb context for reading bits * @param block place for storing coefficients @@ -583,7 +583,7 @@ static int read_dct_coeffs(GetBitContext *gb, DCTELEM block[64], const uint8_t * } /** - * Reads 8x8 block with residue after motion compensation. + * Read 8x8 block with residue after motion compensation. * * @param gb context for reading bits * @param block place to store read data diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bmp.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bmp.c index da7bb787d..270452fe6 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bmp.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/bmp.c @@ -290,7 +290,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, uint16_t *dst = (uint16_t *) ptr; for(j = 0; j < avctx->width; j++) - *dst++ = le2me_16(*src++); + *dst++ = av_le2ne16(*src++); buf += n; ptr += linesize; @@ -345,5 +345,6 @@ AVCodec bmp_decoder = { bmp_decode_end, bmp_decode_frame, CODEC_CAP_DR1, + .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("BMP image"), }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cavsdata.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cavsdata.h index b597da198..9e52fd5cc 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cavsdata.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cavsdata.h @@ -88,15 +88,15 @@ const uint16_t ff_cavs_dequant_mul[64] = { 32771,35734,38965,42497,46341,50535,55109,60099 }; -/** marks block as unavailable, i.e. out of picture +/** mark block as unavailable, i.e. out of picture or not yet decoded */ const cavs_vector ff_cavs_un_mv = {0,0,1,NOT_AVAIL}; -/** marks block as "no prediction from this direction" +/** mark block as "no prediction from this direction" e.g. forward motion vector in BWD partition */ const cavs_vector ff_cavs_dir_mv = {0,0,1,REF_DIR}; -/** marks block as using intra prediction */ +/** mark block as using intra prediction */ const cavs_vector ff_cavs_intra_mv = {0,0,1,REF_INTRA}; #define EOB 0,0,0 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cbrt_tablegen.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cbrt_tablegen.c index dbbd63269..e0a8e63a8 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cbrt_tablegen.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cbrt_tablegen.c @@ -31,9 +31,7 @@ int main(void) write_fileheader(); - printf("static const uint32_t cbrt_tab[1<<13] = {\n"); - write_uint32_array(cbrt_tab, 1 << 13); - printf("};\n"); + WRITE_ARRAY("static const", uint32_t, cbrt_tab); return 0; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cdgraphics.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cdgraphics.c index c174aa9d9..8afbb27aa 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cdgraphics.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cdgraphics.c @@ -377,5 +377,6 @@ AVCodec cdgraphics_decoder = { cdg_decode_end, cdg_decode_frame, CODEC_CAP_DR1, + .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("CD Graphics video"), }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/celp_math.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/celp_math.h index 7cf7861ca..4cf656fb7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/celp_math.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/celp_math.h @@ -43,7 +43,7 @@ int16_t ff_cos(uint16_t arg); int ff_exp2(uint16_t power); /** - * Calculates log2(x). + * Calculate log2(x). * @param value function argument, 0 < value <= 7fff ffff * * @return value of (1<<15) * log2(value) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cga_data.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cga_data.c index 2d1f89ce3..35239814e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cga_data.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cga_data.c @@ -155,3 +155,14 @@ const uint32_t ff_cga_palette[16] = { 0x000000, 0x0000AA, 0x00AA00, 0x00AAAA, 0xAA0000, 0xAA00AA, 0xAA5500, 0xAAAAAA, 0x555555, 0x5555FF, 0x55FF55, 0x55FFFF, 0xFF5555, 0xFF55FF, 0xFFFF55, 0xFFFFFF, }; + +const uint32_t ff_ega_palette[64] = { + 0x000000, 0x0000AA, 0x00AA00, 0x00AAAA, 0xAA0000, 0xAA00AA, 0xAAAA00, 0xAAAAAA, + 0x000055, 0x0000FF, 0x00AA55, 0x00AAFF, 0xAA0055, 0xAA00FF, 0xAAAA55, 0xAAAAFF, + 0x005500, 0x0055AA, 0x00FF00, 0x00FFAA, 0xAA5500, 0xAA55AA, 0xAAFF00, 0xAAFFAA, + 0x005555, 0x0055FF, 0x00FF55, 0x00FFFF, 0xAA5555, 0xAA55FF, 0xAAFF55, 0xAAFFFF, + 0x550000, 0x5500AA, 0x55AA00, 0x55AAAA, 0xFF0000, 0xFF00AA, 0xFFAA00, 0xFFAAAA, + 0x550055, 0x5500FF, 0x55AA55, 0x55AAFF, 0xFF0055, 0xFF00FF, 0xFFAA55, 0xFFAAFF, + 0x555500, 0x5555AA, 0x55FF00, 0x55FFAA, 0xFF5500, 0xFF55AA, 0xFFFF00, 0xFFFFAA, + 0x555555, 0x5555FF, 0x55FF55, 0x55FFFF, 0xFF5555, 0xFF55FF, 0xFFFF55, 0xFFFFFF +}; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cga_data.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cga_data.h index c3f69f1f6..09aaaa57a 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cga_data.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cga_data.h @@ -25,5 +25,6 @@ extern const uint8_t ff_cga_font[2048]; extern const uint32_t ff_cga_palette[16]; +extern const uint32_t ff_ega_palette[64]; #endif diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/chomp_bsf.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/chomp_bsf.c index caf1ff9ac..e9ac8e8e2 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/chomp_bsf.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/chomp_bsf.c @@ -38,7 +38,7 @@ static int chomp_filter(AVBitStreamFilterContext *bsfc, } /** - * This filter removes a string of \0 bytes from the end of a packet. + * This filter removes a string of NULL bytes from the end of a packet. */ AVBitStreamFilter chomp_bsf = { "chomp", diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cook.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cook.c index e406e6510..b7e2ef1a9 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cook.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/cook.c @@ -284,6 +284,9 @@ static av_cold void init_cplscales_table (COOKContext *q) { /*************** init functions end ***********/ +#define DECODE_BYTES_PAD1(bytes) (3 - ((bytes)+3) % 4) +#define DECODE_BYTES_PAD2(bytes) ((bytes) % 4 + DECODE_BYTES_PAD1(2 * (bytes))) + /** * Cook indata decoding, every 32 bits are XORed with 0x37c511f2. * Why? No idea, some checksum/error detection method maybe. @@ -304,8 +307,6 @@ static av_cold void init_cplscales_table (COOKContext *q) { * @param out pointer to byte array of outdata * @param bytes number of bytes */ -#define DECODE_BYTES_PAD1(bytes) (3 - ((bytes)+3) % 4) -#define DECODE_BYTES_PAD2(bytes) ((bytes) % 4 + DECODE_BYTES_PAD1(2 * (bytes))) static inline int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){ int i, off; @@ -315,12 +316,12 @@ static inline int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes) /* FIXME: 64 bit platforms would be able to do 64 bits at a time. * I'm too lazy though, should be something like * for(i=0 ; i> (off*8)) | (0x37c511f2 << (32-(off*8)))); + c = av_be2ne32((0x37c511f2 >> (off*8)) | (0x37c511f2 << (32-(off*8)))); bytes += 3 + off; for (i = 0; i < bytes/4; i++) obuf[i] = c ^ buf[i]; @@ -364,8 +365,8 @@ static av_cold int cook_decode_close(AVCodecContext *avctx) /** * Fill the gain array for the timedomain quantization. * - * @param q pointer to the COOKContext - * @param gaininfo[9] array of gain indexes + * @param gb pointer to the GetBitContext + * @param gaininfo[9] array of gain indexes */ static void decode_gain_info(GetBitContext *gb, int *gaininfo) @@ -713,7 +714,7 @@ static void interpolate_float(COOKContext *q, float* buffer, * @param previous_buffer pointer to the previous buffer to be used for overlapping */ -static void imlt_window_float (COOKContext *q, float *buffer1, +static void imlt_window_float (COOKContext *q, float *inbuffer, cook_gains *gains_ptr, float *previous_buffer) { const float fc = pow2tab[gains_ptr->previous[0] + 63]; @@ -726,7 +727,7 @@ static void imlt_window_float (COOKContext *q, float *buffer1, /* Apply window and overlap */ for(i = 0; i < q->samples_per_channel; i++){ - buffer1[i] = buffer1[i] * fc * q->mlt_window[i] - + inbuffer[i] = inbuffer[i] * fc * q->mlt_window[i] - previous_buffer[i] * q->mlt_window[q->samples_per_channel - 1 - i]; } } @@ -877,7 +878,7 @@ static void joint_decode(COOKContext *q, COOKSubpacket *p, float* mlt_buffer1, * * @param q pointer to the COOKContext * @param inbuffer pointer to raw stream data - * @param gain_ptr array of current/prev gain pointers + * @param gains_ptr array of current/prev gain pointers */ static inline void @@ -923,7 +924,7 @@ saturate_output_float (COOKContext *q, int chan, int16_t *out) * * @param q pointer to the COOKContext * @param decode_buffer pointer to the mlt coefficients - * @param gain_ptr array of current/prev gain pointers + * @param gains_ptr array of current/prev gain pointers * @param previous_buffer pointer to the previous buffer to be used for overlapping * @param out pointer to the output buffer * @param chan 0: left or single channel, 1: right channel @@ -931,10 +932,10 @@ saturate_output_float (COOKContext *q, int chan, int16_t *out) static inline void mlt_compensate_output(COOKContext *q, float *decode_buffer, - cook_gains *gains, float *previous_buffer, + cook_gains *gains_ptr, float *previous_buffer, int16_t *out, int chan) { - imlt_gain(q, decode_buffer, gains, previous_buffer); + imlt_gain(q, decode_buffer, gains_ptr, previous_buffer); q->saturate_output (q, chan, out); } @@ -945,11 +946,8 @@ mlt_compensate_output(COOKContext *q, float *decode_buffer, * * @param q pointer to the COOKContext * @param inbuffer pointer to the inbuffer - * @param sub_packet_size subpacket size * @param outbuffer pointer to the outbuffer */ - - static void decode_subpacket(COOKContext *q, COOKSubpacket* p, const uint8_t *inbuffer, int16_t *outbuffer) { int sub_packet_size = p->size; /* packet dump */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dca.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dca.c index 10bc956e9..77299dfcb 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dca.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dca.c @@ -41,10 +41,12 @@ //#define TRACE -#define DCA_PRIM_CHANNELS_MAX (5) +#define DCA_PRIM_CHANNELS_MAX (7) #define DCA_SUBBANDS (32) #define DCA_ABITS_MAX (32) /* Should be 28 */ -#define DCA_SUBSUBFAMES_MAX (4) +#define DCA_SUBSUBFRAMES_MAX (4) +#define DCA_SUBFRAMES_MAX (16) +#define DCA_BLOCKS_MAX (16) #define DCA_LFE_MAX (3) enum DCAMode { @@ -94,44 +96,81 @@ static const int8_t dca_lfe_index[] = { 1,2,2,2,2,3,2,3,2,3,2,3,1,3,2,3 }; -static const int8_t dca_channel_reorder_lfe[][8] = { - { 0, -1, -1, -1, -1, -1, -1, -1}, - { 0, 1, -1, -1, -1, -1, -1, -1}, - { 0, 1, -1, -1, -1, -1, -1, -1}, - { 0, 1, -1, -1, -1, -1, -1, -1}, - { 0, 1, -1, -1, -1, -1, -1, -1}, - { 2, 0, 1, -1, -1, -1, -1, -1}, - { 0, 1, 3, -1, -1, -1, -1, -1}, - { 2, 0, 1, 4, -1, -1, -1, -1}, - { 0, 1, 3, 4, -1, -1, -1, -1}, - { 2, 0, 1, 4, 5, -1, -1, -1}, - { 3, 4, 0, 1, 5, 6, -1, -1}, - { 2, 0, 1, 4, 5, 6, -1, -1}, - { 0, 6, 4, 5, 2, 3, -1, -1}, - { 4, 2, 5, 0, 1, 6, 7, -1}, - { 5, 6, 0, 1, 7, 3, 8, 4}, - { 4, 2, 5, 0, 1, 6, 8, 7}, +static const int8_t dca_channel_reorder_lfe[][9] = { + { 0, -1, -1, -1, -1, -1, -1, -1, -1}, + { 0, 1, -1, -1, -1, -1, -1, -1, -1}, + { 0, 1, -1, -1, -1, -1, -1, -1, -1}, + { 0, 1, -1, -1, -1, -1, -1, -1, -1}, + { 0, 1, -1, -1, -1, -1, -1, -1, -1}, + { 2, 0, 1, -1, -1, -1, -1, -1, -1}, + { 0, 1, 3, -1, -1, -1, -1, -1, -1}, + { 2, 0, 1, 4, -1, -1, -1, -1, -1}, + { 0, 1, 3, 4, -1, -1, -1, -1, -1}, + { 2, 0, 1, 4, 5, -1, -1, -1, -1}, + { 3, 4, 0, 1, 5, 6, -1, -1, -1}, + { 2, 0, 1, 4, 5, 6, -1, -1, -1}, + { 0, 6, 4, 5, 2, 3, -1, -1, -1}, + { 4, 2, 5, 0, 1, 6, 7, -1, -1}, + { 5, 6, 0, 1, 7, 3, 8, 4, -1}, + { 4, 2, 5, 0, 1, 6, 8, 7, -1}, }; -static const int8_t dca_channel_reorder_nolfe[][8] = { - { 0, -1, -1, -1, -1, -1, -1, -1}, - { 0, 1, -1, -1, -1, -1, -1, -1}, - { 0, 1, -1, -1, -1, -1, -1, -1}, - { 0, 1, -1, -1, -1, -1, -1, -1}, - { 0, 1, -1, -1, -1, -1, -1, -1}, - { 2, 0, 1, -1, -1, -1, -1, -1}, - { 0, 1, 2, -1, -1, -1, -1, -1}, - { 2, 0, 1, 3, -1, -1, -1, -1}, - { 0, 1, 2, 3, -1, -1, -1, -1}, - { 2, 0, 1, 3, 4, -1, -1, -1}, - { 2, 3, 0, 1, 4, 5, -1, -1}, - { 2, 0, 1, 3, 4, 5, -1, -1}, - { 0, 5, 3, 4, 1, 2, -1, -1}, - { 3, 2, 4, 0, 1, 5, 6, -1}, - { 4, 5, 0, 1, 6, 2, 7, 3}, - { 3, 2, 4, 0, 1, 5, 7, 6}, +static const int8_t dca_channel_reorder_lfe_xch[][9] = { + { 0, 2, -1, -1, -1, -1, -1, -1, -1}, + { 0, 1, 3, -1, -1, -1, -1, -1, -1}, + { 0, 1, 3, -1, -1, -1, -1, -1, -1}, + { 0, 1, 3, -1, -1, -1, -1, -1, -1}, + { 0, 1, 3, -1, -1, -1, -1, -1, -1}, + { 2, 0, 1, 4, -1, -1, -1, -1, -1}, + { 0, 1, 3, 4, -1, -1, -1, -1, -1}, + { 2, 0, 1, 4, 5, -1, -1, -1, -1}, + { 0, 1, 4, 5, 3, -1, -1, -1, -1}, + { 2, 0, 1, 5, 6, 4, -1, -1, -1}, + { 3, 4, 0, 1, 6, 7, 5, -1, -1}, + { 2, 0, 1, 4, 5, 6, 7, -1, -1}, + { 0, 6, 4, 5, 2, 3, 7, -1, -1}, + { 4, 2, 5, 0, 1, 7, 8, 6, -1}, + { 5, 6, 0, 1, 8, 3, 9, 4, 7}, + { 4, 2, 5, 0, 1, 6, 9, 8, 7}, }; +static const int8_t dca_channel_reorder_nolfe[][9] = { + { 0, -1, -1, -1, -1, -1, -1, -1, -1}, + { 0, 1, -1, -1, -1, -1, -1, -1, -1}, + { 0, 1, -1, -1, -1, -1, -1, -1, -1}, + { 0, 1, -1, -1, -1, -1, -1, -1, -1}, + { 0, 1, -1, -1, -1, -1, -1, -1, -1}, + { 2, 0, 1, -1, -1, -1, -1, -1, -1}, + { 0, 1, 2, -1, -1, -1, -1, -1, -1}, + { 2, 0, 1, 3, -1, -1, -1, -1, -1}, + { 0, 1, 2, 3, -1, -1, -1, -1, -1}, + { 2, 0, 1, 3, 4, -1, -1, -1, -1}, + { 2, 3, 0, 1, 4, 5, -1, -1, -1}, + { 2, 0, 1, 3, 4, 5, -1, -1, -1}, + { 0, 5, 3, 4, 1, 2, -1, -1, -1}, + { 3, 2, 4, 0, 1, 5, 6, -1, -1}, + { 4, 5, 0, 1, 6, 2, 7, 3, -1}, + { 3, 2, 4, 0, 1, 5, 7, 6, -1}, +}; + +static const int8_t dca_channel_reorder_nolfe_xch[][9] = { + { 0, 1, -1, -1, -1, -1, -1, -1, -1}, + { 0, 1, 2, -1, -1, -1, -1, -1, -1}, + { 0, 1, 2, -1, -1, -1, -1, -1, -1}, + { 0, 1, 2, -1, -1, -1, -1, -1, -1}, + { 0, 1, 2, -1, -1, -1, -1, -1, -1}, + { 2, 0, 1, 3, -1, -1, -1, -1, -1}, + { 0, 1, 2, 3, -1, -1, -1, -1, -1}, + { 2, 0, 1, 3, 4, -1, -1, -1, -1}, + { 0, 1, 3, 4, 2, -1, -1, -1, -1}, + { 2, 0, 1, 4, 5, 3, -1, -1, -1}, + { 2, 3, 0, 1, 5, 6, 4, -1, -1}, + { 2, 0, 1, 3, 4, 5, 6, -1, -1}, + { 0, 5, 3, 4, 1, 2, 6, -1, -1}, + { 3, 2, 4, 0, 1, 6, 7, 5, -1}, + { 4, 5, 0, 1, 7, 2, 8, 3, 6}, + { 3, 2, 4, 0, 1, 5, 8, 7, 6}, +}; #define DCA_DOLBY 101 /* FIXME */ @@ -208,8 +247,8 @@ typedef struct { float scalefactor_adj[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< scale factor adjustment /* Primary audio coding side information */ - int subsubframes; ///< number of subsubframes - int partial_samples; ///< partial subsubframe samples count + int subsubframes[DCA_SUBFRAMES_MAX]; ///< number of subsubframes + int partial_samples[DCA_SUBFRAMES_MAX]; ///< partial subsubframe samples count int prediction_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction mode (ADPCM used or not) int prediction_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction VQ coefs int bitalloc[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< bit allocation index @@ -222,8 +261,7 @@ typedef struct { int high_freq_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< VQ encoded high frequency subbands - float lfe_data[2 * DCA_SUBSUBFAMES_MAX * DCA_LFE_MAX * - 2 /*history */ ]; ///< Low frequency effect data + float lfe_data[2 * DCA_LFE_MAX * (DCA_BLOCKS_MAX + 4)]; ///< Low frequency effect data int lfe_scale_factor; /* Subband samples history (for ADPCM) */ @@ -237,8 +275,9 @@ typedef struct { float add_bias; ///< output bias float scale_bias; ///< output scale - DECLARE_ALIGNED(16, float, samples)[1536]; /* 6 * 256 = 1536, might only need 5 */ - const float *samples_chanptr[6]; + DECLARE_ALIGNED(16, float, subband_samples)[DCA_BLOCKS_MAX][DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8]; + DECLARE_ALIGNED(16, float, samples)[(DCA_PRIM_CHANNELS_MAX+1)*256]; + const float *samples_chanptr[DCA_PRIM_CHANNELS_MAX+1]; uint8_t dca_buffer[DCA_MAX_FRAME_SIZE]; int dca_buffer_size; ///< how much data is in the dca_buffer @@ -249,6 +288,10 @@ typedef struct { int current_subframe; int current_subsubframe; + /* XCh extension information */ + int xch_present; + int xch_base_channel; ///< index of first (only) channel containing XCH data + int debug_flag; ///< used for suppressing repeated error messages output DSPContext dsp; FFTContext imdct; @@ -302,9 +345,9 @@ static av_cold void dca_init_vlcs(void) tmode_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); } - for(i = 0; i < 10; i++) - for(j = 0; j < 7; j++){ - if(!bitalloc_codes[i][j]) break; + for (i = 0; i < 10; i++) + for (j = 0; j < 7; j++){ + if (!bitalloc_codes[i][j]) break; dca_smpl_bitalloc[i+1].offset = bitalloc_offsets[i]; dca_smpl_bitalloc[i+1].wrap = 1 + (j > 4); dca_smpl_bitalloc[i+1].vlc[j].table = &dca_table[dca_vlc_offs[c]]; @@ -324,13 +367,87 @@ static inline void get_array(GetBitContext *gb, int *dst, int len, int bits) *dst++ = get_bits(gb, bits); } -static int dca_parse_frame_header(DCAContext * s) +static int dca_parse_audio_coding_header(DCAContext * s, int base_channel) { int i, j; static const float adj_table[4] = { 1.0, 1.1250, 1.2500, 1.4375 }; static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 }; static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 }; + s->total_channels = get_bits(&s->gb, 3) + 1 + base_channel; + s->prim_channels = s->total_channels; + + if (s->prim_channels > DCA_PRIM_CHANNELS_MAX) + s->prim_channels = DCA_PRIM_CHANNELS_MAX; + + + for (i = base_channel; i < s->prim_channels; i++) { + s->subband_activity[i] = get_bits(&s->gb, 5) + 2; + if (s->subband_activity[i] > DCA_SUBBANDS) + s->subband_activity[i] = DCA_SUBBANDS; + } + for (i = base_channel; i < s->prim_channels; i++) { + s->vq_start_subband[i] = get_bits(&s->gb, 5) + 1; + if (s->vq_start_subband[i] > DCA_SUBBANDS) + s->vq_start_subband[i] = DCA_SUBBANDS; + } + get_array(&s->gb, s->joint_intensity + base_channel, s->prim_channels - base_channel, 3); + get_array(&s->gb, s->transient_huffman + base_channel, s->prim_channels - base_channel, 2); + get_array(&s->gb, s->scalefactor_huffman + base_channel, s->prim_channels - base_channel, 3); + get_array(&s->gb, s->bitalloc_huffman + base_channel, s->prim_channels - base_channel, 3); + + /* Get codebooks quantization indexes */ + if (!base_channel) + memset(s->quant_index_huffman, 0, sizeof(s->quant_index_huffman)); + for (j = 1; j < 11; j++) + for (i = base_channel; i < s->prim_channels; i++) + s->quant_index_huffman[i][j] = get_bits(&s->gb, bitlen[j]); + + /* Get scale factor adjustment */ + for (j = 0; j < 11; j++) + for (i = base_channel; i < s->prim_channels; i++) + s->scalefactor_adj[i][j] = 1; + + for (j = 1; j < 11; j++) + for (i = base_channel; i < s->prim_channels; i++) + if (s->quant_index_huffman[i][j] < thr[j]) + s->scalefactor_adj[i][j] = adj_table[get_bits(&s->gb, 2)]; + + if (s->crc_present) { + /* Audio header CRC check */ + get_bits(&s->gb, 16); + } + + s->current_subframe = 0; + s->current_subsubframe = 0; + +#ifdef TRACE + av_log(s->avctx, AV_LOG_DEBUG, "subframes: %i\n", s->subframes); + av_log(s->avctx, AV_LOG_DEBUG, "prim channels: %i\n", s->prim_channels); + for (i = base_channel; i < s->prim_channels; i++){ + av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\n", s->subband_activity[i]); + av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\n", s->vq_start_subband[i]); + av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\n", s->joint_intensity[i]); + av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\n", s->transient_huffman[i]); + av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\n", s->scalefactor_huffman[i]); + av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\n", s->bitalloc_huffman[i]); + av_log(s->avctx, AV_LOG_DEBUG, "quant index huff:"); + for (j = 0; j < 11; j++) + av_log(s->avctx, AV_LOG_DEBUG, " %i", + s->quant_index_huffman[i][j]); + av_log(s->avctx, AV_LOG_DEBUG, "\n"); + av_log(s->avctx, AV_LOG_DEBUG, "scalefac adj:"); + for (j = 0; j < 11; j++) + av_log(s->avctx, AV_LOG_DEBUG, " %1.3f", s->scalefactor_adj[i][j]); + av_log(s->avctx, AV_LOG_DEBUG, "\n"); + } +#endif + + return 0; +} + +static int dca_parse_frame_header(DCAContext * s) +{ init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8); /* Sync code */ @@ -378,7 +495,7 @@ static int dca_parse_frame_header(DCAContext * s) /* FIXME: channels mixing levels */ s->output = s->amode; - if(s->lfe) s->output |= DCA_LFE; + if (s->lfe) s->output |= DCA_LFE; #ifdef TRACE av_log(s->avctx, AV_LOG_DEBUG, "frame type: %i\n", s->frame_type); @@ -420,74 +537,8 @@ static int dca_parse_frame_header(DCAContext * s) /* Primary audio coding header */ s->subframes = get_bits(&s->gb, 4) + 1; - s->total_channels = get_bits(&s->gb, 3) + 1; - s->prim_channels = s->total_channels; - if (s->prim_channels > DCA_PRIM_CHANNELS_MAX) - s->prim_channels = DCA_PRIM_CHANNELS_MAX; /* We only support DTS core */ - - - for (i = 0; i < s->prim_channels; i++) { - s->subband_activity[i] = get_bits(&s->gb, 5) + 2; - if (s->subband_activity[i] > DCA_SUBBANDS) - s->subband_activity[i] = DCA_SUBBANDS; - } - for (i = 0; i < s->prim_channels; i++) { - s->vq_start_subband[i] = get_bits(&s->gb, 5) + 1; - if (s->vq_start_subband[i] > DCA_SUBBANDS) - s->vq_start_subband[i] = DCA_SUBBANDS; - } - get_array(&s->gb, s->joint_intensity, s->prim_channels, 3); - get_array(&s->gb, s->transient_huffman, s->prim_channels, 2); - get_array(&s->gb, s->scalefactor_huffman, s->prim_channels, 3); - get_array(&s->gb, s->bitalloc_huffman, s->prim_channels, 3); - - /* Get codebooks quantization indexes */ - memset(s->quant_index_huffman, 0, sizeof(s->quant_index_huffman)); - for (j = 1; j < 11; j++) - for (i = 0; i < s->prim_channels; i++) - s->quant_index_huffman[i][j] = get_bits(&s->gb, bitlen[j]); - /* Get scale factor adjustment */ - for (j = 0; j < 11; j++) - for (i = 0; i < s->prim_channels; i++) - s->scalefactor_adj[i][j] = 1; - - for (j = 1; j < 11; j++) - for (i = 0; i < s->prim_channels; i++) - if (s->quant_index_huffman[i][j] < thr[j]) - s->scalefactor_adj[i][j] = adj_table[get_bits(&s->gb, 2)]; - - if (s->crc_present) { - /* Audio header CRC check */ - get_bits(&s->gb, 16); - } - - s->current_subframe = 0; - s->current_subsubframe = 0; - -#ifdef TRACE - av_log(s->avctx, AV_LOG_DEBUG, "subframes: %i\n", s->subframes); - av_log(s->avctx, AV_LOG_DEBUG, "prim channels: %i\n", s->prim_channels); - for(i = 0; i < s->prim_channels; i++){ - av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\n", s->subband_activity[i]); - av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\n", s->vq_start_subband[i]); - av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\n", s->joint_intensity[i]); - av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\n", s->transient_huffman[i]); - av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\n", s->scalefactor_huffman[i]); - av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\n", s->bitalloc_huffman[i]); - av_log(s->avctx, AV_LOG_DEBUG, "quant index huff:"); - for (j = 0; j < 11; j++) - av_log(s->avctx, AV_LOG_DEBUG, " %i", - s->quant_index_huffman[i][j]); - av_log(s->avctx, AV_LOG_DEBUG, "\n"); - av_log(s->avctx, AV_LOG_DEBUG, "scalefac adj:"); - for (j = 0; j < 11; j++) - av_log(s->avctx, AV_LOG_DEBUG, " %1.3f", s->scalefactor_adj[i][j]); - av_log(s->avctx, AV_LOG_DEBUG, "\n"); - } -#endif - - return 0; + return dca_parse_audio_coding_header(s, 0); } @@ -496,25 +547,28 @@ static inline int get_scale(GetBitContext *gb, int level, int value) if (level < 5) { /* huffman encoded */ value += get_bitalloc(gb, &dca_scalefactor, level); - } else if(level < 8) + } else if (level < 8) value = get_bits(gb, level + 1); return value; } -static int dca_subframe_header(DCAContext * s) +static int dca_subframe_header(DCAContext * s, int base_channel, int block_index) { /* Primary audio coding side information */ int j, k; - s->subsubframes = get_bits(&s->gb, 2) + 1; - s->partial_samples = get_bits(&s->gb, 3); - for (j = 0; j < s->prim_channels; j++) { + if (!base_channel) { + s->subsubframes[s->current_subframe] = get_bits(&s->gb, 2) + 1; + s->partial_samples[s->current_subframe] = get_bits(&s->gb, 3); + } + + for (j = base_channel; j < s->prim_channels; j++) { for (k = 0; k < s->subband_activity[j]; k++) s->prediction_mode[j][k] = get_bits(&s->gb, 1); } /* Get prediction codebook */ - for (j = 0; j < s->prim_channels; j++) { + for (j = base_channel; j < s->prim_channels; j++) { for (k = 0; k < s->subband_activity[j]; k++) { if (s->prediction_mode[j][k] > 0) { /* (Prediction coefficient VQ address) */ @@ -524,7 +578,7 @@ static int dca_subframe_header(DCAContext * s) } /* Bit allocation index */ - for (j = 0; j < s->prim_channels; j++) { + for (j = base_channel; j < s->prim_channels; j++) { for (k = 0; k < s->vq_start_subband[j]; k++) { if (s->bitalloc_huffman[j] == 6) s->bitalloc[j][k] = get_bits(&s->gb, 5); @@ -548,10 +602,10 @@ static int dca_subframe_header(DCAContext * s) } /* Transition mode */ - for (j = 0; j < s->prim_channels; j++) { + for (j = base_channel; j < s->prim_channels; j++) { for (k = 0; k < s->subband_activity[j]; k++) { s->transition_mode[j][k] = 0; - if (s->subsubframes > 1 && + if (s->subsubframes[s->current_subframe] > 1 && k < s->vq_start_subband[j] && s->bitalloc[j][k] > 0) { s->transition_mode[j][k] = get_bitalloc(&s->gb, &dca_tmode, s->transient_huffman[j]); @@ -559,7 +613,7 @@ static int dca_subframe_header(DCAContext * s) } } - for (j = 0; j < s->prim_channels; j++) { + for (j = base_channel; j < s->prim_channels; j++) { const uint32_t *scale_table; int scale_sum; @@ -588,14 +642,14 @@ static int dca_subframe_header(DCAContext * s) } /* Joint subband scale factor codebook select */ - for (j = 0; j < s->prim_channels; j++) { + for (j = base_channel; j < s->prim_channels; j++) { /* Transmitted only if joint subband coding enabled */ if (s->joint_intensity[j] > 0) s->joint_huff[j] = get_bits(&s->gb, 3); } /* Scale factors for joint subband coding */ - for (j = 0; j < s->prim_channels; j++) { + for (j = base_channel; j < s->prim_channels; j++) { int source_channel; /* Transmitted only if joint subband coding enabled */ @@ -621,15 +675,15 @@ static int dca_subframe_header(DCAContext * s) } /* Stereo downmix coefficients */ - if (s->prim_channels > 2) { - if(s->downmix) { - for (j = 0; j < s->prim_channels; j++) { + if (!base_channel && s->prim_channels > 2) { + if (s->downmix) { + for (j = base_channel; j < s->prim_channels; j++) { s->downmix_coef[j][0] = get_bits(&s->gb, 7); s->downmix_coef[j][1] = get_bits(&s->gb, 7); } } else { int am = s->amode & DCA_CHANNEL_MASK; - for (j = 0; j < s->prim_channels; j++) { + for (j = base_channel; j < s->prim_channels; j++) { s->downmix_coef[j][0] = dca_default_coeffs[am][j][0]; s->downmix_coef[j][1] = dca_default_coeffs[am][j][1]; } @@ -650,18 +704,19 @@ static int dca_subframe_header(DCAContext * s) */ /* VQ encoded high frequency subbands */ - for (j = 0; j < s->prim_channels; j++) + for (j = base_channel; j < s->prim_channels; j++) for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++) /* 1 vector -> 32 samples */ s->high_freq_vq[j][k] = get_bits(&s->gb, 10); /* Low frequency effect data */ - if (s->lfe) { + if (!base_channel && s->lfe) { /* LFE samples */ - int lfe_samples = 2 * s->lfe * s->subsubframes; + int lfe_samples = 2 * s->lfe * (4 + block_index); + int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]); float lfe_scale; - for (j = lfe_samples; j < lfe_samples * 2; j++) { + for (j = lfe_samples; j < lfe_end_sample; j++) { /* Signed 8 bits int */ s->lfe_data[j] = get_sbits(&s->gb, 8); } @@ -672,21 +727,21 @@ static int dca_subframe_header(DCAContext * s) /* Quantization step size * scale factor */ lfe_scale = 0.035 * s->lfe_scale_factor; - for (j = lfe_samples; j < lfe_samples * 2; j++) + for (j = lfe_samples; j < lfe_end_sample; j++) s->lfe_data[j] *= lfe_scale; } #ifdef TRACE - av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n", s->subsubframes); + av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n", s->subsubframes[s->current_subframe]); av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n", - s->partial_samples); - for (j = 0; j < s->prim_channels; j++) { + s->partial_samples[s->current_subframe]); + for (j = base_channel; j < s->prim_channels; j++) { av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:"); for (k = 0; k < s->subband_activity[j]; k++) av_log(s->avctx, AV_LOG_DEBUG, " %i", s->prediction_mode[j][k]); av_log(s->avctx, AV_LOG_DEBUG, "\n"); } - for (j = 0; j < s->prim_channels; j++) { + for (j = base_channel; j < s->prim_channels; j++) { for (k = 0; k < s->subband_activity[j]; k++) av_log(s->avctx, AV_LOG_DEBUG, "prediction coefs: %f, %f, %f, %f\n", @@ -695,19 +750,19 @@ static int dca_subframe_header(DCAContext * s) (float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192, (float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192); } - for (j = 0; j < s->prim_channels; j++) { + for (j = base_channel; j < s->prim_channels; j++) { av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index: "); for (k = 0; k < s->vq_start_subband[j]; k++) av_log(s->avctx, AV_LOG_DEBUG, "%2.2i ", s->bitalloc[j][k]); av_log(s->avctx, AV_LOG_DEBUG, "\n"); } - for (j = 0; j < s->prim_channels; j++) { + for (j = base_channel; j < s->prim_channels; j++) { av_log(s->avctx, AV_LOG_DEBUG, "Transition mode:"); for (k = 0; k < s->subband_activity[j]; k++) av_log(s->avctx, AV_LOG_DEBUG, " %i", s->transition_mode[j][k]); av_log(s->avctx, AV_LOG_DEBUG, "\n"); } - for (j = 0; j < s->prim_channels; j++) { + for (j = base_channel; j < s->prim_channels; j++) { av_log(s->avctx, AV_LOG_DEBUG, "Scale factor:"); for (k = 0; k < s->subband_activity[j]; k++) { if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0) @@ -717,7 +772,7 @@ static int dca_subframe_header(DCAContext * s) } av_log(s->avctx, AV_LOG_DEBUG, "\n"); } - for (j = 0; j < s->prim_channels; j++) { + for (j = base_channel; j < s->prim_channels; j++) { if (s->joint_intensity[j] > 0) { int source_channel = s->joint_intensity[j] - 1; av_log(s->avctx, AV_LOG_DEBUG, "Joint scale factor index:\n"); @@ -726,7 +781,7 @@ static int dca_subframe_header(DCAContext * s) av_log(s->avctx, AV_LOG_DEBUG, "\n"); } } - if (s->prim_channels > 2 && s->downmix) { + if (!base_channel && s->prim_channels > 2 && s->downmix) { av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n"); for (j = 0; j < s->prim_channels; j++) { av_log(s->avctx, AV_LOG_DEBUG, "Channel 0,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][0]]); @@ -734,13 +789,15 @@ static int dca_subframe_header(DCAContext * s) } av_log(s->avctx, AV_LOG_DEBUG, "\n"); } - for (j = 0; j < s->prim_channels; j++) + for (j = base_channel; j < s->prim_channels; j++) for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++) av_log(s->avctx, AV_LOG_DEBUG, "VQ index: %i\n", s->high_freq_vq[j][k]); - if(s->lfe){ - int lfe_samples = 2 * s->lfe * s->subsubframes; + if (!base_channel && s->lfe) { + int lfe_samples = 2 * s->lfe * (4 + block_index); + int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]); + av_log(s->avctx, AV_LOG_DEBUG, "LFE samples:\n"); - for (j = lfe_samples; j < lfe_samples * 2; j++) + for (j = lfe_samples; j < lfe_end_sample; j++) av_log(s->avctx, AV_LOG_DEBUG, " %f", s->lfe_data[j]); av_log(s->avctx, AV_LOG_DEBUG, "\n"); } @@ -835,7 +892,7 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select, samples[i+256] = t * coef[0][1] + samples[i+256] * coef[1][1] + samples[i+512] * coef[2][1]; #define DOWNMIX_TO_STEREO(op1, op2) \ - for(i = 0; i < 256; i++){ \ + for (i = 0; i < 256; i++){ \ op1 \ op2 \ } @@ -847,7 +904,7 @@ static void dca_downmix(float *samples, int srcfmt, float t; float coef[DCA_PRIM_CHANNELS_MAX][2]; - for(i=0; icurrent_subsubframe; @@ -915,7 +972,7 @@ static int dca_subsubframe(DCAContext * s) const float *quant_step_table; /* FIXME */ - LOCAL_ALIGNED_16(float, subband_samples, [DCA_PRIM_CHANNELS_MAX], [DCA_SUBBANDS][8]); + float (*subband_samples)[DCA_SUBBANDS][8] = s->subband_samples[block_index]; LOCAL_ALIGNED_16(int, block, [8]); /* @@ -928,7 +985,7 @@ static int dca_subsubframe(DCAContext * s) else quant_step_table = lossy_quant_d; - for (k = 0; k < s->prim_channels; k++) { + for (k = base_channel; k < s->prim_channels; k++) { for (l = 0; l < s->vq_start_subband[k]; l++) { int m; @@ -947,15 +1004,15 @@ static int dca_subsubframe(DCAContext * s) /* * Extract bits from the bit stream */ - if(!abits){ + if (!abits){ memset(subband_samples[k][l], 0, 8 * sizeof(subband_samples[0][0][0])); } else { /* Deal with transients */ int sfi = s->transition_mode[k][l] && subsubframe >= s->transition_mode[k][l]; float rscale = quant_step_size * s->scale_factor[k][l][sfi] * s->scalefactor_adj[k][sel]; - if(abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table){ - if(abits <= 7){ + if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table){ + if (abits <= 7){ /* Block code */ int block_code1, block_code2, size, levels; @@ -1025,7 +1082,7 @@ static int dca_subsubframe(DCAContext * s) } /* Check for DSYNC after subsubframe */ - if (s->aspf || subsubframe == s->subsubframes - 1) { + if (s->aspf || subsubframe == s->subsubframes[s->current_subframe] - 1) { if (0xFFFF == get_bits(&s->gb, 16)) { /* 0xFFFF */ #ifdef TRACE av_log(s->avctx, AV_LOG_DEBUG, "Got subframe DSYNC\n"); @@ -1036,11 +1093,19 @@ static int dca_subsubframe(DCAContext * s) } /* Backup predictor history for adpcm */ - for (k = 0; k < s->prim_channels; k++) + for (k = base_channel; k < s->prim_channels; k++) for (l = 0; l < s->vq_start_subband[k]; l++) memcpy(s->subband_samples_hist[k][l], &subband_samples[k][l][4], 4 * sizeof(subband_samples[0][0][0])); + return 0; +} + +static int dca_filter_channels(DCAContext * s, int block_index) +{ + float (*subband_samples)[DCA_SUBBANDS][8] = s->subband_samples[block_index]; + int k; + /* 32 subbands QMF */ for (k = 0; k < s->prim_channels; k++) { /* static float pcm_to_double[8] = @@ -1051,18 +1116,14 @@ static int dca_subsubframe(DCAContext * s) } /* Down mixing */ - - if (s->prim_channels > dca_channels[s->output & DCA_CHANNEL_MASK]) { + if (s->avctx->request_channels == 2 && s->prim_channels > 2) { dca_downmix(s->samples, s->amode, s->downmix_coef); } /* Generate LFE samples for this subsubframe FIXME!!! */ if (s->output & DCA_LFE) { - int lfe_samples = 2 * s->lfe * s->subsubframes; - lfe_interpolation_fir(s, s->lfe, 2 * s->lfe, - s->lfe_data + lfe_samples + - 2 * s->lfe * subsubframe, + s->lfe_data + 2 * s->lfe * (block_index + 4), &s->samples[256 * dca_lfe_index[s->amode]], (1.0/256.0)*s->scale_bias, s->add_bias); /* Outputs 20bits pcm samples */ @@ -1072,30 +1133,27 @@ static int dca_subsubframe(DCAContext * s) } -static int dca_subframe_footer(DCAContext * s) +static int dca_subframe_footer(DCAContext * s, int base_channel) { int aux_data_count = 0, i; - int lfe_samples; /* * Unpack optional information */ - if (s->timestamp) - get_bits(&s->gb, 32); + /* presumably optional information only appears in the core? */ + if (!base_channel) { + if (s->timestamp) + get_bits(&s->gb, 32); - if (s->aux_data) - aux_data_count = get_bits(&s->gb, 6); + if (s->aux_data) + aux_data_count = get_bits(&s->gb, 6); - for (i = 0; i < aux_data_count; i++) - get_bits(&s->gb, 8); + for (i = 0; i < aux_data_count; i++) + get_bits(&s->gb, 8); - if (s->crc_present && (s->downmix || s->dynrange)) - get_bits(&s->gb, 16); - - lfe_samples = 2 * s->lfe * s->subsubframes; - for (i = 0; i < lfe_samples; i++) { - s->lfe_data[i] = s->lfe_data[i + lfe_samples]; + if (s->crc_present && (s->downmix || s->dynrange)) + get_bits(&s->gb, 16); } return 0; @@ -1107,7 +1165,7 @@ static int dca_subframe_footer(DCAContext * s) * @param s pointer to the DCAContext */ -static int dca_decode_block(DCAContext * s) +static int dca_decode_block(DCAContext * s, int base_channel, int block_index) { /* Sanity check */ @@ -1122,7 +1180,7 @@ static int dca_decode_block(DCAContext * s) av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_header\n"); #endif /* Read subframe header */ - if (dca_subframe_header(s)) + if (dca_subframe_header(s, base_channel, block_index)) return -1; } @@ -1130,12 +1188,12 @@ static int dca_decode_block(DCAContext * s) #ifdef TRACE av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subsubframe\n"); #endif - if (dca_subsubframe(s)) + if (dca_subsubframe(s, base_channel, block_index)) return -1; /* Update state */ s->current_subsubframe++; - if (s->current_subsubframe >= s->subsubframes) { + if (s->current_subsubframe >= s->subsubframes[s->current_subframe]) { s->current_subsubframe = 0; s->current_subframe++; } @@ -1144,7 +1202,7 @@ static int dca_decode_block(DCAContext * s) av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_footer\n"); #endif /* Read subframe footer */ - if (dca_subframe_footer(s)) + if (dca_subframe_footer(s, base_channel)) return -1; } @@ -1163,7 +1221,7 @@ static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * ds uint16_t *sdst = (uint16_t *) dst; PutBitContext pb; - if((unsigned)src_size > (unsigned)max_size) { + if ((unsigned)src_size > (unsigned)max_size) { // av_log(NULL, AV_LOG_ERROR, "Input frame size larger then DCA_MAX_FRAME_SIZE!\n"); // return -1; src_size = max_size; @@ -1176,7 +1234,7 @@ static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * ds return src_size; case DCA_MARKER_RAW_LE: for (i = 0; i < (src_size + 1) >> 1; i++) - *sdst++ = bswap_16(*ssrc++); + *sdst++ = av_bswap16(*ssrc++); return src_size; case DCA_MARKER_14B_BE: case DCA_MARKER_14B_LE: @@ -1203,12 +1261,15 @@ static int dca_decode_frame(AVCodecContext * avctx, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; + int lfe_samples; + int num_core_channels = 0; int i; int16_t *samples = data; DCAContext *s = avctx->priv_data; int channels; + s->xch_present = 0; s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer, DCA_MAX_FRAME_SIZE); if (s->dca_buffer_size == -1) { av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n"); @@ -1225,22 +1286,89 @@ static int dca_decode_frame(AVCodecContext * avctx, avctx->sample_rate = s->sample_rate; avctx->bit_rate = s->bit_rate; + for (i = 0; i < (s->sample_blocks / 8); i++) { + dca_decode_block(s, 0, i); + } + + /* record number of core channels incase less than max channels are requested */ + num_core_channels = s->prim_channels; + + /* extensions start at 32-bit boundaries into bitstream */ + skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31); + + while(get_bits_left(&s->gb) >= 32) { + uint32_t bits = get_bits_long(&s->gb, 32); + + switch(bits) { + case 0x5a5a5a5a: { + int ext_amode, xch_fsize; + + s->xch_base_channel = s->prim_channels; + + /* validate sync word using XCHFSIZE field */ + xch_fsize = show_bits(&s->gb, 10); + if((s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize) && + (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize + 1)) + continue; + + /* skip length-to-end-of-frame field for the moment */ + skip_bits(&s->gb, 10); + + /* extension amode should == 1, number of channels in extension */ + /* AFAIK XCh is not used for more channels */ + if ((ext_amode = get_bits(&s->gb, 4)) != 1) { + av_log(avctx, AV_LOG_ERROR, "XCh extension amode %d not" + " supported!\n",ext_amode); + continue; + } + + /* much like core primary audio coding header */ + dca_parse_audio_coding_header(s, s->xch_base_channel); + + for (i = 0; i < (s->sample_blocks / 8); i++) { + dca_decode_block(s, s->xch_base_channel, i); + } + + s->xch_present = 1; + break; + } + case 0x1d95f262: + av_log(avctx, AV_LOG_DEBUG, "Possible X96 extension found at %d bits\n", get_bits_count(&s->gb)); + av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", get_bits(&s->gb, 12)+1); + av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\n", get_bits(&s->gb, 4)); + break; + } + + skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31); + } + channels = s->prim_channels + !!s->lfe; if (s->amode<16) { avctx->channel_layout = dca_core_channel_layout[s->amode]; - if (s->lfe) { - avctx->channel_layout |= CH_LOW_FREQUENCY; - s->channel_order_tab = dca_channel_reorder_lfe[s->amode]; - } else - s->channel_order_tab = dca_channel_reorder_nolfe[s->amode]; + if (s->xch_present && (!avctx->request_channels || + avctx->request_channels > num_core_channels)) { + avctx->channel_layout |= CH_BACK_CENTER; + if (s->lfe) { + avctx->channel_layout |= CH_LOW_FREQUENCY; + s->channel_order_tab = dca_channel_reorder_lfe_xch[s->amode]; + } else { + s->channel_order_tab = dca_channel_reorder_nolfe_xch[s->amode]; + } + } else { + if (s->lfe) { + avctx->channel_layout |= CH_LOW_FREQUENCY; + s->channel_order_tab = dca_channel_reorder_lfe[s->amode]; + } else + s->channel_order_tab = dca_channel_reorder_nolfe[s->amode]; + } if (s->prim_channels > 0 && s->channel_order_tab[s->prim_channels - 1] < 0) return -1; - if(avctx->request_channels == 2 && s->prim_channels > 2) { + if (avctx->request_channels == 2 && s->prim_channels > 2) { channels = 2; s->output = DCA_STEREO; avctx->channel_layout = CH_LAYOUT_STEREO; @@ -1259,15 +1387,37 @@ static int dca_decode_frame(AVCodecContext * avctx, if (!avctx->channels) avctx->channels = channels; - if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels) + if (*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels) return -1; *data_size = 256 / 8 * s->sample_blocks * sizeof(int16_t) * channels; + + /* filter to get final output */ for (i = 0; i < (s->sample_blocks / 8); i++) { - dca_decode_block(s); + dca_filter_channels(s, i); + + /* If this was marked as a DTS-ES stream we need to subtract back- */ + /* channel from SL & SR to remove matrixed back-channel signal */ + if((s->source_pcm_res & 1) && s->xch_present) { + float* back_chan = s->samples + s->channel_order_tab[s->xch_base_channel] * 256; + float* lt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 2] * 256; + float* rt_chan = s->samples + s->channel_order_tab[s->xch_base_channel - 1] * 256; + int j; + for(j = 0; j < 256; ++j) { + lt_chan[j] -= (back_chan[j] - s->add_bias) * M_SQRT1_2; + rt_chan[j] -= (back_chan[j] - s->add_bias) * M_SQRT1_2; + } + } + s->dsp.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels); samples += 256 * channels; } + /* update lfe history */ + lfe_samples = 2 * s->lfe * (s->sample_blocks / 8); + for (i = 0; i < 2 * s->lfe * 4; i++) { + s->lfe_data[i] = s->lfe_data[i + lfe_samples]; + } + return buf_size; } @@ -1292,11 +1442,11 @@ static av_cold int dca_decode_init(AVCodecContext * avctx) ff_synth_filter_init(&s->synth); ff_dcadsp_init(&s->dcadsp); - for(i = 0; i < 6; i++) + for (i = 0; i < DCA_PRIM_CHANNELS_MAX+1; i++) s->samples_chanptr[i] = s->samples + i * 256; avctx->sample_fmt = SAMPLE_FMT_S16; - if(s->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) { + if (s->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) { s->add_bias = 385.0f; s->scale_bias = 1.0 / 32768.0; } else { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dct.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dct.c index 0840feca0..dab94c30a 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dct.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dct.c @@ -30,6 +30,10 @@ #include #include "libavutil/mathematics.h" #include "fft.h" +#include "x86/fft.h" + +#define DCT32_FLOAT +#include "dct32.c" /* sin((M_PI * x / (2*n)) */ #define SIN(s,n,x) (s->costab[(n) - (x)]) @@ -167,6 +171,11 @@ static void ff_dct_calc_II_c(DCTContext *ctx, FFTSample *data) } } +static void dct32_func(DCTContext *ctx, FFTSample *data) +{ + ctx->dct32(data, data); +} + void ff_dct_calc(DCTContext *s, FFTSample *data) { s->dct_calc(s, data); @@ -200,6 +209,13 @@ av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse) case DCT_III: s->dct_calc = ff_dct_calc_III_c; break; case DST_I : s->dct_calc = ff_dst_calc_I_c; break; } + + if (inverse == DCT_II && nbits == 5) + s->dct_calc = dct32_func; + + s->dct32 = dct32; + if (HAVE_MMX) ff_dct_init_mmx(s); + return 0; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dct32.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dct32.c new file mode 100644 index 000000000..4e843ee83 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dct32.c @@ -0,0 +1,267 @@ +/* + * Template for the Discrete Cosine Transform for 32 samples + * Copyright (c) 2001, 2002 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifdef DCT32_FLOAT +# define FIXHR(x) ((float)(x)) +# define MULH3(x, y, s) ((s)*(y)*(x)) +# define INTFLOAT float +#endif + + +/* tab[i][j] = 1.0 / (2.0 * cos(pi*(2*k+1) / 2^(6 - j))) */ + +/* cos(i*pi/64) */ + +#define COS0_0 FIXHR(0.50060299823519630134/2) +#define COS0_1 FIXHR(0.50547095989754365998/2) +#define COS0_2 FIXHR(0.51544730992262454697/2) +#define COS0_3 FIXHR(0.53104259108978417447/2) +#define COS0_4 FIXHR(0.55310389603444452782/2) +#define COS0_5 FIXHR(0.58293496820613387367/2) +#define COS0_6 FIXHR(0.62250412303566481615/2) +#define COS0_7 FIXHR(0.67480834145500574602/2) +#define COS0_8 FIXHR(0.74453627100229844977/2) +#define COS0_9 FIXHR(0.83934964541552703873/2) +#define COS0_10 FIXHR(0.97256823786196069369/2) +#define COS0_11 FIXHR(1.16943993343288495515/4) +#define COS0_12 FIXHR(1.48416461631416627724/4) +#define COS0_13 FIXHR(2.05778100995341155085/8) +#define COS0_14 FIXHR(3.40760841846871878570/8) +#define COS0_15 FIXHR(10.19000812354805681150/32) + +#define COS1_0 FIXHR(0.50241928618815570551/2) +#define COS1_1 FIXHR(0.52249861493968888062/2) +#define COS1_2 FIXHR(0.56694403481635770368/2) +#define COS1_3 FIXHR(0.64682178335999012954/2) +#define COS1_4 FIXHR(0.78815462345125022473/2) +#define COS1_5 FIXHR(1.06067768599034747134/4) +#define COS1_6 FIXHR(1.72244709823833392782/4) +#define COS1_7 FIXHR(5.10114861868916385802/16) + +#define COS2_0 FIXHR(0.50979557910415916894/2) +#define COS2_1 FIXHR(0.60134488693504528054/2) +#define COS2_2 FIXHR(0.89997622313641570463/2) +#define COS2_3 FIXHR(2.56291544774150617881/8) + +#define COS3_0 FIXHR(0.54119610014619698439/2) +#define COS3_1 FIXHR(1.30656296487637652785/4) + +#define COS4_0 FIXHR(0.70710678118654752439/2) + +/* butterfly operator */ +#define BF(a, b, c, s)\ +{\ + tmp0 = val##a + val##b;\ + tmp1 = val##a - val##b;\ + val##a = tmp0;\ + val##b = MULH3(tmp1, c, 1<<(s));\ +} + +#define BF0(a, b, c, s)\ +{\ + tmp0 = tab[a] + tab[b];\ + tmp1 = tab[a] - tab[b];\ + val##a = tmp0;\ + val##b = MULH3(tmp1, c, 1<<(s));\ +} + +#define BF1(a, b, c, d)\ +{\ + BF(a, b, COS4_0, 1);\ + BF(c, d,-COS4_0, 1);\ + val##c += val##d;\ +} + +#define BF2(a, b, c, d)\ +{\ + BF(a, b, COS4_0, 1);\ + BF(c, d,-COS4_0, 1);\ + val##c += val##d;\ + val##a += val##c;\ + val##c += val##b;\ + val##b += val##d;\ +} + +#define ADD(a, b) val##a += val##b + +/* DCT32 without 1/sqrt(2) coef zero scaling. */ +static void dct32(INTFLOAT *out, const INTFLOAT *tab) +{ + INTFLOAT tmp0, tmp1; + + INTFLOAT val0 , val1 , val2 , val3 , val4 , val5 , val6 , val7 , + val8 , val9 , val10, val11, val12, val13, val14, val15, + val16, val17, val18, val19, val20, val21, val22, val23, + val24, val25, val26, val27, val28, val29, val30, val31; + + /* pass 1 */ + BF0( 0, 31, COS0_0 , 1); + BF0(15, 16, COS0_15, 5); + /* pass 2 */ + BF( 0, 15, COS1_0 , 1); + BF(16, 31,-COS1_0 , 1); + /* pass 1 */ + BF0( 7, 24, COS0_7 , 1); + BF0( 8, 23, COS0_8 , 1); + /* pass 2 */ + BF( 7, 8, COS1_7 , 4); + BF(23, 24,-COS1_7 , 4); + /* pass 3 */ + BF( 0, 7, COS2_0 , 1); + BF( 8, 15,-COS2_0 , 1); + BF(16, 23, COS2_0 , 1); + BF(24, 31,-COS2_0 , 1); + /* pass 1 */ + BF0( 3, 28, COS0_3 , 1); + BF0(12, 19, COS0_12, 2); + /* pass 2 */ + BF( 3, 12, COS1_3 , 1); + BF(19, 28,-COS1_3 , 1); + /* pass 1 */ + BF0( 4, 27, COS0_4 , 1); + BF0(11, 20, COS0_11, 2); + /* pass 2 */ + BF( 4, 11, COS1_4 , 1); + BF(20, 27,-COS1_4 , 1); + /* pass 3 */ + BF( 3, 4, COS2_3 , 3); + BF(11, 12,-COS2_3 , 3); + BF(19, 20, COS2_3 , 3); + BF(27, 28,-COS2_3 , 3); + /* pass 4 */ + BF( 0, 3, COS3_0 , 1); + BF( 4, 7,-COS3_0 , 1); + BF( 8, 11, COS3_0 , 1); + BF(12, 15,-COS3_0 , 1); + BF(16, 19, COS3_0 , 1); + BF(20, 23,-COS3_0 , 1); + BF(24, 27, COS3_0 , 1); + BF(28, 31,-COS3_0 , 1); + + + + /* pass 1 */ + BF0( 1, 30, COS0_1 , 1); + BF0(14, 17, COS0_14, 3); + /* pass 2 */ + BF( 1, 14, COS1_1 , 1); + BF(17, 30,-COS1_1 , 1); + /* pass 1 */ + BF0( 6, 25, COS0_6 , 1); + BF0( 9, 22, COS0_9 , 1); + /* pass 2 */ + BF( 6, 9, COS1_6 , 2); + BF(22, 25,-COS1_6 , 2); + /* pass 3 */ + BF( 1, 6, COS2_1 , 1); + BF( 9, 14,-COS2_1 , 1); + BF(17, 22, COS2_1 , 1); + BF(25, 30,-COS2_1 , 1); + + /* pass 1 */ + BF0( 2, 29, COS0_2 , 1); + BF0(13, 18, COS0_13, 3); + /* pass 2 */ + BF( 2, 13, COS1_2 , 1); + BF(18, 29,-COS1_2 , 1); + /* pass 1 */ + BF0( 5, 26, COS0_5 , 1); + BF0(10, 21, COS0_10, 1); + /* pass 2 */ + BF( 5, 10, COS1_5 , 2); + BF(21, 26,-COS1_5 , 2); + /* pass 3 */ + BF( 2, 5, COS2_2 , 1); + BF(10, 13,-COS2_2 , 1); + BF(18, 21, COS2_2 , 1); + BF(26, 29,-COS2_2 , 1); + /* pass 4 */ + BF( 1, 2, COS3_1 , 2); + BF( 5, 6,-COS3_1 , 2); + BF( 9, 10, COS3_1 , 2); + BF(13, 14,-COS3_1 , 2); + BF(17, 18, COS3_1 , 2); + BF(21, 22,-COS3_1 , 2); + BF(25, 26, COS3_1 , 2); + BF(29, 30,-COS3_1 , 2); + + /* pass 5 */ + BF1( 0, 1, 2, 3); + BF2( 4, 5, 6, 7); + BF1( 8, 9, 10, 11); + BF2(12, 13, 14, 15); + BF1(16, 17, 18, 19); + BF2(20, 21, 22, 23); + BF1(24, 25, 26, 27); + BF2(28, 29, 30, 31); + + /* pass 6 */ + + ADD( 8, 12); + ADD(12, 10); + ADD(10, 14); + ADD(14, 9); + ADD( 9, 13); + ADD(13, 11); + ADD(11, 15); + + out[ 0] = val0; + out[16] = val1; + out[ 8] = val2; + out[24] = val3; + out[ 4] = val4; + out[20] = val5; + out[12] = val6; + out[28] = val7; + out[ 2] = val8; + out[18] = val9; + out[10] = val10; + out[26] = val11; + out[ 6] = val12; + out[22] = val13; + out[14] = val14; + out[30] = val15; + + ADD(24, 28); + ADD(28, 26); + ADD(26, 30); + ADD(30, 25); + ADD(25, 29); + ADD(29, 27); + ADD(27, 31); + + out[ 1] = val16 + val24; + out[17] = val17 + val25; + out[ 9] = val18 + val26; + out[25] = val19 + val27; + out[ 5] = val20 + val28; + out[21] = val21 + val29; + out[13] = val22 + val30; + out[29] = val23 + val31; + out[ 3] = val24 + val20; + out[19] = val25 + val21; + out[11] = val26 + val22; + out[27] = val27 + val23; + out[ 7] = val28 + val18; + out[23] = val29 + val19; + out[15] = val30 + val17; + out[31] = val31; +} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dirac.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dirac.h index 09c558101..87d66ccab 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dirac.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dirac.h @@ -24,7 +24,7 @@ /** * @file - * Interfaces to Dirac Decoder/Encoder + * Interface to Dirac Decoder/Encoder * @author Marco Gerards */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dirac_parser.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dirac_parser.c index c82f0e673..e5b9599c7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dirac_parser.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dirac_parser.c @@ -33,7 +33,7 @@ #define DIRAC_PARSE_INFO_PREFIX 0x42424344 /** - * Finds the end of the current frame in the bitstream. + * Find the end of the current frame in the bitstream. * @return the position of the first byte of the next frame or -1 */ typedef struct DiracParseContext { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dpcm.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dpcm.c index 7c5351686..3f3842c8e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dpcm.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dpcm.c @@ -20,7 +20,7 @@ */ /** - * @file: dpcm.c + * @file * Assorted DPCM (differential pulse code modulation) audio codecs * by Mike Melanson (melanson@pcisys.net) * Xan DPCM decoder by Mario Brito (mbrito@student.dei.uc.pt) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dsputil.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dsputil.c index a09d19d75..44fcf596c 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dsputil.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dsputil.c @@ -39,6 +39,7 @@ #include "ac3dec.h" #include "vorbis.h" #include "png.h" +#include "vp8dsp.h" uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0, }; uint32_t ff_squareTbl[512] = {0, }; @@ -246,17 +247,17 @@ static void bswap_buf(uint32_t *dst, const 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]); + dst[i+0]= av_bswap32(src[i+0]); + dst[i+1]= av_bswap32(src[i+1]); + dst[i+2]= av_bswap32(src[i+2]); + dst[i+3]= av_bswap32(src[i+3]); + dst[i+4]= av_bswap32(src[i+4]); + dst[i+5]= av_bswap32(src[i+5]); + dst[i+6]= av_bswap32(src[i+6]); + dst[i+7]= av_bswap32(src[i+7]); } for(;iavg_2tap_qpel_pixels_tab[0][i]= c->avg_h264_qpel_pixels_tab[0][i]; } + c->put_rv30_tpel_pixels_tab[0][0] = c->put_h264_qpel_pixels_tab[0][0]; + c->put_rv30_tpel_pixels_tab[1][0] = c->put_h264_qpel_pixels_tab[1][0]; + c->avg_rv30_tpel_pixels_tab[0][0] = c->avg_h264_qpel_pixels_tab[0][0]; + c->avg_rv30_tpel_pixels_tab[1][0] = c->avg_h264_qpel_pixels_tab[1][0]; + + c->put_rv40_qpel_pixels_tab[0][0] = c->put_h264_qpel_pixels_tab[0][0]; + c->put_rv40_qpel_pixels_tab[1][0] = c->put_h264_qpel_pixels_tab[1][0]; + c->avg_rv40_qpel_pixels_tab[0][0] = c->avg_h264_qpel_pixels_tab[0][0]; + c->avg_rv40_qpel_pixels_tab[1][0] = c->avg_h264_qpel_pixels_tab[1][0]; + switch(c->idct_permutation_type){ case FF_NO_IDCT_PERM: for(i=0; i<64; i++) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dsputil.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dsputil.h index d943b8492..d67483679 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dsputil.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dsputil.h @@ -544,14 +544,14 @@ typedef struct DSPContext { * @param len length of vectors, should be multiple of 16 * @param shift number of bits to discard from product */ - int32_t (*scalarproduct_int16)(int16_t *v1, int16_t *v2/*align 16*/, int len, int shift); + int32_t (*scalarproduct_int16)(const int16_t *v1, const int16_t *v2/*align 16*/, int len, int shift); /* ape functions */ /** * Calculate scalar product of v1 and v2, * and v1[i] += v3[i] * mul * @param len length of vectors, should be multiple of 16 */ - int32_t (*scalarproduct_and_madd_int16)(int16_t *v1/*align 16*/, int16_t *v2, int16_t *v3, int len, int mul); + int32_t (*scalarproduct_and_madd_int16)(int16_t *v1/*align 16*/, const int16_t *v2, const int16_t *v3, int len, int mul); /* rv30 functions */ qpel_mc_func put_rv30_tpel_pixels_tab[4][16]; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dv.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dv.c index ea1f66179..9f5356232 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dv.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dv.c @@ -1304,6 +1304,7 @@ AVCodec dvvideo_decoder = { dvvideo_decode_frame, CODEC_CAP_DR1, NULL, + .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), }; #endif diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dv_tablegen.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dv_tablegen.c index 0e2b39dfb..5d3793e11 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dv_tablegen.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dv_tablegen.c @@ -29,9 +29,9 @@ #include "tableprint.h" #include -WRITE_1D_FUNC_ARGV(vlc_pair, struct dv_vlc_pair, 7, +WRITE_1D_FUNC_ARGV(dv_vlc_pair, 7, "{0x%"PRIx32", %"PRId8"}", data[i].vlc, data[i].size) -WRITE_2D_FUNC(vlc_pair, struct dv_vlc_pair) +WRITE_2D_FUNC(dv_vlc_pair) int main(void) { @@ -40,7 +40,7 @@ int main(void) write_fileheader(); printf("static const struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE] = {\n"); - write_vlc_pair_2d_array(dv_vlc_map, DV_VLC_MAP_RUN_SIZE, DV_VLC_MAP_LEV_SIZE); + write_dv_vlc_pair_2d_array(dv_vlc_map, DV_VLC_MAP_RUN_SIZE, DV_VLC_MAP_LEV_SIZE); printf("};\n"); return 0; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dv_tablegen.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dv_tablegen.h index ee6e8220a..47e8c362c 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dv_tablegen.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dv_tablegen.h @@ -35,10 +35,10 @@ #endif /* VLC encoding lookup table */ -struct dv_vlc_pair { +typedef struct dv_vlc_pair { uint32_t vlc; uint32_t size; -}; +} dv_vlc_pair; #if CONFIG_HARDCODED_TABLES #define dv_vlc_map_tableinit() diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dvbsub.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dvbsub.c index 0f098266d..ea55cae31 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dvbsub.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dvbsub.c @@ -20,7 +20,7 @@ */ #include "avcodec.h" #include "bytestream.h" -#include "colorspace.h" +#include "libavutil/colorspace.h" typedef struct DVBSubtitleContext { int hide_state; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dvbsubdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dvbsubdec.c index 2805f79e0..d1d01fd13 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dvbsubdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dvbsubdec.c @@ -21,7 +21,8 @@ #include "avcodec.h" #include "dsputil.h" #include "get_bits.h" -#include "colorspace.h" +#include "bytestream.h" +#include "libavutil/colorspace.h" //#define DEBUG //#define DEBUG_PACKET_CONTENTS @@ -31,6 +32,7 @@ #define DVBSUB_REGION_SEGMENT 0x11 #define DVBSUB_CLUT_SEGMENT 0x12 #define DVBSUB_OBJECT_SEGMENT 0x13 +#define DVBSUB_DISPLAYDEFINITION_SEGMENT 0x14 #define DVBSUB_DISPLAY_SEGMENT 0x80 #define cm (ff_cropTbl + MAX_NEG_CROP) @@ -216,6 +218,15 @@ typedef struct DVBSubRegion { struct DVBSubRegion *next; } DVBSubRegion; +typedef struct DVBSubDisplayDefinition { + int version; + + int x; + int y; + int width; + int height; +} DVBSubDisplayDefinition; + typedef struct DVBSubContext { int composition_id; int ancillary_id; @@ -227,6 +238,7 @@ typedef struct DVBSubContext { int display_list_size; DVBSubRegionDisplay *display_list; + DVBSubDisplayDefinition *display_definition; } DVBSubContext; @@ -334,6 +346,8 @@ static void delete_state(DVBSubContext *ctx) av_free(clut); } + av_freep(&ctx->display_definition); + /* Should already be null */ if (ctx->object_list) av_log(0, AV_LOG_ERROR, "Memory deallocation error!\n"); @@ -342,9 +356,7 @@ static void delete_state(DVBSubContext *ctx) static av_cold int dvbsub_init_decoder(AVCodecContext *avctx) { int i, r, g, b, a = 0; - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; - - memset(avctx->priv_data, 0, sizeof(DVBSubContext)); + DVBSubContext *ctx = avctx->priv_data; ctx->composition_id = avctx->sub_id & 0xffff; ctx->ancillary_id = avctx->sub_id >> 16; @@ -414,7 +426,7 @@ static av_cold int dvbsub_init_decoder(AVCodecContext *avctx) static av_cold int dvbsub_close_decoder(AVCodecContext *avctx) { - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; + DVBSubContext *ctx = avctx->priv_data; DVBSubRegionDisplay *display; delete_state(ctx); @@ -717,7 +729,7 @@ static int dvbsub_read_8bit_string(uint8_t *destbuf, int dbuf_len, static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDisplay *display, const uint8_t *buf, int buf_size, int top_bottom, int non_mod) { - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; + DVBSubContext *ctx = avctx->priv_data; DVBSubRegion *region = get_region(ctx, display->region_id); const uint8_t *buf_end = buf + buf_size; @@ -834,7 +846,7 @@ static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDis static void dvbsub_parse_object_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; + DVBSubContext *ctx = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; const uint8_t *block; @@ -893,7 +905,7 @@ static void dvbsub_parse_object_segment(AVCodecContext *avctx, static void dvbsub_parse_clut_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; + DVBSubContext *ctx = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; int clut_id; @@ -981,7 +993,7 @@ static void dvbsub_parse_clut_segment(AVCodecContext *avctx, static void dvbsub_parse_region_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; + DVBSubContext *ctx = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; int region_id, object_id; @@ -1093,7 +1105,7 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx, static void dvbsub_parse_page_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; + DVBSubContext *ctx = avctx->priv_data; DVBSubRegionDisplay *display; DVBSubRegionDisplay *tmp_display_list, **tmp_ptr; @@ -1254,10 +1266,51 @@ static void save_display_set(DVBSubContext *ctx) } #endif +static void dvbsub_parse_display_definition_segment(AVCodecContext *avctx, + const uint8_t *buf, + int buf_size) +{ + DVBSubContext *ctx = avctx->priv_data; + DVBSubDisplayDefinition *display_def = ctx->display_definition; + int dds_version, info_byte; + + if (buf_size < 5) + return; + + info_byte = bytestream_get_byte(&buf); + dds_version = info_byte >> 4; + if (display_def && display_def->version == dds_version) + return; // already have this display definition version + + if (!display_def) { + display_def = av_mallocz(sizeof(*display_def)); + ctx->display_definition = display_def; + } + if (!display_def) + return; + + display_def->version = dds_version; + display_def->x = 0; + display_def->y = 0; + display_def->width = bytestream_get_be16(&buf) + 1; + display_def->height = bytestream_get_be16(&buf) + 1; + + if (buf_size < 13) + return; + + if (info_byte & 1<<3) { // display_window_flag + display_def->x = bytestream_get_be16(&buf); + display_def->y = bytestream_get_be16(&buf); + display_def->width = bytestream_get_be16(&buf) - display_def->x + 1; + display_def->height = bytestream_get_be16(&buf) - display_def->y + 1; + } +} + static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size, AVSubtitle *sub) { - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; + DVBSubContext *ctx = avctx->priv_data; + DVBSubDisplayDefinition *display_def = ctx->display_definition; DVBSubRegion *region; DVBSubRegionDisplay *display; @@ -1265,12 +1318,18 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, DVBSubCLUT *clut; uint32_t *clut_table; int i; + int offset_x=0, offset_y=0; sub->rects = NULL; sub->start_display_time = 0; sub->end_display_time = ctx->time_out * 1000; sub->format = 0; + if (display_def) { + offset_x = display_def->x; + offset_y = display_def->y; + } + sub->num_rects = ctx->display_list_size; if (sub->num_rects > 0){ @@ -1288,11 +1347,11 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, if (!region) continue; - rect->x = display->x_pos; - rect->y = display->y_pos; + rect->x = display->x_pos + offset_x; + rect->y = display->y_pos + offset_y; rect->w = region->width; rect->h = region->height; - rect->nb_colors = (1 << region->depth); + rect->nb_colors = 16; rect->type = SUBTITLE_BITMAP; rect->pict.linesize[0] = region->width; @@ -1338,8 +1397,8 @@ static int dvbsub_decode(AVCodecContext *avctx, { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; - AVSubtitle *sub = (AVSubtitle*) data; + DVBSubContext *ctx = avctx->priv_data; + AVSubtitle *sub = data; const uint8_t *p, *p_end; int segment_type; int page_id; @@ -1389,6 +1448,8 @@ static int dvbsub_decode(AVCodecContext *avctx, case DVBSUB_OBJECT_SEGMENT: dvbsub_parse_object_segment(avctx, p, segment_length); break; + case DVBSUB_DISPLAYDEFINITION_SEGMENT: + dvbsub_parse_display_definition_segment(avctx, p, segment_length); case DVBSUB_DISPLAY_SEGMENT: *data_size = dvbsub_display_end_segment(avctx, p, segment_length, sub); break; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dvdsubdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dvdsubdec.c index a75aae0c2..98b766e65 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dvdsubdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/dvdsubdec.c @@ -20,19 +20,11 @@ */ #include "avcodec.h" #include "get_bits.h" -#include "colorspace.h" #include "dsputil.h" +#include "libavutil/colorspace.h" //#define DEBUG -typedef struct DVDSubContext -{ - uint8_t colormap[4]; - uint8_t alpha[4]; - uint32_t palette[16]; - int has_palette; -} DVDSubContext; - static void yuv_a_to_rgba(const uint8_t *ycbcr, const uint8_t *alpha, uint32_t *rgba, int num_values) { uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; @@ -50,24 +42,6 @@ static void yuv_a_to_rgba(const uint8_t *ycbcr, const uint8_t *alpha, uint32_t * } } -static void ayvu_to_argb(const uint8_t *ayvu, uint32_t *argb, int num_values) -{ - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; - uint8_t r, g, b; - int i, y, cb, cr, a; - int r_add, g_add, b_add; - - for (i = num_values; i > 0; i--) { - a = *ayvu++; - y = *ayvu++; - cr = *ayvu++; - cb = *ayvu++; - YUV_TO_RGB1_CCIR(cb, cr); - YUV_TO_RGB2_CCIR(r, g, b, y); - *argb++ = (a << 24) | (r << 16) | (g << 8) | b; - } -} - static int decode_run_2bit(GetBitContext *gb, int *color) { unsigned int v, t; @@ -141,21 +115,13 @@ static int decode_rle(uint8_t *bitmap, int linesize, int w, int h, return 0; } -static void fill_palette(DVDSubContext* ctx, - uint32_t *rgba_palette, - uint32_t subtitle_color) +static void guess_palette(uint32_t *rgba_palette, + uint8_t *colormap, + uint8_t *alpha, + uint32_t subtitle_color) { uint8_t color_used[16]; int nb_opaque_colors, i, level, j, r, g, b; - uint8_t *colormap = ctx->colormap; - uint8_t *alpha = ctx->alpha; - - if(ctx->has_palette) { - for(i = 0; i < 4; i++) - rgba_palette[i] = (ctx->palette[ctx->colormap[i]] & 0x00ffffff) - | ((alpha[i] * 17) << 24); - return; - } for(i = 0; i < 4; i++) rgba_palette[i] = 0; @@ -194,14 +160,13 @@ static void fill_palette(DVDSubContext* ctx, #define READ_OFFSET(a) (big_offsets ? AV_RB32(a) : AV_RB16(a)) -static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header, +static int decode_dvd_subtitles(AVSubtitle *sub_header, const uint8_t *buf, int buf_size) { int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos; int big_offsets, offset_size, is_8bit = 0; const uint8_t *yuv_palette = 0; - uint8_t *colormap = ctx->colormap; - uint8_t *alpha = ctx->alpha; + uint8_t colormap[4], alpha[256]; int date; int i; int is_menu = 0; @@ -361,7 +326,8 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header, yuv_a_to_rgba(yuv_palette, alpha, (uint32_t*)sub_header->rects[0]->pict.data[1], 256); } else { sub_header->rects[0]->nb_colors = 4; - fill_palette(ctx, sub_header->rects[0]->pict.data[1], 0xffff00); + guess_palette((uint32_t*)sub_header->rects[0]->pict.data[1], + colormap, alpha, 0xffff00); } sub_header->rects[0]->x = x1; sub_header->rects[0]->y = y1; @@ -492,13 +458,12 @@ static int dvdsub_decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { - DVDSubContext *ctx = (DVDSubContext*) avctx->priv_data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AVSubtitle *sub = (void *)data; int is_menu; - is_menu = decode_dvd_subtitles(ctx, sub, buf, buf_size); + is_menu = decode_dvd_subtitles(sub, buf, buf_size); if (is_menu < 0) { no_subtitle: @@ -521,54 +486,12 @@ static int dvdsub_decode(AVCodecContext *avctx, return buf_size; } -static int dvdsub_init(AVCodecContext *avctx) -{ - DVDSubContext *ctx = (DVDSubContext*) avctx->priv_data; - char *data = avctx->extradata; - - if (!avctx->extradata || !avctx->extradata_size) - return 1; - - data[avctx->extradata_size] = '\0'; - - for(;;) { - int pos = strcspn(data, "\n\r"); - if (pos==0 && *data==0) - break; - - if (strncmp("palette:", data, 8) == 0) { - int i; - char *p = data+8; - ctx->has_palette = 1; - for(i=0;i<16;i++) { - ctx->palette[i] = strtoul(p, &p, 16); - while(*p == ',' || isspace(*p)) - p++; - } -#if defined(DEBUG) - av_log(avctx, AV_LOG_INFO, "palette:"); - for(i=0;i<16;i++) - av_log(avctx, AV_LOG_WARNING, " 0x%06x", ctx->palette[i]); - av_log(avctx, AV_LOG_INFO, "\n"); -#endif - } - - data += pos; - data += strspn(data, "\n\r"); - } - - if(!ctx->has_palette && avctx->extradata_size == 64) - ayvu_to_argb((uint8_t*)avctx->extradata, ctx->palette, 16); - - return 1; -} - AVCodec dvdsub_decoder = { "dvdsub", AVMEDIA_TYPE_SUBTITLE, CODEC_ID_DVD_SUBTITLE, - sizeof(DVDSubContext), - dvdsub_init, + 0, + NULL, NULL, NULL, dvdsub_decode, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/eamad.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/eamad.c index 8fc5ef136..3077c0883 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/eamad.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/eamad.c @@ -53,7 +53,7 @@ static void bswap16_buf(uint16_t *dst, const uint16_t *src, int count) { int i; for (i=0; iscratchbuf + 3*dim, + elbg->scratchbuf + 4*dim + }; cell *tempcell; - memset(newcentroid, 0, sizeof(newcentroid)); + memset(newcentroid[0], 0, 2 * dim * sizeof(*newcentroid[0])); newutility[0] = newutility[1] = 0; @@ -158,8 +163,8 @@ static void get_new_centroids(elbg_data *elbg, int huc, int *newcentroid_i, int *newcentroid_p) { cell *tempcell; - int min[elbg->dim]; - int max[elbg->dim]; + int *min = newcentroid_i; + int *max = newcentroid_p; int i; for (i=0; i< elbg->dim; i++) { @@ -174,8 +179,10 @@ static void get_new_centroids(elbg_data *elbg, int huc, int *newcentroid_i, } for (i=0; idim; i++) { - newcentroid_i[i] = min[i] + (max[i] - min[i])/3; - newcentroid_p[i] = min[i] + (2*(max[i] - min[i]))/3; + int ni = min[i] + (max[i] - min[i])/3; + int np = min[i] + (2*(max[i] - min[i]))/3; + newcentroid_i[i] = ni; + newcentroid_p[i] = np; } } @@ -242,20 +249,19 @@ static void update_utility_and_n_cb(elbg_data *elbg, int idx, int newutility) * and update elbg->error, elbg->utility and elbg->nearest_cb. * * @param elbg Internal elbg data - * @param indexes {luc (low utility cell, huc (high utility cell), cluc (closest cell to low utility cell)} + * @param idx {luc (low utility cell, huc (high utility cell), cluc (closest cell to low utility cell)} */ static void try_shift_candidate(elbg_data *elbg, int idx[3]) { int j, k, olderror=0, newerror, cont=0; int newutility[3]; - int newcentroid[3][elbg->dim]; - int *newcentroid_ptrs[3]; + int *newcentroid[3] = { + elbg->scratchbuf, + elbg->scratchbuf + elbg->dim, + elbg->scratchbuf + 2*elbg->dim + }; cell *tempcell; - newcentroid_ptrs[0] = newcentroid[0]; - newcentroid_ptrs[1] = newcentroid[1]; - newcentroid_ptrs[2] = newcentroid[2]; - for (j=0; j<3; j++) olderror += elbg->utility[idx[j]]; @@ -277,11 +283,11 @@ static void try_shift_candidate(elbg_data *elbg, int idx[3]) newerror = newutility[2]; - newerror += simple_lbg(elbg->dim, newcentroid_ptrs, newutility, elbg->points, + newerror += simple_lbg(elbg, elbg->dim, newcentroid, newutility, elbg->points, elbg->cells[idx[1]]); if (olderror > newerror) { - shift_codebook(elbg, idx, newcentroid_ptrs); + shift_codebook(elbg, idx, newcentroid); elbg->error += newerror - olderror; @@ -366,6 +372,7 @@ void ff_do_elbg(int *points, int dim, int numpoints, int *codebook, elbg->nearest_cb = closest_cb; elbg->points = points; elbg->utility_inc = av_malloc(numCB*sizeof(int)); + elbg->scratchbuf = av_malloc(5*dim*sizeof(int)); elbg->rand_state = rand_state; @@ -425,4 +432,5 @@ void ff_do_elbg(int *points, int dim, int numpoints, int *codebook, av_free(list_buffer); av_free(elbg->cells); av_free(elbg->utility_inc); + av_free(elbg->scratchbuf); } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/fft.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/fft.c index bf240bf5c..81765510e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/fft.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/fft.c @@ -80,26 +80,21 @@ av_cold void ff_init_ff_cos_tabs(int index) av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse) { - int i, j, m, n; - float alpha, c1, s1, s2; - int av_unused has_vectors; + int i, j, n; if (nbits < 2 || nbits > 16) goto fail; s->nbits = nbits; n = 1 << nbits; - s->tmp_buf = NULL; - 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->tmp_buf = av_malloc(n * sizeof(FFTComplex)); + if (!s->tmp_buf) + goto fail; s->inverse = inverse; - s2 = inverse ? 1.0 : -1.0; - s->fft_permute = ff_fft_permute_c; s->fft_calc = ff_fft_calc_c; #if CONFIG_MDCT @@ -107,104 +102,37 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse) s->imdct_half = ff_imdct_half_c; s->mdct_calc = ff_mdct_calc_c; #endif - s->exptab1 = NULL; - s->split_radix = 1; if (ARCH_ARM) ff_fft_init_arm(s); if (HAVE_ALTIVEC) ff_fft_init_altivec(s); if (HAVE_MMX) ff_fft_init_mmx(s); - if (s->split_radix) { - for(j=4; j<=nbits; j++) { - ff_init_ff_cos_tabs(j); - } - for(i=0; irevtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = i; - s->tmp_buf = av_malloc(n * sizeof(FFTComplex)); - } else { - int np, nblocks, np2, l; - FFTComplex *q; - - 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; - } - - 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); - - /* compute bit reverse table */ - for(i=0;i> j) & 1) << (nbits-j-1); - } - s->revtab[i]=m; - } + for(j=4; j<=nbits; j++) { + ff_init_ff_cos_tabs(j); } + for(i=0; irevtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = i; return 0; fail: av_freep(&s->revtab); - av_freep(&s->exptab); - av_freep(&s->exptab1); av_freep(&s->tmp_buf); return -1; } void ff_fft_permute_c(FFTContext *s, FFTComplex *z) { - int j, k, np; - FFTComplex tmp; + int j, np; const uint16_t *revtab = s->revtab; np = 1 << s->nbits; - - if (s->tmp_buf) { - /* TODO: handle split-radix permute in a more optimal way, probably in-place */ - for(j=0;jtmp_buf[revtab[j]] = z[j]; - memcpy(z, s->tmp_buf, np * sizeof(FFTComplex)); - return; - } - - /* reverse */ - for(j=0;jtmp_buf[revtab[j]] = z[j]; + memcpy(z, s->tmp_buf, np * sizeof(FFTComplex)); } av_cold void ff_fft_end(FFTContext *s) { av_freep(&s->revtab); - av_freep(&s->exptab); - av_freep(&s->exptab1); av_freep(&s->tmp_buf); } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/fft.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/fft.h index 1f5b2e86d..eb6714fe9 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/fft.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/fft.h @@ -33,8 +33,6 @@ struct FFTContext { int nbits; int inverse; uint16_t *revtab; - FFTComplex *exptab; - FFTComplex *exptab1; /* only used by SSE code */ FFTComplex *tmp_buf; int mdct_size; /* size of MDCT (i.e. number of input data * 2) */ int mdct_bits; /* n = 2^nbits */ @@ -46,7 +44,6 @@ struct FFTContext { void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input); void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); - int split_radix; int permutation; #define FF_MDCT_PERM_NONE 0 #define FF_MDCT_PERM_INTERLEAVE 1 @@ -84,7 +81,7 @@ extern COSTABLE(65536); extern COSTABLE_CONST FFTSample* const ff_cos_tabs[17]; /** - * Initializes the cosine table in ff_cos_tabs[index] + * Initialize the cosine table in ff_cos_tabs[index] * \param index index in ff_cos_tabs array of the table to initialize */ void ff_init_ff_cos_tabs(int index); @@ -104,7 +101,7 @@ extern SINTABLE(32768); extern SINTABLE(65536); /** - * Sets up a complex FFT. + * Set up a complex FFT. * @param nbits log2 of the length of the input array * @param inverse if 0 perform the forward transform, if 1 perform the inverse */ @@ -115,6 +112,7 @@ void ff_fft_calc_c(FFTContext *s, FFTComplex *z); void ff_fft_init_altivec(FFTContext *s); void ff_fft_init_mmx(FFTContext *s); void ff_fft_init_arm(FFTContext *s); +void ff_dct_init_mmx(DCTContext *s); /** * Do the permutation needed BEFORE calling ff_fft_calc(). @@ -150,11 +148,16 @@ static inline void ff_mdct_calc(FFTContext *s, FFTSample *output, s->mdct_calc(s, output, input); } +/** + * Maximum window size for ff_kbd_window_init. + */ +#define FF_KBD_WINDOW_MAX 1024 + /** * Generate a Kaiser-Bessel Derived Window. * @param window pointer to half window * @param alpha determines window shape - * @param n size of half window + * @param n size of half window, max FF_KBD_WINDOW_MAX */ void ff_kbd_window_init(float *window, float alpha, int n); @@ -200,7 +203,7 @@ struct RDFTContext { }; /** - * Sets up a real FFT. + * Set up a real FFT. * @param nbits log2 of the length of the input array * @param trans the type of transform */ @@ -223,10 +226,11 @@ struct DCTContext { const float *costab; FFTSample *csc2; void (*dct_calc)(struct DCTContext *s, FFTSample *data); + void (*dct32)(FFTSample *out, const FFTSample *in); }; /** - * Sets up DCT. + * Set up DCT. * @param nbits size of the input array: * (1 << nbits) for DCT-II, DCT-III and DST-I * (1 << nbits) + 1 for DCT-I diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ffv1.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ffv1.c index 12056e120..0e3007fa8 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ffv1.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ffv1.c @@ -237,6 +237,7 @@ typedef struct FFV1Context{ uint8_t state_transition[256]; int run_index; int colorspace; + int_fast16_t *sample_buffer; DSPContext dsp; }FFV1Context; @@ -509,14 +510,14 @@ static inline int encode_line(FFV1Context *s, int w, int_fast16_t *sample[2], in static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index){ int x,y,i; const int ring_size= s->avctx->context_model ? 3 : 2; - int_fast16_t sample_buffer[ring_size][w+6], *sample[ring_size]; + int_fast16_t *sample[3]; s->run_index=0; - memset(sample_buffer, 0, sizeof(sample_buffer)); + memset(s->sample_buffer, 0, ring_size*(w+6)*sizeof(*s->sample_buffer)); for(y=0; ysample_buffer + (w+6)*((h+i-y)%ring_size) + 3; sample[0][-1]= sample[1][0 ]; sample[1][ w]= sample[1][w-1]; @@ -539,15 +540,15 @@ static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, static void encode_rgb_frame(FFV1Context *s, uint32_t *src, int w, int h, int stride){ int x, y, p, i; const int ring_size= s->avctx->context_model ? 3 : 2; - int_fast16_t sample_buffer[3][ring_size][w+6], *sample[3][ring_size]; + int_fast16_t *sample[3][3]; s->run_index=0; - memset(sample_buffer, 0, sizeof(sample_buffer)); + memset(s->sample_buffer, 0, ring_size*3*(w+6)*sizeof(*s->sample_buffer)); for(y=0; ysample_buffer + p*ring_size*(w+6) + ((h+i-y)%ring_size)*(w+6) + 3; for(x=0; xwidth && s->height); + s->sample_buffer = av_malloc(6 * (s->width+6) * sizeof(*s->sample_buffer)); + if (!s->sample_buffer) + return AVERROR(ENOMEM); + return 0; } @@ -823,6 +828,8 @@ static av_cold int common_end(AVCodecContext *avctx){ av_freep(&p->vlc_state); } + av_freep(&s->sample_buffer); + return 0; } @@ -885,14 +892,13 @@ static av_always_inline void decode_line(FFV1Context *s, int w, int_fast16_t *sa static void decode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index){ int x, y; - int_fast16_t sample_buffer[2][w+6]; int_fast16_t *sample[2]; - sample[0]=sample_buffer[0]+3; - sample[1]=sample_buffer[1]+3; + sample[0]=s->sample_buffer +3; + sample[1]=s->sample_buffer+w+6+3; s->run_index=0; - memset(sample_buffer, 0, sizeof(sample_buffer)); + memset(s->sample_buffer, 0, 2*(w+6)*sizeof(*s->sample_buffer)); for(y=0; ysample_buffer + x*2 *(w+6) + 3; + sample[x][1] = s->sample_buffer + (x*2+1)*(w+6) + 3; } s->run_index=0; - memset(sample_buffer, 0, sizeof(sample_buffer)); + memset(s->sample_buffer, 0, 6*(w+6)*sizeof(*s->sample_buffer)); for(y=0; y= BLOCK_TIME_MS milliseconds + * Set blocksize based on samplerate + * Choose the closest predefined blocksize >= BLOCK_TIME_MS milliseconds */ static int select_blocksize(int samplerate, int block_time_ms) { @@ -208,7 +209,11 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) } s->options.block_time_ms = ((int[]){ 27, 27, 27,105,105,105,105,105,105,105,105,105,105})[level]; - s->options.use_lpc = ((int[]){ 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})[level]; + s->options.lpc_type = ((int[]){ AV_LPC_TYPE_FIXED, AV_LPC_TYPE_FIXED, AV_LPC_TYPE_FIXED, + AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, + AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, + AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, AV_LPC_TYPE_LEVINSON, + AV_LPC_TYPE_LEVINSON})[level]; s->options.min_prediction_order= ((int[]){ 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})[level]; s->options.max_prediction_order= ((int[]){ 3, 4, 4, 6, 8, 8, 8, 8, 12, 12, 12, 32, 32})[level]; s->options.prediction_order_method = ((int[]){ ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST, @@ -220,45 +225,83 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) s->options.max_partition_order = ((int[]){ 2, 2, 3, 3, 3, 8, 8, 8, 8, 8, 8, 8, 8})[level]; /* set compression option overrides from AVCodecContext */ - if(avctx->use_lpc >= 0) { - s->options.use_lpc = av_clip(avctx->use_lpc, 0, 11); - } - if(s->options.use_lpc == 1) - av_log(avctx, AV_LOG_DEBUG, " use lpc: Levinson-Durbin recursion with Welch window\n"); - else if(s->options.use_lpc > 1) - av_log(avctx, AV_LOG_DEBUG, " use lpc: Cholesky factorization\n"); - - if(avctx->min_prediction_order >= 0) { - if(s->options.use_lpc) { - if(avctx->min_prediction_order < MIN_LPC_ORDER || - avctx->min_prediction_order > MAX_LPC_ORDER) { - av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n", - avctx->min_prediction_order); +#if LIBAVCODEC_VERSION_MAJOR < 53 + /* for compatibility with deprecated AVCodecContext.use_lpc */ + if (avctx->use_lpc == 0) { + s->options.lpc_type = AV_LPC_TYPE_FIXED; + } else if (avctx->use_lpc == 1) { + s->options.lpc_type = AV_LPC_TYPE_LEVINSON; + } else if (avctx->use_lpc > 1) { + s->options.lpc_type = AV_LPC_TYPE_CHOLESKY; + s->options.lpc_passes = avctx->use_lpc - 1; + } +#endif + if (avctx->lpc_type > AV_LPC_TYPE_DEFAULT) { + if (avctx->lpc_type > AV_LPC_TYPE_CHOLESKY) { + av_log(avctx, AV_LOG_ERROR, "unknown lpc type: %d\n", avctx->lpc_type); + return -1; + } + s->options.lpc_type = avctx->lpc_type; + if (s->options.lpc_type == AV_LPC_TYPE_CHOLESKY) { + if (avctx->lpc_passes < 0) { + // default number of passes for Cholesky + s->options.lpc_passes = 2; + } else if (avctx->lpc_passes == 0) { + av_log(avctx, AV_LOG_ERROR, "invalid number of lpc passes: %d\n", + avctx->lpc_passes); return -1; + } else { + s->options.lpc_passes = avctx->lpc_passes; } - } else { + } + } + switch (s->options.lpc_type) { + case AV_LPC_TYPE_NONE: + av_log(avctx, AV_LOG_DEBUG, " lpc type: None\n"); + break; + case AV_LPC_TYPE_FIXED: + av_log(avctx, AV_LOG_DEBUG, " lpc type: Fixed pre-defined coefficients\n"); + break; + case AV_LPC_TYPE_LEVINSON: + av_log(avctx, AV_LOG_DEBUG, " lpc type: Levinson-Durbin recursion with Welch window\n"); + break; + case AV_LPC_TYPE_CHOLESKY: + av_log(avctx, AV_LOG_DEBUG, " lpc type: Cholesky factorization, %d pass%s\n", + s->options.lpc_passes, s->options.lpc_passes==1?"":"es"); + break; + } + + if (s->options.lpc_type == AV_LPC_TYPE_NONE) { + s->options.min_prediction_order = 0; + } else if (avctx->min_prediction_order >= 0) { + if (s->options.lpc_type == AV_LPC_TYPE_FIXED) { if(avctx->min_prediction_order > MAX_FIXED_ORDER) { av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n", avctx->min_prediction_order); return -1; } + } else if(avctx->min_prediction_order < MIN_LPC_ORDER || + avctx->min_prediction_order > MAX_LPC_ORDER) { + av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n", + avctx->min_prediction_order); + return -1; } s->options.min_prediction_order = avctx->min_prediction_order; } - if(avctx->max_prediction_order >= 0) { - if(s->options.use_lpc) { - if(avctx->max_prediction_order < MIN_LPC_ORDER || - avctx->max_prediction_order > MAX_LPC_ORDER) { - av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n", - avctx->max_prediction_order); - return -1; - } - } else { + if (s->options.lpc_type == AV_LPC_TYPE_NONE) { + s->options.max_prediction_order = 0; + } else if (avctx->max_prediction_order >= 0) { + if (s->options.lpc_type == AV_LPC_TYPE_FIXED) { if(avctx->max_prediction_order > MAX_FIXED_ORDER) { av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n", avctx->max_prediction_order); return -1; } + } else if (avctx->max_prediction_order < MIN_LPC_ORDER || + avctx->max_prediction_order > MAX_LPC_ORDER) { + av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n", + avctx->max_prediction_order); + return -1; } s->options.max_prediction_order = avctx->max_prediction_order; } @@ -754,7 +797,8 @@ static int encode_residual(FlacEncodeContext *ctx, int ch) omethod = ctx->options.prediction_order_method; /* FIXED */ - if(!ctx->options.use_lpc || max_order == 0 || (n <= max_order)) { + if (ctx->options.lpc_type == AV_LPC_TYPE_NONE || + ctx->options.lpc_type == AV_LPC_TYPE_FIXED || n <= max_order) { uint32_t bits[MAX_FIXED_ORDER+1]; if(max_order > MAX_FIXED_ORDER) max_order = MAX_FIXED_ORDER; opt_order = 0; @@ -780,14 +824,15 @@ static int encode_residual(FlacEncodeContext *ctx, int ch) /* LPC */ opt_order = ff_lpc_calc_coefs(&ctx->dsp, smp, n, min_order, max_order, - precision, coefs, shift, ctx->options.use_lpc, - omethod, MAX_LPC_SHIFT, 0); + precision, coefs, shift, ctx->options.lpc_type, + ctx->options.lpc_passes, omethod, + MAX_LPC_SHIFT, 0); if(omethod == ORDER_METHOD_2LEVEL || omethod == ORDER_METHOD_4LEVEL || omethod == ORDER_METHOD_8LEVEL) { int levels = 1 << omethod; - uint32_t bits[levels]; + uint32_t bits[1 << ORDER_METHOD_8LEVEL]; int order; int opt_index = levels-1; opt_order = max_order-1; @@ -1153,7 +1198,7 @@ static void output_frame_footer(FlacEncodeContext *s) { int crc; flush_put_bits(&s->pb); - crc = bswap_16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, + crc = av_bswap16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, s->pb.buf, put_bits_count(&s->pb)>>3)); put_bits(&s->pb, 16, crc); flush_put_bits(&s->pb); @@ -1164,7 +1209,7 @@ static void update_md5_sum(FlacEncodeContext *s, int16_t *samples) #if HAVE_BIGENDIAN int i; for(i = 0; i < s->frame.blocksize*s->channels; i++) { - int16_t smp = le2me_16(samples[i]); + int16_t smp = av_le2ne16(samples[i]); av_md5_update(s->md5ctx, (uint8_t *)&smp, 2); } #else diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/flvdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/flvdec.c index cf9661ce1..b21a9e4a3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/flvdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/flvdec.c @@ -127,6 +127,7 @@ AVCodec flv_decoder = { ff_h263_decode_end, ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"), .pix_fmts= ff_pixfmt_list_420, }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/fraps.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/fraps.c index 959ce92ea..0829ac7e7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/fraps.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/fraps.c @@ -23,7 +23,7 @@ /** * @file * Lossless Fraps 'FPS1' decoder - * @author Roine Gustafsson + * @author Roine Gustafsson (roine at users sf net) * @author Konstantin Shishkov * * Codec algorithm for version 0 is taken from Transcode diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/get_bits.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/get_bits.h index 556f542e6..f4b3646e6 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/get_bits.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/get_bits.h @@ -267,7 +267,7 @@ static inline void skip_bits_long(GetBitContext *s, int n){ # define UPDATE_CACHE(name, gb)\ if(name##_bit_count > 0){\ - const uint32_t next= be2me_32( *name##_buffer_ptr );\ + const uint32_t next= av_be2ne32( *name##_buffer_ptr );\ name##_cache0 |= NEG_USR32(next,name##_bit_count);\ name##_cache1 |= next<>5; re_bit_count &= 31; - re_cache0 = be2me_32( re_buffer_ptr[-1] ) << re_bit_count; + re_cache0 = av_be2ne32( re_buffer_ptr[-1] ) << re_bit_count; re_cache1 = 0; UPDATE_CACHE(re, s) CLOSE_READER(re, s) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/gsmdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/gsmdec.c new file mode 100644 index 000000000..3759f35d2 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/gsmdec.c @@ -0,0 +1,316 @@ +/* + * gsm 06.10 decoder + * Copyright (c) 2010 Reimar Döffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * GSM decoder + */ + +#define ALT_BITSTREAM_READER_LE +#include "avcodec.h" +#include "get_bits.h" + +// input and output sizes in byte +#define GSM_BLOCK_SIZE 33 +#define GSM_MS_BLOCK_SIZE 65 +#define GSM_FRAME_SIZE 160 + +typedef struct { + int16_t ref_buf[280]; + int v[9]; + int lar[2][8]; + int lar_idx; + int msr; +} GSMContext; + +static av_cold int gsm_init(AVCodecContext *avctx) +{ + avctx->channels = 1; + if (!avctx->sample_rate) + avctx->sample_rate = 8000; + avctx->sample_fmt = SAMPLE_FMT_S16; + + switch (avctx->codec_id) { + case CODEC_ID_GSM: + avctx->frame_size = GSM_FRAME_SIZE; + avctx->block_align = GSM_BLOCK_SIZE; + break; + case CODEC_ID_GSM_MS: + avctx->frame_size = 2 * GSM_FRAME_SIZE; + avctx->block_align = GSM_MS_BLOCK_SIZE; + } + + return 0; +} + +static const int16_t dequant_tab[64][8] = { + { -28, -20, -12, -4, 4, 12, 20, 28}, + { -56, -40, -24, -8, 8, 24, 40, 56}, + { -84, -60, -36, -12, 12, 36, 60, 84}, + { -112, -80, -48, -16, 16, 48, 80, 112}, + { -140, -100, -60, -20, 20, 60, 100, 140}, + { -168, -120, -72, -24, 24, 72, 120, 168}, + { -196, -140, -84, -28, 28, 84, 140, 196}, + { -224, -160, -96, -32, 32, 96, 160, 224}, + { -252, -180, -108, -36, 36, 108, 180, 252}, + { -280, -200, -120, -40, 40, 120, 200, 280}, + { -308, -220, -132, -44, 44, 132, 220, 308}, + { -336, -240, -144, -48, 48, 144, 240, 336}, + { -364, -260, -156, -52, 52, 156, 260, 364}, + { -392, -280, -168, -56, 56, 168, 280, 392}, + { -420, -300, -180, -60, 60, 180, 300, 420}, + { -448, -320, -192, -64, 64, 192, 320, 448}, + { -504, -360, -216, -72, 72, 216, 360, 504}, + { -560, -400, -240, -80, 80, 240, 400, 560}, + { -616, -440, -264, -88, 88, 264, 440, 616}, + { -672, -480, -288, -96, 96, 288, 480, 672}, + { -728, -520, -312, -104, 104, 312, 520, 728}, + { -784, -560, -336, -112, 112, 336, 560, 784}, + { -840, -600, -360, -120, 120, 360, 600, 840}, + { -896, -640, -384, -128, 128, 384, 640, 896}, + { -1008, -720, -432, -144, 144, 432, 720, 1008}, + { -1120, -800, -480, -160, 160, 480, 800, 1120}, + { -1232, -880, -528, -176, 176, 528, 880, 1232}, + { -1344, -960, -576, -192, 192, 576, 960, 1344}, + { -1456, -1040, -624, -208, 208, 624, 1040, 1456}, + { -1568, -1120, -672, -224, 224, 672, 1120, 1568}, + { -1680, -1200, -720, -240, 240, 720, 1200, 1680}, + { -1792, -1280, -768, -256, 256, 768, 1280, 1792}, + { -2016, -1440, -864, -288, 288, 864, 1440, 2016}, + { -2240, -1600, -960, -320, 320, 960, 1600, 2240}, + { -2464, -1760, -1056, -352, 352, 1056, 1760, 2464}, + { -2688, -1920, -1152, -384, 384, 1152, 1920, 2688}, + { -2912, -2080, -1248, -416, 416, 1248, 2080, 2912}, + { -3136, -2240, -1344, -448, 448, 1344, 2240, 3136}, + { -3360, -2400, -1440, -480, 480, 1440, 2400, 3360}, + { -3584, -2560, -1536, -512, 512, 1536, 2560, 3584}, + { -4032, -2880, -1728, -576, 576, 1728, 2880, 4032}, + { -4480, -3200, -1920, -640, 640, 1920, 3200, 4480}, + { -4928, -3520, -2112, -704, 704, 2112, 3520, 4928}, + { -5376, -3840, -2304, -768, 768, 2304, 3840, 5376}, + { -5824, -4160, -2496, -832, 832, 2496, 4160, 5824}, + { -6272, -4480, -2688, -896, 896, 2688, 4480, 6272}, + { -6720, -4800, -2880, -960, 960, 2880, 4800, 6720}, + { -7168, -5120, -3072, -1024, 1024, 3072, 5120, 7168}, + { -8063, -5759, -3456, -1152, 1152, 3456, 5760, 8064}, + { -8959, -6399, -3840, -1280, 1280, 3840, 6400, 8960}, + { -9855, -7039, -4224, -1408, 1408, 4224, 7040, 9856}, + {-10751, -7679, -4608, -1536, 1536, 4608, 7680, 10752}, + {-11647, -8319, -4992, -1664, 1664, 4992, 8320, 11648}, + {-12543, -8959, -5376, -1792, 1792, 5376, 8960, 12544}, + {-13439, -9599, -5760, -1920, 1920, 5760, 9600, 13440}, + {-14335, -10239, -6144, -2048, 2048, 6144, 10240, 14336}, + {-16127, -11519, -6912, -2304, 2304, 6912, 11519, 16127}, + {-17919, -12799, -7680, -2560, 2560, 7680, 12799, 17919}, + {-19711, -14079, -8448, -2816, 2816, 8448, 14079, 19711}, + {-21503, -15359, -9216, -3072, 3072, 9216, 15359, 21503}, + {-23295, -16639, -9984, -3328, 3328, 9984, 16639, 23295}, + {-25087, -17919, -10752, -3584, 3584, 10752, 17919, 25087}, + {-26879, -19199, -11520, -3840, 3840, 11520, 19199, 26879}, + {-28671, -20479, -12288, -4096, 4096, 12288, 20479, 28671} +}; + +static void apcm_dequant_add(GetBitContext *gb, int16_t *dst) +{ + int i; + int maxidx = get_bits(gb, 6); + const int16_t *tab = dequant_tab[maxidx]; + for (i = 0; i < 13; i++) + dst[3*i] += tab[get_bits(gb, 3)]; +} + +static inline int gsm_mult(int a, int b) +{ + return (a * b + (1 << 14)) >> 15; +} + +static const uint16_t long_term_gain_tab[4] = { + 3277, 11469, 21299, 32767 +}; + +static void long_term_synth(int16_t *dst, int lag, int gain_idx) +{ + int i; + const int16_t *src = dst - lag; + uint16_t gain = long_term_gain_tab[gain_idx]; + for (i = 0; i < 40; i++) + dst[i] = gsm_mult(gain, src[i]); +} + +static inline int decode_log_area(int coded, int factor, int offset) +{ + coded <<= 10; + coded -= offset; + return gsm_mult(coded, factor) << 1; +} + +static av_noinline int get_rrp(int filtered) +{ + int abs = FFABS(filtered); + if (abs < 11059) abs <<= 1; + else if (abs < 20070) abs += 11059; + else abs = (abs >> 2) + 26112; + return filtered < 0 ? -abs : abs; +} + +static int filter_value(int in, int rrp[8], int v[9]) +{ + int i; + for (i = 7; i >= 0; i--) { + in -= gsm_mult(rrp[i], v[i]); + v[i + 1] = v[i] + gsm_mult(rrp[i], in); + } + v[0] = in; + return in; +} + +static void short_term_synth(GSMContext *ctx, int16_t *dst, const int16_t *src) +{ + int i; + int rrp[8]; + int *lar = ctx->lar[ctx->lar_idx]; + int *lar_prev = ctx->lar[ctx->lar_idx ^ 1]; + for (i = 0; i < 8; i++) + rrp[i] = get_rrp((lar_prev[i] >> 2) + (lar_prev[i] >> 1) + (lar[i] >> 2)); + for (i = 0; i < 13; i++) + dst[i] = filter_value(src[i], rrp, ctx->v); + + for (i = 0; i < 8; i++) + rrp[i] = get_rrp((lar_prev[i] >> 1) + (lar [i] >> 1)); + for (i = 13; i < 27; i++) + dst[i] = filter_value(src[i], rrp, ctx->v); + + for (i = 0; i < 8; i++) + rrp[i] = get_rrp((lar_prev[i] >> 2) + (lar [i] >> 1) + (lar[i] >> 2)); + for (i = 27; i < 40; i++) + dst[i] = filter_value(src[i], rrp, ctx->v); + + for (i = 0; i < 8; i++) + rrp[i] = get_rrp(lar[i]); + for (i = 40; i < 160; i++) + dst[i] = filter_value(src[i], rrp, ctx->v); + + ctx->lar_idx ^= 1; +} + +static int postprocess(int16_t *data, int msr) +{ + int i; + for (i = 0; i < 160; i++) { + msr = av_clip_int16(data[i] + gsm_mult(msr, 28180)); + data[i] = av_clip_int16(msr << 1) & ~7; + } + return msr; +} + +static int gsm_decode_block(AVCodecContext *avctx, int16_t *samples, + GetBitContext *gb) +{ + GSMContext *ctx = avctx->priv_data; + int i; + int16_t *ref_dst = ctx->ref_buf + 120; + int *lar = ctx->lar[ctx->lar_idx]; + lar[0] = decode_log_area(get_bits(gb, 6), 13107, 1 << 15); + lar[1] = decode_log_area(get_bits(gb, 6), 13107, 1 << 15); + lar[2] = decode_log_area(get_bits(gb, 5), 13107, (1 << 14) + 2048*2); + lar[3] = decode_log_area(get_bits(gb, 5), 13107, (1 << 14) - 2560*2); + lar[4] = decode_log_area(get_bits(gb, 4), 19223, (1 << 13) + 94*2); + lar[5] = decode_log_area(get_bits(gb, 4), 17476, (1 << 13) - 1792*2); + lar[6] = decode_log_area(get_bits(gb, 3), 31454, (1 << 12) - 341*2); + lar[7] = decode_log_area(get_bits(gb, 3), 29708, (1 << 12) - 1144*2); + + for (i = 0; i < 4; i++) { + int lag = get_bits(gb, 7); + int gain_idx = get_bits(gb, 2); + int offset = get_bits(gb, 2); + lag = av_clip(lag, 40, 120); + long_term_synth(ref_dst, lag, gain_idx); + apcm_dequant_add(gb, ref_dst + offset); + ref_dst += 40; + } + memcpy(ctx->ref_buf, ctx->ref_buf + 160, 120 * sizeof(*ctx->ref_buf)); + short_term_synth(ctx, samples, ctx->ref_buf + 120); + // for optimal speed this could be merged with short_term_synth, + // not done yet because it is a bit ugly + ctx->msr = postprocess(samples, ctx->msr); + return 0; +} + +static int gsm_decode_frame(AVCodecContext *avctx, void *data, + int *data_size, AVPacket *avpkt) +{ + int res; + GetBitContext gb; + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; + int16_t *samples = data; + int frame_bytes = 2 * avctx->frame_size; + + if (*data_size < frame_bytes) + return -1; + *data_size = 0; + if(buf_size < avctx->block_align) + return AVERROR_INVALIDDATA; + init_get_bits(&gb, buf, buf_size * 8); + + switch (avctx->codec_id) { + case CODEC_ID_GSM: + if (get_bits(&gb, 4) != 0xd) + av_log(avctx, AV_LOG_WARNING, "Missing GSM magic!\n"); + res = gsm_decode_block(avctx, samples, &gb); + if (res < 0) + return res; + break; + case CODEC_ID_GSM_MS: + res = gsm_decode_block(avctx, samples, &gb); + if (res < 0) + return res; + res = gsm_decode_block(avctx, samples + GSM_FRAME_SIZE, &gb); + if (res < 0) + return res; + } + *data_size = frame_bytes; + return avctx->block_align; +} + +AVCodec gsm_decoder = { + "gsm", + AVMEDIA_TYPE_AUDIO, + CODEC_ID_GSM, + sizeof(GSMContext), + gsm_init, + NULL, + NULL, + gsm_decode_frame, + .long_name = NULL_IF_CONFIG_SMALL("GSM"), +}; + +AVCodec gsm_ms_decoder = { + "gsm_ms", + AVMEDIA_TYPE_AUDIO, + CODEC_ID_GSM_MS, + sizeof(GSMContext), + gsm_init, + NULL, + NULL, + gsm_decode_frame, + .long_name = NULL_IF_CONFIG_SMALL("GSM Microsoft variant"), +}; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h261dec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h261dec.c index bb5f27d50..3809a0179 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h261dec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h261dec.c @@ -651,5 +651,6 @@ AVCodec h261_decoder = { h261_decode_end, h261_decode_frame, CODEC_CAP_DR1, + .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("H.261"), }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h261enc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h261enc.c index d3f2219f6..c85ee8bb0 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h261enc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h261enc.c @@ -84,7 +84,7 @@ void ff_h261_encode_picture_header(MpegEncContext * s, int picture_number){ } /** - * Encodes a group of blocks header. + * Encode a group of blocks header. */ static void h261_encode_gob_header(MpegEncContext * s, int mb_line){ H261Context * h = (H261Context *)s; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h263.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h263.h index 678588a17..6c05565c7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h263.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h263.h @@ -93,7 +93,7 @@ void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n); /** - * Prints picture info if FF_DEBUG_PICT_INFO is set. + * Print picture info if FF_DEBUG_PICT_INFO is set. */ void ff_h263_show_pict_info(MpegEncContext *s); @@ -102,8 +102,8 @@ int ff_h263_decode_mb(MpegEncContext *s, DCTELEM block[6][64]); /** - * Returns the value of the 3bit "source format" syntax element. - * that represents some standard picture dimensions or indicates that + * Return the value of the 3bit "source format" syntax element. + * This represents some standard picture dimensions or indicates that * width&height are explicitly stored later. */ int av_const h263_get_picture_format(int width, int height); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h263dec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h263dec.c index c80cfcfa2..d9d6f7e5d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h263dec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h263dec.c @@ -738,6 +738,7 @@ AVCodec h263_decoder = { ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, .flush= ff_mpeg_flush, + .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"), .pix_fmts= ff_hwaccel_pixfmt_list_420, }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264.c index ef0999617..d1662fcb6 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264.c @@ -1428,7 +1428,7 @@ static int pred_weight_table(H264Context *h){ /** * Initialize implicit_weight table. - * @param field, 0/1 initialize the weight for interlaced MBAFF + * @param field 0/1 initialize the weight for interlaced MBAFF * -1 initializes the rest */ static void implicit_weight_table(H264Context *h, int field){ @@ -1690,7 +1690,7 @@ static void field_end(H264Context *h){ } /** - * Replicates H264 "master" context to thread contexts. + * Replicate H264 "master" context to thread contexts. */ static void clone_slice(H264Context *dst, H264Context *src) { @@ -1902,13 +1902,14 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ if(h0->current_slice == 0){ while(h->frame_num != h->prev_frame_num && h->frame_num != (h->prev_frame_num+1)%(1<sps.log2_max_frame_num)){ - av_log(NULL, AV_LOG_DEBUG, "Frame num gap %d %d\n", h->frame_num, h->prev_frame_num); + av_log(h->s.avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n", h->frame_num, h->prev_frame_num); if (ff_h264_frame_start(h) < 0) return -1; h->prev_frame_num++; h->prev_frame_num %= 1<sps.log2_max_frame_num; s->current_picture_ptr->frame_num= h->prev_frame_num; - ff_h264_execute_ref_pic_marking(h, NULL, 0); + ff_generate_sliding_window_mmcos(h); + ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); } /* See if we have a decoded first field looking for a pair... */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264.h index 0922ede6f..7158d9748 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264.h @@ -620,7 +620,7 @@ int ff_h264_decode_seq_parameter_set(H264Context *h); int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length); /** - * Decodes a network abstraction layer unit. + * Decode 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 tailing? @@ -629,29 +629,29 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length); const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length); /** - * identifies the exact end of the bitstream + * Identify the exact end of the bitstream * @return the length of the trailing, or 0 if damaged */ int ff_h264_decode_rbsp_trailing(H264Context *h, const uint8_t *src); /** - * frees any data that may have been allocated in the H264 context like SPS, PPS etc. + * Free any data that may have been allocated in the H264 context like SPS, PPS etc. */ av_cold void ff_h264_free_context(H264Context *h); /** - * reconstructs bitstream slice_type. + * Reconstruct bitstream slice_type. */ int ff_h264_get_slice_type(const H264Context *h); /** - * allocates tables. + * Allocate tables. * needs width/height */ int ff_h264_alloc_tables(H264Context *h); /** - * fills the default_ref_list. + * Fill the default_ref_list. */ int ff_h264_fill_default_ref_list(H264Context *h); @@ -660,20 +660,22 @@ void ff_h264_fill_mbaff_ref_list(H264Context *h); void ff_h264_remove_all_refs(H264Context *h); /** - * Executes the reference picture marking (memory management control operations). + * Execute the reference picture marking (memory management control operations). */ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count); int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb); +void ff_generate_sliding_window_mmcos(H264Context *h); + /** - * checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks. + * Check if the top & left blocks are available if needed & change the dc mode so it only uses the available blocks. */ int ff_h264_check_intra4x4_pred_mode(H264Context *h); /** - * checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks. + * Check if the top & left blocks are available if needed & change the dc mode so it only uses the available blocks. */ int ff_h264_check_intra_pred_mode(H264Context *h, int mode); @@ -686,13 +688,13 @@ av_cold int ff_h264_decode_end(AVCodecContext *avctx); av_cold void ff_h264_decode_init_vlc(void); /** - * decodes a macroblock + * Decode a macroblock * @return 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed */ int ff_h264_decode_mb_cavlc(H264Context *h); /** - * decodes a CABAC coded macroblock + * Decode a CABAC coded macroblock * @return 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed */ int ff_h264_decode_mb_cabac(H264Context *h); @@ -1255,7 +1257,7 @@ static inline int get_dct8x8_allowed(H264Context *h){ /** * decodes a P_SKIP or B_SKIP macroblock */ -static void decode_mb_skip(H264Context *h){ +static void av_unused decode_mb_skip(H264Context *h){ MpegEncContext * const s = &h->s; const int mb_xy= h->mb_xy; int mb_type=0; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264_mp4toannexb_bsf.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264_mp4toannexb_bsf.c index 0c92b36f6..e2ee10a03 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264_mp4toannexb_bsf.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264_mp4toannexb_bsf.c @@ -25,27 +25,32 @@ typedef struct H264BSFContext { uint8_t length_size; uint8_t first_idr; - uint8_t *sps_pps_data; - uint32_t size; + int extradata_parsed; } H264BSFContext; -static void alloc_and_copy(uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *sps_pps, uint32_t sps_pps_size, - const uint8_t *in, uint32_t in_size) { +static int alloc_and_copy(uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *sps_pps, uint32_t sps_pps_size, + const uint8_t *in, uint32_t in_size) { uint32_t offset = *poutbuf_size; uint8_t nal_header_size = offset ? 3 : 4; + void *tmp; *poutbuf_size += sps_pps_size+in_size+nal_header_size; - *poutbuf = av_realloc(*poutbuf, *poutbuf_size); + tmp = av_realloc(*poutbuf, *poutbuf_size); + if (!tmp) + return AVERROR(ENOMEM); + *poutbuf = tmp; if (sps_pps) memcpy(*poutbuf+offset, sps_pps, sps_pps_size); memcpy(*poutbuf+sps_pps_size+nal_header_size+offset, in, in_size); - if (!offset) + if (!offset) { AV_WB32(*poutbuf+sps_pps_size, 1); - else { + } else { (*poutbuf+offset+sps_pps_size)[0] = (*poutbuf+offset+sps_pps_size)[1] = 0; (*poutbuf+offset+sps_pps_size)[2] = 1; } + + return 0; } static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, @@ -67,9 +72,9 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, } /* retrieve sps and pps NAL units from extradata */ - if (!ctx->sps_pps_data) { + if (!ctx->extradata_parsed) { uint16_t unit_size; - uint32_t total_size = 0; + uint64_t total_size = 0; uint8_t *out = NULL, unit_nb, sps_done = 0; const uint8_t *extradata = avctx->extradata+4; static const uint8_t nalu_header[4] = {0, 0, 0, 1}; @@ -86,15 +91,21 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, sps_done++; } while (unit_nb--) { + void *tmp; + unit_size = AV_RB16(extradata); total_size += unit_size+4; - if (extradata+2+unit_size > avctx->extradata+avctx->extradata_size) { + if (total_size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE || + extradata+2+unit_size > avctx->extradata+avctx->extradata_size) { av_free(out); return AVERROR(EINVAL); } - out = av_realloc(out, total_size); - if (!out) + tmp = av_realloc(out, total_size + FF_INPUT_BUFFER_PADDING_SIZE); + if (!tmp) { + av_free(out); return AVERROR(ENOMEM); + } + out = tmp; memcpy(out+total_size-unit_size-4, nalu_header, 4); memcpy(out+total_size-unit_size, extradata+2, unit_size); extradata += 2+unit_size; @@ -103,9 +114,12 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, unit_nb = *extradata++; /* number of pps unit(s) */ } - ctx->sps_pps_data = out; - ctx->size = total_size; - ctx->first_idr = 1; + memset(out + total_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + av_free(avctx->extradata); + avctx->extradata = out; + avctx->extradata_size = total_size; + ctx->first_idr = 1; + ctx->extradata_parsed = 1; } *poutbuf_size = 0; @@ -114,11 +128,11 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, if (buf + ctx->length_size > buf_end) goto fail; - if (ctx->length_size == 1) + if (ctx->length_size == 1) { nal_size = buf[0]; - else if (ctx->length_size == 2) + } else if (ctx->length_size == 2) { nal_size = AV_RB16(buf); - else + } else nal_size = AV_RB32(buf); buf += ctx->length_size; @@ -129,15 +143,16 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, /* prepend only to the first type 5 NAL unit of an IDR picture */ if (ctx->first_idr && unit_type == 5) { - alloc_and_copy(poutbuf, poutbuf_size, - ctx->sps_pps_data, ctx->size, - buf, nal_size); + if (alloc_and_copy(poutbuf, poutbuf_size, + avctx->extradata, avctx->extradata_size, + buf, nal_size) < 0) + goto fail; ctx->first_idr = 0; - } - else { - alloc_and_copy(poutbuf, poutbuf_size, - NULL, 0, - buf, nal_size); + } else { + if (alloc_and_copy(poutbuf, poutbuf_size, + NULL, 0, + buf, nal_size) < 0) + goto fail; if (!ctx->first_idr && unit_type == 1) ctx->first_idr = 1; } @@ -154,16 +169,9 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc, return AVERROR(EINVAL); } -static void h264_mp4toannexb_close(AVBitStreamFilterContext *bsfc) -{ - H264BSFContext *ctx = bsfc->priv_data; - av_freep(&ctx->sps_pps_data); -} - AVBitStreamFilter h264_mp4toannexb_bsf = { "h264_mp4toannexb", sizeof(H264BSFContext), h264_mp4toannexb_filter, - h264_mp4toannexb_close, }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264_refs.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264_refs.c index ed715c6b0..74eaaa8ad 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264_refs.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264_refs.c @@ -474,6 +474,25 @@ static void print_long_term(H264Context *h) { } } +void ff_generate_sliding_window_mmcos(H264Context *h) { + MpegEncContext * const s = &h->s; + assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count); + + h->mmco_index= 0; + if(h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count && + !(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->reference)) { + h->mmco[0].opcode= MMCO_SHORT2UNUSED; + h->mmco[0].short_pic_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num; + h->mmco_index= 1; + if (FIELD_PICTURE) { + h->mmco[0].short_pic_num *= 2; + h->mmco[1].opcode= MMCO_SHORT2UNUSED; + h->mmco[1].short_pic_num= h->mmco[0].short_pic_num + 1; + h->mmco_index= 2; + } + } +} + int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){ MpegEncContext * const s = &h->s; int i, av_uninit(j); @@ -673,20 +692,7 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb){ } h->mmco_index= i; }else{ - assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count); - - if(h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count && - !(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->reference)) { - h->mmco[0].opcode= MMCO_SHORT2UNUSED; - h->mmco[0].short_pic_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num; - h->mmco_index= 1; - if (FIELD_PICTURE) { - h->mmco[0].short_pic_num *= 2; - h->mmco[1].opcode= MMCO_SHORT2UNUSED; - h->mmco[1].short_pic_num= h->mmco[0].short_pic_num + 1; - h->mmco_index= 2; - } - } + ff_generate_sliding_window_mmcos(h); } } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264idct.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264idct.c index da5c6a518..31e072f98 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264idct.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264idct.c @@ -143,24 +143,24 @@ void ff_h264_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride){ // assumes all AC coefs are 0 void ff_h264_idct_dc_add_c(uint8_t *dst, DCTELEM *block, int stride){ int i, j; - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; int dc = (block[0] + 32) >> 6; + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP + dc; for( j = 0; j < 4; j++ ) { for( i = 0; i < 4; i++ ) - dst[i] = cm[ dst[i] + dc ]; + dst[i] = cm[ dst[i] ]; dst += stride; } } void ff_h264_idct8_dc_add_c(uint8_t *dst, DCTELEM *block, int stride){ int i, j; - uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; int dc = (block[0] + 32) >> 6; + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP + dc; for( j = 0; j < 8; j++ ) { for( i = 0; i < 8; i++ ) - dst[i] = cm[ dst[i] + dc ]; + dst[i] = cm[ dst[i] ]; dst += stride; } } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264pred.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264pred.c index 9637b4542..5706c97e1 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264pred.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264pred.c @@ -28,8 +28,9 @@ #include "avcodec.h" #include "mpegvideo.h" #include "h264pred.h" +#include "mathops.h" -static void pred4x4_vertical_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_vertical_c(uint8_t *src, const 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; @@ -37,14 +38,14 @@ static void pred4x4_vertical_c(uint8_t *src, uint8_t *topright, int stride){ ((uint32_t*)(src+3*stride))[0]= a; } -static void pred4x4_horizontal_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_horizontal_c(uint8_t *src, const 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){ +static void pred4x4_dc_c(uint8_t *src, const 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; @@ -54,7 +55,7 @@ static void pred4x4_dc_c(uint8_t *src, uint8_t *topright, int stride){ ((uint32_t*)(src+3*stride))[0]= dc* 0x01010101; } -static void pred4x4_left_dc_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_left_dc_c(uint8_t *src, const 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]= @@ -63,7 +64,7 @@ static void pred4x4_left_dc_c(uint8_t *src, uint8_t *topright, int stride){ ((uint32_t*)(src+3*stride))[0]= dc* 0x01010101; } -static void pred4x4_top_dc_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_top_dc_c(uint8_t *src, const 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]= @@ -72,7 +73,7 @@ static void pred4x4_top_dc_c(uint8_t *src, uint8_t *topright, int stride){ ((uint32_t*)(src+3*stride))[0]= dc* 0x01010101; } -static void pred4x4_128_dc_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_128_dc_c(uint8_t *src, const uint8_t *topright, int stride){ ((uint32_t*)(src+0*stride))[0]= ((uint32_t*)(src+1*stride))[0]= ((uint32_t*)(src+2*stride))[0]= @@ -104,7 +105,32 @@ static void pred4x4_128_dc_c(uint8_t *src, uint8_t *topright, int stride){ const int av_unused t2= src[ 2-1*stride];\ const int av_unused t3= src[ 3-1*stride];\ -static void pred4x4_down_right_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_vertical_vp8_c(uint8_t *src, const uint8_t *topright, int stride){ + const int lt= src[-1-1*stride]; + LOAD_TOP_EDGE + LOAD_TOP_RIGHT_EDGE + uint32_t v = PACK_4U8((lt + 2*t0 + t1 + 2) >> 2, + (t0 + 2*t1 + t2 + 2) >> 2, + (t1 + 2*t2 + t3 + 2) >> 2, + (t2 + 2*t3 + t4 + 2) >> 2); + + AV_WN32A(src+0*stride, v); + AV_WN32A(src+1*stride, v); + AV_WN32A(src+2*stride, v); + AV_WN32A(src+3*stride, v); +} + +static void pred4x4_horizontal_vp8_c(uint8_t *src, const uint8_t *topright, int stride){ + const int lt= src[-1-1*stride]; + LOAD_LEFT_EDGE + + AV_WN32A(src+0*stride, ((lt + 2*l0 + l1 + 2) >> 2)*0x01010101); + AV_WN32A(src+1*stride, ((l0 + 2*l1 + l2 + 2) >> 2)*0x01010101); + AV_WN32A(src+2*stride, ((l1 + 2*l2 + l3 + 2) >> 2)*0x01010101); + AV_WN32A(src+3*stride, ((l2 + 2*l3 + l3 + 2) >> 2)*0x01010101); +} + +static void pred4x4_down_right_c(uint8_t *src, const uint8_t *topright, int stride){ const int lt= src[-1-1*stride]; LOAD_TOP_EDGE LOAD_LEFT_EDGE @@ -127,7 +153,7 @@ static void pred4x4_down_right_c(uint8_t *src, uint8_t *topright, int stride){ src[3+0*stride]=(t1 + 2*t2 + t3 + 2)>>2; } -static void pred4x4_down_left_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_down_left_c(uint8_t *src, const uint8_t *topright, int stride){ LOAD_TOP_EDGE LOAD_TOP_RIGHT_EDGE // LOAD_LEFT_EDGE @@ -150,7 +176,7 @@ static void pred4x4_down_left_c(uint8_t *src, uint8_t *topright, int stride){ src[3+3*stride]=(t6 + 3*t7 + 2)>>2; } -static void pred4x4_down_left_svq3_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_down_left_svq3_c(uint8_t *src, const uint8_t *topright, int stride){ LOAD_TOP_EDGE LOAD_LEFT_EDGE const av_unused int unu0= t0; @@ -174,7 +200,7 @@ static void pred4x4_down_left_svq3_c(uint8_t *src, uint8_t *topright, int stride src[3+3*stride]=(l3 + t3)>>1; } -static void pred4x4_down_left_rv40_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_down_left_rv40_c(uint8_t *src, const uint8_t *topright, int stride){ LOAD_TOP_EDGE LOAD_TOP_RIGHT_EDGE LOAD_LEFT_EDGE @@ -198,7 +224,7 @@ static void pred4x4_down_left_rv40_c(uint8_t *src, uint8_t *topright, int stride src[3+3*stride]=(t6 + t7 + 1 + l6 + l7 + 1)>>2; } -static void pred4x4_down_left_rv40_nodown_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_down_left_rv40_nodown_c(uint8_t *src, const uint8_t *topright, int stride){ LOAD_TOP_EDGE LOAD_TOP_RIGHT_EDGE LOAD_LEFT_EDGE @@ -221,7 +247,7 @@ static void pred4x4_down_left_rv40_nodown_c(uint8_t *src, uint8_t *topright, int src[3+3*stride]=(t6 + t7 + 1 + 2*l3 + 1)>>2; } -static void pred4x4_vertical_right_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_vertical_right_c(uint8_t *src, const uint8_t *topright, int stride){ const int lt= src[-1-1*stride]; LOAD_TOP_EDGE LOAD_LEFT_EDGE @@ -244,7 +270,7 @@ static void pred4x4_vertical_right_c(uint8_t *src, uint8_t *topright, int stride src[0+3*stride]=(l0 + 2*l1 + l2 + 2)>>2; } -static void pred4x4_vertical_left_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_vertical_left_c(uint8_t *src, const uint8_t *topright, int stride){ LOAD_TOP_EDGE LOAD_TOP_RIGHT_EDGE @@ -266,7 +292,7 @@ static void pred4x4_vertical_left_c(uint8_t *src, uint8_t *topright, int stride) src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2; } -static void pred4x4_vertical_left_rv40(uint8_t *src, uint8_t *topright, int stride, +static void pred4x4_vertical_left_rv40(uint8_t *src, const uint8_t *topright, int stride, const int l0, const int l1, const int l2, const int l3, const int l4){ LOAD_TOP_EDGE LOAD_TOP_RIGHT_EDGE @@ -289,20 +315,42 @@ static void pred4x4_vertical_left_rv40(uint8_t *src, uint8_t *topright, int stri src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2; } -static void pred4x4_vertical_left_rv40_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_vertical_left_rv40_c(uint8_t *src, const uint8_t *topright, int stride){ LOAD_LEFT_EDGE LOAD_DOWN_LEFT_EDGE pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l4); } -static void pred4x4_vertical_left_rv40_nodown_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_vertical_left_rv40_nodown_c(uint8_t *src, const uint8_t *topright, int stride){ LOAD_LEFT_EDGE pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l3); } -static void pred4x4_horizontal_up_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_vertical_left_vp8_c(uint8_t *src, const uint8_t *topright, int stride){ + LOAD_TOP_EDGE + LOAD_TOP_RIGHT_EDGE + + 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[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+2*stride]=(t4 + 2*t5 + t6 + 2)>>2; + src[3+3*stride]=(t5 + 2*t6 + t7 + 2)>>2; +} + +static void pred4x4_horizontal_up_c(uint8_t *src, const uint8_t *topright, int stride){ LOAD_LEFT_EDGE src[0+0*stride]=(l0 + l1 + 1)>>1; @@ -323,7 +371,7 @@ static void pred4x4_horizontal_up_c(uint8_t *src, uint8_t *topright, int stride) src[3+3*stride]=l3; } -static void pred4x4_horizontal_up_rv40_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_horizontal_up_rv40_c(uint8_t *src, const uint8_t *topright, int stride){ LOAD_LEFT_EDGE LOAD_DOWN_LEFT_EDGE LOAD_TOP_EDGE @@ -347,7 +395,7 @@ static void pred4x4_horizontal_up_rv40_c(uint8_t *src, uint8_t *topright, int st src[3+3*stride]=(l4 + 2*l5 + l6 + 2)>>2; } -static void pred4x4_horizontal_up_rv40_nodown_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_horizontal_up_rv40_nodown_c(uint8_t *src, const uint8_t *topright, int stride){ LOAD_LEFT_EDGE LOAD_TOP_EDGE LOAD_TOP_RIGHT_EDGE @@ -370,7 +418,7 @@ static void pred4x4_horizontal_up_rv40_nodown_c(uint8_t *src, uint8_t *topright, src[3+3*stride]=l3; } -static void pred4x4_horizontal_down_c(uint8_t *src, uint8_t *topright, int stride){ +static void pred4x4_horizontal_down_c(uint8_t *src, const uint8_t *topright, int stride){ const int lt= src[-1-1*stride]; LOAD_TOP_EDGE LOAD_LEFT_EDGE @@ -393,6 +441,21 @@ static void pred4x4_horizontal_down_c(uint8_t *src, uint8_t *topright, int strid src[1+3*stride]=(l1 + 2*l2 + l3 + 2)>>2; } +static void pred4x4_tm_vp8_c(uint8_t *src, const uint8_t *topright, int stride){ + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride]; + uint8_t *top = src-stride; + int y; + + for (y = 0; y < 4; y++) { + uint8_t *cm_in = cm + src[-1]; + src[0] = cm_in[top[0]]; + src[1] = cm_in[top[1]]; + src[2] = cm_in[top[2]]; + src[3] = cm_in[top[3]]; + src += stride; + } +} + static void pred16x16_vertical_c(uint8_t *src, int stride){ int i; const uint32_t a= ((uint32_t*)(src-stride))[0]; @@ -539,6 +602,33 @@ static void pred16x16_plane_rv40_c(uint8_t *src, int stride){ pred16x16_plane_compat_c(src, stride, 0, 1); } +static void pred16x16_tm_vp8_c(uint8_t *src, int stride){ + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride]; + uint8_t *top = src-stride; + int y; + + for (y = 0; y < 16; y++) { + uint8_t *cm_in = cm + src[-1]; + src[0] = cm_in[top[0]]; + src[1] = cm_in[top[1]]; + src[2] = cm_in[top[2]]; + src[3] = cm_in[top[3]]; + src[4] = cm_in[top[4]]; + src[5] = cm_in[top[5]]; + src[6] = cm_in[top[6]]; + src[7] = cm_in[top[7]]; + src[8] = cm_in[top[8]]; + src[9] = cm_in[top[9]]; + src[10] = cm_in[top[10]]; + src[11] = cm_in[top[11]]; + src[12] = cm_in[top[12]]; + src[13] = cm_in[top[13]]; + src[14] = cm_in[top[14]]; + src[15] = cm_in[top[15]]; + src += stride; + } +} + static void pred8x8_vertical_c(uint8_t *src, int stride){ int i; const uint32_t a= ((uint32_t*)(src-stride))[0]; @@ -745,6 +835,25 @@ static void pred8x8_plane_c(uint8_t *src, int stride){ } } +static void pred8x8_tm_vp8_c(uint8_t *src, int stride){ + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride]; + uint8_t *top = src-stride; + int y; + + for (y = 0; y < 8; y++) { + uint8_t *cm_in = cm + src[-1]; + src[0] = cm_in[top[0]]; + src[1] = cm_in[top[1]]; + src[2] = cm_in[top[2]]; + src[3] = cm_in[top[3]]; + src[4] = cm_in[top[4]]; + src[5] = cm_in[top[5]]; + src[6] = cm_in[top[6]]; + src[7] = cm_in[top[7]]; + src += stride; + } +} + #define SRC(x,y) src[(x)+(y)*stride] #define PL(y) \ const int l##y = (SRC(-1,y-1) + 2*SRC(-1,y) + SRC(-1,y+1) + 2) >> 2; @@ -1075,14 +1184,19 @@ static void pred8x8_horizontal_add_c(uint8_t *pix, const int *block_offset, cons /** - * Sets the intra prediction function pointers. + * Set the intra prediction function pointers. */ void ff_h264_pred_init(H264PredContext *h, int codec_id){ // MpegEncContext * const s = &h->s; if(codec_id != CODEC_ID_RV40){ - h->pred4x4[VERT_PRED ]= pred4x4_vertical_c; - h->pred4x4[HOR_PRED ]= pred4x4_horizontal_c; + if(codec_id == CODEC_ID_VP8) { + h->pred4x4[VERT_PRED ]= pred4x4_vertical_vp8_c; + h->pred4x4[HOR_PRED ]= pred4x4_horizontal_vp8_c; + } else { + h->pred4x4[VERT_PRED ]= pred4x4_vertical_c; + h->pred4x4[HOR_PRED ]= pred4x4_horizontal_c; + } h->pred4x4[DC_PRED ]= pred4x4_dc_c; if(codec_id == CODEC_ID_SVQ3) h->pred4x4[DIAG_DOWN_LEFT_PRED ]= pred4x4_down_left_svq3_c; @@ -1091,11 +1205,16 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){ 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; + if (codec_id == CODEC_ID_VP8) { + h->pred4x4[VERT_LEFT_PRED ]= pred4x4_vertical_left_vp8_c; + } else + 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; + if(codec_id == CODEC_ID_VP8) + h->pred4x4[TM_VP8_PRED ]= pred4x4_tm_vp8_c; }else{ h->pred4x4[VERT_PRED ]= pred4x4_vertical_c; h->pred4x4[HOR_PRED ]= pred4x4_horizontal_c; @@ -1129,8 +1248,11 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){ h->pred8x8[VERT_PRED8x8 ]= pred8x8_vertical_c; h->pred8x8[HOR_PRED8x8 ]= pred8x8_horizontal_c; - h->pred8x8[PLANE_PRED8x8 ]= pred8x8_plane_c; - if(codec_id != CODEC_ID_RV40){ + if (codec_id != CODEC_ID_VP8) { + h->pred8x8[PLANE_PRED8x8]= pred8x8_plane_c; + } else + h->pred8x8[PLANE_PRED8x8]= pred8x8_tm_vp8_c; + if(codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8){ h->pred8x8[DC_PRED8x8 ]= pred8x8_dc_c; h->pred8x8[LEFT_DC_PRED8x8]= pred8x8_left_dc_c; h->pred8x8[TOP_DC_PRED8x8 ]= pred8x8_top_dc_c; @@ -1156,6 +1278,9 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){ case CODEC_ID_RV40: h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_rv40_c; break; + case CODEC_ID_VP8: + h->pred16x16[PLANE_PRED8x8 ]= pred16x16_tm_vp8_c; + break; default: h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_c; } @@ -1174,4 +1299,5 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){ h->pred16x16_add[ HOR_PRED8x8]= pred16x16_horizontal_add_c; if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id); + if (HAVE_MMX) ff_h264_pred_init_x86(h, codec_id); } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264pred.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264pred.h index c52aeaa25..b7fd2a2b7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264pred.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/h264pred.h @@ -49,6 +49,8 @@ #define TOP_DC_PRED 10 #define DC_128_PRED 11 +#define TM_VP8_PRED 9 ///< "True Motion", used instead of plane + #define DIAG_DOWN_LEFT_PRED_RV40_NODOWN 12 #define HOR_UP_PRED_RV40_NODOWN 13 #define VERT_LEFT_PRED_RV40_NODOWN 14 @@ -72,7 +74,7 @@ * Context for storing H.264 prediction functions */ typedef struct H264PredContext{ - void (*pred4x4 [9+3+3])(uint8_t *src, uint8_t *topright, int stride);//FIXME move to dsp? + void (*pred4x4 [9+3+3])(uint8_t *src, const uint8_t *topright, int stride);//FIXME move to dsp? void (*pred8x8l [9+3])(uint8_t *src, int topleft, int topright, int stride); void (*pred8x8 [4+3+4])(uint8_t *src, int stride); void (*pred16x16[4+3])(uint8_t *src, int stride); @@ -85,5 +87,6 @@ typedef struct H264PredContext{ void ff_h264_pred_init(H264PredContext *h, int codec_id); void ff_h264_pred_init_arm(H264PredContext *h, int codec_id); +void ff_h264_pred_init_x86(H264PredContext *h, int codec_id); #endif /* AVCODEC_H264PRED_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/huffyuv.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/huffyuv.c index 7764c3518..7541785cb 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/huffyuv.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/huffyuv.c @@ -231,11 +231,12 @@ static void heap_sift(HeapElem *h, int root, int size) } } -static void generate_len_table(uint8_t *dst, const uint64_t *stats, int size){ - HeapElem h[size]; - int up[2*size]; - int len[2*size]; +static void generate_len_table(uint8_t *dst, const uint64_t *stats){ + HeapElem h[256]; + int up[2*256]; + int len[2*256]; int offset, i, next; + int size = 256; for(offset=1; ; offset<<=1){ for(i=0; ilen[i], s->stats[i], 256); + generate_len_table(s->len[i], s->stats[i]); if(generate_bits_table(s->bits[i], s->len[i])<0){ return -1; @@ -1224,7 +1225,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, if(s->context){ for(i=0; i<3; i++){ - generate_len_table(s->len[i], s->stats[i], 256); + generate_len_table(s->len[i], s->stats[i]); if(generate_bits_table(s->bits[i], s->len[i])<0) return -1; size+= store_table(s, s->len[i], &buf[size]); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/idcinvideo.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/idcinvideo.c index 203812b12..cc79ef0a4 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/idcinvideo.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/idcinvideo.c @@ -77,7 +77,7 @@ typedef struct IdcinContext { /* * Find the lowest probability node in a Huffman table, and mark it as * being assigned to a higher probability. - * Returns the node index of the lowest unused node, or -1 if all nodes + * @return the node index of the lowest unused node, or -1 if all nodes * are used. */ static int huff_smallest_node(hnode *hnodes, int num_hnodes) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/iff.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/iff.c index 29353bf1f..2992cb43a 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/iff.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/iff.c @@ -38,22 +38,22 @@ typedef struct { } IffContext; #define LUT8_PART(plane, v) \ - AV_LE2ME64C(UINT64_C(0x0000000)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x1000000)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x0010000)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x1010000)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x0000100)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x1000100)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x0010100)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x1010100)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x0000001)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x1000001)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x0010001)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x1010001)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x0000101)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x1000101)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x0010101)<<32 | v) << plane, \ - AV_LE2ME64C(UINT64_C(0x1010101)<<32 | v) << plane + AV_LE2NE64C(UINT64_C(0x0000000)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x1000000)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x0010000)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x1010000)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x0000100)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x1000100)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x0010100)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x1010100)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x0000001)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x1000001)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x0010001)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x1010001)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x0000101)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x1000101)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x0010101)<<32 | v) << plane, \ + AV_LE2NE64C(UINT64_C(0x1010101)<<32 | v) << plane #define LUT8(plane) { \ LUT8_PART(plane, 0x0000000), \ @@ -215,7 +215,7 @@ static void decodeplane32(uint32_t *dst, const uint8_t *buf, int buf_size, int p } /** - * Decodes one complete byterun1 encoded line. + * Decode one complete byterun1 encoded line. * * @param dst the destination buffer where to store decompressed bitstream * @param dst_size the destination plane size in bytes @@ -293,7 +293,7 @@ static int decode_frame_ilbm(AVCodecContext *avctx, for(y = 0; y < avctx->height; y++ ) { uint8_t *row = &s->frame.data[0][y * s->frame.linesize[0]]; memcpy(row, buf, FFMIN(avctx->width, buf_end - buf)); - buf += avctx->width; + buf += avctx->width + (avctx->width % 2); // padding if odd } } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/imc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/imc.c index 2a420f5bc..a27e4b6d3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/imc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/imc.c @@ -660,7 +660,7 @@ static int imc_decode_frame(AVCodecContext * avctx, return -1; } for(i = 0; i < IMC_BLOCK_SIZE / 2; i++) - buf16[i] = bswap_16(((const uint16_t*)buf)[i]); + buf16[i] = av_bswap16(((const uint16_t*)buf)[i]); init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/imgconvert.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/imgconvert.c index 4984f2cb1..68f1a7574 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/imgconvert.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/imgconvert.c @@ -32,9 +32,9 @@ #include "avcodec.h" #include "dsputil.h" -#include "colorspace.h" #include "internal.h" #include "imgconvert.h" +#include "libavutil/colorspace.h" #include "libavutil/pixdesc.h" #if HAVE_MMX diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/indeo3.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/indeo3.c index e5df32c67..63d91da6a 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/indeo3.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/indeo3.c @@ -359,14 +359,14 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s, switch(correction_type_sp[0][k]) { case 0: - *cur_lp = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); + *cur_lp = av_le2ne32(((av_le2ne32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); lp2++; break; case 1: - res = ((le2me_16(((unsigned short *)(ref_lp))[0]) >> 1) + correction_lp[lp2 & 0x01][*buf1]) << 1; - ((unsigned short *)cur_lp)[0] = le2me_16(res); - res = ((le2me_16(((unsigned short *)(ref_lp))[1]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1; - ((unsigned short *)cur_lp)[1] = le2me_16(res); + res = ((av_le2ne16(((unsigned short *)(ref_lp))[0]) >> 1) + correction_lp[lp2 & 0x01][*buf1]) << 1; + ((unsigned short *)cur_lp)[0] = av_le2ne16(res); + res = ((av_le2ne16(((unsigned short *)(ref_lp))[1]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1; + ((unsigned short *)cur_lp)[1] = av_le2ne16(res); buf1++; lp2++; break; @@ -462,19 +462,19 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s, switch(correction_type_sp[lp2 & 0x01][k]) { case 0: - cur_lp[width_tbl[1]] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); + cur_lp[width_tbl[1]] = av_le2ne32(((av_le2ne32(*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] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); + cur_lp[0] = av_le2ne32(((av_le2ne32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); lp2++; break; case 1: - res = ((le2me_16(((unsigned short *)ref_lp)[0]) >> 1) + correction_lp[lp2 & 0x01][*buf1]) << 1; - ((unsigned short *)cur_lp)[width_tbl[2]] = le2me_16(res); - res = ((le2me_16(((unsigned short *)ref_lp)[1]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1; - ((unsigned short *)cur_lp)[width_tbl[2]+1] = le2me_16(res); + res = ((av_le2ne16(((unsigned short *)ref_lp)[0]) >> 1) + correction_lp[lp2 & 0x01][*buf1]) << 1; + ((unsigned short *)cur_lp)[width_tbl[2]] = av_le2ne16(res); + res = ((av_le2ne16(((unsigned short *)ref_lp)[1]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1; + ((unsigned short *)cur_lp)[width_tbl[2]+1] = av_le2ne16(res); if(lp2 > 0 || flag1 == 0 || strip->ypos != 0) cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; @@ -591,8 +591,8 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s, switch(correction_type_sp[lp2 & 0x01][k]) { case 0: - cur_lp[width_tbl[1]] = le2me_32(((le2me_32(lv1) >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1); - cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(lv2) >> 1) + correctionhighorder_lp[lp2 & 0x01][k]) << 1); + cur_lp[width_tbl[1]] = av_le2ne32(((av_le2ne32(lv1) >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1); + cur_lp[width_tbl[1]+1] = av_le2ne32(((av_le2ne32(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; @@ -604,8 +604,8 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s, break; case 1: - cur_lp[width_tbl[1]] = le2me_32(((le2me_32(lv1) >> 1) + correctionloworder_lp[lp2 & 0x01][*buf1]) << 1); - cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(lv2) >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1); + cur_lp[width_tbl[1]] = av_le2ne32(((av_le2ne32(lv1) >> 1) + correctionloworder_lp[lp2 & 0x01][*buf1]) << 1); + cur_lp[width_tbl[1]+1] = av_le2ne32(((av_le2ne32(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; @@ -748,20 +748,20 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s, case 0: lv1 = correctionloworder_lp[lp2 & 0x01][k]; lv2 = correctionhighorder_lp[lp2 & 0x01][k]; - cur_lp[0] = le2me_32(((le2me_32(ref_lp[0]) >> 1) + lv1) << 1); - cur_lp[1] = le2me_32(((le2me_32(ref_lp[1]) >> 1) + lv2) << 1); - cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + lv1) << 1); - cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(ref_lp[width_tbl[1]+1]) >> 1) + lv2) << 1); + cur_lp[0] = av_le2ne32(((av_le2ne32(ref_lp[0]) >> 1) + lv1) << 1); + cur_lp[1] = av_le2ne32(((av_le2ne32(ref_lp[1]) >> 1) + lv2) << 1); + cur_lp[width_tbl[1]] = av_le2ne32(((av_le2ne32(ref_lp[width_tbl[1]]) >> 1) + lv1) << 1); + cur_lp[width_tbl[1]+1] = av_le2ne32(((av_le2ne32(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] = le2me_32(((le2me_32(ref_lp[0]) >> 1) + lv1) << 1); - cur_lp[1] = le2me_32(((le2me_32(ref_lp[1]) >> 1) + lv2) << 1); - cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + lv1) << 1); - cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(ref_lp[width_tbl[1]+1]) >> 1) + lv2) << 1); + cur_lp[0] = av_le2ne32(((av_le2ne32(ref_lp[0]) >> 1) + lv1) << 1); + cur_lp[1] = av_le2ne32(((av_le2ne32(ref_lp[1]) >> 1) + lv2) << 1); + cur_lp[width_tbl[1]] = av_le2ne32(((av_le2ne32(ref_lp[width_tbl[1]]) >> 1) + lv1) << 1); + cur_lp[width_tbl[1]+1] = av_le2ne32(((av_le2ne32(ref_lp[width_tbl[1]+1]) >> 1) + lv2) << 1); lp2++; break; @@ -849,22 +849,22 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s, switch(correction_type_sp[lp2 & 0x01][k]) { case 0: - cur_lp[0] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); - cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); + cur_lp[0] = av_le2ne32(((av_le2ne32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); + cur_lp[width_tbl[1]] = av_le2ne32(((av_le2ne32(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]); - res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[0]) >> 1) + lv1) << 1); - ((unsigned short *)cur_lp)[0] = le2me_16(res); - res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[1]) >> 1) + lv2) << 1); - ((unsigned short *)cur_lp)[1] = le2me_16(res); - res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[width_tbl[2]]) >> 1) + lv1) << 1); - ((unsigned short *)cur_lp)[width_tbl[2]] = le2me_16(res); - res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[width_tbl[2]+1]) >> 1) + lv2) << 1); - ((unsigned short *)cur_lp)[width_tbl[2]+1] = le2me_16(res); + res = (unsigned short)(((av_le2ne16(((unsigned short *)ref_lp)[0]) >> 1) + lv1) << 1); + ((unsigned short *)cur_lp)[0] = av_le2ne16(res); + res = (unsigned short)(((av_le2ne16(((unsigned short *)ref_lp)[1]) >> 1) + lv2) << 1); + ((unsigned short *)cur_lp)[1] = av_le2ne16(res); + res = (unsigned short)(((av_le2ne16(((unsigned short *)ref_lp)[width_tbl[2]]) >> 1) + lv1) << 1); + ((unsigned short *)cur_lp)[width_tbl[2]] = av_le2ne16(res); + res = (unsigned short)(((av_le2ne16(((unsigned short *)ref_lp)[width_tbl[2]+1]) >> 1) + lv2) << 1); + ((unsigned short *)cur_lp)[width_tbl[2]+1] = av_le2ne16(res); lp2++; break; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/indeo5.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/indeo5.c index 0898b618c..dd22d4fb9 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/indeo5.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/indeo5.c @@ -80,7 +80,7 @@ typedef struct { /** - * Decodes Indeo5 GOP (Group of pictures) header. + * Decode Indeo5 GOP (Group of pictures) header. * This header is present in key frames only. * It defines parameters for all frames in a GOP. * @@ -90,7 +90,8 @@ typedef struct { */ static int decode_gop_header(IVI5DecContext *ctx, AVCodecContext *avctx) { - int result, i, p, tile_size, pic_size_indx, mb_size, blk_size, blk_size_changed = 0; + int result, i, p, tile_size, pic_size_indx, mb_size, blk_size; + int quant_mat, blk_size_changed = 0; IVIBandDesc *band, *band1, *band2; IVIPicConfig pic_conf; @@ -212,9 +213,21 @@ static int decode_gop_header(IVI5DecContext *ctx, AVCodecContext *avctx) /* select dequant matrix according to plane and band number */ if (!p) { - band->quant_mat = (pic_conf.luma_bands > 1) ? i+1 : 0; + quant_mat = (pic_conf.luma_bands > 1) ? i+1 : 0; } else { - band->quant_mat = 5; + quant_mat = 5; + } + + if (band->blk_size == 8) { + band->intra_base = &ivi5_base_quant_8x8_intra[quant_mat][0]; + band->inter_base = &ivi5_base_quant_8x8_inter[quant_mat][0]; + band->intra_scale = &ivi5_scale_quant_8x8_intra[quant_mat][0]; + band->inter_scale = &ivi5_scale_quant_8x8_inter[quant_mat][0]; + } else { + band->intra_base = ivi5_base_quant_4x4_intra; + band->inter_base = ivi5_base_quant_4x4_inter; + band->intra_scale = ivi5_scale_quant_4x4_intra; + band->inter_scale = ivi5_scale_quant_4x4_inter; } if (get_bits(&ctx->gb, 2)) { @@ -234,7 +247,10 @@ static int decode_gop_header(IVI5DecContext *ctx, AVCodecContext *avctx) band2->mb_size = band1->mb_size; band2->blk_size = band1->blk_size; band2->is_halfpel = band1->is_halfpel; - band2->quant_mat = band1->quant_mat; + band2->intra_base = band1->intra_base; + band2->inter_base = band1->inter_base; + band2->intra_scale = band1->intra_scale; + band2->inter_scale = band1->inter_scale; band2->scan = band1->scan; band2->inv_transform = band1->inv_transform; band2->dc_transform = band1->dc_transform; @@ -280,7 +296,7 @@ static int decode_gop_header(IVI5DecContext *ctx, AVCodecContext *avctx) /** - * Skips a header extension. + * Skip a header extension. * * @param gb [in,out] the GetBit context */ @@ -296,7 +312,7 @@ static inline void skip_hdr_extension(GetBitContext *gb) /** - * Decodes Indeo5 picture header. + * Decode Indeo5 picture header. * * @param ctx [in,out] ptr to the decoder context * @param avctx [in] ptr to the AVCodecContext @@ -348,7 +364,7 @@ static int decode_pic_hdr(IVI5DecContext *ctx, AVCodecContext *avctx) /** - * Decodes Indeo5 band header. + * Decode Indeo5 band header. * * @param ctx [in,out] ptr to the decoder context * @param band [in,out] ptr to the band descriptor @@ -416,7 +432,7 @@ static int decode_band_hdr(IVI5DecContext *ctx, IVIBandDesc *band, /** - * Decodes info (block type, cbp, quant delta, motion vector) + * Decode info (block type, cbp, quant delta, motion vector) * for all macroblocks in the current tile. * * @param ctx [in,out] ptr to the decoder context @@ -541,7 +557,7 @@ static int decode_mb_info(IVI5DecContext *ctx, IVIBandDesc *band, /** - * Decodes an Indeo5 band. + * Decode an Indeo5 band. * * @param ctx [in,out] ptr to the decoder context * @param band [in,out] ptr to the band descriptor @@ -570,18 +586,6 @@ static int decode_band(IVI5DecContext *ctx, int plane_num, return -1; } - if (band->blk_size == 8) { - band->intra_base = &ivi5_base_quant_8x8_intra[band->quant_mat][0]; - band->inter_base = &ivi5_base_quant_8x8_inter[band->quant_mat][0]; - band->intra_scale = &ivi5_scale_quant_8x8_intra[band->quant_mat][0]; - band->inter_scale = &ivi5_scale_quant_8x8_inter[band->quant_mat][0]; - } else { - band->intra_base = ivi5_base_quant_4x4_intra; - band->inter_base = ivi5_base_quant_4x4_inter; - band->intra_scale = ivi5_scale_quant_4x4_intra; - band->inter_scale = ivi5_scale_quant_4x4_inter; - } - band->rv_map = &ctx->rvmap_tabs[band->rvmap_sel]; /* apply corrections to the selected rvmap table if present */ @@ -643,12 +647,11 @@ static int decode_band(IVI5DecContext *ctx, int plane_num, /** - * Switches buffers. + * Switch buffers. * * @param ctx [in,out] ptr to the decoder context - * @param avctx [in] ptr to the AVCodecContext */ -static void switch_buffers(IVI5DecContext *ctx, AVCodecContext *avctx) +static void switch_buffers(IVI5DecContext *ctx) { switch (ctx->prev_frame_type) { case FRAMETYPE_INTRA: @@ -687,7 +690,7 @@ static void switch_buffers(IVI5DecContext *ctx, AVCodecContext *avctx) /** - * Initializes Indeo5 decoder. + * Initialize Indeo5 decoder. */ static av_cold int decode_init(AVCodecContext *avctx) { @@ -752,7 +755,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, return -1; } - switch_buffers(ctx, avctx); + switch_buffers(ctx); //START_TIMER; @@ -797,7 +800,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, /** - * Closes Indeo5 decoder and cleans up its context. + * Close Indeo5 decoder and clean up its context. */ static av_cold int decode_close(AVCodecContext *avctx) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/indeo5data.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/indeo5data.h index 87a0a6060..a6217d0bf 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/indeo5data.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/indeo5data.h @@ -47,68 +47,68 @@ static const uint8_t ivi5_common_pic_sizes[30] = { * ivi5_base_quant_bbb_ttt - base tables for block size 'bbb' of type 'ttt' * ivi5_scale_quant_bbb_ttt - scale tables for block size 'bbb' of type 'ttt' */ -static const uint8_t ivi5_base_quant_8x8_inter[5][64] = { - {0x13, 0x1d, 0x1f, 0x23, 0x25, 0x27, 0x29, 0x2d, 0x1d, 0x1f, 0x21, 0x23, 0x25, 0x27, 0x2b, 0x2f, - 0x1f, 0x21, 0x23, 0x24, 0x26, 0x29, 0x2d, 0x31, 0x23, 0x23, 0x24, 0x25, 0x27, 0x2b, 0x2f, 0x33, - 0x25, 0x25, 0x26, 0x27, 0x29, 0x2d, 0x31, 0x35, 0x27, 0x27, 0x29, 0x2b, 0x2d, 0x2f, 0x33, 0x37, - 0x29, 0x2b, 0x2d, 0x2f, 0x31, 0x33, 0x35, 0x39, 0x2d, 0x2f, 0x31, 0x33, 0x35, 0x37, 0x39, 0x3b - }, - {0x13, 0x1d, 0x1f, 0x23, 0x25, 0x27, 0x29, 0x2d, 0x1d, 0x1f, 0x21, 0x23, 0x25, 0x27, 0x2b, 0x2f, - 0x1f, 0x21, 0x23, 0x24, 0x26, 0x29, 0x2d, 0x31, 0x23, 0x23, 0x24, 0x25, 0x27, 0x2b, 0x2f, 0x33, - 0x25, 0x25, 0x26, 0x27, 0x29, 0x2d, 0x31, 0x35, 0x27, 0x27, 0x29, 0x2b, 0x2d, 0x2f, 0x33, 0x37, - 0x29, 0x2b, 0x2d, 0x2f, 0x31, 0x33, 0x35, 0x39, 0x2d, 0x2f, 0x31, 0x33, 0x35, 0x37, 0x39, 0x3b - }, - {0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, - 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, - 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, - 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61 - }, - {0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, - 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, - 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, - 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61 - }, - {0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, - 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, - 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, - 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f +static const uint16_t ivi5_base_quant_8x8_inter[5][64] = { + {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e, + 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66, + 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e, + 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76, + }, + {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e, + 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66, + 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e, + 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76, + }, + {0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, + 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, + 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, + 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, + }, + {0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, + 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, + 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, + }, + {0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, + 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, + 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, + 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, } }; -static const uint8_t ivi5_base_quant_8x8_intra[5][64] = { - {0x0d, 0x17, 0x1b, 0x21, 0x23, 0x25, 0x27, 0x2d, 0x17, 0x19, 0x1f, 0x21, 0x23, 0x27, 0x2b, 0x35, - 0x1b, 0x1f, 0x1f, 0x22, 0x25, 0x2a, 0x33, 0x39, 0x21, 0x21, 0x22, 0x25, 0x29, 0x31, 0x36, 0x3d, - 0x23, 0x23, 0x25, 0x29, 0x2f, 0x33, 0x39, 0x47, 0x25, 0x27, 0x2a, 0x31, 0x33, 0x37, 0x43, 0x53, - 0x27, 0x2b, 0x33, 0x36, 0x39, 0x43, 0x4d, 0x65, 0x2d, 0x35, 0x39, 0x3d, 0x47, 0x53, 0x65, 0x7f - }, - {0x13, 0x1d, 0x1f, 0x23, 0x25, 0x27, 0x29, 0x2d, 0x1d, 0x1f, 0x21, 0x23, 0x25, 0x27, 0x2b, 0x2f, - 0x1f, 0x21, 0x23, 0x24, 0x26, 0x29, 0x2d, 0x31, 0x23, 0x23, 0x24, 0x25, 0x27, 0x2b, 0x2f, 0x33, - 0x25, 0x25, 0x26, 0x27, 0x29, 0x2d, 0x31, 0x35, 0x27, 0x27, 0x29, 0x2b, 0x2d, 0x2f, 0x33, 0x37, - 0x29, 0x2b, 0x2d, 0x2f, 0x31, 0x33, 0x35, 0x39, 0x2d, 0x2f, 0x31, 0x33, 0x35, 0x37, 0x39, 0x3b - }, - {0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, - 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, - 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, - 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61, 0x27, 0x55, 0x79, 0x6a, 0x6f, 0x61, 0x6b, 0x61 - }, - {0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, - 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, - 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, - 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61 - }, - {0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, - 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, - 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, - 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f +static const uint16_t ivi5_base_quant_8x8_intra[5][64] = { + {0x1a, 0x2e, 0x36, 0x42, 0x46, 0x4a, 0x4e, 0x5a, 0x2e, 0x32, 0x3e, 0x42, 0x46, 0x4e, 0x56, 0x6a, + 0x36, 0x3e, 0x3e, 0x44, 0x4a, 0x54, 0x66, 0x72, 0x42, 0x42, 0x44, 0x4a, 0x52, 0x62, 0x6c, 0x7a, + 0x46, 0x46, 0x4a, 0x52, 0x5e, 0x66, 0x72, 0x8e, 0x4a, 0x4e, 0x54, 0x62, 0x66, 0x6e, 0x86, 0xa6, + 0x4e, 0x56, 0x66, 0x6c, 0x72, 0x86, 0x9a, 0xca, 0x5a, 0x6a, 0x72, 0x7a, 0x8e, 0xa6, 0xca, 0xfe, + }, + {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e, + 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66, + 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e, + 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76, + }, + {0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, + 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, + 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, + 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, + }, + {0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, + 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, + 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, + 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, + }, + {0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, + 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, + 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, + 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, } }; -static const uint8_t ivi5_base_quant_4x4_inter[16] = { - 0x0f, 0x1f, 0x25, 0x29, 0x1f, 0x25, 0x29, 0x2b, 0x25, 0x29, 0x2b, 0x2f, 0x29, 0x2b, 0x2f, 0x33 +static const uint16_t ivi5_base_quant_4x4_inter[16] = { + 0x1e, 0x3e, 0x4a, 0x52, 0x3e, 0x4a, 0x52, 0x56, 0x4a, 0x52, 0x56, 0x5e, 0x52, 0x56, 0x5e, 0x66 }; -static const uint8_t ivi5_base_quant_4x4_intra[16] = { - 0x0f, 0x1f, 0x25, 0x29, 0x1f, 0x25, 0x29, 0x2f, 0x25, 0x29, 0x2f, 0x3d, 0x29, 0x2f, 0x3d, 0x49 +static const uint16_t ivi5_base_quant_4x4_intra[16] = { + 0x1e, 0x3e, 0x4a, 0x52, 0x3e, 0x4a, 0x52, 0x5e, 0x4a, 0x52, 0x5e, 0x7a, 0x52, 0x5e, 0x7a, 0x92 }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/internal.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/internal.h index 67d5be7c3..24aca6b28 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/internal.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/internal.h @@ -28,12 +28,12 @@ #include "avcodec.h" /** - * Determines whether pix_fmt is a hardware accelerated format. + * Determine whether pix_fmt is a hardware accelerated format. */ int ff_is_hwaccel_pix_fmt(enum PixelFormat pix_fmt); /** - * Returns the hardware accelerated codec for codec codec_id and + * Return the hardware accelerated codec for codec codec_id and * pixel format pix_fmt. * * @param codec_id the codec to match diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ituh263enc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ituh263enc.c index f736d7c66..253783822 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ituh263enc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ituh263enc.c @@ -84,7 +84,7 @@ static const uint8_t wrong_run[102] = { }; /** - * Returns the 4 bit value that specifies the given aspect ratio. + * Return the 4 bit value that specifies the given aspect ratio. * This may be one of the standard aspect ratios or it specifies * that the aspect will be stored explicitly later. */ @@ -245,7 +245,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number) } /** - * Encodes a group of blocks header. + * Encode a group of blocks header. */ void h263_encode_gob_header(MpegEncContext * s, int mb_line) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ivi_common.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ivi_common.c index 5fcaca2c3..b15845808 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ivi_common.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ivi_common.c @@ -40,7 +40,7 @@ VLC ff_ivi_mb_vlc_tabs [8]; VLC ff_ivi_blk_vlc_tabs[8]; /** - * Reverses "nbits" bits of the value "val" and returns the result + * Reverse "nbits" bits of the value "val" and return the result * in the least significant bits. */ static uint16_t inv_bits(uint16_t val, int nbits) @@ -338,7 +338,8 @@ int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile) RVMapDesc *rvmap = band->rv_map; void (*mc_with_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type); void (*mc_no_delta_func) (int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type); - const uint8_t *base_tab, *scale_tab; + const uint16_t *base_tab; + const uint8_t *scale_tab; prev_dc = 0; /* init intra prediction for the DC coefficient */ @@ -363,6 +364,8 @@ int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile) base_tab = is_intra ? band->intra_base : band->inter_base; scale_tab = is_intra ? band->intra_scale : band->inter_scale; + if (scale_tab) + quant = scale_tab[quant]; if (!is_intra) { mv_x = mb->mv_x; @@ -414,7 +417,7 @@ int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile) if (IVI_DEBUG && !val) av_log(NULL, AV_LOG_ERROR, "Val = 0 encountered!\n"); - q = (base_tab[pos] * scale_tab[quant]) >> 8; + q = (base_tab[pos] * quant) >> 9; if (q > 1) val = val * q + FFSIGN(val) * (((q ^ 1) - 1) >> 1); trvec[pos] = val; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ivi_common.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ivi_common.h index bb2d4ed2e..6f7ea9005 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ivi_common.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ivi_common.h @@ -75,6 +75,13 @@ extern const uint8_t ff_ivi_horizontal_scan_8x8[64]; extern const uint8_t ff_ivi_direct_scan_4x4[16]; +/** + * Declare inverse transform function types + */ +typedef void (InvTransformPtr)(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags); +typedef void (DCTransformPtr) (const int32_t *in, int16_t *out, uint32_t pitch, int blk_size); + + /** * run-value (RLE) table descriptor */ @@ -152,14 +159,14 @@ typedef struct { RVMapDesc *rv_map; ///< ptr to the RLE table for this band int num_tiles; ///< number of tiles in this band IVITile *tiles; ///< array of tile descriptors - void (*inv_transform)(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags); ///< inverse transform function pointer - void (*dc_transform) (const int32_t *in, int16_t *out, uint32_t pitch, int blk_size); ///< dc transform function pointer, it may be NULL + InvTransformPtr *inv_transform; + DCTransformPtr *dc_transform; int is_2d_trans; ///< 1 indicates that the two-dimensional inverse transform is used int32_t checksum; ///< for debug purposes int checksum_present; int bufsize; ///< band buffer size in bytes - const uint8_t *intra_base; ///< quantization matrix for intra blocks - const uint8_t *inter_base; ///< quantization matrix for inter blocks + const uint16_t *intra_base; ///< quantization matrix for intra blocks + const uint16_t *inter_base; ///< quantization matrix for inter blocks const uint8_t *intra_scale; ///< quantization coefficient for intra blocks const uint8_t *inter_scale; ///< quantization coefficient for inter blocks } IVIBandDesc; @@ -187,7 +194,7 @@ typedef struct { uint8_t chroma_bands; } IVIPicConfig; -/** compares some properties of two pictures */ +/** compare some properties of two pictures */ static inline int ivi_pic_config_cmp(IVIPicConfig *str1, IVIPicConfig *str2) { return (str1->pic_width != str2->pic_width || str1->pic_height != str2->pic_height || @@ -206,15 +213,15 @@ static inline int ivi_pic_config_cmp(IVIPicConfig *str1, IVIPicConfig *str2) /** convert unsigned values into signed ones (the sign is in the LSB) */ #define IVI_TOSIGNED(val) (-(((val) >> 1) ^ -((val) & 1))) -/** scales motion vector */ +/** scale motion vector */ static inline int ivi_scale_mv(int mv, int mv_scale) { return (mv + (mv > 0) + (mv_scale - 1)) >> mv_scale; } /** - * Generates a huffman codebook from the given descriptor - * and converts it into the FFmpeg VLC table. + * Generate a huffman codebook from the given descriptor + * and convert it into the FFmpeg VLC table. * * @param cb [in] pointer to codebook descriptor * @param vlc [out] where to place the generated VLC table @@ -224,13 +231,13 @@ static inline int ivi_scale_mv(int mv, int mv_scale) int ff_ivi_create_huff_from_desc(const IVIHuffDesc *cb, VLC *vlc, int flag); /** - * Initializes static codes used for macroblock and block decoding. + * Initialize static codes used for macroblock and block decoding. */ void ff_ivi_init_static_vlc(void); /** - * Decodes a huffman codebook descriptor from the bitstream - * and selects specified huffman table. + * Decode a huffman codebook descriptor from the bitstream + * and select specified huffman table. * * @param gb [in,out] the GetBit context * @param desc_coded [in] flag signalling if table descriptor was coded @@ -243,7 +250,7 @@ int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab, IVIHuffTab *huff_tab, AVCodecContext *avctx); /** - * Compares two huffman codebook descriptors. + * Compare two huffman codebook descriptors. * * @param desc1 [in] ptr to the 1st descriptor to compare * @param desc2 [in] ptr to the 2nd descriptor to compare @@ -252,7 +259,7 @@ int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab, int ff_ivi_huff_desc_cmp(const IVIHuffDesc *desc1, const IVIHuffDesc *desc2); /** - * Copies huffman codebook descriptors. + * Copy huffman codebook descriptors. * * @param dst [out] ptr to the destination descriptor * @param src [in] ptr to the source descriptor @@ -260,7 +267,7 @@ int ff_ivi_huff_desc_cmp(const IVIHuffDesc *desc1, const IVIHuffDesc *desc2); void ff_ivi_huff_desc_copy(IVIHuffDesc *dst, const IVIHuffDesc *src); /** - * Initializes planes (prepares descriptors, allocates buffers etc). + * Initialize planes (prepares descriptors, allocates buffers etc). * * @param planes [in,out] pointer to the array of the plane descriptors * @param cfg [in] pointer to the ivi_pic_config structure describing picture layout @@ -269,14 +276,14 @@ void ff_ivi_huff_desc_copy(IVIHuffDesc *dst, const IVIHuffDesc *src); int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg); /** - * Frees planes, bands and macroblocks buffers. + * Free planes, bands and macroblocks buffers. * * @param planes [in] pointer to the array of the plane descriptors */ void ff_ivi_free_buffers(IVIPlaneDesc *planes); /** - * Initializes tile and macroblock descriptors. + * Initialize tile and macroblock descriptors. * * @param planes [in,out] pointer to the array of the plane descriptors * @param tile_width [in] tile width @@ -286,7 +293,7 @@ void ff_ivi_free_buffers(IVIPlaneDesc *planes); int ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height); /** - * Decodes size of the tile data. + * Decode size of the tile data. * The size is stored as a variable-length field having the following format: * if (tile_data_size < 255) than this field is only one byte long * if (tile_data_size >= 255) than this field four is byte long: 0xFF X1 X2 X3 @@ -298,9 +305,9 @@ int ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height); int ff_ivi_dec_tile_data_size(GetBitContext *gb); /** - * Decodes block data: - * extracts huffman-coded transform coefficients from the bitstream, - * dequantizes them, applies inverse transform and motion compensation + * Decode block data: + * extract huffman-coded transform coefficients from the bitstream, + * dequantize them, apply inverse transform and motion compensation * in order to reconstruct the picture. * * @param gb [in,out] the GetBit context @@ -311,7 +318,7 @@ int ff_ivi_dec_tile_data_size(GetBitContext *gb); int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile); /** - * Handles empty tiles by performing data copying and motion + * Handle empty tiles by performing data copying and motion * compensation respectively. * * @param avctx [in] ptr to the AVCodecContext @@ -323,7 +330,7 @@ void ff_ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band, IVITile *tile, int32_t mv_scale); /** - * Converts and outputs the current plane. + * Convert and output the current plane. * This conversion is done by adding back the bias value of 128 * (subtracted in the encoder) and clipping the result. * @@ -335,12 +342,12 @@ void ff_ivi_output_plane(IVIPlaneDesc *plane, uint8_t *dst, int dst_pitch); #if IVI_DEBUG /** - * Calculates band checksum from band data. + * Calculate band checksum from band data. */ uint16_t ivi_calc_band_checksum (IVIBandDesc *band); /** - * Verifies that band data lies in range. + * Verify that band data lies in range. */ int ivi_check_band (IVIBandDesc *band, const uint8_t *ref, int pitch); #endif diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ivi_dsp.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ivi_dsp.h index bdd9654c7..927461f5a 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ivi_dsp.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ivi_dsp.h @@ -117,13 +117,13 @@ void ff_ivi_dc_row_slant(const int32_t *in, int16_t *out, uint32_t pitch, int bl void ff_ivi_dc_col_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size); /** - * Copies the pixels into the frame buffer. + * Copy the pixels into the frame buffer. */ void ff_ivi_put_pixels_8x8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags); /** - * Copies the DC coefficient into the first pixel of the block and - * zeroes all others. + * Copy the DC coefficient into the first pixel of the block and + * zero all others. */ void ff_ivi_put_dc_pixel_8x8(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/kgv1dec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/kgv1dec.c index 5af6b3b2b..7ecb28d41 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/kgv1dec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/kgv1dec.c @@ -172,5 +172,6 @@ AVCodec kgv1_decoder = { NULL, decode_end, decode_frame, + .max_lowres = 1, .long_name = NULL_IF_CONFIG_SMALL("Kega Game Video"), }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/latm_parser.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/latm_parser.c deleted file mode 100644 index 4ac90c8d3..000000000 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/latm_parser.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * copyright (c) 2008 Paul Kendall - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file latm_parser.c - * LATM parser - */ - -#include -#include -#include -#include -#include - -#include "parser.h" - -#define LATM_HEADER 0x56e000 // 0x2b7 (11 bits) -#define LATM_MASK 0xFFE000 // top 11 bits -#define LATM_SIZE_MASK 0x001FFF // bottom 13 bits - -typedef struct LATMParseContext{ - ParseContext pc; - int count; -} LATMParseContext; - -/** - * 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 latm_find_frame_end(AVCodecParserContext *s1, const uint8_t *buf, - int buf_size) { - LATMParseContext *s = s1->priv_data; - ParseContext *pc = &s->pc; - int pic_found, i; - uint32_t state; - - pic_found = pc->frame_start_found; - state = pc->state; - - i = 0; - if(!pic_found){ - for(i=0; icount = - i; - pic_found=1; - break; - } - } - } - - if(pic_found){ - /* EOF considered as end of frame */ - if (buf_size == 0) - return 0; - if((state & LATM_SIZE_MASK) - s->count <= buf_size) { - pc->frame_start_found = 0; - pc->state = -1; - return (state & LATM_SIZE_MASK) - s->count; - } - } - - s->count += buf_size; - pc->frame_start_found = pic_found; - pc->state = state; - return END_NOT_FOUND; -} - -static int latm_parse(AVCodecParserContext *s1, - AVCodecContext *avctx, - const uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size) -{ - LATMParseContext *s = s1->priv_data; - ParseContext *pc = &s->pc; - int next; - - if(s1->flags & PARSER_FLAG_COMPLETE_FRAMES){ - next = buf_size; - }else{ - next = latm_find_frame_end(s1, buf, buf_size); - - if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { - *poutbuf = NULL; - *poutbuf_size = 0; - return buf_size; - } - } - *poutbuf = buf; - *poutbuf_size = buf_size; - return next; -} - -AVCodecParser latm_parser = { - { CODEC_ID_AAC_LATM }, - sizeof(LATMParseContext), - NULL, - latm_parse, - ff_parse_close -}; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/latmaac.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/latmaac.c deleted file mode 100644 index c2241649f..000000000 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/latmaac.c +++ /dev/null @@ -1,391 +0,0 @@ -/* - * copyright (c) 2008 Paul Kendall - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file latmaac.c - * LATM wrapped AAC decoder - */ - -#include -#include -#include -#include -#include - -#include "parser.h" -#include "get_bits.h" -#include "put_bits.h" -#include "mpeg4audio.h" -#include "neaacdec.h" - -#define min(a,b) ((a)<(b) ? (a) : (b)) - -/* - Note: This decoder filter is intended to decode LATM streams transferred - in MPEG transport streams which only contain one program. - To do a more complex LATM demuxing a separate LATM demuxer should be used. -*/ - -#define SYNC_LATM 0x2b7 // 11 bits -#define MAX_SIZE 8*1024 - -typedef struct AACDecoder -{ - faacDecHandle aac_decoder; - uint8_t initialized; - - // parser data - uint8_t audio_mux_version_A; - uint8_t frameLengthType; - uint8_t extra[64]; // should be way enough - int extrasize; -} AACDecoder; - -static inline int64_t latm_get_value(GetBitContext *b) -{ - uint8_t bytesForValue = get_bits(b, 2); - int64_t value = 0; - int i; - for (i=0; i<=bytesForValue; i++) { - value <<= 8; - value |= get_bits(b, 8); - } - return value; -} - -static void readGASpecificConfig(int audioObjectType, GetBitContext *b, PutBitContext *o) -{ - int framelen_flag; - int dependsOnCoder; - int ext_flag; - - framelen_flag = get_bits(b, 1); - put_bits(o, 1, framelen_flag); - dependsOnCoder = get_bits(b, 1); - put_bits(o, 1, dependsOnCoder); - if (dependsOnCoder) { - int delay = get_bits(b, 14); - put_bits(o, 14, delay); - } - ext_flag = get_bits(b, 1); - put_bits(o, 1, ext_flag); - - if (audioObjectType == 6 || audioObjectType == 20) { - int layerNr = get_bits(b, 3); - put_bits(o, 3, layerNr); - } - if (ext_flag) { - if (audioObjectType == 22) { - skip_bits(b, 5); // numOfSubFrame - skip_bits(b, 11); // layer_length - - put_bits(o, 16, 0); - } - if (audioObjectType == 17 || - audioObjectType == 19 || - audioObjectType == 20 || - audioObjectType == 23) { - - skip_bits(b, 3); // stuff - put_bits(o, 3, 0); - } - - skip_bits(b, 1); // extflag3 - put_bits(o, 1, 0); - } -} - -static int readAudioSpecificConfig(struct AACDecoder *decoder, GetBitContext *b) -{ - PutBitContext o; - int ret = 0; - int audioObjectType; - int samplingFrequencyIndex; - int channelConfiguration; - - init_put_bits(&o, decoder->extra, sizeof(decoder->extra)); - - audioObjectType = get_bits(b, 5); - put_bits(&o, 5, audioObjectType); - if (audioObjectType == 31) { - uint8_t extended = get_bits(b, 6); - put_bits(&o, 6, extended); - audioObjectType = 32 + extended; - } - - samplingFrequencyIndex = get_bits(b, 4); - put_bits(&o, 4, samplingFrequencyIndex); - if (samplingFrequencyIndex == 0x0f) { - uint32_t f = get_bits_long(b, 24); - put_bits(&o, 24, f); - } - channelConfiguration = get_bits(b, 4); - put_bits(&o, 4, channelConfiguration); - - if (audioObjectType == 1 || audioObjectType == 2 || audioObjectType == 3 - || audioObjectType == 4 || audioObjectType == 6 || audioObjectType == 7) { - readGASpecificConfig(audioObjectType, b, &o); - } else if (audioObjectType == 5) { - int sbr_present = 1; - samplingFrequencyIndex = get_bits(b, 4); - if (samplingFrequencyIndex == 0x0f) { - uint32_t f = get_bits_long(b, 24); - put_bits(&o, 24, f); - } - audioObjectType = get_bits(b, 5); - put_bits(&o, 5, audioObjectType); - } else if (audioObjectType >= 17) { - int epConfig; - readGASpecificConfig(audioObjectType, b, &o); - epConfig = get_bits(b, 2); - put_bits(&o, 2, epConfig); - } - - // count the extradata - ret = put_bits_count(&o); - decoder->extrasize = (ret + 7) / 8; - - flush_put_bits(&o); - return ret; -} - -static void readStreamMuxConfig(struct AACDecoder *parser, GetBitContext *b) -{ - int audio_mux_version = get_bits(b, 1); - parser->audio_mux_version_A = 0; - if (audio_mux_version == 1) { // audioMuxVersion - parser->audio_mux_version_A = get_bits(b, 1); - } - - if (parser->audio_mux_version_A == 0) { - int frame_length_type; - - if (audio_mux_version == 1) { - // taraFullness - latm_get_value(b); - } - get_bits(b, 1); // allStreamSameTimeFraming = 1 - get_bits(b, 6); // numSubFrames = 0 - get_bits(b, 4); // numPrograms = 0 - - // for each program (which there is only on in DVB) - get_bits(b, 3); // numLayer = 0 - - // for each layer (which there is only on in DVB) - if (audio_mux_version == 0) { - readAudioSpecificConfig(parser, b); - } else { - int ascLen = latm_get_value(b); - ascLen -= readAudioSpecificConfig(parser, b); - - // skip left over bits - while (ascLen > 16) { - skip_bits(b, 16); - ascLen -= 16; - } - skip_bits(b, ascLen); - } - - // these are not needed... perhaps - frame_length_type = get_bits(b, 3); - parser->frameLengthType = frame_length_type; - if (frame_length_type == 0) { - get_bits(b, 8); - } else if (frame_length_type == 1) { - get_bits(b, 9); - } else if (frame_length_type == 3 || frame_length_type == 4 || frame_length_type == 5) { - // celp_table_index - get_bits(b, 6); - } else if (frame_length_type == 6 || frame_length_type == 7) { - // hvxc_table_index - get_bits(b, 1); - } - - // other data - if (get_bits(b, 1)) { - // other data present - if (audio_mux_version == 1) { - // other_data_bits - latm_get_value(b); - } else { - int esc, tmp; - // other data bits - int64_t other_data_bits = 0; - do { - esc = get_bits(b, 1); - tmp = get_bits(b, 8); - other_data_bits = other_data_bits << 8 | tmp; - } while (esc); - } - } - - // CRC if necessary - if (get_bits(b, 1)) { - // config_crc - get_bits(b, 8); - } - } else { - // TBD - } -} - -static int readPayloadLengthInfo(struct AACDecoder *parser, GetBitContext *b) -{ - if (parser->frameLengthType == 0) { - uint8_t tmp; - int muxSlotLengthBytes = 0; - do { - tmp = get_bits(b, 8); - muxSlotLengthBytes += tmp; - } while (tmp == 255); - return muxSlotLengthBytes; - } else { - if (parser->frameLengthType == 3 || - parser->frameLengthType == 5 || - parser->frameLengthType == 7) { - get_bits(b, 2); - } - return 0; - } -} - -static void readAudioMuxElement(struct AACDecoder *parser, GetBitContext *b, uint8_t *payload, int *payloadsize) -{ - uint8_t use_same_mux = get_bits(b, 1); - if (!use_same_mux) { - readStreamMuxConfig(parser, b); - } - if (parser->audio_mux_version_A == 0) { - int j; - int muxSlotLengthBytes = readPayloadLengthInfo(parser, b); - muxSlotLengthBytes = min(muxSlotLengthBytes, *payloadsize); - for (j=0; j size) return -1; // not enough data, the parser should have sorted this - - readAudioMuxElement(parser, b, payload, payloadsize); - - return 0; -} - -static void channel_setup(AVCodecContext *avctx) -{ - AACDecoder *decoder = avctx->priv_data; - - if (avctx->request_channels == 2 && avctx->channels > 2) { - NeAACDecConfigurationPtr faac_cfg; - avctx->channels = 2; - faac_cfg = NeAACDecGetCurrentConfiguration(decoder->aac_decoder); - if (faac_cfg) { - faac_cfg->downMatrix = 1; - faac_cfg->defSampleRate = (!avctx->sample_rate) ? 44100 : avctx->sample_rate; - NeAACDecSetConfiguration(decoder->aac_decoder, faac_cfg); - } - } -} - -static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size, AVPacket *avpkt) -{ - AACDecoder *decoder = avctx->priv_data; - uint8_t tempbuf[MAX_SIZE]; - int bufsize = sizeof(tempbuf); - int max_size = *out_size; - NeAACDecFrameInfo info; - GetBitContext b; - - init_get_bits(&b, avpkt->data, avpkt->size * 8); - if (readAudioSyncStream(decoder, &b, avpkt->size, tempbuf, &bufsize)) { - return -1; - } - - if (!decoder->initialized) { - // we are going to initialize from decoder specific info when available - if (decoder->extrasize > 0) { - if (NeAACDecInit2(decoder->aac_decoder, decoder->extra, decoder->extrasize, &avctx->sample_rate, &avctx->channels)) { - return -1; - } - channel_setup(avctx); - decoder->initialized = 1; - } else { - *out_size = 0; - return avpkt->size; - } - } - - if (!NeAACDecDecode2(decoder->aac_decoder, &info, tempbuf, bufsize, &out, max_size)) { - return -1; - } - *out_size = info.samples * sizeof(short); - return avpkt->size; -} - -static int latm_decode_init(AVCodecContext *avctx) -{ - AACDecoder *decoder = avctx->priv_data; - NeAACDecConfigurationPtr faac_cfg; - - avctx->bit_rate = 0; - avctx->sample_fmt = SAMPLE_FMT_S16; - decoder->aac_decoder = NeAACDecOpen(); - if (!decoder->aac_decoder) { - return -1; - } - - faac_cfg = NeAACDecGetCurrentConfiguration(decoder->aac_decoder); - if (faac_cfg) { - faac_cfg->outputFormat = FAAD_FMT_16BIT; - faac_cfg->defSampleRate = (!avctx->sample_rate) ? 44100 : avctx->sample_rate; - faac_cfg->defObjectType = LC; - NeAACDecSetConfiguration(decoder->aac_decoder, faac_cfg); - } - - decoder->initialized = 0; - return 0; -} - -static int latm_decode_end(AVCodecContext *avctx) -{ - AACDecoder *decoder = avctx->priv_data; - NeAACDecClose(decoder->aac_decoder); - return 0; -} - -AVCodec libfaad_latm_decoder = { - .name = "AAC/LATM", - .type = CODEC_TYPE_AUDIO, - .id = CODEC_ID_AAC_LATM, - .priv_data_size = sizeof (AACDecoder), - .init = latm_decode_init, - .close = latm_decode_end, - .decode = latm_decode_frame, - .long_name = "AAC over LATM", -}; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/lcldec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/lcldec.c index 2bf448a77..23af51145 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/lcldec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/lcldec.c @@ -117,6 +117,7 @@ static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsign } +#if CONFIG_ZLIB_DECODER /** * \brief decompress a zlib-compressed data block into decomp_buf * \param src compressed input buffer @@ -124,7 +125,6 @@ static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsign * \param offset offset in decomp_buf * \param expected expected decompressed length */ -#if CONFIG_ZLIB_DECODER static int zlib_decomp(AVCodecContext *avctx, const uint8_t *src, int src_len, int offset, int expected) { LclDecContext *c = avctx->priv_data; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libfaad.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libfaad.c deleted file mode 100644 index 679729ad2..000000000 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libfaad.c +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Faad decoder - * Copyright (c) 2003 Zdenek Kabelac - * Copyright (c) 2004 Thomas Raivio - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * AAC decoder. - * - * still a bit unfinished - but it plays something - */ - -#include "avcodec.h" -#include "faad.h" - -#ifndef FAADAPI -#define FAADAPI -#endif - -/* - * when CONFIG_LIBFAADBIN is true libfaad will be opened at runtime - */ -//#undef CONFIG_LIBFAADBIN -//#define CONFIG_LIBFAADBIN 0 -//#define CONFIG_LIBFAADBIN 1 - -#if CONFIG_LIBFAADBIN -#include -static const char* const libfaadname = "libfaad.so"; -#else -#define dlopen(a) -#define dlclose(a) -#endif - -typedef struct { - void* handle; /* dlopen handle */ - void* faac_handle; /* FAAD library handle */ - int sample_size; - int init; - - /* faad calls */ - faacDecHandle FAADAPI (*faacDecOpen)(void); - faacDecConfigurationPtr FAADAPI (*faacDecGetCurrentConfiguration)(faacDecHandle hDecoder); -#ifndef FAAD2_VERSION - int FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder, - faacDecConfigurationPtr config); - int FAADAPI (*faacDecInit)(faacDecHandle hDecoder, - unsigned char *buffer, - unsigned long *samplerate, - unsigned long *channels); - int FAADAPI (*faacDecInit2)(faacDecHandle hDecoder, unsigned char *pBuffer, - unsigned long SizeOfDecoderSpecificInfo, - unsigned long *samplerate, unsigned long *channels); - int FAADAPI (*faacDecDecode)(faacDecHandle hDecoder, - unsigned char *buffer, - unsigned long *bytesconsumed, - short *sample_buffer, - unsigned long *samples); -#else - unsigned char FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder, - faacDecConfigurationPtr config); - long FAADAPI (*faacDecInit)(faacDecHandle hDecoder, - unsigned char *buffer, - unsigned long buffer_size, - 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 (*faacDecDecode)(faacDecHandle hDecoder, - faacDecFrameInfo *hInfo, - unsigned char *buffer, - unsigned long buffer_size); - char* FAADAPI (*faacDecGetErrorMessage)(unsigned char errcode); -#endif - - void FAADAPI (*faacDecClose)(faacDecHandle hDecoder); - - -} FAACContext; - -static const unsigned long faac_srates[] = -{ - 96000, 88200, 64000, 48000, 44100, 32000, - 24000, 22050, 16000, 12000, 11025, 8000 -}; - -static void channel_setup(AVCodecContext *avctx) -{ -#ifdef FAAD2_VERSION - FAACContext *s = avctx->priv_data; - if (avctx->request_channels > 0 && avctx->request_channels == 2 && - avctx->request_channels < avctx->channels) { - faacDecConfigurationPtr faac_cfg; - avctx->channels = 2; - faac_cfg = s->faacDecGetCurrentConfiguration(s->faac_handle); - faac_cfg->downMatrix = 1; - s->faacDecSetConfiguration(s->faac_handle, faac_cfg); - } -#endif -} - -static av_cold int faac_init_mp4(AVCodecContext *avctx) -{ - FAACContext *s = avctx->priv_data; - unsigned long samplerate; -#ifndef FAAD2_VERSION - unsigned long channels; -#else - unsigned char channels; -#endif - int r = 0; - - if (avctx->extradata){ - r = s->faacDecInit2(s->faac_handle, (uint8_t*) avctx->extradata, - avctx->extradata_size, - &samplerate, &channels); - if (r < 0){ - av_log(avctx, AV_LOG_ERROR, - "faacDecInit2 failed r:%d sr:%ld ch:%ld s:%d\n", - r, samplerate, (long)channels, avctx->extradata_size); - } else { - avctx->sample_rate = samplerate; - avctx->channels = channels; - channel_setup(avctx); - s->init = 1; - } - } - - return r; -} - -static int faac_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - AVPacket *avpkt) -{ - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; - FAACContext *s = avctx->priv_data; -#ifndef FAAD2_VERSION - unsigned long bytesconsumed; - short *sample_buffer = NULL; - unsigned long samples; - int out; -#else - faacDecFrameInfo frame_info; - void *out; -#endif - if(buf_size == 0) - return 0; -#ifndef FAAD2_VERSION - out = s->faacDecDecode(s->faac_handle, - (unsigned char*)buf, - &bytesconsumed, - data, - &samples); - samples *= s->sample_size; - if (data_size) - *data_size = samples; - return (buf_size < (int)bytesconsumed) - ? buf_size : (int)bytesconsumed; -#else - - if(!s->init){ - unsigned long srate; - unsigned char channels; - int r = s->faacDecInit(s->faac_handle, buf, buf_size, &srate, &channels); - if(r < 0){ - av_log(avctx, AV_LOG_ERROR, "libfaad: codec init failed.\n"); - return -1; - } - avctx->sample_rate = srate; - avctx->channels = channels; - channel_setup(avctx); - s->init = 1; - } - - out = s->faacDecDecode(s->faac_handle, &frame_info, (unsigned char*)buf, (unsigned long)buf_size); - - if (frame_info.error > 0) { - av_log(avctx, AV_LOG_ERROR, "libfaad: frame decoding failed: %s\n", - s->faacDecGetErrorMessage(frame_info.error)); - return -1; - } - if (!avctx->frame_size) - avctx->frame_size = frame_info.samples/avctx->channels; - 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; -#endif -} - -static av_cold int faac_decode_end(AVCodecContext *avctx) -{ - FAACContext *s = avctx->priv_data; - - s->faacDecClose(s->faac_handle); - - dlclose(s->handle); - return 0; -} - -static av_cold int faac_decode_init(AVCodecContext *avctx) -{ - FAACContext *s = avctx->priv_data; - faacDecConfigurationPtr faac_cfg; - -#if CONFIG_LIBFAADBIN - const char* err = 0; - - s->handle = dlopen(libfaadname, RTLD_LAZY); - if (!s->handle) - { - av_log(avctx, AV_LOG_ERROR, "FAAD library: %s could not be opened! \n%s\n", - libfaadname, dlerror()); - return -1; - } - -#define dfaac(a) do { \ - const char* n = AV_STRINGIFY(faacDec ## a); \ - if (!err && !(s->faacDec ## a = dlsym(s->handle, n))) { \ - err = n; \ - } \ - } while(0) -#else /* !CONFIG_LIBFAADBIN */ -#define dfaac(a) s->faacDec ## a = faacDec ## a -#endif /* CONFIG_LIBFAADBIN */ - - // resolve all needed function calls - dfaac(Open); - dfaac(Close); - dfaac(GetCurrentConfiguration); - dfaac(SetConfiguration); - dfaac(Init); - dfaac(Init2); - dfaac(Decode); -#ifdef FAAD2_VERSION - dfaac(GetErrorMessage); -#endif - -#undef dfaac - -#if CONFIG_LIBFAADBIN - if (err) { - dlclose(s->handle); - av_log(avctx, AV_LOG_ERROR, "FAAD library: cannot resolve %s in %s!\n", - err, libfaadname); - return -1; - } -#endif - - s->faac_handle = s->faacDecOpen(); - if (!s->faac_handle) { - av_log(avctx, AV_LOG_ERROR, "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_coded_sample) { - case 8: av_log(avctx, AV_LOG_ERROR, "FAADlib unsupported bps %d\n", avctx->bits_per_coded_sample); break; - default: - case 16: -#ifdef FAAD2_VERSION - faac_cfg->outputFormat = FAAD_FMT_16BIT; -#endif - s->sample_size = 2; - break; - case 24: -#ifdef FAAD2_VERSION - faac_cfg->outputFormat = FAAD_FMT_24BIT; -#endif - s->sample_size = 3; - break; - case 32: -#ifdef FAAD2_VERSION - faac_cfg->outputFormat = FAAD_FMT_32BIT; -#endif - 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); - - if(!s->init && avctx->channels > 0) - channel_setup(avctx); - - avctx->sample_fmt = SAMPLE_FMT_S16; - return 0; -} - -AVCodec libfaad_decoder = { - "libfaad", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_AAC, - sizeof(FAACContext), - faac_decode_init, - NULL, - faac_decode_end, - faac_decode_frame, - .long_name = NULL_IF_CONFIG_SMALL("libfaad AAC (Advanced Audio Codec)"), -}; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libgsm.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libgsm.c index 1062099a7..a7bc68ad7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libgsm.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libgsm.c @@ -54,7 +54,7 @@ static av_cold int libgsm_init(AVCodecContext *avctx) { if (avctx->sample_rate != 8000) { av_log(avctx, AV_LOG_ERROR, "Sample rate 8000Hz required for GSM, got %dHz\n", avctx->sample_rate); - if(avctx->strict_std_compliance > FF_COMPLIANCE_INOFFICIAL) + if(avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) return -1; } if (avctx->bit_rate != 13000 /* Official */ && @@ -62,7 +62,7 @@ static av_cold int libgsm_init(AVCodecContext *avctx) { avctx->bit_rate != 0 /* Unknown; a.o. mov does not set bitrate when decoding */ ) { av_log(avctx, AV_LOG_ERROR, "Bitrate 13000bps required for GSM, got %dbps\n", avctx->bit_rate); - if(avctx->strict_std_compliance > FF_COMPLIANCE_INOFFICIAL) + if(avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) return -1; } } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libopenjpeg.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libopenjpeg.c index 0956da9c3..f85ec0015 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libopenjpeg.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libopenjpeg.c @@ -193,5 +193,6 @@ AVCodec libopenjpeg_decoder = { libopenjpeg_decode_close, libopenjpeg_decode_frame, CODEC_CAP_DR1, + .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("OpenJPEG based JPEG 2000 decoder"), } ; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libtheoraenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libtheoraenc.c index b50294271..e4ca72116 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libtheoraenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libtheoraenc.c @@ -49,7 +49,7 @@ typedef struct TheoraContext { int keyframe_mask; } TheoraContext; -/** Concatenates an ogg_packet into the extradata. */ +/** Concatenate an ogg_packet into the extradata. */ static int concatenate_packet(unsigned int* offset, AVCodecContext* avc_context, const ogg_packet* packet) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libvorbis.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libvorbis.c index f9a1b3299..d0463adee 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libvorbis.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libvorbis.c @@ -28,6 +28,7 @@ #include "avcodec.h" #include "bytestream.h" +#include "vorbis.h" #undef NDEBUG #include @@ -144,18 +145,16 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext, int l; if(data) { - int samples = OGGVORBIS_FRAME_SIZE; + const int samples = avccontext->frame_size; float **buffer ; + int c, channels = context->vi.channels; buffer = vorbis_analysis_buffer(&context->vd, samples) ; - if(context->vi.channels == 1) { + for (c = 0; c < channels; c++) { + int co = (channels > 8) ? c : + ff_vorbis_encoding_channel_layout_offsets[channels-1][c]; for(l = 0 ; l < samples ; l++) - buffer[0][l]=audio[l]/32768.f; - } else { - for(l = 0 ; l < samples ; l++){ - buffer[0][l]=audio[l*2]/32768.f; - buffer[1][l]=audio[l*2+1]/32768.f; - } + buffer[c][l]=audio[l*channels+co]/32768.f; } vorbis_analysis_wrote(&context->vd, samples) ; } else { @@ -171,8 +170,12 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext, while(vorbis_bitrate_flushpacket(&context->vd, &op)) { /* i'd love to say the following line is a hack, but sadly it's * not, apparently the end of stream decision is in libogg. */ - if(op.bytes==1) + if(op.bytes==1 && op.e_o_s) continue; + if (context->buffer_index + sizeof(ogg_packet) + op.bytes > BUFFER_SIZE) { + av_log(avccontext, AV_LOG_ERROR, "libvorbis: buffer overflow."); + return -1; + } memcpy(context->buffer + context->buffer_index, &op, sizeof(ogg_packet)); context->buffer_index += sizeof(ogg_packet); memcpy(context->buffer + context->buffer_index, op.packet, op.bytes); @@ -190,9 +193,14 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext, avccontext->coded_frame->pts= av_rescale_q(op2->granulepos, (AVRational){1, avccontext->sample_rate}, avccontext->time_base); //FIXME we should reorder the user supplied pts and not assume that they are spaced by 1/sample_rate + if (l > buf_size) { + av_log(avccontext, AV_LOG_ERROR, "libvorbis: buffer overflow."); + return -1; + } + memcpy(packets, op2->packet, l); context->buffer_index -= l + sizeof(ogg_packet); - memcpy(context->buffer, context->buffer + l + sizeof(ogg_packet), context->buffer_index); + memmove(context->buffer, context->buffer + l + sizeof(ogg_packet), context->buffer_index); // av_log(avccontext, AV_LOG_DEBUG, "E%d\n", l); } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libvpxenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libvpxenc.c index e3fc33397..c83ab936d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libvpxenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libvpxenc.c @@ -237,14 +237,12 @@ static av_cold int vp8_init(AVCodecContext *avctx) enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000, AV_ROUND_NEAR_INF); - //convert [1,51] -> [0,63] - enccfg.rc_min_quantizer = ((avctx->qmin * 5 + 1) >> 2) - 1; - enccfg.rc_max_quantizer = ((avctx->qmax * 5 + 1) >> 2) - 1; + enccfg.rc_min_quantizer = avctx->qmin; + enccfg.rc_max_quantizer = avctx->qmax; + enccfg.rc_dropframe_thresh = avctx->frame_skip_threshold; + //_enc_init() will balk if kf_min_dist differs from max w/VPX_KF_AUTO if (avctx->keyint_min == avctx->gop_size) - enccfg.kf_mode = VPX_KF_FIXED; - //_enc_init() will balk if kf_min_dist is set in this case - if (enccfg.kf_mode != VPX_KF_AUTO) enccfg.kf_min_dist = avctx->keyint_min; enccfg.kf_max_dist = avctx->gop_size; @@ -278,6 +276,11 @@ static av_cold int vp8_init(AVCodecContext *avctx) } ctx->deadline = VPX_DL_GOOD_QUALITY; + /* 0-3: For non-zero values the encoder increasingly optimizes for reduced + complexity playback on low powered devices at the expense of encode + quality. */ + if (avctx->profile != FF_PROFILE_UNKNOWN) + enccfg.g_profile = avctx->profile; dump_enc_cfg(avctx, &enccfg); /* Construct Encoder Context */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libxvid_internal.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libxvid_internal.h index ffa5cf8d2..6517f6217 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libxvid_internal.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libxvid_internal.h @@ -27,6 +27,6 @@ */ -int av_tempfile(char *prefix, char **filename); +int ff_tempfile(const char *prefix, char **filename); #endif /* AVCODEC_LIBXVID_INTERNAL_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libxvid_rc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libxvid_rc.c index c161ba710..08e89c8df 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libxvid_rc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libxvid_rc.c @@ -40,7 +40,7 @@ int ff_xvid_rate_control_init(MpegEncContext *s){ //xvid_debug=-1; - fd=av_tempfile("xvidrc.", &tmp_name); + fd=ff_tempfile("xvidrc.", &tmp_name); if (fd == -1) { av_log(NULL, AV_LOG_ERROR, "Can't create temporary pass2 file.\n"); return -1; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libxvidff.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libxvidff.c index 2a404cd5f..140848f0d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libxvidff.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/libxvidff.c @@ -25,11 +25,17 @@ * @author Adam Thayer (krevnik@comcast.net) */ +/* needed for mkstemp() */ +#define _XOPEN_SOURCE 600 + #include #include #include "avcodec.h" #include "libavutil/intreadwrite.h" #include "libxvid_internal.h" +#if !HAVE_MKSTEMP +#include +#endif /** * Buffer management macros. @@ -74,8 +80,46 @@ int xvid_strip_vol_header(AVCodecContext *avctx, unsigned char *frame, unsigned int xvid_ff_2pass(void *ref, int opt, void *p1, void *p2); void xvid_correct_framerate(AVCodecContext *avctx); +/* Wrapper to work around the lack of mkstemp() on mingw. + * Also, tries to create file in /tmp first, if possible. + * *prefix can be a character constant; *filename will be allocated internally. + * @return file descriptor of opened file (or -1 on error) + * and opened file name in **filename. */ +int ff_tempfile(const char *prefix, char **filename) { + int fd=-1; +#if !HAVE_MKSTEMP + *filename = tempnam(".", prefix); +#else + size_t len = strlen(prefix) + 12; /* room for "/tmp/" and "XXXXXX\0" */ + *filename = av_malloc(len); +#endif + /* -----common section-----*/ + if (*filename == NULL) { + av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n"); + return -1; + } +#if !HAVE_MKSTEMP + fd = open(*filename, O_RDWR | O_BINARY | O_CREAT, 0444); +#else + snprintf(*filename, len, "/tmp/%sXXXXXX", prefix); + fd = mkstemp(*filename); + if (fd < 0) { + snprintf(*filename, len, "./%sXXXXXX", prefix); + fd = mkstemp(*filename); + } +#endif + /* -----common section-----*/ + if (fd < 0) { + av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename); + return -1; + } + return fd; /* success */ +} + +#if CONFIG_LIBXVID_ENCODER + /** - * Creates the private context for the encoder. + * Create the private context for the encoder. * All buffers are allocated, settings are loaded from the user, * and the encoder context created. * @@ -229,7 +273,7 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) { rc2pass2.version = XVID_VERSION; rc2pass2.bitrate = avctx->bit_rate; - fd = av_tempfile("xvidff.", &(x->twopassfile)); + fd = ff_tempfile("xvidff.", &(x->twopassfile)); if( fd == -1 ) { av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write 2-pass pipe\n"); @@ -359,7 +403,7 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) { } /** - * Encodes a single frame. + * Encode a single frame. * * @param avctx AVCodecContext pointer to context * @param frame Pointer to encoded frame buffer @@ -469,7 +513,7 @@ static int xvid_encode_frame(AVCodecContext *avctx, } /** - * Destroys the private context for the encoder. + * Destroy the private context for the encoder. * All buffers are freed, and the Xvid encoder context is destroyed. * * @param avctx AVCodecContext pointer to context @@ -609,7 +653,7 @@ void xvid_correct_framerate(AVCodecContext *avctx) { */ /** - * Initializes the two-pass plugin and context. + * Initialize the two-pass plugin and context. * * @param param Input construction parameter structure * @param handle Private context handle @@ -640,7 +684,7 @@ static int xvid_ff_2pass_create(xvid_plg_create_t * param, } /** - * Destroys the two-pass plugin context. + * Destroy the two-pass plugin context. * * @param ref Context pointer for the plugin * @param param Destrooy context @@ -656,7 +700,7 @@ static int xvid_ff_2pass_destroy(struct xvid_context *ref, } /** - * Enables fast encode mode during the first pass. + * Enable fast encode mode during the first pass. * * @param ref Context pointer for the plugin * @param param Frame data @@ -699,7 +743,7 @@ static int xvid_ff_2pass_before(struct xvid_context *ref, } /** - * Captures statistic data and writes it during first pass. + * Capture statistic data and write it during first pass. * * @param ref Context pointer for the plugin * @param param Statistic data @@ -778,3 +822,5 @@ AVCodec libxvid_encoder = { .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("libxvidcore MPEG-4 part 2"), }; + +#endif /* CONFIG_LIBXVID_ENCODER */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/lpc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/lpc.c index 49e41d8c3..112a78d4b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/lpc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/lpc.c @@ -52,7 +52,7 @@ static void apply_welch_window(const int32_t *data, int len, double *w_data) } /** - * Calculates autocorrelation data from audio samples + * Calculate autocorrelation data from audio samples * A Welch window function is applied before calculation. */ void ff_lpc_compute_autocorr(const int32_t *data, int len, int lag, @@ -165,7 +165,8 @@ static int estimate_best_order(double *ref, int min_order, int max_order) int ff_lpc_calc_coefs(DSPContext *s, const int32_t *samples, int blocksize, int min_order, int max_order, int precision, - int32_t coefs[][MAX_LPC_ORDER], int *shift, int use_lpc, + int32_t coefs[][MAX_LPC_ORDER], int *shift, + enum AVLPCType lpc_type, int lpc_passes, int omethod, int max_shift, int zero_shift) { double autoc[MAX_LPC_ORDER+1]; @@ -174,20 +175,21 @@ int ff_lpc_calc_coefs(DSPContext *s, int i, j, pass; int opt_order; - assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER && use_lpc > 0); + assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER && + lpc_type > AV_LPC_TYPE_FIXED); - if(use_lpc == 1){ + if (lpc_type == AV_LPC_TYPE_LEVINSON) { s->lpc_compute_autocorr(samples, blocksize, max_order, autoc); compute_lpc_coefs(autoc, max_order, &lpc[0][0], MAX_LPC_ORDER, 0, 1); for(i=0; i>(32-(s))) #endif +#if HAVE_BIGENDIAN +# ifndef PACK_2U8 +# define PACK_2U8(a,b) (((a) << 8) | (b)) +# endif +# ifndef PACK_4U8 +# define PACK_4U8(a,b,c,d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) +# endif +# ifndef PACK_2U16 +# define PACK_2U16(a,b) (((a) << 16) | (b)) +# endif +#else +# ifndef PACK_2U8 +# define PACK_2U8(a,b) (((b) << 8) | (a)) +# endif +# ifndef PACK_4U2 +# define PACK_4U8(a,b,c,d) (((d) << 24) | ((c) << 16) | ((b) << 8) | (a)) +# endif +# ifndef PACK_2U16 +# define PACK_2U16(a,b) (((b) << 16) | (a)) +# endif +#endif + +#ifndef PACK_2S8 +# define PACK_2S8(a,b) PACK_2U8((a)&255, (b)&255) +#endif +#ifndef PACK_4S8 +# define PACK_4S8(a,b,c,d) PACK_4U8((a)&255, (b)&255, (c)&255, (d)&255) +#endif +#ifndef PACK_2S16 +# define PACK_2S16(a,b) PACK_2U16((a)&0xffff, (b)&0xffff) +#endif + #endif /* AVCODEC_MATHOPS_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mdct.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mdct.c index 69e1bbff2..c511188d2 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mdct.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mdct.c @@ -36,9 +36,11 @@ av_cold void ff_kbd_window_init(float *window, float alpha, int n) { int i, j; double sum = 0.0, bessel, tmp; - double local_window[n]; + double local_window[FF_KBD_WINDOW_MAX]; double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n); + assert(n <= FF_KBD_WINDOW_MAX); + for (i = 0; i < n; i++) { tmp = i * (n - i) * alpha2; bessel = 1.0; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mdct_tablegen.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mdct_tablegen.h index 1722c3b4d..51a009422 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mdct_tablegen.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mdct_tablegen.h @@ -21,10 +21,10 @@ */ #include -// do not use libavutil/mathematics.h since this is compiled both +// do not use libavutil/libm.h since this is compiled both // for the host and the target and config.h is only valid for the target #include -#include "../libavutil/attributes.h" +#include "libavutil/attributes.h" #if !CONFIG_HARDCODED_TABLES SINETABLE( 32); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mjpegbdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mjpegbdec.c index b418f5734..907fa6f50 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mjpegbdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mjpegbdec.c @@ -156,5 +156,6 @@ AVCodec mjpegb_decoder = { mjpegb_decode_frame, CODEC_CAP_DR1, NULL, + .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("Apple MJPEG-B"), }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mjpegdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mjpegdec.c index 7f57af905..8aff966f6 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mjpegdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mjpegdec.c @@ -1027,7 +1027,7 @@ static int mjpeg_decode_app(MJpegDecodeContext *s) return -1; id = (get_bits(&s->gb, 16) << 16) | get_bits(&s->gb, 16); - id = be2me_32(id); + id = av_be2ne32(id); len -= 6; if(s->avctx->debug & FF_DEBUG_STARTCODE){ @@ -1134,7 +1134,7 @@ static int mjpeg_decode_app(MJpegDecodeContext *s) if ((s->start_code == APP1) && (len > (0x28 - 8))) { id = (get_bits(&s->gb, 16) << 16) | get_bits(&s->gb, 16); - id = be2me_32(id); + id = av_be2ne32(id); len -= 4; if (id == AV_RL32("mjpg")) /* Apple MJPEG-A */ { @@ -1542,6 +1542,7 @@ AVCodec mjpeg_decoder = { ff_mjpeg_decode_frame, CODEC_CAP_DR1, NULL, + .max_lowres = 8, .long_name = NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"), }; @@ -1556,5 +1557,6 @@ AVCodec thp_decoder = { ff_mjpeg_decode_frame, CODEC_CAP_DR1, NULL, + .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("Nintendo Gamecube THP video"), }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mlpdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mlpdec.c index 80fbbdb07..16397eefd 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mlpdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mlpdec.c @@ -939,8 +939,8 @@ static int output_data(MLPDecodeContext *m, unsigned int substr, /** Read an access unit from the stream. - * Returns < 0 on error, 0 if not enough data is present in the input stream - * otherwise returns the number of bytes consumed. */ + * @return negative on error, 0 if not enough data is present in the input stream, + * otherwise the number of bytes consumed. */ static int read_access_unit(AVCodecContext *avctx, void* data, int *data_size, AVPacket *avpkt) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/motion_est.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/motion_est.c index 82a36d003..50078f93c 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/motion_est.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/motion_est.c @@ -1476,6 +1476,7 @@ static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y) const int xmax= c->xmax<ymax<gb, 14); skip_bits(&s->gb, 1); //marker h= get_bits(&s->gb, 14); - skip_bits(&s->gb, 1); //marker + // remaining 3 bits are zero padding s1->pan_scan.width= 16*w; s1->pan_scan.height=16*h; @@ -1920,7 +1920,7 @@ static int slice_decode_thread(AVCodecContext *c, void *arg){ } /** - * Handles slice ends. + * Handle slice ends. * @return 1 if it seems to be the last slice */ static int slice_end(AVCodecContext *avctx, AVFrame *pict) @@ -2155,7 +2155,7 @@ static void mpeg_decode_gop(AVCodecContext *avctx, time_code_pictures, s->closed_gop, broken_link); } /** - * Finds the end of the current frame in the bitstream. + * Find the end of the current frame in the bitstream. * @return the position of the first byte of the next frame, or -1 */ int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s) @@ -2511,6 +2511,7 @@ AVCodec mpeg1video_decoder = { mpeg_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, .flush= flush, + .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"), }; @@ -2525,6 +2526,7 @@ AVCodec mpeg2video_decoder = { mpeg_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, .flush= flush, + .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"), }; @@ -2540,6 +2542,7 @@ AVCodec mpegvideo_decoder = { mpeg_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, .flush= flush, + .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"), }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg12enc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg12enc.c index bf3612902..6868e2a20 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg12enc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg12enc.c @@ -119,7 +119,7 @@ static int find_frame_rate_index(MpegEncContext *s){ for(i=1;i<14;i++) { int64_t n0= 1001LL/ff_frame_rate_tab[i].den*ff_frame_rate_tab[i].num*s->avctx->time_base.num; int64_t n1= 1001LL*s->avctx->time_base.den; - if(s->avctx->strict_std_compliance > FF_COMPLIANCE_INOFFICIAL && i>=9) break; + if(s->avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL && i>=9) break; d = FFABS(n0 - n1); if(d < dmin){ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg4audio.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg4audio.c index 7507212c7..f9951b160 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg4audio.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg4audio.c @@ -131,6 +131,14 @@ int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_si get_bits1(&gb); // skip 1 bit } } + + //PS requires SBR + if (!c->sbr) + c->ps = 0; + //Limit implicit PS to the HE-AACv2 Profile + if ((c->ps == -1 && c->object_type != AOT_AAC_LC) || c->channels & ~0x01) + c->ps = 0; + return specific_config_bitindex; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg4videodec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg4videodec.c index fa69c9ef8..b339f7812 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg4videodec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg4videodec.c @@ -2245,6 +2245,7 @@ AVCodec mpeg4_decoder = { ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, .flush= ff_mpeg_flush, + .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"), .pix_fmts= ff_hwaccel_pixfmt_list_420, }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg4videoenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg4videoenc.c index 79190f0a6..856cfa777 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg4videoenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpeg4videoenc.c @@ -54,7 +54,7 @@ max run: 29/41 /** - * Returns the number of bits that encoding the 8x8 block in block would need. + * Return the number of bits that encoding the 8x8 block in block would need. * @param[in] block_last_index last index in scantable order that refers to a non zero element in block. */ static inline int get_block_rate(MpegEncContext * s, DCTELEM block[64], int block_last_index, uint8_t scantable[64]){ @@ -82,7 +82,7 @@ static inline int get_block_rate(MpegEncContext * s, DCTELEM block[64], int bloc /** - * Restores the ac coefficients in block that have been changed by decide_ac_pred(). + * Restore the ac coefficients in block that have been changed by decide_ac_pred(). * This function also restores s->block_last_index. * @param[in,out] block MB coefficients, these will be restored * @param[in] dir ac prediction direction for each 8x8 block @@ -113,7 +113,7 @@ static inline void restore_ac_coeffs(MpegEncContext * s, DCTELEM block[6][64], c } /** - * Returns the optimal value (0 or 1) for the ac_pred element for the given MB in mpeg4. + * Return the optimal value (0 or 1) for the ac_pred element for the given MB in mpeg4. * This function will also update s->block_last_index and s->ac_val. * @param[in,out] block MB coefficients, these will be updated if 1 is returned * @param[in] dir ac prediction direction for each 8x8 block diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudio.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudio.h index 53d82da4e..e2ad911b0 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudio.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudio.h @@ -33,6 +33,7 @@ #include "avcodec.h" #include "get_bits.h" #include "dsputil.h" +#include "fft.h" #define CONFIG_AUDIO_NONSHORT 0 @@ -156,6 +157,11 @@ typedef struct MPADecodeContext { int dither_state; int error_recognition; AVCodecContext* avctx; +#if CONFIG_FLOAT + DCTContext dct; +#endif + void (*apply_window_mp3)(MPA_INT *synth_buf, MPA_INT *window, + int *dither_state, OUT_INT *samples, int incr); } MPADecodeContext; /* layer 3 huffman tables */ @@ -175,11 +181,15 @@ void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset, INTFLOAT sb_samples[SBLIMIT]); void ff_mpa_synth_init_float(MPA_INT *window); -void ff_mpa_synth_filter_float(MPA_INT *synth_buf_ptr, int *synth_buf_offset, +void ff_mpa_synth_filter_float(MPADecodeContext *s, + MPA_INT *synth_buf_ptr, int *synth_buf_offset, MPA_INT *window, int *dither_state, OUT_INT *samples, int incr, INTFLOAT sb_samples[SBLIMIT]); +void ff_mpegaudiodec_init_mmx(MPADecodeContext *s); +void ff_mpegaudiodec_init_altivec(MPADecodeContext *s); + /* fast header check for resync */ static inline int ff_mpa_check_header(uint32_t header){ /* header */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudio_tablegen.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudio_tablegen.c index bb1c7ea5e..0888e7862 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudio_tablegen.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudio_tablegen.c @@ -31,29 +31,12 @@ int main(void) write_fileheader(); - printf("static const int8_t table_4_3_exp[TABLE_4_3_SIZE] = {\n"); - write_int8_array(table_4_3_exp, TABLE_4_3_SIZE); - printf("};\n"); - - printf("static const uint32_t table_4_3_value[TABLE_4_3_SIZE] = {\n"); - write_uint32_array(table_4_3_value, TABLE_4_3_SIZE); - printf("};\n"); - - printf("static const uint32_t exp_table[512] = {\n"); - write_uint32_array(exp_table, 512); - printf("};\n"); - - printf("static const float exp_table_float[512] = {\n"); - write_float_array(exp_table_float, 512); - printf("};\n"); - - printf("static const uint32_t expval_table[512][16] = {\n"); - write_uint32_2d_array(expval_table, 512, 16); - printf("};\n"); - - printf("static const float expval_table_float[512][16] = {\n"); - write_float_2d_array(expval_table_float, 512, 16); - printf("};\n"); + WRITE_ARRAY("static const", int8_t, table_4_3_exp); + WRITE_ARRAY("static const", uint32_t, table_4_3_value); + WRITE_ARRAY("static const", uint32_t, exp_table); + WRITE_ARRAY("static const", float, exp_table_float); + WRITE_2D_ARRAY("static const", uint32_t, expval_table); + WRITE_2D_ARRAY("static const", float, expval_table_float); return 0; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudio_tablegen.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudio_tablegen.h index 56bf40864..6b5ff2280 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudio_tablegen.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudio_tablegen.h @@ -24,8 +24,6 @@ #define MPEGAUDIO_TABLEGEN_H #include -// do not use libavutil/mathematics.h since this is compiled both -// for the host and the target and config.h is only valid for the target #include #define TABLE_4_3_SIZE (8191 + 16)*4 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudiodec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudiodec.c index 86903a762..4f48c15e0 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudiodec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudiodec.c @@ -67,8 +67,15 @@ #include "mpegaudiodata.h" #include "mpegaudiodectab.h" -static void compute_antialias_integer(MPADecodeContext *s, GranuleDef *g); -static void compute_antialias_float(MPADecodeContext *s, GranuleDef *g); +#if CONFIG_FLOAT +# include "fft.h" +#else +# include "dct32.c" +#endif + +static void compute_antialias(MPADecodeContext *s, GranuleDef *g); +static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window, + int *dither_state, OUT_INT *samples, int incr); /* vlc structure for decoding layer 3 huffman tables */ static VLC huff_vlc[16]; @@ -95,6 +102,14 @@ static int32_t csa_table[8][4]; static float csa_table_float[8][4]; static INTFLOAT mdct_win[8][36]; +static int16_t division_tab3[1<<6 ]; +static int16_t division_tab5[1<<8 ]; +static int16_t division_tab9[1<<11]; + +static int16_t * const division_tabs[4] = { + division_tab3, division_tab5, NULL, division_tab9 +}; + /* lower 2 bits: modulo 3, higher bits: shift */ static uint16_t scale_factor_modshift[64]; /* [i][j]: 2^(-j/3) * FRAC_ONE * 2^(i+2) / (2^(i+2) - 1) */ @@ -110,7 +125,7 @@ static const int32_t scale_factor_mult2[3][3] = { SCALE_GEN(4.0 / 9.0), /* 9 steps */ }; -DECLARE_ALIGNED(16, MPA_INT, RENAME(ff_mpa_synth_window))[512]; +DECLARE_ALIGNED(16, MPA_INT, RENAME(ff_mpa_synth_window))[512+256]; /** * Convert region offsets to region sizes and truncate @@ -305,6 +320,14 @@ static av_cold int decode_init(AVCodecContext * avctx) int i, j, k; s->avctx = avctx; + s->apply_window_mp3 = apply_window_mp3_c; +#if HAVE_MMX && CONFIG_FLOAT + ff_mpegaudiodec_init_mmx(s); +#endif +#if CONFIG_FLOAT + ff_dct_init(&s->dct, 5, DCT_II); +#endif + if (HAVE_ALTIVEC && CONFIG_FLOAT) ff_mpegaudiodec_init_altivec(s); avctx->sample_fmt= OUT_FMT; s->error_recognition= avctx->error_recognition; @@ -394,6 +417,20 @@ static av_cold int decode_init(AVCodecContext * avctx) int_pow_init(); mpegaudio_tableinit(); + for (i = 0; i < 4; i++) + if (ff_mpa_quant_bits[i] < 0) + for (j = 0; j < (1<<(-ff_mpa_quant_bits[i]+1)); j++) { + int val1, val2, val3, steps; + int val = j; + steps = ff_mpa_quant_steps[i]; + val1 = val % steps; + val /= steps; + val2 = val % steps; + val3 = val / steps; + division_tabs[i][j] = val1 + (val2 << 4) + (val3 << 8); + } + + for(i=0;i<7;i++) { float f; INTFLOAT v; @@ -485,245 +522,6 @@ static av_cold int decode_init(AVCodecContext * avctx) return 0; } -/* tab[i][j] = 1.0 / (2.0 * cos(pi*(2*k+1) / 2^(6 - j))) */ - -/* cos(i*pi/64) */ - -#define COS0_0 FIXHR(0.50060299823519630134/2) -#define COS0_1 FIXHR(0.50547095989754365998/2) -#define COS0_2 FIXHR(0.51544730992262454697/2) -#define COS0_3 FIXHR(0.53104259108978417447/2) -#define COS0_4 FIXHR(0.55310389603444452782/2) -#define COS0_5 FIXHR(0.58293496820613387367/2) -#define COS0_6 FIXHR(0.62250412303566481615/2) -#define COS0_7 FIXHR(0.67480834145500574602/2) -#define COS0_8 FIXHR(0.74453627100229844977/2) -#define COS0_9 FIXHR(0.83934964541552703873/2) -#define COS0_10 FIXHR(0.97256823786196069369/2) -#define COS0_11 FIXHR(1.16943993343288495515/4) -#define COS0_12 FIXHR(1.48416461631416627724/4) -#define COS0_13 FIXHR(2.05778100995341155085/8) -#define COS0_14 FIXHR(3.40760841846871878570/8) -#define COS0_15 FIXHR(10.19000812354805681150/32) - -#define COS1_0 FIXHR(0.50241928618815570551/2) -#define COS1_1 FIXHR(0.52249861493968888062/2) -#define COS1_2 FIXHR(0.56694403481635770368/2) -#define COS1_3 FIXHR(0.64682178335999012954/2) -#define COS1_4 FIXHR(0.78815462345125022473/2) -#define COS1_5 FIXHR(1.06067768599034747134/4) -#define COS1_6 FIXHR(1.72244709823833392782/4) -#define COS1_7 FIXHR(5.10114861868916385802/16) - -#define COS2_0 FIXHR(0.50979557910415916894/2) -#define COS2_1 FIXHR(0.60134488693504528054/2) -#define COS2_2 FIXHR(0.89997622313641570463/2) -#define COS2_3 FIXHR(2.56291544774150617881/8) - -#define COS3_0 FIXHR(0.54119610014619698439/2) -#define COS3_1 FIXHR(1.30656296487637652785/4) - -#define COS4_0 FIXHR(0.70710678118654752439/2) - -/* butterfly operator */ -#define BF(a, b, c, s)\ -{\ - tmp0 = val##a + val##b;\ - tmp1 = val##a - val##b;\ - val##a = tmp0;\ - val##b = MULH3(tmp1, c, 1<<(s));\ -} - -#define BF0(a, b, c, s)\ -{\ - tmp0 = tab[a] + tab[b];\ - tmp1 = tab[a] - tab[b];\ - val##a = tmp0;\ - val##b = MULH3(tmp1, c, 1<<(s));\ -} - -#define BF1(a, b, c, d)\ -{\ - BF(a, b, COS4_0, 1);\ - BF(c, d,-COS4_0, 1);\ - val##c += val##d;\ -} - -#define BF2(a, b, c, d)\ -{\ - BF(a, b, COS4_0, 1);\ - BF(c, d,-COS4_0, 1);\ - val##c += val##d;\ - val##a += val##c;\ - val##c += val##b;\ - val##b += val##d;\ -} - -#define ADD(a, b) val##a += val##b - -/* DCT32 without 1/sqrt(2) coef zero scaling. */ -static void dct32(INTFLOAT *out, const INTFLOAT *tab) -{ - INTFLOAT tmp0, tmp1; - - INTFLOAT val0 , val1 , val2 , val3 , val4 , val5 , val6 , val7 , - val8 , val9 , val10, val11, val12, val13, val14, val15, - val16, val17, val18, val19, val20, val21, val22, val23, - val24, val25, val26, val27, val28, val29, val30, val31; - - /* pass 1 */ - BF0( 0, 31, COS0_0 , 1); - BF0(15, 16, COS0_15, 5); - /* pass 2 */ - BF( 0, 15, COS1_0 , 1); - BF(16, 31,-COS1_0 , 1); - /* pass 1 */ - BF0( 7, 24, COS0_7 , 1); - BF0( 8, 23, COS0_8 , 1); - /* pass 2 */ - BF( 7, 8, COS1_7 , 4); - BF(23, 24,-COS1_7 , 4); - /* pass 3 */ - BF( 0, 7, COS2_0 , 1); - BF( 8, 15,-COS2_0 , 1); - BF(16, 23, COS2_0 , 1); - BF(24, 31,-COS2_0 , 1); - /* pass 1 */ - BF0( 3, 28, COS0_3 , 1); - BF0(12, 19, COS0_12, 2); - /* pass 2 */ - BF( 3, 12, COS1_3 , 1); - BF(19, 28,-COS1_3 , 1); - /* pass 1 */ - BF0( 4, 27, COS0_4 , 1); - BF0(11, 20, COS0_11, 2); - /* pass 2 */ - BF( 4, 11, COS1_4 , 1); - BF(20, 27,-COS1_4 , 1); - /* pass 3 */ - BF( 3, 4, COS2_3 , 3); - BF(11, 12,-COS2_3 , 3); - BF(19, 20, COS2_3 , 3); - BF(27, 28,-COS2_3 , 3); - /* pass 4 */ - BF( 0, 3, COS3_0 , 1); - BF( 4, 7,-COS3_0 , 1); - BF( 8, 11, COS3_0 , 1); - BF(12, 15,-COS3_0 , 1); - BF(16, 19, COS3_0 , 1); - BF(20, 23,-COS3_0 , 1); - BF(24, 27, COS3_0 , 1); - BF(28, 31,-COS3_0 , 1); - - - - /* pass 1 */ - BF0( 1, 30, COS0_1 , 1); - BF0(14, 17, COS0_14, 3); - /* pass 2 */ - BF( 1, 14, COS1_1 , 1); - BF(17, 30,-COS1_1 , 1); - /* pass 1 */ - BF0( 6, 25, COS0_6 , 1); - BF0( 9, 22, COS0_9 , 1); - /* pass 2 */ - BF( 6, 9, COS1_6 , 2); - BF(22, 25,-COS1_6 , 2); - /* pass 3 */ - BF( 1, 6, COS2_1 , 1); - BF( 9, 14,-COS2_1 , 1); - BF(17, 22, COS2_1 , 1); - BF(25, 30,-COS2_1 , 1); - - /* pass 1 */ - BF0( 2, 29, COS0_2 , 1); - BF0(13, 18, COS0_13, 3); - /* pass 2 */ - BF( 2, 13, COS1_2 , 1); - BF(18, 29,-COS1_2 , 1); - /* pass 1 */ - BF0( 5, 26, COS0_5 , 1); - BF0(10, 21, COS0_10, 1); - /* pass 2 */ - BF( 5, 10, COS1_5 , 2); - BF(21, 26,-COS1_5 , 2); - /* pass 3 */ - BF( 2, 5, COS2_2 , 1); - BF(10, 13,-COS2_2 , 1); - BF(18, 21, COS2_2 , 1); - BF(26, 29,-COS2_2 , 1); - /* pass 4 */ - BF( 1, 2, COS3_1 , 2); - BF( 5, 6,-COS3_1 , 2); - BF( 9, 10, COS3_1 , 2); - BF(13, 14,-COS3_1 , 2); - BF(17, 18, COS3_1 , 2); - BF(21, 22,-COS3_1 , 2); - BF(25, 26, COS3_1 , 2); - BF(29, 30,-COS3_1 , 2); - - /* pass 5 */ - BF1( 0, 1, 2, 3); - BF2( 4, 5, 6, 7); - BF1( 8, 9, 10, 11); - BF2(12, 13, 14, 15); - BF1(16, 17, 18, 19); - BF2(20, 21, 22, 23); - BF1(24, 25, 26, 27); - BF2(28, 29, 30, 31); - - /* pass 6 */ - - ADD( 8, 12); - ADD(12, 10); - ADD(10, 14); - ADD(14, 9); - ADD( 9, 13); - ADD(13, 11); - ADD(11, 15); - - out[ 0] = val0; - out[16] = val1; - out[ 8] = val2; - out[24] = val3; - out[ 4] = val4; - out[20] = val5; - out[12] = val6; - out[28] = val7; - out[ 2] = val8; - out[18] = val9; - out[10] = val10; - out[26] = val11; - out[ 6] = val12; - out[22] = val13; - out[14] = val14; - out[30] = val15; - - ADD(24, 28); - ADD(28, 26); - ADD(26, 30); - ADD(30, 25); - ADD(25, 29); - ADD(29, 27); - ADD(27, 31); - - out[ 1] = val16 + val24; - out[17] = val17 + val25; - out[ 9] = val18 + val26; - out[25] = val19 + val27; - out[ 5] = val20 + val28; - out[21] = val21 + val29; - out[13] = val22 + val30; - out[29] = val23 + val31; - out[ 3] = val24 + val20; - out[19] = val25 + val21; - out[11] = val26 + val22; - out[27] = val27 + val23; - out[ 7] = val28 + val18; - out[23] = val29 + val19; - out[15] = val30 + val17; - out[31] = val31; -} #if CONFIG_FLOAT static inline float round_sample(float *sum) @@ -817,7 +615,7 @@ static inline int round_sample(int64_t *sum) void av_cold RENAME(ff_mpa_synth_init)(MPA_INT *window) { - int i; + int i, j; /* max = 18760, max sum over all 16 coefs : 44736 */ for(i=0;i<257;i++) { @@ -834,43 +632,31 @@ void av_cold RENAME(ff_mpa_synth_init)(MPA_INT *window) if (i != 0) window[512 - i] = v; } + + // Needed for avoiding shuffles in ASM implementations + for(i=0; i < 8; i++) + for(j=0; j < 16; j++) + window[512+16*i+j] = window[64*i+32-j]; + + for(i=0; i < 8; i++) + for(j=0; j < 16; j++) + window[512+128+16*i+j] = window[64*i+48-j]; } -/* 32 sub band synthesis filter. Input: 32 sub band samples, Output: - 32 samples. */ -/* XXX: optimize by avoiding ring buffer usage */ -void RENAME(ff_mpa_synth_filter)(MPA_INT *synth_buf_ptr, int *synth_buf_offset, - MPA_INT *window, int *dither_state, - OUT_INT *samples, int incr, - INTFLOAT sb_samples[SBLIMIT]) +static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window, + int *dither_state, OUT_INT *samples, int incr) { - register MPA_INT *synth_buf; register const MPA_INT *w, *w2, *p; - int j, offset; + int j; OUT_INT *samples2; #if CONFIG_FLOAT float sum, sum2; #elif FRAC_BITS <= 15 - int32_t tmp[32]; int sum, sum2; #else int64_t sum, sum2; #endif - offset = *synth_buf_offset; - synth_buf = synth_buf_ptr + offset; - -#if FRAC_BITS <= 15 && !CONFIG_FLOAT - dct32(tmp, sb_samples); - for(j=0;j<32;j++) { - /* NOTE: can cause a loss in precision if very high amplitude - sound */ - synth_buf[j] = av_clip_int16(tmp[j]); - } -#else - dct32(synth_buf, sb_samples); -#endif - /* copy to avoid wrap */ memcpy(synth_buf + 512, synth_buf, 32 * sizeof(*synth_buf)); @@ -909,10 +695,45 @@ void RENAME(ff_mpa_synth_filter)(MPA_INT *synth_buf_ptr, int *synth_buf_offset, SUM8(MLSS, sum, w + 32, p); *samples = round_sample(&sum); *dither_state= sum; +} + + +/* 32 sub band synthesis filter. Input: 32 sub band samples, Output: + 32 samples. */ +/* XXX: optimize by avoiding ring buffer usage */ +#if !CONFIG_FLOAT +void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset, + MPA_INT *window, int *dither_state, + OUT_INT *samples, int incr, + INTFLOAT sb_samples[SBLIMIT]) +{ + register MPA_INT *synth_buf; + int offset; +#if FRAC_BITS <= 15 + int32_t tmp[32]; + int j; +#endif + + offset = *synth_buf_offset; + synth_buf = synth_buf_ptr + offset; + +#if FRAC_BITS <= 15 + dct32(tmp, sb_samples); + for(j=0;j<32;j++) { + /* NOTE: can cause a loss in precision if very high amplitude + sound */ + synth_buf[j] = av_clip_int16(tmp[j]); + } +#else + dct32(synth_buf, sb_samples); +#endif + + apply_window_mp3_c(synth_buf, window, dither_state, samples, incr); offset = (offset - 32) & 511; *synth_buf_offset = offset; } +#endif #define C3 FIXHR(0.86602540378443864676/2) @@ -1240,17 +1061,18 @@ static int mp_decode_layer2(MPADecodeContext *s) qindex = alloc_table[j+b]; bits = ff_mpa_quant_bits[qindex]; if (bits < 0) { + int v2; /* 3 values at the same time */ v = get_bits(&s->gb, -bits); - steps = ff_mpa_quant_steps[qindex]; + v2 = division_tabs[qindex][v]; + steps = ff_mpa_quant_steps[qindex]; + s->sb_samples[ch][k * 12 + l + 0][i] = - l2_unscale_group(steps, v % steps, scale); - v = v / steps; + l2_unscale_group(steps, v2 & 15, scale); s->sb_samples[ch][k * 12 + l + 1][i] = - l2_unscale_group(steps, v % steps, scale); - v = v / steps; + l2_unscale_group(steps, (v2 >> 4) & 15, scale); s->sb_samples[ch][k * 12 + l + 2][i] = - l2_unscale_group(steps, v, scale); + l2_unscale_group(steps, v2 >> 8 , scale); } else { for(m=0;m<3;m++) { v = get_bits(&s->gb, bits); @@ -1752,6 +1574,7 @@ static void compute_stereo(MPADecodeContext *s, } } +#if !CONFIG_FLOAT static void compute_antialias_integer(MPADecodeContext *s, GranuleDef *g) { @@ -1791,45 +1614,7 @@ static void compute_antialias_integer(MPADecodeContext *s, ptr += 18; } } - -static void compute_antialias_float(MPADecodeContext *s, - GranuleDef *g) -{ - float *ptr; - int n, i; - - /* we antialias only "long" bands */ - if (g->block_type == 2) { - if (!g->switch_point) - return; - /* XXX: check this for 8000Hz case */ - n = 1; - } else { - n = SBLIMIT - 1; - } - - ptr = g->sb_hybrid + 18; - for(i = n;i > 0;i--) { - float tmp0, tmp1; - float *csa = &csa_table_float[0][0]; -#define FLOAT_AA(j)\ - tmp0= ptr[-1-j];\ - tmp1= ptr[ j];\ - ptr[-1-j] = tmp0 * csa[0+4*j] - tmp1 * csa[1+4*j];\ - ptr[ j] = tmp0 * csa[1+4*j] + tmp1 * csa[0+4*j]; - - FLOAT_AA(0) - FLOAT_AA(1) - FLOAT_AA(2) - FLOAT_AA(3) - FLOAT_AA(4) - FLOAT_AA(5) - FLOAT_AA(6) - FLOAT_AA(7) - - ptr += 18; - } -} +#endif static void compute_imdct(MPADecodeContext *s, GranuleDef *g, @@ -2227,7 +2012,11 @@ static int mp_decode_frame(MPADecodeContext *s, for(ch=0;chnb_channels;ch++) { samples_ptr = samples + ch; for(i=0;isynth_buf[ch], &(s->synth_buf_offset[ch]), + RENAME(ff_mpa_synth_filter)( +#if CONFIG_FLOAT + s, +#endif + s->synth_buf[ch], &(s->synth_buf_offset[ch]), RENAME(ff_mpa_synth_window), &s->dither_state, samples_ptr, s->nb_channels, s->sb_samples[ch][i]); @@ -2297,7 +2086,7 @@ static void flush(AVCodecContext *avctx){ s->last_buf_size= 0; } -#if CONFIG_MP3ADU_DECODER +#if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER static int decode_frame_adu(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt) @@ -2347,9 +2136,9 @@ static int decode_frame_adu(AVCodecContext * avctx, *data_size = out_size; return buf_size; } -#endif /* CONFIG_MP3ADU_DECODER */ +#endif /* CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER */ -#if CONFIG_MP3ON4_DECODER +#if CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER /** * Context for MP3On4 decoder @@ -2513,7 +2302,7 @@ static int decode_frame_mp3on4(AVCodecContext * avctx, *data_size = out_size; return buf_size; } -#endif /* CONFIG_MP3ON4_DECODER */ +#endif /* CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER */ #if !CONFIG_FLOAT #if CONFIG_MP1_DECODER diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudiodec_float.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudiodec_float.c index dcdeea59c..93adaf8cc 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudiodec_float.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudiodec_float.c @@ -22,6 +22,64 @@ #define CONFIG_FLOAT 1 #include "mpegaudiodec.c" +void ff_mpa_synth_filter_float(MPADecodeContext *s, float *synth_buf_ptr, + int *synth_buf_offset, + float *window, int *dither_state, + float *samples, int incr, + float sb_samples[SBLIMIT]) +{ + float *synth_buf; + int offset; + + offset = *synth_buf_offset; + synth_buf = synth_buf_ptr + offset; + + s->dct.dct32(synth_buf, sb_samples); + s->apply_window_mp3(synth_buf, window, dither_state, samples, incr); + + offset = (offset - 32) & 511; + *synth_buf_offset = offset; +} + +static void compute_antialias_float(MPADecodeContext *s, + GranuleDef *g) +{ + float *ptr; + int n, i; + + /* we antialias only "long" bands */ + if (g->block_type == 2) { + if (!g->switch_point) + return; + /* XXX: check this for 8000Hz case */ + n = 1; + } else { + n = SBLIMIT - 1; + } + + ptr = g->sb_hybrid + 18; + for(i = n;i > 0;i--) { + float tmp0, tmp1; + float *csa = &csa_table_float[0][0]; +#define FLOAT_AA(j)\ + tmp0= ptr[-1-j];\ + tmp1= ptr[ j];\ + ptr[-1-j] = tmp0 * csa[0+4*j] - tmp1 * csa[1+4*j];\ + ptr[ j] = tmp0 * csa[1+4*j] + tmp1 * csa[0+4*j]; + + FLOAT_AA(0) + FLOAT_AA(1) + FLOAT_AA(2) + FLOAT_AA(3) + FLOAT_AA(4) + FLOAT_AA(5) + FLOAT_AA(6) + FLOAT_AA(7) + + ptr += 18; + } +} + #if CONFIG_MP1FLOAT_DECODER AVCodec mp1float_decoder = { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudioenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudioenc.c index 264175ecc..ce1524ba9 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudioenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegaudioenc.c @@ -40,12 +40,10 @@ typedef struct MpegAudioContext { PutBitContext pb; int nb_channels; - int freq, bit_rate; int lsf; /* 1 if mpeg2 low bitrate selected */ int bitrate_index; /* bit rate */ int freq_index; int frame_size; /* frame size, in bits, without padding */ - int64_t nb_samples; /* total number of samples encoded */ /* padding computation */ int frame_frac, frame_frac_incr, do_padding; short samples_buf[MPA_MAX_CHANNELS][SAMPLES_BUF_SIZE]; /* buffer for filter */ @@ -79,8 +77,6 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx) } bitrate = bitrate / 1000; s->nb_channels = channels; - s->freq = freq; - s->bit_rate = bitrate * 1000; avctx->frame_size = MPA_FRAME_SIZE; /* encoding freq */ @@ -778,7 +774,6 @@ static int MPA_encode_frame(AVCodecContext *avctx, encode_frame(s, bit_alloc, padding); - s->nb_samples += MPA_FRAME_SIZE; return put_bits_ptr(&s->pb) - s->pb.buf; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo.c index b5631cffc..684bdfe13 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo.c @@ -200,7 +200,7 @@ void ff_copy_picture(Picture *dst, Picture *src){ } /** - * Releases a frame buffer + * Release a frame buffer */ static void free_frame_buffer(MpegEncContext *s, Picture *pic) { @@ -209,7 +209,7 @@ static void free_frame_buffer(MpegEncContext *s, Picture *pic) } /** - * Allocates a frame buffer + * Allocate a frame buffer */ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) { @@ -356,6 +356,9 @@ static void free_picture(MpegEncContext *s, Picture *pic){ } static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){ + int y_size = s->b8_stride * (2 * s->mb_height + 1); + int c_size = s->mb_stride * (s->mb_height + 1); + int yc_size = y_size + 2 * c_size; int i; // edge emu needs blocksize + filter length - 1 (=17x17 for halfpel / 21x21 for h264) @@ -381,6 +384,15 @@ static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){ for(i=0;i<12;i++){ s->pblocks[i] = &s->block[i]; } + + if (s->out_format == FMT_H263) { + /* ac values */ + FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, yc_size * sizeof(int16_t) * 16, fail); + s->ac_val[0] = s->ac_val_base + s->b8_stride + 1; + s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1; + s->ac_val[2] = s->ac_val[1] + c_size; + } + return 0; fail: return -1; //free() through MPV_common_end() @@ -400,6 +412,7 @@ static void free_duplicate_context(MpegEncContext *s){ av_freep(&s->me.map); av_freep(&s->me.score_map); av_freep(&s->blocks); + av_freep(&s->ac_val_base); s->block= NULL; } @@ -423,6 +436,10 @@ static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src){ COPY(dct_error_sum); COPY(dct_count[0]); COPY(dct_count[1]); + COPY(ac_val_base); + COPY(ac_val[0]); + COPY(ac_val[1]); + COPY(ac_val[2]); #undef COPY } @@ -605,12 +622,6 @@ av_cold int MPV_common_init(MpegEncContext *s) } } if (s->out_format == FMT_H263) { - /* ac values */ - FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, yc_size * sizeof(int16_t) * 16, fail); - s->ac_val[0] = s->ac_val_base + s->b8_stride + 1; - s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1; - s->ac_val[2] = s->ac_val[1] + c_size; - /* cbp values */ FF_ALLOCZ_OR_GOTO(s->avctx, s->coded_block_base, y_size, fail); s->coded_block= s->coded_block_base + s->b8_stride + 1; @@ -712,7 +723,6 @@ void MPV_common_end(MpegEncContext *s) } av_freep(&s->dc_val_base); - av_freep(&s->ac_val_base); av_freep(&s->coded_block_base); av_freep(&s->mbintra_table); av_freep(&s->cbp_table); @@ -1634,7 +1644,7 @@ static inline void chroma_4mv_motion_lowres(MpegEncContext *s, * @param dest_cr chroma cr/v destination pointer * @param dir direction (0->forward, 1->backward) * @param ref_picture array[3] of pointers to the 3 planes of the reference picture - * @param pic_op halfpel motion compensation function (average or put normally) + * @param pix_op halfpel motion compensation function (average or put normally) * the motion vectors are taken from s->mv and the MV type from s->mv_type */ static inline void MPV_motion_lowres(MpegEncContext *s, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo_common.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo_common.h index 73106664f..8e46e692f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo_common.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo_common.h @@ -580,11 +580,11 @@ static inline void chroma_4mv_motion(MpegEncContext *s, src_x = s->mb_x * 8 + mx; src_y = s->mb_y * 8 + my; - src_x = av_clip(src_x, -8, s->width/2); - if (src_x == s->width/2) + src_x = av_clip(src_x, -8, (s->width >> 1)); + if (src_x == (s->width >> 1)) dxy &= ~1; - src_y = av_clip(src_y, -8, s->height/2); - if (src_y == s->height/2) + src_y = av_clip(src_y, -8, (s->height >> 1)); + if (src_y == (s->height >> 1)) dxy &= ~2; offset = (src_y * (s->uvlinesize)) + src_x; @@ -631,8 +631,8 @@ static inline void prefetch_motion(MpegEncContext *s, uint8_t **pix, int dir){ * @param dest_cr chroma cr/v destination pointer * @param dir direction (0->forward, 1->backward) * @param ref_picture array[3] of pointers to the 3 planes of the reference picture - * @param pic_op halfpel motion compensation function (average or put normally) - * @param pic_op qpel motion compensation function (average or put normally) + * @param pix_op halfpel motion compensation function (average or put normally) + * @param qpix_op qpel motion compensation function (average or put normally) * the motion vectors are taken from s->mv and the MV type from s->mv_type */ static av_always_inline void MPV_motion_internal(MpegEncContext *s, @@ -670,19 +670,19 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s, } if(mb_x==0 || IS_INTRA(s->current_picture.mb_type[xy-1])){ - *(int32_t*)mv_cache[1][0]= *(int32_t*)mv_cache[1][1]; - *(int32_t*)mv_cache[2][0]= *(int32_t*)mv_cache[2][1]; + AV_COPY32(mv_cache[1][0], mv_cache[1][1]); + AV_COPY32(mv_cache[2][0], mv_cache[2][1]); }else{ - *(int32_t*)mv_cache[1][0]= *(int32_t*)s->current_picture.motion_val[0][mot_xy-1]; - *(int32_t*)mv_cache[2][0]= *(int32_t*)s->current_picture.motion_val[0][mot_xy-1+mot_stride]; + AV_COPY32(mv_cache[1][0], s->current_picture.motion_val[0][mot_xy-1]); + AV_COPY32(mv_cache[2][0], s->current_picture.motion_val[0][mot_xy-1+mot_stride]); } if(mb_x+1>=s->mb_width || IS_INTRA(s->current_picture.mb_type[xy+1])){ - *(int32_t*)mv_cache[1][3]= *(int32_t*)mv_cache[1][2]; - *(int32_t*)mv_cache[2][3]= *(int32_t*)mv_cache[2][2]; + AV_COPY32(mv_cache[1][3], mv_cache[1][2]); + AV_COPY32(mv_cache[2][3], mv_cache[2][2]); }else{ - *(int32_t*)mv_cache[1][3]= *(int32_t*)s->current_picture.motion_val[0][mot_xy+2]; - *(int32_t*)mv_cache[2][3]= *(int32_t*)s->current_picture.motion_val[0][mot_xy+2+mot_stride]; + AV_COPY32(mv_cache[1][3], s->current_picture.motion_val[0][mot_xy+2]); + AV_COPY32(mv_cache[2][3], s->current_picture.motion_val[0][mot_xy+2+mot_stride]); } mx = 0; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo_enc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo_enc.c index a8616d0ae..9f8682cae 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo_enc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo_enc.c @@ -254,7 +254,7 @@ av_cold int MPV_encode_init(AVCodecContext *avctx) case CODEC_ID_LJPEG: case CODEC_ID_MJPEG: if(avctx->pix_fmt != PIX_FMT_YUVJ420P && avctx->pix_fmt != PIX_FMT_YUVJ422P && avctx->pix_fmt != PIX_FMT_RGB32 && - ((avctx->pix_fmt != PIX_FMT_YUV420P && avctx->pix_fmt != PIX_FMT_YUV422P) || avctx->strict_std_compliance>FF_COMPLIANCE_INOFFICIAL)){ + ((avctx->pix_fmt != PIX_FMT_YUV420P && avctx->pix_fmt != PIX_FMT_YUV422P) || avctx->strict_std_compliance>FF_COMPLIANCE_UNOFFICIAL)){ av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n"); return -1; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo_xvmc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo_xvmc.c index df81e5da6..a24520051 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo_xvmc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/mpegvideo_xvmc.c @@ -33,7 +33,7 @@ #include "xvmc_internal.h" /** - * Initializes the block field of the MpegEncContext pointer passed as + * Initialize the block field of the MpegEncContext pointer passed as * parameter after making sure that the data is not corrupted. * In order to implement something like direct rendering instead of decoding * coefficients in s->blocks and then copying them, copy them directly @@ -48,7 +48,7 @@ void ff_xvmc_init_block(MpegEncContext *s) } /** - * Fills individual block pointers, so there are no gaps in the data_block array + * Fill individual block pointers, so there are no gaps in the data_block array * in case not all blocks in the macroblock are coded. */ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp) @@ -67,7 +67,7 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp) } /** - * Finds and stores the surfaces that are used as reference frames. + * Find and store the surfaces that are used as reference frames. * This function should be called for every new field and/or frame. * It should be safe to call the function a few times for the same field. */ @@ -134,7 +134,7 @@ return -1; } /** - * Completes frame/field rendering by passing any remaining blocks. + * Complete frame/field rendering by passing any remaining blocks. * Normally ff_draw_horiz_band() is called for each slice, however, * some leftover blocks, for example from error_resilience(), may remain. * It should be safe to call the function a few times for the same field. @@ -149,8 +149,8 @@ void ff_xvmc_field_end(MpegEncContext *s) } /** - * Synthesizes the data needed by XvMC to render one macroblock of data. - * Fills all relevant fields, if necessary do IDCT. + * Synthesize the data needed by XvMC to render one macroblock of data. + * Fill all relevant fields, if necessary do IDCT. */ void ff_xvmc_decode_mb(MpegEncContext *s) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/msmpeg4.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/msmpeg4.c index 84658fe84..8b48dc7cd 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/msmpeg4.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/msmpeg4.c @@ -1929,6 +1929,7 @@ AVCodec msmpeg4v1_decoder = { ff_h263_decode_end, ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"), .pix_fmts= ff_pixfmt_list_420, }; @@ -1943,6 +1944,7 @@ AVCodec msmpeg4v2_decoder = { ff_h263_decode_end, ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"), .pix_fmts= ff_pixfmt_list_420, }; @@ -1957,6 +1959,7 @@ AVCodec msmpeg4v3_decoder = { ff_h263_decode_end, ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"), .pix_fmts= ff_pixfmt_list_420, }; @@ -1971,6 +1974,7 @@ AVCodec wmv1_decoder = { ff_h263_decode_end, ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("Windows Media Video 7"), .pix_fmts= ff_pixfmt_list_420, }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/msrledec.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/msrledec.h index 7495de532..223016269 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/msrledec.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/msrledec.h @@ -25,7 +25,7 @@ #include "avcodec.h" /** - * Decodes stream in MS RLE format into frame. + * Decode stream in MS RLE format into frame. * * @param avctx codec context * @param pic destination frame diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/nellymoserdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/nellymoserdec.c index 82a3f0795..8976467f6 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/nellymoserdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/nellymoserdec.c @@ -166,21 +166,18 @@ static int decode_tag(AVCodecContext * avctx, if (buf_size < avctx->block_align) return buf_size; - switch (buf_size) { - case 64: // 8000Hz - blocks = 1; break; - case 128: // 11025Hz - blocks = 2; break; - case 192: // 16000Hz - blocks = 3; break; - case 256: // 22050Hz - blocks = 4; break; - case 512: // 44100Hz - blocks = 8; break; - default: - av_log(avctx, AV_LOG_DEBUG, "Tag size %d.\n", buf_size); - return buf_size; + if (buf_size % 64) { + av_log(avctx, AV_LOG_ERROR, "Tag size %d.\n", buf_size); + return buf_size; } + blocks = buf_size / 64; + /* Normal numbers of blocks for sample rates: + * 8000 Hz - 1 + * 11025 Hz - 2 + * 16000 Hz - 3 + * 22050 Hz - 4 + * 44100 Hz - 8 + */ for (i=0 ; ifloat_buf); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/nellymoserenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/nellymoserenc.c index dd9a2719e..1f9442cf9 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/nellymoserenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/nellymoserenc.c @@ -270,7 +270,7 @@ static void get_exponent_dynamic(NellyMoserEncodeContext *s, float *cand, int *i } /** - * Encodes NELLY_SAMPLES samples. It assumes, that samples contains 3 * NELLY_BUF_LEN values + * Encode NELLY_SAMPLES samples. It assumes, that samples contains 3 * NELLY_BUF_LEN values * @param s encoder context * @param output output buffer * @param output_size size of output buffer diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/opt.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/opt.h index 55ca4ea63..9f0da7296 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/opt.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/opt.h @@ -139,7 +139,7 @@ typedef struct AVOption2 { /** - * Looks for an option in obj. Looks only for the options which + * Look for an option in obj. Look only for the options which * have the flags set as specified in mask and flags (that is, * for which it is the case that opt->flags & mask == flags). * @@ -168,7 +168,7 @@ attribute_deprecated const AVOption *av_set_string2(void *obj, const char *name, #endif /** - * Sets the field of obj with the given name to value. + * Set the field of obj with the given name to value. * * @param[in] obj A struct whose first element is a pointer to an * AVClass. diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/options.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/options.c index 5a2c281e4..744957dc5 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/options.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/options.c @@ -117,8 +117,8 @@ static const AVOption options[]={ {"delay", NULL, OFFSET(delay), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX}, {"qcomp", "video quantizer scale compression (VBR)", OFFSET(qcompress), FF_OPT_TYPE_FLOAT, 0.5, -FLT_MAX, FLT_MAX, V|E}, {"qblur", "video quantizer scale blur (VBR)", OFFSET(qblur), FF_OPT_TYPE_FLOAT, 0.5, 0, FLT_MAX, V|E}, -{"qmin", "min video quantizer scale (VBR)", OFFSET(qmin), FF_OPT_TYPE_INT, 2, 1, 51, V|E}, -{"qmax", "max video quantizer scale (VBR)", OFFSET(qmax), FF_OPT_TYPE_INT, 31, 1, 51, V|E}, +{"qmin", "min video quantizer scale (VBR)", OFFSET(qmin), FF_OPT_TYPE_INT, 2, 0, 63, V|E}, +{"qmax", "max video quantizer scale (VBR)", OFFSET(qmax), FF_OPT_TYPE_INT, 31, 0, 63, V|E}, {"qdiff", "max difference between the quantizer scale (VBR)", OFFSET(max_qdiff), FF_OPT_TYPE_INT, 3, INT_MIN, INT_MAX, V|E}, {"bf", "use 'frames' B frames", OFFSET(max_b_frames), FF_OPT_TYPE_INT, DEFAULT, 0, FF_MAX_B_FRAMES, V|E}, {"b_qfactor", "qp factor between p and b frames", OFFSET(b_quant_factor), FF_OPT_TYPE_FLOAT, 1.25, -FLT_MAX, FLT_MAX, V|E}, @@ -160,7 +160,10 @@ static const AVOption options[]={ {"very", "strictly conform to a older more strict version of the spec or reference software", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_VERY_STRICT, INT_MIN, INT_MAX, V|D|E, "strict"}, {"strict", "strictly conform to all the things in the spec no matter what consequences", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_STRICT, INT_MIN, INT_MAX, V|D|E, "strict"}, {"normal", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_NORMAL, INT_MIN, INT_MAX, V|D|E, "strict"}, -{"inofficial", "allow unofficial extensions", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_INOFFICIAL, INT_MIN, INT_MAX, V|D|E, "strict"}, +#if LIBAVCODEC_VERSION_MAJOR < 53 +{"inofficial", "allow unofficial extensions (deprecated - use unofficial)", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_UNOFFICIAL, INT_MIN, INT_MAX, V|D|E, "strict"}, +#endif +{"unofficial", "allow unofficial extensions", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_UNOFFICIAL, INT_MIN, INT_MAX, V|D|E, "strict"}, {"experimental", "allow non standardized experimental things", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_EXPERIMENTAL, INT_MIN, INT_MAX, V|D|E, "strict"}, {"b_qoffset", "qp offset between P and B frames", OFFSET(b_quant_offset), FF_OPT_TYPE_FLOAT, 1.25, -FLT_MAX, FLT_MAX, V|E}, {"er", "set error detection aggressivity", OFFSET(error_recognition), FF_OPT_TYPE_INT, FF_ER_CAREFUL, INT_MIN, INT_MAX, A|V|D, "er"}, @@ -379,7 +382,9 @@ static const AVOption options[]={ {"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_VLC, INT_MIN, INT_MAX, V|E, "flags2"}, {"b_sensitivity", "adjusts sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), FF_OPT_TYPE_INT, 40, 1, INT_MAX, V|E}, {"compression_level", NULL, OFFSET(compression_level), FF_OPT_TYPE_INT, FF_COMPRESSION_DEFAULT, INT_MIN, INT_MAX, V|A|E}, +#if LIBAVCODEC_VERSION_MAJOR < 53 {"use_lpc", "sets whether to use LPC mode (FLAC)", OFFSET(use_lpc), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E}, +#endif {"lpc_coeff_precision", "LPC coefficient precision (FLAC)", OFFSET(lpc_coeff_precision), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|E}, {"min_prediction_order", NULL, OFFSET(min_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E}, {"max_prediction_order", NULL, OFFSET(max_prediction_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E}, @@ -414,6 +419,12 @@ static const AVOption options[]={ {"intra_refresh", "use periodic insertion of intra blocks instead of keyframes", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_REFRESH, INT_MIN, INT_MAX, V|E, "flags2"}, {"crf_max", "in crf mode, prevents vbv from lowering quality beyond this point", OFFSET(crf_max), FF_OPT_TYPE_FLOAT, DEFAULT, 0, 51, V|E}, {"log_level_offset", "set the log level offset", OFFSET(log_level_offset), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX }, +{"lpc_type", "specify LPC algorithm", OFFSET(lpc_type), FF_OPT_TYPE_INT, AV_LPC_TYPE_DEFAULT, AV_LPC_TYPE_DEFAULT, AV_LPC_TYPE_NB-1, A|E}, +{"none", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_NONE, INT_MIN, INT_MAX, A|E, "lpc_type"}, +{"fixed", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_FIXED, INT_MIN, INT_MAX, A|E, "lpc_type"}, +{"levinson", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_LEVINSON, INT_MIN, INT_MAX, A|E, "lpc_type"}, +{"cholesky", NULL, 0, FF_OPT_TYPE_CONST, AV_LPC_TYPE_CHOLESKY, INT_MIN, INT_MAX, A|E, "lpc_type"}, +{"lpc_passes", "number of passes to use for Cholesky factorization during LPC analysis", OFFSET(lpc_passes), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E}, {NULL}, }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/os2thread.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/os2thread.c deleted file mode 100644 index 3d1367c8f..000000000 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/os2thread.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2004 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -//#define DEBUG - -// Ported by Vlad Stelmahovsky - -#include "avcodec.h" - -#define INCL_DOS -#define INCL_DOSERRORS -#define INCL_DOSDEVIOCTL -#include - -typedef struct ThreadContext{ - AVCodecContext *avctx; - int thread; - HEV work_sem; - HEV done_sem; - int (*func)(AVCodecContext *c, void *arg); - void *arg; - int ret; -}ThreadContext; - - -static void attribute_align_arg thread_func(void *v){ - ThreadContext *c= v; - - for(;;){ - //printf("thread_func %X enter wait\n", (int)v); fflush(stdout); - DosWaitEventSem(c->work_sem, SEM_INDEFINITE_WAIT); -// WaitForSingleObject(c->work_sem, INFINITE); -//printf("thread_func %X after wait (func=%X)\n", (int)v, (int)c->func); fflush(stdout); - if(c->func) - c->ret= c->func(c->avctx, c->arg); - else - return; - //printf("thread_func %X signal complete\n", (int)v); fflush(stdout); - DosPostEventSem(c->done_sem); -// ReleaseSemaphore(c->done_sem, 1, 0); - } - - return; -} - -/** - * free what has been allocated by avcodec_thread_init(). - * must be called after decoding has finished, especially do not call while avcodec_thread_execute() is running - */ -void avcodec_thread_free(AVCodecContext *s){ - ThreadContext *c= s->thread_opaque; - int i; - - for(i=0; ithread_count; i++){ - - c[i].func= NULL; - DosPostEventSem(c[i].work_sem); - // ReleaseSemaphore(c[i].work_sem, 1, 0); - DosWaitThread((PTID)&c[i].thread,DCWW_WAIT); -// WaitForSingleObject(c[i].thread, INFINITE); - if(c[i].work_sem) DosCloseEventSem(c[i].work_sem);//CloseHandle(c[i].work_sem); - if(c[i].done_sem) DosCloseEventSem(c[i].done_sem);//CloseHandle(c[i].done_sem); - } - - av_freep(&s->thread_opaque); -} - -static int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size){ - ThreadContext *c= s->thread_opaque; - int i; - - assert(s == c->avctx); - assert(count <= s->thread_count); - - /* note, we can be certain that this is not called with the same AVCodecContext by different threads at the same time */ - - for(i=0; ithread_count= thread_count; - - if (thread_count <= 1) - return 0; - - assert(!s->thread_opaque); - c= av_mallocz(sizeof(ThreadContext)*thread_count); - s->thread_opaque= c; - - for(i=0; iexecute= avcodec_thread_execute; - - return 0; -fail: - avcodec_thread_free(s); - return -1; -} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/parser.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/parser.c index 864b5f2d2..1aa86515d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/parser.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/parser.c @@ -74,7 +74,7 @@ AVCodecParserContext *av_parser_init(int codec_id) s->fetch_timestamp=1; s->pict_type = FF_I_TYPE; s->key_frame = -1; - s->convergence_duration = AV_NOPTS_VALUE; + s->convergence_duration = 0; s->dts_sync_point = INT_MIN; s->dts_ref_dts_delta = INT_MIN; s->pts_dts_delta = INT_MIN; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/parser.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/parser.h index 6274bb2b4..6712bfe8b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/parser.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/parser.h @@ -61,7 +61,7 @@ void ff_parse_close(AVCodecParserContext *s); void ff_parse1_close(AVCodecParserContext *s); /** - * Fetches timestamps for a specific byte within the current access unit. + * Fetch timestamps for a specific byte within the current access unit. * @param off byte position within the access unit * @param remove Found timestamps will be removed if set to 1, kept if set to 0. */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcm.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcm.c index 746a52025..4e8615483 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcm.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcm.c @@ -227,6 +227,10 @@ static av_cold int pcm_decode_init(AVCodecContext * avctx) } avctx->sample_fmt = avctx->codec->sample_fmts[0]; + + if (avctx->sample_fmt == SAMPLE_FMT_S32) + avctx->bits_per_raw_sample = av_get_bits_per_sample(avctx->codec->id); + return 0; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcm_tablegen.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcm_tablegen.c index 57ecb43dc..b0fde936c 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcm_tablegen.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcm_tablegen.c @@ -32,13 +32,8 @@ int main(void) write_fileheader(); - printf("static const uint8_t linear_to_alaw[1 << 14] = {\n"); - write_uint8_array(linear_to_alaw, 1 << 14); - printf("};\n"); - - printf("static const uint8_t linear_to_ulaw[1 << 14] = {\n"); - write_uint8_array(linear_to_ulaw, 1 << 14); - printf("};\n"); + WRITE_ARRAY("static const", uint8_t, linear_to_alaw); + WRITE_ARRAY("static const", uint8_t, linear_to_ulaw); return 0; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcm_tablegen.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcm_tablegen.h index 8921baaba..3d641b05b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcm_tablegen.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcm_tablegen.h @@ -24,7 +24,7 @@ #define PCM_TABLEGEN_H #include -#include "../libavutil/attributes.h" +#include "libavutil/attributes.h" /* from g711.c by SUN microsystems (unrestricted use) */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcx.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcx.c index 2174184bc..072d136d8 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcx.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pcx.c @@ -87,6 +87,8 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, bytes_per_scanline; uint8_t *ptr; uint8_t const *bufstart = buf; + uint8_t *scanline; + int ret = -1; if (buf[0] != 0x0a || buf[1] > 5) { av_log(avctx, AV_LOG_ERROR, "this is not PCX encoded data\n"); @@ -154,9 +156,11 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, ptr = p->data[0]; stride = p->linesize[0]; - if (nplanes == 3 && bits_per_pixel == 8) { - uint8_t scanline[bytes_per_scanline]; + scanline = av_malloc(bytes_per_scanline); + if (!scanline) + return AVERROR(ENOMEM); + if (nplanes == 3 && bits_per_pixel == 8) { for (y=0; ypicture; *data_size = sizeof(AVFrame); - return buf - bufstart; + ret = buf - bufstart; +end: + av_free(scanline); + return ret; } static av_cold int pcx_end(AVCodecContext *avctx) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pgssubdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pgssubdec.c index 551200684..bda7665f5 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pgssubdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pgssubdec.c @@ -26,8 +26,8 @@ #include "avcodec.h" #include "dsputil.h" -#include "colorspace.h" #include "bytestream.h" +#include "libavutil/colorspace.h" //#define DEBUG_PACKET_CONTENTS @@ -64,7 +64,7 @@ typedef struct PGSSubContext { static av_cold int init_decoder(AVCodecContext *avctx) { - avctx->pix_fmt = PIX_FMT_RGB32; + avctx->pix_fmt = PIX_FMT_PAL8; return 0; } @@ -80,7 +80,7 @@ static av_cold int close_decoder(AVCodecContext *avctx) } /** - * Decodes the RLE data. + * Decode the RLE data. * * The subtitle is stored as an Run Length Encoded image. * @@ -141,7 +141,7 @@ static int decode_rle(AVCodecContext *avctx, AVSubtitle *sub, } /** - * Parses the picture segment packet. + * Parse the picture segment packet. * * The picture segment contains details on the sequence id, * width, height and Run Length Encoded (RLE) bitmap data. @@ -205,7 +205,7 @@ static int parse_picture_segment(AVCodecContext *avctx, } /** - * Parses the palette segment packet. + * Parse the palette segment packet. * * The palette segment contains details of the palette, * a maximum of 256 colors can be defined. @@ -246,7 +246,7 @@ static void parse_palette_segment(AVCodecContext *avctx, } /** - * Parses the presentation segment packet. + * Parse the presentation segment packet. * * The presentation segment contains details on the video * width, video height, x & y subtitle position. @@ -317,7 +317,7 @@ static void parse_presentation_segment(AVCodecContext *avctx, } /** - * Parses the display segment packet. + * Parse the display segment packet. * * The display segment controls the updating of the display. * diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pictordec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pictordec.c new file mode 100644 index 000000000..f990b1852 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pictordec.c @@ -0,0 +1,250 @@ +/* + * Pictor/PC Paint decoder + * Copyright (c) 2010 Peter Ross + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Pictor/PC Paint decoder + */ + +#include "avcodec.h" +#include "bytestream.h" +#include "cga_data.h" + +typedef struct PicContext { + AVFrame frame; + int width, height; + int nb_planes; +} PicContext; + +static void picmemset_8bpp(PicContext *s, int value, int run, int *x, int *y) +{ + while (run > 0) { + uint8_t *d = s->frame.data[0] + *y * s->frame.linesize[0]; + if (*x + run >= s->width) { + int n = s->width - *x; + memset(d + *x, value, n); + run -= n; + *x = 0; + *y -= 1; + if (*y < 0) + break; + } else { + memset(d + *x, value, run); + *x += run; + break; + } + } +} + +static void picmemset(PicContext *s, int value, int run, int *x, int *y, int *plane, int bits_per_plane) +{ + uint8_t *d; + int shift = *plane * bits_per_plane; + int mask = ((1 << bits_per_plane) - 1) << shift; + value <<= shift; + + while (run > 0) { + int j; + for (j = 8-bits_per_plane; j >= 0; j -= bits_per_plane) { + d = s->frame.data[0] + *y * s->frame.linesize[0]; + d[*x] |= (value >> j) & mask; + *x += 1; + if (*x == s->width) { + *y -= 1; + *x = 0; + if (*y < 0) { + *y = s->height - 1; + *plane += 1; + value <<= bits_per_plane; + mask <<= bits_per_plane; + if (*plane >= s->nb_planes) + break; + } + } + } + run--; + } +} + +static const uint8_t cga_mode45_index[6][4] = { + [0] = { 0, 3, 5, 7 }, // mode4, palette#1, low intensity + [1] = { 0, 2, 4, 6 }, // mode4, palette#2, low intensity + [2] = { 0, 3, 4, 7 }, // mode5, low intensity + [3] = { 0, 11, 13, 15 }, // mode4, palette#1, high intensity + [4] = { 0, 10, 12, 14 }, // mode4, palette#2, high intensity + [5] = { 0, 11, 12, 15 }, // mode5, high intensity +}; + +static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, + AVPacket *avpkt) +{ + PicContext *s = avctx->priv_data; + int buf_size = avpkt->size; + const uint8_t *buf = avpkt->data; + const uint8_t *buf_end = avpkt->data + buf_size; + uint32_t *palette; + int bits_per_plane, bpp, etype, esize, npal; + int i, x, y, plane; + + if (buf_size < 11) + return AVERROR_INVALIDDATA; + + if (bytestream_get_le16(&buf) != 0x1234) + return AVERROR_INVALIDDATA; + s->width = bytestream_get_le16(&buf); + s->height = bytestream_get_le16(&buf); + buf += 4; + bits_per_plane = *buf & 0xF; + s->nb_planes = (*buf++ >> 4) + 1; + bpp = s->nb_planes ? bits_per_plane*s->nb_planes : bits_per_plane; + if (bits_per_plane > 8 || bpp < 1 || bpp > 32) { + av_log_ask_for_sample(s, "unsupported bit depth\n"); + return AVERROR_INVALIDDATA; + } + + if (*buf == 0xFF) { + buf += 2; + etype = bytestream_get_le16(&buf); + esize = bytestream_get_le16(&buf); + if (buf_end - buf < esize) + return AVERROR_INVALIDDATA; + } else { + etype = -1; + esize = 0; + } + + avctx->pix_fmt = PIX_FMT_PAL8; + + if (s->width != avctx->width && s->height != avctx->height) { + if (avcodec_check_dimensions(avctx, s->width, s->height) < 0) + return -1; + avcodec_set_dimensions(avctx, s->width, s->height); + if (s->frame.data[0]) + avctx->release_buffer(avctx, &s->frame); + } + + if (avctx->get_buffer(avctx, &s->frame) < 0){ + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + return -1; + } + memset(s->frame.data[0], 0, s->height * s->frame.linesize[0]); + s->frame.pict_type = FF_I_TYPE; + s->frame.palette_has_changed = 1; + + palette = (uint32_t*)s->frame.data[1]; + if (etype == 1 && esize > 1 && *buf < 6) { + int idx = *buf; + npal = 4; + for (i = 0; i < npal; i++) + palette[i] = ff_cga_palette[ cga_mode45_index[idx][i] ]; + } else if (etype == 2) { + npal = FFMIN(esize, 16); + for (i = 0; i < npal; i++) + palette[i] = ff_cga_palette[ FFMIN(buf[i], 16)]; + } else if (etype == 3) { + npal = FFMIN(esize, 16); + for (i = 0; i < npal; i++) + palette[i] = ff_ega_palette[ FFMIN(buf[i], 63)]; + } else if (etype == 4 || etype == 5) { + npal = FFMIN(esize / 3, 256); + for (i = 0; i < npal; i++) + palette[i] = AV_RB24(buf + i*3) << 2; + } else { + if (bpp == 1) { + npal = 2; + palette[0] = 0x000000; + palette[1] = 0xFFFFFF; + } else if (bpp == 2) { + npal = 4; + for (i = 0; i < npal; i++) + palette[i] = ff_cga_palette[ cga_mode45_index[0][i] ]; + } else { + npal = 16; + memcpy(palette, ff_cga_palette, npal * 4); + } + } + // fill remaining palette entries + memset(palette + npal, 0, AVPALETTE_SIZE - npal * 4); + buf += esize; + + + x = 0; + y = s->height - 1; + plane = 0; + if (bytestream_get_le16(&buf)) { + while (buf_end - buf >= 6) { + const uint8_t *buf_pend = buf + FFMIN(AV_RL16(buf), buf_end - buf); + //ignore uncompressed block size reported at buf[2] + int marker = buf[4]; + buf += 5; + + while (plane < s->nb_planes && buf_pend - buf >= 1) { + int run = 1; + int val = *buf++; + if (val == marker) { + run = *buf++; + if (run == 0) + run = bytestream_get_le16(&buf); + val = *buf++; + } + if (buf > buf_end) + break; + + if (bits_per_plane == 8) { + picmemset_8bpp(s, val, run, &x, &y); + if (y < 0) + break; + } else { + picmemset(s, val, run, &x, &y, &plane, bits_per_plane); + } + } + } + } else { + av_log_ask_for_sample(s, "uncompressed image\n"); + return buf_size; + } + + *data_size = sizeof(AVFrame); + *(AVFrame*)data = s->frame; + return buf_size; +} + +static av_cold int decode_end(AVCodecContext *avctx) +{ + PicContext *s = avctx->priv_data; + if (s->frame.data[0]) + avctx->release_buffer(avctx, &s->frame); + return 0; +} + +AVCodec pictor_decoder = { + "pictor", + CODEC_TYPE_VIDEO, + CODEC_ID_PICTOR, + sizeof(PicContext), + NULL, + NULL, + decode_end, + decode_frame, + CODEC_CAP_DR1, + .long_name = NULL_IF_CONFIG_SMALL("Pictor/PC Paint"), +}; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pngdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pngdec.c index 03859a991..037c5a0e5 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pngdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pngdec.c @@ -429,7 +429,7 @@ static int decode_frame(AVCodecContext *avctx, if (length > 0x7fffffff) goto fail; tag32 = bytestream_get_be32(&s->bytestream); - tag = bswap_32(tag32); + tag = av_bswap32(tag32); dprintf(avctx, "png: tag=%c%c%c%c length=%u\n", (tag & 0xff), ((tag >> 8) & 0xff), @@ -667,5 +667,6 @@ AVCodec png_decoder = { decode_frame, CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/, NULL, + .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PNG image"), }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pngenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pngenc.c index 615bcc44c..d199b95da 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pngenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pngenc.c @@ -199,7 +199,7 @@ static void png_write_chunk(uint8_t **f, uint32_t tag, crc = crc32(0, Z_NULL, 0); AV_WL32(tagbuf, tag); crc = crc32(crc, tagbuf, 4); - bytestream_put_be32(f, bswap_32(tag)); + bytestream_put_be32(f, av_bswap32(tag)); if (length > 0) { crc = crc32(crc, buf, length); memcpy(*f, buf, length); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pnmdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pnmdec.c index 66033c1f4..6bea93de0 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pnmdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/pnmdec.c @@ -124,7 +124,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data, } else if (upgrade == 2) { unsigned int j, v, f = (65535 * 32768 + s->maxval / 2) / s->maxval; for (j = 0; j < n / 2; j++) { - v = be2me_16(((uint16_t *)s->bytestream)[j]); + v = av_be2ne16(((uint16_t *)s->bytestream)[j]); ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15; } } @@ -199,6 +199,7 @@ AVCodec pgm_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE}, + .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"), }; #endif @@ -215,6 +216,7 @@ AVCodec pgmyuv_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, + .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"), }; #endif @@ -231,6 +233,7 @@ AVCodec ppm_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE}, + .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"), }; #endif @@ -247,6 +250,7 @@ AVCodec pbm_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE}, + .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"), }; #endif @@ -263,6 +267,7 @@ AVCodec pam_decoder = { pnm_decode_frame, CODEC_CAP_DR1, .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE}, + .max_lowres = 5, .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), }; #endif diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/Makefile b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/Makefile index 5d5a59b4c..175b1093b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/Makefile +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/Makefile @@ -5,11 +5,22 @@ ALTIVEC-OBJS-$(CONFIG_VC1_DECODER) += ppc/vc1dsp_altivec.o ALTIVEC-OBJS-$(CONFIG_VP3_DECODER) += ppc/vp3dsp_altivec.o ALTIVEC-OBJS-$(CONFIG_VP5_DECODER) += ppc/vp3dsp_altivec.o ALTIVEC-OBJS-$(CONFIG_VP6_DECODER) += ppc/vp3dsp_altivec.o +ALTIVEC-OBJS-$(CONFIG_VP8_DECODER) += ppc/vp8dsp_altivec.o + +ALTIVEC-OBJS-$(CONFIG_MP1FLOAT_DECODER) += ppc/mpegaudiodec_altivec.o +ALTIVEC-OBJS-$(CONFIG_MP2FLOAT_DECODER) += ppc/mpegaudiodec_altivec.o +ALTIVEC-OBJS-$(CONFIG_MP3FLOAT_DECODER) += ppc/mpegaudiodec_altivec.o +ALTIVEC-OBJS-$(CONFIG_MP3ON4FLOAT_DECODER) += ppc/mpegaudiodec_altivec.o +ALTIVEC-OBJS-$(CONFIG_MP3ADUFLOAT_DECODER) += ppc/mpegaudiodec_altivec.o + +FFT-OBJS-$(HAVE_GNU_AS) += ppc/fft_altivec_s.o \ + +ALTIVEC-OBJS-$(CONFIG_FFT) += ppc/fft_altivec.o \ + $(FFT-OBJS-yes) OBJS-$(HAVE_ALTIVEC) += ppc/check_altivec.o \ ppc/dsputil_altivec.o \ ppc/fdct_altivec.o \ - ppc/fft_altivec.o \ ppc/float_altivec.o \ ppc/gmc_altivec.o \ ppc/idct_altivec.o \ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/asm.S b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/asm.S new file mode 100644 index 000000000..e372d53c6 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/asm.S @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2009 Loren Merritt + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#define GLUE(a, b) a ## b +#define JOIN(a, b) GLUE(a, b) +#define X(s) JOIN(EXTERN_ASM, s) + +#if ARCH_PPC64 + +#define PTR .quad +#define lp ld +#define lpx ldx +#define stp std +#define stpu stdu +#define PS 8 +#define L(s) JOIN(., s) + +.macro extfunc name + .global X(\name) + .section .opd, "aw" +X(\name): + .quad L(\name), .TOC.@tocbase, 0 + .previous + .type X(\name), STT_FUNC +L(\name): +.endm + +.macro movrel rd, sym + ld \rd, \sym@got(r2) +.endm + +#else /* ARCH_PPC64 */ + +#define PTR .int +#define lp lwz +#define lpx lwzx +#define stp stw +#define stpu stwu +#define PS 4 +#define L(s) s + +.macro extfunc name + .global X(\name) + .type X(\name), STT_FUNC +X(\name): +\name: +.endm + +.macro movrel rd, sym +#if CONFIG_PIC + lwz \rd, \sym@got(r2) +#else + lis \rd, \sym@ha + la \rd, \sym@l(\rd) +#endif +.endm + +#endif /* ARCH_PPC64 */ + +#if HAVE_IBM_ASM + +.macro DEFINE_REG n + .equiv r\n, \n + .equiv f\n, \n + .equiv v\n, \n +.endm + +DEFINE_REG 0 +DEFINE_REG 1 +DEFINE_REG 2 +DEFINE_REG 3 +DEFINE_REG 4 +DEFINE_REG 5 +DEFINE_REG 6 +DEFINE_REG 7 +DEFINE_REG 8 +DEFINE_REG 9 +DEFINE_REG 10 +DEFINE_REG 11 +DEFINE_REG 12 +DEFINE_REG 13 +DEFINE_REG 14 +DEFINE_REG 15 +DEFINE_REG 16 +DEFINE_REG 17 +DEFINE_REG 18 +DEFINE_REG 19 +DEFINE_REG 20 +DEFINE_REG 21 +DEFINE_REG 22 +DEFINE_REG 23 +DEFINE_REG 24 +DEFINE_REG 25 +DEFINE_REG 26 +DEFINE_REG 27 +DEFINE_REG 28 +DEFINE_REG 29 +DEFINE_REG 30 +DEFINE_REG 31 + +#endif /* HAVE_IBM_ASM */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/check_altivec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/check_altivec.c index c8bc6edcf..6b9332ce3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/check_altivec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/check_altivec.c @@ -19,7 +19,7 @@ /** * @file - * Checks for AltiVec presence. + * Check for AltiVec presence. */ #ifdef __APPLE__ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/dsputil_altivec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/dsputil_altivec.c index 925b6c83b..163323264 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/dsputil_altivec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/dsputil_altivec.c @@ -25,7 +25,6 @@ #include #endif #include "libavcodec/dsputil.h" -#include "dsputil_ppc.h" #include "util_altivec.h" #include "types_altivec.h" #include "dsputil_altivec.h" @@ -610,7 +609,6 @@ static void add_bytes_altivec(uint8_t *dst, uint8_t *src, int w) { /* next one assumes that ((line_size % 16) == 0) */ void put_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) { -POWERPC_PERF_DECLARE(altivec_put_pixels16_num, 1); register vector unsigned char pixelsv1, pixelsv2; register vector unsigned char pixelsv1B, pixelsv2B; register vector unsigned char pixelsv1C, pixelsv2C; @@ -622,7 +620,6 @@ POWERPC_PERF_DECLARE(altivec_put_pixels16_num, 1); register int line_size_3 = line_size + line_size_2; register int line_size_4 = line_size << 2; -POWERPC_PERF_START_COUNT(altivec_put_pixels16_num, 1); // hand-unrolling the loop by 4 gains about 15% // mininum execution time goes from 74 to 60 cycles // it's faster than -funroll-loops, but using @@ -659,20 +656,16 @@ POWERPC_PERF_START_COUNT(altivec_put_pixels16_num, 1); block +=line_size_4; } #endif -POWERPC_PERF_STOP_COUNT(altivec_put_pixels16_num, 1); } /* next one assumes that ((line_size % 16) == 0) */ #define op_avg(a,b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEUL)>>1) ) void avg_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) { -POWERPC_PERF_DECLARE(altivec_avg_pixels16_num, 1); register vector unsigned char pixelsv1, pixelsv2, pixelsv, blockv; register vector unsigned char perm = vec_lvsl(0, pixels); int i; -POWERPC_PERF_START_COUNT(altivec_avg_pixels16_num, 1); - for (i = 0; i < h; i++) { pixelsv1 = vec_ld( 0, pixels); pixelsv2 = vec_ld(16,pixels); @@ -683,19 +676,14 @@ POWERPC_PERF_START_COUNT(altivec_avg_pixels16_num, 1); pixels+=line_size; block +=line_size; } - -POWERPC_PERF_STOP_COUNT(altivec_avg_pixels16_num, 1); } /* next one assumes that ((line_size % 8) == 0) */ static void avg_pixels8_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h) { -POWERPC_PERF_DECLARE(altivec_avg_pixels8_num, 1); register vector unsigned char pixelsv1, pixelsv2, pixelsv, blockv; int i; -POWERPC_PERF_START_COUNT(altivec_avg_pixels8_num, 1); - for (i = 0; i < h; i++) { /* block is 8 bytes-aligned, so we're either in the left block (16 bytes-aligned) or in the right block (not) */ @@ -719,14 +707,11 @@ POWERPC_PERF_START_COUNT(altivec_avg_pixels8_num, 1); pixels += line_size; block += line_size; } - -POWERPC_PERF_STOP_COUNT(altivec_avg_pixels8_num, 1); } /* next one assumes that ((line_size % 8) == 0) */ static void put_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) { -POWERPC_PERF_DECLARE(altivec_put_pixels8_xy2_num, 1); register int i; register vector unsigned char pixelsv1, pixelsv2, pixelsavg; register vector unsigned char blockv, temp1, temp2; @@ -748,7 +733,6 @@ POWERPC_PERF_DECLARE(altivec_put_pixels8_xy2_num, 1); (vector unsigned short)pixelsv2); pixelssum1 = vec_add(pixelssum1, vctwo); -POWERPC_PERF_START_COUNT(altivec_put_pixels8_xy2_num, 1); for (i = 0; i < h ; i++) { int rightside = ((unsigned long)block & 0x0000000F); blockv = vec_ld(0, block); @@ -782,14 +766,11 @@ POWERPC_PERF_START_COUNT(altivec_put_pixels8_xy2_num, 1); block += line_size; pixels += line_size; } - -POWERPC_PERF_STOP_COUNT(altivec_put_pixels8_xy2_num, 1); } /* next one assumes that ((line_size % 8) == 0) */ static void put_no_rnd_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) { -POWERPC_PERF_DECLARE(altivec_put_no_rnd_pixels8_xy2_num, 1); register int i; register vector unsigned char pixelsv1, pixelsv2, pixelsavg; register vector unsigned char blockv, temp1, temp2; @@ -812,7 +793,6 @@ POWERPC_PERF_DECLARE(altivec_put_no_rnd_pixels8_xy2_num, 1); (vector unsigned short)pixelsv2); pixelssum1 = vec_add(pixelssum1, vcone); -POWERPC_PERF_START_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1); for (i = 0; i < h ; i++) { int rightside = ((unsigned long)block & 0x0000000F); blockv = vec_ld(0, block); @@ -846,14 +826,11 @@ POWERPC_PERF_START_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1); block += line_size; pixels += line_size; } - -POWERPC_PERF_STOP_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1); } /* next one assumes that ((line_size % 16) == 0) */ static void put_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h) { -POWERPC_PERF_DECLARE(altivec_put_pixels16_xy2_num, 1); register int i; register vector unsigned char pixelsv1, pixelsv2, pixelsv3, pixelsv4; register vector unsigned char blockv, temp1, temp2; @@ -862,8 +839,6 @@ POWERPC_PERF_DECLARE(altivec_put_pixels16_xy2_num, 1); register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0); register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2); -POWERPC_PERF_START_COUNT(altivec_put_pixels16_xy2_num, 1); - temp1 = vec_ld(0, pixels); temp2 = vec_ld(16, pixels); pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels)); @@ -919,14 +894,11 @@ POWERPC_PERF_START_COUNT(altivec_put_pixels16_xy2_num, 1); block += line_size; pixels += line_size; } - -POWERPC_PERF_STOP_COUNT(altivec_put_pixels16_xy2_num, 1); } /* next one assumes that ((line_size % 16) == 0) */ static void put_no_rnd_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h) { -POWERPC_PERF_DECLARE(altivec_put_no_rnd_pixels16_xy2_num, 1); register int i; register vector unsigned char pixelsv1, pixelsv2, pixelsv3, pixelsv4; register vector unsigned char blockv, temp1, temp2; @@ -936,8 +908,6 @@ POWERPC_PERF_DECLARE(altivec_put_no_rnd_pixels16_xy2_num, 1); register const vector unsigned short vcone = (const vector unsigned short)vec_splat_u16(1); register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2); -POWERPC_PERF_START_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1); - temp1 = vec_ld(0, pixels); temp2 = vec_ld(16, pixels); pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels)); @@ -993,18 +963,14 @@ POWERPC_PERF_START_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1); block += line_size; pixels += line_size; } - -POWERPC_PERF_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1); } static int hadamard8_diff8x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){ -POWERPC_PERF_DECLARE(altivec_hadamard8_diff8x8_num, 1); int sum; register const vector unsigned char vzero = (const vector unsigned char)vec_splat_u8(0); register vector signed short temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; -POWERPC_PERF_START_COUNT(altivec_hadamard8_diff8x8_num, 1); { register const vector signed short vprod1 =(const vector signed short) { 1,-1, 1,-1, 1,-1, 1,-1 }; @@ -1100,7 +1066,6 @@ POWERPC_PERF_START_COUNT(altivec_hadamard8_diff8x8_num, 1); vsum = vec_splat(vsum, 3); vec_ste(vsum, 0, &sum); } -POWERPC_PERF_STOP_COUNT(altivec_hadamard8_diff8x8_num, 1); return sum; } @@ -1319,16 +1284,13 @@ static int hadamard8_diff16x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, } static int hadamard8_diff16_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){ -POWERPC_PERF_DECLARE(altivec_hadamard8_diff16_num, 1); int score; -POWERPC_PERF_START_COUNT(altivec_hadamard8_diff16_num, 1); score = hadamard8_diff16x8_altivec(s, dst, src, stride, 8); if (h==16) { dst += 8*stride; src += 8*stride; score += hadamard8_diff16x8_altivec(s, dst, src, stride, 8); } -POWERPC_PERF_STOP_COUNT(altivec_hadamard8_diff16_num, 1); return score; } @@ -1358,7 +1320,6 @@ static void vorbis_inverse_coupling_altivec(float *mag, float *ang, /* next one assumes that ((line_size % 8) == 0) */ static void avg_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) { -POWERPC_PERF_DECLARE(altivec_avg_pixels8_xy2_num, 1); register int i; register vector unsigned char pixelsv1, pixelsv2, pixelsavg; register vector unsigned char blockv, temp1, temp2, blocktemp; @@ -1383,7 +1344,6 @@ POWERPC_PERF_DECLARE(altivec_avg_pixels8_xy2_num, 1); (vector unsigned short)pixelsv2); pixelssum1 = vec_add(pixelssum1, vctwo); -POWERPC_PERF_START_COUNT(altivec_avg_pixels8_xy2_num, 1); for (i = 0; i < h ; i++) { int rightside = ((unsigned long)block & 0x0000000F); blockv = vec_ld(0, block); @@ -1418,8 +1378,6 @@ POWERPC_PERF_START_COUNT(altivec_avg_pixels8_xy2_num, 1); block += line_size; pixels += line_size; } - -POWERPC_PERF_STOP_COUNT(altivec_avg_pixels8_xy2_num, 1); } void dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/dsputil_ppc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/dsputil_ppc.c index cf0ac39de..229ca0996 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/dsputil_ppc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/dsputil_ppc.c @@ -21,9 +21,6 @@ */ #include "libavcodec/dsputil.h" - -#include "dsputil_ppc.h" - #include "dsputil_altivec.h" int mm_flags = 0; @@ -39,63 +36,6 @@ int mm_support(void) return result; } -#if CONFIG_POWERPC_PERF -unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total]; -/* list below must match enum in dsputil_ppc.h */ -static unsigned char* perfname[] = { - "ff_fft_calc_altivec", - "gmc1_altivec", - "dct_unquantize_h263_altivec", - "fdct_altivec", - "idct_add_altivec", - "idct_put_altivec", - "put_pixels16_altivec", - "avg_pixels16_altivec", - "avg_pixels8_altivec", - "put_pixels8_xy2_altivec", - "put_no_rnd_pixels8_xy2_altivec", - "put_pixels16_xy2_altivec", - "put_no_rnd_pixels16_xy2_altivec", - "hadamard8_diff8x8_altivec", - "hadamard8_diff16_altivec", - "avg_pixels8_xy2_altivec", - "clear_blocks_dcbz32_ppc", - "clear_blocks_dcbz128_ppc", - "put_h264_chroma_mc8_altivec", - "avg_h264_chroma_mc8_altivec", - "put_h264_qpel16_h_lowpass_altivec", - "avg_h264_qpel16_h_lowpass_altivec", - "put_h264_qpel16_v_lowpass_altivec", - "avg_h264_qpel16_v_lowpass_altivec", - "put_h264_qpel16_hv_lowpass_altivec", - "avg_h264_qpel16_hv_lowpass_altivec", - "" -}; -#include -#endif - -#if CONFIG_POWERPC_PERF -void powerpc_display_perf_report(void) -{ - int i, j; - av_log(NULL, AV_LOG_INFO, "PowerPC performance report\n Values are from the PMC registers, and represent whatever the registers are set to record.\n"); - for(i = 0 ; i < powerpc_perf_total ; i++) { - for (j = 0; j < POWERPC_NUM_PMC_ENABLED ; j++) { - if (perfdata[j][i][powerpc_data_num] != (unsigned long long)0) - av_log(NULL, AV_LOG_INFO, - " Function \"%s\" (pmc%d):\n\tmin: %"PRIu64"\n\tmax: %"PRIu64"\n\tavg: %1.2lf (%"PRIu64")\n", - perfname[i], - j+1, - perfdata[j][i][powerpc_data_min], - perfdata[j][i][powerpc_data_max], - (double)perfdata[j][i][powerpc_data_sum] / - (double)perfdata[j][i][powerpc_data_num], - perfdata[j][i][powerpc_data_num]); - } - } -} -#endif /* CONFIG_POWERPC_PERF */ - /* ***** WARNING ***** WARNING ***** WARNING ***** */ /* clear_blocks_dcbz32_ppc will not work properly on PowerPC processors with a @@ -118,10 +58,8 @@ and */ static void clear_blocks_dcbz32_ppc(DCTELEM *blocks) { -POWERPC_PERF_DECLARE(powerpc_clear_blocks_dcbz32, 1); register int misal = ((unsigned long)blocks & 0x00000010); register int i = 0; -POWERPC_PERF_START_COUNT(powerpc_clear_blocks_dcbz32, 1); #if 1 if (misal) { ((unsigned long*)blocks)[0] = 0L; @@ -143,7 +81,6 @@ POWERPC_PERF_START_COUNT(powerpc_clear_blocks_dcbz32, 1); #else memset(blocks, 0, sizeof(DCTELEM)*6*64); #endif -POWERPC_PERF_STOP_COUNT(powerpc_clear_blocks_dcbz32, 1); } /* same as above, when dcbzl clear a whole 128B cache line @@ -151,10 +88,8 @@ POWERPC_PERF_STOP_COUNT(powerpc_clear_blocks_dcbz32, 1); #if HAVE_DCBZL static void clear_blocks_dcbz128_ppc(DCTELEM *blocks) { -POWERPC_PERF_DECLARE(powerpc_clear_blocks_dcbz128, 1); register int misal = ((unsigned long)blocks & 0x0000007f); register int i = 0; -POWERPC_PERF_START_COUNT(powerpc_clear_blocks_dcbz128, 1); #if 1 if (misal) { // we could probably also optimize this case, @@ -169,7 +104,6 @@ POWERPC_PERF_START_COUNT(powerpc_clear_blocks_dcbz128, 1); #else memset(blocks, 0, sizeof(DCTELEM)*6*64); #endif -POWERPC_PERF_STOP_COUNT(powerpc_clear_blocks_dcbz128, 1); } #else static void clear_blocks_dcbz128_ppc(DCTELEM *blocks) @@ -279,19 +213,6 @@ void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx) } } -#if CONFIG_POWERPC_PERF - { - int i, j; - for (i = 0 ; i < powerpc_perf_total ; i++) { - for (j = 0; j < POWERPC_NUM_PMC_ENABLED ; j++) { - perfdata[j][i][powerpc_data_min] = 0xFFFFFFFFFFFFFFFFULL; - perfdata[j][i][powerpc_data_max] = 0x0000000000000000ULL; - perfdata[j][i][powerpc_data_sum] = 0x0000000000000000ULL; - perfdata[j][i][powerpc_data_num] = 0x0000000000000000ULL; - } - } - } -#endif /* CONFIG_POWERPC_PERF */ } #endif /* HAVE_ALTIVEC */ } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/dsputil_ppc.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/dsputil_ppc.h deleted file mode 100644 index d028574f0..000000000 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/dsputil_ppc.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2003-2004 Romain Dolbeau - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_PPC_DSPUTIL_PPC_H -#define AVCODEC_PPC_DSPUTIL_PPC_H - -#include "config.h" - -#if CONFIG_POWERPC_PERF -void powerpc_display_perf_report(void); -/* the 604* have 2, the G3* have 4, the G4s have 6, - and the G5 are completely different (they MUST use - ARCH_PPC64, and let's hope all future 64 bis PPC - will use the same PMCs... */ -#define POWERPC_NUM_PMC_ENABLED 6 -/* if you add to the enum below, also add to the perfname array - in dsputil_ppc.c */ -enum powerpc_perf_index { - altivec_fft_num = 0, - altivec_gmc1_num, - altivec_dct_unquantize_h263_num, - altivec_fdct, - altivec_idct_add_num, - altivec_idct_put_num, - altivec_put_pixels16_num, - altivec_avg_pixels16_num, - altivec_avg_pixels8_num, - altivec_put_pixels8_xy2_num, - altivec_put_no_rnd_pixels8_xy2_num, - altivec_put_pixels16_xy2_num, - altivec_put_no_rnd_pixels16_xy2_num, - altivec_hadamard8_diff8x8_num, - altivec_hadamard8_diff16_num, - altivec_avg_pixels8_xy2_num, - powerpc_clear_blocks_dcbz32, - powerpc_clear_blocks_dcbz128, - altivec_put_h264_chroma_mc8_num, - altivec_avg_h264_chroma_mc8_num, - altivec_put_h264_qpel16_h_lowpass_num, - altivec_avg_h264_qpel16_h_lowpass_num, - altivec_put_h264_qpel16_v_lowpass_num, - altivec_avg_h264_qpel16_v_lowpass_num, - altivec_put_h264_qpel16_hv_lowpass_num, - altivec_avg_h264_qpel16_hv_lowpass_num, - powerpc_perf_total -}; -enum powerpc_data_index { - powerpc_data_min = 0, - powerpc_data_max, - powerpc_data_sum, - powerpc_data_num, - powerpc_data_total -}; -extern unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total]; - -#if !ARCH_PPC64 -#define POWERP_PMC_DATATYPE unsigned long -#define POWERPC_GET_PMC1(a) __asm__ volatile("mfspr %0, 937" : "=r" (a)) -#define POWERPC_GET_PMC2(a) __asm__ volatile("mfspr %0, 938" : "=r" (a)) -#if (POWERPC_NUM_PMC_ENABLED > 2) -#define POWERPC_GET_PMC3(a) __asm__ volatile("mfspr %0, 941" : "=r" (a)) -#define POWERPC_GET_PMC4(a) __asm__ volatile("mfspr %0, 942" : "=r" (a)) -#else -#define POWERPC_GET_PMC3(a) do {} while (0) -#define POWERPC_GET_PMC4(a) do {} while (0) -#endif -#if (POWERPC_NUM_PMC_ENABLED > 4) -#define POWERPC_GET_PMC5(a) __asm__ volatile("mfspr %0, 929" : "=r" (a)) -#define POWERPC_GET_PMC6(a) __asm__ volatile("mfspr %0, 930" : "=r" (a)) -#else -#define POWERPC_GET_PMC5(a) do {} while (0) -#define POWERPC_GET_PMC6(a) do {} while (0) -#endif -#else /* ARCH_PPC64 */ -#define POWERP_PMC_DATATYPE unsigned long long -#define POWERPC_GET_PMC1(a) __asm__ volatile("mfspr %0, 771" : "=r" (a)) -#define POWERPC_GET_PMC2(a) __asm__ volatile("mfspr %0, 772" : "=r" (a)) -#if (POWERPC_NUM_PMC_ENABLED > 2) -#define POWERPC_GET_PMC3(a) __asm__ volatile("mfspr %0, 773" : "=r" (a)) -#define POWERPC_GET_PMC4(a) __asm__ volatile("mfspr %0, 774" : "=r" (a)) -#else -#define POWERPC_GET_PMC3(a) do {} while (0) -#define POWERPC_GET_PMC4(a) do {} while (0) -#endif -#if (POWERPC_NUM_PMC_ENABLED > 4) -#define POWERPC_GET_PMC5(a) __asm__ volatile("mfspr %0, 775" : "=r" (a)) -#define POWERPC_GET_PMC6(a) __asm__ volatile("mfspr %0, 776" : "=r" (a)) -#else -#define POWERPC_GET_PMC5(a) do {} while (0) -#define POWERPC_GET_PMC6(a) do {} while (0) -#endif -#endif /* ARCH_PPC64 */ -#define POWERPC_PERF_DECLARE(a, cond) \ - POWERP_PMC_DATATYPE \ - pmc_start[POWERPC_NUM_PMC_ENABLED], \ - pmc_stop[POWERPC_NUM_PMC_ENABLED], \ - pmc_loop_index; -#define POWERPC_PERF_START_COUNT(a, cond) do { \ - POWERPC_GET_PMC6(pmc_start[5]); \ - POWERPC_GET_PMC5(pmc_start[4]); \ - POWERPC_GET_PMC4(pmc_start[3]); \ - POWERPC_GET_PMC3(pmc_start[2]); \ - POWERPC_GET_PMC2(pmc_start[1]); \ - POWERPC_GET_PMC1(pmc_start[0]); \ - } while (0) -#define POWERPC_PERF_STOP_COUNT(a, cond) do { \ - POWERPC_GET_PMC1(pmc_stop[0]); \ - POWERPC_GET_PMC2(pmc_stop[1]); \ - POWERPC_GET_PMC3(pmc_stop[2]); \ - POWERPC_GET_PMC4(pmc_stop[3]); \ - POWERPC_GET_PMC5(pmc_stop[4]); \ - POWERPC_GET_PMC6(pmc_stop[5]); \ - if (cond) { \ - for(pmc_loop_index = 0; \ - pmc_loop_index < POWERPC_NUM_PMC_ENABLED; \ - pmc_loop_index++) { \ - if (pmc_stop[pmc_loop_index] >= pmc_start[pmc_loop_index]) { \ - POWERP_PMC_DATATYPE diff = \ - pmc_stop[pmc_loop_index] - pmc_start[pmc_loop_index]; \ - if (diff < perfdata[pmc_loop_index][a][powerpc_data_min]) \ - perfdata[pmc_loop_index][a][powerpc_data_min] = diff; \ - if (diff > perfdata[pmc_loop_index][a][powerpc_data_max]) \ - perfdata[pmc_loop_index][a][powerpc_data_max] = diff; \ - perfdata[pmc_loop_index][a][powerpc_data_sum] += diff; \ - perfdata[pmc_loop_index][a][powerpc_data_num] ++; \ - } \ - } \ - } \ -} while (0) -#else /* CONFIG_POWERPC_PERF */ -// those are needed to avoid empty statements. -#define POWERPC_PERF_DECLARE(a, cond) int altivec_placeholder __attribute__ ((unused)) -#define POWERPC_PERF_START_COUNT(a, cond) do {} while (0) -#define POWERPC_PERF_STOP_COUNT(a, cond) do {} while (0) -#endif /* CONFIG_POWERPC_PERF */ - -#endif /* AVCODEC_PPC_DSPUTIL_PPC_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/fdct_altivec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/fdct_altivec.c index 8f3bc2694..6309a47f3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/fdct_altivec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/fdct_altivec.c @@ -24,7 +24,6 @@ #endif #include "libavutil/common.h" #include "libavcodec/dsputil.h" -#include "dsputil_ppc.h" #include "dsputil_altivec.h" #define vs16(v) ((vector signed short)(v)) @@ -198,7 +197,6 @@ static vector float fdctconsts[3] = { void fdct_altivec(int16_t *block) { -POWERPC_PERF_DECLARE(altivec_fdct, 1); vector signed short *bp; vector float *cp; vector float b00, b10, b20, b30, b40, b50, b60, b70; @@ -206,9 +204,6 @@ POWERPC_PERF_DECLARE(altivec_fdct, 1); vector float mzero, cnst, cnsts0, cnsts1, cnsts2; vector float x0, x1, x2, x3, x4, x5, x6, x7, x8; - POWERPC_PERF_START_COUNT(altivec_fdct, 1); - - /* setup constants {{{ */ /* mzero = -0.0 */ mzero = ((vector float)vec_splat_u32(-1)); @@ -487,8 +482,6 @@ POWERPC_PERF_DECLARE(altivec_fdct, 1); #undef CTS /* }}} */ - -POWERPC_PERF_STOP_COUNT(altivec_fdct, 1); } /* vim:set foldmethod=marker foldlevel=0: */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/fft_altivec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/fft_altivec.c index ce35ab602..ec610b0a4 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/fft_altivec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/fft_altivec.c @@ -1,8 +1,7 @@ /* * FFT/IFFT transforms * AltiVec-enabled - * Copyright (c) 2003 Romain Dolbeau - * Based on code Copyright (c) 2002 Fabrice Bellard + * Copyright (c) 2009 Loren Merritt * * This file is part of FFmpeg. * @@ -21,9 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavcodec/fft.h" -#include "dsputil_ppc.h" #include "util_altivec.h" -#include "dsputil_altivec.h" +#include "types_altivec.h" /** * Do a complex FFT with the parameters defined in ff_fft_init(). The @@ -32,112 +30,118 @@ * AltiVec-enabled * This code assumes that the 'z' pointer is 16 bytes-aligned * It also assumes all FFTComplex are 8 bytes-aligned pair of float - * The code is exactly the same as the SSE version, except - * that successive MUL + ADD/SUB have been merged into - * fused multiply-add ('vec_madd' in altivec) */ -static void ff_fft_calc_altivec(FFTContext *s, FFTComplex *z) -{ -POWERPC_PERF_DECLARE(altivec_fft_num, s->nbits >= 6); - register const vector float vczero = (const vector float)vec_splat_u32(0.); - - int ln = s->nbits; - int j, np, np2; - int nblocks, nloops; - register FFTComplex *p, *q; - FFTComplex *cptr, *cptr1; - int k; - -POWERPC_PERF_START_COUNT(altivec_fft_num, s->nbits >= 6); - - np = 1 << ln; - - { - vector float *r, a, b, a1, c1, c2; - - r = (vector float *)&z[0]; - c1 = vcii(p,p,n,n); +void ff_fft_calc_altivec(FFTContext *s, FFTComplex *z); +void ff_fft_calc_interleave_altivec(FFTContext *s, FFTComplex *z); - if (s->inverse) { - c2 = vcii(p,p,n,p); - } else { - c2 = vcii(p,p,p,n); - } - - j = (np >> 2); - do { - a = vec_ld(0, r); - a1 = vec_ld(sizeof(vector float), r); - - b = vec_perm(a,a,vcprmle(1,0,3,2)); - a = vec_madd(a,c1,b); - /* do the pass 0 butterfly */ - - b = vec_perm(a1,a1,vcprmle(1,0,3,2)); - b = vec_madd(a1,c1,b); - /* do the pass 0 butterfly */ - - /* multiply third by -i */ - b = vec_perm(b,b,vcprmle(2,3,1,0)); - - /* do the pass 1 butterfly */ - vec_st(vec_madd(b,c2,a), 0, r); - vec_st(vec_nmsub(b,c2,a), sizeof(vector float), r); - - r += 2; - } while (--j != 0); - } - /* pass 2 .. ln-1 */ - - nblocks = np >> 3; - nloops = 1 << 2; - np2 = np >> 1; - - cptr1 = s->exptab1; +#if HAVE_GNU_AS +static void ff_imdct_half_altivec(FFTContext *s, FFTSample *output, const FFTSample *input) +{ + int j, k; + int n = 1 << s->mdct_bits; + int n4 = n >> 2; + int n8 = n >> 3; + int n32 = n >> 5; + const uint16_t *revtabj = s->revtab; + const uint16_t *revtabk = s->revtab+n4; + const vec_f *tcos = (const vec_f*)(s->tcos+n8); + const vec_f *tsin = (const vec_f*)(s->tsin+n8); + const vec_f *pin = (const vec_f*)(input+n4); + vec_f *pout = (vec_f*)(output+n4); + + /* pre rotation */ + k = n32-1; do { - p = z; - q = z + nloops; - j = nblocks; - do { - cptr = cptr1; - k = nloops >> 1; - do { - vector float a,b,c,t1; - - a = vec_ld(0, (float*)p); - b = vec_ld(0, (float*)q); - - /* complex mul */ - c = vec_ld(0, (float*)cptr); - /* cre*re cim*re */ - t1 = vec_madd(c, vec_perm(b,b,vcprmle(2,2,0,0)),vczero); - c = vec_ld(sizeof(vector float), (float*)cptr); - /* -cim*im cre*im */ - b = vec_madd(c, vec_perm(b,b,vcprmle(3,3,1,1)),t1); - - /* butterfly */ - vec_st(vec_add(a,b), 0, (float*)p); - vec_st(vec_sub(a,b), 0, (float*)q); - - p += 2; - q += 2; - cptr += 4; - } while (--k); - - p += nloops; - q += nloops; - } while (--j); - cptr1 += nloops * 2; - nblocks = nblocks >> 1; - nloops = nloops << 1; - } while (nblocks != 0); + vec_f cos,sin,cos0,sin0,cos1,sin1,re,im,r0,i0,r1,i1,a,b,c,d; +#define CMULA(p,o0,o1,o2,o3)\ + a = pin[ k*2+p]; /* { z[k].re, z[k].im, z[k+1].re, z[k+1].im } */\ + b = pin[-k*2-p-1]; /* { z[-k-2].re, z[-k-2].im, z[-k-1].re, z[-k-1].im } */\ + re = vec_perm(a, b, vcprm(0,2,s0,s2)); /* { z[k].re, z[k+1].re, z[-k-2].re, z[-k-1].re } */\ + im = vec_perm(a, b, vcprm(s3,s1,3,1)); /* { z[-k-1].im, z[-k-2].im, z[k+1].im, z[k].im } */\ + cos = vec_perm(cos0, cos1, vcprm(o0,o1,s##o2,s##o3)); /* { cos[k], cos[k+1], cos[-k-2], cos[-k-1] } */\ + sin = vec_perm(sin0, sin1, vcprm(o0,o1,s##o2,s##o3));\ + r##p = im*cos - re*sin;\ + i##p = re*cos + im*sin; +#define STORE2(v,dst)\ + j = dst;\ + vec_ste(v, 0, output+j*2);\ + vec_ste(v, 4, output+j*2); +#define STORE8(p)\ + a = vec_perm(r##p, i##p, vcprm(0,s0,0,s0));\ + b = vec_perm(r##p, i##p, vcprm(1,s1,1,s1));\ + c = vec_perm(r##p, i##p, vcprm(2,s2,2,s2));\ + d = vec_perm(r##p, i##p, vcprm(3,s3,3,s3));\ + STORE2(a, revtabk[ p*2-4]);\ + STORE2(b, revtabk[ p*2-3]);\ + STORE2(c, revtabj[-p*2+2]);\ + STORE2(d, revtabj[-p*2+3]); + + cos0 = tcos[k]; + sin0 = tsin[k]; + cos1 = tcos[-k-1]; + sin1 = tsin[-k-1]; + CMULA(0, 0,1,2,3); + CMULA(1, 2,3,0,1); + STORE8(0); + STORE8(1); + revtabj += 4; + revtabk -= 4; + k--; + } while(k >= 0); + + ff_fft_calc_altivec(s, (FFTComplex*)output); + + /* post rotation + reordering */ + j = -n32; + k = n32-1; + do { + vec_f cos,sin,re,im,a,b,c,d; +#define CMULB(d0,d1,o)\ + re = pout[o*2];\ + im = pout[o*2+1];\ + cos = tcos[o];\ + sin = tsin[o];\ + d0 = im*sin - re*cos;\ + d1 = re*sin + im*cos; + + CMULB(a,b,j); + CMULB(c,d,k); + pout[2*j] = vec_perm(a, d, vcprm(0,s3,1,s2)); + pout[2*j+1] = vec_perm(a, d, vcprm(2,s1,3,s0)); + pout[2*k] = vec_perm(c, b, vcprm(0,s3,1,s2)); + pout[2*k+1] = vec_perm(c, b, vcprm(2,s1,3,s0)); + j++; + k--; + } while(k >= 0); +} -POWERPC_PERF_STOP_COUNT(altivec_fft_num, s->nbits >= 6); +static void ff_imdct_calc_altivec(FFTContext *s, FFTSample *output, const FFTSample *input) +{ + int k; + int n = 1 << s->mdct_bits; + int n4 = n >> 2; + int n16 = n >> 4; + vec_u32 sign = {1<<31,1<<31,1<<31,1<<31}; + vec_u32 *p0 = (vec_u32*)(output+n4); + vec_u32 *p1 = (vec_u32*)(output+n4*3); + + ff_imdct_half_altivec(s, output+n4, input); + + for (k = 0; k < n16; k++) { + vec_u32 a = p0[k] ^ sign; + vec_u32 b = p1[-k-1]; + p0[-k-1] = vec_perm(a, a, vcprm(3,2,1,0)); + p1[k] = vec_perm(b, b, vcprm(3,2,1,0)); + } } +#endif /* HAVE_GNU_AS */ av_cold void ff_fft_init_altivec(FFTContext *s) { - s->fft_calc = ff_fft_calc_altivec; - s->split_radix = 0; +#if HAVE_GNU_AS + s->fft_calc = ff_fft_calc_interleave_altivec; + s->imdct_calc = ff_imdct_calc_altivec; + s->imdct_half = ff_imdct_half_altivec; +#endif } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/fft_altivec_s.S b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/fft_altivec_s.S new file mode 100644 index 000000000..d17d033ba --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/fft_altivec_s.S @@ -0,0 +1,445 @@ +/* + * FFT transform with Altivec optimizations + * Copyright (c) 2009 Loren Merritt + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * These functions are not individually interchangeable with the C versions. + * While C takes arrays of FFTComplex, Altivec leaves intermediate results + * in blocks as convenient to the vector size. + * i.e. {4x real, 4x imaginary, 4x real, ...} + * + * I ignore standard calling convention. + * Instead, the following registers are treated as global constants: + * v14: zero + * v15..v18: cosines + * v19..v29: permutations + * r9: 16 + * r12: ff_cos_tabs + * and the rest are free for local use. + */ + +#include "config.h" +#include "asm.S" + +.text + +.macro addi2 ra, imm // add 32-bit immediate +.if \imm & 0xffff + addi \ra, \ra, \imm@l +.endif +.if (\imm+0x8000)>>16 + addis \ra, \ra, \imm@ha +.endif +.endm + +.macro FFT4 a0, a1, a2, a3 // in:0-1 out:2-3 + vperm \a2,\a0,\a1,v20 // vcprm(0,1,s2,s1) // {r0,i0,r3,i2} + vperm \a3,\a0,\a1,v21 // vcprm(2,3,s0,s3) // {r1,i1,r2,i3} + vaddfp \a0,\a2,\a3 // {t1,t2,t6,t5} + vsubfp \a1,\a2,\a3 // {t3,t4,t8,t7} + vmrghw \a2,\a0,\a1 // vcprm(0,s0,1,s1) // {t1,t3,t2,t4} + vperm \a3,\a0,\a1,v22 // vcprm(2,s3,3,s2) // {t6,t7,t5,t8} + vaddfp \a0,\a2,\a3 // {r0,r1,i0,i1} + vsubfp \a1,\a2,\a3 // {r2,r3,i2,i3} + vperm \a2,\a0,\a1,v23 // vcprm(0,1,s0,s1) // {r0,r1,r2,r3} + vperm \a3,\a0,\a1,v24 // vcprm(2,3,s2,s3) // {i0,i1,i2,i3} +.endm + +.macro FFT4x2 a0, a1, b0, b1, a2, a3, b2, b3 + vperm \a2,\a0,\a1,v20 // vcprm(0,1,s2,s1) // {r0,i0,r3,i2} + vperm \a3,\a0,\a1,v21 // vcprm(2,3,s0,s3) // {r1,i1,r2,i3} + vperm \b2,\b0,\b1,v20 + vperm \b3,\b0,\b1,v21 + vaddfp \a0,\a2,\a3 // {t1,t2,t6,t5} + vsubfp \a1,\a2,\a3 // {t3,t4,t8,t7} + vaddfp \b0,\b2,\b3 + vsubfp \b1,\b2,\b3 + vmrghw \a2,\a0,\a1 // vcprm(0,s0,1,s1) // {t1,t3,t2,t4} + vperm \a3,\a0,\a1,v22 // vcprm(2,s3,3,s2) // {t6,t7,t5,t8} + vmrghw \b2,\b0,\b1 + vperm \b3,\b0,\b1,v22 + vaddfp \a0,\a2,\a3 // {r0,r1,i0,i1} + vsubfp \a1,\a2,\a3 // {r2,r3,i2,i3} + vaddfp \b0,\b2,\b3 + vsubfp \b1,\b2,\b3 + vperm \a2,\a0,\a1,v23 // vcprm(0,1,s0,s1) // {r0,r1,r2,r3} + vperm \a3,\a0,\a1,v24 // vcprm(2,3,s2,s3) // {i0,i1,i2,i3} + vperm \b2,\b0,\b1,v23 + vperm \b3,\b0,\b1,v24 +.endm + +.macro FFT8 a0, a1, b0, b1, a2, a3, b2, b3, b4 // in,out:a0-b1 + vmrghw \b2,\b0,\b1 // vcprm(0,s0,1,s1) // {r4,r6,i4,i6} + vmrglw \b3,\b0,\b1 // vcprm(2,s2,3,s3) // {r5,r7,i5,i7} + vperm \a2,\a0,\a1,v20 // FFT4 ... + vperm \a3,\a0,\a1,v21 + vaddfp \b0,\b2,\b3 // {t1,t3,t2,t4} + vsubfp \b1,\b2,\b3 // {r5,r7,i5,i7} + vperm \b4,\b1,\b1,v25 // vcprm(2,3,0,1) // {i5,i7,r5,r7} + vaddfp \a0,\a2,\a3 + vsubfp \a1,\a2,\a3 + vmaddfp \b1,\b1,v17,v14 // * {-1,1,1,-1}/sqrt(2) + vmaddfp \b1,\b4,v18,\b1 // * { 1,1,1,1 }/sqrt(2) // {t8,ta,t7,t9} + vmrghw \a2,\a0,\a1 + vperm \a3,\a0,\a1,v22 + vperm \b2,\b0,\b1,v26 // vcprm(1,2,s3,s0) // {t3,t2,t9,t8} + vperm \b3,\b0,\b1,v27 // vcprm(0,3,s2,s1) // {t1,t4,t7,ta} + vaddfp \a0,\a2,\a3 + vsubfp \a1,\a2,\a3 + vaddfp \b0,\b2,\b3 // {t1,t2,t9,ta} + vsubfp \b1,\b2,\b3 // {t6,t5,tc,tb} + vperm \a2,\a0,\a1,v23 + vperm \a3,\a0,\a1,v24 + vperm \b2,\b0,\b1,v28 // vcprm(0,2,s1,s3) // {t1,t9,t5,tb} + vperm \b3,\b0,\b1,v29 // vcprm(1,3,s0,s2) // {t2,ta,t6,tc} + vsubfp \b0,\a2,\b2 // {r4,r5,r6,r7} + vsubfp \b1,\a3,\b3 // {i4,i5,i6,i7} + vaddfp \a0,\a2,\b2 // {r0,r1,r2,r3} + vaddfp \a1,\a3,\b3 // {i0,i1,i2,i3} +.endm + +.macro BF d0,d1,s0,s1 + vsubfp \d1,\s0,\s1 + vaddfp \d0,\s0,\s1 +.endm + +.macro zip d0,d1,s0,s1 + vmrghw \d0,\s0,\s1 + vmrglw \d1,\s0,\s1 +.endm + +.macro def_fft4 interleave +fft4\interleave\()_altivec: + lvx v0, 0,r3 + lvx v1,r9,r3 + FFT4 v0,v1,v2,v3 +.ifnb \interleave + zip v0,v1,v2,v3 + stvx v0, 0,r3 + stvx v1,r9,r3 +.else + stvx v2, 0,r3 + stvx v3,r9,r3 +.endif + blr +.endm + +.macro def_fft8 interleave +fft8\interleave\()_altivec: + addi r4,r3,32 + lvx v0, 0,r3 + lvx v1,r9,r3 + lvx v2, 0,r4 + lvx v3,r9,r4 + FFT8 v0,v1,v2,v3,v4,v5,v6,v7,v8 +.ifnb \interleave + zip v4,v5,v0,v1 + zip v6,v7,v2,v3 + stvx v4, 0,r3 + stvx v5,r9,r3 + stvx v6, 0,r4 + stvx v7,r9,r4 +.else + stvx v0, 0,r3 + stvx v1,r9,r3 + stvx v2, 0,r4 + stvx v3,r9,r4 +.endif + blr +.endm + +.macro def_fft16 interleave +fft16\interleave\()_altivec: + addi r5,r3,64 + addi r6,r3,96 + addi r4,r3,32 + lvx v0, 0,r5 + lvx v1,r9,r5 + lvx v2, 0,r6 + lvx v3,r9,r6 + FFT4x2 v0,v1,v2,v3,v4,v5,v6,v7 + lvx v0, 0,r3 + lvx v1,r9,r3 + lvx v2, 0,r4 + lvx v3,r9,r4 + FFT8 v0,v1,v2,v3,v8,v9,v10,v11,v12 + vmaddfp v8,v4,v15,v14 // r2*wre + vmaddfp v9,v5,v15,v14 // i2*wre + vmaddfp v10,v6,v15,v14 // r3*wre + vmaddfp v11,v7,v15,v14 // i3*wre + vmaddfp v8,v5,v16,v8 // i2*wim + vnmsubfp v9,v4,v16,v9 // r2*wim + vnmsubfp v10,v7,v16,v10 // i3*wim + vmaddfp v11,v6,v16,v11 // r3*wim + BF v10,v12,v10,v8 + BF v11,v13,v9,v11 + BF v0,v4,v0,v10 + BF v3,v7,v3,v12 + BF v1,v5,v1,v11 + BF v2,v6,v2,v13 +.ifnb \interleave + zip v8, v9,v0,v1 + zip v10,v11,v2,v3 + zip v12,v13,v4,v5 + zip v14,v15,v6,v7 + stvx v8, 0,r3 + stvx v9,r9,r3 + stvx v10, 0,r4 + stvx v11,r9,r4 + stvx v12, 0,r5 + stvx v13,r9,r5 + stvx v14, 0,r6 + stvx v15,r9,r6 +.else + stvx v0, 0,r3 + stvx v4, 0,r5 + stvx v3,r9,r4 + stvx v7,r9,r6 + stvx v1,r9,r3 + stvx v5,r9,r5 + stvx v2, 0,r4 + stvx v6, 0,r6 +.endif + blr +.endm + +// void pass(float *z, float *wre, int n) +.macro PASS interleave, suffix +fft_pass\suffix\()_altivec: + mtctr r5 + slwi r0,r5,4 + slwi r7,r5,6 // o2 + slwi r5,r5,5 // o1 + add r10,r5,r7 // o3 + add r0,r4,r0 // wim + addi r6,r5,16 // o1+16 + addi r8,r7,16 // o2+16 + addi r11,r10,16 // o3+16 +1: + lvx v8, 0,r4 // wre + lvx v10, 0,r0 // wim + sub r0,r0,r9 + lvx v9, 0,r0 + vperm v9,v9,v10,v19 // vcprm(s0,3,2,1) => wim[0 .. -3] + lvx v4,r3,r7 // r2 = z[o2] + lvx v5,r3,r8 // i2 = z[o2+16] + lvx v6,r3,r10 // r3 = z[o3] + lvx v7,r3,r11 // i3 = z[o3+16] + vmaddfp v10,v4,v8,v14 // r2*wre + vmaddfp v11,v5,v8,v14 // i2*wre + vmaddfp v12,v6,v8,v14 // r3*wre + vmaddfp v13,v7,v8,v14 // i3*wre + lvx v0, 0,r3 // r0 = z[0] + lvx v3,r3,r6 // i1 = z[o1+16] + vmaddfp v10,v5,v9,v10 // i2*wim + vnmsubfp v11,v4,v9,v11 // r2*wim + vnmsubfp v12,v7,v9,v12 // i3*wim + vmaddfp v13,v6,v9,v13 // r3*wim + lvx v1,r3,r9 // i0 = z[16] + lvx v2,r3,r5 // r1 = z[o1] + BF v12,v8,v12,v10 + BF v13,v9,v11,v13 + BF v0,v4,v0,v12 + BF v3,v7,v3,v8 +.if !\interleave + stvx v0, 0,r3 + stvx v4,r3,r7 + stvx v3,r3,r6 + stvx v7,r3,r11 +.endif + BF v1,v5,v1,v13 + BF v2,v6,v2,v9 +.if !\interleave + stvx v1,r3,r9 + stvx v2,r3,r5 + stvx v5,r3,r8 + stvx v6,r3,r10 +.else + vmrghw v8,v0,v1 + vmrglw v9,v0,v1 + stvx v8, 0,r3 + stvx v9,r3,r9 + vmrghw v8,v2,v3 + vmrglw v9,v2,v3 + stvx v8,r3,r5 + stvx v9,r3,r6 + vmrghw v8,v4,v5 + vmrglw v9,v4,v5 + stvx v8,r3,r7 + stvx v9,r3,r8 + vmrghw v8,v6,v7 + vmrglw v9,v6,v7 + stvx v8,r3,r10 + stvx v9,r3,r11 +.endif + addi r3,r3,32 + addi r4,r4,16 + bdnz 1b + sub r3,r3,r5 + blr +.endm + +#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ + +#define WORD_0 0x00,0x01,0x02,0x03 +#define WORD_1 0x04,0x05,0x06,0x07 +#define WORD_2 0x08,0x09,0x0a,0x0b +#define WORD_3 0x0c,0x0d,0x0e,0x0f +#define WORD_s0 0x10,0x11,0x12,0x13 +#define WORD_s1 0x14,0x15,0x16,0x17 +#define WORD_s2 0x18,0x19,0x1a,0x1b +#define WORD_s3 0x1c,0x1d,0x1e,0x1f + +#define vcprm(a, b, c, d) .byte WORD_##a, WORD_##b, WORD_##c, WORD_##d + + .rodata + .align 4 +fft_data: + .float 0, 0, 0, 0 + .float 1, 0.92387953, M_SQRT1_2, 0.38268343 + .float 0, 0.38268343, M_SQRT1_2, 0.92387953 + .float -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2,-M_SQRT1_2 + .float M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2 + vcprm(s0,3,2,1) + vcprm(0,1,s2,s1) + vcprm(2,3,s0,s3) + vcprm(2,s3,3,s2) + vcprm(0,1,s0,s1) + vcprm(2,3,s2,s3) + vcprm(2,3,0,1) + vcprm(1,2,s3,s0) + vcprm(0,3,s2,s1) + vcprm(0,2,s1,s3) + vcprm(1,3,s0,s2) + +.macro lvm b, r, regs:vararg + lvx \r, 0, \b + addi \b, \b, 16 + .ifnb \regs + lvm \b, \regs + .endif +.endm + +.macro stvm b, r, regs:vararg + stvx \r, 0, \b + addi \b, \b, 16 + .ifnb \regs + stvm \b, \regs + .endif +.endm + +.macro fft_calc interleave +extfunc ff_fft_calc\interleave\()_altivec + mflr r0 + stp r0, 2*PS(r1) + stpu r1, -(160+16*PS)(r1) + addi r6, r1, 16*PS + stvm r6, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29 + mfvrsave r0 + stw r0, 15*PS(r1) + li r6, 0xfffffffc + mtvrsave r6 + + movrel r6, fft_data + lvm r6, v14, v15, v16, v17, v18, v19, v20, v21 + lvm r6, v22, v23, v24, v25, v26, v27, v28, v29 + + li r9, 16 + movrel r12, X(ff_cos_tabs) + + movrel r6, fft_dispatch_tab\interleave\()_altivec + lwz r3, 0(r3) + subi r3, r3, 2 + slwi r3, r3, 2+ARCH_PPC64 + lpx r3, r3, r6 + mtctr r3 + mr r3, r4 + bctrl + + addi r6, r1, 16*PS + lvm r6, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29 + lwz r6, 15*PS(r1) + mtvrsave r6 + lp r1, 0(r1) + lp r0, 2*PS(r1) + mtlr r0 + blr +.endm + +.macro DECL_FFT suffix, bits, n, n2, n4 +fft\n\suffix\()_altivec: + mflr r0 + stp r0,PS*(\bits-3)(r1) + bl fft\n2\()_altivec + addi2 r3,\n*4 + bl fft\n4\()_altivec + addi2 r3,\n*2 + bl fft\n4\()_altivec + addi2 r3,\n*-6 + lp r0,PS*(\bits-3)(r1) + lp r4,\bits*PS(r12) + mtlr r0 + li r5,\n/16 + b fft_pass\suffix\()_altivec +.endm + +.macro DECL_FFTS interleave, suffix + .text + def_fft4 \suffix + def_fft8 \suffix + def_fft16 \suffix + PASS \interleave, \suffix + DECL_FFT \suffix, 5, 32, 16, 8 + DECL_FFT \suffix, 6, 64, 32, 16 + DECL_FFT \suffix, 7, 128, 64, 32 + DECL_FFT \suffix, 8, 256, 128, 64 + DECL_FFT \suffix, 9, 512, 256, 128 + DECL_FFT \suffix,10, 1024, 512, 256 + DECL_FFT \suffix,11, 2048, 1024, 512 + DECL_FFT \suffix,12, 4096, 2048, 1024 + DECL_FFT \suffix,13, 8192, 4096, 2048 + DECL_FFT \suffix,14,16384, 8192, 4096 + DECL_FFT \suffix,15,32768,16384, 8192 + DECL_FFT \suffix,16,65536,32768,16384 + + fft_calc \suffix + + .rodata + .align 3 +fft_dispatch_tab\suffix\()_altivec: + PTR fft4\suffix\()_altivec + PTR fft8\suffix\()_altivec + PTR fft16\suffix\()_altivec + PTR fft32\suffix\()_altivec + PTR fft64\suffix\()_altivec + PTR fft128\suffix\()_altivec + PTR fft256\suffix\()_altivec + PTR fft512\suffix\()_altivec + PTR fft1024\suffix\()_altivec + PTR fft2048\suffix\()_altivec + PTR fft4096\suffix\()_altivec + PTR fft8192\suffix\()_altivec + PTR fft16384\suffix\()_altivec + PTR fft32768\suffix\()_altivec + PTR fft65536\suffix\()_altivec +.endm + +DECL_FFTS 0 +DECL_FFTS 1, _interleave diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/gmc_altivec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/gmc_altivec.c index fa71047b7..0e93c337f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/gmc_altivec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/gmc_altivec.c @@ -21,7 +21,6 @@ */ #include "libavcodec/dsputil.h" -#include "dsputil_ppc.h" #include "util_altivec.h" #include "types_altivec.h" #include "dsputil_altivec.h" @@ -30,10 +29,8 @@ altivec-enhanced gmc1. ATM this code assume stride is a multiple of 8, to preserve proper dst alignment. */ -#define GMC1_PERF_COND (h==8) void gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */, int stride, int h, int x16, int y16, int rounder) { -POWERPC_PERF_DECLARE(altivec_gmc1_num, GMC1_PERF_COND); const DECLARE_ALIGNED(16, unsigned short, rounder_a) = rounder; const DECLARE_ALIGNED(16, unsigned short, ABCD)[8] = { @@ -51,9 +48,6 @@ POWERPC_PERF_DECLARE(altivec_gmc1_num, GMC1_PERF_COND); unsigned long dst_odd = (unsigned long)dst & 0x0000000F; unsigned long src_really_odd = (unsigned long)src & 0x0000000F; - -POWERPC_PERF_START_COUNT(altivec_gmc1_num, GMC1_PERF_COND); - tempA = vec_ld(0, (unsigned short*)ABCD); Av = vec_splat(tempA, 0); Bv = vec_splat(tempA, 1); @@ -133,6 +127,4 @@ POWERPC_PERF_START_COUNT(altivec_gmc1_num, GMC1_PERF_COND); dst += stride; src += stride; } - -POWERPC_PERF_STOP_COUNT(altivec_gmc1_num, GMC1_PERF_COND); } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/h264_altivec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/h264_altivec.c index 47e416b82..c9c29442c 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/h264_altivec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/h264_altivec.c @@ -22,7 +22,6 @@ #include "libavcodec/h264data.h" #include "libavcodec/h264dsp.h" -#include "dsputil_ppc.h" #include "dsputil_altivec.h" #include "util_altivec.h" #include "types_altivec.h" diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/h264_template_altivec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/h264_template_altivec.c index c0a4eb7a6..8cf39c8be 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/h264_template_altivec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/h264_template_altivec.c @@ -77,7 +77,6 @@ static void PREFIX_h264_chroma_mc8_altivec(uint8_t * dst, uint8_t * src, int stride, int h, int x, int y) { - POWERPC_PERF_DECLARE(PREFIX_h264_chroma_mc8_num, 1); DECLARE_ALIGNED(16, signed int, ABCD)[4] = {((8 - x) * (8 - y)), (( x) * (8 - y)), @@ -103,8 +102,6 @@ static void PREFIX_h264_chroma_mc8_altivec(uint8_t * dst, uint8_t * src, vec_s16 vsrc2ssH, vsrc3ssH, psum; vec_u8 vdst, ppsum, vfdst, fsum; - POWERPC_PERF_START_COUNT(PREFIX_h264_chroma_mc8_num, 1); - if (((unsigned long)dst) % 16 == 0) { fperm = (vec_u8){0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, @@ -203,7 +200,6 @@ static void PREFIX_h264_chroma_mc8_altivec(uint8_t * dst, uint8_t * src, } } } - POWERPC_PERF_STOP_COUNT(PREFIX_h264_chroma_mc8_num, 1); } /* this code assume that stride % 16 == 0 */ @@ -295,7 +291,6 @@ static void PREFIX_no_rnd_vc1_chroma_mc8_altivec(uint8_t * dst, uint8_t * src, i /* this code assume stride % 16 == 0 */ static void PREFIX_h264_qpel16_h_lowpass_altivec(uint8_t * dst, uint8_t * src, int dstStride, int srcStride) { - POWERPC_PERF_DECLARE(PREFIX_h264_qpel16_h_lowpass_num, 1); register int i; LOAD_ZERO; @@ -323,8 +318,6 @@ static void PREFIX_h264_qpel16_h_lowpass_altivec(uint8_t * dst, uint8_t * src, i vec_u8 sum, vdst, fsum; - POWERPC_PERF_START_COUNT(PREFIX_h264_qpel16_h_lowpass_num, 1); - for (i = 0 ; i < 16 ; i ++) { vec_u8 srcR1 = vec_ld(-2, src); vec_u8 srcR2 = vec_ld(14, src); @@ -433,13 +426,10 @@ static void PREFIX_h264_qpel16_h_lowpass_altivec(uint8_t * dst, uint8_t * src, i src += srcStride; dst += dstStride; } - POWERPC_PERF_STOP_COUNT(PREFIX_h264_qpel16_h_lowpass_num, 1); } /* this code assume stride % 16 == 0 */ static void PREFIX_h264_qpel16_v_lowpass_altivec(uint8_t * dst, uint8_t * src, int dstStride, int srcStride) { - POWERPC_PERF_DECLARE(PREFIX_h264_qpel16_v_lowpass_num, 1); - register int i; LOAD_ZERO; @@ -490,8 +480,6 @@ static void PREFIX_h264_qpel16_v_lowpass_altivec(uint8_t * dst, uint8_t * src, i vec_u8 sum, vdst, fsum, srcP3a, srcP3b, srcP3; - POWERPC_PERF_START_COUNT(PREFIX_h264_qpel16_v_lowpass_num, 1); - for (i = 0 ; i < 16 ; i++) { srcP3a = vec_ld(0, srcbis += srcStride); srcP3b = vec_ld(16, srcbis); @@ -544,12 +532,10 @@ static void PREFIX_h264_qpel16_v_lowpass_altivec(uint8_t * dst, uint8_t * src, i dst += dstStride; } - POWERPC_PERF_STOP_COUNT(PREFIX_h264_qpel16_v_lowpass_num, 1); } /* this code assume stride % 16 == 0 *and* tmp is properly aligned */ static void PREFIX_h264_qpel16_hv_lowpass_altivec(uint8_t * dst, int16_t * tmp, uint8_t * src, int dstStride, int tmpStride, int srcStride) { - POWERPC_PERF_DECLARE(PREFIX_h264_qpel16_hv_lowpass_num, 1); register int i; LOAD_ZERO; const vec_u8 permM2 = vec_lvsl(-2, src); @@ -589,7 +575,6 @@ static void PREFIX_h264_qpel16_hv_lowpass_altivec(uint8_t * dst, int16_t * tmp, vec_u8 fsum, sumv, sum, vdst; vec_s16 ssume, ssumo; - POWERPC_PERF_START_COUNT(PREFIX_h264_qpel16_hv_lowpass_num, 1); src -= (2 * srcStride); for (i = 0 ; i < 21 ; i ++) { vec_u8 srcM2, srcM1, srcP0, srcP1, srcP2, srcP3; @@ -779,5 +764,4 @@ static void PREFIX_h264_qpel16_hv_lowpass_altivec(uint8_t * dst, int16_t * tmp, dst += dstStride; } - POWERPC_PERF_STOP_COUNT(PREFIX_h264_qpel16_hv_lowpass_num, 1); } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/idct_altivec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/idct_altivec.c index 7c6b79e9c..d65ba24f3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/idct_altivec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/idct_altivec.c @@ -43,7 +43,6 @@ #endif #include "libavcodec/dsputil.h" #include "types_altivec.h" -#include "dsputil_ppc.h" #include "dsputil_altivec.h" #define IDCT_HALF \ @@ -161,13 +160,9 @@ static const vec_s16 constants[5] = { void idct_put_altivec(uint8_t* dest, int stride, int16_t *blk) { -POWERPC_PERF_DECLARE(altivec_idct_put_num, 1); vec_s16 *block = (vec_s16*)blk; vec_u8 tmp; -#if CONFIG_POWERPC_PERF -POWERPC_PERF_START_COUNT(altivec_idct_put_num, 1); -#endif IDCT #define COPY(dest,src) \ @@ -183,13 +178,10 @@ POWERPC_PERF_START_COUNT(altivec_idct_put_num, 1); COPY (dest, vx5) dest += stride; COPY (dest, vx6) dest += stride; COPY (dest, vx7) - -POWERPC_PERF_STOP_COUNT(altivec_idct_put_num, 1); } void idct_add_altivec(uint8_t* dest, int stride, int16_t *blk) { -POWERPC_PERF_DECLARE(altivec_idct_add_num, 1); vec_s16 *block = (vec_s16*)blk; vec_u8 tmp; vec_s16 tmp2, tmp3; @@ -197,10 +189,6 @@ POWERPC_PERF_DECLARE(altivec_idct_add_num, 1); vec_u8 perm1; vec_u8 p0, p1, p; -#if CONFIG_POWERPC_PERF -POWERPC_PERF_START_COUNT(altivec_idct_add_num, 1); -#endif - IDCT p0 = vec_lvsl (0, dest); @@ -226,7 +214,5 @@ POWERPC_PERF_START_COUNT(altivec_idct_add_num, 1); ADD (dest, vx5, perm1) dest += stride; ADD (dest, vx6, perm0) dest += stride; ADD (dest, vx7, perm1) - -POWERPC_PERF_STOP_COUNT(altivec_idct_add_num, 1); } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/int_altivec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/int_altivec.c index 7fb11ddd9..61c18c815 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/int_altivec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/int_altivec.c @@ -79,7 +79,7 @@ static int ssd_int8_vs_int16_altivec(const int8_t *pix1, const int16_t *pix2, return u.score[3]; } -static int32_t scalarproduct_int16_altivec(int16_t * v1, int16_t * v2, int order, const int shift) +static int32_t scalarproduct_int16_altivec(const int16_t * v1, const int16_t * v2, int order, const int shift) { int i; LOAD_ZERO; @@ -109,7 +109,7 @@ static int32_t scalarproduct_int16_altivec(int16_t * v1, int16_t * v2, int order return ires; } -static int32_t scalarproduct_and_madd_int16_altivec(int16_t *v1, int16_t *v2, int16_t *v3, int order, int mul) +static int32_t scalarproduct_and_madd_int16_altivec(int16_t *v1, const int16_t *v2, const int16_t *v3, int order, int mul) { LOAD_ZERO; vec_s16 *pv1 = (vec_s16*)v1; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/mpegaudiodec_altivec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/mpegaudiodec_altivec.c new file mode 100644 index 000000000..e087d4add --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/mpegaudiodec_altivec.c @@ -0,0 +1,130 @@ +/* + * Altivec optimized MP3 decoding functions + * Copyright (c) 2010 Vitor Sessak + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "dsputil_altivec.h" +#include "util_altivec.h" + +#define CONFIG_FLOAT 1 +#include "libavcodec/mpegaudio.h" + +#define MACS(rt, ra, rb) rt+=(ra)*(rb) +#define MLSS(rt, ra, rb) rt-=(ra)*(rb) + +#define SUM8(op, sum, w, p) \ +{ \ + op(sum, (w)[0 * 64], (p)[0 * 64]); \ + op(sum, (w)[1 * 64], (p)[1 * 64]); \ + op(sum, (w)[2 * 64], (p)[2 * 64]); \ + op(sum, (w)[3 * 64], (p)[3 * 64]); \ + op(sum, (w)[4 * 64], (p)[4 * 64]); \ + op(sum, (w)[5 * 64], (p)[5 * 64]); \ + op(sum, (w)[6 * 64], (p)[6 * 64]); \ + op(sum, (w)[7 * 64], (p)[7 * 64]); \ +} + +static void apply_window(const float *buf, const float *win1, + const float *win2, float *sum1, float *sum2, int len) +{ + const vector float *win1a = (const vector float *) win1; + const vector float *win2a = (const vector float *) win2; + const vector float *bufa = (const vector float *) buf; + vector float *sum1a = (vector float *) sum1; + vector float *sum2a = (vector float *) sum2; + vector float av_uninit(v0), av_uninit(v4); + vector float v1, v2, v3; + + len = len >> 2; + +#define MULT(a, b) \ + { \ + v1 = vec_ld(a, win1a); \ + v2 = vec_ld(b, win2a); \ + v3 = vec_ld(a, bufa); \ + v0 = vec_madd(v3, v1, v0); \ + v4 = vec_madd(v2, v3, v4); \ + } + + while (len--) { + v0 = vec_xor(v0, v0); + v4 = vec_xor(v4, v4); + + MULT( 0, 0); + MULT( 256, 64); + MULT( 512, 128); + MULT( 768, 192); + MULT(1024, 256); + MULT(1280, 320); + MULT(1536, 384); + MULT(1792, 448); + + vec_st(v0, 0, sum1a); + vec_st(v4, 0, sum2a); + sum1a++; + sum2a++; + win1a++; + win2a++; + bufa++; + } +} + +static void apply_window_mp3(float *in, float *win, int *unused, float *out, + int incr) +{ + LOCAL_ALIGNED_16(float, suma, [17]); + LOCAL_ALIGNED_16(float, sumb, [17]); + LOCAL_ALIGNED_16(float, sumc, [17]); + LOCAL_ALIGNED_16(float, sumd, [17]); + + float sum; + int j; + float *out2 = out + 32 * incr; + + /* copy to avoid wrap */ + memcpy(in + 512, in, 32 * sizeof(*in)); + + apply_window(in + 16, win , win + 512, suma, sumc, 16); + apply_window(in + 32, win + 48, win + 640, sumb, sumd, 16); + + SUM8(MLSS, suma[0], win + 32, in + 48); + + sumc[ 0] = 0; + sumb[16] = 0; + sumd[16] = 0; + + out[0 ] = suma[ 0]; + out += incr; + out2 -= incr; + for(j=1;j<16;j++) { + *out = suma[ j] - sumd[16-j]; + *out2 = -sumb[16-j] - sumc[ j]; + out += incr; + out2 -= incr; + } + + sum = 0; + SUM8(MLSS, sum, win + 16 + 32, in + 32); + *out = sum; +} + +void ff_mpegaudiodec_init_altivec(MPADecodeContext *s) +{ + s->apply_window_mp3 = apply_window_mp3; +} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/mpegvideo_altivec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/mpegvideo_altivec.c index 07e63be47..0126b7f42 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/mpegvideo_altivec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/mpegvideo_altivec.c @@ -26,7 +26,6 @@ #include "libavcodec/dsputil.h" #include "libavcodec/mpegvideo.h" -#include "dsputil_ppc.h" #include "util_altivec.h" #include "types_altivec.h" #include "dsputil_altivec.h" @@ -479,14 +478,11 @@ static int dct_quantize_altivec(MpegEncContext* s, static void dct_unquantize_h263_altivec(MpegEncContext *s, DCTELEM *block, int n, int qscale) { -POWERPC_PERF_DECLARE(altivec_dct_unquantize_h263_num, 1); int i, level, qmul, qadd; int nCoeffs; assert(s->block_last_index[n]>=0); -POWERPC_PERF_START_COUNT(altivec_dct_unquantize_h263_num, 1); - qadd = (qscale - 1) | 1; qmul = qscale << 1; @@ -569,7 +565,6 @@ POWERPC_PERF_START_COUNT(altivec_dct_unquantize_h263_num, 1); block[0] = backup_0; } } -POWERPC_PERF_STOP_COUNT(altivec_dct_unquantize_h263_num, nCoeffs == 63); } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/regs.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/regs.h new file mode 100644 index 000000000..63861f28f --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/regs.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2010 Mans Rullgard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_PPC_REGS_H +#define AVCODEC_PPC_REGS_H + +#include "libavutil/avutil.h" +#include "config.h" + +#if HAVE_IBM_ASM +# define r(n) AV_TOSTRING(n) +# define f(n) AV_TOSTRING(n) +# define v(n) AV_TOSTRING(n) +#else +# define r(n) AV_TOSTRING(r ## n) +# define f(n) AV_TOSTRING(f ## n) +# define v(n) AV_TOSTRING(v ## n) +#endif + +#endif /* AVCODEC_PPC_REGS_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/types_altivec.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/types_altivec.h index 2870e83e7..36b6e1f38 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/types_altivec.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/types_altivec.h @@ -30,6 +30,7 @@ #define vec_s16 vector signed short #define vec_u32 vector unsigned int #define vec_s32 vector signed int +#define vec_f vector float /*********************************************************************** * Null vector diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/util_altivec.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/util_altivec.h index 62f228a27..cb638dff0 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/util_altivec.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/util_altivec.h @@ -32,6 +32,8 @@ #include #endif +#include "types_altivec.h" + // used to build registers permutation vectors (vcprm) // the 's' are for words in the _s_econd vector #define WORD_0 0x00,0x01,0x02,0x03 @@ -102,4 +104,15 @@ static inline vector unsigned char unaligned_load(int offset, uint8_t *src) return vec_perm(first, second, mask); } +/** + * loads vector known misalignment + * @param perm_vec the align permute vector to combine the two loads from lvsl + */ +static inline vec_u8 load_with_perm_vec(int offset, uint8_t *src, vec_u8 perm_vec) +{ + vec_u8 a = vec_ld(offset, src); + vec_u8 b = vec_ld(offset+15, src); + return vec_perm(a, b, perm_vec); +} + #endif /* AVCODEC_PPC_UTIL_ALTIVEC_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c new file mode 100644 index 000000000..f7b3cda7a --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ppc/vp8dsp_altivec.c @@ -0,0 +1,295 @@ +/** + * VP8 compatible video decoder + * + * Copyright (C) 2010 David Conrad + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/vp8dsp.h" +#include "dsputil_altivec.h" +#include "types_altivec.h" +#include "util_altivec.h" + +#define REPT4(...) { __VA_ARGS__, __VA_ARGS__, __VA_ARGS__, __VA_ARGS__ } + +// h subpel filter uses msum to multiply+add 4 pixel taps at once +static const vec_s8 h_subpel_filters_inner[7] = +{ + REPT4( -6, 123, 12, -1), + REPT4(-11, 108, 36, -8), + REPT4( -9, 93, 50, -6), + REPT4(-16, 77, 77, -16), + REPT4( -6, 50, 93, -9), + REPT4( -8, 36, 108, -11), + REPT4( -1, 12, 123, -6), +}; + +// for 6tap filters, these are the outer two taps +// The zeros mask off pixels 4-7 when filtering 0-3 +// and vice-versa +static const vec_s8 h_subpel_filters_outer[3] = +{ + REPT4(0, 0, 2, 1), + REPT4(0, 0, 3, 3), + REPT4(0, 0, 1, 2), +}; + +#define LOAD_H_SUBPEL_FILTER(i) \ + vec_s8 filter_inner = h_subpel_filters_inner[i]; \ + vec_s8 filter_outerh = h_subpel_filters_outer[(i)>>1]; \ + vec_s8 filter_outerl = vec_sld(filter_outerh, filter_outerh, 2) + +#define FILTER_H(dstv, off) \ + a = vec_ld((off)-2, src); \ + b = vec_ld((off)-2+15, src); \ +\ + pixh = vec_perm(a, b, permh##off); \ + pixl = vec_perm(a, b, perml##off); \ + filth = vec_msum(filter_inner, pixh, c64); \ + filtl = vec_msum(filter_inner, pixl, c64); \ +\ + if (is6tap) { \ + outer = vec_perm(a, b, perm_6tap##off); \ + filth = vec_msum(filter_outerh, outer, filth); \ + filtl = vec_msum(filter_outerl, outer, filtl); \ + } \ + if (w == 4) \ + filtl = filth; /* discard pixels 4-7 */ \ + dstv = vec_packs(filth, filtl); \ + dstv = vec_sra(dstv, c7) + +static av_always_inline +void put_vp8_epel_h_altivec_core(uint8_t *dst, int dst_stride, + uint8_t *src, int src_stride, + int h, int mx, int w, int is6tap) +{ + LOAD_H_SUBPEL_FILTER(mx-1); + vec_u8 align_vec0, align_vec8, permh0, permh8, filt; + vec_u8 perm_6tap0, perm_6tap8, perml0, perml8; + vec_u8 a, b, pixh, pixl, outer; + vec_s16 f16h, f16l; + vec_s32 filth, filtl; + + vec_u8 perm_inner = { 1,2,3,4, 2,3,4,5, 3,4,5,6, 4,5,6,7 }; + vec_u8 perm_outer = { 4,9, 0,5, 5,10, 1,6, 6,11, 2,7, 7,12, 3,8 }; + vec_s32 c64 = vec_sl(vec_splat_s32(1), vec_splat_u32(6)); + vec_u16 c7 = vec_splat_u16(7); + + align_vec0 = vec_lvsl( -2, src); + align_vec8 = vec_lvsl(8-2, src); + + permh0 = vec_perm(align_vec0, align_vec0, perm_inner); + permh8 = vec_perm(align_vec8, align_vec8, perm_inner); + perm_inner = vec_add(perm_inner, vec_splat_u8(4)); + perml0 = vec_perm(align_vec0, align_vec0, perm_inner); + perml8 = vec_perm(align_vec8, align_vec8, perm_inner); + perm_6tap0 = vec_perm(align_vec0, align_vec0, perm_outer); + perm_6tap8 = vec_perm(align_vec8, align_vec8, perm_outer); + + while (h --> 0) { + FILTER_H(f16h, 0); + + if (w == 16) { + FILTER_H(f16l, 8); + filt = vec_packsu(f16h, f16l); + vec_st(filt, 0, dst); + } else { + filt = vec_packsu(f16h, f16h); + vec_ste((vec_u32)filt, 0, (uint32_t*)dst); + if (w == 8) + vec_ste((vec_u32)filt, 4, (uint32_t*)dst); + } + src += src_stride; + dst += dst_stride; + } +} + +// v subpel filter does a simple vertical multiply + add +static const vec_u8 v_subpel_filters[7] = +{ + { 0, 6, 123, 12, 1, 0 }, + { 2, 11, 108, 36, 8, 1 }, + { 0, 9, 93, 50, 6, 0 }, + { 3, 16, 77, 77, 16, 3 }, + { 0, 6, 50, 93, 9, 0 }, + { 1, 8, 36, 108, 11, 2 }, + { 0, 1, 12, 123, 6, 0 }, +}; + +#define LOAD_V_SUBPEL_FILTER(i) \ + vec_u8 subpel_filter = v_subpel_filters[i]; \ + vec_u8 f0 = vec_splat(subpel_filter, 0); \ + vec_u8 f1 = vec_splat(subpel_filter, 1); \ + vec_u8 f2 = vec_splat(subpel_filter, 2); \ + vec_u8 f3 = vec_splat(subpel_filter, 3); \ + vec_u8 f4 = vec_splat(subpel_filter, 4); \ + vec_u8 f5 = vec_splat(subpel_filter, 5) + +#define FILTER_V(dstv, vec_mul) \ + s1f = (vec_s16)vec_mul(s1, f1); \ + s2f = (vec_s16)vec_mul(s2, f2); \ + s3f = (vec_s16)vec_mul(s3, f3); \ + s4f = (vec_s16)vec_mul(s4, f4); \ + s2f = vec_subs(s2f, s1f); \ + s3f = vec_subs(s3f, s4f); \ + if (is6tap) { \ + s0f = (vec_s16)vec_mul(s0, f0); \ + s5f = (vec_s16)vec_mul(s5, f5); \ + s2f = vec_adds(s2f, s0f); \ + s3f = vec_adds(s3f, s5f); \ + } \ + dstv = vec_adds(s2f, s3f); \ + dstv = vec_adds(dstv, c64); \ + dstv = vec_sra(dstv, c7) + +static av_always_inline +void put_vp8_epel_v_altivec_core(uint8_t *dst, int dst_stride, + uint8_t *src, int src_stride, + int h, int my, int w, int is6tap) +{ + LOAD_V_SUBPEL_FILTER(my-1); + vec_u8 s0, s1, s2, s3, s4, s5, filt, align_vech, perm_vec, align_vecl; + vec_s16 s0f, s1f, s2f, s3f, s4f, s5f, f16h, f16l; + vec_s16 c64 = vec_sl(vec_splat_s16(1), vec_splat_u16(6)); + vec_u16 c7 = vec_splat_u16(7); + + // we want pixels 0-7 to be in the even positions and 8-15 in the odd, + // so combine this permute with the alignment permute vector + align_vech = vec_lvsl(0, src); + align_vecl = vec_sld(align_vech, align_vech, 8); + if (w ==16) + perm_vec = vec_mergeh(align_vech, align_vecl); + else + perm_vec = vec_mergeh(align_vech, align_vech); + + if (is6tap) + s0 = load_with_perm_vec(-2*src_stride, src, perm_vec); + s1 = load_with_perm_vec(-1*src_stride, src, perm_vec); + s2 = load_with_perm_vec( 0*src_stride, src, perm_vec); + s3 = load_with_perm_vec( 1*src_stride, src, perm_vec); + if (is6tap) + s4 = load_with_perm_vec( 2*src_stride, src, perm_vec); + + src += (2+is6tap)*src_stride; + + while (h --> 0) { + if (is6tap) + s5 = load_with_perm_vec(0, src, perm_vec); + else + s4 = load_with_perm_vec(0, src, perm_vec); + + FILTER_V(f16h, vec_mule); + + if (w == 16) { + FILTER_V(f16l, vec_mulo); + filt = vec_packsu(f16h, f16l); + vec_st(filt, 0, dst); + } else { + filt = vec_packsu(f16h, f16h); + if (w == 4) + filt = (vec_u8)vec_splat((vec_u32)filt, 0); + else + vec_ste((vec_u32)filt, 4, (uint32_t*)dst); + vec_ste((vec_u32)filt, 0, (uint32_t*)dst); + } + + if (is6tap) + s0 = s1; + s1 = s2; + s2 = s3; + s3 = s4; + if (is6tap) + s4 = s5; + + dst += dst_stride; + src += src_stride; + } +} + +#define EPEL_FUNCS(WIDTH, TAPS) \ +static av_noinline \ +void put_vp8_epel ## WIDTH ## _h ## TAPS ## _altivec(uint8_t *dst, int dst_stride, uint8_t *src, int src_stride, int h, int mx, int my) \ +{ \ + put_vp8_epel_h_altivec_core(dst, dst_stride, src, src_stride, h, mx, WIDTH, TAPS == 6); \ +} \ +\ +static av_noinline \ +void put_vp8_epel ## WIDTH ## _v ## TAPS ## _altivec(uint8_t *dst, int dst_stride, uint8_t *src, int src_stride, int h, int mx, int my) \ +{ \ + put_vp8_epel_v_altivec_core(dst, dst_stride, src, src_stride, h, my, WIDTH, TAPS == 6); \ +} + +#define EPEL_HV(WIDTH, HTAPS, VTAPS) \ +static void put_vp8_epel ## WIDTH ## _h ## HTAPS ## v ## VTAPS ## _altivec(uint8_t *dst, int stride, uint8_t *src, int s, int h, int mx, int my) \ +{ \ + DECLARE_ALIGNED(16, uint8_t, tmp)[(2*WIDTH+5)*16]; \ + put_vp8_epel ## WIDTH ## _h ## HTAPS ## _altivec(tmp, 16, src-2*stride, stride, h+5, mx, my); \ + put_vp8_epel ## WIDTH ## _v ## VTAPS ## _altivec(dst, stride, tmp+2*16, 16, h, mx, my); \ +} + +EPEL_FUNCS(16,6) +EPEL_FUNCS(8, 6) +EPEL_FUNCS(8, 4) +EPEL_FUNCS(4, 6) +EPEL_FUNCS(4, 4) + +EPEL_HV(16, 6,6) +EPEL_HV(8, 6,6) +EPEL_HV(8, 4,6) +EPEL_HV(8, 6,4) +EPEL_HV(8, 4,4) +EPEL_HV(4, 6,6) +EPEL_HV(4, 4,6) +EPEL_HV(4, 6,4) +EPEL_HV(4, 4,4) + +static void put_vp8_pixels16_altivec(uint8_t *dst, int stride, uint8_t *src, int s, int h, int mx, int my) +{ + put_pixels16_altivec(dst, src, stride, h); +} + +av_cold void ff_vp8dsp_init_altivec(VP8DSPContext *c) +{ + if (!has_altivec()) + return; + + c->put_vp8_epel_pixels_tab[0][0][0] = put_vp8_pixels16_altivec; + c->put_vp8_epel_pixels_tab[0][0][2] = put_vp8_epel16_h6_altivec; + c->put_vp8_epel_pixels_tab[0][2][0] = put_vp8_epel16_v6_altivec; + c->put_vp8_epel_pixels_tab[0][2][2] = put_vp8_epel16_h6v6_altivec; + + c->put_vp8_epel_pixels_tab[1][0][2] = put_vp8_epel8_h6_altivec; + c->put_vp8_epel_pixels_tab[1][2][0] = put_vp8_epel8_v6_altivec; + c->put_vp8_epel_pixels_tab[1][0][1] = put_vp8_epel8_h4_altivec; + c->put_vp8_epel_pixels_tab[1][1][0] = put_vp8_epel8_v4_altivec; + + c->put_vp8_epel_pixels_tab[1][2][2] = put_vp8_epel8_h6v6_altivec; + c->put_vp8_epel_pixels_tab[1][1][1] = put_vp8_epel8_h4v4_altivec; + c->put_vp8_epel_pixels_tab[1][1][2] = put_vp8_epel8_h6v4_altivec; + c->put_vp8_epel_pixels_tab[1][2][1] = put_vp8_epel8_h4v6_altivec; + + c->put_vp8_epel_pixels_tab[2][0][2] = put_vp8_epel4_h6_altivec; + c->put_vp8_epel_pixels_tab[2][2][0] = put_vp8_epel4_v6_altivec; + c->put_vp8_epel_pixels_tab[2][0][1] = put_vp8_epel4_h4_altivec; + c->put_vp8_epel_pixels_tab[2][1][0] = put_vp8_epel4_v4_altivec; + + c->put_vp8_epel_pixels_tab[2][2][2] = put_vp8_epel4_h6v6_altivec; + c->put_vp8_epel_pixels_tab[2][1][1] = put_vp8_epel4_h4v4_altivec; + c->put_vp8_epel_pixels_tab[2][1][2] = put_vp8_epel4_h6v4_altivec; + c->put_vp8_epel_pixels_tab[2][2][1] = put_vp8_epel4_h4v6_altivec; +} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/psymodel.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/psymodel.c index f87dbcf27..a85c29baa 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/psymodel.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/psymodel.c @@ -123,5 +123,6 @@ av_cold void ff_psy_preprocess_end(struct FFPsyPreprocessContext *ctx) for (i = 0; i < ctx->avctx->channels; i++) ff_iir_filter_free_state(ctx->fstate[i]); av_freep(&ctx->fstate); + av_free(ctx); } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/put_bits.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/put_bits.h index 80a514df8..d301d0afc 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/put_bits.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/put_bits.h @@ -52,7 +52,7 @@ typedef struct PutBitContext { } PutBitContext; /** - * Initializes the PutBitContext s. + * Initialize the PutBitContext s. * * @param buffer the buffer where to put bits * @param buffer_size the size in bytes of buffer @@ -79,7 +79,7 @@ static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_s } /** - * Returns the total number of bits written to the bitstream. + * @return the total number of bits written to the bitstream. */ static inline int put_bits_count(PutBitContext *s) { @@ -91,7 +91,7 @@ static inline int put_bits_count(PutBitContext *s) } /** - * Pads the end of the output stream with zeros. + * Pad the end of the output stream with zeros. */ static inline void flush_put_bits(PutBitContext *s) { @@ -123,19 +123,19 @@ static inline void flush_put_bits(PutBitContext *s) #define ff_copy_bits ff_copy_bits_unsupported_here #else /** - * Pads the bitstream with zeros up to the next byte boundary. + * Pad the bitstream with zeros up to the next byte boundary. */ void align_put_bits(PutBitContext *s); /** - * Puts the string string in the bitstream. + * Put the string string in the bitstream. * * @param terminate_string 0-terminates the written string if value is 1 */ void ff_put_string(PutBitContext *pb, const char *string, int terminate_string); /** - * Copies the content of src to the bitstream. + * Copy the content of src to the bitstream. * * @param length the number of bits of src to copy */ @@ -143,7 +143,7 @@ void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length); #endif /** - * Writes up to 31 bits into a bitstream. + * Write up to 31 bits into a bitstream. * Use put_bits32 to write 32 bits. */ static inline void put_bits(PutBitContext *s, int n, unsigned int value) @@ -168,7 +168,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) AV_WL32(s->buf_ptr, bit_buf); } else #endif - *(uint32_t *)s->buf_ptr = le2me_32(bit_buf); + *(uint32_t *)s->buf_ptr = av_le2ne32(bit_buf); s->buf_ptr+=4; bit_buf = (bit_left==32)?0:value >> bit_left; bit_left+=32; @@ -186,7 +186,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) AV_WB32(s->buf_ptr, bit_buf); } else #endif - *(uint32_t *)s->buf_ptr = be2me_32(bit_buf); + *(uint32_t *)s->buf_ptr = av_be2ne32(bit_buf); //printf("bitbuf = %08x\n", bit_buf); s->buf_ptr+=4; bit_left+=32 - n; @@ -224,8 +224,8 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) value<<= 32-n; - ptr[0] |= be2me_32(value>>(index&31)); - ptr[1] = be2me_32(value<<(32-(index&31))); + ptr[0] |= av_be2ne32(value>>(index&31)); + ptr[1] = av_be2ne32(value<<(32-(index&31))); //if(n>24) printf("%d %d\n", n, value); index+= n; s->index= index; @@ -252,7 +252,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value) 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[0] |= av_be2ne32(value<<(32-n-(index&7) )); ptr[1] = 0; //if(n>24) printf("%d %d\n", n, value); index+= n; @@ -270,7 +270,7 @@ static inline void put_sbits(PutBitContext *pb, int n, int32_t value) } /** - * Writes exactly 32 bits into a bitstream. + * Write exactly 32 bits into a bitstream. */ static void av_unused put_bits32(PutBitContext *s, uint32_t value) { @@ -286,7 +286,7 @@ static void av_unused put_bits32(PutBitContext *s, uint32_t value) } /** - * Returns the pointer to the byte where the bitstream writer will put + * Return the pointer to the byte where the bitstream writer will put * the next bit. */ static inline uint8_t* put_bits_ptr(PutBitContext *s) @@ -299,7 +299,7 @@ static inline uint8_t* put_bits_ptr(PutBitContext *s) } /** - * Skips the given number of bytes. + * Skip the given number of bytes. * PutBitContext must be flushed & aligned to a byte boundary before calling this. */ static inline void skip_put_bytes(PutBitContext *s, int n) @@ -315,7 +315,7 @@ static inline void skip_put_bytes(PutBitContext *s, int n) } /** - * Skips the given number of bits. + * Skip the given number of bits. * Must only be used if the actual values in the bitstream do not matter. * If n is 0 the behavior is undefined. */ @@ -331,7 +331,7 @@ static inline void skip_put_bits(PutBitContext *s, int n) } /** - * Changes the end of the buffer. + * Change the end of the buffer. * * @param size the new size in bytes of the buffer where to put bits */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qcelpdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qcelpdec.c index 97785adb9..0441e1fca 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qcelpdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qcelpdec.c @@ -101,8 +101,8 @@ static av_cold int qcelp_decode_init(AVCodecContext *avctx) } /** - * Decodes the 10 quantized LSP frequencies from the LSPV/LSP - * transmission codes of any bitrate and checks for badly received packets. + * Decode the 10 quantized LSP frequencies from the LSPV/LSP + * transmission codes of any bitrate and check for badly received packets. * * @param q the context * @param lspf line spectral pair frequencies @@ -197,7 +197,7 @@ static int decode_lspf(QCELPContext *q, float *lspf) } /** - * Converts codebook transmission codes to GAIN and INDEX. + * Convert codebook transmission codes to GAIN and INDEX. * * @param q the context * @param gain array holding the decoded gain @@ -309,7 +309,7 @@ static int codebook_sanity_check_for_rate_quarter(const uint8_t *cbgain) } /** - * Computes the scaled codebook vector Cdn From INDEX and GAIN + * Compute the scaled codebook vector Cdn From INDEX and GAIN * for all rates. * * The specification lacks some information here. @@ -564,8 +564,8 @@ static void apply_pitch_filters(QCELPContext *q, float *cdn_vector) } /** - * Reconstructs LPC coefficients from the line spectral pair frequencies - * and performs bandwidth expansion. + * Reconstruct LPC coefficients from the line spectral pair frequencies + * and perform bandwidth expansion. * * @param lspf line spectral pair frequencies * @param lpc linear predictive coding coefficients @@ -594,7 +594,7 @@ static void lspf2lpc(const float *lspf, float *lpc) } /** - * Interpolates LSP frequencies and computes LPC coefficients + * Interpolate LSP frequencies and compute LPC coefficients * for a given bitrate & pitch subframe. * * TIA/EIA/IS-733 2.4.3.3.4, 2.4.8.7.2 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qdm2.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qdm2.c index 6451fbe91..87dd0717e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qdm2.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qdm2.c @@ -385,7 +385,7 @@ static uint16_t qdm2_packet_checksum (const uint8_t *data, int length, int value /** - * Fills a QDM2SubPacket structure with packet type, size, and data pointer. + * Fill a QDM2SubPacket structure with packet type, size, and data pointer. * * @param gb bitreader context * @param sub_packet packet under analysis @@ -436,7 +436,7 @@ static QDM2SubPNode* qdm2_search_subpacket_type_in_list (QDM2SubPNode *list, int /** - * Replaces 8 elements with their average value. + * Replace 8 elements with their average value. * Called by qdm2_decode_superblock before starting subblock decoding. * * @param q context @@ -942,7 +942,6 @@ static void synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int l * This is similar to process_subpacket_9, but for a single channel and for element [0] * same VLC tables as process_subpacket_9 are used. * - * @param q context * @param quantized_coeffs pointer to quantized_coeffs[ch][0] * @param gb bitreader context * @param length packet length in bits diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qdm2_tablegen.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qdm2_tablegen.c index c225bc439..a7a9fb664 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qdm2_tablegen.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qdm2_tablegen.c @@ -33,25 +33,12 @@ int main(void) write_fileheader(); - printf("static const uint16_t softclip_table[HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1] = {\n"); - write_uint16_array(softclip_table, HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD + 1); - printf("};\n"); + WRITE_ARRAY("static const", uint16_t, softclip_table); + WRITE_ARRAY("static const", float, noise_table); + WRITE_ARRAY("static const", float, noise_samples); - printf("static const float noise_table[4096] = {\n"); - write_float_array(noise_table, 4096); - printf("};\n"); - - printf("static const uint8_t random_dequant_index[256][5] = {\n"); - write_uint8_2d_array(random_dequant_index, 256, 5); - printf("};\n"); - - printf("static const uint8_t random_dequant_type24[128][3] = {\n"); - write_uint8_2d_array(random_dequant_type24, 128, 3); - printf("};\n"); - - printf("static const float noise_samples[128] = {\n"); - write_float_array(noise_samples, 128); - printf("};\n"); + WRITE_2D_ARRAY("static const", uint8_t, random_dequant_index); + WRITE_2D_ARRAY("static const", uint8_t, random_dequant_type24); return 0; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qdm2_tablegen.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qdm2_tablegen.h index de9ff0c90..6718f58b0 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qdm2_tablegen.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qdm2_tablegen.h @@ -25,7 +25,7 @@ #include #include -#include "../libavutil/attributes.h" +#include "libavutil/attributes.h" #define SOFTCLIP_THRESHOLD 27600 #define HARDCLIP_THRESHOLD 35716 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qtrleenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qtrleenc.c index 7f95c7f5a..6cc7a556f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qtrleenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/qtrleenc.c @@ -104,7 +104,7 @@ static av_cold int qtrle_encode_init(AVCodecContext *avctx) } /** - * Computes the best RLE sequence for a line + * Compute the best RLE sequence for a line */ static void qtrle_encode_line(QtrleEncContext *s, AVFrame *p, int line, uint8_t **buf) { @@ -235,7 +235,7 @@ static void qtrle_encode_line(QtrleEncContext *s, AVFrame *p, int line, uint8_t bytestream_put_byte(buf, -1); // end RLE line } -/** Encodes frame including header */ +/** Encode frame including header */ static int encode_frame(QtrleEncContext *s, AVFrame *p, uint8_t *buf) { int i; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/r210dec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/r210dec.c index 416f76498..cf0407069 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/r210dec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/r210dec.c @@ -61,7 +61,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, for (h = 0; h < avctx->height; h++) { uint16_t *dst = (uint16_t *)dst_line; for (w = 0; w < avctx->width; w++) { - uint32_t pixel = be2me_32(*src++); + uint32_t pixel = av_be2ne32(*src++); uint16_t r, g, b; b = pixel << 6; g = (pixel >> 4) & 0xffc0; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144.c index efa62c491..35b7921ec 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144.c @@ -1,9 +1,6 @@ /* * Real Audio 1.0 (14.4K) - * - * Copyright (c) 2008 Vitor Sessak - * Copyright (c) 2003 Nick Kurshev - * Based on public domain decoder at http://www.honeypot.net/audio + * Copyright (c) 2003 the ffmpeg project * * This file is part of FFmpeg. * @@ -22,126 +19,1499 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/intmath.h" +#include #include "avcodec.h" -#include "get_bits.h" -#include "ra144.h" #include "celp_filters.h" +#include "ra144.h" -#define NBLOCKS 4 ///< number of subblocks within a block -#define BLOCKSIZE 40 ///< subblock size in 16-bit words -#define BUFFERSIZE 146 ///< the size of the adaptive codebook - - -typedef struct { - AVCodecContext *avctx; - - unsigned int old_energy; ///< previous frame energy - - unsigned int lpc_tables[2][10]; - - /** LPC coefficients: lpc_coef[0] is the coefficients of the current frame - * and lpc_coef[1] of the previous one. */ - unsigned int *lpc_coef[2]; - - unsigned int lpc_refl_rms[2]; - - /** The current subblock padded by the last 10 values of the previous one. */ - int16_t curr_sblock[50]; - - /** Adaptive codebook, its size is two units bigger to avoid a - * buffer overflow. */ - uint16_t adapt_cb[146+2]; -} RA144Context; +const int16_t ff_gain_val_tab[256][3] = { + { 541, 956, 768}, { 877, 581, 568}, { 675,1574, 635}, {1248,1464, 668}, + {1246, 839, 1394}, {2560,1386, 991}, { 925, 687, 608}, {2208, 797, 1144}, + { 535, 832, 799}, { 762, 605, 1154}, { 832,1122, 1003}, {1180, 687, 1176}, + {1292, 901, 732}, {1656, 689, 896}, {1750,1248, 848}, {2284, 942, 1022}, + { 824,1472, 643}, { 517, 765, 512}, { 562,1816, 1522}, { 694,1826, 2700}, + { 704, 524, 672}, {1442, 757, 2232}, { 884, 551, 1266}, {2232,1007, 1692}, + { 932, 746, 777}, {1132, 822, 926}, {1226, 771, 611}, {2948,1342, 1008}, + {1302, 594, 1158}, {1602, 636, 1128}, {3408, 910, 1438}, {1996, 614, 575}, + { 665, 935, 628}, { 631,1192, 829}, { 644, 926, 1052}, { 879, 988, 1226}, + { 941,2768, 2772}, { 565,1344, 2304}, { 547, 628, 740}, { 639, 532, 1074}, + { 955,1208, 598}, {1124,1160, 900}, {1206, 899, 1242}, { 746, 533, 624}, + {1458,1028, 735}, {1706,1102, 692}, {1898,1018, 1004}, {2176, 988, 735}, + {1578, 782, 1642}, { 897, 516, 754}, {2068, 702, 1656}, {2344, 818, 1526}, + { 907, 652, 592}, {1056, 652, 642}, {2124,1416, 780}, {2664,1250, 727}, + {1894, 727, 1108}, {2196, 657, 981}, {4840, 920, 1704}, {4992,1238, 983}, + {2420, 909, 1094}, {2760, 935, 1032}, {2800, 612, 853}, {3068, 832, 574}, + { 523,1796, 923}, { 722,1916, 1382}, {1226,1542, 928}, { 758, 757, 584}, + { 512,1134, 577}, { 615,1276, 698}, { 574,2568, 2356}, { 993,2728, 3512}, + { 539, 890, 913}, { 694, 928, 1088}, { 805, 600, 1360}, {2160, 951, 3128}, + { 816, 950, 590}, { 955, 847, 811}, {1094, 883, 556}, {1304, 888, 604}, + { 863,1170, 855}, {1023, 997, 1032}, { 932,1228, 1280}, { 627, 564, 573}, + { 876, 900, 1448}, {1030, 857, 1792}, {1294, 953, 1758}, {1612, 854, 1714}, + {1090,1166, 631}, {1314,1202, 751}, {1480, 905, 795}, {1682,1016, 568}, + {1494,1178, 983}, { 878, 613, 526}, {1728,1446, 779}, {2136,1348, 774}, + { 950, 649, 939}, {1180, 703, 899}, {1236, 527, 1158}, {1450, 647, 972}, + {1282, 647, 707}, {1460, 663, 644}, {1614, 572, 578}, {3516,1222, 821}, + {2668, 729, 1682}, {3128, 585, 1502}, {3208, 733, 976}, {6800, 871, 1416}, + {3480, 743, 1408}, {3764, 899, 1170}, {3772, 632, 875}, {4092, 732, 638}, + {3112, 753, 2620}, {3372, 945, 1890}, {3768, 969, 2288}, {2016, 559, 854}, + {1736, 729, 787}, {1940, 686, 547}, {2140, 635, 674}, {4480,1272, 828}, + {3976, 592, 1666}, {4384, 621, 1388}, {4400, 801, 955}, {4656, 522, 646}, + {4848, 625, 1636}, {4984, 591, 874}, {5352, 535, 1001}, {11216,938, 1184}, + { 925,3280, 1476}, { 735,1580, 1088}, {1150,1576, 674}, { 655, 783, 528}, + { 527,2052, 1354}, { 782,1704, 1880}, { 578, 910, 1026}, { 692, 882, 1468}, + { 586, 683, 715}, { 739, 609, 717}, { 778, 773, 697}, { 922, 785, 813}, + { 766, 651, 984}, { 978, 596, 1030}, {1070, 757, 1080}, {1324, 687, 1178}, + {1108,2144, 979}, { 723, 982, 690}, { 936, 956, 527}, {1180,1002, 547}, + { 517,1306, 825}, { 832,1184, 974}, {1024, 957, 903}, {1262,1090, 906}, + {1028, 720, 649}, {1192, 679, 694}, {2468,1480, 979}, {2844,1370, 877}, + {1310, 835, 848}, {1508, 839, 698}, {1742,1030, 769}, {1910, 852, 573}, + {1280, 859, 1174}, {1584, 863, 1108}, {1686, 708, 1364}, {1942, 768, 1104}, + { 891, 536, 690}, {1016, 560, 663}, {2172, 870, 1348}, {2404, 999, 1170}, + {1890, 966, 889}, {2116, 912, 777}, {2296,1020, 714}, {4872,1844, 932}, + {2392, 778, 929}, {2604, 772, 744}, {2764, 957, 722}, {5832,1532, 984}, + {2188, 519, 1264}, {2332, 532, 922}, {5064, 995, 2412}, {2708, 571, 874}, + {2408, 545, 666}, {5016,1084, 875}, {5376, 983, 1196}, {5536, 979, 730}, + {5344, 634, 1744}, {5688, 706, 1348}, {5912, 977, 1190}, {6072, 905, 763}, + {6048, 582, 1526}, {11968,1013,1816}, {12864,937, 1900}, {12560,1086, 998}, + {1998, 684, 1884}, {2504, 633, 1992}, {1252, 567, 835}, {1478, 571, 973}, + {2620, 769, 1414}, {2808, 952, 1142}, {2908, 712, 1028}, {2976, 686, 741}, + {1462, 552, 714}, {3296, 991, 1452}, {1590, 615, 544}, {3480,1150, 824}, + {3212, 832, 923}, {3276, 839, 531}, {3548, 786, 852}, {3732, 764, 570}, + {5728, 906, 2616}, {6272, 804, 2252}, {3096, 535, 876}, {3228, 598, 649}, + {6536, 759, 1436}, {6648, 993, 846}, {6864, 567, 1210},{14016,1012, 1302}, + {3408, 548, 1098}, {7160,1008, 1742}, {7136,1000, 1182}, {7480,1032, 836}, + {7448, 612, 1552}, {7744, 614, 816}, {8384, 777, 1438}, {8784, 694, 786}, + { 882,1508, 1068}, { 597, 837, 766}, {1270, 954, 1408}, { 803, 550, 798}, + {1398,1308, 798}, {1848,1534, 738}, { 970, 675, 608}, {1264, 706, 684}, + {1716, 767, 1126}, {2108, 765, 1404}, {2236, 924, 1003}, {2472,1048, 611}, + { 999, 942, 963}, {1094, 857, 935}, {2936, 926, 1138}, {1934, 746, 551}, + {3336, 633, 1762}, {3764, 701, 1454}, {1890, 564, 636}, {4096,1126, 793}, + {3936, 556, 1140}, {3936, 540, 740}, {4216, 764, 874}, {8480,1328, 1014}, + {2184, 515, 1042}, {4432, 934, 1344}, {4784, 945, 1112}, {5016,1062, 733}, + {9216,1020, 2028}, {9968, 924, 1188}, {5424, 909, 1206}, {6512, 744, 1086} +}; -static av_cold int ra144_decode_init(AVCodecContext * avctx) -{ - RA144Context *ractx = avctx->priv_data; +const uint8_t ff_gain_exp_tab[256] = { + 15, 15, 15, 15, 15, 16, 14, 15, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 13, 14, 14, 13, 14, 13, 14, 13, 13, 13, 14, 13, 13, 14, 13, + 13, 13, 13, 13, 14, 13, 12, 12, 13, 13, 13, 12, 13, 13, 13, 13, + 13, 12, 13, 13, 12, 12, 13, 13, 13, 13, 14, 14, 13, 13, 13, 13, + 13, 13, 13, 12, 12, 12, 13, 13, 12, 12, 12, 13, 12, 12, 12, 12, + 12, 12, 12, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 14, 13, 13, 13, 13, + 13, 13, 13, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 14, + 13, 12, 12, 11, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 11, 11, 11, 11, + 12, 12, 12, 12, 11, 11, 12, 12, 12, 12, 12, 13, 12, 12, 12, 13, + 12, 12, 13, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, + 12, 12, 11, 11, 12, 12, 12, 12, 11, 12, 11, 12, 12, 12, 12, 12, + 13, 13, 12, 12, 13, 13, 13, 14, 12, 13, 13, 13, 13, 13, 13, 13, + 11, 10, 11, 10, 11, 11, 10, 10, 11, 11, 11, 11, 10, 9, 11, 10, + 12, 12, 11, 12, 12, 12, 12, 13, 11, 12, 12, 12, 13, 13, 12, 12 +}; - ractx->avctx = avctx; +const int8_t ff_cb1_vects[128][40]={ + { + 38, -4, 15, -4, 14, -13, 12, -11, -2, -6, + -6, -11, -45, -16, -11, -13, -7, 6, -12, 4, + -20, 3, -16, 12, -1, 12, 46, 24, 0, 33, + -3, 9, -12, -12, -8, -7, 17, -6, 0, -2, + }, { + 60, -16, 3, -22, 10, -32, 0, -28, -17, -18, + -3, -25, -37, -23, -10, 3, 2, 3, 0, 3, + -14, 0, -14, -1, 0, 2, 32, 9, -1, 25, + 7, 13, -5, 13, 8, 1, 2, 8, -10, 6, + }, { + 27, -12, 28, -2, 6, -7, 15, 9, -11, 1, + -13, -11, -40, 4, -29, -14, -19, -5, -23, -8, + -30, -13, -17, 0, -14, 12, 34, 20, -2, 25, + 2, -16, -4, -12, 15, 16, 29, 7, 24, 10, + }, { + 49, -24, 16, -20, 2, -26, 2, -7, -25, -10, + -11, -25, -32, -3, -27, 2, -8, -8, -11, -9, + -24, -17, -16, -14, -13, 2, 20, 5, -4, 17, + 14, -12, 3, 13, 33, 25, 14, 23, 15, 19, + }, { + 46, -6, 21, 8, -2, -16, -5, -8, -11, 4, + 8, 15, -24, 4, -2, -26, -3, -16, -16, -14, + -9, -2, -1, 4, 19, 7, 36, 17, 9, 13, + 0, 31, -5, -12, 7, -8, 11, -15, -13, -4, + }, { + 68, -18, 9, -9, -6, -35, -18, -25, -26, -7, + 10, 1, -16, -3, -1, -9, 6, -19, -4, -15, + -4, -6, 0, -8, 20, -2, 23, 2, 7, 5, + 12, 35, 1, 13, 24, 0, -3, 0, -22, 4, + }, { + 35, -14, 34, 10, -10, -10, -1, 12, -20, 12, + 0, 15, -18, 24, -20, -27, -14, -28, -27, -27, + -20, -19, -2, -8, 5, 7, 25, 13, 5, 5, + 6, 5, 2, -12, 31, 15, 23, -1, 12, 8, + }, { + 57, -26, 22, -7, -14, -28, -14, -3, -35, 0, + 3, 1, -11, 16, -18, -10, -4, -31, -15, -28, + -14, -23, -1, -21, 7, -2, 11, -1, 3, -1, + 18, 9, 10, 13, 49, 24, 8, 14, 2, 16, + }, { + 25, 15, 22, 11, 18, 4, 15, -22, 8, -2, + -17, -9, -48, -20, -30, -17, -16, 11, -1, 16, + 2, 10, -5, 26, -2, -4, 22, 0, 2, 10, + -6, 13, -14, 10, -23, 0, 10, -2, 1, 0, + }, { + 47, 3, 11, -6, 15, -13, 2, -38, -6, -13, + -15, -22, -40, -28, -28, 0, -5, 8, 10, 15, + 7, 7, -4, 13, -1, -14, 9, -14, 0, 2, + 4, 18, -7, 36, -6, 8, -3, 13, -7, 8, + }, { + 14, 7, 36, 13, 10, 10, 18, 0, 0, 5, + -25, -8, -43, 0, -48, -18, -27, 0, -12, 3, + -7, -6, -7, 13, -15, -5, 11, -3, 0, 2, + 0, -12, -6, 10, 0, 23, 22, 11, 26, 12, + }, { + 36, -5, 24, -4, 7, -7, 6, -17, -14, -5, + -22, -22, -35, -8, -46, -1, -17, -3, 0, 2, + -2, -10, -5, 0, -14, -15, -2, -18, -2, -4, + 11, -7, 1, 36, 18, 32, 7, 27, 17, 20, + }, { + 33, 13, 29, 24, 1, 1, -2, -18, 0, 9, + -3, 17, -27, 0, -21, -30, -12, -11, -5, -2, + 12, 4, 9, 19, 18, -9, 13, -6, 11, -8, + -2, 35, -8, 10, -7, -1, 4, -11, -10, -2, + }, { + 55, 1, 17, 6, -1, -16, -15, -35, -15, -2, + 0, 4, -19, -8, -20, -13, -1, -14, 7, -3, + 18, 0, 10, 5, 19, -19, 0, -21, 8, -16, + 9, 39, 0, 36, 10, 7, -9, 4, -20, 5, + }, { + 22, 5, 42, 26, -6, 8, 1, 2, -9, 17, + -10, 18, -21, 19, -39, -31, -23, -23, -16, -15, + 2, -12, 7, 6, 5, -9, 1, -10, 7, -16, + 4, 9, 0, 10, 17, 22, 16, 2, 14, 9, + }, { + 44, -6, 30, 8, -9, -10, -11, -14, -23, 5, + -8, 4, -14, 12, -37, -14, -12, -26, -4, -16, + 8, -16, 9, -7, 6, -19, -12, -25, 5, -24, + 15, 13, 8, 36, 34, 31, 1, 18, 4, 18, + }, { + -3, -5, -9, -7, 15, -1, 5, 13, 2, 12, + 5, 2, -21, -23, -2, -16, 0, 5, -6, 13, + -23, 3, -32, 10, -15, 8, 44, 28, 9, 37, + -2, 13, -9, -15, -12, -27, -7, -12, 0, -11, + }, { + 18, -17, -21, -25, 11, -19, -6, -3, -11, 0, + 7, -11, -13, -31, -1, 0, 9, 1, 5, 12, + -18, 0, -31, -2, -13, -1, 30, 14, 7, 29, + 9, 18, -1, 10, 4, -18, -22, 3, -10, -2, + }, { + -13, -13, 3, -5, 7, 4, 9, 34, -5, 20, + -2, 3, -16, -3, -20, -17, -11, -7, -17, 0, + -34, -13, -33, -2, -28, 8, 32, 24, 5, 29, + 3, -12, 0, -15, 11, -3, 3, 2, 24, 1, + }, { + 8, -25, -8, -23, 3, -13, -3, 17, -20, 8, + 0, -10, -8, -11, -18, 0, -1, -10, -5, 0, + -28, -17, -32, -15, -26, -1, 19, 9, 3, 21, + 15, -7, 6, 9, 29, 5, -10, 17, 15, 9, + }, { + 4, -6, -3, 5, -1, -4, -11, 16, -6, 23, + 19, 29, 0, -3, 6, -30, 3, -17, -10, -5, + -13, -2, -17, 3, 5, 3, 35, 21, 17, 17, + 2, 35, -2, -15, 3, -28, -13, -21, -13, -13, + }, { + 26, -19, -15, -12, -5, -22, -24, 0, -21, 12, + 21, 15, 8, -11, 7, -12, 14, -20, 2, -6, + -7, -6, -16, -9, 6, -5, 21, 7, 15, 10, + 13, 39, 5, 10, 20, -19, -28, -5, -22, -5, + }, { + -5, -15, 9, 7, -9, 2, -8, 37, -14, 31, + 11, 29, 5, 16, -11, -30, -7, -29, -21, -18, + -23, -19, -18, -9, -7, 3, 23, 17, 14, 9, + 8, 9, 6, -15, 27, -4, -2, -6, 12, -1, + }, { + 16, -27, -2, -10, -13, -16, -20, 20, -29, 20, + 14, 16, 13, 8, -9, -13, 2, -33, -9, -19, + -17, -23, -17, -22, -6, -6, 9, 2, 12, 2, + 20, 13, 13, 10, 45, 4, -16, 8, 2, 7, + }, { + -16, 14, -2, 8, 20, 17, 9, 2, 14, 16, + -6, 5, -24, -28, -21, -20, -8, 9, 4, 25, + -1, 11, -22, 24, -15, -8, 21, 5, 11, 14, + -5, 18, -11, 7, -27, -20, -14, -7, 1, -9, + }, { + 6, 2, -14, -9, 16, -1, -3, -14, 0, 5, + -3, -8, -16, -36, -19, -3, 1, 6, 17, 24, + 4, 7, -21, 11, -14, -18, 7, -9, 9, 7, + 6, 22, -3, 33, -10, -11, -28, 7, -7, 0, + }, { + -26, 6, 11, 10, 12, 23, 12, 23, 5, 24, + -13, 5, -19, -8, -38, -21, -20, -2, -6, 12, + -11, -5, -23, 11, -29, -9, 9, 0, 7, 6, + 1, -7, -2, 7, -3, 3, -2, 6, 27, 3, + }, { + -4, -6, 0, -7, 8, 4, 0, 6, -9, 13, + -11, -7, -11, -15, -37, -4, -9, -5, 5, 11, + -5, -9, -22, -1, -27, -18, -4, -14, 5, 0, + 12, -3, 4, 32, 14, 12, -17, 22, 17, 11, + }, { + -8, 12, 3, 21, 3, 14, -8, 5, 4, 28, + 7, 32, -2, -8, -12, -34, -4, -12, 1, 6, + 9, 4, -7, 17, 4, -13, 11, -1, 19, -4, + 0, 39, -4, 7, -11, -21, -20, -16, -10, -11, + }, { + 13, 0, -8, 3, 0, -4, -21, -11, -9, 16, + 10, 18, 5, -16, -10, -16, 5, -15, 13, 5, + 15, 1, -6, 4, 6, -23, -2, -16, 17, -12, + 10, 44, 3, 33, 6, -12, -34, -1, -20, -3, + }, { + -18, 4, 17, 23, -4, 20, -4, 26, -3, 36, + 0, 32, 2, 12, -29, -34, -16, -24, -10, -6, + 0, -12, -8, 4, -8, -13, 0, -6, 16, -12, + 5, 13, 3, 7, 13, 3, -8, -2, 14, 0, + }, { + 3, -7, 5, 5, -8, 2, -17, 9, -18, 24, + 2, 19, 10, 4, -28, -17, -5, -28, 2, -7, + 4, -15, -7, -8, -6, -23, -13, -21, 14, -20, + 17, 18, 11, 33, 30, 11, -23, 13, 5, 9, + }, { + 60, 10, 7, -1, 9, -8, 6, -13, 2, -15, + -1, -10, -13, -11, 15, 0, 6, 9, -1, 0, + -13, 1, -11, -3, -13, 21, 13, 26, -7, 31, + -10, -7, -16, -33, -31, -10, 22, -8, 1, -2, + }, { + 82, -1, -4, -19, 6, -27, -6, -29, -12, -26, + 1, -24, -5, -18, 17, 17, 17, 6, 10, 0, + -7, -2, -9, -16, -12, 11, 0, 11, -9, 23, + 0, -3, -8, -8, -13, -1, 8, 7, -7, 6, + }, { + 49, 2, 21, 0, 1, -2, 9, 8, -6, -6, + -8, -10, -8, 9, -2, 0, -4, -2, -13, -12, + -23, -15, -12, -16, -26, 21, 2, 21, -11, 23, + -4, -33, -7, -33, -6, 13, 34, 5, 27, 10, + }, { + 71, -10, 9, -17, -1, -20, -3, -8, -21, -18, + -6, -24, 0, 1, 0, 16, 6, -5, 0, -13, + -17, -19, -11, -29, -25, 11, -11, 6, -13, 15, + 7, -29, 0, -8, 11, 22, 20, 21, 17, 18, + }, { + 67, 8, 14, 11, -7, -11, -11, -9, -7, -3, + 13, 16, 8, 9, 24, -12, 10, -13, -5, -17, + -2, -4, 3, -10, 6, 17, 4, 19, 0, 11, + -6, 13, -9, -33, -14, -10, 16, -17, -10, -4, + }, { + 90, -3, 2, -6, -10, -29, -24, -26, -21, -15, + 15, 2, 16, 1, 25, 4, 21, -16, 6, -18, + 3, -8, 5, -24, 8, 7, -9, 4, -1, 3, + 5, 18, -1, -7, 2, -1, 2, -1, -19, 3, + }, { + 57, 0, 27, 13, -14, -5, -7, 11, -15, 4, + 5, 16, 13, 29, 6, -13, 0, -25, -16, -31, + -12, -22, 2, -23, -6, 16, -7, 14, -2, 3, + 0, -12, 0, -33, 9, 13, 28, -3, 14, 7, + }, { + 79, -11, 15, -4, -18, -23, -20, -5, -30, -7, + 7, 2, 21, 21, 8, 3, 10, -28, -4, -31, + -6, -25, 3, -37, -4, 7, -20, 0, -4, -4, + 11, -7, 6, -8, 27, 22, 14, 12, 5, 16, + }, { + 47, 30, 15, 14, 14, 9, 9, -23, 13, -10, + -12, -7, -16, -15, -3, -3, -1, 14, 9, 12, + 9, 8, 0, 10, -14, 4, -9, 2, -5, 8, + -13, -3, -18, -10, -45, -3, 16, -4, 4, 0, + }, { + 69, 17, 3, -3, 10, -8, -3, -40, -1, -21, + -10, -21, -8, -23, -1, 13, 8, 11, 21, 11, + 15, 4, 0, -2, -13, -5, -23, -12, -7, 0, + -1, 0, -10, 14, -28, 5, 1, 11, -5, 7, + }, { + 36, 21, 28, 16, 6, 16, 12, -2, 4, -2, + -20, -7, -11, 4, -20, -4, -12, 2, -1, 0, + 0, -8, -2, -2, -27, 4, -21, -2, -9, 0, + -6, -29, -9, -10, -21, 21, 28, 10, 29, 11, + }, { + 58, 9, 16, -1, 2, -2, 0, -19, -10, -13, + -17, -21, -3, -3, -19, 12, -2, 0, 10, -1, + 5, -12, 0, -15, -26, -5, -34, -16, -11, -7, + 4, -25, -2, 14, -3, 29, 13, 25, 20, 20, + }, { + 55, 28, 21, 27, -2, 7, -8, -20, 4, 1, + 1, 18, 5, 4, 5, -16, 2, -8, 5, -5, + 19, 2, 14, 3, 6, 0, -18, -4, 2, -11, + -8, 18, -11, -10, -29, -3, 10, -13, -8, -3, + }, { + 77, 16, 9, 9, -6, -11, -21, -37, -10, -10, + 4, 5, 13, -3, 7, 0, 13, -11, 17, -6, + 25, -1, 15, -9, 7, -9, -32, -19, 0, -18, + 2, 22, -3, 15, -12, 5, -4, 2, -17, 5, + }, { + 44, 20, 34, 29, -10, 13, -4, 0, -4, 9, + -5, 19, 10, 24, -11, -17, -8, -20, -5, -19, + 9, -14, 12, -9, -6, 0, -30, -9, 0, -19, + -2, -7, -2, -10, -5, 20, 21, 1, 17, 9, + }, { + 66, 8, 23, 11, -14, -5, -17, -16, -19, -2, + -3, 5, 18, 17, -10, 0, 1, -23, 6, -20, + 15, -18, 14, -22, -5, -10, -44, -23, -2, -26, + 9, -3, 4, 14, 12, 29, 7, 16, 7, 18, + }, { + 18, 9, -17, -4, 11, 3, 0, 11, 7, 4, + 10, 3, 10, -18, 24, -3, 14, 7, 4, 10, + -16, 1, -27, -4, -27, 17, 12, 30, 0, 35, + -9, -3, -12, -36, -35, -30, -2, -13, 2, -11, + }, { + 40, -2, -29, -22, 7, -14, -12, -5, -7, -7, + 12, -9, 18, -26, 26, 14, 24, 4, 16, 9, + -10, -2, -26, -18, -26, 7, -1, 15, -1, 27, + 2, 0, -4, -11, -17, -21, -16, 1, -7, -3, + }, { + 8, 1, -3, -2, 3, 10, 3, 32, -1, 12, + 2, 4, 15, 1, 7, -3, 2, -4, -6, -3, + -26, -15, -29, -17, -40, 17, 0, 26, -2, 27, + -2, -29, -4, -36, -10, -6, 9, 0, 27, 0, + }, { + 30, -11, -15, -20, 0, -8, -9, 15, -15, 0, + 5, -9, 23, -6, 8, 13, 13, -7, 5, -3, + -20, -19, -27, -31, -39, 7, -13, 11, -4, 19, + 8, -25, 3, -11, 7, 2, -4, 16, 18, 9, + }, { + 26, 7, -11, 8, -5, 1, -17, 14, -1, 15, + 24, 30, 32, 1, 33, -16, 18, -14, 0, -8, + -6, -4, -12, -12, -6, 13, 2, 23, 8, 15, + -4, 17, -5, -36, -18, -30, -8, -22, -10, -14, + }, { + 48, -4, -23, -9, -9, -17, -30, -2, -16, 3, + 26, 16, 40, -6, 35, 1, 28, -17, 12, -9, + 0, -8, -11, -25, -5, 3, -10, 8, 6, 7, + 6, 22, 1, -11, -1, -21, -22, -7, -19, -5, + }, { + 15, 0, 2, 10, -13, 7, -14, 35, -10, 23, + 16, 31, 37, 21, 16, -17, 6, -26, -10, -21, + -16, -21, -13, -25, -19, 13, -8, 19, 5, 7, + 1, -8, 2, -36, 5, -6, 3, -8, 15, -1, + }, { + 37, -12, -9, -7, -17, -11, -26, 18, -25, 12, + 19, 17, 45, 14, 17, 0, 17, -30, 1, -22, + -10, -25, -12, -38, -18, 3, -22, 4, 3, 0, + 13, -3, 10, -11, 23, 2, -10, 7, 5, 7, + }, { + 5, 29, -9, 11, 15, 22, 3, 0, 18, 8, + -1, 6, 7, -23, 6, -6, 5, 12, 15, 21, + 5, 8, -17, 9, -28, 0, -11, 6, 2, 12, + -11, 0, -14, -13, -49, -22, -8, -9, 4, -9, + }, { + 27, 16, -21, -6, 12, 3, -9, -16, 3, -2, + 1, -7, 15, -31, 7, 10, 16, 9, 27, 21, + 11, 5, -16, -3, -26, -9, -24, -7, 0, 4, + 0, 4, -6, 11, -32, -14, -23, 6, -5, -1, + }, { + -4, 20, 3, 13, 8, 28, 6, 21, 10, 16, + -8, 7, 12, -3, -11, -7, -5, 0, 4, 8, + -4, -8, -18, -3, -41, 0, -22, 2, 0, 4, + -5, -25, -6, -14, -25, 1, 2, 4, 29, 2, + }, { + 17, 8, -8, -4, 4, 10, -6, 5, -4, 5, + -6, -6, 20, -10, -9, 9, 4, -2, 16, 7, + 1, -12, -17, -16, -39, -9, -36, -12, -2, -3, + 6, -21, 1, 11, -7, 10, -11, 20, 20, 11, + }, { + 13, 27, -3, 24, -1, 19, -14, 3, 9, 20, + 12, 33, 29, -3, 15, -20, 9, -9, 11, 3, + 16, 2, -2, 2, -7, -3, -20, 0, 10, -7, + -7, 22, -7, -13, -33, -23, -14, -18, -7, -12, + }, { + 35, 15, -15, 6, -4, 1, -27, -12, -5, 8, + 15, 19, 37, -11, 16, -2, 20, -12, 23, 2, + 22, -1, -1, -11, -5, -13, -34, -14, 8, -14, + 4, 26, 0, 11, -16, -14, -29, -2, -17, -3, + }, { + 3, 19, 9, 26, -8, 26, -10, 24, 0, 28, + 5, 33, 34, 17, -2, -20, -1, -22, 0, -10, + 6, -14, -3, -10, -20, -4, -32, -4, 7, -15, + 0, -3, 0, -13, -9, 0, -3, -4, 17, 0, + }, { + 25, 7, -2, 8, -12, 7, -23, 8, -13, 16, + 7, 20, 42, 9, 0, -3, 9, -25, 12, -10, + 12, -18, -2, -24, -19, -13, -46, -19, 5, -22, + 10, 0, 8, 11, 8, 9, -17, 11, 7, 8, + }, { + -25, -7, 2, -8, 12, -7, 23, -8, 13, -16, + -7, -20, -42, -9, 0, 3, -9, 25, -12, 10, + -12, 18, 2, 24, 19, 13, 46, 19, -5, 22, + -10, 0, -8, -11, -8, -9, 17, -11, -7, -8, + }, { + -3, -19, -9, -26, 8, -26, 10, -24, 0, -28, + -5, -33, -34, -17, 2, 20, 1, 22, 0, 10, + -6, 14, 3, 10, 20, 4, 32, 4, -7, 15, + 0, 3, 0, 13, 9, 0, 3, 4, -17, 0, + }, { + -35, -15, 15, -6, 4, -1, 27, 12, 5, -8, + -15, -19, -37, 11, -16, 2, -20, 12, -23, -2, + -22, 1, 1, 11, 5, 13, 34, 14, -8, 14, + -4, -26, 0, -11, 16, 14, 29, 2, 17, 3, + }, { + -13, -27, 3, -24, 1, -19, 14, -3, -9, -20, + -12, -33, -29, 3, -15, 20, -9, 9, -11, -3, + -16, -2, 2, -2, 7, 3, 20, 0, -10, 7, + 7, -22, 7, 13, 33, 23, 14, 18, 7, 12, + }, { + -17, -8, 8, 4, -4, -10, 6, -5, 4, -5, + 6, 6, -20, 10, 9, -9, -4, 2, -16, -7, + -1, 12, 17, 16, 39, 9, 36, 12, 2, 3, + -6, 21, -1, -11, 7, -10, 11, -20, -20, -11, + }, { + 4, -20, -3, -13, -8, -28, -6, -21, -10, -16, + 8, -7, -12, 3, 11, 7, 5, 0, -4, -8, + 4, 8, 18, 3, 41, 0, 22, -2, 0, -4, + 5, 25, 6, 14, 25, -1, -2, -4, -29, -2, + }, { + -27, -16, 21, 6, -12, -3, 9, 16, -3, 2, + -1, 7, -15, 31, -7, -10, -16, -9, -27, -21, + -11, -5, 16, 3, 26, 9, 24, 7, 0, -4, + 0, -4, 6, -11, 32, 14, 23, -6, 5, 1, + }, { + -5, -29, 9, -11, -15, -22, -3, 0, -18, -8, + 1, -6, -7, 23, -6, 6, -5, -12, -15, -21, + -5, -8, 17, -9, 28, 0, 11, -6, -2, -12, + 11, 0, 14, 13, 49, 22, 8, 9, -4, 9, + }, { + -37, 12, 9, 7, 17, 11, 26, -18, 25, -12, + -19, -17, -45, -14, -17, 0, -17, 30, -1, 22, + 10, 25, 12, 38, 18, -3, 22, -4, -3, 0, + -13, 3, -10, 11, -23, -2, 10, -7, -5, -7, + }, { + -15, 0, -2, -10, 13, -7, 14, -35, 10, -23, + -16, -31, -37, -21, -16, 17, -6, 26, 10, 21, + 16, 21, 13, 25, 19, -13, 8, -19, -5, -7, + -1, 8, -2, 36, -5, 6, -3, 8, -15, 1, + }, { + -48, 4, 23, 9, 9, 17, 30, 2, 16, -3, + -26, -16, -40, 6, -35, -1, -28, 17, -12, 9, + 0, 8, 11, 25, 5, -3, 10, -8, -6, -7, + -6, -22, -1, 11, 1, 21, 22, 7, 19, 5, + }, { + -26, -7, 11, -8, 5, -1, 17, -14, 1, -15, + -24, -30, -32, -1, -33, 16, -18, 14, 0, 8, + 6, 4, 12, 12, 6, -13, -2, -23, -8, -15, + 4, -17, 5, 36, 18, 30, 8, 22, 10, 14, + }, { + -30, 11, 15, 20, 0, 8, 9, -15, 15, 0, + -5, 9, -23, 6, -8, -13, -13, 7, -5, 3, + 20, 19, 27, 31, 39, -7, 13, -11, 4, -19, + -8, 25, -3, 11, -7, -2, 4, -16, -18, -9, + }, { + -8, -1, 3, 2, -3, -10, -3, -32, 1, -12, + -2, -4, -15, -1, -7, 3, -2, 4, 6, 3, + 26, 15, 29, 17, 40, -17, 0, -26, 2, -27, + 2, 29, 4, 36, 10, 6, -9, 0, -27, 0, + }, { + -40, 2, 29, 22, -7, 14, 12, 5, 7, 7, + -12, 9, -18, 26, -26, -14, -24, -4, -16, -9, + 10, 2, 26, 18, 26, -7, 1, -15, 1, -27, + -2, 0, 4, 11, 17, 21, 16, -1, 7, 3, + }, { + -18, -9, 17, 4, -11, -3, 0, -11, -7, -4, + -10, -3, -10, 18, -24, 3, -14, -7, -4, -10, + 16, -1, 27, 4, 27, -17, -12, -30, 0, -35, + 9, 3, 12, 36, 35, 30, 2, 13, -2, 11, + }, { + -66, -8, -23, -11, 14, 5, 17, 16, 19, 2, + 3, -5, -18, -17, 10, 0, -1, 23, -6, 20, + -15, 18, -14, 22, 5, 10, 44, 23, 2, 26, + -9, 3, -4, -14, -12, -29, -7, -16, -7, -18, + }, { + -44, -20, -34, -29, 10, -13, 4, 0, 4, -9, + 5, -19, -10, -24, 11, 17, 8, 20, 5, 19, + -9, 14, -12, 9, 6, 0, 30, 9, 0, 19, + 2, 7, 2, 10, 5, -20, -21, -1, -17, -9, + }, { + -77, -16, -9, -9, 6, 11, 21, 37, 10, 10, + -4, -5, -13, 3, -7, 0, -13, 11, -17, 6, + -25, 1, -15, 9, -7, 9, 32, 19, 0, 18, + -2, -22, 3, -15, 12, -5, 4, -2, 17, -5, + }, { + -55, -28, -21, -27, 2, -7, 8, 20, -4, -1, + -1, -18, -5, -4, -5, 16, -2, 8, -5, 5, + -19, -2, -14, -3, -6, 0, 18, 4, -2, 11, + 8, -18, 11, 10, 29, 3, -10, 13, 8, 3, + }, { + -58, -9, -16, 1, -2, 2, 0, 19, 10, 13, + 17, 21, 3, 3, 19, -12, 2, 0, -10, 1, + -5, 12, 0, 15, 26, 5, 34, 16, 11, 7, + -4, 25, 2, -14, 3, -29, -13, -25, -20, -20, + }, { + -36, -21, -28, -16, -6, -16, -12, 2, -4, 2, + 20, 7, 11, -4, 20, 4, 12, -2, 1, 0, + 0, 8, 2, 2, 27, -4, 21, 2, 9, 0, + 6, 29, 9, 10, 21, -21, -28, -10, -29, -11, + }, { + -69, -17, -3, 3, -10, 8, 3, 40, 1, 21, + 10, 21, 8, 23, 1, -13, -8, -11, -21, -11, + -15, -4, 0, 2, 13, 5, 23, 12, 7, 0, + 1, 0, 10, -14, 28, -5, -1, -11, 5, -7, + }, { + -47, -30, -15, -14, -14, -9, -9, 23, -13, 10, + 12, 7, 16, 15, 3, 3, 1, -14, -9, -12, + -9, -8, 0, -10, 14, -4, 9, -2, 5, -8, + 13, 3, 18, 10, 45, 3, -16, 4, -4, 0, + }, { + -79, 11, -15, 4, 18, 23, 20, 5, 30, 7, + -7, -2, -21, -21, -8, -3, -10, 28, 4, 31, + 6, 25, -3, 37, 4, -7, 20, 0, 4, 4, + -11, 7, -6, 8, -27, -22, -14, -12, -5, -16, + }, { + -57, 0, -27, -13, 14, 5, 7, -11, 15, -4, + -5, -16, -13, -29, -6, 13, 0, 25, 16, 31, + 12, 22, -2, 23, 6, -16, 7, -14, 2, -3, + 0, 12, 0, 33, -9, -13, -28, 3, -14, -7, + }, { + -90, 3, -2, 6, 10, 29, 24, 26, 21, 15, + -15, -2, -16, -1, -25, -4, -21, 16, -6, 18, + -3, 8, -5, 24, -8, -7, 9, -4, 1, -3, + -5, -18, 1, 7, -2, 1, -2, 1, 19, -3, + }, { + -67, -8, -14, -11, 7, 11, 11, 9, 7, 3, + -13, -16, -8, -9, -24, 12, -10, 13, 5, 17, + 2, 4, -3, 10, -6, -17, -4, -19, 0, -11, + 6, -13, 9, 33, 14, 10, -16, 17, 10, 4, + }, { + -71, 10, -9, 17, 1, 20, 3, 8, 21, 18, + 6, 24, 0, -1, 0, -16, -6, 5, 0, 13, + 17, 19, 11, 29, 25, -11, 11, -6, 13, -15, + -7, 29, 0, 8, -11, -22, -20, -21, -17, -18, + }, { + -49, -2, -21, 0, -1, 2, -9, -8, 6, 6, + 8, 10, 8, -9, 2, 0, 4, 2, 13, 12, + 23, 15, 12, 16, 26, -21, -2, -21, 11, -23, + 4, 33, 7, 33, 6, -13, -34, -5, -27, -10, + }, { + -82, 1, 4, 19, -6, 27, 6, 29, 12, 26, + -1, 24, 5, 18, -17, -17, -17, -6, -10, 0, + 7, 2, 9, 16, 12, -11, 0, -11, 9, -23, + 0, 3, 8, 8, 13, 1, -8, -7, 7, -6, + }, { + -60, -10, -7, 1, -9, 8, -6, 13, -2, 15, + 1, 10, 13, 11, -15, 0, -6, -9, 1, 0, + 13, -1, 11, 3, 13, -21, -13, -26, 7, -31, + 10, 7, 16, 33, 31, 10, -22, 8, -1, 2, + }, { + -3, 7, -5, -5, 8, -2, 17, -9, 18, -24, + -2, -19, -10, -4, 28, 17, 5, 28, -2, 7, + -4, 15, 7, 8, 6, 23, 13, 21, -14, 20, + -17, -18, -11, -33, -30, -11, 23, -13, -5, -9, + }, { + 18, -4, -17, -23, 4, -20, 4, -26, 3, -36, + 0, -32, -2, -12, 29, 34, 16, 24, 10, 6, + 0, 12, 8, -4, 8, 13, 0, 6, -16, 12, + -5, -13, -3, -7, -13, -3, 8, 2, -14, 0, + }, { + -13, 0, 8, -3, 0, 4, 21, 11, 9, -16, + -10, -18, -5, 16, 10, 16, -5, 15, -13, -5, + -15, -1, 6, -4, -6, 23, 2, 16, -17, 12, + -10, -44, -3, -33, -6, 12, 34, 1, 20, 3, + }, { + 8, -12, -3, -21, -3, -14, 8, -5, -4, -28, + -7, -32, 2, 8, 12, 34, 4, 12, -1, -6, + -9, -4, 7, -17, -4, 13, -11, 1, -19, 4, + 0, -39, 4, -7, 11, 21, 20, 16, 10, 11, + }, { + 4, 6, 0, 7, -8, -4, 0, -6, 9, -13, + 11, 7, 11, 15, 37, 4, 9, 5, -5, -11, + 5, 9, 22, 1, 27, 18, 4, 14, -5, 0, + -12, 3, -4, -32, -14, -12, 17, -22, -17, -11, + }, { + 26, -6, -11, -10, -12, -23, -12, -23, -5, -24, + 13, -5, 19, 8, 38, 21, 20, 2, 6, -12, + 11, 5, 23, -11, 29, 9, -9, 0, -7, -6, + -1, 7, 2, -7, 3, -3, 2, -6, -27, -3, + }, { + -6, -2, 14, 9, -16, 1, 3, 14, 0, -5, + 3, 8, 16, 36, 19, 3, -1, -6, -17, -24, + -4, -7, 21, -11, 14, 18, -7, 9, -9, -7, + -6, -22, 3, -33, 10, 11, 28, -7, 7, 0, + }, { + 16, -14, 2, -8, -20, -17, -9, -2, -14, -16, + 6, -5, 24, 28, 21, 20, 8, -9, -4, -25, + 1, -11, 22, -24, 15, 8, -21, -5, -11, -14, + 5, -18, 11, -7, 27, 20, 14, 7, -1, 9, + }, { + -16, 27, 2, 10, 13, 16, 20, -20, 29, -20, + -14, -16, -13, -8, 9, 13, -2, 33, 9, 19, + 17, 23, 17, 22, 6, 6, -9, -2, -12, -2, + -20, -13, -13, -10, -45, -4, 16, -8, -2, -7, + }, { + 5, 15, -9, -7, 9, -2, 8, -37, 14, -31, + -11, -29, -5, -16, 11, 30, 7, 29, 21, 18, + 23, 19, 18, 9, 7, -3, -23, -17, -14, -9, + -8, -9, -6, 15, -27, 4, 2, 6, -12, 1, + }, { + -26, 19, 15, 12, 5, 22, 24, 0, 21, -12, + -21, -15, -8, 11, -7, 12, -14, 20, -2, 6, + 7, 6, 16, 9, -6, 5, -21, -7, -15, -10, + -13, -39, -5, -10, -20, 19, 28, 5, 22, 5, + }, { + -4, 6, 3, -5, 1, 4, 11, -16, 6, -23, + -19, -29, 0, 3, -6, 30, -3, 17, 10, 5, + 13, 2, 17, -3, -5, -3, -35, -21, -17, -17, + -2, -35, 2, 15, -3, 28, 13, 21, 13, 13, + }, { + -8, 25, 8, 23, -3, 13, 3, -17, 20, -8, + 0, 10, 8, 11, 18, 0, 1, 10, 5, 0, + 28, 17, 32, 15, 26, 1, -19, -9, -3, -21, + -15, 7, -6, -9, -29, -5, 10, -17, -15, -9, + }, { + 13, 13, -3, 5, -7, -4, -9, -34, 5, -20, + 2, -3, 16, 3, 20, 17, 11, 7, 17, 0, + 34, 13, 33, 2, 28, -8, -32, -24, -5, -29, + -3, 12, 0, 15, -11, 3, -3, -2, -24, -1, + }, { + -18, 17, 21, 25, -11, 19, 6, 3, 11, 0, + -7, 11, 13, 31, 1, 0, -9, -1, -5, -12, + 18, 0, 31, 2, 13, 1, -30, -14, -7, -29, + -9, -18, 1, -10, -4, 18, 22, -3, 10, 2, + }, { + 3, 5, 9, 7, -15, 1, -5, -13, -2, -12, + -5, -2, 21, 23, 2, 16, 0, -5, 6, -13, + 23, -3, 32, -10, 15, -8, -44, -28, -9, -37, + 2, -13, 9, 15, 12, 27, 7, 12, 0, 11, + }, { + -44, 6, -30, -8, 9, 10, 11, 14, 23, -5, + 8, -4, 14, -12, 37, 14, 12, 26, 4, 16, + -8, 16, -9, 7, -6, 19, 12, 25, -5, 24, + -15, -13, -8, -36, -34, -31, -1, -18, -4, -18, + }, { + -22, -5, -42, -26, 6, -8, -1, -2, 9, -17, + 10, -18, 21, -19, 39, 31, 23, 23, 16, 15, + -2, 12, -7, -6, -5, 9, -1, 10, -7, 16, + -4, -9, 0, -10, -17, -22, -16, -2, -14, -9, + }, { + -55, -1, -17, -6, 1, 16, 15, 35, 15, 2, + 0, -4, 19, 8, 20, 13, 1, 14, -7, 3, + -18, 0, -10, -5, -19, 19, 0, 21, -8, 16, + -9, -39, 0, -36, -10, -7, 9, -4, 20, -5, + }, { + -33, -13, -29, -24, -1, -1, 2, 18, 0, -9, + 3, -17, 27, 0, 21, 30, 12, 11, 5, 2, + -12, -4, -9, -19, -18, 9, -13, 6, -11, 8, + 2, -35, 8, -10, 7, 1, -4, 11, 10, 2, + }, { + -36, 5, -24, 4, -7, 7, -6, 17, 14, 5, + 22, 22, 35, 8, 46, 1, 17, 3, 0, -2, + 2, 10, 5, 0, 14, 15, 2, 18, 2, 4, + -11, 7, -1, -36, -18, -32, -7, -27, -17, -20, + }, { + -14, -7, -36, -13, -10, -10, -18, 0, 0, -5, + 25, 8, 43, 0, 48, 18, 27, 0, 12, -3, + 7, 6, 7, -13, 15, 5, -11, 3, 0, -2, + 0, 12, 6, -10, 0, -23, -22, -11, -26, -12, + }, { + -47, -3, -11, 6, -15, 13, -2, 38, 6, 13, + 15, 22, 40, 28, 28, 0, 5, -8, -10, -15, + -7, -7, 4, -13, 1, 14, -9, 14, 0, -2, + -4, -18, 7, -36, 6, -8, 3, -13, 7, -8, + }, { + -25, -15, -22, -11, -18, -4, -15, 22, -8, 2, + 17, 9, 48, 20, 30, 17, 16, -11, 1, -16, + -2, -10, 5, -26, 2, 4, -22, 0, -2, -10, + 6, -13, 14, -10, 23, 0, -10, 2, -1, 0, + }, { + -57, 26, -22, 7, 14, 28, 14, 3, 35, 0, + -3, -1, 11, -16, 18, 10, 4, 31, 15, 28, + 14, 23, 1, 21, -7, 2, -11, 1, -3, 1, + -18, -9, -10, -13, -49, -24, -8, -14, -2, -16, + }, { + -35, 14, -34, -10, 10, 10, 1, -12, 20, -12, + 0, -15, 18, -24, 20, 27, 14, 28, 27, 27, + 20, 19, 2, 8, -5, -7, -25, -13, -5, -5, + -6, -5, -2, 12, -31, -15, -23, 1, -12, -8, + }, { + -68, 18, -9, 9, 6, 35, 18, 25, 26, 7, + -10, -1, 16, 3, 1, 9, -6, 19, 4, 15, + 4, 6, 0, 8, -20, 2, -23, -2, -7, -5, + -12, -35, -1, -13, -24, 0, 3, 0, 22, -4, + }, { + -46, 6, -21, -8, 2, 16, 5, 8, 11, -4, + -8, -15, 24, -4, 2, 26, 3, 16, 16, 14, + 9, 2, 1, -4, -19, -7, -36, -17, -9, -13, + 0, -31, 5, 12, -7, 8, -11, 15, 13, 4, + }, { + -49, 24, -16, 20, -2, 26, -2, 7, 25, 10, + 11, 25, 32, 3, 27, -2, 8, 8, 11, 9, + 24, 17, 16, 14, 13, -2, -20, -5, 4, -17, + -14, 12, -3, -13, -33, -25, -14, -23, -15, -19, + }, { + -27, 12, -28, 2, -6, 7, -15, -9, 11, -1, + 13, 11, 40, -4, 29, 14, 19, 5, 23, 8, + 30, 13, 17, 0, 14, -12, -34, -20, 2, -25, + -2, 16, 4, 12, -15, -16, -29, -7, -24, -10, + }, { + -60, 16, -3, 22, -10, 32, 0, 28, 17, 18, + 3, 25, 37, 23, 10, -3, -2, -3, 0, -3, + 14, 0, 14, 1, 0, -2, -32, -9, 1, -25, + -7, -13, 5, -13, -8, -1, -2, -8, 10, -6, + }, { + -38, 4, -15, 4, -14, 13, -12, 11, 2, 6, + 6, 11, 45, 16, 11, 13, 7, -6, 12, -4, + 20, -3, 16, -12, 1, -12, -46, -24, 0, -33, + 3, -9, 12, 12, 8, 7, -17, 6, 0, 2 + } +}; - ractx->lpc_coef[0] = ractx->lpc_tables[0]; - ractx->lpc_coef[1] = ractx->lpc_tables[1]; +const int8_t ff_cb2_vects[128][40]={ + { + 73, -32, -60, -15, -26, 59, 2, -33, 30, -10, + -3, -17, 8, 30, -1, -26, -4, -22, 10, 16, + -36, -5, -11, 56, 37, 6, -10, -5, -13, -3, + 6, -5, 11, 4, -19, -5, -16, 41, 24, 13, + }, { + 4, -11, -37, 23, -5, 46, -2, -29, -5, -39, + -21, -9, 0, 49, 12, -9, -16, -26, 22, 15, + -45, -20, -5, 40, 22, 17, -26, 31, -14, 2, + -14, 10, 30, 20, -27, -9, -39, 39, 18, 5, + }, { + 34, -25, -48, -28, -11, 34, -2, -41, 9, -7, + -17, 21, 20, 24, -17, -33, 0, -24, 10, 42, + 3, -5, 10, 42, 11, 8, -3, 3, 16, 9, + 22, -2, 0, -33, -10, 18, 7, 58, 10, 28, + }, { + -34, -4, -25, 10, 9, 21, -7, -36, -26, -36, + -35, 28, 12, 42, -3, -16, -12, -28, 21, 42, + -5, -21, 16, 26, -4, 19, -19, 39, 15, 15, + 1, 13, 19, -17, -17, 14, -15, 55, 4, 19, + }, { + 28, -20, -51, -14, -6, 7, 0, -26, 27, -4, + 18, -40, -6, 16, -1, -15, 0, -55, -5, -16, + -19, 14, -3, 49, 14, 1, -22, -30, -12, 0, + 24, 15, 9, -17, -45, -29, 4, 28, 51, 35, + }, { + -40, 0, -28, 24, 14, -5, -4, -21, -7, -33, + 0, -32, -15, 35, 12, 1, -11, -58, 5, -16, + -28, 0, 1, 33, 0, 11, -39, 5, -14, 6, + 3, 31, 28, -1, -53, -33, -19, 25, 46, 26, + }, { + -11, -14, -39, -27, 9, -17, -4, -33, 6, 0, + 4, -1, 5, 10, -17, -22, 5, -57, -5, 9, + 20, 13, 18, 35, -11, 3, -16, -22, 17, 13, + 40, 19, -1, -55, -35, -5, 27, 44, 37, 49, + }, { + -80, 6, -16, 11, 30, -30, -9, -28, -28, -29, + -13, 6, -2, 28, -3, -5, -7, -60, 5, 9, + 11, -1, 24, 19, -27, 13, -32, 13, 15, 19, + 19, 35, 17, -39, -43, -9, 4, 42, 32, 41, + }, { + 78, -21, -43, 4, -38, 17, 17, -5, 55, 24, + -15, -36, 14, 4, 24, -24, 12, 5, 17, 31, + -54, -5, -2, 27, 43, -12, 2, 9, -9, -15, + 22, -3, 28, 21, -20, 3, 20, 28, 9, -5, + }, { + 9, -1, -20, 43, -17, 3, 12, 0, 20, -4, + -33, -29, 6, 22, 38, -7, 0, 1, 29, 30, + -63, -21, 3, 11, 27, -1, -14, 45, -10, -9, + 1, 12, 47, 37, -28, 0, -2, 26, 4, -13, + }, { + 39, -14, -30, -8, -22, -8, 12, -12, 34, 27, + -29, 2, 26, -2, 8, -31, 16, 3, 17, 57, + -14, -6, 19, 13, 16, -10, 8, 17, 20, -2, + 38, 0, 17, -16, -11, 27, 44, 45, -4, 8, + }, { + -29, 5, -7, 30, -1, -21, 7, -7, 0, 0, + -47, 9, 18, 15, 22, -14, 4, 0, 28, 57, + -23, -21, 25, -2, 1, 0, -7, 53, 19, 3, + 17, 15, 36, 0, -19, 24, 21, 43, -9, 0, + }, { + 33, -10, -34, 5, -17, -35, 15, 1, 53, 30, + 6, -59, 0, -10, 24, -13, 17, -27, 1, -1, + -37, 13, 4, 20, 20, -18, -10, -16, -8, -11, + 39, 18, 26, 0, -46, -20, 41, 15, 37, 15, + }, { + -35, 10, -11, 44, 3, -48, 10, 6, 17, 2, + -11, -51, -8, 8, 38, 3, 4, -31, 12, -2, + -46, -1, 10, 4, 5, -7, -26, 19, -10, -5, + 18, 34, 45, 15, -54, -24, 18, 13, 31, 7, + }, { + -5, -3, -21, -7, -2, -60, 10, -5, 32, 34, + -7, -20, 11, -16, 8, -20, 21, -29, 1, 24, + 2, 13, 27, 6, -5, -15, -3, -8, 21, 1, + 55, 21, 15, -38, -37, 3, 65, 32, 23, 30, + }, { + -74, 17, 0, 31, 18, -73, 5, 0, -3, 5, + -25, -12, 3, 1, 22, -3, 9, -33, 12, 24, + -6, -2, 33, -9, -21, -5, -20, 27, 19, 7, + 34, 37, 34, -22, -44, 0, 41, 29, 17, 21, + }, { + 76, -35, -31, -28, -49, 43, -40, 0, 29, -14, + 8, 5, 10, 18, -26, -46, 0, 7, 6, 3, + -25, -7, -2, 40, 28, 14, 18, -3, -27, -28, + -8, -45, -13, 34, -13, -27, -15, 31, 12, 3, + }, { + 7, -15, -9, 9, -28, 29, -45, 5, -6, -43, + -9, 12, 2, 36, -12, -30, -11, 3, 17, 3, + -34, -22, 3, 24, 12, 24, 2, 32, -28, -22, + -29, -29, 5, 50, -21, -31, -38, 29, 7, -5, + }, { + 36, -29, -19, -41, -34, 18, -45, -6, 8, -10, + -5, 43, 23, 11, -42, -53, 5, 5, 6, 30, + 14, -8, 20, 26, 1, 16, 25, 4, 3, -15, + 7, -41, -23, -3, -4, -3, 8, 48, -1, 17, + }, { + -32, -8, 3, -2, -13, 4, -50, -1, -27, -39, + -23, 51, 15, 30, -27, -37, -7, 1, 17, 29, + 5, -23, 25, 10, -14, 26, 8, 41, 1, -9, + -13, -26, -5, 12, -12, -7, -14, 45, -6, 9, + }, { + 31, -24, -23, -27, -29, -9, -43, 8, 26, -7, + 30, -17, -4, 3, -26, -35, 5, -24, -10, -28, + -9, 12, 5, 33, 5, 8, 5, -29, -26, -24, + 9, -23, -14, 12, -39, -52, 5, 18, 39, 24, + }, { + -37, -3, 0, 10, -7, -22, -48, 12, -8, -36, + 12, -9, -12, 22, -12, -19, -6, -28, 0, -29, + -18, -3, 11, 17, -10, 18, -10, 7, -27, -18, + -11, -7, 3, 28, -47, -55, -18, 15, 34, 16, + }, { + -8, -17, -10, -40, -13, -34, -47, 0, 5, -4, + 16, 21, 8, -2, -42, -43, 10, -26, -10, -2, + 31, 11, 27, 19, -21, 10, 12, -20, 3, -11, + 25, -20, -25, -25, -29, -28, 28, 34, 25, 38, + }, { + -77, 2, 11, -1, 7, -47, -52, 5, -29, -33, + -1, 28, 0, 15, -28, -26, -2, -30, 0, -2, + 22, -4, 33, 3, -36, 21, -3, 15, 2, -5, + 4, -4, -6, -9, -37, -31, 5, 32, 20, 30, + }, { + 81, -25, -14, -8, -61, 0, -25, 28, 54, 20, + -3, -14, 17, -8, 0, -44, 16, 35, 13, 18, + -43, -7, 6, 11, 33, -4, 30, 11, -22, -40, + 6, -43, 3, 50, -14, -18, 22, 18, -1, -16, + }, { + 12, -4, 8, 29, -39, -12, -30, 33, 19, -8, + -21, -6, 8, 9, 13, -28, 4, 31, 24, 18, + -52, -23, 12, -4, 18, 5, 14, 47, -24, -34, + -14, -27, 22, 66, -22, -22, -1, 16, -6, -24, + }, { + 41, -18, -2, -21, -45, -24, -30, 21, 33, 24, + -17, 24, 29, -15, -16, -51, 21, 33, 13, 45, + -3, -8, 28, -2, 7, -2, 37, 19, 7, -27, + 22, -39, -7, 12, -5, 5, 45, 35, -15, -1, + }, { + -27, 1, 20, 17, -24, -38, -35, 26, -1, -4, + -35, 32, 21, 3, -2, -35, 8, 29, 24, 44, + -12, -24, 34, -18, -8, 7, 21, 55, 5, -21, + 2, -23, 11, 28, -13, 1, 22, 33, -21, -10, + }, { + 36, -13, -5, -7, -40, -51, -28, 36, 52, 27, + 18, -36, 2, -22, 0, -33, 21, 2, -3, -13, + -26, 11, 14, 4, 10, -10, 18, -14, -22, -36, + 24, -21, 1, 28, -40, -42, 42, 5, 25, 5, + }, { + -32, 6, 17, 31, -19, -65, -33, 41, 16, -1, + 0, -29, -6, -4, 13, -17, 9, -1, 8, -14, + -35, -3, 19, -11, -4, 0, 1, 21, -23, -30, + 3, -5, 20, 44, -48, -46, 19, 3, 20, -3, + }, { + -3, -7, 6, -20, -25, -77, -32, 29, 31, 30, + 4, 2, 14, -29, -16, -40, 26, 0, -3, 12, + 13, 10, 36, -9, -15, -8, 24, -6, 7, -22, + 40, -17, -8, -9, -31, -18, 66, 22, 11, 19, + }, { + -72, 13, 29, 18, -4, -90, -37, 34, -4, 1, + -13, 9, 6, -11, -2, -24, 13, -3, 7, 11, + 4, -4, 42, -25, -31, 1, 8, 29, 6, -17, + 19, -2, 10, 6, -38, -22, 42, 19, 6, 11, + }, { + 116, -20, -68, -30, -28, 83, 28, -18, 32, -22, + -13, -21, 5, 28, 5, -7, -24, -8, -22, 17, + -23, 30, -25, 45, 15, -9, -11, -18, 22, -10, + 4, -2, 19, -12, 23, 3, -43, 2, 12, -4, + }, { + 47, 0, -45, 7, -7, 69, 23, -13, -2, -51, + -32, -14, -3, 47, 19, 8, -37, -11, -10, 16, + -32, 15, -19, 29, 0, 1, -28, 18, 20, -4, + -16, 13, 38, 3, 15, 0, -66, 0, 7, -13, + }, { + 77, -13, -56, -43, -13, 57, 23, -26, 11, -19, + -27, 16, 17, 22, -10, -15, -19, -10, -22, 43, + 16, 30, -2, 31, -11, -6, -5, -9, 52, 2, + 20, 0, 8, -50, 33, 27, -19, 19, -1, 9, + }, { + 8, 6, -33, -4, 7, 44, 18, -21, -23, -48, + -46, 24, 9, 40, 3, 1, -32, -13, -11, 43, + 7, 14, 3, 15, -26, 3, -21, 26, 50, 8, + 0, 16, 27, -34, 25, 23, -43, 17, -6, 1, + }, { + 71, -9, -59, -29, -8, 30, 26, -11, 30, -16, + 8, -44, -9, 14, 5, 2, -19, -40, -38, -15, + -7, 50, -17, 38, -7, -14, -24, -43, 22, -6, + 22, 19, 17, -34, -2, -20, -23, -10, 39, 16, + }, { + 2, 11, -36, 9, 13, 17, 21, -6, -5, -45, + -10, -36, -18, 33, 19, 19, -31, -44, -27, -15, + -16, 34, -11, 22, -22, -4, -40, -7, 21, 0, + 1, 35, 36, -18, -10, -24, -46, -12, 34, 8, + }, { + 32, -2, -47, -42, 7, 5, 21, -18, 9, -12, + -5, -5, 2, 8, -10, -4, -14, -42, -38, 10, + 33, 49, 5, 24, -33, -12, -17, -35, 52, 6, + 38, 22, 7, -72, 7, 3, 0, 6, 25, 30, + }, { + -36, 18, -24, -3, 28, -7, 16, -13, -26, -41, + -24, 1, -5, 26, 3, 12, -27, -46, -27, 10, + 24, 34, 10, 8, -49, -2, -34, 0, 51, 12, + 17, 38, 25, -56, 0, 0, -22, 3, 20, 22, + }, { + 121, -9, -50, -10, -40, 40, 43, 9, 58, 12, + -25, -41, 11, 2, 31, -5, -8, 19, -15, 32, + -41, 30, -16, 16, 20, -28, 0, -3, 26, -22, + 19, 0, 36, 4, 22, 12, -6, -9, -1, -24, + }, { + 52, 10, -27, 27, -18, 26, 38, 14, 23, -16, + -44, -33, 3, 20, 45, 10, -20, 15, -3, 31, + -50, 14, -10, 0, 5, -17, -15, 32, 24, -16, + -1, 15, 55, 20, 14, 8, -29, -12, -7, -32, + }, { + 82, -3, -38, -23, -24, 15, 38, 2, 37, 15, + -39, -2, 23, -4, 15, -12, -3, 17, -15, 58, + -1, 29, 6, 2, -5, -26, 7, 4, 56, -9, + 35, 3, 25, -33, 32, 36, 17, 7, -15, -9, + }, { + 13, 17, -15, 15, -3, 1, 33, 7, 1, -12, + -58, 5, 15, 13, 29, 3, -16, 13, -4, 57, + -10, 13, 11, -13, -21, -15, -9, 40, 55, -3, + 14, 19, 44, -17, 24, 32, -5, 4, -21, -18, + }, { + 76, 1, -41, -9, -19, -12, 41, 17, 55, 18, + -3, -63, -3, -12, 30, 5, -3, -12, -31, 0, + -24, 49, -8, 9, -1, -33, -12, -29, 27, -18, + 37, 21, 34, -17, -3, -11, 14, -23, 25, -2, + }, { + 7, 22, -18, 29, 1, -25, 36, 21, 20, -9, + -22, -56, -11, 6, 45, 21, -15, -16, -20, -1, + -33, 34, -2, -6, -17, -23, -28, 6, 25, -12, + 16, 37, 53, -1, -11, -15, -8, -25, 20, -11, + }, { + 37, 8, -29, -22, -4, -37, 36, 9, 34, 22, + -17, -24, 8, -18, 15, -2, 1, -14, -31, 25, + 15, 48, 13, -4, -28, -31, -5, -21, 57, -4, + 53, 24, 23, -55, 6, 12, 37, -6, 11, 11, + }, { + -31, 28, -6, 16, 16, -50, 31, 14, 0, -6, + -36, -17, 0, 0, 29, 14, -11, -18, -20, 25, + 6, 33, 19, -20, -43, -21, -21, 14, 55, 0, + 32, 40, 42, -39, -1, 8, 14, -8, 6, 3, + }, { + 119, -24, -39, -44, -51, 66, -14, 15, 31, -26, + -1, 0, 7, 16, -19, -28, -19, 22, -26, 4, + -13, 28, -16, 29, 5, -1, 16, -16, 8, -35, + -10, -42, -4, 17, 29, -19, -42, -7, 0, -15, + }, { + 50, -3, -16, -5, -30, 53, -19, 20, -3, -55, + -19, 8, 0, 34, -5, -11, -32, 18, -15, 4, + -22, 13, -10, 13, -9, 8, 0, 19, 7, -29, + -31, -26, 13, 33, 21, -22, -65, -9, -4, -23, + }, { + 79, -17, -27, -56, -36, 41, -19, 8, 10, -22, + -15, 39, 20, 9, -35, -35, -15, 20, -26, 31, + 26, 27, 6, 15, -20, 0, 23, -8, 38, -22, + 5, -38, -15, -20, 39, 4, -18, 9, -13, -1, + }, { + 10, 3, -4, -18, -15, 27, -24, 13, -24, -51, + -34, 47, 12, 28, -21, -19, -27, 16, -15, 30, + 17, 12, 12, 0, -36, 10, 7, 27, 37, -16, + -15, -22, 3, -4, 31, 1, -42, 7, -18, -9, + }, { + 74, -12, -30, -42, -30, 14, -16, 23, 29, -19, + 20, -21, -7, 1, -19, -17, -14, -10, -43, -27, + 3, 48, -8, 22, -16, -7, 4, -42, 9, -31, + 6, -20, -6, -4, 3, -43, -22, -20, 28, 5, + }, { + 5, 7, -7, -4, -9, 0, -21, 28, -6, -48, + 2, -14, -15, 20, -5, 0, -27, -14, -32, -28, + -5, 32, -2, 6, -32, 3, -12, -5, 8, -25, + -14, -4, 12, 11, -4, -47, -45, -22, 22, -2, + }, { + 34, -6, -18, -55, -15, -11, -21, 16, 8, -16, + 6, 16, 5, -4, -35, -24, -10, -12, -43, -1, + 43, 47, 14, 8, -43, -5, 10, -34, 39, -18, + 22, -16, -17, -42, 13, -19, 1, -3, 14, 20, + }, { + -34, 14, 4, -17, 5, -24, -26, 20, -27, -45, + -12, 24, -2, 13, -21, -8, -22, -16, -32, -2, + 34, 31, 20, -7, -58, 5, -5, 2, 38, -12, + 2, -1, 1, -26, 5, -23, -21, -6, 8, 11, + }, { + 124, -13, -21, -23, -62, 23, 0, 43, 57, 8, + -13, -18, 14, -10, 6, -26, -3, 49, -19, 19, + -31, 27, -7, 0, 11, -20, 29, -1, 12, -47, + 4, -39, 11, 34, 28, -9, -5, -19, -13, -34, + }, { + 55, 6, 1, 14, -41, 10, -4, 48, 22, -20, + -31, -10, 5, 7, 20, -9, -16, 45, -8, 19, + -40, 12, -1, -15, -4, -10, 12, 34, 11, -41, + -16, -24, 30, 49, 20, -13, -28, -22, -18, -43, + }, { + 84, -6, -9, -36, -47, -1, -4, 36, 36, 12, + -27, 20, 26, -17, -9, -33, 1, 47, -19, 46, + 9, 27, 15, -13, -15, -18, 35, 6, 42, -33, + 20, -36, 1, -4, 38, 14, 18, -2, -27, -20, + }, { + 15, 13, 13, 1, -26, -14, -9, 41, 1, -16, + -46, 27, 18, 1, 4, -16, -11, 43, -8, 45, + 0, 11, 21, -29, -30, -8, 19, 42, 41, -28, + 0, -20, 20, 11, 30, 10, -4, -5, -32, -28, + }, { + 79, -2, -12, -22, -42, -28, -1, 51, 54, 15, + 8, -41, 0, -24, 6, -15, 1, 17, -36, -12, + -14, 47, 0, -6, -11, -26, 16, -27, 13, -43, + 22, -18, 10, 12, 2, -34, 15, -33, 13, -13, + }, { + 10, 18, 10, 15, -21, -41, -6, 56, 19, -13, + -9, -33, -9, -6, 20, 1, -11, 13, -24, -13, + -23, 32, 6, -22, -26, -15, 0, 8, 12, -37, + 1, -2, 28, 27, -5, -37, -7, -35, 8, -21, + }, { + 39, 4, 0, -35, -27, -53, -6, 44, 33, 18, + -5, -2, 11, -31, -9, -22, 6, 15, -36, 13, + 25, 46, 23, -20, -37, -24, 23, -19, 43, -29, + 38, -14, 0, -26, 12, -10, 38, -16, 0, 0, + }, { + -29, 25, 22, 2, -6, -67, -11, 49, -1, -10, + -24, 5, 3, -13, 4, -5, -6, 11, -25, 12, + 16, 31, 28, -36, -53, -13, 6, 16, 42, -24, + 17, 1, 18, -10, 4, -13, 15, -18, -5, -7, + }, { + 29, -25, -22, -2, 6, 67, 11, -49, 1, 10, + 24, -5, -3, 13, -4, 5, 6, -11, 25, -12, + -16, -31, -28, 36, 53, 13, -6, -16, -42, 24, + -17, -1, -18, 10, -4, 13, -15, 18, 5, 7, + }, { + -39, -4, 0, 35, 27, 53, 6, -44, -33, -18, + 5, 2, -11, 31, 9, 22, -6, -15, 36, -13, + -25, -46, -23, 20, 37, 24, -23, 19, -43, 29, + -38, 14, 0, 26, -12, 10, -38, 16, 0, 0, + }, { + -10, -18, -10, -15, 21, 41, 6, -56, -19, 13, + 9, 33, 9, 6, -20, -1, 11, -13, 24, 13, + 23, -32, -6, 22, 26, 15, 0, -8, -12, 37, + -1, 2, -28, -27, 5, 37, 7, 35, -8, 21, + }, { + -79, 2, 12, 22, 42, 28, 1, -51, -54, -15, + -8, 41, 0, 24, -6, 15, -1, -17, 36, 12, + 14, -47, 0, 6, 11, 26, -16, 27, -13, 43, + -22, 18, -10, -12, -2, 34, -15, 33, -13, 13, + }, { + -15, -13, -13, -1, 26, 14, 9, -41, -1, 16, + 46, -27, -18, -1, -4, 16, 11, -43, 8, -45, + 0, -11, -21, 29, 30, 8, -19, -42, -41, 28, + 0, 20, -20, -11, -30, -10, 4, 5, 32, 28, + }, { + -84, 6, 9, 36, 47, 1, 4, -36, -36, -12, + 27, -20, -26, 17, 9, 33, -1, -47, 19, -46, + -9, -27, -15, 13, 15, 18, -35, -6, -42, 33, + -20, 36, -1, 4, -38, -14, -18, 2, 27, 20, + }, { + -55, -6, -1, -14, 41, -10, 4, -48, -22, 20, + 31, 10, -5, -7, -20, 9, 16, -45, 8, -19, + 40, -12, 1, 15, 4, 10, -12, -34, -11, 41, + 16, 24, -30, -49, -20, 13, 28, 22, 18, 43, + }, { + -124, 13, 21, 23, 62, -23, 0, -43, -57, -8, + 13, 18, -14, 10, -6, 26, 3, -49, 19, -19, + 31, -27, 7, 0, -11, 20, -29, 1, -12, 47, + -4, 39, -11, -34, -28, 9, 5, 19, 13, 34, + }, { + 34, -14, -4, 17, -5, 24, 26, -20, 27, 45, + 12, -24, 2, -13, 21, 8, 22, 16, 32, 2, + -34, -31, -20, 7, 58, -5, 5, -2, -38, 12, + -2, 1, -1, 26, -5, 23, 21, 6, -8, -11, + }, { + -34, 6, 18, 55, 15, 11, 21, -16, -8, 16, + -6, -16, -5, 4, 35, 24, 10, 12, 43, 1, + -43, -47, -14, -8, 43, 5, -10, 34, -39, 18, + -22, 16, 17, 42, -13, 19, -1, 3, -14, -20, + }, { + -5, -7, 7, 4, 9, 0, 21, -28, 6, 48, + -2, 14, 15, -20, 5, 0, 27, 14, 32, 28, + 5, -32, 2, -6, 32, -3, 12, 5, -8, 25, + 14, 4, -12, -11, 4, 47, 45, 22, -22, 2, + }, { + -74, 12, 30, 42, 30, -14, 16, -23, -29, 19, + -20, 21, 7, -1, 19, 17, 14, 10, 43, 27, + -3, -48, 8, -22, 16, 7, -4, 42, -9, 31, + -6, 20, 6, 4, -3, 43, 22, 20, -28, -5, + }, { + -10, -3, 4, 18, 15, -27, 24, -13, 24, 51, + 34, -47, -12, -28, 21, 19, 27, -16, 15, -30, + -17, -12, -12, 0, 36, -10, -7, -27, -37, 16, + 15, 22, -3, 4, -31, -1, 42, -7, 18, 9, + }, { + -79, 17, 27, 56, 36, -41, 19, -8, -10, 22, + 15, -39, -20, -9, 35, 35, 15, -20, 26, -31, + -26, -27, -6, -15, 20, 0, -23, 8, -38, 22, + -5, 38, 15, 20, -39, -4, 18, -9, 13, 1, + }, { + -50, 3, 16, 5, 30, -53, 19, -20, 3, 55, + 19, -8, 0, -34, 5, 11, 32, -18, 15, -4, + 22, -13, 10, -13, 9, -8, 0, -19, -7, 29, + 31, 26, -13, -33, -21, 22, 65, 9, 4, 23, + }, { + -119, 24, 39, 44, 51, -66, 14, -15, -31, 26, + 1, 0, -7, -16, 19, 28, 19, -22, 26, -4, + 13, -28, 16, -29, -5, 1, -16, 16, -8, 35, + 10, 42, 4, -17, -29, 19, 42, 7, 0, 15, + }, { + 31, -28, 6, -16, -16, 50, -31, -14, 0, 6, + 36, 17, 0, 0, -29, -14, 11, 18, 20, -25, + -6, -33, -19, 20, 43, 21, 21, -14, -55, 0, + -32, -40, -42, 39, 1, -8, -14, 8, -6, -3, + }, { + -37, -8, 29, 22, 4, 37, -36, -9, -34, -22, + 17, 24, -8, 18, -15, 2, -1, 14, 31, -25, + -15, -48, -13, 4, 28, 31, 5, 21, -57, 4, + -53, -24, -23, 55, -6, -12, -37, 6, -11, -11, + }, { + -7, -22, 18, -29, -1, 25, -36, -21, -20, 9, + 22, 56, 11, -6, -45, -21, 15, 16, 20, 1, + 33, -34, 2, 6, 17, 23, 28, -6, -25, 12, + -16, -37, -53, 1, 11, 15, 8, 25, -20, 11, + }, { + -76, -1, 41, 9, 19, 12, -41, -17, -55, -18, + 3, 63, 3, 12, -30, -5, 3, 12, 31, 0, + 24, -49, 8, -9, 1, 33, 12, 29, -27, 18, + -37, -21, -34, 17, 3, 11, -14, 23, -25, 2, + }, { + -13, -17, 15, -15, 3, -1, -33, -7, -1, 12, + 58, -5, -15, -13, -29, -3, 16, -13, 4, -57, + 10, -13, -11, 13, 21, 15, 9, -40, -55, 3, + -14, -19, -44, 17, -24, -32, 5, -4, 21, 18, + }, { + -82, 3, 38, 23, 24, -15, -38, -2, -37, -15, + 39, 2, -23, 4, -15, 12, 3, -17, 15, -58, + 1, -29, -6, -2, 5, 26, -7, -4, -56, 9, + -35, -3, -25, 33, -32, -36, -17, -7, 15, 9, + }, { + -52, -10, 27, -27, 18, -26, -38, -14, -23, 16, + 44, 33, -3, -20, -45, -10, 20, -15, 3, -31, + 50, -14, 10, 0, -5, 17, 15, -32, -24, 16, + 1, -15, -55, -20, -14, -8, 29, 12, 7, 32, + }, { + -121, 9, 50, 10, 40, -40, -43, -9, -58, -12, + 25, 41, -11, -2, -31, 5, 8, -19, 15, -32, + 41, -30, 16, -16, -20, 28, 0, 3, -26, 22, + -19, 0, -36, -4, -22, -12, 6, 9, 1, 24, + }, { + 36, -18, 24, 3, -28, 7, -16, 13, 26, 41, + 24, -1, 5, -26, -3, -12, 27, 46, 27, -10, + -24, -34, -10, -8, 49, 2, 34, 0, -51, -12, + -17, -38, -25, 56, 0, 0, 22, -3, -20, -22, + }, { + -32, 2, 47, 42, -7, -5, -21, 18, -9, 12, + 5, 5, -2, -8, 10, 4, 14, 42, 38, -10, + -33, -49, -5, -24, 33, 12, 17, 35, -52, -6, + -38, -22, -7, 72, -7, -3, 0, -6, -25, -30, + }, { + -2, -11, 36, -9, -13, -17, -21, 6, 5, 45, + 10, 36, 18, -33, -19, -19, 31, 44, 27, 15, + 16, -34, 11, -22, 22, 4, 40, 7, -21, 0, + -1, -35, -36, 18, 10, 24, 46, 12, -34, -8, + }, { + -71, 9, 59, 29, 8, -30, -26, 11, -30, 16, + -8, 44, 9, -14, -5, -2, 19, 40, 38, 15, + 7, -50, 17, -38, 7, 14, 24, 43, -22, 6, + -22, -19, -17, 34, 2, 20, 23, 10, -39, -16, + }, { + -8, -6, 33, 4, -7, -44, -18, 21, 23, 48, + 46, -24, -9, -40, -3, -1, 32, 13, 11, -43, + -7, -14, -3, -15, 26, -3, 21, -26, -50, -8, + 0, -16, -27, 34, -25, -23, 43, -17, 6, -1, + }, { + -77, 13, 56, 43, 13, -57, -23, 26, -11, 19, + 27, -16, -17, -22, 10, 15, 19, 10, 22, -43, + -16, -30, 2, -31, 11, 6, 5, 9, -52, -2, + -20, 0, -8, 50, -33, -27, 19, -19, 1, -9, + }, { + -47, 0, 45, -7, 7, -69, -23, 13, 2, 51, + 32, 14, 3, -47, -19, -8, 37, 11, 10, -16, + 32, -15, 19, -29, 0, -1, 28, -18, -20, 4, + 16, -13, -38, -3, -15, 0, 66, 0, -7, 13, + }, { + -116, 20, 68, 30, 28, -83, -28, 18, -32, 22, + 13, 21, -5, -28, -5, 7, 24, 8, 22, -17, + 23, -30, 25, -45, -15, 9, 11, 18, -22, 10, + -4, 2, -19, 12, -23, -3, 43, -2, -12, 4, + }, { + 72, -13, -29, -18, 4, 90, 37, -34, 4, -1, + 13, -9, -6, 11, 2, 24, -13, 3, -7, -11, + -4, 4, -42, 25, 31, -1, -8, -29, -6, 17, + -19, 2, -10, -6, 38, 22, -42, -19, -6, -11, + }, { + 3, 7, -6, 20, 25, 77, 32, -29, -31, -30, + -4, -2, -14, 29, 16, 40, -26, 0, 3, -12, + -13, -10, -36, 9, 15, 8, -24, 6, -7, 22, + -40, 17, 8, 9, 31, 18, -66, -22, -11, -19, + }, { + 32, -6, -17, -31, 19, 65, 33, -41, -16, 1, + 0, 29, 6, 4, -13, 17, -9, 1, -8, 14, + 35, 3, -19, 11, 4, 0, -1, -21, 23, 30, + -3, 5, -20, -44, 48, 46, -19, -3, -20, 3, + }, { + -36, 13, 5, 7, 40, 51, 28, -36, -52, -27, + -18, 36, -2, 22, 0, 33, -21, -2, 3, 13, + 26, -11, -14, -4, -10, 10, -18, 14, 22, 36, + -24, 21, -1, -28, 40, 42, -42, -5, -25, -5, + }, { + 27, -1, -20, -17, 24, 38, 35, -26, 1, 4, + 35, -32, -21, -3, 2, 35, -8, -29, -24, -44, + 12, 24, -34, 18, 8, -7, -21, -55, -5, 21, + -2, 23, -11, -28, 13, -1, -22, -33, 21, 10, + }, { + -41, 18, 2, 21, 45, 24, 30, -21, -33, -24, + 17, -24, -29, 15, 16, 51, -21, -33, -13, -45, + 3, 8, -28, 2, -7, 2, -37, -19, -7, 27, + -22, 39, 7, -12, 5, -5, -45, -35, 15, 1, + }, { + -12, 4, -8, -29, 39, 12, 30, -33, -19, 8, + 21, 6, -8, -9, -13, 28, -4, -31, -24, -18, + 52, 23, -12, 4, -18, -5, -14, -47, 24, 34, + 14, 27, -22, -66, 22, 22, 1, -16, 6, 24, + }, { + -81, 25, 14, 8, 61, 0, 25, -28, -54, -20, + 3, 14, -17, 8, 0, 44, -16, -35, -13, -18, + 43, 7, -6, -11, -33, 4, -30, -11, 22, 40, + -6, 43, -3, -50, 14, 18, -22, -18, 1, 16, + }, { + 77, -2, -11, 1, -7, 47, 52, -5, 29, 33, + 1, -28, 0, -15, 28, 26, 2, 30, 0, 2, + -22, 4, -33, -3, 36, -21, 3, -15, -2, 5, + -4, 4, 6, 9, 37, 31, -5, -32, -20, -30, + }, { + 8, 17, 10, 40, 13, 34, 47, 0, -5, 4, + -16, -21, -8, 2, 42, 43, -10, 26, 10, 2, + -31, -11, -27, -19, 21, -10, -12, 20, -3, 11, + -25, 20, 25, 25, 29, 28, -28, -34, -25, -38, + }, { + 37, 3, 0, -10, 7, 22, 48, -12, 8, 36, + -12, 9, 12, -22, 12, 19, 6, 28, 0, 29, + 18, 3, -11, -17, 10, -18, 10, -7, 27, 18, + 11, 7, -3, -28, 47, 55, 18, -15, -34, -16, + }, { + -31, 24, 23, 27, 29, 9, 43, -8, -26, 7, + -30, 17, 4, -3, 26, 35, -5, 24, 10, 28, + 9, -12, -5, -33, -5, -8, -5, 29, 26, 24, + -9, 23, 14, -12, 39, 52, -5, -18, -39, -24, + }, { + 32, 8, -3, 2, 13, -4, 50, 1, 27, 39, + 23, -51, -15, -30, 27, 37, 7, -1, -17, -29, + -5, 23, -25, -10, 14, -26, -8, -41, -1, 9, + 13, 26, 5, -12, 12, 7, 14, -45, 6, -9, + }, { + -36, 29, 19, 41, 34, -18, 45, 6, -8, 10, + 5, -43, -23, -11, 42, 53, -5, -5, -6, -30, + -14, 8, -20, -26, -1, -16, -25, -4, -3, 15, + -7, 41, 23, 3, 4, 3, -8, -48, 1, -17, + }, { + -7, 15, 9, -9, 28, -29, 45, -5, 6, 43, + 9, -12, -2, -36, 12, 30, 11, -3, -17, -3, + 34, 22, -3, -24, -12, -24, -2, -32, 28, 22, + 29, 29, -5, -50, 21, 31, 38, -29, -7, 5, + }, { + -76, 35, 31, 28, 49, -43, 40, 0, -29, 14, + -8, -5, -10, -18, 26, 46, 0, -7, -6, -3, + 25, 7, 2, -40, -28, -14, -18, 3, 27, 28, + 8, 45, 13, -34, 13, 27, 15, -31, -12, -3, + }, { + 74, -17, 0, -31, -18, 73, -5, 0, 3, -5, + 25, 12, -3, -1, -22, 3, -9, 33, -12, -24, + 6, 2, -33, 9, 21, 5, 20, -27, -19, -7, + -34, -37, -34, 22, 44, 0, -41, -29, -17, -21, + }, { + 5, 3, 21, 7, 2, 60, -10, 5, -32, -34, + 7, 20, -11, 16, -8, 20, -21, 29, -1, -24, + -2, -13, -27, -6, 5, 15, 3, 8, -21, -1, + -55, -21, -15, 38, 37, -3, -65, -32, -23, -30, + }, { + 35, -10, 11, -44, -3, 48, -10, -6, -17, -2, + 11, 51, 8, -8, -38, -3, -4, 31, -12, 2, + 46, 1, -10, -4, -5, 7, 26, -19, 10, 5, + -18, -34, -45, -15, 54, 24, -18, -13, -31, -7, + }, { + -33, 10, 34, -5, 17, 35, -15, -1, -53, -30, + -6, 59, 0, 10, -24, 13, -17, 27, -1, 1, + 37, -13, -4, -20, -20, 18, 10, 16, 8, 11, + -39, -18, -26, 0, 46, 20, -41, -15, -37, -15, + }, { + 29, -5, 7, -30, 1, 21, -7, 7, 0, 0, + 47, -9, -18, -15, -22, 14, -4, 0, -28, -57, + 23, 21, -25, 2, -1, 0, 7, -53, -19, -3, + -17, -15, -36, 0, 19, -24, -21, -43, 9, 0, + }, { + -39, 14, 30, 8, 22, 8, -12, 12, -34, -27, + 29, -2, -26, 2, -8, 31, -16, -3, -17, -57, + 14, 6, -19, -13, -16, 10, -8, -17, -20, 2, + -38, 0, -17, 16, 11, -27, -44, -45, 4, -8, + }, { + -9, 1, 20, -43, 17, -3, -12, 0, -20, 4, + 33, 29, -6, -22, -38, 7, 0, -1, -29, -30, + 63, 21, -3, -11, -27, 1, 14, -45, 10, 9, + -1, -12, -47, -37, 28, 0, 2, -26, -4, 13, + }, { + -78, 21, 43, -4, 38, -17, -17, 5, -55, -24, + 15, 36, -14, -4, -24, 24, -12, -5, -17, -31, + 54, 5, 2, -27, -43, 12, -2, -9, 9, 15, + -22, 3, -28, -21, 20, -3, -20, -28, -9, 5, + }, { + 80, -6, 16, -11, -30, 30, 9, 28, 28, 29, + 13, -6, 2, -28, 3, 5, 7, 60, -5, -9, + -11, 1, -24, -19, 27, -13, 32, -13, -15, -19, + -19, -35, -17, 39, 43, 9, -4, -42, -32, -41, + }, { + 11, 14, 39, 27, -9, 17, 4, 33, -6, 0, + -4, 1, -5, -10, 17, 22, -5, 57, 5, -9, + -20, -13, -18, -35, 11, -3, 16, 22, -17, -13, + -40, -19, 1, 55, 35, 5, -27, -44, -37, -49, + }, { + 40, 0, 28, -24, -14, 5, 4, 21, 7, 33, + 0, 32, 15, -35, -12, -1, 11, 58, -5, 16, + 28, 0, -1, -33, 0, -11, 39, -5, 14, -6, + -3, -31, -28, 1, 53, 33, 19, -25, -46, -26, + }, { + -28, 20, 51, 14, 6, -7, 0, 26, -27, 4, + -18, 40, 6, -16, 1, 15, 0, 55, 5, 16, + 19, -14, 3, -49, -14, -1, 22, 30, 12, 0, + -24, -15, -9, 17, 45, 29, -4, -28, -51, -35, + }, { + 34, 4, 25, -10, -9, -21, 7, 36, 26, 36, + 35, -28, -12, -42, 3, 16, 12, 28, -21, -42, + 5, 21, -16, -26, 4, -19, 19, -39, -15, -15, + -1, -13, -19, 17, 17, -14, 15, -55, -4, -19, + }, { + -34, 25, 48, 28, 11, -34, 2, 41, -9, 7, + 17, -21, -20, -24, 17, 33, 0, 24, -10, -42, + -3, 5, -10, -42, -11, -8, 3, -3, -16, -9, + -22, 2, 0, 33, 10, -18, -7, -58, -10, -28, + }, { + -4, 11, 37, -23, 5, -46, 2, 29, 5, 39, + 21, 9, 0, -49, -12, 9, 16, 26, -22, -15, + 45, 20, 5, -40, -22, -17, 26, -31, 14, -2, + 14, -10, -30, -20, 27, 9, 39, -39, -18, -5, + }, { + -73, 32, 60, 15, 26, -59, -2, 33, -30, 10, + 3, 17, -8, -30, 1, 26, 4, 22, -10, -16, + 36, 5, 11, -56, -37, -6, 10, 5, 13, 3, + -6, 5, -11, -4, 19, 5, 16, -41, -24, -13 + } +}; - avctx->sample_fmt = SAMPLE_FMT_S16; - return 0; -} +const uint16_t ff_cb1_base[128]={ + 19657, 18474, 18365, 17520, 21048, 18231, 18584, 16671, + 20363, 19069, 19409, 18430, 21844, 18753, 19613, 17411, + 20389, 21772, 20129, 21702, 20978, 20472, 19627, 19387, + 21477, 23134, 21841, 23919, 22089, 21519, 21134, 20852, + 19675, 17821, 19044, 17477, 19986, 16955, 18446, 16086, + 21138, 18899, 20952, 18929, 21452, 17833, 20104, 17159, + 19770, 20056, 20336, 20866, 19329, 18217, 18908, 18004, + 21556, 21948, 23079, 23889, 20922, 19544, 20984, 19781, + 19781, 20984, 19544, 20922, 23889, 23079, 21948, 21556, + 18004, 18908, 18217, 19329, 20866, 20336, 20056, 19770, + 17159, 20104, 17833, 21452, 18929, 20952, 18899, 21138, + 16086, 18446, 16955, 19986, 17477, 19044, 17821, 19675, + 20852, 21134, 21519, 22089, 23919, 21841, 23134, 21477, + 19387, 19627, 20472, 20978, 21702, 20129, 21772, 20389, + 17411, 19613, 18753, 21844, 18430, 19409, 19069, 20363, + 16671, 18584, 18231, 21048, 17520, 18365, 18474, 19657, +}; -/** - * Evaluate sqrt(x << 24). x must fit in 20 bits. This value is evaluated in an - * odd way to make the output identical to the binary decoder. - */ -static int t_sqrt(unsigned int x) -{ - int s = 2; - while (x > 0xfff) { - s++; - x >>= 2; - } +const uint16_t ff_cb2_base[128]={ + 12174, 13380, 13879, 13832, 13170, 13227, 13204, 12053, + 12410, 13988, 14348, 14631, 13100, 13415, 13224, 12268, + 11982, 13825, 13499, 14210, 13877, 14788, 13811, 13109, + 11449, 13275, 12833, 13717, 12728, 13696, 12759, 12405, + 10230, 12185, 11628, 13161, 11762, 13458, 12312, 12818, + 10443, 12773, 12011, 14020, 11818, 13825, 12453, 13226, + 10446, 13162, 11881, 14300, 12859, 16288, 13490, 15053, + 10155, 12820, 11519, 13973, 12041, 15081, 12635, 14198, + 14198, 12635, 15081, 12041, 13973, 11519, 12820, 10155, + 15053, 13490, 16288, 12859, 14300, 11881, 13162, 10446, + 13226, 12453, 13825, 11818, 14020, 12011, 12773, 10443, + 12818, 12312, 13458, 11762, 13161, 11628, 12185, 10230, + 12405, 12759, 13696, 12728, 13717, 12833, 13275, 11449, + 13109, 13811, 14788, 13877, 14210, 13499, 13825, 11982, + 12268, 13224, 13415, 13100, 14631, 14348, 13988, 12410, + 12053, 13204, 13227, 13170, 13832, 13879, 13380, 12174, +}; - return ff_sqrt(x << 20) << s; -} +const int16_t ff_energy_tab[32]={ + 0, 16, 20, 25, 32, 41, 51, 65, + 81, 103, 129, 163, 205, 259, 326, 410, + 516, 650, 819, 1031, 1298, 1634, 2057, 2590, + 3261, 4105, 5168, 6507, 8192, 10313, 12983, 16345 +}; -/** - * Evaluate the LPC filter coefficients from the reflection coefficients. - * Does the inverse of the eval_refl() function. - */ -static void eval_coefs(int *coefs, const int *refl) -{ - int buffer[10]; - int *b1 = buffer; - int *b2 = coefs; - int i, j; +static const int16_t lpc_refl_cb1[64]={ + -4041, -4018, -3998, -3977, -3954, -3930, -3906, -3879, + -3852, -3825, -3795, -3764, -3731, -3699, -3666, -3631, + -3594, -3555, -3513, -3468, -3420, -3372, -3321, -3268, + -3212, -3153, -3090, -3021, -2944, -2863, -2772, -2676, + -2565, -2445, -2328, -2202, -2072, -1941, -1808, -1660, + -1508, -1348, -1185, -994, -798, -600, -374, -110, + 152, 447, 720, 982, 1229, 1456, 1682, 1916, + 2130, 2353, 2595, 2853, 3118, 3363, 3588, 3814 +}; - for (i=0; i < 10; i++) { - b1[i] = refl[i] << 4; +static const int16_t lpc_refl_cb2[32]={ + -3091, -2386, -1871, -1425, -1021, -649, -316, -20, + 267, 544, 810, 1065, 1305, 1534, 1756, 1970, + 2171, 2359, 2536, 2700, 2854, 2996, 3133, 3263, + 3386, 3499, 3603, 3701, 3789, 3870, 3947, 4020 +}; - for (j=0; j < i; j++) - b1[j] = ((refl[i] * b2[i-j-1]) >> 12) + b2[j]; +static const int16_t lpc_refl_cb3[32]={ + -3525, -3295, -3081, -2890, -2696, -2511, -2328, -2149, + -1979, -1817, -1658, -1498, -1341, -1188, -1032, -876, + -721, -561, -394, -228, -54, 119, 296, 484, + 683, 895, 1123, 1373, 1651, 1965, 2360, 2854 +}; - FFSWAP(int *, b1, b2); - } +static const int16_t lpc_refl_cb4[16]={ + -1845, -1057, -522, -77, 301, 647, 975, 1285, + 1582, 1873, 2163, 2452, 2735, 3017, 3299, 3569 +}; - for (i=0; i < 10; i++) - coefs[i] >>= 4; -} +static const int16_t lpc_refl_cb5[16]={ + -2691, -2187, -1788, -1435, -1118, -837, -571, -316, + -59, 201, 470, 759, 1077, 1457, 1908, 2495 +}; -/** - * Copy the last offset values of *source to *target. If those values are not - * enough to fill the target buffer, fill it with another copy of those values. - */ -static void copy_and_dup(int16_t *target, const int16_t *source, int offset) -{ - source += BUFFERSIZE - offset; +static const int16_t lpc_refl_cb6[8]={ + -1372, -474, 133, 632, 1100, 1571, 2075, 2672 +}; - memcpy(target, source, FFMIN(BLOCKSIZE, offset)*sizeof(*target)); - if (offset < BLOCKSIZE) - memcpy(target + offset, source, (BLOCKSIZE - offset)*sizeof(*target)); -} +static const int16_t lpc_refl_cb7[8]={ + -2389, -1787, -1231, -717, -239, 234, 770, 1474 +}; -/** inverse root mean square */ -static int irms(const int16_t *data) -{ - unsigned int i, sum = 0; +static const int16_t lpc_refl_cb8[8]={ + -1569, -864, -296, 200, 670, 1151, 1709, 2385 +}; - for (i=0; i < BLOCKSIZE; i++) - sum += data[i] * data[i]; +static const int16_t lpc_refl_cb9[8]={ + -2200, -1608, -1062, -569, -120, 338, 863, 1621 +}; - if (sum == 0) - return 0; /* OOPS - division by zero */ +static const int16_t lpc_refl_cb10[4]={ + -617, 190, 802, 1483 +}; - return 0x20000000 / (t_sqrt(sum) >> 8); -} +const int16_t * const ff_lpc_refl_cb[10]={ + lpc_refl_cb1, lpc_refl_cb2, lpc_refl_cb3, lpc_refl_cb4, lpc_refl_cb5, + lpc_refl_cb6, lpc_refl_cb7, lpc_refl_cb8, lpc_refl_cb9, lpc_refl_cb10 +}; -static void add_wav(int16_t *dest, int n, int skip_first, int *m, - const int16_t *s1, const int8_t *s2, const int8_t *s3) +void ff_add_wav(int16_t *dest, int n, int skip_first, int *m, const int16_t *s1, + const int8_t *s2, const int8_t *s3) { int i; int v[3]; v[0] = 0; for (i=!skip_first; i<3; i++) - v[i] = (gain_val_tab[n][i] * m[i]) >> gain_exp_tab[n]; + v[i] = (ff_gain_val_tab[n][i] * m[i]) >> ff_gain_exp_tab[n]; if (v[0]) { for (i=0; i < BLOCKSIZE; i++) @@ -152,86 +1522,26 @@ static void add_wav(int16_t *dest, int n, int skip_first, int *m, } } -static unsigned int rescale_rms(unsigned int rms, unsigned int energy) -{ - return (rms * energy) >> 10; -} - -static unsigned int rms(const int *data) -{ - int i; - unsigned int res = 0x10000; - int b = 10; - - for (i=0; i < 10; i++) { - res = (((0x1000000 - data[i]*data[i]) >> 12) * res) >> 12; - - if (res == 0) - return 0; - - while (res <= 0x3fff) { - b++; - res <<= 2; - } - } - - return t_sqrt(res) >> b; -} - -static void do_output_subblock(RA144Context *ractx, const uint16_t *lpc_coefs, - int gval, GetBitContext *gb) -{ - uint16_t buffer_a[40]; - uint16_t *block; - int cba_idx = get_bits(gb, 7); // index of the adaptive CB, 0 if none - int gain = get_bits(gb, 8); - int cb1_idx = get_bits(gb, 7); - int cb2_idx = get_bits(gb, 7); - int m[3]; - - if (cba_idx) { - cba_idx += BLOCKSIZE/2 - 1; - copy_and_dup(buffer_a, ractx->adapt_cb, cba_idx); - m[0] = (irms(buffer_a) * gval) >> 12; - } else { - m[0] = 0; - } - - m[1] = (cb1_base[cb1_idx] * gval) >> 8; - m[2] = (cb2_base[cb2_idx] * gval) >> 8; - - memmove(ractx->adapt_cb, ractx->adapt_cb + BLOCKSIZE, - (BUFFERSIZE - BLOCKSIZE) * sizeof(*ractx->adapt_cb)); - - block = ractx->adapt_cb + BUFFERSIZE - BLOCKSIZE; - - add_wav(block, gain, cba_idx, m, cba_idx? buffer_a: NULL, - cb1_vects[cb1_idx], cb2_vects[cb2_idx]); - - memcpy(ractx->curr_sblock, ractx->curr_sblock + 40, - 10*sizeof(*ractx->curr_sblock)); - - if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + 10, lpc_coefs, - block, BLOCKSIZE, 10, 1, 0xfff)) - memset(ractx->curr_sblock, 0, 50*sizeof(*ractx->curr_sblock)); -} - -static void int_to_int16(int16_t *out, const int *inp) +/** + * Copy the last offset values of *source to *target. If those values are not + * enough to fill the target buffer, fill it with another copy of those values. + */ +void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset) { - int i; + source += BUFFERSIZE - offset; - for (i=0; i < 10; i++) - *out++ = *inp++; + memcpy(target, source, FFMIN(BLOCKSIZE, offset)*sizeof(*target)); + if (offset < BLOCKSIZE) + memcpy(target + offset, source, (BLOCKSIZE - offset)*sizeof(*target)); } /** * Evaluate the reflection coefficients from the filter coefficients. - * Does the inverse of the eval_coefs() function. * * @return 1 if one of the reflection coefficients is greater than * 4095, 0 if not. */ -static int eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx) +int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx) { int b, i, j; int buffer1[10]; @@ -268,8 +1578,75 @@ static int eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx) return 0; } -static int interp(RA144Context *ractx, int16_t *out, int a, - int copyold, int energy) +/** + * Evaluate the LPC filter coefficients from the reflection coefficients. + * Does the inverse of the ff_eval_refl() function. + */ +void ff_eval_coefs(int *coefs, const int *refl) +{ + int buffer[10]; + int *b1 = buffer; + int *b2 = coefs; + int i, j; + + for (i=0; i < 10; i++) { + b1[i] = refl[i] << 4; + + for (j=0; j < i; j++) + b1[j] = ((refl[i] * b2[i-j-1]) >> 12) + b2[j]; + + FFSWAP(int *, b1, b2); + } + + for (i=0; i < 10; i++) + coefs[i] >>= 4; +} + +void ff_int_to_int16(int16_t *out, const int *inp) +{ + int i; + + for (i=0; i < 10; i++) + *out++ = *inp++; +} + +/** + * Evaluate sqrt(x << 24). x must fit in 20 bits. This value is evaluated in an + * odd way to make the output identical to the binary decoder. + */ +int ff_t_sqrt(unsigned int x) +{ + int s = 2; + while (x > 0xfff) { + s++; + x >>= 2; + } + + return ff_sqrt(x << 20) << s; +} + +unsigned int ff_rms(const int *data) +{ + int i; + unsigned int res = 0x10000; + int b = 10; + + for (i=0; i < 10; i++) { + res = (((0x1000000 - data[i]*data[i]) >> 12) * res) >> 12; + + if (res == 0) + return 0; + + while (res <= 0x3fff) { + b++; + res <<= 2; + } + } + + return ff_t_sqrt(res) >> b; +} + +int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold, int energy) { int work[10]; int b = NBLOCKS - a; @@ -280,85 +1657,64 @@ static int interp(RA144Context *ractx, int16_t *out, int a, for (i=0; i<10; i++) out[i] = (a * ractx->lpc_coef[0][i] + b * ractx->lpc_coef[1][i])>> 2; - if (eval_refl(work, out, ractx->avctx)) { + if (ff_eval_refl(work, out, ractx->avctx)) { // The interpolated coefficients are unstable, copy either new or old // coefficients. - int_to_int16(out, ractx->lpc_coef[copyold]); - return rescale_rms(ractx->lpc_refl_rms[copyold], energy); + ff_int_to_int16(out, ractx->lpc_coef[copyold]); + return ff_rescale_rms(ractx->lpc_refl_rms[copyold], energy); } else { - return rescale_rms(rms(work), energy); + return ff_rescale_rms(ff_rms(work), energy); } } -/** Uncompress one block (20 bytes -> 160*2 bytes). */ -static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, - int *data_size, AVPacket *avpkt) +unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy) { - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; - static const uint8_t sizes[10] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2}; - unsigned int refl_rms[4]; // RMS of the reflection coefficients - uint16_t block_coefs[4][10]; // LPC coefficients of each sub-block - unsigned int lpc_refl[10]; // LPC reflection coefficients of the frame - int i, j; - int16_t *data = vdata; - unsigned int energy; - - RA144Context *ractx = avctx->priv_data; - GetBitContext gb; - - if (*data_size < 2*160) - return -1; - - if(buf_size < 20) { - av_log(avctx, AV_LOG_ERROR, - "Frame too small (%d bytes). Truncated file?\n", buf_size); - *data_size = 0; - return buf_size; - } - init_get_bits(&gb, buf, 20 * 8); - - for (i=0; i<10; i++) - lpc_refl[i] = lpc_refl_cb[i][get_bits(&gb, sizes[i])]; + return (rms * energy) >> 10; +} - eval_coefs(ractx->lpc_coef[0], lpc_refl); - ractx->lpc_refl_rms[0] = rms(lpc_refl); +/** inverse root mean square */ +int ff_irms(const int16_t *data) +{ + unsigned int i, sum = 0; - energy = energy_tab[get_bits(&gb, 5)]; + for (i=0; i < BLOCKSIZE; i++) + sum += data[i] * data[i]; - refl_rms[0] = interp(ractx, block_coefs[0], 1, 1, ractx->old_energy); - refl_rms[1] = interp(ractx, block_coefs[1], 2, energy <= ractx->old_energy, - t_sqrt(energy*ractx->old_energy) >> 12); - refl_rms[2] = interp(ractx, block_coefs[2], 3, 0, energy); - refl_rms[3] = rescale_rms(ractx->lpc_refl_rms[0], energy); + if (sum == 0) + return 0; /* OOPS - division by zero */ - int_to_int16(block_coefs[3], ractx->lpc_coef[0]); + return 0x20000000 / (ff_t_sqrt(sum) >> 8); +} - for (i=0; i < 4; i++) { - do_output_subblock(ractx, block_coefs[i], refl_rms[i], &gb); +void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs, + int cba_idx, int cb1_idx, int cb2_idx, + int gval, int gain) +{ + uint16_t buffer_a[40]; + uint16_t *block; + int m[3]; - for (j=0; j < BLOCKSIZE; j++) - *data++ = av_clip_int16(ractx->curr_sblock[j + 10] << 2); + if (cba_idx) { + cba_idx += BLOCKSIZE/2 - 1; + ff_copy_and_dup(buffer_a, ractx->adapt_cb, cba_idx); + m[0] = (ff_irms(buffer_a) * gval) >> 12; + } else { + m[0] = 0; } + m[1] = (ff_cb1_base[cb1_idx] * gval) >> 8; + m[2] = (ff_cb2_base[cb2_idx] * gval) >> 8; + memmove(ractx->adapt_cb, ractx->adapt_cb + BLOCKSIZE, + (BUFFERSIZE - BLOCKSIZE) * sizeof(*ractx->adapt_cb)); - ractx->old_energy = energy; - ractx->lpc_refl_rms[1] = ractx->lpc_refl_rms[0]; + block = ractx->adapt_cb + BUFFERSIZE - BLOCKSIZE; - FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]); + ff_add_wav(block, gain, cba_idx, m, cba_idx? buffer_a: NULL, + ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]); - *data_size = 2*160; - return 20; -} + memcpy(ractx->curr_sblock, ractx->curr_sblock + 40, + 10*sizeof(*ractx->curr_sblock)); -AVCodec ra_144_decoder = -{ - "real_144", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_RA_144, - sizeof(RA144Context), - ra144_decode_init, - NULL, - NULL, - ra144_decode_frame, - .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"), -}; + if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + 10, lpc_coefs, + block, BLOCKSIZE, 10, 1, 0xfff)) + memset(ractx->curr_sblock, 0, 50*sizeof(*ractx->curr_sblock)); +} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144.h index 4413530c0..536b5bbe7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144.h @@ -23,1484 +23,62 @@ #define AVCODEC_RA144_H #include - -static const int16_t gain_val_tab[256][3] = { - { 541, 956, 768}, { 877, 581, 568}, { 675,1574, 635}, {1248,1464, 668}, - {1246, 839, 1394}, {2560,1386, 991}, { 925, 687, 608}, {2208, 797, 1144}, - { 535, 832, 799}, { 762, 605, 1154}, { 832,1122, 1003}, {1180, 687, 1176}, - {1292, 901, 732}, {1656, 689, 896}, {1750,1248, 848}, {2284, 942, 1022}, - { 824,1472, 643}, { 517, 765, 512}, { 562,1816, 1522}, { 694,1826, 2700}, - { 704, 524, 672}, {1442, 757, 2232}, { 884, 551, 1266}, {2232,1007, 1692}, - { 932, 746, 777}, {1132, 822, 926}, {1226, 771, 611}, {2948,1342, 1008}, - {1302, 594, 1158}, {1602, 636, 1128}, {3408, 910, 1438}, {1996, 614, 575}, - { 665, 935, 628}, { 631,1192, 829}, { 644, 926, 1052}, { 879, 988, 1226}, - { 941,2768, 2772}, { 565,1344, 2304}, { 547, 628, 740}, { 639, 532, 1074}, - { 955,1208, 598}, {1124,1160, 900}, {1206, 899, 1242}, { 746, 533, 624}, - {1458,1028, 735}, {1706,1102, 692}, {1898,1018, 1004}, {2176, 988, 735}, - {1578, 782, 1642}, { 897, 516, 754}, {2068, 702, 1656}, {2344, 818, 1526}, - { 907, 652, 592}, {1056, 652, 642}, {2124,1416, 780}, {2664,1250, 727}, - {1894, 727, 1108}, {2196, 657, 981}, {4840, 920, 1704}, {4992,1238, 983}, - {2420, 909, 1094}, {2760, 935, 1032}, {2800, 612, 853}, {3068, 832, 574}, - { 523,1796, 923}, { 722,1916, 1382}, {1226,1542, 928}, { 758, 757, 584}, - { 512,1134, 577}, { 615,1276, 698}, { 574,2568, 2356}, { 993,2728, 3512}, - { 539, 890, 913}, { 694, 928, 1088}, { 805, 600, 1360}, {2160, 951, 3128}, - { 816, 950, 590}, { 955, 847, 811}, {1094, 883, 556}, {1304, 888, 604}, - { 863,1170, 855}, {1023, 997, 1032}, { 932,1228, 1280}, { 627, 564, 573}, - { 876, 900, 1448}, {1030, 857, 1792}, {1294, 953, 1758}, {1612, 854, 1714}, - {1090,1166, 631}, {1314,1202, 751}, {1480, 905, 795}, {1682,1016, 568}, - {1494,1178, 983}, { 878, 613, 526}, {1728,1446, 779}, {2136,1348, 774}, - { 950, 649, 939}, {1180, 703, 899}, {1236, 527, 1158}, {1450, 647, 972}, - {1282, 647, 707}, {1460, 663, 644}, {1614, 572, 578}, {3516,1222, 821}, - {2668, 729, 1682}, {3128, 585, 1502}, {3208, 733, 976}, {6800, 871, 1416}, - {3480, 743, 1408}, {3764, 899, 1170}, {3772, 632, 875}, {4092, 732, 638}, - {3112, 753, 2620}, {3372, 945, 1890}, {3768, 969, 2288}, {2016, 559, 854}, - {1736, 729, 787}, {1940, 686, 547}, {2140, 635, 674}, {4480,1272, 828}, - {3976, 592, 1666}, {4384, 621, 1388}, {4400, 801, 955}, {4656, 522, 646}, - {4848, 625, 1636}, {4984, 591, 874}, {5352, 535, 1001}, {11216,938, 1184}, - { 925,3280, 1476}, { 735,1580, 1088}, {1150,1576, 674}, { 655, 783, 528}, - { 527,2052, 1354}, { 782,1704, 1880}, { 578, 910, 1026}, { 692, 882, 1468}, - { 586, 683, 715}, { 739, 609, 717}, { 778, 773, 697}, { 922, 785, 813}, - { 766, 651, 984}, { 978, 596, 1030}, {1070, 757, 1080}, {1324, 687, 1178}, - {1108,2144, 979}, { 723, 982, 690}, { 936, 956, 527}, {1180,1002, 547}, - { 517,1306, 825}, { 832,1184, 974}, {1024, 957, 903}, {1262,1090, 906}, - {1028, 720, 649}, {1192, 679, 694}, {2468,1480, 979}, {2844,1370, 877}, - {1310, 835, 848}, {1508, 839, 698}, {1742,1030, 769}, {1910, 852, 573}, - {1280, 859, 1174}, {1584, 863, 1108}, {1686, 708, 1364}, {1942, 768, 1104}, - { 891, 536, 690}, {1016, 560, 663}, {2172, 870, 1348}, {2404, 999, 1170}, - {1890, 966, 889}, {2116, 912, 777}, {2296,1020, 714}, {4872,1844, 932}, - {2392, 778, 929}, {2604, 772, 744}, {2764, 957, 722}, {5832,1532, 984}, - {2188, 519, 1264}, {2332, 532, 922}, {5064, 995, 2412}, {2708, 571, 874}, - {2408, 545, 666}, {5016,1084, 875}, {5376, 983, 1196}, {5536, 979, 730}, - {5344, 634, 1744}, {5688, 706, 1348}, {5912, 977, 1190}, {6072, 905, 763}, - {6048, 582, 1526}, {11968,1013,1816}, {12864,937, 1900}, {12560,1086, 998}, - {1998, 684, 1884}, {2504, 633, 1992}, {1252, 567, 835}, {1478, 571, 973}, - {2620, 769, 1414}, {2808, 952, 1142}, {2908, 712, 1028}, {2976, 686, 741}, - {1462, 552, 714}, {3296, 991, 1452}, {1590, 615, 544}, {3480,1150, 824}, - {3212, 832, 923}, {3276, 839, 531}, {3548, 786, 852}, {3732, 764, 570}, - {5728, 906, 2616}, {6272, 804, 2252}, {3096, 535, 876}, {3228, 598, 649}, - {6536, 759, 1436}, {6648, 993, 846}, {6864, 567, 1210},{14016,1012, 1302}, - {3408, 548, 1098}, {7160,1008, 1742}, {7136,1000, 1182}, {7480,1032, 836}, - {7448, 612, 1552}, {7744, 614, 816}, {8384, 777, 1438}, {8784, 694, 786}, - { 882,1508, 1068}, { 597, 837, 766}, {1270, 954, 1408}, { 803, 550, 798}, - {1398,1308, 798}, {1848,1534, 738}, { 970, 675, 608}, {1264, 706, 684}, - {1716, 767, 1126}, {2108, 765, 1404}, {2236, 924, 1003}, {2472,1048, 611}, - { 999, 942, 963}, {1094, 857, 935}, {2936, 926, 1138}, {1934, 746, 551}, - {3336, 633, 1762}, {3764, 701, 1454}, {1890, 564, 636}, {4096,1126, 793}, - {3936, 556, 1140}, {3936, 540, 740}, {4216, 764, 874}, {8480,1328, 1014}, - {2184, 515, 1042}, {4432, 934, 1344}, {4784, 945, 1112}, {5016,1062, 733}, - {9216,1020, 2028}, {9968, 924, 1188}, {5424, 909, 1206}, {6512, 744, 1086} -}; - -static const uint8_t gain_exp_tab[256] = { - 15, 15, 15, 15, 15, 16, 14, 15, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 13, 14, 14, 13, 14, 13, 14, 13, 13, 13, 14, 13, 13, 14, 13, - 13, 13, 13, 13, 14, 13, 12, 12, 13, 13, 13, 12, 13, 13, 13, 13, - 13, 12, 13, 13, 12, 12, 13, 13, 13, 13, 14, 14, 13, 13, 13, 13, - 13, 13, 13, 12, 12, 12, 13, 13, 12, 12, 12, 13, 12, 12, 12, 12, - 12, 12, 12, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 14, 13, 13, 13, 13, - 13, 13, 13, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 14, - 13, 12, 12, 11, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 11, 11, 11, 11, - 12, 12, 12, 12, 11, 11, 12, 12, 12, 12, 12, 13, 12, 12, 12, 13, - 12, 12, 13, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, - 12, 12, 11, 11, 12, 12, 12, 12, 11, 12, 11, 12, 12, 12, 12, 12, - 13, 13, 12, 12, 13, 13, 13, 14, 12, 13, 13, 13, 13, 13, 13, 13, - 11, 10, 11, 10, 11, 11, 10, 10, 11, 11, 11, 11, 10, 9, 11, 10, - 12, 12, 11, 12, 12, 12, 12, 13, 11, 12, 12, 12, 13, 13, 12, 12 -}; - -static const int8_t cb1_vects[128][40]={ - { - 38, -4, 15, -4, 14, -13, 12, -11, -2, -6, - -6, -11, -45, -16, -11, -13, -7, 6, -12, 4, - -20, 3, -16, 12, -1, 12, 46, 24, 0, 33, - -3, 9, -12, -12, -8, -7, 17, -6, 0, -2, - }, { - 60, -16, 3, -22, 10, -32, 0, -28, -17, -18, - -3, -25, -37, -23, -10, 3, 2, 3, 0, 3, - -14, 0, -14, -1, 0, 2, 32, 9, -1, 25, - 7, 13, -5, 13, 8, 1, 2, 8, -10, 6, - }, { - 27, -12, 28, -2, 6, -7, 15, 9, -11, 1, - -13, -11, -40, 4, -29, -14, -19, -5, -23, -8, - -30, -13, -17, 0, -14, 12, 34, 20, -2, 25, - 2, -16, -4, -12, 15, 16, 29, 7, 24, 10, - }, { - 49, -24, 16, -20, 2, -26, 2, -7, -25, -10, - -11, -25, -32, -3, -27, 2, -8, -8, -11, -9, - -24, -17, -16, -14, -13, 2, 20, 5, -4, 17, - 14, -12, 3, 13, 33, 25, 14, 23, 15, 19, - }, { - 46, -6, 21, 8, -2, -16, -5, -8, -11, 4, - 8, 15, -24, 4, -2, -26, -3, -16, -16, -14, - -9, -2, -1, 4, 19, 7, 36, 17, 9, 13, - 0, 31, -5, -12, 7, -8, 11, -15, -13, -4, - }, { - 68, -18, 9, -9, -6, -35, -18, -25, -26, -7, - 10, 1, -16, -3, -1, -9, 6, -19, -4, -15, - -4, -6, 0, -8, 20, -2, 23, 2, 7, 5, - 12, 35, 1, 13, 24, 0, -3, 0, -22, 4, - }, { - 35, -14, 34, 10, -10, -10, -1, 12, -20, 12, - 0, 15, -18, 24, -20, -27, -14, -28, -27, -27, - -20, -19, -2, -8, 5, 7, 25, 13, 5, 5, - 6, 5, 2, -12, 31, 15, 23, -1, 12, 8, - }, { - 57, -26, 22, -7, -14, -28, -14, -3, -35, 0, - 3, 1, -11, 16, -18, -10, -4, -31, -15, -28, - -14, -23, -1, -21, 7, -2, 11, -1, 3, -1, - 18, 9, 10, 13, 49, 24, 8, 14, 2, 16, - }, { - 25, 15, 22, 11, 18, 4, 15, -22, 8, -2, - -17, -9, -48, -20, -30, -17, -16, 11, -1, 16, - 2, 10, -5, 26, -2, -4, 22, 0, 2, 10, - -6, 13, -14, 10, -23, 0, 10, -2, 1, 0, - }, { - 47, 3, 11, -6, 15, -13, 2, -38, -6, -13, - -15, -22, -40, -28, -28, 0, -5, 8, 10, 15, - 7, 7, -4, 13, -1, -14, 9, -14, 0, 2, - 4, 18, -7, 36, -6, 8, -3, 13, -7, 8, - }, { - 14, 7, 36, 13, 10, 10, 18, 0, 0, 5, - -25, -8, -43, 0, -48, -18, -27, 0, -12, 3, - -7, -6, -7, 13, -15, -5, 11, -3, 0, 2, - 0, -12, -6, 10, 0, 23, 22, 11, 26, 12, - }, { - 36, -5, 24, -4, 7, -7, 6, -17, -14, -5, - -22, -22, -35, -8, -46, -1, -17, -3, 0, 2, - -2, -10, -5, 0, -14, -15, -2, -18, -2, -4, - 11, -7, 1, 36, 18, 32, 7, 27, 17, 20, - }, { - 33, 13, 29, 24, 1, 1, -2, -18, 0, 9, - -3, 17, -27, 0, -21, -30, -12, -11, -5, -2, - 12, 4, 9, 19, 18, -9, 13, -6, 11, -8, - -2, 35, -8, 10, -7, -1, 4, -11, -10, -2, - }, { - 55, 1, 17, 6, -1, -16, -15, -35, -15, -2, - 0, 4, -19, -8, -20, -13, -1, -14, 7, -3, - 18, 0, 10, 5, 19, -19, 0, -21, 8, -16, - 9, 39, 0, 36, 10, 7, -9, 4, -20, 5, - }, { - 22, 5, 42, 26, -6, 8, 1, 2, -9, 17, - -10, 18, -21, 19, -39, -31, -23, -23, -16, -15, - 2, -12, 7, 6, 5, -9, 1, -10, 7, -16, - 4, 9, 0, 10, 17, 22, 16, 2, 14, 9, - }, { - 44, -6, 30, 8, -9, -10, -11, -14, -23, 5, - -8, 4, -14, 12, -37, -14, -12, -26, -4, -16, - 8, -16, 9, -7, 6, -19, -12, -25, 5, -24, - 15, 13, 8, 36, 34, 31, 1, 18, 4, 18, - }, { - -3, -5, -9, -7, 15, -1, 5, 13, 2, 12, - 5, 2, -21, -23, -2, -16, 0, 5, -6, 13, - -23, 3, -32, 10, -15, 8, 44, 28, 9, 37, - -2, 13, -9, -15, -12, -27, -7, -12, 0, -11, - }, { - 18, -17, -21, -25, 11, -19, -6, -3, -11, 0, - 7, -11, -13, -31, -1, 0, 9, 1, 5, 12, - -18, 0, -31, -2, -13, -1, 30, 14, 7, 29, - 9, 18, -1, 10, 4, -18, -22, 3, -10, -2, - }, { - -13, -13, 3, -5, 7, 4, 9, 34, -5, 20, - -2, 3, -16, -3, -20, -17, -11, -7, -17, 0, - -34, -13, -33, -2, -28, 8, 32, 24, 5, 29, - 3, -12, 0, -15, 11, -3, 3, 2, 24, 1, - }, { - 8, -25, -8, -23, 3, -13, -3, 17, -20, 8, - 0, -10, -8, -11, -18, 0, -1, -10, -5, 0, - -28, -17, -32, -15, -26, -1, 19, 9, 3, 21, - 15, -7, 6, 9, 29, 5, -10, 17, 15, 9, - }, { - 4, -6, -3, 5, -1, -4, -11, 16, -6, 23, - 19, 29, 0, -3, 6, -30, 3, -17, -10, -5, - -13, -2, -17, 3, 5, 3, 35, 21, 17, 17, - 2, 35, -2, -15, 3, -28, -13, -21, -13, -13, - }, { - 26, -19, -15, -12, -5, -22, -24, 0, -21, 12, - 21, 15, 8, -11, 7, -12, 14, -20, 2, -6, - -7, -6, -16, -9, 6, -5, 21, 7, 15, 10, - 13, 39, 5, 10, 20, -19, -28, -5, -22, -5, - }, { - -5, -15, 9, 7, -9, 2, -8, 37, -14, 31, - 11, 29, 5, 16, -11, -30, -7, -29, -21, -18, - -23, -19, -18, -9, -7, 3, 23, 17, 14, 9, - 8, 9, 6, -15, 27, -4, -2, -6, 12, -1, - }, { - 16, -27, -2, -10, -13, -16, -20, 20, -29, 20, - 14, 16, 13, 8, -9, -13, 2, -33, -9, -19, - -17, -23, -17, -22, -6, -6, 9, 2, 12, 2, - 20, 13, 13, 10, 45, 4, -16, 8, 2, 7, - }, { - -16, 14, -2, 8, 20, 17, 9, 2, 14, 16, - -6, 5, -24, -28, -21, -20, -8, 9, 4, 25, - -1, 11, -22, 24, -15, -8, 21, 5, 11, 14, - -5, 18, -11, 7, -27, -20, -14, -7, 1, -9, - }, { - 6, 2, -14, -9, 16, -1, -3, -14, 0, 5, - -3, -8, -16, -36, -19, -3, 1, 6, 17, 24, - 4, 7, -21, 11, -14, -18, 7, -9, 9, 7, - 6, 22, -3, 33, -10, -11, -28, 7, -7, 0, - }, { - -26, 6, 11, 10, 12, 23, 12, 23, 5, 24, - -13, 5, -19, -8, -38, -21, -20, -2, -6, 12, - -11, -5, -23, 11, -29, -9, 9, 0, 7, 6, - 1, -7, -2, 7, -3, 3, -2, 6, 27, 3, - }, { - -4, -6, 0, -7, 8, 4, 0, 6, -9, 13, - -11, -7, -11, -15, -37, -4, -9, -5, 5, 11, - -5, -9, -22, -1, -27, -18, -4, -14, 5, 0, - 12, -3, 4, 32, 14, 12, -17, 22, 17, 11, - }, { - -8, 12, 3, 21, 3, 14, -8, 5, 4, 28, - 7, 32, -2, -8, -12, -34, -4, -12, 1, 6, - 9, 4, -7, 17, 4, -13, 11, -1, 19, -4, - 0, 39, -4, 7, -11, -21, -20, -16, -10, -11, - }, { - 13, 0, -8, 3, 0, -4, -21, -11, -9, 16, - 10, 18, 5, -16, -10, -16, 5, -15, 13, 5, - 15, 1, -6, 4, 6, -23, -2, -16, 17, -12, - 10, 44, 3, 33, 6, -12, -34, -1, -20, -3, - }, { - -18, 4, 17, 23, -4, 20, -4, 26, -3, 36, - 0, 32, 2, 12, -29, -34, -16, -24, -10, -6, - 0, -12, -8, 4, -8, -13, 0, -6, 16, -12, - 5, 13, 3, 7, 13, 3, -8, -2, 14, 0, - }, { - 3, -7, 5, 5, -8, 2, -17, 9, -18, 24, - 2, 19, 10, 4, -28, -17, -5, -28, 2, -7, - 4, -15, -7, -8, -6, -23, -13, -21, 14, -20, - 17, 18, 11, 33, 30, 11, -23, 13, 5, 9, - }, { - 60, 10, 7, -1, 9, -8, 6, -13, 2, -15, - -1, -10, -13, -11, 15, 0, 6, 9, -1, 0, - -13, 1, -11, -3, -13, 21, 13, 26, -7, 31, - -10, -7, -16, -33, -31, -10, 22, -8, 1, -2, - }, { - 82, -1, -4, -19, 6, -27, -6, -29, -12, -26, - 1, -24, -5, -18, 17, 17, 17, 6, 10, 0, - -7, -2, -9, -16, -12, 11, 0, 11, -9, 23, - 0, -3, -8, -8, -13, -1, 8, 7, -7, 6, - }, { - 49, 2, 21, 0, 1, -2, 9, 8, -6, -6, - -8, -10, -8, 9, -2, 0, -4, -2, -13, -12, - -23, -15, -12, -16, -26, 21, 2, 21, -11, 23, - -4, -33, -7, -33, -6, 13, 34, 5, 27, 10, - }, { - 71, -10, 9, -17, -1, -20, -3, -8, -21, -18, - -6, -24, 0, 1, 0, 16, 6, -5, 0, -13, - -17, -19, -11, -29, -25, 11, -11, 6, -13, 15, - 7, -29, 0, -8, 11, 22, 20, 21, 17, 18, - }, { - 67, 8, 14, 11, -7, -11, -11, -9, -7, -3, - 13, 16, 8, 9, 24, -12, 10, -13, -5, -17, - -2, -4, 3, -10, 6, 17, 4, 19, 0, 11, - -6, 13, -9, -33, -14, -10, 16, -17, -10, -4, - }, { - 90, -3, 2, -6, -10, -29, -24, -26, -21, -15, - 15, 2, 16, 1, 25, 4, 21, -16, 6, -18, - 3, -8, 5, -24, 8, 7, -9, 4, -1, 3, - 5, 18, -1, -7, 2, -1, 2, -1, -19, 3, - }, { - 57, 0, 27, 13, -14, -5, -7, 11, -15, 4, - 5, 16, 13, 29, 6, -13, 0, -25, -16, -31, - -12, -22, 2, -23, -6, 16, -7, 14, -2, 3, - 0, -12, 0, -33, 9, 13, 28, -3, 14, 7, - }, { - 79, -11, 15, -4, -18, -23, -20, -5, -30, -7, - 7, 2, 21, 21, 8, 3, 10, -28, -4, -31, - -6, -25, 3, -37, -4, 7, -20, 0, -4, -4, - 11, -7, 6, -8, 27, 22, 14, 12, 5, 16, - }, { - 47, 30, 15, 14, 14, 9, 9, -23, 13, -10, - -12, -7, -16, -15, -3, -3, -1, 14, 9, 12, - 9, 8, 0, 10, -14, 4, -9, 2, -5, 8, - -13, -3, -18, -10, -45, -3, 16, -4, 4, 0, - }, { - 69, 17, 3, -3, 10, -8, -3, -40, -1, -21, - -10, -21, -8, -23, -1, 13, 8, 11, 21, 11, - 15, 4, 0, -2, -13, -5, -23, -12, -7, 0, - -1, 0, -10, 14, -28, 5, 1, 11, -5, 7, - }, { - 36, 21, 28, 16, 6, 16, 12, -2, 4, -2, - -20, -7, -11, 4, -20, -4, -12, 2, -1, 0, - 0, -8, -2, -2, -27, 4, -21, -2, -9, 0, - -6, -29, -9, -10, -21, 21, 28, 10, 29, 11, - }, { - 58, 9, 16, -1, 2, -2, 0, -19, -10, -13, - -17, -21, -3, -3, -19, 12, -2, 0, 10, -1, - 5, -12, 0, -15, -26, -5, -34, -16, -11, -7, - 4, -25, -2, 14, -3, 29, 13, 25, 20, 20, - }, { - 55, 28, 21, 27, -2, 7, -8, -20, 4, 1, - 1, 18, 5, 4, 5, -16, 2, -8, 5, -5, - 19, 2, 14, 3, 6, 0, -18, -4, 2, -11, - -8, 18, -11, -10, -29, -3, 10, -13, -8, -3, - }, { - 77, 16, 9, 9, -6, -11, -21, -37, -10, -10, - 4, 5, 13, -3, 7, 0, 13, -11, 17, -6, - 25, -1, 15, -9, 7, -9, -32, -19, 0, -18, - 2, 22, -3, 15, -12, 5, -4, 2, -17, 5, - }, { - 44, 20, 34, 29, -10, 13, -4, 0, -4, 9, - -5, 19, 10, 24, -11, -17, -8, -20, -5, -19, - 9, -14, 12, -9, -6, 0, -30, -9, 0, -19, - -2, -7, -2, -10, -5, 20, 21, 1, 17, 9, - }, { - 66, 8, 23, 11, -14, -5, -17, -16, -19, -2, - -3, 5, 18, 17, -10, 0, 1, -23, 6, -20, - 15, -18, 14, -22, -5, -10, -44, -23, -2, -26, - 9, -3, 4, 14, 12, 29, 7, 16, 7, 18, - }, { - 18, 9, -17, -4, 11, 3, 0, 11, 7, 4, - 10, 3, 10, -18, 24, -3, 14, 7, 4, 10, - -16, 1, -27, -4, -27, 17, 12, 30, 0, 35, - -9, -3, -12, -36, -35, -30, -2, -13, 2, -11, - }, { - 40, -2, -29, -22, 7, -14, -12, -5, -7, -7, - 12, -9, 18, -26, 26, 14, 24, 4, 16, 9, - -10, -2, -26, -18, -26, 7, -1, 15, -1, 27, - 2, 0, -4, -11, -17, -21, -16, 1, -7, -3, - }, { - 8, 1, -3, -2, 3, 10, 3, 32, -1, 12, - 2, 4, 15, 1, 7, -3, 2, -4, -6, -3, - -26, -15, -29, -17, -40, 17, 0, 26, -2, 27, - -2, -29, -4, -36, -10, -6, 9, 0, 27, 0, - }, { - 30, -11, -15, -20, 0, -8, -9, 15, -15, 0, - 5, -9, 23, -6, 8, 13, 13, -7, 5, -3, - -20, -19, -27, -31, -39, 7, -13, 11, -4, 19, - 8, -25, 3, -11, 7, 2, -4, 16, 18, 9, - }, { - 26, 7, -11, 8, -5, 1, -17, 14, -1, 15, - 24, 30, 32, 1, 33, -16, 18, -14, 0, -8, - -6, -4, -12, -12, -6, 13, 2, 23, 8, 15, - -4, 17, -5, -36, -18, -30, -8, -22, -10, -14, - }, { - 48, -4, -23, -9, -9, -17, -30, -2, -16, 3, - 26, 16, 40, -6, 35, 1, 28, -17, 12, -9, - 0, -8, -11, -25, -5, 3, -10, 8, 6, 7, - 6, 22, 1, -11, -1, -21, -22, -7, -19, -5, - }, { - 15, 0, 2, 10, -13, 7, -14, 35, -10, 23, - 16, 31, 37, 21, 16, -17, 6, -26, -10, -21, - -16, -21, -13, -25, -19, 13, -8, 19, 5, 7, - 1, -8, 2, -36, 5, -6, 3, -8, 15, -1, - }, { - 37, -12, -9, -7, -17, -11, -26, 18, -25, 12, - 19, 17, 45, 14, 17, 0, 17, -30, 1, -22, - -10, -25, -12, -38, -18, 3, -22, 4, 3, 0, - 13, -3, 10, -11, 23, 2, -10, 7, 5, 7, - }, { - 5, 29, -9, 11, 15, 22, 3, 0, 18, 8, - -1, 6, 7, -23, 6, -6, 5, 12, 15, 21, - 5, 8, -17, 9, -28, 0, -11, 6, 2, 12, - -11, 0, -14, -13, -49, -22, -8, -9, 4, -9, - }, { - 27, 16, -21, -6, 12, 3, -9, -16, 3, -2, - 1, -7, 15, -31, 7, 10, 16, 9, 27, 21, - 11, 5, -16, -3, -26, -9, -24, -7, 0, 4, - 0, 4, -6, 11, -32, -14, -23, 6, -5, -1, - }, { - -4, 20, 3, 13, 8, 28, 6, 21, 10, 16, - -8, 7, 12, -3, -11, -7, -5, 0, 4, 8, - -4, -8, -18, -3, -41, 0, -22, 2, 0, 4, - -5, -25, -6, -14, -25, 1, 2, 4, 29, 2, - }, { - 17, 8, -8, -4, 4, 10, -6, 5, -4, 5, - -6, -6, 20, -10, -9, 9, 4, -2, 16, 7, - 1, -12, -17, -16, -39, -9, -36, -12, -2, -3, - 6, -21, 1, 11, -7, 10, -11, 20, 20, 11, - }, { - 13, 27, -3, 24, -1, 19, -14, 3, 9, 20, - 12, 33, 29, -3, 15, -20, 9, -9, 11, 3, - 16, 2, -2, 2, -7, -3, -20, 0, 10, -7, - -7, 22, -7, -13, -33, -23, -14, -18, -7, -12, - }, { - 35, 15, -15, 6, -4, 1, -27, -12, -5, 8, - 15, 19, 37, -11, 16, -2, 20, -12, 23, 2, - 22, -1, -1, -11, -5, -13, -34, -14, 8, -14, - 4, 26, 0, 11, -16, -14, -29, -2, -17, -3, - }, { - 3, 19, 9, 26, -8, 26, -10, 24, 0, 28, - 5, 33, 34, 17, -2, -20, -1, -22, 0, -10, - 6, -14, -3, -10, -20, -4, -32, -4, 7, -15, - 0, -3, 0, -13, -9, 0, -3, -4, 17, 0, - }, { - 25, 7, -2, 8, -12, 7, -23, 8, -13, 16, - 7, 20, 42, 9, 0, -3, 9, -25, 12, -10, - 12, -18, -2, -24, -19, -13, -46, -19, 5, -22, - 10, 0, 8, 11, 8, 9, -17, 11, 7, 8, - }, { - -25, -7, 2, -8, 12, -7, 23, -8, 13, -16, - -7, -20, -42, -9, 0, 3, -9, 25, -12, 10, - -12, 18, 2, 24, 19, 13, 46, 19, -5, 22, - -10, 0, -8, -11, -8, -9, 17, -11, -7, -8, - }, { - -3, -19, -9, -26, 8, -26, 10, -24, 0, -28, - -5, -33, -34, -17, 2, 20, 1, 22, 0, 10, - -6, 14, 3, 10, 20, 4, 32, 4, -7, 15, - 0, 3, 0, 13, 9, 0, 3, 4, -17, 0, - }, { - -35, -15, 15, -6, 4, -1, 27, 12, 5, -8, - -15, -19, -37, 11, -16, 2, -20, 12, -23, -2, - -22, 1, 1, 11, 5, 13, 34, 14, -8, 14, - -4, -26, 0, -11, 16, 14, 29, 2, 17, 3, - }, { - -13, -27, 3, -24, 1, -19, 14, -3, -9, -20, - -12, -33, -29, 3, -15, 20, -9, 9, -11, -3, - -16, -2, 2, -2, 7, 3, 20, 0, -10, 7, - 7, -22, 7, 13, 33, 23, 14, 18, 7, 12, - }, { - -17, -8, 8, 4, -4, -10, 6, -5, 4, -5, - 6, 6, -20, 10, 9, -9, -4, 2, -16, -7, - -1, 12, 17, 16, 39, 9, 36, 12, 2, 3, - -6, 21, -1, -11, 7, -10, 11, -20, -20, -11, - }, { - 4, -20, -3, -13, -8, -28, -6, -21, -10, -16, - 8, -7, -12, 3, 11, 7, 5, 0, -4, -8, - 4, 8, 18, 3, 41, 0, 22, -2, 0, -4, - 5, 25, 6, 14, 25, -1, -2, -4, -29, -2, - }, { - -27, -16, 21, 6, -12, -3, 9, 16, -3, 2, - -1, 7, -15, 31, -7, -10, -16, -9, -27, -21, - -11, -5, 16, 3, 26, 9, 24, 7, 0, -4, - 0, -4, 6, -11, 32, 14, 23, -6, 5, 1, - }, { - -5, -29, 9, -11, -15, -22, -3, 0, -18, -8, - 1, -6, -7, 23, -6, 6, -5, -12, -15, -21, - -5, -8, 17, -9, 28, 0, 11, -6, -2, -12, - 11, 0, 14, 13, 49, 22, 8, 9, -4, 9, - }, { - -37, 12, 9, 7, 17, 11, 26, -18, 25, -12, - -19, -17, -45, -14, -17, 0, -17, 30, -1, 22, - 10, 25, 12, 38, 18, -3, 22, -4, -3, 0, - -13, 3, -10, 11, -23, -2, 10, -7, -5, -7, - }, { - -15, 0, -2, -10, 13, -7, 14, -35, 10, -23, - -16, -31, -37, -21, -16, 17, -6, 26, 10, 21, - 16, 21, 13, 25, 19, -13, 8, -19, -5, -7, - -1, 8, -2, 36, -5, 6, -3, 8, -15, 1, - }, { - -48, 4, 23, 9, 9, 17, 30, 2, 16, -3, - -26, -16, -40, 6, -35, -1, -28, 17, -12, 9, - 0, 8, 11, 25, 5, -3, 10, -8, -6, -7, - -6, -22, -1, 11, 1, 21, 22, 7, 19, 5, - }, { - -26, -7, 11, -8, 5, -1, 17, -14, 1, -15, - -24, -30, -32, -1, -33, 16, -18, 14, 0, 8, - 6, 4, 12, 12, 6, -13, -2, -23, -8, -15, - 4, -17, 5, 36, 18, 30, 8, 22, 10, 14, - }, { - -30, 11, 15, 20, 0, 8, 9, -15, 15, 0, - -5, 9, -23, 6, -8, -13, -13, 7, -5, 3, - 20, 19, 27, 31, 39, -7, 13, -11, 4, -19, - -8, 25, -3, 11, -7, -2, 4, -16, -18, -9, - }, { - -8, -1, 3, 2, -3, -10, -3, -32, 1, -12, - -2, -4, -15, -1, -7, 3, -2, 4, 6, 3, - 26, 15, 29, 17, 40, -17, 0, -26, 2, -27, - 2, 29, 4, 36, 10, 6, -9, 0, -27, 0, - }, { - -40, 2, 29, 22, -7, 14, 12, 5, 7, 7, - -12, 9, -18, 26, -26, -14, -24, -4, -16, -9, - 10, 2, 26, 18, 26, -7, 1, -15, 1, -27, - -2, 0, 4, 11, 17, 21, 16, -1, 7, 3, - }, { - -18, -9, 17, 4, -11, -3, 0, -11, -7, -4, - -10, -3, -10, 18, -24, 3, -14, -7, -4, -10, - 16, -1, 27, 4, 27, -17, -12, -30, 0, -35, - 9, 3, 12, 36, 35, 30, 2, 13, -2, 11, - }, { - -66, -8, -23, -11, 14, 5, 17, 16, 19, 2, - 3, -5, -18, -17, 10, 0, -1, 23, -6, 20, - -15, 18, -14, 22, 5, 10, 44, 23, 2, 26, - -9, 3, -4, -14, -12, -29, -7, -16, -7, -18, - }, { - -44, -20, -34, -29, 10, -13, 4, 0, 4, -9, - 5, -19, -10, -24, 11, 17, 8, 20, 5, 19, - -9, 14, -12, 9, 6, 0, 30, 9, 0, 19, - 2, 7, 2, 10, 5, -20, -21, -1, -17, -9, - }, { - -77, -16, -9, -9, 6, 11, 21, 37, 10, 10, - -4, -5, -13, 3, -7, 0, -13, 11, -17, 6, - -25, 1, -15, 9, -7, 9, 32, 19, 0, 18, - -2, -22, 3, -15, 12, -5, 4, -2, 17, -5, - }, { - -55, -28, -21, -27, 2, -7, 8, 20, -4, -1, - -1, -18, -5, -4, -5, 16, -2, 8, -5, 5, - -19, -2, -14, -3, -6, 0, 18, 4, -2, 11, - 8, -18, 11, 10, 29, 3, -10, 13, 8, 3, - }, { - -58, -9, -16, 1, -2, 2, 0, 19, 10, 13, - 17, 21, 3, 3, 19, -12, 2, 0, -10, 1, - -5, 12, 0, 15, 26, 5, 34, 16, 11, 7, - -4, 25, 2, -14, 3, -29, -13, -25, -20, -20, - }, { - -36, -21, -28, -16, -6, -16, -12, 2, -4, 2, - 20, 7, 11, -4, 20, 4, 12, -2, 1, 0, - 0, 8, 2, 2, 27, -4, 21, 2, 9, 0, - 6, 29, 9, 10, 21, -21, -28, -10, -29, -11, - }, { - -69, -17, -3, 3, -10, 8, 3, 40, 1, 21, - 10, 21, 8, 23, 1, -13, -8, -11, -21, -11, - -15, -4, 0, 2, 13, 5, 23, 12, 7, 0, - 1, 0, 10, -14, 28, -5, -1, -11, 5, -7, - }, { - -47, -30, -15, -14, -14, -9, -9, 23, -13, 10, - 12, 7, 16, 15, 3, 3, 1, -14, -9, -12, - -9, -8, 0, -10, 14, -4, 9, -2, 5, -8, - 13, 3, 18, 10, 45, 3, -16, 4, -4, 0, - }, { - -79, 11, -15, 4, 18, 23, 20, 5, 30, 7, - -7, -2, -21, -21, -8, -3, -10, 28, 4, 31, - 6, 25, -3, 37, 4, -7, 20, 0, 4, 4, - -11, 7, -6, 8, -27, -22, -14, -12, -5, -16, - }, { - -57, 0, -27, -13, 14, 5, 7, -11, 15, -4, - -5, -16, -13, -29, -6, 13, 0, 25, 16, 31, - 12, 22, -2, 23, 6, -16, 7, -14, 2, -3, - 0, 12, 0, 33, -9, -13, -28, 3, -14, -7, - }, { - -90, 3, -2, 6, 10, 29, 24, 26, 21, 15, - -15, -2, -16, -1, -25, -4, -21, 16, -6, 18, - -3, 8, -5, 24, -8, -7, 9, -4, 1, -3, - -5, -18, 1, 7, -2, 1, -2, 1, 19, -3, - }, { - -67, -8, -14, -11, 7, 11, 11, 9, 7, 3, - -13, -16, -8, -9, -24, 12, -10, 13, 5, 17, - 2, 4, -3, 10, -6, -17, -4, -19, 0, -11, - 6, -13, 9, 33, 14, 10, -16, 17, 10, 4, - }, { - -71, 10, -9, 17, 1, 20, 3, 8, 21, 18, - 6, 24, 0, -1, 0, -16, -6, 5, 0, 13, - 17, 19, 11, 29, 25, -11, 11, -6, 13, -15, - -7, 29, 0, 8, -11, -22, -20, -21, -17, -18, - }, { - -49, -2, -21, 0, -1, 2, -9, -8, 6, 6, - 8, 10, 8, -9, 2, 0, 4, 2, 13, 12, - 23, 15, 12, 16, 26, -21, -2, -21, 11, -23, - 4, 33, 7, 33, 6, -13, -34, -5, -27, -10, - }, { - -82, 1, 4, 19, -6, 27, 6, 29, 12, 26, - -1, 24, 5, 18, -17, -17, -17, -6, -10, 0, - 7, 2, 9, 16, 12, -11, 0, -11, 9, -23, - 0, 3, 8, 8, 13, 1, -8, -7, 7, -6, - }, { - -60, -10, -7, 1, -9, 8, -6, 13, -2, 15, - 1, 10, 13, 11, -15, 0, -6, -9, 1, 0, - 13, -1, 11, 3, 13, -21, -13, -26, 7, -31, - 10, 7, 16, 33, 31, 10, -22, 8, -1, 2, - }, { - -3, 7, -5, -5, 8, -2, 17, -9, 18, -24, - -2, -19, -10, -4, 28, 17, 5, 28, -2, 7, - -4, 15, 7, 8, 6, 23, 13, 21, -14, 20, - -17, -18, -11, -33, -30, -11, 23, -13, -5, -9, - }, { - 18, -4, -17, -23, 4, -20, 4, -26, 3, -36, - 0, -32, -2, -12, 29, 34, 16, 24, 10, 6, - 0, 12, 8, -4, 8, 13, 0, 6, -16, 12, - -5, -13, -3, -7, -13, -3, 8, 2, -14, 0, - }, { - -13, 0, 8, -3, 0, 4, 21, 11, 9, -16, - -10, -18, -5, 16, 10, 16, -5, 15, -13, -5, - -15, -1, 6, -4, -6, 23, 2, 16, -17, 12, - -10, -44, -3, -33, -6, 12, 34, 1, 20, 3, - }, { - 8, -12, -3, -21, -3, -14, 8, -5, -4, -28, - -7, -32, 2, 8, 12, 34, 4, 12, -1, -6, - -9, -4, 7, -17, -4, 13, -11, 1, -19, 4, - 0, -39, 4, -7, 11, 21, 20, 16, 10, 11, - }, { - 4, 6, 0, 7, -8, -4, 0, -6, 9, -13, - 11, 7, 11, 15, 37, 4, 9, 5, -5, -11, - 5, 9, 22, 1, 27, 18, 4, 14, -5, 0, - -12, 3, -4, -32, -14, -12, 17, -22, -17, -11, - }, { - 26, -6, -11, -10, -12, -23, -12, -23, -5, -24, - 13, -5, 19, 8, 38, 21, 20, 2, 6, -12, - 11, 5, 23, -11, 29, 9, -9, 0, -7, -6, - -1, 7, 2, -7, 3, -3, 2, -6, -27, -3, - }, { - -6, -2, 14, 9, -16, 1, 3, 14, 0, -5, - 3, 8, 16, 36, 19, 3, -1, -6, -17, -24, - -4, -7, 21, -11, 14, 18, -7, 9, -9, -7, - -6, -22, 3, -33, 10, 11, 28, -7, 7, 0, - }, { - 16, -14, 2, -8, -20, -17, -9, -2, -14, -16, - 6, -5, 24, 28, 21, 20, 8, -9, -4, -25, - 1, -11, 22, -24, 15, 8, -21, -5, -11, -14, - 5, -18, 11, -7, 27, 20, 14, 7, -1, 9, - }, { - -16, 27, 2, 10, 13, 16, 20, -20, 29, -20, - -14, -16, -13, -8, 9, 13, -2, 33, 9, 19, - 17, 23, 17, 22, 6, 6, -9, -2, -12, -2, - -20, -13, -13, -10, -45, -4, 16, -8, -2, -7, - }, { - 5, 15, -9, -7, 9, -2, 8, -37, 14, -31, - -11, -29, -5, -16, 11, 30, 7, 29, 21, 18, - 23, 19, 18, 9, 7, -3, -23, -17, -14, -9, - -8, -9, -6, 15, -27, 4, 2, 6, -12, 1, - }, { - -26, 19, 15, 12, 5, 22, 24, 0, 21, -12, - -21, -15, -8, 11, -7, 12, -14, 20, -2, 6, - 7, 6, 16, 9, -6, 5, -21, -7, -15, -10, - -13, -39, -5, -10, -20, 19, 28, 5, 22, 5, - }, { - -4, 6, 3, -5, 1, 4, 11, -16, 6, -23, - -19, -29, 0, 3, -6, 30, -3, 17, 10, 5, - 13, 2, 17, -3, -5, -3, -35, -21, -17, -17, - -2, -35, 2, 15, -3, 28, 13, 21, 13, 13, - }, { - -8, 25, 8, 23, -3, 13, 3, -17, 20, -8, - 0, 10, 8, 11, 18, 0, 1, 10, 5, 0, - 28, 17, 32, 15, 26, 1, -19, -9, -3, -21, - -15, 7, -6, -9, -29, -5, 10, -17, -15, -9, - }, { - 13, 13, -3, 5, -7, -4, -9, -34, 5, -20, - 2, -3, 16, 3, 20, 17, 11, 7, 17, 0, - 34, 13, 33, 2, 28, -8, -32, -24, -5, -29, - -3, 12, 0, 15, -11, 3, -3, -2, -24, -1, - }, { - -18, 17, 21, 25, -11, 19, 6, 3, 11, 0, - -7, 11, 13, 31, 1, 0, -9, -1, -5, -12, - 18, 0, 31, 2, 13, 1, -30, -14, -7, -29, - -9, -18, 1, -10, -4, 18, 22, -3, 10, 2, - }, { - 3, 5, 9, 7, -15, 1, -5, -13, -2, -12, - -5, -2, 21, 23, 2, 16, 0, -5, 6, -13, - 23, -3, 32, -10, 15, -8, -44, -28, -9, -37, - 2, -13, 9, 15, 12, 27, 7, 12, 0, 11, - }, { - -44, 6, -30, -8, 9, 10, 11, 14, 23, -5, - 8, -4, 14, -12, 37, 14, 12, 26, 4, 16, - -8, 16, -9, 7, -6, 19, 12, 25, -5, 24, - -15, -13, -8, -36, -34, -31, -1, -18, -4, -18, - }, { - -22, -5, -42, -26, 6, -8, -1, -2, 9, -17, - 10, -18, 21, -19, 39, 31, 23, 23, 16, 15, - -2, 12, -7, -6, -5, 9, -1, 10, -7, 16, - -4, -9, 0, -10, -17, -22, -16, -2, -14, -9, - }, { - -55, -1, -17, -6, 1, 16, 15, 35, 15, 2, - 0, -4, 19, 8, 20, 13, 1, 14, -7, 3, - -18, 0, -10, -5, -19, 19, 0, 21, -8, 16, - -9, -39, 0, -36, -10, -7, 9, -4, 20, -5, - }, { - -33, -13, -29, -24, -1, -1, 2, 18, 0, -9, - 3, -17, 27, 0, 21, 30, 12, 11, 5, 2, - -12, -4, -9, -19, -18, 9, -13, 6, -11, 8, - 2, -35, 8, -10, 7, 1, -4, 11, 10, 2, - }, { - -36, 5, -24, 4, -7, 7, -6, 17, 14, 5, - 22, 22, 35, 8, 46, 1, 17, 3, 0, -2, - 2, 10, 5, 0, 14, 15, 2, 18, 2, 4, - -11, 7, -1, -36, -18, -32, -7, -27, -17, -20, - }, { - -14, -7, -36, -13, -10, -10, -18, 0, 0, -5, - 25, 8, 43, 0, 48, 18, 27, 0, 12, -3, - 7, 6, 7, -13, 15, 5, -11, 3, 0, -2, - 0, 12, 6, -10, 0, -23, -22, -11, -26, -12, - }, { - -47, -3, -11, 6, -15, 13, -2, 38, 6, 13, - 15, 22, 40, 28, 28, 0, 5, -8, -10, -15, - -7, -7, 4, -13, 1, 14, -9, 14, 0, -2, - -4, -18, 7, -36, 6, -8, 3, -13, 7, -8, - }, { - -25, -15, -22, -11, -18, -4, -15, 22, -8, 2, - 17, 9, 48, 20, 30, 17, 16, -11, 1, -16, - -2, -10, 5, -26, 2, 4, -22, 0, -2, -10, - 6, -13, 14, -10, 23, 0, -10, 2, -1, 0, - }, { - -57, 26, -22, 7, 14, 28, 14, 3, 35, 0, - -3, -1, 11, -16, 18, 10, 4, 31, 15, 28, - 14, 23, 1, 21, -7, 2, -11, 1, -3, 1, - -18, -9, -10, -13, -49, -24, -8, -14, -2, -16, - }, { - -35, 14, -34, -10, 10, 10, 1, -12, 20, -12, - 0, -15, 18, -24, 20, 27, 14, 28, 27, 27, - 20, 19, 2, 8, -5, -7, -25, -13, -5, -5, - -6, -5, -2, 12, -31, -15, -23, 1, -12, -8, - }, { - -68, 18, -9, 9, 6, 35, 18, 25, 26, 7, - -10, -1, 16, 3, 1, 9, -6, 19, 4, 15, - 4, 6, 0, 8, -20, 2, -23, -2, -7, -5, - -12, -35, -1, -13, -24, 0, 3, 0, 22, -4, - }, { - -46, 6, -21, -8, 2, 16, 5, 8, 11, -4, - -8, -15, 24, -4, 2, 26, 3, 16, 16, 14, - 9, 2, 1, -4, -19, -7, -36, -17, -9, -13, - 0, -31, 5, 12, -7, 8, -11, 15, 13, 4, - }, { - -49, 24, -16, 20, -2, 26, -2, 7, 25, 10, - 11, 25, 32, 3, 27, -2, 8, 8, 11, 9, - 24, 17, 16, 14, 13, -2, -20, -5, 4, -17, - -14, 12, -3, -13, -33, -25, -14, -23, -15, -19, - }, { - -27, 12, -28, 2, -6, 7, -15, -9, 11, -1, - 13, 11, 40, -4, 29, 14, 19, 5, 23, 8, - 30, 13, 17, 0, 14, -12, -34, -20, 2, -25, - -2, 16, 4, 12, -15, -16, -29, -7, -24, -10, - }, { - -60, 16, -3, 22, -10, 32, 0, 28, 17, 18, - 3, 25, 37, 23, 10, -3, -2, -3, 0, -3, - 14, 0, 14, 1, 0, -2, -32, -9, 1, -25, - -7, -13, 5, -13, -8, -1, -2, -8, 10, -6, - }, { - -38, 4, -15, 4, -14, 13, -12, 11, 2, 6, - 6, 11, 45, 16, 11, 13, 7, -6, 12, -4, - 20, -3, 16, -12, 1, -12, -46, -24, 0, -33, - 3, -9, 12, 12, 8, 7, -17, 6, 0, 2 - } -}; - -static const int8_t cb2_vects[128][40]={ - { - 73, -32, -60, -15, -26, 59, 2, -33, 30, -10, - -3, -17, 8, 30, -1, -26, -4, -22, 10, 16, - -36, -5, -11, 56, 37, 6, -10, -5, -13, -3, - 6, -5, 11, 4, -19, -5, -16, 41, 24, 13, - }, { - 4, -11, -37, 23, -5, 46, -2, -29, -5, -39, - -21, -9, 0, 49, 12, -9, -16, -26, 22, 15, - -45, -20, -5, 40, 22, 17, -26, 31, -14, 2, - -14, 10, 30, 20, -27, -9, -39, 39, 18, 5, - }, { - 34, -25, -48, -28, -11, 34, -2, -41, 9, -7, - -17, 21, 20, 24, -17, -33, 0, -24, 10, 42, - 3, -5, 10, 42, 11, 8, -3, 3, 16, 9, - 22, -2, 0, -33, -10, 18, 7, 58, 10, 28, - }, { - -34, -4, -25, 10, 9, 21, -7, -36, -26, -36, - -35, 28, 12, 42, -3, -16, -12, -28, 21, 42, - -5, -21, 16, 26, -4, 19, -19, 39, 15, 15, - 1, 13, 19, -17, -17, 14, -15, 55, 4, 19, - }, { - 28, -20, -51, -14, -6, 7, 0, -26, 27, -4, - 18, -40, -6, 16, -1, -15, 0, -55, -5, -16, - -19, 14, -3, 49, 14, 1, -22, -30, -12, 0, - 24, 15, 9, -17, -45, -29, 4, 28, 51, 35, - }, { - -40, 0, -28, 24, 14, -5, -4, -21, -7, -33, - 0, -32, -15, 35, 12, 1, -11, -58, 5, -16, - -28, 0, 1, 33, 0, 11, -39, 5, -14, 6, - 3, 31, 28, -1, -53, -33, -19, 25, 46, 26, - }, { - -11, -14, -39, -27, 9, -17, -4, -33, 6, 0, - 4, -1, 5, 10, -17, -22, 5, -57, -5, 9, - 20, 13, 18, 35, -11, 3, -16, -22, 17, 13, - 40, 19, -1, -55, -35, -5, 27, 44, 37, 49, - }, { - -80, 6, -16, 11, 30, -30, -9, -28, -28, -29, - -13, 6, -2, 28, -3, -5, -7, -60, 5, 9, - 11, -1, 24, 19, -27, 13, -32, 13, 15, 19, - 19, 35, 17, -39, -43, -9, 4, 42, 32, 41, - }, { - 78, -21, -43, 4, -38, 17, 17, -5, 55, 24, - -15, -36, 14, 4, 24, -24, 12, 5, 17, 31, - -54, -5, -2, 27, 43, -12, 2, 9, -9, -15, - 22, -3, 28, 21, -20, 3, 20, 28, 9, -5, - }, { - 9, -1, -20, 43, -17, 3, 12, 0, 20, -4, - -33, -29, 6, 22, 38, -7, 0, 1, 29, 30, - -63, -21, 3, 11, 27, -1, -14, 45, -10, -9, - 1, 12, 47, 37, -28, 0, -2, 26, 4, -13, - }, { - 39, -14, -30, -8, -22, -8, 12, -12, 34, 27, - -29, 2, 26, -2, 8, -31, 16, 3, 17, 57, - -14, -6, 19, 13, 16, -10, 8, 17, 20, -2, - 38, 0, 17, -16, -11, 27, 44, 45, -4, 8, - }, { - -29, 5, -7, 30, -1, -21, 7, -7, 0, 0, - -47, 9, 18, 15, 22, -14, 4, 0, 28, 57, - -23, -21, 25, -2, 1, 0, -7, 53, 19, 3, - 17, 15, 36, 0, -19, 24, 21, 43, -9, 0, - }, { - 33, -10, -34, 5, -17, -35, 15, 1, 53, 30, - 6, -59, 0, -10, 24, -13, 17, -27, 1, -1, - -37, 13, 4, 20, 20, -18, -10, -16, -8, -11, - 39, 18, 26, 0, -46, -20, 41, 15, 37, 15, - }, { - -35, 10, -11, 44, 3, -48, 10, 6, 17, 2, - -11, -51, -8, 8, 38, 3, 4, -31, 12, -2, - -46, -1, 10, 4, 5, -7, -26, 19, -10, -5, - 18, 34, 45, 15, -54, -24, 18, 13, 31, 7, - }, { - -5, -3, -21, -7, -2, -60, 10, -5, 32, 34, - -7, -20, 11, -16, 8, -20, 21, -29, 1, 24, - 2, 13, 27, 6, -5, -15, -3, -8, 21, 1, - 55, 21, 15, -38, -37, 3, 65, 32, 23, 30, - }, { - -74, 17, 0, 31, 18, -73, 5, 0, -3, 5, - -25, -12, 3, 1, 22, -3, 9, -33, 12, 24, - -6, -2, 33, -9, -21, -5, -20, 27, 19, 7, - 34, 37, 34, -22, -44, 0, 41, 29, 17, 21, - }, { - 76, -35, -31, -28, -49, 43, -40, 0, 29, -14, - 8, 5, 10, 18, -26, -46, 0, 7, 6, 3, - -25, -7, -2, 40, 28, 14, 18, -3, -27, -28, - -8, -45, -13, 34, -13, -27, -15, 31, 12, 3, - }, { - 7, -15, -9, 9, -28, 29, -45, 5, -6, -43, - -9, 12, 2, 36, -12, -30, -11, 3, 17, 3, - -34, -22, 3, 24, 12, 24, 2, 32, -28, -22, - -29, -29, 5, 50, -21, -31, -38, 29, 7, -5, - }, { - 36, -29, -19, -41, -34, 18, -45, -6, 8, -10, - -5, 43, 23, 11, -42, -53, 5, 5, 6, 30, - 14, -8, 20, 26, 1, 16, 25, 4, 3, -15, - 7, -41, -23, -3, -4, -3, 8, 48, -1, 17, - }, { - -32, -8, 3, -2, -13, 4, -50, -1, -27, -39, - -23, 51, 15, 30, -27, -37, -7, 1, 17, 29, - 5, -23, 25, 10, -14, 26, 8, 41, 1, -9, - -13, -26, -5, 12, -12, -7, -14, 45, -6, 9, - }, { - 31, -24, -23, -27, -29, -9, -43, 8, 26, -7, - 30, -17, -4, 3, -26, -35, 5, -24, -10, -28, - -9, 12, 5, 33, 5, 8, 5, -29, -26, -24, - 9, -23, -14, 12, -39, -52, 5, 18, 39, 24, - }, { - -37, -3, 0, 10, -7, -22, -48, 12, -8, -36, - 12, -9, -12, 22, -12, -19, -6, -28, 0, -29, - -18, -3, 11, 17, -10, 18, -10, 7, -27, -18, - -11, -7, 3, 28, -47, -55, -18, 15, 34, 16, - }, { - -8, -17, -10, -40, -13, -34, -47, 0, 5, -4, - 16, 21, 8, -2, -42, -43, 10, -26, -10, -2, - 31, 11, 27, 19, -21, 10, 12, -20, 3, -11, - 25, -20, -25, -25, -29, -28, 28, 34, 25, 38, - }, { - -77, 2, 11, -1, 7, -47, -52, 5, -29, -33, - -1, 28, 0, 15, -28, -26, -2, -30, 0, -2, - 22, -4, 33, 3, -36, 21, -3, 15, 2, -5, - 4, -4, -6, -9, -37, -31, 5, 32, 20, 30, - }, { - 81, -25, -14, -8, -61, 0, -25, 28, 54, 20, - -3, -14, 17, -8, 0, -44, 16, 35, 13, 18, - -43, -7, 6, 11, 33, -4, 30, 11, -22, -40, - 6, -43, 3, 50, -14, -18, 22, 18, -1, -16, - }, { - 12, -4, 8, 29, -39, -12, -30, 33, 19, -8, - -21, -6, 8, 9, 13, -28, 4, 31, 24, 18, - -52, -23, 12, -4, 18, 5, 14, 47, -24, -34, - -14, -27, 22, 66, -22, -22, -1, 16, -6, -24, - }, { - 41, -18, -2, -21, -45, -24, -30, 21, 33, 24, - -17, 24, 29, -15, -16, -51, 21, 33, 13, 45, - -3, -8, 28, -2, 7, -2, 37, 19, 7, -27, - 22, -39, -7, 12, -5, 5, 45, 35, -15, -1, - }, { - -27, 1, 20, 17, -24, -38, -35, 26, -1, -4, - -35, 32, 21, 3, -2, -35, 8, 29, 24, 44, - -12, -24, 34, -18, -8, 7, 21, 55, 5, -21, - 2, -23, 11, 28, -13, 1, 22, 33, -21, -10, - }, { - 36, -13, -5, -7, -40, -51, -28, 36, 52, 27, - 18, -36, 2, -22, 0, -33, 21, 2, -3, -13, - -26, 11, 14, 4, 10, -10, 18, -14, -22, -36, - 24, -21, 1, 28, -40, -42, 42, 5, 25, 5, - }, { - -32, 6, 17, 31, -19, -65, -33, 41, 16, -1, - 0, -29, -6, -4, 13, -17, 9, -1, 8, -14, - -35, -3, 19, -11, -4, 0, 1, 21, -23, -30, - 3, -5, 20, 44, -48, -46, 19, 3, 20, -3, - }, { - -3, -7, 6, -20, -25, -77, -32, 29, 31, 30, - 4, 2, 14, -29, -16, -40, 26, 0, -3, 12, - 13, 10, 36, -9, -15, -8, 24, -6, 7, -22, - 40, -17, -8, -9, -31, -18, 66, 22, 11, 19, - }, { - -72, 13, 29, 18, -4, -90, -37, 34, -4, 1, - -13, 9, 6, -11, -2, -24, 13, -3, 7, 11, - 4, -4, 42, -25, -31, 1, 8, 29, 6, -17, - 19, -2, 10, 6, -38, -22, 42, 19, 6, 11, - }, { - 116, -20, -68, -30, -28, 83, 28, -18, 32, -22, - -13, -21, 5, 28, 5, -7, -24, -8, -22, 17, - -23, 30, -25, 45, 15, -9, -11, -18, 22, -10, - 4, -2, 19, -12, 23, 3, -43, 2, 12, -4, - }, { - 47, 0, -45, 7, -7, 69, 23, -13, -2, -51, - -32, -14, -3, 47, 19, 8, -37, -11, -10, 16, - -32, 15, -19, 29, 0, 1, -28, 18, 20, -4, - -16, 13, 38, 3, 15, 0, -66, 0, 7, -13, - }, { - 77, -13, -56, -43, -13, 57, 23, -26, 11, -19, - -27, 16, 17, 22, -10, -15, -19, -10, -22, 43, - 16, 30, -2, 31, -11, -6, -5, -9, 52, 2, - 20, 0, 8, -50, 33, 27, -19, 19, -1, 9, - }, { - 8, 6, -33, -4, 7, 44, 18, -21, -23, -48, - -46, 24, 9, 40, 3, 1, -32, -13, -11, 43, - 7, 14, 3, 15, -26, 3, -21, 26, 50, 8, - 0, 16, 27, -34, 25, 23, -43, 17, -6, 1, - }, { - 71, -9, -59, -29, -8, 30, 26, -11, 30, -16, - 8, -44, -9, 14, 5, 2, -19, -40, -38, -15, - -7, 50, -17, 38, -7, -14, -24, -43, 22, -6, - 22, 19, 17, -34, -2, -20, -23, -10, 39, 16, - }, { - 2, 11, -36, 9, 13, 17, 21, -6, -5, -45, - -10, -36, -18, 33, 19, 19, -31, -44, -27, -15, - -16, 34, -11, 22, -22, -4, -40, -7, 21, 0, - 1, 35, 36, -18, -10, -24, -46, -12, 34, 8, - }, { - 32, -2, -47, -42, 7, 5, 21, -18, 9, -12, - -5, -5, 2, 8, -10, -4, -14, -42, -38, 10, - 33, 49, 5, 24, -33, -12, -17, -35, 52, 6, - 38, 22, 7, -72, 7, 3, 0, 6, 25, 30, - }, { - -36, 18, -24, -3, 28, -7, 16, -13, -26, -41, - -24, 1, -5, 26, 3, 12, -27, -46, -27, 10, - 24, 34, 10, 8, -49, -2, -34, 0, 51, 12, - 17, 38, 25, -56, 0, 0, -22, 3, 20, 22, - }, { - 121, -9, -50, -10, -40, 40, 43, 9, 58, 12, - -25, -41, 11, 2, 31, -5, -8, 19, -15, 32, - -41, 30, -16, 16, 20, -28, 0, -3, 26, -22, - 19, 0, 36, 4, 22, 12, -6, -9, -1, -24, - }, { - 52, 10, -27, 27, -18, 26, 38, 14, 23, -16, - -44, -33, 3, 20, 45, 10, -20, 15, -3, 31, - -50, 14, -10, 0, 5, -17, -15, 32, 24, -16, - -1, 15, 55, 20, 14, 8, -29, -12, -7, -32, - }, { - 82, -3, -38, -23, -24, 15, 38, 2, 37, 15, - -39, -2, 23, -4, 15, -12, -3, 17, -15, 58, - -1, 29, 6, 2, -5, -26, 7, 4, 56, -9, - 35, 3, 25, -33, 32, 36, 17, 7, -15, -9, - }, { - 13, 17, -15, 15, -3, 1, 33, 7, 1, -12, - -58, 5, 15, 13, 29, 3, -16, 13, -4, 57, - -10, 13, 11, -13, -21, -15, -9, 40, 55, -3, - 14, 19, 44, -17, 24, 32, -5, 4, -21, -18, - }, { - 76, 1, -41, -9, -19, -12, 41, 17, 55, 18, - -3, -63, -3, -12, 30, 5, -3, -12, -31, 0, - -24, 49, -8, 9, -1, -33, -12, -29, 27, -18, - 37, 21, 34, -17, -3, -11, 14, -23, 25, -2, - }, { - 7, 22, -18, 29, 1, -25, 36, 21, 20, -9, - -22, -56, -11, 6, 45, 21, -15, -16, -20, -1, - -33, 34, -2, -6, -17, -23, -28, 6, 25, -12, - 16, 37, 53, -1, -11, -15, -8, -25, 20, -11, - }, { - 37, 8, -29, -22, -4, -37, 36, 9, 34, 22, - -17, -24, 8, -18, 15, -2, 1, -14, -31, 25, - 15, 48, 13, -4, -28, -31, -5, -21, 57, -4, - 53, 24, 23, -55, 6, 12, 37, -6, 11, 11, - }, { - -31, 28, -6, 16, 16, -50, 31, 14, 0, -6, - -36, -17, 0, 0, 29, 14, -11, -18, -20, 25, - 6, 33, 19, -20, -43, -21, -21, 14, 55, 0, - 32, 40, 42, -39, -1, 8, 14, -8, 6, 3, - }, { - 119, -24, -39, -44, -51, 66, -14, 15, 31, -26, - -1, 0, 7, 16, -19, -28, -19, 22, -26, 4, - -13, 28, -16, 29, 5, -1, 16, -16, 8, -35, - -10, -42, -4, 17, 29, -19, -42, -7, 0, -15, - }, { - 50, -3, -16, -5, -30, 53, -19, 20, -3, -55, - -19, 8, 0, 34, -5, -11, -32, 18, -15, 4, - -22, 13, -10, 13, -9, 8, 0, 19, 7, -29, - -31, -26, 13, 33, 21, -22, -65, -9, -4, -23, - }, { - 79, -17, -27, -56, -36, 41, -19, 8, 10, -22, - -15, 39, 20, 9, -35, -35, -15, 20, -26, 31, - 26, 27, 6, 15, -20, 0, 23, -8, 38, -22, - 5, -38, -15, -20, 39, 4, -18, 9, -13, -1, - }, { - 10, 3, -4, -18, -15, 27, -24, 13, -24, -51, - -34, 47, 12, 28, -21, -19, -27, 16, -15, 30, - 17, 12, 12, 0, -36, 10, 7, 27, 37, -16, - -15, -22, 3, -4, 31, 1, -42, 7, -18, -9, - }, { - 74, -12, -30, -42, -30, 14, -16, 23, 29, -19, - 20, -21, -7, 1, -19, -17, -14, -10, -43, -27, - 3, 48, -8, 22, -16, -7, 4, -42, 9, -31, - 6, -20, -6, -4, 3, -43, -22, -20, 28, 5, - }, { - 5, 7, -7, -4, -9, 0, -21, 28, -6, -48, - 2, -14, -15, 20, -5, 0, -27, -14, -32, -28, - -5, 32, -2, 6, -32, 3, -12, -5, 8, -25, - -14, -4, 12, 11, -4, -47, -45, -22, 22, -2, - }, { - 34, -6, -18, -55, -15, -11, -21, 16, 8, -16, - 6, 16, 5, -4, -35, -24, -10, -12, -43, -1, - 43, 47, 14, 8, -43, -5, 10, -34, 39, -18, - 22, -16, -17, -42, 13, -19, 1, -3, 14, 20, - }, { - -34, 14, 4, -17, 5, -24, -26, 20, -27, -45, - -12, 24, -2, 13, -21, -8, -22, -16, -32, -2, - 34, 31, 20, -7, -58, 5, -5, 2, 38, -12, - 2, -1, 1, -26, 5, -23, -21, -6, 8, 11, - }, { - 124, -13, -21, -23, -62, 23, 0, 43, 57, 8, - -13, -18, 14, -10, 6, -26, -3, 49, -19, 19, - -31, 27, -7, 0, 11, -20, 29, -1, 12, -47, - 4, -39, 11, 34, 28, -9, -5, -19, -13, -34, - }, { - 55, 6, 1, 14, -41, 10, -4, 48, 22, -20, - -31, -10, 5, 7, 20, -9, -16, 45, -8, 19, - -40, 12, -1, -15, -4, -10, 12, 34, 11, -41, - -16, -24, 30, 49, 20, -13, -28, -22, -18, -43, - }, { - 84, -6, -9, -36, -47, -1, -4, 36, 36, 12, - -27, 20, 26, -17, -9, -33, 1, 47, -19, 46, - 9, 27, 15, -13, -15, -18, 35, 6, 42, -33, - 20, -36, 1, -4, 38, 14, 18, -2, -27, -20, - }, { - 15, 13, 13, 1, -26, -14, -9, 41, 1, -16, - -46, 27, 18, 1, 4, -16, -11, 43, -8, 45, - 0, 11, 21, -29, -30, -8, 19, 42, 41, -28, - 0, -20, 20, 11, 30, 10, -4, -5, -32, -28, - }, { - 79, -2, -12, -22, -42, -28, -1, 51, 54, 15, - 8, -41, 0, -24, 6, -15, 1, 17, -36, -12, - -14, 47, 0, -6, -11, -26, 16, -27, 13, -43, - 22, -18, 10, 12, 2, -34, 15, -33, 13, -13, - }, { - 10, 18, 10, 15, -21, -41, -6, 56, 19, -13, - -9, -33, -9, -6, 20, 1, -11, 13, -24, -13, - -23, 32, 6, -22, -26, -15, 0, 8, 12, -37, - 1, -2, 28, 27, -5, -37, -7, -35, 8, -21, - }, { - 39, 4, 0, -35, -27, -53, -6, 44, 33, 18, - -5, -2, 11, -31, -9, -22, 6, 15, -36, 13, - 25, 46, 23, -20, -37, -24, 23, -19, 43, -29, - 38, -14, 0, -26, 12, -10, 38, -16, 0, 0, - }, { - -29, 25, 22, 2, -6, -67, -11, 49, -1, -10, - -24, 5, 3, -13, 4, -5, -6, 11, -25, 12, - 16, 31, 28, -36, -53, -13, 6, 16, 42, -24, - 17, 1, 18, -10, 4, -13, 15, -18, -5, -7, - }, { - 29, -25, -22, -2, 6, 67, 11, -49, 1, 10, - 24, -5, -3, 13, -4, 5, 6, -11, 25, -12, - -16, -31, -28, 36, 53, 13, -6, -16, -42, 24, - -17, -1, -18, 10, -4, 13, -15, 18, 5, 7, - }, { - -39, -4, 0, 35, 27, 53, 6, -44, -33, -18, - 5, 2, -11, 31, 9, 22, -6, -15, 36, -13, - -25, -46, -23, 20, 37, 24, -23, 19, -43, 29, - -38, 14, 0, 26, -12, 10, -38, 16, 0, 0, - }, { - -10, -18, -10, -15, 21, 41, 6, -56, -19, 13, - 9, 33, 9, 6, -20, -1, 11, -13, 24, 13, - 23, -32, -6, 22, 26, 15, 0, -8, -12, 37, - -1, 2, -28, -27, 5, 37, 7, 35, -8, 21, - }, { - -79, 2, 12, 22, 42, 28, 1, -51, -54, -15, - -8, 41, 0, 24, -6, 15, -1, -17, 36, 12, - 14, -47, 0, 6, 11, 26, -16, 27, -13, 43, - -22, 18, -10, -12, -2, 34, -15, 33, -13, 13, - }, { - -15, -13, -13, -1, 26, 14, 9, -41, -1, 16, - 46, -27, -18, -1, -4, 16, 11, -43, 8, -45, - 0, -11, -21, 29, 30, 8, -19, -42, -41, 28, - 0, 20, -20, -11, -30, -10, 4, 5, 32, 28, - }, { - -84, 6, 9, 36, 47, 1, 4, -36, -36, -12, - 27, -20, -26, 17, 9, 33, -1, -47, 19, -46, - -9, -27, -15, 13, 15, 18, -35, -6, -42, 33, - -20, 36, -1, 4, -38, -14, -18, 2, 27, 20, - }, { - -55, -6, -1, -14, 41, -10, 4, -48, -22, 20, - 31, 10, -5, -7, -20, 9, 16, -45, 8, -19, - 40, -12, 1, 15, 4, 10, -12, -34, -11, 41, - 16, 24, -30, -49, -20, 13, 28, 22, 18, 43, - }, { - -124, 13, 21, 23, 62, -23, 0, -43, -57, -8, - 13, 18, -14, 10, -6, 26, 3, -49, 19, -19, - 31, -27, 7, 0, -11, 20, -29, 1, -12, 47, - -4, 39, -11, -34, -28, 9, 5, 19, 13, 34, - }, { - 34, -14, -4, 17, -5, 24, 26, -20, 27, 45, - 12, -24, 2, -13, 21, 8, 22, 16, 32, 2, - -34, -31, -20, 7, 58, -5, 5, -2, -38, 12, - -2, 1, -1, 26, -5, 23, 21, 6, -8, -11, - }, { - -34, 6, 18, 55, 15, 11, 21, -16, -8, 16, - -6, -16, -5, 4, 35, 24, 10, 12, 43, 1, - -43, -47, -14, -8, 43, 5, -10, 34, -39, 18, - -22, 16, 17, 42, -13, 19, -1, 3, -14, -20, - }, { - -5, -7, 7, 4, 9, 0, 21, -28, 6, 48, - -2, 14, 15, -20, 5, 0, 27, 14, 32, 28, - 5, -32, 2, -6, 32, -3, 12, 5, -8, 25, - 14, 4, -12, -11, 4, 47, 45, 22, -22, 2, - }, { - -74, 12, 30, 42, 30, -14, 16, -23, -29, 19, - -20, 21, 7, -1, 19, 17, 14, 10, 43, 27, - -3, -48, 8, -22, 16, 7, -4, 42, -9, 31, - -6, 20, 6, 4, -3, 43, 22, 20, -28, -5, - }, { - -10, -3, 4, 18, 15, -27, 24, -13, 24, 51, - 34, -47, -12, -28, 21, 19, 27, -16, 15, -30, - -17, -12, -12, 0, 36, -10, -7, -27, -37, 16, - 15, 22, -3, 4, -31, -1, 42, -7, 18, 9, - }, { - -79, 17, 27, 56, 36, -41, 19, -8, -10, 22, - 15, -39, -20, -9, 35, 35, 15, -20, 26, -31, - -26, -27, -6, -15, 20, 0, -23, 8, -38, 22, - -5, 38, 15, 20, -39, -4, 18, -9, 13, 1, - }, { - -50, 3, 16, 5, 30, -53, 19, -20, 3, 55, - 19, -8, 0, -34, 5, 11, 32, -18, 15, -4, - 22, -13, 10, -13, 9, -8, 0, -19, -7, 29, - 31, 26, -13, -33, -21, 22, 65, 9, 4, 23, - }, { - -119, 24, 39, 44, 51, -66, 14, -15, -31, 26, - 1, 0, -7, -16, 19, 28, 19, -22, 26, -4, - 13, -28, 16, -29, -5, 1, -16, 16, -8, 35, - 10, 42, 4, -17, -29, 19, 42, 7, 0, 15, - }, { - 31, -28, 6, -16, -16, 50, -31, -14, 0, 6, - 36, 17, 0, 0, -29, -14, 11, 18, 20, -25, - -6, -33, -19, 20, 43, 21, 21, -14, -55, 0, - -32, -40, -42, 39, 1, -8, -14, 8, -6, -3, - }, { - -37, -8, 29, 22, 4, 37, -36, -9, -34, -22, - 17, 24, -8, 18, -15, 2, -1, 14, 31, -25, - -15, -48, -13, 4, 28, 31, 5, 21, -57, 4, - -53, -24, -23, 55, -6, -12, -37, 6, -11, -11, - }, { - -7, -22, 18, -29, -1, 25, -36, -21, -20, 9, - 22, 56, 11, -6, -45, -21, 15, 16, 20, 1, - 33, -34, 2, 6, 17, 23, 28, -6, -25, 12, - -16, -37, -53, 1, 11, 15, 8, 25, -20, 11, - }, { - -76, -1, 41, 9, 19, 12, -41, -17, -55, -18, - 3, 63, 3, 12, -30, -5, 3, 12, 31, 0, - 24, -49, 8, -9, 1, 33, 12, 29, -27, 18, - -37, -21, -34, 17, 3, 11, -14, 23, -25, 2, - }, { - -13, -17, 15, -15, 3, -1, -33, -7, -1, 12, - 58, -5, -15, -13, -29, -3, 16, -13, 4, -57, - 10, -13, -11, 13, 21, 15, 9, -40, -55, 3, - -14, -19, -44, 17, -24, -32, 5, -4, 21, 18, - }, { - -82, 3, 38, 23, 24, -15, -38, -2, -37, -15, - 39, 2, -23, 4, -15, 12, 3, -17, 15, -58, - 1, -29, -6, -2, 5, 26, -7, -4, -56, 9, - -35, -3, -25, 33, -32, -36, -17, -7, 15, 9, - }, { - -52, -10, 27, -27, 18, -26, -38, -14, -23, 16, - 44, 33, -3, -20, -45, -10, 20, -15, 3, -31, - 50, -14, 10, 0, -5, 17, 15, -32, -24, 16, - 1, -15, -55, -20, -14, -8, 29, 12, 7, 32, - }, { - -121, 9, 50, 10, 40, -40, -43, -9, -58, -12, - 25, 41, -11, -2, -31, 5, 8, -19, 15, -32, - 41, -30, 16, -16, -20, 28, 0, 3, -26, 22, - -19, 0, -36, -4, -22, -12, 6, 9, 1, 24, - }, { - 36, -18, 24, 3, -28, 7, -16, 13, 26, 41, - 24, -1, 5, -26, -3, -12, 27, 46, 27, -10, - -24, -34, -10, -8, 49, 2, 34, 0, -51, -12, - -17, -38, -25, 56, 0, 0, 22, -3, -20, -22, - }, { - -32, 2, 47, 42, -7, -5, -21, 18, -9, 12, - 5, 5, -2, -8, 10, 4, 14, 42, 38, -10, - -33, -49, -5, -24, 33, 12, 17, 35, -52, -6, - -38, -22, -7, 72, -7, -3, 0, -6, -25, -30, - }, { - -2, -11, 36, -9, -13, -17, -21, 6, 5, 45, - 10, 36, 18, -33, -19, -19, 31, 44, 27, 15, - 16, -34, 11, -22, 22, 4, 40, 7, -21, 0, - -1, -35, -36, 18, 10, 24, 46, 12, -34, -8, - }, { - -71, 9, 59, 29, 8, -30, -26, 11, -30, 16, - -8, 44, 9, -14, -5, -2, 19, 40, 38, 15, - 7, -50, 17, -38, 7, 14, 24, 43, -22, 6, - -22, -19, -17, 34, 2, 20, 23, 10, -39, -16, - }, { - -8, -6, 33, 4, -7, -44, -18, 21, 23, 48, - 46, -24, -9, -40, -3, -1, 32, 13, 11, -43, - -7, -14, -3, -15, 26, -3, 21, -26, -50, -8, - 0, -16, -27, 34, -25, -23, 43, -17, 6, -1, - }, { - -77, 13, 56, 43, 13, -57, -23, 26, -11, 19, - 27, -16, -17, -22, 10, 15, 19, 10, 22, -43, - -16, -30, 2, -31, 11, 6, 5, 9, -52, -2, - -20, 0, -8, 50, -33, -27, 19, -19, 1, -9, - }, { - -47, 0, 45, -7, 7, -69, -23, 13, 2, 51, - 32, 14, 3, -47, -19, -8, 37, 11, 10, -16, - 32, -15, 19, -29, 0, -1, 28, -18, -20, 4, - 16, -13, -38, -3, -15, 0, 66, 0, -7, 13, - }, { - -116, 20, 68, 30, 28, -83, -28, 18, -32, 22, - 13, 21, -5, -28, -5, 7, 24, 8, 22, -17, - 23, -30, 25, -45, -15, 9, 11, 18, -22, 10, - -4, 2, -19, 12, -23, -3, 43, -2, -12, 4, - }, { - 72, -13, -29, -18, 4, 90, 37, -34, 4, -1, - 13, -9, -6, 11, 2, 24, -13, 3, -7, -11, - -4, 4, -42, 25, 31, -1, -8, -29, -6, 17, - -19, 2, -10, -6, 38, 22, -42, -19, -6, -11, - }, { - 3, 7, -6, 20, 25, 77, 32, -29, -31, -30, - -4, -2, -14, 29, 16, 40, -26, 0, 3, -12, - -13, -10, -36, 9, 15, 8, -24, 6, -7, 22, - -40, 17, 8, 9, 31, 18, -66, -22, -11, -19, - }, { - 32, -6, -17, -31, 19, 65, 33, -41, -16, 1, - 0, 29, 6, 4, -13, 17, -9, 1, -8, 14, - 35, 3, -19, 11, 4, 0, -1, -21, 23, 30, - -3, 5, -20, -44, 48, 46, -19, -3, -20, 3, - }, { - -36, 13, 5, 7, 40, 51, 28, -36, -52, -27, - -18, 36, -2, 22, 0, 33, -21, -2, 3, 13, - 26, -11, -14, -4, -10, 10, -18, 14, 22, 36, - -24, 21, -1, -28, 40, 42, -42, -5, -25, -5, - }, { - 27, -1, -20, -17, 24, 38, 35, -26, 1, 4, - 35, -32, -21, -3, 2, 35, -8, -29, -24, -44, - 12, 24, -34, 18, 8, -7, -21, -55, -5, 21, - -2, 23, -11, -28, 13, -1, -22, -33, 21, 10, - }, { - -41, 18, 2, 21, 45, 24, 30, -21, -33, -24, - 17, -24, -29, 15, 16, 51, -21, -33, -13, -45, - 3, 8, -28, 2, -7, 2, -37, -19, -7, 27, - -22, 39, 7, -12, 5, -5, -45, -35, 15, 1, - }, { - -12, 4, -8, -29, 39, 12, 30, -33, -19, 8, - 21, 6, -8, -9, -13, 28, -4, -31, -24, -18, - 52, 23, -12, 4, -18, -5, -14, -47, 24, 34, - 14, 27, -22, -66, 22, 22, 1, -16, 6, 24, - }, { - -81, 25, 14, 8, 61, 0, 25, -28, -54, -20, - 3, 14, -17, 8, 0, 44, -16, -35, -13, -18, - 43, 7, -6, -11, -33, 4, -30, -11, 22, 40, - -6, 43, -3, -50, 14, 18, -22, -18, 1, 16, - }, { - 77, -2, -11, 1, -7, 47, 52, -5, 29, 33, - 1, -28, 0, -15, 28, 26, 2, 30, 0, 2, - -22, 4, -33, -3, 36, -21, 3, -15, -2, 5, - -4, 4, 6, 9, 37, 31, -5, -32, -20, -30, - }, { - 8, 17, 10, 40, 13, 34, 47, 0, -5, 4, - -16, -21, -8, 2, 42, 43, -10, 26, 10, 2, - -31, -11, -27, -19, 21, -10, -12, 20, -3, 11, - -25, 20, 25, 25, 29, 28, -28, -34, -25, -38, - }, { - 37, 3, 0, -10, 7, 22, 48, -12, 8, 36, - -12, 9, 12, -22, 12, 19, 6, 28, 0, 29, - 18, 3, -11, -17, 10, -18, 10, -7, 27, 18, - 11, 7, -3, -28, 47, 55, 18, -15, -34, -16, - }, { - -31, 24, 23, 27, 29, 9, 43, -8, -26, 7, - -30, 17, 4, -3, 26, 35, -5, 24, 10, 28, - 9, -12, -5, -33, -5, -8, -5, 29, 26, 24, - -9, 23, 14, -12, 39, 52, -5, -18, -39, -24, - }, { - 32, 8, -3, 2, 13, -4, 50, 1, 27, 39, - 23, -51, -15, -30, 27, 37, 7, -1, -17, -29, - -5, 23, -25, -10, 14, -26, -8, -41, -1, 9, - 13, 26, 5, -12, 12, 7, 14, -45, 6, -9, - }, { - -36, 29, 19, 41, 34, -18, 45, 6, -8, 10, - 5, -43, -23, -11, 42, 53, -5, -5, -6, -30, - -14, 8, -20, -26, -1, -16, -25, -4, -3, 15, - -7, 41, 23, 3, 4, 3, -8, -48, 1, -17, - }, { - -7, 15, 9, -9, 28, -29, 45, -5, 6, 43, - 9, -12, -2, -36, 12, 30, 11, -3, -17, -3, - 34, 22, -3, -24, -12, -24, -2, -32, 28, 22, - 29, 29, -5, -50, 21, 31, 38, -29, -7, 5, - }, { - -76, 35, 31, 28, 49, -43, 40, 0, -29, 14, - -8, -5, -10, -18, 26, 46, 0, -7, -6, -3, - 25, 7, 2, -40, -28, -14, -18, 3, 27, 28, - 8, 45, 13, -34, 13, 27, 15, -31, -12, -3, - }, { - 74, -17, 0, -31, -18, 73, -5, 0, 3, -5, - 25, 12, -3, -1, -22, 3, -9, 33, -12, -24, - 6, 2, -33, 9, 21, 5, 20, -27, -19, -7, - -34, -37, -34, 22, 44, 0, -41, -29, -17, -21, - }, { - 5, 3, 21, 7, 2, 60, -10, 5, -32, -34, - 7, 20, -11, 16, -8, 20, -21, 29, -1, -24, - -2, -13, -27, -6, 5, 15, 3, 8, -21, -1, - -55, -21, -15, 38, 37, -3, -65, -32, -23, -30, - }, { - 35, -10, 11, -44, -3, 48, -10, -6, -17, -2, - 11, 51, 8, -8, -38, -3, -4, 31, -12, 2, - 46, 1, -10, -4, -5, 7, 26, -19, 10, 5, - -18, -34, -45, -15, 54, 24, -18, -13, -31, -7, - }, { - -33, 10, 34, -5, 17, 35, -15, -1, -53, -30, - -6, 59, 0, 10, -24, 13, -17, 27, -1, 1, - 37, -13, -4, -20, -20, 18, 10, 16, 8, 11, - -39, -18, -26, 0, 46, 20, -41, -15, -37, -15, - }, { - 29, -5, 7, -30, 1, 21, -7, 7, 0, 0, - 47, -9, -18, -15, -22, 14, -4, 0, -28, -57, - 23, 21, -25, 2, -1, 0, 7, -53, -19, -3, - -17, -15, -36, 0, 19, -24, -21, -43, 9, 0, - }, { - -39, 14, 30, 8, 22, 8, -12, 12, -34, -27, - 29, -2, -26, 2, -8, 31, -16, -3, -17, -57, - 14, 6, -19, -13, -16, 10, -8, -17, -20, 2, - -38, 0, -17, 16, 11, -27, -44, -45, 4, -8, - }, { - -9, 1, 20, -43, 17, -3, -12, 0, -20, 4, - 33, 29, -6, -22, -38, 7, 0, -1, -29, -30, - 63, 21, -3, -11, -27, 1, 14, -45, 10, 9, - -1, -12, -47, -37, 28, 0, 2, -26, -4, 13, - }, { - -78, 21, 43, -4, 38, -17, -17, 5, -55, -24, - 15, 36, -14, -4, -24, 24, -12, -5, -17, -31, - 54, 5, 2, -27, -43, 12, -2, -9, 9, 15, - -22, 3, -28, -21, 20, -3, -20, -28, -9, 5, - }, { - 80, -6, 16, -11, -30, 30, 9, 28, 28, 29, - 13, -6, 2, -28, 3, 5, 7, 60, -5, -9, - -11, 1, -24, -19, 27, -13, 32, -13, -15, -19, - -19, -35, -17, 39, 43, 9, -4, -42, -32, -41, - }, { - 11, 14, 39, 27, -9, 17, 4, 33, -6, 0, - -4, 1, -5, -10, 17, 22, -5, 57, 5, -9, - -20, -13, -18, -35, 11, -3, 16, 22, -17, -13, - -40, -19, 1, 55, 35, 5, -27, -44, -37, -49, - }, { - 40, 0, 28, -24, -14, 5, 4, 21, 7, 33, - 0, 32, 15, -35, -12, -1, 11, 58, -5, 16, - 28, 0, -1, -33, 0, -11, 39, -5, 14, -6, - -3, -31, -28, 1, 53, 33, 19, -25, -46, -26, - }, { - -28, 20, 51, 14, 6, -7, 0, 26, -27, 4, - -18, 40, 6, -16, 1, 15, 0, 55, 5, 16, - 19, -14, 3, -49, -14, -1, 22, 30, 12, 0, - -24, -15, -9, 17, 45, 29, -4, -28, -51, -35, - }, { - 34, 4, 25, -10, -9, -21, 7, 36, 26, 36, - 35, -28, -12, -42, 3, 16, 12, 28, -21, -42, - 5, 21, -16, -26, 4, -19, 19, -39, -15, -15, - -1, -13, -19, 17, 17, -14, 15, -55, -4, -19, - }, { - -34, 25, 48, 28, 11, -34, 2, 41, -9, 7, - 17, -21, -20, -24, 17, 33, 0, 24, -10, -42, - -3, 5, -10, -42, -11, -8, 3, -3, -16, -9, - -22, 2, 0, 33, 10, -18, -7, -58, -10, -28, - }, { - -4, 11, 37, -23, 5, -46, 2, 29, 5, 39, - 21, 9, 0, -49, -12, 9, 16, 26, -22, -15, - 45, 20, 5, -40, -22, -17, 26, -31, 14, -2, - 14, -10, -30, -20, 27, 9, 39, -39, -18, -5, - }, { - -73, 32, 60, 15, 26, -59, -2, 33, -30, 10, - 3, 17, -8, -30, 1, 26, 4, 22, -10, -16, - 36, 5, 11, -56, -37, -6, 10, 5, 13, 3, - -6, 5, -11, -4, 19, 5, 16, -41, -24, -13 - } -}; - -static const uint16_t cb1_base[128]={ - 19657, 18474, 18365, 17520, 21048, 18231, 18584, 16671, - 20363, 19069, 19409, 18430, 21844, 18753, 19613, 17411, - 20389, 21772, 20129, 21702, 20978, 20472, 19627, 19387, - 21477, 23134, 21841, 23919, 22089, 21519, 21134, 20852, - 19675, 17821, 19044, 17477, 19986, 16955, 18446, 16086, - 21138, 18899, 20952, 18929, 21452, 17833, 20104, 17159, - 19770, 20056, 20336, 20866, 19329, 18217, 18908, 18004, - 21556, 21948, 23079, 23889, 20922, 19544, 20984, 19781, - 19781, 20984, 19544, 20922, 23889, 23079, 21948, 21556, - 18004, 18908, 18217, 19329, 20866, 20336, 20056, 19770, - 17159, 20104, 17833, 21452, 18929, 20952, 18899, 21138, - 16086, 18446, 16955, 19986, 17477, 19044, 17821, 19675, - 20852, 21134, 21519, 22089, 23919, 21841, 23134, 21477, - 19387, 19627, 20472, 20978, 21702, 20129, 21772, 20389, - 17411, 19613, 18753, 21844, 18430, 19409, 19069, 20363, - 16671, 18584, 18231, 21048, 17520, 18365, 18474, 19657, -}; - -static const uint16_t cb2_base[128]={ - 12174, 13380, 13879, 13832, 13170, 13227, 13204, 12053, - 12410, 13988, 14348, 14631, 13100, 13415, 13224, 12268, - 11982, 13825, 13499, 14210, 13877, 14788, 13811, 13109, - 11449, 13275, 12833, 13717, 12728, 13696, 12759, 12405, - 10230, 12185, 11628, 13161, 11762, 13458, 12312, 12818, - 10443, 12773, 12011, 14020, 11818, 13825, 12453, 13226, - 10446, 13162, 11881, 14300, 12859, 16288, 13490, 15053, - 10155, 12820, 11519, 13973, 12041, 15081, 12635, 14198, - 14198, 12635, 15081, 12041, 13973, 11519, 12820, 10155, - 15053, 13490, 16288, 12859, 14300, 11881, 13162, 10446, - 13226, 12453, 13825, 11818, 14020, 12011, 12773, 10443, - 12818, 12312, 13458, 11762, 13161, 11628, 12185, 10230, - 12405, 12759, 13696, 12728, 13717, 12833, 13275, 11449, - 13109, 13811, 14788, 13877, 14210, 13499, 13825, 11982, - 12268, 13224, 13415, 13100, 14631, 14348, 13988, 12410, - 12053, 13204, 13227, 13170, 13832, 13879, 13380, 12174, -}; - -static const int16_t energy_tab[32]={ - 0, 16, 20, 25, 32, 41, 51, 65, - 81, 103, 129, 163, 205, 259, 326, 410, - 516, 650, 819, 1031, 1298, 1634, 2057, 2590, - 3261, 4105, 5168, 6507, 8192, 10313, 12983, 16345 -}; - -static const int16_t lpc_refl_cb1[64]={ - -4041, -4018, -3998, -3977, -3954, -3930, -3906, -3879, - -3852, -3825, -3795, -3764, -3731, -3699, -3666, -3631, - -3594, -3555, -3513, -3468, -3420, -3372, -3321, -3268, - -3212, -3153, -3090, -3021, -2944, -2863, -2772, -2676, - -2565, -2445, -2328, -2202, -2072, -1941, -1808, -1660, - -1508, -1348, -1185, -994, -798, -600, -374, -110, - 152, 447, 720, 982, 1229, 1456, 1682, 1916, - 2130, 2353, 2595, 2853, 3118, 3363, 3588, 3814 -}; - -static const int16_t lpc_refl_cb2[32]={ - -3091, -2386, -1871, -1425, -1021, -649, -316, -20, - 267, 544, 810, 1065, 1305, 1534, 1756, 1970, - 2171, 2359, 2536, 2700, 2854, 2996, 3133, 3263, - 3386, 3499, 3603, 3701, 3789, 3870, 3947, 4020 -}; - -static const int16_t lpc_refl_cb3[32]={ - -3525, -3295, -3081, -2890, -2696, -2511, -2328, -2149, - -1979, -1817, -1658, -1498, -1341, -1188, -1032, -876, - -721, -561, -394, -228, -54, 119, 296, 484, - 683, 895, 1123, 1373, 1651, 1965, 2360, 2854 -}; - -static const int16_t lpc_refl_cb4[16]={ - -1845, -1057, -522, -77, 301, 647, 975, 1285, - 1582, 1873, 2163, 2452, 2735, 3017, 3299, 3569 -}; - -static const int16_t lpc_refl_cb5[16]={ - -2691, -2187, -1788, -1435, -1118, -837, -571, -316, - -59, 201, 470, 759, 1077, 1457, 1908, 2495 -}; - -static const int16_t lpc_refl_cb6[8]={ - -1372, -474, 133, 632, 1100, 1571, 2075, 2672 -}; - -static const int16_t lpc_refl_cb7[8]={ - -2389, -1787, -1231, -717, -239, 234, 770, 1474 -}; - -static const int16_t lpc_refl_cb8[8]={ - -1569, -864, -296, 200, 670, 1151, 1709, 2385 -}; - -static const int16_t lpc_refl_cb9[8]={ - -2200, -1608, -1062, -569, -120, 338, 863, 1621 -}; - -static const int16_t lpc_refl_cb10[4]={ - -617, 190, 802, 1483 -}; - -static const int16_t * const lpc_refl_cb[10]={ - lpc_refl_cb1, lpc_refl_cb2, lpc_refl_cb3, lpc_refl_cb4, lpc_refl_cb5, - lpc_refl_cb6, lpc_refl_cb7, lpc_refl_cb8, lpc_refl_cb9, lpc_refl_cb10 -}; +#include "dsputil.h" + +#define NBLOCKS 4 ///< number of subblocks within a block +#define BLOCKSIZE 40 ///< subblock size in 16-bit words +#define BUFFERSIZE 146 ///< the size of the adaptive codebook +#define FIXED_CB_SIZE 128 ///< size of fixed codebooks +#define FRAMESIZE 20 ///< size of encoded frame +#define LPC_ORDER 10 ///< order of LPC filter + +typedef struct { + AVCodecContext *avctx; + DSPContext dsp; + + unsigned int old_energy; ///< previous frame energy + + unsigned int lpc_tables[2][10]; + + /** LPC coefficients: lpc_coef[0] is the coefficients of the current frame + * and lpc_coef[1] of the previous one. */ + unsigned int *lpc_coef[2]; + + unsigned int lpc_refl_rms[2]; + + int16_t curr_block[NBLOCKS * BLOCKSIZE]; + + /** The current subblock padded by the last 10 values of the previous one. */ + int16_t curr_sblock[50]; + + /** Adaptive codebook, its size is two units bigger to avoid a + * buffer overflow. */ + uint16_t adapt_cb[146+2]; +} RA144Context; + +void ff_add_wav(int16_t *dest, int n, int skip_first, int *m, const int16_t *s1, + const int8_t *s2, const int8_t *s3); +void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset); +int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx); +void ff_eval_coefs(int *coefs, const int *refl); +void ff_int_to_int16(int16_t *out, const int *inp); +int ff_t_sqrt(unsigned int x); +unsigned int ff_rms(const int *data); +int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold, + int energy); +unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy); +int ff_irms(const int16_t *data); +void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs, + int cba_idx, int cb1_idx, int cb2_idx, + int gval, int gain); + +extern const int16_t ff_gain_val_tab[256][3]; +extern const uint8_t ff_gain_exp_tab[256]; +extern const int8_t ff_cb1_vects[128][40]; +extern const int8_t ff_cb2_vects[128][40]; +extern const uint16_t ff_cb1_base[128]; +extern const uint16_t ff_cb2_base[128]; +extern const int16_t ff_energy_tab[32]; +extern const int16_t * const ff_lpc_refl_cb[10]; #endif /* AVCODEC_RA144_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144dec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144dec.c new file mode 100644 index 000000000..5b391d467 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144dec.c @@ -0,0 +1,128 @@ +/* + * Real Audio 1.0 (14.4K) + * + * Copyright (c) 2008 Vitor Sessak + * Copyright (c) 2003 Nick Kurshev + * Based on public domain decoder at http://www.honeypot.net/audio + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/intmath.h" +#include "avcodec.h" +#include "get_bits.h" +#include "ra144.h" + + +static av_cold int ra144_decode_init(AVCodecContext * avctx) +{ + RA144Context *ractx = avctx->priv_data; + + ractx->avctx = avctx; + + ractx->lpc_coef[0] = ractx->lpc_tables[0]; + ractx->lpc_coef[1] = ractx->lpc_tables[1]; + + avctx->sample_fmt = SAMPLE_FMT_S16; + return 0; +} + +static void do_output_subblock(RA144Context *ractx, const uint16_t *lpc_coefs, + int gval, GetBitContext *gb) +{ + int cba_idx = get_bits(gb, 7); // index of the adaptive CB, 0 if none + int gain = get_bits(gb, 8); + int cb1_idx = get_bits(gb, 7); + int cb2_idx = get_bits(gb, 7); + + ff_subblock_synthesis(ractx, lpc_coefs, cba_idx, cb1_idx, cb2_idx, gval, + gain); +} + +/** Uncompress one block (20 bytes -> 160*2 bytes). */ +static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, + int *data_size, AVPacket *avpkt) +{ + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; + static const uint8_t sizes[10] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2}; + unsigned int refl_rms[4]; // RMS of the reflection coefficients + uint16_t block_coefs[4][10]; // LPC coefficients of each sub-block + unsigned int lpc_refl[10]; // LPC reflection coefficients of the frame + int i, j; + int16_t *data = vdata; + unsigned int energy; + + RA144Context *ractx = avctx->priv_data; + GetBitContext gb; + + if (*data_size < 2*160) + return -1; + + if(buf_size < 20) { + av_log(avctx, AV_LOG_ERROR, + "Frame too small (%d bytes). Truncated file?\n", buf_size); + *data_size = 0; + return buf_size; + } + init_get_bits(&gb, buf, 20 * 8); + + for (i=0; i<10; i++) + lpc_refl[i] = ff_lpc_refl_cb[i][get_bits(&gb, sizes[i])]; + + ff_eval_coefs(ractx->lpc_coef[0], lpc_refl); + ractx->lpc_refl_rms[0] = ff_rms(lpc_refl); + + energy = ff_energy_tab[get_bits(&gb, 5)]; + + refl_rms[0] = ff_interp(ractx, block_coefs[0], 1, 1, ractx->old_energy); + refl_rms[1] = ff_interp(ractx, block_coefs[1], 2, + energy <= ractx->old_energy, + ff_t_sqrt(energy*ractx->old_energy) >> 12); + refl_rms[2] = ff_interp(ractx, block_coefs[2], 3, 0, energy); + refl_rms[3] = ff_rescale_rms(ractx->lpc_refl_rms[0], energy); + + ff_int_to_int16(block_coefs[3], ractx->lpc_coef[0]); + + for (i=0; i < 4; i++) { + do_output_subblock(ractx, block_coefs[i], refl_rms[i], &gb); + + for (j=0; j < BLOCKSIZE; j++) + *data++ = av_clip_int16(ractx->curr_sblock[j + 10] << 2); + } + + ractx->old_energy = energy; + ractx->lpc_refl_rms[1] = ractx->lpc_refl_rms[0]; + + FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]); + + *data_size = 2*160; + return 20; +} + +AVCodec ra_144_decoder = +{ + "real_144", + AVMEDIA_TYPE_AUDIO, + CODEC_ID_RA_144, + sizeof(RA144Context), + ra144_decode_init, + NULL, + NULL, + ra144_decode_frame, + .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"), +}; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144enc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144enc.c new file mode 100644 index 000000000..9e2cf36c2 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra144enc.c @@ -0,0 +1,511 @@ +/* + * Real Audio 1.0 (14.4K) encoder + * Copyright (c) 2010 Francesco Lavra + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Real Audio 1.0 (14.4K) encoder + * @author Francesco Lavra + */ + +#include + +#include "avcodec.h" +#include "put_bits.h" +#include "lpc.h" +#include "celp_filters.h" +#include "ra144.h" + + +static av_cold int ra144_encode_init(AVCodecContext * avctx) +{ + RA144Context *ractx; + + if (avctx->sample_fmt != SAMPLE_FMT_S16) { + av_log(avctx, AV_LOG_ERROR, "invalid sample format\n"); + return -1; + } + if (avctx->channels != 1) { + av_log(avctx, AV_LOG_ERROR, "invalid number of channels: %d\n", + avctx->channels); + return -1; + } + avctx->frame_size = NBLOCKS * BLOCKSIZE; + avctx->bit_rate = 8000; + ractx = avctx->priv_data; + ractx->lpc_coef[0] = ractx->lpc_tables[0]; + ractx->lpc_coef[1] = ractx->lpc_tables[1]; + ractx->avctx = avctx; + dsputil_init(&ractx->dsp, avctx); + return 0; +} + + +/** + * Quantize a value by searching a sorted table for the element with the + * nearest value + * + * @param value value to quantize + * @param table array containing the quantization table + * @param size size of the quantization table + * @return index of the quantization table corresponding to the element with the + * nearest value + */ +static int quantize(int value, const int16_t *table, unsigned int size) +{ + unsigned int low = 0, high = size - 1; + + while (1) { + int index = (low + high) >> 1; + int error = table[index] - value; + + if (index == low) + return table[high] + error > value ? low : high; + if (error > 0) { + high = index; + } else { + low = index; + } + } +} + + +/** + * Orthogonalize a vector to another vector + * + * @param v vector to orthogonalize + * @param u vector against which orthogonalization is performed + */ +static void orthogonalize(float *v, const float *u) +{ + int i; + float num = 0, den = 0; + + for (i = 0; i < BLOCKSIZE; i++) { + num += v[i] * u[i]; + den += u[i] * u[i]; + } + num /= den; + for (i = 0; i < BLOCKSIZE; i++) + v[i] -= num * u[i]; +} + + +/** + * Calculate match score and gain of an LPC-filtered vector with respect to + * input data, possibly othogonalizing it to up to 2 other vectors + * + * @param work array used to calculate the filtered vector + * @param coefs coefficients of the LPC filter + * @param vect original vector + * @param ortho1 first vector against which orthogonalization is performed + * @param ortho2 second vector against which orthogonalization is performed + * @param data input data + * @param score pointer to variable where match score is returned + * @param gain pointer to variable where gain is returned + */ +static void get_match_score(float *work, const float *coefs, float *vect, + const float *ortho1, const float *ortho2, + const float *data, float *score, float *gain) +{ + float c, g; + int i; + + ff_celp_lp_synthesis_filterf(work, coefs, vect, BLOCKSIZE, LPC_ORDER); + if (ortho1) + orthogonalize(work, ortho1); + if (ortho2) + orthogonalize(work, ortho2); + c = g = 0; + for (i = 0; i < BLOCKSIZE; i++) { + g += work[i] * work[i]; + c += data[i] * work[i]; + } + if (c <= 0) { + *score = 0; + return; + } + *gain = c / g; + *score = *gain * c; +} + + +/** + * Create a vector from the adaptive codebook at a given lag value + * + * @param vect array where vector is stored + * @param cb adaptive codebook + * @param lag lag value + */ +static void create_adapt_vect(float *vect, const int16_t *cb, int lag) +{ + int i; + + cb += BUFFERSIZE - lag; + for (i = 0; i < FFMIN(BLOCKSIZE, lag); i++) + vect[i] = cb[i]; + if (lag < BLOCKSIZE) + for (i = 0; i < BLOCKSIZE - lag; i++) + vect[lag + i] = cb[i]; +} + + +/** + * Search the adaptive codebook for the best entry and gain and remove its + * contribution from input data + * + * @param adapt_cb array from which the adaptive codebook is extracted + * @param work array used to calculate LPC-filtered vectors + * @param coefs coefficients of the LPC filter + * @param data input data + * @return index of the best entry of the adaptive codebook + */ +static int adaptive_cb_search(const int16_t *adapt_cb, float *work, + const float *coefs, float *data) +{ + int i, best_vect; + float score, gain, best_score, best_gain; + float exc[BLOCKSIZE]; + + gain = best_score = 0; + for (i = BLOCKSIZE / 2; i <= BUFFERSIZE; i++) { + create_adapt_vect(exc, adapt_cb, i); + get_match_score(work, coefs, exc, NULL, NULL, data, &score, &gain); + if (score > best_score) { + best_score = score; + best_vect = i; + best_gain = gain; + } + } + if (!best_score) + return 0; + + /** + * Re-calculate the filtered vector from the vector with maximum match score + * and remove its contribution from input data. + */ + create_adapt_vect(exc, adapt_cb, best_vect); + ff_celp_lp_synthesis_filterf(work, coefs, exc, BLOCKSIZE, LPC_ORDER); + for (i = 0; i < BLOCKSIZE; i++) + data[i] -= best_gain * work[i]; + return (best_vect - BLOCKSIZE / 2 + 1); +} + + +/** + * Find the best vector of a fixed codebook by applying an LPC filter to + * codebook entries, possibly othogonalizing them to up to 2 other vectors and + * matching the results with input data + * + * @param work array used to calculate the filtered vectors + * @param coefs coefficients of the LPC filter + * @param cb fixed codebook + * @param ortho1 first vector against which orthogonalization is performed + * @param ortho2 second vector against which orthogonalization is performed + * @param data input data + * @param idx pointer to variable where the index of the best codebook entry is + * returned + * @param gain pointer to variable where the gain of the best codebook entry is + * returned + */ +static void find_best_vect(float *work, const float *coefs, + const int8_t cb[][BLOCKSIZE], const float *ortho1, + const float *ortho2, float *data, int *idx, + float *gain) +{ + int i, j; + float g, score, best_score; + float vect[BLOCKSIZE]; + + *idx = *gain = best_score = 0; + for (i = 0; i < FIXED_CB_SIZE; i++) { + for (j = 0; j < BLOCKSIZE; j++) + vect[j] = cb[i][j]; + get_match_score(work, coefs, vect, ortho1, ortho2, data, &score, &g); + if (score > best_score) { + best_score = score; + *idx = i; + *gain = g; + } + } +} + + +/** + * Search the two fixed codebooks for the best entry and gain + * + * @param work array used to calculate LPC-filtered vectors + * @param coefs coefficients of the LPC filter + * @param data input data + * @param cba_idx index of the best entry of the adaptive codebook + * @param cb1_idx pointer to variable where the index of the best entry of the + * first fixed codebook is returned + * @param cb2_idx pointer to variable where the index of the best entry of the + * second fixed codebook is returned + */ +static void fixed_cb_search(float *work, const float *coefs, float *data, + int cba_idx, int *cb1_idx, int *cb2_idx) +{ + int i, ortho_cb1; + float gain; + float cba_vect[BLOCKSIZE], cb1_vect[BLOCKSIZE]; + float vect[BLOCKSIZE]; + + /** + * The filtered vector from the adaptive codebook can be retrieved from + * work, because this function is called just after adaptive_cb_search(). + */ + if (cba_idx) + memcpy(cba_vect, work, sizeof(cba_vect)); + + find_best_vect(work, coefs, ff_cb1_vects, cba_idx ? cba_vect : NULL, NULL, + data, cb1_idx, &gain); + + /** + * Re-calculate the filtered vector from the vector with maximum match score + * and remove its contribution from input data. + */ + if (gain) { + for (i = 0; i < BLOCKSIZE; i++) + vect[i] = ff_cb1_vects[*cb1_idx][i]; + ff_celp_lp_synthesis_filterf(work, coefs, vect, BLOCKSIZE, LPC_ORDER); + if (cba_idx) + orthogonalize(work, cba_vect); + for (i = 0; i < BLOCKSIZE; i++) + data[i] -= gain * work[i]; + memcpy(cb1_vect, work, sizeof(cb1_vect)); + ortho_cb1 = 1; + } else + ortho_cb1 = 0; + + find_best_vect(work, coefs, ff_cb2_vects, cba_idx ? cba_vect : NULL, + ortho_cb1 ? cb1_vect : NULL, data, cb2_idx, &gain); +} + + +/** + * Encode a subblock of the current frame + * + * @param ractx encoder context + * @param sblock_data input data of the subblock + * @param lpc_coefs coefficients of the LPC filter + * @param rms RMS of the reflection coefficients + * @param pb pointer to PutBitContext of the current frame + */ +static void ra144_encode_subblock(RA144Context *ractx, + const int16_t *sblock_data, + const int16_t *lpc_coefs, unsigned int rms, + PutBitContext *pb) +{ + float data[BLOCKSIZE], work[LPC_ORDER + BLOCKSIZE]; + float coefs[LPC_ORDER]; + float zero[BLOCKSIZE], cba[BLOCKSIZE], cb1[BLOCKSIZE], cb2[BLOCKSIZE]; + int16_t cba_vect[BLOCKSIZE]; + int cba_idx, cb1_idx, cb2_idx, gain; + int i, n, m[3]; + float g[3]; + float error, best_error; + + for (i = 0; i < LPC_ORDER; i++) { + work[i] = ractx->curr_sblock[BLOCKSIZE + i]; + coefs[i] = lpc_coefs[i] * (1/4096.0); + } + + /** + * Calculate the zero-input response of the LPC filter and subtract it from + * input data. + */ + memset(data, 0, sizeof(data)); + ff_celp_lp_synthesis_filterf(work + LPC_ORDER, coefs, data, BLOCKSIZE, + LPC_ORDER); + for (i = 0; i < BLOCKSIZE; i++) { + zero[i] = work[LPC_ORDER + i]; + data[i] = sblock_data[i] - zero[i]; + } + + /** + * Codebook search is performed without taking into account the contribution + * of the previous subblock, since it has been just subtracted from input + * data. + */ + memset(work, 0, LPC_ORDER * sizeof(*work)); + + cba_idx = adaptive_cb_search(ractx->adapt_cb, work + LPC_ORDER, coefs, + data); + if (cba_idx) { + /** + * The filtered vector from the adaptive codebook can be retrieved from + * work, see implementation of adaptive_cb_search(). + */ + memcpy(cba, work + LPC_ORDER, sizeof(cba)); + + ff_copy_and_dup(cba_vect, ractx->adapt_cb, cba_idx + BLOCKSIZE / 2 - 1); + m[0] = (ff_irms(cba_vect) * rms) >> 12; + } + fixed_cb_search(work + LPC_ORDER, coefs, data, cba_idx, &cb1_idx, &cb2_idx); + for (i = 0; i < BLOCKSIZE; i++) { + cb1[i] = ff_cb1_vects[cb1_idx][i]; + cb2[i] = ff_cb2_vects[cb2_idx][i]; + } + ff_celp_lp_synthesis_filterf(work + LPC_ORDER, coefs, cb1, BLOCKSIZE, + LPC_ORDER); + memcpy(cb1, work + LPC_ORDER, sizeof(cb1)); + m[1] = (ff_cb1_base[cb1_idx] * rms) >> 8; + ff_celp_lp_synthesis_filterf(work + LPC_ORDER, coefs, cb2, BLOCKSIZE, + LPC_ORDER); + memcpy(cb2, work + LPC_ORDER, sizeof(cb2)); + m[2] = (ff_cb2_base[cb2_idx] * rms) >> 8; + best_error = FLT_MAX; + gain = 0; + for (n = 0; n < 256; n++) { + g[1] = ((ff_gain_val_tab[n][1] * m[1]) >> ff_gain_exp_tab[n]) * + (1/4096.0); + g[2] = ((ff_gain_val_tab[n][2] * m[2]) >> ff_gain_exp_tab[n]) * + (1/4096.0); + error = 0; + if (cba_idx) { + g[0] = ((ff_gain_val_tab[n][0] * m[0]) >> ff_gain_exp_tab[n]) * + (1/4096.0); + for (i = 0; i < BLOCKSIZE; i++) { + data[i] = zero[i] + g[0] * cba[i] + g[1] * cb1[i] + + g[2] * cb2[i]; + error += (data[i] - sblock_data[i]) * + (data[i] - sblock_data[i]); + } + } else { + for (i = 0; i < BLOCKSIZE; i++) { + data[i] = zero[i] + g[1] * cb1[i] + g[2] * cb2[i]; + error += (data[i] - sblock_data[i]) * + (data[i] - sblock_data[i]); + } + } + if (error < best_error) { + best_error = error; + gain = n; + } + } + put_bits(pb, 7, cba_idx); + put_bits(pb, 8, gain); + put_bits(pb, 7, cb1_idx); + put_bits(pb, 7, cb2_idx); + ff_subblock_synthesis(ractx, lpc_coefs, cba_idx, cb1_idx, cb2_idx, rms, + gain); +} + + +static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame, + int buf_size, void *data) +{ + static const uint8_t sizes[LPC_ORDER] = {64, 32, 32, 16, 16, 8, 8, 8, 8, 4}; + static const uint8_t bit_sizes[LPC_ORDER] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2}; + RA144Context *ractx; + PutBitContext pb; + int32_t lpc_data[NBLOCKS * BLOCKSIZE]; + int32_t lpc_coefs[LPC_ORDER][MAX_LPC_ORDER]; + int shift[LPC_ORDER]; + int16_t block_coefs[NBLOCKS][LPC_ORDER]; + int lpc_refl[LPC_ORDER]; /**< reflection coefficients of the frame */ + unsigned int refl_rms[NBLOCKS]; /**< RMS of the reflection coefficients */ + int energy = 0; + int i, idx; + + if (buf_size < FRAMESIZE) { + av_log(avctx, AV_LOG_ERROR, "output buffer too small\n"); + return 0; + } + ractx = avctx->priv_data; + + /** + * Since the LPC coefficients are calculated on a frame centered over the + * fourth subframe, to encode a given frame, data from the next frame is + * needed. In each call to this function, the previous frame (whose data are + * saved in the encoder context) is encoded, and data from the current frame + * are saved in the encoder context to be used in the next function call. + */ + for (i = 0; i < (2 * BLOCKSIZE + BLOCKSIZE / 2); i++) { + lpc_data[i] = ractx->curr_block[BLOCKSIZE + BLOCKSIZE / 2 + i]; + energy += (lpc_data[i] * lpc_data[i]) >> 4; + } + for (i = 2 * BLOCKSIZE + BLOCKSIZE / 2; i < NBLOCKS * BLOCKSIZE; i++) { + lpc_data[i] = *((int16_t *)data + i - 2 * BLOCKSIZE - BLOCKSIZE / 2) >> + 2; + energy += (lpc_data[i] * lpc_data[i]) >> 4; + } + energy = ff_energy_tab[quantize(ff_t_sqrt(energy >> 5) >> 10, ff_energy_tab, + 32)]; + + ff_lpc_calc_coefs(&ractx->dsp, lpc_data, NBLOCKS * BLOCKSIZE, LPC_ORDER, + LPC_ORDER, 16, lpc_coefs, shift, AV_LPC_TYPE_LEVINSON, + 0, ORDER_METHOD_EST, 12, 0); + for (i = 0; i < LPC_ORDER; i++) + block_coefs[NBLOCKS - 1][i] = -(lpc_coefs[LPC_ORDER - 1][i] << + (12 - shift[LPC_ORDER - 1])); + + /** + * TODO: apply perceptual weighting of the input speech through bandwidth + * expansion of the LPC filter. + */ + + if (ff_eval_refl(lpc_refl, block_coefs[NBLOCKS - 1], avctx)) { + /** + * The filter is unstable: use the coefficients of the previous frame. + */ + ff_int_to_int16(block_coefs[NBLOCKS - 1], ractx->lpc_coef[1]); + ff_eval_refl(lpc_refl, block_coefs[NBLOCKS - 1], avctx); + } + init_put_bits(&pb, frame, buf_size); + for (i = 0; i < LPC_ORDER; i++) { + idx = quantize(lpc_refl[i], ff_lpc_refl_cb[i], sizes[i]); + put_bits(&pb, bit_sizes[i], idx); + lpc_refl[i] = ff_lpc_refl_cb[i][idx]; + } + ractx->lpc_refl_rms[0] = ff_rms(lpc_refl); + ff_eval_coefs(ractx->lpc_coef[0], lpc_refl); + refl_rms[0] = ff_interp(ractx, block_coefs[0], 1, 1, ractx->old_energy); + refl_rms[1] = ff_interp(ractx, block_coefs[1], 2, + energy <= ractx->old_energy, + ff_t_sqrt(energy * ractx->old_energy) >> 12); + refl_rms[2] = ff_interp(ractx, block_coefs[2], 3, 0, energy); + refl_rms[3] = ff_rescale_rms(ractx->lpc_refl_rms[0], energy); + ff_int_to_int16(block_coefs[NBLOCKS - 1], ractx->lpc_coef[0]); + put_bits(&pb, 5, quantize(energy, ff_energy_tab, 32)); + for (i = 0; i < NBLOCKS; i++) + ra144_encode_subblock(ractx, ractx->curr_block + i * BLOCKSIZE, + block_coefs[i], refl_rms[i], &pb); + flush_put_bits(&pb); + ractx->old_energy = energy; + ractx->lpc_refl_rms[1] = ractx->lpc_refl_rms[0]; + FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]); + for (i = 0; i < NBLOCKS * BLOCKSIZE; i++) + ractx->curr_block[i] = *((int16_t *)data + i) >> 2; + return FRAMESIZE; +} + + +AVCodec ra_144_encoder = +{ + "real_144", + CODEC_TYPE_AUDIO, + CODEC_ID_RA_144, + sizeof(RA144Context), + ra144_encode_init, + ra144_encode_frame, + .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K) encoder"), +}; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra288.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra288.c index 20a21f5dc..bfc62e1ff 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra288.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/ra288.c @@ -27,6 +27,10 @@ #include "celp_math.h" #include "celp_filters.h" +#define MAX_BACKWARD_FILTER_ORDER 36 +#define MAX_BACKWARD_FILTER_LEN 40 +#define MAX_BACKWARD_FILTER_NONREC 35 + typedef struct { float sp_lpc[36]; ///< LPC coefficients for speech data (spec: A) float gain_lpc[10]; ///< LPC coefficients for gain (spec: GB) @@ -120,9 +124,9 @@ static void do_hybrid_window(int order, int n, int non_rec, float *out, float *hist, float *out2, const float *window) { int i; - float buffer1[order + 1]; - float buffer2[order + 1]; - float work[order + n + non_rec]; + float buffer1[MAX_BACKWARD_FILTER_ORDER + 1]; + float buffer2[MAX_BACKWARD_FILTER_ORDER + 1]; + float work[MAX_BACKWARD_FILTER_ORDER + MAX_BACKWARD_FILTER_LEN + MAX_BACKWARD_FILTER_NONREC]; apply_window(work, window, hist, order + n + non_rec); @@ -145,7 +149,7 @@ static void backward_filter(float *hist, float *rec, const float *window, float *lpc, const float *tab, int order, int n, int non_rec, int move_size) { - float temp[order+1]; + float temp[MAX_BACKWARD_FILTER_ORDER+1]; do_hybrid_window(order, n, non_rec, temp, hist, rec, window); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/raw.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/raw.c index 41f5c9091..1fbf4d252 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/raw.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/raw.c @@ -127,6 +127,8 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { { PIX_FMT_BGRA, MKTAG('B', 'G', 'R', 'A') }, { PIX_FMT_RGBA, MKTAG('R', 'G', 'B', 'A') }, { PIX_FMT_ABGR, MKTAG('A', 'B', 'G', 'R') }, + { PIX_FMT_GRAY16BE,MKTAG('b', '1', '6', 'g') }, + { PIX_FMT_RGB48BE, MKTAG('b', '4', '8', 'r') }, /* special */ { PIX_FMT_RGB565LE,MKTAG( 3 , 0 , 0 , 0 ) }, /* flipped RGB565LE */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rawdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rawdec.c index ab13bdc59..ce1febbf9 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rawdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rawdec.c @@ -77,7 +77,7 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx) avctx->pix_fmt = find_pix_fmt(pix_fmt_bps_mov, avctx->bits_per_coded_sample); else if (avctx->codec_tag) avctx->pix_fmt = find_pix_fmt(ff_raw_pix_fmt_tags, avctx->codec_tag); - else if (avctx->bits_per_coded_sample) + else if (avctx->pix_fmt == PIX_FMT_NONE && avctx->bits_per_coded_sample) avctx->pix_fmt = find_pix_fmt(pix_fmt_bps_avi, avctx->bits_per_coded_sample); context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/resample2.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/resample2.c index 45f41a144..b940059d8 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/resample2.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/resample2.c @@ -94,12 +94,17 @@ static double bessel(double x){ * @param factor resampling factor * @param scale wanted sum of coefficients for each filter * @param type 0->cubic, 1->blackman nuttall windowed sinc, 2..16->kaiser windowed sinc beta=2..16 + * @return 0 on success, negative on error */ -static void build_filter(FELEM *filter, double factor, int tap_count, int phase_count, int scale, int type){ +static int build_filter(FELEM *filter, double factor, int tap_count, int phase_count, int scale, int type){ int ph, i; - double x, y, w, tab[tap_count]; + double x, y, w; + double *tab = av_malloc(tap_count * sizeof(*tab)); const int center= (tap_count-1)/2; + if (!tab) + return AVERROR(ENOMEM); + /* if upsampling, only need to interpolate, no filter */ if (factor > 1.0) factor = 1.0; @@ -176,6 +181,9 @@ static void build_filter(FELEM *filter, double factor, int tap_count, int phase_ } } #endif + + av_free(tab); + return 0; } AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff){ @@ -183,13 +191,19 @@ AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_size, double factor= FFMIN(out_rate * cutoff / in_rate, 1.0); int phase_count= 1<phase_shift= phase_shift; c->phase_mask= phase_count-1; c->linear= linear; c->filter_length= FFMAX((int)ceil(filter_size/factor), 1); c->filter_bank= av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM)); - build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<filter_bank) + goto error; + if (build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM)); c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1]; @@ -198,6 +212,10 @@ AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_size, c->index= -phase_count*((c->filter_length-1)/2); return c; +error: + av_free(c->filter_bank); + av_free(c); + return NULL; } void av_resample_close(AVResampleContext *c){ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rl2.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rl2.c index 30f5e839c..1174c35d5 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rl2.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rl2.c @@ -50,7 +50,7 @@ typedef struct Rl2Context { /** * Run Length Decode a single 320x200 frame * @param s rl2 context - * @param buf input buffer + * @param in input buffer * @param size input buffer size * @param out ouput buffer * @param stride stride of the output buffer diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rle.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rle.h index f89244326..24851321f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rle.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rle.h @@ -28,7 +28,7 @@ * Value before raw bytes is (count ^ xor_raw) + add_raw. * @param outbuf Output buffer * @param out_size Maximum output size - * @param ptr Input buffer + * @param inbuf Input buffer * @param bpp Bytes per pixel * @param w Image width * @return Size of output in bytes, or -1 if larger than out_size diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/roqvideoenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/roqvideoenc.c index f9fbb64bd..28fd9d851 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/roqvideoenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/roqvideoenc.c @@ -165,7 +165,7 @@ static int eval_motion_dist(RoqContext *enc, int x, int y, motion_vect vect, } /** - * Returns distortion between two macroblocks + * @return distortion between two macroblocks */ static inline int squared_diff_macroblock(uint8_t a[], uint8_t b[], int size) { @@ -240,7 +240,7 @@ typedef struct RoqTempData } RoqTempdata; /** - * Initializes cel evaluators and sets their source coordinates + * Initialize cel evaluators and set their source coordinates */ static void create_cel_evals(RoqContext *enc, RoqTempdata *tempData) { @@ -393,7 +393,7 @@ static void motion_search(RoqContext *enc, int blocksize) } /** - * Gets distortion for all options available to a subcel + * Get distortion for all options available to a subcel */ static void gather_data_for_subcel(SubcelEvaluation *subcel, int x, int y, RoqContext *enc, RoqTempdata *tempData) @@ -457,7 +457,7 @@ static void gather_data_for_subcel(SubcelEvaluation *subcel, int x, } /** - * Gets distortion for all options available to a cel + * Get distortion for all options available to a cel */ static void gather_data_for_cel(CelEvaluation *cel, RoqContext *enc, RoqTempdata *tempData) @@ -773,7 +773,7 @@ static inline void frame_block_to_cell(uint8_t *block, uint8_t **data, } /** - * Creates YUV clusters for the entire image + * Create YUV clusters for the entire image */ static void create_clusters(AVFrame *frame, int w, int h, uint8_t *yuvClusters) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv10.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv10.c index b6ca031df..e9face622 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv10.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv10.c @@ -716,6 +716,7 @@ AVCodec rv10_decoder = { rv10_decode_end, rv10_decode_frame, CODEC_CAP_DR1, + .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("RealVideo 1.0"), .pix_fmts= ff_pixfmt_list_420, }; @@ -731,6 +732,7 @@ AVCodec rv20_decoder = { rv10_decode_frame, CODEC_CAP_DR1 | CODEC_CAP_DELAY, .flush= ff_mpeg_flush, + .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("RealVideo 2.0"), .pix_fmts= ff_pixfmt_list_420, }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv34.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv34.c index 88652f9fe..b586aa0b8 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv34.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv34.c @@ -103,8 +103,8 @@ static void rv34_gen_vlc(const uint8_t *bits, int size, VLC *vlc, const uint8_t { int i; int counts[17] = {0}, codes[17]; - uint16_t cw[size], syms[size]; - uint8_t bits2[size]; + uint16_t cw[MAX_VLC_SIZE], syms[MAX_VLC_SIZE]; + uint8_t bits2[MAX_VLC_SIZE]; int maxbits = 0, realsize = 0; for(i = 0; i < size; i++){ @@ -393,7 +393,7 @@ static inline void rv34_dequant4x4_16x16(DCTELEM *block, int Qdc, int Q) /** - * @defgroup bitstream RV30/40 bitstream parsing + * @defgroup rv3040_bitstream RV30/40 bitstream parsing * @{ */ @@ -1142,7 +1142,7 @@ static int rv34_set_deblock_coef(RV34DecContext *r) MpegEncContext *s = &r->s; int hmvmask = 0, vmvmask = 0, i, j; int midx = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; - int16_t (*motion_val)[2] = s->current_picture_ptr->motion_val[0][midx]; + int16_t (*motion_val)[2] = &s->current_picture_ptr->motion_val[0][midx]; for(j = 0; j < 16; j += 8){ for(i = 0; i < 2; i++){ if(is_mv_diff_gt_3(motion_val + i, 1)) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv34vlc.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv34vlc.h index 2b89e4cb4..aa29357c7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv34vlc.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv34vlc.h @@ -37,6 +37,7 @@ #define FIRSTBLK_VLC_SIZE 864 #define OTHERBLK_VLC_SIZE 108 #define COEFF_VLC_SIZE 32 +#define MAX_VLC_SIZE 1296 static const uint8_t rv34_table_intra_cbppat[NUM_INTRA_TABLES][2][CBPPAT_VLC_SIZE] = { { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv40.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv40.c index abdeeffb7..e4a46c188 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv40.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv40.c @@ -307,7 +307,7 @@ static inline void rv40_weak_loop_filter(uint8_t *src, const int step, } } -static inline void rv40_adaptive_loop_filter(uint8_t *src, const int step, +static av_always_inline void rv40_adaptive_loop_filter(uint8_t *src, const int step, const int stride, const int dmode, const int lim_q1, const int lim_p1, const int alpha, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv40data.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv40data.h index 556656920..7912919ba 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv40data.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/rv40data.h @@ -65,7 +65,7 @@ static const uint8_t rv40_luma_dc_quant[2][32] = { }; /** - * @begingroup loopfilter coefficients used by the RV40 loop filter + * @defgroup loopfilter coefficients used by the RV40 loop filter * @{ */ /** diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/sbr.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/sbr.h index f1da5c5fe..82a996fdc 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/sbr.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/sbr.h @@ -31,6 +31,7 @@ #include #include "fft.h" +#include "aacps.h" /** * Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the previous header. @@ -57,7 +58,7 @@ typedef struct { */ typedef struct { /** - * @defgroup bitstream Main bitstream data variables + * @defgroup aac_bitstream Main bitstream data variables * @{ */ unsigned bs_frame_class; @@ -133,6 +134,7 @@ typedef struct { ///The number of frequency bands in f_master unsigned n_master; SBRData data[2]; + PSContext ps; ///N_Low and N_High respectively, the number of frequency bands for low and high resolution unsigned n[2]; ///Number of noise floor bands @@ -157,7 +159,7 @@ typedef struct { ///QMF output of the HF generator float X_high[64][40][2]; ///QMF values of the reconstructed signal - DECLARE_ALIGNED(16, float, X)[2][2][32][64]; + DECLARE_ALIGNED(16, float, X)[2][2][38][64]; ///Zeroth coefficient used to filter the subband signals float alpha0[64][2]; ///First coefficient used to filter the subband signals diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/shorten.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/shorten.c index 7e17f18e1..213e5b39b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/shorten.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/shorten.c @@ -83,6 +83,7 @@ typedef struct ShortenContext { int32_t *decoded[MAX_CHANNELS]; int32_t *offset[MAX_CHANNELS]; + int *coeffs; uint8_t *bitstream; int bitstream_size; int bitstream_index; @@ -112,6 +113,8 @@ static av_cold int shorten_decode_init(AVCodecContext * avctx) static int allocate_buffers(ShortenContext *s) { int i, chan; + int *coeffs; + for (chan=0; chanchannels; chan++) { if(FFMAX(1, s->nmean) >= UINT_MAX/sizeof(int32_t)){ av_log(s->avctx, AV_LOG_ERROR, "nmean too large\n"); @@ -129,6 +132,12 @@ static int allocate_buffers(ShortenContext *s) s->decoded[chan][i] = 0; s->decoded[chan] += s->nwrap; } + + coeffs = av_realloc(s->coeffs, s->nwrap * sizeof(*s->coeffs)); + if (!coeffs) + return AVERROR(ENOMEM); + s->coeffs = coeffs; + return 0; } @@ -175,12 +184,12 @@ static void init_offset(ShortenContext *s) static inline int get_le32(GetBitContext *gb) { - return bswap_32(get_bits_long(gb, 32)); + return av_bswap32(get_bits_long(gb, 32)); } static inline short get_le16(GetBitContext *gb) { - return bswap_16(get_bits_long(gb, 16)); + return av_bswap16(get_bits_long(gb, 16)); } static int decode_wave_header(AVCodecContext *avctx, uint8_t *header, int header_size) @@ -253,7 +262,7 @@ static int16_t * interleave_buffer(int16_t *samples, int nchan, int blocksize, i static void decode_subframe_lpc(ShortenContext *s, int channel, int residual_size, int pred_order) { int sum, i, j; - int coeffs[pred_order]; + int *coeffs = s->coeffs; for (i=0; igb, LPCQUANT); @@ -427,6 +436,12 @@ static int shorten_decode_frame(AVCodecContext *avctx, case FN_QLPC: { int pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE); + if (pred_order > s->nwrap) { + av_log(avctx, AV_LOG_ERROR, + "invalid pred_order %d\n", + pred_order); + return -1; + } for (i=0; idecoded[channel][i - pred_order] -= coffset; decode_subframe_lpc(s, channel, residual_size, pred_order); @@ -515,6 +530,7 @@ static av_cold int shorten_decode_close(AVCodecContext *avctx) av_freep(&s->offset[i]); } av_freep(&s->bitstream); + av_freep(&s->coeffs); return 0; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/sipr.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/sipr.c index b76e89100..aa798340b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/sipr.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/sipr.c @@ -184,7 +184,7 @@ static void pitch_sharpening(int pitch_lag_int, float beta, } /** - * Extracts decoding parameters from the input bitstream. + * Extract decoding parameters from the input bitstream. * @param parms parameters structure * @param pgb pointer to initialized GetBitContext structure */ @@ -254,7 +254,7 @@ static void sipr_decode_lp(float *lsfnew, const float *lsfold, float *Az, } /** - * Evaluates the adaptive impulse response. + * Evaluate the adaptive impulse response. */ static void eval_ir(const float *Az, int pitch_lag, float *freq, float pitch_sharp_factor) @@ -276,7 +276,7 @@ static void eval_ir(const float *Az, int pitch_lag, float *freq, } /** - * Evaluates the convolution of a vector with a sparse vector. + * Evaluate the convolution of a vector with a sparse vector. */ static void convolute_with_sparse(float *out, const AMRFixed *pulses, const float *shape, int length) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/smacker.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/smacker.c index 1d85f6890..ac2f76b77 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/smacker.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/smacker.c @@ -618,7 +618,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, } if(bits) { //decode 16-bit data for(i = stereo; i >= 0; i--) - pred[i] = bswap_16(get_bits(&gb, 16)); + pred[i] = av_bswap16(get_bits(&gb, 16)); for(i = 0; i < stereo; i++) *samples++ = pred[i]; for(i = 0; i < unp_size / 2; i++) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/snow.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/snow.c index 5ef9e5e81..18039d229 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/snow.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/snow.c @@ -920,7 +920,7 @@ static void decode_blocks(SnowContext *s){ } } -static void mc_block(Plane *p, uint8_t *dst, const uint8_t *src, uint8_t *tmp, int stride, int b_w, int b_h, int dx, int dy){ +static void mc_block(Plane *p, uint8_t *dst, const uint8_t *src, int stride, int b_w, int b_h, int dx, int dy){ static const uint8_t weight[64]={ 8,7,6,5,4,3,2,1, 7,7,0,0,0,0,0,1, @@ -1106,9 +1106,8 @@ static void mc_block(Plane *p, uint8_t *dst, const uint8_t *src, uint8_t *tmp, i #define mca(dx,dy,b_w)\ static void mc_block_hpel ## dx ## dy ## b_w(uint8_t *dst, const uint8_t *src, int stride, int h){\ - uint8_t tmp[stride*(b_w+HTAPS_MAX-1)];\ assert(h==b_w);\ - mc_block(NULL, dst, src-(HTAPS_MAX/2-1)-(HTAPS_MAX/2-1)*stride, tmp, stride, b_w, b_w, dx, dy);\ + mc_block(NULL, dst, src-(HTAPS_MAX/2-1)-(HTAPS_MAX/2-1)*stride, stride, b_w, b_w, dx, dy);\ } mca( 0, 0,16) @@ -1180,7 +1179,7 @@ static void pred_block(SnowContext *s, uint8_t *dst, uint8_t *tmp, int stride, i assert(b_w>1 && b_h>1); assert((tab_index>=0 && tab_index<4) || b_w==32); if((dx&3) || (dy&3) || !(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h) || (b_w&(b_w-1)) || !s->plane[plane_index].fast_mc ) - mc_block(&s->plane[plane_index], dst, src, tmp, stride, b_w, b_h, dx, dy); + mc_block(&s->plane[plane_index], dst, src, stride, b_w, b_h, dx, dy); else if(b_w==32){ int y; for(y=0; ygb,buf,buf_size*8); @@ -692,6 +693,10 @@ static int svq1_decode_frame(AVCodecContext *avctx, if(MPV_frame_start(s, avctx) < 0) return -1; + pmv = av_malloc((FFALIGN(s->width, 16)/8 + 3) * sizeof(*pmv)); + if (!pmv) + return -1; + /* decode y, u and v components */ for (i=0; i < 3; i++) { int linesize; @@ -724,13 +729,12 @@ static int svq1_decode_frame(AVCodecContext *avctx, //#ifdef DEBUG_SVQ1 av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_block %i (keyframe)\n",result); //#endif - return result; + goto err; } } current += 16*linesize; } } else { - svq1_pmv pmv[width/8+3]; /* delta frame */ memset (pmv, 0, ((width / 8) + 3) * sizeof(svq1_pmv)); @@ -743,7 +747,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, #ifdef DEBUG_SVQ1 av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_delta_block %i\n",result); #endif - return result; + goto err; } } @@ -761,7 +765,10 @@ static int svq1_decode_frame(AVCodecContext *avctx, MPV_frame_end(s); *data_size=sizeof(AVFrame); - return buf_size; + result = buf_size; +err: + av_free(pmv); + return result; } static av_cold int svq1_decode_init(AVCodecContext *avctx) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/svq3.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/svq3.c index bf7659a80..df2acd895 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/svq3.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/svq3.c @@ -886,7 +886,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) int u2 = get_bits(&gb, 8); int u3 = get_bits(&gb, 2); int u4 = svq3_get_ue_golomb(&gb); - unsigned buf_len = watermark_width*watermark_height*4; + unsigned long buf_len = watermark_width*watermark_height*4; int offset = (get_bits_count(&gb)+7)>>3; uint8_t *buf; @@ -896,7 +896,7 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) buf = av_malloc(buf_len); av_log(avctx, AV_LOG_DEBUG, "watermark size: %dx%d\n", watermark_width, watermark_height); av_log(avctx, AV_LOG_DEBUG, "u1: %x u2: %x u3: %x compressed data size: %d offset: %d\n", u1, u2, u3, u4, offset); - if (uncompress(buf, (uLong*)&buf_len, extradata + 8 + offset, size - offset) != Z_OK) { + if (uncompress(buf, &buf_len, extradata + 8 + offset, size - offset) != Z_OK) { av_log(avctx, AV_LOG_ERROR, "could not uncompress watermark logo\n"); av_free(buf); return -1; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/tableprint.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/tableprint.c index 0f422eb88..52f6ac2a7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/tableprint.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/tableprint.c @@ -24,16 +24,16 @@ #include #include "tableprint.h" -WRITE_1D_FUNC(int8, int8_t, "%3"PRIi8, 15) -WRITE_1D_FUNC(uint8, uint8_t, "0x%02"PRIx8, 15) -WRITE_1D_FUNC(uint16, uint16_t, "0x%08"PRIx16, 7) -WRITE_1D_FUNC(uint32, uint32_t, "0x%08"PRIx32, 7) -WRITE_1D_FUNC(float, float, "%.18e", 3) +WRITE_1D_FUNC(int8_t, "%3"PRIi8, 15) +WRITE_1D_FUNC(uint8_t, "0x%02"PRIx8, 15) +WRITE_1D_FUNC(uint16_t, "0x%08"PRIx16, 7) +WRITE_1D_FUNC(uint32_t, "0x%08"PRIx32, 7) +WRITE_1D_FUNC(float, "%.18e", 3) -WRITE_2D_FUNC(int8, int8_t) -WRITE_2D_FUNC(uint8, uint8_t) -WRITE_2D_FUNC(uint32, uint32_t) -WRITE_2D_FUNC(float, float) +WRITE_2D_FUNC(int8_t) +WRITE_2D_FUNC(uint8_t) +WRITE_2D_FUNC(uint32_t) +WRITE_2D_FUNC(float) void write_fileheader(void) { printf("/* This file was generated by libavcodec/tableprint */\n"); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/tableprint.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/tableprint.h index 76ab8028b..97a667db3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/tableprint.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/tableprint.h @@ -25,9 +25,10 @@ #include #include +#include "libavutil/common.h" -#define WRITE_1D_FUNC_ARGV(name, type, linebrk, fmtstr, ...)\ -void write_##name##_array(const type *data, int len)\ +#define WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, ...)\ +void write_##type##_array(const type *data, int len)\ {\ int i;\ printf(" ");\ @@ -38,17 +39,17 @@ void write_##name##_array(const type *data, int len)\ printf(" "fmtstr"\n", __VA_ARGS__);\ } -#define WRITE_1D_FUNC(name, type, fmtstr, linebrk)\ - WRITE_1D_FUNC_ARGV(name, type, linebrk, fmtstr, data[i]) +#define WRITE_1D_FUNC(type, fmtstr, linebrk)\ + WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, data[i]) -#define WRITE_2D_FUNC(name, type)\ -void write_##name##_2d_array(const void *arg, int len, int len2)\ +#define WRITE_2D_FUNC(type)\ +void write_##type##_2d_array(const void *arg, int len, int len2)\ {\ const type *data = arg;\ int i;\ printf(" {\n");\ for (i = 0; i < len; i++) {\ - write_##name##_array(data + i * len2, len2);\ + write_##type##_array(data + i * len2, len2);\ printf(i == len - 1 ? " }\n" : " }, {\n");\ }\ } @@ -58,18 +59,37 @@ void write_##name##_2d_array(const void *arg, int len, int len2)\ * * \{ */ -void write_int8_array (const int8_t *, int); -void write_uint8_array (const uint8_t *, int); -void write_uint16_array (const uint16_t *, int); -void write_uint32_array (const uint32_t *, int); -void write_float_array (const float *, int); -void write_int8_2d_array (const void *, int, int); -void write_uint8_2d_array (const void *, int, int); -void write_uint32_2d_array(const void *, int, int); -void write_float_2d_array (const void *, int, int); +void write_int8_t_array (const int8_t *, int); +void write_uint8_t_array (const uint8_t *, int); +void write_uint16_t_array (const uint16_t *, int); +void write_uint32_t_array (const uint32_t *, int); +void write_float_array (const float *, int); +void write_int8_t_2d_array (const void *, int, int); +void write_uint8_t_2d_array (const void *, int, int); +void write_uint32_t_2d_array(const void *, int, int); +void write_float_2d_array (const void *, int, int); /** \} */ // end of printfuncs group /** Write a standard file header */ void write_fileheader(void); +#define WRITE_ARRAY(prefix, type, name) \ + do { \ + const size_t array_size = FF_ARRAY_ELEMS(name); \ + printf(prefix" "#type" "#name"[%zu] = {\n", \ + array_size); \ + write_##type##_array(name, array_size); \ + printf("};\n"); \ + } while(0) + +#define WRITE_2D_ARRAY(prefix, type, name) \ + do { \ + const size_t array_size1 = FF_ARRAY_ELEMS(name); \ + const size_t array_size2 = FF_ARRAY_ELEMS(name[0]); \ + printf(prefix" "#type" "#name"[%zu][%zu] = {\n", \ + array_size1, array_size2 ); \ + write_##type##_2d_array(name, array_size1, array_size2); \ + printf("};\n"); \ + } while(0) + #endif /* AVCODEC_TABLEPRINT_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/truespeech.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/truespeech.c index 37fbef9de..eafbca52d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/truespeech.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/truespeech.c @@ -347,6 +347,11 @@ static int truespeech_decode_frame(AVCodecContext *avctx, if (!buf_size) return 0; + if (buf_size < 32) { + av_log(avctx, AV_LOG_ERROR, + "Too small input buffer (%d bytes), need at least 32 bytes\n", buf_size); + return -1; + } iterations = FFMIN(buf_size / 32, *data_size / 480); for(j = 0; j < iterations; j++) { truespeech_read_frame(c, buf + consumed); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/tta.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/tta.c index 4bdfd73fb..0a4c69a47 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/tta.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/tta.c @@ -36,6 +36,24 @@ #define FORMAT_INT 1 #define FORMAT_FLOAT 3 +#define MAX_ORDER 16 +typedef struct TTAFilter { + int32_t shift, round, error, mode; + int32_t qm[MAX_ORDER]; + int32_t dx[MAX_ORDER]; + int32_t dl[MAX_ORDER]; +} TTAFilter; + +typedef struct TTARice { + uint32_t k0, k1, sum0, sum1; +} TTARice; + +typedef struct TTAChannel { + int32_t predictor; + TTAFilter filter; + TTARice rice; +} TTAChannel; + typedef struct TTAContext { AVCodecContext *avctx; GetBitContext gb; @@ -44,6 +62,8 @@ typedef struct TTAContext { int frame_length, last_frame_length, total_frames; int32_t *decode_buffer; + + TTAChannel *ch_ctx;; } TTAContext; #if 0 @@ -79,14 +99,6 @@ static const uint32_t shift_1[] = { static const uint32_t * const shift_16 = shift_1 + 4; #endif -#define MAX_ORDER 16 -typedef struct TTAFilter { - int32_t shift, round, error, mode; - int32_t qm[MAX_ORDER]; - int32_t dx[MAX_ORDER]; - int32_t dl[MAX_ORDER]; -} TTAFilter; - static const int32_t ttafilter_configs[4][2] = { {10, 1}, {9, 1}, @@ -175,10 +187,6 @@ static inline void ttafilter_process(TTAFilter *c, int32_t *in, int32_t mode) { memshl(c->dx, c->dx + 1); } -typedef struct TTARice { - uint32_t k0, k1, sum0, sum1; -} TTARice; - static void rice_init(TTARice *c, uint32_t k0, uint32_t k1) { c->k0 = k0; @@ -213,7 +221,7 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) { /* signature */ skip_bits(&s->gb, 32); -// if (get_bits_long(&s->gb, 32) != bswap_32(AV_RL32("TTA1"))) { +// if (get_bits_long(&s->gb, 32) != av_bswap32(AV_RL32("TTA1"))) { // av_log(s->avctx, AV_LOG_ERROR, "Missing magic\n"); // return -1; // } @@ -277,6 +285,9 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) } s->decode_buffer = av_mallocz(sizeof(int32_t)*s->frame_length*s->channels); + s->ch_ctx = av_malloc(avctx->channels * sizeof(*s->ch_ctx)); + if (!s->ch_ctx) + return AVERROR(ENOMEM); } else { av_log(avctx, AV_LOG_ERROR, "Wrong extradata present\n"); return -1; @@ -296,9 +307,6 @@ static int tta_decode_frame(AVCodecContext *avctx, init_get_bits(&s->gb, buf, buf_size*8); { - int32_t predictors[s->channels]; - TTAFilter filters[s->channels]; - TTARice rices[s->channels]; int cur_chan = 0, framelen = s->frame_length; int32_t *p; @@ -313,15 +321,15 @@ static int tta_decode_frame(AVCodecContext *avctx, // init per channel states for (i = 0; i < s->channels; i++) { - predictors[i] = 0; - ttafilter_init(&(filters[i]), ttafilter_configs[s->bps-1][0], ttafilter_configs[s->bps-1][1]); - rice_init(&(rices[i]), 10, 10); + s->ch_ctx[i].predictor = 0; + ttafilter_init(&s->ch_ctx[i].filter, ttafilter_configs[s->bps-1][0], ttafilter_configs[s->bps-1][1]); + rice_init(&s->ch_ctx[i].rice, 10, 10); } for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) { - int32_t *predictor = &(predictors[cur_chan]); - TTAFilter *filter = &(filters[cur_chan]); - TTARice *rice = &(rices[cur_chan]); + int32_t *predictor = &s->ch_ctx[cur_chan].predictor; + TTAFilter *filter = &s->ch_ctx[cur_chan].filter; + TTARice *rice = &s->ch_ctx[cur_chan].rice; uint32_t unary, depth, k; int32_t value; @@ -443,6 +451,7 @@ static av_cold int tta_decode_close(AVCodecContext *avctx) { if (s->decode_buffer) av_free(s->decode_buffer); + av_freep(&s->ch_ctx); return 0; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/twinvq.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/twinvq.c index 6ab3a465d..701e9595c 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/twinvq.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/twinvq.c @@ -202,6 +202,7 @@ typedef struct TwinContext { } TwinContext; #define PPC_SHAPE_CB_SIZE 64 +#define PPC_SHAPE_LEN_MAX 60 #define SUB_AMP_MAX 4500.0 #define MULAW_MU 100.0 #define GAIN_BITS 8 @@ -209,6 +210,11 @@ typedef struct TwinContext { #define SUB_GAIN_BITS 5 #define WINDOW_TYPE_BITS 4 #define PGAIN_MU 200 +#define LSP_COEFS_MAX 20 +#define LSP_SPLIT_MAX 4 +#define CHANNELS_MAX 2 +#define SUBBLOCKS_MAX 16 +#define BARK_N_COEF_MAX 4 /** @note not speed critical, hence not optimized */ static void memset_float(float *buf, float val, int size) @@ -252,7 +258,7 @@ static float eval_lpc_spectrum(const float *lsp, float cos_val, int order) } /** - * Evaluates the LPC amplitude spectrum envelope from the line spectrum pairs. + * Evaluate the LPC amplitude spectrum envelope from the line spectrum pairs. */ static void eval_lpcenv(TwinContext *tctx, const float *cos_vals, float *lpc) { @@ -285,7 +291,7 @@ static inline float get_cos(int idx, int part, const float *cos_tab, int size) } /** - * Evaluates the LPC amplitude spectrum envelope from the line spectrum pairs. + * Evaluate the LPC amplitude spectrum envelope from the line spectrum pairs. * Probably for speed reasons, the coefficients are evaluated as * siiiibiiiisiiiibiiiisiiiibiiiisiiiibiiiis ... * where s is an evaluated value, i is a value interpolated from the others @@ -727,14 +733,14 @@ static void read_and_decode_spectrum(TwinContext *tctx, GetBitContext *gb, int channels = tctx->avctx->channels; int sub = mtab->fmode[ftype].sub; int block_size = mtab->size / sub; - float gain[channels*sub]; - float ppc_shape[mtab->ppc_shape_len * channels * 4]; - uint8_t bark1[channels][sub][mtab->fmode[ftype].bark_n_coef]; - uint8_t bark_use_hist[channels][sub]; + float gain[CHANNELS_MAX*SUBBLOCKS_MAX]; + float ppc_shape[PPC_SHAPE_LEN_MAX * CHANNELS_MAX * 4]; + uint8_t bark1[CHANNELS_MAX][SUBBLOCKS_MAX][BARK_N_COEF_MAX]; + uint8_t bark_use_hist[CHANNELS_MAX][SUBBLOCKS_MAX]; - uint8_t lpc_idx1[channels]; - uint8_t lpc_idx2[channels][tctx->mtab->lsp_split]; - uint8_t lpc_hist_idx[channels]; + uint8_t lpc_idx1[CHANNELS_MAX]; + uint8_t lpc_idx2[CHANNELS_MAX][LSP_SPLIT_MAX]; + uint8_t lpc_hist_idx[CHANNELS_MAX]; int i, j, k; @@ -771,7 +777,7 @@ static void read_and_decode_spectrum(TwinContext *tctx, GetBitContext *gb, for (i = 0; i < channels; i++) { float *chunk = out + mtab->size * i; - float lsp[tctx->mtab->n_lsp]; + float lsp[LSP_COEFS_MAX]; for (j = 0; j < sub; j++) { dec_bark_env(tctx, bark1[i][j], bark_use_hist[i][j], i, @@ -1064,7 +1070,7 @@ static av_cold int twin_decode_init(AVCodecContext *avctx) tctx->avctx = avctx; avctx->sample_fmt = SAMPLE_FMT_FLT; - if (avctx->channels > 2) { + if (avctx->channels > CHANNELS_MAX) { av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %i\n", avctx->channels); return -1; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/utils.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/utils.c index 008f9e9e8..f21e9eda7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/utils.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/utils.c @@ -25,9 +25,6 @@ * utils. */ -/* needed for mkstemp() */ -#define _XOPEN_SOURCE 600 - #include "libavutil/avstring.h" #include "libavutil/integer.h" #include "libavutil/crc.h" @@ -37,15 +34,11 @@ #include "opt.h" #include "imgconvert.h" #include "audioconvert.h" -#include "libxvid_internal.h" #include "internal.h" #include #include #include #include -#if !HAVE_MKSTEMP -#include -#endif static int volatile entangled_thread_counter=0; int (*ff_lockmgr_cb)(void **mutex, enum AVLockOp op); @@ -513,6 +506,13 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) } avctx->frame_number = 0; if(avctx->codec->init){ + if(avctx->codec_type == AVMEDIA_TYPE_VIDEO && + avctx->codec->max_lowres < avctx->lowres){ + av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n", + avctx->codec->max_lowres); + goto free_and_end; + } + ret = avctx->codec->init(avctx); if (ret < 0) { goto free_and_end; @@ -689,6 +689,26 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, return ret; } +void avsubtitle_free(AVSubtitle *sub) +{ + int i; + + for (i = 0; i < sub->num_rects; i++) + { + av_freep(&sub->rects[i]->pict.data[0]); + av_freep(&sub->rects[i]->pict.data[1]); + av_freep(&sub->rects[i]->pict.data[2]); + av_freep(&sub->rects[i]->pict.data[3]); + av_freep(&sub->rects[i]->text); + av_freep(&sub->rects[i]->ass); + av_freep(&sub->rects[i]); + } + + av_freep(&sub->rects); + + memset(sub, 0, sizeof(AVSubtitle)); +} + av_cold int avcodec_close(AVCodecContext *avctx) { /* If there is a user-supplied mutex locking routine, call it. */ @@ -1072,42 +1092,6 @@ unsigned int av_xiphlacing(unsigned char *s, unsigned int v) return n; } -/* Wrapper to work around the lack of mkstemp() on mingw/cygin. - * Also, tries to create file in /tmp first, if possible. - * *prefix can be a character constant; *filename will be allocated internally. - * Returns file descriptor of opened file (or -1 on error) - * and opened file name in **filename. */ -int av_tempfile(char *prefix, char **filename) { - int fd=-1; -#if !HAVE_MKSTEMP - *filename = tempnam(".", prefix); -#else - size_t len = strlen(prefix) + 12; /* room for "/tmp/" and "XXXXXX\0" */ - *filename = av_malloc(len); -#endif - /* -----common section-----*/ - if (*filename == NULL) { - av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n"); - return -1; - } -#if !HAVE_MKSTEMP - fd = open(*filename, O_RDWR | O_BINARY | O_CREAT, 0444); -#else - snprintf(*filename, len, "/tmp/%sXXXXXX", prefix); - fd = mkstemp(*filename); - if (fd < 0) { - snprintf(*filename, len, "./%sXXXXXX", prefix); - fd = mkstemp(*filename); - } -#endif - /* -----common section-----*/ - if (fd < 0) { - av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename); - return -1; - } - return fd; /* success */ -} - typedef struct { const char *abbr; int width, height; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/v210dec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/v210dec.c index a1a0827be..61e9566c8 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/v210dec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/v210dec.c @@ -68,7 +68,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, #define READ_PIXELS(a, b, c) \ do { \ - val = le2me_32(*src++); \ + val = av_le2ne32(*src++); \ *a++ = val << 6; \ *b++ = (val >> 4) & 0xFFC0; \ *c++ = (val >> 14) & 0xFFC0; \ @@ -86,14 +86,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, if (w < avctx->width - 1) { READ_PIXELS(u, y, v); - val = le2me_32(*src++); + val = av_le2ne32(*src++); *y++ = val << 6; } if (w < avctx->width - 3) { *u++ = (val >> 4) & 0xFFC0; *y++ = (val >> 14) & 0xFFC0; - val = le2me_32(*src++); + val = av_le2ne32(*src++); *v++ = val << 6; *y++ = (val >> 4) & 0xFFC0; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/v210x.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/v210x.c index d869d6472..6b93a056f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/v210x.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/v210x.c @@ -67,12 +67,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac pic->key_frame= 1; for(;;){ - uint32_t v= be2me_32(*src++); + uint32_t v= av_be2ne32(*src++); *udst++= (v>>16) & 0xFFC0; *ydst++= (v>>6 ) & 0xFFC0; *vdst++= (v<<4 ) & 0xFFC0; - v= be2me_32(*src++); + v= av_be2ne32(*src++); *ydst++= (v>>16) & 0xFFC0; if(ydst >= yend){ @@ -87,7 +87,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac *udst++= (v>>6 ) & 0xFFC0; *ydst++= (v<<4 ) & 0xFFC0; - v= be2me_32(*src++); + v= av_be2ne32(*src++); *vdst++= (v>>16) & 0xFFC0; *ydst++= (v>>6 ) & 0xFFC0; @@ -102,7 +102,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac *udst++= (v<<4 ) & 0xFFC0; - v= be2me_32(*src++); + v= av_be2ne32(*src++); *ydst++= (v>>16) & 0xFFC0; *vdst++= (v>>6 ) & 0xFFC0; *ydst++= (v<<4 ) & 0xFFC0; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vaapi_h264.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vaapi_h264.c index 6d4251a26..29f3a81ba 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vaapi_h264.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vaapi_h264.c @@ -29,7 +29,7 @@ */ /** - * Initializes an empty VA API picture. + * Initialize an empty VA API picture. * * VA API requires a fixed-size reference picture array. */ @@ -42,7 +42,7 @@ static void init_vaapi_pic(VAPictureH264 *va_pic) } /** - * Translates an FFmpeg Picture into its VA API form. + * Translate an FFmpeg Picture into its VA API form. * * @param[out] va_pic A pointer to VA API's own picture struct * @param[in] pic A pointer to the FFmpeg picture struct to convert @@ -82,7 +82,7 @@ typedef struct DPB { } DPB; /** - * Appends picture to the decoded picture buffer, in a VA API form that + * Append picture to the decoded picture buffer, in a VA API form that * merges the second field picture attributes with the first, if * available. The decoded picture buffer's size must be large enough * to receive the new VA API picture object. @@ -117,7 +117,7 @@ static int dpb_add(DPB *dpb, Picture *pic) return 0; } -/** Fills in VA API reference frames array. */ +/** Fill in VA API reference frames array. */ static int fill_vaapi_ReferenceFrames(VAPictureParameterBufferH264 *pic_param, H264Context *h) { @@ -145,7 +145,7 @@ static int fill_vaapi_ReferenceFrames(VAPictureParameterBufferH264 *pic_param, } /** - * Fills in VA API reference picture lists from the FFmpeg reference + * Fill in VA API reference picture lists from the FFmpeg reference * picture list. * * @param[out] RefPicList VA API internal reference picture list @@ -166,7 +166,7 @@ static void fill_vaapi_RefPicList(VAPictureH264 RefPicList[32], } /** - * Fills in prediction weight table. + * Fill in prediction weight table. * * VA API requires a plain prediction weight table as it does not infer * any value. @@ -216,7 +216,7 @@ static void fill_vaapi_plain_pred_weight_table(H264Context *h, } } -/** Initializes and starts decoding a frame with VA API. */ +/** Initialize and start decoding a frame with VA API. */ static int start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) @@ -284,7 +284,7 @@ static int start_frame(AVCodecContext *avctx, return 0; } -/** Ends a hardware decoding based frame. */ +/** End a hardware decoding based frame. */ static int end_frame(AVCodecContext *avctx) { H264Context * const h = avctx->priv_data; @@ -293,7 +293,7 @@ static int end_frame(AVCodecContext *avctx) return ff_vaapi_common_end_frame(&h->s); } -/** Decodes the given H.264 slice with VA API. */ +/** Decode the given H.264 slice with VA API. */ static int decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vaapi_mpeg4.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vaapi_mpeg4.c index 466ce2fd9..8f02e9139 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vaapi_mpeg4.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vaapi_mpeg4.c @@ -21,6 +21,7 @@ */ #include "vaapi_internal.h" +#include "h263.h" /** Reconstruct bitstream intra_dc_vlc_thr */ static int mpeg4_get_intra_dc_vlc_thr(MpegEncContext *s) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vaapi_vc1.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vaapi_vc1.c index 992e1da4b..2c24042ab 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vaapi_vc1.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vaapi_vc1.c @@ -24,7 +24,7 @@ #include "vc1.h" #include "vc1data.h" -/** Translates FFmpeg MV modes to VA API */ +/** Translate FFmpeg MV modes to VA API */ static int get_VAMvModeVC1(enum MVModes mv_mode) { switch (mv_mode) { @@ -37,7 +37,7 @@ static int get_VAMvModeVC1(enum MVModes mv_mode) return 0; } -/** Checks whether the MVTYPEMB bitplane is present */ +/** Check whether the MVTYPEMB bitplane is present */ static inline int vc1_has_MVTYPEMB_bitplane(VC1Context *v) { if (v->mv_type_is_raw) @@ -48,7 +48,7 @@ static inline int vc1_has_MVTYPEMB_bitplane(VC1Context *v) v->mv_mode2 == MV_PMODE_MIXED_MV))); } -/** Checks whether the SKIPMB bitplane is present */ +/** Check whether the SKIPMB bitplane is present */ static inline int vc1_has_SKIPMB_bitplane(VC1Context *v) { if (v->skip_is_raw) @@ -57,7 +57,7 @@ static inline int vc1_has_SKIPMB_bitplane(VC1Context *v) (v->s.pict_type == FF_B_TYPE && !v->bi_type)); } -/** Checks whether the DIRECTMB bitplane is present */ +/** Check whether the DIRECTMB bitplane is present */ static inline int vc1_has_DIRECTMB_bitplane(VC1Context *v) { if (v->dmb_is_raw) @@ -65,7 +65,7 @@ static inline int vc1_has_DIRECTMB_bitplane(VC1Context *v) return v->s.pict_type == FF_B_TYPE && !v->bi_type; } -/** Checks whether the ACPRED bitplane is present */ +/** Check whether the ACPRED bitplane is present */ static inline int vc1_has_ACPRED_bitplane(VC1Context *v) { if (v->acpred_is_raw) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vc1.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vc1.c index 7d00072b7..cca345df3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vc1.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vc1.c @@ -388,7 +388,7 @@ int vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitConte // av_log(avctx, AV_LOG_ERROR, // "0 for reserved RES_RTM_FLAG is forbidden\n"); av_log(avctx, AV_LOG_ERROR, - "Old WMV3 version detected, only I-frames will be decoded\n"); + "Old WMV3 version detected, some frames may be decoded incorrectly\n"); //return -1; } //TODO: figure out what they mean (always 0x402F) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vc1dec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vc1dec.c index 8a583df96..8c9cbcd9d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vc1dec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vc1dec.c @@ -162,17 +162,27 @@ enum Imode { static void vc1_loop_filter_iblk(MpegEncContext *s, int pq) { - int i, j; - if(!s->first_slice_line) + int j; + if (!s->first_slice_line) { s->dsp.vc1_v_loop_filter16(s->dest[0], s->linesize, pq); - s->dsp.vc1_v_loop_filter16(s->dest[0] + 8*s->linesize, s->linesize, pq); - for(i = !s->mb_x*8; i < 16; i += 8) - s->dsp.vc1_h_loop_filter16(s->dest[0] + i, s->linesize, pq); - for(j = 0; j < 2; j++){ - if(!s->first_slice_line) + if (s->mb_x) + s->dsp.vc1_h_loop_filter16(s->dest[0] - 16*s->linesize, s->linesize, pq); + s->dsp.vc1_h_loop_filter16(s->dest[0] - 16*s->linesize+8, s->linesize, pq); + for(j = 0; j < 2; j++){ s->dsp.vc1_v_loop_filter8(s->dest[j+1], s->uvlinesize, pq); - if(s->mb_x) - s->dsp.vc1_h_loop_filter8(s->dest[j+1], s->uvlinesize, pq); + if (s->mb_x) + s->dsp.vc1_h_loop_filter8(s->dest[j+1]-8*s->uvlinesize, s->uvlinesize, pq); + } + } + s->dsp.vc1_v_loop_filter16(s->dest[0] + 8*s->linesize, s->linesize, pq); + + if (s->mb_y == s->mb_height-1) { + if (s->mb_x) { + s->dsp.vc1_h_loop_filter16(s->dest[0], s->linesize, pq); + s->dsp.vc1_h_loop_filter8(s->dest[1], s->uvlinesize, pq); + s->dsp.vc1_h_loop_filter8(s->dest[2], s->uvlinesize, pq); + } + s->dsp.vc1_h_loop_filter16(s->dest[0] + 8, s->linesize, pq); } } @@ -1481,7 +1491,7 @@ static int vc1_decode_i_block(VC1Context *v, DCTELEM block[64], int n, int coded { int last = 0, skip, value; - const int8_t *zz_table; + const uint8_t *zz_table; int scale; int k; @@ -1667,7 +1677,7 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int c if(coded) { int last = 0, skip, value; - const int8_t *zz_table; + const uint8_t *zz_table; int k; if(v->s.ac_pred) { @@ -1874,7 +1884,7 @@ static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int c if(coded) { int last = 0, skip, value; - const int8_t *zz_table; + const uint8_t *zz_table; int k; zz_table = wmv1_scantable[0]; @@ -1996,7 +2006,9 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquan if(ttblk == TT_4X4) { subblkpat = ~(get_vlc2(gb, ff_vc1_subblkpat_vlc[v->tt_index].table, VC1_SUBBLKPAT_VLC_BITS, 1) + 1); } - if((ttblk != TT_8X8 && ttblk != TT_4X4) && (v->ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block))) { + if((ttblk != TT_8X8 && ttblk != TT_4X4) + && ((v->ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block)) + || (!v->res_rtm_flag && !first_block))) { subblkpat = decode012(gb); if(subblkpat) subblkpat ^= 3; //swap decoded pattern bits if(ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM) ttblk = TT_8X4; @@ -2678,9 +2690,15 @@ static void vc1_decode_i_blocks(VC1Context *v) return; } } - ff_draw_horiz_band(s, s->mb_y * 16, 16); + if (!v->s.loop_filter) + ff_draw_horiz_band(s, s->mb_y * 16, 16); + else if (s->mb_y) + ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16); + s->first_slice_line = 0; } + if (v->s.loop_filter) + ff_draw_horiz_band(s, (s->mb_height-1)*16, 16); ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END)); } @@ -2810,9 +2828,14 @@ static void vc1_decode_i_blocks_adv(VC1Context *v) return; } } - ff_draw_horiz_band(s, s->mb_y * 16, 16); + if (!v->s.loop_filter) + ff_draw_horiz_band(s, s->mb_y * 16, 16); + else if (s->mb_y) + ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16); s->first_slice_line = 0; } + if (v->s.loop_filter) + ff_draw_horiz_band(s, (s->mb_height-1)*16, 16); ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END)); } @@ -2911,9 +2934,14 @@ static void vc1_decode_b_blocks(VC1Context *v) } if(v->s.loop_filter) vc1_loop_filter_iblk(s, v->pq); } - ff_draw_horiz_band(s, s->mb_y * 16, 16); + if (!v->s.loop_filter) + ff_draw_horiz_band(s, s->mb_y * 16, 16); + else if (s->mb_y) + ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16); s->first_slice_line = 0; } + if (v->s.loop_filter) + ff_draw_horiz_band(s, (s->mb_height-1)*16, 16); ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END)); } @@ -3212,11 +3240,6 @@ static int vc1_decode_frame(AVCodecContext *avctx, } } - if(s->pict_type != FF_I_TYPE && !v->res_rtm_flag){ - av_free(buf2); - return -1; - } - // for hurry_up==5 s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == FF_I_TYPE; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vc1dsp.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vc1dsp.c index 47b69c821..8634bef69 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vc1dsp.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vc1dsp.c @@ -182,18 +182,19 @@ static void vc1_inv_trans_8x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block) { int i; int dc = block[0]; - const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + const uint8_t *cm; dc = (3 * dc + 1) >> 1; dc = (3 * dc + 16) >> 5; + cm = ff_cropTbl + MAX_NEG_CROP + dc; for(i = 0; i < 8; i++){ - dest[0] = cm[dest[0]+dc]; - dest[1] = cm[dest[1]+dc]; - dest[2] = cm[dest[2]+dc]; - dest[3] = cm[dest[3]+dc]; - dest[4] = cm[dest[4]+dc]; - dest[5] = cm[dest[5]+dc]; - dest[6] = cm[dest[6]+dc]; - dest[7] = cm[dest[7]+dc]; + dest[0] = cm[dest[0]]; + dest[1] = cm[dest[1]]; + dest[2] = cm[dest[2]]; + dest[3] = cm[dest[3]]; + dest[4] = cm[dest[4]]; + dest[5] = cm[dest[5]]; + dest[6] = cm[dest[6]]; + dest[7] = cm[dest[7]]; dest += linesize; } } @@ -273,18 +274,19 @@ static void vc1_inv_trans_8x4_dc_c(uint8_t *dest, int linesize, DCTELEM *block) { int i; int dc = block[0]; - const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + const uint8_t *cm; dc = ( 3 * dc + 1) >> 1; dc = (17 * dc + 64) >> 7; + cm = ff_cropTbl + MAX_NEG_CROP + dc; for(i = 0; i < 4; i++){ - dest[0] = cm[dest[0]+dc]; - dest[1] = cm[dest[1]+dc]; - dest[2] = cm[dest[2]+dc]; - dest[3] = cm[dest[3]+dc]; - dest[4] = cm[dest[4]+dc]; - dest[5] = cm[dest[5]+dc]; - dest[6] = cm[dest[6]+dc]; - dest[7] = cm[dest[7]+dc]; + dest[0] = cm[dest[0]]; + dest[1] = cm[dest[1]]; + dest[2] = cm[dest[2]]; + dest[3] = cm[dest[3]]; + dest[4] = cm[dest[4]]; + dest[5] = cm[dest[5]]; + dest[6] = cm[dest[6]]; + dest[7] = cm[dest[7]]; dest += linesize; } } @@ -350,14 +352,15 @@ static void vc1_inv_trans_4x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block) { int i; int dc = block[0]; - const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + const uint8_t *cm; dc = (17 * dc + 4) >> 3; dc = (12 * dc + 64) >> 7; + cm = ff_cropTbl + MAX_NEG_CROP + dc; for(i = 0; i < 8; i++){ - dest[0] = cm[dest[0]+dc]; - dest[1] = cm[dest[1]+dc]; - dest[2] = cm[dest[2]+dc]; - dest[3] = cm[dest[3]+dc]; + dest[0] = cm[dest[0]]; + dest[1] = cm[dest[1]]; + dest[2] = cm[dest[2]]; + dest[3] = cm[dest[3]]; dest += linesize; } } @@ -423,14 +426,15 @@ static void vc1_inv_trans_4x4_dc_c(uint8_t *dest, int linesize, DCTELEM *block) { int i; int dc = block[0]; - const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + const uint8_t *cm; dc = (17 * dc + 4) >> 3; dc = (17 * dc + 64) >> 7; + cm = ff_cropTbl + MAX_NEG_CROP + dc; for(i = 0; i < 4; i++){ - dest[0] = cm[dest[0]+dc]; - dest[1] = cm[dest[1]+dc]; - dest[2] = cm[dest[2]+dc]; - dest[3] = cm[dest[3]+dc]; + dest[0] = cm[dest[0]]; + dest[1] = cm[dest[1]]; + dest[2] = cm[dest[2]]; + dest[3] = cm[dest[3]]; dest += linesize; } } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vdpau.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vdpau.c index 54fdcd66b..bd721e8f8 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vdpau.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vdpau.c @@ -315,7 +315,6 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, render->bitstream_buffers_used = 0; } -#ifdef VDP_DECODER_PROFILE_MPEG4_PART2_SP void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, int buf_size) { @@ -369,6 +368,5 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, ff_draw_horiz_band(s, 0, s->avctx->height); render->bitstream_buffers_used = 0; } -#endif /* @}*/ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vdpau.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vdpau.h index 8e65f4632..ab5f682c6 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vdpau.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vdpau.h @@ -38,7 +38,6 @@ * and rendering (API calls) are done as part of the VDPAU * presentation (vo_vdpau.c) module. * - * @{ * \defgroup VDPAU_Decoding VDPAU Decoding * \ingroup Decoder * @{ @@ -73,9 +72,7 @@ struct vdpau_render_state { VdpPictureInfoH264 h264; VdpPictureInfoMPEG1Or2 mpeg; VdpPictureInfoVC1 vc1; -#ifdef VDP_DECODER_PROFILE_MPEG4_PART2_SP VdpPictureInfoMPEG4Part2 mpeg4; -#endif } info; /** Describe size/location of the compressed video data. diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vorbis.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vorbis.h index ce9bead42..64bade62b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vorbis.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vorbis.h @@ -26,6 +26,7 @@ extern const float ff_vorbis_floor1_inverse_db_table[256]; extern const float * const ff_vorbis_vwin[8]; extern const uint8_t ff_vorbis_channel_layout_offsets[8][8]; +extern const uint8_t ff_vorbis_encoding_channel_layout_offsets[8][8]; extern const int64_t ff_vorbis_channel_layouts[9]; typedef struct { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vorbis_data.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vorbis_data.c index 9bc7979cd..24c9921fd 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vorbis_data.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vorbis_data.c @@ -22,14 +22,25 @@ #include "vorbis.h" const uint8_t ff_vorbis_channel_layout_offsets[8][8] = { - { 0, }, - { 0, 1, }, - { 0, 2, 1, }, - { 0, 1, 2, 3, }, - { 0, 2, 1, 3, 4, }, - { 0, 2, 1, 5, 3, 4, }, - { 0, 2, 1, 6, 5, 3, 4, }, - { 0, 2, 1, 7, 5, 6, 3, 4}, + { 0 }, + { 0, 1 }, + { 0, 2, 1 }, + { 0, 1, 2, 3 }, + { 0, 2, 1, 3, 4 }, + { 0, 2, 1, 5, 3, 4 }, + { 0, 2, 1, 6, 5, 3, 4 }, + { 0, 2, 1, 7, 5, 6, 3, 4 }, +}; + +const uint8_t ff_vorbis_encoding_channel_layout_offsets[8][8] = { + { 0 }, + { 0, 1 }, + { 0, 2, 1 }, + { 0, 1, 2, 3 }, + { 0, 2, 1, 3, 4 }, + { 0, 2, 1, 4, 5, 3 }, + { 0, 2, 1, 5, 6, 4, 3 }, + { 0, 2, 1, 6, 7, 4, 5, 3 }, }; const int64_t ff_vorbis_channel_layouts[9] = { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vorbis_dec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vorbis_dec.c index 8c56400c7..b3cc43fca 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vorbis_dec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vorbis_dec.c @@ -81,7 +81,6 @@ typedef struct { } t0; struct vorbis_floor1_s { uint_fast8_t partitions; - uint_fast8_t maximum_class; uint_fast8_t partition_class[32]; uint_fast8_t class_dimensions[16]; uint_fast8_t class_subclasses[16]; @@ -103,6 +102,8 @@ typedef struct { uint_fast8_t classbook; int_fast16_t books[64][8]; uint_fast8_t maxpass; + uint_fast16_t ptns_to_read; + uint_fast8_t *classifs; } vorbis_residue; typedef struct { @@ -195,6 +196,8 @@ static void vorbis_free(vorbis_context *vc) av_freep(&vc->channel_floors); av_freep(&vc->saved); + for (i = 0; i < vc->residue_count; i++) + av_free(vc->residues[i].classifs); av_freep(&vc->residues); av_freep(&vc->modes); @@ -237,6 +240,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) uint8_t *tmp_vlc_bits; uint32_t *tmp_vlc_codes; GetBitContext *gb = &vc->gb; + uint_fast16_t *codebook_multiplicands; vc->codebook_count = get_bits(gb, 8) + 1; @@ -245,6 +249,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) vc->codebooks = av_mallocz(vc->codebook_count * sizeof(vorbis_codebook)); tmp_vlc_bits = av_mallocz(V_MAX_VLCS * sizeof(uint8_t)); tmp_vlc_codes = av_mallocz(V_MAX_VLCS * sizeof(uint32_t)); + codebook_multiplicands = av_malloc(V_MAX_VLCS * sizeof(*codebook_multiplicands)); for (cb = 0; cb < vc->codebook_count; ++cb) { vorbis_codebook *codebook_setup = &vc->codebooks[cb]; @@ -337,7 +342,6 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) if (codebook_setup->lookup_type == 1) { uint_fast16_t i, j, k; uint_fast16_t codebook_lookup_values = ff_vorbis_nth_root(entries, codebook_setup->dimensions); - uint_fast16_t codebook_multiplicands[codebook_lookup_values]; float codebook_minimum_value = vorbisfloat2float(get_bits_long(gb, 32)); float codebook_delta_value = vorbisfloat2float(get_bits_long(gb, 32)); @@ -421,12 +425,14 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) av_free(tmp_vlc_bits); av_free(tmp_vlc_codes); + av_free(codebook_multiplicands); return 0; // Error: error: av_free(tmp_vlc_bits); av_free(tmp_vlc_codes); + av_free(codebook_multiplicands); return -1; } @@ -475,7 +481,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) AV_DEBUG(" %d. floor type %d \n", i, floor_setup->floor_type); if (floor_setup->floor_type == 1) { - uint_fast8_t maximum_class = 0; + int maximum_class = -1; uint_fast8_t rangebits; uint_fast16_t floor1_values = 2; @@ -496,8 +502,6 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) AV_DEBUG(" maximum class %d \n", maximum_class); - floor_setup->data.t1.maximum_class = maximum_class; - for (j = 0; j <= maximum_class; ++j) { floor_setup->data.t1.class_dimensions[j] = get_bits(gb, 3) + 1; floor_setup->data.t1.class_subclasses[j] = get_bits(gb, 2); @@ -572,7 +576,8 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) int idx; uint_fast8_t book_idx; for (idx = 0; idx < floor_setup->data.t0.num_books; ++idx) { - GET_VALIDATED_INDEX(floor_setup->data.t0.book_list[idx], 8, vc->codebook_count) + GET_VALIDATED_INDEX(book_idx, 8, vc->codebook_count) + floor_setup->data.t0.book_list[idx] = book_idx; if (vc->codebooks[book_idx].dimensions > max_codebook_dim) max_codebook_dim = vc->codebooks[book_idx].dimensions; } @@ -648,7 +653,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc) res_setup->partition_size = get_bits(gb, 24) + 1; /* Validations to prevent a buffer overflow later. */ if (res_setup->begin>res_setup->end || - res_setup->end>vc->blocksize[1] / (res_setup->type == 2 ? 1 : 2) || + res_setup->end > vc->avccontext->channels * vc->blocksize[1] / (res_setup->type == 2 ? 1 : 2) || (res_setup->end-res_setup->begin) / res_setup->partition_size > V_MAX_PARTITIONS) { av_log(vc->avccontext, AV_LOG_ERROR, "partition out of bounds: type, begin, end, size, blocksize: %"PRIdFAST16", %"PRIdFAST32", %"PRIdFAST32", %"PRIdFAST32", %"PRIdFAST32"\n", res_setup->type, res_setup->begin, res_setup->end, res_setup->partition_size, vc->blocksize[1] / 2); return -1; @@ -657,6 +662,12 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc) res_setup->classifications = get_bits(gb, 6) + 1; GET_VALIDATED_INDEX(res_setup->classbook, 8, vc->codebook_count) + res_setup->ptns_to_read = + (res_setup->end - res_setup->begin) / res_setup->partition_size; + res_setup->classifs = av_malloc(res_setup->ptns_to_read * + vc->audio_channels * + sizeof(*res_setup->classifs)); + AV_DEBUG(" begin %d end %d part.size %d classif.s %d classbook %d \n", res_setup->begin, res_setup->end, res_setup->partition_size, res_setup->classifications, res_setup->classbook); @@ -1119,9 +1130,9 @@ static uint_fast8_t vorbis_floor1_decode(vorbis_context *vc, GetBitContext *gb = &vc->gb; uint_fast16_t range_v[4] = { 256, 128, 86, 64 }; uint_fast16_t range = range_v[vf->multiplier-1]; - uint_fast16_t floor1_Y[vf->x_list_dim]; - uint_fast16_t floor1_Y_final[vf->x_list_dim]; - int floor1_flag[vf->x_list_dim]; + uint_fast16_t floor1_Y[258]; + uint_fast16_t floor1_Y_final[258]; + int floor1_flag[258]; uint_fast8_t class_; uint_fast8_t cdim; uint_fast8_t cbits; @@ -1255,9 +1266,8 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, { GetBitContext *gb = &vc->gb; uint_fast8_t c_p_c = vc->codebooks[vr->classbook].dimensions; - uint_fast16_t n_to_read = vr->end-vr->begin; - uint_fast16_t ptns_to_read = n_to_read/vr->partition_size; - uint_fast8_t classifs[ptns_to_read*vc->audio_channels]; + uint_fast16_t ptns_to_read = vr->ptns_to_read; + uint_fast8_t *classifs = vr->classifs; uint_fast8_t pass; uint_fast8_t ch_used; uint_fast8_t i,j,l; @@ -1453,12 +1463,12 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) uint_fast8_t blockflag; uint_fast16_t blocksize; int_fast32_t i,j; - uint_fast8_t no_residue[vc->audio_channels]; - uint_fast8_t do_not_decode[vc->audio_channels]; + uint_fast8_t no_residue[255]; + uint_fast8_t do_not_decode[255]; vorbis_mapping *mapping; float *ch_res_ptr = vc->channel_residues; float *ch_floor_ptr = vc->channel_floors; - uint_fast8_t res_chan[vc->audio_channels]; + uint_fast8_t res_chan[255]; uint_fast8_t res_num = 0; int_fast16_t retlen = 0; float fadd_bias = vc->add_bias; @@ -1590,7 +1600,7 @@ static int vorbis_decode_frame(AVCodecContext *avccontext, int buf_size = avpkt->size; vorbis_context *vc = avccontext->priv_data ; GetBitContext *gb = &(vc->gb); - const float *channel_ptrs[vc->audio_channels]; + const float *channel_ptrs[255]; int i; int_fast16_t len; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp3.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp3.c index 6c76269b0..9a247404e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp3.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp3.c @@ -258,7 +258,7 @@ typedef struct Vp3DecodeContext { * superblocks <-> fragments, macroblocks <-> fragments, * superblocks <-> macroblocks * - * Returns 0 is successful; returns 1 if *anything* went wrong. + * @return 0 is successful; returns 1 if *anything* went wrong. */ static int init_block_mapping(Vp3DecodeContext *s) { @@ -1270,7 +1270,7 @@ static void apply_loop_filter(Vp3DecodeContext *s, int plane, int ystart, int ye } /** - * Pulls DCT tokens from the 64 levels to decode and dequant the coefficients + * Pull DCT tokens from the 64 levels to decode and dequant the coefficients * for the next block in coding order */ static inline int vp3_dequant(Vp3DecodeContext *s, Vp3Fragment *frag, @@ -1329,7 +1329,7 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y) y = s->height - y - h; } - cy = y >> 1; + cy = y >> s->chroma_y_shift; offset[0] = s->current_frame.linesize[0]*y; offset[1] = s->current_frame.linesize[1]*cy; offset[2] = s->current_frame.linesize[2]*cy; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp3dsp.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp3dsp.c index b7cff788e..94efa3b1d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp3dsp.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp3dsp.c @@ -224,18 +224,18 @@ void ff_vp3_idct_add_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/* } void ff_vp3_idct_dc_add_c(uint8_t *dest/*align 8*/, int line_size, const DCTELEM *block/*align 16*/){ - const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; int i, dc = (block[0] + 15) >> 5; + const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP + dc; for(i = 0; i < 8; i++){ - dest[0] = cm[dest[0]+dc]; - dest[1] = cm[dest[1]+dc]; - dest[2] = cm[dest[2]+dc]; - dest[3] = cm[dest[3]+dc]; - dest[4] = cm[dest[4]+dc]; - dest[5] = cm[dest[5]+dc]; - dest[6] = cm[dest[6]+dc]; - dest[7] = cm[dest[7]+dc]; + dest[0] = cm[dest[0]]; + dest[1] = cm[dest[1]]; + dest[2] = cm[dest[2]]; + dest[3] = cm[dest[3]]; + dest[4] = cm[dest[4]]; + dest[5] = cm[dest[5]]; + dest[6] = cm[dest[6]]; + dest[7] = cm[dest[7]]; dest += line_size; } } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp56.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp56.h index 89eba0563..6bdea23fd 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp56.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp56.h @@ -28,6 +28,7 @@ #include "dsputil.h" #include "get_bits.h" #include "bytestream.h" +#include "cabac.h" #include "vp56dsp.h" typedef struct vp56_context VP56Context; @@ -47,7 +48,8 @@ typedef int (*VP56ParseHeader)(VP56Context *s, const uint8_t *buf, typedef struct { int high; - int bits; + int bits; /* stored negated (i.e. negative "bits" is a positive number of + bits left) in order to eliminate a negate in cache refilling */ const uint8_t *buffer; const uint8_t *end; unsigned long code_word; @@ -184,7 +186,7 @@ static inline void vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size) { c->high = 255; - c->bits = 8; + c->bits = -8; c->buffer = buf; c->end = buf + buf_size; c->code_word = bytestream_get_be16(&c->buffer); @@ -192,26 +194,32 @@ static inline void vp56_init_range_decoder(VP56RangeCoder *c, static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) { - unsigned int low = 1 + (((c->high - 1) * prob) / 256); + /* Don't put c->high in a local variable; if we do that, gcc gets + * the stupids and turns the code below into a branch again. */ + int bits = c->bits; + unsigned long code_word = c->code_word; + unsigned int low = 1 + (((c->high - 1) * prob) >> 8); unsigned int low_shift = low << 8; - int bit = c->code_word >= low_shift; + int bit = code_word >= low_shift; + int shift; - if (bit) { - c->high -= low; - c->code_word -= low_shift; - } else { - c->high = low; - } + /* Incantation to convince GCC to turn these into conditional moves + * instead of branches -- faster, as this branch is basically + * unpredictable. */ + c->high = bit ? c->high - low : low; + code_word = bit ? code_word - low_shift : code_word; /* normalize */ - while (c->high < 128) { - c->high <<= 1; - c->code_word <<= 1; - if (--c->bits == 0 && c->buffer < c->end) { - c->bits = 8; - c->code_word |= *c->buffer++; - } + shift = ff_h264_norm_shift[c->high] - 1; + c->high <<= shift; + code_word <<= shift; + bits += shift; + if(bits >= 0 && c->buffer < c->end) { + code_word |= *c->buffer++ << bits; + bits -= 8; } + c->bits = bits; + c->code_word = code_word; return bit; } @@ -230,13 +238,19 @@ static inline int vp56_rac_get(VP56RangeCoder *c) /* normalize */ c->code_word <<= 1; - if (--c->bits == 0 && c->buffer < c->end) { - c->bits = 8; + if (++c->bits == 0 && c->buffer < c->end) { + c->bits = -8; c->code_word |= *c->buffer++; } return bit; } +// rounding is different than vp56_rac_get, is vp56_rac_get wrong? +static inline int vp8_rac_get(VP56RangeCoder *c) +{ + return vp56_rac_get_prob(c, 128); +} + static inline int vp56_rac_gets(VP56RangeCoder *c, int bits) { int value = 0; @@ -248,12 +262,46 @@ static inline int vp56_rac_gets(VP56RangeCoder *c, int bits) return value; } +static inline int vp8_rac_get_uint(VP56RangeCoder *c, int bits) +{ + int value = 0; + + while (bits--) { + value = (value << 1) | vp8_rac_get(c); + } + + return value; +} + +// fixme: add 1 bit to all the calls to this? +static inline int vp8_rac_get_sint(VP56RangeCoder *c, int bits) +{ + int v; + + if (!vp8_rac_get(c)) + return 0; + + v = vp8_rac_get_uint(c, bits); + + if (vp8_rac_get(c)) + v = -v; + + return v; +} + +// P(7) static inline int vp56_rac_gets_nn(VP56RangeCoder *c, int bits) { int v = vp56_rac_gets(c, 7) << 1; return v + !v; } +static inline int vp8_rac_get_nn(VP56RangeCoder *c) +{ + int v = vp8_rac_get_uint(c, 7) << 1; + return v + !v; +} + static inline int vp56_rac_get_tree(VP56RangeCoder *c, const VP56Tree *tree, const uint8_t *probs) @@ -267,4 +315,39 @@ static inline int vp56_rac_get_tree(VP56RangeCoder *c, return -tree->val; } +/** + * This is identical to vp8_rac_get_tree except for the possibility of starting + * on a node other than the root node, needed for coeff decode where this is + * used to save a bit after a 0 token (by disallowing EOB to immediately follow.) + */ +static inline int vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t (*tree)[2], + const uint8_t *probs, int i) +{ + do { + i = tree[i][vp56_rac_get_prob(c, probs[i])]; + } while (i > 0); + + return -i; +} + +// how probabilities are associated with decisions is different I think +// well, the new scheme fits in the old but this way has one fewer branches per decision +static inline int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t (*tree)[2], + const uint8_t *probs) +{ + return vp8_rac_get_tree_with_offset(c, tree, probs, 0); +} + +// DCTextra +static inline int vp8_rac_get_coeff(VP56RangeCoder *c, const uint8_t *prob) +{ + int v = 0; + + do { + v = (v<<1) + vp56_rac_get_prob(c, *prob++); + } while (*prob); + + return v; +} + #endif /* AVCODEC_VP56_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp6.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp6.c index 58c31f965..f8bcd4be3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp6.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp6.c @@ -36,6 +36,7 @@ #include "vp56data.h" #include "vp6data.h" +#define VP6_MAX_HUFF_SIZE 12 static void vp6_parse_coeff(VP56Context *s); static void vp6_parse_coeff_huffman(VP56Context *s); @@ -215,7 +216,7 @@ static int vp6_huff_cmp(const void *va, const void *vb) static void vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[], const uint8_t *map, unsigned size, VLC *vlc) { - Node nodes[2*size], *tmp = &nodes[size]; + Node nodes[2*VP6_MAX_HUFF_SIZE], *tmp = &nodes[size]; int a, b, i; /* first compute probabilities from model */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8.c new file mode 100644 index 000000000..74a05f331 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8.c @@ -0,0 +1,1478 @@ +/** + * VP8 compatible video decoder + * + * Copyright (C) 2010 David Conrad + * Copyright (C) 2010 Ronald S. Bultje + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avcodec.h" +#include "vp56.h" +#include "vp8data.h" +#include "vp8dsp.h" +#include "h264pred.h" +#include "rectangle.h" + +typedef struct { + uint8_t segment; + uint8_t skip; + // todo: make it possible to check for at least (i4x4 or split_mv) + // in one op. are others needed? + uint8_t mode; + uint8_t ref_frame; + uint8_t partitioning; + VP56mv mv; + VP56mv bmv[16]; +} VP8Macroblock; + +typedef struct { + AVCodecContext *avctx; + DSPContext dsp; + VP8DSPContext vp8dsp; + H264PredContext hpc; + vp8_mc_func put_pixels_tab[3][3][3]; + AVFrame frames[4]; + AVFrame *framep[4]; + uint8_t *edge_emu_buffer; + VP56RangeCoder c; ///< header context, includes mb modes and motion vectors + int profile; + + int mb_width; /* number of horizontal MB */ + int mb_height; /* number of vertical MB */ + int linesize; + int uvlinesize; + + int keyframe; + int invisible; + int update_last; ///< update VP56_FRAME_PREVIOUS with the current one + int update_golden; ///< VP56_FRAME_NONE if not updated, or which frame to copy if so + int update_altref; + + /** + * If this flag is not set, all the probability updates + * are discarded after this frame is decoded. + */ + int update_probabilities; + + /** + * All coefficients are contained in separate arith coding contexts. + * There can be 1, 2, 4, or 8 of these after the header context. + */ + int num_coeff_partitions; + VP56RangeCoder coeff_partition[8]; + + VP8Macroblock *macroblocks; + VP8Macroblock *macroblocks_base; + int mb_stride; + + uint8_t *intra4x4_pred_mode; + uint8_t *intra4x4_pred_mode_base; + int b4_stride; + + /** + * For coeff decode, we need to know whether the above block had non-zero + * coefficients. This means for each macroblock, we need data for 4 luma + * blocks, 2 u blocks, 2 v blocks, and the luma dc block, for a total of 9 + * per macroblock. We keep the last row in top_nnz. + */ + uint8_t (*top_nnz)[9]; + DECLARE_ALIGNED(8, uint8_t, left_nnz)[9]; + + /** + * This is the index plus one of the last non-zero coeff + * for each of the blocks in the current macroblock. + * So, 0 -> no coeffs + * 1 -> dc-only (special transform) + * 2+-> full transform + */ + DECLARE_ALIGNED(16, uint8_t, non_zero_count_cache)[6][4]; + DECLARE_ALIGNED(16, DCTELEM, block)[6][4][16]; + + int chroma_pred_mode; ///< 8x8c pred mode of the current macroblock + + int mbskip_enabled; + int sign_bias[4]; ///< one state [0, 1] per ref frame type + + /** + * Base parameters for segmentation, i.e. per-macroblock parameters. + * These must be kept unchanged even if segmentation is not used for + * a frame, since the values persist between interframes. + */ + struct { + int enabled; + int absolute_vals; + int update_map; + int8_t base_quant[4]; + int8_t filter_level[4]; ///< base loop filter level + } segmentation; + + /** + * Macroblocks can have one of 4 different quants in a frame when + * segmentation is enabled. + * If segmentation is disabled, only the first segment's values are used. + */ + struct { + // [0] - DC qmul [1] - AC qmul + int16_t luma_qmul[2]; + int16_t luma_dc_qmul[2]; ///< luma dc-only block quant + int16_t chroma_qmul[2]; + } qmat[4]; + + struct { + int simple; + int level; + int sharpness; + } filter; + + struct { + int enabled; ///< whether each mb can have a different strength based on mode/ref + + /** + * filter strength adjustment for the following macroblock modes: + * [0] - i4x4 + * [1] - zero mv + * [2] - inter modes except for zero or split mv + * [3] - split mv + * i16x16 modes never have any adjustment + */ + int8_t mode[4]; + + /** + * filter strength adjustment for macroblocks that reference: + * [0] - intra / VP56_FRAME_CURRENT + * [1] - VP56_FRAME_PREVIOUS + * [2] - VP56_FRAME_GOLDEN + * [3] - altref / VP56_FRAME_GOLDEN2 + */ + int8_t ref[4]; + } lf_delta; + + /** + * These are all of the updatable probabilities for binary decisions. + * They are only implictly reset on keyframes, making it quite likely + * for an interframe to desync if a prior frame's header was corrupt + * or missing outright! + */ + struct { + uint8_t segmentid[3]; + uint8_t mbskip; + uint8_t intra; + uint8_t last; + uint8_t golden; + uint8_t pred16x16[4]; + uint8_t pred8x8c[3]; + uint8_t token[4][8][3][NUM_DCT_TOKENS-1]; + uint8_t mvc[2][19]; + } prob[2]; +} VP8Context; + +#define RL24(p) (AV_RL16(p) + ((p)[2] << 16)) + +static void vp8_decode_flush(AVCodecContext *avctx) +{ + VP8Context *s = avctx->priv_data; + int i; + + for (i = 0; i < 4; i++) + if (s->frames[i].data[0]) + avctx->release_buffer(avctx, &s->frames[i]); + memset(s->framep, 0, sizeof(s->framep)); + + av_freep(&s->macroblocks_base); + av_freep(&s->intra4x4_pred_mode_base); + av_freep(&s->top_nnz); + av_freep(&s->edge_emu_buffer); + + s->macroblocks = NULL; + s->intra4x4_pred_mode = NULL; +} + +static int update_dimensions(VP8Context *s, int width, int height) +{ + int i; + + if (avcodec_check_dimensions(s->avctx, width, height)) + return AVERROR_INVALIDDATA; + + vp8_decode_flush(s->avctx); + + avcodec_set_dimensions(s->avctx, width, height); + + s->mb_width = (s->avctx->coded_width +15) / 16; + s->mb_height = (s->avctx->coded_height+15) / 16; + + // we allocate a border around the top/left of intra4x4 modes + // this is 4 blocks for intra4x4 to keep 4-byte alignment for fill_rectangle + s->mb_stride = s->mb_width+1; + s->b4_stride = 4*s->mb_stride; + + s->macroblocks_base = av_mallocz(s->mb_stride*(s->mb_height+1)*sizeof(*s->macroblocks)); + s->intra4x4_pred_mode_base = av_mallocz(s->b4_stride*(4*s->mb_height+1)); + s->top_nnz = av_mallocz(s->mb_width*sizeof(*s->top_nnz)); + + s->macroblocks = s->macroblocks_base + 1 + s->mb_stride; + s->intra4x4_pred_mode = s->intra4x4_pred_mode_base + 4 + s->b4_stride; + + memset(s->intra4x4_pred_mode_base, DC_PRED, s->b4_stride); + for (i = 0; i < 4*s->mb_height; i++) + s->intra4x4_pred_mode[i*s->b4_stride-1] = DC_PRED; + + return 0; +} + +static void parse_segment_info(VP8Context *s) +{ + VP56RangeCoder *c = &s->c; + int i; + + s->segmentation.update_map = vp8_rac_get(c); + + if (vp8_rac_get(c)) { // update segment feature data + s->segmentation.absolute_vals = vp8_rac_get(c); + + for (i = 0; i < 4; i++) + s->segmentation.base_quant[i] = vp8_rac_get_sint(c, 7); + + for (i = 0; i < 4; i++) + s->segmentation.filter_level[i] = vp8_rac_get_sint(c, 6); + } + if (s->segmentation.update_map) + for (i = 0; i < 3; i++) + s->prob->segmentid[i] = vp8_rac_get(c) ? vp8_rac_get_uint(c, 8) : 255; +} + +static void update_lf_deltas(VP8Context *s) +{ + VP56RangeCoder *c = &s->c; + int i; + + for (i = 0; i < 4; i++) + s->lf_delta.ref[i] = vp8_rac_get_sint(c, 6); + + for (i = 0; i < 4; i++) + s->lf_delta.mode[i] = vp8_rac_get_sint(c, 6); +} + +static int setup_partitions(VP8Context *s, const uint8_t *buf, int buf_size) +{ + const uint8_t *sizes = buf; + int i; + + s->num_coeff_partitions = 1 << vp8_rac_get_uint(&s->c, 2); + + buf += 3*(s->num_coeff_partitions-1); + buf_size -= 3*(s->num_coeff_partitions-1); + if (buf_size < 0) + return -1; + + for (i = 0; i < s->num_coeff_partitions-1; i++) { + int size = RL24(sizes + 3*i); + if (buf_size - size < 0) + return -1; + + vp56_init_range_decoder(&s->coeff_partition[i], buf, size); + buf += size; + buf_size -= size; + } + vp56_init_range_decoder(&s->coeff_partition[i], buf, buf_size); + + return 0; +} + +static void get_quants(VP8Context *s) +{ + VP56RangeCoder *c = &s->c; + int i, base_qi; + + int yac_qi = vp8_rac_get_uint(c, 7); + int ydc_delta = vp8_rac_get_sint(c, 4); + int y2dc_delta = vp8_rac_get_sint(c, 4); + int y2ac_delta = vp8_rac_get_sint(c, 4); + int uvdc_delta = vp8_rac_get_sint(c, 4); + int uvac_delta = vp8_rac_get_sint(c, 4); + + for (i = 0; i < 4; i++) { + if (s->segmentation.enabled) { + base_qi = s->segmentation.base_quant[i]; + if (!s->segmentation.absolute_vals) + base_qi += yac_qi; + } else + base_qi = yac_qi; + + s->qmat[i].luma_qmul[0] = vp8_dc_qlookup[av_clip(base_qi + ydc_delta , 0, 127)]; + s->qmat[i].luma_qmul[1] = vp8_ac_qlookup[av_clip(base_qi , 0, 127)]; + s->qmat[i].luma_dc_qmul[0] = 2 * vp8_dc_qlookup[av_clip(base_qi + y2dc_delta, 0, 127)]; + s->qmat[i].luma_dc_qmul[1] = 155 * vp8_ac_qlookup[av_clip(base_qi + y2ac_delta, 0, 127)] / 100; + s->qmat[i].chroma_qmul[0] = vp8_dc_qlookup[av_clip(base_qi + uvdc_delta, 0, 127)]; + s->qmat[i].chroma_qmul[1] = vp8_ac_qlookup[av_clip(base_qi + uvac_delta, 0, 127)]; + + s->qmat[i].luma_dc_qmul[1] = FFMAX(s->qmat[i].luma_dc_qmul[1], 8); + s->qmat[i].chroma_qmul[0] = FFMIN(s->qmat[i].chroma_qmul[0], 132); + } +} + +/** + * Determine which buffers golden and altref should be updated with after this frame. + * The spec isn't clear here, so I'm going by my understanding of what libvpx does + * + * Intra frames update all 3 references + * Inter frames update VP56_FRAME_PREVIOUS if the update_last flag is set + * If the update (golden|altref) flag is set, it's updated with the current frame + * if update_last is set, and VP56_FRAME_PREVIOUS otherwise. + * If the flag is not set, the number read means: + * 0: no update + * 1: VP56_FRAME_PREVIOUS + * 2: update golden with altref, or update altref with golden + */ +static VP56Frame ref_to_update(VP8Context *s, int update, VP56Frame ref) +{ + VP56RangeCoder *c = &s->c; + + if (update) + return VP56_FRAME_CURRENT; + + switch (vp8_rac_get_uint(c, 2)) { + case 1: + return VP56_FRAME_PREVIOUS; + case 2: + return (ref == VP56_FRAME_GOLDEN) ? VP56_FRAME_GOLDEN2 : VP56_FRAME_GOLDEN; + } + return VP56_FRAME_NONE; +} + +static void update_refs(VP8Context *s) +{ + VP56RangeCoder *c = &s->c; + + int update_golden = vp8_rac_get(c); + int update_altref = vp8_rac_get(c); + + s->update_golden = ref_to_update(s, update_golden, VP56_FRAME_GOLDEN); + s->update_altref = ref_to_update(s, update_altref, VP56_FRAME_GOLDEN2); +} + +static int decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) +{ + VP56RangeCoder *c = &s->c; + int header_size, hscale, vscale, i, j, k, l, ret; + int width = s->avctx->width; + int height = s->avctx->height; + + s->keyframe = !(buf[0] & 1); + s->profile = (buf[0]>>1) & 7; + s->invisible = !(buf[0] & 0x10); + header_size = RL24(buf) >> 5; + buf += 3; + buf_size -= 3; + + if (s->profile > 3) + av_log(s->avctx, AV_LOG_WARNING, "Unknown profile %d\n", s->profile); + + if (!s->profile) + memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab, sizeof(s->put_pixels_tab)); + else // profile 1-3 use bilinear, 4+ aren't defined so whatever + memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_bilinear_pixels_tab, sizeof(s->put_pixels_tab)); + + if (header_size > buf_size - 7*s->keyframe) { + av_log(s->avctx, AV_LOG_ERROR, "Header size larger than data provided\n"); + return AVERROR_INVALIDDATA; + } + + if (s->keyframe) { + if (RL24(buf) != 0x2a019d) { + av_log(s->avctx, AV_LOG_ERROR, "Invalid start code 0x%x\n", RL24(buf)); + return AVERROR_INVALIDDATA; + } + width = AV_RL16(buf+3) & 0x3fff; + height = AV_RL16(buf+5) & 0x3fff; + hscale = buf[4] >> 6; + vscale = buf[6] >> 6; + buf += 7; + buf_size -= 7; + + if (hscale || vscale) + av_log_missing_feature(s->avctx, "Upscaling", 1); + + s->update_golden = s->update_altref = VP56_FRAME_CURRENT; + memcpy(s->prob->token , vp8_token_default_probs , sizeof(s->prob->token)); + memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter, sizeof(s->prob->pred16x16)); + memcpy(s->prob->pred8x8c , vp8_pred8x8c_prob_inter , sizeof(s->prob->pred8x8c)); + memcpy(s->prob->mvc , vp8_mv_default_prob , sizeof(s->prob->mvc)); + memset(&s->segmentation, 0, sizeof(s->segmentation)); + } + + if (!s->macroblocks_base || /* first frame */ + width != s->avctx->width || height != s->avctx->height) { + if ((ret = update_dimensions(s, width, height) < 0)) + return ret; + } + + vp56_init_range_decoder(c, buf, header_size); + buf += header_size; + buf_size -= header_size; + + if (s->keyframe) { + if (vp8_rac_get(c)) + av_log(s->avctx, AV_LOG_WARNING, "Unspecified colorspace\n"); + vp8_rac_get(c); // whether we can skip clamping in dsp functions + } + + if ((s->segmentation.enabled = vp8_rac_get(c))) + parse_segment_info(s); + else + s->segmentation.update_map = 0; // FIXME: move this to some init function? + + s->filter.simple = vp8_rac_get(c); + s->filter.level = vp8_rac_get_uint(c, 6); + s->filter.sharpness = vp8_rac_get_uint(c, 3); + + if ((s->lf_delta.enabled = vp8_rac_get(c))) + if (vp8_rac_get(c)) + update_lf_deltas(s); + + if (setup_partitions(s, buf, buf_size)) { + av_log(s->avctx, AV_LOG_ERROR, "Invalid partitions\n"); + return AVERROR_INVALIDDATA; + } + + get_quants(s); + + if (!s->keyframe) { + update_refs(s); + s->sign_bias[VP56_FRAME_GOLDEN] = vp8_rac_get(c); + s->sign_bias[VP56_FRAME_GOLDEN2 /* altref */] = vp8_rac_get(c); + } + + // if we aren't saving this frame's probabilities for future frames, + // make a copy of the current probabilities + if (!(s->update_probabilities = vp8_rac_get(c))) + s->prob[1] = s->prob[0]; + + s->update_last = s->keyframe || vp8_rac_get(c); + + for (i = 0; i < 4; i++) + for (j = 0; j < 8; j++) + for (k = 0; k < 3; k++) + for (l = 0; l < NUM_DCT_TOKENS-1; l++) + if (vp56_rac_get_prob(c, vp8_token_update_probs[i][j][k][l])) + s->prob->token[i][j][k][l] = vp8_rac_get_uint(c, 8); + + if ((s->mbskip_enabled = vp8_rac_get(c))) + s->prob->mbskip = vp8_rac_get_uint(c, 8); + + if (!s->keyframe) { + s->prob->intra = vp8_rac_get_uint(c, 8); + s->prob->last = vp8_rac_get_uint(c, 8); + s->prob->golden = vp8_rac_get_uint(c, 8); + + if (vp8_rac_get(c)) + for (i = 0; i < 4; i++) + s->prob->pred16x16[i] = vp8_rac_get_uint(c, 8); + if (vp8_rac_get(c)) + for (i = 0; i < 3; i++) + s->prob->pred8x8c[i] = vp8_rac_get_uint(c, 8); + + // 17.2 MV probability update + for (i = 0; i < 2; i++) + for (j = 0; j < 19; j++) + if (vp56_rac_get_prob(c, vp8_mv_update_prob[i][j])) + s->prob->mvc[i][j] = vp8_rac_get_nn(c); + } + + return 0; +} + +static inline void clamp_mv(VP8Context *s, VP56mv *dst, const VP56mv *src, + int mb_x, int mb_y) +{ +#define MARGIN (16 << 2) + dst->x = av_clip(src->x, -((mb_x << 6) + MARGIN), + ((s->mb_width - 1 - mb_x) << 6) + MARGIN); + dst->y = av_clip(src->y, -((mb_y << 6) + MARGIN), + ((s->mb_height - 1 - mb_y) << 6) + MARGIN); +} + +static void find_near_mvs(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, + VP56mv near[2], VP56mv *best, int cnt[4]) +{ + VP8Macroblock *mb_edge[3] = { mb - s->mb_stride /* top */, + mb - 1 /* left */, + mb - s->mb_stride - 1 /* top-left */ }; + enum { EDGE_TOP, EDGE_LEFT, EDGE_TOPLEFT }; + VP56mv near_mv[4] = {{ 0 }}; + enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV }; + int idx = CNT_ZERO, n; + int best_idx = CNT_ZERO; + + /* Process MB on top, left and top-left */ + for (n = 0; n < 3; n++) { + VP8Macroblock *edge = mb_edge[n]; + if (edge->ref_frame != VP56_FRAME_CURRENT) { + if (edge->mv.x | edge->mv.y) { + VP56mv tmp = edge->mv; + if (s->sign_bias[mb->ref_frame] != s->sign_bias[edge->ref_frame]) { + tmp.x *= -1; + tmp.y *= -1; + } + if ((tmp.x ^ near_mv[idx].x) | (tmp.y ^ near_mv[idx].y)) + near_mv[++idx] = tmp; + cnt[idx] += 1 + (n != 2); + } else + cnt[CNT_ZERO] += 1 + (n != 2); + } + } + + /* If we have three distinct MV's, merge first and last if they're the same */ + if (cnt[CNT_SPLITMV] && + !((near_mv[1+EDGE_TOP].x ^ near_mv[1+EDGE_TOPLEFT].x) | + (near_mv[1+EDGE_TOP].y ^ near_mv[1+EDGE_TOPLEFT].y))) + cnt[CNT_NEAREST] += 1; + + cnt[CNT_SPLITMV] = ((mb_edge[EDGE_LEFT]->mode == VP8_MVMODE_SPLIT) + + (mb_edge[EDGE_TOP]->mode == VP8_MVMODE_SPLIT)) * 2 + + (mb_edge[EDGE_TOPLEFT]->mode == VP8_MVMODE_SPLIT); + + /* Swap near and nearest if necessary */ + if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) { + FFSWAP(int, cnt[CNT_NEAREST], cnt[CNT_NEAR]); + FFSWAP(VP56mv, near_mv[CNT_NEAREST], near_mv[CNT_NEAR]); + } + + /* Choose the best mv out of 0,0 and the nearest mv */ + if (cnt[CNT_NEAREST] >= cnt[CNT_ZERO]) + best_idx = CNT_NEAREST; + + clamp_mv(s, best, &near_mv[best_idx], mb_x, mb_y); + near[0] = near_mv[CNT_NEAREST]; + near[1] = near_mv[CNT_NEAR]; +} + +/** + * Motion vector coding, 17.1. + */ +static int read_mv_component(VP56RangeCoder *c, const uint8_t *p) +{ + int x = 0; + + if (vp56_rac_get_prob(c, p[0])) { + int i; + + for (i = 0; i < 3; i++) + x += vp56_rac_get_prob(c, p[9 + i]) << i; + for (i = 9; i > 3; i--) + x += vp56_rac_get_prob(c, p[9 + i]) << i; + if (!(x & 0xFFF0) || vp56_rac_get_prob(c, p[12])) + x += 8; + } else + x = vp8_rac_get_tree(c, vp8_small_mvtree, &p[2]); + + return (x && vp56_rac_get_prob(c, p[1])) ? -x : x; +} + +static const uint8_t *get_submv_prob(const VP56mv *left, const VP56mv *top) +{ + int l_is_zero = !(left->x | left->y); + int t_is_zero = !(top->x | top->y); + int equal = !((left->x ^ top->x) | (left->y ^ top->y)); + + if (equal) + return l_is_zero ? vp8_submv_prob[4] : vp8_submv_prob[3]; + if (t_is_zero) + return vp8_submv_prob[2]; + return l_is_zero ? vp8_submv_prob[1] : vp8_submv_prob[0]; +} + +/** + * Split motion vector prediction, 16.4. + * @returns the number of motion vectors parsed (2, 4 or 16) + */ +static int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, + VP8Macroblock *mb, VP56mv *base_mv) +{ + int part_idx = mb->partitioning = + vp8_rac_get_tree(c, vp8_mbsplit_tree, vp8_mbsplit_prob); + int n, num = vp8_mbsplit_count[part_idx]; + const uint8_t *mbsplits = vp8_mbsplits[part_idx], + *firstidx = vp8_mbfirstidx[part_idx]; + + for (n = 0; n < num; n++) { + int k = firstidx[n]; + const VP56mv *left, *above; + const uint8_t *submv_prob; + + if (!(k & 3)) { + VP8Macroblock *left_mb = &mb[-1]; + left = &left_mb->bmv[vp8_mbsplits[left_mb->partitioning][k + 3]]; + } else + left = &mb->bmv[mbsplits[k - 1]]; + if (k <= 3) { + VP8Macroblock *above_mb = &mb[-s->mb_stride]; + above = &above_mb->bmv[vp8_mbsplits[above_mb->partitioning][k + 12]]; + } else + above = &mb->bmv[mbsplits[k - 4]]; + + submv_prob = get_submv_prob(left, above); + + switch (vp8_rac_get_tree(c, vp8_submv_ref_tree, submv_prob)) { + case VP8_SUBMVMODE_NEW4X4: + mb->bmv[n].y = base_mv->y + read_mv_component(c, s->prob->mvc[0]); + mb->bmv[n].x = base_mv->x + read_mv_component(c, s->prob->mvc[1]); + break; + case VP8_SUBMVMODE_ZERO4X4: + mb->bmv[n].x = 0; + mb->bmv[n].y = 0; + break; + case VP8_SUBMVMODE_LEFT4X4: + mb->bmv[n] = *left; + break; + case VP8_SUBMVMODE_TOP4X4: + mb->bmv[n] = *above; + break; + } + } + + return num; +} + +static inline void decode_intra4x4_modes(VP56RangeCoder *c, uint8_t *intra4x4, + int stride, int keyframe) +{ + int x, y, t, l; + const uint8_t *ctx = vp8_pred4x4_prob_inter; + + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + if (keyframe) { + t = intra4x4[x - stride]; + l = intra4x4[x - 1]; + ctx = vp8_pred4x4_prob_intra[t][l]; + } + intra4x4[x] = vp8_rac_get_tree(c, vp8_pred4x4_tree, ctx); + } + intra4x4 += stride; + } +} + +static void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, + uint8_t *intra4x4) +{ + VP56RangeCoder *c = &s->c; + int n; + + if (s->segmentation.update_map) + mb->segment = vp8_rac_get_tree(c, vp8_segmentid_tree, s->prob->segmentid); + + mb->skip = s->mbskip_enabled ? vp56_rac_get_prob(c, s->prob->mbskip) : 0; + + if (s->keyframe) { + mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_intra, vp8_pred16x16_prob_intra); + + if (mb->mode == MODE_I4x4) { + decode_intra4x4_modes(c, intra4x4, s->b4_stride, 1); + } else + fill_rectangle(intra4x4, 4, 4, s->b4_stride, vp8_pred4x4_mode[mb->mode], 1); + + s->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree, vp8_pred8x8c_prob_intra); + mb->ref_frame = VP56_FRAME_CURRENT; + } else if (vp56_rac_get_prob(c, s->prob->intra)) { + VP56mv near[2], best; + int cnt[4] = { 0 }; + uint8_t p[4]; + + // inter MB, 16.2 + if (vp56_rac_get_prob(c, s->prob->last)) + mb->ref_frame = vp56_rac_get_prob(c, s->prob->golden) ? + VP56_FRAME_GOLDEN2 /* altref */ : VP56_FRAME_GOLDEN; + else + mb->ref_frame = VP56_FRAME_PREVIOUS; + + // motion vectors, 16.3 + find_near_mvs(s, mb, mb_x, mb_y, near, &best, cnt); + for (n = 0; n < 4; n++) + p[n] = vp8_mode_contexts[cnt[n]][n]; + mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_mvinter, p); + switch (mb->mode) { + case VP8_MVMODE_SPLIT: + mb->mv = mb->bmv[decode_splitmvs(s, c, mb, &best) - 1]; + break; + case VP8_MVMODE_ZERO: + mb->mv.x = 0; + mb->mv.y = 0; + break; + case VP8_MVMODE_NEAREST: + clamp_mv(s, &mb->mv, &near[0], mb_x, mb_y); + break; + case VP8_MVMODE_NEAR: + clamp_mv(s, &mb->mv, &near[1], mb_x, mb_y); + break; + case VP8_MVMODE_NEW: + mb->mv.y = best.y + read_mv_component(c, s->prob->mvc[0]); + mb->mv.x = best.x + read_mv_component(c, s->prob->mvc[1]); + break; + } + if (mb->mode != VP8_MVMODE_SPLIT) { + mb->partitioning = VP8_SPLITMVMODE_NONE; + mb->bmv[0] = mb->mv; + } + } else { + // intra MB, 16.1 + mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, s->prob->pred16x16); + + if (mb->mode == MODE_I4x4) { + decode_intra4x4_modes(c, intra4x4, s->b4_stride, 0); + } else + fill_rectangle(intra4x4, 4, 4, s->b4_stride, vp8_pred4x4_mode[mb->mode], 1); + + s->chroma_pred_mode = vp8_rac_get_tree(c, vp8_pred8x8c_tree, s->prob->pred8x8c); + mb->ref_frame = VP56_FRAME_CURRENT; + } +} + +/** + * @param c arithmetic bitstream reader context + * @param block destination for block coefficients + * @param probs probabilities to use when reading trees from the bitstream + * @param i initial coeff index, 0 unless a separate DC block is coded + * @param zero_nhood the initial prediction context for number of surrounding + * all-zero blocks (only left/top, so 0-2) + * @param qmul array holding the dc/ac dequant factor at position 0/1 + * @return 0 if no coeffs were decoded + * otherwise, the index of the last coeff decoded plus one + */ +static int decode_block_coeffs(VP56RangeCoder *c, DCTELEM block[16], + uint8_t probs[8][3][NUM_DCT_TOKENS-1], + int i, int zero_nhood, int16_t qmul[2]) +{ + int token, nonzero = 0; + int offset = 0; + + for (; i < 16; i++) { + token = vp8_rac_get_tree_with_offset(c, vp8_coeff_tree, probs[vp8_coeff_band[i]][zero_nhood], offset); + + if (token == DCT_EOB) + break; + else if (token >= DCT_CAT1) { + int cat = token-DCT_CAT1; + token = vp8_rac_get_coeff(c, vp8_dct_cat_prob[cat]); + token += vp8_dct_cat_offset[cat]; + } + + // after the first token, the non-zero prediction context becomes + // based on the last decoded coeff + if (!token) { + zero_nhood = 0; + offset = 1; + continue; + } else if (token == 1) + zero_nhood = 1; + else + zero_nhood = 2; + + // todo: full [16] qmat? load into register? + block[zigzag_scan[i]] = (vp8_rac_get(c) ? -token : token) * qmul[!!i]; + nonzero = i+1; + offset = 0; + } + return nonzero; +} + +static void decode_mb_coeffs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, + uint8_t t_nnz[9], uint8_t l_nnz[9]) +{ + LOCAL_ALIGNED_16(DCTELEM, dc,[16]); + int i, x, y, luma_start = 0, luma_ctx = 3; + int nnz_pred, nnz, nnz_total = 0; + int segment = s->segmentation.enabled ? mb->segment : 0; + + s->dsp.clear_blocks((DCTELEM *)s->block); + + if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) { + AV_ZERO128(dc); + AV_ZERO128(dc+8); + nnz_pred = t_nnz[8] + l_nnz[8]; + + // decode DC values and do hadamard + nnz = decode_block_coeffs(c, dc, s->prob->token[1], 0, nnz_pred, + s->qmat[segment].luma_dc_qmul); + l_nnz[8] = t_nnz[8] = !!nnz; + nnz_total += nnz; + s->vp8dsp.vp8_luma_dc_wht(s->block, dc); + luma_start = 1; + luma_ctx = 0; + } + + // luma blocks + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) { + nnz_pred = l_nnz[y] + t_nnz[x]; + nnz = decode_block_coeffs(c, s->block[y][x], s->prob->token[luma_ctx], luma_start, + nnz_pred, s->qmat[segment].luma_qmul); + // nnz+luma_start may be one more than the actual last index, but we don't care + s->non_zero_count_cache[y][x] = nnz + luma_start; + t_nnz[x] = l_nnz[y] = !!nnz; + nnz_total += nnz; + } + + // chroma blocks + // TODO: what to do about dimensions? 2nd dim for luma is x, + // but for chroma it's (y<<1)|x + for (i = 4; i < 6; i++) + for (y = 0; y < 2; y++) + for (x = 0; x < 2; x++) { + nnz_pred = l_nnz[i+2*y] + t_nnz[i+2*x]; + nnz = decode_block_coeffs(c, s->block[i][(y<<1)+x], s->prob->token[2], 0, + nnz_pred, s->qmat[segment].chroma_qmul); + s->non_zero_count_cache[i][(y<<1)+x] = nnz; + t_nnz[i+2*x] = l_nnz[i+2*y] = !!nnz; + nnz_total += nnz; + } + + // if there were no coded coeffs despite the macroblock not being marked skip, + // we MUST not do the inner loop filter and should not do IDCT + // Since skip isn't used for bitstream prediction, just manually set it. + if (!nnz_total) + mb->skip = 1; +} + +static int check_intra_pred_mode(int mode, int mb_x, int mb_y) +{ + if (mode == DC_PRED8x8) { + if (!(mb_x|mb_y)) + mode = DC_128_PRED8x8; + else if (!mb_y) + mode = LEFT_DC_PRED8x8; + else if (!mb_x) + mode = TOP_DC_PRED8x8; + } + return mode; +} + +static void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, + uint8_t *bmode, int mb_x, int mb_y) +{ + int x, y, mode, nnz, tr; + + if (mb->mode < MODE_I4x4) { + mode = check_intra_pred_mode(mb->mode, mb_x, mb_y); + s->hpc.pred16x16[mode](dst[0], s->linesize); + } else { + uint8_t *ptr = dst[0]; + + // all blocks on the right edge of the macroblock use bottom edge + // the top macroblock for their topright edge + uint8_t *tr_right = ptr - s->linesize + 16; + + // if we're on the right edge of the frame, said edge is extended + // from the top macroblock + if (mb_x == s->mb_width-1) { + tr = tr_right[-1]*0x01010101; + tr_right = (uint8_t *)&tr; + } + + for (y = 0; y < 4; y++) { + uint8_t *topright = ptr + 4 - s->linesize; + for (x = 0; x < 4; x++) { + if (x == 3) + topright = tr_right; + + s->hpc.pred4x4[bmode[x]](ptr+4*x, topright, s->linesize); + + nnz = s->non_zero_count_cache[y][x]; + if (nnz) { + if (nnz == 1) + s->vp8dsp.vp8_idct_dc_add(ptr+4*x, s->block[y][x], s->linesize); + else + s->vp8dsp.vp8_idct_add(ptr+4*x, s->block[y][x], s->linesize); + } + topright += 4; + } + + ptr += 4*s->linesize; + bmode += s->b4_stride; + } + } + + mode = check_intra_pred_mode(s->chroma_pred_mode, mb_x, mb_y); + s->hpc.pred8x8[mode](dst[1], s->uvlinesize); + s->hpc.pred8x8[mode](dst[2], s->uvlinesize); +} + +/** + * Generic MC function. + * + * @param s VP8 decoding context + * @param luma 1 for luma (Y) planes, 0 for chroma (Cb/Cr) planes + * @param dst target buffer for block data at block position + * @param src reference picture buffer at origin (0, 0) + * @param mv motion vector (relative to block position) to get pixel data from + * @param x_off horizontal position of block from origin (0, 0) + * @param y_off vertical position of block from origin (0, 0) + * @param block_w width of block (16, 8 or 4) + * @param block_h height of block (always same as block_w) + * @param width width of src/dst plane data + * @param height height of src/dst plane data + * @param linesize size of a single line of plane data, including padding + * @param mc_func motion compensation function pointers (bilinear or sixtap MC) + */ +static inline void vp8_mc(VP8Context *s, int luma, + uint8_t *dst, uint8_t *src, const VP56mv *mv, + int x_off, int y_off, int block_w, int block_h, + int width, int height, int linesize, + vp8_mc_func mc_func[3][3]) +{ + static const uint8_t idx[8] = { 0, 1, 2, 1, 2, 1, 2, 1 }; + int mx = (mv->x << luma)&7, mx_idx = idx[mx]; + int my = (mv->y << luma)&7, my_idx = idx[my]; + + x_off += mv->x >> (3 - luma); + y_off += mv->y >> (3 - luma); + + // edge emulation + src += y_off * linesize + x_off; + if (x_off < 2 || x_off >= width - block_w - 3 || + y_off < 2 || y_off >= height - block_h - 3) { + ff_emulated_edge_mc(s->edge_emu_buffer, src - 2 * linesize - 2, linesize, + block_w + 5, block_h + 5, + x_off - 2, y_off - 2, width, height); + src = s->edge_emu_buffer + 2 + linesize * 2; + } + + mc_func[my_idx][mx_idx](dst, linesize, src, linesize, block_h, mx, my); +} + +static inline void vp8_mc_part(VP8Context *s, uint8_t *dst[3], + AVFrame *ref_frame, int x_off, int y_off, + int bx_off, int by_off, + int block_w, int block_h, + int width, int height, VP56mv *mv) +{ + VP56mv uvmv = *mv; + + /* Y */ + vp8_mc(s, 1, dst[0] + by_off * s->linesize + bx_off, + ref_frame->data[0], mv, x_off + bx_off, y_off + by_off, + block_w, block_h, width, height, s->linesize, + s->put_pixels_tab[block_w == 8]); + + /* U/V */ + if (s->profile == 3) { + uvmv.x &= ~7; + uvmv.y &= ~7; + } + x_off >>= 1; y_off >>= 1; + bx_off >>= 1; by_off >>= 1; + width >>= 1; height >>= 1; + block_w >>= 1; block_h >>= 1; + vp8_mc(s, 0, dst[1] + by_off * s->uvlinesize + bx_off, + ref_frame->data[1], &uvmv, x_off + bx_off, y_off + by_off, + block_w, block_h, width, height, s->uvlinesize, + s->put_pixels_tab[1 + (block_w == 4)]); + vp8_mc(s, 0, dst[2] + by_off * s->uvlinesize + bx_off, + ref_frame->data[2], &uvmv, x_off + bx_off, y_off + by_off, + block_w, block_h, width, height, s->uvlinesize, + s->put_pixels_tab[1 + (block_w == 4)]); +} + +/** + * Apply motion vectors to prediction buffer, chapter 18. + */ +static void inter_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, + int mb_x, int mb_y) +{ + int x_off = mb_x << 4, y_off = mb_y << 4; + int width = 16*s->mb_width, height = 16*s->mb_height; + + if (mb->mode < VP8_MVMODE_SPLIT) { + vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, + 0, 0, 16, 16, width, height, &mb->mv); + } else switch (mb->partitioning) { + case VP8_SPLITMVMODE_4x4: { + int x, y; + VP56mv uvmv; + + /* Y */ + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + vp8_mc(s, 1, dst[0] + 4*y*s->linesize + x*4, + s->framep[mb->ref_frame]->data[0], &mb->bmv[4*y + x], + 4*x + x_off, 4*y + y_off, 4, 4, + width, height, s->linesize, + s->put_pixels_tab[2]); + } + } + + /* U/V */ + x_off >>= 1; y_off >>= 1; width >>= 1; height >>= 1; + for (y = 0; y < 2; y++) { + for (x = 0; x < 2; x++) { + uvmv.x = mb->bmv[ 2*y * 4 + 2*x ].x + + mb->bmv[ 2*y * 4 + 2*x+1].x + + mb->bmv[(2*y+1) * 4 + 2*x ].x + + mb->bmv[(2*y+1) * 4 + 2*x+1].x; + uvmv.y = mb->bmv[ 2*y * 4 + 2*x ].y + + mb->bmv[ 2*y * 4 + 2*x+1].y + + mb->bmv[(2*y+1) * 4 + 2*x ].y + + mb->bmv[(2*y+1) * 4 + 2*x+1].y; + uvmv.x = (uvmv.x + 2 + (uvmv.x >> (INT_BIT-1))) >> 2; + uvmv.y = (uvmv.y + 2 + (uvmv.y >> (INT_BIT-1))) >> 2; + if (s->profile == 3) { + uvmv.x &= ~7; + uvmv.y &= ~7; + } + vp8_mc(s, 0, dst[1] + 4*y*s->uvlinesize + x*4, + s->framep[mb->ref_frame]->data[1], &uvmv, + 4*x + x_off, 4*y + y_off, 4, 4, + width, height, s->uvlinesize, + s->put_pixels_tab[2]); + vp8_mc(s, 0, dst[2] + 4*y*s->uvlinesize + x*4, + s->framep[mb->ref_frame]->data[2], &uvmv, + 4*x + x_off, 4*y + y_off, 4, 4, + width, height, s->uvlinesize, + s->put_pixels_tab[2]); + } + } + break; + } + case VP8_SPLITMVMODE_16x8: + vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, + 0, 0, 16, 8, width, height, &mb->bmv[0]); + vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, + 0, 8, 16, 8, width, height, &mb->bmv[1]); + break; + case VP8_SPLITMVMODE_8x16: + vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, + 0, 0, 8, 16, width, height, &mb->bmv[0]); + vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, + 8, 0, 8, 16, width, height, &mb->bmv[1]); + break; + case VP8_SPLITMVMODE_8x8: + vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, + 0, 0, 8, 8, width, height, &mb->bmv[0]); + vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, + 8, 0, 8, 8, width, height, &mb->bmv[1]); + vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, + 0, 8, 8, 8, width, height, &mb->bmv[2]); + vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, + 8, 8, 8, 8, width, height, &mb->bmv[3]); + break; + } +} + +static void idct_mb(VP8Context *s, uint8_t *y_dst, uint8_t *u_dst, uint8_t *v_dst, + VP8Macroblock *mb) +{ + int x, y, nnz; + + if (mb->mode != MODE_I4x4) + for (y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + nnz = s->non_zero_count_cache[y][x]; + if (nnz) { + if (nnz == 1) + s->vp8dsp.vp8_idct_dc_add(y_dst+4*x, s->block[y][x], s->linesize); + else + s->vp8dsp.vp8_idct_add(y_dst+4*x, s->block[y][x], s->linesize); + } + } + y_dst += 4*s->linesize; + } + + for (y = 0; y < 2; y++) { + for (x = 0; x < 2; x++) { + nnz = s->non_zero_count_cache[4][(y<<1)+x]; + if (nnz) { + if (nnz == 1) + s->vp8dsp.vp8_idct_dc_add(u_dst+4*x, s->block[4][(y<<1)+x], s->uvlinesize); + else + s->vp8dsp.vp8_idct_add(u_dst+4*x, s->block[4][(y<<1)+x], s->uvlinesize); + } + + nnz = s->non_zero_count_cache[5][(y<<1)+x]; + if (nnz) { + if (nnz == 1) + s->vp8dsp.vp8_idct_dc_add(v_dst+4*x, s->block[5][(y<<1)+x], s->uvlinesize); + else + s->vp8dsp.vp8_idct_add(v_dst+4*x, s->block[5][(y<<1)+x], s->uvlinesize); + } + } + u_dst += 4*s->uvlinesize; + v_dst += 4*s->uvlinesize; + } +} + +static void filter_level_for_mb(VP8Context *s, VP8Macroblock *mb, int *level, int *inner, int *hev_thresh) +{ + int interior_limit, filter_level; + + if (s->segmentation.enabled) { + filter_level = s->segmentation.filter_level[mb->segment]; + if (!s->segmentation.absolute_vals) + filter_level += s->filter.level; + } else + filter_level = s->filter.level; + + if (s->lf_delta.enabled) { + filter_level += s->lf_delta.ref[mb->ref_frame]; + + if (mb->ref_frame == VP56_FRAME_CURRENT) { + if (mb->mode == MODE_I4x4) + filter_level += s->lf_delta.mode[0]; + } else { + if (mb->mode == VP8_MVMODE_ZERO) + filter_level += s->lf_delta.mode[1]; + else if (mb->mode == VP8_MVMODE_SPLIT) + filter_level += s->lf_delta.mode[3]; + else + filter_level += s->lf_delta.mode[2]; + } + } + filter_level = av_clip(filter_level, 0, 63); + + interior_limit = filter_level; + if (s->filter.sharpness) { + interior_limit >>= s->filter.sharpness > 4 ? 2 : 1; + interior_limit = FFMIN(interior_limit, 9 - s->filter.sharpness); + } + interior_limit = FFMAX(interior_limit, 1); + + *level = filter_level; + *inner = interior_limit; + + if (hev_thresh) { + *hev_thresh = filter_level >= 15; + + if (s->keyframe) { + if (filter_level >= 40) + *hev_thresh = 2; + } else { + if (filter_level >= 40) + *hev_thresh = 3; + else if (filter_level >= 20) + *hev_thresh = 2; + } + } +} + +// TODO: look at backup_mb_border / xchg_mb_border in h264.c +static void filter_mb(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb, int mb_x, int mb_y) +{ + int filter_level, inner_limit, hev_thresh, mbedge_lim, bedge_lim; + + filter_level_for_mb(s, mb, &filter_level, &inner_limit, &hev_thresh); + if (!filter_level) + return; + + mbedge_lim = 2*(filter_level+2) + inner_limit; + bedge_lim = 2* filter_level + inner_limit; + + if (mb_x) { + s->vp8dsp.vp8_h_loop_filter16(dst[0], s->linesize, mbedge_lim, inner_limit, hev_thresh); + s->vp8dsp.vp8_h_loop_filter8 (dst[1], s->uvlinesize, mbedge_lim, inner_limit, hev_thresh); + s->vp8dsp.vp8_h_loop_filter8 (dst[2], s->uvlinesize, mbedge_lim, inner_limit, hev_thresh); + } + + if (!mb->skip || mb->mode == MODE_I4x4 || mb->mode == VP8_MVMODE_SPLIT) { + s->vp8dsp.vp8_h_loop_filter16_inner(dst[0]+ 4, s->linesize, bedge_lim, inner_limit, hev_thresh); + s->vp8dsp.vp8_h_loop_filter16_inner(dst[0]+ 8, s->linesize, bedge_lim, inner_limit, hev_thresh); + s->vp8dsp.vp8_h_loop_filter16_inner(dst[0]+12, s->linesize, bedge_lim, inner_limit, hev_thresh); + s->vp8dsp.vp8_h_loop_filter8_inner (dst[1]+ 4, s->uvlinesize, bedge_lim, inner_limit, hev_thresh); + s->vp8dsp.vp8_h_loop_filter8_inner (dst[2]+ 4, s->uvlinesize, bedge_lim, inner_limit, hev_thresh); + } + + if (mb_y) { + s->vp8dsp.vp8_v_loop_filter16(dst[0], s->linesize, mbedge_lim, inner_limit, hev_thresh); + s->vp8dsp.vp8_v_loop_filter8 (dst[1], s->uvlinesize, mbedge_lim, inner_limit, hev_thresh); + s->vp8dsp.vp8_v_loop_filter8 (dst[2], s->uvlinesize, mbedge_lim, inner_limit, hev_thresh); + } + + if (!mb->skip || mb->mode == MODE_I4x4 || mb->mode == VP8_MVMODE_SPLIT) { + s->vp8dsp.vp8_v_loop_filter16_inner(dst[0]+ 4*s->linesize, s->linesize, bedge_lim, inner_limit, hev_thresh); + s->vp8dsp.vp8_v_loop_filter16_inner(dst[0]+ 8*s->linesize, s->linesize, bedge_lim, inner_limit, hev_thresh); + s->vp8dsp.vp8_v_loop_filter16_inner(dst[0]+12*s->linesize, s->linesize, bedge_lim, inner_limit, hev_thresh); + s->vp8dsp.vp8_v_loop_filter8_inner (dst[1]+ 4*s->uvlinesize, s->uvlinesize, bedge_lim, inner_limit, hev_thresh); + s->vp8dsp.vp8_v_loop_filter8_inner (dst[2]+ 4*s->uvlinesize, s->uvlinesize, bedge_lim, inner_limit, hev_thresh); + } +} + +static void filter_mb_simple(VP8Context *s, uint8_t *dst, VP8Macroblock *mb, int mb_x, int mb_y) +{ + int filter_level, inner_limit, mbedge_lim, bedge_lim; + + filter_level_for_mb(s, mb, &filter_level, &inner_limit, NULL); + if (!filter_level) + return; + + mbedge_lim = 2*(filter_level+2) + inner_limit; + bedge_lim = 2* filter_level + inner_limit; + + if (mb_x) + s->vp8dsp.vp8_h_loop_filter_simple(dst, s->linesize, mbedge_lim); + if (!mb->skip || mb->mode == MODE_I4x4 || mb->mode == VP8_MVMODE_SPLIT) { + s->vp8dsp.vp8_h_loop_filter_simple(dst+ 4, s->linesize, bedge_lim); + s->vp8dsp.vp8_h_loop_filter_simple(dst+ 8, s->linesize, bedge_lim); + s->vp8dsp.vp8_h_loop_filter_simple(dst+12, s->linesize, bedge_lim); + } + + if (mb_y) + s->vp8dsp.vp8_v_loop_filter_simple(dst, s->linesize, mbedge_lim); + if (!mb->skip || mb->mode == MODE_I4x4 || mb->mode == VP8_MVMODE_SPLIT) { + s->vp8dsp.vp8_v_loop_filter_simple(dst+ 4*s->linesize, s->linesize, bedge_lim); + s->vp8dsp.vp8_v_loop_filter_simple(dst+ 8*s->linesize, s->linesize, bedge_lim); + s->vp8dsp.vp8_v_loop_filter_simple(dst+12*s->linesize, s->linesize, bedge_lim); + } +} + +static void filter_mb_row(VP8Context *s, int mb_y) +{ + VP8Macroblock *mb = s->macroblocks + mb_y*s->mb_stride; + uint8_t *dst[3] = { + s->framep[VP56_FRAME_CURRENT]->data[0] + 16*mb_y*s->linesize, + s->framep[VP56_FRAME_CURRENT]->data[1] + 8*mb_y*s->uvlinesize, + s->framep[VP56_FRAME_CURRENT]->data[2] + 8*mb_y*s->uvlinesize + }; + int mb_x; + + for (mb_x = 0; mb_x < s->mb_width; mb_x++) { + filter_mb(s, dst, mb++, mb_x, mb_y); + dst[0] += 16; + dst[1] += 8; + dst[2] += 8; + } +} + +static void filter_mb_row_simple(VP8Context *s, int mb_y) +{ + uint8_t *dst = s->framep[VP56_FRAME_CURRENT]->data[0] + 16*mb_y*s->linesize; + VP8Macroblock *mb = s->macroblocks + mb_y*s->mb_stride; + int mb_x; + + for (mb_x = 0; mb_x < s->mb_width; mb_x++) { + filter_mb_simple(s, dst, mb++, mb_x, mb_y); + dst += 16; + } +} + +static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, + AVPacket *avpkt) +{ + VP8Context *s = avctx->priv_data; + int ret, mb_x, mb_y, i, y, referenced; + enum AVDiscard skip_thresh; + AVFrame *curframe; + + if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0) + return ret; + + referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT + || s->update_altref == VP56_FRAME_CURRENT; + + skip_thresh = !referenced ? AVDISCARD_NONREF : + !s->keyframe ? AVDISCARD_NONKEY : AVDISCARD_ALL; + + if (avctx->skip_frame >= skip_thresh) { + s->invisible = 1; + goto skip_decode; + } + + for (i = 0; i < 4; i++) + if (&s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] && + &s->frames[i] != s->framep[VP56_FRAME_GOLDEN] && + &s->frames[i] != s->framep[VP56_FRAME_GOLDEN2]) { + curframe = s->framep[VP56_FRAME_CURRENT] = &s->frames[i]; + break; + } + if (curframe->data[0]) + avctx->release_buffer(avctx, curframe); + + curframe->key_frame = s->keyframe; + curframe->pict_type = s->keyframe ? FF_I_TYPE : FF_P_TYPE; + curframe->reference = referenced ? 3 : 0; + if ((ret = avctx->get_buffer(avctx, curframe))) { + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed!\n"); + return ret; + } + + // Given that arithmetic probabilities are updated every frame, it's quite likely + // that the values we have on a random interframe are complete junk if we didn't + // start decode on a keyframe. So just don't display anything rather than junk. + if (!s->keyframe && (!s->framep[VP56_FRAME_PREVIOUS] || + !s->framep[VP56_FRAME_GOLDEN] || + !s->framep[VP56_FRAME_GOLDEN2])) { + av_log(avctx, AV_LOG_WARNING, "Discarding interframe without a prior keyframe!\n"); + return AVERROR_INVALIDDATA; + } + + s->linesize = curframe->linesize[0]; + s->uvlinesize = curframe->linesize[1]; + + if (!s->edge_emu_buffer) + s->edge_emu_buffer = av_malloc(21*s->linesize); + + memset(s->top_nnz, 0, s->mb_width*sizeof(*s->top_nnz)); + + // top edge of 127 for intra prediction + if (!(avctx->flags & CODEC_FLAG_EMU_EDGE)) { + memset(curframe->data[0] - s->linesize -1, 127, s->linesize +1); + memset(curframe->data[1] - s->uvlinesize-1, 127, s->uvlinesize+1); + memset(curframe->data[2] - s->uvlinesize-1, 127, s->uvlinesize+1); + } + + for (mb_y = 0; mb_y < s->mb_height; mb_y++) { + VP56RangeCoder *c = &s->coeff_partition[mb_y & (s->num_coeff_partitions-1)]; + VP8Macroblock *mb = s->macroblocks + mb_y*s->mb_stride; + uint8_t *intra4x4 = s->intra4x4_pred_mode + 4*mb_y*s->b4_stride; + uint8_t *dst[3] = { + curframe->data[0] + 16*mb_y*s->linesize, + curframe->data[1] + 8*mb_y*s->uvlinesize, + curframe->data[2] + 8*mb_y*s->uvlinesize + }; + + memset(s->left_nnz, 0, sizeof(s->left_nnz)); + + // left edge of 129 for intra prediction + if (!(avctx->flags & CODEC_FLAG_EMU_EDGE)) + for (i = 0; i < 3; i++) + for (y = 0; y < 16>>!!i; y++) + dst[i][y*curframe->linesize[i]-1] = 129; + + for (mb_x = 0; mb_x < s->mb_width; mb_x++) { + decode_mb_mode(s, mb, mb_x, mb_y, intra4x4 + 4*mb_x); + + if (!mb->skip) + decode_mb_coeffs(s, c, mb, s->top_nnz[mb_x], s->left_nnz); + else { + AV_ZERO128(s->non_zero_count_cache); // luma + AV_ZERO64(s->non_zero_count_cache[4]); // chroma + } + + if (mb->mode <= MODE_I4x4) { + intra_predict(s, dst, mb, intra4x4 + 4*mb_x, mb_x, mb_y); + memset(mb->bmv, 0, sizeof(mb->bmv)); + } else { + inter_predict(s, dst, mb, mb_x, mb_y); + } + + if (!mb->skip) { + idct_mb(s, dst[0], dst[1], dst[2], mb); + } else { + AV_ZERO64(s->left_nnz); + AV_WN64(s->top_nnz[mb_x], 0); // array of 9, so unaligned + + // Reset DC block predictors if they would exist if the mb had coefficients + if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) { + s->left_nnz[8] = 0; + s->top_nnz[mb_x][8] = 0; + } + } + + dst[0] += 16; + dst[1] += 8; + dst[2] += 8; + mb++; + } + if (mb_y && s->filter.level && avctx->skip_loop_filter < skip_thresh) { + if (s->filter.simple) + filter_mb_row_simple(s, mb_y-1); + else + filter_mb_row(s, mb_y-1); + } + } + if (s->filter.level && avctx->skip_loop_filter < skip_thresh) { + if (s->filter.simple) + filter_mb_row_simple(s, mb_y-1); + else + filter_mb_row(s, mb_y-1); + } + +skip_decode: + // if future frames don't use the updated probabilities, + // reset them to the values we saved + if (!s->update_probabilities) + s->prob[0] = s->prob[1]; + + // check if golden and altref are swapped + if (s->update_altref == VP56_FRAME_GOLDEN && + s->update_golden == VP56_FRAME_GOLDEN2) + FFSWAP(AVFrame *, s->framep[VP56_FRAME_GOLDEN], s->framep[VP56_FRAME_GOLDEN2]); + else { + if (s->update_altref != VP56_FRAME_NONE) + s->framep[VP56_FRAME_GOLDEN2] = s->framep[s->update_altref]; + + if (s->update_golden != VP56_FRAME_NONE) + s->framep[VP56_FRAME_GOLDEN] = s->framep[s->update_golden]; + } + + if (s->update_last) // move cur->prev + s->framep[VP56_FRAME_PREVIOUS] = s->framep[VP56_FRAME_CURRENT]; + + // release no longer referenced frames + for (i = 0; i < 4; i++) + if (s->frames[i].data[0] && + &s->frames[i] != s->framep[VP56_FRAME_CURRENT] && + &s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] && + &s->frames[i] != s->framep[VP56_FRAME_GOLDEN] && + &s->frames[i] != s->framep[VP56_FRAME_GOLDEN2]) + avctx->release_buffer(avctx, &s->frames[i]); + + if (!s->invisible) { + *(AVFrame*)data = *s->framep[VP56_FRAME_CURRENT]; + *data_size = sizeof(AVFrame); + } + + return avpkt->size; +} + +static av_cold int vp8_decode_init(AVCodecContext *avctx) +{ + VP8Context *s = avctx->priv_data; + + s->avctx = avctx; + avctx->pix_fmt = PIX_FMT_YUV420P; + + dsputil_init(&s->dsp, avctx); + ff_h264_pred_init(&s->hpc, CODEC_ID_VP8); + ff_vp8dsp_init(&s->vp8dsp); + + // intra pred needs edge emulation among other things + if (avctx->flags&CODEC_FLAG_EMU_EDGE) { + av_log(avctx, AV_LOG_ERROR, "Edge emulation not supported\n"); + return AVERROR_PATCHWELCOME; + } + + return 0; +} + +static av_cold int vp8_decode_free(AVCodecContext *avctx) +{ + vp8_decode_flush(avctx); + return 0; +} + +AVCodec vp8_decoder = { + "vp8", + AVMEDIA_TYPE_VIDEO, + CODEC_ID_VP8, + sizeof(VP8Context), + vp8_decode_init, + NULL, + vp8_decode_free, + vp8_decode_frame, + CODEC_CAP_DR1, + .flush = vp8_decode_flush, + .long_name = NULL_IF_CONFIG_SMALL("On2 VP8"), +}; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8data.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8data.h new file mode 100644 index 000000000..e8bd82da7 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8data.h @@ -0,0 +1,762 @@ +/** + * VP8 compatible video decoder + * + * Copyright (C) 2010 David Conrad + * Copyright (C) 2010 Ronald S. Bultje + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +// TODO: move these #define and enum to a better header... + +#define VP8_MAX_QUANT 127 + +enum dct_token { + DCT_0, + DCT_1, + DCT_2, + DCT_3, + DCT_4, + DCT_CAT1, + DCT_CAT2, + DCT_CAT3, + DCT_CAT4, + DCT_CAT5, + DCT_CAT6, + DCT_EOB, + + NUM_DCT_TOKENS +}; + +#include "h264pred.h" + +// used to signal 4x4 intra pred in luma MBs +#define MODE_I4x4 4 + +enum inter_mvmode { + VP8_MVMODE_NEAREST = MODE_I4x4 + 1, + VP8_MVMODE_NEAR, + VP8_MVMODE_ZERO, + VP8_MVMODE_NEW, + VP8_MVMODE_SPLIT +}; + +enum inter_submvmode { + VP8_SUBMVMODE_LEFT4X4, + VP8_SUBMVMODE_TOP4X4, + VP8_SUBMVMODE_ZERO4X4, + VP8_SUBMVMODE_NEW4X4 +}; + +enum inter_splitmvmode { + VP8_SPLITMVMODE_16x8 = 0, ///< 2 16x8 blocks (vertical) + VP8_SPLITMVMODE_8x16, ///< 2 8x16 blocks (horizontal) + VP8_SPLITMVMODE_8x8, ///< 2x2 blocks of 8x8px each + VP8_SPLITMVMODE_4x4, ///< 4x4 blocks of 4x4px each + VP8_SPLITMVMODE_NONE, ///< (only used in prediction) no split MVs +}; + +static const uint8_t vp8_pred4x4_mode[] = +{ + [DC_PRED8x8] = DC_PRED, + [VERT_PRED8x8] = VERT_PRED, + [HOR_PRED8x8] = HOR_PRED, + [PLANE_PRED8x8] = TM_VP8_PRED, +}; + +static const int8_t vp8_pred16x16_tree_intra[4][2] = +{ + { -MODE_I4x4, 1 }, // '0' + { 2, 3 }, + { -DC_PRED8x8, -VERT_PRED8x8 }, // '100', '101' + { -HOR_PRED8x8, -PLANE_PRED8x8 }, // '110', '111' +}; + +static const int8_t vp8_pred16x16_tree_inter[4][2] = +{ + { -DC_PRED8x8, 1 }, // '0' + { 2, 3 }, + { -VERT_PRED8x8, -HOR_PRED8x8 }, // '100', '101' + { -PLANE_PRED8x8, -MODE_I4x4 }, // '110', '111' +}; + +static const int vp8_mode_contexts[6][4] = { + { 7, 1, 1, 143 }, + { 14, 18, 14, 107 }, + { 135, 64, 57, 68 }, + { 60, 56, 128, 65 }, + { 159, 134, 128, 34 }, + { 234, 188, 128, 28 }, +}; + +static const int8_t vp8_pred16x16_tree_mvinter[4][2] = { + { -VP8_MVMODE_ZERO, 1 }, // '0' + { -VP8_MVMODE_NEAREST, 2 }, // '10' + { -VP8_MVMODE_NEAR, 3 }, // '110' + { -VP8_MVMODE_NEW, -VP8_MVMODE_SPLIT } // '1110', '1111' +}; + +static const int8_t vp8_small_mvtree[7][2] = { + { 1, 4 }, + { 2, 3 }, + { -0, -1 }, // '000', '001' + { -2, -3 }, // '010', '011' + { 5, 6 }, + { -4, -5 }, // '100', '101' + { -6, -7 } // '110', '111' +}; + +static const uint8_t vp8_mbsplits[5][16] = { + { 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1 }, + { 0, 0, 1, 1, 0, 0, 1, 1, + 0, 0, 1, 1, 0, 0, 1, 1 }, + { 0, 0, 1, 1, 0, 0, 1, 1, + 2, 2, 3, 3, 2, 2, 3, 3 }, + { 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15 }, + { 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 } +}; + +static const uint8_t vp8_mbfirstidx[4][16] = { + { 0, 8 }, { 0, 2 }, { 0, 2, 8, 10 }, + { 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15 } +}; + +static const int8_t vp8_mbsplit_tree[3][2] = { + { -VP8_SPLITMVMODE_4x4, 1 }, // '0' - 16 individual MVs + { -VP8_SPLITMVMODE_8x8, 2 }, // '10' - quarter-based MVs + { -VP8_SPLITMVMODE_16x8, // '110' - top/bottom MVs + -VP8_SPLITMVMODE_8x16 } // '111' - left/right MVs +}; +static const uint8_t vp8_mbsplit_count[4] = { 2, 2, 4, 16 }; +static const uint8_t vp8_mbsplit_prob[3] = { 110, 111, 150 }; + +static const uint8_t vp8_submv_prob[5][3] = { + { 147, 136, 18 }, + { 106, 145, 1 }, + { 179, 121, 1 }, + { 223, 1, 34 }, + { 208, 1, 1 } +}; + +static const int8_t vp8_submv_ref_tree[3][2] = { + { -VP8_SUBMVMODE_LEFT4X4, 1 }, // '0' + { -VP8_SUBMVMODE_TOP4X4, 2 }, // '10' + { -VP8_SUBMVMODE_ZERO4X4, -VP8_SUBMVMODE_NEW4X4 } // '110', '111' +}; + +static const uint8_t vp8_pred16x16_prob_intra[4] = { 145, 156, 163, 128 }; +static const uint8_t vp8_pred16x16_prob_inter[4] = { 112, 86, 140, 37 }; + +static const int8_t vp8_pred4x4_tree[9][2] = +{ + { -DC_PRED, 1 }, // '0' + { -TM_VP8_PRED, 2 }, // '10' + { -VERT_PRED, 3 }, // '110' + { 4, 6 }, + { -HOR_PRED, 5 }, // '11100' + { -DIAG_DOWN_RIGHT_PRED, -VERT_RIGHT_PRED }, // '111010', '111011' + { -DIAG_DOWN_LEFT_PRED, 7 }, // '11110' + { -VERT_LEFT_PRED, 8 }, // '111110' + { -HOR_DOWN_PRED, -HOR_UP_PRED }, // '1111110', '1111111' +}; + +static const int8_t vp8_pred8x8c_tree[3][2] = +{ + { -DC_PRED8x8, 1 }, // '0' + { -VERT_PRED8x8, 2 }, // '10 + { -HOR_PRED8x8, -PLANE_PRED8x8 }, // '110', '111' +}; + +static const uint8_t vp8_pred8x8c_prob_intra[3] = { 142, 114, 183 }; +static const uint8_t vp8_pred8x8c_prob_inter[3] = { 162, 101, 204 }; + +static const uint8_t vp8_pred4x4_prob_inter[9] = +{ + 120, 90, 79, 133, 87, 85, 80, 111, 151 +}; + +static const uint8_t vp8_pred4x4_prob_intra[10][10][9] = +{ + { + { 39, 53, 200, 87, 26, 21, 43, 232, 171 }, + { 56, 34, 51, 104, 114, 102, 29, 93, 77 }, + { 88, 88, 147, 150, 42, 46, 45, 196, 205 }, + { 107, 54, 32, 26, 51, 1, 81, 43, 31 }, + { 39, 28, 85, 171, 58, 165, 90, 98, 64 }, + { 34, 22, 116, 206, 23, 34, 43, 166, 73 }, + { 34, 19, 21, 102, 132, 188, 16, 76, 124 }, + { 68, 25, 106, 22, 64, 171, 36, 225, 114 }, + { 62, 18, 78, 95, 85, 57, 50, 48, 51 }, + { 43, 97, 183, 117, 85, 38, 35, 179, 61 }, + }, + { + { 112, 113, 77, 85, 179, 255, 38, 120, 114 }, + { 40, 42, 1, 196, 245, 209, 10, 25, 109 }, + { 193, 101, 35, 159, 215, 111, 89, 46, 111 }, + { 100, 80, 8, 43, 154, 1, 51, 26, 71 }, + { 88, 43, 29, 140, 166, 213, 37, 43, 154 }, + { 61, 63, 30, 155, 67, 45, 68, 1, 209 }, + { 41, 40, 5, 102, 211, 183, 4, 1, 221 }, + { 142, 78, 78, 16, 255, 128, 34, 197, 171 }, + { 51, 50, 17, 168, 209, 192, 23, 25, 82 }, + { 60, 148, 31, 172, 219, 228, 21, 18, 111 }, + }, + { + { 175, 69, 143, 80, 85, 82, 72, 155, 103 }, + { 56, 58, 10, 171, 218, 189, 17, 13, 152 }, + { 231, 120, 48, 89, 115, 113, 120, 152, 112 }, + { 144, 71, 10, 38, 171, 213, 144, 34, 26 }, + { 114, 26, 17, 163, 44, 195, 21, 10, 173 }, + { 121, 24, 80, 195, 26, 62, 44, 64, 85 }, + { 63, 20, 8, 114, 114, 208, 12, 9, 226 }, + { 170, 46, 55, 19, 136, 160, 33, 206, 71 }, + { 81, 40, 11, 96, 182, 84, 29, 16, 36 }, + { 152, 179, 64, 126, 170, 118, 46, 70, 95 }, + }, + { + { 75, 79, 123, 47, 51, 128, 81, 171, 1 }, + { 57, 17, 5, 71, 102, 57, 53, 41, 49 }, + { 125, 98, 42, 88, 104, 85, 117, 175, 82 }, + { 115, 21, 2, 10, 102, 255, 166, 23, 6 }, + { 38, 33, 13, 121, 57, 73, 26, 1, 85 }, + { 41, 10, 67, 138, 77, 110, 90, 47, 114 }, + { 57, 18, 10, 102, 102, 213, 34, 20, 43 }, + { 101, 29, 16, 10, 85, 128, 101, 196, 26 }, + { 117, 20, 15, 36, 163, 128, 68, 1, 26 }, + { 95, 84, 53, 89, 128, 100, 113, 101, 45 }, + }, + { + { 63, 59, 90, 180, 59, 166, 93, 73, 154 }, + { 40, 40, 21, 116, 143, 209, 34, 39, 175 }, + { 138, 31, 36, 171, 27, 166, 38, 44, 229 }, + { 57, 46, 22, 24, 128, 1, 54, 17, 37 }, + { 47, 15, 16, 183, 34, 223, 49, 45, 183 }, + { 46, 17, 33, 183, 6, 98, 15, 32, 183 }, + { 40, 3, 9, 115, 51, 192, 18, 6, 223 }, + { 65, 32, 73, 115, 28, 128, 23, 128, 205 }, + { 87, 37, 9, 115, 59, 77, 64, 21, 47 }, + { 67, 87, 58, 169, 82, 115, 26, 59, 179 }, + }, + { + { 54, 57, 112, 184, 5, 41, 38, 166, 213 }, + { 30, 34, 26, 133, 152, 116, 10, 32, 134 }, + { 104, 55, 44, 218, 9, 54, 53, 130, 226 }, + { 75, 32, 12, 51, 192, 255, 160, 43, 51 }, + { 39, 19, 53, 221, 26, 114, 32, 73, 255 }, + { 31, 9, 65, 234, 2, 15, 1, 118, 73 }, + { 56, 21, 23, 111, 59, 205, 45, 37, 192 }, + { 88, 31, 35, 67, 102, 85, 55, 186, 85 }, + { 55, 38, 70, 124, 73, 102, 1, 34, 98 }, + { 64, 90, 70, 205, 40, 41, 23, 26, 57 }, + }, + { + { 86, 40, 64, 135, 148, 224, 45, 183, 128 }, + { 22, 26, 17, 131, 240, 154, 14, 1, 209 }, + { 164, 50, 31, 137, 154, 133, 25, 35, 218 }, + { 83, 12, 13, 54, 192, 255, 68, 47, 28 }, + { 45, 16, 21, 91, 64, 222, 7, 1, 197 }, + { 56, 21, 39, 155, 60, 138, 23, 102, 213 }, + { 18, 11, 7, 63, 144, 171, 4, 4, 246 }, + { 85, 26, 85, 85, 128, 128, 32, 146, 171 }, + { 35, 27, 10, 146, 174, 171, 12, 26, 128 }, + { 51, 103, 44, 131, 131, 123, 31, 6, 158 }, + }, + { + { 68, 45, 128, 34, 1, 47, 11, 245, 171 }, + { 62, 17, 19, 70, 146, 85, 55, 62, 70 }, + { 102, 61, 71, 37, 34, 53, 31, 243, 192 }, + { 75, 15, 9, 9, 64, 255, 184, 119, 16 }, + { 37, 43, 37, 154, 100, 163, 85, 160, 1 }, + { 63, 9, 92, 136, 28, 64, 32, 201, 85 }, + { 56, 8, 17, 132, 137, 255, 55, 116, 128 }, + { 86, 6, 28, 5, 64, 255, 25, 248, 1 }, + { 58, 15, 20, 82, 135, 57, 26, 121, 40 }, + { 69, 60, 71, 38, 73, 119, 28, 222, 37 }, + }, + { + { 101, 75, 128, 139, 118, 146, 116, 128, 85 }, + { 56, 41, 15, 176, 236, 85, 37, 9, 62 }, + { 190, 80, 35, 99, 180, 80, 126, 54, 45 }, + { 146, 36, 19, 30, 171, 255, 97, 27, 20 }, + { 71, 30, 17, 119, 118, 255, 17, 18, 138 }, + { 101, 38, 60, 138, 55, 70, 43, 26, 142 }, + { 32, 41, 20, 117, 151, 142, 20, 21, 163 }, + { 138, 45, 61, 62, 219, 1, 81, 188, 64 }, + { 112, 19, 12, 61, 195, 128, 48, 4, 24 }, + { 85, 126, 47, 87, 176, 51, 41, 20, 32 }, + }, + { + { 66, 102, 167, 99, 74, 62, 40, 234, 128 }, + { 41, 53, 9, 178, 241, 141, 26, 8, 107 }, + { 134, 183, 89, 137, 98, 101, 106, 165, 148 }, + { 104, 79, 12, 27, 217, 255, 87, 17, 7 }, + { 74, 43, 26, 146, 73, 166, 49, 23, 157 }, + { 65, 38, 105, 160, 51, 52, 31, 115, 128 }, + { 47, 41, 14, 110, 182, 183, 21, 17, 194 }, + { 87, 68, 71, 44, 114, 51, 15, 186, 23 }, + { 66, 45, 25, 102, 197, 189, 23, 18, 22 }, + { 72, 187, 100, 130, 157, 111, 32, 75, 80 }, + }, +}; + +static const int8_t vp8_segmentid_tree[][2] = +{ + { 1, 2 }, + { -0, -1 }, // '00', '01' + { -2, -3 }, // '10', '11' +}; + +static const uint8_t vp8_coeff_band[16] = +{ + 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7 +}; + +static const int8_t vp8_coeff_tree[NUM_DCT_TOKENS-1][2] = +{ + { -DCT_EOB, 1 }, // '0' + { -DCT_0, 2 }, // '10' + { -DCT_1, 3 }, // '110' + { 4, 6 }, + { -DCT_2, 5 }, // '11100' + { -DCT_3, -DCT_4 }, // '111010', '111011' + { 7, 8 }, + { -DCT_CAT1, -DCT_CAT2 }, // '111100', '111101' + { 9, 10 }, + { -DCT_CAT3, -DCT_CAT4 }, // '1111100', '1111101' + { -DCT_CAT5, -DCT_CAT6 }, // '1111110', '1111111' +}; + +static const uint8_t vp8_dct_cat1_prob[] = { 159, 0 }; +static const uint8_t vp8_dct_cat2_prob[] = { 165, 145, 0 }; +static const uint8_t vp8_dct_cat3_prob[] = { 173, 148, 140, 0 }; +static const uint8_t vp8_dct_cat4_prob[] = { 176, 155, 140, 135, 0 }; +static const uint8_t vp8_dct_cat5_prob[] = { 180, 157, 141, 134, 130, 0 }; +static const uint8_t vp8_dct_cat6_prob[] = { 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0 }; + +static const uint8_t * const vp8_dct_cat_prob[6] = +{ + vp8_dct_cat1_prob, + vp8_dct_cat2_prob, + vp8_dct_cat3_prob, + vp8_dct_cat4_prob, + vp8_dct_cat5_prob, + vp8_dct_cat6_prob, +}; + +static const uint8_t vp8_dct_cat_offset[6] = { 5, 7, 11, 19, 35, 67 }; + +static const uint8_t vp8_token_default_probs[4][8][3][NUM_DCT_TOKENS-1] = +{ + { + { + { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }, + { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }, + { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }, + }, + { + { 253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128 }, + { 189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128 }, + { 106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128 }, + }, + { + { 1, 98, 248, 255, 236, 226, 255, 255, 128, 128, 128 }, + { 181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128 }, + { 78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128 }, + }, + { + { 1, 185, 249, 255, 243, 255, 128, 128, 128, 128, 128 }, + { 184, 150, 247, 255, 236, 224, 128, 128, 128, 128, 128 }, + { 77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128 }, + }, + { + { 1, 101, 251, 255, 241, 255, 128, 128, 128, 128, 128 }, + { 170, 139, 241, 252, 236, 209, 255, 255, 128, 128, 128 }, + { 37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128 }, + }, + { + { 1, 204, 254, 255, 245, 255, 128, 128, 128, 128, 128 }, + { 207, 160, 250, 255, 238, 128, 128, 128, 128, 128, 128 }, + { 102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128 }, + }, + { + { 1, 152, 252, 255, 240, 255, 128, 128, 128, 128, 128 }, + { 177, 135, 243, 255, 234, 225, 128, 128, 128, 128, 128 }, + { 80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128 }, + }, + { + { 1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 }, + { 246, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 }, + { 255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }, + }, + }, + { + { + { 198, 35, 237, 223, 193, 187, 162, 160, 145, 155, 62 }, + { 131, 45, 198, 221, 172, 176, 220, 157, 252, 221, 1 }, + { 68, 47, 146, 208, 149, 167, 221, 162, 255, 223, 128 }, + }, + { + { 1, 149, 241, 255, 221, 224, 255, 255, 128, 128, 128 }, + { 184, 141, 234, 253, 222, 220, 255, 199, 128, 128, 128 }, + { 81, 99, 181, 242, 176, 190, 249, 202, 255, 255, 128 }, + }, + { + { 1, 129, 232, 253, 214, 197, 242, 196, 255, 255, 128 }, + { 99, 121, 210, 250, 201, 198, 255, 202, 128, 128, 128 }, + { 23, 91, 163, 242, 170, 187, 247, 210, 255, 255, 128 }, + }, + { + { 1, 200, 246, 255, 234, 255, 128, 128, 128, 128, 128 }, + { 109, 178, 241, 255, 231, 245, 255, 255, 128, 128, 128 }, + { 44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128 }, + }, + { + { 1, 132, 239, 251, 219, 209, 255, 165, 128, 128, 128 }, + { 94, 136, 225, 251, 218, 190, 255, 255, 128, 128, 128 }, + { 22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128 }, + }, + { + { 1, 182, 249, 255, 232, 235, 128, 128, 128, 128, 128 }, + { 124, 143, 241, 255, 227, 234, 128, 128, 128, 128, 128 }, + { 35, 77, 181, 251, 193, 211, 255, 205, 128, 128, 128 }, + }, + { + { 1, 157, 247, 255, 236, 231, 255, 255, 128, 128, 128 }, + { 121, 141, 235, 255, 225, 227, 255, 255, 128, 128, 128 }, + { 45, 99, 188, 251, 195, 217, 255, 224, 128, 128, 128 }, + }, + { + { 1, 1, 251, 255, 213, 255, 128, 128, 128, 128, 128 }, + { 203, 1, 248, 255, 255, 128, 128, 128, 128, 128, 128 }, + { 137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128 }, + }, + }, + { + { + { 253, 9, 248, 251, 207, 208, 255, 192, 128, 128, 128 }, + { 175, 13, 224, 243, 193, 185, 249, 198, 255, 255, 128 }, + { 73, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128 }, + }, + { + { 1, 95, 247, 253, 212, 183, 255, 255, 128, 128, 128 }, + { 239, 90, 244, 250, 211, 209, 255, 255, 128, 128, 128 }, + { 155, 77, 195, 248, 188, 195, 255, 255, 128, 128, 128 }, + }, + { + { 1, 24, 239, 251, 218, 219, 255, 205, 128, 128, 128 }, + { 201, 51, 219, 255, 196, 186, 128, 128, 128, 128, 128 }, + { 69, 46, 190, 239, 201, 218, 255, 228, 128, 128, 128 }, + }, + { + { 1, 191, 251, 255, 255, 128, 128, 128, 128, 128, 128 }, + { 223, 165, 249, 255, 213, 255, 128, 128, 128, 128, 128 }, + { 141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128 }, + }, + { + { 1, 16, 248, 255, 255, 128, 128, 128, 128, 128, 128 }, + { 190, 36, 230, 255, 236, 255, 128, 128, 128, 128, 128 }, + { 149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 }, + }, + { + { 1, 226, 255, 128, 128, 128, 128, 128, 128, 128, 128 }, + { 247, 192, 255, 128, 128, 128, 128, 128, 128, 128, 128 }, + { 240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128 }, + }, + { + { 1, 134, 252, 255, 255, 128, 128, 128, 128, 128, 128 }, + { 213, 62, 250, 255, 255, 128, 128, 128, 128, 128, 128 }, + { 55, 93, 255, 128, 128, 128, 128, 128, 128, 128, 128 }, + }, + { + { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }, + { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }, + { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }, + }, + }, + { + { + { 202, 24, 213, 235, 186, 191, 220, 160, 240, 175, 255 }, + { 126, 38, 182, 232, 169, 184, 228, 174, 255, 187, 128 }, + { 61, 46, 138, 219, 151, 178, 240, 170, 255, 216, 128 }, + }, + { + { 1, 112, 230, 250, 199, 191, 247, 159, 255, 255, 128 }, + { 166, 109, 228, 252, 211, 215, 255, 174, 128, 128, 128 }, + { 39, 77, 162, 232, 172, 180, 245, 178, 255, 255, 128 }, + }, + { + { 1, 52, 220, 246, 198, 199, 249, 220, 255, 255, 128 }, + { 124, 74, 191, 243, 183, 193, 250, 221, 255, 255, 128 }, + { 24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128 }, + }, + { + { 1, 182, 225, 249, 219, 240, 255, 224, 128, 128, 128 }, + { 149, 150, 226, 252, 216, 205, 255, 171, 128, 128, 128 }, + { 28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128 }, + }, + { + { 1, 81, 230, 252, 204, 203, 255, 192, 128, 128, 128 }, + { 123, 102, 209, 247, 188, 196, 255, 233, 128, 128, 128 }, + { 20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128 }, + }, + { + { 1, 222, 248, 255, 216, 213, 128, 128, 128, 128, 128 }, + { 168, 175, 246, 252, 235, 205, 255, 255, 128, 128, 128 }, + { 47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128 }, + }, + { + { 1, 121, 236, 253, 212, 214, 255, 255, 128, 128, 128 }, + { 141, 84, 213, 252, 201, 202, 255, 219, 128, 128, 128 }, + { 42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128 }, + }, + { + { 1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 }, + { 244, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 }, + { 238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 }, + }, + }, +}; + +static const uint8_t vp8_token_update_probs[4][8][3][NUM_DCT_TOKENS-1] = +{ + { + { + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255 }, + { 250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255 }, + { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + }, + { + { + { 217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255 }, + { 234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255 }, + }, + { + { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + }, + { + { + { 186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255 }, + { 251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255 }, + }, + { + { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + }, + { + { + { 248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255 }, + { 248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + { + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }, + }, + }, +}; + +// fixme: copied from h264data.h +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 vp8_dc_qlookup[VP8_MAX_QUANT+1] = +{ + 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 17, + 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 25, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 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, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 91, 93, 95, 96, 98, 100, 101, 102, 104, 106, 108, 110, 112, 114, 116, 118, + 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 143, 145, 148, 151, 154, 157, +}; + +static const uint16_t vp8_ac_qlookup[VP8_MAX_QUANT+1] = +{ + 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, 60, 62, 64, 66, 68, 70, 72, 74, 76, + 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, + 110, 112, 114, 116, 119, 122, 125, 128, 131, 134, 137, 140, 143, 146, 149, 152, + 155, 158, 161, 164, 167, 170, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209, + 213, 217, 221, 225, 229, 234, 239, 245, 249, 254, 259, 264, 269, 274, 279, 284, +}; + +static const uint8_t vp8_mv_update_prob[2][19] = { + { 237, + 246, + 253, 253, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 250, 250, 252, 254, 254 }, + { 231, + 243, + 245, 253, 254, 254, 254, 254, 254, + 254, 254, 254, 254, 254, 251, 251, 254, 254, 254 } +}; + +static const uint8_t vp8_mv_default_prob[2][19] = { + { 162, + 128, + 225, 146, 172, 147, 214, 39, 156, + 128, 129, 132, 75, 145, 178, 206, 239, 254, 254 }, + { 164, + 128, + 204, 170, 119, 235, 140, 230, 228, + 128, 130, 130, 74, 148, 180, 203, 236, 254, 254 } +}; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8dsp.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8dsp.c new file mode 100644 index 000000000..0d2dc01e7 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8dsp.c @@ -0,0 +1,471 @@ +/** + * VP8 compatible video decoder + * + * Copyright (C) 2010 David Conrad + * Copyright (C) 2010 Ronald S. Bultje + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "dsputil.h" +#include "vp8dsp.h" + +// TODO: Maybe add dequant +static void vp8_luma_dc_wht_c(DCTELEM block[4][4][16], DCTELEM dc[16]) +{ + int i, t0, t1, t2, t3; + + for (i = 0; i < 4; i++) { + t0 = dc[0*4+i] + dc[3*4+i]; + t1 = dc[1*4+i] + dc[2*4+i]; + t2 = dc[1*4+i] - dc[2*4+i]; + t3 = dc[0*4+i] - dc[3*4+i]; + + dc[0*4+i] = t0 + t1; + dc[1*4+i] = t3 + t2; + dc[2*4+i] = t0 - t1; + dc[3*4+i] = t3 - t2; + } + + for (i = 0; i < 4; i++) { + t0 = dc[i*4+0] + dc[i*4+3] + 3; // rounding + t1 = dc[i*4+1] + dc[i*4+2]; + t2 = dc[i*4+1] - dc[i*4+2]; + t3 = dc[i*4+0] - dc[i*4+3] + 3; // rounding + + *block[i][0] = (t0 + t1) >> 3; + *block[i][1] = (t3 + t2) >> 3; + *block[i][2] = (t0 - t1) >> 3; + *block[i][3] = (t3 - t2) >> 3; + } +} + + +#define MUL_20091(a) ((((a)*20091) >> 16) + (a)) +#define MUL_35468(a) (((a)*35468) >> 16) + +static void vp8_idct_add_c(uint8_t *dst, DCTELEM block[16], int stride) +{ + int i, t0, t1, t2, t3; + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + DCTELEM tmp[16]; + + for (i = 0; i < 4; i++) { + t0 = block[0*4+i] + block[2*4+i]; + t1 = block[0*4+i] - block[2*4+i]; + t2 = MUL_35468(block[1*4+i]) - MUL_20091(block[3*4+i]); + t3 = MUL_20091(block[1*4+i]) + MUL_35468(block[3*4+i]); + + tmp[i*4+0] = t0 + t3; + tmp[i*4+1] = t1 + t2; + tmp[i*4+2] = t1 - t2; + tmp[i*4+3] = t0 - t3; + } + + for (i = 0; i < 4; i++) { + t0 = tmp[0*4+i] + tmp[2*4+i]; + t1 = tmp[0*4+i] - tmp[2*4+i]; + t2 = MUL_35468(tmp[1*4+i]) - MUL_20091(tmp[3*4+i]); + t3 = MUL_20091(tmp[1*4+i]) + MUL_35468(tmp[3*4+i]); + + dst[0] = cm[dst[0] + ((t0 + t3 + 4) >> 3)]; + dst[1] = cm[dst[1] + ((t1 + t2 + 4) >> 3)]; + dst[2] = cm[dst[2] + ((t1 - t2 + 4) >> 3)]; + dst[3] = cm[dst[3] + ((t0 - t3 + 4) >> 3)]; + dst += stride; + } +} + +static void vp8_idct_dc_add_c(uint8_t *dst, DCTELEM block[16], int stride) +{ + int i, dc = (block[0] + 4) >> 3; + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP + dc; + + for (i = 0; i < 4; i++) { + dst[0] = cm[dst[0]]; + dst[1] = cm[dst[1]]; + dst[2] = cm[dst[2]]; + dst[3] = cm[dst[3]]; + dst += stride; + } +} + + +// because I like only having two parameters to pass functions... +#define LOAD_PIXELS\ + int av_unused p3 = p[-4*stride];\ + int av_unused p2 = p[-3*stride];\ + int av_unused p1 = p[-2*stride];\ + int av_unused p0 = p[-1*stride];\ + int av_unused q0 = p[ 0*stride];\ + int av_unused q1 = p[ 1*stride];\ + int av_unused q2 = p[ 2*stride];\ + int av_unused q3 = p[ 3*stride]; + +#define clip_int8(n) (cm[n+0x80]-0x80) + +static av_always_inline void filter_common(uint8_t *p, int stride, int is4tap) +{ + LOAD_PIXELS + int a, f1, f2; + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + + a = 3*(q0 - p0); + + if (is4tap) + a += clip_int8(p1 - q1); + + a = clip_int8(a); + + // We deviate from the spec here with c(a+3) >> 3 + // since that's what libvpx does. + f1 = FFMIN(a+4, 127) >> 3; + f2 = FFMIN(a+3, 127) >> 3; + + // Despite what the spec says, we do need to clamp here to + // be bitexact with libvpx. + p[-1*stride] = cm[p0 + f2]; + p[ 0*stride] = cm[q0 - f1]; + + // only used for _inner on blocks without high edge variance + if (!is4tap) { + a = (f1+1)>>1; + p[-2*stride] = cm[p1 + a]; + p[ 1*stride] = cm[q1 - a]; + } +} + +static av_always_inline int simple_limit(uint8_t *p, int stride, int flim) +{ + LOAD_PIXELS + return 2*FFABS(p0-q0) + (FFABS(p1-q1) >> 1) <= flim; +} + +/** + * E - limit at the macroblock edge + * I - limit for interior difference + */ +static av_always_inline int normal_limit(uint8_t *p, int stride, int E, int I) +{ + LOAD_PIXELS + return simple_limit(p, stride, E) + && FFABS(p3-p2) <= I && FFABS(p2-p1) <= I && FFABS(p1-p0) <= I + && FFABS(q3-q2) <= I && FFABS(q2-q1) <= I && FFABS(q1-q0) <= I; +} + +// high edge variance +static av_always_inline int hev(uint8_t *p, int stride, int thresh) +{ + LOAD_PIXELS + return FFABS(p1-p0) > thresh || FFABS(q1-q0) > thresh; +} + +static av_always_inline void filter_mbedge(uint8_t *p, int stride) +{ + int a0, a1, a2, w; + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + + LOAD_PIXELS + + w = clip_int8(p1-q1); + w = clip_int8(w + 3*(q0-p0)); + + a0 = (27*w + 63) >> 7; + a1 = (18*w + 63) >> 7; + a2 = ( 9*w + 63) >> 7; + + p[-3*stride] = cm[p2 + a2]; + p[-2*stride] = cm[p1 + a1]; + p[-1*stride] = cm[p0 + a0]; + p[ 0*stride] = cm[q0 - a0]; + p[ 1*stride] = cm[q1 - a1]; + p[ 2*stride] = cm[q2 - a2]; +} + +#define LOOP_FILTER(dir, size, stridea, strideb) \ +static void vp8_ ## dir ## _loop_filter ## size ## _c(uint8_t *dst, int stride,\ + int flim_E, int flim_I, int hev_thresh)\ +{\ + int i;\ +\ + for (i = 0; i < size; i++)\ + if (normal_limit(dst+i*stridea, strideb, flim_E, flim_I)) {\ + if (hev(dst+i*stridea, strideb, hev_thresh))\ + filter_common(dst+i*stridea, strideb, 1);\ + else\ + filter_mbedge(dst+i*stridea, strideb);\ + }\ +}\ +\ +static void vp8_ ## dir ## _loop_filter ## size ## _inner_c(uint8_t *dst, int stride,\ + int flim_E, int flim_I, int hev_thresh)\ +{\ + int i;\ +\ + for (i = 0; i < size; i++)\ + if (normal_limit(dst+i*stridea, strideb, flim_E, flim_I)) {\ + int hv = hev(dst+i*stridea, strideb, hev_thresh);\ + if (hv) \ + filter_common(dst+i*stridea, strideb, 1);\ + else \ + filter_common(dst+i*stridea, strideb, 0);\ + }\ +} + +LOOP_FILTER(v, 16, 1, stride) +LOOP_FILTER(h, 16, stride, 1) +LOOP_FILTER(v, 8, 1, stride) +LOOP_FILTER(h, 8, stride, 1) + +static void vp8_v_loop_filter_simple_c(uint8_t *dst, int stride, int flim) +{ + int i; + + for (i = 0; i < 16; i++) + if (simple_limit(dst+i, stride, flim)) + filter_common(dst+i, stride, 1); +} + +static void vp8_h_loop_filter_simple_c(uint8_t *dst, int stride, int flim) +{ + int i; + + for (i = 0; i < 16; i++) + if (simple_limit(dst+i*stride, 1, flim)) + filter_common(dst+i*stride, 1, 1); +} + +static const uint8_t subpel_filters[7][6] = { + { 0, 6, 123, 12, 1, 0 }, + { 2, 11, 108, 36, 8, 1 }, + { 0, 9, 93, 50, 6, 0 }, + { 3, 16, 77, 77, 16, 3 }, + { 0, 6, 50, 93, 9, 0 }, + { 1, 8, 36, 108, 11, 2 }, + { 0, 1, 12, 123, 6, 0 }, +}; + +#define PUT_PIXELS(WIDTH) \ +static void put_vp8_pixels ## WIDTH ##_c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int x, int y) { \ + int i; \ + for (i = 0; i < h; i++, dst+= dststride, src+= srcstride) { \ + memcpy(dst, src, WIDTH); \ + } \ +} + +PUT_PIXELS(16) +PUT_PIXELS(8) +PUT_PIXELS(4) + +#define FILTER_6TAP(src, F, stride) \ + cm[(F[2]*src[x+0*stride] - F[1]*src[x-1*stride] + F[0]*src[x-2*stride] + \ + F[3]*src[x+1*stride] - F[4]*src[x+2*stride] + F[5]*src[x+3*stride] + 64) >> 7] + +#define FILTER_4TAP(src, F, stride) \ + cm[(F[2]*src[x+0*stride] - F[1]*src[x-1*stride] + \ + F[3]*src[x+1*stride] - F[4]*src[x+2*stride] + 64) >> 7] + +#define VP8_EPEL_H(SIZE, FILTER, FILTERNAME) \ +static void put_vp8_epel ## SIZE ## _ ## FILTERNAME ## _c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int mx, int my) \ +{ \ + const uint8_t *filter = subpel_filters[mx-1]; \ + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \ + int x, y; \ +\ + for (y = 0; y < h; y++) { \ + for (x = 0; x < SIZE; x++) \ + dst[x] = FILTER(src, filter, 1); \ + dst += dststride; \ + src += srcstride; \ + } \ +} +#define VP8_EPEL_V(SIZE, FILTER, FILTERNAME) \ +static void put_vp8_epel ## SIZE ## _ ## FILTERNAME ## _c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int mx, int my) \ +{ \ + const uint8_t *filter = subpel_filters[my-1]; \ + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \ + int x, y; \ +\ + for (y = 0; y < h; y++) { \ + for (x = 0; x < SIZE; x++) \ + dst[x] = FILTER(src, filter, srcstride); \ + dst += dststride; \ + src += srcstride; \ + } \ +} +#define VP8_EPEL_HV(SIZE, FILTERX, FILTERY, FILTERNAME) \ +static void put_vp8_epel ## SIZE ## _ ## FILTERNAME ## _c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int mx, int my) \ +{ \ + const uint8_t *filter = subpel_filters[mx-1]; \ + uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \ + int x, y; \ + uint8_t tmp_array[(2*SIZE+5)*SIZE]; \ + uint8_t *tmp = tmp_array; \ + src -= 2*srcstride; \ +\ + for (y = 0; y < h+5; y++) { \ + for (x = 0; x < SIZE; x++) \ + tmp[x] = FILTERX(src, filter, 1); \ + tmp += SIZE; \ + src += srcstride; \ + } \ +\ + tmp = tmp_array + 2*SIZE; \ + filter = subpel_filters[my-1]; \ +\ + for (y = 0; y < h; y++) { \ + for (x = 0; x < SIZE; x++) \ + dst[x] = FILTERY(tmp, filter, SIZE); \ + dst += dststride; \ + tmp += SIZE; \ + } \ +} + +VP8_EPEL_H(16, FILTER_4TAP, h4) +VP8_EPEL_H(8, FILTER_4TAP, h4) +VP8_EPEL_H(4, FILTER_4TAP, h4) +VP8_EPEL_H(16, FILTER_6TAP, h6) +VP8_EPEL_H(8, FILTER_6TAP, h6) +VP8_EPEL_H(4, FILTER_6TAP, h6) +VP8_EPEL_V(16, FILTER_4TAP, v4) +VP8_EPEL_V(8, FILTER_4TAP, v4) +VP8_EPEL_V(4, FILTER_4TAP, v4) +VP8_EPEL_V(16, FILTER_6TAP, v6) +VP8_EPEL_V(8, FILTER_6TAP, v6) +VP8_EPEL_V(4, FILTER_6TAP, v6) +VP8_EPEL_HV(16, FILTER_4TAP, FILTER_4TAP, h4v4) +VP8_EPEL_HV(8, FILTER_4TAP, FILTER_4TAP, h4v4) +VP8_EPEL_HV(4, FILTER_4TAP, FILTER_4TAP, h4v4) +VP8_EPEL_HV(16, FILTER_4TAP, FILTER_6TAP, h4v6) +VP8_EPEL_HV(8, FILTER_4TAP, FILTER_6TAP, h4v6) +VP8_EPEL_HV(4, FILTER_4TAP, FILTER_6TAP, h4v6) +VP8_EPEL_HV(16, FILTER_6TAP, FILTER_4TAP, h6v4) +VP8_EPEL_HV(8, FILTER_6TAP, FILTER_4TAP, h6v4) +VP8_EPEL_HV(4, FILTER_6TAP, FILTER_4TAP, h6v4) +VP8_EPEL_HV(16, FILTER_6TAP, FILTER_6TAP, h6v6) +VP8_EPEL_HV(8, FILTER_6TAP, FILTER_6TAP, h6v6) +VP8_EPEL_HV(4, FILTER_6TAP, FILTER_6TAP, h6v6) + +#define VP8_BILINEAR(SIZE) \ +static void put_vp8_bilinear ## SIZE ## _h_c(uint8_t *dst, int stride, uint8_t *src, int s2, int h, int mx, int my) \ +{ \ + int a = 8-mx, b = mx; \ + int x, y; \ +\ + for (y = 0; y < h; y++) { \ + for (x = 0; x < SIZE; x++) \ + dst[x] = (a*src[x] + b*src[x+1] + 4) >> 3; \ + dst += stride; \ + src += stride; \ + } \ +} \ +static void put_vp8_bilinear ## SIZE ## _v_c(uint8_t *dst, int stride, uint8_t *src, int s2, int h, int mx, int my) \ +{ \ + int c = 8-my, d = my; \ + int x, y; \ +\ + for (y = 0; y < h; y++) { \ + for (x = 0; x < SIZE; x++) \ + dst[x] = (c*src[x] + d*src[x+stride] + 4) >> 3; \ + dst += stride; \ + src += stride; \ + } \ +} \ +\ +static void put_vp8_bilinear ## SIZE ## _hv_c(uint8_t *dst, int stride, uint8_t *src, int s2, int h, int mx, int my) \ +{ \ + int a = 8-mx, b = mx; \ + int c = 8-my, d = my; \ + int x, y; \ + uint8_t tmp_array[(2*SIZE+1)*SIZE]; \ + uint8_t *tmp = tmp_array; \ +\ + for (y = 0; y < h+1; y++) { \ + for (x = 0; x < SIZE; x++) \ + tmp[x] = (a*src[x] + b*src[x+1] + 4) >> 3; \ + tmp += SIZE; \ + src += stride; \ + } \ +\ + tmp = tmp_array; \ +\ + for (y = 0; y < h; y++) { \ + for (x = 0; x < SIZE; x++) \ + dst[x] = (c*tmp[x] + d*tmp[x+SIZE] + 4) >> 3; \ + dst += stride; \ + tmp += SIZE; \ + } \ +} + +VP8_BILINEAR(16) +VP8_BILINEAR(8) +VP8_BILINEAR(4) + +#define VP8_MC_FUNC(IDX, SIZE) \ + dsp->put_vp8_epel_pixels_tab[IDX][0][0] = put_vp8_pixels ## SIZE ## _c; \ + dsp->put_vp8_epel_pixels_tab[IDX][0][1] = put_vp8_epel ## SIZE ## _h4_c; \ + dsp->put_vp8_epel_pixels_tab[IDX][0][2] = put_vp8_epel ## SIZE ## _h6_c; \ + dsp->put_vp8_epel_pixels_tab[IDX][1][0] = put_vp8_epel ## SIZE ## _v4_c; \ + dsp->put_vp8_epel_pixels_tab[IDX][1][1] = put_vp8_epel ## SIZE ## _h4v4_c; \ + dsp->put_vp8_epel_pixels_tab[IDX][1][2] = put_vp8_epel ## SIZE ## _h6v4_c; \ + dsp->put_vp8_epel_pixels_tab[IDX][2][0] = put_vp8_epel ## SIZE ## _v6_c; \ + dsp->put_vp8_epel_pixels_tab[IDX][2][1] = put_vp8_epel ## SIZE ## _h4v6_c; \ + dsp->put_vp8_epel_pixels_tab[IDX][2][2] = put_vp8_epel ## SIZE ## _h6v6_c + +#define VP8_BILINEAR_MC_FUNC(IDX, SIZE) \ + dsp->put_vp8_bilinear_pixels_tab[IDX][0][0] = put_vp8_pixels ## SIZE ## _c; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][0][1] = put_vp8_bilinear ## SIZE ## _h_c; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][0][2] = put_vp8_bilinear ## SIZE ## _h_c; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][1][0] = put_vp8_bilinear ## SIZE ## _v_c; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][1][1] = put_vp8_bilinear ## SIZE ## _hv_c; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][1][2] = put_vp8_bilinear ## SIZE ## _hv_c; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][2][0] = put_vp8_bilinear ## SIZE ## _v_c; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][2][1] = put_vp8_bilinear ## SIZE ## _hv_c; \ + dsp->put_vp8_bilinear_pixels_tab[IDX][2][2] = put_vp8_bilinear ## SIZE ## _hv_c + +av_cold void ff_vp8dsp_init(VP8DSPContext *dsp) +{ + dsp->vp8_luma_dc_wht = vp8_luma_dc_wht_c; + dsp->vp8_idct_add = vp8_idct_add_c; + dsp->vp8_idct_dc_add = vp8_idct_dc_add_c; + + dsp->vp8_v_loop_filter16 = vp8_v_loop_filter16_c; + dsp->vp8_h_loop_filter16 = vp8_h_loop_filter16_c; + dsp->vp8_v_loop_filter8 = vp8_v_loop_filter8_c; + dsp->vp8_h_loop_filter8 = vp8_h_loop_filter8_c; + + dsp->vp8_v_loop_filter16_inner = vp8_v_loop_filter16_inner_c; + dsp->vp8_h_loop_filter16_inner = vp8_h_loop_filter16_inner_c; + dsp->vp8_v_loop_filter8_inner = vp8_v_loop_filter8_inner_c; + dsp->vp8_h_loop_filter8_inner = vp8_h_loop_filter8_inner_c; + + dsp->vp8_v_loop_filter_simple = vp8_v_loop_filter_simple_c; + dsp->vp8_h_loop_filter_simple = vp8_h_loop_filter_simple_c; + + VP8_MC_FUNC(0, 16); + VP8_MC_FUNC(1, 8); + VP8_MC_FUNC(2, 4); + + VP8_BILINEAR_MC_FUNC(0, 16); + VP8_BILINEAR_MC_FUNC(1, 8); + VP8_BILINEAR_MC_FUNC(2, 4); + + if (HAVE_MMX) + ff_vp8dsp_init_x86(dsp); + if (HAVE_ALTIVEC) + ff_vp8dsp_init_altivec(dsp); +} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8dsp.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8dsp.h new file mode 100644 index 000000000..b660048cc --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/vp8dsp.h @@ -0,0 +1,72 @@ +/** + * VP8 compatible video decoder + * + * Copyright (C) 2010 David Conrad + * Copyright (C) 2010 Ronald S. Bultje + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef AVCODEC_VP8DSP_H +#define AVCODEC_VP8DSP_H + +#include "dsputil.h" + +typedef void (*vp8_mc_func)(uint8_t *dst/*align 8*/, int dstStride, uint8_t *src/*align 1*/, int srcStride, int h, int x, int y); + +typedef struct VP8DSPContext { + void (*vp8_luma_dc_wht)(DCTELEM block[4][4][16], DCTELEM dc[16]); + void (*vp8_idct_add)(uint8_t *dst, DCTELEM block[16], int stride); + void (*vp8_idct_dc_add)(uint8_t *dst, DCTELEM block[16], int stride); + + // loop filter applied to edges between macroblocks + void (*vp8_v_loop_filter16)(uint8_t *dst, int stride, int flim_E, int flim_I, int hev_thresh); + void (*vp8_h_loop_filter16)(uint8_t *dst, int stride, int flim_E, int flim_I, int hev_thresh); + void (*vp8_v_loop_filter8)(uint8_t *dst, int stride, int flim_E, int flim_I, int hev_thresh); + void (*vp8_h_loop_filter8)(uint8_t *dst, int stride, int flim_E, int flim_I, int hev_thresh); + + // loop filter applied to inner macroblock edges + void (*vp8_v_loop_filter16_inner)(uint8_t *dst, int stride, int flim_E, int flim_I, int hev_thresh); + void (*vp8_h_loop_filter16_inner)(uint8_t *dst, int stride, int flim_E, int flim_I, int hev_thresh); + void (*vp8_v_loop_filter8_inner)(uint8_t *dst, int stride, int flim_E, int flim_I, int hev_thresh); + void (*vp8_h_loop_filter8_inner)(uint8_t *dst, int stride, int flim_E, int flim_I, int hev_thresh); + + void (*vp8_v_loop_filter_simple)(uint8_t *dst, int stride, int flim); + void (*vp8_h_loop_filter_simple)(uint8_t *dst, int stride, int flim); + + /** + * first dimension: width>>3, height is assumed equal to width + * second dimension: 0 if no vertical interpolation is needed; + * 1 4-tap vertical interpolation filter (my & 1) + * 2 6-tap vertical interpolation filter (!(my & 1)) + * third dimension: same as second dimention, for horizontal interpolation + * so something like put_vp8_epel_pixels_tab[width>>3][2*!!my-(my&1)][2*!!mx-(mx&1)](..., mx, my) + */ + vp8_mc_func put_vp8_epel_pixels_tab[3][3][3]; + vp8_mc_func put_vp8_bilinear_pixels_tab[3][3][3]; +} VP8DSPContext; + +void ff_put_vp8_pixels16_c(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y); +void ff_put_vp8_pixels8_c(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y); +void ff_put_vp8_pixels4_c(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y); + +void ff_vp8dsp_init(VP8DSPContext *c); +void ff_vp8dsp_init_x86(VP8DSPContext *c); +void ff_vp8dsp_init_altivec(VP8DSPContext *c); + +#endif /* AVCODEC_VP8DSP_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/w32thread.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/w32thread.c index 565433491..f7a143064 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/w32thread.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/w32thread.c @@ -130,7 +130,7 @@ int avcodec_thread_init(AVCodecContext *s, int thread_count){ uint32_t threadid; s->thread_count= thread_count; -av_log(NULL, AV_LOG_INFO, "[w32thread] thread count = %d\n", thread_count); + if (thread_count <= 1) return 0; @@ -147,19 +147,17 @@ av_log(NULL, AV_LOG_INFO, "[w32thread] thread count = %d\n", thread_count); for(i=0; iexecute= avcodec_thread_execute; s->execute2= avcodec_thread_execute2; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wma.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wma.c index 65780459a..e2d153b83 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wma.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wma.c @@ -429,7 +429,7 @@ int ff_wma_end(AVCodecContext *avctx) /** * Decode an uncompressed coefficient. - * @param s codec context + * @param gb GetBitContext * @return the decoded coefficient */ unsigned int ff_wma_get_large_val(GetBitContext* gb) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wmadec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wmadec.c index a24256d45..5582a7236 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wmadec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wmadec.c @@ -804,10 +804,10 @@ static int wma_decode_frame(WMACodecContext *s, int16_t *samples) s->frame_len * sizeof(float)); } } else { - float *output[MAX_CHANNELS]; + const float *output[MAX_CHANNELS]; for (ch = 0; ch < MAX_CHANNELS; ch++) output[ch] = s->frame_out[ch]; - s->dsp.float_to_int16_interleave(samples, (const float **)output, n, incr); + s->dsp.float_to_int16_interleave(samples, output, n, incr); for(ch = 0; ch < incr; ch++) { /* prepare for next block */ memmove(&s->frame_out[ch][0], &s->frame_out[ch][n], n * sizeof(float)); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wmavoice.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wmavoice.c index 4ec17eb4f..2a58014da 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wmavoice.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wmavoice.c @@ -287,7 +287,7 @@ typedef struct { } WMAVoiceContext; /** - * Sets up the variable bit mode (VBM) tree from container extradata. + * Set up the variable bit mode (VBM) tree from container extradata. * @param gb bit I/O context. * The bit context (s->gb) should be loaded with byte 23-46 of the * container extradata (i.e. the ones containing the VBM tree). @@ -660,7 +660,7 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs, * overlap-add method (otherwise you get clicking-artifacts). * * @param s WMA Voice decoding context - * @param s fcb_type Frame (codebook) type + * @param fcb_type Frame (codebook) type * @param synth_pf input: the noisy speech signal, output: denoised speech * data; should be 16-byte aligned (for ASM purposes) * @param size size of the speech data @@ -744,6 +744,7 @@ static void wiener_denoise(WMAVoiceContext *s, int fcb_type, * @param samples Output buffer for filtered samples * @param size Buffer size of synth & samples * @param lpcs Generated LPCs used for speech synthesis + * @param zero_exc_pf destination for zero synthesis filter (16-byte aligned) * @param fcb_type Frame type (silence, hardcoded, AW-pulses or FCB-pulses) * @param pitch Pitch of the input signal */ @@ -1342,7 +1343,7 @@ static void synth_block_fcb_acb(WMAVoiceContext *s, GetBitContext *gb, wmavoice_ipol2_coeffs, 4, idx, 8, size); } else - av_memcpy_backptr(excitation, sizeof(float) * block_pitch, + av_memcpy_backptr((uint8_t *) excitation, sizeof(float) * block_pitch, sizeof(float) * size); } @@ -1901,7 +1902,7 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, void *data, if (*data_size < 480 * sizeof(float)) { av_log(ctx, AV_LOG_ERROR, - "Output buffer too small (%d given - %lu needed)\n", + "Output buffer too small (%d given - %zu needed)\n", *data_size, 480 * sizeof(float)); return -1; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wmv2dec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wmv2dec.c index a9bb80cae..c83f898d7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wmv2dec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/wmv2dec.c @@ -494,6 +494,7 @@ AVCodec wmv2_decoder = { wmv2_decode_end, ff_h263_decode_frame, CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, + .max_lowres = 3, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 8"), .pix_fmts= ff_pixfmt_list_420, }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/Makefile b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/Makefile index f4d0c847d..6d1a9c606 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/Makefile +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/Makefile @@ -9,7 +9,16 @@ YASM-OBJS-$(CONFIG_FFT) += x86/fft_mmx.o \ YASM-OBJS-$(CONFIG_GPL) += x86/h264_deblock_sse2.o \ x86/h264_idct_sse2.o \ +YASM-OBJS-$(CONFIG_H264DSP) += x86/h264_intrapred.o \ + +YASM-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_yasm.o + MMX-OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsdsp_mmx.o +MMX-OBJS-$(CONFIG_MP1FLOAT_DECODER) += x86/mpegaudiodec_mmx.o +MMX-OBJS-$(CONFIG_MP2FLOAT_DECODER) += x86/mpegaudiodec_mmx.o +MMX-OBJS-$(CONFIG_MP3FLOAT_DECODER) += x86/mpegaudiodec_mmx.o +MMX-OBJS-$(CONFIG_MP3ON4FLOAT_DECODER) += x86/mpegaudiodec_mmx.o +MMX-OBJS-$(CONFIG_MP3ADUFLOAT_DECODER) += x86/mpegaudiodec_mmx.o MMX-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_mmx.o MMX-OBJS-$(CONFIG_GPL) += x86/idct_mmx.o MMX-OBJS-$(CONFIG_LPC) += x86/lpc_mmx.o @@ -23,6 +32,8 @@ MMX-OBJS-$(CONFIG_VP6_DECODER) += x86/vp3dsp_mmx.o \ x86/vp3dsp_sse2.o \ x86/vp6dsp_mmx.o \ x86/vp6dsp_sse2.o +YASM-OBJS-$(CONFIG_VP8_DECODER) += x86/vp8dsp.o +MMX-OBJS-$(CONFIG_VP8_DECODER) += x86/vp8dsp-init.o MMX-OBJS-$(HAVE_YASM) += x86/dsputil_yasm.o \ $(YASM-OBJS-yes) @@ -37,3 +48,5 @@ OBJS-$(HAVE_MMX) += x86/cpuid.o \ x86/motion_est_mmx.o \ x86/mpegvideo_mmx.o \ x86/simple_idct_mmx.o \ + +MMX-OBJS-$(CONFIG_DCT) += x86/dct32_sse.o diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/cavsdsp_mmx.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/cavsdsp_mmx.c index 638eaf7ce..e8c7065fd 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/cavsdsp_mmx.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/cavsdsp_mmx.c @@ -118,7 +118,7 @@ static void cavs_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride) for(i=0; i<2; i++){ DECLARE_ALIGNED(8, uint64_t, tmp); - cavs_idct8_1d(block+4*i, ff_pw_4); + cavs_idct8_1d(block+4*i, ff_pw_4.a); __asm__ volatile( "psraw $3, %%mm7 \n\t" diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dct32_sse.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dct32_sse.c new file mode 100644 index 000000000..216a5efb6 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dct32_sse.c @@ -0,0 +1,294 @@ +/* + * 32 point SSE-optimized DCT transform + * Copyright (c) 2010 Vitor Sessak + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "libavutil/x86_cpu.h" +#include "libavutil/mem.h" +#include "libavcodec/dsputil.h" +#include "fft.h" + +DECLARE_ALIGNED(16, static const float, b1)[] = { + 0.500603, 0.505471, 0.515447, 0.531043, + 0.553104, 0.582935, 0.622504, 0.674808, + -1.169440, -0.972568, -0.839350, -0.744536, + -10.190008, -3.407609, -2.057781, -1.484165, + 0.502419, 0.522499, 0.566944, 0.646822, + 0.788155, 1.060678, 1.722447, 5.101149, + 0.509796, 0.601345, 0.899976, 2.562916, + 1.000000, 1.000000, 1.306563, 0.541196, + 1.000000, 0.707107, 1.000000, -0.707107 +}; + +DECLARE_ALIGNED(16, static const int32_t, smask)[4] = { + 0, 0, 0x80000000, 0x80000000 +}; + +/* butterfly operator */ +#define BUTTERFLY(a,b,c,tmp) \ + "movaps %%" #a ", %%" #tmp " \n\t" \ + "subps %%" #b ", %%" #a " \n\t" \ + "addps %%" #tmp ", %%" #b " \n\t" \ + "mulps " #c ", %%" #a " \n\t" + +///* Same as BUTTERFLY when vectors a and b overlap */ +#define BUTTERFLY0(val, mask, cos, tmp, shuf) \ + "movaps %%" #val ", %%" #tmp " \n\t" \ + "shufps " #shuf ", %%" #val ",%%" #val " \n\t" \ + "xorps %%" #mask ", %%" #tmp " \n\t" /* flip signs */ \ + "addps %%" #tmp ", %%" #val " \n\t" \ + "mulps %%" #cos ", %%" #val " \n\t" + +#define BUTTERFLY2(val, mask, cos, tmp) BUTTERFLY0(val, mask, cos, tmp, $0x1b) +#define BUTTERFLY3(val, mask, cos, tmp) BUTTERFLY0(val, mask, cos, tmp, $0xb1) + +void ff_dct32_float_sse(FFTSample *out, const FFTSample *in) +{ + int32_t tmp1 = 0; + __asm__ volatile( + /* pass 1 */ + + "movaps (%4), %%xmm0 \n\t" + "movaps 112(%4), %%xmm1 \n\t" + "shufps $0x1b, %%xmm1, %%xmm1 \n\t" + BUTTERFLY(xmm0, xmm1, (%2), xmm3) + + "movaps 64(%4), %%xmm7 \n\t" + "movaps 48(%4), %%xmm4 \n\t" + "shufps $0x1b, %%xmm4, %%xmm4 \n\t" + BUTTERFLY(xmm7, xmm4, 48(%2), xmm3) + + + /* pass 2 */ + "movaps 64(%2), %%xmm2 \n\t" + BUTTERFLY(xmm1, xmm4, %%xmm2, xmm3) + "movaps %%xmm1, 48(%1) \n\t" + "movaps %%xmm4, (%1) \n\t" + + /* pass 1 */ + "movaps 16(%4), %%xmm1 \n\t" + "movaps 96(%4), %%xmm6 \n\t" + "shufps $0x1b, %%xmm6, %%xmm6 \n\t" + BUTTERFLY(xmm1, xmm6, 16(%2), xmm3) + + "movaps 80(%4), %%xmm4 \n\t" + "movaps 32(%4), %%xmm5 \n\t" + "shufps $0x1b, %%xmm5, %%xmm5 \n\t" + BUTTERFLY(xmm4, xmm5, 32(%2), xmm3) + + /* pass 2 */ + BUTTERFLY(xmm0, xmm7, %%xmm2, xmm3) + + "movaps 80(%2), %%xmm2 \n\t" + BUTTERFLY(xmm6, xmm5, %%xmm2, xmm3) + + BUTTERFLY(xmm1, xmm4, %%xmm2, xmm3) + + /* pass 3 */ + "movaps 96(%2), %%xmm2 \n\t" + "shufps $0x1b, %%xmm1, %%xmm1 \n\t" + BUTTERFLY(xmm0, xmm1, %%xmm2, xmm3) + "movaps %%xmm0, 112(%1) \n\t" + "movaps %%xmm1, 96(%1) \n\t" + + "movaps 0(%1), %%xmm0 \n\t" + "shufps $0x1b, %%xmm5, %%xmm5 \n\t" + BUTTERFLY(xmm0, xmm5, %%xmm2, xmm3) + + "movaps 48(%1), %%xmm1 \n\t" + "shufps $0x1b, %%xmm6, %%xmm6 \n\t" + BUTTERFLY(xmm1, xmm6, %%xmm2, xmm3) + "movaps %%xmm1, 48(%1) \n\t" + + "shufps $0x1b, %%xmm4, %%xmm4 \n\t" + BUTTERFLY(xmm7, xmm4, %%xmm2, xmm3) + + /* pass 4 */ + "movaps (%3), %%xmm3 \n\t" + "movaps 112(%2), %%xmm2 \n\t" + + BUTTERFLY2(xmm5, xmm3, xmm2, xmm1) + + BUTTERFLY2(xmm0, xmm3, xmm2, xmm1) + "movaps %%xmm0, 16(%1) \n\t" + + BUTTERFLY2(xmm6, xmm3, xmm2, xmm1) + "movaps %%xmm6, 32(%1) \n\t" + + "movaps 48(%1), %%xmm0 \n\t" + BUTTERFLY2(xmm0, xmm3, xmm2, xmm1) + "movaps %%xmm0, 48(%1) \n\t" + + BUTTERFLY2(xmm4, xmm3, xmm2, xmm1) + + BUTTERFLY2(xmm7, xmm3, xmm2, xmm1) + + "movaps 96(%1), %%xmm6 \n\t" + BUTTERFLY2(xmm6, xmm3, xmm2, xmm1) + + "movaps 112(%1), %%xmm0 \n\t" + BUTTERFLY2(xmm0, xmm3, xmm2, xmm1) + + /* pass 5 */ + "movaps 128(%2), %%xmm2 \n\t" + "shufps $0xCC, %%xmm3,%%xmm3 \n\t" + + BUTTERFLY3(xmm5, xmm3, xmm2, xmm1) + "movaps %%xmm5, (%1) \n\t" + + "movaps 16(%1), %%xmm1 \n\t" + BUTTERFLY3(xmm1, xmm3, xmm2, xmm5) + "movaps %%xmm1, 16(%1) \n\t" + + BUTTERFLY3(xmm4, xmm3, xmm2, xmm5) + "movaps %%xmm4, 64(%1) \n\t" + + BUTTERFLY3(xmm7, xmm3, xmm2, xmm5) + "movaps %%xmm7, 80(%1) \n\t" + + "movaps 32(%1), %%xmm5 \n\t" + BUTTERFLY3(xmm5, xmm3, xmm2, xmm7) + "movaps %%xmm5, 32(%1) \n\t" + + "movaps 48(%1), %%xmm4 \n\t" + BUTTERFLY3(xmm4, xmm3, xmm2, xmm7) + "movaps %%xmm4, 48(%1) \n\t" + + BUTTERFLY3(xmm6, xmm3, xmm2, xmm7) + "movaps %%xmm6, 96(%1) \n\t" + + BUTTERFLY3(xmm0, xmm3, xmm2, xmm7) + "movaps %%xmm0, 112(%1) \n\t" + + + /* pass 6, no SIMD... */ + "movss 56(%1), %%xmm3 \n\t" + "movl 4(%1), %0 \n\t" + "addss 60(%1), %%xmm3 \n\t" + "movss 72(%1), %%xmm7 \n\t" + "addss %%xmm3, %%xmm4 \n\t" + "movss 52(%1), %%xmm2 \n\t" + "addss %%xmm3, %%xmm2 \n\t" + "movss 24(%1), %%xmm3 \n\t" + "addss 28(%1), %%xmm3 \n\t" + "addss 76(%1), %%xmm7 \n\t" + "addss %%xmm3, %%xmm1 \n\t" + "addss %%xmm4, %%xmm5 \n\t" + "movss %%xmm1, 16(%1) \n\t" + "movss 20(%1), %%xmm1 \n\t" + "addss %%xmm3, %%xmm1 \n\t" + "movss 40(%1), %%xmm3 \n\t" + "movss %%xmm1, 48(%1) \n\t" + "addss 44(%1), %%xmm3 \n\t" + "movss 20(%1), %%xmm1 \n\t" + "addss %%xmm3, %%xmm4 \n\t" + "addss %%xmm2, %%xmm3 \n\t" + "addss 28(%1), %%xmm1 \n\t" + "movss %%xmm3, 40(%1) \n\t" + "addss 36(%1), %%xmm2 \n\t" + "movss 8(%1), %%xmm3 \n\t" + "movss %%xmm2, 56(%1) \n\t" + "addss 12(%1), %%xmm3 \n\t" + "movss %%xmm5, 8(%1) \n\t" + "movss %%xmm3, 32(%1) \n\t" + "movss 52(%1), %%xmm2 \n\t" + "movss 80(%1), %%xmm3 \n\t" + "movss 120(%1), %%xmm5 \n\t" + "movss %%xmm1, 80(%1) \n\t" + "movss %%xmm4, 24(%1) \n\t" + "addss 124(%1), %%xmm5 \n\t" + "movss 64(%1), %%xmm1 \n\t" + "addss 60(%1), %%xmm2 \n\t" + "addss %%xmm5, %%xmm0 \n\t" + "addss 116(%1), %%xmm5 \n\t" + "movl %0, 64(%1) \n\t" + "addss %%xmm0, %%xmm6 \n\t" + "addss %%xmm6, %%xmm1 \n\t" + "movl 12(%1), %0 \n\t" + "movss %%xmm1, 4(%1) \n\t" + "movss 88(%1), %%xmm1 \n\t" + "movl %0, 96(%1) \n\t" + "addss 92(%1), %%xmm1 \n\t" + "movss 104(%1), %%xmm4 \n\t" + "movl 28(%1), %0 \n\t" + "addss 108(%1), %%xmm4 \n\t" + "addss %%xmm4, %%xmm0 \n\t" + "addss %%xmm1, %%xmm3 \n\t" + "addss 84(%1), %%xmm1 \n\t" + "addss %%xmm5, %%xmm4 \n\t" + "addss %%xmm3, %%xmm6 \n\t" + "addss %%xmm0, %%xmm3 \n\t" + "addss %%xmm7, %%xmm0 \n\t" + "addss 100(%1), %%xmm5 \n\t" + "addss %%xmm4, %%xmm7 \n\t" + "movl %0, 112(%1) \n\t" + "movss %%xmm0, 28(%1) \n\t" + "movss 36(%1), %%xmm0 \n\t" + "movss %%xmm7, 36(%1) \n\t" + "addss %%xmm1, %%xmm4 \n\t" + "movss 116(%1), %%xmm7 \n\t" + "addss %%xmm2, %%xmm0 \n\t" + "addss 124(%1), %%xmm7 \n\t" + "movss %%xmm0, 72(%1) \n\t" + "movss 44(%1), %%xmm0 \n\t" + "movss %%xmm6, 12(%1) \n\t" + "movss %%xmm3, 20(%1) \n\t" + "addss %%xmm0, %%xmm2 \n\t" + "movss %%xmm4, 44(%1) \n\t" + "movss %%xmm2, 88(%1) \n\t" + "addss 60(%1), %%xmm0 \n\t" + "movl 60(%1), %0 \n\t" + "movl %0, 120(%1) \n\t" + "movss %%xmm0, 104(%1) \n\t" + "addss %%xmm5, %%xmm1 \n\t" + "addss 68(%1), %%xmm5 \n\t" + "movss %%xmm1, 52(%1) \n\t" + "movss %%xmm5, 60(%1) \n\t" + "movss 68(%1), %%xmm1 \n\t" + "movss 100(%1), %%xmm5 \n\t" + "addss %%xmm7, %%xmm5 \n\t" + "addss 108(%1), %%xmm7 \n\t" + "addss %%xmm5, %%xmm1 \n\t" + "movss 84(%1), %%xmm2 \n\t" + "addss 92(%1), %%xmm2 \n\t" + "addss %%xmm2, %%xmm5 \n\t" + "movss %%xmm1, 68(%1) \n\t" + "addss %%xmm7, %%xmm2 \n\t" + "movss 76(%1), %%xmm1 \n\t" + "movss %%xmm2, 84(%1) \n\t" + "movss %%xmm5, 76(%1) \n\t" + "movss 108(%1), %%xmm2 \n\t" + "addss %%xmm1, %%xmm7 \n\t" + "addss 124(%1), %%xmm2 \n\t" + "addss %%xmm2, %%xmm1 \n\t" + "addss 92(%1), %%xmm2 \n\t" + "movss %%xmm1, 100(%1) \n\t" + "movss %%xmm2, 108(%1) \n\t" + "movss 92(%1), %%xmm2 \n\t" + "movss %%xmm7, 92(%1) \n\t" + "addss 124(%1), %%xmm2 \n\t" + "movss %%xmm2, 116(%1) \n\t" + :"+&r"(tmp1) + :"r"(out), "r"(b1), "r"(smask), "r"(in) + :"memory" + ); +} + diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_h264_template_ssse3.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_h264_template_ssse3.c index e29e05e7c..0eceb74f2 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_h264_template_ssse3.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_h264_template_ssse3.c @@ -43,7 +43,7 @@ static void H264_CHROMA_MC8_TMPL(uint8_t *dst/*align 8*/, uint8_t *src/*align 1* "pshuflw $0, %%xmm7, %%xmm7 \n\t" "movlhps %%xmm6, %%xmm6 \n\t" "movlhps %%xmm7, %%xmm7 \n\t" - :: "r"(255*(x+y)+8), "m"(*(rnd?&ff_pw_4:&ff_pw_3)) + :: "r"(255*(x+y)+8), "m"(*(rnd?&ff_pw_4.a:&ff_pw_3)) ); if(x) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_mmx.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_mmx.c index cbdf0174d..c4202d53d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_mmx.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_mmx.c @@ -47,7 +47,7 @@ DECLARE_ALIGNED(16, const uint64_t, ff_pdw_80000000)[2] = {0x8000000080000000ULL, 0x8000000080000000ULL}; DECLARE_ALIGNED(8, const uint64_t, ff_pw_3 ) = 0x0003000300030003ULL; -DECLARE_ALIGNED(8, const uint64_t, ff_pw_4 ) = 0x0004000400040004ULL; +DECLARE_ALIGNED(16, const xmm_reg, ff_pw_4 ) = {0x0004000400040004ULL, 0x0004000400040004ULL}; DECLARE_ALIGNED(16, const xmm_reg, ff_pw_5 ) = {0x0005000500050005ULL, 0x0005000500050005ULL}; DECLARE_ALIGNED(16, const xmm_reg, ff_pw_8 ) = {0x0008000800080008ULL, 0x0008000800080008ULL}; DECLARE_ALIGNED(8, const uint64_t, ff_pw_15 ) = 0x000F000F000F000FULL; @@ -62,13 +62,17 @@ DECLARE_ALIGNED(8, const uint64_t, ff_pw_128) = 0x0080008000800080ULL; DECLARE_ALIGNED(8, const uint64_t, ff_pw_255) = 0x00ff00ff00ff00ffULL; DECLARE_ALIGNED(8, const uint64_t, ff_pb_1 ) = 0x0101010101010101ULL; -DECLARE_ALIGNED(8, const uint64_t, ff_pb_3 ) = 0x0303030303030303ULL; +DECLARE_ALIGNED(16, const xmm_reg, ff_pb_3 ) = {0x0303030303030303ULL, 0x0303030303030303ULL}; +DECLARE_ALIGNED(16, const xmm_reg, ff_pb_4 ) = {0x0404040404040404ULL, 0x0404040404040404ULL}; DECLARE_ALIGNED(8, const uint64_t, ff_pb_7 ) = 0x0707070707070707ULL; DECLARE_ALIGNED(8, const uint64_t, ff_pb_1F ) = 0x1F1F1F1F1F1F1F1FULL; DECLARE_ALIGNED(8, const uint64_t, ff_pb_3F ) = 0x3F3F3F3F3F3F3F3FULL; +DECLARE_ALIGNED(16, const xmm_reg, ff_pb_80 ) = {0x8080808080808080ULL, 0x8080808080808080ULL}; DECLARE_ALIGNED(8, const uint64_t, ff_pb_81 ) = 0x8181818181818181ULL; DECLARE_ALIGNED(8, const uint64_t, ff_pb_A1 ) = 0xA1A1A1A1A1A1A1A1ULL; +DECLARE_ALIGNED(16, const xmm_reg, ff_pb_F8 ) = {0xF8F8F8F8F8F8F8F8ULL, 0xF8F8F8F8F8F8F8F8ULL}; DECLARE_ALIGNED(8, const uint64_t, ff_pb_FC ) = 0xFCFCFCFCFCFCFCFCULL; +DECLARE_ALIGNED(16, const xmm_reg, ff_pb_FE ) = {0xFEFEFEFEFEFEFEFEULL, 0xFEFEFEFEFEFEFEFEULL}; DECLARE_ALIGNED(16, const double, ff_pd_1)[2] = { 1.0, 1.0 }; DECLARE_ALIGNED(16, const double, ff_pd_2)[2] = { 2.0, 2.0 }; @@ -2374,11 +2378,11 @@ static void float_to_int16_sse2(int16_t *dst, const float *src, long len){ void ff_float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len); void ff_float_to_int16_interleave6_3dnow(int16_t *dst, const float **src, int len); void ff_float_to_int16_interleave6_3dn2(int16_t *dst, const float **src, int len); -int32_t ff_scalarproduct_int16_mmx2(int16_t *v1, int16_t *v2, int order, int shift); -int32_t ff_scalarproduct_int16_sse2(int16_t *v1, int16_t *v2, int order, int shift); -int32_t ff_scalarproduct_and_madd_int16_mmx2(int16_t *v1, int16_t *v2, int16_t *v3, int order, int mul); -int32_t ff_scalarproduct_and_madd_int16_sse2(int16_t *v1, int16_t *v2, int16_t *v3, int order, int mul); -int32_t ff_scalarproduct_and_madd_int16_ssse3(int16_t *v1, int16_t *v2, int16_t *v3, int order, int mul); +int32_t ff_scalarproduct_int16_mmx2(const int16_t *v1, const int16_t *v2, int order, int shift); +int32_t ff_scalarproduct_int16_sse2(const int16_t *v1, const int16_t *v2, int order, int shift); +int32_t ff_scalarproduct_and_madd_int16_mmx2(int16_t *v1, const int16_t *v2, const int16_t *v3, int order, int mul); +int32_t ff_scalarproduct_and_madd_int16_sse2(int16_t *v1, const int16_t *v2, const int16_t *v3, int order, int mul); +int32_t ff_scalarproduct_and_madd_int16_ssse3(int16_t *v1, const int16_t *v2, const int16_t *v3, int order, int mul); void ff_add_hfyu_median_prediction_mmx2(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top); int ff_add_hfyu_left_prediction_ssse3(uint8_t *dst, const uint8_t *src, int w, int left); int ff_add_hfyu_left_prediction_sse4(uint8_t *dst, const uint8_t *src, int w, int left); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_mmx.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_mmx.h index 7d1bf7fae..ca3713c6e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_mmx.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_mmx.h @@ -33,7 +33,7 @@ extern const uint64_t ff_wtwo; extern const uint64_t ff_pdw_80000000[2]; extern const uint64_t ff_pw_3; -extern const uint64_t ff_pw_4; +extern const xmm_reg ff_pw_4; extern const xmm_reg ff_pw_5; extern const xmm_reg ff_pw_8; extern const uint64_t ff_pw_15; @@ -48,7 +48,7 @@ extern const uint64_t ff_pw_128; extern const uint64_t ff_pw_255; extern const uint64_t ff_pb_1; -extern const uint64_t ff_pb_3; +extern const xmm_reg ff_pb_3; extern const uint64_t ff_pb_7; extern const uint64_t ff_pb_1F; extern const uint64_t ff_pb_3F; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_yasm.asm b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_yasm.asm index e2478a484..bda04727d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_yasm.asm +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/dsputil_yasm.asm @@ -40,7 +40,7 @@ section .text align=16 %endmacro %macro FLOAT_TO_INT16_INTERLEAVE6 1 -; void ff_float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len) +; void float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len) cglobal float_to_int16_interleave6_%1, 2,7,0, dst, src, src1, src2, src3, src4, src5 %ifdef ARCH_X86_64 %define lend r10d @@ -272,7 +272,7 @@ SCALARPRODUCT_LOOP 0 -; void ff_add_hfyu_median_prediction_mmx2(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top) +; void add_hfyu_median_prediction_mmx2(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top) cglobal add_hfyu_median_prediction_mmx2, 6,6,0, dst, top, diff, w, left, left_top movq mm0, [topq] movq mm2, mm0 @@ -370,23 +370,23 @@ cglobal add_hfyu_median_prediction_mmx2, 6,6,0, dst, top, diff, w, left, left_to RET %endmacro -; int ff_add_hfyu_left_prediction(uint8_t *dst, const uint8_t *src, int w, int left) +; int add_hfyu_left_prediction(uint8_t *dst, const uint8_t *src, int w, int left) INIT_MMX cglobal add_hfyu_left_prediction_ssse3, 3,3,7, dst, src, w, left .skip_prologue: - mova m5, [pb_7 GLOBAL] - mova m4, [pb_zzzz3333zzzzbbbb GLOBAL] - mova m3, [pb_zz11zz55zz99zzdd GLOBAL] + mova m5, [pb_7] + mova m4, [pb_zzzz3333zzzzbbbb] + mova m3, [pb_zz11zz55zz99zzdd] movd m0, leftm psllq m0, 56 ADD_HFYU_LEFT_LOOP 1 INIT_XMM cglobal add_hfyu_left_prediction_sse4, 3,3,7, dst, src, w, left - mova m5, [pb_f GLOBAL] - mova m6, [pb_zzzzzzzz77777777 GLOBAL] - mova m4, [pb_zzzz3333zzzzbbbb GLOBAL] - mova m3, [pb_zz11zz55zz99zzdd GLOBAL] + mova m5, [pb_f] + mova m6, [pb_zzzzzzzz77777777] + mova m4, [pb_zzzz3333zzzzbbbb] + mova m3, [pb_zz11zz55zz99zzdd] movd m0, leftm pslldq m0, 15 test srcq, 15 @@ -398,7 +398,7 @@ cglobal add_hfyu_left_prediction_sse4, 3,3,7, dst, src, w, left ADD_HFYU_LEFT_LOOP 0 -; float ff_scalarproduct_float_sse(const float *v1, const float *v2, int len) +; float scalarproduct_float_sse(const float *v1, const float *v2, int len) cglobal scalarproduct_float_sse, 3,3,2, v1, v2, offset neg offsetq shl offsetq, 2 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/fft.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/fft.c index 2c46c6361..eb5c65ecb 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/fft.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/fft.c @@ -42,3 +42,13 @@ av_cold void ff_fft_init_mmx(FFTContext *s) } #endif } + +#if CONFIG_DCT +av_cold void ff_dct_init_mmx(DCTContext *s) +{ + int has_vectors = mm_support(); + if (has_vectors & FF_MM_SSE && HAVE_SSE) + s->dct32 = ff_dct32_float_sse; +} +#endif + diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/fft.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/fft.h index 7ef583914..2affacb62 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/fft.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/fft.h @@ -32,5 +32,6 @@ void ff_imdct_calc_3dn2(FFTContext *s, FFTSample *output, const FFTSample *input void ff_imdct_half_3dn2(FFTContext *s, FFTSample *output, const FFTSample *input); void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input); void ff_imdct_half_sse(FFTContext *s, FFTSample *output, const FFTSample *input); +void ff_dct32_float_sse(FFTSample *out, const FFTSample *in); #endif diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/fft_mmx.asm b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/fft_mmx.asm index 9cb0ae1bf..ea78396e7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/fft_mmx.asm +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/fft_mmx.asm @@ -35,7 +35,7 @@ ps_m1p1: dd 1<<31, 0 %assign i 16 %rep 13 -cextern ff_cos_ %+ i +cextern cos_ %+ i %assign i i<<1 %endrep @@ -64,7 +64,7 @@ section .text align=16 mova %5, %3 pfsub %3, %4 pfadd %5, %4 ; {t6,t5} - pxor %3, [ps_m1p1 GLOBAL] ; {t8,t7} + pxor %3, [ps_m1p1] ; {t8,t7} mova %6, %1 pswapd %3, %3 pfadd %1, %5 ; {r0,i0} @@ -105,8 +105,8 @@ section .text align=16 addps %6, %5 ; {t1,t2,t3,t4} mova %5, %3 shufps %5, %5, 0xb1 ; {i5,r5,i7,r7} - mulps %3, [ps_root2mppm GLOBAL] ; {-r5,i5,r7,-i7} - mulps %5, [ps_root2 GLOBAL] + mulps %3, [ps_root2mppm] ; {-r5,i5,r7,-i7} + mulps %5, [ps_root2] addps %3, %5 ; {t8,t7,ta,t9} mova %5, %6 shufps %6, %3, 0x36 ; {t3,t2,t9,t8} @@ -309,7 +309,7 @@ fft16_sse: mova m6, Z(6) mova m7, Z(7) T4_SSE m6, m7, m0 - PASS_SMALL 0, [ff_cos_16 GLOBAL], [ff_cos_16+16 GLOBAL] + PASS_SMALL 0, [cos_16], [cos_16+16] ret @@ -342,12 +342,12 @@ fft8%1: T2_3DN m6, m7, Z(6), Z(7) pswapd m0, m5 pswapd m2, m7 - pxor m0, [ps_m1p1 GLOBAL] - pxor m2, [ps_m1p1 GLOBAL] + pxor m0, [ps_m1p1] + pxor m2, [ps_m1p1] pfsub m5, m0 pfadd m7, m2 - pfmul m5, [ps_root2 GLOBAL] - pfmul m7, [ps_root2 GLOBAL] + pfmul m5, [ps_root2] + pfmul m7, [ps_root2] T4_3DN m1, m3, m5, m7, m0, m2 mova Z(5), m5 mova Z(7), m7 @@ -445,7 +445,7 @@ fft %+ n %+ %3%2: add r0, n*2 - (n2&(-2<<%1)) call fft %+ n4 %+ %2 sub r0, n*6 + (n2&(-2<<%1)) - lea r1, [ff_cos_ %+ n GLOBAL] + lea r1, [cos_ %+ n] mov r2d, n4/2 jmp pass%3%2 @@ -461,10 +461,10 @@ section .text ; On x86_32, this function does the register saving and restoring for all of fft. ; The others pass args in registers and don't spill anything. cglobal fft_dispatch%3%2, 2,5,8, z, nbits - lea r2, [dispatch_tab%3%2 GLOBAL] + lea r2, [dispatch_tab%3%2] mov r2, [r2 + (nbitsq-2)*gprsize] %ifdef PIC - lea r3, [$$ GLOBAL] + lea r3, [$$] add r2, r3 %endif call r2 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264_deblock_sse2.asm b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264_deblock_sse2.asm index bf45c7ea6..b2aa94023 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264_deblock_sse2.asm +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264_deblock_sse2.asm @@ -234,18 +234,18 @@ SECTION .text %macro DEBLOCK_P0_Q0 0 mova m5, m1 pxor m5, m2 ; p0^q0 - pand m5, [pb_01 GLOBAL] ; (p0^q0)&1 + pand m5, [pb_01] ; (p0^q0)&1 pcmpeqb m4, m4 pxor m3, m4 pavgb m3, m0 ; (p1 - q1 + 256)>>1 - pavgb m3, [pb_03 GLOBAL] ; (((p1 - q1 + 256)>>1)+4)>>1 = 64+2+(p1-q1)>>2 + pavgb m3, [pb_03] ; (((p1 - q1 + 256)>>1)+4)>>1 = 64+2+(p1-q1)>>2 pxor m4, m1 pavgb m4, m2 ; (q0 - p0 + 256)>>1 pavgb m3, m5 paddusb m3, m4 ; d+128+33 - mova m6, [pb_a1 GLOBAL] + mova m6, [pb_a1] psubusb m6, m3 - psubusb m3, [pb_a1 GLOBAL] + psubusb m3, [pb_a1] pminub m6, m7 pminub m3, m7 psubusb m1, m6 @@ -263,7 +263,7 @@ SECTION .text pavgb %6, m2 pavgb %2, %6 ; avg(p2,avg(p0,q0)) pxor %6, %3 - pand %6, [pb_01 GLOBAL] ; (p2^avg(p0,q0))&1 + pand %6, [pb_01] ; (p2^avg(p0,q0))&1 psubusb %2, %6 ; (p2+((p0+q0+1)>>1))>>1 mova %6, %1 psubusb %6, %5 @@ -612,8 +612,8 @@ DEBLOCK_LUMA sse2, v, 16 %define mask0 spill(2) %define mask1p spill(3) %define mask1q spill(4) - %define mpb_00 [pb_00 GLOBAL] - %define mpb_01 [pb_01 GLOBAL] + %define mpb_00 [pb_00] + %define mpb_01 [pb_01] %endif ;----------------------------------------------------------------------------- @@ -637,7 +637,7 @@ cglobal x264_deblock_%2_luma_intra_%1, 4,6,16 mova q1, [r0+r1] %ifdef ARCH_X86_64 pxor mpb_00, mpb_00 - mova mpb_01, [pb_01 GLOBAL] + mova mpb_01, [pb_01] LOAD_MASK r2d, r3d, t5 ; m5=beta-1, t5=alpha-1, m7=mask0 SWAP 7, 12 ; m12=mask0 pavgb t5, mpb_00 @@ -656,8 +656,8 @@ cglobal x264_deblock_%2_luma_intra_%1, 4,6,16 LOAD_MASK r2d, r3d, t5 ; m5=beta-1, t5=alpha-1, m7=mask0 mova m4, t5 mova mask0, m7 - pavgb m4, [pb_00 GLOBAL] - pavgb m4, [pb_01 GLOBAL] ; alpha/4+1 + pavgb m4, [pb_00] + pavgb m4, [pb_01] ; alpha/4+1 DIFF_GT2 p0, q0, m4, m6, m7 ; m6 = |p0-q0| > alpha/4+1 pand m6, mask0 DIFF_GT2 p0, p2, m5, m4, m7 ; m4 = |p2-p0| > beta-1 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264_idct_sse2.asm b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264_idct_sse2.asm index f8ee2b628..86c1e66c7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264_idct_sse2.asm +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264_idct_sse2.asm @@ -43,7 +43,7 @@ cglobal x264_add8x4_idct_sse2, 3,3,8 movhps m3, [r1+56] IDCT4_1D 0,1,2,3,4,5 TRANSPOSE2x4x4W 0,1,2,3,4 - paddw m0, [pw_32 GLOBAL] + paddw m0, [pw_32] IDCT4_1D 0,1,2,3,4,5 pxor m7, m7 STORE_DIFF m0, m4, m7, [r0] diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264_intrapred.asm b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264_intrapred.asm new file mode 100644 index 000000000..d36ecfb89 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264_intrapred.asm @@ -0,0 +1,602 @@ +;****************************************************************************** +;* H.264 intra prediction asm optimizations +;* Copyright (c) 2010 Jason Garrett-Glaser +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "x86inc.asm" + +SECTION_RODATA + +tm_shuf: times 8 db 0x03, 0x80 + +SECTION .text + +cextern pb_1 +cextern pb_3 + +;----------------------------------------------------------------------------- +; void pred16x16_vertical(uint8_t *src, int stride) +;----------------------------------------------------------------------------- + +cglobal pred16x16_vertical_mmx, 2,3 + sub r0, r1 + mov r2, 8 + movq mm0, [r0+0] + movq mm1, [r0+8] +.loop: + movq [r0+r1*1+0], mm0 + movq [r0+r1*1+8], mm1 + movq [r0+r1*2+0], mm0 + movq [r0+r1*2+8], mm1 + lea r0, [r0+r1*2] + dec r2 + jg .loop + REP_RET + +cglobal pred16x16_vertical_sse, 2,3 + sub r0, r1 + mov r2, 4 + movaps xmm0, [r0] +.loop: + movaps [r0+r1*1], xmm0 + movaps [r0+r1*2], xmm0 + lea r0, [r0+r1*2] + movaps [r0+r1*1], xmm0 + movaps [r0+r1*2], xmm0 + lea r0, [r0+r1*2] + dec r2 + jg .loop + REP_RET + +;----------------------------------------------------------------------------- +; void pred16x16_horizontal(uint8_t *src, int stride) +;----------------------------------------------------------------------------- + +%macro PRED16x16_H 1 +cglobal pred16x16_horizontal_%1, 2,3 + mov r2, 8 +%ifidn %1, ssse3 + mova m2, [pb_3] +%endif +.loop: + movd m0, [r0+r1*0-4] + movd m1, [r0+r1*1-4] + +%ifidn %1, ssse3 + pshufb m0, m2 + pshufb m1, m2 +%else + punpcklbw m0, m0 + punpcklbw m1, m1 +%ifidn %1, mmxext + pshufw m0, m0, 0xff + pshufw m1, m1, 0xff +%else + punpckhwd m0, m0 + punpckhwd m1, m1 + punpckhdq m0, m0 + punpckhdq m1, m1 +%endif + mova [r0+r1*0+8], m0 + mova [r0+r1*1+8], m1 +%endif + + mova [r0+r1*0], m0 + mova [r0+r1*1], m1 + lea r0, [r0+r1*2] + dec r2 + jg .loop + REP_RET +%endmacro + +INIT_MMX +PRED16x16_H mmx +PRED16x16_H mmxext +INIT_XMM +PRED16x16_H ssse3 + +;----------------------------------------------------------------------------- +; void pred16x16_dc(uint8_t *src, int stride) +;----------------------------------------------------------------------------- + +%macro PRED16x16_DC 1 +cglobal pred16x16_dc_%1, 2,7 + mov r4, r0 + sub r0, r1 + pxor mm0, mm0 + pxor mm1, mm1 + psadbw mm0, [r0+0] + psadbw mm1, [r0+8] + dec r0 + movzx r5d, byte [r0+r1*1] + paddw mm0, mm1 + movd r6d, mm0 + lea r0, [r0+r1*2] +%rep 7 + movzx r2d, byte [r0+r1*0] + movzx r3d, byte [r0+r1*1] + add r5d, r2d + add r6d, r3d + lea r0, [r0+r1*2] +%endrep + movzx r2d, byte [r0+r1*0] + add r5d, r6d + lea r2d, [r2+r5+16] + shr r2d, 5 +%ifidn %1, mmxext + movd m0, r2d + punpcklbw m0, m0 + pshufw m0, m0, 0 +%elifidn %1, sse2 + movd m0, r2d + punpcklbw m0, m0 + pshuflw m0, m0, 0 + punpcklqdq m0, m0 +%elifidn %1, ssse3 + pxor m1, m1 + movd m0, r2d + pshufb m0, m1 +%endif + +%if mmsize==8 + mov r3d, 8 +.loop: + mova [r4+r1*0+0], m0 + mova [r4+r1*0+8], m0 + mova [r4+r1*1+0], m0 + mova [r4+r1*1+8], m0 +%else + mov r3d, 4 +.loop: + mova [r4+r1*0], m0 + mova [r4+r1*1], m0 + lea r4, [r4+r1*2] + mova [r4+r1*0], m0 + mova [r4+r1*1], m0 +%endif + lea r4, [r4+r1*2] + dec r3d + jg .loop + REP_RET +%endmacro + +INIT_MMX +PRED16x16_DC mmxext +INIT_XMM +PRED16x16_DC sse2 +PRED16x16_DC ssse3 + +;----------------------------------------------------------------------------- +; void pred16x16_tm_vp8(uint8_t *src, int stride) +;----------------------------------------------------------------------------- + +%macro PRED16x16_TM_MMX 1 +cglobal pred16x16_tm_vp8_%1, 2,5 + sub r0, r1 + pxor mm7, mm7 + movq mm0, [r0+0] + movq mm2, [r0+8] + movq mm1, mm0 + movq mm3, mm2 + punpcklbw mm0, mm7 + punpckhbw mm1, mm7 + punpcklbw mm2, mm7 + punpckhbw mm3, mm7 + movzx r3d, byte [r0-1] + mov r4d, 16 +.loop: + movzx r2d, byte [r0+r1-1] + sub r2d, r3d + movd mm4, r2d +%ifidn %1, mmx + punpcklwd mm4, mm4 + punpckldq mm4, mm4 +%else + pshufw mm4, mm4, 0 +%endif + movq mm5, mm4 + movq mm6, mm4 + movq mm7, mm4 + paddw mm4, mm0 + paddw mm5, mm1 + paddw mm6, mm2 + paddw mm7, mm3 + packuswb mm4, mm5 + packuswb mm6, mm7 + movq [r0+r1+0], mm4 + movq [r0+r1+8], mm6 + add r0, r1 + dec r4d + jg .loop + REP_RET +%endmacro + +PRED16x16_TM_MMX mmx +PRED16x16_TM_MMX mmxext + +cglobal pred16x16_tm_vp8_sse2, 2,6,6 + sub r0, r1 + pxor xmm2, xmm2 + movdqa xmm0, [r0] + movdqa xmm1, xmm0 + punpcklbw xmm0, xmm2 + punpckhbw xmm1, xmm2 + movzx r4d, byte [r0-1] + mov r5d, 8 +.loop: + movzx r2d, byte [r0+r1*1-1] + movzx r3d, byte [r0+r1*2-1] + sub r2d, r4d + sub r3d, r4d + movd xmm2, r2d + movd xmm4, r3d + pshuflw xmm2, xmm2, 0 + pshuflw xmm4, xmm4, 0 + punpcklqdq xmm2, xmm2 + punpcklqdq xmm4, xmm4 + movdqa xmm3, xmm2 + movdqa xmm5, xmm4 + paddw xmm2, xmm0 + paddw xmm3, xmm1 + paddw xmm4, xmm0 + paddw xmm5, xmm1 + packuswb xmm2, xmm3 + packuswb xmm4, xmm5 + movdqa [r0+r1*1], xmm2 + movdqa [r0+r1*2], xmm4 + lea r0, [r0+r1*2] + dec r5d + jg .loop + REP_RET + +;----------------------------------------------------------------------------- +; void pred8x8_vertical(uint8_t *src, int stride) +;----------------------------------------------------------------------------- + +cglobal pred8x8_vertical_mmx, 2,2 + sub r0, r1 + movq mm0, [r0] +%rep 3 + movq [r0+r1*1], mm0 + movq [r0+r1*2], mm0 + lea r0, [r0+r1*2] +%endrep + movq [r0+r1*1], mm0 + movq [r0+r1*2], mm0 + RET + +;----------------------------------------------------------------------------- +; void pred8x8_horizontal(uint8_t *src, int stride) +;----------------------------------------------------------------------------- + +%macro PRED8x8_H 1 +cglobal pred8x8_horizontal_%1, 2,3 + mov r2, 4 +%ifidn %1, ssse3 + mova m2, [pb_3] +%endif +.loop: + movd m0, [r0+r1*0-4] + movd m1, [r0+r1*1-4] +%ifidn %1, ssse3 + pshufb m0, m2 + pshufb m1, m2 +%else + punpcklbw m0, m0 + punpcklbw m1, m1 +%ifidn %1, mmxext + pshufw m0, m0, 0xff + pshufw m1, m1, 0xff +%else + punpckhwd m0, m0 + punpckhwd m1, m1 + punpckhdq m0, m0 + punpckhdq m1, m1 +%endif +%endif + mova [r0+r1*0], m0 + mova [r0+r1*1], m1 + lea r0, [r0+r1*2] + dec r2 + jg .loop + REP_RET +%endmacro + +INIT_MMX +PRED8x8_H mmx +PRED8x8_H mmxext +PRED8x8_H ssse3 + +;----------------------------------------------------------------------------- +; void pred8x8_dc_rv40(uint8_t *src, int stride) +;----------------------------------------------------------------------------- + +cglobal pred8x8_dc_rv40_mmxext, 2,7 + mov r4, r0 + sub r0, r1 + pxor mm0, mm0 + psadbw mm0, [r0] + dec r0 + movzx r5d, byte [r0+r1*1] + movd r6d, mm0 + lea r0, [r0+r1*2] +%rep 3 + movzx r2d, byte [r0+r1*0] + movzx r3d, byte [r0+r1*1] + add r5d, r2d + add r6d, r3d + lea r0, [r0+r1*2] +%endrep + movzx r2d, byte [r0+r1*0] + add r5d, r6d + lea r2d, [r2+r5+8] + shr r2d, 4 + movd mm0, r2d + punpcklbw mm0, mm0 + pshufw mm0, mm0, 0 + mov r3d, 4 +.loop: + movq [r4+r1*0], mm0 + movq [r4+r1*1], mm0 + lea r4, [r4+r1*2] + dec r3d + jg .loop + REP_RET + +;----------------------------------------------------------------------------- +; void pred8x8_tm_vp8(uint8_t *src, int stride) +;----------------------------------------------------------------------------- + +%macro PRED8x8_TM_MMX 1 +cglobal pred8x8_tm_vp8_%1, 2,6 + sub r0, r1 + pxor mm7, mm7 + movq mm0, [r0] + movq mm1, mm0 + punpcklbw mm0, mm7 + punpckhbw mm1, mm7 + movzx r4d, byte [r0-1] + mov r5d, 4 +.loop: + movzx r2d, byte [r0+r1*1-1] + movzx r3d, byte [r0+r1*2-1] + sub r2d, r4d + sub r3d, r4d + movd mm2, r2d + movd mm4, r3d +%ifidn %1, mmx + punpcklwd mm2, mm2 + punpcklwd mm4, mm4 + punpckldq mm2, mm2 + punpckldq mm4, mm4 +%else + pshufw mm2, mm2, 0 + pshufw mm4, mm4, 0 +%endif + movq mm3, mm2 + movq mm5, mm4 + paddw mm2, mm0 + paddw mm3, mm1 + paddw mm4, mm0 + paddw mm5, mm1 + packuswb mm2, mm3 + packuswb mm4, mm5 + movq [r0+r1*1], mm2 + movq [r0+r1*2], mm4 + lea r0, [r0+r1*2] + dec r5d + jg .loop + REP_RET +%endmacro + +PRED8x8_TM_MMX mmx +PRED8x8_TM_MMX mmxext + +cglobal pred8x8_tm_vp8_sse2, 2,6,4 + sub r0, r1 + pxor xmm1, xmm1 + movq xmm0, [r0] + punpcklbw xmm0, xmm1 + movzx r4d, byte [r0-1] + mov r5d, 4 +.loop: + movzx r2d, byte [r0+r1*1-1] + movzx r3d, byte [r0+r1*2-1] + sub r2d, r4d + sub r3d, r4d + movd xmm2, r2d + movd xmm3, r3d + pshuflw xmm2, xmm2, 0 + pshuflw xmm3, xmm3, 0 + punpcklqdq xmm2, xmm2 + punpcklqdq xmm3, xmm3 + paddw xmm2, xmm0 + paddw xmm3, xmm0 + packuswb xmm2, xmm3 + movq [r0+r1*1], xmm2 + movhps [r0+r1*2], xmm2 + lea r0, [r0+r1*2] + dec r5d + jg .loop + REP_RET + +cglobal pred8x8_tm_vp8_ssse3, 2,3,6 + sub r0, r1 + movdqa xmm4, [tm_shuf] + pxor xmm1, xmm1 + movq xmm0, [r0] + punpcklbw xmm0, xmm1 + movd xmm5, [r0-4] + pshufb xmm5, xmm4 + mov r2d, 4 +.loop: + movd xmm2, [r0+r1*1-4] + movd xmm3, [r0+r1*2-4] + pshufb xmm2, xmm4 + pshufb xmm3, xmm4 + psubw xmm2, xmm5 + psubw xmm3, xmm5 + paddw xmm2, xmm0 + paddw xmm3, xmm0 + packuswb xmm2, xmm3 + movq [r0+r1*1], xmm2 + movhps [r0+r1*2], xmm2 + lea r0, [r0+r1*2] + dec r2d + jg .loop + REP_RET + +;----------------------------------------------------------------------------- +; void pred4x4_dc_mmxext(uint8_t *src, const uint8_t *topright, int stride) +;----------------------------------------------------------------------------- + +cglobal pred4x4_dc_mmxext, 3,5 + pxor mm7, mm7 + mov r4, r0 + sub r0, r2 + movd mm0, [r0] + psadbw mm0, mm7 + movzx r1d, byte [r0+r2*1-1] + movd r3d, mm0 + add r3d, r1d + movzx r1d, byte [r0+r2*2-1] + lea r0, [r0+r2*2] + add r3d, r1d + movzx r1d, byte [r0+r2*1-1] + add r3d, r1d + movzx r1d, byte [r0+r2*2-1] + add r3d, r1d + add r3d, 4 + shr r3d, 3 + imul r3d, 0x01010101 + mov [r4+r2*0], r3d + mov [r0+r2*0], r3d + mov [r0+r2*1], r3d + mov [r0+r2*2], r3d + RET + +;----------------------------------------------------------------------------- +; void pred4x4_tm_vp8_mmxext(uint8_t *src, const uint8_t *topright, int stride) +;----------------------------------------------------------------------------- + +%macro PRED4x4_TM_MMX 1 +cglobal pred4x4_tm_vp8_%1, 3,6 + sub r0, r2 + pxor mm7, mm7 + movd mm0, [r0] + punpcklbw mm0, mm7 + movzx r4d, byte [r0-1] + mov r5d, 2 +.loop: + movzx r1d, byte [r0+r2*1-1] + movzx r3d, byte [r0+r2*2-1] + sub r1d, r4d + sub r3d, r4d + movd mm2, r1d + movd mm4, r3d +%ifidn %1, mmx + punpcklwd mm2, mm2 + punpcklwd mm4, mm4 + punpckldq mm2, mm2 + punpckldq mm4, mm4 +%else + pshufw mm2, mm2, 0 + pshufw mm4, mm4, 0 +%endif + paddw mm2, mm0 + paddw mm4, mm0 + packuswb mm2, mm2 + packuswb mm4, mm4 + movd [r0+r2*1], mm2 + movd [r0+r2*2], mm4 + lea r0, [r0+r2*2] + dec r5d + jg .loop + REP_RET +%endmacro + +PRED4x4_TM_MMX mmx +PRED4x4_TM_MMX mmxext + +cglobal pred4x4_tm_vp8_ssse3, 3,3 + sub r0, r2 + movq mm6, [tm_shuf] + pxor mm1, mm1 + movd mm0, [r0] + punpcklbw mm0, mm1 + movd mm7, [r0-4] + pshufb mm7, mm6 + lea r1, [r0+r2*2] + movd mm2, [r0+r2*1-4] + movd mm3, [r0+r2*2-4] + movd mm4, [r1+r2*1-4] + movd mm5, [r1+r2*2-4] + pshufb mm2, mm6 + pshufb mm3, mm6 + pshufb mm4, mm6 + pshufb mm5, mm6 + psubw mm2, mm7 + psubw mm3, mm7 + psubw mm4, mm7 + psubw mm5, mm7 + paddw mm2, mm0 + paddw mm3, mm0 + paddw mm4, mm0 + paddw mm5, mm0 + packuswb mm2, mm2 + packuswb mm3, mm3 + packuswb mm4, mm4 + packuswb mm5, mm5 + movd [r0+r2*1], mm2 + movd [r0+r2*2], mm3 + movd [r1+r2*1], mm4 + movd [r1+r2*2], mm5 + RET + +; dest, left, right, src, tmp +; output: %1 = (t[n-1] + t[n]*2 + t[n+1] + 2) >> 2 +%macro PRED4x4_LOWPASS 5 + mova %5, %2 + pavgb %2, %3 + pxor %3, %5 + mova %1, %4 + pand %3, [pb_1] + psubusb %2, %3 + pavgb %1, %2 +%endmacro + +;----------------------------------------------------------------------------- +; void pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int stride) +;----------------------------------------------------------------------------- + +INIT_MMX +cglobal pred4x4_vertical_vp8_mmxext, 3,3 + sub r0, r2 + movd m1, [r0-1] + movd m0, [r0] + mova m2, m0 ;t0 t1 t2 t3 + punpckldq m0, [r1] ;t0 t1 t2 t3 t4 t5 t6 t7 + lea r1, [r0+r2*2] + psrlq m0, 8 ;t1 t2 t3 t4 + PRED4x4_LOWPASS m3, m1, m0, m2, m4 + movd [r0+r2*1], m3 + movd [r0+r2*2], m3 + movd [r1+r2*1], m3 + movd [r1+r2*2], m3 + RET diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264dsp_mmx.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264dsp_mmx.c index fd16a02d6..b9d2c3234 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264dsp_mmx.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/h264dsp_mmx.c @@ -19,6 +19,7 @@ */ #include "dsputil_mmx.h" +#include "libavcodec/h264pred.h" DECLARE_ALIGNED(8, static const uint64_t, ff_pb_3_1 ) = 0x0103010301030103ULL; DECLARE_ALIGNED(8, static const uint64_t, ff_pb_7_3 ) = 0x0307030703070307ULL; @@ -2322,3 +2323,85 @@ H264_WEIGHT( 4, 8) H264_WEIGHT( 4, 4) H264_WEIGHT( 4, 2) +void ff_pred16x16_vertical_mmx (uint8_t *src, int stride); +void ff_pred16x16_vertical_sse (uint8_t *src, int stride); +void ff_pred16x16_horizontal_mmx (uint8_t *src, int stride); +void ff_pred16x16_horizontal_mmxext(uint8_t *src, int stride); +void ff_pred16x16_horizontal_ssse3 (uint8_t *src, int stride); +void ff_pred16x16_dc_mmxext (uint8_t *src, int stride); +void ff_pred16x16_dc_sse2 (uint8_t *src, int stride); +void ff_pred16x16_dc_ssse3 (uint8_t *src, int stride); +void ff_pred16x16_tm_vp8_mmx (uint8_t *src, int stride); +void ff_pred16x16_tm_vp8_mmxext (uint8_t *src, int stride); +void ff_pred16x16_tm_vp8_sse2 (uint8_t *src, int stride); +void ff_pred8x8_dc_rv40_mmxext (uint8_t *src, int stride); +void ff_pred8x8_vertical_mmx (uint8_t *src, int stride); +void ff_pred8x8_horizontal_mmx (uint8_t *src, int stride); +void ff_pred8x8_horizontal_mmxext (uint8_t *src, int stride); +void ff_pred8x8_horizontal_ssse3 (uint8_t *src, int stride); +void ff_pred8x8_tm_vp8_mmx (uint8_t *src, int stride); +void ff_pred8x8_tm_vp8_mmxext (uint8_t *src, int stride); +void ff_pred8x8_tm_vp8_sse2 (uint8_t *src, int stride); +void ff_pred8x8_tm_vp8_ssse3 (uint8_t *src, int stride); +void ff_pred4x4_dc_mmxext (uint8_t *src, const uint8_t *topright, int stride); +void ff_pred4x4_tm_vp8_mmx (uint8_t *src, const uint8_t *topright, int stride); +void ff_pred4x4_tm_vp8_mmxext (uint8_t *src, const uint8_t *topright, int stride); +void ff_pred4x4_tm_vp8_ssse3 (uint8_t *src, const uint8_t *topright, int stride); +void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int stride); + +#if CONFIG_H264DSP +void ff_h264_pred_init_x86(H264PredContext *h, int codec_id) +{ + mm_flags = mm_support(); + +#if HAVE_YASM + if (mm_flags & FF_MM_MMX) { + h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_mmx; + h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx; + h->pred8x8 [VERT_PRED8x8] = ff_pred8x8_vertical_mmx; + h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx; + if (codec_id == CODEC_ID_VP8) { + h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmx; + h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmx; + h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx; + } + } + + if (mm_flags & FF_MM_MMX2) { + h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext; + h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext; + h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext; + h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext; + if (codec_id == CODEC_ID_VP8) { + h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmxext; + h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_mmxext; + h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmxext; + h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext; + h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext; + } + } + + if (mm_flags & FF_MM_SSE) { + h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse; + } + + if (mm_flags & FF_MM_SSE2) { + h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2; + if (codec_id == CODEC_ID_VP8) { + h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2; + h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_sse2; + } + } + + if (mm_flags & FF_MM_SSSE3) { + h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3; + h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3; + h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3; + if (codec_id == CODEC_ID_VP8) { + h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_ssse3; + h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3; + } + } +#endif +} +#endif diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/mpegaudiodec_mmx.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/mpegaudiodec_mmx.c new file mode 100644 index 000000000..e7e115078 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/mpegaudiodec_mmx.c @@ -0,0 +1,157 @@ +/* + * MMX optimized MP3 decoding functions + * Copyright (c) 2010 Vitor Sessak + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/x86_cpu.h" + +#define CONFIG_FLOAT 1 +#include "libavcodec/mpegaudio.h" + +#define MACS(rt, ra, rb) rt+=(ra)*(rb) +#define MLSS(rt, ra, rb) rt-=(ra)*(rb) + +#define SUM8(op, sum, w, p) \ +{ \ + op(sum, (w)[0 * 64], (p)[0 * 64]); \ + op(sum, (w)[1 * 64], (p)[1 * 64]); \ + op(sum, (w)[2 * 64], (p)[2 * 64]); \ + op(sum, (w)[3 * 64], (p)[3 * 64]); \ + op(sum, (w)[4 * 64], (p)[4 * 64]); \ + op(sum, (w)[5 * 64], (p)[5 * 64]); \ + op(sum, (w)[6 * 64], (p)[6 * 64]); \ + op(sum, (w)[7 * 64], (p)[7 * 64]); \ +} + +static void apply_window(const float *buf, const float *win1, + const float *win2, float *sum1, float *sum2, int len) +{ + x86_reg count = - 4*len; + const float *win1a = win1+len; + const float *win2a = win2+len; + const float *bufa = buf+len; + float *sum1a = sum1+len; + float *sum2a = sum2+len; + + +#define MULT(a, b) \ + "movaps " #a "(%1,%0), %%xmm1 \n\t" \ + "movaps " #a "(%3,%0), %%xmm2 \n\t" \ + "mulps %%xmm2, %%xmm1 \n\t" \ + "subps %%xmm1, %%xmm0 \n\t" \ + "mulps " #b "(%2,%0), %%xmm2 \n\t" \ + "subps %%xmm2, %%xmm4 \n\t" \ + + __asm__ volatile( + "1: \n\t" + "xorps %%xmm0, %%xmm0 \n\t" + "xorps %%xmm4, %%xmm4 \n\t" + + MULT( 0, 0) + MULT( 256, 64) + MULT( 512, 128) + MULT( 768, 192) + MULT(1024, 256) + MULT(1280, 320) + MULT(1536, 384) + MULT(1792, 448) + + "movaps %%xmm0, (%4,%0) \n\t" + "movaps %%xmm4, (%5,%0) \n\t" + "add $16, %0 \n\t" + "jl 1b \n\t" + :"+&r"(count) + :"r"(win1a), "r"(win2a), "r"(bufa), "r"(sum1a), "r"(sum2a) + ); + +#undef MULT +} + +static void apply_window_mp3(float *in, float *win, int *unused, float *out, + int incr) +{ + LOCAL_ALIGNED_16(float, suma, [17]); + LOCAL_ALIGNED_16(float, sumb, [17]); + LOCAL_ALIGNED_16(float, sumc, [17]); + LOCAL_ALIGNED_16(float, sumd, [17]); + + float sum; + + /* copy to avoid wrap */ + memcpy(in + 512, in, 32 * sizeof(*in)); + + apply_window(in + 16, win , win + 512, suma, sumc, 16); + apply_window(in + 32, win + 48, win + 640, sumb, sumd, 16); + + SUM8(MACS, suma[0], win + 32, in + 48); + + sumc[ 0] = 0; + sumb[16] = 0; + sumd[16] = 0; + +#define SUMS(suma, sumb, sumc, sumd, out1, out2) \ + "movups " #sumd "(%4), %%xmm0 \n\t" \ + "shufps $0x1b, %%xmm0, %%xmm0 \n\t" \ + "subps " #suma "(%1), %%xmm0 \n\t" \ + "movaps %%xmm0," #out1 "(%0) \n\t" \ +\ + "movups " #sumc "(%3), %%xmm0 \n\t" \ + "shufps $0x1b, %%xmm0, %%xmm0 \n\t" \ + "addps " #sumb "(%2), %%xmm0 \n\t" \ + "movaps %%xmm0," #out2 "(%0) \n\t" + + if (incr == 1) { + __asm__ volatile( + SUMS( 0, 48, 4, 52, 0, 112) + SUMS(16, 32, 20, 36, 16, 96) + SUMS(32, 16, 36, 20, 32, 80) + SUMS(48, 0, 52, 4, 48, 64) + + :"+&r"(out) + :"r"(&suma[0]), "r"(&sumb[0]), "r"(&sumc[0]), "r"(&sumd[0]) + :"memory" + ); + out += 16*incr; + } else { + int j; + float *out2 = out + 32 * incr; + out[0 ] = -suma[ 0]; + out += incr; + out2 -= incr; + for(j=1;j<16;j++) { + *out = -suma[ j] + sumd[16-j]; + *out2 = sumb[16-j] + sumc[ j]; + out += incr; + out2 -= incr; + } + } + + sum = 0; + SUM8(MLSS, sum, win + 16 + 32, in + 32); + *out = sum; +} + +void ff_mpegaudiodec_init_mmx(MPADecodeContext *s) +{ + mm_flags = mm_support(); + + if (mm_flags & FF_MM_SSE2) { + s->apply_window_mp3 = apply_window_mp3; + } +} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vc1dsp_mmx.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vc1dsp_mmx.c index e0b1f5b99..3012ec5d1 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vc1dsp_mmx.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vc1dsp_mmx.c @@ -411,7 +411,7 @@ typedef void (*vc1_mspel_mc_filter_hor_16bits)(uint8_t *dst, x86_reg dst_stride, typedef void (*vc1_mspel_mc_filter_8bits)(uint8_t *dst, const uint8_t *src, x86_reg stride, int rnd, x86_reg offset); /** - * Interpolates fractional pel values by applying proper vertical then + * Interpolate fractional pel values by applying proper vertical then * horizontal filter. * * @param dst Destination buffer for interpolated pels. @@ -689,6 +689,39 @@ static void vc1_inv_trans_8x8_dc_mmx2(uint8_t *dest, int linesize, DCTELEM *bloc ); } +#define LOOP_FILTER(EXT) \ +void ff_vc1_v_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \ +void ff_vc1_h_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \ +void ff_vc1_v_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \ +void ff_vc1_h_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \ +\ +static void vc1_v_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \ +{ \ + ff_vc1_v_loop_filter8_ ## EXT(src, stride, pq); \ + ff_vc1_v_loop_filter8_ ## EXT(src+8, stride, pq); \ +} \ +\ +static void vc1_h_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \ +{ \ + ff_vc1_h_loop_filter8_ ## EXT(src, stride, pq); \ + ff_vc1_h_loop_filter8_ ## EXT(src+8*stride, stride, pq); \ +} + +#if HAVE_YASM +LOOP_FILTER(mmx) +LOOP_FILTER(mmx2) +LOOP_FILTER(sse2) +LOOP_FILTER(ssse3) + +void ff_vc1_h_loop_filter8_sse4(uint8_t *src, int stride, int pq); + +static void vc1_h_loop_filter16_sse4(uint8_t *src, int stride, int pq) +{ + ff_vc1_h_loop_filter8_sse4(src, stride, pq); + ff_vc1_h_loop_filter8_sse4(src+8*stride, stride, pq); +} +#endif + void ff_vc1dsp_init_mmx(DSPContext* dsp, AVCodecContext *avctx) { mm_flags = mm_support(); @@ -738,4 +771,35 @@ void ff_vc1dsp_init_mmx(DSPContext* dsp, AVCodecContext *avctx) { dsp->vc1_inv_trans_8x4_dc = vc1_inv_trans_8x4_dc_mmx2; dsp->vc1_inv_trans_4x4_dc = vc1_inv_trans_4x4_dc_mmx2; } + +#define ASSIGN_LF(EXT) \ + dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_ ## EXT; \ + dsp->vc1_h_loop_filter4 = ff_vc1_h_loop_filter4_ ## EXT; \ + dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_ ## EXT; \ + dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_ ## EXT; \ + dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_ ## EXT; \ + dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_ ## EXT + +#if HAVE_YASM + if (mm_flags & FF_MM_MMX) { + ASSIGN_LF(mmx); + } + return; + if (mm_flags & FF_MM_MMX2) { + ASSIGN_LF(mmx2); + } + if (mm_flags & FF_MM_SSE2) { + dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_sse2; + dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse2; + dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_sse2; + dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse2; + } + if (mm_flags & FF_MM_SSSE3) { + ASSIGN_LF(ssse3); + } + if (mm_flags & FF_MM_SSE4) { + dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse4; + dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse4; + } +#endif } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vc1dsp_yasm.asm b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vc1dsp_yasm.asm new file mode 100644 index 000000000..660ff1169 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vc1dsp_yasm.asm @@ -0,0 +1,330 @@ +;****************************************************************************** +;* VC1 deblocking optimizations +;* Copyright (c) 2009 David Conrad +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "x86inc.asm" +%include "x86util.asm" + +cextern pw_4 +cextern pw_5 + +section .text + +; dst_low, dst_high (src), zero +; zero-extends one vector from 8 to 16 bits +%macro UNPACK_8TO16 4 + mova m%2, m%3 + punpckh%1 m%3, m%4 + punpckl%1 m%2, m%4 +%endmacro + +%macro STORE_4_WORDS_MMX 6 + movd %6, %5 +%if mmsize==16 + psrldq %5, 4 +%else + psrlq %5, 32 +%endif + mov %1, %6w + shr %6, 16 + mov %2, %6w + movd %6, %5 + mov %3, %6w + shr %6, 16 + mov %4, %6w +%endmacro + +%macro STORE_4_WORDS_SSE4 6 + pextrw %1, %5, %6+0 + pextrw %2, %5, %6+1 + pextrw %3, %5, %6+2 + pextrw %4, %5, %6+3 +%endmacro + +; in: p1 p0 q0 q1, clobbers p0 +; out: p1 = (2*(p1 - q1) - 5*(p0 - q0) + 4) >> 3 +%macro VC1_LOOP_FILTER_A0 4 + psubw %1, %4 + psubw %2, %3 + paddw %1, %1 + pmullw %2, [pw_5] + psubw %1, %2 + paddw %1, [pw_4] + psraw %1, 3 +%endmacro + +; in: p0 q0 a0 a1 a2 +; m0 m1 m7 m6 m5 +; %1: size +; out: m0=p0' m1=q0' +%macro VC1_FILTER 1 + PABSW m4, m7 + PABSW m3, m6 + PABSW m2, m5 + mova m6, m4 + pminsw m3, m2 + pcmpgtw m6, m3 ; if (a2 < a0 || a1 < a0) + psubw m3, m4 + pmullw m3, [pw_5] ; 5*(a3 - a0) + PABSW m2, m3 + psraw m2, 3 ; abs(d/8) + pxor m7, m3 ; d_sign ^= a0_sign + + pxor m5, m5 + movd m3, r2 +%if %1 > 4 + punpcklbw m3, m3 +%endif + punpcklbw m3, m5 + pcmpgtw m3, m4 ; if (a0 < pq) + pand m6, m3 + + mova m3, m0 + psubw m3, m1 + PABSW m4, m3 + psraw m4, 1 + pxor m3, m7 ; d_sign ^ clip_sign + psraw m3, 15 + pminsw m2, m4 ; min(d, clip) + pcmpgtw m4, m5 + pand m6, m4 ; filt3 (C return value) + +; each set of 4 pixels is not filtered if the 3rd is not +%if mmsize==16 + pshuflw m4, m6, 0xaa +%if %1 > 4 + pshufhw m4, m4, 0xaa +%endif +%else + pshufw m4, m6, 0xaa +%endif + pandn m3, m4 + pand m2, m6 + pand m3, m2 ; d final + + PSIGNW m3, m7 + psubw m0, m3 + paddw m1, m3 + packuswb m0, m0 + packuswb m1, m1 +%endmacro + +; 1st param: size of filter +; 2nd param: mov suffix equivalent to the filter size +%macro VC1_V_LOOP_FILTER 2 + pxor m5, m5 + mov%2 m6, [r4] + mov%2 m4, [r4+r1] + mov%2 m7, [r4+2*r1] + mov%2 m0, [r4+r3] + punpcklbw m6, m5 + punpcklbw m4, m5 + punpcklbw m7, m5 + punpcklbw m0, m5 + + VC1_LOOP_FILTER_A0 m6, m4, m7, m0 + mov%2 m1, [r0] + mov%2 m2, [r0+r1] + punpcklbw m1, m5 + punpcklbw m2, m5 + mova m4, m0 + VC1_LOOP_FILTER_A0 m7, m4, m1, m2 + mov%2 m3, [r0+2*r1] + mov%2 m4, [r0+r3] + punpcklbw m3, m5 + punpcklbw m4, m5 + mova m5, m1 + VC1_LOOP_FILTER_A0 m5, m2, m3, m4 + + VC1_FILTER %1 + mov%2 [r4+r3], m0 + mov%2 [r0], m1 +%endmacro + +; 1st param: size of filter +; NOTE: UNPACK_8TO16 this number of 8 bit numbers are in half a register +; 2nd (optional) param: temp register to use for storing words +%macro VC1_H_LOOP_FILTER 1-2 +%if %1 == 4 + movq m0, [r0 -4] + movq m1, [r0+ r1-4] + movq m2, [r0+2*r1-4] + movq m3, [r0+ r3-4] + TRANSPOSE4x4B 0, 1, 2, 3, 4 +%else + movq m0, [r0 -4] + movq m4, [r0+ r1-4] + movq m1, [r0+2*r1-4] + movq m5, [r0+ r3-4] + movq m2, [r4 -4] + movq m6, [r4+ r1-4] + movq m3, [r4+2*r1-4] + movq m7, [r4+ r3-4] + punpcklbw m0, m4 + punpcklbw m1, m5 + punpcklbw m2, m6 + punpcklbw m3, m7 + TRANSPOSE4x4W 0, 1, 2, 3, 4 +%endif + pxor m5, m5 + + UNPACK_8TO16 bw, 6, 0, 5 + UNPACK_8TO16 bw, 7, 1, 5 + VC1_LOOP_FILTER_A0 m6, m0, m7, m1 + UNPACK_8TO16 bw, 4, 2, 5 + mova m0, m1 ; m0 = p0 + VC1_LOOP_FILTER_A0 m7, m1, m4, m2 + UNPACK_8TO16 bw, 1, 3, 5 + mova m5, m4 + VC1_LOOP_FILTER_A0 m5, m2, m1, m3 + SWAP 1, 4 ; m1 = q0 + + VC1_FILTER %1 + punpcklbw m0, m1 +%if %0 > 1 + STORE_4_WORDS_MMX [r0-1], [r0+r1-1], [r0+2*r1-1], [r0+r3-1], m0, %2 +%if %1 > 4 + psrldq m0, 4 + STORE_4_WORDS_MMX [r4-1], [r4+r1-1], [r4+2*r1-1], [r4+r3-1], m0, %2 +%endif +%else + STORE_4_WORDS_SSE4 [r0-1], [r0+r1-1], [r0+2*r1-1], [r0+r3-1], m0, 0 + STORE_4_WORDS_SSE4 [r4-1], [r4+r1-1], [r4+2*r1-1], [r4+r3-1], m0, 4 +%endif +%endmacro + + +%macro START_V_FILTER 0 + mov r4, r0 + lea r3, [4*r1] + sub r4, r3 + lea r3, [r1+2*r1] + imul r2, 0x01010101 +%endmacro + +%macro START_H_FILTER 1 + lea r3, [r1+2*r1] +%if %1 > 4 + lea r4, [r0+4*r1] +%endif + imul r2, 0x01010101 +%endmacro + +; I dont know why the sign extension is needed... +%macro PSIGNW_SRA_MMX 2 + psraw %2, 15 + PSIGNW_MMX %1, %2 +%endmacro + + +%macro VC1_LF_MMX 1 +INIT_MMX +cglobal vc1_v_loop_filter_internal_%1 + VC1_V_LOOP_FILTER 4, d + ret + +cglobal vc1_h_loop_filter_internal_%1 + VC1_H_LOOP_FILTER 4, r4 + ret + +; void ff_vc1_v_loop_filter4_mmx2(uint8_t *src, int stride, int pq) +cglobal vc1_v_loop_filter4_%1, 3,5,0 + START_V_FILTER + call vc1_v_loop_filter_internal_%1 + RET + +; void ff_vc1_h_loop_filter4_mmx2(uint8_t *src, int stride, int pq) +cglobal vc1_h_loop_filter4_%1, 3,5,0 + START_H_FILTER 4 + call vc1_h_loop_filter_internal_%1 + RET + +; void ff_vc1_v_loop_filter8_mmx2(uint8_t *src, int stride, int pq) +cglobal vc1_v_loop_filter8_%1, 3,5,0 + START_V_FILTER + call vc1_v_loop_filter_internal_%1 + add r4, 4 + add r0, 4 + call vc1_v_loop_filter_internal_%1 + RET + +; void ff_vc1_h_loop_filter8_mmx2(uint8_t *src, int stride, int pq) +cglobal vc1_h_loop_filter8_%1, 3,5,0 + START_H_FILTER 4 + call vc1_h_loop_filter_internal_%1 + lea r0, [r0+4*r1] + call vc1_h_loop_filter_internal_%1 + RET +%endmacro + +%define PABSW PABSW_MMX +%define PSIGNW PSIGNW_SRA_MMX +VC1_LF_MMX mmx + +%define PABSW PABSW_MMX2 +VC1_LF_MMX mmx2 + +INIT_XMM +; void ff_vc1_v_loop_filter8_sse2(uint8_t *src, int stride, int pq) +cglobal vc1_v_loop_filter8_sse2, 3,5,8 + START_V_FILTER + VC1_V_LOOP_FILTER 8, q + RET + +; void ff_vc1_h_loop_filter8_sse2(uint8_t *src, int stride, int pq) +cglobal vc1_h_loop_filter8_sse2, 3,6,8 + START_H_FILTER 8 + VC1_H_LOOP_FILTER 8, r5 + RET + +%define PABSW PABSW_SSSE3 +%define PSIGNW PSIGNW_SSSE3 + +INIT_MMX +; void ff_vc1_v_loop_filter4_ssse3(uint8_t *src, int stride, int pq) +cglobal vc1_v_loop_filter4_ssse3, 3,5,0 + START_V_FILTER + VC1_V_LOOP_FILTER 4, d + RET + +; void ff_vc1_h_loop_filter4_ssse3(uint8_t *src, int stride, int pq) +cglobal vc1_h_loop_filter4_ssse3, 3,5,0 + START_H_FILTER 4 + VC1_H_LOOP_FILTER 4, r4 + RET + +INIT_XMM +; void ff_vc1_v_loop_filter8_ssse3(uint8_t *src, int stride, int pq) +cglobal vc1_v_loop_filter8_ssse3, 3,5,8 + START_V_FILTER + VC1_V_LOOP_FILTER 8, q + RET + +; void ff_vc1_h_loop_filter8_ssse3(uint8_t *src, int stride, int pq) +cglobal vc1_h_loop_filter8_ssse3, 3,6,8 + START_H_FILTER 8 + VC1_H_LOOP_FILTER 8, r5 + RET + +; void ff_vc1_h_loop_filter8_sse4(uint8_t *src, int stride, int pq) +cglobal vc1_h_loop_filter8_sse4, 3,5,8 + START_H_FILTER 8 + VC1_H_LOOP_FILTER 8 + RET diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vp8dsp-init.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vp8dsp-init.c new file mode 100644 index 000000000..9cd72b695 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vp8dsp-init.c @@ -0,0 +1,318 @@ +/* + * VP8 DSP functions x86-optimized + * Copyright (c) 2010 Ronald S. Bultje + * Copyright (c) 2010 Jason Garrett-Glaser + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/x86_cpu.h" +#include "libavcodec/vp8dsp.h" + +#if HAVE_YASM + +/* + * MC functions + */ +extern void ff_put_vp8_epel4_h4_mmxext(uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_epel4_h6_mmxext(uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_epel4_v4_mmxext(uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_epel4_v6_mmxext(uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); + +extern void ff_put_vp8_epel8_h4_sse2 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_epel8_h6_sse2 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_epel8_v4_sse2 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_epel8_v6_sse2 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); + +extern void ff_put_vp8_epel4_h4_ssse3 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_epel4_h6_ssse3 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_epel4_v4_ssse3 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_epel4_v6_ssse3 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_epel8_h4_ssse3 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_epel8_h6_ssse3 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_epel8_v4_ssse3 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_epel8_v6_ssse3 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); + +extern void ff_put_vp8_bilinear4_h_mmxext(uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_bilinear8_h_sse2 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_bilinear4_h_ssse3 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_bilinear8_h_ssse3 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); + +extern void ff_put_vp8_bilinear4_v_mmxext(uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_bilinear8_v_sse2 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_bilinear4_v_ssse3 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_bilinear8_v_ssse3 (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); + + +extern void ff_put_vp8_pixels8_mmx (uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_pixels16_mmx(uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); +extern void ff_put_vp8_pixels16_sse(uint8_t *dst, int dststride, + uint8_t *src, int srcstride, + int height, int mx, int my); + +#define TAP_W16(OPT, FILTERTYPE, TAPTYPE) \ +static void ff_put_vp8_ ## FILTERTYPE ## 16_ ## TAPTYPE ## _ ## OPT( \ + uint8_t *dst, int dststride, uint8_t *src, \ + int srcstride, int height, int mx, int my) \ +{ \ + ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \ + dst, dststride, src, srcstride, height, mx, my); \ + ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \ + dst + 8, dststride, src + 8, srcstride, height, mx, my); \ +} +#define TAP_W8(OPT, FILTERTYPE, TAPTYPE) \ +static void ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \ + uint8_t *dst, int dststride, uint8_t *src, \ + int srcstride, int height, int mx, int my) \ +{ \ + ff_put_vp8_ ## FILTERTYPE ## 4_ ## TAPTYPE ## _ ## OPT( \ + dst, dststride, src, srcstride, height, mx, my); \ + ff_put_vp8_ ## FILTERTYPE ## 4_ ## TAPTYPE ## _ ## OPT( \ + dst + 4, dststride, src + 4, srcstride, height, mx, my); \ +} + +TAP_W8 (mmxext, epel, h4) +TAP_W8 (mmxext, epel, h6) +TAP_W16(mmxext, epel, h6) +TAP_W8 (mmxext, epel, v4) +TAP_W8 (mmxext, epel, v6) +TAP_W16(mmxext, epel, v6) +TAP_W8 (mmxext, bilinear, h) +TAP_W16(mmxext, bilinear, h) +TAP_W8 (mmxext, bilinear, v) +TAP_W16(mmxext, bilinear, v) + +TAP_W16(sse2, epel, h6) +TAP_W16(sse2, epel, v6) +TAP_W16(sse2, bilinear, h) +TAP_W16(sse2, bilinear, v) + +TAP_W16(ssse3, epel, h6) +TAP_W16(ssse3, epel, v6) +TAP_W16(ssse3, bilinear, h) +TAP_W16(ssse3, bilinear, v) + +#define HVTAP(OPT, ALIGN, TAPNUMX, TAPNUMY, SIZE, MAXHEIGHT) \ +static void ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## v ## TAPNUMY ## _ ## OPT( \ + uint8_t *dst, int dststride, uint8_t *src, \ + int srcstride, int height, int mx, int my) \ +{ \ + DECLARE_ALIGNED(ALIGN, uint8_t, tmp)[SIZE * (MAXHEIGHT + TAPNUMY - 1)]; \ + uint8_t *tmpptr = tmp + SIZE * (TAPNUMY / 2 - 1); \ + src -= srcstride * (TAPNUMY / 2 - 1); \ + ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## _ ## OPT( \ + tmp, SIZE, src, srcstride, height + TAPNUMY - 1, mx, my); \ + ff_put_vp8_epel ## SIZE ## _v ## TAPNUMY ## _ ## OPT( \ + dst, dststride, tmpptr, SIZE, height, mx, my); \ +} + +#define HVTAPMMX(x, y) \ +HVTAP(mmxext, 8, x, y, 4, 8) \ +HVTAP(mmxext, 8, x, y, 8, 16) + +HVTAPMMX(4, 4) +HVTAPMMX(4, 6) +HVTAPMMX(6, 4) +HVTAPMMX(6, 6) +HVTAP(mmxext, 8, 6, 6, 16, 16) + +#define HVTAPSSE2(x, y, w) \ +HVTAP(sse2, 16, x, y, w, 16) \ +HVTAP(ssse3, 16, x, y, w, 16) + +HVTAPSSE2(4, 4, 8) +HVTAPSSE2(4, 6, 8) +HVTAPSSE2(6, 4, 8) +HVTAPSSE2(6, 6, 8) +HVTAPSSE2(6, 6, 16) + +HVTAP(ssse3, 16, 4, 4, 4, 8) +HVTAP(ssse3, 16, 4, 6, 4, 8) +HVTAP(ssse3, 16, 6, 4, 4, 8) +HVTAP(ssse3, 16, 6, 6, 4, 8) + +#define HVBILIN(OPT, ALIGN, SIZE, MAXHEIGHT) \ +static void ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT( \ + uint8_t *dst, int dststride, uint8_t *src, \ + int srcstride, int height, int mx, int my) \ +{ \ + DECLARE_ALIGNED(ALIGN, uint8_t, tmp)[SIZE * (MAXHEIGHT + 2)]; \ + ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT( \ + tmp, SIZE, src, srcstride, height + 1, mx, my); \ + ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT( \ + dst, dststride, tmp, SIZE, height, mx, my); \ +} + +HVBILIN(mmxext, 8, 4, 8) +HVBILIN(mmxext, 8, 8, 16) +HVBILIN(mmxext, 8, 16, 16) +HVBILIN(sse2, 8, 8, 16) +HVBILIN(sse2, 8, 16, 16) +HVBILIN(ssse3, 8, 4, 8) +HVBILIN(ssse3, 8, 8, 16) +HVBILIN(ssse3, 8, 16, 16) + +extern void ff_vp8_idct_dc_add_mmx(uint8_t *dst, DCTELEM block[16], int stride); +extern void ff_vp8_idct_dc_add_sse4(uint8_t *dst, DCTELEM block[16], int stride); +extern void ff_vp8_luma_dc_wht_mmxext(DCTELEM block[4][4][16], DCTELEM dc[16]); +extern void ff_vp8_idct_add_mmx(uint8_t *dst, DCTELEM block[16], int stride); + +extern void ff_vp8_v_loop_filter_simple_mmx (uint8_t *dst, int stride, int flim); +extern void ff_vp8_v_loop_filter_simple_mmxext(uint8_t *dst, int stride, int flim); +extern void ff_vp8_v_loop_filter_simple_sse2 (uint8_t *dst, int stride, int flim); +extern void ff_vp8_h_loop_filter_simple_mmx (uint8_t *dst, int stride, int flim); +extern void ff_vp8_h_loop_filter_simple_mmxext(uint8_t *dst, int stride, int flim); +extern void ff_vp8_h_loop_filter_simple_sse2 (uint8_t *dst, int stride, int flim); +#endif + +#define VP8_LUMA_MC_FUNC(IDX, SIZE, OPT) \ + c->put_vp8_epel_pixels_tab[IDX][0][2] = ff_put_vp8_epel ## SIZE ## _h6_ ## OPT; \ + c->put_vp8_epel_pixels_tab[IDX][2][0] = ff_put_vp8_epel ## SIZE ## _v6_ ## OPT; \ + c->put_vp8_epel_pixels_tab[IDX][2][2] = ff_put_vp8_epel ## SIZE ## _h6v6_ ## OPT + +#define VP8_MC_FUNC(IDX, SIZE, OPT) \ + c->put_vp8_epel_pixels_tab[IDX][0][1] = ff_put_vp8_epel ## SIZE ## _h4_ ## OPT; \ + c->put_vp8_epel_pixels_tab[IDX][1][0] = ff_put_vp8_epel ## SIZE ## _v4_ ## OPT; \ + c->put_vp8_epel_pixels_tab[IDX][1][1] = ff_put_vp8_epel ## SIZE ## _h4v4_ ## OPT; \ + c->put_vp8_epel_pixels_tab[IDX][1][2] = ff_put_vp8_epel ## SIZE ## _h6v4_ ## OPT; \ + c->put_vp8_epel_pixels_tab[IDX][2][1] = ff_put_vp8_epel ## SIZE ## _h4v6_ ## OPT; \ + VP8_LUMA_MC_FUNC(IDX, SIZE, OPT) + +#define VP8_BILINEAR_MC_FUNC(IDX, SIZE, OPT) \ + c->put_vp8_bilinear_pixels_tab[IDX][0][1] = ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT; \ + c->put_vp8_bilinear_pixels_tab[IDX][0][2] = ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT; \ + c->put_vp8_bilinear_pixels_tab[IDX][1][0] = ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT; \ + c->put_vp8_bilinear_pixels_tab[IDX][1][1] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \ + c->put_vp8_bilinear_pixels_tab[IDX][1][2] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \ + c->put_vp8_bilinear_pixels_tab[IDX][2][0] = ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT; \ + c->put_vp8_bilinear_pixels_tab[IDX][2][1] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \ + c->put_vp8_bilinear_pixels_tab[IDX][2][2] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT + + +av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c) +{ + mm_flags = mm_support(); + +#if HAVE_YASM + if (mm_flags & FF_MM_MMX) { + c->vp8_idct_dc_add = ff_vp8_idct_dc_add_mmx; + c->vp8_idct_add = ff_vp8_idct_add_mmx; + c->put_vp8_epel_pixels_tab[0][0][0] = + c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_mmx; + c->put_vp8_epel_pixels_tab[1][0][0] = + c->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_mmx; + + c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmx; + c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmx; + } + + /* note that 4-tap width=16 functions are missing because w=16 + * is only used for luma, and luma is always a copy or sixtap. */ + if (mm_flags & FF_MM_MMX2) { + c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_mmxext; + VP8_LUMA_MC_FUNC(0, 16, mmxext); + VP8_MC_FUNC(1, 8, mmxext); + VP8_MC_FUNC(2, 4, mmxext); + VP8_BILINEAR_MC_FUNC(0, 16, mmxext); + VP8_BILINEAR_MC_FUNC(1, 8, mmxext); + VP8_BILINEAR_MC_FUNC(2, 4, mmxext); + + c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmxext; + c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmxext; + } + + if (mm_flags & FF_MM_SSE) { + c->put_vp8_epel_pixels_tab[0][0][0] = + c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_sse; + } + + if (mm_flags & FF_MM_SSE2) { + VP8_LUMA_MC_FUNC(0, 16, sse2); + VP8_MC_FUNC(1, 8, sse2); + VP8_BILINEAR_MC_FUNC(0, 16, sse2); + VP8_BILINEAR_MC_FUNC(1, 8, sse2); + + c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_sse2; + c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_sse2; + } + + if (mm_flags & FF_MM_SSSE3) { + VP8_LUMA_MC_FUNC(0, 16, ssse3); + VP8_MC_FUNC(1, 8, ssse3); + VP8_MC_FUNC(2, 4, ssse3); + VP8_BILINEAR_MC_FUNC(0, 16, ssse3); + VP8_BILINEAR_MC_FUNC(1, 8, ssse3); + VP8_BILINEAR_MC_FUNC(2, 4, ssse3); + } + + if (mm_flags & FF_MM_SSE4) { + c->vp8_idct_dc_add = ff_vp8_idct_dc_add_sse4; + } +#endif +} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vp8dsp.asm b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vp8dsp.asm new file mode 100644 index 000000000..aedd09e5a --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/vp8dsp.asm @@ -0,0 +1,1371 @@ +;****************************************************************************** +;* VP8 MMXEXT optimizations +;* Copyright (c) 2010 Ronald S. Bultje +;* Copyright (c) 2010 Jason Garrett-Glaser +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "x86inc.asm" +%include "x86util.asm" + +SECTION_RODATA + +fourtap_filter_hw_m: times 4 dw -6, 123 + times 4 dw 12, -1 + times 4 dw -9, 93 + times 4 dw 50, -6 + times 4 dw -6, 50 + times 4 dw 93, -9 + times 4 dw -1, 12 + times 4 dw 123, -6 + +sixtap_filter_hw_m: times 4 dw 2, -11 + times 4 dw 108, 36 + times 4 dw -8, 1 + times 4 dw 3, -16 + times 4 dw 77, 77 + times 4 dw -16, 3 + times 4 dw 1, -8 + times 4 dw 36, 108 + times 4 dw -11, 2 + +fourtap_filter_hb_m: times 8 db -6, 123 + times 8 db 12, -1 + times 8 db -9, 93 + times 8 db 50, -6 + times 8 db -6, 50 + times 8 db 93, -9 + times 8 db -1, 12 + times 8 db 123, -6 + +sixtap_filter_hb_m: times 8 db 2, 1 + times 8 db -11, 108 + times 8 db 36, -8 + times 8 db 3, 3 + times 8 db -16, 77 + times 8 db 77, -16 + times 8 db 1, 2 + times 8 db -8, 36 + times 8 db 108, -11 + +fourtap_filter_v_m: times 8 dw -6 + times 8 dw 123 + times 8 dw 12 + times 8 dw -1 + times 8 dw -9 + times 8 dw 93 + times 8 dw 50 + times 8 dw -6 + times 8 dw -6 + times 8 dw 50 + times 8 dw 93 + times 8 dw -9 + times 8 dw -1 + times 8 dw 12 + times 8 dw 123 + times 8 dw -6 + +sixtap_filter_v_m: times 8 dw 2 + times 8 dw -11 + times 8 dw 108 + times 8 dw 36 + times 8 dw -8 + times 8 dw 1 + times 8 dw 3 + times 8 dw -16 + times 8 dw 77 + times 8 dw 77 + times 8 dw -16 + times 8 dw 3 + times 8 dw 1 + times 8 dw -8 + times 8 dw 36 + times 8 dw 108 + times 8 dw -11 + times 8 dw 2 + +bilinear_filter_vw_m: times 8 dw 1 + times 8 dw 2 + times 8 dw 3 + times 8 dw 4 + times 8 dw 5 + times 8 dw 6 + times 8 dw 7 + +bilinear_filter_vb_m: times 8 db 7, 1 + times 8 db 6, 2 + times 8 db 5, 3 + times 8 db 4, 4 + times 8 db 3, 5 + times 8 db 2, 6 + times 8 db 1, 7 + +%ifdef PIC +%define fourtap_filter_hw r11 +%define sixtap_filter_hw r11 +%define fourtap_filter_hb r11 +%define sixtap_filter_hb r11 +%define fourtap_filter_v r11 +%define sixtap_filter_v r11 +%define bilinear_filter_vw r11 +%define bilinear_filter_vb r11 +%else +%define fourtap_filter_hw fourtap_filter_hw_m +%define sixtap_filter_hw sixtap_filter_hw_m +%define fourtap_filter_hb fourtap_filter_hb_m +%define sixtap_filter_hb sixtap_filter_hb_m +%define fourtap_filter_v fourtap_filter_v_m +%define sixtap_filter_v sixtap_filter_v_m +%define bilinear_filter_vw bilinear_filter_vw_m +%define bilinear_filter_vb bilinear_filter_vb_m +%endif + +filter_h2_shuf: db 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 +filter_h4_shuf: db 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10 + +filter_h6_shuf1: db 0, 5, 1, 6, 2, 7, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12 +filter_h6_shuf2: db 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9 +filter_h6_shuf3: db 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11 + +pw_20091: times 4 dw 20091 +pw_17734: times 4 dw 17734 + +cextern pw_3 +cextern pb_3 +cextern pw_4 +cextern pb_4 +cextern pw_64 +cextern pb_80 +cextern pb_F8 +cextern pb_FE + +SECTION .text + +;----------------------------------------------------------------------------- +; subpel MC functions: +; +; void put_vp8_epel_hv_(uint8_t *dst, int deststride, +; uint8_t *src, int srcstride, +; int height, int mx, int my); +;----------------------------------------------------------------------------- + +%macro FILTER_SSSE3 3 +cglobal put_vp8_epel%1_h6_ssse3, 6, 6, %2 + lea r5d, [r5*3] + mova m3, [filter_h6_shuf2] + mova m4, [filter_h6_shuf3] +%ifdef PIC + lea r11, [sixtap_filter_hb_m] +%endif + mova m5, [sixtap_filter_hb+r5*8-48] ; set up 6tap filter in bytes + mova m6, [sixtap_filter_hb+r5*8-32] + mova m7, [sixtap_filter_hb+r5*8-16] + +.nextrow + movu m0, [r2-2] + mova m1, m0 + mova m2, m0 +%ifidn %1, 4 +; For epel4, we need 9 bytes, but only 8 get loaded; to compensate, do the +; shuffle with a memory operand + punpcklbw m0, [r2+3] +%else + pshufb m0, [filter_h6_shuf1] +%endif + pshufb m1, m3 + pshufb m2, m4 + pmaddubsw m0, m5 + pmaddubsw m1, m6 + pmaddubsw m2, m7 + paddsw m0, m1 + paddsw m0, m2 + paddsw m0, [pw_64] + psraw m0, 7 + packuswb m0, m0 + movh [r0], m0 ; store + + ; go to next line + add r0, r1 + add r2, r3 + dec r4 ; next row + jg .nextrow + REP_RET + +cglobal put_vp8_epel%1_h4_ssse3, 6, 6, %3 + shl r5d, 4 + mova m2, [pw_64] + mova m3, [filter_h2_shuf] + mova m4, [filter_h4_shuf] +%ifdef PIC + lea r11, [fourtap_filter_hb_m] +%endif + mova m5, [fourtap_filter_hb+r5-16] ; set up 4tap filter in bytes + mova m6, [fourtap_filter_hb+r5] + +.nextrow + movu m0, [r2-1] + mova m1, m0 + pshufb m0, m3 + pshufb m1, m4 + pmaddubsw m0, m5 + pmaddubsw m1, m6 + paddsw m0, m2 + paddsw m0, m1 + psraw m0, 7 + packuswb m0, m0 + movh [r0], m0 ; store + + ; go to next line + add r0, r1 + add r2, r3 + dec r4 ; next row + jg .nextrow + REP_RET + +cglobal put_vp8_epel%1_v4_ssse3, 7, 7, %2 + shl r6d, 4 +%ifdef PIC + lea r11, [fourtap_filter_hb_m] +%endif + mova m5, [fourtap_filter_hb+r6-16] + mova m6, [fourtap_filter_hb+r6] + mova m7, [pw_64] + + ; read 3 lines + sub r2, r3 + movh m0, [r2] + movh m1, [r2+ r3] + movh m2, [r2+2*r3] + add r2, r3 + +.nextrow + movh m3, [r2+2*r3] ; read new row + mova m4, m0 + mova m0, m1 + punpcklbw m4, m1 + mova m1, m2 + punpcklbw m2, m3 + pmaddubsw m4, m5 + pmaddubsw m2, m6 + paddsw m4, m2 + mova m2, m3 + paddsw m4, m7 + psraw m4, 7 + packuswb m4, m4 + movh [r0], m4 + + ; go to next line + add r0, r1 + add r2, r3 + dec r4 ; next row + jg .nextrow + REP_RET + +cglobal put_vp8_epel%1_v6_ssse3, 7, 7, %2 + lea r6d, [r6*3] +%ifdef PIC + lea r11, [sixtap_filter_hb_m] +%endif + lea r6, [sixtap_filter_hb+r6*8] + + ; read 5 lines + sub r2, r3 + sub r2, r3 + movh m0, [r2] + movh m1, [r2+r3] + movh m2, [r2+r3*2] + lea r2, [r2+r3*2] + add r2, r3 + movh m3, [r2] + movh m4, [r2+r3] + +.nextrow + movh m5, [r2+2*r3] ; read new row + mova m6, m0 + punpcklbw m6, m5 + mova m0, m1 + punpcklbw m1, m2 + mova m7, m3 + punpcklbw m7, m4 + pmaddubsw m6, [r6-48] + pmaddubsw m1, [r6-32] + pmaddubsw m7, [r6-16] + paddsw m6, m1 + paddsw m6, m7 + mova m1, m2 + paddsw m6, [pw_64] + mova m2, m3 + psraw m6, 7 + mova m3, m4 + packuswb m6, m6 + mova m4, m5 + movh [r0], m6 + + ; go to next line + add r0, r1 + add r2, r3 + dec r4 ; next row + jg .nextrow + REP_RET +%endmacro + +INIT_MMX +FILTER_SSSE3 4, 0, 0 +INIT_XMM +FILTER_SSSE3 8, 8, 7 + +; 4x4 block, H-only 4-tap filter +cglobal put_vp8_epel4_h4_mmxext, 6, 6 + shl r5d, 4 +%ifdef PIC + lea r11, [fourtap_filter_hw_m] +%endif + movq mm4, [fourtap_filter_hw+r5-16] ; set up 4tap filter in words + movq mm5, [fourtap_filter_hw+r5] + movq mm7, [pw_64] + pxor mm6, mm6 + +.nextrow + movq mm1, [r2-1] ; (ABCDEFGH) load 8 horizontal pixels + + ; first set of 2 pixels + movq mm2, mm1 ; byte ABCD.. + punpcklbw mm1, mm6 ; byte->word ABCD + pshufw mm0, mm2, 9 ; byte CDEF.. + punpcklbw mm0, mm6 ; byte->word CDEF + pshufw mm3, mm1, 0x94 ; word ABBC + pshufw mm1, mm0, 0x94 ; word CDDE + pmaddwd mm3, mm4 ; multiply 2px with F0/F1 + movq mm0, mm1 ; backup for second set of pixels + pmaddwd mm1, mm5 ; multiply 2px with F2/F3 + paddd mm3, mm1 ; finish 1st 2px + + ; second set of 2 pixels, use backup of above + punpckhbw mm2, mm6 ; byte->word EFGH + pmaddwd mm0, mm4 ; multiply backed up 2px with F0/F1 + pshufw mm1, mm2, 0x94 ; word EFFG + pmaddwd mm1, mm5 ; multiply 2px with F2/F3 + paddd mm0, mm1 ; finish 2nd 2px + + ; merge two sets of 2 pixels into one set of 4, round/clip/store + packssdw mm3, mm0 ; merge dword->word (4px) + paddsw mm3, mm7 ; rounding + psraw mm3, 7 + packuswb mm3, mm6 ; clip and word->bytes + movd [r0], mm3 ; store + + ; go to next line + add r0, r1 + add r2, r3 + dec r4 ; next row + jg .nextrow + REP_RET + +; 4x4 block, H-only 6-tap filter +cglobal put_vp8_epel4_h6_mmxext, 6, 6 + lea r5d, [r5*3] +%ifdef PIC + lea r11, [sixtap_filter_hw_m] +%endif + movq mm4, [sixtap_filter_hw+r5*8-48] ; set up 4tap filter in words + movq mm5, [sixtap_filter_hw+r5*8-32] + movq mm6, [sixtap_filter_hw+r5*8-16] + movq mm7, [pw_64] + pxor mm3, mm3 + +.nextrow + movq mm1, [r2-2] ; (ABCDEFGH) load 8 horizontal pixels + + ; first set of 2 pixels + movq mm2, mm1 ; byte ABCD.. + punpcklbw mm1, mm3 ; byte->word ABCD + pshufw mm0, mm2, 0x9 ; byte CDEF.. + punpckhbw mm2, mm3 ; byte->word EFGH + punpcklbw mm0, mm3 ; byte->word CDEF + pshufw mm1, mm1, 0x94 ; word ABBC + pshufw mm2, mm2, 0x94 ; word EFFG + pmaddwd mm1, mm4 ; multiply 2px with F0/F1 + pshufw mm3, mm0, 0x94 ; word CDDE + movq mm0, mm3 ; backup for second set of pixels + pmaddwd mm3, mm5 ; multiply 2px with F2/F3 + paddd mm1, mm3 ; add to 1st 2px cache + movq mm3, mm2 ; backup for second set of pixels + pmaddwd mm2, mm6 ; multiply 2px with F4/F5 + paddd mm1, mm2 ; finish 1st 2px + + ; second set of 2 pixels, use backup of above + movd mm2, [r2+3] ; byte FGHI (prevent overreads) + pmaddwd mm0, mm4 ; multiply 1st backed up 2px with F0/F1 + pmaddwd mm3, mm5 ; multiply 2nd backed up 2px with F2/F3 + paddd mm0, mm3 ; add to 2nd 2px cache + pxor mm3, mm3 + punpcklbw mm2, mm3 ; byte->word FGHI + pshufw mm2, mm2, 0xE9 ; word GHHI + pmaddwd mm2, mm6 ; multiply 2px with F4/F5 + paddd mm0, mm2 ; finish 2nd 2px + + ; merge two sets of 2 pixels into one set of 4, round/clip/store + packssdw mm1, mm0 ; merge dword->word (4px) + paddsw mm1, mm7 ; rounding + psraw mm1, 7 + packuswb mm1, mm3 ; clip and word->bytes + movd [r0], mm1 ; store + + ; go to next line + add r0, r1 + add r2, r3 + dec r4 ; next row + jg .nextrow + REP_RET + +; 4x4 block, H-only 4-tap filter +INIT_XMM +cglobal put_vp8_epel8_h4_sse2, 6, 6, 8 + shl r5d, 4 +%ifdef PIC + lea r11, [fourtap_filter_hw_m] +%endif + mova m5, [fourtap_filter_hw+r5-16] ; set up 4tap filter in words + mova m6, [fourtap_filter_hw+r5] + pxor m7, m7 + +.nextrow + movh m0, [r2-1] + punpcklbw m0, m7 ; ABCDEFGH + mova m1, m0 + mova m2, m0 + mova m3, m0 + psrldq m1, 2 ; BCDEFGH + psrldq m2, 4 ; CDEFGH + psrldq m3, 6 ; DEFGH + punpcklwd m0, m1 ; ABBCCDDE + punpcklwd m2, m3 ; CDDEEFFG + pmaddwd m0, m5 + pmaddwd m2, m6 + paddd m0, m2 + + movh m1, [r2+3] + punpcklbw m1, m7 ; ABCDEFGH + mova m2, m1 + mova m3, m1 + mova m4, m1 + psrldq m2, 2 ; BCDEFGH + psrldq m3, 4 ; CDEFGH + psrldq m4, 6 ; DEFGH + punpcklwd m1, m2 ; ABBCCDDE + punpcklwd m3, m4 ; CDDEEFFG + pmaddwd m1, m5 + pmaddwd m3, m6 + paddd m1, m3 + + packssdw m0, m1 + paddsw m0, [pw_64] + psraw m0, 7 + packuswb m0, m7 + movh [r0], m0 ; store + + ; go to next line + add r0, r1 + add r2, r3 + dec r4 ; next row + jg .nextrow + REP_RET + +cglobal put_vp8_epel8_h6_sse2, 6, 6, 8 + lea r5d, [r5*3] +%ifdef PIC + lea r11, [sixtap_filter_hw_m] +%endif + lea r5, [sixtap_filter_hw+r5*8] + pxor m7, m7 + +.nextrow + movu m0, [r2-2] + mova m6, m0 + mova m4, m0 + punpcklbw m0, m7 ; ABCDEFGHI + mova m1, m0 + mova m2, m0 + mova m3, m0 + psrldq m1, 2 ; BCDEFGH + psrldq m2, 4 ; CDEFGH + psrldq m3, 6 ; DEFGH + psrldq m4, 4 + punpcklbw m4, m7 ; EFGH + mova m5, m4 + psrldq m5, 2 ; FGH + punpcklwd m0, m1 ; ABBCCDDE + punpcklwd m2, m3 ; CDDEEFFG + punpcklwd m4, m5 ; EFFGGHHI + pmaddwd m0, [r5-48] + pmaddwd m2, [r5-32] + pmaddwd m4, [r5-16] + paddd m0, m2 + paddd m0, m4 + + psrldq m6, 4 + mova m4, m6 + punpcklbw m6, m7 ; ABCDEFGHI + mova m1, m6 + mova m2, m6 + mova m3, m6 + psrldq m1, 2 ; BCDEFGH + psrldq m2, 4 ; CDEFGH + psrldq m3, 6 ; DEFGH + psrldq m4, 4 + punpcklbw m4, m7 ; EFGH + mova m5, m4 + psrldq m5, 2 ; FGH + punpcklwd m6, m1 ; ABBCCDDE + punpcklwd m2, m3 ; CDDEEFFG + punpcklwd m4, m5 ; EFFGGHHI + pmaddwd m6, [r5-48] + pmaddwd m2, [r5-32] + pmaddwd m4, [r5-16] + paddd m6, m2 + paddd m6, m4 + + packssdw m0, m6 + paddsw m0, [pw_64] + psraw m0, 7 + packuswb m0, m7 + movh [r0], m0 ; store + + ; go to next line + add r0, r1 + add r2, r3 + dec r4 ; next row + jg .nextrow + REP_RET + +%macro FILTER_V 3 +; 4x4 block, V-only 4-tap filter +cglobal put_vp8_epel%2_v4_%1, 7, 7, %3 + shl r6d, 5 +%ifdef PIC + lea r11, [fourtap_filter_v_m] +%endif + lea r6, [fourtap_filter_v+r6-32] + mova m6, [pw_64] + pxor m7, m7 + mova m5, [r6+48] + + ; read 3 lines + sub r2, r3 + movh m0, [r2] + movh m1, [r2+ r3] + movh m2, [r2+2*r3] + add r2, r3 + punpcklbw m0, m7 + punpcklbw m1, m7 + punpcklbw m2, m7 + +.nextrow + ; first calculate negative taps (to prevent losing positive overflows) + movh m4, [r2+2*r3] ; read new row + punpcklbw m4, m7 + mova m3, m4 + pmullw m0, [r6+0] + pmullw m4, m5 + paddsw m4, m0 + + ; then calculate positive taps + mova m0, m1 + pmullw m1, [r6+16] + paddsw m4, m1 + mova m1, m2 + pmullw m2, [r6+32] + paddsw m4, m2 + mova m2, m3 + + ; round/clip/store + paddsw m4, m6 + psraw m4, 7 + packuswb m4, m7 + movh [r0], m4 + + ; go to next line + add r0, r1 + add r2, r3 + dec r4 ; next row + jg .nextrow + REP_RET + + +; 4x4 block, V-only 6-tap filter +cglobal put_vp8_epel%2_v6_%1, 7, 7, %3 + shl r6d, 4 + lea r6, [r6*3] +%ifdef PIC + lea r11, [sixtap_filter_v_m] +%endif + lea r6, [sixtap_filter_v+r6-96] + pxor m7, m7 + + ; read 5 lines + sub r2, r3 + sub r2, r3 + movh m0, [r2] + movh m1, [r2+r3] + movh m2, [r2+r3*2] + lea r2, [r2+r3*2] + add r2, r3 + movh m3, [r2] + movh m4, [r2+r3] + punpcklbw m0, m7 + punpcklbw m1, m7 + punpcklbw m2, m7 + punpcklbw m3, m7 + punpcklbw m4, m7 + +.nextrow + ; first calculate negative taps (to prevent losing positive overflows) + mova m5, m1 + pmullw m5, [r6+16] + mova m6, m4 + pmullw m6, [r6+64] + paddsw m6, m5 + + ; then calculate positive taps + movh m5, [r2+2*r3] ; read new row + punpcklbw m5, m7 + pmullw m0, [r6+0] + paddsw m6, m0 + mova m0, m1 + mova m1, m2 + pmullw m2, [r6+32] + paddsw m6, m2 + mova m2, m3 + pmullw m3, [r6+48] + paddsw m6, m3 + mova m3, m4 + mova m4, m5 + pmullw m5, [r6+80] + paddsw m6, m5 + + ; round/clip/store + paddsw m6, [pw_64] + psraw m6, 7 + packuswb m6, m7 + movh [r0], m6 + + ; go to next line + add r0, r1 + add r2, r3 + dec r4 ; next row + jg .nextrow + REP_RET +%endmacro + +INIT_MMX +FILTER_V mmxext, 4, 0 +INIT_XMM +FILTER_V sse2, 8, 8 + +%macro FILTER_BILINEAR 3 +cglobal put_vp8_bilinear%2_v_%1, 7,7,%3 + mov r5d, 8*16 + shl r6d, 4 + sub r5d, r6d +%ifdef PIC + lea r11, [bilinear_filter_vw_m] +%endif + pxor m6, m6 + mova m4, [bilinear_filter_vw+r5-16] + mova m5, [bilinear_filter_vw+r6-16] +.nextrow + movh m0, [r2+r3*0] + movh m1, [r2+r3*1] + movh m3, [r2+r3*2] + punpcklbw m0, m6 + punpcklbw m1, m6 + punpcklbw m3, m6 + mova m2, m1 + pmullw m0, m4 + pmullw m1, m5 + pmullw m2, m4 + pmullw m3, m5 + paddsw m0, m1 + paddsw m2, m3 + psraw m0, 2 + psraw m2, 2 + pavgw m0, m6 + pavgw m2, m6 +%ifidn %1, mmxext + packuswb m0, m0 + packuswb m2, m2 + movh [r0+r1*0], m0 + movh [r0+r1*1], m2 +%else + packuswb m0, m2 + movh [r0+r1*0], m0 + movhps [r0+r1*1], m0 +%endif + + lea r0, [r0+r1*2] + lea r2, [r2+r3*2] + sub r4, 2 + jg .nextrow + REP_RET + +cglobal put_vp8_bilinear%2_h_%1, 7,7,%3 + mov r6d, 8*16 + shl r5d, 4 + sub r6d, r5d +%ifdef PIC + lea r11, [bilinear_filter_vw_m] +%endif + pxor m6, m6 + mova m4, [bilinear_filter_vw+r6-16] + mova m5, [bilinear_filter_vw+r5-16] +.nextrow + movh m0, [r2+r3*0+0] + movh m1, [r2+r3*0+1] + movh m2, [r2+r3*1+0] + movh m3, [r2+r3*1+1] + punpcklbw m0, m6 + punpcklbw m1, m6 + punpcklbw m2, m6 + punpcklbw m3, m6 + pmullw m0, m4 + pmullw m1, m5 + pmullw m2, m4 + pmullw m3, m5 + paddsw m0, m1 + paddsw m2, m3 + psraw m0, 2 + psraw m2, 2 + pavgw m0, m6 + pavgw m2, m6 +%ifidn %1, mmxext + packuswb m0, m0 + packuswb m2, m2 + movh [r0+r1*0], m0 + movh [r0+r1*1], m2 +%else + packuswb m0, m2 + movh [r0+r1*0], m0 + movhps [r0+r1*1], m0 +%endif + + lea r0, [r0+r1*2] + lea r2, [r2+r3*2] + sub r4, 2 + jg .nextrow + REP_RET +%endmacro + +INIT_MMX +FILTER_BILINEAR mmxext, 4, 0 +INIT_XMM +FILTER_BILINEAR sse2, 8, 7 + +%macro FILTER_BILINEAR_SSSE3 1 +cglobal put_vp8_bilinear%1_v_ssse3, 7,7 + shl r6d, 4 +%ifdef PIC + lea r11, [bilinear_filter_vb_m] +%endif + pxor m4, m4 + mova m3, [bilinear_filter_vb+r6-16] +.nextrow + movh m0, [r2+r3*0] + movh m1, [r2+r3*1] + movh m2, [r2+r3*2] + punpcklbw m0, m1 + punpcklbw m1, m2 + pmaddubsw m0, m3 + pmaddubsw m1, m3 + psraw m0, 2 + psraw m1, 2 + pavgw m0, m4 + pavgw m1, m4 +%if mmsize==8 + packuswb m0, m0 + packuswb m1, m1 + movh [r0+r1*0], m0 + movh [r0+r1*1], m1 +%else + packuswb m0, m1 + movh [r0+r1*0], m0 + movhps [r0+r1*1], m0 +%endif + + lea r0, [r0+r1*2] + lea r2, [r2+r3*2] + sub r4, 2 + jg .nextrow + REP_RET + +cglobal put_vp8_bilinear%1_h_ssse3, 7,7 + shl r5d, 4 +%ifdef PIC + lea r11, [bilinear_filter_vb_m] +%endif + pxor m4, m4 + mova m2, [filter_h2_shuf] + mova m3, [bilinear_filter_vb+r5-16] +.nextrow + movu m0, [r2+r3*0] + movu m1, [r2+r3*1] + pshufb m0, m2 + pshufb m1, m2 + pmaddubsw m0, m3 + pmaddubsw m1, m3 + psraw m0, 2 + psraw m1, 2 + pavgw m0, m4 + pavgw m1, m4 +%if mmsize==8 + packuswb m0, m0 + packuswb m1, m1 + movh [r0+r1*0], m0 + movh [r0+r1*1], m1 +%else + packuswb m0, m1 + movh [r0+r1*0], m0 + movhps [r0+r1*1], m0 +%endif + + lea r0, [r0+r1*2] + lea r2, [r2+r3*2] + sub r4, 2 + jg .nextrow + REP_RET +%endmacro + +INIT_MMX +FILTER_BILINEAR_SSSE3 4 +INIT_XMM +FILTER_BILINEAR_SSSE3 8 + +cglobal put_vp8_pixels8_mmx, 5,5 +.nextrow: + movq mm0, [r2+r3*0] + movq mm1, [r2+r3*1] + lea r2, [r2+r3*2] + movq [r0+r1*0], mm0 + movq [r0+r1*1], mm1 + lea r0, [r0+r1*2] + sub r4d, 2 + jg .nextrow + REP_RET + +cglobal put_vp8_pixels16_mmx, 5,5 +.nextrow: + movq mm0, [r2+r3*0+0] + movq mm1, [r2+r3*0+8] + movq mm2, [r2+r3*1+0] + movq mm3, [r2+r3*1+8] + lea r2, [r2+r3*2] + movq [r0+r1*0+0], mm0 + movq [r0+r1*0+8], mm1 + movq [r0+r1*1+0], mm2 + movq [r0+r1*1+8], mm3 + lea r0, [r0+r1*2] + sub r4d, 2 + jg .nextrow + REP_RET + +cglobal put_vp8_pixels16_sse, 5,5,2 +.nextrow: + movups xmm0, [r2+r3*0] + movups xmm1, [r2+r3*1] + lea r2, [r2+r3*2] + movaps [r0+r1*0], xmm0 + movaps [r0+r1*1], xmm1 + lea r0, [r0+r1*2] + sub r4d, 2 + jg .nextrow + REP_RET + +;----------------------------------------------------------------------------- +; IDCT functions: +; +; void vp8_idct_dc_add_(uint8_t *dst, DCTELEM block[16], int stride); +;----------------------------------------------------------------------------- + +cglobal vp8_idct_dc_add_mmx, 3, 3 + ; load data + movd mm0, [r1] + + ; calculate DC + paddw mm0, [pw_4] + pxor mm1, mm1 + psraw mm0, 3 + psubw mm1, mm0 + packuswb mm0, mm0 + packuswb mm1, mm1 + punpcklbw mm0, mm0 + punpcklbw mm1, mm1 + punpcklwd mm0, mm0 + punpcklwd mm1, mm1 + + ; add DC + lea r1, [r0+r2*2] + movd mm2, [r0] + movd mm3, [r0+r2] + movd mm4, [r1] + movd mm5, [r1+r2] + paddusb mm2, mm0 + paddusb mm3, mm0 + paddusb mm4, mm0 + paddusb mm5, mm0 + psubusb mm2, mm1 + psubusb mm3, mm1 + psubusb mm4, mm1 + psubusb mm5, mm1 + movd [r0], mm2 + movd [r0+r2], mm3 + movd [r1], mm4 + movd [r1+r2], mm5 + RET + +cglobal vp8_idct_dc_add_sse4, 3, 3, 6 + ; load data + movd xmm0, [r1] + lea r1, [r0+r2*2] + pxor xmm1, xmm1 + movq xmm2, [pw_4] + + ; calculate DC + paddw xmm0, xmm2 + movd xmm2, [r0] + movd xmm3, [r0+r2] + movd xmm4, [r1] + movd xmm5, [r1+r2] + psraw xmm0, 3 + pshuflw xmm0, xmm0, 0 + punpcklqdq xmm0, xmm0 + punpckldq xmm2, xmm3 + punpckldq xmm4, xmm5 + punpcklbw xmm2, xmm1 + punpcklbw xmm4, xmm1 + paddw xmm2, xmm0 + paddw xmm4, xmm0 + packuswb xmm2, xmm4 + movd [r0], xmm2 + pextrd [r0+r2], xmm2, 1 + pextrd [r1], xmm2, 2 + pextrd [r1+r2], xmm2, 3 + RET + +;----------------------------------------------------------------------------- +; void vp8_idct_add_(uint8_t *dst, DCTELEM block[16], int stride); +;----------------------------------------------------------------------------- + +; calculate %1=mul_35468(%1)-mul_20091(%2); %2=mul_20091(%1)+mul_35468(%2) +; this macro assumes that m6/m7 have words for 20091/17734 loaded +%macro VP8_MULTIPLY_SUMSUB 4 + mova %3, %1 + mova %4, %2 + pmulhw %3, m6 ;20091(1) + pmulhw %4, m6 ;20091(2) + paddw %3, %1 + paddw %4, %2 + paddw %1, %1 + paddw %2, %2 + pmulhw %1, m7 ;35468(1) + pmulhw %2, m7 ;35468(2) + psubw %1, %4 + paddw %2, %3 +%endmacro + +; calculate x0=%1+%3; x1=%1-%3 +; x2=mul_35468(%2)-mul_20091(%4); x3=mul_20091(%2)+mul_35468(%4) +; %1=x0+x3 (tmp0); %2=x1+x2 (tmp1); %3=x1-x2 (tmp2); %4=x0-x3 (tmp3) +; %5/%6 are temporary registers +; we assume m6/m7 have constant words 20091/17734 loaded in them +%macro VP8_IDCT_TRANSFORM4x4_1D 6 + SUMSUB_BA m%3, m%1, m%5 ;t0, t1 + VP8_MULTIPLY_SUMSUB m%2, m%4, m%5,m%6 ;t2, t3 + SUMSUB_BA m%4, m%3, m%5 ;tmp0, tmp3 + SUMSUB_BA m%2, m%1, m%5 ;tmp1, tmp2 + SWAP %4, %1 + SWAP %4, %3 +%endmacro + +INIT_MMX +cglobal vp8_idct_add_mmx, 3, 3 + ; load block data + movq m0, [r1] + movq m1, [r1+8] + movq m2, [r1+16] + movq m3, [r1+24] + movq m6, [pw_20091] + movq m7, [pw_17734] + + ; actual IDCT + VP8_IDCT_TRANSFORM4x4_1D 0, 1, 2, 3, 4, 5 + TRANSPOSE4x4W 0, 1, 2, 3, 4 + paddw m0, [pw_4] + VP8_IDCT_TRANSFORM4x4_1D 0, 1, 2, 3, 4, 5 + TRANSPOSE4x4W 0, 1, 2, 3, 4 + + ; store + pxor m4, m4 + lea r1, [r0+2*r2] + STORE_DIFFx2 m0, m1, m6, m7, m4, 3, r0, r2 + STORE_DIFFx2 m2, m3, m6, m7, m4, 3, r1, r2 + + RET + +;----------------------------------------------------------------------------- +; void vp8_luma_dc_wht_mmxext(DCTELEM block[4][4][16], DCTELEM dc[16]) +;----------------------------------------------------------------------------- + +%macro SCATTER_WHT 1 + pextrw r1d, m0, %1 + pextrw r2d, m1, %1 + mov [r0+2*16*0], r1w + mov [r0+2*16*1], r2w + pextrw r1d, m2, %1 + pextrw r2d, m3, %1 + mov [r0+2*16*2], r1w + mov [r0+2*16*3], r2w +%endmacro + +%macro HADAMARD4_1D 4 + SUMSUB_BADC m%2, m%1, m%4, m%3 + SUMSUB_BADC m%4, m%2, m%3, m%1 + SWAP %1, %4, %3 +%endmacro + +INIT_MMX +cglobal vp8_luma_dc_wht_mmxext, 2,3 + movq m0, [r1] + movq m1, [r1+8] + movq m2, [r1+16] + movq m3, [r1+24] + HADAMARD4_1D 0, 1, 2, 3 + TRANSPOSE4x4W 0, 1, 2, 3, 4 + paddw m0, [pw_3] + HADAMARD4_1D 0, 1, 2, 3 + psraw m0, 3 + psraw m1, 3 + psraw m2, 3 + psraw m3, 3 + SCATTER_WHT 0 + add r0, 2*16*4 + SCATTER_WHT 1 + add r0, 2*16*4 + SCATTER_WHT 2 + add r0, 2*16*4 + SCATTER_WHT 3 + RET + +;----------------------------------------------------------------------------- +; void vp8_h/v_loop_filter_simple_(uint8_t *dst, int stride, int flim); +;----------------------------------------------------------------------------- + +; macro called with 7 mm register indexes as argument, and 4 regular registers +; +; first 4 mm registers will carry the transposed pixel data +; the other three are scratchspace (one would be sufficient, but this allows +; for more spreading/pipelining and thus faster execution on OOE CPUs) +; +; first two regular registers are buf+4*stride and buf+5*stride +; third is -stride, fourth is +stride +%macro READ_8x4_INTERLEAVED 11 + ; interleave 8 (A-H) rows of 4 pixels each + movd m%1, [%8+%10*4] ; A0-3 + movd m%5, [%9+%10*4] ; B0-3 + movd m%2, [%8+%10*2] ; C0-3 + movd m%6, [%8+%10] ; D0-3 + movd m%3, [%8] ; E0-3 + movd m%7, [%9] ; F0-3 + movd m%4, [%9+%11] ; G0-3 + punpcklbw m%1, m%5 ; A/B interleaved + movd m%5, [%9+%11*2] ; H0-3 + punpcklbw m%2, m%6 ; C/D interleaved + punpcklbw m%3, m%7 ; E/F interleaved + punpcklbw m%4, m%5 ; G/H interleaved +%endmacro + +; macro called with 7 mm register indexes as argument, and 5 regular registers +; first 11 mean the same as READ_8x4_TRANSPOSED above +; fifth regular register is scratchspace to reach the bottom 8 rows, it +; will be set to second regular register + 8*stride at the end +%macro READ_16x4_INTERLEAVED 12 + ; transpose 16 (A-P) rows of 4 pixels each + lea %12, [r0+8*r2] + + ; read (and interleave) those addressable by %8 (=r0), A/C/D/E/I/K/L/M + movd m%1, [%8+%10*4] ; A0-3 + movd m%3, [%12+%10*4] ; I0-3 + movd m%2, [%8+%10*2] ; C0-3 + movd m%4, [%12+%10*2] ; K0-3 + movd m%6, [%8+%10] ; D0-3 + movd m%5, [%12+%10] ; L0-3 + movd m%7, [%12] ; M0-3 + add %12, %11 + punpcklbw m%1, m%3 ; A/I + movd m%3, [%8] ; E0-3 + punpcklbw m%2, m%4 ; C/K + punpcklbw m%6, m%5 ; D/L + punpcklbw m%3, m%7 ; E/M + punpcklbw m%2, m%6 ; C/D/K/L interleaved + + ; read (and interleave) those addressable by %9 (=r4), B/F/G/H/J/N/O/P + movd m%5, [%9+%10*4] ; B0-3 + movd m%4, [%12+%10*4] ; J0-3 + movd m%7, [%9] ; F0-3 + movd m%6, [%12] ; N0-3 + punpcklbw m%5, m%4 ; B/J + punpcklbw m%7, m%6 ; F/N + punpcklbw m%1, m%5 ; A/B/I/J interleaved + punpcklbw m%3, m%7 ; E/F/M/N interleaved + movd m%4, [%9+%11] ; G0-3 + movd m%6, [%12+%11] ; O0-3 + movd m%5, [%9+%11*2] ; H0-3 + movd m%7, [%12+%11*2] ; P0-3 + punpcklbw m%4, m%6 ; G/O + punpcklbw m%5, m%7 ; H/P + punpcklbw m%4, m%5 ; G/H/O/P interleaved +%endmacro + +; write 4 mm registers of 2 dwords each +; first four arguments are mm register indexes containing source data +; last four are registers containing buf+4*stride, buf+5*stride, +; -stride and +stride +%macro WRITE_4x2D 8 + ; write out (2 dwords per register) + movd [%5+%7*4], m%1 + movd [%5+%7*2], m%2 + movd [%5], m%3 + movd [%6+%8], m%4 + punpckhdq m%1, m%1 + punpckhdq m%2, m%2 + punpckhdq m%3, m%3 + punpckhdq m%4, m%4 + movd [%6+%7*4], m%1 + movd [%5+%7], m%2 + movd [%6], m%3 + movd [%6+%8*2], m%4 +%endmacro + +; write 4 xmm registers of 4 dwords each +; arguments same as WRITE_2x4D, but with an extra register, so that the 5 regular +; registers contain buf+4*stride, buf+5*stride, buf+12*stride, -stride and +stride +; we add 1*stride to the third regular registry in the process +%macro WRITE_4x4D 9 + ; write out (4 dwords per register), start with dwords zero + movd [%5+%8*4], m%1 + movd [%5], m%2 + movd [%5+%9*4], m%3 + movd [%5+%9*8], m%4 + + ; store dwords 1 + psrldq m%1, 4 + psrldq m%2, 4 + psrldq m%3, 4 + psrldq m%4, 4 + movd [%6+%8*4], m%1 + movd [%6], m%2 + movd [%6+%9*4], m%3 + movd [%6+%9*8], m%4 + + ; write dwords 2 + psrldq m%1, 4 + psrldq m%2, 4 + psrldq m%3, 4 + psrldq m%4, 4 + movd [%5+%8*2], m%1 + movd [%6+%9], m%2 + movd [%7+%8*2], m%3 + movd [%7+%9*2], m%4 + add %7, %9 + + ; store dwords 3 + psrldq m%1, 4 + psrldq m%2, 4 + psrldq m%3, 4 + psrldq m%4, 4 + movd [%5+%8], m%1 + movd [%6+%9*2], m%2 + movd [%7+%8*2], m%3 + movd [%7+%9*2], m%4 +%endmacro + +%macro SIMPLE_LOOPFILTER 3 +cglobal vp8_%2_loop_filter_simple_%1, 3, %3 +%ifidn %2, h + mov r5, rsp ; backup stack pointer + and rsp, ~(mmsize-1) ; align stack +%endif +%if mmsize == 8 ; mmx/mmxext + mov r3, 2 +%endif + + ; splat register with "flim" + movd m7, r2 + punpcklbw m7, m7 +%if mmsize == 16 ; sse2 + punpcklwd m7, m7 + pshufd m7, m7, 0x0 +%elifidn %1, mmx + punpcklwd m7, m7 + punpckldq m7, m7 +%else ; mmxext + pshufw m7, m7, 0x0 +%endif + + ; set up indexes to address 4 rows + mov r2, r1 + neg r1 +%ifidn %2, h + lea r0, [r0+4*r2-2] + sub rsp, mmsize*2 ; (aligned) storage space for saving p1/q1 +%endif + +%if mmsize == 8 ; mmx / mmxext +.next8px +%endif +%ifidn %2, v + ; read 4 half/full rows of pixels + mova m0, [r0+r1*2] ; p1 + mova m1, [r0+r1] ; p0 + mova m2, [r0] ; q0 + mova m3, [r0+r2] ; q1 +%else ; h + lea r4, [r0+r2] + +%if mmsize == 8 ; mmx/mmxext + READ_8x4_INTERLEAVED 0, 1, 2, 3, 4, 5, 6, r0, r4, r1, r2 +%else ; sse2 + READ_16x4_INTERLEAVED 0, 1, 2, 3, 4, 5, 6, r0, r4, r1, r2, r3 +%endif + TRANSPOSE4x4W 0, 1, 2, 3, 4 + + mova [rsp], m0 ; store p1 + mova [rsp+mmsize], m3 ; store q1 +%endif + + ; simple_limit + mova m5, m2 ; m5=backup of q0 + mova m6, m1 ; m6=backup of p0 + psubusb m1, m2 ; p0-q0 + psubusb m2, m6 ; q0-p0 + por m1, m2 ; FFABS(p0-q0) + paddusb m1, m1 ; m1=FFABS(p0-q0)*2 + + mova m4, m3 + mova m2, m0 + psubusb m3, m0 ; q1-p1 + psubusb m0, m4 ; p1-q1 + por m3, m0 ; FFABS(p1-q1) + mova m0, [pb_80] + pxor m2, m0 + pxor m4, m0 + psubsb m2, m4 ; m2=p1-q1 (signed) backup for below + pand m3, [pb_FE] + psrlq m3, 1 ; m3=FFABS(p1-q1)/2, this can be used signed + paddusb m3, m1 + psubusb m3, m7 + pxor m1, m1 + pcmpeqb m3, m1 ; abs(p0-q0)*2+abs(p1-q1)/2<=flim mask(0xff/0x0) + + ; filter_common (use m2/p1-q1, m4=q0, m6=p0, m5/q0-p0 and m3/mask) + mova m4, m5 + pxor m5, m0 + pxor m0, m6 + psubsb m5, m0 ; q0-p0 (signed) + paddsb m2, m5 + paddsb m2, m5 + paddsb m2, m5 ; a=(p1-q1) + 3*(q0-p0) + pand m2, m3 ; apply filter mask (m3) + + mova m3, [pb_F8] + mova m1, m2 + paddsb m2, [pb_4] ; f1<<3=a+4 + paddsb m1, [pb_3] ; f2<<3=a+3 + pand m2, m3 + pand m1, m3 ; cache f2<<3 + + pxor m0, m0 + pxor m3, m3 + pcmpgtb m0, m2 ; which values are <0? + psubb m3, m2 ; -f1<<3 + psrlq m2, 3 ; +f1 + psrlq m3, 3 ; -f1 + pand m3, m0 + pandn m0, m2 + psubusb m4, m0 + paddusb m4, m3 ; q0-f1 + + pxor m0, m0 + pxor m3, m3 + pcmpgtb m0, m1 ; which values are <0? + psubb m3, m1 ; -f2<<3 + psrlq m1, 3 ; +f2 + psrlq m3, 3 ; -f2 + pand m3, m0 + pandn m0, m1 + paddusb m6, m0 + psubusb m6, m3 ; p0+f2 + + ; store +%ifidn %2, v + mova [r0], m4 + mova [r0+r1], m6 +%else ; h + mova m0, [rsp] ; p1 + SWAP 2, 4 ; p0 + SWAP 1, 6 ; q0 + mova m3, [rsp+mmsize] ; q1 + + TRANSPOSE4x4B 0, 1, 2, 3, 4 +%if mmsize == 16 ; sse2 + add r3, r1 ; change from r4*8*stride to r0+8*stride + WRITE_4x4D 0, 1, 2, 3, r0, r4, r3, r1, r2 +%else ; mmx/mmxext + WRITE_4x2D 0, 1, 2, 3, r0, r4, r1, r2 +%endif +%endif + +%if mmsize == 8 ; mmx/mmxext + ; next 8 pixels +%ifidn %2, v + add r0, 8 ; advance 8 cols = pixels +%else ; h + lea r0, [r0+r2*8] ; advance 8 rows = lines +%endif + dec r3 + jg .next8px +%ifidn %2, v + REP_RET +%else ; h + mov rsp, r5 ; restore stack pointer + RET +%endif +%else ; sse2 +%ifidn %2, h + mov rsp, r5 ; restore stack pointer +%endif + RET +%endif +%endmacro + +INIT_MMX +SIMPLE_LOOPFILTER mmx, v, 4 +SIMPLE_LOOPFILTER mmx, h, 6 +SIMPLE_LOOPFILTER mmxext, v, 4 +SIMPLE_LOOPFILTER mmxext, h, 6 +INIT_XMM +SIMPLE_LOOPFILTER sse2, v, 3 +SIMPLE_LOOPFILTER sse2, h, 6 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/x86inc.asm b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/x86inc.asm index c29ef3ee3..410b11bb2 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/x86inc.asm +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/x86inc.asm @@ -1,25 +1,39 @@ ;***************************************************************************** ;* x86inc.asm ;***************************************************************************** -;* Copyright (C) 2005-2008 Loren Merritt +;* Copyright (C) 2005-2008 x264 project ;* -;* This file is part of FFmpeg. +;* Authors: Loren Merritt +;* Anton Mitrofanov ;* -;* FFmpeg is free software; you can redistribute it and/or -;* modify it under the terms of the GNU Lesser General Public -;* License as published by the Free Software Foundation; either -;* version 2.1 of the License, or (at your option) any later version. +;* Permission to use, copy, modify, and/or distribute this software for any +;* purpose with or without fee is hereby granted, provided that the above +;* copyright notice and this permission notice appear in all copies. ;* -;* FFmpeg is distributed in the hope that it will be useful, -;* but WITHOUT ANY WARRANTY; without even the implied warranty of -;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;* Lesser General Public License for more details. -;* -;* You should have received a copy of the GNU Lesser General Public -;* License along with FFmpeg; if not, write to the Free Software -;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +;* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +;* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +;* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +;* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +;* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +;* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ;***************************************************************************** +; This is a header file for the x264ASM assembly language, which uses +; NASM/YASM syntax combined with a large number of macros to provide easy +; abstraction between different calling conventions (x86_32, win64, linux64). +; It also has various other useful features to simplify writing the kind of +; DSP functions that are most often used in x264. + +; Unlike the rest of x264, this file is available under an ISC license, as it +; has significant usefulness outside of x264 and we want it to be available +; to the largest audience possible. Of course, if you modify it for your own +; purposes to add a new feature, we strongly encourage contributing a patch +; as this feature might be useful for others as well. Send patches or ideas +; to x264-devel@videolan.org . + +%define program_name ff + %ifdef ARCH_X86_64 %ifidn __OUTPUT_FORMAT__,win32 %define WIN64 @@ -28,6 +42,12 @@ %endif %endif +%ifdef PREFIX + %define mangle(x) _ %+ x +%else + %define mangle(x) x +%endif + ; FIXME: All of the 64bit asm functions that take a stride as an argument ; via register, assume that the high dword of that register is filled with 0. ; This is true in practice (since we never do any 64bit arithmetic on strides, @@ -47,28 +67,16 @@ %endif %endmacro -; PIC support macros. -; x86_64 can't fit 64bit address literals in most instruction types, -; so shared objects (under the assumption that they might be anywhere -; in memory) must use an address mode that does fit. -; So all accesses to global variables must use this macro, e.g. -; mov eax, [foo GLOBAL] -; instead of -; mov eax, [foo] -; -; x86_32 doesn't require PIC. -; Some distros prefer shared objects to be PIC, but nothing breaks if -; the code contains a few textrels, so we'll skip that complexity. - %ifdef WIN64 %define PIC %elifndef ARCH_X86_64 +; x86_32 doesn't require PIC. +; Some distros prefer shared objects to be PIC, but nothing breaks if +; the code contains a few textrels, so we'll skip that complexity. %undef PIC %endif %ifdef PIC - %define GLOBAL wrt rip -%else - %define GLOBAL + default rel %endif ; Macros to eliminate most code duplication between x86_32 and x86_64: @@ -163,7 +171,7 @@ DECLARE_REG_SIZE bp, bpl %endrep %endmacro -DECLARE_REG_TMP_SIZE 0,1,2,3,4,5,6,7 +DECLARE_REG_TMP_SIZE 0,1,2,3,4,5,6,7,8,9 %ifdef ARCH_X86_64 %define gprsize 8 @@ -259,15 +267,11 @@ DECLARE_REG 6, rax, eax, ax, al, [rsp + stack_offset + 56] %endif %endmacro -%macro PROLOGUE 2-4+ ; #args, #regs, #xmm_regs, arg_names... +%macro PROLOGUE 2-4+ 0 ; #args, #regs, #xmm_regs, arg_names... ASSERT %2 >= %1 %assign regs_used %2 ASSERT regs_used <= 7 - %if %0 > 2 - %assign xmm_regs_used %3 - %else - %assign xmm_regs_used 0 - %endif + %assign xmm_regs_used %3 ASSERT xmm_regs_used <= 16 %if regs_used > 4 push r4 @@ -388,7 +392,7 @@ DECLARE_REG 6, ebp, ebp, bp, null, [esp + stack_offset + 28] %endif %endmacro -%macro PROLOGUE 2-4+ ; #args, #regs, arg_names... +%macro PROLOGUE 2-4+ ; #args, #regs, #xmm_regs, arg_names... ASSERT %2 >= %1 %assign regs_used %2 ASSERT regs_used <= 7 @@ -434,10 +438,7 @@ DECLARE_REG 6, ebp, ebp, bp, null, [esp + stack_offset + 28] ; Symbol prefix for C linkage %macro cglobal 1-2+ - %xdefine %1 ff_%1 - %ifdef PREFIX - %xdefine %1 _ %+ %1 - %endif + %xdefine %1 mangle(program_name %+ _ %+ %1) %xdefine %1.skip_prologue %1 %+ .skip_prologue %ifidn __OUTPUT_FORMAT__,elf global %1:function hidden @@ -454,21 +455,28 @@ DECLARE_REG 6, ebp, ebp, bp, null, [esp + stack_offset + 28] %endmacro %macro cextern 1 - %ifdef PREFIX - %xdefine %1 _%1 - %endif + %xdefine %1 mangle(program_name %+ _ %+ %1) + extern %1 +%endmacro + +;like cextern, but without the prefix +%macro cextern_naked 1 + %xdefine %1 mangle(%1) extern %1 %endmacro +%macro const 2+ + %xdefine %1 mangle(program_name %+ _ %+ %1) + global %1 + %1: %2 +%endmacro + ; This is needed for ELF, otherwise the GNU linker assumes the stack is ; executable by default. %ifidn __OUTPUT_FORMAT__,elf SECTION .note.GNU-stack noalloc noexec nowrite progbits %endif -%assign FENC_STRIDE 16 -%assign FDEC_STRIDE 32 - ; merge mmx and sse* %macro CAT_XDEFINE 3 @@ -575,7 +583,10 @@ INIT_MMX %endrep %endmacro -%macro SAVE_MM_PERMUTATION 1 +; If SAVE_MM_PERMUTATION is placed at the end of a function and given the +; function name, then any later calls to that function will automatically +; load the permutation, so values can be returned in mmregs. +%macro SAVE_MM_PERMUTATION 1 ; name to save as %assign %%i 0 %rep num_mmregs CAT_XDEFINE %1_m, %%i, m %+ %%i @@ -583,7 +594,7 @@ INIT_MMX %endrep %endmacro -%macro LOAD_MM_PERMUTATION 1 +%macro LOAD_MM_PERMUTATION 1 ; name to load from %assign %%i 0 %rep num_mmregs CAT_XDEFINE m, %%i, %1_m %+ %%i @@ -599,7 +610,7 @@ INIT_MMX %endif %endmacro -;Substitutions that reduce instruction size but are functionally equivalent +; Substitutions that reduce instruction size but are functionally equivalent %macro add 2 %ifnum %2 %if %2==128 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/x86util.asm b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/x86util.asm index f3e0e2dbe..5dd65dca5 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/x86util.asm +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/x86/x86util.asm @@ -1,22 +1,27 @@ ;***************************************************************************** ;* x86util.asm ;***************************************************************************** -;* Copyright (C) 2008 Loren Merritt +;* Copyright (C) 2008-2010 x264 project ;* -;* 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. +;* Authors: Loren Merritt +;* Holger Lubitz ;* -;* This program is distributed in the hope that it will be useful, +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, ;* but WITHOUT ANY WARRANTY; without even the implied warranty of -;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;* GNU General Public License for more details. +;* 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 General Public License -;* along with this program; if not, write to the Free Software -;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. -;***************************************************************************** +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** %macro SBUTTERFLY 4 mova m%4, m%2 @@ -25,6 +30,21 @@ SWAP %3, %4 %endmacro +%macro SBUTTERFLY2 4 + mova m%4, m%2 + punpckh%1 m%2, m%3 + punpckl%1 m%4, m%3 + SWAP %2, %4, %3 +%endmacro + +%macro TRANSPOSE4x4B 5 + SBUTTERFLY bw, %1, %2, %5 + SBUTTERFLY bw, %3, %4, %5 + SBUTTERFLY wd, %1, %3, %5 + SBUTTERFLY wd, %2, %4, %5 + SWAP %2, %3 +%endmacro + %macro TRANSPOSE4x4W 5 SBUTTERFLY wd, %1, %2, %5 SBUTTERFLY wd, %3, %4, %5 @@ -99,6 +119,34 @@ %endif %endmacro +; PABSW macros assume %1 != %2, while ABS1/2 macros work in-place +%macro PABSW_MMX 2 + pxor %1, %1 + pcmpgtw %1, %2 + pxor %2, %1 + psubw %2, %1 + SWAP %1, %2 +%endmacro + +%macro PSIGNW_MMX 2 + pxor %1, %2 + psubw %1, %2 +%endmacro + +%macro PABSW_MMX2 2 + pxor %1, %1 + psubw %1, %2 + pmaxsw %1, %2 +%endmacro + +%macro PABSW_SSSE3 2 + pabsw %1, %2 +%endmacro + +%macro PSIGNW_SSSE3 2 + psignw %1, %2 +%endmacro + %macro ABS1_MMX 2 ; a, tmp pxor %2, %2 psubw %2, %1 @@ -123,14 +171,40 @@ pabsw %2, %2 %endmacro -%define ABS1 ABS1_MMX -%define ABS2 ABS2_MMX +%macro ABSB_MMX 2 + pxor %2, %2 + psubb %2, %1 + pminub %1, %2 +%endmacro + +%macro ABSB2_MMX 4 + pxor %3, %3 + pxor %4, %4 + psubb %3, %1 + psubb %4, %2 + pminub %1, %3 + pminub %2, %4 +%endmacro + +%macro ABSB_SSSE3 2 + pabsb %1, %1 +%endmacro + +%macro ABSB2_SSSE3 4 + pabsb %1, %1 + pabsb %2, %2 +%endmacro %macro ABS4 6 ABS2 %1, %2, %5, %6 ABS2 %3, %4, %5, %6 %endmacro +%define ABS1 ABS1_MMX +%define ABS2 ABS2_MMX +%define ABSB ABSB_MMX +%define ABSB2 ABSB2_MMX + %macro SPLATB_MMX 3 movd %1, [%2-3] ;to avoid crossing a cacheline punpcklbw %1, %1 @@ -205,165 +279,6 @@ %endif %endmacro -%macro HADAMARD4_V 4+ - SUMSUB_BADC %1, %2, %3, %4 - SUMSUB_BADC %1, %3, %2, %4 -%endmacro - -%macro HADAMARD8_V 8+ - SUMSUB_BADC %1, %2, %3, %4 - SUMSUB_BADC %5, %6, %7, %8 - SUMSUB_BADC %1, %3, %2, %4 - SUMSUB_BADC %5, %7, %6, %8 - SUMSUB_BADC %1, %5, %2, %6 - SUMSUB_BADC %3, %7, %4, %8 -%endmacro - -%macro TRANS_SSE2 5-6 -; TRANSPOSE2x2 -; %1: transpose width (d/q) - use SBUTTERFLY qdq for dq -; %2: ord/unord (for compat with sse4, unused) -; %3/%4: source regs -; %5/%6: tmp regs -%ifidn %1, d -%define mask [mask_10 GLOBAL] -%define shift 16 -%elifidn %1, q -%define mask [mask_1100 GLOBAL] -%define shift 32 -%endif -%if %0==6 ; less dependency if we have two tmp - mova m%5, mask ; ff00 - mova m%6, m%4 ; x5x4 - psll%1 m%4, shift ; x4.. - pand m%6, m%5 ; x5.. - pandn m%5, m%3 ; ..x0 - psrl%1 m%3, shift ; ..x1 - por m%4, m%5 ; x4x0 - por m%3, m%6 ; x5x1 -%else ; more dependency, one insn less. sometimes faster, sometimes not - mova m%5, m%4 ; x5x4 - psll%1 m%4, shift ; x4.. - pxor m%4, m%3 ; (x4^x1)x0 - pand m%4, mask ; (x4^x1).. - pxor m%3, m%4 ; x4x0 - psrl%1 m%4, shift ; ..(x1^x4) - pxor m%5, m%4 ; x5x1 - SWAP %4, %3, %5 -%endif -%endmacro - -%macro TRANS_SSE4 5-6 ; see above -%ifidn %1, d - mova m%5, m%3 -%ifidn %2, ord - psrl%1 m%3, 16 -%endif - pblendw m%3, m%4, 10101010b - psll%1 m%4, 16 -%ifidn %2, ord - pblendw m%4, m%5, 01010101b -%else - psrl%1 m%5, 16 - por m%4, m%5 -%endif -%elifidn %1, q - mova m%5, m%3 - shufps m%3, m%4, 10001000b - shufps m%5, m%4, 11011101b - SWAP %4, %5 -%endif -%endmacro - -%macro HADAMARD 5-6 -; %1=distance in words (0 for vertical pass, 1/2/4 for horizontal passes) -; %2=sumsub/max/amax (sum and diff / maximum / maximum of absolutes) -; %3/%4: regs -; %5(%6): tmpregs -%if %1!=0 ; have to reorder stuff for horizontal op - %ifidn %2, sumsub - %define ORDER ord - ; sumsub needs order because a-b != b-a unless a=b - %else - %define ORDER unord - ; if we just max, order doesn't matter (allows pblendw+or in sse4) - %endif - %if %1==1 - TRANS d, ORDER, %3, %4, %5, %6 - %elif %1==2 - %if mmsize==8 - SBUTTERFLY dq, %3, %4, %5 - %else - TRANS q, ORDER, %3, %4, %5, %6 - %endif - %elif %1==4 - SBUTTERFLY qdq, %3, %4, %5 - %endif -%endif -%ifidn %2, sumsub - SUMSUB_BA m%3, m%4, m%5 -%else - %ifidn %2, amax - %if %0==6 - ABS2 m%3, m%4, m%5, m%6 - %else - ABS1 m%3, m%5 - ABS1 m%4, m%5 - %endif - %endif - pmaxsw m%3, m%4 -%endif -%endmacro - - -%macro HADAMARD2_2D 6-7 sumsub - HADAMARD 0, sumsub, %1, %2, %5 - HADAMARD 0, sumsub, %3, %4, %5 - SBUTTERFLY %6, %1, %2, %5 -%ifnum %7 - HADAMARD 0, amax, %1, %2, %5, %7 -%else - HADAMARD 0, %7, %1, %2, %5 -%endif - SBUTTERFLY %6, %3, %4, %5 -%ifnum %7 - HADAMARD 0, amax, %3, %4, %5, %7 -%else - HADAMARD 0, %7, %3, %4, %5 -%endif -%endmacro - -%macro HADAMARD4_2D 5-6 sumsub - HADAMARD2_2D %1, %2, %3, %4, %5, wd - HADAMARD2_2D %1, %3, %2, %4, %5, dq, %6 - SWAP %2, %3 -%endmacro - -%macro HADAMARD4_2D_SSE 5-6 sumsub - HADAMARD 0, sumsub, %1, %2, %5 ; 1st V row 0 + 1 - HADAMARD 0, sumsub, %3, %4, %5 ; 1st V row 2 + 3 - SBUTTERFLY wd, %1, %2, %5 ; %1: m0 1+0 %2: m1 1+0 - SBUTTERFLY wd, %3, %4, %5 ; %3: m0 3+2 %4: m1 3+2 - HADAMARD2_2D %1, %3, %2, %4, %5, dq - SBUTTERFLY qdq, %1, %2, %5 - HADAMARD 0, %6, %1, %2, %5 ; 2nd H m1/m0 row 0+1 - SBUTTERFLY qdq, %3, %4, %5 - HADAMARD 0, %6, %3, %4, %5 ; 2nd H m1/m0 row 2+3 -%endmacro - -%macro HADAMARD8_2D 9-10 sumsub - HADAMARD2_2D %1, %2, %3, %4, %9, wd - HADAMARD2_2D %5, %6, %7, %8, %9, wd - HADAMARD2_2D %1, %3, %2, %4, %9, dq - HADAMARD2_2D %5, %7, %6, %8, %9, dq - HADAMARD2_2D %1, %5, %3, %7, %9, qdq, %10 - HADAMARD2_2D %2, %6, %4, %8, %9, qdq, %10 -%ifnidn %10, amax - SWAP %2, %5 - SWAP %4, %7 -%endif -%endmacro - %macro SUMSUB2_AB 3 mova %3, %1 paddw %1, %1 @@ -383,10 +298,10 @@ %macro SUMSUBD2_AB 4 mova %4, %1 mova %3, %2 - psraw %2, 1 - psraw %1, 1 - paddw %2, %4 - psubw %1, %3 + psraw %2, 1 ; %2: %2>>1 + psraw %1, 1 ; %1: %1>>1 + paddw %2, %4 ; %2: %2>>1+%1 + psubw %1, %3 ; %1: %1>>1-%2 %endmacro %macro DCT4_1D 5 @@ -407,16 +322,27 @@ %macro IDCT4_1D 5-6 %ifnum %5 SUMSUBD2_AB m%2, m%4, m%6, m%5 + ; %2: %2>>1-%4 %4: %2+%4>>1 SUMSUB_BA m%3, m%1, m%6 + ; %3: %1+%3 %1: %1-%3 SUMSUB_BADC m%4, m%3, m%2, m%1, m%6 + ; %4: %1+%3 + (%2+%4>>1) + ; %3: %1+%3 - (%2+%4>>1) + ; %2: %1-%3 + (%2>>1-%4) + ; %1: %1-%3 - (%2>>1-%4) %else SUMSUBD2_AB m%2, m%4, [%5], [%5+16] SUMSUB_BA m%3, m%1 SUMSUB_BADC m%4, m%3, m%2, m%1 %endif SWAP %1, %4, %3 + ; %1: %1+%3 + (%2+%4>>1) row0 + ; %2: %1-%3 + (%2>>1-%4) row1 + ; %3: %1-%3 - (%2>>1-%4) row2 + ; %4: %1+%3 - (%2+%4>>1) row3 %endmacro + %macro LOAD_DIFF 5 %ifidn %3, none movh %1, %4 @@ -433,32 +359,6 @@ %endif %endmacro -%macro LOAD_DIFF8x4_SSE2 8 - LOAD_DIFF m%1, m%5, m%6, [%7+%1*FENC_STRIDE], [%8+%1*FDEC_STRIDE] - LOAD_DIFF m%2, m%5, m%6, [%7+%2*FENC_STRIDE], [%8+%2*FDEC_STRIDE] - LOAD_DIFF m%3, m%5, m%6, [%7+%3*FENC_STRIDE], [%8+%3*FDEC_STRIDE] - LOAD_DIFF m%4, m%5, m%6, [%7+%4*FENC_STRIDE], [%8+%4*FDEC_STRIDE] -%endmacro - -%macro LOAD_DIFF8x4_SSSE3 8 ; 4x dst, 1x tmp, 1x mul, 2x ptr - movh m%2, [%8+%1*FDEC_STRIDE] - movh m%1, [%7+%1*FENC_STRIDE] - punpcklbw m%1, m%2 - movh m%3, [%8+%2*FDEC_STRIDE] - movh m%2, [%7+%2*FENC_STRIDE] - punpcklbw m%2, m%3 - movh m%4, [%8+%3*FDEC_STRIDE] - movh m%3, [%7+%3*FENC_STRIDE] - punpcklbw m%3, m%4 - movh m%5, [%8+%4*FDEC_STRIDE] - movh m%4, [%7+%4*FENC_STRIDE] - punpcklbw m%4, m%5 - pmaddubsw m%1, m%6 - pmaddubsw m%2, m%6 - pmaddubsw m%3, m%6 - pmaddubsw m%4, m%6 -%endmacro - %macro STORE_DCT 6 movq [%5+%6+ 0], m%1 movq [%5+%6+ 8], m%2 @@ -470,17 +370,6 @@ movhps [%5+%6+56], m%4 %endmacro -%macro STORE_IDCT 4 - movhps [r0-4*FDEC_STRIDE], %1 - movh [r0-3*FDEC_STRIDE], %1 - movhps [r0-2*FDEC_STRIDE], %2 - movh [r0-1*FDEC_STRIDE], %2 - movhps [r0+0*FDEC_STRIDE], %3 - movh [r0+1*FDEC_STRIDE], %3 - movhps [r0+2*FDEC_STRIDE], %4 - movh [r0+3*FDEC_STRIDE], %4 -%endmacro - %macro LOAD_DIFF_8x4P 7-10 r0,r2,0 ; 4x dest, 2x temp, 2x pointer, increment? LOAD_DIFF m%1, m%5, m%7, [%8], [%9] LOAD_DIFF m%2, m%6, m%7, [%8+r1], [%9+r3] @@ -513,3 +402,17 @@ movh %4, %1 %endmacro +%macro STORE_DIFFx2 8 ; add1, add2, reg1, reg2, zero, shift, source, stride + movh %3, [%7] + movh %4, [%7+%8] + punpcklbw %3, %5 + punpcklbw %4, %5 + psraw %1, %6 + psraw %2, %6 + paddw %3, %1 + paddw %4, %2 + packuswb %3, %5 + packuswb %4, %5 + movh [%7], %3 + movh [%7+%8], %4 +%endmacro diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/xiph.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/xiph.h index 60f4a95d1..0cbb87035 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/xiph.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/xiph.h @@ -24,7 +24,7 @@ #include "libavutil/common.h" /** - * Splits a single extradata buffer into the three headers that most + * Split a single extradata buffer into the three headers that most * Xiph codecs use. (e.g. Theora and Vorbis) * Works both with Matroska's packing and lavc's packing. * diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/xsubenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/xsubenc.c index 903cbd209..60f4979ed 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/xsubenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/xsubenc.c @@ -35,7 +35,7 @@ #define PADDING_COLOR 0 /** - * Encodes a single color run. At most 16 bits will be used. + * Encode a single color run. At most 16 bits will be used. * \param len length of the run, values > 255 mean "until end of line", may not be < 0. * \param color color to encode, only the lowest two bits are used and all others must be 0. */ @@ -49,7 +49,7 @@ static void put_xsub_rle(PutBitContext *pb, int len, int color) } /** - * Encodes a 4-color bitmap with XSUB rle. + * Encode a 4-color bitmap with XSUB rle. * * The encoded bitmap may be wider than the source bitmap due to padding. */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/xvmc.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/xvmc.h index 01f84b28c..29c010bff 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/xvmc.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/xvmc.h @@ -71,7 +71,7 @@ struct xvmc_pix_fmt { */ int allocated_data_blocks; - /** Indicates that the hardware would interpret data_blocks as IDCT + /** Indicate that the hardware would interpret data_blocks as IDCT coefficients and perform IDCT on them. - application - set during initialization - libavcodec - unchanged diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/yop.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/yop.c index 1eb76b128..72aebc68d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/yop.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/yop.c @@ -114,7 +114,7 @@ static av_cold int yop_decode_close(AVCodecContext *avctx) } /** - * Paints a macroblock using the pattern in paint_lut. + * Paint a macroblock using the pattern in paint_lut. * @param s codec context * @param tag the tag that was in the nibble */ @@ -130,7 +130,7 @@ static void yop_paint_block(YopDecContext *s, int tag) } /** - * Copies a previously painted macroblock to the current_block. + * Copy a previously painted macroblock to the current_block. * @param copy_tag the tag that was in the nibble */ static int yop_copy_previous_block(YopDecContext *s, int copy_tag) @@ -155,7 +155,7 @@ static int yop_copy_previous_block(YopDecContext *s, int copy_tag) } /** - * Returns the next nibble in sequence, consuming a new byte on the input + * Return the next nibble in sequence, consuming a new byte on the input * only if necessary. */ static uint8_t yop_get_next_nibble(YopDecContext *s) @@ -173,7 +173,7 @@ static uint8_t yop_get_next_nibble(YopDecContext *s) } /** - * Takes s->dstptr to the next macroblock in sequence. + * Take s->dstptr to the next macroblock in sequence. */ static void yop_next_macroblock(YopDecContext *s) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/zmbv.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/zmbv.c index 8af8c840a..6ac908919 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/zmbv.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/zmbv.c @@ -397,7 +397,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; ZmbvContext * const c = avctx->priv_data; - uint8_t *outptr; int zret = Z_OK; // Zlib return code int len = buf_size; int hi_ver, lo_ver; @@ -412,8 +411,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac return -1; } - outptr = c->pic.data[0]; // Output image pointer - /* parse header */ c->flags = buf[0]; buf++; len--; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/Makefile b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/Makefile index a0c3858d8..be28f4a0a 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/Makefile +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/Makefile @@ -25,9 +25,6 @@ OBJS-$(CONFIG_X11_GRAB_DEVICE_INDEV) += x11grab.o # external libraries OBJS-$(CONFIG_LIBDC1394_INDEV) += libdc1394.o -OBJS-$(CONFIG_AUDIO_BEOS_INDEV) += beosaudio.o -OBJS-$(CONFIG_AUDIO_BEOS_OUTDEV) += beosaudio.o - SKIPHEADERS-$(HAVE_ALSA_ASOUNDLIB_H) += alsa-audio.h include $(SUBDIR)../subdir.mak diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/alldevices.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/alldevices.c index e7a9a5e6f..de3bc8239 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/alldevices.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/alldevices.c @@ -40,7 +40,6 @@ void avdevice_register_all(void) /* devices */ REGISTER_INOUTDEV (ALSA, alsa); - REGISTER_INOUTDEV (AUDIO_BEOS, audio_beos); REGISTER_INDEV (BKTR, bktr); REGISTER_INDEV (DV1394, dv1394); REGISTER_INDEV (JACK, jack); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/alsa-audio.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/alsa-audio.h index 9a8a089ba..a90d5e780 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/alsa-audio.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/alsa-audio.h @@ -50,7 +50,7 @@ typedef struct { } AlsaData; /** - * Opens an ALSA PCM. + * Open an ALSA PCM. * * @param s media file handle * @param mode either SND_PCM_STREAM_CAPTURE or SND_PCM_STREAM_PLAYBACK @@ -68,7 +68,7 @@ int ff_alsa_open(AVFormatContext *s, snd_pcm_stream_t mode, int channels, enum CodecID *codec_id); /** - * Closes the ALSA PCM. + * Close the ALSA PCM. * * @param s1 media file handle * @@ -77,7 +77,7 @@ int ff_alsa_open(AVFormatContext *s, snd_pcm_stream_t mode, int ff_alsa_close(AVFormatContext *s1); /** - * Tries to recover from ALSA buffer underrun. + * Try to recover from ALSA buffer underrun. * * @param s1 media file handle * @param err error code reported by the previous ALSA call diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/avdevice.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/avdevice.h index dcd835cb1..b9c0fd7b8 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/avdevice.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/avdevice.h @@ -34,17 +34,17 @@ #define LIBAVDEVICE_BUILD LIBAVDEVICE_VERSION_INT /** - * Returns the LIBAVDEVICE_VERSION_INT constant. + * Return the LIBAVDEVICE_VERSION_INT constant. */ unsigned avdevice_version(void); /** - * Returns the libavdevice build-time configuration. + * Return the libavdevice build-time configuration. */ const char *avdevice_configuration(void); /** - * Returns the libavdevice license. + * Return the libavdevice license. */ const char *avdevice_license(void); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/beosaudio.cpp b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/beosaudio.cpp deleted file mode 100644 index 9f32571b3..000000000 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/beosaudio.cpp +++ /dev/null @@ -1,467 +0,0 @@ -/* - * BeOS audio play interface - * Copyright (c) 2000, 2001 Fabrice Bellard - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -extern "C" { -#include "libavformat/avformat.h" -} - -#if HAVE_BSOUNDRECORDER -#include -using namespace BPrivate::Media::Experimental; -#endif - -/* enable performance checks */ -//#define PERF_CHECK - -/* enable Media Kit latency checks */ -//#define LATENCY_CHECK - -#define AUDIO_BLOCK_SIZE 4096 -#define AUDIO_BLOCK_COUNT 8 - -#define AUDIO_BUFFER_SIZE (AUDIO_BLOCK_SIZE*AUDIO_BLOCK_COUNT) - -typedef struct { - int fd; // UNUSED - int sample_rate; - int channels; - int frame_size; /* in bytes ! */ - CodecID codec_id; - uint8_t buffer[AUDIO_BUFFER_SIZE]; - int buffer_ptr; - /* ring buffer */ - sem_id input_sem; - int input_index; - sem_id output_sem; - int output_index; - BSoundPlayer *player; -#if HAVE_BSOUNDRECORDER - BSoundRecorder *recorder; -#endif - int has_quit; /* signal callbacks not to wait */ - volatile bigtime_t starve_time; -} AudioData; - -static thread_id main_thid; -static thread_id bapp_thid; -static int own_BApp_created = 0; -static int refcount = 0; - -/* create the BApplication and Run() it */ -static int32 bapp_thread(void *arg) -{ - new BApplication("application/x-vnd.ffmpeg"); - own_BApp_created = 1; - be_app->Run(); - /* kill the process group */ -// kill(0, SIGINT); -// kill(main_thid, SIGHUP); - return B_OK; -} - -/* create the BApplication only if needed */ -static void create_bapp_if_needed(void) -{ - if (refcount++ == 0) { - /* needed by libmedia */ - if (be_app == NULL) { - bapp_thid = spawn_thread(bapp_thread, "ffmpeg BApplication", B_NORMAL_PRIORITY, NULL); - resume_thread(bapp_thid); - while (!own_BApp_created) - snooze(50000); - } - } -} - -static void destroy_bapp_if_needed(void) -{ - if (--refcount == 0 && own_BApp_created) { - be_app->Lock(); - be_app->Quit(); - be_app = NULL; - } -} - -/* called back by BSoundPlayer */ -static void audioplay_callback(void *cookie, void *buffer, size_t bufferSize, const media_raw_audio_format &format) -{ - AudioData *s; - size_t len, amount; - unsigned char *buf = (unsigned char *)buffer; - - s = (AudioData *)cookie; - if (s->has_quit) - return; - while (bufferSize > 0) { -#ifdef PERF_CHECK - bigtime_t t; - t = system_time(); -#endif - len = MIN(AUDIO_BLOCK_SIZE, bufferSize); - if (acquire_sem_etc(s->output_sem, len, B_CAN_INTERRUPT, 0LL) < B_OK) { - s->has_quit = 1; - s->player->SetHasData(false); - return; - } - amount = MIN(len, (AUDIO_BUFFER_SIZE - s->output_index)); - memcpy(buf, &s->buffer[s->output_index], amount); - s->output_index += amount; - if (s->output_index >= AUDIO_BUFFER_SIZE) { - s->output_index %= AUDIO_BUFFER_SIZE; - memcpy(buf + amount, &s->buffer[s->output_index], len - amount); - s->output_index += len-amount; - s->output_index %= AUDIO_BUFFER_SIZE; - } - release_sem_etc(s->input_sem, len, 0); -#ifdef PERF_CHECK - t = system_time() - t; - s->starve_time = MAX(s->starve_time, t); -#endif - buf += len; - bufferSize -= len; - } -} - -#if HAVE_BSOUNDRECORDER -/* called back by BSoundRecorder */ -static void audiorecord_callback(void *cookie, bigtime_t timestamp, void *buffer, size_t bufferSize, const media_multi_audio_format &format) -{ - AudioData *s; - size_t len, amount; - unsigned char *buf = (unsigned char *)buffer; - - s = (AudioData *)cookie; - if (s->has_quit) - return; - - while (bufferSize > 0) { - len = MIN(bufferSize, AUDIO_BLOCK_SIZE); - //printf("acquire_sem(input, %d)\n", len); - if (acquire_sem_etc(s->input_sem, len, B_CAN_INTERRUPT, 0LL) < B_OK) { - s->has_quit = 1; - return; - } - amount = MIN(len, (AUDIO_BUFFER_SIZE - s->input_index)); - memcpy(&s->buffer[s->input_index], buf, amount); - s->input_index += amount; - if (s->input_index >= AUDIO_BUFFER_SIZE) { - s->input_index %= AUDIO_BUFFER_SIZE; - memcpy(&s->buffer[s->input_index], buf + amount, len - amount); - s->input_index += len - amount; - } - release_sem_etc(s->output_sem, len, 0); - //printf("release_sem(output, %d)\n", len); - buf += len; - bufferSize -= len; - } -} -#endif - -static int audio_open(AudioData *s, int is_output, const char *audio_device) -{ - int p[2]; - int ret; - media_raw_audio_format format; - media_multi_audio_format iformat; - -#if !HAVE_BSOUNDRECORDER - if (!is_output) - return AVERROR(EIO); /* not for now */ -#endif - s->input_sem = create_sem(AUDIO_BUFFER_SIZE, "ffmpeg_ringbuffer_input"); - if (s->input_sem < B_OK) - return AVERROR(EIO); - s->output_sem = create_sem(0, "ffmpeg_ringbuffer_output"); - if (s->output_sem < B_OK) { - delete_sem(s->input_sem); - return AVERROR(EIO); - } - s->input_index = 0; - s->output_index = 0; - create_bapp_if_needed(); - s->frame_size = AUDIO_BLOCK_SIZE; - /* bump up the priority (avoid realtime though) */ - set_thread_priority(find_thread(NULL), B_DISPLAY_PRIORITY+1); -#if HAVE_BSOUNDRECORDER - if (!is_output) { - bool wait_for_input = false; - if (audio_device && !strcmp(audio_device, "wait:")) - wait_for_input = true; - s->recorder = new BSoundRecorder(&iformat, wait_for_input, "ffmpeg input", audiorecord_callback); - if (wait_for_input && (s->recorder->InitCheck() == B_OK)) { - s->recorder->WaitForIncomingConnection(&iformat); - } - if (s->recorder->InitCheck() != B_OK || iformat.format != media_raw_audio_format::B_AUDIO_SHORT) { - delete s->recorder; - s->recorder = NULL; - if (s->input_sem) - delete_sem(s->input_sem); - if (s->output_sem) - delete_sem(s->output_sem); - return AVERROR(EIO); - } - s->codec_id = (iformat.byte_order == B_MEDIA_LITTLE_ENDIAN)?CODEC_ID_PCM_S16LE:CODEC_ID_PCM_S16BE; - s->channels = iformat.channel_count; - s->sample_rate = (int)iformat.frame_rate; - s->frame_size = iformat.buffer_size; - s->recorder->SetCookie(s); - s->recorder->SetVolume(1.0); - s->recorder->Start(); - return 0; - } -#endif - format = media_raw_audio_format::wildcard; - format.format = media_raw_audio_format::B_AUDIO_SHORT; - format.byte_order = B_HOST_IS_LENDIAN ? B_MEDIA_LITTLE_ENDIAN : B_MEDIA_BIG_ENDIAN; - format.channel_count = s->channels; - format.buffer_size = s->frame_size; - format.frame_rate = s->sample_rate; - s->player = new BSoundPlayer(&format, "ffmpeg output", audioplay_callback); - if (s->player->InitCheck() != B_OK) { - delete s->player; - s->player = NULL; - if (s->input_sem) - delete_sem(s->input_sem); - if (s->output_sem) - delete_sem(s->output_sem); - return AVERROR(EIO); - } - s->player->SetCookie(s); - s->player->SetVolume(1.0); - s->player->Start(); - s->player->SetHasData(true); - return 0; -} - -static int audio_close(AudioData *s) -{ - if (s->input_sem) - delete_sem(s->input_sem); - if (s->output_sem) - delete_sem(s->output_sem); - s->has_quit = 1; - if (s->player) { - s->player->Stop(); - } - if (s->player) - delete s->player; -#if HAVE_BSOUNDRECORDER - if (s->recorder) - delete s->recorder; -#endif - destroy_bapp_if_needed(); - return 0; -} - -/* sound output support */ -static int audio_write_header(AVFormatContext *s1) -{ - AudioData *s = (AudioData *)s1->priv_data; - AVStream *st; - int ret; - - st = s1->streams[0]; - s->sample_rate = st->codec->sample_rate; - s->channels = st->codec->channels; - ret = audio_open(s, 1, NULL); - if (ret < 0) - return AVERROR(EIO); - return 0; -} - -static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt) -{ - AudioData *s = (AudioData *)s1->priv_data; - int len, ret; - const uint8_t *buf = pkt->data; - int size = pkt->size; -#ifdef LATENCY_CHECK -bigtime_t lat1, lat2; -lat1 = s->player->Latency(); -#endif -#ifdef PERF_CHECK - bigtime_t t = s->starve_time; - s->starve_time = 0; - printf("starve_time: %lld \n", t); -#endif - while (size > 0) { - int amount; - len = MIN(size, AUDIO_BLOCK_SIZE); - if (acquire_sem_etc(s->input_sem, len, B_CAN_INTERRUPT, 0LL) < B_OK) - return AVERROR(EIO); - amount = MIN(len, (AUDIO_BUFFER_SIZE - s->input_index)); - memcpy(&s->buffer[s->input_index], buf, amount); - s->input_index += amount; - if (s->input_index >= AUDIO_BUFFER_SIZE) { - s->input_index %= AUDIO_BUFFER_SIZE; - memcpy(&s->buffer[s->input_index], buf + amount, len - amount); - s->input_index += len - amount; - } - release_sem_etc(s->output_sem, len, 0); - buf += len; - size -= len; - } -#ifdef LATENCY_CHECK -lat2 = s->player->Latency(); -printf("#### BSoundPlayer::Latency(): before= %lld, after= %lld\n", lat1, lat2); -#endif - return 0; -} - -static int audio_write_trailer(AVFormatContext *s1) -{ - AudioData *s = (AudioData *)s1->priv_data; - - audio_close(s); - return 0; -} - -/* grab support */ - -static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap) -{ - AudioData *s = (AudioData *)s1->priv_data; - AVStream *st; - int ret; - - if (!ap || ap->sample_rate <= 0 || ap->channels <= 0) - return -1; - - st = av_new_stream(s1, 0); - if (!st) { - return AVERROR(ENOMEM); - } - s->sample_rate = ap->sample_rate; - s->channels = ap->channels; - - ret = audio_open(s, 0, s1->filename); - if (ret < 0) { - av_free(st); - return AVERROR(EIO); - } - /* take real parameters */ - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->codec_id = s->codec_id; - st->codec->sample_rate = s->sample_rate; - st->codec->channels = s->channels; - return 0; - av_set_pts_info(st, 48, 1, 1000000); /* 48 bits pts in us */ -} - -static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) -{ - AudioData *s = (AudioData *)s1->priv_data; - int size; - size_t len, amount; - unsigned char *buf; - status_t err; - - if (av_new_packet(pkt, s->frame_size) < 0) - return AVERROR(EIO); - buf = (unsigned char *)pkt->data; - size = pkt->size; - while (size > 0) { - len = MIN(AUDIO_BLOCK_SIZE, size); - //printf("acquire_sem(output, %d)\n", len); - while ((err=acquire_sem_etc(s->output_sem, len, B_CAN_INTERRUPT, 0LL)) == B_INTERRUPTED); - if (err < B_OK) { - av_free_packet(pkt); - return AVERROR(EIO); - } - amount = MIN(len, (AUDIO_BUFFER_SIZE - s->output_index)); - memcpy(buf, &s->buffer[s->output_index], amount); - s->output_index += amount; - if (s->output_index >= AUDIO_BUFFER_SIZE) { - s->output_index %= AUDIO_BUFFER_SIZE; - memcpy(buf + amount, &s->buffer[s->output_index], len - amount); - s->output_index += len-amount; - s->output_index %= AUDIO_BUFFER_SIZE; - } - release_sem_etc(s->input_sem, len, 0); - //printf("release_sem(input, %d)\n", len); - buf += len; - size -= len; - } - //XXX: add pts info - return 0; -} - -static int audio_read_close(AVFormatContext *s1) -{ - AudioData *s = (AudioData *)s1->priv_data; - - audio_close(s); - return 0; -} - -static AVInputFormat audio_beos_demuxer = { - "audio_beos", - NULL_IF_CONFIG_SMALL("audio grab and output"), - sizeof(AudioData), - NULL, - audio_read_header, - audio_read_packet, - audio_read_close, - NULL, - NULL, - AVFMT_NOFILE, -}; - -AVOutputFormat audio_beos_muxer = { - "audio_beos", - NULL_IF_CONFIG_SMALL("audio grab and output"), - "", - "", - sizeof(AudioData), -#if HAVE_BIGENDIAN - CODEC_ID_PCM_S16BE, -#else - CODEC_ID_PCM_S16LE, -#endif - CODEC_ID_NONE, - audio_write_header, - audio_write_packet, - audio_write_trailer, - AVFMT_NOFILE, -}; - -extern "C" { - -int audio_init(void) -{ - main_thid = find_thread(NULL); - av_register_input_format(&audio_beos_demuxer); - av_register_output_format(&audio_beos_muxer); - return 0; -} - -} // "C" - diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/x11grab.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/x11grab.c index ab0a94ca2..1b58d44f2 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/x11grab.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavdevice/x11grab.c @@ -71,7 +71,7 @@ struct x11_grab }; /** - * Initializes the x11 grab device demuxer (public device demuxer API). + * Initialize the x11 grab device demuxer (public device demuxer API). * * @param s1 Context from avformat core * @param ap Parameters from avformat core @@ -238,13 +238,11 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) } /** - * Paints a mouse pointer in an X11 image. + * Paint a mouse pointer in an X11 image. * * @param image image to paint the mouse pointer to * @param s context used to retrieve original grabbing rectangle * coordinates - * @param x Mouse pointer coordinate - * @param y Mouse pointer coordinate */ static void paint_mouse_pointer(XImage *image, struct x11_grab *s) @@ -260,7 +258,7 @@ paint_mouse_pointer(XImage *image, struct x11_grab *s) int to_line, to_column; int image_addr, xcim_addr; - xcim = XFixesGetCursorImage(dpy);; + xcim = XFixesGetCursorImage(dpy); x = xcim->x - xcim->xhot; y = xcim->y - xcim->yhot; @@ -288,7 +286,7 @@ paint_mouse_pointer(XImage *image, struct x11_grab *s) /** - * Reads new data in the image structure. + * Read new data in the image structure. * * @param dpy X11 display to grab from * @param d @@ -335,7 +333,7 @@ xget_zpixmap(Display *dpy, Drawable d, XImage *image, int x, int y) } /** - * Grabs a frame from x11 (public device demuxer API). + * Grab a frame from x11 (public device demuxer API). * * @param s1 Context from avformat core * @param pkt Packet holding the brabbed frame @@ -398,7 +396,7 @@ x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt) } /** - * Closes x11 frame grabber (public device demuxer API). + * Close x11 frame grabber (public device demuxer API). * * @param s1 Context from avformat core * @return 0 success, !0 failure diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/Makefile b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/Makefile index 2ddf21763..e1f5f5c8f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/Makefile +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/Makefile @@ -20,6 +20,7 @@ OBJS-$(CONFIG_FORMAT_FILTER) += vf_format.o OBJS-$(CONFIG_NOFORMAT_FILTER) += vf_format.o OBJS-$(CONFIG_NULL_FILTER) += vf_null.o OBJS-$(CONFIG_PAD_FILTER) += vf_pad.o +OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o OBJS-$(CONFIG_PIXELASPECT_FILTER) += vf_aspect.o OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o OBJS-$(CONFIG_SLICIFY_FILTER) += vf_slicify.o diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/allfilters.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/allfilters.c index e85485c41..90be2b45e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/allfilters.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/allfilters.c @@ -40,6 +40,7 @@ void avfilter_register_all(void) REGISTER_FILTER (NOFORMAT, noformat, vf); REGISTER_FILTER (NULL, null, vf); REGISTER_FILTER (PAD, pad, vf); + REGISTER_FILTER (PIXDESCTEST, pixdesctest, vf); REGISTER_FILTER (PIXELASPECT, pixelaspect, vf); REGISTER_FILTER (SCALE, scale, vf); REGISTER_FILTER (SLICIFY, slicify, vf); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/avfilter.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/avfilter.c index 38ca3b1e9..f442cdc3b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/avfilter.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/avfilter.c @@ -263,11 +263,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterPicRef *picref) link->cur_pic = avfilter_default_get_video_buffer(link, dst->min_perms, link->w, link->h); link->srcpic = picref; - link->cur_pic->pts = link->srcpic->pts; - link->cur_pic->pos = link->srcpic->pos; - link->cur_pic->pixel_aspect = link->srcpic->pixel_aspect; - link->cur_pic->interlaced = link->srcpic->interlaced; - link->cur_pic->top_field_first = link->srcpic->top_field_first; + avfilter_copy_picref_props(link->cur_pic, link->srcpic); } else link->cur_pic = picref; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/avfilter.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/avfilter.h index 716dc0b45..dff685fc2 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/avfilter.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/avfilter.h @@ -25,7 +25,7 @@ #include "libavutil/avutil.h" #define LIBAVFILTER_VERSION_MAJOR 1 -#define LIBAVFILTER_VERSION_MINOR 20 +#define LIBAVFILTER_VERSION_MINOR 22 #define LIBAVFILTER_VERSION_MICRO 0 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ @@ -40,17 +40,17 @@ #include "libavcodec/avcodec.h" /** - * Returns the LIBAVFILTER_VERSION_INT constant. + * Return the LIBAVFILTER_VERSION_INT constant. */ unsigned avfilter_version(void); /** - * Returns the libavfilter build-time configuration. + * Return the libavfilter build-time configuration. */ const char *avfilter_configuration(void); /** - * Returns the libavfilter license. + * Return the libavfilter license. */ const char *avfilter_license(void); @@ -121,7 +121,20 @@ typedef struct AVFilterPicRef } AVFilterPicRef; /** - * Adds a new reference to a picture. + * Copy properties of src to dst, without copying the actual video + * data. + */ +static inline void avfilter_copy_picref_props(AVFilterPicRef *dst, AVFilterPicRef *src) +{ + dst->pts = src->pts; + dst->pos = src->pos; + dst->pixel_aspect = src->pixel_aspect; + dst->interlaced = src->interlaced; + dst->top_field_first = src->top_field_first; +} + +/** + * Add a new reference to a picture. * @param ref an existing reference to the picture * @param pmask a bitmask containing the allowable permissions in the new * reference @@ -131,7 +144,7 @@ typedef struct AVFilterPicRef AVFilterPicRef *avfilter_ref_pic(AVFilterPicRef *ref, int pmask); /** - * Removes a reference to a picture. If this is the last reference to the + * Remove a reference to a picture. If this is the last reference to the * picture, the picture itself is also automatically freed. * @param ref reference to the picture */ @@ -188,15 +201,15 @@ struct AVFilterFormats }; /** - * Creates a list of supported formats. This is intended for use in + * Create a list of supported formats. This is intended for use in * AVFilter->query_formats(). - * @param pix_fmt list of pixel formats, terminated by PIX_FMT_NONE + * @param pix_fmts list of pixel formats, terminated by PIX_FMT_NONE * @return the format list, with no existing references */ AVFilterFormats *avfilter_make_format_list(const enum PixelFormat *pix_fmts); /** - * Adds pix_fmt to the list of pixel formats contained in *avff. + * Add pix_fmt to the list of pixel formats contained in *avff. * If *avff is NULL the function allocates the filter formats struct * and puts its pointer in *avff. * @@ -206,12 +219,12 @@ AVFilterFormats *avfilter_make_format_list(const enum PixelFormat *pix_fmts); int avfilter_add_colorspace(AVFilterFormats **avff, enum PixelFormat pix_fmt); /** - * Returns a list of all colorspaces supported by FFmpeg. + * Return a list of all colorspaces supported by FFmpeg. */ AVFilterFormats *avfilter_all_colorspaces(void); /** - * Returns a format list which contains the intersection of the formats of + * Return a format list which contains the intersection of the formats of * a and b. Also, all the references of a, all the references of b, and * a and b themselves will be deallocated. * @@ -221,7 +234,7 @@ AVFilterFormats *avfilter_all_colorspaces(void); AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b); /** - * Adds *ref as a new reference to formats. + * Add *ref as a new reference to formats. * That is the pointers will point like in the ascii art below: * ________ * |formats |<--------. @@ -235,7 +248,7 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b); void avfilter_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref); /** - * If *ref is non-NULL, removes *ref as a reference to the format list + * If *ref is non-NULL, remove *ref as a reference to the format list * it currently points to, deallocates that list if this was the last * reference, and sets *ref to NULL. * @@ -524,7 +537,7 @@ struct AVFilterLink }; /** - * Links two filters together. + * Link two filters together. * @param src the source filter * @param srcpad index of the output pad on the source filter * @param dst the destination filter @@ -535,14 +548,14 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad); /** - * Negotiates the colorspace, dimensions, etc of all inputs to a filter. + * Negotiate the colorspace, dimensions, etc of all inputs to a filter. * @param filter the filter to negotiate the properties for its inputs * @return zero on successful negotiation */ int avfilter_config_links(AVFilterContext *filter); /** - * Requests a picture buffer with a specific set of permissions. + * Request a picture buffer with a specific set of permissions. * @param link the output link to the filter from which the picture will * be requested * @param perms the required access permissions @@ -555,14 +568,14 @@ AVFilterPicRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h); /** - * Requests an input frame from the filter at the other end of the link. + * Request an input frame from the filter at the other end of the link. * @param link the input link * @return zero on success */ int avfilter_request_frame(AVFilterLink *link); /** - * Polls a frame from the filter chain. + * Poll a frame from the filter chain. * @param link the input link * @return the number of immediately available frames, a negative * number in case of error @@ -570,7 +583,7 @@ int avfilter_request_frame(AVFilterLink *link); int avfilter_poll_frame(AVFilterLink *link); /** - * Notifies the next filter of the start of a frame. + * Notifie the next filter of the start of a frame. * @param link the output link the frame will be sent over * @param picref A reference to the frame about to be sent. The data for this * frame need only be valid once draw_slice() is called for that @@ -580,13 +593,13 @@ int avfilter_poll_frame(AVFilterLink *link); void avfilter_start_frame(AVFilterLink *link, AVFilterPicRef *picref); /** - * Notifies the next filter that the current frame has finished. + * Notifie the next filter that the current frame has finished. * @param link the output link the frame was sent over */ void avfilter_end_frame(AVFilterLink *link); /** - * Sends a slice to the next filter. + * Send a slice to the next filter. * * Slices have to be provided in sequential order, either in * top-bottom or bottom-top order. If slices are provided in @@ -602,14 +615,14 @@ void avfilter_end_frame(AVFilterLink *link); */ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); -/** Initializes the filter system. Registers all builtin filters. */ +/** Initialize the filter system. Register all builtin filters. */ void avfilter_register_all(void); -/** Uninitializes the filter system. Unregisters all filters. */ +/** Uninitialize the filter system. Unregister all filters. */ void avfilter_uninit(void); /** - * Registers a filter. This is only needed if you plan to use + * Register a filter. This is only needed if you plan to use * avfilter_get_by_name later to lookup the AVFilter structure by name. A * filter can still by instantiated with avfilter_open even if it is not * registered. @@ -620,7 +633,7 @@ void avfilter_uninit(void); int avfilter_register(AVFilter *filter); /** - * Gets a filter definition matching the given name. + * Get a filter definition matching the given name. * @param name the filter name to find * @return the filter definition, if any matching one is registered. * NULL if none found. @@ -636,7 +649,7 @@ AVFilter *avfilter_get_by_name(const char *name); AVFilter **av_filter_next(AVFilter **filter); /** - * Creates a filter instance. + * Create a filter instance. * @param filter the filter to create an instance of * @param inst_name Name to give to the new instance. Can be NULL for none. * @return Pointer to the new instance on success. NULL on failure. @@ -644,7 +657,7 @@ AVFilter **av_filter_next(AVFilter **filter); AVFilterContext *avfilter_open(AVFilter *filter, const char *inst_name); /** - * Initializes a filter. + * Initialize a filter. * @param filter the filter to initialize * @param args A string of parameters to use when initializing the filter. * The format and meaning of this string varies by filter. @@ -655,13 +668,13 @@ AVFilterContext *avfilter_open(AVFilter *filter, const char *inst_name); int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque); /** - * Destroys a filter. + * Destroy a filter. * @param filter the filter to destroy */ void avfilter_destroy(AVFilterContext *filter); /** - * Inserts a filter in the middle of an existing link. + * Insert a filter in the middle of an existing link. * @param link the link into which the filter should be inserted * @param filt the filter to be inserted * @param in the input pad on the filter to connect @@ -672,7 +685,7 @@ int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, unsigned in, unsigned out); /** - * Inserts a new pad. + * Insert a new pad. * @param idx Insertion point. Pad is inserted at the end if this point * is beyond the end of the list of pads. * @param count Pointer to the number of pads in the list @@ -687,7 +700,7 @@ void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, AVFilterPad **pads, AVFilterLink ***links, AVFilterPad *newpad); -/** Inserts a new input pad for the filter. */ +/** Insert a new input pad for the filter. */ static inline void avfilter_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p) { @@ -695,7 +708,7 @@ static inline void avfilter_insert_inpad(AVFilterContext *f, unsigned index, &f->input_pads, &f->inputs, p); } -/** Inserts a new output pad for the filter. */ +/** Insert a new output pad for the filter. */ static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index, AVFilterPad *p) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/avfiltergraph.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/avfiltergraph.h index 164079598..23fc57c31 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/avfiltergraph.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/avfiltergraph.h @@ -32,7 +32,7 @@ typedef struct AVFilterGraph { } AVFilterGraph; /** - * Gets a filter instance with name name from graph. + * Get a filter instance with name name from graph. * * @return the pointer to the found filter instance or NULL if it * cannot be found. @@ -40,15 +40,15 @@ typedef struct AVFilterGraph { AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name); /** - * Adds an existing filter instance to a filter graph. + * Add an existing filter instance to a filter graph. * - * @param graph the filter graph + * @param graphctx the filter graph * @param filter the filter to be added */ int avfilter_graph_add_filter(AVFilterGraph *graphctx, AVFilterContext *filter); /** - * Checks for the validity of graph. + * Check for the validity of graph. * * A graph is considered valid if all its input and output pads are * connected. @@ -58,19 +58,19 @@ int avfilter_graph_add_filter(AVFilterGraph *graphctx, AVFilterContext *filter); int avfilter_graph_check_validity(AVFilterGraph *graphctx, AVClass *log_ctx); /** - * Configures all the links of graphctx. + * Configure all the links of graphctx. * * @return 0 in case of success, a negative value otherwise */ int avfilter_graph_config_links(AVFilterGraph *graphctx, AVClass *log_ctx); /** - * Configures the formats of all the links in the graph. + * Configure the formats of all the links in the graph. */ int avfilter_graph_config_formats(AVFilterGraph *graphctx, AVClass *log_ctx); /** - * Frees a graph and destroys its links. + * Free a graph and destroy its links. */ void avfilter_graph_destroy(AVFilterGraph *graph); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/defaults.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/defaults.c index 0ac88f85e..f53ec2472 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/defaults.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/defaults.c @@ -74,11 +74,7 @@ void avfilter_default_start_frame(AVFilterLink *link, AVFilterPicRef *picref) if(out) { out->outpic = avfilter_get_video_buffer(out, AV_PERM_WRITE, out->w, out->h); - out->outpic->pts = picref->pts; - out->outpic->pos = picref->pos; - out->outpic->pixel_aspect = picref->pixel_aspect; - out->outpic->interlaced = picref->interlaced; - out->outpic->top_field_first = picref->top_field_first; + avfilter_copy_picref_props(out->outpic, picref); avfilter_start_frame(out, avfilter_ref_pic(out->outpic, ~0)); } } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/graphparser.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/graphparser.c index 3fe8524ad..46d767609 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/graphparser.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/graphparser.c @@ -81,6 +81,7 @@ static AVFilterContext *create_filter(AVFilterGraph *ctx, int index, AVFilter *filt; char inst_name[30]; + char tmp_args[256]; snprintf(inst_name, sizeof(inst_name), "Filter %d %s", index, filt_name); @@ -104,6 +105,12 @@ static AVFilterContext *create_filter(AVFilterGraph *ctx, int index, return NULL; } + if (!strcmp(filt_name, "scale") && !strstr(args, "flags")) { + snprintf(tmp_args, sizeof(tmp_args), "%s:%s", + args, ctx->scale_sws_opts); + args = tmp_args; + } + if(avfilter_init_filter(filt_ctx, args, NULL)) { av_log(log_ctx, AV_LOG_ERROR, "error initializing filter '%s' with args '%s'\n", filt_name, args); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/graphparser.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/graphparser.h index e69f29574..510b4b335 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/graphparser.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/graphparser.h @@ -37,7 +37,7 @@ typedef struct AVFilterInOut { } AVFilterInOut; /** - * Adds a graph described by a string to a graph. + * Add a graph described by a string to a graph. * * @param graph the filter graph where to link the parsed graph context * @param filters string to be parsed diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/parseutils.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/parseutils.c index 9ac61d807..669ec9d29 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/parseutils.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/parseutils.c @@ -24,6 +24,7 @@ #include #include "libavutil/avutil.h" +#include "libavutil/avstring.h" #include "libavutil/random_seed.h" #include "parseutils.h" @@ -34,6 +35,7 @@ char *av_get_token(const char **buf, const char *term) char *out = av_malloc(strlen(*buf) + 1); char *ret= out, *end= out; const char *p = *buf; + if (!out) return NULL; p += strspn(p, WHITESPACES); while(*p && !strspn(p, term)) { @@ -64,7 +66,7 @@ char *av_get_token(const char **buf, const char *term) typedef struct { const char *name; ///< a string representing the name of the color - uint8_t rgba_color[4]; ///< RGBA values for the color + uint8_t rgb_color[3]; ///< RGB values for the color } ColorEntry; static ColorEntry color_table[] = { @@ -215,22 +217,30 @@ static int color_table_compare(const void *lhs, const void *rhs) return strcasecmp(lhs, ((const ColorEntry *)rhs)->name); } +#define ALPHA_SEP '@' + int av_parse_color(uint8_t *rgba_color, const char *color_string, void *log_ctx) { - if (!strcasecmp(color_string, "random") || !strcasecmp(color_string, "bikeshed")) { + char *tail, color_string2[128]; + const ColorEntry *entry; + av_strlcpy(color_string2, color_string, sizeof(color_string2)); + if ((tail = strchr(color_string2, ALPHA_SEP))) + *tail++ = 0; + rgba_color[3] = 255; + + if (!strcasecmp(color_string2, "random") || !strcasecmp(color_string2, "bikeshed")) { int rgba = av_get_random_seed(); rgba_color[0] = rgba >> 24; rgba_color[1] = rgba >> 16; rgba_color[2] = rgba >> 8; rgba_color[3] = rgba; - } else - if (!strncmp(color_string, "0x", 2)) { + } else if (!strncmp(color_string2, "0x", 2)) { char *tail; - int len = strlen(color_string); - unsigned int rgba = strtoul(color_string, &tail, 16); + int len = strlen(color_string2); + unsigned int rgba = strtoul(color_string2, &tail, 16); if (*tail || (len != 8 && len != 10)) { - av_log(log_ctx, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", color_string); + av_log(log_ctx, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", color_string2); return AVERROR(EINVAL); } if (len == 10) { @@ -241,23 +251,44 @@ int av_parse_color(uint8_t *rgba_color, const char *color_string, void *log_ctx) rgba_color[1] = rgba >> 8; rgba_color[2] = rgba; } else { - const ColorEntry *entry = bsearch(color_string, - color_table, - FF_ARRAY_ELEMS(color_table), - sizeof(ColorEntry), - color_table_compare); + entry = bsearch(color_string2, + color_table, + FF_ARRAY_ELEMS(color_table), + sizeof(ColorEntry), + color_table_compare); if (!entry) { - av_log(log_ctx, AV_LOG_ERROR, "Cannot find color '%s'\n", color_string); + av_log(log_ctx, AV_LOG_ERROR, "Cannot find color '%s'\n", color_string2); + return AVERROR(EINVAL); + } + memcpy(rgba_color, entry->rgb_color, 3); + } + + if (tail) { + unsigned long int alpha; + const char *alpha_string = tail; + if (!strncmp(alpha_string, "0x", 2)) { + alpha = strtoul(alpha_string, &tail, 16); + } else { + alpha = strtoul(alpha_string, &tail, 10); + if (*tail) { + double d = strtod(alpha_string, &tail); + alpha = d * 255; + } + } + + if (tail == alpha_string || *tail || alpha > 255) { + av_log(log_ctx, AV_LOG_ERROR, "Invalid alpha value specifier '%s' in '%s'\n", + alpha_string, color_string); return AVERROR(EINVAL); } - memcpy(rgba_color, entry->rgba_color, 4); + rgba_color[3] = alpha; } return 0; } /** - * Stores the value in the field in ctx that is named like key. + * Store the value in the field in ctx that is named like key. * ctx must be an AVClass context, storing is done using AVOptions. * * @param buf the string to parse, buf will be updated to point at the @@ -420,6 +451,21 @@ int main(void) "0xffXXee", "0xfoobar", "0xffffeeeeeeee", + "red@foo", + "random@10", + "0xff0000@1.0", + "red@", + "red@0xfff", + "red@0xf", + "red@2", + "red@0.1", + "red@-1", + "red@0.5", + "red@1.0", + "red@256", + "red@10foo", + "red@-1.0", + "red@-0.0", }; av_log_set_level(AV_LOG_DEBUG); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/parseutils.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/parseutils.h index b5b494e3a..e8e1e1a09 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/parseutils.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/parseutils.h @@ -28,25 +28,33 @@ #include "libavcodec/opt.h" /** - * Unescapes the given string until a non escaped terminating char, - * and returns the token corresponding to the unescaped string. + * Unescape the given string until a non escaped terminating char, + * and return the token corresponding to the unescaped string. * * The normal \ and ' escaping is supported. Leading and trailing * whitespaces are removed. * - * @param term a 0-terminated list of terminating chars * @param buf the buffer to parse, buf will be updated to point to the * terminating char + * @param term a 0-terminated list of terminating chars * @return the malloced unescaped string, which must be av_freed by - * the user + * the user, NULL in case of allocation failure */ char *av_get_token(const char **buf, const char *term); /** - * Puts the RGBA values that correspond to color_string in rgba_color. + * Put the RGBA values that correspond to color_string in rgba_color. * * @param color_string a string specifying a color. It can be the name of - * a color (case insensitive match) or a 0xRRGGBB[AA] sequence. + * a color (case insensitive match) or a 0xRRGGBB[AA] sequence, + * possibly followed by "@" and a string representing the alpha + * component. + * The alpha component may be a string composed by "0x" followed by an + * hexadecimal number or a base-10 number between 0 and 255, or a + * decimal number between 0.0 and 1.0, which represents the opacity + * value (0/0x00/0.0 means completely transparent, 255/0xff/1.0 + * completely opaque). + * If the alpha component is not specified then 255 is assumed. * The string "random" will result in a random color. * @return >= 0 in case of success, a negative value in case of * failure (for example if color_string cannot be parsed). @@ -54,7 +62,7 @@ char *av_get_token(const char **buf, const char *term); int av_parse_color(uint8_t *rgba_color, const char *color_string, void *log_ctx); /** - * Parses the key/value pairs list in opts. For each key/value pair + * Parse the key/value pairs list in opts. For each key/value pair * found, stores the value in the field in ctx that is named like the * key. ctx must be an AVClass context, storing is done using * AVOptions. diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_pad.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_pad.c index 13f1ed419..af80a68af 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_pad.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_pad.c @@ -27,7 +27,100 @@ #include "avfilter.h" #include "parseutils.h" #include "libavutil/pixdesc.h" -#include "libavcodec/colorspace.h" +#include "libavutil/colorspace.h" + +enum { RED = 0, GREEN, BLUE, ALPHA }; + +static int fill_line_with_color(uint8_t *line[4], int line_step[4], int w, uint8_t color[4], + enum PixelFormat pix_fmt, uint8_t rgba_color[4], int *is_packed_rgba) +{ + uint8_t rgba_map[4] = {0}; + int i; + const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[pix_fmt]; + int hsub = pix_desc->log2_chroma_w; + + *is_packed_rgba = 1; + switch (pix_fmt) { + case PIX_FMT_ARGB: rgba_map[ALPHA] = 0; rgba_map[RED ] = 1; rgba_map[GREEN] = 2; rgba_map[BLUE ] = 3; break; + case PIX_FMT_ABGR: rgba_map[ALPHA] = 0; rgba_map[BLUE ] = 1; rgba_map[GREEN] = 2; rgba_map[RED ] = 3; break; + case PIX_FMT_RGBA: + case PIX_FMT_RGB24: rgba_map[RED ] = 0; rgba_map[GREEN] = 1; rgba_map[BLUE ] = 2; rgba_map[ALPHA] = 3; break; + case PIX_FMT_BGRA: + case PIX_FMT_BGR24: rgba_map[BLUE ] = 0; rgba_map[GREEN] = 1; rgba_map[RED ] = 2; rgba_map[ALPHA] = 3; break; + default: + *is_packed_rgba = 0; + } + + if (*is_packed_rgba) { + line_step[0] = (av_get_bits_per_pixel(pix_desc))>>3; + for (i = 0; i < 4; i++) + color[rgba_map[i]] = rgba_color[i]; + + line[0] = av_malloc(w * line_step[0]); + for (i = 0; i < w; i++) + memcpy(line[0] + i * line_step[0], color, line_step[0]); + } else { + int plane; + + color[RED ] = RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]); + color[GREEN] = RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0); + color[BLUE ] = RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0); + color[ALPHA] = rgba_color[3]; + + for (plane = 0; plane < 4; plane++) { + int line_size; + int hsub1 = (plane == 1 || plane == 2) ? hsub : 0; + + line_step[plane] = 1; + line_size = (w >> hsub1) * line_step[plane]; + line[plane] = av_malloc(line_size); + memset(line[plane], color[plane], line_size); + } + } + + return 0; +} + +static void draw_rectangle(AVFilterPicRef *outpic, uint8_t *line[4], int line_step[4], + int hsub, int vsub, int x, int y, int w, int h) +{ + int i, plane; + uint8_t *p; + + for (plane = 0; plane < 4 && outpic->data[plane]; plane++) { + int hsub1 = plane == 1 || plane == 2 ? hsub : 0; + int vsub1 = plane == 1 || plane == 2 ? vsub : 0; + + p = outpic->data[plane] + (y >> vsub1) * outpic->linesize[plane]; + for (i = 0; i < (h >> vsub1); i++) { + memcpy(p + (x >> hsub1) * line_step[plane], line[plane], (w >> hsub1) * line_step[plane]); + p += outpic->linesize[plane]; + } + } +} + +static int query_formats(AVFilterContext *ctx) +{ + static const enum PixelFormat pix_fmts[] = { + PIX_FMT_ARGB, PIX_FMT_RGBA, + PIX_FMT_ABGR, PIX_FMT_BGRA, + PIX_FMT_RGB24, PIX_FMT_BGR24, + + PIX_FMT_YUV444P, PIX_FMT_YUV422P, + PIX_FMT_YUV420P, PIX_FMT_YUV411P, + PIX_FMT_YUV410P, PIX_FMT_YUV440P, + PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, + PIX_FMT_YUVJ420P, PIX_FMT_YUVJ440P, + PIX_FMT_YUVA420P, + + PIX_FMT_NONE + }; + + avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + return 0; +} + +#if CONFIG_PAD_FILTER typedef struct { int w, h; ///< output dimensions, a value of 0 will result in the input size @@ -71,56 +164,13 @@ static av_cold void uninit(AVFilterContext *ctx) } } -static int query_formats(AVFilterContext *ctx) -{ - static const enum PixelFormat pix_fmts[] = { - PIX_FMT_ARGB, PIX_FMT_RGBA, - PIX_FMT_ABGR, PIX_FMT_BGRA, - PIX_FMT_RGB24, PIX_FMT_BGR24, - - PIX_FMT_YUV444P, PIX_FMT_YUV422P, - PIX_FMT_YUV420P, PIX_FMT_YUV411P, - PIX_FMT_YUV410P, PIX_FMT_YUV440P, - PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, - PIX_FMT_YUVJ420P, PIX_FMT_YUVJ440P, - PIX_FMT_YUVA420P, - - PIX_FMT_NONE - }; - - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); - return 0; -} - -enum { RED = 0, GREEN, BLUE, ALPHA }; - static int config_input(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; PadContext *pad = ctx->priv; const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format]; uint8_t rgba_color[4]; - uint8_t rgba_map[4] = {0}; - int i, is_packed_rgb = 1; - - switch (inlink->format) { - case PIX_FMT_ARGB: - rgba_map[ALPHA] = 0; rgba_map[RED] = 1; rgba_map[GREEN] = 2; rgba_map[BLUE] = 3; - break; - case PIX_FMT_ABGR: - rgba_map[ALPHA] = 0; rgba_map[BLUE] = 1; rgba_map[GREEN] = 2; rgba_map[RED] = 3; - break; - case PIX_FMT_RGBA: - case PIX_FMT_RGB24: - rgba_map[RED] = 0; rgba_map[GREEN] = 1; rgba_map[BLUE] = 2; rgba_map[ALPHA] = 3; - break; - case PIX_FMT_BGRA: - case PIX_FMT_BGR24: - rgba_map[BLUE] = 0; rgba_map[GREEN] = 1; rgba_map[RED] = 2; rgba_map[ALPHA] = 3; - break; - default: - is_packed_rgb = 0; - } + int is_packed_rgba; pad->hsub = pix_desc->log2_chroma_w; pad->vsub = pix_desc->log2_chroma_h; @@ -139,37 +189,13 @@ static int config_input(AVFilterLink *inlink) pad->in_h = inlink->h & ~((1 << pad->vsub) - 1); memcpy(rgba_color, pad->color, sizeof(rgba_color)); - if (is_packed_rgb) { - pad->line_step[0] = (av_get_bits_per_pixel(&av_pix_fmt_descriptors[inlink->format]))>>3; - for (i = 0; i < 4; i++) - pad->color[rgba_map[i]] = rgba_color[i]; - - pad->line[0] = av_malloc(pad->w * pad->line_step[0]); - for (i = 0; i < pad->w; i++) - memcpy(pad->line[0] + i * pad->line_step[0], pad->color, pad->line_step[0]); - } else { - int plane; - - pad->color[0] = RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]); - pad->color[1] = RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0); - pad->color[2] = RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0); - pad->color[3] = rgba_color[3]; - - for (plane = 0; plane < 4; plane++) { - int line_size; - int hsub = (plane == 1 || plane == 2) ? pad->hsub : 0; - - pad->line_step[plane] = 1; - line_size = (pad->w >> hsub) * pad->line_step[plane]; - pad->line[plane] = av_malloc(line_size); - memset(pad->line[plane], pad->color[plane], line_size); - } - } + fill_line_with_color(pad->line, pad->line_step, pad->w, pad->color, + inlink->format, rgba_color, &is_packed_rgba); av_log(ctx, AV_LOG_INFO, "w:%d h:%d x:%d y:%d color:0x%02X%02X%02X%02X[%s]\n", pad->w, pad->h, pad->x, pad->y, pad->color[0], pad->color[1], pad->color[2], pad->color[3], - is_packed_rgb ? "rgba" : "yuva"); + is_packed_rgba ? "rgba" : "yuva"); if (pad->x < 0 || pad->y < 0 || pad->w <= 0 || pad->h <= 0 || @@ -238,24 +264,6 @@ static void end_frame(AVFilterLink *link) avfilter_unref_pic(link->cur_pic); } -static void draw_rectangle(AVFilterPicRef *outpic, uint8_t *line[4], int line_step[4], - int hsub, int vsub, int x, int y, int w, int h) -{ - int i, plane; - uint8_t *p; - - for (plane = 0; plane < 4 && outpic->data[plane]; plane++) { - int hsub1 = plane == 1 || plane == 2 ? hsub : 0; - int vsub1 = plane == 1 || plane == 2 ? vsub : 0; - - p = outpic->data[plane] + (y >> vsub1) * outpic->linesize[plane]; - for (i = 0; i < (h >> vsub1); i++) { - memcpy(p + (x >> hsub1) * line_step[plane], line[plane], (w >> hsub1) * line_step[plane]); - p += outpic->linesize[plane]; - } - } -} - static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice) { PadContext *pad = link->dst->priv; @@ -306,7 +314,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) AVFilter avfilter_vf_pad = { .name = "pad", - .description = "Add pads to the input image.", + .description = NULL_IF_CONFIG_SMALL("Pad input image to width:height[:x:y[:color]] (default x and y: 0, default color: black)."), .priv_size = sizeof(PadContext), .init = init, @@ -327,3 +335,5 @@ AVFilter avfilter_vf_pad = { .config_props = config_output, }, { .name = NULL}}, }; + +#endif /* CONFIG_PAD_FILTER */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_pixdesctest.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_pixdesctest.c new file mode 100644 index 000000000..179e2a8aa --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_pixdesctest.c @@ -0,0 +1,128 @@ +/* + * This file is part of FFmpeg. + * copyright (C) 2009 Stefano Sabatini + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * pixdesc test filter + */ + +#include "libavutil/pixdesc.h" +#include "avfilter.h" + +typedef struct { + const AVPixFmtDescriptor *pix_desc; + uint16_t *line; +} PixdescTestContext; + +static av_cold void uninit(AVFilterContext *ctx) +{ + PixdescTestContext *priv = ctx->priv; + av_freep(&priv->line); +} + +static int config_props(AVFilterLink *inlink) +{ + PixdescTestContext *priv = inlink->dst->priv; + + priv->pix_desc = &av_pix_fmt_descriptors[inlink->format]; + + if (!(priv->line = av_malloc(sizeof(*priv->line) * inlink->w))) + return AVERROR(ENOMEM); + + return 0; +} + +static void start_frame(AVFilterLink *inlink, AVFilterPicRef *picref) +{ + PixdescTestContext *priv = inlink->dst->priv; + AVFilterLink *outlink = inlink->dst->outputs[0]; + AVFilterPicRef *outpicref; + int i; + + outlink->outpic = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, + outlink->w, outlink->h); + outpicref = outlink->outpic; + avfilter_copy_picref_props(outpicref, picref); + + for (i = 0; i < 4; i++) { + int h = outlink->h; + h = i == 1 || i == 2 ? h>>priv->pix_desc->log2_chroma_h : h; + if (outpicref->data[i]) { + uint8_t *data = outpicref->data[i] + + (outpicref->linesize[i] > 0 ? 0 : outpicref->linesize[i] * (h-1)); + memset(data, 0, FFABS(outpicref->linesize[i]) * h); + } + } + + /* copy palette */ + if (priv->pix_desc->flags & PIX_FMT_PAL) + memcpy(outpicref->data[1], outpicref->data[1], 256*4); + + avfilter_start_frame(outlink, avfilter_ref_pic(outpicref, ~0)); +} + +static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) +{ + PixdescTestContext *priv = inlink->dst->priv; + AVFilterPicRef *inpic = inlink->cur_pic; + AVFilterPicRef *outpic = inlink->dst->outputs[0]->outpic; + int i, c, w = inlink->w; + + for (c = 0; c < priv->pix_desc->nb_components; c++) { + int w1 = c == 1 || c == 2 ? w>>priv->pix_desc->log2_chroma_w : w; + int h1 = c == 1 || c == 2 ? h>>priv->pix_desc->log2_chroma_h : h; + int y1 = c == 1 || c == 2 ? y>>priv->pix_desc->log2_chroma_h : y; + + for (i = y1; i < y1 + h1; i++) { + av_read_image_line(priv->line, + inpic->data, + inpic->linesize, + priv->pix_desc, + 0, i, c, w1, 0); + + av_write_image_line(priv->line, + outpic->data, + outpic->linesize, + priv->pix_desc, + 0, i, c, w1); + } + } + + avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); +} + +AVFilter avfilter_vf_pixdesctest = { + .name = "pixdesctest", + .description = "Test pixel format definitions.", + + .priv_size = sizeof(PixdescTestContext), + .uninit = uninit, + + .inputs = (AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .start_frame = start_frame, + .draw_slice = draw_slice, + .config_props = config_props, + .min_perms = AV_PERM_READ, }, + { .name = NULL}}, + + .outputs = (AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, }, + { .name = NULL}}, +}; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_scale.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_scale.c index 29fd3fe4e..ebbc57532 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_scale.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_scale.c @@ -152,10 +152,7 @@ static void start_frame(AVFilterLink *link, AVFilterPicRef *picref) scale->vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h; outpicref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); - outpicref->pts = picref->pts; - outpicref->pos = picref->pos; - outpicref->interlaced = picref->interlaced; - outpicref->top_field_first = picref->top_field_first; + avfilter_copy_picref_props(outpicref, picref); outlink->outpic = outpicref; @@ -173,7 +170,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) ScaleContext *scale = link->dst->priv; int out_h; AVFilterPicRef *cur_pic = link->cur_pic; - uint8_t *data[4]; + const uint8_t *data[4]; if (scale->slice_y == 0 && slice_dir == -1) scale->slice_y = link->dst->outputs[0]->h; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_unsharp.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_unsharp.c index 78a6d7c36..d2314a3f8 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_unsharp.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vf_unsharp.c @@ -83,9 +83,9 @@ static void unsharpen(uint8_t *dst, uint8_t *src, int dst_stride, int src_stride for (y = 0; y < 2 * fp->steps_y; y++) memset(sc[y], 0, sizeof(sc[y][0]) * (width + 2 * fp->steps_x)); - for (y =- fp->steps_y; y < height + fp->steps_y; y++) { + for (y = -fp->steps_y; y < height + fp->steps_y; y++) { memset(sr, 0, sizeof(sr[0]) * (2 * fp->steps_x - 1)); - for (x =- fp->steps_x; x < width + fp->steps_x; x++) { + for (x = -fp->steps_x; x < width + fp->steps_x; x++) { tmp1 = x <= 0 ? src[0] : x >= width ? src[width-1] : src[x]; for (z = 0; z < fp->steps_x * 2; z += 2) { tmp2 = sr[z + 0] + tmp1; sr[z + 0] = tmp1; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vsrc_buffer.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vsrc_buffer.c index 17e56eeb7..98f2e371f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vsrc_buffer.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vsrc_buffer.c @@ -26,7 +26,8 @@ typedef struct { int64_t pts; AVFrame frame; int has_frame; - int h, w, pix_fmt; + int h, w; + enum PixelFormat pix_fmt; AVRational pixel_aspect; } BufferSourceContext; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vsrc_buffer.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vsrc_buffer.h index 071403c77..fa204438d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vsrc_buffer.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavfilter/vsrc_buffer.h @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "avfilter.h" + int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts, AVRational pixel_aspect); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/Makefile b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/Makefile index 4b8103fed..36669bd57 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/Makefile +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/Makefile @@ -55,14 +55,14 @@ OBJS-$(CONFIG_DIRAC_MUXER) += raw.o OBJS-$(CONFIG_DNXHD_DEMUXER) += raw.o OBJS-$(CONFIG_DNXHD_MUXER) += raw.o OBJS-$(CONFIG_DSICIN_DEMUXER) += dsicin.o -OBJS-$(CONFIG_DTS_DEMUXER) += raw.o id3v2.o +OBJS-$(CONFIG_DTS_DEMUXER) += raw.o OBJS-$(CONFIG_DTS_MUXER) += raw.o OBJS-$(CONFIG_DV_DEMUXER) += dv.o OBJS-$(CONFIG_DV_MUXER) += dvenc.o OBJS-$(CONFIG_DXA_DEMUXER) += dxa.o riff.o OBJS-$(CONFIG_EA_CDATA_DEMUXER) += eacdata.o OBJS-$(CONFIG_EA_DEMUXER) += electronicarts.o -OBJS-$(CONFIG_EAC3_DEMUXER) += raw.o id3v2.o +OBJS-$(CONFIG_EAC3_DEMUXER) += raw.o OBJS-$(CONFIG_EAC3_MUXER) += raw.o OBJS-$(CONFIG_FFM_DEMUXER) += ffmdec.o OBJS-$(CONFIG_FFM_MUXER) += ffmenc.o @@ -80,7 +80,7 @@ OBJS-$(CONFIG_FOURXM_DEMUXER) += 4xm.o OBJS-$(CONFIG_FRAMECRC_MUXER) += framecrcenc.o OBJS-$(CONFIG_FRAMEMD5_MUXER) += md5enc.o OBJS-$(CONFIG_GIF_MUXER) += gif.o -OBJS-$(CONFIG_GSM_DEMUXER) += raw.o id3v2.o +OBJS-$(CONFIG_GSM_DEMUXER) += raw.o OBJS-$(CONFIG_GXF_DEMUXER) += gxf.o OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o audiointerleave.o OBJS-$(CONFIG_H261_DEMUXER) += raw.o @@ -111,14 +111,14 @@ OBJS-$(CONFIG_MATROSKA_MUXER) += matroskaenc.o matroska.o \ OBJS-$(CONFIG_MD5_MUXER) += md5enc.o OBJS-$(CONFIG_MJPEG_DEMUXER) += raw.o OBJS-$(CONFIG_MJPEG_MUXER) += raw.o -OBJS-$(CONFIG_MLP_DEMUXER) += raw.o id3v2.o +OBJS-$(CONFIG_MLP_DEMUXER) += raw.o OBJS-$(CONFIG_MLP_MUXER) += raw.o OBJS-$(CONFIG_MM_DEMUXER) += mm.o OBJS-$(CONFIG_MMF_DEMUXER) += mmf.o raw.o OBJS-$(CONFIG_MMF_MUXER) += mmf.o riff.o OBJS-$(CONFIG_MOV_DEMUXER) += mov.o riff.o isom.o OBJS-$(CONFIG_MOV_MUXER) += movenc.o riff.o isom.o avc.o movenchint.o -OBJS-$(CONFIG_MP2_MUXER) += mp3.o id3v1.o +OBJS-$(CONFIG_MP2_MUXER) += mp3.o id3v1.o id3v2.o OBJS-$(CONFIG_MP3_DEMUXER) += mp3.o id3v1.o id3v2.o OBJS-$(CONFIG_MP3_MUXER) += mp3.o id3v1.o id3v2.o OBJS-$(CONFIG_MPC_DEMUXER) += mpc.o id3v1.o id3v2.o apetag.o @@ -158,7 +158,7 @@ OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o \ vorbiscomment.o OBJS-$(CONFIG_OGG_MUXER) += oggenc.o \ vorbiscomment.o -OBJS-$(CONFIG_OMA_DEMUXER) += oma.o raw.o +OBJS-$(CONFIG_OMA_DEMUXER) += oma.o raw.o id3v2.o id3v1.o OBJS-$(CONFIG_PCM_ALAW_DEMUXER) += raw.o OBJS-$(CONFIG_PCM_ALAW_MUXER) += raw.o OBJS-$(CONFIG_PCM_F32BE_DEMUXER) += raw.o @@ -228,9 +228,11 @@ OBJS-$(CONFIG_SDP_DEMUXER) += rtsp.o \ rtpdec_asf.o \ rtpdec_h263.o \ rtpdec_h264.o \ + rtpdec_mpeg4.o \ + rtpdec_svq3.o \ rtpdec_xiph.o OBJS-$(CONFIG_SEGAFILM_DEMUXER) += segafilm.o -OBJS-$(CONFIG_SHORTEN_DEMUXER) += raw.o id3v2.o +OBJS-$(CONFIG_SHORTEN_DEMUXER) += raw.o OBJS-$(CONFIG_SIFF_DEMUXER) += siff.o OBJS-$(CONFIG_SMACKER_DEMUXER) += smacker.o OBJS-$(CONFIG_SOL_DEMUXER) += sol.o raw.o @@ -243,7 +245,7 @@ OBJS-$(CONFIG_SWF_MUXER) += swfenc.o OBJS-$(CONFIG_THP_DEMUXER) += thp.o OBJS-$(CONFIG_TIERTEXSEQ_DEMUXER) += tiertexseq.o OBJS-$(CONFIG_TMV_DEMUXER) += tmv.o -OBJS-$(CONFIG_TRUEHD_DEMUXER) += raw.o id3v2.o +OBJS-$(CONFIG_TRUEHD_DEMUXER) += raw.o OBJS-$(CONFIG_TRUEHD_MUXER) += raw.o OBJS-$(CONFIG_TTA_DEMUXER) += tta.o id3v1.o id3v2.o OBJS-$(CONFIG_TXD_DEMUXER) += txd.o diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/adtsenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/adtsenc.c index ecc8dc40d..232d32270 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/adtsenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/adtsenc.c @@ -23,6 +23,7 @@ #include "libavcodec/get_bits.h" #include "libavcodec/put_bits.h" #include "libavcodec/avcodec.h" +#include "libavcodec/mpeg4audio.h" #include "avformat.h" #include "adts.h" @@ -30,11 +31,17 @@ int ff_adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf { GetBitContext gb; PutBitContext pb; + MPEG4AudioConfig m4ac; + int off; init_get_bits(&gb, buf, size * 8); - adts->objecttype = get_bits(&gb, 5) - 1; - adts->sample_rate_index = get_bits(&gb, 4); - adts->channel_conf = get_bits(&gb, 4); + off = ff_mpeg4audio_get_config(&m4ac, buf, size); + if (off < 0) + return off; + skip_bits_long(&gb, off); + adts->objecttype = m4ac.object_type - 1; + adts->sample_rate_index = m4ac.sampling_index; + adts->channel_conf = m4ac.chan_config; if (adts->objecttype > 3U) { av_log(s, AV_LOG_ERROR, "MPEG-4 AOT %d is not allowed in ADTS\n", adts->objecttype+1); @@ -52,10 +59,6 @@ int ff_adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf av_log(s, AV_LOG_ERROR, "Scalable configurations are not allowed in ADTS\n"); return -1; } - if (get_bits(&gb, 1)) { - av_log_missing_feature(s, "Signaled SBR or PS", 0); - return -1; - } if (!adts->channel_conf) { init_put_bits(&pb, adts->pce_data, MAX_PCE_SIZE); @@ -74,7 +77,7 @@ static int adts_write_header(AVFormatContext *s) ADTSContext *adts = s->priv_data; AVCodecContext *avc = s->streams[0]->codec; - if(avc->extradata_size > 0 && + if (avc->extradata_size > 0 && ff_adts_decode_extradata(s, adts, avc->extradata, avc->extradata_size) < 0) return -1; @@ -120,10 +123,10 @@ static int adts_write_packet(AVFormatContext *s, AVPacket *pkt) if (!pkt->size) return 0; - if(adts->write_adts) { + if (adts->write_adts) { ff_adts_write_frame_header(adts, buf, pkt->size, adts->pce_size); put_buffer(pb, buf, ADTS_HEADER_SIZE); - if(adts->pce_size) { + if (adts->pce_size) { put_buffer(pb, adts->pce_data, adts->pce_size); adts->pce_size = 0; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/allformats.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/allformats.c index 2fd2b4cac..94ab78c4e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/allformats.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/allformats.c @@ -34,7 +34,7 @@ #define REGISTER_PROTOCOL(X,x) { \ extern URLProtocol x##_protocol; \ - if(CONFIG_##X##_PROTOCOL) av_register_protocol(&x##_protocol); } + if(CONFIG_##X##_PROTOCOL) av_register_protocol2(&x##_protocol, sizeof(x##_protocol)); } void av_register_all(void) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/asfcrypt.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/asfcrypt.c index 09e9af6f2..55ad82795 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/asfcrypt.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/asfcrypt.c @@ -170,7 +170,7 @@ void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len) { ms_state = multiswap_enc(ms_keys, ms_state, AV_RL64(qwords)); multiswap_invert_keys(ms_keys); packetkey = (packetkey << 32) | (packetkey >> 32); - packetkey = le2me_64(packetkey); + packetkey = av_le2ne64(packetkey); packetkey = multiswap_dec(ms_keys, ms_state, packetkey); AV_WL64(qwords, packetkey); } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/asfdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/asfdec.c index b0927797a..149a49306 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/asfdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/asfdec.c @@ -35,6 +35,7 @@ void ff_mms_set_stream_selection(URLContext *h, AVFormatContext *format); #undef NDEBUG #include +#define ASF_MAX_STREAMS 127 #define FRAME_HEADER_SIZE 17 // Fix Me! FRAME_HEADER_SIZE may be different. @@ -244,6 +245,11 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) int64_t pos1, pos2, start_time; int test_for_ext_stream_audio, is_dvr_ms_audio=0; + if (s->nb_streams == ASF_MAX_STREAMS) { + av_log(s, AV_LOG_ERROR, "too many streams\n"); + return AVERROR(EINVAL); + } + pos1 = url_ftell(pb); st = av_new_stream(s, 0); @@ -380,7 +386,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl)); #if HAVE_BIGENDIAN for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++) - st->codec->palctrl->palette[i] = bswap_32(((uint32_t*)st->codec->extradata)[i]); + st->codec->palctrl->palette[i] = av_bswap32(((uint32_t*)st->codec->extradata)[i]); #else memcpy(st->codec->palctrl->palette, st->codec->extradata, FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); @@ -390,8 +396,14 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->codec_tag = tag1; st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag1); - if(tag1 == MKTAG('D', 'V', 'R', ' ')) + if(tag1 == MKTAG('D', 'V', 'R', ' ')){ st->need_parsing = AVSTREAM_PARSE_FULL; + // issue658 containse wrong w/h and MS even puts a fake seq header with wrong w/h in extradata while a correct one is in te stream. maximum lameness + st->codec->width = + st->codec->height = 0; + av_freep(&st->codec->extradata); + st->codec->extradata_size=0; + } if(st->codec->codec_id == CODEC_ID_H264) st->need_parsing = AVSTREAM_PARSE_FULL_ONCE; } @@ -519,11 +531,13 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) // there could be a optional stream properties object to follow // if so the next iteration will pick it up + continue; } else if (!guidcmp(&g, &ff_asf_head1_guid)) { int v1, v2; get_guid(pb, &g); v1 = get_le32(pb); v2 = get_le16(pb); + continue; } else if (!guidcmp(&g, &ff_asf_marker_header)) { int i, count, name_len; char name[1024]; @@ -1051,7 +1065,7 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pts; int64_t pos= *ppos; int i; - int64_t start_pos[s->nb_streams]; + int64_t start_pos[ASF_MAX_STREAMS]; for(i=0; inb_streams; i++){ start_pos[i]= pos; @@ -1060,8 +1074,7 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, if (s->packet_size > 0) pos= (pos+s->packet_size-1-s->data_offset)/s->packet_size*s->packet_size+ s->data_offset; *ppos= pos; - if (url_fseek(s->pb, pos, SEEK_SET) < 0) - return AV_NOPTS_VALUE; + url_fseek(s->pb, pos, SEEK_SET); //printf("asf_read_pts\n"); asf_reset_header(s); @@ -1103,11 +1116,7 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index) int64_t current_pos= url_ftell(s->pb); int i; - if(url_fseek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET) < 0) { - asf->index_read= -1; - return; - } - + url_fseek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET); get_guid(s->pb, &g); if (!guidcmp(&g, &index_guid)) { int64_t itime, last_pos=-1; @@ -1132,8 +1141,6 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index) } } asf->index_read= 1; - } else { - asf->index_read= -1; } url_fseek(s->pb, current_pos, SEEK_SET); } @@ -1145,20 +1152,9 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int int64_t pos; int index; - if (pts == 0) { - // this is a hack since av_gen_search searches the entire file in this case - av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", s->data_offset); - if (url_fseek(s->pb, s->data_offset, SEEK_SET) < 0) - return -1; - return 0; - } - if (s->packet_size <= 0) return -1; - if (st->codec->codec_type != CODEC_TYPE_VIDEO) - return -1; - /* Try using the protocol's read_seek if available */ if(s->pb) { int ret = av_url_read_fseek(s->pb, stream_index, pts, flags); @@ -1205,8 +1201,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int /* do the seek */ av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos); - if(url_fseek(s->pb, pos, SEEK_SET)<0) - return -1; + url_fseek(s->pb, pos, SEEK_SET); } asf_reset_header(s); return 0; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/assdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/assdec.c index 5f8e0b96b..676fb39d6 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/assdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/assdec.c @@ -177,7 +177,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) AVInputFormat ass_demuxer = { "ass", - NULL_IF_CONFIG_SMALL("SSA/ASS format"), + NULL_IF_CONFIG_SMALL("Advanced SubStation Alpha subtitle format"), sizeof(ASSContext), probe, read_header, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/assenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/assenc.c index d1b93e82e..41d5bbdca 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/assenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/assenc.c @@ -79,7 +79,7 @@ static int write_trailer(AVFormatContext *s) AVOutputFormat ass_muxer = { "ass", - NULL_IF_CONFIG_SMALL("SSA/ASS format"), + NULL_IF_CONFIG_SMALL("Advanced SubStation Alpha subtitle format"), NULL, "ass,ssa", sizeof(ASSContext), diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avformat.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avformat.h index a3b0dec2e..7d7fce855 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avformat.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avformat.h @@ -22,7 +22,7 @@ #define AVFORMAT_AVFORMAT_H #define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 68 +#define LIBAVFORMAT_VERSION_MINOR 73 #define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ @@ -42,12 +42,12 @@ unsigned avformat_version(void); /** - * Returns the libavformat build-time configuration. + * Return the libavformat build-time configuration. */ const char *avformat_configuration(void); /** - * Returns the libavformat license. + * Return the libavformat license. */ const char *avformat_license(void); @@ -130,7 +130,7 @@ typedef struct AVMetadata AVMetadata; typedef struct AVMetadataConv AVMetadataConv; /** - * Gets a metadata element with matching key. + * Get a metadata element with matching key. * @param prev Set to the previous matching element to find the next. * If set to NULL the first matching element is returned. * @param flags Allows case as well as suffix-insensitive comparisons. @@ -141,7 +141,7 @@ av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int f #if LIBAVFORMAT_VERSION_MAJOR == 52 /** - * Sets the given tag in m, overwriting an existing tag. + * Set the given tag in m, overwriting an existing tag. * @param key tag key to add to m (will be av_strduped) * @param value tag value to add to m (will be av_strduped) * @return >= 0 on success otherwise an error code <0 @@ -151,7 +151,7 @@ attribute_deprecated int av_metadata_set(AVMetadata **pm, const char *key, const #endif /** - * Sets the given tag in m, overwriting an existing tag. + * Set the given tag in m, overwriting an existing tag. * @param key tag key to add to m (will be av_strduped depending on flags) * @param value tag value to add to m (will be av_strduped depending on flags). * Passing a NULL value will cause an existing tag to be deleted. @@ -160,7 +160,7 @@ attribute_deprecated int av_metadata_set(AVMetadata **pm, const char *key, const int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags); /** - * Converts all the metadata sets from ctx according to the source and + * Convert all the metadata sets from ctx according to the source and * destination conversion tables. If one of the tables is NULL, then * tags are converted to/from ffmpeg generic tag names. * @param d_conv destination tags format conversion table @@ -170,7 +170,7 @@ void av_metadata_conv(struct AVFormatContext *ctx,const AVMetadataConv *d_conv, const AVMetadataConv *s_conv); /** - * Frees all the memory allocated for an AVMetadata struct. + * Free all the memory allocated for an AVMetadata struct. */ void av_metadata_free(AVMetadata **m); @@ -179,7 +179,7 @@ void av_metadata_free(AVMetadata **m); /** - * Allocates and reads the payload of a packet and initializes its + * Allocate and read the payload of a packet and initialize its * fields with default values. * * @param pkt packet @@ -349,18 +349,18 @@ typedef struct AVInputFormat { /** General purpose read-only value that the format can use. */ int value; - /** Starts/resumes playing - only meaningful if using a network-based format + /** Start/resume playing - only meaningful if using a network-based format (RTSP). */ int (*read_play)(struct AVFormatContext *); - /** Pauses playing - only meaningful if using a network-based format + /** Pause playing - only meaningful if using a network-based format (RTSP). */ int (*read_pause)(struct AVFormatContext *); const struct AVCodecTag * const *codec_tag; /** - * Seeks to timestamp ts. + * Seek to timestamp ts. * Seeking will be done so that the point from which all active streams * can be presented successfully will be closest to ts and within min/max_ts. * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. @@ -396,6 +396,9 @@ typedef struct AVIndexEntry { #define AV_DISPOSITION_COMMENT 0x0008 #define AV_DISPOSITION_LYRICS 0x0010 #define AV_DISPOSITION_KARAOKE 0x0020 +/** Track should be used during playback by default. + Useful for subtitle track that should be displayed + even when user did not explicitly ask for subtitles. */ #define AV_DISPOSITION_FORCED 0x0040 /** @@ -495,7 +498,8 @@ typedef struct AVStream { AVMetadata *metadata; - /* av_read_frame() support */ + /* Intended mostly for av_read_frame() support. Not supposed to be used by */ + /* external applications; try to use something else if at all possible. */ const uint8_t *cur_ptr; int cur_len; AVPacket cur_pkt; @@ -569,9 +573,7 @@ typedef struct AVChapter { } AVChapter; #if LIBAVFORMAT_VERSION_MAJOR < 53 -#define MAX_STREAMS 100 -#else -#define MAX_STREAMS 100 +#define MAX_STREAMS 20 #endif /** @@ -793,8 +795,8 @@ attribute_deprecated AVOutputFormat *guess_format(const char *short_name, #endif /** - * Returns the output format in the list of registered output formats - * which best matches the provided parameters, or returns NULL if + * Return the output format in the list of registered output formats + * which best matches the provided parameters, or return NULL if * there is no match. * * @param short_name if non-NULL checks if short_name matches with the @@ -809,14 +811,14 @@ AVOutputFormat *av_guess_format(const char *short_name, const char *mime_type); /** - * Guesses the codec ID based upon muxer and filename. + * Guess the codec ID based upon muxer and filename. */ enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, const char *filename, const char *mime_type, enum AVMediaType type); /** - * Sends a nice hexadecimal dump of a buffer to the specified file stream. + * Send a nice hexadecimal dump of a buffer to the specified file stream. * * @param f The file stream pointer where the dump should be sent to. * @param buf buffer @@ -827,7 +829,7 @@ enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, void av_hex_dump(FILE *f, uint8_t *buf, int size); /** - * Sends a nice hexadecimal dump of a buffer to the log. + * Send a nice hexadecimal dump of a buffer to the log. * * @param avcl A pointer to an arbitrary struct of which the first field is a * pointer to an AVClass struct. @@ -841,7 +843,7 @@ void av_hex_dump(FILE *f, uint8_t *buf, int size); void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size); /** - * Sends a nice dump of a packet to the specified file stream. + * Send a nice dump of a packet to the specified file stream. * * @param f The file stream pointer where the dump should be sent to. * @param pkt packet to dump @@ -850,7 +852,7 @@ void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size); void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); /** - * Sends a nice dump of a packet to the log. + * Send a nice dump of a packet to the log. * * @param avcl A pointer to an arbitrary struct of which the first field is a * pointer to an AVClass struct. @@ -862,7 +864,7 @@ void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload); /** - * Initializes libavformat and registers all the muxers, demuxers and + * Initialize libavformat and register all the muxers, demuxers and * protocols. If you do not call this function, then you can select * exactly which formats you want to support. * @@ -873,7 +875,7 @@ void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload); void av_register_all(void); /** - * Gets the CodecID for the given codec tag tag. + * Get the CodecID for the given codec tag tag. * If no codec id is found returns CODEC_ID_NONE. * * @param tags list of supported codec_id-codec_tag pairs, as stored @@ -882,7 +884,7 @@ void av_register_all(void); enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag); /** - * Gets the codec tag for the given codec id id. + * Get the codec tag for the given codec id id. * If no codec tag is found returns 0. * * @param tags list of supported codec_id-codec_tag pairs, as stored @@ -893,12 +895,12 @@ unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecI /* media file input */ /** - * Finds AVInputFormat based on the short name of the input format. + * Find AVInputFormat based on the short name of the input format. */ AVInputFormat *av_find_input_format(const char *short_name); /** - * Guesses the file format. + * Guess the file format. * * @param is_opened Whether the file is already opened; determines whether * demuxers with or without AVFMT_NOFILE are probed. @@ -906,7 +908,7 @@ AVInputFormat *av_find_input_format(const char *short_name); AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); /** - * Guesses the file format. + * Guess the file format. * * @param is_opened Whether the file is already opened; determines whether * demuxers with or without AVFMT_NOFILE are probed. @@ -919,7 +921,7 @@ AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max); /** - * Allocates all the structures needed to read an input stream. + * Allocate all the structures needed to read an input stream. * This does not open the needed codecs for decoding the stream[s]. */ int av_open_input_stream(AVFormatContext **ic_ptr, @@ -927,7 +929,7 @@ int av_open_input_stream(AVFormatContext **ic_ptr, AVInputFormat *fmt, AVFormatParameters *ap); /** - * Opens a media file as input. The codecs are not opened. Only the file + * Open a media file as input. The codecs are not opened. Only the file * header (if present) is read. * * @param ic_ptr The opened media file handle is put here. @@ -951,14 +953,14 @@ attribute_deprecated AVFormatContext *av_alloc_format_context(void); #endif /** - * Allocates an AVFormatContext. + * Allocate an AVFormatContext. * Can be freed with av_free() but do not forget to free everything you * explicitly allocated as well! */ AVFormatContext *avformat_alloc_context(void); /** - * Reads packets of a media file to get stream information. This + * Read packets of a media file to get stream information. This * is useful for file formats with no headers such as MPEG. This * function also computes the real framerate in case of MPEG-2 repeat * frame mode. @@ -973,7 +975,7 @@ AVFormatContext *avformat_alloc_context(void); int av_find_stream_info(AVFormatContext *ic); /** - * Reads a transport packet from a media file. + * Read a transport packet from a media file. * * This function is obsolete and should never be used. * Use av_read_frame() instead. @@ -985,7 +987,7 @@ int av_find_stream_info(AVFormatContext *ic); int av_read_packet(AVFormatContext *s, AVPacket *pkt); /** - * Returns the next frame of a stream. + * Return the next frame of a stream. * * The returned packet is valid * until the next av_read_frame() or until av_close_input_file() and @@ -1006,7 +1008,7 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt); int av_read_frame(AVFormatContext *s, AVPacket *pkt); /** - * Seeks to the keyframe at timestamp. + * Seek to the keyframe at timestamp. * 'timestamp' in 'stream_index'. * @param stream_index If stream_index is (-1), a default * stream is selected, and timestamp is automatically converted @@ -1020,7 +1022,7 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags); /** - * Seeks to timestamp ts. + * Seek to timestamp ts. * Seeking will be done so that the point from which all active streams * can be presented successfully will be closest to ts and within min/max_ts. * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. @@ -1041,40 +1043,40 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, * @param flags flags * @return >=0 on success, error code otherwise * - * @NOTE This is part of the new seek API which is still under construction. + * @note This is part of the new seek API which is still under construction. * Thus do not use this yet. It may change at any time, do not expect * ABI compatibility yet! */ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); /** - * Starts playing a network-based stream (e.g. RTSP stream) at the + * Start playing a network-based stream (e.g. RTSP stream) at the * current position. */ int av_read_play(AVFormatContext *s); /** - * Pauses a network-based stream (e.g. RTSP stream). + * Pause a network-based stream (e.g. RTSP stream). * * Use av_read_play() to resume it. */ int av_read_pause(AVFormatContext *s); /** - * Frees a AVFormatContext allocated by av_open_input_stream. + * Free a AVFormatContext allocated by av_open_input_stream. * @param s context to free */ void av_close_input_stream(AVFormatContext *s); /** - * Closes a media file (but not its codecs). + * Close a media file (but not its codecs). * * @param s media file handle */ void av_close_input_file(AVFormatContext *s); /** - * Adds a new stream to a media file. + * Add a new stream to a media file. * * Can only be called in the read_header() function. If the flag * AVFMTCTX_NOHEADER is in the format context, then new streams @@ -1087,7 +1089,7 @@ AVStream *av_new_stream(AVFormatContext *s, int id); AVProgram *av_new_program(AVFormatContext *s, int id); /** - * Adds a new chapter. + * Add a new chapter. * This function is NOT part of the public API * and should ONLY be used by demuxers. * @@ -1103,7 +1105,7 @@ AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int64_t start, int64_t end, const char *title); /** - * Sets the pts for a given stream. + * Set the pts for a given stream. * * @param s stream * @param pts_wrap_bits number of bits effectively used by the pts @@ -1122,7 +1124,7 @@ void av_set_pts_info(AVStream *s, int pts_wrap_bits, int av_find_default_stream_index(AVFormatContext *s); /** - * Gets the index for a specific timestamp. + * Get the index for a specific timestamp. * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond * to the timestamp which is <= the requested one, if backward * is 0, then it will be >= @@ -1132,7 +1134,7 @@ int av_find_default_stream_index(AVFormatContext *s); int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags); /** - * Ensures the index uses less memory than the maximum specified in + * Ensure the index uses less memory than the maximum specified in * AVFormatContext.max_index_size by discarding entries if it grows * too large. * This function is not part of the public API and should only be called @@ -1141,7 +1143,7 @@ int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags); void ff_reduce_index(AVFormatContext *s, int stream_index); /** - * Adds an index entry into a sorted list. Updates the entry if the list + * Add an index entry into a sorted list. Update the entry if the list * already contains it. * * @param timestamp timestamp in the time base of the given stream @@ -1150,7 +1152,7 @@ int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags); /** - * Does a binary search using av_index_search_timestamp() and + * Perform a binary search using av_index_search_timestamp() and * AVCodec.read_timestamp(). * This is not supposed to be called directly by a user application, * but by demuxers. @@ -1161,7 +1163,7 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags); /** - * Updates cur_dts of all streams based on the given timestamp and AVStream. + * Update cur_dts of all streams based on the given timestamp and AVStream. * * Stream ref_st unchanged, others set cur_dts in their native time base. * Only needed for timestamp wrapping or if (dts not set and pts!=dts). @@ -1171,7 +1173,7 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); /** - * Does a binary search using read_timestamp(). + * Perform a binary search using read_timestamp(). * This is not supposed to be called directly by a user application, * but by demuxers. * @param target_ts target timestamp in the time base of the given stream @@ -1188,7 +1190,33 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap); /** - * Allocates the stream private data and writes the stream header to an + * Split a URL string into components. + * + * The pointers to buffers for storing individual components may be null, + * in order to ignore that component. Buffers for components not found are + * set to empty strings. If the port is not found, it is set to a negative + * value. + * + * @param proto the buffer for the protocol + * @param proto_size the size of the proto buffer + * @param authorization the buffer for the authorization + * @param authorization_size the size of the authorization buffer + * @param hostname the buffer for the host name + * @param hostname_size the size of the hostname buffer + * @param port_ptr a pointer to store the port number in + * @param path the buffer for the path + * @param path_size the size of the path buffer + * @param url the URL to split + */ +void av_url_split(char *proto, int proto_size, + char *authorization, int authorization_size, + char *hostname, int hostname_size, + int *port_ptr, + char *path, int path_size, + const char *url); + +/** + * Allocate the stream private data and write the stream header to an * output media file. * * @param s media file handle @@ -1197,7 +1225,7 @@ int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap); int av_write_header(AVFormatContext *s); /** - * Writes a packet to an output media file. + * Write a packet to an output media file. * * The packet shall contain one audio or video frame. * The packet must be correctly interleaved according to the container @@ -1211,7 +1239,7 @@ int av_write_header(AVFormatContext *s); int av_write_frame(AVFormatContext *s, AVPacket *pkt); /** - * Writes a packet to an output media file ensuring correct interleaving. + * Write a packet to an output media file ensuring correct interleaving. * * The packet must contain one audio or video frame. * If the packets are already correctly interleaved, the application should @@ -1228,7 +1256,7 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt); int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); /** - * Interleaves a packet per dts in an output media file. + * Interleave a packet per dts in an output media file. * * Packets with pkt->destruct == av_destruct_packet will be freed inside this * function, so they cannot be used after it. Note that calling av_free_packet() @@ -1236,7 +1264,7 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); * * @param s media file handle * @param out the interleaved packet will be output here - * @param in the input packet + * @param pkt the input packet * @param flush 1 if no further packets are available as input and all * remaining packets should be output * @return 1 if a packet was output, 0 if no packet could be output, @@ -1246,7 +1274,7 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush); /** - * Writes the stream trailer to an output media file and frees the + * Write the stream trailer to an output media file and free the * file private data. * * May only be called after a successful call to av_write_header. @@ -1263,14 +1291,14 @@ void dump_format(AVFormatContext *ic, #if LIBAVFORMAT_VERSION_MAJOR < 53 /** - * Parses width and height out of string str. + * Parse width and height out of string str. * @deprecated Use av_parse_video_frame_size instead. */ attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr, const char *str); /** - * Converts framerate from a string to a fraction. + * Convert framerate from a string to a fraction. * @deprecated Use av_parse_video_frame_rate instead. */ attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base, @@ -1278,17 +1306,18 @@ attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base, #endif /** - * Parses datestr and returns a corresponding number of microseconds. + * Parse datestr and return a corresponding number of microseconds. * @param datestr String representing a date or a duration. * - If a date the syntax is: * @code - * [{YYYY-MM-DD|YYYYMMDD}]{T| }{HH[:MM[:SS[.m...]]][Z]|HH[MM[SS[.m...]]][Z]} + * now|{[{YYYY-MM-DD|YYYYMMDD}[T|t| ]]{{HH[:MM[:SS[.m...]]]}|{HH[MM[SS[.m...]]]}}[Z|z]} * @endcode + * If the value is "now" it takes the current time. * Time is local time unless Z is appended, in which case it is * interpreted as UTC. * If the year-month-day part is not specified it takes the current * year-month-day. - * Returns the number of microseconds since 1st of January, 1970 up to + * @return the number of microseconds since 1st of January, 1970 up to * the time of the parsed date or INT64_MIN if datestr cannot be * successfully parsed. * - If a duration the syntax is: @@ -1296,7 +1325,7 @@ attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base, * [-]HH[:MM[:SS[.m...]]] * [-]S+[.m...] * @endcode - * Returns the number of microseconds contained in a time interval + * @return the number of microseconds contained in a time interval * with the specified duration or INT64_MIN if datestr cannot be * successfully parsed. * @param duration Flag which tells how to interpret datestr, if @@ -1305,7 +1334,7 @@ attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base, */ int64_t parse_date(const char *datestr, int duration); -/** Gets the current time in microseconds. */ +/** Get the current time in microseconds. */ int64_t av_gettime(void); /* ffm-specific for ffserver */ @@ -1315,7 +1344,7 @@ int ffm_write_write_index(int fd, int64_t pos); void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size); /** - * Attempts to find a specific tag in a URL. + * Attempt to find a specific tag in a URL. * * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done. * Return 1 if found. @@ -1323,7 +1352,7 @@ void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size); int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info); /** - * Returns in 'buf' the path with '%d' replaced by a number. + * Return in 'buf' the path with '%d' replaced by a number. * * Also handles the '%0nd' format where 'n' is the total number * of digits and '%%'. @@ -1338,7 +1367,7 @@ int av_get_frame_filename(char *buf, int buf_size, const char *path, int number); /** - * Checks whether filename actually is a numbered sequence generator. + * Check whether filename actually is a numbered sequence generator. * * @param filename possible numbered sequence string * @return 1 if a valid numbered sequence string, 0 otherwise @@ -1346,7 +1375,7 @@ int av_get_frame_filename(char *buf, int buf_size, int av_filename_number_test(const char *filename); /** - * Generates an SDP for an RTP session. + * Generate an SDP for an RTP session. * * @param ac array of AVFormatContexts describing the RTP streams. If the * array is composed by only one context, such context can contain @@ -1362,7 +1391,7 @@ int av_filename_number_test(const char *filename); int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size); /** - * Returns a positive value if the given filename has one of the given + * Return a positive value if the given filename has one of the given * extensions, 0 otherwise. * * @param extensions a comma-separated list of filename extensions diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avidec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avidec.c index f98e4fdef..78ccc2639 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avidec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avidec.c @@ -48,6 +48,7 @@ typedef struct AVIStream { int prefix_count; uint32_t pal[256]; int has_pal; + int dshow_block_align; ///< block align variable used to emulate bugs in the MS dshow demuxer } AVIStream; typedef struct { @@ -61,6 +62,8 @@ typedef struct { int non_interleaved; int stream_index; DVDemuxContext* dv_demux; + int odml_depth; +#define MAX_ODML_DEPTH 1000 } AVIContext; static const char avi_headers[][8] = { @@ -87,6 +90,15 @@ static void print_tag(const char *str, unsigned int tag, int size) } #endif +static inline int get_duration(AVIStream *ast, int len){ + if(ast->sample_size){ + return len; + }else if (ast->dshow_block_align){ + return (len + ast->dshow_block_align - 1)/ast->dshow_block_align; + }else + return 1; +} + static int get_riff(AVFormatContext *s, ByteIOContext *pb) { AVIContext *avi = s->priv_data; @@ -125,7 +137,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){ AVIStream *ast; int i; int64_t last_pos= -1; - int64_t filesize= avi->fsize; + int64_t filesize= url_fsize(s->pb); #ifdef DEBUG_SEEK av_log(s, AV_LOG_ERROR, "longs_pre_entry:%d index_type:%d entries_in_use:%d chunk_id:%X base:%16"PRIX64"\n", @@ -173,12 +185,7 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){ if(last_pos != pos && (len || !ast->sample_size)) av_add_index_entry(st, pos, ast->cum_len, len, 0, key ? AVINDEX_KEYFRAME : 0); - if(ast->sample_size) - ast->cum_len += len; - else if (st->codec->block_align) - ast->cum_len += (len + st->codec->block_align - 1)/st->codec->block_align; - else - ast->cum_len ++; + ast->cum_len += get_duration(ast, len); last_pos= pos; }else{ int64_t offset, pos; @@ -192,16 +199,18 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){ pos = url_ftell(pb); - if(url_fseek(pb, offset+8, SEEK_SET) < 0) + if(avi->odml_depth > MAX_ODML_DEPTH){ + av_log(s, AV_LOG_ERROR, "Too deeply nested ODML indexes\n"); return -1; + } + url_fseek(pb, offset+8, SEEK_SET); + avi->odml_depth++; read_braindead_odml_indx(s, frame_num); + avi->odml_depth--; frame_num += duration; - if(url_fseek(pb, pos, SEEK_SET) < 0) { - av_log(s, AV_LOG_ERROR, "Failed to restore position after reading index"); - return -1; - } + url_fseek(pb, pos, SEEK_SET); } } avi->index_loaded=1; @@ -288,7 +297,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) return -1; avi->fsize = url_fsize(pb); - if(avi->fsize<=0 || avi->fsize < avi->riff_end) + if(avi->fsize<=0) avi->fsize= avi->riff_end == 8 ? INT64_MAX : avi->riff_end; /* first list tag */ @@ -315,7 +324,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) if (tag1 == MKTAG('m', 'o', 'v', 'i')) { avi->movi_list = url_ftell(pb) - 4; if(size) avi->movi_end = avi->movi_list + size + (size & 1); - else avi->movi_end = avi->fsize; + else avi->movi_end = url_fsize(pb); dprintf(NULL, "movi end=%"PRIx64"\n", avi->movi_end); goto end_of_header; } @@ -530,7 +539,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl)); #if HAVE_BIGENDIAN for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++) - st->codec->palctrl->palette[i] = bswap_32(((uint32_t*)st->codec->extradata)[i]); + st->codec->palctrl->palette[i] = av_bswap32(((uint32_t*)st->codec->extradata)[i]); #else memcpy(st->codec->palctrl->palette, st->codec->extradata, FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); @@ -563,6 +572,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) break; case AVMEDIA_TYPE_AUDIO: ff_get_wav_header(pb, st->codec, size); + ast->dshow_block_align= st->codec->block_align; if(ast->sample_size && st->codec->block_align && ast->sample_size != st->codec->block_align){ av_log(s, AV_LOG_WARNING, "sample size (%d) != block align (%d)\n", ast->sample_size, st->codec->block_align); ast->sample_size= st->codec->block_align; @@ -583,8 +593,10 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) st->codec->codec_id = CODEC_ID_XAN_DPCM; st->codec->codec_tag = 0; } - if (amv_file_format) + if (amv_file_format){ st->codec->codec_id = CODEC_ID_ADPCM_IMA_AMV; + ast->dshow_block_align = 0; + } break; default: st->codec->codec_type = AVMEDIA_TYPE_DATA; @@ -637,7 +649,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) av_log(s, AV_LOG_ERROR, "Something went wrong during header parsing, " "I will ignore it and try to continue anyway.\n"); avi->movi_list = url_ftell(pb) - 4; - avi->movi_end = avi->fsize; + avi->movi_end = url_fsize(pb); goto end_of_header; } /* skip tag */ @@ -745,8 +757,7 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt) if(i>=0){ int64_t pos= best_st->index_entries[i].pos; pos += best_ast->packet_size - best_ast->remaining; - if(url_fseek(s->pb, pos + 8, SEEK_SET) < 0) - return AVERROR_EOF; + url_fseek(s->pb, pos + 8, SEEK_SET); // av_log(s, AV_LOG_DEBUG, "pos=%"PRId64"\n", pos); assert(best_ast->remaining <= best_ast->packet_size); @@ -756,8 +767,6 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt) best_ast->packet_size= best_ast->remaining= best_st->index_entries[i].size; } - else - return AVERROR_EOF; } resync: @@ -822,12 +831,7 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt) } else { pkt->flags |= AV_PKT_FLAG_KEY; } - if(ast->sample_size) - ast->frame_offset += pkt->size; - else if (st->codec->block_align) - ast->frame_offset += (size + st->codec->block_align - 1)/st->codec->block_align; - else - ast->frame_offset++; + ast->frame_offset += get_duration(ast, pkt->size); } ast->remaining -= size; if(!ast->remaining){ @@ -909,9 +913,7 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt) if( (st->discard >= AVDISCARD_DEFAULT && size==0) /*|| (st->discard >= AVDISCARD_NONKEY && !(pkt->flags & AV_PKT_FLAG_KEY))*/ //FIXME needs a little reordering || st->discard >= AVDISCARD_ALL){ - if(ast->sample_size) ast->frame_offset += size; - else if (st->codec->block_align) ast->frame_offset += (pkt->size + st->codec->block_align - 1)/st->codec->block_align; - else ast->frame_offset++; + ast->frame_offset += get_duration(ast, size); url_fskip(pb, size); goto resync; } @@ -1004,12 +1006,7 @@ static int avi_read_idx1(AVFormatContext *s, int size) avi->non_interleaved= 1; else if(len || !ast->sample_size) av_add_index_entry(st, pos, ast->cum_len, len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0); - if(ast->sample_size) - ast->cum_len += len; - else if (st->codec->block_align) - ast->cum_len += (len + st->codec->block_align - 1)/st->codec->block_align; - else - ast->cum_len ++; + ast->cum_len += get_duration(ast, len); last_pos= pos; } return 0; @@ -1056,7 +1053,6 @@ static int avi_load_index(AVFormatContext *s) if (url_fseek(pb, avi->movi_end, SEEK_SET) < 0) goto the_end; // maybe truncated file - #ifdef DEBUG_SEEK printf("movi_end=0x%"PRIx64"\n", avi->movi_end); #endif @@ -1126,13 +1122,11 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp /* the av_index_search_timestamp call above. */ assert(stream_index == 0); - if(url_fseek(s->pb, pos, SEEK_SET) < 0) - return -1; - /* Feed the DV video stream version of the timestamp to the */ /* DV demux so it can synthesize correct timestamps. */ dv_offset_reset(avi->dv_demux, timestamp); + url_fseek(s->pb, pos, SEEK_SET); avi->stream_index= -1; return 0; } @@ -1169,8 +1163,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp } /* do the seek */ - if(url_fseek(s->pb, pos, SEEK_SET) < 0) - return -1; + url_fseek(s->pb, pos, SEEK_SET); avi->stream_index= -1; return 0; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avienc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avienc.c index b4a31ec54..161fb1bfc 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avienc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avienc.c @@ -225,7 +225,10 @@ static int avi_write_header(AVFormatContext *s) case AVMEDIA_TYPE_SUBTITLE: // XSUB subtitles behave like video tracks, other subtitles // are not (yet) supported. - if (stream->codec_id != CODEC_ID_XSUB) break; + if (stream->codec_id != CODEC_ID_XSUB) { + av_log(s, AV_LOG_ERROR, "Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n"); + return AVERROR_PATCHWELCOME; + } case AVMEDIA_TYPE_VIDEO: put_tag(pb, "vids"); break; case AVMEDIA_TYPE_AUDIO: put_tag(pb, "auds"); break; // case AVMEDIA_TYPE_TEXT : put_tag(pb, "txts"); break; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avio.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avio.c index e79c8fcbf..19f0183ab 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avio.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avio.c @@ -56,9 +56,14 @@ URLProtocol *av_protocol_next(URLProtocol *p) else return first_protocol; } -int av_register_protocol(URLProtocol *protocol) +int av_register_protocol2(URLProtocol *protocol, int size) { URLProtocol **p; + if (size < sizeof(URLProtocol)) { + URLProtocol* temp = av_mallocz(sizeof(URLProtocol)); + memcpy(temp, protocol, size); + protocol = temp; + } p = &first_protocol; while (*p != NULL) p = &(*p)->next; *p = protocol; @@ -67,14 +72,30 @@ int av_register_protocol(URLProtocol *protocol) } #if LIBAVFORMAT_VERSION_MAJOR < 53 +/* The layout of URLProtocol as of when major was bumped to 52 */ +struct URLProtocol_compat { + const char *name; + int (*url_open)(URLContext *h, const char *filename, int flags); + int (*url_read)(URLContext *h, unsigned char *buf, int size); + int (*url_write)(URLContext *h, unsigned char *buf, int size); + int64_t (*url_seek)(URLContext *h, int64_t pos, int whence); + int (*url_close)(URLContext *h); + struct URLProtocol *next; +}; + +int av_register_protocol(URLProtocol *protocol) +{ + return av_register_protocol2(protocol, sizeof(struct URLProtocol_compat)); +} + int register_protocol(URLProtocol *protocol) { return av_register_protocol(protocol); } #endif -int url_open_protocol (URLContext **puc, struct URLProtocol *up, - const char *filename, int flags) +static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up, + const char *filename, int flags) { URLContext *uc; int err; @@ -97,17 +118,14 @@ int url_open_protocol (URLContext **puc, struct URLProtocol *up, uc->flags = flags; uc->is_streamed = 0; /* default = not streamed */ uc->max_packet_size = 0; /* default: stream file */ - err = up->url_open(uc, filename, flags); - if (err < 0) { - av_free(uc); - goto fail; + if (up->priv_data_size) { + uc->priv_data = av_mallocz(up->priv_data_size); + if (up->priv_data_class) { + *(const AVClass**)uc->priv_data = up->priv_data_class; + av_opt_set_defaults(uc->priv_data); + } } - //We must be careful here as url_seek() could be slow, for example for http - if( (flags & (URL_WRONLY | URL_RDWR)) - || !strcmp(up->name, "file")) - if(!uc->is_streamed && url_seek(uc, 0, SEEK_SET) < 0) - uc->is_streamed= 1; *puc = uc; return 0; fail: @@ -118,7 +136,38 @@ int url_open_protocol (URLContext **puc, struct URLProtocol *up, return err; } -int url_open(URLContext **puc, const char *filename, int flags) +int url_connect(URLContext* uc) +{ + int err = uc->prot->url_open(uc, uc->filename, uc->flags); + if (err) + return err; + uc->is_connected = 1; + //We must be careful here as url_seek() could be slow, for example for http + if( (uc->flags & (URL_WRONLY | URL_RDWR)) + || !strcmp(uc->prot->name, "file")) + if(!uc->is_streamed && url_seek(uc, 0, SEEK_SET) < 0) + uc->is_streamed= 1; + return 0; +} + +int url_open_protocol (URLContext **puc, struct URLProtocol *up, + const char *filename, int flags) +{ + int ret; + + ret = url_alloc_for_protocol(puc, up, filename, flags); + if (ret) + goto fail; + ret = url_connect(*puc); + if (!ret) + return 0; + fail: + url_close(*puc); + *puc = NULL; + return ret; +} + +int url_alloc(URLContext **puc, const char *filename, int flags) { URLProtocol *up; const char *p; @@ -145,13 +194,26 @@ int url_open(URLContext **puc, const char *filename, int flags) up = first_protocol; while (up != NULL) { if (!strcmp(proto_str, up->name)) - return url_open_protocol (puc, up, filename, flags); + return url_alloc_for_protocol (puc, up, filename, flags); up = up->next; } *puc = NULL; return AVERROR(ENOENT); } +int url_open(URLContext **puc, const char *filename, int flags) +{ + int ret = url_alloc(puc, filename, flags); + if (ret) + return ret; + ret = url_connect(*puc); + if (!ret) + return 0; + url_close(*puc); + *puc = NULL; + return ret; +} + int url_read(URLContext *h, unsigned char *buf, int size) { int ret; @@ -211,11 +273,13 @@ int url_close(URLContext *h) int ret = 0; if (!h) return 0; /* can happen when url_open fails */ - if (h->prot->url_close) + if (h->is_connected && h->prot->url_close) ret = h->prot->url_close(h); #if CONFIG_NETWORK ff_network_close(); #endif + if (h->prot->priv_data_size) + av_free(h->priv_data); av_free(h); return ret; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avio.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avio.h index 2b15e8d76..a95504838 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avio.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avio.h @@ -31,6 +31,7 @@ #include #include "libavutil/common.h" +#include "libavutil/log.h" /* unbuffered I/O */ @@ -51,6 +52,7 @@ typedef struct URLContext { int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */ void *priv_data; char *filename; /**< specified URL */ + int is_connected; } URLContext; typedef struct URLPollEntry { @@ -66,8 +68,8 @@ typedef struct URLPollEntry { typedef int URLInterruptCB(void); /** - * Creates an URLContext for accessing to the resource indicated by - * url, and opens it using the URLProtocol up. + * Create a URLContext for accessing to the resource indicated by + * url, and open it using the URLProtocol up. * * @param puc pointer to the location where, in case of success, the * function puts the pointer to the created URLContext @@ -80,8 +82,26 @@ int url_open_protocol (URLContext **puc, struct URLProtocol *up, const char *url, int flags); /** - * Creates an URLContext for accessing to the resource indicated by - * url, and opens it. + * Create a URLContext for accessing to the resource indicated by + * url, but do not initiate the connection yet. + * + * @param puc pointer to the location where, in case of success, the + * function puts the pointer to the created URLContext + * @param flags flags which control how the resource indicated by url + * is to be opened + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code in case of failure + */ +int url_alloc(URLContext **h, const char *url, int flags); + +/** + * Connect an URLContext that has been allocated by url_alloc + */ +int url_connect(URLContext *h); + +/** + * Create an URLContext for accessing to the resource indicated by + * url, and open it. * * @param puc pointer to the location where, in case of success, the * function puts the pointer to the created URLContext @@ -93,7 +113,7 @@ int url_open_protocol (URLContext **puc, struct URLProtocol *up, int url_open(URLContext **h, const char *url, int flags); /** - * Reads up to size bytes from the resource accessed by h, and stores + * Read up to size bytes from the resource accessed by h, and store * the read bytes in buf. * * @return The number of bytes actually read, or a negative value @@ -115,7 +135,7 @@ int url_read_complete(URLContext *h, unsigned char *buf, int size); int url_write(URLContext *h, const unsigned char *buf, int size); /** - * Changes the position that will be used by the next read/write + * Change the position that will be used by the next read/write * operation on the resource accessed by h. * * @param pos specifies the new position to set @@ -131,7 +151,7 @@ int url_write(URLContext *h, const unsigned char *buf, int size); int64_t url_seek(URLContext *h, int64_t pos, int whence); /** - * Closes the resource accessed by the URLContext h, and frees the + * Close the resource accessed by the URLContext h, and free the * memory used by it. * * @return a negative value if an error condition occurred, 0 @@ -140,7 +160,7 @@ int64_t url_seek(URLContext *h, int64_t pos, int whence); int url_close(URLContext *h); /** - * Returns a non-zero value if the resource indicated by url + * Return a non-zero value if the resource indicated by url * exists, 0 otherwise. */ int url_exist(const char *url); @@ -232,6 +252,8 @@ typedef struct URLProtocol { int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); int (*url_get_file_handle)(URLContext *h); + int priv_data_size; + const AVClass *priv_data_class; } URLProtocol; #if LIBAVFORMAT_VERSION_MAJOR < 53 @@ -252,12 +274,19 @@ URLProtocol *av_protocol_next(URLProtocol *p); * @deprecated Use av_register_protocol() instead. */ attribute_deprecated int register_protocol(URLProtocol *protocol); + +/** + * @deprecated Use av_register_protocol2() instead. + */ +attribute_deprecated int av_register_protocol(URLProtocol *protocol); #endif /** - * Registers the URLProtocol protocol. + * Register the URLProtocol protocol. + * + * @param size the size of the URLProtocol struct referenced */ -int av_register_protocol(URLProtocol *protocol); +int av_register_protocol2(URLProtocol *protocol, int size); /** * Bytestream IO Context. @@ -339,7 +368,7 @@ void url_fskip(ByteIOContext *s, int64_t offset); int64_t url_ftell(ByteIOContext *s); /** - * Gets the filesize. + * Get the filesize. * @return filesize or AVERROR */ int64_t url_fsize(ByteIOContext *s); @@ -375,13 +404,13 @@ void put_flush_packet(ByteIOContext *s); /** - * Reads size bytes from ByteIOContext into buf. + * Read size bytes from ByteIOContext into buf. * @return number of bytes read or AVERROR */ int get_buffer(ByteIOContext *s, unsigned char *buf, int size); /** - * Reads size bytes from ByteIOContext into buf. + * Read size bytes from ByteIOContext into buf. * This reads at most 1 packet. If that is not enough fewer bytes will be * returned. * @return number of bytes read or AVERROR @@ -410,7 +439,7 @@ static inline int url_is_streamed(ByteIOContext *s) } /** - * Creates and initializes a ByteIOContext for accessing the + * Create and initialize a ByteIOContext for accessing the * resource referenced by the URLContext h. * @note When the URLContext h has been opened in read+write mode, the * ByteIOContext can be used only for writing. @@ -433,7 +462,7 @@ int url_resetbuf(ByteIOContext *s, int flags); #endif /** - * Rewinds the ByteIOContext using the specified buffer containing the first buf_size bytes of the file. + * Rewind the ByteIOContext using the specified buffer containing the first buf_size bytes of the file. * Used after probing to avoid seeking. * Joins buf and s->buffer, taking any overlap into consideration. * @note s->buffer must overlap with buf or they can't be joined and the function fails @@ -448,7 +477,7 @@ int url_resetbuf(ByteIOContext *s, int flags); int ff_rewind_with_probe_data(ByteIOContext *s, unsigned char *buf, int buf_size); /** - * Creates and initializes a ByteIOContext for accessing the + * Create and initialize a ByteIOContext for accessing the * resource indicated by url. * @note When the resource indicated by url has been opened in * read+write mode, the ByteIOContext can be used only for writing. @@ -501,7 +530,10 @@ int url_open_dyn_packet_buf(ByteIOContext **s, int max_packet_size); /** * Return the written size and a pointer to the buffer. The buffer - * must be freed with av_free(). + * must be freed with av_free(). If the buffer is opened with + * url_open_dyn_buf, then padding of FF_INPUT_BUFFER_PADDING_SIZE is + * added; if opened with url_open_dyn_packet_buf, no padding is added. + * * @param s IO context * @param pbuffer pointer to a byte buffer * @return the length of the byte buffer diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/aviobuf.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/aviobuf.c index 868490346..9f1187efe 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/aviobuf.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/aviobuf.c @@ -23,6 +23,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" #include "avio.h" +#include "internal.h" #include #define IO_BUFFER_SIZE 32768 @@ -248,6 +249,24 @@ void put_strz(ByteIOContext *s, const char *str) put_byte(s, 0); } +int ff_get_v_length(uint64_t val){ + int i=1; + + while(val>>=7) + i++; + + return i; +} + +void ff_put_v(ByteIOContext *bc, uint64_t val){ + int i= ff_get_v_length(val); + + while(--i>0) + put_byte(bc, 128 | (val>>(7*i))); + + put_byte(bc, val&127); +} + void put_le64(ByteIOContext *s, uint64_t val) { put_le32(s, (uint32_t)(val & 0xffffffff)); @@ -605,8 +624,7 @@ static int url_resetbuf(ByteIOContext *s, int flags) #endif { #if LIBAVFORMAT_VERSION_MAJOR < 53 - URLContext *h = s->opaque; - if ((flags & URL_RDWR) || (h && h->flags != flags && !h->flags & URL_RDWR)) + if (flags & URL_RDWR) return AVERROR(EINVAL); #else assert(flags == URL_WRONLY || flags == URL_RDONLY); @@ -894,6 +912,14 @@ int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer) { DynBuffer *d = s->opaque; int size; + static const char padbuf[FF_INPUT_BUFFER_PADDING_SIZE] = {0}; + int padding = 0; + + /* don't attempt to pad fixed-size packet buffers */ + if (!s->max_packet_size) { + put_buffer(s, padbuf, sizeof(padbuf)); + padding = FF_INPUT_BUFFER_PADDING_SIZE; + } put_flush_packet(s); @@ -901,6 +927,6 @@ int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer) size = d->size; av_free(d); av_free(s); - return size; + return size - padding; } #endif /* CONFIG_MUXERS || CONFIG_NETWORK */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avlanguage.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avlanguage.h index eac003145..7fb896881 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avlanguage.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/avlanguage.h @@ -31,8 +31,8 @@ enum AVLangCodespace { }; /** - * Converts a language code to a target codespace. The source codespace is guessed. - * Returns NULL if the provided lang is null or invalid. + * Convert a language code to a target codespace. The source codespace is guessed. + * @return NULL if the provided lang is null or invalid. */ const char *av_convert_lang_to(const char *lang, enum AVLangCodespace target_codespace); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/electronicarts.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/electronicarts.c index 86d7f91e6..df517df89 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/electronicarts.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/electronicarts.c @@ -301,7 +301,7 @@ static int process_ea_header(AVFormatContext *s) { if (i == 0) ea->big_endian = size > 0x000FFFFF; if (ea->big_endian) - size = bswap_32(size); + size = av_bswap32(size); switch (blockid) { case ISNh_TAG: diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/file.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/file.c index d6ba1fa36..3c3f42f4d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/file.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/file.c @@ -27,13 +27,31 @@ #endif #include #include -#include #include #include "os_support.h" /* standard file protocol */ +static int file_read(URLContext *h, unsigned char *buf, int size) +{ + int fd = (intptr_t) h->priv_data; + return read(fd, buf, size); +} + +static int file_write(URLContext *h, const unsigned char *buf, int size) +{ + int fd = (intptr_t) h->priv_data; + return write(fd, buf, size); +} + +static int file_get_handle(URLContext *h) +{ + return (intptr_t) h->priv_data; +} + +#if CONFIG_FILE_PROTOCOL + static int file_open(URLContext *h, const char *filename, int flags) { int access; @@ -58,18 +76,6 @@ static int file_open(URLContext *h, const char *filename, int flags) return 0; } -static int file_read(URLContext *h, unsigned char *buf, int size) -{ - int fd = (intptr_t) h->priv_data; - return read(fd, buf, size); -} - -static int file_write(URLContext *h, const unsigned char *buf, int size) -{ - int fd = (intptr_t) h->priv_data; - return write(fd, buf, size); -} - /* XXX: use llseek */ static int64_t file_seek(URLContext *h, int64_t pos, int whence) { @@ -88,11 +94,6 @@ static int file_close(URLContext *h) return close(fd); } -static int file_get_handle(URLContext *h) -{ - return (intptr_t) h->priv_data; -} - URLProtocol file_protocol = { "file", file_open, @@ -103,7 +104,9 @@ URLProtocol file_protocol = { .url_get_file_handle = file_get_handle, }; -/* pipe protocol */ +#endif /* CONFIG_FILE_PROTOCOL */ + +#if CONFIG_PIPE_PROTOCOL static int pipe_open(URLContext *h, const char *filename, int flags) { @@ -134,3 +137,5 @@ URLProtocol pipe_protocol = { file_write, .url_get_file_handle = file_get_handle, }; + +#endif /* CONFIG_PIPE_PROTOCOL */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/flacdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/flacdec.c index 2ceef964e..3cdd53c6a 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/flacdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/flacdec.c @@ -43,7 +43,7 @@ static int flac_read_header(AVFormatContext *s, /* skip ID3v2 header if found */ ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE); - if (ret == ID3v2_HEADER_SIZE && ff_id3v2_match(buf)) { + if (ret == ID3v2_HEADER_SIZE && ff_id3v2_match(buf, ID3v2_DEFAULT_MAGIC)) { int len = ff_id3v2_tag_len(buf); url_fseek(s->pb, len - ID3v2_HEADER_SIZE, SEEK_CUR); } else { @@ -130,7 +130,7 @@ static int flac_probe(AVProbeData *p) uint8_t *bufptr = p->buf; uint8_t *end = p->buf + p->buf_size; - if(ff_id3v2_match(bufptr)) + if(ff_id3v2_match(bufptr, ID3v2_DEFAULT_MAGIC)) bufptr += ff_id3v2_tag_len(bufptr); if(bufptr > end-4 || memcmp(bufptr, "fLaC", 4)) return 0; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/flvdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/flvdec.c index fcdf2143a..063f9064f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/flvdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/flvdec.c @@ -414,7 +414,10 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) ff_mpeg4audio_get_config(&cfg, st->codec->extradata, st->codec->extradata_size); st->codec->channels = cfg.channels; - st->codec->sample_rate = cfg.sample_rate; + if (cfg.ext_sample_rate) + st->codec->sample_rate = cfg.ext_sample_rate; + else + st->codec->sample_rate = cfg.sample_rate; dprintf(s, "mp4a config channels %d sample rate %d\n", st->codec->channels, st->codec->sample_rate); } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/gopher.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/gopher.c index 13f3a5f9e..b528f9bbb 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/gopher.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/gopher.c @@ -90,7 +90,7 @@ static int gopher_open(URLContext *h, const char *uri, int flags) h->priv_data = s; /* needed in any case to build the host string */ - ff_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, + av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, path, sizeof(path), uri); if (port < 0) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/gxf.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/gxf.c index 3798bb7e8..af2ee9dea 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/gxf.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/gxf.c @@ -71,7 +71,7 @@ static int gxf_probe(AVProbeData *p) { /** * \brief gets the stream index for the track with the specified id, creates new * stream if not found - * \param stream id of stream to find / add + * \param id id of stream to find / add * \param format stream format identifier */ static int get_sindex(AVFormatContext *s, int id, int format) { @@ -191,7 +191,7 @@ static AVRational fps_tag2avr(int32_t fps) { /** * \brief convert UMF attributes flags to AVRational fps - * \param fps fps value from flags + * \param flags UMF flags to convert * \return fps as AVRational, or 0 / 0 if unknown */ static AVRational fps_umf2avr(uint32_t flags) { @@ -397,9 +397,11 @@ static int64_t gxf_resync_media(AVFormatContext *s, uint64_t max_interval, int t if (tmp != 1) goto start; last_pos = url_ftell(pb); - url_fseek(pb, -5, SEEK_CUR); + if (url_fseek(pb, -5, SEEK_CUR) < 0) + goto out; if (!parse_packet_header(pb, &type, &len) || type != PKT_MEDIA) { - url_fseek(pb, last_pos, SEEK_SET); + if (url_fseek(pb, last_pos, SEEK_SET) < 0) + goto out; goto start; } get_byte(pb); @@ -407,8 +409,8 @@ static int64_t gxf_resync_media(AVFormatContext *s, uint64_t max_interval, int t cur_timestamp = get_be32(pb); last_found_pos = url_ftell(pb) - 16 - 6; if ((track >= 0 && track != cur_track) || (timestamp >= 0 && timestamp > cur_timestamp)) { - url_fseek(pb, last_pos, SEEK_SET); - goto start; + if (url_fseek(pb, last_pos, SEEK_SET) >= 0) + goto start; } out: if (last_found_pos) @@ -477,6 +479,7 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) { } static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { + int res = 0; uint64_t pos; uint64_t maxlen = 100 * 1024 * 1024; AVStream *st = s->streams[0]; @@ -492,7 +495,9 @@ static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int if (idx < st->nb_index_entries - 2) maxlen = st->index_entries[idx + 2].pos - pos; maxlen = FFMAX(maxlen, 200 * 1024); - url_fseek(s->pb, pos, SEEK_SET); + res = url_fseek(s->pb, pos, SEEK_SET); + if (res < 0) + return res; found = gxf_resync_media(s, maxlen, -1, timestamp); if (FFABS(found - timestamp) > 4) return -1; @@ -503,7 +508,8 @@ static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index, int64_t *pos, int64_t pos_limit) { ByteIOContext *pb = s->pb; int64_t res; - url_fseek(pb, *pos, SEEK_SET); + if (url_fseek(pb, *pos, SEEK_SET) < 0) + return AV_NOPTS_VALUE; res = gxf_resync_media(s, pos_limit - *pos, -1, -1); *pos = url_ftell(pb); return res; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/http.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/http.c index 4e2152f5e..2b503a1a0 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/http.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/http.c @@ -25,8 +25,10 @@ #include #include "internal.h" #include "network.h" +#include "http.h" #include "os_support.h" #include "httpauth.h" +#include "libavcodec/opt.h" /* XXX: POST protocol is not completely implemented because ffmpeg uses only a subset of it. */ @@ -37,6 +39,7 @@ #define MAX_REDIRECTS 8 typedef struct { + const AVClass *class; URLContext *hd; unsigned char buffer[BUFFER_SIZE], *buf_ptr, *buf_end; int line_count; @@ -45,12 +48,42 @@ typedef struct { int64_t off, filesize; char location[URL_SIZE]; HTTPAuthState auth_state; + unsigned char headers[BUFFER_SIZE]; } HTTPContext; +#define OFFSET(x) offsetof(HTTPContext, x) +static const AVOption options[] = { +{"chunksize", "use chunked transfer-encoding for posts, -1 disables it, 0 enables it", OFFSET(chunksize), FF_OPT_TYPE_INT64, 0, -1, 0 }, /* Default to 0, for chunked POSTs */ +{NULL} +}; +static const AVClass httpcontext_class = { + "HTTP", av_default_item_name, options, LIBAVUTIL_VERSION_INT +}; + static int http_connect(URLContext *h, const char *path, const char *hoststr, const char *auth, int *new_location); -static int http_write(URLContext *h, const uint8_t *buf, int size); +void ff_http_set_headers(URLContext *h, const char *headers) +{ + HTTPContext *s = h->priv_data; + int len = strlen(headers); + + if (len && strcmp("\r\n", headers + len - 2)) + av_log(NULL, AV_LOG_ERROR, "No trailing CRLF found in HTTP header.\n"); + + av_strlcpy(s->headers, headers, sizeof(s->headers)); +} + +void ff_http_set_chunked_transfer_encoding(URLContext *h, int is_chunked) +{ + ((HTTPContext*)h->priv_data)->chunksize = is_chunked ? 0 : -1; +} + +void ff_http_init_auth_state(URLContext *dest, const URLContext *src) +{ + memcpy(&((HTTPContext*)dest->priv_data)->auth_state, + &((HTTPContext*)src->priv_data)->auth_state, sizeof(HTTPAuthState)); +} /* return non zero if error */ static int http_open_cnx(URLContext *h) @@ -72,12 +105,12 @@ static int http_open_cnx(URLContext *h) /* fill the dest addr */ redo: /* needed in any case to build the host string */ - ff_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, + av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, path1, sizeof(path1), s->location); ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL); if (use_proxy) { - ff_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, + av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, NULL, 0, proxy_path); path = s->location; } else { @@ -117,31 +150,20 @@ static int http_open_cnx(URLContext *h) fail: if (hd) url_close(hd); + s->hd = NULL; return AVERROR(EIO); } static int http_open(URLContext *h, const char *uri, int flags) { - HTTPContext *s; - int ret; + HTTPContext *s = h->priv_data; h->is_streamed = 1; - s = av_malloc(sizeof(HTTPContext)); - if (!s) { - return AVERROR(ENOMEM); - } - h->priv_data = s; s->filesize = -1; - s->chunksize = -1; - s->off = 0; - memset(&s->auth_state, 0, sizeof(s->auth_state)); av_strlcpy(s->location, uri, URL_SIZE); - ret = http_open_cnx(h); - if (ret != 0) - av_free (s); - return ret; + return http_open_cnx(h); } static int http_getc(HTTPContext *s) { @@ -246,40 +268,63 @@ static int process_line(URLContext *h, char *line, int line_count, return 1; } +static inline int has_header(const char *str, const char *header) +{ + /* header + 2 to skip over CRLF prefix. (make sure you have one!) */ + return av_stristart(str, header + 2, NULL) || av_stristr(str, header); +} + static int http_connect(URLContext *h, const char *path, const char *hoststr, const char *auth, int *new_location) { HTTPContext *s = h->priv_data; int post, err; char line[1024]; + char headers[1024] = ""; char *authstr = NULL; int64_t off = s->off; + int len = 0; /* send http header */ post = h->flags & URL_WRONLY; authstr = ff_http_auth_create_response(&s->auth_state, auth, path, post ? "POST" : "GET"); + + /* set default headers if needed */ + if (!has_header(s->headers, "\r\nUser-Agent: ")) + len += av_strlcatf(headers + len, sizeof(headers) - len, + "User-Agent: %s\r\n", LIBAVFORMAT_IDENT); + if (!has_header(s->headers, "\r\nAccept: ")) + len += av_strlcpy(headers + len, "Accept: */*\r\n", + sizeof(headers) - len); + if (!has_header(s->headers, "\r\nRange: ")) + len += av_strlcatf(headers + len, sizeof(headers) - len, + "Range: bytes=%"PRId64"-\r\n", s->off); + if (!has_header(s->headers, "\r\nConnection: ")) + len += av_strlcpy(headers + len, "Connection: close\r\n", + sizeof(headers)-len); + if (!has_header(s->headers, "\r\nHost: ")) + len += av_strlcatf(headers + len, sizeof(headers) - len, + "Host: %s\r\n", hoststr); + + /* now add in custom headers */ + av_strlcpy(headers+len, s->headers, sizeof(headers)-len); + snprintf(s->buffer, sizeof(s->buffer), "%s %s HTTP/1.1\r\n" - "User-Agent: %s\r\n" - "Accept: */*\r\n" - "Range: bytes=%"PRId64"-\r\n" - "Host: %s\r\n" "%s" - "Connection: close\r\n" + "%s" "%s" "\r\n", post ? "POST" : "GET", path, - LIBAVFORMAT_IDENT, - s->off, - hoststr, - authstr ? authstr : "", - post ? "Transfer-Encoding: chunked\r\n" : ""); + post && s->chunksize >= 0 ? "Transfer-Encoding: chunked\r\n" : "", + headers, + authstr ? authstr : ""); av_freep(&authstr); - if (http_write(h, s->buffer, strlen(s->buffer)) < 0) + if (url_write(s->hd, s->buffer, strlen(s->buffer)) < 0) return AVERROR(EIO); /* init input buffer */ @@ -289,14 +334,13 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr, s->off = 0; s->filesize = -1; if (post) { - /* always use chunked encoding for upload data */ - s->chunksize = 0; /* Pretend that it did work. We didn't read any header yet, since * we've still to send the POST data, but the code calling this * function will check http_code after we return. */ s->http_code = 200; return 0; } + s->chunksize = -1; /* wait for header */ for(;;) { @@ -364,13 +408,13 @@ static int http_read(URLContext *h, uint8_t *buf, int size) /* used only when posting data */ static int http_write(URLContext *h, const uint8_t *buf, int size) { - char temp[11]; /* 32-bit hex + CRLF + nul */ + char temp[11] = ""; /* 32-bit hex + CRLF + nul */ int ret; char crlf[] = "\r\n"; HTTPContext *s = h->priv_data; if (s->chunksize == -1) { - /* headers are sent without any special encoding */ + /* non-chunked data is sent without any special encoding */ return url_write(s->hd, buf, size); } @@ -400,8 +444,8 @@ static int http_close(URLContext *h) ret = ret > 0 ? 0 : ret; } - url_close(s->hd); - av_free(s); + if (s->hd) + url_close(s->hd); return ret; } @@ -456,4 +500,6 @@ URLProtocol http_protocol = { http_seek, http_close, .url_get_file_handle = http_get_file_handle, + .priv_data_size = sizeof(HTTPContext), + .priv_data_class = &httpcontext_class, }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/http.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/http.h new file mode 100644 index 000000000..cd003bba8 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/http.h @@ -0,0 +1,64 @@ +/* + * HTTP definitions + * Copyright (c) 2010 Josh Allmann + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_HTTP_H +#define AVFORMAT_HTTP_H + +#include "avio.h" + +/** + * Set custom HTTP headers. + * A trailing CRLF ("\r\n") is required for custom headers. + * Passing in an empty header string ("\0") will reset to defaults. + * + * The following headers can be overriden by custom values, + * otherwise they will be set to their defaults. + * -User-Agent + * -Accept + * -Range + * -Host + * -Connection + * + * @param h URL context for this HTTP connection + * @param headers the custom headers to set + */ +void ff_http_set_headers(URLContext *h, const char *headers); + +/** + * Enable or disable chunked transfer encoding. (default is enabled) + * + * @param h URL context for this HTTP connection + * @param is_chunked 0 to disable chunking, nonzero otherwise. + */ +void ff_http_set_chunked_transfer_encoding(URLContext *h, int is_chunked); + +/** + * Initialize the authentication state based on another HTTP URLContext. + * This can be used to pre-initialize the authentication parameters if + * they are known beforehand, to avoid having to do an initial failing + * request just to get the parameters. + * + * @param dest URL context whose authentication state gets updated + * @param src URL context whose authentication state gets copied + */ +void ff_http_init_auth_state(URLContext *dest, const URLContext *src); + +#endif /* AVFORMAT_HTTP_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/id3v2.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/id3v2.c index 6fa11db6c..7e4a16fae 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/id3v2.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/id3v2.c @@ -22,12 +22,13 @@ #include "id3v2.h" #include "id3v1.h" #include "libavutil/avstring.h" +#include "libavutil/intreadwrite.h" -int ff_id3v2_match(const uint8_t *buf) +int ff_id3v2_match(const uint8_t *buf, const char * magic) { - return buf[0] == 'I' && - buf[1] == 'D' && - buf[2] == '3' && + return buf[0] == magic[0] && + buf[1] == magic[1] && + buf[2] == magic[2] && buf[3] != 0xff && buf[4] != 0xff && (buf[6] & 0x80) == 0 && @@ -48,7 +49,7 @@ int ff_id3v2_tag_len(const uint8_t * buf) return len; } -void ff_id3v2_read(AVFormatContext *s) +void ff_id3v2_read(AVFormatContext *s, const char *magic) { int len, ret; uint8_t buf[ID3v2_HEADER_SIZE]; @@ -56,7 +57,7 @@ void ff_id3v2_read(AVFormatContext *s) ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE); if (ret != ID3v2_HEADER_SIZE) return; - if (ff_id3v2_match(buf)) { + if (ff_id3v2_match(buf, magic)) { /* parse ID3v2 header */ len = ((buf[6] & 0x7f) << 21) | ((buf[7] & 0x7f) << 14) | diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/id3v2.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/id3v2.h index 70030d297..48373bb3f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/id3v2.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/id3v2.h @@ -29,14 +29,21 @@ #define ID3v2_HEADER_SIZE 10 /** - * Detects ID3v2 Header. - * @buf must be ID3v2_HEADER_SIZE byte long + * Default magic bytes for ID3v2 header: "ID3" */ -int ff_id3v2_match(const uint8_t *buf); +#define ID3v2_DEFAULT_MAGIC "ID3" /** - * Gets the length of an ID3v2 tag. - * @buf must be ID3v2_HEADER_SIZE bytes long and point to the start of an + * Detect ID3v2 Header. + * @param buf must be ID3v2_HEADER_SIZE byte long + * @param magic magic bytes to identify the header, machine byte order. + * If in doubt, use ID3v2_DEFAULT_MAGIC. + */ +int ff_id3v2_match(const uint8_t *buf, const char *magic); + +/** + * Get the length of an ID3v2 tag. + * @param buf must be ID3v2_HEADER_SIZE bytes long and point to the start of an * already detected ID3v2 tag */ int ff_id3v2_tag_len(const uint8_t *buf); @@ -50,7 +57,7 @@ void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags) /** * Read an ID3v2 tag */ -void ff_id3v2_read(AVFormatContext *s); +void ff_id3v2_read(AVFormatContext *s, const char *magic); extern const AVMetadataConv ff_id3v2_metadata_conv[]; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/img2.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/img2.c index 85bee971c..7c152cb9d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/img2.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/img2.c @@ -73,6 +73,7 @@ static const IdStrMap img_tags[] = { { CODEC_ID_SUNRAST , "sunras"}, { CODEC_ID_JPEG2000 , "jp2"}, { CODEC_ID_DPX , "dpx"}, + { CODEC_ID_PICTOR , "pic"}, { CODEC_ID_NONE , NULL} }; @@ -441,7 +442,7 @@ AVOutputFormat image2_muxer = { "image2", NULL_IF_CONFIG_SMALL("image2 sequence"), "", - "bmp,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png,ppm,sgi,tif,tiff,jp2", + "bmp,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png,ppm,sgi,tga,tif,tiff,jp2", sizeof(VideoData), CODEC_ID_NONE, CODEC_ID_MJPEG, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/internal.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/internal.h index 358959ce7..9b68e9e49 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/internal.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/internal.h @@ -67,11 +67,11 @@ void ff_read_frame_flush(AVFormatContext *s); #define NTP_OFFSET 2208988800ULL #define NTP_OFFSET_US (NTP_OFFSET * 1000000ULL) -/** Gets the current time since NTP epoch in microseconds. */ +/** Get the current time since NTP epoch in microseconds. */ uint64_t ff_ntp_time(void); /** - * Probes a bytestream to determine the input format. Each time a probe returns + * Probe a bytestream to determine the input format. Each time a probe returns * with a score that is too low, the probe buffer size is increased and another * attempt is made. When the maximum probe size is reached, the input format * with the highest score is returned. @@ -89,27 +89,9 @@ int ff_probe_input_buffer(ByteIOContext **pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size); +#if LIBAVFORMAT_VERSION_MAJOR < 53 /** - * Splits a URL string into components. To reassemble components back into - * a URL, use ff_url_join instead of using snprintf directly. - * - * The pointers to buffers for storing individual components may be null, - * in order to ignore that component. Buffers for components not found are - * set to empty strings. If the port isn't found, it is set to a negative - * value. - * - * @see ff_url_join - * - * @param proto the buffer for the protocol - * @param proto_size the size of the proto buffer - * @param authorization the buffer for the authorization - * @param authorization_size the size of the authorization buffer - * @param hostname the buffer for the host name - * @param hostname_size the size of the hostname buffer - * @param port_ptr a pointer to store the port number in - * @param path the buffer for the path - * @param path_size the size of the path buffer - * @param url the URL to split + * @deprecated use av_url_split() instead */ void ff_url_split(char *proto, int proto_size, char *authorization, int authorization_size, @@ -117,21 +99,23 @@ void ff_url_split(char *proto, int proto_size, int *port_ptr, char *path, int path_size, const char *url); +#endif /** - * Assembles a URL string from components. This is the reverse operation - * of ff_url_split. + * Assemble a URL string from components. This is the reverse operation + * of av_url_split. * * Note, this requires networking to be initialized, so the caller must * ensure ff_network_init has been called. * - * @see ff_url_split + * @see av_url_split * * @param str the buffer to fill with the url * @param size the size of the str buffer * @param proto the protocol identifier, if null, the separator * after the identifier is left out, too - * @param authorization an optional authorization string, may be null + * @param authorization an optional authorization string, may be null. + * An empty string is treated the same as a null string. * @param hostname the host name string * @param port the port number, left out from the string if negative * @param fmt a generic format string for everything to add after the @@ -143,7 +127,7 @@ int ff_url_join(char *str, int size, const char *proto, int port, const char *fmt, ...); /** - * Appends the media-specific SDP fragment for the media stream c + * Append the media-specific SDP fragment for the media stream c * to the buffer buff. * * Note, the buffer needs to be initialized, since it is appended to @@ -173,4 +157,14 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt, AVFormatContext *src); +/** + * Get the length in bytes which is needed to store val as v. + */ +int ff_get_v_length(uint64_t val); + +/** + * Put val using a variable number of bytes. + */ +void ff_put_v(ByteIOContext *bc, uint64_t val); + #endif /* AVFORMAT_INTERNAL_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/isom.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/isom.c index e106ab95c..bf2d3b1da 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/isom.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/isom.c @@ -74,6 +74,8 @@ const AVCodecTag codec_movvideo_tags[] = { { CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'R', 'A') }, { CODEC_ID_RAWVIDEO, MKTAG('R', 'G', 'B', 'A') }, { CODEC_ID_RAWVIDEO, MKTAG('A', 'B', 'G', 'R') }, + { CODEC_ID_RAWVIDEO, MKTAG('b', '1', '6', 'g') }, + { CODEC_ID_RAWVIDEO, MKTAG('b', '4', '8', 'r') }, { CODEC_ID_R210, MKTAG('r', '2', '1', '0') }, /* UNCOMPRESSED 10BIT RGB */ { CODEC_ID_V210, MKTAG('v', '2', '1', '0') }, /* UNCOMPRESSED 10BIT 4:2:2 */ @@ -221,7 +223,6 @@ const AVCodecTag codec_movaudio_tags[] = { { CODEC_ID_AAC, MKTAG('m', 'p', '4', 'a') }, /* MPEG-4 AAC */ { CODEC_ID_AC3, MKTAG('a', 'c', '-', '3') }, /* ETSI TS 102 366 Annex F */ { CODEC_ID_AC3, MKTAG('s', 'a', 'c', '3') }, /* Nero Recode */ - { CODEC_ID_DTS, MKTAG('D', 'T', 'S', ' ') }, /* DTS */ { CODEC_ID_AMR_NB, MKTAG('s', 'a', 'm', 'r') }, /* AMR-NB 3gp */ { CODEC_ID_AMR_WB, MKTAG('s', 'a', 'w', 'b') }, /* AMR-WB 3gp */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/librtmp.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/librtmp.c index dd7640aae..344f0f908 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/librtmp.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/librtmp.c @@ -55,7 +55,7 @@ static int rtmp_close(URLContext *s) } /** - * Opens RTMP connection and verifies that the stream can be played. + * Open RTMP connection and verify that the stream can be played. * * URL syntax: rtmp://server[:port][/app][/playpath][ keyword=value]... * where 'app' is first one or two directories in the path @@ -94,7 +94,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) } if (flags & URL_WRONLY) - r->Link.protocol |= RTMP_FEATURE_WRITE; + RTMP_EnableWrite(r); if (!RTMP_Connect(r, NULL) || !RTMP_ConnectStream(r, 0)) { rc = -1; @@ -127,10 +127,7 @@ static int rtmp_read_pause(URLContext *s, int pause) { RTMP *r = s->priv_data; - if (pause) - r->m_pauseStamp = - r->m_channelTimestamp[r->m_mediaChannel]; - if (!RTMP_SendPause(r, pause, r->m_pauseStamp)) + if (!RTMP_Pause(r, pause)) return -1; return 0; } @@ -157,7 +154,7 @@ static int rtmp_get_file_handle(URLContext *s) { RTMP *r = s->priv_data; - return r->m_sb.sb_socket; + return RTMP_Socket(r); } URLProtocol rtmp_protocol = { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/matroska.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/matroska.h index 40ab3a742..0d0d0bcff 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/matroska.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/matroska.h @@ -148,7 +148,8 @@ #define MATROSKA_ID_TAGNAME 0x45A3 #define MATROSKA_ID_TAGSTRING 0x4487 #define MATROSKA_ID_TAGLANG 0x447A -#define MATROSKA_ID_TAGDEFAULT 0x44B4 +#define MATROSKA_ID_TAGDEFAULT 0x4484 +#define MATROSKA_ID_TAGDEFAULT_BUG 0x44B4 #define MATROSKA_ID_TAGTARGETS 0x63C0 #define MATROSKA_ID_TAGTARGETS_TYPE 0x63CA #define MATROSKA_ID_TAGTARGETS_TYPEVALUE 0x68CA diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/matroskadec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/matroskadec.c index 6bb2b6014..954ef3b86 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/matroskadec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/matroskadec.c @@ -215,6 +215,7 @@ typedef struct { int num_levels; MatroskaLevel levels[EBML_MAX_DEPTH]; int level_up; + uint32_t current_id; uint64_t time_scale; double duration; @@ -235,7 +236,6 @@ typedef struct { AVPacket *prev_pkt; int done; - int has_cluster_id; /* What to skip before effectively reading a packet. */ int skip_to_keyframe; @@ -337,11 +337,11 @@ static EbmlSyntax matroska_track[] = { { MATROSKA_ID_TRACKDEFAULTDURATION, EBML_UINT, 0, offsetof(MatroskaTrack,default_duration) }, { MATROSKA_ID_TRACKTIMECODESCALE, EBML_FLOAT,0, offsetof(MatroskaTrack,time_scale), {.f=1.0} }, { MATROSKA_ID_TRACKFLAGDEFAULT, EBML_UINT, 0, offsetof(MatroskaTrack,flag_default), {.u=1} }, + { MATROSKA_ID_TRACKFLAGFORCED, EBML_UINT, 0, offsetof(MatroskaTrack,flag_forced), {.u=0} }, { MATROSKA_ID_TRACKVIDEO, EBML_NEST, 0, offsetof(MatroskaTrack,video), {.n=matroska_track_video} }, { MATROSKA_ID_TRACKAUDIO, EBML_NEST, 0, offsetof(MatroskaTrack,audio), {.n=matroska_track_audio} }, { MATROSKA_ID_TRACKCONTENTENCODINGS,EBML_NEST, 0, 0, {.n=matroska_track_encodings} }, { MATROSKA_ID_TRACKFLAGENABLED, EBML_NONE }, - { MATROSKA_ID_TRACKFLAGFORCED, EBML_UINT, 0, offsetof(MatroskaTrack,flag_forced), {.u=1} }, { MATROSKA_ID_TRACKFLAGLACING, EBML_NONE }, { MATROSKA_ID_CODECNAME, EBML_NONE }, { MATROSKA_ID_CODECDECODEALL, EBML_NONE }, @@ -427,6 +427,7 @@ static EbmlSyntax matroska_simpletag[] = { { MATROSKA_ID_TAGSTRING, EBML_UTF8, 0, offsetof(MatroskaTag,string) }, { MATROSKA_ID_TAGLANG, EBML_STR, 0, offsetof(MatroskaTag,lang), {.s="und"} }, { MATROSKA_ID_TAGDEFAULT, EBML_UINT, 0, offsetof(MatroskaTag,def) }, + { MATROSKA_ID_TAGDEFAULT_BUG, EBML_UINT, 0, offsetof(MatroskaTag,def) }, { MATROSKA_ID_SIMPLETAG, EBML_NEST, sizeof(MatroskaTag), offsetof(MatroskaTag,sub), {.n=matroska_simpletag} }, { 0 } }; @@ -470,7 +471,7 @@ static EbmlSyntax matroska_segment[] = { { MATROSKA_ID_CUES, EBML_NEST, 0, 0, {.n=matroska_index } }, { MATROSKA_ID_TAGS, EBML_NEST, 0, 0, {.n=matroska_tags } }, { MATROSKA_ID_SEEKHEAD, EBML_NEST, 0, 0, {.n=matroska_seekhead } }, - { MATROSKA_ID_CLUSTER, EBML_STOP, 0, offsetof(MatroskaDemuxContext,has_cluster_id) }, + { MATROSKA_ID_CLUSTER, EBML_STOP }, { 0 } }; @@ -518,7 +519,7 @@ static int ebml_level_end(MatroskaDemuxContext *matroska) if (matroska->num_levels > 0) { MatroskaLevel *level = &matroska->levels[matroska->num_levels - 1]; - if (pos - level->start >= level->length) { + if (pos - level->start >= level->length || matroska->current_id) { matroska->num_levels--; return 1; } @@ -657,7 +658,7 @@ static int ebml_read_binary(ByteIOContext *pb, int length, EbmlBin *bin) * are supposed to be sub-elements which can be read separately. * 0 is success, < 0 is failure. */ -static int ebml_read_master(MatroskaDemuxContext *matroska, int length) +static int ebml_read_master(MatroskaDemuxContext *matroska, uint64_t length) { ByteIOContext *pb = matroska->ctx->pb; MatroskaLevel *level; @@ -716,6 +717,10 @@ static int ebml_parse_id(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, for (i=0; syntax[i].id; i++) if (id == syntax[i].id) break; + if (!syntax[i].id && id == MATROSKA_ID_CLUSTER && + matroska->num_levels > 0 && + matroska->levels[matroska->num_levels-1].length == 0xffffffffffffff) + return 0; // we reached the end of an unknown size cluster if (!syntax[i].id && id != EBML_ID_VOID && id != EBML_ID_CRC32) av_log(matroska->ctx, AV_LOG_INFO, "Unknown entry 0x%X\n", id); return ebml_parse_elem(matroska, &syntax[i], data); @@ -724,10 +729,14 @@ static int ebml_parse_id(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, static int ebml_parse(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, void *data) { - uint64_t id; - int res = ebml_read_num(matroska, matroska->ctx->pb, 4, &id); - id |= 1 << 7*res; - return res < 0 ? res : ebml_parse_id(matroska, syntax, id, data); + if (!matroska->current_id) { + uint64_t id; + int res = ebml_read_num(matroska, matroska->ctx->pb, 4, &id); + if (res < 0) + return res; + matroska->current_id = id | 1 << 7*res; + } + return ebml_parse_id(matroska, syntax, matroska->current_id, data); } static int ebml_parse_nest(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, @@ -772,9 +781,11 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska, list->nb_elem++; } - if (syntax->type != EBML_PASS && syntax->type != EBML_STOP) + if (syntax->type != EBML_PASS && syntax->type != EBML_STOP) { + matroska->current_id = 0; if ((res = ebml_read_num(matroska, pb, 8, &length)) < 0) return res; + } switch (syntax->type) { case EBML_UINT: res = ebml_read_uint (pb, length, data); break; @@ -788,7 +799,7 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska, matroska->segment_start = url_ftell(matroska->ctx->pb); return ebml_parse_nest(matroska, syntax->def.n, data); case EBML_PASS: return ebml_parse_id(matroska, syntax->def.n, id, data); - case EBML_STOP: *(int *)data = 1; return 1; + case EBML_STOP: return 1; default: return url_fseek(pb,length,SEEK_CUR)<0 ? AVERROR(EIO) : 0; } if (res == AVERROR_INVALIDDATA) @@ -1061,9 +1072,15 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) MatroskaSeekhead *seekhead = seekhead_list->elem; uint32_t level_up = matroska->level_up; int64_t before_pos = url_ftell(matroska->ctx->pb); + uint32_t saved_id = matroska->current_id; MatroskaLevel level; int i; + // we should not do any seeking in the streaming case + if (url_is_streamed(matroska->ctx->pb) || + (matroska->ctx->flags & AVFMT_FLAG_IGNIDX)) + return; + for (i=0; inb_elem; i++) { int64_t offset = seekhead[i].pos + matroska->segment_start; @@ -1089,6 +1106,7 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) level.length = (uint64_t)-1; matroska->levels[matroska->num_levels] = level; matroska->num_levels++; + matroska->current_id = 0; ebml_parse(matroska, matroska_segment, matroska); @@ -1103,6 +1121,7 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) /* seek back */ url_fseek(matroska->ctx->pb, before_pos, SEEK_SET); matroska->level_up = level_up; + matroska->current_id = saved_id; } static int matroska_aac_profile(char *codec_id) @@ -1140,7 +1159,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) uint64_t max_start = 0; Ebml ebml = { 0 }; AVStream *st; - int i, j; + int i, j, res; matroska->ctx = s; @@ -1164,8 +1183,8 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) ebml_free(ebml_syntax, &ebml); /* The next thing is a segment. */ - if (ebml_parse(matroska, matroska_segments, matroska) < 0) - return -1; + if ((res = ebml_parse(matroska, matroska_segments, matroska)) < 0) + return res; matroska_execute_seekhead(matroska); if (!matroska->time_scale) @@ -1757,7 +1776,8 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, if (matroska->prev_pkt && timecode != AV_NOPTS_VALUE && matroska->prev_pkt->pts == timecode && - matroska->prev_pkt->stream_index == st->index) + matroska->prev_pkt->stream_index == st->index && + st->codec->codec_id == CODEC_ID_SSA) matroska_merge_packets(matroska->prev_pkt, pkt); else { dynarray_add(&matroska->packets,&matroska->num_packets,pkt); @@ -1784,15 +1804,9 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) int i, res; int64_t pos = url_ftell(matroska->ctx->pb); matroska->prev_pkt = NULL; - if (matroska->has_cluster_id){ - /* For the first cluster we parse, its ID was already read as - part of matroska_read_header(), so don't read it again */ - res = ebml_parse_id(matroska, matroska_clusters, - MATROSKA_ID_CLUSTER, &cluster); + if (matroska->current_id) pos -= 4; /* sizeof the ID which was already read */ - matroska->has_cluster_id = 0; - } else - res = ebml_parse(matroska, matroska_clusters, &cluster); + res = ebml_parse(matroska, matroska_clusters, &cluster); blocks_list = &cluster.blocks; blocks = blocks_list->elem; for (i=0; inb_elem; i++) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/matroskaenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/matroskaenc.c index e78d062cb..d906662b9 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/matroskaenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/matroskaenc.c @@ -83,7 +83,6 @@ typedef struct MatroskaMuxContext { mkv_cues *cues; mkv_track *tracks; - AVLFG lfg; unsigned int audio_buffer_size; AVPacket cur_audio_pkt; } MatroskaMuxContext; @@ -194,7 +193,7 @@ static void put_ebml_string(ByteIOContext *pb, unsigned int elementid, const cha } /** - * Writes a void element of a given size. Useful for reserving space in + * Write a void element of a given size. Useful for reserving space in * the file to be written to later. * * @param size The number of bytes to reserve, which must be at least 2. @@ -699,8 +698,6 @@ static int mkv_write_header(AVFormatContext *s) if (!strcmp(s->oformat->name, "webm")) mkv->mode = MODE_WEBM; else mkv->mode = MODE_MATROSKAv2; - av_lfg_init(&mkv->lfg, av_get_random_seed()); - mkv->tracks = av_mallocz(s->nb_streams * sizeof(*mkv->tracks)); if (!mkv->tracks) return AVERROR(ENOMEM); @@ -736,8 +733,12 @@ static int mkv_write_header(AVFormatContext *s) put_ebml_string(pb, MATROSKA_ID_TITLE, tag->value); if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) { uint32_t segment_uid[4]; + AVLFG lfg; + + av_lfg_init(&lfg, av_get_random_seed()); + for (i = 0; i < 4; i++) - segment_uid[i] = av_lfg_get(&mkv->lfg); + segment_uid[i] = av_lfg_get(&lfg); put_ebml_string(pb, MATROSKA_ID_MUXINGAPP , LIBAVFORMAT_IDENT); put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, LIBAVFORMAT_IDENT); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/metadata_compat.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/metadata_compat.c index ac99c05c6..26d22242e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/metadata_compat.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/metadata_compat.c @@ -108,10 +108,11 @@ void ff_metadata_demux_compat(AVFormatContext *ctx) #define FILL_METADATA(s, key, value) { \ - if (value && *value && !av_metadata_get(s->metadata, #key, NULL, 0)) \ + if (!av_metadata_get(s->metadata, #key, NULL, 0)) \ av_metadata_set2(&s->metadata, #key, value, 0); \ } -#define FILL_METADATA_STR(s, key) FILL_METADATA(s, key, s->key) +#define FILL_METADATA_STR(s, key) { \ + if (s->key && *s->key) FILL_METADATA(s, key, s->key); } #define FILL_METADATA_INT(s, key) { \ char number[10]; \ snprintf(number, sizeof(number), "%d", s->key); \ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mmst.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mmst.c index 9b2e497c3..1750390a2 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mmst.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mmst.c @@ -258,7 +258,7 @@ static MMSSCPacketType get_tcp_server_response(MMSContext *mms) // read the rest of the packet. if (length_remaining < 0 || length_remaining > sizeof(mms->in_buffer) - 12) { - dprintf("Incoming message len %d exceeds buffer len %d\n", + dprintf(NULL, "Incoming message len %d exceeds buffer len %d\n", length_remaining, sizeof(mms->in_buffer) - 12); return -1; } @@ -291,7 +291,7 @@ static MMSSCPacketType get_tcp_server_response(MMSContext *mms) if (length_remaining < 0 || length_remaining > sizeof(mms->in_buffer) - 8) { - dprintf("Incoming data len %d exceeds buffer len %d\n", + dprintf(NULL, "Incoming data len %d exceeds buffer len %d\n", length_remaining, sizeof(mms->in_buffer)); return -1; } @@ -431,7 +431,7 @@ static int asf_header_parser(MMSContext *mms) while(end - p >= sizeof(ff_asf_guid) + 8) { uint64_t chunksize = AV_RL64(p + sizeof(ff_asf_guid)); if (!chunksize || chunksize > end - p) { - dprintf("chunksize is exceptional value:%d!\n", chunksize); + dprintf(NULL, "chunksize is exceptional value:%d!\n", chunksize); return -1; } if (!memcmp(p, ff_asf_file_header, sizeof(ff_asf_guid))) { @@ -455,7 +455,7 @@ static int asf_header_parser(MMSContext *mms) mms->streams[mms->stream_num].id = stream_id; mms->stream_num++; } else { - dprintf("Too many streams.\n"); + dprintf(NULL, "Too many streams.\n"); return -1; } } @@ -581,7 +581,7 @@ static int mms_open(URLContext *h, const char *uri, int flags) return AVERROR(ENOMEM); // only for MMS over TCP, so set proto = NULL - ff_url_split(NULL, 0, NULL, 0, + av_url_split(NULL, 0, NULL, 0, mms->host, sizeof(mms->host), &port, mms->path, sizeof(mms->path), uri); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mov.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mov.c index c777660c8..bf986b337 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mov.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mov.c @@ -222,14 +222,16 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom) static int mov_read_chpl(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { int64_t start; - int i, nb_chapters, str_len; + int i, nb_chapters, str_len, version; char str[256+1]; if ((atom.size -= 5) < 0) return 0; - get_be32(pb); // version + flags - get_be32(pb); // ??? + version = get_byte(pb); + get_be24(pb); + if (version) + get_be32(pb); // ??? nb_chapters = get_byte(pb); for (i = 0; i < nb_chapters; i++) { @@ -265,9 +267,9 @@ static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOVAtom atom) a.size = get_be32(pb); a.type = get_le32(pb); } + dprintf(c->fc, "type: %08x '%.4s' parent:'%.4s' sz: %"PRId64" %"PRId64" %"PRId64"\n", + a.type, (char*)&a.type, (char*)&atom.type, a.size, total_size, atom.size); total_size += 8; - dprintf(c->fc, "type: %08x %.4s sz: %"PRIx64" %"PRIx64" %"PRIx64"\n", - a.type, (char*)&a.type, a.size, atom.size, total_size); if (a.size == 1) { /* 64 bit extended size */ a.size = get_be64(pb) - 8; total_size += 8; @@ -535,8 +537,10 @@ int ff_mov_read_esds(AVFormatContext *fc, ByteIOContext *pb, MOVAtom atom) st->codec->channels = cfg.channels; if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4 st->codec->sample_rate = ff_mpa_freq_tab[cfg.sampling_index]; + else if (cfg.ext_sample_rate) + st->codec->sample_rate = cfg.ext_sample_rate; else - st->codec->sample_rate = cfg.sample_rate; // ext sample rate ? + st->codec->sample_rate = cfg.sample_rate; dprintf(fc, "mp4a config channels %d obj %d ext obj %d " "sample rate %d ext sample rate %d\n", st->codec->channels, cfg.object_type, cfg.ext_object_type, @@ -960,7 +964,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom) //Parsing Sample description table enum CodecID id; int dref_id = 1; - MOVAtom a = { 0 }; + MOVAtom a = { AV_RL32("stsd") }; int64_t start_pos = url_ftell(pb); int size = get_be32(pb); /* size */ uint32_t format = get_le32(pb); /* data format */ @@ -989,7 +993,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom) st->codec->codec_tag = format; id = ff_codec_get_id(codec_movaudio_tags, format); if (id<=0 && ((format&0xFFFF) == 'm'+('s'<<8) || (format&0xFFFF) == 'T'+('S'<<8))) - id = ff_codec_get_id(ff_codec_wav_tags, bswap_32(format)&0xFFFF); + id = ff_codec_get_id(ff_codec_wav_tags, av_bswap32(format)&0xFFFF); if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO && id > 0) { st->codec->codec_type = AVMEDIA_TYPE_AUDIO; @@ -2363,7 +2367,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) MOVContext *mov = s->priv_data; ByteIOContext *pb = s->pb; int err; - MOVAtom atom = { 0 }; + MOVAtom atom = { AV_RL32("root") }; mov->fc = s; /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */ @@ -2427,7 +2431,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) if (!sample) { mov->found_mdat = 0; if (!url_is_streamed(s->pb) || - mov_read_default(mov, s->pb, (MOVAtom){ 0, INT64_MAX }) < 0 || + mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || url_feof(s->pb)) return AVERROR_EOF; dprintf(s, "read fragments, offset 0x%llx\n", url_ftell(s->pb)); @@ -2494,6 +2498,8 @@ static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, sample = av_index_search_timestamp(st, timestamp, flags); dprintf(s, "stream %d, timestamp %"PRId64", sample %d\n", st->index, timestamp, sample); + if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp) + sample = 0; if (sample < 0) /* not sure what to do */ return -1; sc->current_sample = sample; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/movenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/movenc.c index 3495eb040..c0efa3a96 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/movenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/movenc.c @@ -626,12 +626,14 @@ static const struct { { PIX_FMT_RGB555LE,MKTAG('L','5','5','5'), 16 }, { PIX_FMT_RGB565LE,MKTAG('L','5','6','5'), 16 }, { PIX_FMT_RGB565BE,MKTAG('B','5','6','5'), 16 }, + { PIX_FMT_GRAY16BE,MKTAG('b','1','6','g'), 16 }, { PIX_FMT_RGB24, MKTAG('r','a','w',' '), 24 }, { PIX_FMT_BGR24, MKTAG('2','4','B','G'), 24 }, { PIX_FMT_ARGB, MKTAG('r','a','w',' '), 32 }, { PIX_FMT_BGRA, MKTAG('B','G','R','A'), 32 }, { PIX_FMT_RGBA, MKTAG('R','G','B','A'), 32 }, { PIX_FMT_ABGR, MKTAG('A','B','G','R'), 32 }, + { PIX_FMT_RGB48BE, MKTAG('b','4','8','r'), 48 }, }; static int mov_get_rawvideo_codec_tag(AVFormatContext *s, MOVTrack *track) @@ -745,6 +747,19 @@ static int mov_write_subtitle_tag(ByteIOContext *pb, MOVTrack *track) return updateSize(pb, pos); } +static int mov_write_pasp_tag(ByteIOContext *pb, MOVTrack *track) +{ + AVRational sar; + av_reduce(&sar.num, &sar.den, track->enc->sample_aspect_ratio.num, + track->enc->sample_aspect_ratio.den, INT_MAX); + + put_be32(pb, 16); + put_tag(pb, "pasp"); + put_be32(pb, track->enc->sample_aspect_ratio.num); + put_be32(pb, track->enc->sample_aspect_ratio.den); + return 16; +} + static int mov_write_video_tag(ByteIOContext *pb, MOVTrack *track) { int64_t pos = url_ftell(pb); @@ -806,6 +821,12 @@ static int mov_write_video_tag(ByteIOContext *pb, MOVTrack *track) } else if(track->vosLen > 0) mov_write_glbl_tag(pb, track); + if (track->mode == MODE_MOV && + track->enc->sample_aspect_ratio.den && track->enc->sample_aspect_ratio.num && + track->enc->sample_aspect_ratio.den != track->enc->sample_aspect_ratio.num) { + mov_write_pasp_tag(pb, track); + } + return updateSize(pb, pos); } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mp3.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mp3.c index dcb59e841..11ce59cec 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mp3.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mp3.c @@ -42,7 +42,7 @@ static int mp3_read_probe(AVProbeData *p) AVCodecContext avctx; buf0 = p->buf; - if(ff_id3v2_match(buf0)) { + if(ff_id3v2_match(buf0, ID3v2_DEFAULT_MAGIC)) { buf0 += ff_id3v2_tag_len(buf0); } end = p->buf + p->buf_size - sizeof(uint32_t); @@ -148,7 +148,7 @@ static int mp3_read_header(AVFormatContext *s, // lcm of all mp3 sample rates av_set_pts_info(st, 64, 1, 14112000); - ff_id3v2_read(s); + ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC); off = url_ftell(s->pb); if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX)) @@ -214,18 +214,18 @@ static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf) buf[0] = 'T'; buf[1] = 'A'; buf[2] = 'G'; - count += id3v1_set_string(s, "title", buf + 3, 30); - count += id3v1_set_string(s, "author", buf + 33, 30); - count += id3v1_set_string(s, "album", buf + 63, 30); - count += id3v1_set_string(s, "date", buf + 93, 4); + count += id3v1_set_string(s, "TIT2", buf + 3, 30); //title + count += id3v1_set_string(s, "TPE1", buf + 33, 30); //author|artist + count += id3v1_set_string(s, "TALB", buf + 63, 30); //album + count += id3v1_set_string(s, "TDRL", buf + 93, 4); //date count += id3v1_set_string(s, "comment", buf + 97, 30); - if ((tag = av_metadata_get(s->metadata, "track", NULL, 0))) { + if ((tag = av_metadata_get(s->metadata, "TRCK", NULL, 0))) { //track buf[125] = 0; buf[126] = atoi(tag->value); count++; } buf[127] = 0xFF; /* default to unknown genre */ - if ((tag = av_metadata_get(s->metadata, "genre", NULL, 0))) { + if ((tag = av_metadata_get(s->metadata, "TCON", NULL, 0))) { //genre for(i = 0; i <= ID3v1_GENRE_MAX; i++) { if (!strcasecmp(tag->value, ff_id3v1_genre_str[i])) { buf[127] = i; @@ -290,6 +290,7 @@ AVOutputFormat mp2_muxer = { NULL, mp3_write_packet, mp3_write_trailer, + .metadata_conv = ff_id3v2_metadata_conv, }; #endif diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpc.c index 4dda65dbc..681e37f77 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpc.c @@ -45,7 +45,7 @@ typedef struct { static int mpc_probe(AVProbeData *p) { const uint8_t *d = p->buf; - if (ff_id3v2_match(d)) { + if (ff_id3v2_match(d, ID3v2_DEFAULT_MAGIC)) { d += ff_id3v2_tag_len(d); } if (d+3 < p->buf+p->buf_size) @@ -67,7 +67,7 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap) if (url_fseek(s->pb, pos, SEEK_SET) < 0) return -1; ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE); - if (ret != ID3v2_HEADER_SIZE || !ff_id3v2_match(buf)) { + if (ret != ID3v2_HEADER_SIZE || !ff_id3v2_match(buf, ID3v2_DEFAULT_MAGIC)) { av_log(s, AV_LOG_ERROR, "Not a Musepack file\n"); return -1; } @@ -82,7 +82,7 @@ static int mpc_read_header(AVFormatContext *s, AVFormatParameters *ap) /* read ID3 tags */ if (url_fseek(s->pb, pos, SEEK_SET) < 0) return -1; - ff_id3v2_read(s); + ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC); get_le24(s->pb); } c->ver = get_byte(s->pb); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpeg.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpeg.c index d132c6306..6fd0125f5 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpeg.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpeg.c @@ -50,18 +50,6 @@ static int check_pes(uint8_t *p, uint8_t *end){ return pes1||pes2; } -static int cdxa_probe(AVProbeData *p) -{ - /* check file header */ - if (p->buf[0] == 'R' && p->buf[1] == 'I' && - p->buf[2] == 'F' && p->buf[3] == 'F' && - p->buf[8] == 'C' && p->buf[9] == 'D' && - p->buf[10] == 'X' && p->buf[11] == 'A') - return AVPROBE_SCORE_MAX; - else - return 0; -} - static int mpegps_probe(AVProbeData *p) { uint32_t code= -1; @@ -69,10 +57,6 @@ static int mpegps_probe(AVProbeData *p) int i; int score=0; - score = cdxa_probe(p); - if (score > 0) return score; - - /* Search for MPEG stream */ for(i=0; ibuf_size; i++){ code = (code<<8) + p->buf[i]; if ((code & 0xffffff00) == 0x100) { @@ -212,7 +196,7 @@ static int find_prev_start_code(ByteIOContext *pb, int *size_ptr) #endif /** - * Extracts stream types from a program stream map + * Extract stream types from a program stream map * According to ISO/IEC 13818-1 ('MPEG-2 Systems') table 2-35 * * @return number of bytes occupied by PSM in the bitstream @@ -474,9 +458,6 @@ static int mpegps_read_packet(AVFormatContext *s, } else if(es_type == STREAM_TYPE_AUDIO_AAC){ codec_id = CODEC_ID_AAC; type = AVMEDIA_TYPE_AUDIO; - } else if(es_type == STREAM_TYPE_AUDIO_AAC_LATM){ - codec_id = CODEC_ID_AAC_LATM; - type = CODEC_TYPE_AUDIO; } else if(es_type == STREAM_TYPE_VIDEO_MPEG4){ codec_id = CODEC_ID_MPEG4; type = AVMEDIA_TYPE_VIDEO; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpeg.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpeg.h index c207d3a07..d09b2e81b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpeg.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpeg.h @@ -53,7 +53,6 @@ #define STREAM_TYPE_PRIVATE_DATA 0x06 #define STREAM_TYPE_AUDIO_AAC 0x0f #define STREAM_TYPE_VIDEO_MPEG4 0x10 -#define STREAM_TYPE_AUDIO_AAC_LATM 0x11 #define STREAM_TYPE_VIDEO_H264 0x1b #define STREAM_TYPE_AUDIO_AC3 0x81 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpegts.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpegts.c index af1c6695b..d9ee987e1 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpegts.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpegts.c @@ -71,7 +71,6 @@ typedef struct MpegTSSectionFilter { struct MpegTSFilter { int pid; int last_cc; /* last cc code (-1 if first packet) */ - int last_version; /* last version of data on this pid */ enum MpegTSFilterType type; union { MpegTSPESFilter pes_filter; @@ -240,7 +239,7 @@ static int discard_pid(MpegTSContext *ts, unsigned int pid) } /** - * Assembles PES packets out of TS packets, and then calls the "section_cb" + * Assemble PES packets out of TS packets, and then call the "section_cb" * function when they are complete. */ static void write_section_data(AVFormatContext *s, MpegTSFilter *tss1, @@ -300,7 +299,6 @@ static MpegTSFilter *mpegts_open_section_filter(MpegTSContext *ts, unsigned int filter->type = MPEGTS_SECTION; filter->pid = pid; filter->last_cc = -1; - filter->last_version = -1; sec = &filter->u.section_filter; sec->section_cb = section_cb; sec->opaque = opaque; @@ -403,7 +401,6 @@ typedef struct SectionHeader { uint8_t tid; uint16_t id; uint8_t version; - uint8_t current; uint8_t sec_num; uint8_t last_sec_num; } SectionHeader; @@ -475,7 +472,6 @@ static int parse_section_header(SectionHeader *h, val = get8(pp, p_end); if (val < 0) return -1; - h->current = val & 0x1; h->version = (val >> 1) & 0x1f; val = get8(pp, p_end); if (val < 0) @@ -501,7 +497,7 @@ static const StreamType ISO_types[] = { { 0x04, AVMEDIA_TYPE_AUDIO, CODEC_ID_MP3 }, { 0x0f, AVMEDIA_TYPE_AUDIO, CODEC_ID_AAC }, { 0x10, AVMEDIA_TYPE_VIDEO, CODEC_ID_MPEG4 }, - { 0x11, AVMEDIA_TYPE_AUDIO, CODEC_ID_AAC_LATM }, /* LATM syntax */ + //{ 0x11, AVMEDIA_TYPE_AUDIO, CODEC_ID_AAC }, /* LATM syntax */ { 0x1b, AVMEDIA_TYPE_VIDEO, CODEC_ID_H264 }, { 0xd1, AVMEDIA_TYPE_VIDEO, CODEC_ID_DIRAC }, { 0xea, AVMEDIA_TYPE_VIDEO, CODEC_ID_VC1 }, @@ -514,8 +510,6 @@ static const StreamType HDMV_types[] = { { 0x82, AVMEDIA_TYPE_AUDIO, CODEC_ID_DTS }, { 0x83, AVMEDIA_TYPE_AUDIO, CODEC_ID_TRUEHD }, { 0x84, AVMEDIA_TYPE_AUDIO, CODEC_ID_EAC3 }, - { 0x85, CODEC_TYPE_AUDIO, CODEC_ID_DTS }, /* DTS HD */ - { 0x86, CODEC_TYPE_AUDIO, CODEC_ID_DTS }, /* DTS HD MASTER*/ { 0x90, AVMEDIA_TYPE_SUBTITLE, CODEC_ID_HDMV_PGS_SUBTITLE }, { 0 }, }; @@ -530,10 +524,6 @@ static const StreamType MISC_types[] = { static const StreamType REGD_types[] = { { MKTAG('d','r','a','c'), AVMEDIA_TYPE_VIDEO, CODEC_ID_DIRAC }, { MKTAG('A','C','-','3'), AVMEDIA_TYPE_AUDIO, CODEC_ID_AC3 }, - { MKTAG('D','T','S','1'), CODEC_TYPE_AUDIO, CODEC_ID_DTS }, - { MKTAG('D','T','S','2'), CODEC_TYPE_AUDIO, CODEC_ID_DTS }, - { MKTAG('D','T','S','3'), CODEC_TYPE_AUDIO, CODEC_ID_DTS }, - { MKTAG('V','C','-','1'), CODEC_TYPE_VIDEO, CODEC_ID_VC1 }, { 0 }, }; @@ -544,8 +534,6 @@ static const StreamType DESC_types[] = { { 0x7b, AVMEDIA_TYPE_AUDIO, CODEC_ID_DTS }, { 0x56, AVMEDIA_TYPE_SUBTITLE, CODEC_ID_DVB_TELETEXT }, { 0x59, AVMEDIA_TYPE_SUBTITLE, CODEC_ID_DVB_SUBTITLE }, /* subtitling descriptor */ - { 0x45, CODEC_TYPE_DATA, CODEC_ID_VBI_DATA }, /* VBI Data descriptor */ - { 0x46, CODEC_TYPE_DATA, CODEC_ID_VBI_TELETEXT }, /* VBI Teletext descriptor */ { 0 }, }; @@ -700,7 +688,7 @@ static int mpegts_push_data(MpegTSFilter *filter, goto skip; /* stream not present in PMT */ - if (ts->auto_guess && !pes->st) { + if (!pes->st) { pes->st = av_new_stream(ts->stream, pes->pid); if (!pes->st) return AVERROR(ENOMEM); @@ -1045,12 +1033,6 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len return; if (h->tid != PAT_TID) return; - if (!h->current) - return; - if (h->version == filter->last_version) - return; - filter->last_version = h->version; - dprintf(ts->stream, "version=%d\n", filter->last_version); clear_programs(ts); for(;;) { @@ -1366,44 +1348,6 @@ static int parse_pcr(int64_t *ppcr_high, int *ppcr_low, return 0; } -static int parse_timestamp(int64_t *ts, const uint8_t *buf) -{ - int afc, flags; - const uint8_t *p; - - if(!(buf[1] & 0x40)) /* must be a start packet */ - return -1; - - afc = (buf[3] >> 4) & 3; - p = buf + 4; - if (afc == 0 || afc == 2) /* invalid or only adaption field */ - return -1; - if (afc == 3) - p += p[0] + 1; - if (p >= buf + TS_PACKET_SIZE) - return -1; - - if (p[0] != 0x00 || p[1] != 0x00 || p[2] != 0x01) /* packet_start_code_prefix */ - return -1; - - flags = p[3] | 0x100; /* stream type */ - if (!((flags >= 0x1c0 && flags <= 0x1df) || - (flags >= 0x1e0 && flags <= 0x1ef) || - (flags == 0x1bd) || (flags == 0x1fd))) - return -1; - - flags = p[7]; - if ((flags & 0xc0) == 0x80) { - *ts = get_pts(p+9); - return 0; - } else if ((flags & 0xc0) == 0xc0) { - *ts = get_pts(p+9+5); - return 0; - } - return -1; -} - - static int mpegts_read_header(AVFormatContext *s, AVFormatParameters *ap) { @@ -1449,10 +1393,7 @@ static int mpegts_read_header(AVFormatContext *s, dprintf(ts->stream, "tuning done\n"); - /* only flag NOHEADER if we are in file mode, - in streaming mode scanning may take too long for users */ - if (!url_is_streamed(pb)) - s->ctx_flags |= AVFMTCTX_NOHEADER; + s->ctx_flags |= AVFMTCTX_NOHEADER; } else { AVStream *st; int pcr_pid, pid, nb_packets, nb_pcrs, ret, pcr_l; @@ -1615,39 +1556,38 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index, int64_t pos, timestamp; uint8_t buf[TS_PACKET_SIZE]; int pcr_l, pcr_pid = ((PESContext*)s->streams[stream_index]->priv_data)->pcr_pid; - int pid = ((PESContext*)s->streams[stream_index]->priv_data)->pid; + const int find_next= 1; pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47; - while(pos < pos_limit) { - if (url_fseek(s->pb, pos, SEEK_SET) < 0) - return AV_NOPTS_VALUE; + if (find_next) { + for(;;) { + url_fseek(s->pb, pos, SEEK_SET); if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) return AV_NOPTS_VALUE; - if (buf[0] != 0x47) { - url_fseek(s->pb, -TS_PACKET_SIZE, SEEK_CUR); - if (mpegts_resync(s) < 0) - return AV_NOPTS_VALUE; - pos = url_ftell(s->pb); - continue; + if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) && + parse_pcr(×tamp, &pcr_l, buf) == 0) { + break; } + pos += ts->raw_packet_size; + } + } else { + for(;;) { + pos -= ts->raw_packet_size; + if (pos < 0) + return AV_NOPTS_VALUE; + url_fseek(s->pb, pos, SEEK_SET); + if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) + return AV_NOPTS_VALUE; if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) && parse_pcr(×tamp, &pcr_l, buf) == 0) { - *ppos = pos; - return timestamp; + break; + } + } } - - if ((pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pid) && - parse_timestamp(×tamp, buf) == 0) { *ppos = pos; return timestamp; } - pos += ts->raw_packet_size; - } - - return AV_NOPTS_VALUE; -} - #ifdef USE_SYNCPOINT_SEARCH static int read_seek2(AVFormatContext *s, @@ -1752,6 +1692,7 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t target_ts, in if(buf[1] & 0x40) break; pos += ts->raw_packet_size; } + url_fseek(s->pb, pos, SEEK_SET); return 0; } @@ -1772,9 +1713,6 @@ MpegTSContext *ff_mpegts_parse_open(AVFormatContext *s) ts->raw_packet_size = TS_PACKET_SIZE; ts->stream = s; ts->auto_guess = 1; - mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1); - mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1); - return ts; } @@ -1822,7 +1760,7 @@ AVInputFormat mpegts_demuxer = { mpegts_read_header, mpegts_read_packet, mpegts_read_close, - NULL, + read_seek, mpegts_get_pcr, .flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT, #ifdef USE_SYNCPOINT_SEARCH @@ -1838,7 +1776,7 @@ AVInputFormat mpegtsraw_demuxer = { mpegts_read_header, mpegts_raw_read_packet, mpegts_read_close, - NULL, + read_seek, mpegts_get_pcr, .flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT, #ifdef USE_SYNCPOINT_SEARCH diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpegts.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpegts.h index a6fc56d40..6be9b73f0 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpegts.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpegts.h @@ -49,7 +49,6 @@ #define STREAM_TYPE_PRIVATE_DATA 0x06 #define STREAM_TYPE_AUDIO_AAC 0x0f #define STREAM_TYPE_VIDEO_MPEG4 0x10 -#define STREAM_TYPE_AUDIO_AAC_LATM 0x11 #define STREAM_TYPE_VIDEO_H264 0x1b #define STREAM_TYPE_VIDEO_VC1 0xea #define STREAM_TYPE_VIDEO_DIRAC 0xd1 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpegtsenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpegtsenc.c index 3fc6dc195..4bd48d392 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpegtsenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mpegtsenc.c @@ -74,7 +74,7 @@ static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len) unsigned char *q; int first, b, len1, left; - crc = bswap_32(av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, buf, len - 4)); + crc = av_bswap32(av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, buf, len - 4)); buf[len - 4] = (crc >> 24) & 0xff; buf[len - 3] = (crc >> 16) & 0xff; buf[len - 2] = (crc >> 8) & 0xff; @@ -387,8 +387,9 @@ static int mpegts_write_header(AVFormatContext *s) MpegTSService *service; AVStream *st, *pcr_st = NULL; AVMetadataTag *title; - int i; + int i, j; const char *service_name; + int *pids; ts->tsid = DEFAULT_TSID; ts->onid = DEFAULT_ONID; @@ -411,6 +412,10 @@ static int mpegts_write_header(AVFormatContext *s) ts->sdt.write_packet = section_write_packet; ts->sdt.opaque = s; + pids = av_malloc(s->nb_streams * sizeof(*pids)); + if (!pids) + return AVERROR(ENOMEM); + /* assign pids to each stream */ for(i = 0;i < s->nb_streams; i++) { st = s->streams[i]; @@ -419,7 +424,26 @@ static int mpegts_write_header(AVFormatContext *s) goto fail; st->priv_data = ts_st; ts_st->service = service; - ts_st->pid = DEFAULT_START_PID + i; + /* MPEG pid values < 16 are reserved. Applications which set st->id in + * this range are assigned a calculated pid. */ + if (st->id < 16) { + ts_st->pid = DEFAULT_START_PID + i; + } else if (st->id < 0x1FFF) { + ts_st->pid = st->id; + } else { + av_log(s, AV_LOG_ERROR, "Invalid stream id %d, must be less than 8191\n", st->id); + goto fail; + } + if (ts_st->pid == service->pmt.pid) { + av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", ts_st->pid); + goto fail; + } + for (j = 0; j < i; j++) + if (pids[j] == ts_st->pid) { + av_log(s, AV_LOG_ERROR, "Duplicate stream id %d\n", ts_st->pid); + goto fail; + } + pids[i] = ts_st->pid; ts_st->payload_pts = AV_NOPTS_VALUE; ts_st->payload_dts = AV_NOPTS_VALUE; ts_st->first_pts_check = 1; @@ -441,6 +465,8 @@ static int mpegts_write_header(AVFormatContext *s) } } + av_free(pids); + /* if no video stream, use the first stream as PCR */ if (service->pcr_pid == 0x1fff && s->nb_streams > 0) { pcr_st = s->streams[0]; @@ -484,18 +510,21 @@ static int mpegts_write_header(AVFormatContext *s) ts->pat_packet_count = ts->pat_packet_period-1; ts->sdt_packet_count = ts->sdt_packet_period-1; - av_log(s, AV_LOG_INFO, - "muxrate %d bps, pcr every %d pkts, " + if (ts->mux_rate == 1) + av_log(s, AV_LOG_INFO, "muxrate VBR, "); + else + av_log(s, AV_LOG_INFO, "muxrate %d, ", ts->mux_rate); + av_log(s, AV_LOG_INFO, "pcr every %d pkts, " "sdt every %d, pat/pmt every %d pkts\n", - ts->mux_rate, service->pcr_packet_period, + service->pcr_packet_period, ts->sdt_packet_period, ts->pat_packet_period); - put_flush_packet(s->pb); return 0; fail: + av_free(pids); for(i = 0;i < s->nb_streams; i++) { st = s->streams[i]; av_free(st->priv_data); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mtv.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mtv.c index 4eae1a19e..9280455d2 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mtv.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mtv.c @@ -188,7 +188,7 @@ static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt) */ for(i=0;iimg_segment_size/2;i++) - *((uint16_t *)pkt->data+i) = bswap_16(*((uint16_t *)pkt->data+i)); + *((uint16_t *)pkt->data+i) = av_bswap16(*((uint16_t *)pkt->data+i)); #endif pkt->stream_index = VIDEO_SID; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxf.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxf.c index 452ee6ddf..c7423b0b6 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxf.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxf.c @@ -51,3 +51,44 @@ const MXFCodecUL ff_mxf_codec_uls[] = { //{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x1C,0x00 }, 15, CODEC_ID_DOLBY_E }, /* Dolby-E */ { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE }, }; + +const MXFPixelLayout ff_mxf_pixel_layouts[] = { + /** + * See SMPTE 377M E.2.46 + * + * Note: Only RGB, palette based and "abnormal" YUV pixel formats like 4:2:2:4 go here. + * For regular YUV, use CDCIPictureEssenceDescriptor. + * + * Note: Do not use these for encoding descriptors for little-endian formats until we + * get samples or official word from SMPTE on how/if those can be encoded. + */ + {PIX_FMT_ABGR, {'A', 8, 'B', 8, 'G', 8, 'R', 8 }}, + {PIX_FMT_ARGB, {'A', 8, 'R', 8, 'G', 8, 'B', 8 }}, + {PIX_FMT_BGR24, {'B', 8, 'G', 8, 'R', 8 }}, + {PIX_FMT_BGRA, {'B', 8, 'G', 8, 'R', 8, 'A', 8 }}, + {PIX_FMT_RGB24, {'R', 8, 'G', 8, 'B', 8 }}, + {PIX_FMT_RGB444BE,{'F', 4, 'R', 4, 'G', 4, 'B', 4 }}, + {PIX_FMT_RGB48BE, {'R', 8, 'r', 8, 'G', 8, 'g', 8, 'B', 8, 'b', 8 }}, + {PIX_FMT_RGB48BE, {'R', 16, 'G', 16, 'B', 16 }}, + {PIX_FMT_RGB48LE, {'r', 8, 'R', 8, 'g', 8, 'G', 8, 'b', 8, 'B', 8 }}, + {PIX_FMT_RGB555BE,{'F', 1, 'R', 5, 'G', 5, 'B', 5 }}, + {PIX_FMT_RGB565BE,{'R', 5, 'G', 6, 'B', 5 }}, + {PIX_FMT_RGBA, {'R', 8, 'G', 8, 'B', 8, 'A', 8 }}, + {PIX_FMT_PAL8, {'P', 8 }}, +}; + +static const int num_pixel_layouts = sizeof(ff_mxf_pixel_layouts) / sizeof(*ff_mxf_pixel_layouts); + +int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum PixelFormat *pix_fmt) +{ + int x; + + for(x = 0; x < num_pixel_layouts; x++) { + if (!memcmp(pixel_layout, ff_mxf_pixel_layouts[x].data, 16)) { + *pix_fmt = ff_mxf_pixel_layouts[x].pix_fmt; + return 0; + } + } + + return -1; +} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxf.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxf.h index 99553a537..26832c27b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxf.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxf.h @@ -61,6 +61,15 @@ typedef struct { extern const MXFCodecUL ff_mxf_data_definition_uls[]; extern const MXFCodecUL ff_mxf_codec_uls[]; +typedef struct { + enum PixelFormat pix_fmt; + const char data[16]; +} MXFPixelLayout; + +extern const MXFPixelLayout ff_mxf_pixel_layouts[]; + +int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum PixelFormat *pix_fmt); + #ifdef DEBUG #define PRINT_KEY(pc, s, x) dprintf(pc, "%s %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", s, \ (x)[0], (x)[1], (x)[2], (x)[3], (x)[4], (x)[5], (x)[6], (x)[7], (x)[8], (x)[9], (x)[10], (x)[11], (x)[12], (x)[13], (x)[14], (x)[15]) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxfdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxfdec.c index 168fd8d69..7bca6874d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxfdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxfdec.c @@ -101,6 +101,7 @@ typedef struct { int linked_track_id; uint8_t *extradata; int extradata_size; + enum PixelFormat pix_fmt; } MXFDescriptor; typedef struct { @@ -139,9 +140,11 @@ enum MXFWrappingScheme { Clip, }; +typedef int MXFMetadataReadFunc(void *arg, ByteIOContext *pb, int tag, int size, UID uid); + typedef struct { const UID key; - int (*read)(); + MXFMetadataReadFunc *read; int ctx_size; enum MXFMetadataSetType type; } MXFMetadataReadTableEntry; @@ -341,9 +344,9 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR_EOF; } -static int mxf_read_primer_pack(MXFContext *mxf) +static int mxf_read_primer_pack(void *arg, ByteIOContext *pb, int tag, int size, UID uid) { - ByteIOContext *pb = mxf->fc->pb; + MXFContext *mxf = arg; int item_num = get_be32(pb); int item_len = get_be32(pb); @@ -373,8 +376,9 @@ static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set) return 0; } -static int mxf_read_cryptographic_context(MXFCryptoContext *cryptocontext, ByteIOContext *pb, int tag, int size, UID uid) +static int mxf_read_cryptographic_context(void *arg, ByteIOContext *pb, int tag, int size, UID uid) { + MXFCryptoContext *cryptocontext = arg; if (size != 16) return -1; if (IS_KLV_KEY(uid, mxf_crypto_source_container_ul)) @@ -382,8 +386,9 @@ static int mxf_read_cryptographic_context(MXFCryptoContext *cryptocontext, ByteI return 0; } -static int mxf_read_content_storage(MXFContext *mxf, ByteIOContext *pb, int tag) +static int mxf_read_content_storage(void *arg, ByteIOContext *pb, int tag, int size, UID uid) { + MXFContext *mxf = arg; switch (tag) { case 0x1901: mxf->packages_count = get_be32(pb); @@ -399,8 +404,9 @@ static int mxf_read_content_storage(MXFContext *mxf, ByteIOContext *pb, int tag) return 0; } -static int mxf_read_source_clip(MXFStructuralComponent *source_clip, ByteIOContext *pb, int tag) +static int mxf_read_source_clip(void *arg, ByteIOContext *pb, int tag, int size, UID uid) { + MXFStructuralComponent *source_clip = arg; switch(tag) { case 0x0202: source_clip->duration = get_be64(pb); @@ -420,8 +426,9 @@ static int mxf_read_source_clip(MXFStructuralComponent *source_clip, ByteIOConte return 0; } -static int mxf_read_material_package(MXFPackage *package, ByteIOContext *pb, int tag) +static int mxf_read_material_package(void *arg, ByteIOContext *pb, int tag, int size, UID uid) { + MXFPackage *package = arg; switch(tag) { case 0x4403: package->tracks_count = get_be32(pb); @@ -437,8 +444,9 @@ static int mxf_read_material_package(MXFPackage *package, ByteIOContext *pb, int return 0; } -static int mxf_read_track(MXFTrack *track, ByteIOContext *pb, int tag) +static int mxf_read_track(void *arg, ByteIOContext *pb, int tag, int size, UID uid) { + MXFTrack *track = arg; switch(tag) { case 0x4801: track->track_id = get_be32(pb); @@ -457,8 +465,9 @@ static int mxf_read_track(MXFTrack *track, ByteIOContext *pb, int tag) return 0; } -static int mxf_read_sequence(MXFSequence *sequence, ByteIOContext *pb, int tag) +static int mxf_read_sequence(void *arg, ByteIOContext *pb, int tag, int size, UID uid) { + MXFSequence *sequence = arg; switch(tag) { case 0x0202: sequence->duration = get_be64(pb); @@ -480,8 +489,9 @@ static int mxf_read_sequence(MXFSequence *sequence, ByteIOContext *pb, int tag) return 0; } -static int mxf_read_source_package(MXFPackage *package, ByteIOContext *pb, int tag) +static int mxf_read_source_package(void *arg, ByteIOContext *pb, int tag, int size, UID uid) { + MXFPackage *package = arg; switch(tag) { case 0x4403: package->tracks_count = get_be32(pb); @@ -505,7 +515,7 @@ static int mxf_read_source_package(MXFPackage *package, ByteIOContext *pb, int t return 0; } -static int mxf_read_index_table_segment(MXFIndexTableSegment *segment, ByteIOContext *pb, int tag) +static int mxf_read_index_table_segment(void *arg, ByteIOContext *pb, int tag, int size, UID uid) { switch(tag) { case 0x3F05: dprintf(NULL, "EditUnitByteCount %d\n", get_be32(pb)); break; @@ -520,29 +530,26 @@ static int mxf_read_index_table_segment(MXFIndexTableSegment *segment, ByteIOCon static void mxf_read_pixel_layout(ByteIOContext *pb, MXFDescriptor *descriptor) { - int code; + int code, value, ofs = 0; + char layout[16] = {}; do { code = get_byte(pb); + value = get_byte(pb); dprintf(NULL, "pixel layout: code %#x\n", code); - switch (code) { - case 0x52: /* R */ - descriptor->bits_per_sample += get_byte(pb); - break; - case 0x47: /* G */ - descriptor->bits_per_sample += get_byte(pb); - break; - case 0x42: /* B */ - descriptor->bits_per_sample += get_byte(pb); - break; - default: - get_byte(pb); + + if (ofs < 16) { + layout[ofs++] = code; + layout[ofs++] = value; } } while (code != 0); /* SMPTE 377M E.2.46 */ + + ff_mxf_decode_pixel_layout(layout, &descriptor->pix_fmt); } -static int mxf_read_generic_descriptor(MXFDescriptor *descriptor, ByteIOContext *pb, int tag, int size, UID uid) +static int mxf_read_generic_descriptor(void *arg, ByteIOContext *pb, int tag, int size, UID uid) { + MXFDescriptor *descriptor = arg; switch(tag) { case 0x3F01: descriptor->sub_descriptors_count = get_be32(pb); @@ -801,7 +808,8 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) st->codec->codec_id = container_ul->id; st->codec->width = descriptor->width; st->codec->height = descriptor->height; - st->codec->bits_per_coded_sample = descriptor->bits_per_sample; /* Uncompressed */ + if (st->codec->codec_id == CODEC_ID_RAWVIDEO) + st->codec->pix_fmt = descriptor->pix_fmt; st->need_parsing = AVSTREAM_PARSE_HEADERS; } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { container_ul = mxf_get_codec_ul(mxf_essence_container_uls, essence_container_ul); @@ -854,7 +862,7 @@ static const MXFMetadataReadTableEntry mxf_metadata_read_table[] = { { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, NULL, 0, AnyType }, }; -static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, int (*read_child)(), int ctx_size, enum MXFMetadataSetType type) +static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadFunc *read_child, int ctx_size, enum MXFMetadataSetType type) { ByteIOContext *pb = mxf->fc->pb; MXFMetadataSet *ctx = ctx_size ? av_mallocz(ctx_size) : mxf; @@ -922,8 +930,12 @@ static int mxf_read_header(AVFormatContext *s, AVFormatParameters *ap) for (metadata = mxf_metadata_read_table; metadata->read; metadata++) { if (IS_KLV_KEY(klv.key, metadata->key)) { - int (*read)() = klv.key[5] == 0x53 ? mxf_read_local_tags : metadata->read; - if (read(mxf, &klv, metadata->read, metadata->ctx_size, metadata->type) < 0) { + int res; + if (klv.key[5] == 0x53) { + res = mxf_read_local_tags(mxf, &klv, metadata->read, metadata->ctx_size, metadata->type); + } else + res = metadata->read(mxf, s->pb, 0, 0, NULL); + if (res < 0) { av_log(s, AV_LOG_ERROR, "error reading header metadata\n"); return -1; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxfenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxfenc.c index 6ca7ee8c0..6c82339e7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxfenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/mxfenc.c @@ -58,6 +58,7 @@ typedef struct { uint8_t flags; uint64_t offset; unsigned slice_offset; ///< offset of audio slice + uint16_t temporal_ref; } MXFIndexEntry; typedef struct { @@ -1039,8 +1040,7 @@ static void mxf_write_index_table_segment(AVFormatContext *s) { MXFContext *mxf = s->priv_data; ByteIOContext *pb = s->pb; - int i, j; - int temporal_reordering = 0; + int i, j, temporal_reordering = 0; int key_index = mxf->last_key_index; av_log(s, AV_LOG_DEBUG, "edit units count %d\n", mxf->edit_units_count); @@ -1122,32 +1122,29 @@ static void mxf_write_index_table_segment(AVFormatContext *s) mxf_write_local_tag(pb, 8 + mxf->edit_units_count*(11+mxf->slice_count*4), 0x3F0A); put_be32(pb, mxf->edit_units_count); // num of entries put_be32(pb, 11+mxf->slice_count*4); // size of one entry + for (i = 0; i < mxf->edit_units_count; i++) { int temporal_offset = 0; + + if (!(mxf->index_entries[i].flags & 0x33)) { // I frame + mxf->last_key_index = key_index; + key_index = i; + } + if (temporal_reordering) { - for (j = i+1; j < mxf->edit_units_count; j++) { - temporal_offset++; - if (mxf->index_entries[j].flags & 0x10) { // backward prediction - // next is not b, so is reordered - if (!(mxf->index_entries[i+1].flags & 0x10)) { - if ((mxf->index_entries[i].flags & 0x11) == 0) // I frame - temporal_offset = 0; - else - temporal_offset = -temporal_offset; - } - break; + int pic_num_in_gop = i - key_index; + if (pic_num_in_gop != mxf->index_entries[i].temporal_ref) { + for (j = key_index; j < mxf->edit_units_count; j++) { + if (pic_num_in_gop == mxf->index_entries[j].temporal_ref) + break; } + if (j == mxf->edit_units_count) + av_log(s, AV_LOG_WARNING, "missing frames\n"); + temporal_offset = j - key_index - pic_num_in_gop; } } put_byte(pb, temporal_offset); - if (!(mxf->index_entries[i].flags & 0x33)) { // I frame - if (mxf->index_entries[i].flags & 0x40 && // seq header - (!temporal_reordering || !temporal_offset)) - mxf->index_entries[i].flags |= 0x80; // random access - mxf->last_key_index = key_index; - key_index = i; - } if ((mxf->index_entries[i].flags & 0x30) == 0x30) { // back and forward prediction put_byte(pb, mxf->last_key_index - i); } else { @@ -1155,6 +1152,10 @@ static void mxf_write_index_table_segment(AVFormatContext *s) if ((mxf->index_entries[i].flags & 0x20) == 0x20) // only forward mxf->last_key_index = key_index; } + + if (!(mxf->index_entries[i].flags & 0x33) && // I frame + mxf->index_entries[i].flags & 0x40 && !temporal_offset) + mxf->index_entries[i].flags |= 0x80; // random access put_byte(pb, mxf->index_entries[i].flags); // stream offset put_be64(pb, mxf->index_entries[i].offset); @@ -1303,15 +1304,14 @@ static const UID *mxf_get_mpeg2_codec_ul(AVCodecContext *avctx) return NULL; } -static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st, AVPacket *pkt, int *flags) +static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st, + AVPacket *pkt, MXFIndexEntry *e) { MXFStreamContext *sc = st->priv_data; MXFContext *mxf = s->priv_data; uint32_t c = -1; int i; - *flags = 0; - for(i = 0; i < pkt->size - 4; i++) { c = (c<<8) + pkt->data[i]; if (c == 0x1b5) { @@ -1325,8 +1325,8 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st, AVPacket *pkt } else if (c == 0x1b8) { // gop if (pkt->data[i+4]>>6 & 0x01) { // closed sc->closed_gop = 1; - if (*flags & 0x40) // sequence header present - *flags |= 0x80; // random access + if (e->flags & 0x40) // sequence header present + e->flags |= 0x80; // random access } if (!mxf->header_written) { unsigned hours = (pkt->data[i+1]>>2) & 0x1f; @@ -1344,7 +1344,7 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st, AVPacket *pkt hours, minutes, seconds, mxf->timecode_drop_frame ? ';':':', frames); } } else if (c == 0x1b3) { // seq - *flags |= 0x40; + e->flags |= 0x40; switch ((pkt->data[i+4]>>4) & 0xf) { case 2: sc->aspect_ratio = (AVRational){ 4, 3}; break; case 3: sc->aspect_ratio = (AVRational){ 16, 9}; break; @@ -1355,14 +1355,15 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st, AVPacket *pkt } } else if (c == 0x100) { // pic int pict_type = (pkt->data[i+2]>>3) & 0x07; + e->temporal_ref = (pkt->data[i+1]<<2) | (pkt->data[i+2]>>6); if (pict_type == 2) { // P frame - *flags |= 0x22; + e->flags |= 0x22; sc->closed_gop = 0; // reset closed gop, don't matter anymore } else if (pict_type == 3) { // B frame if (sc->closed_gop) - *flags |= 0x13; // only backward prediction + e->flags |= 0x13; // only backward prediction else - *flags |= 0x33; + e->flags |= 0x33; sc->temporal_reordering = -1; } else if (!pict_type) { av_log(s, AV_LOG_ERROR, "error parsing mpeg2 frame\n"); @@ -1660,7 +1661,7 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt) ByteIOContext *pb = s->pb; AVStream *st = s->streams[pkt->stream_index]; MXFStreamContext *sc = st->priv_data; - int flags = 0; + MXFIndexEntry ie = {0}; if (!mxf->edit_unit_byte_count && !(mxf->edit_units_count % EDIT_UNITS_PER_BODY)) { mxf->index_entries = av_realloc(mxf->index_entries, @@ -1672,7 +1673,7 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt) } if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO) { - if (!mxf_parse_mpeg2_frame(s, st, pkt, &flags)) { + if (!mxf_parse_mpeg2_frame(s, st, pkt, &ie)) { av_log(s, AV_LOG_ERROR, "could not get mpeg2 profile and level\n"); return -1; } @@ -1692,7 +1693,7 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt) if (st->index == 0) { if (!mxf->edit_unit_byte_count && (!mxf->edit_units_count || mxf->edit_units_count > EDIT_UNITS_PER_BODY) && - !(flags & 0x33)) { // I frame, Gop start + !(ie.flags & 0x33)) { // I frame, Gop start mxf_write_klv_fill(s); mxf_write_partition(s, 1, 2, body_partition_key, 0); @@ -1705,7 +1706,8 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt) if (!mxf->edit_unit_byte_count) { mxf->index_entries[mxf->edit_units_count].offset = mxf->body_offset; - mxf->index_entries[mxf->edit_units_count].flags = flags; + mxf->index_entries[mxf->edit_units_count].flags = ie.flags; + mxf->index_entries[mxf->edit_units_count].temporal_ref = ie.temporal_ref; mxf->body_offset += KAG_SIZE; // size of system element } mxf->edit_units_count++; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/nutdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/nutdec.c index eed644cd6..1b616dee4 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/nutdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/nutdec.c @@ -94,8 +94,8 @@ static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int calculate_ch int64_t size; // start= url_ftell(bc) - 8; - startcode= be2me_64(startcode); - startcode= ff_crc04C11DB7_update(0, &startcode, 8); + startcode= av_be2ne64(startcode); + startcode= ff_crc04C11DB7_update(0, (uint8_t*)&startcode, 8); init_checksum(bc, ff_crc04C11DB7_update, startcode); size= ff_get_v(bc); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/nutenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/nutenc.c index 061cd870d..87a7900b4 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/nutenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/nutenc.c @@ -241,52 +241,31 @@ static void build_frame_code(AVFormatContext *s){ nut->frame_code['N'].flags= FLAG_INVALID; } -/** - * Gets the length in bytes which is needed to store val as v. - */ -static int get_length(uint64_t val){ - int i=1; - - while(val>>=7) - i++; - - return i; -} - -static void put_v(ByteIOContext *bc, uint64_t val){ - int i= get_length(val); - - while(--i>0) - put_byte(bc, 128 | (val>>(7*i))); - - put_byte(bc, val&127); -} - static void put_tt(NUTContext *nut, StreamContext *nus, ByteIOContext *bc, uint64_t val){ val *= nut->time_base_count; val += nus->time_base - nut->time_base; - put_v(bc, val); + ff_put_v(bc, val); } /** - * Stores a string as vb. + * Store a string as vb. */ static void put_str(ByteIOContext *bc, const char *string){ int len= strlen(string); - put_v(bc, len); + ff_put_v(bc, len); put_buffer(bc, string, len); } static void put_s(ByteIOContext *bc, int64_t val){ - put_v(bc, 2*FFABS(val) - (val>0)); + ff_put_v(bc, 2*FFABS(val) - (val>0)); } #ifdef TRACE -static inline void put_v_trace(ByteIOContext *bc, uint64_t v, char *file, char *func, int line){ - av_log(NULL, AV_LOG_DEBUG, "put_v %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line); +static inline void ff_put_v_trace(ByteIOContext *bc, uint64_t v, char *file, char *func, int line){ + av_log(NULL, AV_LOG_DEBUG, "ff_put_v %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line); - put_v(bc, v); + ff_put_v(bc, v); } static inline void put_s_trace(ByteIOContext *bc, int64_t v, char *file, char *func, int line){ @@ -294,7 +273,7 @@ static inline void put_s_trace(ByteIOContext *bc, int64_t v, char *file, char *f put_s(bc, v); } -#define put_v(bc, v) put_v_trace(bc, v, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define ff_put_v(bc, v) ff_put_v_trace(bc, v, __FILE__, __PRETTY_FUNCTION__, __LINE__) #define put_s(bc, v) put_s_trace(bc, v, __FILE__, __PRETTY_FUNCTION__, __LINE__) #endif @@ -307,7 +286,7 @@ static void put_packet(NUTContext *nut, ByteIOContext *bc, ByteIOContext *dyn_bc if(forw_ptr > 4096) init_checksum(bc, ff_crc04C11DB7_update, 0); put_be64(bc, startcode); - put_v(bc, forw_ptr); + ff_put_v(bc, forw_ptr); if(forw_ptr > 4096) put_le32(bc, get_checksum(bc)); @@ -324,14 +303,14 @@ static void write_mainheader(NUTContext *nut, ByteIOContext *bc){ int i, j, tmp_pts, tmp_flags, tmp_stream, tmp_mul, tmp_size, tmp_fields, tmp_head_idx; int64_t tmp_match; - put_v(bc, 3); /* version */ - put_v(bc, nut->avf->nb_streams); - put_v(bc, nut->max_distance); - put_v(bc, nut->time_base_count); + ff_put_v(bc, 3); /* version */ + ff_put_v(bc, nut->avf->nb_streams); + ff_put_v(bc, nut->max_distance); + ff_put_v(bc, nut->time_base_count); for(i=0; itime_base_count; i++){ - put_v(bc, nut->time_base[i].num); - put_v(bc, nut->time_base[i].den); + ff_put_v(bc, nut->time_base[i].num); + ff_put_v(bc, nut->time_base[i].den); } tmp_pts=0; @@ -373,20 +352,20 @@ static void write_mainheader(NUTContext *nut, ByteIOContext *bc){ } if(j != tmp_mul - tmp_size) tmp_fields=6; - put_v(bc, tmp_flags); - put_v(bc, tmp_fields); + ff_put_v(bc, tmp_flags); + ff_put_v(bc, tmp_fields); if(tmp_fields>0) put_s(bc, tmp_pts); - if(tmp_fields>1) put_v(bc, tmp_mul); - if(tmp_fields>2) put_v(bc, tmp_stream); - if(tmp_fields>3) put_v(bc, tmp_size); - if(tmp_fields>4) put_v(bc, 0 /*tmp_res*/); - if(tmp_fields>5) put_v(bc, j); - if(tmp_fields>6) put_v(bc, tmp_match); - if(tmp_fields>7) put_v(bc, tmp_head_idx); + if(tmp_fields>1) ff_put_v(bc, tmp_mul); + if(tmp_fields>2) ff_put_v(bc, tmp_stream); + if(tmp_fields>3) ff_put_v(bc, tmp_size); + if(tmp_fields>4) ff_put_v(bc, 0 /*tmp_res*/); + if(tmp_fields>5) ff_put_v(bc, j); + if(tmp_fields>6) ff_put_v(bc, tmp_match); + if(tmp_fields>7) ff_put_v(bc, tmp_head_idx); } - put_v(bc, nut->header_count-1); + ff_put_v(bc, nut->header_count-1); for(i=1; iheader_count; i++){ - put_v(bc, nut->header_len[i]); + ff_put_v(bc, nut->header_len[i]); put_buffer(bc, nut->header[i], nut->header_len[i]); } } @@ -394,14 +373,14 @@ static void write_mainheader(NUTContext *nut, ByteIOContext *bc){ static int write_streamheader(AVFormatContext *avctx, ByteIOContext *bc, AVStream *st, int i){ NUTContext *nut = avctx->priv_data; AVCodecContext *codec = st->codec; - put_v(bc, i); + ff_put_v(bc, i); switch(codec->codec_type){ - case AVMEDIA_TYPE_VIDEO: put_v(bc, 0); break; - case AVMEDIA_TYPE_AUDIO: put_v(bc, 1); break; - case AVMEDIA_TYPE_SUBTITLE: put_v(bc, 2); break; - default : put_v(bc, 3); break; + case AVMEDIA_TYPE_VIDEO: ff_put_v(bc, 0); break; + case AVMEDIA_TYPE_AUDIO: ff_put_v(bc, 1); break; + case AVMEDIA_TYPE_SUBTITLE: ff_put_v(bc, 2); break; + default : ff_put_v(bc, 3); break; } - put_v(bc, 4); + ff_put_v(bc, 4); if (codec->codec_tag){ put_le32(bc, codec->codec_tag); } else { @@ -409,33 +388,33 @@ static int write_streamheader(AVFormatContext *avctx, ByteIOContext *bc, AVStrea return AVERROR(EINVAL); } - put_v(bc, nut->stream[i].time_base - nut->time_base); - put_v(bc, nut->stream[i].msb_pts_shift); - put_v(bc, nut->stream[i].max_pts_distance); - put_v(bc, codec->has_b_frames); + ff_put_v(bc, nut->stream[i].time_base - nut->time_base); + ff_put_v(bc, nut->stream[i].msb_pts_shift); + ff_put_v(bc, nut->stream[i].max_pts_distance); + ff_put_v(bc, codec->has_b_frames); put_byte(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */ - put_v(bc, codec->extradata_size); + ff_put_v(bc, codec->extradata_size); put_buffer(bc, codec->extradata, codec->extradata_size); switch(codec->codec_type){ case AVMEDIA_TYPE_AUDIO: - put_v(bc, codec->sample_rate); - put_v(bc, 1); - put_v(bc, codec->channels); + ff_put_v(bc, codec->sample_rate); + ff_put_v(bc, 1); + ff_put_v(bc, codec->channels); break; case AVMEDIA_TYPE_VIDEO: - put_v(bc, codec->width); - put_v(bc, codec->height); + ff_put_v(bc, codec->width); + ff_put_v(bc, codec->height); if(st->sample_aspect_ratio.num<=0 || st->sample_aspect_ratio.den<=0){ - put_v(bc, 0); - put_v(bc, 0); + ff_put_v(bc, 0); + ff_put_v(bc, 0); }else{ - put_v(bc, st->sample_aspect_ratio.num); - put_v(bc, st->sample_aspect_ratio.den); + ff_put_v(bc, st->sample_aspect_ratio.num); + ff_put_v(bc, st->sample_aspect_ratio.den); } - put_v(bc, 0); /* csp type -- unknown */ + ff_put_v(bc, 0); /* csp type -- unknown */ break; default: break; @@ -463,12 +442,12 @@ static int write_globalinfo(NUTContext *nut, ByteIOContext *bc){ while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX))) count += add_info(dyn_bc, t->key, t->value); - put_v(bc, 0); //stream_if_plus1 - put_v(bc, 0); //chapter_id - put_v(bc, 0); //timestamp_start - put_v(bc, 0); //length + ff_put_v(bc, 0); //stream_if_plus1 + ff_put_v(bc, 0); //chapter_id + ff_put_v(bc, 0); //timestamp_start + ff_put_v(bc, 0); //length - put_v(bc, count); + ff_put_v(bc, count); dyn_size= url_close_dyn_buf(dyn_bc, &dyn_buf); put_buffer(bc, dyn_buf, dyn_size); @@ -493,12 +472,12 @@ static int write_streaminfo(NUTContext *nut, ByteIOContext *bc, int stream_id){ dyn_size = url_close_dyn_buf(dyn_bc, &dyn_buf); if (count) { - put_v(bc, stream_id + 1); //stream_id_plus1 - put_v(bc, 0); //chapter_id - put_v(bc, 0); //timestamp_start - put_v(bc, 0); //length + ff_put_v(bc, stream_id + 1); //stream_id_plus1 + ff_put_v(bc, 0); //chapter_id + ff_put_v(bc, 0); //timestamp_start + ff_put_v(bc, 0); //length - put_v(bc, count); + ff_put_v(bc, count); put_buffer(bc, dyn_buf, dyn_size); } @@ -692,7 +671,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt){ if(ret < 0) return ret; put_tt(nut, nus, dyn_bc, pkt->dts); - put_v(dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos)>>4 : 0); + ff_put_v(dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos)>>4 : 0); put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE); ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0/*unused*/, pkt->dts); @@ -728,18 +707,18 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt){ continue; if(flags & FLAG_STREAM_ID) - length+= get_length(pkt->stream_index); + length+= ff_get_v_length(pkt->stream_index); if(pkt->size % fc->size_mul != fc->size_lsb) continue; if(flags & FLAG_SIZE_MSB) - length += get_length(pkt->size / fc->size_mul); + length += ff_get_v_length(pkt->size / fc->size_mul); if(flags & FLAG_CHECKSUM) length+=4; if(flags & FLAG_CODED_PTS) - length += get_length(coded_pts); + length += ff_get_v_length(coded_pts); if( (flags & FLAG_CODED) && nut->header_len[best_header_idx] > nut->header_len[fc->header_idx]+1){ @@ -770,13 +749,13 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt){ init_checksum(bc, ff_crc04C11DB7_update, 0); put_byte(bc, frame_code); if(flags & FLAG_CODED){ - put_v(bc, (flags^needed_flags) & ~(FLAG_CODED)); + ff_put_v(bc, (flags^needed_flags) & ~(FLAG_CODED)); flags = needed_flags; } - if(flags & FLAG_STREAM_ID) put_v(bc, pkt->stream_index); - if(flags & FLAG_CODED_PTS) put_v(bc, coded_pts); - if(flags & FLAG_SIZE_MSB) put_v(bc, pkt->size / fc->size_mul); - if(flags & FLAG_HEADER_IDX) put_v(bc, header_idx= best_header_idx); + if(flags & FLAG_STREAM_ID) ff_put_v(bc, pkt->stream_index); + if(flags & FLAG_CODED_PTS) ff_put_v(bc, coded_pts); + if(flags & FLAG_SIZE_MSB) ff_put_v(bc, pkt->size / fc->size_mul); + if(flags & FLAG_HEADER_IDX) ff_put_v(bc, header_idx= best_header_idx); if(flags & FLAG_CHECKSUM) put_le32(bc, get_checksum(bc)); else get_checksum(bc); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/nuv.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/nuv.c index 2aa0bb4cc..f0eacd5f8 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/nuv.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/nuv.c @@ -218,18 +218,12 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) { ret = av_new_packet(pkt, copyhdrsize + size); if (ret < 0) return ret; - // HACK: we have no idea if it is a keyframe, // but if we mark none seeking will not work at all. pkt->flags |= AV_PKT_FLAG_KEY; pkt->pos = pos; pkt->pts = AV_RL32(&hdr[4]); pkt->stream_index = ctx->v_id; - if(hdr[2] == 0) { - AVStream *st = s->streams[pkt->stream_index]; - pkt->flags |= PKT_FLAG_KEY; - av_add_index_entry(st, pkt->pos, pkt->pts, size + HDRSIZE, 0, AVINDEX_KEYFRAME); - } memcpy(pkt->data, hdr, copyhdrsize); ret = get_buffer(pb, pkt->data + copyhdrsize, size); if (ret < 0) { @@ -263,83 +257,6 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) { return AVERROR(EIO); } -/** - * \brief looks for the string RTjjjjjjjjjj in the stream too resync reading - * \return TRUE if the syncword is found. - */ -static int nuv_resync(AVFormatContext *s, int64_t pos_limit) { - ByteIOContext *pb = s->pb; - uint32_t tag; - - tag = get_be32(pb); - while(!url_feof(pb) && url_ftell(pb) < pos_limit) { - if(tag != MKBETAG('R','T','j','j')) { - tag = (tag << 8) | get_byte(pb); - continue; - } - tag = get_be32(pb); - if(tag != MKBETAG('j','j','j','j')) - continue; - - tag = get_be32(pb); - if(tag != MKBETAG('j','j','j','j')) - continue; - - return 1; - } - return 0; -} - -/** - * \brief attempts to read a timestamp from stream at the given stream position - * \return timestamp if successfull and AV_NOPTS_VALUE if failure - */ -static int64_t nuv_read_dts(AVFormatContext *s, int stream_index, - int64_t *ppos, int64_t pos_limit) -{ - NUVContext *ctx = s->priv_data; - ByteIOContext *pb = s->pb; - uint8_t hdr[HDRSIZE]; - nuv_frametype frametype; - int size; - int64_t pos, dts; - - if (url_fseek(pb, *ppos, SEEK_SET) < 0) - return AV_NOPTS_VALUE; - - if (!nuv_resync(s, pos_limit)) - return AV_NOPTS_VALUE; - - while (!url_feof(pb) && url_ftell(pb) < pos_limit) { - if (get_buffer(pb, hdr, HDRSIZE) <= 0) - return AV_NOPTS_VALUE; - frametype = hdr[0]; - size = PKTSIZE(AV_RL32(&hdr[8])); - switch (frametype) { - case NUV_SEEKP: - break; - case NUV_AUDIO: - case NUV_VIDEO: - pos = url_ftell(s->pb) - HDRSIZE; - dts = AV_RL32(&hdr[4]); - // TODO - add general support in av_gen_search, so it adds positions after reading timestamps - av_add_index_entry(s->streams[frametype == NUV_VIDEO ? ctx->v_id : ctx->a_id] - , pos, dts, size + HDRSIZE, 0, hdr[2] == 0 ? AVINDEX_KEYFRAME : 0); - - if ((frametype == NUV_VIDEO && stream_index == ctx->v_id) || - (frametype == NUV_AUDIO && stream_index == ctx->a_id)) { - *ppos = pos; - return dts; - } - default: - url_fskip(pb, size); - break; - } - } - return AV_NOPTS_VALUE; -} - - AVInputFormat nuv_demuxer = { "nuv", NULL_IF_CONFIG_SMALL("NuppelVideo format"), @@ -349,6 +266,5 @@ AVInputFormat nuv_demuxer = { nuv_packet, NULL, NULL, - nuv_read_dts, .flags = AVFMT_GENERIC_INDEX, }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/oggdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/oggdec.c index 3161e68c6..4c9a43a1c 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/oggdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/oggdec.c @@ -363,7 +363,7 @@ ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize, int64_t *fpo #endif if (os->granule == -1) - av_log(s, AV_LOG_WARNING, "Page at %lld is missing granule\n", os->page_pos); + av_log(s, AV_LOG_WARNING, "Page at %"PRId64" is missing granule\n", os->page_pos); ogg->curidx = idx; os->incomplete = 0; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/oggenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/oggenc.c index a0560acf1..c35b49749 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/oggenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/oggenc.c @@ -44,7 +44,6 @@ typedef struct { unsigned page_counter; uint8_t *header[3]; int header_len[3]; - int free_header; // if the header needs to be freed outside of libvorbis /** for theora granule */ int kfgshift; int64_t last_kf_pts; @@ -212,139 +211,6 @@ static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact, return p0; } -static int ogg_build_comment_header(OGGStreamContext *oggstream, AVMetadata *m) { - uint8_t *p = NULL; - uint32_t i, c; - size_t size; - - uint8_t *packet_type = NULL; - char *packet_magic = NULL; - uint32_t vendor_length = 0; - char *vendor_string = NULL; - uint32_t list_length = 0; - uint32_t *comment_length = NULL; - char *comment_string = NULL; - uint8_t framing_bit = 0; - - int32_t name_size, value_size; - char *name, *value; - - // load the old header in if it is set - if (oggstream->header_len[1] > 0) { - p = oggstream->header[1]; - packet_type = (uint8_t*)p; - p += sizeof(uint8_t); - packet_magic = (char*)p; - p += 6; - - // if the header is a valid vorbis header then read it - if (*packet_type == 3 && strncmp(packet_magic, "vorbis", 6) == 0) { - // copy the vendor so we can re-use it later - vendor_length = *(uint32_t*)p; - p += sizeof(uint32_t); - vendor_string = (char*)av_mallocz(vendor_length + 1); - if (!vendor_string) - return AVERROR_NOMEM; - memcpy(vendor_string, p, vendor_length); - p += vendor_length; - - list_length = *(uint32_t*)p; - p += sizeof(uint32_t); - - for(i = list_length; i > 0; --i) { - comment_length = (uint32_t*)p; - p += sizeof(uint32_t); - - // copy the comment so we can use strtok on it - comment_string = (char*)av_mallocz(*comment_length + 1); - if (!comment_string) { - av_free(vendor_string); - return AVERROR_NOMEM; - } - - memcpy(comment_string, p, *comment_length); - p += *comment_length; - - //split up the comment name & value - name = strtok(comment_string, "="); - value = name + strlen(name) + 1; - - //set the name & value - av_metadata_set2(&m, name, value, 0); - - //clean up - av_free(comment_string); - } - - framing_bit = *(uint8_t*)p; - } - } - - if (!vendor_length) { - vendor_string = (char*)av_mallocz(sizeof(LIBAVFORMAT_IDENT)); - memcpy(vendor_string, LIBAVFORMAT_IDENT, sizeof(LIBAVFORMAT_IDENT) - 1); - vendor_length = sizeof(LIBAVFORMAT_IDENT) - 1; - framing_bit = 1; - } - - // calculate the total header size - size = 7; // packet_type + packet_magic - size += sizeof(uint32_t) + vendor_length; - size += sizeof(uint32_t); // list length - if (m) - for(c = 0; c < m->count; ++c) - size += sizeof(uint32_t) + strlen(m->elems[c].key) + 1 + strlen(m->elems[c].value); - size += 1; // framing bit - - // allocate a new header - oggstream->header_len[1] = size; - oggstream->header [1] = (uint8_t*)av_mallocz(size); - if (!oggstream->header[1]) { - oggstream->header_len[1] = 0; - av_free(vendor_string); - return AVERROR_NOMEM; - } - - oggstream->free_header = 1; - - // setup the new header - p = oggstream->header[1]; - *(uint8_t*)p = 3; - p += sizeof(uint8_t); - memcpy(p, "vorbis", 6); - p += 6; - - // write the vendor length and string - *(uint32_t*)p = vendor_length; - p += sizeof(uint32_t); - memcpy(p, vendor_string, vendor_length); - p += vendor_length; - - // write the comments - *(uint32_t*)p = m ? m->count : 0; - p += sizeof(uint32_t); - if (m) - for(c = 0; c < m->count; ++c) { - name_size = strlen(m->elems[c].key ); - value_size = strlen(m->elems[c].value); - *(uint32_t*)p = name_size + 1 + value_size; - p += sizeof(uint32_t); - memcpy(p, m->elems[c].key, name_size); - p += name_size; - *(char*)p = '='; - ++p; - memcpy(p, m->elems[c].value, value_size); - p += value_size; - } - - // write the framing bit - *(uint8_t*)p = framing_bit; - - // clean up and return success - av_free(vendor_string); - return 0; -} - static int ogg_build_flac_headers(AVCodecContext *avctx, OGGStreamContext *oggstream, int bitexact, AVMetadata *m) @@ -415,7 +281,7 @@ static int ogg_build_speex_headers(AVCodecContext *avctx, static int ogg_write_header(AVFormatContext *s) { OGGStreamContext *oggstream; - int i, j, err; + int i, j; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; @@ -453,7 +319,7 @@ static int ogg_write_header(AVFormatContext *s) st->priv_data = oggstream; if (st->codec->codec_id == CODEC_ID_FLAC) { - err = ogg_build_flac_headers(st->codec, oggstream, + int err = ogg_build_flac_headers(st->codec, oggstream, st->codec->flags & CODEC_FLAG_BITEXACT, s->metadata); if (err) { @@ -462,7 +328,7 @@ static int ogg_write_header(AVFormatContext *s) return err; } } else if (st->codec->codec_id == CODEC_ID_SPEEX) { - err = ogg_build_speex_headers(st->codec, oggstream, + int err = ogg_build_speex_headers(st->codec, oggstream, st->codec->flags & CODEC_FLAG_BITEXACT, s->metadata); if (err) { @@ -486,13 +352,6 @@ static int ogg_write_header(AVFormatContext *s) av_log(s, AV_LOG_DEBUG, "theora kfgshift %d, vrev %d\n", oggstream->kfgshift, oggstream->vrev); } - - err = ogg_build_comment_header(oggstream, s->metadata); - if (err) { - av_log(s, AV_LOG_ERROR, "Error writing Vorbis comment header\n"); - av_freep(&st->priv_data); - return err; - } } } @@ -582,9 +441,6 @@ static int ogg_write_trailer(AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; OGGStreamContext *oggstream = st->priv_data; - if (oggstream->free_header) - av_free(oggstream->header[1]); - else if (st->codec->codec_id == CODEC_ID_FLAC || st->codec->codec_id == CODEC_ID_SPEEX) { av_free(oggstream->header[0]); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/oma.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/oma.c index c12365e10..a47fde02f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/oma.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/oma.c @@ -27,7 +27,8 @@ * * Known file extensions: ".oma", "aa3" * The format of such files consists of three parts: - * - "ea3" header carrying overall info and metadata. + * - "ea3" header carrying overall info and metadata. Except for starting with + * "ea" instead of "ID", it's an ID3v2 header. * - "EA3" header is a Sony-specific header containing information about * the OpenMG file: codec type (usually ATRAC, can also be MP3 or WMA), * codec specific info (packet size, sample rate, channels and so on) @@ -46,6 +47,7 @@ #include "libavutil/intreadwrite.h" #include "raw.h" #include "riff.h" +#include "id3v2.h" #define EA3_HEADER_SIZE 96 @@ -63,36 +65,21 @@ static const AVCodecTag codec_oma_tags[] = { { CODEC_ID_MP3, OMA_CODECID_MP3 }, }; +#define ID3v2_EA3_MAGIC "ea3" + static int oma_read_header(AVFormatContext *s, AVFormatParameters *ap) { static const uint16_t srate_tab[6] = {320,441,480,882,960,0}; - int ret, ea3_taglen, EA3_pos, framesize, jsflag, samplerate; + int ret, framesize, jsflag, samplerate; uint32_t codec_params; int16_t eid; uint8_t buf[EA3_HEADER_SIZE]; uint8_t *edata; AVStream *st; - ret = get_buffer(s->pb, buf, 10); - if (ret != 10) - return -1; - - if(!memcmp(buf, "ea3", 3)) { - ea3_taglen = ((buf[6] & 0x7f) << 21) | ((buf[7] & 0x7f) << 14) | ((buf[8] & 0x7f) << 7) | (buf[9] & 0x7f); - - EA3_pos = ea3_taglen + 10; - if (buf[5] & 0x10) - EA3_pos += 10; - - url_fseek(s->pb, EA3_pos, SEEK_SET); - ret = get_buffer(s->pb, buf, EA3_HEADER_SIZE); - if (ret != EA3_HEADER_SIZE) - return -1; - } else { - ret = get_buffer(s->pb, buf + 10, EA3_HEADER_SIZE - 10); - EA3_pos = 0; - } + ff_id3v2_read(s, ID3v2_EA3_MAGIC); + ret = get_buffer(s->pb, buf, EA3_HEADER_SIZE); if (memcmp(buf, ((const uint8_t[]){'E', 'A', '3'}),3) || buf[4] != 0 || buf[5] != EA3_HEADER_SIZE) { av_log(s, AV_LOG_ERROR, "Couldn't find the EA3 header !\n"); @@ -163,7 +150,6 @@ static int oma_read_header(AVFormatContext *s, } st->codec->block_align = framesize; - url_fseek(s->pb, EA3_pos + EA3_HEADER_SIZE, SEEK_SET); return 0; } @@ -182,9 +168,21 @@ static int oma_read_packet(AVFormatContext *s, AVPacket *pkt) static int oma_read_probe(AVProbeData *p) { - if (!memcmp(p->buf, ((const uint8_t[]){'e', 'a', '3', 3, 0}), 5) || - (!memcmp(p->buf, "EA3", 3) && - !p->buf[4] && p->buf[5] == EA3_HEADER_SIZE)) + const uint8_t *buf; + unsigned tag_len = 0; + + buf = p->buf; + /* version must be 3 and flags byte zero */ + if (ff_id3v2_match(buf, ID3v2_EA3_MAGIC) && buf[3] == 3 && !buf[4]) + tag_len = ff_id3v2_tag_len(buf); + + // This check cannot overflow as tag_len has at most 28 bits + if (p->buf_size < tag_len + 5) + return 0; + + buf += tag_len; + + if (!memcmp(buf, "EA3", 3) && !buf[4] && buf[5] == EA3_HEADER_SIZE) return AVPROBE_SCORE_MAX; else return 0; @@ -203,5 +201,6 @@ AVInputFormat oma_demuxer = { .flags= AVFMT_GENERIC_INDEX, .extensions = "oma,aa3", .codec_tag= (const AVCodecTag* const []){codec_oma_tags, 0}, + .metadata_conv = ff_id3v2_metadata_conv, }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/options.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/options.c index 0c1ac2d86..6a7f908fe 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/options.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/options.c @@ -48,7 +48,7 @@ static const AVOption options[]={ {"genpts", "generate pts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_GENPTS, INT_MIN, INT_MAX, D, "fflags"}, {"nofillin", "do not fill in missing values that can be exactly calculated", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_NOFILLIN, INT_MIN, INT_MAX, D, "fflags"}, {"noparse", "disable AVParsers, this needs nofillin too", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_NOPARSE, INT_MIN, INT_MAX, D, "fflags"}, -{"igndts", "ingore dts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_IGNDTS, INT_MIN, INT_MAX, D, "fflags"}, +{"igndts", "ignore dts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_IGNDTS, INT_MIN, INT_MAX, D, "fflags"}, {"rtphint", "add rtp hinting", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_RTP_HINT, INT_MIN, INT_MAX, E, "fflags"}, #if LIBAVFORMAT_VERSION_INT < (53<<16) {"track", " set the track number", OFFSET(track), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E}, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/os_support.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/os_support.c index 27863031d..83f082066 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/os_support.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/os_support.c @@ -26,13 +26,13 @@ #include "config.h" #include "avformat.h" -#include -#include -#include #include "os_support.h" #if CONFIG_NETWORK +#include +#include #if !HAVE_POLL_H +#include #if HAVE_WINSOCK2_H #include #elif HAVE_SYS_SELECT_H diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/os_support.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/os_support.h index a3cc40a85..5c9e81b34 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/os_support.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/os_support.h @@ -45,23 +45,6 @@ static inline int is_dos_path(const char *path) return 0; } -#ifdef __BEOS__ -# include -# include - /* not net_server ? */ -# include - /* R5 didn't have usleep, fake it. Haiku and Zeta has it now. */ -# if B_BEOS_VERSION <= B_BEOS_VERSION_5 -# include - /* doesn't set errno but that's enough */ -# define usleep(t) snooze((bigtime_t)(t)) -# endif -# ifndef SA_RESTART -# warning SA_RESTART not implemented; ffserver might misbehave. -# define SA_RESTART 0 -# endif -#endif - #if CONFIG_NETWORK #if !HAVE_SOCKLEN_T typedef int socklen_t; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/output-example.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/output-example.c index dd61cfe08..15e2d9ac9 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/output-example.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/output-example.c @@ -68,6 +68,7 @@ static AVStream *add_audio_stream(AVFormatContext *oc, enum CodecID codec_id) c->codec_type = AVMEDIA_TYPE_AUDIO; /* put sample parameters */ + c->sample_fmt = SAMPLE_FMT_S16; c->bit_rate = 64000; c->sample_rate = 44100; c->channels = 2; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/raw.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/raw.c index 7837de842..0c83c429b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/raw.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/raw.c @@ -283,6 +283,7 @@ static int video_read_header(AVFormatContext *s, st->codec->codec_id == CODEC_ID_MPEG4 || st->codec->codec_id == CODEC_ID_DIRAC || st->codec->codec_id == CODEC_ID_DNXHD || + st->codec->codec_id == CODEC_ID_VC1 || st->codec->codec_id == CODEC_ID_H264) { st->codec->time_base= (AVRational){1,25}; } @@ -456,6 +457,7 @@ static int h263_probe(AVProbeData *p) int invalid_psc=0; int res_change=0; int src_fmt, last_src_fmt=-1; + int last_gn=0; for(i=0; ibuf_size; i++){ code = (code<<8) + p->buf[i]; @@ -468,9 +470,16 @@ static int h263_probe(AVProbeData *p) if((code&0x300)==0x200 && src_fmt){ valid_psc++; + last_gn=0; }else invalid_psc++; last_src_fmt= src_fmt; + } else if((code & 0xffff800000) == 0x800000) { + int gn= (code>>(23-5)) & 0x1F; + if(gnbuf_size - 7; - if (ff_id3v2_match(buf0)) { + if (ff_id3v2_match(buf0, ID3v2_DEFAULT_MAGIC)) { buf0 += ff_id3v2_tag_len(buf0); } buf = buf0; @@ -705,7 +714,7 @@ static int adts_aac_read_header(AVFormatContext *s, st->need_parsing = AVSTREAM_PARSE_FULL; ff_id3v1_read(s); - ff_id3v2_read(s); + ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC); return 0; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rdt.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rdt.c index 7dda3f3d7..284665ee1 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rdt.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rdt.c @@ -140,14 +140,14 @@ rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr) /** * Layout of the MLTI chunk: - * 4:MLTI - * 2: + * 4: MLTI + * 2: number of streams * Then for each stream ([number_of_streams] times): - * 2: - * 2: + * 2: mdpr index + * 2: number of mdpr chunks * Then for each mdpr chunk ([number_of_mdpr_chunks] times): - * 4: - * [size]: + * 4: size + * [size]: data * we skip MDPR chunks until we reach the one of the stream * we're interested in, and forward that ([size]+[data]) to * the RM demuxer to parse the stream-specific header data. diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rdt.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rdt.h index 1592c2f02..8117989d2 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rdt.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rdt.h @@ -85,7 +85,7 @@ void ff_rdt_subscribe_rule(char *cmd, int size, * @param stream_id will be set to the stream ID this packet belongs to * @param is_keyframe will be whether this packet belongs to a keyframe * @param timestamp will be set to the timestamp of the packet - * @return the amount of bytes consumed, or <0 on error + * @return the amount of bytes consumed, or negative on error */ int ff_rdt_parse_header(const uint8_t *buf, int len, int *set_id, int *seq_no, int *stream_id, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rmdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rmdec.c index 4ab4457db..436a7e08f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rmdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rmdec.c @@ -294,17 +294,18 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb, goto fail1; st->codec->width = get_be16(pb); st->codec->height = get_be16(pb); - st->codec->time_base.num= 1 << 16; + st->codec->time_base.num= 1; fps= get_be16(pb); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; get_be32(pb); - fps2= get_be32(pb); + fps2= get_be16(pb); + get_be16(pb); if ((ret = rm_read_extradata(pb, st->codec, codec_data_size - (url_ftell(pb) - codec_pos))) < 0) return ret; // av_log(s, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2); - st->codec->time_base.den = fps2; + st->codec->time_base.den = fps * st->codec->time_base.num; //XXX: do we really need that? switch(st->codec->extradata[4]>>4){ case 1: st->codec->codec_id = CODEC_ID_RV10; break; @@ -903,9 +904,7 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index, if(rm->old_format) return AV_NOPTS_VALUE; - if (url_fseek(s->pb, pos, SEEK_SET) < 0) - return AV_NOPTS_VALUE; - + url_fseek(s->pb, pos, SEEK_SET); rm->remaining_len=0; for(;;){ int seq=1; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtmppkt.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtmppkt.h index 23d4ebcd0..431095d39 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtmppkt.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtmppkt.h @@ -83,7 +83,7 @@ typedef struct RTMPPacket { } RTMPPacket; /** - * Creates new RTMP packet with given attributes. + * Create new RTMP packet with given attributes. * * @param pkt packet * @param channel_id packet channel ID @@ -96,14 +96,14 @@ int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type, int timestamp, int size); /** - * Frees RTMP packet. + * Free RTMP packet. * * @param pkt packet */ void ff_rtmp_packet_destroy(RTMPPacket *pkt); /** - * Reads RTMP packet sent by the server. + * Read RTMP packet sent by the server. * * @param h reader context * @param p packet @@ -116,7 +116,7 @@ int ff_rtmp_packet_read(URLContext *h, RTMPPacket *p, int chunk_size, RTMPPacket *prev_pkt); /** - * Sends RTMP packet to the server. + * Send RTMP packet to the server. * * @param h reader context * @param p packet to send @@ -129,9 +129,9 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *p, int chunk_size, RTMPPacket *prev_pkt); /** - * Prints information and contents of RTMP packet. + * Print information and contents of RTMP packet. * - * @param h output context + * @param ctx output context * @param p packet to dump */ void ff_rtmp_packet_dump(void *ctx, RTMPPacket *p); @@ -143,7 +143,7 @@ void ff_rtmp_packet_dump(void *ctx, RTMPPacket *p); */ /** - * Calculates number of bytes taken by first AMF entry in data. + * Calculate number of bytes taken by first AMF entry in data. * * @param data input data * @param data_end input buffer end @@ -152,7 +152,7 @@ void ff_rtmp_packet_dump(void *ctx, RTMPPacket *p); int ff_amf_tag_size(const uint8_t *data, const uint8_t *data_end); /** - * Retrieves value of given AMF object field in string form. + * Retrieve value of given AMF object field in string form. * * @param data AMF object data * @param data_end input buffer end @@ -165,7 +165,7 @@ int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end, const uint8_t *name, uint8_t *dst, int dst_size); /** - * Writes boolean value in AMF format to buffer. + * Write boolean value in AMF format to buffer. * * @param dst pointer to the input buffer (will be modified) * @param val value to write @@ -173,7 +173,7 @@ int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end, void ff_amf_write_bool(uint8_t **dst, int val); /** - * Writes number in AMF format to buffer. + * Write number in AMF format to buffer. * * @param dst pointer to the input buffer (will be modified) * @param num value to write @@ -181,7 +181,7 @@ void ff_amf_write_bool(uint8_t **dst, int val); void ff_amf_write_number(uint8_t **dst, double num); /** - * Writes string in AMF format to buffer. + * Write string in AMF format to buffer. * * @param dst pointer to the input buffer (will be modified) * @param str string to write @@ -189,21 +189,21 @@ void ff_amf_write_number(uint8_t **dst, double num); void ff_amf_write_string(uint8_t **dst, const char *str); /** - * Writes AMF NULL value to buffer. + * Write AMF NULL value to buffer. * * @param dst pointer to the input buffer (will be modified) */ void ff_amf_write_null(uint8_t **dst); /** - * Writes marker for AMF object to buffer. + * Write marker for AMF object to buffer. * * @param dst pointer to the input buffer (will be modified) */ void ff_amf_write_object_start(uint8_t **dst); /** - * Writes string used as field name in AMF object to buffer. + * Write string used as field name in AMF object to buffer. * * @param dst pointer to the input buffer (will be modified) * @param str string to write @@ -211,7 +211,7 @@ void ff_amf_write_object_start(uint8_t **dst); void ff_amf_write_field_name(uint8_t **dst, const char *str); /** - * Writes marker for end of AMF object to buffer. + * Write marker for end of AMF object to buffer. * * @param dst pointer to the input buffer (will be modified) */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtmpproto.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtmpproto.c index 1f572320f..aca1fd327 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtmpproto.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtmpproto.c @@ -102,7 +102,7 @@ static const uint8_t rtmp_server_key[] = { }; /** - * Generates 'connect' call and sends it to the server. + * Generate 'connect' call and send it to the server. */ static void gen_connect(URLContext *s, RTMPContext *rt, const char *proto, const char *host, int port) @@ -154,7 +154,7 @@ static void gen_connect(URLContext *s, RTMPContext *rt, const char *proto, } /** - * Generates 'releaseStream' call and sends it to the server. It should make + * Generate 'releaseStream' call and send it to the server. It should make * the server release some channel for media streams. */ static void gen_release_stream(URLContext *s, RTMPContext *rt) @@ -177,7 +177,7 @@ static void gen_release_stream(URLContext *s, RTMPContext *rt) } /** - * Generates 'FCPublish' call and sends it to the server. It should make + * Generate 'FCPublish' call and send it to the server. It should make * the server preapare for receiving media streams. */ static void gen_fcpublish_stream(URLContext *s, RTMPContext *rt) @@ -200,7 +200,7 @@ static void gen_fcpublish_stream(URLContext *s, RTMPContext *rt) } /** - * Generates 'FCUnpublish' call and sends it to the server. It should make + * Generate 'FCUnpublish' call and send it to the server. It should make * the server destroy stream. */ static void gen_fcunpublish_stream(URLContext *s, RTMPContext *rt) @@ -223,7 +223,7 @@ static void gen_fcunpublish_stream(URLContext *s, RTMPContext *rt) } /** - * Generates 'createStream' call and sends it to the server. It should make + * Generate 'createStream' call and send it to the server. It should make * the server allocate some channel for media streams. */ static void gen_create_stream(URLContext *s, RTMPContext *rt) @@ -245,7 +245,7 @@ static void gen_create_stream(URLContext *s, RTMPContext *rt) /** - * Generates 'deleteStream' call and sends it to the server. It should make + * Generate 'deleteStream' call and send it to the server. It should make * the server remove some channel for media streams. */ static void gen_delete_stream(URLContext *s, RTMPContext *rt) @@ -267,7 +267,7 @@ static void gen_delete_stream(URLContext *s, RTMPContext *rt) } /** - * Generates 'play' call and sends it to the server, then pings the server + * Generate 'play' call and send it to the server, then ping the server * to start actual playing. */ static void gen_play(URLContext *s, RTMPContext *rt) @@ -302,7 +302,7 @@ static void gen_play(URLContext *s, RTMPContext *rt) } /** - * Generates 'publish' call and sends it to the server. + * Generate 'publish' call and send it to the server. */ static void gen_publish(URLContext *s, RTMPContext *rt) { @@ -326,7 +326,7 @@ static void gen_publish(URLContext *s, RTMPContext *rt) } /** - * Generates ping reply and sends it to the server. + * Generate ping reply and send it to the server. */ static void gen_pong(URLContext *s, RTMPContext *rt, RTMPPacket *ppkt) { @@ -342,7 +342,7 @@ static void gen_pong(URLContext *s, RTMPContext *rt, RTMPPacket *ppkt) } /** - * Generates report on bytes read so far and sends it to the server. + * Generate report on bytes read so far and send it to the server. */ static void gen_bytes_read(URLContext *s, RTMPContext *rt, uint32_t ts) { @@ -361,7 +361,7 @@ static void gen_bytes_read(URLContext *s, RTMPContext *rt, uint32_t ts) #define HMAC_OPAD_VAL 0x5C /** - * Calculates HMAC-SHA2 digest for RTMP handshake packets. + * Calculate HMAC-SHA2 digest for RTMP handshake packets. * * @param src input buffer * @param len input buffer length (should be 1536) @@ -410,7 +410,7 @@ static void rtmp_calc_digest(const uint8_t *src, int len, int gap, } /** - * Puts HMAC-SHA2 digest of packet data (except for the bytes where this digest + * Put HMAC-SHA2 digest of packet data (except for the bytes where this digest * will be stored) into that packet. * * @param buf handshake data (1536 bytes) @@ -431,7 +431,7 @@ static int rtmp_handshake_imprint_with_digest(uint8_t *buf) } /** - * Verifies that the received server response has the expected digest value. + * Verify that the received server response has the expected digest value. * * @param buf handshake data received from the server (1536 bytes) * @param off position to search digest offset from @@ -455,7 +455,7 @@ static int rtmp_validate_digest(uint8_t *buf, int off) } /** - * Performs handshake with the server by means of exchanging pseudorandom data + * Perform handshake with the server by means of exchanging pseudorandom data * signed with HMAC-SHA2 digest. * * @return 0 if handshake succeeds, negative value otherwise @@ -540,7 +540,7 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt) } /** - * Parses received packet and may perform some action depending on + * Parse received packet and possibly perform some action depending on * the packet contents. * @return 0 for no errors, negative values for serious errors which prevent * further communications, positive values for uncritical errors @@ -666,7 +666,7 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) } /** - * Interacts with the server by receiving and sending RTMP packets until + * Interact with the server by receiving and sending RTMP packets until * there is some significant data (media data or expected status notification). * * @param s reading context @@ -791,7 +791,7 @@ static int rtmp_close(URLContext *h) } /** - * Opens RTMP connection and verifies that the stream can be played. + * Open RTMP connection and verify that the stream can be played. * * URL syntax: rtmp://server[:port][/app][/playpath] * where 'app' is first one or two directories in the path @@ -813,7 +813,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) s->priv_data = rt; rt->is_input = !(flags & URL_WRONLY); - ff_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), &port, + av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), &port, path, sizeof(path), s->filename); if (port < 0) @@ -915,6 +915,7 @@ static int rtmp_read(URLContext *s, uint8_t *buf, int size) buf += data_left; size -= data_left; rt->flv_off = rt->flv_size; + return data_left; } if ((ret = get_packet(s, 0)) < 0) return ret; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec.c index 0d2df59a7..ca06bfff0 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec.c @@ -34,6 +34,8 @@ #include "rtpdec_asf.h" #include "rtpdec_h263.h" #include "rtpdec_h264.h" +#include "rtpdec_mpeg4.h" +#include "rtpdec_svq3.h" #include "rtpdec_xiph.h" //#define DEBUG @@ -50,9 +52,6 @@ /* statistics functions */ RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler= NULL; -static RTPDynamicProtocolHandler mp4v_es_handler= {"MP4V-ES", AVMEDIA_TYPE_VIDEO, CODEC_ID_MPEG4}; -static RTPDynamicProtocolHandler mpeg4_generic_handler= {"mpeg4-generic", AVMEDIA_TYPE_AUDIO, CODEC_ID_AAC}; - void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler) { handler->next= RTPFirstDynamicPayloadHandler; @@ -61,8 +60,8 @@ void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler) void av_register_rtp_dynamic_payload_handlers(void) { - ff_register_dynamic_payload_handler(&mp4v_es_handler); - ff_register_dynamic_payload_handler(&mpeg4_generic_handler); + ff_register_dynamic_payload_handler(&ff_mp4v_es_dynamic_handler); + ff_register_dynamic_payload_handler(&ff_mpeg4_generic_dynamic_handler); ff_register_dynamic_payload_handler(&ff_amr_nb_dynamic_handler); ff_register_dynamic_payload_handler(&ff_amr_wb_dynamic_handler); ff_register_dynamic_payload_handler(&ff_h263_1998_dynamic_handler); @@ -70,6 +69,7 @@ void av_register_rtp_dynamic_payload_handlers(void) ff_register_dynamic_payload_handler(&ff_h264_dynamic_handler); ff_register_dynamic_payload_handler(&ff_vorbis_dynamic_handler); ff_register_dynamic_payload_handler(&ff_theora_dynamic_handler); + ff_register_dynamic_payload_handler(&ff_svq3_dynamic_handler); ff_register_dynamic_payload_handler(&ff_ms_rtp_asf_pfv_handler); ff_register_dynamic_payload_handler(&ff_ms_rtp_asf_pfa_handler); @@ -317,9 +317,8 @@ void rtp_send_punch_packets(URLContext* rtp_handle) * open a new RTP parse context for stream 'st'. 'st' can be NULL for * MPEG2TS streams to indicate that they should be demuxed inside the * rtp demux (otherwise CODEC_ID_MPEG2TS packets are returned) - * TODO: change this to not take rtp_payload data, and use the new dynamic payload system. */ -RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, RTPPayloadData *rtp_payload_data) +RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type) { RTPDemuxContext *s; @@ -331,7 +330,6 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *r s->first_rtcp_ntp_time = AV_NOPTS_VALUE; s->ic = s1; s->st = st; - s->rtp_payload_data = rtp_payload_data; rtp_init_statistics(&s->statistics, 0); // do we know the initial sequence from sdp? if (!strcmp(ff_rtp_enc_name(payload_type), "MP2T")) { s->ts = ff_mpegts_parse_open(s->ic); @@ -372,58 +370,6 @@ rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, s->parse_packet = handler->parse_packet; } -static int rtp_parse_mp4_au(RTPDemuxContext *s, const uint8_t *buf) -{ - int au_headers_length, au_header_size, i; - GetBitContext getbitcontext; - RTPPayloadData *infos; - - infos = s->rtp_payload_data; - - if (infos == NULL) - return -1; - - /* decode the first 2 bytes where the AUHeader sections are stored - length in bits */ - au_headers_length = AV_RB16(buf); - - if (au_headers_length > RTP_MAX_PACKET_LENGTH) - return -1; - - infos->au_headers_length_bytes = (au_headers_length + 7) / 8; - - /* skip AU headers length section (2 bytes) */ - buf += 2; - - init_get_bits(&getbitcontext, buf, infos->au_headers_length_bytes * 8); - - /* XXX: Wrong if optionnal additional sections are present (cts, dts etc...) */ - au_header_size = infos->sizelength + infos->indexlength; - if (au_header_size <= 0 || (au_headers_length % au_header_size != 0)) - return -1; - - infos->nb_au_headers = au_headers_length / au_header_size; - if (!infos->au_headers || infos->au_headers_allocated < infos->nb_au_headers) { - av_free(infos->au_headers); - infos->au_headers = av_malloc(sizeof(struct AUHeaders) * infos->nb_au_headers); - infos->au_headers_allocated = infos->nb_au_headers; - } - - /* XXX: We handle multiple AU Section as only one (need to fix this for interleaving) - In my test, the FAAD decoder does not behave correctly when sending each AU one by one - but does when sending the whole as one big packet... */ - infos->au_headers[0].size = 0; - infos->au_headers[0].index = 0; - for (i = 0; i < infos->nb_au_headers; ++i) { - infos->au_headers[0].size += get_bits_long(&getbitcontext, infos->sizelength); - infos->au_headers[0].index = get_bits_long(&getbitcontext, infos->indexlength); - } - - infos->nb_au_headers = 1; - - return 0; -} - /** * This was the second switch in rtp_parse packet. Normalizes time, if required, sets stream_index, etc. */ @@ -565,29 +511,6 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, av_new_packet(pkt, len); memcpy(pkt->data, buf, len); break; - // moved from below, verbatim. this is because this section handles packets, and the lower switch handles - // timestamps. - // TODO: Put this into a dynamic packet handler... - case CODEC_ID_AAC: - if (rtp_parse_mp4_au(s, buf)) - return -1; - { - RTPPayloadData *infos = s->rtp_payload_data; - if (infos == NULL) - return -1; - buf += infos->au_headers_length_bytes + 2; - len -= infos->au_headers_length_bytes + 2; - - /* XXX: Fixme we only handle the case where rtp_parse_mp4_au define - one au_header */ - av_new_packet(pkt, infos->au_headers[0].size); - memcpy(pkt->data, buf, infos->au_headers[0].size); - buf += infos->au_headers[0].size; - len -= infos->au_headers[0].size; - } - s->read_buf_size = len; - rv= 0; - break; default: av_new_packet(pkt, len); memcpy(pkt->data, buf, len); @@ -605,11 +528,42 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, void rtp_parse_close(RTPDemuxContext *s) { - // TODO: fold this into the protocol specific data fields. - av_free(s->rtp_payload_data->mode); - av_free(s->rtp_payload_data->au_headers); if (!strcmp(ff_rtp_enc_name(s->payload_type), "MP2T")) { ff_mpegts_parse_close(s->ts); } av_free(s); } + +int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p, + int (*parse_fmtp)(AVStream *stream, + PayloadContext *data, + char *attr, char *value)) +{ + char attr[256]; + char *value; + int res; + int value_size = strlen(p) + 1; + + if (!(value = av_malloc(value_size))) { + av_log(stream, AV_LOG_ERROR, "Failed to allocate data for FMTP."); + return AVERROR(ENOMEM); + } + + // remove protocol identifier + while (*p && *p == ' ') p++; // strip spaces + while (*p && *p != ' ') p++; // eat protocol identifier + while (*p && *p == ' ') p++; // strip trailing spaces + + while (ff_rtsp_next_attr_and_value(&p, + attr, sizeof(attr), + value, value_size)) { + + res = parse_fmtp(stream, data, attr, value); + if (res < 0 && res != AVERROR_PATCHWELCOME) { + av_free(value); + return res; + } + } + av_free(value); + return 0; +} diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec.h index 477ab723f..86af2b9d4 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec.h @@ -26,33 +26,7 @@ #include "avformat.h" #include "rtp.h" -/** Structure listing useful vars to parse RTP packet payload*/ -typedef struct rtp_payload_data -{ - int sizelength; - int indexlength; - int indexdeltalength; - int profile_level_id; - int streamtype; - int objecttype; - char *mode; - - /** mpeg 4 AU headers */ - struct AUHeaders { - int size; - int index; - int cts_flag; - int cts; - int dts_flag; - int dts; - int rap_flag; - int streamstate; - } *au_headers; - int au_headers_allocated; - int nb_au_headers; - int au_headers_length_bytes; - int cur_au_index; -} RTPPayloadData; +#define SPACE_CHARS " \t\r\n" typedef struct PayloadContext PayloadContext; typedef struct RTPDynamicProtocolHandler_s RTPDynamicProtocolHandler; @@ -61,7 +35,7 @@ typedef struct RTPDynamicProtocolHandler_s RTPDynamicProtocolHandler; #define RTP_MAX_PACKET_LENGTH 1500 /* XXX: suppress this define */ typedef struct RTPDemuxContext RTPDemuxContext; -RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, RTPPayloadData *rtp_payload_data); +RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type); void rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, RTPDynamicProtocolHandler *handler); int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, @@ -187,9 +161,6 @@ struct RTPDemuxContext { uint8_t buf[RTP_MAX_PACKET_LENGTH]; uint8_t *buf_ptr; - /* special infos for au headers parsing */ - RTPPayloadData *rtp_payload_data; // TODO: Move into dynamic payload handlers - /* dynamic payload stuff */ DynamicPayloadPacketHandlerProc parse_packet; ///< This is also copied from the dynamic protocol handler structure PayloadContext *dynamic_protocol_context; ///< This is a copy from the values setup from the sdp parsing, in rtsp.c don't free me. @@ -201,6 +172,11 @@ void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler); int ff_rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size); ///< from rtsp.c, but used by rtp dynamic protocol handlers. +int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p, + int (*parse_fmtp)(AVStream *stream, + PayloadContext *data, + char *attr, char *value)); + void av_register_rtp_dynamic_payload_handlers(void); #endif /* AVFORMAT_RTPDEC_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_amr.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_amr.c index a7b36c7ab..737b411a9 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_amr.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_amr.c @@ -30,6 +30,26 @@ static const uint8_t frame_sizes_wb[16] = { 17, 23, 32, 36, 40, 46, 50, 58, 60, 5, 5, 0, 0, 0, 0, 0 }; +struct PayloadContext { + int octet_align; + int crc; + int interleaving; + int channels; +}; + +static PayloadContext *amr_new_context(void) +{ + PayloadContext *data = av_mallocz(sizeof(PayloadContext)); + if(!data) return data; + data->channels = 1; + return data; +} + +static void amr_free_context(PayloadContext *data) +{ + av_free(data); +} + static int amr_handle_packet(AVFormatContext *ctx, PayloadContext *data, AVStream *st, @@ -120,11 +140,34 @@ static int amr_handle_packet(AVFormatContext *ctx, return 0; } +static int amr_parse_fmtp(AVStream *stream, PayloadContext *data, + char *attr, char *value) +{ + /* Some AMR SDP configurations contain "octet-align", without + * the trailing =1. Therefore, if the value is empty, + * interpret it as "1". + */ + if (!strcmp(value, "")) { + av_log(NULL, AV_LOG_WARNING, "AMR fmtp attribute %s had " + "nonstandard empty value\n", attr); + strcpy(value, "1"); + } + if (!strcmp(attr, "octet-align")) + data->octet_align = atoi(value); + else if (!strcmp(attr, "crc")) + data->crc = atoi(value); + else if (!strcmp(attr, "interleaving")) + data->interleaving = atoi(value); + else if (!strcmp(attr, "channels")) + data->channels = atoi(value); + return 0; +} + static int amr_parse_sdp_line(AVFormatContext *s, int st_index, PayloadContext *data, const char *line) { const char *p; - char attr[25], value[25]; + int ret; /* Parse an fmtp line this one: * a=fmtp:97 octet-align=1; interleaving=0 @@ -132,38 +175,13 @@ static int amr_parse_sdp_line(AVFormatContext *s, int st_index, * separated key/value pairs. */ if (av_strstart(line, "fmtp:", &p)) { - int octet_align = 0; - int crc = 0; - int interleaving = 0; - int channels = 1; - - while (*p && *p == ' ') p++; /* strip spaces */ - while (*p && *p != ' ') p++; /* eat protocol identifier */ - while (*p && *p == ' ') p++; /* strip trailing spaces */ - - while (ff_rtsp_next_attr_and_value(&p, attr, sizeof(attr), value, sizeof(value))) { - /* Some AMR SDP configurations contain "octet-align", without - * the trailing =1. Therefore, if the value is empty, - * interpret it as "1". - */ - if (!strcmp(value, "")) { - av_log(s, AV_LOG_WARNING, "AMR fmtp attribute %s had " - "nonstandard empty value\n", attr); - strcpy(value, "1"); - } - if (!strcmp(attr, "octet-align")) - octet_align = atoi(value); - else if (!strcmp(attr, "crc")) - crc = atoi(value); - else if (!strcmp(attr, "interleaving")) - interleaving = atoi(value); - else if (!strcmp(attr, "channels")) - channels = atoi(value); - } - if (!octet_align || crc || interleaving || channels != 1) { + ret = ff_parse_fmtp(s->streams[st_index], data, p, amr_parse_fmtp); + if (!data->octet_align || data->crc || + data->interleaving || data->channels != 1) { av_log(s, AV_LOG_ERROR, "Unsupported RTP/AMR configuration!\n"); return -1; } + return ret; } return 0; } @@ -173,6 +191,8 @@ RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler = { .codec_type = AVMEDIA_TYPE_AUDIO, .codec_id = CODEC_ID_AMR_NB, .parse_sdp_a_line = amr_parse_sdp_line, + .open = amr_new_context, + .close = amr_free_context, .parse_packet = amr_handle_packet, }; @@ -181,6 +201,8 @@ RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler = { .codec_type = AVMEDIA_TYPE_AUDIO, .codec_id = CODEC_ID_AMR_WB, .parse_sdp_a_line = amr_parse_sdp_line, + .open = amr_new_context, + .close = amr_free_context, .parse_packet = amr_handle_packet, }; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_asf.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_asf.c index 7ca15f024..340b7cc44 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_asf.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_asf.c @@ -91,8 +91,9 @@ static void init_packetizer(ByteIOContext *pb, uint8_t *buf, int len) pb->buf_end = buf + len; } -void ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) +int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) { + int ret = 0; if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) { ByteIOContext pb; RTSPState *rt = s->priv_data; @@ -108,11 +109,14 @@ void ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) av_close_input_stream(rt->asf_ctx); rt->asf_ctx = NULL; } - av_open_input_stream(&rt->asf_ctx, &pb, "", &asf_demuxer, NULL); + ret = av_open_input_stream(&rt->asf_ctx, &pb, "", &asf_demuxer, NULL); + if (ret < 0) + return ret; rt->asf_pb_pos = url_ftell(&pb); av_free(buf); rt->asf_ctx->pb = NULL; } + return ret; } static int asfrtp_parse_sdp_line(AVFormatContext *s, int stream_index, @@ -143,7 +147,7 @@ static int asfrtp_parse_sdp_line(AVFormatContext *s, int stream_index, struct PayloadContext { ByteIOContext *pktbuf, pb; - char *buf; + uint8_t *buf; }; /** diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_asf.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_asf.h index 5d60a1435..dbd85dc84 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_asf.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_asf.h @@ -29,9 +29,8 @@ * Parse a Windows Media Server-specific SDP line * * @param s RTSP demux context - * @param line the SDP line to be parsed */ -void ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p); +int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p); /** * Handlers for the x-asf-pf payloads (the payload ID for RTP/ASF). diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_h264.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_h264.c index 49db08a45..3ee0788f9 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_h264.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_h264.c @@ -69,9 +69,9 @@ struct PayloadContext { #define DEAD_COOKIE (0xdeaddead) ///< Cookie for the extradata; once it is freed. /* ---------------- private code */ -static void sdp_parse_fmtp_config_h264(AVStream * stream, - PayloadContext * h264_data, - char *attr, char *value) +static int sdp_parse_fmtp_config_h264(AVStream * stream, + PayloadContext * h264_data, + char *attr, char *value) { AVCodecContext *codec = stream->codec; assert(codec->codec_id == CODEC_ID_H264); @@ -120,7 +120,7 @@ static void sdp_parse_fmtp_config_h264(AVStream * stream, while (*value) { char base64packet[1024]; uint8_t decoded_packet[1024]; - uint32_t packet_size; + int packet_size; char *dst = base64packet; while (*value && *value != ',' @@ -133,7 +133,7 @@ static void sdp_parse_fmtp_config_h264(AVStream * stream, value++; packet_size= av_base64_decode(decoded_packet, base64packet, sizeof(decoded_packet)); - if (packet_size) { + if (packet_size > 0) { uint8_t *dest = av_malloc(packet_size + sizeof(start_sequence) + codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); @@ -155,11 +155,13 @@ static void sdp_parse_fmtp_config_h264(AVStream * stream, codec->extradata_size+= sizeof(start_sequence)+packet_size; } else { av_log(codec, AV_LOG_ERROR, "Unable to allocate memory for extradata!"); + return AVERROR(ENOMEM); } } } av_log(codec, AV_LOG_DEBUG, "Extradata set to %p (size: %d)!", codec->extradata, codec->extradata_size); } + return 0; } // return 0 on packet, no more left, 1 on packet, 1 on partial packet... @@ -383,20 +385,7 @@ static int parse_h264_sdp_line(AVFormatContext *s, int st_index, codec->height = atoi(p + 1); // skip the - codec->pix_fmt = PIX_FMT_YUV420P; } else if (av_strstart(p, "fmtp:", &p)) { - char attr[256]; - char value[4096]; - - // remove the protocol identifier.. - while (*p && *p == ' ') p++; // strip spaces. - while (*p && *p != ' ') p++; // eat protocol identifier - while (*p && *p == ' ') p++; // strip trailing spaces. - - /* loop on each attribute */ - while (ff_rtsp_next_attr_and_value - (&p, attr, sizeof(attr), value, sizeof(value))) { - /* grab the codec extra_data from the config parameter of the fmtp line */ - sdp_parse_fmtp_config_h264(stream, h264_data, attr, value); - } + return ff_parse_fmtp(stream, h264_data, p, sdp_parse_fmtp_config_h264); } else if (av_strstart(p, "cliprect:", &p)) { // could use this if we wanted. } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_mpeg4.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_mpeg4.c new file mode 100644 index 000000000..d443b6445 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_mpeg4.c @@ -0,0 +1,280 @@ +/** + * Common code for the RTP depacketization of MPEG-4 formats. + * Copyright (c) 2010 Fabrice Bellard + * Romain Degez + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @brief MPEG4 / RTP Code + * @author Fabrice Bellard + * @author Romain Degez + */ + +#include "rtpdec_mpeg4.h" +#include "libavutil/avstring.h" +#include "libavcodec/get_bits.h" +#include + +/** Structure listing useful vars to parse RTP packet payload*/ +struct PayloadContext +{ + int sizelength; + int indexlength; + int indexdeltalength; + int profile_level_id; + int streamtype; + int objecttype; + char *mode; + + /** mpeg 4 AU headers */ + struct AUHeaders { + int size; + int index; + int cts_flag; + int cts; + int dts_flag; + int dts; + int rap_flag; + int streamstate; + } *au_headers; + int au_headers_allocated; + int nb_au_headers; + int au_headers_length_bytes; + int cur_au_index; +}; + +/* return the length and optionally the data */ +static int hex_to_data(uint8_t *data, const char *p) +{ + int c, len, v; + + len = 0; + v = 1; + for (;;) { + p += strspn(p, SPACE_CHARS); + if (*p == '\0') + break; + c = toupper((unsigned char) *p++); + if (c >= '0' && c <= '9') + c = c - '0'; + else if (c >= 'A' && c <= 'F') + c = c - 'A' + 10; + else + break; + v = (v << 4) | c; + if (v & 0x100) { + if (data) + data[len] = v; + len++; + v = 1; + } + } + return len; +} + +typedef struct { + const char *str; + uint16_t type; + uint32_t offset; +} AttrNameMap; + +/* All known fmtp parameters and the corresponding RTPAttrTypeEnum */ +#define ATTR_NAME_TYPE_INT 0 +#define ATTR_NAME_TYPE_STR 1 +static const AttrNameMap attr_names[]= +{ + { "SizeLength", ATTR_NAME_TYPE_INT, + offsetof(PayloadContext, sizelength) }, + { "IndexLength", ATTR_NAME_TYPE_INT, + offsetof(PayloadContext, indexlength) }, + { "IndexDeltaLength", ATTR_NAME_TYPE_INT, + offsetof(PayloadContext, indexdeltalength) }, + { "profile-level-id", ATTR_NAME_TYPE_INT, + offsetof(PayloadContext, profile_level_id) }, + { "StreamType", ATTR_NAME_TYPE_INT, + offsetof(PayloadContext, streamtype) }, + { "mode", ATTR_NAME_TYPE_STR, + offsetof(PayloadContext, mode) }, + { NULL, -1, -1 }, +}; + +static PayloadContext *new_context(void) +{ + return av_mallocz(sizeof(PayloadContext)); +} + +static void free_context(PayloadContext * data) +{ + int i; + for (i = 0; i < data->nb_au_headers; i++) { + /* according to rtp_parse_mp4_au, we treat multiple + * au headers as one, so nb_au_headers is always 1. + * loop anyway in case this changes. + * (note: changes done carelessly might lead to a double free) + */ + av_free(&data->au_headers[i]); + } + av_free(data->mode); + av_free(data); +} + +static int parse_fmtp_config(AVCodecContext * codec, char *value) +{ + /* decode the hexa encoded parameter */ + int len = hex_to_data(NULL, value); + if (codec->extradata) + av_free(codec->extradata); + codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); + if (!codec->extradata) + return AVERROR(ENOMEM); + codec->extradata_size = len; + hex_to_data(codec->extradata, value); + return 0; +} + +static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf) +{ + int au_headers_length, au_header_size, i; + GetBitContext getbitcontext; + + /* decode the first 2 bytes where the AUHeader sections are stored + length in bits */ + au_headers_length = AV_RB16(buf); + + if (au_headers_length > RTP_MAX_PACKET_LENGTH) + return -1; + + data->au_headers_length_bytes = (au_headers_length + 7) / 8; + + /* skip AU headers length section (2 bytes) */ + buf += 2; + + init_get_bits(&getbitcontext, buf, data->au_headers_length_bytes * 8); + + /* XXX: Wrong if optionnal additional sections are present (cts, dts etc...) */ + au_header_size = data->sizelength + data->indexlength; + if (au_header_size <= 0 || (au_headers_length % au_header_size != 0)) + return -1; + + data->nb_au_headers = au_headers_length / au_header_size; + if (!data->au_headers || data->au_headers_allocated < data->nb_au_headers) { + av_free(data->au_headers); + data->au_headers = av_malloc(sizeof(struct AUHeaders) * data->nb_au_headers); + data->au_headers_allocated = data->nb_au_headers; + } + + /* XXX: We handle multiple AU Section as only one (need to fix this for interleaving) + In my test, the FAAD decoder does not behave correctly when sending each AU one by one + but does when sending the whole as one big packet... */ + data->au_headers[0].size = 0; + data->au_headers[0].index = 0; + for (i = 0; i < data->nb_au_headers; ++i) { + data->au_headers[0].size += get_bits_long(&getbitcontext, data->sizelength); + data->au_headers[0].index = get_bits_long(&getbitcontext, data->indexlength); + } + + data->nb_au_headers = 1; + + return 0; +} + + +/* Follows RFC 3640 */ +static int aac_parse_packet(AVFormatContext *ctx, + PayloadContext *data, + AVStream *st, + AVPacket *pkt, + uint32_t *timestamp, + const uint8_t *buf, int len, int flags) +{ + if (rtp_parse_mp4_au(data, buf)) + return -1; + + buf += data->au_headers_length_bytes + 2; + len -= data->au_headers_length_bytes + 2; + + /* XXX: Fixme we only handle the case where rtp_parse_mp4_au define + one au_header */ + av_new_packet(pkt, data->au_headers[0].size); + memcpy(pkt->data, buf, data->au_headers[0].size); + + pkt->stream_index = st->index; + return 0; +} + +static int parse_fmtp(AVStream *stream, PayloadContext *data, + char *attr, char *value) +{ + AVCodecContext *codec = stream->codec; + int res, i; + + if (!strcmp(attr, "config")) { + res = parse_fmtp_config(codec, value); + + if (res < 0) + return res; + } + + if (codec->codec_id == CODEC_ID_AAC) { + /* Looking for a known attribute */ + for (i = 0; attr_names[i].str; ++i) { + if (!strcasecmp(attr, attr_names[i].str)) { + if (attr_names[i].type == ATTR_NAME_TYPE_INT) { + *(int *)((char *)data+ + attr_names[i].offset) = atoi(value); + } else if (attr_names[i].type == ATTR_NAME_TYPE_STR) + *(char **)((char *)data+ + attr_names[i].offset) = av_strdup(value); + } + } + } + return 0; +} + +static int parse_sdp_line(AVFormatContext *s, int st_index, + PayloadContext *data, const char *line) +{ + const char *p; + + if (av_strstart(line, "fmtp:", &p)) + return ff_parse_fmtp(s->streams[st_index], data, p, parse_fmtp); + + return 0; +} + +RTPDynamicProtocolHandler ff_mp4v_es_dynamic_handler = { + .enc_name = "MP4V-ES", + .codec_type = AVMEDIA_TYPE_VIDEO, + .codec_id = CODEC_ID_MPEG4, + .parse_sdp_a_line = parse_sdp_line, + .open = NULL, + .close = NULL, + .parse_packet = NULL +}; + +RTPDynamicProtocolHandler ff_mpeg4_generic_dynamic_handler = { + .enc_name = "mpeg4-generic", + .codec_type = AVMEDIA_TYPE_AUDIO, + .codec_id = CODEC_ID_AAC, + .parse_sdp_a_line = parse_sdp_line, + .open = new_context, + .close = free_context, + .parse_packet = aac_parse_packet +}; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_mpeg4.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_mpeg4.h new file mode 100644 index 000000000..06d9e577f --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_mpeg4.h @@ -0,0 +1,39 @@ +/** + * Common code for the RTP depacketization of MPEG-4 formats. + * Copyright (c) 2010 Fabrice Bellard + * Romain Degez + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_RTPDEC_MPEG4_H +#define AVFORMAT_RTPDEC_MPEG4_H + +#include "rtpdec.h" + +/** + * MPEG-4 Video RTP callbacks. (RFC 3016) + */ +extern RTPDynamicProtocolHandler ff_mp4v_es_dynamic_handler; + +/** + * AAC RTP callbacks. (RFC 3640) + */ +extern RTPDynamicProtocolHandler ff_mpeg4_generic_dynamic_handler; + +#endif /* AVFORMAT_RTPDEC_MPEG4_H */ + diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_svq3.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_svq3.c new file mode 100644 index 000000000..a28503699 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_svq3.c @@ -0,0 +1,138 @@ +/* + * Sorenson-3 (SVQ3/SV3V) payload for RTP + * Copyright (c) 2010 Ronald S. Bultje + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @brief RTP support for the SV3V (SVQ3) payload + * (http://wiki.multimedia.cx/index.php?title=Sorenson_Video_3#Packetization) + * @author Ronald S. Bultje + */ + +#include +#include +#include "rtp.h" +#include "rtpdec.h" +#include "rtpdec_svq3.h" + +struct PayloadContext { + ByteIOContext *pktbuf; + int64_t timestamp; + int is_keyframe; +}; + +/** return 0 on packet, <0 on partial packet or error... */ +static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv, + AVStream *st, AVPacket *pkt, + uint32_t *timestamp, + const uint8_t *buf, int len, int flags) +{ + int config_packet, start_packet, end_packet; + + if (len < 2) + return AVERROR_INVALIDDATA; + + config_packet = buf[0] & 0x40; + start_packet = buf[0] & 0x20; + end_packet = buf[0] & 0x10; + buf += 2; // ignore buf[1] + len -= 2; + + if (config_packet) { + + av_freep(&st->codec->extradata); + st->codec->extradata_size = 0; + + if (len < 2 || !(st->codec->extradata = + av_malloc(len + 8 + FF_INPUT_BUFFER_PADDING_SIZE))) + return AVERROR_INVALIDDATA; + + st->codec->extradata_size = len + 8; + memcpy(st->codec->extradata, "SEQH", 4); + AV_WB32(st->codec->extradata + 4, len); + memcpy(st->codec->extradata + 8, buf, len); + + /* We set codec_id to CODEC_ID_NONE initially to + * delay decoder initialization since extradata is + * carried within the RTP stream, not SDP. Here, + * by setting codec_id to CODEC_ID_SVQ3, we are signalling + * to the decoder that it is OK to initialize. */ + st->codec->codec_id = CODEC_ID_SVQ3; + + return AVERROR(EAGAIN); + } + + if (start_packet) { + int res; + + if (sv->pktbuf) { + uint8_t *tmp; + url_close_dyn_buf(sv->pktbuf, &tmp); + av_free(tmp); + } + if ((res = url_open_dyn_buf(&sv->pktbuf)) < 0) + return res; + sv->timestamp = *timestamp; + sv->is_keyframe = flags & RTP_FLAG_KEY; + } + + if (!sv->pktbuf) + return AVERROR_INVALIDDATA; + + put_buffer(sv->pktbuf, buf, len); + + if (end_packet) { + av_init_packet(pkt); + pkt->stream_index = st->index; + pkt->pts = sv->timestamp; + pkt->flags = sv->is_keyframe ? AV_PKT_FLAG_KEY : 0; + pkt->size = url_close_dyn_buf(sv->pktbuf, &pkt->data); + pkt->destruct = av_destruct_packet; + sv->pktbuf = NULL; + return 0; + } + + return AVERROR(EAGAIN); +} + +static PayloadContext *svq3_extradata_new(void) +{ + return av_mallocz(sizeof(PayloadContext)); +} + +static void svq3_extradata_free(PayloadContext *sv) +{ + if (sv->pktbuf) { + uint8_t *buf; + url_close_dyn_buf(sv->pktbuf, &buf); + av_free(buf); + } + av_free(sv); +} + +RTPDynamicProtocolHandler ff_svq3_dynamic_handler = { + "X-SV3V-ES", + CODEC_TYPE_VIDEO, + CODEC_ID_NONE, // see if (config_packet) above + NULL, // parse sdp line + svq3_extradata_new, + svq3_extradata_free, + svq3_parse_packet, +}; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_svq3.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_svq3.h new file mode 100644 index 000000000..267d4d9de --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_svq3.h @@ -0,0 +1,33 @@ +/* + * Sorenson-3 (SVQ3/SV3V) payload for RTP + * Copyright (c) 2010 Ronald S. Bultje + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_RTPDEC_SVQ3_H +#define AVFORMAT_RTPDEC_SVQ3_H + +#include "libavcodec/avcodec.h" +#include "rtpdec.h" + +/** + * Sorenson-3 RTP callbacks. + */ +extern RTPDynamicProtocolHandler ff_svq3_dynamic_handler; + +#endif /* AVFORMAT_RTPDEC_SVQ3_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_xiph.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_xiph.c index 9a1f33d53..9973efcd7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_xiph.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpdec_xiph.c @@ -236,7 +236,7 @@ parse_packed_headers(const uint8_t * packed_headers, if (packed_headers_end - packed_headers < 9) { av_log(codec, AV_LOG_ERROR, - "Invalid %d byte packed header.", + "Invalid %td byte packed header.", packed_headers_end - packed_headers); return AVERROR_INVALIDDATA; } @@ -258,7 +258,7 @@ parse_packed_headers(const uint8_t * packed_headers, if (packed_headers_end - packed_headers != length || length1 > length || length2 > length - length1) { av_log(codec, AV_LOG_ERROR, - "Bad packed header lengths (%d,%d,%d,%d)\n", length1, + "Bad packed header lengths (%d,%d,%td,%d)\n", length1, length2, packed_headers_end - packed_headers, length); return AVERROR_INVALIDDATA; } @@ -286,10 +286,11 @@ parse_packed_headers(const uint8_t * packed_headers, return 0; } -static int xiph_parse_fmtp_pair(AVCodecContext * codec, +static int xiph_parse_fmtp_pair(AVStream* stream, PayloadContext *xiph_data, char *attr, char *value) { + AVCodecContext *codec = stream->codec; int result = 0; if (!strcmp(attr, "sampling")) { @@ -346,34 +347,12 @@ static int xiph_parse_sdp_line(AVFormatContext *s, int st_index, PayloadContext *data, const char *line) { const char *p; - char *value; - char attr[25]; - int value_size = strlen(line), attr_size = sizeof(attr), res = 0; - AVCodecContext* codec = s->streams[st_index]->codec; - - assert(data); - - if (!(value = av_malloc(value_size))) { - av_log(codec, AV_LOG_ERROR, "Out of memory\n"); - return AVERROR(ENOMEM); - } if (av_strstart(line, "fmtp:", &p)) { - // remove protocol identifier - while (*p && *p == ' ') p++; // strip spaces - while (*p && *p != ' ') p++; // eat protocol identifier - while (*p && *p == ' ') p++; // strip trailing spaces - - while (ff_rtsp_next_attr_and_value(&p, - attr, attr_size, - value, value_size)) { - res = xiph_parse_fmtp_pair(codec, data, attr, value); - if (res < 0 && res != AVERROR_PATCHWELCOME) - return res; - } + return ff_parse_fmtp(s->streams[st_index], data, p, + xiph_parse_fmtp_pair); } - av_free(value); return 0; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpenc.c index 3111c2b32..4453f65a8 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpenc.c @@ -24,8 +24,6 @@ #include "internal.h" #include "libavutil/random_seed.h" -#include - #include "rtpenc.h" //#define DEBUG @@ -131,6 +129,12 @@ static int rtp_write_header(AVFormatContext *s1) s->max_payload_size = n * TS_PACKET_SIZE; s->buf_ptr = s->buf; break; + case CODEC_ID_H264: + /* check for H.264 MP4 syntax */ + if (st->codec->extradata_size > 4 && st->codec->extradata[0] == 1) { + s->nal_length_size = (st->codec->extradata[4] & 0x03) + 1; + } + break; case CODEC_ID_AMR_NB: case CODEC_ID_AMR_WB: if (!s->max_frames_per_packet) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpenc.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpenc.h index 57101601c..95e70c140 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpenc.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpenc.h @@ -50,6 +50,12 @@ struct RTPMuxContext { uint8_t *buf_ptr; int max_frames_per_packet; + + /** + * Number of bytes used for H.264 NAL length, if the MP4 syntax is used + * (1, 2 or 4) + */ + int nal_length_size; }; typedef struct RTPMuxContext RTPMuxContext; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpproto.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpproto.c index bbcf0d91c..46511bab6 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpproto.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtpproto.c @@ -52,7 +52,7 @@ typedef struct RTPContext { * get the local port first, then you must call this function to set * the remote server address. * - * @param s1 media file context + * @param h media file context * @param uri of the remote server * @return zero if no error. */ @@ -66,7 +66,7 @@ int rtp_set_remote_url(URLContext *h, const char *uri) char buf[1024]; char path[1024]; - ff_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, + av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, path, sizeof(path), uri); ff_url_join(buf, sizeof(buf), "udp", NULL, hostname, port, "%s", path); @@ -146,7 +146,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) return AVERROR(ENOMEM); h->priv_data = s; - ff_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &rtp_port, + av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &rtp_port, path, sizeof(path), uri); /* extract parameters */ ttl = -1; @@ -317,7 +317,7 @@ static int rtp_close(URLContext *h) /** * Return the local rtp port used by the RTP connection - * @param s1 media file context + * @param h media file context * @return the local port number */ @@ -329,7 +329,7 @@ int rtp_get_local_rtp_port(URLContext *h) /** * Return the local rtp port used by the RTP connection - * @param s1 media file context + * @param h media file context * @return the local port number */ @@ -341,7 +341,7 @@ int rtp_get_local_port(URLContext *h) /** * Return the local rtcp port used by the RTP connection - * @param s1 media file context + * @param h media file context * @return the local port number */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtsp.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtsp.c index 0b557426f..9316f3cea 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtsp.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtsp.c @@ -22,6 +22,7 @@ #include "libavutil/base64.h" #include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" +#include "libavutil/random_seed.h" #include "avformat.h" #include @@ -32,6 +33,7 @@ #include "internal.h" #include "network.h" #include "os_support.h" +#include "http.h" #include "rtsp.h" #include "rtpdec.h" @@ -51,19 +53,6 @@ int rtsp_default_protocols = (1 << RTSP_LOWER_TRANSPORT_UDP); #define READ_PACKET_TIMEOUT_S 10 #define MAX_TIMEOUTS READ_PACKET_TIMEOUT_S * 1000 / SELECT_TIMEOUT_MS -#define SPACE_CHARS " \t\r\n" -/* we use memchr() instead of strchr() here because strchr() will return - * the terminating '\0' of SPACE_CHARS instead of NULL if c is '\0'. */ -#define redir_isspace(c) memchr(SPACE_CHARS, c, 4) -static void skip_spaces(const char **pp) -{ - const char *p; - p = *pp; - while (redir_isspace(*p)) - p++; - *pp = p; -} - static void get_word_until_chars(char *buf, int buf_size, const char *sep, const char **pp) { @@ -71,7 +60,7 @@ static void get_word_until_chars(char *buf, int buf_size, char *q; p = *pp; - skip_spaces(&p); + p += strspn(p, SPACE_CHARS); q = buf; while (!strchr(sep, *p) && *p != '\0') { if ((q - buf) < buf_size - 1) @@ -169,92 +158,13 @@ static int sdp_parse_rtpmap(AVFormatContext *s, return 0; } -/* return the length and optionally the data */ -static int hex_to_data(uint8_t *data, const char *p) -{ - int c, len, v; - - len = 0; - v = 1; - for (;;) { - skip_spaces(&p); - if (*p == '\0') - break; - c = toupper((unsigned char) *p++); - if (c >= '0' && c <= '9') - c = c - '0'; - else if (c >= 'A' && c <= 'F') - c = c - 'A' + 10; - else - break; - v = (v << 4) | c; - if (v & 0x100) { - if (data) - data[len] = v; - len++; - v = 1; - } - } - return len; -} - -static void sdp_parse_fmtp_config(AVCodecContext * codec, void *ctx, - char *attr, char *value) -{ - switch (codec->codec_id) { - case CODEC_ID_MPEG4: - case CODEC_ID_AAC: - if (!strcmp(attr, "config")) { - /* decode the hexa encoded parameter */ - int len = hex_to_data(NULL, value); - if (codec->extradata) - av_free(codec->extradata); - codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); - if (!codec->extradata) - return; - codec->extradata_size = len; - hex_to_data(codec->extradata, value); - } - break; - default: - break; - } - return; -} - -typedef struct { - const char *str; - uint16_t type; - uint32_t offset; -} AttrNameMap; - -/* All known fmtp parameters and the corresponding RTPAttrTypeEnum */ -#define ATTR_NAME_TYPE_INT 0 -#define ATTR_NAME_TYPE_STR 1 -static const AttrNameMap attr_names[]= -{ - { "SizeLength", ATTR_NAME_TYPE_INT, - offsetof(RTPPayloadData, sizelength) }, - { "IndexLength", ATTR_NAME_TYPE_INT, - offsetof(RTPPayloadData, indexlength) }, - { "IndexDeltaLength", ATTR_NAME_TYPE_INT, - offsetof(RTPPayloadData, indexdeltalength) }, - { "profile-level-id", ATTR_NAME_TYPE_INT, - offsetof(RTPPayloadData, profile_level_id) }, - { "StreamType", ATTR_NAME_TYPE_INT, - offsetof(RTPPayloadData, streamtype) }, - { "mode", ATTR_NAME_TYPE_STR, - offsetof(RTPPayloadData, mode) }, - { NULL, -1, -1 }, -}; - /* parse the attribute line from the fmtp a line of an sdp response. This * is broken out as a function because it is used in rtp_h264.c, which is * forthcoming. */ int ff_rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size) { - skip_spaces(p); + *p += strspn(*p, SPACE_CHARS); if (**p) { get_word_sep(attr, attr_size, "=", p); if (**p == '=') @@ -267,39 +177,6 @@ int ff_rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, return 0; } -/* parse a SDP line and save stream attributes */ -static void sdp_parse_fmtp(AVStream *st, const char *p) -{ - char attr[256]; - /* Vorbis setup headers can be up to 12KB and are sent base64 - * encoded, giving a 12KB * (4/3) = 16KB FMTP line. */ - char value[16384]; - int i; - RTSPStream *rtsp_st = st->priv_data; - AVCodecContext *codec = st->codec; - RTPPayloadData *rtp_payload_data = &rtsp_st->rtp_payload_data; - - /* loop on each attribute */ - while (ff_rtsp_next_attr_and_value(&p, attr, sizeof(attr), - value, sizeof(value))) { - /* grab the codec extra_data from the config parameter of the fmtp - * line */ - sdp_parse_fmtp_config(codec, rtsp_st->dynamic_protocol_context, - attr, value); - /* Looking for a known attribute */ - for (i = 0; attr_names[i].str; ++i) { - if (!strcasecmp(attr, attr_names[i].str)) { - if (attr_names[i].type == ATTR_NAME_TYPE_INT) { - *(int *)((char *)rtp_payload_data + - attr_names[i].offset) = atoi(value); - } else if (attr_names[i].type == ATTR_NAME_TYPE_STR) - *(char **)((char *)rtp_payload_data + - attr_names[i].offset) = av_strdup(value); - } - } - } -} - /** Parse a string p in the form of Range:npt=xx-xx, and determine the start * and end time. * Used for seeking in the rtp stream. @@ -308,7 +185,7 @@ static void rtsp_parse_range_npt(const char *p, int64_t *start, int64_t *end) { char buf[256]; - skip_spaces(&p); + p += strspn(p, SPACE_CHARS); if (!av_stristart(p, "npt=", &p)) return; @@ -450,7 +327,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, rtsp_st = st->priv_data; /* XXX: may need to add full url resolution */ - ff_url_split(proto, sizeof(proto), NULL, 0, NULL, 0, + av_url_split(proto, sizeof(proto), NULL, 0, NULL, 0, NULL, NULL, 0, p); if (proto[0] == '\0') { /* relative control URL */ @@ -470,22 +347,9 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, st = s->streams[s->nb_streams - 1]; rtsp_st = st->priv_data; sdp_parse_rtpmap(s, st->codec, rtsp_st, payload_type, p); - } else if (av_strstart(p, "fmtp:", &p)) { + } else if (av_strstart(p, "fmtp:", &p) || + av_strstart(p, "framesize:", &p)) { /* NOTE: fmtp is only supported AFTER the 'a=rtpmap:xxx' tag */ - get_word(buf1, sizeof(buf1), &p); - payload_type = atoi(buf1); - for (i = 0; i < s->nb_streams; i++) { - st = s->streams[i]; - rtsp_st = st->priv_data; - if (rtsp_st->sdp_payload_type == payload_type) { - if (!(rtsp_st->dynamic_handler && - rtsp_st->dynamic_handler->parse_sdp_a_line && - rtsp_st->dynamic_handler->parse_sdp_a_line(s, - i, rtsp_st->dynamic_protocol_context, buf))) - sdp_parse_fmtp(st, p); - } - } - } else if (av_strstart(p, "framesize:", &p)) { // let dynamic protocol handlers have a stab at the line. get_word(buf1, sizeof(buf1), &p); payload_type = atoi(buf1); @@ -539,14 +403,15 @@ static int sdp_parse(AVFormatContext *s, const char *content) * "rulebooks" describing their properties. Therefore, the SDP line * buffer is large. * - * The Vorbis FMTP line can be up to 16KB - see sdp_parse_fmtp. */ + * The Vorbis FMTP line can be up to 16KB - see xiph_parse_sdp_line + * in rtpdec_xiph.c. */ char buf[16384], *q; SDPParseState sdp_parse_state, *s1 = &sdp_parse_state; memset(s1, 0, sizeof(SDPParseState)); p = content; for (;;) { - skip_spaces(&p); + p += strspn(p, SPACE_CHARS); letter = *p; if (letter == '\0') break; @@ -696,8 +561,7 @@ static int rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st) rtsp_st->dynamic_handler); else rtsp_st->transport_priv = rtp_parse_open(s, st, rtsp_st->rtp_handle, - rtsp_st->sdp_payload_type, - &rtsp_st->rtp_payload_data); + rtsp_st->sdp_payload_type); if (!rtsp_st->transport_priv) { return AVERROR(ENOMEM); @@ -726,7 +590,7 @@ static void rtsp_parse_range(int *min_ptr, int *max_ptr, const char **pp) int v; p = *pp; - skip_spaces(&p); + p += strspn(p, SPACE_CHARS); v = strtol(p, (char **)&p, 10); if (*p == '-') { p++; @@ -753,7 +617,7 @@ static void rtsp_parse_transport(RTSPMessageHeader *reply, const char *p) reply->nb_transports = 0; for (;;) { - skip_spaces(&p); + p += strspn(p, SPACE_CHARS); if (*p == '\0') break; @@ -863,22 +727,22 @@ void ff_rtsp_parse_line(RTSPMessageHeader *reply, const char *buf, } else if (av_stristart(p, "Range:", &p)) { rtsp_parse_range_npt(p, &reply->range_start, &reply->range_end); } else if (av_stristart(p, "RealChallenge1:", &p)) { - skip_spaces(&p); + p += strspn(p, SPACE_CHARS); av_strlcpy(reply->real_challenge, p, sizeof(reply->real_challenge)); } else if (av_stristart(p, "Server:", &p)) { - skip_spaces(&p); + p += strspn(p, SPACE_CHARS); av_strlcpy(reply->server, p, sizeof(reply->server)); } else if (av_stristart(p, "Notice:", &p) || av_stristart(p, "X-Notice:", &p)) { reply->notice = strtol(p, NULL, 10); } else if (av_stristart(p, "Location:", &p)) { - skip_spaces(&p); + p += strspn(p, SPACE_CHARS); av_strlcpy(reply->location, p , sizeof(reply->location)); } else if (av_stristart(p, "WWW-Authenticate:", &p) && auth_state) { - skip_spaces(&p); + p += strspn(p, SPACE_CHARS); ff_http_auth_handle_header(auth_state, "WWW-Authenticate", p); } else if (av_stristart(p, "Authentication-Info:", &p) && auth_state) { - skip_spaces(&p); + p += strspn(p, SPACE_CHARS); ff_http_auth_handle_header(auth_state, "Authentication-Info", p); } } @@ -1008,8 +872,11 @@ int ff_rtsp_send_cmd_with_content_async(AVFormatContext *s, int send_content_length) { RTSPState *rt = s->priv_data; - char buf[4096]; + char buf[4096], *out_buf; + char base64buf[AV_BASE64_SIZE(sizeof(buf))]; + /* Add in RTSP headers */ + out_buf = buf; rt->seq++; snprintf(buf, sizeof(buf), "%s %s RTSP/1.0\r\n", method, url); if (headers) @@ -1030,11 +897,23 @@ int ff_rtsp_send_cmd_with_content_async(AVFormatContext *s, av_strlcatf(buf, sizeof(buf), "Content-Length: %d\r\n", send_content_length); av_strlcat(buf, "\r\n", sizeof(buf)); + /* base64 encode rtsp if tunneling */ + if (rt->control_transport == RTSP_MODE_TUNNEL) { + av_base64_encode(base64buf, sizeof(base64buf), buf, strlen(buf)); + out_buf = base64buf; + } + dprintf(s, "Sending:\n%s--\n", buf); - url_write(rt->rtsp_hd_out, buf, strlen(buf)); - if (send_content_length > 0 && send_content) + url_write(rt->rtsp_hd_out, out_buf, strlen(out_buf)); + if (send_content_length > 0 && send_content) { + if (rt->control_transport == RTSP_MODE_TUNNEL) { + av_log(s, AV_LOG_ERROR, "tunneling of RTSP requests " + "with content data not supported\n"); + return AVERROR_PATCHWELCOME; + } url_write(rt->rtsp_hd_out, send_content, send_content_length); + } rt->last_cmd_time = av_gettime(); return 0; @@ -1080,6 +959,13 @@ int ff_rtsp_send_cmd_with_content(AVFormatContext *s, rt->auth_state.auth_type != HTTP_AUTH_NONE) goto retry; + if (reply->status_code > 400){ + av_log(s, AV_LOG_ERROR, "method %s failed, %d\n", + method, + reply->status_code); + av_log(s, AV_LOG_DEBUG, "%s\n", rt->last_reply); + } + return 0; } @@ -1467,6 +1353,7 @@ void ff_rtsp_close_connections(AVFormatContext *s) RTSPState *rt = s->priv_data; if (rt->rtsp_hd_out != rt->rtsp_hd) url_close(rt->rtsp_hd_out); url_close(rt->rtsp_hd); + rt->rtsp_hd = rt->rtsp_hd_out = NULL; } int ff_rtsp_connect(AVFormatContext *s) @@ -1474,7 +1361,6 @@ int ff_rtsp_connect(AVFormatContext *s) RTSPState *rt = s->priv_data; char host[1024], path[1024], tcpname[1024], cmd[2048], auth[128]; char *option_list, *option, *filename; - URLContext *rtsp_hd, *rtsp_hd_out; int port, err, tcp_fd; RTSPMessageHeader reply1 = {}, *reply = &reply1; int lower_transport_mask = 0; @@ -1485,8 +1371,9 @@ int ff_rtsp_connect(AVFormatContext *s) if (!ff_network_init()) return AVERROR(EIO); redirect: + rt->control_transport = RTSP_MODE_PLAIN; /* extract hostname and port */ - ff_url_split(NULL, 0, auth, sizeof(auth), + av_url_split(NULL, 0, auth, sizeof(auth), host, sizeof(host), &port, path, sizeof(path), s->filename); if (*auth) { av_strlcpy(rt->auth, auth, sizeof(rt->auth)); @@ -1514,6 +1401,9 @@ int ff_rtsp_connect(AVFormatContext *s) lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_UDP_MULTICAST); } else if (!strcmp(option, "tcp")) { lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP); + } else if(!strcmp(option, "http")) { + lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP); + rt->control_transport = RTSP_MODE_TUNNEL; } else { /* Write options back into the buffer, using memmove instead * of strcpy since the strings may overlap. */ @@ -1533,7 +1423,7 @@ int ff_rtsp_connect(AVFormatContext *s) /* Only UDP or TCP - UDP multicast isn't supported. */ lower_transport_mask &= (1 << RTSP_LOWER_TRANSPORT_UDP) | (1 << RTSP_LOWER_TRANSPORT_TCP); - if (!lower_transport_mask) { + if (!lower_transport_mask || rt->control_transport == RTSP_MODE_TUNNEL) { av_log(s, AV_LOG_ERROR, "Unsupported lower transport method, " "only UDP and TCP are supported for output.\n"); err = AVERROR(EINVAL); @@ -1547,18 +1437,90 @@ int ff_rtsp_connect(AVFormatContext *s) ff_url_join(rt->control_uri, sizeof(rt->control_uri), "rtsp", NULL, host, port, "%s", path); - /* open the tcp connexion */ - ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL); - if (url_open(&rtsp_hd, tcpname, URL_RDWR) < 0) { - err = AVERROR(EIO); - goto fail; + if (rt->control_transport == RTSP_MODE_TUNNEL) { + /* set up initial handshake for tunneling */ + char httpname[1024]; + char sessioncookie[17]; + char headers[1024]; + + ff_url_join(httpname, sizeof(httpname), "http", auth, host, port, "%s", path); + snprintf(sessioncookie, sizeof(sessioncookie), "%08x%08x", + av_get_random_seed(), av_get_random_seed()); + + /* GET requests */ + if (url_alloc(&rt->rtsp_hd, httpname, URL_RDONLY) < 0) { + err = AVERROR(EIO); + goto fail; + } + + /* generate GET headers */ + snprintf(headers, sizeof(headers), + "x-sessioncookie: %s\r\n" + "Accept: application/x-rtsp-tunnelled\r\n" + "Pragma: no-cache\r\n" + "Cache-Control: no-cache\r\n", + sessioncookie); + ff_http_set_headers(rt->rtsp_hd, headers); + + /* complete the connection */ + if (url_connect(rt->rtsp_hd)) { + err = AVERROR(EIO); + goto fail; + } + + /* POST requests */ + if (url_alloc(&rt->rtsp_hd_out, httpname, URL_WRONLY) < 0 ) { + err = AVERROR(EIO); + goto fail; + } + + /* generate POST headers */ + snprintf(headers, sizeof(headers), + "x-sessioncookie: %s\r\n" + "Content-Type: application/x-rtsp-tunnelled\r\n" + "Pragma: no-cache\r\n" + "Cache-Control: no-cache\r\n" + "Content-Length: 32767\r\n" + "Expires: Sun, 9 Jan 1972 00:00:00 GMT\r\n", + sessioncookie); + ff_http_set_headers(rt->rtsp_hd_out, headers); + ff_http_set_chunked_transfer_encoding(rt->rtsp_hd_out, 0); + + /* Initialize the authentication state for the POST session. The HTTP + * protocol implementation doesn't properly handle multi-pass + * authentication for POST requests, since it would require one of + * the following: + * - implementing Expect: 100-continue, which many HTTP servers + * don't support anyway, even less the RTSP servers that do HTTP + * tunneling + * - sending the whole POST data until getting a 401 reply specifying + * what authentication method to use, then resending all that data + * - waiting for potential 401 replies directly after sending the + * POST header (waiting for some unspecified time) + * Therefore, we copy the full auth state, which works for both basic + * and digest. (For digest, we would have to synchronize the nonce + * count variable between the two sessions, if we'd do more requests + * with the original session, though.) + */ + ff_http_init_auth_state(rt->rtsp_hd_out, rt->rtsp_hd); + + /* complete the connection */ + if (url_connect(rt->rtsp_hd_out)) { + err = AVERROR(EIO); + goto fail; + } + } else { + /* open the tcp connection */ + ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL); + if (url_open(&rt->rtsp_hd, tcpname, URL_RDWR) < 0) { + err = AVERROR(EIO); + goto fail; + } + rt->rtsp_hd_out = rt->rtsp_hd; } - rtsp_hd_out = rtsp_hd; - rt->rtsp_hd = rtsp_hd; - rt->rtsp_hd_out = rtsp_hd_out; rt->seq = 0; - tcp_fd = url_get_file_handle(rtsp_hd); + tcp_fd = url_get_file_handle(rt->rtsp_hd); if (!getpeername(tcp_fd, (struct sockaddr*) &peer, &peer_len)) { getnameinfo((struct sockaddr*) &peer, peer_len, host, sizeof(host), NULL, 0, NI_NUMERICHOST); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtsp.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtsp.h index a28bb94bb..2853253e4 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtsp.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtsp.h @@ -49,6 +49,15 @@ enum RTSPTransport { RTSP_TRANSPORT_NB }; +/** + * Transport mode for the RTSP data. This may be plain, or + * tunneled, which is done over HTTP. + */ +enum RTSPControlTransport { + RTSP_MODE_PLAIN, /**< Normal RTSP */ + RTSP_MODE_TUNNEL /**< RTSP over HTTP (tunneling) */ +}; + #define RTSP_DEFAULT_PORT 554 #define RTSP_MAX_TRANSPORTS 8 #define RTSP_TCP_MAX_PACKET_SIZE 1472 @@ -181,7 +190,7 @@ enum RTSPServerType { * @todo Use ByteIOContext instead of URLContext */ typedef struct RTSPState { - URLContext *rtsp_hd; /* RTSP TCP connexion handle */ + URLContext *rtsp_hd; /* RTSP TCP connection handle */ /** number of items in the 'rtsp_streams' variable */ int nb_rtsp_streams; @@ -282,6 +291,9 @@ typedef struct RTSPState { /** Additional output handle, used when input and output are done * separately, eg for HTTP tunneling. */ URLContext *rtsp_hd_out; + + /** RTSP transport mode, such as plain or tunneled. */ + enum RTSPControlTransport control_transport; } RTSPState; /** @@ -311,11 +323,6 @@ typedef struct RTSPStream { int sdp_payload_type; /**< payload type */ //@} - /** rtp payload parsing infos from SDP (i.e. mapping between private - * payload IDs and media-types (string), so that we can derive what - * type of payload we're dealing with (and how to parse it). */ - RTPPayloadData rtp_payload_data; - /** The following are used for dynamic protocols (rtp_*.c/rdt.c) */ //@{ /** handler structure */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtspenc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtspenc.c index 0baee1d14..5923ea027 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtspenc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/rtspenc.c @@ -92,7 +92,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) interleave_header[0] = '$'; interleave_header[1] = id; AV_WB16(interleave_header + 2, packet_len); - url_write(rt->rtsp_hd, interleaved_packet, 4 + packet_len); + url_write(rt->rtsp_hd_out, interleaved_packet, 4 + packet_len); ptr += packet_len; size -= packet_len; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/sdp.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/sdp.c index 6bf05dbe3..b34b944e5 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/sdp.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/sdp.c @@ -109,7 +109,7 @@ static int sdp_get_address(char *dest_addr, int size, int *ttl, const char *url) const char *p; char proto[32]; - ff_url_split(proto, sizeof(proto), NULL, 0, dest_addr, size, &port, NULL, 0, url); + av_url_split(proto, sizeof(proto), NULL, 0, dest_addr, size, &port, NULL, 0, url); *ttl = 0; @@ -149,6 +149,19 @@ static char *extradata2psets(AVCodecContext *c) return NULL; } + if (c->extradata[0] == 1) { + uint8_t *dummy_p; + int dummy_int; + AVBitStreamFilterContext *bsfc= av_bitstream_filter_init("h264_mp4toannexb"); + + if (!bsfc) { + av_log(c, AV_LOG_ERROR, "Cannot open the h264_mp4toannexb BSF!\n"); + + return NULL; + } + av_bitstream_filter_filter(bsfc, c, NULL, &dummy_p, &dummy_int, NULL, 0, 0); + av_bitstream_filter_close(bsfc); + } psets = av_mallocz(MAX_PSET_SIZE); if (psets == NULL) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/smacker.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/smacker.c index 0dcc28655..89e9e35df 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/smacker.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/smacker.c @@ -213,10 +213,10 @@ static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap) av_free(smk->frm_flags); return AVERROR(EIO); } - ((int32_t*)st->codec->extradata)[0] = le2me_32(smk->mmap_size); - ((int32_t*)st->codec->extradata)[1] = le2me_32(smk->mclr_size); - ((int32_t*)st->codec->extradata)[2] = le2me_32(smk->full_size); - ((int32_t*)st->codec->extradata)[3] = le2me_32(smk->type_size); + ((int32_t*)st->codec->extradata)[0] = av_le2ne32(smk->mmap_size); + ((int32_t*)st->codec->extradata)[1] = av_le2ne32(smk->mclr_size); + ((int32_t*)st->codec->extradata)[2] = av_le2ne32(smk->full_size); + ((int32_t*)st->codec->extradata)[3] = av_le2ne32(smk->type_size); smk->curstream = -1; smk->nextpos = url_ftell(pb); @@ -236,7 +236,7 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) int pos; if (url_feof(s->pb) || smk->cur_frame >= smk->frames) - return AVERROR(EIO); + return AVERROR_EOF; /* if we demuxed all streams, pass another frame */ if(smk->curstream < 0) { diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/sol.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/sol.c index 3ae2d04bb..a7faacc8e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/sol.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/sol.c @@ -34,7 +34,7 @@ static int sol_probe(AVProbeData *p) { /* check file header */ uint16_t magic; - magic=le2me_16(*((uint16_t*)p->buf)); + magic=av_le2ne16(*((uint16_t*)p->buf)); if ((magic == 0x0B8D || magic == 0x0C0D || magic == 0x0C8D) && p->buf[2] == 'S' && p->buf[3] == 'O' && p->buf[4] == 'L' && p->buf[5] == 0) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/spdif.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/spdif.c index b37a9d61b..ac84c50e0 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/spdif.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/spdif.c @@ -43,7 +43,7 @@ #include "avformat.h" #include "libavcodec/ac3.h" #include "libavcodec/dca.h" -#include "libavcodec/aac_parser.h" +#include "libavcodec/aacadtsdec.h" #define SYNCWORD1 0xF872 #define SYNCWORD2 0x4E1F @@ -61,13 +61,20 @@ enum IEC958DataType { IEC958_DTS1 = 0x0B, ///< DTS type I (512 samples) IEC958_DTS2 = 0x0C, ///< DTS type II (1024 samples) IEC958_DTS3 = 0x0D, ///< DTS type III (2048 samples) + IEC958_ATRAC = 0x0E, ///< Atrac data + IEC958_ATRAC3 = 0x0F, ///< Atrac 3 data + IEC958_ATRACX = 0x10, ///< Atrac 3 plus data + IEC958_DTSHD = 0x11, ///< DTS HD data + IEC958_WMAPRO = 0x12, ///< WMA 9 Professional data IEC958_MPEG2_AAC_LSF_2048 = 0x13, ///< MPEG-2 AAC ADTS half-rate low sampling frequency IEC958_MPEG2_AAC_LSF_4096 = 0x13 | 0x20, ///< MPEG-2 AAC ADTS quarter-rate low sampling frequency + IEC958_EAC3 = 0x15, ///< E-AC-3 data + IEC958_TRUEHD = 0x16, ///< TrueHD data }; typedef struct IEC958Context { enum IEC958DataType data_type; ///< burst info - reference to type of payload of the data-burst - int pkt_size; ///< length code in bytes + int pkt_size; ///< length code in bits int pkt_offset; ///< data burst repetition period in bytes uint8_t *buffer; ///< allocated buffer, used for swap bytes int buffer_size; ///< size of allocated buffer @@ -83,17 +90,17 @@ static void bswap_buf16(uint16_t *dst, const uint16_t *src, int w) int i; for (i = 0; i + 8 <= w; i += 8) { - dst[i + 0] = bswap_16(src[i + 0]); - dst[i + 1] = bswap_16(src[i + 1]); - dst[i + 2] = bswap_16(src[i + 2]); - dst[i + 3] = bswap_16(src[i + 3]); - dst[i + 4] = bswap_16(src[i + 4]); - dst[i + 5] = bswap_16(src[i + 5]); - dst[i + 6] = bswap_16(src[i + 6]); - dst[i + 7] = bswap_16(src[i + 7]); + dst[i + 0] = av_bswap16(src[i + 0]); + dst[i + 1] = av_bswap16(src[i + 1]); + dst[i + 2] = av_bswap16(src[i + 2]); + dst[i + 3] = av_bswap16(src[i + 3]); + dst[i + 4] = av_bswap16(src[i + 4]); + dst[i + 5] = av_bswap16(src[i + 5]); + dst[i + 6] = av_bswap16(src[i + 6]); + dst[i + 7] = av_bswap16(src[i + 7]); } for (; i < w; i++) - dst[i + 0] = bswap_16(src[i + 0]); + dst[i + 0] = av_bswap16(src[i + 0]); } static int spdif_header_ac3(AVFormatContext *s, AVPacket *pkt) @@ -103,7 +110,6 @@ static int spdif_header_ac3(AVFormatContext *s, AVPacket *pkt) ctx->data_type = IEC958_AC3 | (bitstream_mode << 8); ctx->pkt_offset = AC3_FRAME_SIZE << 2; - ctx->pkt_size = FFALIGN(pkt->size, 2); return 0; } @@ -143,7 +149,6 @@ static int spdif_header_dts(AVFormatContext *s, AVPacket *pkt) return -1; } ctx->pkt_offset = blocks << 7; - ctx->pkt_size = FFALIGN(pkt->size, 2); return 0; } @@ -179,7 +184,6 @@ static int spdif_header_mpeg(AVFormatContext *s, AVPacket *pkt) ctx->data_type = mpeg_data_type [version & 1][layer]; ctx->pkt_offset = mpeg_pkt_offset[version & 1][layer]; } - ctx->pkt_size = FFALIGN(pkt->size, 2); // TODO Data type dependant info (normal/karaoke, dynamic range control) return 0; } @@ -198,7 +202,6 @@ static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt) return -1; } - ctx->pkt_size = FFALIGN(pkt->size, 2); ctx->pkt_offset = hdr.samples << 2; switch (hdr.num_aac_frames) { case 1: @@ -257,15 +260,12 @@ static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt) IEC958Context *ctx = s->priv_data; int ret, padding; + ctx->pkt_size = FFALIGN(pkt->size, 2) << 3; ret = ctx->header_info(s, pkt); if (ret < 0) return -1; - if (ctx->pkt_size > pkt->size + 1) { - av_log(s, AV_LOG_ERROR, "not enough data for requested frame size\n"); - return -1; - } - padding = (ctx->pkt_offset - BURST_HEADER_SIZE - ctx->pkt_size) >> 1; + padding = (ctx->pkt_offset - BURST_HEADER_SIZE - pkt->size) >> 1; if (padding < 0) { av_log(s, AV_LOG_ERROR, "bitrate is too high\n"); return -1; @@ -274,18 +274,21 @@ static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt) put_le16(s->pb, SYNCWORD1); //Pa put_le16(s->pb, SYNCWORD2); //Pb put_le16(s->pb, ctx->data_type); //Pc - put_le16(s->pb, ctx->pkt_size << 3); //Pd + put_le16(s->pb, ctx->pkt_size); //Pd #if HAVE_BIGENDIAN - put_buffer(s->pb, pkt->data, ctx->pkt_size); + put_buffer(s->pb, pkt->data, pkt->size & ~1); #else - av_fast_malloc(&ctx->buffer, &ctx->buffer_size, ctx->pkt_size + FF_INPUT_BUFFER_PADDING_SIZE); + av_fast_malloc(&ctx->buffer, &ctx->buffer_size, pkt->size + FF_INPUT_BUFFER_PADDING_SIZE); if (!ctx->buffer) return AVERROR(ENOMEM); - bswap_buf16((uint16_t *)ctx->buffer, (uint16_t *)pkt->data, ctx->pkt_size >> 1); - put_buffer(s->pb, ctx->buffer, ctx->pkt_size); + bswap_buf16((uint16_t *)ctx->buffer, (uint16_t *)pkt->data, pkt->size >> 1); + put_buffer(s->pb, ctx->buffer, pkt->size & ~1); #endif + if (pkt->size & 1) + put_be16(s->pb, pkt->data[pkt->size - 1]); + for (; padding > 0; padding--) put_be16(s->pb, 0); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/tcp.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/tcp.c index fb6dec798..1827aa00a 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/tcp.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/tcp.c @@ -45,7 +45,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags) char hostname[1024],proto[1024],path[1024]; char portstr[10]; - ff_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), + av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), &port, path, sizeof(path), uri); if (strcmp(proto,"tcp") || port <= 0 || port >= 65536) return AVERROR(EINVAL); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/tta.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/tta.c index 66d3bad90..628932da0 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/tta.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/tta.c @@ -32,7 +32,7 @@ static int tta_probe(AVProbeData *p) { const uint8_t *d = p->buf; - if (ff_id3v2_match(d)) + if (ff_id3v2_match(d, ID3v2_DEFAULT_MAGIC)) d += ff_id3v2_tag_len(d); if (d - p->buf >= p->buf_size) @@ -50,7 +50,7 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap) int i, channels, bps, samplerate, datalen, framelen; uint64_t framepos, start_offset; - ff_id3v2_read(s); + ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC); if (!av_metadata_get(s->metadata, "", NULL, AV_METADATA_IGNORE_SUFFIX)) ff_id3v1_read(s); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/udp.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/udp.c index 0ec24cd4e..6bd5c9c39 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/udp.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/udp.c @@ -256,7 +256,7 @@ static int udp_port(struct sockaddr_storage *addr, int addr_len) * 'pkt_size=n' : set max packet size * 'reuse=1' : enable reusing the socket * - * @param s1 media file context + * @param h media file context * @param uri of the remote server * @return zero if no error. */ @@ -266,7 +266,7 @@ int udp_set_remote_url(URLContext *h, const char *uri) char hostname[256]; int port; - ff_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri); + av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri); /* set the destination address */ s->dest_addr_len = udp_set_url(&s->dest_addr, hostname, port); @@ -279,8 +279,8 @@ int udp_set_remote_url(URLContext *h, const char *uri) } /** - * Return the local port used by the UDP connexion - * @param s1 media file context + * Return the local port used by the UDP connection + * @param h media file context * @return the local port number */ int udp_get_local_port(URLContext *h) @@ -347,9 +347,9 @@ static int udp_open(URLContext *h, const char *uri, int flags) } /* fill the dest addr */ - ff_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri); + av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri); - /* XXX: fix ff_url_split */ + /* XXX: fix av_url_split */ if (hostname[0] == '\0' || hostname[0] == '?') { /* only accepts null hostname if input */ if (flags & URL_WRONLY) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/utils.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/utils.c index af939c12a..6fa4dff41 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/utils.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/utils.c @@ -283,8 +283,38 @@ AVInputFormat *av_find_input_format(const char *short_name) return NULL; } -/* memory handling */ +#if LIBAVFORMAT_VERSION_MAJOR < 53 && CONFIG_SHARED && HAVE_SYMVER +FF_SYMVER(void, av_destruct_packet_nofree, (AVPacket *pkt), "LIBAVFORMAT_52") +{ + av_destruct_packet_nofree(pkt); +} + +FF_SYMVER(void, av_destruct_packet, (AVPacket *pkt), "LIBAVFORMAT_52") +{ + av_destruct_packet(pkt); +} + +FF_SYMVER(int, av_new_packet, (AVPacket *pkt, int size), "LIBAVFORMAT_52") +{ + return av_new_packet(pkt, size); +} + +FF_SYMVER(int, av_dup_packet, (AVPacket *pkt), "LIBAVFORMAT_52") +{ + return av_dup_packet(pkt); +} + +FF_SYMVER(void, av_free_packet, (AVPacket *pkt), "LIBAVFORMAT_52") +{ + av_free_packet(pkt); +} +FF_SYMVER(void, av_init_packet, (AVPacket *pkt), "LIBAVFORMAT_52") +{ + av_log(NULL, AV_LOG_WARNING, "Diverting av_*_packet function calls to libavcodec. Recompile to improve performance\n"); + av_init_packet(pkt); +} +#endif int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size) { @@ -1047,7 +1077,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt) if(pkt->data == st->cur_pkt.data && pkt->size == st->cur_pkt.size){ s->cur_st = NULL; pkt->destruct= st->cur_pkt.destruct; - st->cur_pkt.destruct= + st->cur_pkt.destruct= NULL; st->cur_pkt.data = NULL; assert(st->cur_len == 0); }else{ @@ -1075,8 +1105,6 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt) if (ret < 0) { if (ret == AVERROR(EAGAIN)) return ret; - if (ret == AVERROR_IO) - return ret; /* return the last frames, if any */ for(i = 0; i < s->nb_streams; i++) { st = s->streams[i]; @@ -1161,11 +1189,11 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) AVPacket *next_pkt= &pktl->pkt; if(genpts && next_pkt->dts != AV_NOPTS_VALUE){ + int wrap_bits = s->streams[next_pkt->stream_index]->pts_wrap_bits; while(pktl && next_pkt->pts == AV_NOPTS_VALUE){ if( pktl->pkt.stream_index == next_pkt->stream_index - && next_pkt->dts < pktl->pkt.dts - && pktl->pkt.pts != pktl->pkt.dts //not b frame - /*&& pktl->pkt.dts != AV_NOPTS_VALUE*/){ + && (0 > av_compare_mod(next_pkt->dts, pktl->pkt.dts, 2LL << (wrap_bits - 1))) + && av_compare_mod(pktl->pkt.pts, pktl->pkt.dts, 2LL << (wrap_bits - 1))) { //not b frame next_pkt->pts= pktl->pkt.dts; } pktl= pktl->next; @@ -1717,7 +1745,7 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int /*******************************************************/ /** - * Returns TRUE if the stream has accurate duration in any stream. + * Return TRUE if the stream has accurate duration in any stream. * * @return TRUE if the stream has accurate duration for at least one component. */ @@ -1725,8 +1753,6 @@ static int av_has_duration(AVFormatContext *ic) { int i; AVStream *st; - if(ic->duration != AV_NOPTS_VALUE) - return 1; for(i = 0;i < ic->nb_streams; i++) { st = ic->streams[i]; @@ -1777,14 +1803,14 @@ static void av_update_stream_timings(AVFormatContext *ic) duration = end_time - start_time; } } - if (duration != INT64_MIN && ic->duration == AV_NOPTS_VALUE) { + if (duration != INT64_MIN) { ic->duration = duration; - } - if (ic->file_size > 0 && ic->duration != AV_NOPTS_VALUE) { + if (ic->file_size > 0) { /* compute the bitrate */ ic->bit_rate = (double)ic->file_size * 8.0 * AV_TIME_BASE / (double)ic->duration; } + } } static void fill_all_stream_timings(AVFormatContext *ic) @@ -1920,43 +1946,6 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset } } -static void av_estimate_timings_from_pts2(AVFormatContext *ic, int64_t old_offset) -{ - AVStream *st; - int i, step= 1024; - int64_t ts, pos; - - for(i=0;inb_streams;i++) { - st = ic->streams[i]; - - pos = 0; - ts = ic->iformat->read_timestamp(ic, i, &pos, DURATION_MAX_READ_SIZE); - if (ts == AV_NOPTS_VALUE) - continue; - if (st->start_time == AV_NOPTS_VALUE || - st->start_time > ts) - st->start_time = ts; - - pos = url_fsize(ic->pb) - 1; - do { - pos -= step; - ts = ic->iformat->read_timestamp(ic, i, &pos, pos + step); - step += step; - } while (ts == AV_NOPTS_VALUE && pos >= step && step < DURATION_MAX_READ_SIZE); - - if (ts == AV_NOPTS_VALUE) - continue; - - if (st->duration == AV_NOPTS_VALUE - || st->duration < ts - st->start_time) - st->duration = ts - st->start_time; - } - - fill_all_stream_timings(ic); - - url_fseek(ic->pb, old_offset, SEEK_SET); -} - static void av_estimate_timings(AVFormatContext *ic, int64_t old_offset) { int64_t file_size; @@ -1980,10 +1969,6 @@ static void av_estimate_timings(AVFormatContext *ic, int64_t old_offset) /* at least one component has timings - we use them for all the components */ fill_all_stream_timings(ic); - } else if (ic->iformat->read_timestamp && - file_size && !url_is_streamed(ic->pb)) { - /* get accurate estimate from the PTSes */ - av_estimate_timings_from_pts2(ic, old_offset); } else { av_log(ic, AV_LOG_WARNING, "Estimating duration from bitrate, this may be inaccurate\n"); /* less precise: use bitrate info */ @@ -2031,7 +2016,13 @@ static int has_codec_parameters(AVCodecContext *enc) val = 1; break; } - return enc->codec_id != CODEC_ID_PROBE && val != 0; + return enc->codec_id != CODEC_ID_NONE && val != 0; +} + +static int has_decode_delay_been_guessed(AVStream *st) +{ + return st->codec->codec_id != CODEC_ID_H264 || + st->codec_info_nb_frames >= 4 + st->codec->has_b_frames; } static int try_decode_frame(AVStream *st, AVPacket *avpkt) @@ -2050,7 +2041,7 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt) return ret; } - if(!has_codec_parameters(st->codec)){ + if(!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st)){ switch(st->codec->codec_type) { case AVMEDIA_TYPE_VIDEO: avcodec_get_frame_defaults(&picture); @@ -2232,7 +2223,7 @@ int av_find_stream_info(AVFormatContext *ic) break; if(st->parser && st->parser->parser->split && !st->codec->extradata) break; - if(st->first_dts == AV_NOPTS_VALUE && (st->codec->codec_type == CODEC_TYPE_VIDEO || st->codec->codec_type == CODEC_TYPE_AUDIO)) + if(st->first_dts == AV_NOPTS_VALUE) break; } if (i == ic->nb_streams) { @@ -2290,8 +2281,6 @@ int av_find_stream_info(AVFormatContext *ic) } codec_info_duration[st->index] += pkt->duration; } - st->codec_info_nb_frames++; - { int index= pkt->stream_index; int64_t last= last_dts[index]; @@ -2332,9 +2321,10 @@ int av_find_stream_info(AVFormatContext *ic) decompress the frame. We try to avoid that in most cases as it takes longer and uses more memory. For MPEG-4, we need to decompress for QuickTime. */ - if (!has_codec_parameters(st->codec)) + if (!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st)) try_decode_frame(st, pkt); + st->codec_info_nb_frames++; count++; } @@ -2939,7 +2929,7 @@ int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pk } /** - * Interleaves an AVPacket correctly so it can be muxed. + * Interleave an AVPacket correctly so it can be muxed. * @param out the interleaved packet will be output here * @param in the input packet * @param flush 1 if no further packets are available as input and all @@ -3508,12 +3498,30 @@ void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload) pkt_dump_internal(avcl, NULL, level, pkt, dump_payload); } +#if LIBAVFORMAT_VERSION_MAJOR < 53 +attribute_deprecated void ff_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url) +{ + av_url_split(proto, proto_size, + authorization, authorization_size, + hostname, hostname_size, + port_ptr, + path, path_size, + url); +} +#endif + +void av_url_split(char *proto, int proto_size, + char *authorization, int authorization_size, + char *hostname, int hostname_size, + int *port_ptr, + char *path, int path_size, + const char *url) { const char *p, *ls, *at, *col, *brk; @@ -3616,7 +3624,7 @@ int ff_url_join(char *str, int size, const char *proto, str[0] = '\0'; if (proto) av_strlcatf(str, size, "%s://", proto); - if (authorization) + if (authorization && authorization[0]) av_strlcatf(str, size, "%s@", authorization); #if CONFIG_NETWORK && defined(AF_INET6) /* Determine if hostname is a numerical IPv6 address, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/vorbiscomment.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/vorbiscomment.h index 714f1f2b9..fe989a043 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/vorbiscomment.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavformat/vorbiscomment.h @@ -26,7 +26,7 @@ #include "metadata.h" /** - * Calculates the length in bytes of a VorbisComment. This is the minimum + * Calculate the length in bytes of a VorbisComment. This is the minimum * size required by ff_vorbiscomment_write(). * * @param m The metadata structure to be parsed. For no metadata, set to NULL. diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/Makefile b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/Makefile index f6961ac84..9238808ce 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/Makefile +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/Makefile @@ -7,12 +7,15 @@ HEADERS = adler32.h \ avstring.h \ avutil.h \ base64.h \ + bswap.h \ common.h \ crc.h \ error.h \ eval.h \ fifo.h \ intfloat_readwrite.h \ + intreadwrite.h \ + lfg.h \ log.h \ lzo.h \ mathematics.h \ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/adler32.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/adler32.h index 9626c8056..0b890bcc1 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/adler32.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/adler32.h @@ -24,6 +24,18 @@ #include #include "attributes.h" +/** + * Calculate the Adler32 checksum of a buffer. + * + * Passing the return value to a subsequent av_adler32_update() call + * allows the checksum of multiple buffers to be calculated as though + * they were concatenated. + * + * @param adler initial checksum value + * @param buf pointer to input buffer + * @param len size of input buffer + * @return updated checksum + */ unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, unsigned int len) av_pure; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/aes.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/aes.c index d3a271c37..59f1cf34e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/aes.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/aes.c @@ -23,11 +23,18 @@ #include "common.h" #include "aes.h" +typedef union { + uint64_t u64[2]; + uint32_t u32[4]; + uint8_t u8x4[4][4]; + uint8_t u8[16]; +} av_aes_block; + typedef struct AVAES{ // Note: round_key[16] is accessed in the init code, but this only // overwrites state, which does not matter (see also r7471). - uint8_t round_key[15][4][4]; - uint8_t state[2][4][4]; + av_aes_block round_key[15]; + av_aes_block state[2]; int rounds; }AVAES; @@ -47,21 +54,21 @@ static uint32_t enc_multbl[4][256]; static uint32_t dec_multbl[4][256]; #endif -static inline void addkey(uint64_t dst[2], const uint64_t src[2], const uint64_t round_key[2]){ - dst[0] = src[0] ^ round_key[0]; - dst[1] = src[1] ^ round_key[1]; +static inline void addkey(av_aes_block *dst, const av_aes_block *src, const av_aes_block *round_key){ + dst->u64[0] = src->u64[0] ^ round_key->u64[0]; + dst->u64[1] = src->u64[1] ^ round_key->u64[1]; } -static void subshift(uint8_t s0[2][16], int s, const uint8_t *box){ - uint8_t (*s1)[16]= s0[0] - s; - uint8_t (*s3)[16]= s0[0] + s; - s0[0][0]=box[s0[1][ 0]]; s0[0][ 4]=box[s0[1][ 4]]; s0[0][ 8]=box[s0[1][ 8]]; s0[0][12]=box[s0[1][12]]; - s1[0][3]=box[s1[1][ 7]]; s1[0][ 7]=box[s1[1][11]]; s1[0][11]=box[s1[1][15]]; s1[0][15]=box[s1[1][ 3]]; - s0[0][2]=box[s0[1][10]]; s0[0][10]=box[s0[1][ 2]]; s0[0][ 6]=box[s0[1][14]]; s0[0][14]=box[s0[1][ 6]]; - s3[0][1]=box[s3[1][13]]; s3[0][13]=box[s3[1][ 9]]; s3[0][ 9]=box[s3[1][ 5]]; s3[0][ 5]=box[s3[1][ 1]]; +static void subshift(av_aes_block s0[2], int s, const uint8_t *box){ + av_aes_block *s1= (av_aes_block *)(s0[0].u8 - s); + av_aes_block *s3= (av_aes_block *)(s0[0].u8 + s); + s0[0].u8[0]=box[s0[1].u8[ 0]]; s0[0].u8[ 4]=box[s0[1].u8[ 4]]; s0[0].u8[ 8]=box[s0[1].u8[ 8]]; s0[0].u8[12]=box[s0[1].u8[12]]; + s1[0].u8[3]=box[s1[1].u8[ 7]]; s1[0].u8[ 7]=box[s1[1].u8[11]]; s1[0].u8[11]=box[s1[1].u8[15]]; s1[0].u8[15]=box[s1[1].u8[ 3]]; + s0[0].u8[2]=box[s0[1].u8[10]]; s0[0].u8[10]=box[s0[1].u8[ 2]]; s0[0].u8[ 6]=box[s0[1].u8[14]]; s0[0].u8[14]=box[s0[1].u8[ 6]]; + s3[0].u8[1]=box[s3[1].u8[13]]; s3[0].u8[13]=box[s3[1].u8[ 9]]; s3[0].u8[ 9]=box[s3[1].u8[ 5]]; s3[0].u8[ 5]=box[s3[1].u8[ 1]]; } -static inline int mix_core(uint32_t multbl[4][256], int a, int b, int c, int d){ +static inline int mix_core(uint32_t multbl[][256], int a, int b, int c, int d){ #if CONFIG_SMALL #define ROT(x,s) ((x<>(32-s))) return multbl[0][a] ^ ROT(multbl[0][b], 8) ^ ROT(multbl[0][c], 16) ^ ROT(multbl[0][d], 24); @@ -70,41 +77,45 @@ static inline int mix_core(uint32_t multbl[4][256], int a, int b, int c, int d){ #endif } -static inline void mix(uint8_t state[2][4][4], uint32_t multbl[4][256], int s1, int s3){ - ((uint32_t *)(state))[0] = mix_core(multbl, state[1][0][0], state[1][s1 ][1], state[1][2][2], state[1][s3 ][3]); - ((uint32_t *)(state))[1] = mix_core(multbl, state[1][1][0], state[1][s3-1][1], state[1][3][2], state[1][s1-1][3]); - ((uint32_t *)(state))[2] = mix_core(multbl, state[1][2][0], state[1][s3 ][1], state[1][0][2], state[1][s1 ][3]); - ((uint32_t *)(state))[3] = mix_core(multbl, state[1][3][0], state[1][s1-1][1], state[1][1][2], state[1][s3-1][3]); +static inline void mix(av_aes_block state[2], uint32_t multbl[][256], int s1, int s3){ + uint8_t (*src)[4] = state[1].u8x4; + state[0].u32[0] = mix_core(multbl, src[0][0], src[s1 ][1], src[2][2], src[s3 ][3]); + state[0].u32[1] = mix_core(multbl, src[1][0], src[s3-1][1], src[3][2], src[s1-1][3]); + state[0].u32[2] = mix_core(multbl, src[2][0], src[s3 ][1], src[0][2], src[s1 ][3]); + state[0].u32[3] = mix_core(multbl, src[3][0], src[s1-1][1], src[1][2], src[s3-1][3]); } -static inline void crypt(AVAES *a, int s, const uint8_t *sbox, const uint32_t *multbl){ +static inline void crypt(AVAES *a, int s, const uint8_t *sbox, uint32_t multbl[][256]){ int r; for(r=a->rounds-1; r>0; r--){ mix(a->state, multbl, 3-s, 1+s); - addkey(a->state[1], a->state[0], a->round_key[r]); + addkey(&a->state[1], &a->state[0], &a->round_key[r]); } - subshift(a->state[0][0], s, sbox); + subshift(&a->state[0], s, sbox); } -void av_aes_crypt(AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt){ +void av_aes_crypt(AVAES *a, uint8_t *dst_, const uint8_t *src_, int count, uint8_t *iv_, int decrypt){ + av_aes_block *dst = (av_aes_block *)dst_; + const av_aes_block *src = (const av_aes_block *)src_; + av_aes_block *iv = (av_aes_block *)iv_; while(count--){ - addkey(a->state[1], src, a->round_key[a->rounds]); + addkey(&a->state[1], src, &a->round_key[a->rounds]); if(decrypt) { crypt(a, 0, inv_sbox, dec_multbl); if(iv){ - addkey(a->state[0], a->state[0], iv); + addkey(&a->state[0], &a->state[0], iv); memcpy(iv, src, 16); } - addkey(dst, a->state[0], a->round_key[0]); + addkey(dst, &a->state[0], &a->round_key[0]); }else{ - if(iv) addkey(a->state[1], a->state[1], iv); + if(iv) addkey(&a->state[1], &a->state[1], iv); crypt(a, 2, sbox, enc_multbl); - addkey(dst, a->state[0], a->round_key[0]); + addkey(dst, &a->state[0], &a->round_key[0]); if(iv) memcpy(iv, dst, 16); } - src+=16; - dst+=16; + src++; + dst++; } } @@ -130,7 +141,7 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) { uint8_t log8[256]; uint8_t alog8[512]; - if(!enc_multbl[0][sizeof(enc_multbl)/sizeof(enc_multbl[0][0])-1]){ + if(!enc_multbl[FF_ARRAY_ELEMS(enc_multbl)-1][FF_ARRAY_ELEMS(enc_multbl[0])-1]){ j=1; for(i=0; i<255; i++){ alog8[i]= @@ -158,7 +169,7 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) { memcpy(tk, key, KC*4); for(t= 0; t < (rounds+1)*16;) { - memcpy(a->round_key[0][0]+t, tk, KC*4); + memcpy(a->round_key[0].u8+t, tk, KC*4); t+= KC*4; for(i = 0; i < 4; i++) @@ -175,16 +186,16 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt) { if(decrypt){ for(i=1; iround_key[i][0], 16); - subshift(tmp[1], 0, sbox); + av_aes_block tmp[3]; + memcpy(&tmp[2], &a->round_key[i], 16); + subshift(&tmp[1], 0, sbox); mix(tmp, dec_multbl, 1, 3); - memcpy(a->round_key[i][0], tmp[0], 16); + memcpy(&a->round_key[i], &tmp[0], 16); } }else{ for(i=0; i<(rounds+1)>>1; i++){ for(j=0; j<16; j++) - FFSWAP(int, a->round_key[i][0][j], a->round_key[rounds-i][0][j]); + FFSWAP(int, a->round_key[i].u8[j], a->round_key[rounds-i].u8[j]); } } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/aes.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/aes.h index 1ca853d93..368f70cbb 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/aes.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/aes.h @@ -28,14 +28,14 @@ extern const int av_aes_size; struct AVAES; /** - * Initializes an AVAES context. + * Initialize an AVAES context. * @param key_bits 128, 192 or 256 * @param decrypt 0 for encryption, 1 for decryption */ int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt); /** - * Encrypts / decrypts. + * Encrypt or decrypt a buffer using a previously initialized context. * @param count number of 16 byte blocks * @param dst destination array, can be equal to src * @param src source array, can be equal to dst diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/arm/bswap.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/arm/bswap.h index 912635071..c5e74cc6d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/arm/bswap.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/arm/bswap.h @@ -26,15 +26,15 @@ #ifdef __ARMCC_VERSION #if HAVE_ARMV6 -#define bswap_16 bswap_16 -static av_always_inline av_const unsigned bswap_16(unsigned x) +#define av_bswap16 av_bswap16 +static av_always_inline av_const unsigned av_bswap16(unsigned x) { __asm { rev16 x, x } return x; } -#define bswap_32 bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) +#define av_bswap32 av_bswap32 +static av_always_inline av_const uint32_t av_bswap32(uint32_t x) { return __rev(x); } @@ -43,16 +43,16 @@ static av_always_inline av_const uint32_t bswap_32(uint32_t x) #elif HAVE_INLINE_ASM #if HAVE_ARMV6 -#define bswap_16 bswap_16 -static av_always_inline av_const unsigned bswap_16(unsigned x) +#define av_bswap16 av_bswap16 +static av_always_inline av_const unsigned av_bswap16(unsigned x) { __asm__("rev16 %0, %0" : "+r"(x)); return x; } #endif -#define bswap_32 bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) +#define av_bswap32 av_bswap32 +static av_always_inline av_const uint32_t av_bswap32(uint32_t x) { #if HAVE_ARMV6 __asm__("rev %0, %0" : "+r"(x)); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/arm/intmath.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/arm/intmath.h index 48a05eaa1..2c0aa3b11 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/arm/intmath.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/arm/intmath.h @@ -21,12 +21,16 @@ #ifndef AVUTIL_ARM_INTMATH_H #define AVUTIL_ARM_INTMATH_H +#include + #include "config.h" #include "libavutil/attributes.h" #if HAVE_INLINE_ASM #if HAVE_ARMV6 + +#define FASTDIV FASTDIV static inline av_const int FASTDIV(int a, int b) { int r, t; @@ -37,7 +41,42 @@ static inline av_const int FASTDIV(int a, int b) : "=&r"(r), "=&r"(t) : "r"(a), "r"(b), "r"(ff_inverse)); return r; } -#else + +#define av_clip_uint8 av_clip_uint8_arm +static inline av_const uint8_t av_clip_uint8_arm(int a) +{ + unsigned x; + __asm__ volatile ("usat %0, #8, %1" : "=r"(x) : "r"(a)); + return x; +} + +#define av_clip_int8 av_clip_int8_arm +static inline av_const uint8_t av_clip_int8_arm(int a) +{ + unsigned x; + __asm__ volatile ("ssat %0, #8, %1" : "=r"(x) : "r"(a)); + return x; +} + +#define av_clip_uint16 av_clip_uint16_arm +static inline av_const uint16_t av_clip_uint16_arm(int a) +{ + unsigned x; + __asm__ volatile ("usat %0, #16, %1" : "=r"(x) : "r"(a)); + return x; +} + +#define av_clip_int16 av_clip_int16_arm +static inline av_const int16_t av_clip_int16_arm(int a) +{ + int x; + __asm__ volatile ("ssat %0, #16, %1" : "=r"(x) : "r"(a)); + return x; +} + +#else /* HAVE_ARMV6 */ + +#define FASTDIV FASTDIV static inline av_const int FASTDIV(int a, int b) { int r, t; @@ -45,9 +84,19 @@ static inline av_const int FASTDIV(int a, int b) : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b])); return r; } -#endif -#define FASTDIV FASTDIV +#endif /* HAVE_ARMV6 */ + +#define av_clipl_int32 av_clipl_int32_arm +static inline av_const int32_t av_clipl_int32_arm(int64_t a) +{ + int x, y; + __asm__ volatile ("adds %1, %R2, %Q2, lsr #31 \n\t" + "mvnne %1, #1<<31 \n\t" + "eorne %0, %1, %R2, asr #31 \n\t" + : "=r"(x), "=&r"(y) : "r"(a)); + return x; +} #endif /* HAVE_INLINE_ASM */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/avr32/bswap.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/avr32/bswap.h index e8c8ddc4e..e79d53f36 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/avr32/bswap.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/avr32/bswap.h @@ -25,15 +25,15 @@ #if HAVE_INLINE_ASM -#define bswap_16 bswap_16 -static av_always_inline av_const uint16_t bswap_16(uint16_t x) +#define av_bswap16 av_bswap16 +static av_always_inline av_const uint16_t av_bswap16(uint16_t x) { __asm__ ("swap.bh %0" : "+r"(x)); return x; } -#define bswap_32 bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) +#define av_bswap32 av_bswap32 +static av_always_inline av_const uint32_t av_bswap32(uint32_t x) { __asm__ ("swap.b %0" : "+r"(x)); return x; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/avr32/intreadwrite.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/avr32/intreadwrite.h index 3e468b4e8..c6fd3aa47 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/avr32/intreadwrite.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/avr32/intreadwrite.h @@ -106,8 +106,8 @@ static av_always_inline void AV_WB32(void *p, uint32_t v) } /* These two would be defined by generic code, but we need them sooner. */ -#define AV_RL32(p) bswap_32(AV_RB32(p)) -#define AV_WL32(p, v) AV_WB32(p, bswap_32(v)) +#define AV_RL32(p) av_bswap32(AV_RB32(p)) +#define AV_WL32(p, v) AV_WB32(p, av_bswap32(v)) #define AV_WB64 AV_WB64 static av_always_inline void AV_WB64(void *p, uint64_t v) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/avutil.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/avutil.h index 663b386e8..cd1f9bdf5 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/avutil.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/avutil.h @@ -40,7 +40,7 @@ #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) #define LIBAVUTIL_VERSION_MAJOR 50 -#define LIBAVUTIL_VERSION_MINOR 18 +#define LIBAVUTIL_VERSION_MINOR 22 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ @@ -54,17 +54,17 @@ #define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION) /** - * Returns the LIBAVUTIL_VERSION_INT constant. + * Return the LIBAVUTIL_VERSION_INT constant. */ unsigned avutil_version(void); /** - * Returns the libavutil build-time configuration. + * Return the libavutil build-time configuration. */ const char *avutil_configuration(void); /** - * Returns the libavutil license. + * Return the libavutil license. */ const char *avutil_license(void); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/base64.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/base64.h index 477128afa..092980b09 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/base64.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/base64.h @@ -24,25 +24,25 @@ #include /** - * Decodes the base64-encoded string in in and puts the decoded - * data in out. + * Decode a base64-encoded string. * - * @param out_size size in bytes of the out buffer, it should be at - * least 3/4 of the length of in - * @return the number of bytes written, or a negative value in case of - * error + * @param out buffer for decoded data + * @param in null-terminated input string + * @param out_size size in bytes of the out buffer, must be at + * least 3/4 of the length of in + * @return number of bytes written, or a negative value in case of + * invalid input */ int av_base64_decode(uint8_t *out, const char *in, int out_size); /** - * Encodes in base64 the data in in and puts the resulting string - * in out. + * Encode data to base64 and null-terminate. * - * @param out_size size in bytes of the out string, it should be at - * least ((in_size + 2) / 3) * 4 + 1 - * @param in_size size in bytes of the in buffer - * @return the string containing the encoded data, or NULL in case of - * error + * @param out buffer for encoded data + * @param out_size size in bytes of the output buffer, must be at + * least AV_BASE64_SIZE(in_size) + * @param in_size size in bytes of the 'in' buffer + * @return 'out' or NULL in case of error */ char *av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/bfin/bswap.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/bfin/bswap.h index ccdfeb7c8..363ed40bc 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/bfin/bswap.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/bfin/bswap.h @@ -30,8 +30,8 @@ #include "config.h" #include "libavutil/attributes.h" -#define bswap_32 bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) +#define av_bswap32 av_bswap32 +static av_always_inline av_const uint32_t av_bswap32(uint32_t x) { unsigned tmp; __asm__("%1 = %0 >> 8 (V); \n\t" diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/bswap.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/bswap.h index 6dd2a3511..303bcf353 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/bswap.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/bswap.h @@ -27,9 +27,13 @@ #define AVUTIL_BSWAP_H #include -#include "config.h" +#include "libavutil/avconfig.h" #include "attributes.h" +#ifdef HAVE_AV_CONFIG_H + +#include "config.h" + #if ARCH_ARM # include "arm/bswap.h" #elif ARCH_AVR32 @@ -42,22 +46,24 @@ # include "x86/bswap.h" #endif +#endif /* HAVE_AV_CONFIG_H */ + #define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff)) #define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16)) #define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C((x) >> 32)) #define AV_BSWAPC(s, x) AV_BSWAP##s##C(x) -#ifndef bswap_16 -static av_always_inline av_const uint16_t bswap_16(uint16_t x) +#ifndef av_bswap16 +static av_always_inline av_const uint16_t av_bswap16(uint16_t x) { x= (x>>8) | (x<<8); return x; } #endif -#ifndef bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) +#ifndef av_bswap32 +static av_always_inline av_const uint32_t av_bswap32(uint32_t x) { x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); x= (x>>16) | (x<<16); @@ -65,8 +71,8 @@ static av_always_inline av_const uint32_t bswap_32(uint32_t x) } #endif -#ifndef bswap_64 -static inline uint64_t av_const bswap_64(uint64_t x) +#ifndef av_bswap64 +static inline uint64_t av_const av_bswap64(uint64_t x) { #if 0 x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); @@ -78,41 +84,41 @@ static inline uint64_t av_const bswap_64(uint64_t x) 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]); + r.l[0] = av_bswap32 (w.l[1]); + r.l[1] = av_bswap32 (w.l[0]); return r.ll; #endif } #endif -// be2me ... big-endian to machine-endian -// le2me ... little-endian to machine-endian - -#if HAVE_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) -#define AV_BE2MEC(s, x) (x) -#define AV_LE2MEC(s, x) AV_BSWAPC(s, x) +// be2ne ... big-endian to native-endian +// le2ne ... little-endian to native-endian + +#if AV_HAVE_BIGENDIAN +#define av_be2ne16(x) (x) +#define av_be2ne32(x) (x) +#define av_be2ne64(x) (x) +#define av_le2ne16(x) av_bswap16(x) +#define av_le2ne32(x) av_bswap32(x) +#define av_le2ne64(x) av_bswap64(x) +#define AV_BE2NEC(s, x) (x) +#define AV_LE2NEC(s, x) AV_BSWAPC(s, 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) -#define AV_BE2MEC(s, x) AV_BSWAPC(s, x) -#define AV_LE2MEC(s, x) (x) +#define av_be2ne16(x) av_bswap16(x) +#define av_be2ne32(x) av_bswap32(x) +#define av_be2ne64(x) av_bswap64(x) +#define av_le2ne16(x) (x) +#define av_le2ne32(x) (x) +#define av_le2ne64(x) (x) +#define AV_BE2NEC(s, x) AV_BSWAPC(s, x) +#define AV_LE2NEC(s, x) (x) #endif -#define AV_BE2ME16C(x) AV_BE2MEC(16, x) -#define AV_BE2ME32C(x) AV_BE2MEC(32, x) -#define AV_BE2ME64C(x) AV_BE2MEC(64, x) -#define AV_LE2ME16C(x) AV_LE2MEC(16, x) -#define AV_LE2ME32C(x) AV_LE2MEC(32, x) -#define AV_LE2ME64C(x) AV_LE2MEC(64, x) +#define AV_BE2NE16C(x) AV_BE2NEC(16, x) +#define AV_BE2NE32C(x) AV_BE2NEC(32, x) +#define AV_BE2NE64C(x) AV_BE2NEC(64, x) +#define AV_LE2NE16C(x) AV_LE2NEC(16, x) +#define AV_LE2NE32C(x) AV_LE2NEC(32, x) +#define AV_LE2NE64C(x) AV_LE2NEC(64, x) #endif /* AVUTIL_BSWAP_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/colorspace.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/colorspace.h similarity index 97% rename from xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/colorspace.h rename to xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/colorspace.h index 4ec081e9d..f43815981 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavcodec/colorspace.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/colorspace.h @@ -24,8 +24,8 @@ * Various defines for YUV<->RGB conversion */ -#ifndef AVCODEC_COLORSPACE_H -#define AVCODEC_COLORSPACE_H +#ifndef AVUTIL_COLORSPACE_H +#define AVUTIL_COLORSPACE_H #define SCALEBITS 10 #define ONE_HALF (1 << (SCALEBITS - 1)) @@ -108,4 +108,4 @@ static inline int C_JPEG_TO_CCIR(int y) { (((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) -#endif /* AVCODEC_COLORSPACE_H */ +#endif /* AVUTIL_COLORSPACE_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/common.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/common.h index 54a3e81d5..f9c03db55 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/common.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/common.h @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -91,21 +90,17 @@ static inline av_const int av_log2_16bit_c(unsigned int v) # include "intmath.h" #endif -#ifndef av_log2 -# define av_log2 av_log2_c -#endif -#ifndef av_log2_16bit -# define av_log2_16bit av_log2_16bit_c -#endif +/* Pull in unguarded fallback defines at the end of this file. */ +#include "common.h" /** - * Clips a signed integer value into the amin-amax range. + * Clip a signed integer value into the amin-amax range. * @param a value to clip * @param amin minimum value of the clip range * @param amax maximum value of the clip range * @return clipped value */ -static inline av_const int av_clip(int a, int amin, int amax) +static inline av_const int av_clip_c(int a, int amin, int amax) { if (a < amin) return amin; else if (a > amax) return amax; @@ -113,87 +108,96 @@ static inline av_const int av_clip(int a, int amin, int amax) } /** - * Clips a signed integer value into the 0-255 range. + * Clip a signed integer value into the 0-255 range. * @param a value to clip * @return clipped value */ -static inline av_const uint8_t av_clip_uint8(int a) +static inline av_const uint8_t av_clip_uint8_c(int a) { if (a&(~0xFF)) return (-a)>>31; else return a; } /** - * Clips a signed integer value into the 0-65535 range. + * Clip a signed integer value into the -128,127 range. * @param a value to clip * @return clipped value */ -static inline av_const uint16_t av_clip_uint16(int a) +static inline av_const int8_t av_clip_int8_c(int a) +{ + if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F; + else return a; +} + +/** + * Clip a signed integer value into the 0-65535 range. + * @param a value to clip + * @return clipped value + */ +static inline av_const uint16_t av_clip_uint16_c(int a) { if (a&(~0xFFFF)) return (-a)>>31; else return a; } /** - * Clips a signed integer value into the -32768,32767 range. + * Clip a signed integer value into the -32768,32767 range. * @param a value to clip * @return clipped value */ -static inline av_const int16_t av_clip_int16(int a) +static inline av_const int16_t av_clip_int16_c(int a) { if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF; else return a; } /** - * Clips a signed 64-bit integer value into the -2147483648,2147483647 range. + * Clip a signed 64-bit integer value into the -2147483648,2147483647 range. * @param a value to clip * @return clipped value */ -static inline av_const int32_t av_clipl_int32(int64_t a) +static inline av_const int32_t av_clipl_int32_c(int64_t a) { if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (a>>63) ^ 0x7FFFFFFF; else return a; } /** - * Clips a float value into the amin-amax range. + * Clip a float value into the amin-amax range. * @param a value to clip * @param amin minimum value of the clip range * @param amax maximum value of the clip range * @return clipped value */ -static inline av_const float av_clipf(float a, float amin, float amax) +static inline av_const float av_clipf_c(float a, float amin, float amax) { if (a < amin) return amin; else if (a > amax) return amax; else return a; } -/** Computes ceil(log2(x)). +/** Compute ceil(log2(x)). * @param x value used to compute ceil(log2(x)) * @return computed ceiling of log2(x) */ -static inline av_const int av_ceil_log2(int x) +static inline av_const int av_ceil_log2_c(int x) { return av_log2((x - 1) << 1); } -#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) -#define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24)) +#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24)) +#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24)) -/*! - * \def GET_UTF8(val, GET_BYTE, ERROR) - * Converts a UTF-8 character (up to 4 bytes long) to its 32-bit UCS-4 encoded form - * \param val is the output and should be of type uint32_t. It holds the converted - * UCS-4 character and should be a left value. - * \param GET_BYTE gets UTF-8 encoded bytes from any proper source. It can be - * a function or a statement whose return value or evaluated value is of type - * uint8_t. It will be executed up to 4 times for values in the valid UTF-8 range, - * and up to 7 times in the general case. - * \param ERROR action that should be taken when an invalid UTF-8 byte is returned - * from GET_BYTE. It should be a statement that jumps out of the macro, - * like exit(), goto, return, break, or continue. +/** + * Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form. + * + * @param val Output value, must be an lvalue of type uint32_t. + * @param GET_BYTE Expression reading one byte from the input. + * Evaluated up to 7 times (4 for the currently + * assigned Unicode range). With a memory buffer + * input, this could be *ptr++. + * @param ERROR Expression to be evaluated on invalid input, + * typically a goto statement. */ #define GET_UTF8(val, GET_BYTE, ERROR)\ val= GET_BYTE;\ @@ -210,17 +214,14 @@ static inline av_const int av_ceil_log2(int x) }\ } -/*! - * \def GET_UTF16(val, GET_16BIT, ERROR) - * Converts a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form - * \param val is the output and should be of type uint32_t. It holds the converted - * UCS-4 character and should be a left value. - * \param GET_16BIT gets two bytes of UTF-16 encoded data converted to native endianness. - * It can be a function or a statement whose return value or evaluated value is of type - * uint16_t. It will be executed up to 2 times. - * \param ERROR action that should be taken when an invalid UTF-16 surrogate is - * returned from GET_BYTE. It should be a statement that jumps out of the macro, - * like exit(), goto, return, break, or continue. +/** + * Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form. + * + * @param val Output value, must be an lvalue of type uint32_t. + * @param GET_16BIT Expression returning two bytes of UTF-16 data converted + * to native byte order. Evaluated one or two times. + * @param ERROR Expression to be evaluated on invalid input, + * typically a goto statement. */ #define GET_UTF16(val, GET_16BIT, ERROR)\ val = GET_16BIT;\ @@ -236,7 +237,7 @@ static inline av_const int av_ceil_log2(int x) /*! * \def PUT_UTF8(val, tmp, PUT_BYTE) - * Converts a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). + * Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). * \param val is an input-only argument and should be of type uint32_t. It holds * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If * val is given as a function it is executed only once. @@ -272,7 +273,7 @@ static inline av_const int av_ceil_log2(int x) /*! * \def PUT_UTF16(val, tmp, PUT_16BIT) - * Converts a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes). + * Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes). * \param val is an input-only argument and should be of type uint32_t. It holds * a UCS-4 encoded Unicode character that is to be converted to UTF-16. If * val is given as a function it is executed only once. @@ -307,3 +308,39 @@ static inline av_const int av_ceil_log2(int x) #endif /* HAVE_AV_CONFIG_H */ #endif /* AVUTIL_COMMON_H */ + +/* + * The following definitions are outside the multiple inclusion guard + * to ensure they are immediately available in intmath.h. + */ + +#ifndef av_log2 +# define av_log2 av_log2_c +#endif +#ifndef av_log2_16bit +# define av_log2_16bit av_log2_16bit_c +#endif +#ifndef av_ceil_log2 +# define av_ceil_log2 av_ceil_log2_c +#endif +#ifndef av_clip +# define av_clip av_clip_c +#endif +#ifndef av_clip_uint8 +# define av_clip_uint8 av_clip_uint8_c +#endif +#ifndef av_clip_int8 +# define av_clip_int8 av_clip_int8_c +#endif +#ifndef av_clip_uint16 +# define av_clip_uint16 av_clip_uint16_c +#endif +#ifndef av_clip_int16 +# define av_clip_int16 av_clip_int16_c +#endif +#ifndef av_clipl_int32 +# define av_clipl_int32 av_clipl_int32_c +#endif +#ifndef av_clipf +# define av_clipf av_clipf_c +#endif diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/crc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/crc.c index 2719baeef..c3d74a2ce 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/crc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/crc.c @@ -41,19 +41,19 @@ static AVCRC av_crc_table[AV_CRC_MAX][257]; #endif /** - * Initializes a CRC table. + * Initialize a CRC table. * @param ctx must be an array of size sizeof(AVCRC)*257 or sizeof(AVCRC)*1024 - * @param cts_size size of ctx in bytes * @param le If 1, the lowest bit represents the coefficient for the highest * exponent of the corresponding polynomial (both for poly and * actual CRC). * If 0, you must swap the CRC parameter and the result of av_crc * if you need the standard representation (can be simplified in * most cases to e.g. bswap16): - * bswap_32(crc << (32-bits)) + * av_bswap32(crc << (32-bits)) * @param bits number of bits for the CRC * @param poly generator polynomial without the x**bits coefficient, in the * representation as specified by le + * @param ctx_size size of ctx in bytes * @return <0 on failure */ int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size){ @@ -73,7 +73,7 @@ int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size){ } else { for (c = i << 24, j = 0; j < 8; j++) c = (c<<1) ^ ((poly<<(32-bits)) & (((int32_t)c)>>31) ); - ctx[i] = bswap_32(c); + ctx[i] = av_bswap32(c); } } ctx[256]=1; @@ -88,7 +88,7 @@ int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size){ } /** - * Gets an initialized standard CRC table. + * Get an initialized standard CRC table. * @param crc_id ID of a standard CRC * @return a pointer to the CRC table or NULL on failure */ @@ -106,7 +106,7 @@ const AVCRC *av_crc_get_table(AVCRCId crc_id){ } /** - * Calculates the CRC of a block. + * Calculate the CRC of a block. * @param crc CRC of previous blocks if any or initial value for CRC * @return CRC updated with the data from the given block * @@ -121,7 +121,7 @@ uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t le crc = ctx[((uint8_t)crc) ^ *buffer++] ^ (crc >> 8); while(buffer>8 )&0xFF)] ^ctx[1*256 + ((crc>>16)&0xFF)] diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/des.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/des.c index ab66a0b59..9c1a53066 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/des.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/des.c @@ -297,10 +297,10 @@ int av_des_init(AVDES *d, const uint8_t *key, int key_bits, int decrypt) { } void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt) { - uint64_t iv_val = iv ? be2me_64(*(uint64_t *)iv) : 0; + uint64_t iv_val = iv ? av_be2ne64(*(uint64_t *)iv) : 0; while (count-- > 0) { uint64_t dst_val; - uint64_t src_val = src ? be2me_64(*(const uint64_t *)src) : 0; + uint64_t src_val = src ? av_be2ne64(*(const uint64_t *)src) : 0; if (decrypt) { uint64_t tmp = src_val; if (d->triple_des) { @@ -317,12 +317,12 @@ void av_des_crypt(AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t } iv_val = iv ? dst_val : 0; } - *(uint64_t *)dst = be2me_64(dst_val); + *(uint64_t *)dst = av_be2ne64(dst_val); src += 8; dst += 8; } if (iv) - *(uint64_t *)iv = be2me_64(iv_val); + *(uint64_t *)iv = av_be2ne64(iv_val); } #ifdef TEST diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/error.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/error.h index 13a9a3593..28fa92579 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/error.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/error.h @@ -58,11 +58,13 @@ #endif /** - * Puts a description of the AVERROR code errnum in errbuf. + * Put a description of the AVERROR code errnum in errbuf. * In case of failure the global variable errno is set to indicate the * error. Even in case of failure av_strerror() will print a generic * error message indicating the errnum provided to errbuf. * + * @param errnum error code to describe + * @param errbuf buffer to which description is written * @param errbuf_size the size in bytes of errbuf * @return 0 on success, a negative value if a description for errnum * cannot be found diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/eval.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/eval.c index 59ebd947f..6e0349872 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/eval.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/eval.c @@ -182,7 +182,7 @@ void av_free_expr(AVExpr *e) static int parse_primary(AVExpr **e, Parser *p) { AVExpr *d = av_mallocz(sizeof(AVExpr)); - char *next= p->s; + char *next = p->s, *s0 = p->s; int ret, i; if (!d) @@ -211,7 +211,7 @@ static int parse_primary(AVExpr **e, Parser *p) p->s= strchr(p->s, '('); if (p->s==NULL) { - av_log(p, AV_LOG_ERROR, "undefined constant or missing (\n"); + av_log(p, AV_LOG_ERROR, "Undefined constant or missing '(' in '%s'\n", s0); p->s= next; av_free_expr(d); return AVERROR(EINVAL); @@ -222,7 +222,7 @@ static int parse_primary(AVExpr **e, Parser *p) if ((ret = parse_expr(&d, p)) < 0) return ret; if (p->s[0] != ')') { - av_log(p, AV_LOG_ERROR, "missing )\n"); + av_log(p, AV_LOG_ERROR, "Missing ')' in '%s'\n", s0); av_free_expr(d); return AVERROR(EINVAL); } @@ -239,7 +239,7 @@ static int parse_primary(AVExpr **e, Parser *p) parse_expr(&d->param[1], p); } if (p->s[0] != ')') { - av_log(p, AV_LOG_ERROR, "missing )\n"); + av_log(p, AV_LOG_ERROR, "Missing ')' or too many args in '%s'\n", s0); av_free_expr(d); return AVERROR(EINVAL); } @@ -290,7 +290,7 @@ static int parse_primary(AVExpr **e, Parser *p) } } - av_log(p, AV_LOG_ERROR, "unknown function\n"); + av_log(p, AV_LOG_ERROR, "Unknown function in '%s'\n", s0); av_free_expr(d); return AVERROR(EINVAL); } @@ -448,6 +448,7 @@ int av_parse_expr(AVExpr **expr, const char *s, AVExpr *e = NULL; char *w = av_malloc(strlen(s) + 1); char *wp = w; + const char *s0 = s; int ret = 0; if (!w) @@ -470,6 +471,11 @@ int av_parse_expr(AVExpr **expr, const char *s, if ((ret = parse_expr(&e, &p)) < 0) goto end; + if (*p.s) { + av_log(&p, AV_LOG_ERROR, "Invalid chars '%s' at the end of expression '%s'\n", p.s, s0); + ret = AVERROR(EINVAL); + goto end; + } if (!verify_expr(e)) { av_free_expr(e); ret = AVERROR(EINVAL); @@ -526,6 +532,44 @@ int main(void) { int i; double d; + const char **expr, *exprs[] = { + "", + "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", + "80G/80Gi" + "1k", + "1Gi", + "1gi", + "1GiFoo", + "1k+1k", + "1Gi*3foo", + "foo", + "foo(", + "foo()", + "foo)", + "sin", + "sin(", + "sin()", + "sin)", + "sin 10", + "sin(1,2,3)", + "sin(1 )", + "1", + "1foo", + "bar + PI + E + 100f*2 + foo", + "13k + 12f - foo(1, 2)", + "1gi", + "1Gi", + NULL + }; + + for (expr = exprs; *expr; expr++) { + printf("Evaluating '%s'\n", *expr); + av_parse_and_eval_expr(&d, *expr, + const_names, const_values, + NULL, NULL, NULL, NULL, NULL, 0, NULL); + printf("'%s' -> %f\n\n", *expr, d); + } + av_parse_and_eval_expr(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, NULL); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/eval.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/eval.h index 38b4c25ce..7a4f5f0c2 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/eval.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/eval.h @@ -29,7 +29,7 @@ typedef struct AVExpr AVExpr; /** - * Parses and evaluates an expression. + * Parse and evaluate an expression. * Note, this is significantly slower than av_eval_expr(). * * @param res a pointer to a double where is put the result value of @@ -53,7 +53,7 @@ int av_parse_and_eval_expr(double *res, const char *s, void *opaque, int log_offset, void *log_ctx); /** - * Parses an expression. + * Parse an expression. * * @param expr a pointer where is put an AVExpr containing the parsed * value in case of successfull parsing, or NULL otherwise. @@ -76,7 +76,7 @@ int av_parse_expr(AVExpr **expr, const char *s, int log_offset, void *log_ctx); /** - * Evaluates a previously parsed expression. + * Evaluate a previously parsed expression. * * @param const_values a zero terminated array of values for the identifiers from av_parse_expr() const_names * @param opaque a pointer which will be passed to all functions from funcs1 and funcs2 @@ -85,12 +85,12 @@ int av_parse_expr(AVExpr **expr, const char *s, double av_eval_expr(AVExpr *e, const double *const_values, void *opaque); /** - * Frees a parsed expression previously created with av_parse_expr(). + * Free a parsed expression previously created with av_parse_expr(). */ void av_free_expr(AVExpr *e); /** - * Parses the string in numstr and returns its value as a double. If + * Parse the string in numstr and return its value as a double. If * the string is empty, contains only whitespaces, or does not contain * an initial substring that has the expected syntax for a * floating-point number, no conversion is performed. In this case, diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/fifo.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/fifo.h index fb1ed47ff..999d0bf89 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/fifo.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/fifo.h @@ -33,26 +33,26 @@ typedef struct AVFifoBuffer { } AVFifoBuffer; /** - * Initializes an AVFifoBuffer. + * Initialize an AVFifoBuffer. * @param size of FIFO * @return AVFifoBuffer or NULL in case of memory allocation failure */ AVFifoBuffer *av_fifo_alloc(unsigned int size); /** - * Frees an AVFifoBuffer. + * Free an AVFifoBuffer. * @param *f AVFifoBuffer to free */ void av_fifo_free(AVFifoBuffer *f); /** - * Resets the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied. + * Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied. * @param *f AVFifoBuffer to reset */ void av_fifo_reset(AVFifoBuffer *f); /** - * Returns the amount of data in bytes in the AVFifoBuffer, that is the + * Return the amount of data in bytes in the AVFifoBuffer, that is the * amount of data you can read from it. * @param *f AVFifoBuffer to read from * @return size @@ -60,7 +60,7 @@ void av_fifo_reset(AVFifoBuffer *f); int av_fifo_size(AVFifoBuffer *f); /** - * Returns the amount of space in bytes in the AVFifoBuffer, that is the + * Return the amount of space in bytes in the AVFifoBuffer, that is the * amount of data you can write into it. * @param *f AVFifoBuffer to write into * @return size @@ -68,7 +68,7 @@ int av_fifo_size(AVFifoBuffer *f); int av_fifo_space(AVFifoBuffer *f); /** - * Feeds data from an AVFifoBuffer to a user-supplied callback. + * Feed data from an AVFifoBuffer to a user-supplied callback. * @param *f AVFifoBuffer to read from * @param buf_size number of bytes to read * @param *func generic read function @@ -77,7 +77,7 @@ int av_fifo_space(AVFifoBuffer *f); int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)); /** - * Feeds data from a user-supplied callback to an AVFifoBuffer. + * Feed data from a user-supplied callback to an AVFifoBuffer. * @param *f AVFifoBuffer to write to * @param *src data source; non-const since it may be used as a * modifiable context by the function defined in func @@ -92,7 +92,7 @@ int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func) int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int)); /** - * Resizes an AVFifoBuffer. + * Resize an AVFifoBuffer. * @param *f AVFifoBuffer to resize * @param size new AVFifoBuffer size in bytes * @return <0 for failure, >=0 otherwise @@ -100,7 +100,7 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); /** - * Reads and discards the specified amount of data from an AVFifoBuffer. + * Read and discard the specified amount of data from an AVFifoBuffer. * @param *f AVFifoBuffer to read from * @param size amount of data to read in bytes */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/integer.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/integer.h index fb46acbe0..45f733c04 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/integer.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/integer.h @@ -41,7 +41,7 @@ AVInteger av_add_i(AVInteger a, AVInteger b) av_const; AVInteger av_sub_i(AVInteger a, AVInteger b) av_const; /** - * Returns the rounded-down value of the base 2 logarithm of the given + * Return the rounded-down value of the base 2 logarithm of the given * AVInteger. This is simply the index of the most significant bit * which is 1, or 0 if all bits are 0. */ @@ -49,7 +49,7 @@ int av_log2_i(AVInteger a) av_const; AVInteger av_mul_i(AVInteger a, AVInteger b) av_const; /** - * Returns 0 if a==b, 1 if a>b and -1 if ab and -1 if a> 32)) -#else -# define FASTDIV(a,b) ((a) / (b)) -#endif - +# if CONFIG_FASTDIV +# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32)) +# else +# define FASTDIV(a,b) ((a) / (b)) +# endif #endif /* FASTDIV */ -/* - * Get definition of av_log2_c from common.h. In the event we got - * here through common.h including this file, including it again will - * be a no-op due to multi-inclusion guards, so we must duplicate the - * fallback defines here. - */ - #include "common.h" -#ifndef av_log2 -# define av_log2 av_log2_c -#endif -#ifndef av_log2_16bit -# define av_log2_16bit av_log2_16bit_c -#endif - extern const uint8_t ff_sqrt_tab[256]; static inline av_const unsigned int ff_sqrt(unsigned int a) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/intreadwrite.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/intreadwrite.h index c8026f087..1849a6466 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/intreadwrite.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/intreadwrite.h @@ -20,9 +20,9 @@ #define AVUTIL_INTREADWRITE_H #include -#include "config.h" +#include "libavutil/avconfig.h" +#include "attributes.h" #include "bswap.h" -#include "common.h" typedef union { uint64_t u64; @@ -52,6 +52,10 @@ typedef union { * as inline functions. */ +#ifdef HAVE_AV_CONFIG_H + +#include "config.h" + #if ARCH_ARM # include "arm/intreadwrite.h" #elif ARCH_AVR32 @@ -66,11 +70,13 @@ typedef union { # include "x86/intreadwrite.h" #endif +#endif /* HAVE_AV_CONFIG_H */ + /* * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers. */ -#if HAVE_BIGENDIAN +#if AV_HAVE_BIGENDIAN # if defined(AV_RN16) && !defined(AV_RB16) # define AV_RB16(p) AV_RN16(p) @@ -120,7 +126,7 @@ typedef union { # define AV_WN64(p, v) AV_WB64(p, v) # endif -#else /* HAVE_BIGENDIAN */ +#else /* AV_HAVE_BIGENDIAN */ # if defined(AV_RN16) && !defined(AV_RL16) # define AV_RL16(p) AV_RN16(p) @@ -170,14 +176,14 @@ typedef union { # define AV_WN64(p, v) AV_WL64(p, v) # endif -#endif /* !HAVE_BIGENDIAN */ +#endif /* !AV_HAVE_BIGENDIAN */ /* * Define AV_[RW]N helper macros to simplify definitions not provided * by per-arch headers. */ -#if HAVE_ATTRIBUTE_PACKED +#if defined(__GNUC__) && !defined(__TI_COMPILER_VERSION__) union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias; union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias; @@ -191,7 +197,7 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; # define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p))) # define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v)) -#elif HAVE_FAST_UNALIGNED +#elif AV_HAVE_FAST_UNALIGNED # define AV_RN(s, p) (((const av_alias##s*)(p))->u##s) # define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v)) @@ -302,7 +308,7 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; } while(0) #endif -#if HAVE_BIGENDIAN +#if AV_HAVE_BIGENDIAN # define AV_RN(s, p) AV_RB##s(p) # define AV_WN(s, p, v) AV_WB##s(p, v) #else @@ -336,14 +342,14 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; # define AV_WN64(p, v) AV_WN(64, p, v) #endif -#if HAVE_BIGENDIAN +#if AV_HAVE_BIGENDIAN # define AV_RB(s, p) AV_RN##s(p) # define AV_WB(s, p, v) AV_WN##s(p, v) -# define AV_RL(s, p) bswap_##s(AV_RN##s(p)) -# define AV_WL(s, p, v) AV_WN##s(p, bswap_##s(v)) +# define AV_RL(s, p) av_bswap##s(AV_RN##s(p)) +# define AV_WL(s, p, v) AV_WN##s(p, av_bswap##s(v)) #else -# define AV_RB(s, p) bswap_##s(AV_RN##s(p)) -# define AV_WB(s, p, v) AV_WN##s(p, bswap_##s(v)) +# define AV_RB(s, p) av_bswap##s(AV_RN##s(p)) +# define AV_WB(s, p, v) AV_WN##s(p, av_bswap##s(v)) # define AV_RL(s, p) AV_RN##s(p) # define AV_WL(s, p, v) AV_WN##s(p, v) #endif diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/lfg.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/lfg.c index 1dad4e442..b5db5a4b1 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/lfg.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/lfg.c @@ -20,6 +20,8 @@ */ #include +#include +#include #include "lfg.h" #include "md5.h" #include "intreadwrite.h" diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/lfg.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/lfg.h index ac89d120d..0e89ea308 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/lfg.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/lfg.h @@ -30,7 +30,7 @@ typedef struct { void av_lfg_init(AVLFG *c, unsigned int seed); /** - * Gets the next random unsigned 32-bit number using an ALFG. + * Get the next random unsigned 32-bit number using an ALFG. * * Please also consider a simple LCG like state= state*1664525+1013904223, * it may be good enough and faster for your specific use case. @@ -41,7 +41,7 @@ static inline unsigned int av_lfg_get(AVLFG *c){ } /** - * Gets the next random unsigned 32-bit number using a MLFG. + * Get the next random unsigned 32-bit number using a MLFG. * * Please also consider av_lfg_get() above, it is faster. */ @@ -52,10 +52,10 @@ static inline unsigned int av_mlfg_get(AVLFG *c){ } /** - * Gets the next two numbers generated by a Box-Muller Gaussian + * Get the next two numbers generated by a Box-Muller Gaussian * generator using the random numbers issued by lfg. * - * @param out[2] array where are placed the two generated numbers + * @param out[2] array where the two generated numbers are placed */ void av_bmg_get(AVLFG *lfg, double out[2]); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/log.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/log.c index ce0dc4aa5..9b493367e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/log.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/log.c @@ -34,24 +34,45 @@ static #endif int av_log_level = AV_LOG_INFO; -static int use_ansi_color=-1; +#if defined(_WIN32) && !defined(__MINGW32CE__) +#include +static const uint8_t color[] = {12,12,12,14,7,7,7}; +static int16_t background, attr_orig; +static HANDLE con; +#define set_color(x) SetConsoleTextAttribute(con, background | color[x]) +#define reset_color() SetConsoleTextAttribute(con, attr_orig) +#else +static const uint8_t color[]={0x41,0x41,0x11,0x03,9,9,9}; +#define set_color(x) fprintf(stderr, "\033[%d;3%dm", color[x]>>4, color[x]&15) +#define reset_color() fprintf(stderr, "\033[0m") +#endif +static int use_color=-1; #undef fprintf -static void colored_fputs(int color, const char *str){ - if(use_ansi_color<0){ -#if HAVE_ISATTY && !defined(_WIN32) - use_ansi_color= getenv("TERM") && !getenv("NO_COLOR") && isatty(2); +static void colored_fputs(int level, const char *str){ + if(use_color<0){ +#if defined(_WIN32) && !defined(__MINGW32CE__) + CONSOLE_SCREEN_BUFFER_INFO con_info; + con = GetStdHandle(STD_ERROR_HANDLE); + use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR"); + if (use_color) { + GetConsoleScreenBufferInfo(con, &con_info); + attr_orig = con_info.wAttributes; + background = attr_orig & 0xF0; + } +#elif HAVE_ISATTY + use_color= getenv("TERM") && !getenv("NO_COLOR") && isatty(2); #else - use_ansi_color= 0; + use_color= 0; #endif } - if(use_ansi_color){ - fprintf(stderr, "\033[%d;3%dm", color>>4, color&15); + if(use_color){ + set_color(level); } fputs(str, stderr); - if(use_ansi_color){ - fprintf(stderr, "\033[0m"); + if(use_color){ + reset_color(); } } @@ -64,7 +85,6 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) static int print_prefix=1; static int count; static char line[1024], prev[1024]; - static const uint8_t color[]={0x41,0x41,0x11,0x03,9,9,9}; AVClass* avc= ptr ? *(AVClass**)ptr : NULL; if(level>av_log_level) return; @@ -74,10 +94,10 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) if(avc->version >= (50<<16 | 15<<8 | 3) && avc->parent_log_context_offset){ AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset); if(parent && *parent){ - snprintf(line, sizeof(line), "[%s @ %p]", (*parent)->item_name(parent), parent); + snprintf(line, sizeof(line), "[%s @ %p] ", (*parent)->item_name(parent), parent); } } - snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p]", avc->item_name(ptr), ptr); + snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr); } vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl); @@ -91,7 +111,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) fprintf(stderr, " Last message repeated %d times\n", count); count=0; } - colored_fputs(color[av_clip(level>>3, 0, 6)], line); + colored_fputs(av_clip(level>>3, 0, 6), line); strcpy(prev, line); } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/log.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/log.h index 0a413f6e8..831c26eae 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/log.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/log.h @@ -25,7 +25,7 @@ #include "avutil.h" /** - * Describes the class of an AVClass context structure. That is an + * Describe the class of an AVClass context structure. That is an * arbitrary struct of which the first field is a pointer to an * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.). */ @@ -109,7 +109,7 @@ typedef struct { #define AV_LOG_DEBUG 48 /** - * Sends the specified message to the log if the level is less than or equal + * Send the specified message to the log if the level is less than or equal * to the current av_log_level. By default, all logging messages are sent to * stderr. This behavior can be altered by setting a different av_vlog callback * function. @@ -123,12 +123,12 @@ typedef struct { * @see av_vlog */ #ifdef __GNUC__ -void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); +void av_log(void *avcl, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); #else -void av_log(void*, int level, const char *fmt, ...); +void av_log(void *avcl, int level, const char *fmt, ...); #endif -void av_vlog(void*, int level, const char *fmt, va_list); +void av_vlog(void *avcl, int level, const char *fmt, va_list); int av_log_get_level(void); void av_log_set_level(int); void av_log_set_callback(void (*)(void*, int, const char*, va_list)); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/mathematics.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/mathematics.c index c06cb1616..c6851cb75 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/mathematics.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/mathematics.c @@ -78,7 +78,7 @@ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){ int64_t r=0; assert(c > 0); assert(b >=0); - assert(rnd >=0 && rnd<=5 && rnd!=4); + assert((unsigned)rnd<=5 && rnd!=4); if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1)); @@ -144,6 +144,13 @@ int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){ return 0; } +int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod){ + int64_t c= (a-b) & (mod-1); + if(c > (mod>>1)) + c-= mod; + return c; +} + #ifdef TEST #include "integer.h" #undef printf diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/mathematics.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/mathematics.h index e198aef8c..3e5631116 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/mathematics.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/mathematics.h @@ -63,36 +63,47 @@ enum AVRounding { }; /** - * Returns the greatest common divisor of a and b. + * Return the greatest common divisor of a and b. * If both a and b are 0 or either or both are <0 then behavior is * undefined. */ int64_t av_const av_gcd(int64_t a, int64_t b); /** - * Rescales a 64-bit integer with rounding to nearest. + * Rescale a 64-bit integer with rounding to nearest. * A simple a*b/c isn't possible as it can overflow. */ int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const; /** - * Rescales a 64-bit integer with specified rounding. + * Rescale a 64-bit integer with specified rounding. * A simple a*b/c isn't possible as it can overflow. */ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const; /** - * Rescales a 64-bit integer by 2 rational numbers. + * Rescale a 64-bit integer by 2 rational numbers. */ int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const; /** - * Compares 2 timestamps each in its own timebases. + * Compare 2 timestamps each in its own timebases. * The result of the function is undefined if one of the timestamps * is outside the int64_t range when represented in the others timebase. * @return -1 if ts_a is before ts_b, 1 if ts_a is after ts_b or 0 if they represent the same position */ int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b); +/** + * Compare 2 integers modulo mod. + * That is we compare integers a and b for which only the least + * significant log2(mod) bits are known. + * + * @param mod must be a power of 2 + * @return a negative value if a is smaller than b + * a positive value if a is greater than b + * 0 if a equals b + */ +int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod); #endif /* AVUTIL_MATHEMATICS_H */ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/md5.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/md5.c index 39ee6242e..173ed0623 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/md5.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/md5.c @@ -95,7 +95,7 @@ static void body(uint32_t ABCD[4], uint32_t X[16]){ #if HAVE_BIGENDIAN for(i=0; i<16; i++) - X[i]= bswap_32(X[i]); + X[i]= av_bswap32(X[i]); #endif #if CONFIG_SMALL @@ -141,7 +141,7 @@ void av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len){ void av_md5_final(AVMD5 *ctx, uint8_t *dst){ int i; - uint64_t finalcount= le2me_64(ctx->len<<3); + uint64_t finalcount= av_le2ne64(ctx->len<<3); av_md5_update(ctx, "\200", 1); while((ctx->len & 63)!=56) @@ -150,7 +150,7 @@ void av_md5_final(AVMD5 *ctx, uint8_t *dst){ av_md5_update(ctx, (uint8_t*)&finalcount, 8); for(i=0; i<4; i++) - ((uint32_t*)dst)[i]= le2me_32(ctx->ABCD[3-i]); + ((uint32_t*)dst)[i]= av_le2ne32(ctx->ABCD[3-i]); } void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len){ diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/mem.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/mem.h index 148879270..c5ec2ab3c 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/mem.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/mem.h @@ -27,8 +27,9 @@ #define AVUTIL_MEM_H #include "attributes.h" +#include "avutil.h" -#if defined(__ICC) || defined(__SUNPRO_C) +#if defined(__ICC) && _ICC < 1200 || defined(__SUNPRO_C) #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v #elif defined(__TI_COMPILER_VERSION__) @@ -62,7 +63,7 @@ #endif /** - * Allocates a block of size bytes with alignment suitable for all + * Allocate a block of size bytes with alignment suitable for all * memory accesses (including vectors if available on the CPU). * @param size Size in bytes for the memory block to be allocated. * @return Pointer to the allocated block, NULL if the block cannot @@ -72,9 +73,9 @@ void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1); /** - * Allocates or reallocates a block of memory. - * If ptr is NULL and size > 0, allocates a new block. If - * size is zero, frees the memory block pointed to by ptr. + * Allocate or reallocate a block of memory. + * If ptr is NULL and size > 0, allocate a new block. If + * size is zero, free the memory block pointed to by ptr. * @param size Size in bytes for the memory block to be allocated or * reallocated. * @param ptr Pointer to a memory block already allocated with @@ -86,7 +87,7 @@ void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1); void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2); /** - * Frees a memory block which has been allocated with av_malloc(z)() or + * Free a memory block which has been allocated with av_malloc(z)() or * av_realloc(). * @param ptr Pointer to the memory block which should be freed. * @note ptr = NULL is explicitly allowed. @@ -96,9 +97,9 @@ void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2); void av_free(void *ptr); /** - * Allocates a block of size bytes with alignment suitable for all + * Allocate a block of size bytes with alignment suitable for all * memory accesses (including vectors if available on the CPU) and - * zeroes all the bytes of the block. + * zero all the bytes of the block. * @param size Size in bytes for the memory block to be allocated. * @return Pointer to the allocated block, NULL if it cannot be allocated. * @see av_malloc() @@ -106,7 +107,7 @@ void av_free(void *ptr); void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1); /** - * Duplicates the string s. + * Duplicate the string s. * @param s string to be duplicated * @return Pointer to a newly allocated string containing a * copy of s or NULL if the string cannot be allocated. @@ -114,7 +115,7 @@ void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1); char *av_strdup(const char *s) av_malloc_attrib; /** - * Frees a memory block which has been allocated with av_malloc(z)() or + * Free a memory block which has been allocated with av_malloc(z)() or * av_realloc() and set the pointer pointing to it to NULL. * @param ptr Pointer to the pointer to the memory block which should * be freed. diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/pixdesc.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/pixdesc.c index 82b3631e4..e2bc6491d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/pixdesc.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/pixdesc.c @@ -19,13 +19,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#include #include "pixfmt.h" #include "pixdesc.h" #include "intreadwrite.h" -void read_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], - const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component) +void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], + const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component) { AVComponentDescriptor comp= desc->comp[c]; int plane= comp.plane; @@ -65,8 +67,8 @@ void read_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], } } -void write_line(const uint16_t *src, uint8_t *data[4], const int linesize[4], - const AVPixFmtDescriptor *desc, int x, int y, int c, int w) +void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4], + const AVPixFmtDescriptor *desc, int x, int y, int c, int w) { AVComponentDescriptor comp = desc->comp[c]; int plane = comp.plane; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/pixdesc.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/pixdesc.h index 8e4c85d71..8d131beb3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/pixdesc.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/pixdesc.h @@ -93,11 +93,11 @@ typedef struct AVPixFmtDescriptor{ extern const AVPixFmtDescriptor av_pix_fmt_descriptors[]; /** - * Reads a line from an image, and writes the values of the + * Read a line from an image, and write the values of the * pixel format component c to dst. * * @param data the array containing the pointers to the planes of the image - * @param linesizes the array containing the linesizes of the image + * @param linesize the array containing the linesizes of the image * @param desc the pixel format descriptor for the image * @param x the horizontal coordinate of the first pixel to read * @param y the vertical coordinate of the first pixel to read @@ -108,28 +108,28 @@ extern const AVPixFmtDescriptor av_pix_fmt_descriptors[]; * component c in data[1] to dst, rather than the palette indexes in * data[0]. The behavior is undefined if the format is not paletted. */ -void read_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], - const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component); +void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], + const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component); /** - * Writes the values from src to the pixel format component c of an + * Write the values from src to the pixel format component c of an * image line. * * @param src array containing the values to write * @param data the array containing the pointers to the planes of the * image to write into. It is supposed to be zeroed. - * @param linesizes the array containing the linesizes of the image + * @param linesize the array containing the linesizes of the image * @param desc the pixel format descriptor for the image * @param x the horizontal coordinate of the first pixel to write * @param y the vertical coordinate of the first pixel to write * @param w the width of the line to write, that is the number of * values to write to the image line */ -void write_line(const uint16_t *src, uint8_t *data[4], const int linesize[4], - const AVPixFmtDescriptor *desc, int x, int y, int c, int w); +void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4], + const AVPixFmtDescriptor *desc, int x, int y, int c, int w); /** - * Returns the pixel format corresponding to name. + * Return the pixel format corresponding to name. * * If there is no pixel format with name name, then looks for a * pixel format with the name corresponding to the native endian @@ -142,7 +142,7 @@ void write_line(const uint16_t *src, uint8_t *data[4], const int linesize[4], enum PixelFormat av_get_pix_fmt(const char *name); /** - * Returns the number of bits per pixel used by the pixel format + * Return the number of bits per pixel used by the pixel format * described by pixdesc. * * The returned number of bits refers to the number of bits actually diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/random_seed.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/random_seed.c index 00d631724..db1ba39cf 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/random_seed.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/random_seed.c @@ -21,27 +21,64 @@ #include #include #include "timer.h" +#include "time.h" #include "random_seed.h" #include "avutil.h" -uint32_t av_get_random_seed(void) +static int read_random(uint32_t *dst, const char *file) { - uint32_t seed; - int fd; - - if ((fd = open("/dev/random", O_RDONLY)) == -1) - fd = open("/dev/urandom", O_RDONLY); - if (fd != -1){ - int err = read(fd, &seed, 4); - close(fd); - if (err == 4) - return seed; + int fd = open(file, O_RDONLY); + int err = -1; + + if (fd == -1) + return -1; + err = read(fd, dst, sizeof(*dst)); + close(fd); + + return err; +} + +static uint32_t get_generic_seed(void) +{ + clock_t last_t=0; + int bits=0; + uint64_t random=0; + unsigned i; + float s=0.000000000001; + + for(i=0;bits<64;i++){ + clock_t t= clock(); + if(last_t && fabs(t-last_t)>s || t==(clock_t)-1){ + if(i<10000 && s<(1<<24)){ + s+=s; + i=t=0; + }else{ + random= 2*random + (i&1); + bits++; + } + } + last_t= t; } #ifdef AV_READ_TIME - seed = AV_READ_TIME(); + random ^= AV_READ_TIME(); +#else + random ^= clock(); #endif - // XXX what to do ? - return seed; + + random += random>>32; + + return random; +} + +uint32_t av_get_random_seed(void) +{ + uint32_t seed; + + if (read_random(&seed, "/dev/urandom") == sizeof(seed)) + return seed; + if (read_random(&seed, "/dev/random") == sizeof(seed)) + return seed; + return get_generic_seed(); } #if LIBAVUTIL_VERSION_MAJOR < 51 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/random_seed.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/random_seed.h index 11a901764..7f7506323 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/random_seed.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/random_seed.h @@ -24,7 +24,7 @@ #include /** - * Gets a seed to use in conjunction with random functions. + * Get a seed to use in conjunction with random functions. */ uint32_t av_get_random_seed(void); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/rational.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/rational.h index 4d91f7bae..2dd0c2c59 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/rational.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/rational.h @@ -40,7 +40,7 @@ typedef struct AVRational{ } AVRational; /** - * Compares two rationals. + * Compare two rationals. * @param a first rational * @param b second rational * @return 0 if a==b, 1 if a>b and -1 if a> (32 - (bits)))) /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ -#define blk0(i) (block[i] = be2me_32(((const uint32_t*)buffer)[i])) +#define blk0(i) (block[i] = av_be2ne32(((const uint32_t*)buffer)[i])) #define blk(i) (block[i] = rol(block[i-3] ^ block[i-8] ^ block[i-14] ^ block[i-16], 1)) #define R0(v,w,x,y,z,i) z += ((w&(x^y))^y) + blk0(i) + 0x5A827999 + rol(v, 5); w = rol(w, 30); @@ -68,7 +68,7 @@ static void sha1_transform(uint32_t state[5], const uint8_t buffer[64]) for (i = 0; i < 80; i++) { int t; if (i < 16) - t = be2me_32(((uint32_t*)buffer)[i]); + t = av_be2ne32(((uint32_t*)buffer)[i]); else t = rol(block[i-3] ^ block[i-8] ^ block[i-14] ^ block[i-16], 1); block[i] = t; @@ -314,7 +314,7 @@ void av_sha_update(AVSHA* ctx, const uint8_t* data, unsigned int len) void av_sha_final(AVSHA* ctx, uint8_t *digest) { int i; - uint64_t finalcount = be2me_64(ctx->count << 3); + uint64_t finalcount = av_be2ne64(ctx->count << 3); av_sha_update(ctx, "\200", 1); while ((ctx->count & 63) != 56) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/sha.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/sha.h index 5a20230a3..543f5a194 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/sha.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/sha.h @@ -28,7 +28,7 @@ extern const int av_sha_size; struct AVSHA; /** - * Initializes SHA-1 or SHA-2 hashing. + * Initialize SHA-1 or SHA-2 hashing. * * @param context pointer to the function context (of size av_sha_size) * @param bits number of bits in digest (SHA-1 - 160 bits, SHA-2 224 or 256 bits) @@ -37,7 +37,7 @@ struct AVSHA; int av_sha_init(struct AVSHA* context, int bits); /** - * Updates hash value. + * Update hash value. * * @param context hash function context * @param data input data to update hash with @@ -46,7 +46,7 @@ int av_sha_init(struct AVSHA* context, int bits); void av_sha_update(struct AVSHA* context, const uint8_t* data, unsigned int len); /** - * Finishes hashing and output digest value. + * Finish hashing and output digest value. * * @param context hash function context * @param digest buffer where output digest value is stored diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/sha1.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/sha1.h index cf7c4a656..3ff58043e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/sha1.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/sha1.h @@ -28,7 +28,7 @@ extern const int av_sha1_size; struct AVSHA1; /** - * Initializes SHA-1 hashing. + * Initialize SHA-1 hashing. * * @param context pointer to the function context (of size av_sha_size) * @deprecated use av_sha_init() instead @@ -36,7 +36,7 @@ struct AVSHA1; void av_sha1_init(struct AVSHA1* context); /** - * Updates hash value. + * Update hash value. * * @param context hash function context * @param data input data to update hash with @@ -46,7 +46,7 @@ void av_sha1_init(struct AVSHA1* context); void av_sha1_update(struct AVSHA1* context, const uint8_t* data, unsigned int len); /** - * Finishes hashing and output digest value. + * Finish hashing and output digest value. * * @param context hash function context * @param digest buffer where output digest value is stored diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/tree.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/tree.h index dde2f1056..bf09fd0be 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/tree.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/tree.h @@ -33,7 +33,7 @@ struct AVTreeNode; extern const int av_tree_node_size; /** - * Finds an element. + * Find an element. * @param root a pointer to the root node of the tree * @param next If next is not NULL, then next[0] will contain the previous * element and next[1] the next element. If either does not exist, @@ -44,7 +44,7 @@ extern const int av_tree_node_size; void *av_tree_find(const struct AVTreeNode *root, void *key, int (*cmp)(void *key, const void *b), void *next[2]); /** - * Inserts or removes an element. + * Insert or remove an element. * If *next is NULL, then the supplied element will be removed if it exists. * If *next is not NULL, then the supplied element will be inserted, unless * it already exists in the tree. @@ -80,7 +80,7 @@ void *av_tree_insert(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, void av_tree_destroy(struct AVTreeNode *t); /** - * Applies enu(opaque, &elem) to all the elements in the tree in a given range. + * Apply enu(opaque, &elem) to all the elements in the tree in a given range. * * @param cmp a comparison function that returns < 0 for a element below the * range, > 0 for a element above the range and == 0 for a diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/x86/bswap.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/x86/bswap.h index 26dc4e2bf..b6ceb76d3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/x86/bswap.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libavutil/x86/bswap.h @@ -28,15 +28,15 @@ #include "config.h" #include "libavutil/attributes.h" -#define bswap_16 bswap_16 -static av_always_inline av_const uint16_t bswap_16(uint16_t x) +#define av_bswap16 av_bswap16 +static av_always_inline av_const uint16_t av_bswap16(uint16_t x) { __asm__("rorw $8, %0" : "+r"(x)); return x; } -#define bswap_32 bswap_32 -static av_always_inline av_const uint32_t bswap_32(uint32_t x) +#define av_bswap32 av_bswap32 +static av_always_inline av_const uint32_t av_bswap32(uint32_t x) { #if HAVE_BSWAP __asm__("bswap %0" : "+r" (x)); @@ -50,8 +50,8 @@ static av_always_inline av_const uint32_t bswap_32(uint32_t x) } #if ARCH_X86_64 -#define bswap_64 bswap_64 -static inline uint64_t av_const bswap_64(uint64_t x) +#define av_bswap64 av_bswap64 +static inline uint64_t av_const av_bswap64(uint64_t x) { __asm__("bswap %0": "=r" (x) : "0" (x)); return x; diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libpostproc/postprocess.h b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libpostproc/postprocess.h index 4cfcf7c6f..0713c4795 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libpostproc/postprocess.h +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libpostproc/postprocess.h @@ -44,17 +44,17 @@ #define LIBPOSTPROC_IDENT "postproc" AV_STRINGIFY(LIBPOSTPROC_VERSION) /** - * Returns the LIBPOSTPROC_VERSION_INT constant. + * Return the LIBPOSTPROC_VERSION_INT constant. */ unsigned postproc_version(void); /** - * Returns the libpostproc build-time configuration. + * Return the libpostproc build-time configuration. */ const char *postproc_configuration(void); /** - * Returns the libpostproc license. + * Return the libpostproc license. */ const char *postproc_license(void); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libpostproc/postprocess_template.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libpostproc/postprocess_template.c index 637ebc637..918d005fa 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libpostproc/postprocess_template.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libpostproc/postprocess_template.c @@ -1390,7 +1390,7 @@ DERING_CORE((%0, %1, 8) ,(%%REGd, %1, 4),%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1, #endif //HAVE_ALTIVEC /** - * Deinterlaces the given block by linearly interpolating every second line. + * Deinterlace the given block by linearly interpolating every second line. * will be called for every 8x8 block and can read & write from line 4-15 * lines 0-3 have been passed through the deblock / dering filters already, but can be read, too. * lines 4-12 will be read into the deblocking filter and should be deinterlaced @@ -1442,7 +1442,7 @@ static inline void RENAME(deInterlaceInterpolateLinear)(uint8_t src[], int strid } /** - * Deinterlaces the given block by cubic interpolating every second line. + * Deinterlace the given block by cubic interpolating every second line. * will be called for every 8x8 block and can read & write from line 4-15 * lines 0-3 have been passed through the deblock / dering filters already, but can be read, too. * lines 4-12 will be read into the deblocking filter and should be deinterlaced @@ -1506,7 +1506,7 @@ DEINT_CUBIC((%%REGd, %1), (%0, %1, 8) , (%%REGd, %1, 4), (%%REGc) , (%%REGc, } /** - * Deinterlaces the given block by filtering every second line with a (-1 4 2 4 -1) filter. + * Deinterlace the given block by filtering every second line with a (-1 4 2 4 -1) filter. * will be called for every 8x8 block and can read & write from line 4-15 * lines 0-3 have been passed through the deblock / dering filters already, but can be read, too. * lines 4-12 will be read into the deblocking filter and should be deinterlaced @@ -1585,7 +1585,7 @@ DEINT_FF((%%REGd, %1), (%%REGd, %1, 2), (%0, %1, 8) , (%%REGd, %1, 4)) } /** - * Deinterlaces the given block by filtering every line with a (-1 2 6 2 -1) filter. + * Deinterlace the given block by filtering every line with a (-1 2 6 2 -1) filter. * will be called for every 8x8 block and can read & write from line 4-15 * lines 0-3 have been passed through the deblock / dering filters already, but can be read, too. * lines 4-12 will be read into the deblocking filter and should be deinterlaced @@ -1686,7 +1686,7 @@ DEINT_L5(%%mm1, %%mm0, (%%REGd, %1, 2), (%0, %1, 8) , (%%REGd, %1, 4)) } /** - * Deinterlaces the given block by filtering all lines with a (1 2 1) filter. + * Deinterlace the given block by filtering all lines with a (1 2 1) filter. * will be called for every 8x8 block and can read & write from line 4-15 * lines 0-3 have been passed through the deblock / dering filters already, but can be read, too. * lines 4-12 will be read into the deblocking filter and should be deinterlaced @@ -1788,7 +1788,7 @@ static inline void RENAME(deInterlaceBlendLinear)(uint8_t src[], int stride, uin } /** - * Deinterlaces the given block by applying a median filter to every second line. + * Deinterlace the given block by applying a median filter to every second line. * will be called for every 8x8 block and can read & write from line 4-15, * lines 0-3 have been passed through the deblock / dering filters already, but can be read, too. * lines 4-12 will be read into the deblocking filter and should be deinterlaced @@ -3006,7 +3006,7 @@ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[ const QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c); /** - * Copies a block from src to dst and fixes the blacklevel. + * Copy a block from src to dst and fixes the blacklevel. * levelFix == 0 -> do not touch the brighness & contrast */ #undef REAL_SCALED_CPY @@ -3138,7 +3138,7 @@ SIMPLE_CPY((%%REGa, %2), (%%REGa, %2, 2), (%%REGd, %3), (%%REGd, %3, 2)) } /** - * Duplicates the given 8 src pixels ? times upward + * Duplicate the given 8 src pixels ? times upward */ static inline void RENAME(duplicate)(uint8_t src[], int stride) { @@ -3163,7 +3163,7 @@ static inline void RENAME(duplicate)(uint8_t src[], int stride) } /** - * Filters array of bytes (Y or U or V values) + * Filter array of bytes (Y or U or V values) */ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, const QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2) diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libswscale/rgb2rgb.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libswscale/rgb2rgb.c index 983944de2..f92e165c6 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/libswscale/rgb2rgb.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/libswscale/rgb2rgb.c @@ -231,7 +231,7 @@ void palette8tobgr16(const uint8_t *src, uint8_t *dst, long num_pixels, const ui { long i; for (i=0; i> 9); @@ -774,7 +775,7 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int } if (isNotNe) for (i = 0; i < 1024*3; i++) - y_table16[i] = bswap_16(y_table16[i]); + y_table16[i] = av_bswap16(y_table16[i]); fill_table(c->table_rV, 2, crv, y_table16 + yoffs); fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024); fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048); @@ -797,7 +798,7 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int } if(isNotNe) for (i = 0; i < 1024*3; i++) - y_table16[i] = bswap_16(y_table16[i]); + y_table16[i] = av_bswap16(y_table16[i]); fill_table(c->table_rV, 2, crv, y_table16 + yoffs); fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024); fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048); diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/codec-regression.sh b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/codec-regression.sh index faa066bff..ea49155a6 100755 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/codec-regression.sh +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/codec-regression.sh @@ -219,17 +219,17 @@ fi if [ -n "$do_dnxhd_1080i" ] ; then # FIXME: interlaced raw DNxHD decoding is broken -do_video_encoding dnxhd-1080i.mov "" "-vcodec dnxhd -flags +ildct -s hd1080 -b 120Mb -pix_fmt yuv422p -vframes 5 -an" +do_video_encoding dnxhd-1080i.mov "" "-vcodec dnxhd -flags +ildct -s hd1080 -b 120M -pix_fmt yuv422p -vframes 5 -an" do_video_decoding "-r 25" "-s cif -pix_fmt yuv420p" fi if [ -n "$do_dnxhd_720p" ] ; then -do_video_encoding dnxhd-720p.dnxhd "" "-s hd720 -b 90Mb -pix_fmt yuv422p -vframes 5 -an" +do_video_encoding dnxhd-720p.dnxhd "" "-s hd720 -b 90M -pix_fmt yuv422p -vframes 5 -an" do_video_decoding "-r 25" "-s cif -pix_fmt yuv420p" fi if [ -n "$do_dnxhd_720p_rd" ] ; then -do_video_encoding dnxhd-720p-rd.dnxhd "" "-threads 4 -mbd rd -s hd720 -b 90Mb -pix_fmt yuv422p -vframes 5 -an" +do_video_encoding dnxhd-720p-rd.dnxhd "" "-threads 4 -mbd rd -s hd720 -b 90M -pix_fmt yuv422p -vframes 5 -an" do_video_decoding "-r 25" "-s cif -pix_fmt yuv420p" fi diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/fate-run.sh b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/fate-run.sh index 899580fa7..83befedd3 100755 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/fate-run.sh +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/fate-run.sh @@ -8,12 +8,36 @@ SAMPLES_PATH=$2 target_exec=$3 BUILD_PATH=$4 command=$5 +cmp=${6:-diff} -ref="${base}/ref/fate/${test}" +ref=${7:-"${base}/ref/fate/${test}"} +fuzz=$8 outdir="tests/data/fate" outfile="${outdir}/${test}" +oneoff(){ + psnr=$(tests/tiny_psnr "$1" "$2" 2 0 0) + max=$(expr "$psnr" : '.*MAXDIFF: *\([0-9]*\)') + size1=$(expr "$psnr" : '.*bytes: *\([0-9]*\)') + size2=$(expr "$psnr" : '.*bytes:[ 0-9]*/ *\([0-9]*\)') + if [ $max -gt ${3:-1} ] || [ $size1 != $size2 ]; then + echo "$psnr" + return 1 + fi +} + +if ! test -e "$ref"; then + echo "reference file '$ref' not found" + exit 1 +fi + mkdir -p "$outdir" -eval $target_exec $command > "$outfile" 2>/dev/null -diff -u -w "$ref" "$outfile" +eval $target_exec $command > "$outfile" 2>/dev/null || exit + +case $cmp in + diff) diff -u -w "$ref" "$outfile" ;; + oneoff) oneoff "$ref" "$outfile" "$fuzz" ;; +esac + +test $? = 0 && rm $outfile diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/fate.mak b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/fate.mak index e496984a5..3e8ae0199 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/fate.mak +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/fate.mak @@ -668,6 +668,40 @@ FATE_TESTS += fate-vp6a fate-vp6a: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/flash-vp6/300x180-Scr-f8-056alpha.flv -f framecrc - FATE_TESTS += fate-vp6f fate-vp6f: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/flash-vp6/clip1024.flv -f framecrc - +FATE_TESTS += fate-vp8-test-vector-001 +fate-vp8-test-vector-001: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-001.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-002 +fate-vp8-test-vector-002: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-002.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-003 +fate-vp8-test-vector-003: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-003.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-004 +fate-vp8-test-vector-004: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-004.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-005 +fate-vp8-test-vector-005: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-005.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-006 +fate-vp8-test-vector-006: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-006.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-007 +fate-vp8-test-vector-007: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-007.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-008 +fate-vp8-test-vector-008: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-008.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-009 +fate-vp8-test-vector-009: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-009.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-010 +fate-vp8-test-vector-010: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-010.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-011 +fate-vp8-test-vector-011: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-011.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-012 +fate-vp8-test-vector-012: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-012.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-013 +fate-vp8-test-vector-013: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-013.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-014 +fate-vp8-test-vector-014: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-014.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-015 +fate-vp8-test-vector-015: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-015.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-016 +fate-vp8-test-vector-016: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-016.ivf -f framemd5 - +FATE_TESTS += fate-vp8-test-vector-017 +fate-vp8-test-vector-017: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vp8-test-vectors-r1/vp80-00-comprehensive-017.ivf -f framemd5 - FATE_TESTS += fate-vqa-cc fate-vqa-cc: CMD = $$BUILD_PATH/ffmpeg -i $$SAMPLES_PATH/vqa/cc-demo1-partial.vqa -pix_fmt rgb24 -f framecrc - FATE_TESTS += fate-vqf-demux diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/fate2.mak b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/fate2.mak new file mode 100644 index 000000000..e65f9d99e --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/fate2.mak @@ -0,0 +1,104 @@ +FATE2_TESTS += fate-twinvq +fate-twinvq: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/vqf/achterba.vqf -f s16le - +fate-twinvq: CMP = oneoff +fate-twinvq: REF = $(SAMPLES)/vqf/achterba.pcm + +FATE2_TESTS += fate-sipr-16k +fate-sipr-16k: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/sipr/sipr_16k.rm -f s16le - +fate-sipr-16k: CMP = oneoff +fate-sipr-16k: REF = $(SAMPLES)/sipr/sipr_16k.pcm + +FATE2_TESTS += fate-sipr-8k5 +fate-sipr-8k5: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/sipr/sipr_8k5.rm -f s16le - +fate-sipr-8k5: CMP = oneoff +fate-sipr-8k5: REF = $(SAMPLES)/sipr/sipr_8k5.pcm + +FATE2_TESTS += fate-sipr-6k5 +fate-sipr-6k5: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/sipr/sipr_6k5.rm -f s16le - +fate-sipr-6k5: CMP = oneoff +fate-sipr-6k5: REF = $(SAMPLES)/sipr/sipr_6k5.pcm + +FATE2_TESTS += fate-sipr-5k0 +fate-sipr-5k0: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/sipr/sipr_5k0.rm -f s16le - +fate-sipr-5k0: CMP = oneoff +fate-sipr-5k0: REF = $(SAMPLES)/sipr/sipr_5k0.pcm + +FATE2_TESTS += fate-aac-al04_44 +fate-aac-al04_44: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/aac/al04_44.mp4 -f s16le - +fate-aac-al04_44: CMP = oneoff +fate-aac-al04_44: REF = $(SAMPLES)/aac/al04_44.s16 +fate-aac-al04_44: FUZZ = 2 + +FATE2_TESTS += fate-aac-al07_96 +fate-aac-al07_96: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/aac/al07_96.mp4 -f s16le - +fate-aac-al07_96: CMP = oneoff +fate-aac-al07_96: REF = $(SAMPLES)/aac/al07_96.s16 +fate-aac-al07_96: FUZZ = 2 + +FATE2_TESTS += fate-aac-am00_88 +fate-aac-am00_88: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/aac/am00_88.mp4 -f s16le - +fate-aac-am00_88: CMP = oneoff +fate-aac-am00_88: REF = $(SAMPLES)/aac/am00_88.s16 +fate-aac-am00_88: FUZZ = 2 + +FATE2_TESTS += fate-aac-al_sbr_hq_cm_48_2 +fate-aac-al_sbr_hq_cm_48_2: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/aac/al_sbr_cm_48_2.mp4 -f s16le - +fate-aac-al_sbr_hq_cm_48_2: CMP = oneoff +fate-aac-al_sbr_hq_cm_48_2: REF = $(SAMPLES)/aac/al_sbr_hq_cm_48_2.s16 +fate-aac-al_sbr_hq_cm_48_2: FUZZ = 2 + +FATE2_TESTS += fate-aac-al_sbr_ps_06_ur +fate-aac-al_sbr_ps_06_ur: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/aac/al_sbr_ps_06_new.mp4 -f s16le - +fate-aac-al_sbr_ps_06_ur: CMP = oneoff +fate-aac-al_sbr_ps_06_ur: REF = $(SAMPLES)/aac/al_sbr_ps_06_ur.s16 +fate-aac-al_sbr_ps_06_ur: FUZZ = 2 + +FATE2_TESTS += fate-ra-288 +fate-ra-288: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/real/ra_288.rm -f s16le - +fate-ra-288: CMP = oneoff +fate-ra-288: REF = $(SAMPLES)/real/ra_288.pcm + +FATE2_TESTS += fate-ra-cook +fate-ra-cook: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/real/ra_cook.rm -f s16le - +fate-ra-cook: CMP = oneoff +fate-ra-cook: REF = $(SAMPLES)/real/ra_cook.pcm + +FATE2_TESTS += fate-mpeg2-field-enc +fate-mpeg2-field-enc: CMD = $(TARGET_PATH)/ffmpeg -flags +bitexact -dct fastint -idct simple -i $(SAMPLES)/mpeg2/mpeg2_field_encoding.ts -f framecrc - + +FATE2_TESTS += fate-qcelp +fate-qcelp: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/qcp/0036580847.QCP -f s16le - +fate-qcelp: CMP = oneoff +fate-qcelp: REF = $(SAMPLES)/qcp/0036580847.pcm + +FATE2_TESTS += fate-qdm2 +fate-qdm2: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/qt-surge-suite/surge-2-16-B-QDM2.mov -f s16le - +fate-qdm2: CMP = oneoff +fate-qdm2: REF = $(SAMPLES)/qt-surge-suite/surge-2-16-B-QDM2.pcm +fate-qdm2: FUZZ = 2 + +FATE2_TESTS += fate-imc +fate-imc: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/imc/imc.avi -f s16le - +fate-imc: CMP = oneoff +fate-imc: REF = $(SAMPLES)/imc/imc.pcm + +FATE2_TESTS += fate-yop +fate-yop: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/yop/test1.yop -pix_fmt rgb24 -an -f framecrc - + +FATE2_TESTS += fate-pictor +fate-pictor: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/pictor/MFISH.PIC -pix_fmt rgb24 -an -f framecrc - + +FATE2_TESTS += fate-dts +fate-dts: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/dts/dts.ts -f s16le - +fate-dts: CMP = oneoff +fate-dts: REF = $(SAMPLES)/dts/dts.pcm + +FATE2_TESTS += fate-nellymoser +fate-nellymoser: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/nellymoser/nellymoser.flv -f s16le - +fate-nellymoser: CMP = oneoff +fate-nellymoser: REF = $(SAMPLES)/nellymoser/nellymoser.pcm + +FATE2_TESTS += fate-truespeech +fate-truespeech: CMD = $(TARGET_PATH)/ffmpeg -i $(SAMPLES)/truespeech/a6.wav -f s16le - +fate-truespeech: CMP = oneoff +fate-truespeech: REF = $(SAMPLES)/truespeech/a6.pcm diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/lavfi-regression.sh b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/lavfi-regression.sh index ebbc0f3f6..220d43cf0 100755 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/lavfi-regression.sh +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/lavfi-regression.sh @@ -86,6 +86,26 @@ if [ -n "$do_lavfi_pix_fmts" ]; then done fi +if [ -n "$do_lavfi_pixdesc" ]; then + pix_fmts="$($ffmpeg -pix_fmts list 2>/dev/null | sed -ne '9,$p' | grep '^IO' | cut -d' ' -f2)" + + ref_file=tests/ref/lavfi/lavfi_pixdesc + rm -f $ref_file + res_file=$logfile + + for pix_fmt in $pix_fmts; do + # print to the reference logfile + logfile=$ref_file + do_video_encoding "lavfi_pixdesc-${pix_fmt}.nut" "" \ + "-vf slicify=random,format=$pix_fmt -vcodec rawvideo -pix_fmt $pix_fmt" + + # print to the result logfile + logfile=$res_file + do_video_encoding "lavfi_pixdesc-${pix_fmt}.nut" "" \ + "-vf slicify=random,format=$pix_fmt,pixdesctest -vcodec rawvideo -pix_fmt $pix_fmt" + done +fi + # TODO: add tests for # direct rendering, # chains with feedback loops diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_ima_qt b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_ima_qt index 4fef15482..6e4415660 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_ima_qt +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_ima_qt @@ -1,4 +1,4 @@ 3c06fd2f7831e3e8735b936e23ca220c *./tests/data/acodec/adpcm_qt.aiff 281252 ./tests/data/acodec/adpcm_qt.aiff 9580492803ba1c1a3746367b24b751c8 *./tests/data/adpcm_ima_qt.acodec.out.wav -stddev: 914.63 PSNR: 37.10 bytes: 1058604/ 1058444 +stddev: 914.65 PSNR: 37.10 MAXDIFF:34026 bytes: 1058560/ 1058400 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_ima_wav b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_ima_wav index a58c27988..29f5836fd 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_ima_wav +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_ima_wav @@ -1,4 +1,4 @@ 56b75c3a6dacedcf2ce7b0586aa33594 *./tests/data/acodec/adpcm_ima.wav 267324 ./tests/data/acodec/adpcm_ima.wav 78a2af1c895792d0c221d127bdd48ece *./tests/data/adpcm_ima_wav.acodec.out.wav -stddev: 903.51 PSNR: 37.21 bytes: 1061792/ 1058444 +stddev: 903.51 PSNR: 37.21 MAXDIFF:34026 bytes: 1061748/ 1058400 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_ms b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_ms index 99a7105fc..65d2a6ca6 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_ms +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_ms @@ -1,4 +1,4 @@ a407b87daeef5b25dfb6c5b3f519e9c1 *./tests/data/acodec/adpcm_ms.wav 268378 ./tests/data/acodec/adpcm_ms.wav 7be370f937c51e8a967e6a3d08d5156a *./tests/data/adpcm_ms.acodec.out.wav -stddev: 1050.00 PSNR: 35.91 bytes: 1060620/ 1058444 +stddev: 1050.01 PSNR: 35.91 MAXDIFF:29806 bytes: 1060576/ 1058400 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_swf b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_swf index 59bf8f3a4..27a5da518 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_swf +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_swf @@ -1,4 +1,4 @@ 42d4639866ed4d692eaf126228a4fa2a *./tests/data/acodec/adpcm_swf.flv 269166 ./tests/data/acodec/adpcm_swf.flv 628089745a7059ae4055c2515b6d668b *./tests/data/adpcm_swf.acodec.out.wav -stddev: 933.65 PSNR: 36.93 bytes: 1065004/ 1058444 +stddev: 933.58 PSNR: 36.93 MAXDIFF:51119 bytes: 1064960/ 1058400 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_yam b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_yam index 9889dd90d..d7076e721 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_yam +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/adpcm_yam @@ -1,4 +1,4 @@ 2546d72df736b5ffa1557e8c9c9ef788 *./tests/data/acodec/adpcm_yam.wav 266296 ./tests/data/acodec/adpcm_yam.wav c80c847a53a0fee17a88fa889ec34a4e *./tests/data/adpcm_yam.acodec.out.wav -stddev: 1247.64 PSNR: 34.41 bytes: 1065004/ 1058444 +stddev: 1247.60 PSNR: 34.41 MAXDIFF:39895 bytes: 1064960/ 1058400 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/alac b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/alac index 143b1f3cd..1f4b264b8 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/alac +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/alac @@ -1,4 +1,4 @@ c68f649777ab8e7c9a0f1f221451d3ad *./tests/data/acodec/alac.m4a 389386 ./tests/data/acodec/alac.m4a 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/alac.acodec.out.wav -stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/flac b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/flac index b1e417426..e9d7cfc0a 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/flac +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/flac @@ -1,4 +1,4 @@ 151eef9097f944726968bec48649f00a *./tests/data/acodec/flac.flac 361582 ./tests/data/acodec/flac.flac 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/flac.acodec.out.wav -stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/g726 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/g726 index 02b9eea65..e0399bf23 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/g726 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/g726 @@ -1,4 +1,4 @@ 5d8cce28f83dd33c3c7eaf43a5db5294 *./tests/data/acodec/g726.wav 24082 ./tests/data/acodec/g726.wav 4f1ba1af75dee64625a1c852e6cd01d3 *./tests/data/g726.acodec.out.wav -stddev: 8506.46 PSNR: 17.73 bytes: 96148/ 1058444 +stddev: 8504.69 PSNR: 17.74 MAXDIFF:31645 bytes: 96104/ 1058400 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/mp2 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/mp2 index 0607caba1..df21be2bd 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/mp2 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/mp2 @@ -1,5 +1,5 @@ f6eb0a205350bbd7fb1028a01c7ae8aa *./tests/data/acodec/mp2.mp2 96130 ./tests/data/acodec/mp2.mp2 74c7b6b15a001add199619fafe4059a1 *./tests/data/mp2.acodec.out.wav -stddev: 9315.80 PSNR: 16.94 bytes: 1059884/ 1058444 -stddev: 4385.25 PSNR: 23.49 bytes: 1057960/ 1058444 +stddev: 9315.99 PSNR: 16.94 MAXDIFF:65388 bytes: 1059840/ 1058400 +stddev: 4384.33 PSNR: 23.49 MAXDIFF:52631 bytes: 1057916/ 1058400 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/pcm b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/pcm index 6f2c56e3a..1d876e4ac 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/pcm +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/pcm @@ -1,72 +1,72 @@ 89f5b8dd97e0dddbe59af0d44fd229f3 *./tests/data/acodec/pcm_alaw.wav 529256 ./tests/data/acodec/pcm_alaw.wav 0568b0b9a72e31559e150e7e09d301cd *./tests/data/pcm.acodec.out.wav -stddev: 101.67 PSNR: 56.19 bytes: 1058444/ 1058444 +stddev: 101.67 PSNR: 56.19 MAXDIFF: 515 bytes: 1058400/ 1058400 f443a8eeb1647ec1eeb8370c939e52d4 *./tests/data/acodec/pcm_mulaw.wav 529256 ./tests/data/acodec/pcm_mulaw.wav 1c3eeaa8814ebd4916780dff80ed6dc5 *./tests/data/pcm.acodec.out.wav -stddev: 103.38 PSNR: 56.04 bytes: 1058444/ 1058444 +stddev: 103.38 PSNR: 56.04 MAXDIFF: 644 bytes: 1058400/ 1058400 b7936d7170e0efefb379349d81aed360 *./tests/data/acodec/pcm_s8.mov 530837 ./tests/data/acodec/pcm_s8.mov 652edf30f35ad89bf27bcc9d2f9c7b53 *./tests/data/pcm.acodec.out.wav -stddev: 147.89 PSNR: 52.93 bytes: 1058444/ 1058444 +stddev: 147.89 PSNR: 52.93 MAXDIFF: 255 bytes: 1058400/ 1058400 98cadb3502dbdc99e6e077c28b1a036c *./tests/data/acodec/pcm_u8.wav 529244 ./tests/data/acodec/pcm_u8.wav 652edf30f35ad89bf27bcc9d2f9c7b53 *./tests/data/pcm.acodec.out.wav -stddev: 147.89 PSNR: 52.93 bytes: 1058444/ 1058444 +stddev: 147.89 PSNR: 52.93 MAXDIFF: 255 bytes: 1058400/ 1058400 c42b9c04305455250366c84e17c1023f *./tests/data/acodec/pcm_s16be.mov 1060037 ./tests/data/acodec/pcm_s16be.mov 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav -stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/acodec/pcm_s16le.wav 1058444 ./tests/data/acodec/pcm_s16le.wav 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav -stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 352a6bcf51d0f3ca4bf27c423a3d4d14 *./tests/data/acodec/pcm_s16be.mkv 1060650 ./tests/data/acodec/pcm_s16be.mkv 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav -stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 2c089d83b2699c02c9358415e00a9707 *./tests/data/acodec/pcm_s16le.mkv 1060650 ./tests/data/acodec/pcm_s16le.mkv 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav -stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 07ffe7ffb78f3648b6524debdde5aec1 *./tests/data/acodec/pcm_s24be.mov 1589237 ./tests/data/acodec/pcm_s24be.mov 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav -stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 a85380fb79b0d4fff38e24ac1e34bb94 *./tests/data/acodec/pcm_s24le.wav 1587668 ./tests/data/acodec/pcm_s24le.wav 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav -stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 d7792f0343cd66fda8b50b569e2bcc48 *./tests/data/acodec/pcm_s32be.mov 2118437 ./tests/data/acodec/pcm_s32be.mov 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav -stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 da6ed80f4f40f0082577dea80827e014 *./tests/data/acodec/pcm_s32le.wav 2116868 ./tests/data/acodec/pcm_s32le.wav 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav -stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 118ff3dc83c62ce9ce669eef57e55bb2 *./tests/data/acodec/pcm_f32be.au 2116824 ./tests/data/acodec/pcm_f32be.au 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav -stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 46f44f86a18984a832206ab9e29a79f2 *./tests/data/acodec/pcm_f32le.wav 2116880 ./tests/data/acodec/pcm_f32le.wav 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav -stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 8112296b1ed94f72f20d04b1a54850a7 *./tests/data/acodec/pcm_f64be.au 4233624 ./tests/data/acodec/pcm_f64be.au 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav -stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 ba17c6d1a270e1333e981f239bf7eb45 *./tests/data/acodec/pcm_f64le.wav 4233680 ./tests/data/acodec/pcm_f64le.wav 95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav -stddev: 0.00 PSNR:999.99 bytes: 1058444/ 1058444 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 8c74234928ed425b1171211a89f67ead *./tests/data/acodec/pcm_zork.wav 529256 ./tests/data/acodec/pcm_zork.wav 864c8c866ac25642c29a13b122c70709 *./tests/data/pcm.acodec.out.wav -stddev: 633.10 PSNR: 40.30 bytes: 1058444/ 1058444 +stddev: 633.11 PSNR: 40.30 MAXDIFF:32768 bytes: 1058400/ 1058400 8168a5c1343553ef027541830f2cb879 *./tests/data/acodec/pcm_s24daud.302 10368730 ./tests/data/acodec/pcm_s24daud.302 f552afadfdfcd6348a07095da6382de5 *./tests/data/pcm.acodec.out.wav -stddev: 9415.16 PSNR: 16.85 bytes: 6911864/ 1058444 +stddev: 9416.28 PSNR: 16.85 MAXDIFF:42744 bytes: 6911796/ 1058400 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/wmav1 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/wmav1 index f1bb69c4f..916e4a8ab 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/wmav1 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/wmav1 @@ -1,4 +1,4 @@ 26a7f6b0f0b7181df8df3fa589f6bf81 *./tests/data/acodec/wmav1.asf 106004 ./tests/data/acodec/wmav1.asf -stddev:12245.27 PSNR: 14.57 bytes: 1065004/ 1058444 -stddev: 2097.78 PSNR: 29.89 bytes: 1056812/ 1058444 +stddev:12245.52 PSNR: 14.57 MAXDIFF:65521 bytes: 1064960/ 1058400 +stddev: 2095.89 PSNR: 29.90 MAXDIFF:27658 bytes: 1056768/ 1058400 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/wmav2 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/wmav2 index ca18dea7a..622b6fcc3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/wmav2 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/acodec/wmav2 @@ -1,4 +1,4 @@ 7c6c0cb692af01b312ae345723674b5f *./tests/data/acodec/wmav2.asf 106044 ./tests/data/acodec/wmav2.asf -stddev:12249.69 PSNR: 14.57 bytes: 1065004/ 1058444 -stddev: 2091.12 PSNR: 29.92 bytes: 1056812/ 1058444 +stddev:12249.93 PSNR: 14.57 MAXDIFF:65521 bytes: 1064960/ 1058400 +stddev: 2089.21 PSNR: 29.93 MAXDIFF:27650 bytes: 1056768/ 1058400 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/mpeg2-field-enc b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/mpeg2-field-enc new file mode 100644 index 000000000..1ea05bd9b --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/mpeg2-field-enc @@ -0,0 +1,39 @@ +0, 0, 622080, 0xb3b66c5c +0, 3600, 622080, 0xb3b66c5c +0, 7200, 622080, 0xb3b66c5c +0, 10800, 622080, 0xb3b66c5c +0, 14400, 622080, 0xb3b66c5c +0, 18000, 622080, 0xb3b66c5c +0, 21600, 622080, 0xb3b66c5c +0, 25200, 622080, 0xb3b66c5c +0, 28800, 622080, 0xb3b66c5c +0, 32400, 622080, 0x088ec02b +0, 36000, 622080, 0x7a36db21 +0, 39600, 622080, 0x541b286f +0, 43200, 622080, 0xb6c3e590 +0, 46800, 622080, 0x39dbed51 +0, 50400, 622080, 0x973dc728 +0, 54000, 622080, 0xd7a4f804 +0, 57600, 622080, 0xa2484762 +0, 61200, 622080, 0x0cd268d1 +0, 64800, 622080, 0x72eb663d +0, 68400, 622080, 0x8fdbac59 +0, 72000, 622080, 0xa6f4feb9 +0, 75600, 622080, 0xadb828c6 +0, 79200, 622080, 0xea630a63 +0, 82800, 622080, 0xa901d925 +0, 86400, 622080, 0xac5e7087 +0, 90000, 622080, 0x10274a2b +0, 93600, 622080, 0x143d541c +0, 97200, 622080, 0xee94c93a +0, 100800, 622080, 0xca030208 +0, 104400, 622080, 0x26f30ead +0, 108000, 622080, 0xfc22f32c +0, 111600, 622080, 0x940a5ff8 +0, 115200, 622080, 0x2164f805 +0, 118800, 622080, 0xa76f5aba +0, 122400, 622080, 0x8c311471 +0, 126000, 622080, 0xa45e1d95 +0, 129600, 622080, 0x6cc61d6c +0, 133200, 622080, 0x6983b417 +0, 136800, 622080, 0x982363c0 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/pictor b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/pictor new file mode 100644 index 000000000..3fa0f31f1 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/pictor @@ -0,0 +1 @@ +0, 0, 192816, 0xf97e2ba1 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vc1 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vc1 index 737dad045..d8b8f93e3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vc1 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vc1 @@ -1,2 +1,15 @@ 0, 0, 38016, 0xf1b25db5 -0, 0, 38016, 0xf1b25db5 +0, 3600, 38016, 0xf1b25db5 +0, 7200, 38016, 0xf1b25db5 +0, 10800, 38016, 0x9ed7f0de +0, 14400, 38016, 0x5a0b2cf6 +0, 18000, 38016, 0x5e3ed87b +0, 21600, 38016, 0xe2e3432d +0, 25200, 38016, 0xe2e3432d +0, 28800, 38016, 0x76854773 +0, 32400, 38016, 0x76854773 +0, 36000, 38016, 0xefbb2133 +0, 39600, 38016, 0xefbb2133 +0, 43200, 38016, 0xefbb2133 +0, 46800, 38016, 0xefbb2133 +0, 50400, 38016, 0xefbb2133 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-001 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-001 new file mode 100644 index 000000000..df138923d --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-001 @@ -0,0 +1,29 @@ +0, 0, 38016, 83c78b5db579710f61f9354d5c51e8c8 +0, 3000, 38016, 8d089d226f52d6cdaffdb3fcc080b75b +0, 6000, 38016, acaae81ca812145e85e0be83bdf54226 +0, 9000, 38016, e94651d798b6bf5f09a9bba10cacaf7a +0, 12000, 38016, 60c2607913e528d501962bf407341731 +0, 15000, 38016, e683f2bf28b31e36db88087bd03b6917 +0, 18000, 38016, 0c2923785051bc9b90c2447a85527764 +0, 21000, 38016, 1bc97b6b2e4ca36b149c3768495747ac +0, 24000, 38016, 0586d948ed3fd479c6dd08055973bcb4 +0, 27000, 38016, c9a1198e1680487c77a2d1631695aeec +0, 30000, 38016, 547d8ffce9c085231c74717a9b815625 +0, 33000, 38016, d31c02a5591eb7bd8e73703252e1a1ab +0, 36000, 38016, 23bafc8e22b2ed7e8c5e52369095cd30 +0, 39000, 38016, 9725d52d7810a19b20dcc9bb0fa36abd +0, 42000, 38016, 7aefaabdcd2595939fd05078d01b484b +0, 45000, 38016, 828e758d6f0b29b2693b2dc6b09249a6 +0, 48000, 38016, 53f09380dde1420ba270b74d8819537c +0, 51000, 38016, 09791a7db3bc28258350cfdc95d8f224 +0, 54000, 38016, 2050271dc4ba3f3e427cf8088c96e28d +0, 57000, 38016, 4e69d3f7cea45844b740368fcd4dd815 +0, 60000, 38016, 4ed07697e239b7f12ee6a97ad09c08fb +0, 63000, 38016, 1437c129bfbda63ca1d39a94ee91b097 +0, 66000, 38016, 4fc951bf45e164b711591155a59c73fa +0, 69000, 38016, 97d1007e27b4b9072751e87e8d1f1415 +0, 72000, 38016, 18c809835dcc3d30c93ae1be569dcd24 +0, 75000, 38016, de0fd0035a542791c4dda5735657efc5 +0, 78000, 38016, 27a70ff95d0cfa10f54652c9fb8a9db2 +0, 81000, 38016, 2285b9324ec91099626191f769962e44 +0, 84000, 38016, 56794d911b02190212bca92f88ad60c6 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-002 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-002 new file mode 100644 index 000000000..0ec5af81d --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-002 @@ -0,0 +1,49 @@ +0, 0, 38016, 872e9922f37f0e92c767d33e0a15b8e0 +0, 3750, 38016, ea5ad6c6ee4355018fc0ba83b5172836 +0, 7500, 38016, fe744612b2167c9ba6e1dc81c031e16a +0, 11250, 38016, 744359695caee3f32307a2d7eef09e85 +0, 15000, 38016, 07211ac8d8bae4d931ade402ff6e3c12 +0, 18750, 38016, 2ce02854f228b1378d9dc34cab8d343b +0, 22500, 38016, af5222ad42c4f22f22fbf19c26c02dcb +0, 26250, 38016, 88538d39f2647df8fedf15bd1b767bbf +0, 30000, 38016, d0d936471dd4e9922eb067c0f09eacab +0, 33750, 38016, 03cb1f5c5026e96f6e686aa1fa9b1028 +0, 37500, 38016, 2ebe35e23d2244c5b0f777fbc01f8f37 +0, 41250, 38016, f9314f5ea91ebbaaed6e37ca0701ed67 +0, 45000, 38016, 37dca7530d09fd1e8bad154b9e312ea2 +0, 48750, 38016, 9841dc8ff6424abe362c4dfe03b5fbd0 +0, 52500, 38016, 72bd0b70c576dfb544f622c488217491 +0, 56250, 38016, 309b21c126153f20f312e38a8dad44e1 +0, 60000, 38016, 0acbb170ede66ebdae4e9d8e56908f75 +0, 63750, 38016, 318c9c3e531d00734b5f78433da176c9 +0, 67500, 38016, 0388dfdb2a792148b44bdb705cc2df99 +0, 71250, 38016, f440adff2b44888becbf3ca16e425441 +0, 75000, 38016, ac41431627d8d1712d40412ab8c3200c +0, 78750, 38016, 417e1abbfe2a078663dae688ae4a9bb1 +0, 82500, 38016, 73d493bdf4a29d5cfeec610109f582a8 +0, 86250, 38016, 3c026a536ef36467d4a9db6bcc20cec1 +0, 90000, 38016, 57836430f2f10862b84541d99cca062c +0, 93750, 38016, 04ad6fa97e1ff49931b574bdaaddd5db +0, 97500, 38016, e94f2ec4cbf2b9067a4a4307eadebb6f +0, 101250, 38016, e3542cdee672d97c65ab06dbe611247d +0, 105000, 38016, 6c83c6c76aa8bf73646eb7a714cb42bf +0, 108750, 38016, b5f64c6fc6d0c777a0a0b9097862f171 +0, 112500, 38016, 293dccaf5027759679bb9e8696b6381a +0, 116250, 38016, 1a3d015ff9b164cb7922aef0aeac520e +0, 120000, 38016, 93f9152d9425f0ec43160a0c01c485b2 +0, 123750, 38016, c7c4a8f78f781f70cedc44edc1d06911 +0, 127500, 38016, 21330442d5bef415fd765759d867c98b +0, 131250, 38016, 6164258040f85206a3833aeb4f27a34f +0, 135000, 38016, 3213e1405dfe6588a7334a8bc2b1e47f +0, 138750, 38016, a619fa73f0081a349dfa2b000de19045 +0, 142500, 38016, 1f3cec4bb793dc4a118ddcf500090f37 +0, 146250, 38016, 12308ec77632ca10f1451aec8e62b82f +0, 150000, 38016, 018c7f50ed4a494a9fcd32fdfed6705f +0, 153750, 38016, a7282728fbd7e0b49a6967b0ea4e1f61 +0, 157500, 38016, 6aa15ab83e82f246ee9c7b7a040bfaac +0, 161250, 38016, e4c17d2603e03753d54a142491cf5dc0 +0, 165000, 38016, 0a7331aa707e42e732f04e9175438195 +0, 168750, 38016, b522cfa3f3c706d1901231bb9e6b4b8a +0, 172500, 38016, 7b2a70e47d9af98cfa6216ed2a7d528c +0, 176250, 38016, b56e22bc9beacff9c3207b2757fc7f94 +0, 180000, 38016, a3dfc9461c0480cf56ee465ddabf0de1 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-003 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-003 new file mode 100644 index 000000000..9ff420028 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-003 @@ -0,0 +1,49 @@ +0, 0, 38016, 96e6ce168b5ef377053e86ab5484e7f9 +0, 3750, 38016, 10fd750292d8522ab7ee577043604789 +0, 7500, 38016, e040995173dc5c85abbbe38f6823ff9a +0, 11250, 38016, 5aa18f4fbd8b5b887d74f84cc92075dc +0, 15000, 38016, f0dc7f520e88b94e5cb924d804b0472a +0, 18750, 38016, 2375955dce3bb0a824779a800cd1555b +0, 22500, 38016, 3e96a0e477de39530e1950cff284a854 +0, 26250, 38016, 6cd40fa8a89221f2b990bd8af2a9ee14 +0, 30000, 38016, 0b929243ceeffce836279e2aa84647cd +0, 33750, 38016, 1e95f0ad25fe033076b57c3852bb3550 +0, 37500, 38016, 81aa93a3f9c56d2aa4b8285d3507e6b4 +0, 41250, 38016, cf9947a302dec306d7f487cf3a2731b0 +0, 45000, 38016, 3b9ca47752db95a049678da07974b476 +0, 48750, 38016, aa6788405dc47dd44867fca6c95ba3d9 +0, 52500, 38016, 276d1c62b908c081c7bbb78f943b0de1 +0, 56250, 38016, eb006b6218e457fd794e9b3a5dfbf638 +0, 60000, 38016, 9dd5312833e770286c5aa5436a00376e +0, 63750, 38016, 7899278e66aa255ce5bf69a6e1137d0f +0, 67500, 38016, 0ac7d062ea7550fa0717723b1272abc2 +0, 71250, 38016, d8f1bb881a46ecafcbbe457a004a71f1 +0, 75000, 38016, cc3a04b98159189a74b5241df540d8fb +0, 78750, 38016, 4e29eb2c8c465ae9ffcfa28ec0b3694b +0, 82500, 38016, 608fb6ba526e6aa4ad1c0290aedaa69d +0, 86250, 38016, 4acc6a73547be6310b9a275436c55805 +0, 90000, 38016, 482cf409b86242d30f3a78a6c85364df +0, 93750, 38016, a22cb76770f112eb1169218cc87c1e4f +0, 97500, 38016, e74675b051ff05e178a9a24893721d99 +0, 101250, 38016, ee5061bff62c8c8603b7bc2bb2bb29e8 +0, 105000, 38016, a3c0ab11f338bd488c69f2b62e1e5a74 +0, 108750, 38016, 9f6b7e30e0ed4e272393b9a9957752e1 +0, 112500, 38016, 9cce9f2ffff1766d05bda04e46eff997 +0, 116250, 38016, 5105a2ba923bc6f21ea3d32ab1bc7bf8 +0, 120000, 38016, 957d619a1001e2b5e52db166b66b7f50 +0, 123750, 38016, fdb4e71cddeec8a321d9c8d4ffc506ce +0, 127500, 38016, 9ee646940fb8ac2312d29e9f1c3b6d40 +0, 131250, 38016, a110e81d2105beae81cd36b15bc5ac2f +0, 135000, 38016, 804b6d8fc99fadb9c6bfdae3becee6b5 +0, 138750, 38016, e217627bbaeebf30456e38aeb1f0746b +0, 142500, 38016, 56468a2c548dd3085b4bce88c4a1e41d +0, 146250, 38016, ef170e7f21e2b262525b43d6b25dec4c +0, 150000, 38016, 3acc3c47def8a0fa0561eaacaf9e41a1 +0, 153750, 38016, 0c3e2187f13e4504fb4b246706bba83c +0, 157500, 38016, 397326a22e6e49487309c39d64037df8 +0, 161250, 38016, 95236c1319b6f1f692b3998547811ee7 +0, 165000, 38016, 5aff1957504884abf74d6fb74b74b032 +0, 168750, 38016, 6de06343435a8926a746037cab5f633c +0, 172500, 38016, 3de68e05ddf2c60ee9110048ceefeb6a +0, 176250, 38016, e637fef689edad6ffd6eeb4a29004bf7 +0, 180000, 38016, bb809114af8df5cb4ed82d3a1d11a673 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-004 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-004 new file mode 100644 index 000000000..56e05b29d --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-004 @@ -0,0 +1,29 @@ +0, 0, 38016, 83c78b5db579710f61f9354d5c51e8c8 +0, 3000, 38016, d173eb8a8211a05672b43206609c9034 +0, 6000, 38016, 204e3e91613d647d30244c00fa2b9563 +0, 9000, 38016, 3cc1a395bd10a49b006741778285925b +0, 12000, 38016, 024548b00dea4f104d6b9a728be05786 +0, 15000, 38016, 01401e9418f2e00ab4ffdb3296d40ffa +0, 18000, 38016, 35d8b3c1ef9cb864315b7502b93629b2 +0, 21000, 38016, aeb44f0fe4c2eecb26c0bd657d65b00b +0, 24000, 38016, 42e40bed012bacf59f0c41d4cfd3e52a +0, 27000, 38016, 9796191fa2bd4572123ea043396e8485 +0, 30000, 38016, 2d6d68b902129f3c3f1730e73b98f9c9 +0, 33000, 38016, ba348b89248b92d0b86d794dc413e6a0 +0, 36000, 38016, 5ce49bf164033d49bef1b23120d202d6 +0, 39000, 38016, 54837a426c63a9c40ef8750232615dad +0, 42000, 38016, 350bcddf9a34f5003f6f655aaa020a00 +0, 45000, 38016, babb82b1e2ca9315816b6f43b8ef84a0 +0, 48000, 38016, c770825785c51fa374fd5bb08ff9f536 +0, 51000, 38016, e9e0f92e416fcd27ca2e93a0804ac938 +0, 54000, 38016, e0f2b89423da549eaa8b2b89f956f0f8 +0, 57000, 38016, 9926b7e13b51115735eb0af8bb5e4ea1 +0, 60000, 38016, d6b30a058b854c54068ebfc2b05f8fa0 +0, 63000, 38016, a03048df79e41ada8a3ecc15a85e3f94 +0, 66000, 38016, 34bef9af0633a43434841fd5189c161c +0, 69000, 38016, 219b447552b1ee409c1b9b56176d36bf +0, 72000, 38016, 95ea99459eaebc2f7233feeaf0549224 +0, 75000, 38016, 34e08ce4067ca67ee9014cf628b6bb1c +0, 78000, 38016, 066c09a20d11b9dc3fa6972fd7f242c4 +0, 81000, 38016, aed02c1951070ae5febea21ad54add55 +0, 84000, 38016, f5a0fde2d818c4aaabd29b069ced6aea diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-005 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-005 new file mode 100644 index 000000000..b672ee9b1 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-005 @@ -0,0 +1,49 @@ +0, 0, 38016, e7a4be434df4bb524ba56a03cba901f4 +0, 3750, 38016, d903ade6d49e51485627c044fbb2190c +0, 7500, 38016, af07ee39629b852870104cb9a9dde9e3 +0, 11250, 38016, 388a5f736db2de15342b62294fda4c82 +0, 15000, 38016, a072600936aa77738fa2fa88ba212849 +0, 18750, 38016, 0f96b1fb05b92498c0e1fcb6552e7e79 +0, 22500, 38016, 68b0db002a0127ee79a7c70062aa8c3a +0, 26250, 38016, f9bc8edfeb9ceca9227a20cdab6788de +0, 30000, 38016, bfe2115b000565abc3dce1d38f804ed7 +0, 33750, 38016, 67f17f96177f5464af1b97452560d2af +0, 37500, 38016, 658278016e5409b69d014fab0d94d0ea +0, 41250, 38016, 04dfd36afa0ddf22993d21c0a0fc715e +0, 45000, 38016, 088e5a7cc75a895f01f7a4362f104bc1 +0, 48750, 38016, fb622a1a421b3689950f1adde9296dbb +0, 52500, 38016, 3711ac7adc816614a2efda9e138f53fc +0, 56250, 38016, 8e6fe3e68ccf53f23dd430b611fbfa6d +0, 60000, 38016, 1c77dd651cd38d3308671f0705d29926 +0, 63750, 38016, bb5d7afccebc5d8a29f5980d21530d61 +0, 67500, 38016, e51f2eeb39afa50ea243eaca39974f82 +0, 71250, 38016, 7a73b1546fb5d8d4b05ebd4c839f74f8 +0, 75000, 38016, 62a0db46717d7fb6523c62968fd3bc85 +0, 78750, 38016, 98d6e520a164c42c5d19167c0ad48b22 +0, 82500, 38016, 9749a21ea432221323c1a6b61ea59d51 +0, 86250, 38016, 45fa9a9583db0139611b860bed8f6bc1 +0, 90000, 38016, aac06fe351759ca81a5028f2f4a7b534 +0, 93750, 38016, 7b7c7c16a377d61b6fe474541a18f0cd +0, 97500, 38016, 2a84883fdfa8450d46b8b9352b7d5a87 +0, 101250, 38016, 3fc42d7dd6fa25ec17d8f2881f81b376 +0, 105000, 38016, bfb243be1eada17adab5580b748248e7 +0, 108750, 38016, 531fd799989db62210efc1999397d280 +0, 112500, 38016, 1c1e68673b295e17fca1b14d1eb1995e +0, 116250, 38016, 12ee0f8810a1a3574337ef98987cf919 +0, 120000, 38016, 0c6ef1cec243c552e83054d5ac56a8c1 +0, 123750, 38016, cf0af3fb96e57143d335086485fbfa5c +0, 127500, 38016, f5df68bb123d1f2f59ba471fbd118a9e +0, 131250, 38016, 0b4a0cf5dd7968fd26959ad2849655b0 +0, 135000, 38016, 0ba766224688a95bfa43ac2453555972 +0, 138750, 38016, ef3f9fd7e5509bb880377fa1997d318c +0, 142500, 38016, d7486c3176cef98c0046522acbdaa4f0 +0, 146250, 38016, f8dd15973993f4a2acd1d34b3610622e +0, 150000, 38016, e99b7f294e6bdd9ae18f013f62174fcd +0, 153750, 38016, 68ccf7e14a1055b24c5faf1b3a1888e7 +0, 157500, 38016, 2f230afb6e5c67e4b7e000317638e919 +0, 161250, 38016, 9cab31ac76ed26a879ac8b88bf7d33a1 +0, 165000, 38016, 1e2affc0f458808b4564bd0453565a81 +0, 168750, 38016, 79669092f6c73053c3de6d0d1408cc8c +0, 172500, 38016, 7b27977ba84341b9af4d58a7864f763a +0, 176250, 38016, 2481a387d65e7a16fe831b8da2200985 +0, 180000, 38016, fa5e3bc265877b30ca71de0a2b14663b diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-006 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-006 new file mode 100644 index 000000000..bbdf8142f --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-006 @@ -0,0 +1,48 @@ +0, 0, 37697, 9ca5df27b0158aca2a38dff946f58c41 +0, 3750, 37697, 627129a99538ec1ac51be910ca92ebc4 +0, 7500, 37697, 6c2df1f21af317aa5bb68b161ca96c70 +0, 11250, 37697, d66db823863838ca5b7f9125609e7de3 +0, 15000, 37697, ecc970f8846290c0b7bf8d0865975cb7 +0, 18750, 37697, 2fe7575c448562e291933e297335e1c8 +0, 22500, 37697, e2a6fb8af11f65ce1153d6021df39e5f +0, 26250, 37697, 4536008cd0a425c9a9d93cbb3e8ba640 +0, 30000, 37697, 478f042fff1cf0b6fd2eed391879c7ba +0, 33750, 37697, f079ee39021b1dd730f80bfaff9a6ae4 +0, 37500, 37697, cb9b166c785ceabecf79e12e6068d4e4 +0, 41250, 37697, 6bd6f77dc9c45cec08949a42aa1c2653 +0, 45000, 37697, 1433577eb50b3270c0f1d6d26fb26277 +0, 48750, 37697, 2765b207d230efd9a3e2e93c641b8553 +0, 52500, 37697, a67e2f6bcf3b03e250c0ad8f1384ffb6 +0, 56250, 37697, b5ea80e2dbffefdd8a613c25ee7f5f0c +0, 60000, 37697, e4b58bf735a8258842ad3c364eb9418c +0, 63750, 37697, 8e5fc5d4c78eb495f62e4a014a6a2a6c +0, 67500, 37697, 53bee2faf4cfae16037cda36a6194a57 +0, 71250, 37697, e5c2e1de872a7107f80966ae857557d4 +0, 75000, 37697, 882e46851681e6e3b376b5d1d9e139fb +0, 78750, 37697, 40b199fe02b5885947af22ce1314a085 +0, 82500, 37697, 942b79dd5360c2a114db760424620a84 +0, 86250, 37697, fe9f69dd6fc113ceec9127d9e12b3958 +0, 90000, 37697, db13edae7e8e8a91d1ec84227c8f818f +0, 93750, 37697, 1963ea61c3e93150f7604ee6fa09b12c +0, 97500, 37697, 8cf43556160454d2353cedb9ba5675aa +0, 101250, 37697, a5e6b5b00fea3d9b1bdbd01fda712f27 +0, 105000, 37697, 35f006cb6e570999b9011282c49c6d22 +0, 108750, 37697, d884d482371cb2727e26475bb390d38b +0, 112500, 37697, a7233206056d3af69c6cff343b57de84 +0, 116250, 37697, 437492f3e594576e1c17065e0091aa2d +0, 120000, 37697, 47f0677d9aff054056a194755628fdb8 +0, 123750, 37697, fc93105a16501763a6e6ba3445ee6f32 +0, 127500, 37697, 68612903d08399e0f0d9e28c1f18f6ea +0, 131250, 37697, a340fbba24c73372e6248f10e878f11b +0, 135000, 37697, 58c3561b06f9d866587f728877c08860 +0, 138750, 37697, f2dd2a029515ad9c0655ccf86a2c524b +0, 142500, 37697, 789d43f63cbb302dad9f3e4b33713746 +0, 146250, 37697, d8f979aca1774470269283da048a505b +0, 150000, 37697, ecc06e2175290319cb36614370c8ad62 +0, 153750, 37697, 5ba26b83766b666007b502a7194170e3 +0, 157500, 37697, 8163a20e9a345b70579c625c50e7ec73 +0, 161250, 37697, 1f1a497d768c4bcd57de11b21baf9138 +0, 165000, 37697, a21e9a52a982675815c9937b49ebb0ff +0, 168750, 37697, dcc0bd83ce31ac99577cd2f9ced69096 +0, 172500, 37697, df36b27588b8515580d5015e5f66dbf9 +0, 176250, 37697, 156a6351549949953ce3197b990760a9 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-007 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-007 new file mode 100644 index 000000000..d4aa997ce --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-007 @@ -0,0 +1,29 @@ +0, 0, 38016, 98bd0af6928c144888a9c320270e9f0e +0, 3000, 38016, 9ff7cff703d58481acd233451388377c +0, 6000, 38016, e4cd8815527846cc782ea61ef5a46e49 +0, 9000, 38016, db45275b87e194e5b505dd8c47da4f5d +0, 12000, 38016, c889d0f7bd34faf4df0e0a9eb9fc292a +0, 15000, 38016, 4dbfb1727baf9b75980e7fdd44ca0924 +0, 18000, 38016, 5f217ac95c891dc81f7193fc5352d582 +0, 21000, 38016, 11166789635e472f629510f551b11e2c +0, 24000, 38016, 336e6e42e67e1ccb7cda6298cb63f192 +0, 27000, 38016, 02dbcff56882e304d5043d0f9b1ff9ff +0, 30000, 38016, fe033ea2c6b8b81a9328b470f8b0d6bb +0, 33000, 38016, 0e3330fe9a7c0439ff53f18f0d15eb48 +0, 36000, 38016, 6c0d7e042a3bb32a128c4a405f59b426 +0, 39000, 38016, 7e51afc33dbf4b77fc5735f5d9ec0248 +0, 42000, 38016, a8381f193f34a5071b8eeba7f5cd1968 +0, 45000, 38016, 501a7914b47ff85c24f0533ee98b9fe9 +0, 48000, 38016, 00bd5fbb7e3b66514e6c77c3a5f118c3 +0, 51000, 38016, 23e296d12a45909cadda252b9f4e67bd +0, 54000, 38016, fa0b5c69bacf766551bebdde0910eb9f +0, 57000, 38016, f5cc24d10d58ebc50503ca321db708cc +0, 60000, 38016, 3997eb9ff6231dee9e23752776113cd6 +0, 63000, 38016, 68d4c9cd494d91dd70e7a94c7a4b9a12 +0, 66000, 38016, 647b34f3aa7318adce68803ba00104fb +0, 69000, 38016, ffed5301bd6fddd1d24d12e6096cc8a6 +0, 72000, 38016, 9511388180811c10d166886868d6e71c +0, 75000, 38016, a9b330803b8ccd91596591c0449423ab +0, 78000, 38016, 69b192888cda09dac658d5820183a2e8 +0, 81000, 38016, 8886e5851e60a7474cc9e214ba6373ad +0, 84000, 38016, f59e354deedb129a90ab3922838b03d3 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-008 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-008 new file mode 100644 index 000000000..105b6b49a --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-008 @@ -0,0 +1,2 @@ +0, 0, 1907424, 7146d3a72b6cb8e43ee5280ef8d661fe +0, 3913, 1907424, 5a537e9710158efb5ad2683a1d3b4c72 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-009 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-009 new file mode 100644 index 000000000..c65210e0d --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-009 @@ -0,0 +1,49 @@ +0, 0, 38016, b3a3121c796a60c88988fef5240a07fe +0, 3750, 38016, f25147764829cf837e00b8fd6383e2c4 +0, 7500, 38016, 1b1552291a89c97d5deea145ab0ac0cd +0, 11250, 38016, 0b2e75bbbe8f4248eb1519b6542efc96 +0, 15000, 38016, 99e8fc68547e119253ee3b8d79efa774 +0, 18750, 38016, 3aaf9210819238da7f704339bd8f262c +0, 22500, 38016, de80b11f4c325e6d467d4abe5ad0db51 +0, 26250, 38016, 93d2fba68721768018b35ccac27b6bb1 +0, 30000, 38016, 07d7d4f8ad4151a013b652bec21ea9b8 +0, 33750, 38016, aaa95e4d39aa31cf68fdb8da268827e5 +0, 37500, 38016, 3607fcda0733e0b0fd10a8f7fbe6e39e +0, 41250, 38016, 6d8cc24ea3b9827ef0147c8b7cc6938d +0, 45000, 38016, 977a6b65d41b1b70dd4df9f526045675 +0, 48750, 38016, 9258b0e5fc2217c3aebbd96bb06c937a +0, 52500, 38016, 887378a3aad18346a3827cd0aadc6873 +0, 56250, 38016, c2a3ff302d74eefd0855f2c862766aca +0, 60000, 38016, 1a7d835f5a977e1fd8cc37bdd8d029ca +0, 63750, 38016, 232be1f7e334001c3abbed550cc60c34 +0, 67500, 38016, e8cb3470b9a3ffbc7014793514dc89cf +0, 71250, 38016, 54b20adca41910f003790a975ff7b50d +0, 75000, 38016, 2c5fce4dcdd538f1d9377fa071f3d615 +0, 78750, 38016, d559840da8cef1f0b1379a592f708f0a +0, 82500, 38016, ffab5f1060938a62cf8ef9df30ec8a33 +0, 86250, 38016, b7d93c8eda8cce4d387f2ea78c415704 +0, 90000, 38016, 7840aa27333e6350d114b256ab4304f1 +0, 93750, 38016, dc1f3b125177d0ad7f53dd058bba03e7 +0, 97500, 38016, 37134fcaad963a22f4df04c0765af455 +0, 101250, 38016, 4dc062fb76943a75e7b2428e5babbb3c +0, 105000, 38016, dfda91bc05efc72073a2b6b62f294327 +0, 108750, 38016, 7ffc690c63a1c54e35978336dc5828a3 +0, 112500, 38016, 9ae31bacbc097c2ccf1500ff89882e46 +0, 116250, 38016, 1450c24713dcad41aeba1c44007bf12f +0, 120000, 38016, f125bb52b8a1b11e076de55cca1069ee +0, 123750, 38016, 555e1f2a6d293a0bdc9f92e9c3b3118d +0, 127500, 38016, ec9a8d577a07a4f0d5deae63b3cea6dd +0, 131250, 38016, a54f74e0ee329db4a78851bb7e54b2ba +0, 135000, 38016, 99fcfe7ed9028bc443a790f9cf8eb812 +0, 138750, 38016, b9b994ffbe0150945b752a2120b4a475 +0, 142500, 38016, f00d70d8a28cecaaec1eb84592e3f6c3 +0, 146250, 38016, 3bc8ed07fc92c4d339164891e6624306 +0, 150000, 38016, d755777560d745d6bdfa01b9e9cbbcc0 +0, 153750, 38016, bcefb5ef8fae173e413406b4a60e2255 +0, 157500, 38016, fb47098c334b82764e30819066b13096 +0, 161250, 38016, 9e31f68fc96045bba43cf1253eedc419 +0, 165000, 38016, 53522d46d2ba91ab23693db7d41ecda7 +0, 168750, 38016, d66a074ebe6123590622e5cb308d75e5 +0, 172500, 38016, 6574fce175632a22fcc05b47157318e4 +0, 176250, 38016, 31f7fb05d060c1dea46044787772baaf +0, 180000, 38016, cec733062ae526ae71b39ae0dc402482 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-010 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-010 new file mode 100644 index 000000000..ea5c8f396 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-010 @@ -0,0 +1,57 @@ +0, 0, 115200, 3441ec1a9b9d325c9aeda44e3b68377d +0, 3000, 115200, bff86a84fd673394f45c09d19a1ee0ac +0, 6000, 115200, 8cd920f0de408e8cd883f9241680ff80 +0, 9000, 115200, d1b27cbb40859bbbb6da40dce6ddbf1b +0, 12000, 115200, ca102ed86e45fe452f55a2cf0253de21 +0, 15000, 115200, ac7630be64017becd6e958df360263b5 +0, 18000, 115200, a044041ede746687d33ba6342d8d3edb +0, 21000, 115200, 75d7c0eec357afd0c2d54e769f551b20 +0, 24000, 115200, eebd916e4fba53a66fc8e6ab98091a0f +0, 27000, 115200, c0044160a944dcac81efe9f63def4bc2 +0, 30000, 115200, 9ba8b2ccbea045b39bd150ea383abc00 +0, 33000, 115200, 8d7654804fc62f7d52d5bf3d47f536e9 +0, 36000, 115200, 9fd6cd81fbe6cfc43e03cdf166c7ea93 +0, 39000, 115200, a1a494064dba27238005227c0808c5f6 +0, 42000, 115200, b8dca72164ea72b3f257c97c3ad87416 +0, 45000, 115200, 90ae005c0f3ddb4318318805b8fc29cf +0, 48000, 115200, 8183e7b60f18887a9530a7905db4b417 +0, 51000, 115200, 1650ad1fff9076141f59b660c562f0f2 +0, 54000, 115200, e9ee675cafd270c366ac9d3ced5af879 +0, 57000, 115200, 2257172d6e8628b4dd4d9bf97e9ee2c3 +0, 60000, 115200, 577438f88feca7a876381a6fcf094684 +0, 63000, 115200, 4b37e90eb35cba66d31616169020c039 +0, 66000, 115200, 2c631ab87b8d3b7df13f888e3d6f1690 +0, 69000, 115200, e0d46e04d6a57b20c2b056cd0a0ca1ec +0, 72000, 115200, 65bd3e207b8ed966b71f40a04f1900b8 +0, 75000, 115200, fd842606a20fb297463b7b3dd6efa2c2 +0, 78000, 115200, 778cd96eabe785320254db7692583f47 +0, 81000, 115200, 094272ad385a64fbc70a62f958e27eff +0, 84000, 115200, cf5f7b3b94a00938b633ea1d9aa8e8dc +0, 87000, 115200, 032e2f3649484ca17c739cf89052de77 +0, 90000, 115200, 9afe92189c21675745609e3b21a75941 +0, 93000, 115200, a5e087c496798bfbc64d6c26eee0b3af +0, 96000, 115200, efb2716347ba2e01f7dc103d2a6cebb4 +0, 99000, 115200, c83541678dcca8937e372102bc4d1f68 +0, 102000, 115200, 3401ed97a9296610c8473dcf03e13f20 +0, 105000, 115200, 35af1327fafe026b6539951a9baee282 +0, 108000, 115200, f320e2d64192849c08c4c5e6d79e4ecf +0, 111000, 115200, 5a661af83f451d8651cf081399d451b2 +0, 114000, 115200, 625d271b60d91229699f1de35d232b13 +0, 117000, 115200, 8e504154fa8eba5f9807bf40c647eea8 +0, 120000, 115200, 094ecb39a65c71e85d15a587472bb336 +0, 123000, 115200, 4d08bfe5771f00e13646be49e3471c4c +0, 126000, 115200, 20841206e07721fb631088d492622543 +0, 129000, 115200, edf969142e1b053f951c1a5756f2b5d9 +0, 132000, 115200, 4959a13f20311d9b435e501fd753c94b +0, 135000, 115200, a7f34e6c985d630af07a9f6dc47ea50e +0, 138000, 115200, 96f6667d849f3abe4e85e3ce368b76ee +0, 141000, 115200, a47d443c8aa5f2d2e3b44deab3f4f8e7 +0, 144000, 115200, 4ebda78d96facc4472ecdb4f667be0c6 +0, 147000, 115200, 6ba744c47edab85c6e77584e35e1b735 +0, 150000, 115200, 4d2e6882f15356171e4383111ec70e6e +0, 153000, 115200, 85077fc81dff947b1251bfbd981aaf52 +0, 156000, 115200, f03e8879a5218387c502eaab31682df9 +0, 159000, 115200, 90f6128298cb52f769d697f9f842df27 +0, 162000, 115200, 700a705680c1a940141bc03ae5de391b +0, 165000, 115200, 049b3df3ed9673ab8e0f0d0d896f65c2 +0, 168000, 115200, ca8c3e5509211dc92078371f06dc8635 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-011 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-011 new file mode 100644 index 000000000..99409cd43 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-011 @@ -0,0 +1,29 @@ +0, 0, 38016, 83c78b5db579710f61f9354d5c51e8c8 +0, 3000, 38016, 9b755a63c7c5352660a265f6e24991e1 +0, 6000, 38016, a591f0b04447d6d6dd9bb990502594aa +0, 9000, 38016, 6ebbd38d20a4104a842c66df53a8b86e +0, 12000, 38016, a114c37e74a4252ed66c5c4e7c8df84b +0, 15000, 38016, 4bad182348dcfb627b3e15bc228a3c8f +0, 18000, 38016, a843b5c80266f890044a4ba1f59de8ed +0, 21000, 38016, 34816d9129f252afcbd56d6ad1df94c7 +0, 24000, 38016, 7d7d46cd08e18aea6fc52c0ec58a4803 +0, 27000, 38016, c96c3357d89534fce32251a0d52c68c5 +0, 30000, 38016, 5eb1329f955ab80696d8220605a51552 +0, 33000, 38016, 68b3d5162cd5b004a6dfeac705c75afa +0, 36000, 38016, b79647c678fbbb9ffbd8c4ff63c05e43 +0, 39000, 38016, 4566eb5f995852d72b6913d2ca2e321c +0, 42000, 38016, 02e7e951ac9e42eafb1260defaecf685 +0, 45000, 38016, ddbfa0f81a009c41271c9aa587e88baa +0, 48000, 38016, 27d31dba74cb2170c456830a9f888c0b +0, 51000, 38016, 0537650a41bb087a5fd33d6347fe9036 +0, 54000, 38016, df2205297d4f00164a3440c8fa1ac4ee +0, 57000, 38016, 9942b757bd3839c1cd6b1068c68967f2 +0, 60000, 38016, d9284e1e989cd38d0226b1a3c6e89409 +0, 63000, 38016, 12427a3fdc22461fe9d6ff9dd5863bef +0, 66000, 38016, 63f75f2a63630347671c0e6dd2f88bcb +0, 69000, 38016, b161169a678e3959b492d83a03d47dee +0, 72000, 38016, 50a6d4c8722197f0abd1028b968dce58 +0, 75000, 38016, c0f81ef6b25034cff00db1e3c369be97 +0, 78000, 38016, 01b502a4b69d5be7a82f292e735aa087 +0, 81000, 38016, 6bbff03307f93a654e4529e2a5092887 +0, 84000, 38016, 17ef5fd4bd1cc6030e1370a43f1d19bf diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-012 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-012 new file mode 100644 index 000000000..5af0e4c1a --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-012 @@ -0,0 +1,29 @@ +0, 0, 38016, cc3069a59b6f4319761af2b39923a6e5 +0, 3000, 38016, c0bc935941d994c6af6a864f02a90a62 +0, 6000, 38016, 5b6073ce4a03967aa87e56dfa27e32c2 +0, 9000, 38016, 5310a9d6bf938ed89b10727f11e131c4 +0, 12000, 38016, 290fb1310ea10b862b51d37ff9d79f7c +0, 15000, 38016, 0ca1accba77dc867df682b8e3768d6e2 +0, 18000, 38016, 2a90659dd4cd5d2f825641be55609d97 +0, 21000, 38016, e003db31fbfeab54385252e8c64197fc +0, 24000, 38016, 0778609bd9626652e8a8dd07d5ef9f45 +0, 27000, 38016, 36eecf49c4aa2d8c3f232a1dbbb5f4ca +0, 30000, 38016, f69f30dd8ebb7db4c51e0371f6a23736 +0, 33000, 38016, e9d5293db5122b9683a0853c2ef678cb +0, 36000, 38016, 75d6a09bca67a82c8aacabb710558330 +0, 39000, 38016, 973d73aa4bb4e3de2cb1ba97685e08ca +0, 42000, 38016, daf9ce67baaaa02bc56f49b540f22a30 +0, 45000, 38016, d08fd3b942e1219132015819c553f2c2 +0, 48000, 38016, 0aeea73b030e47bbd80bb0fb33fb6ebd +0, 51000, 38016, 6e9f5f98fffe27abfae52304c693ae44 +0, 54000, 38016, 961c71a47741a1ac47fcaebf958647c8 +0, 57000, 38016, e75e53160b9f33eca0dfba999d8002eb +0, 60000, 38016, ebb5d79336f75c44a09971dbba6947f3 +0, 63000, 38016, f02317fae5e143103a114ca692b58c25 +0, 66000, 38016, 8282867aa63fa23c48cc0216e21933cc +0, 69000, 38016, d0d74ebbf56ca62825641028b66cdb20 +0, 72000, 38016, a8df24b0a22fe4fb334ea7063cba8754 +0, 75000, 38016, 8a570e42ad6ab42ead80b5022c2eb2f1 +0, 78000, 38016, dae566f13fa69de11db3ba7673e6211d +0, 81000, 38016, 914ed8403cdbf4c54d0b9cb1eeee6832 +0, 84000, 38016, 18aa8d4bfe06a04ec4e9ccf9c7a92643 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-013 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-013 new file mode 100644 index 000000000..fbb111778 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-013 @@ -0,0 +1,29 @@ +0, 0, 38016, ad137b9eae93daed28fe31fd5165b4d0 +0, 3000, 38016, 7cd527f647680c0eb305050d27fb8092 +0, 6000, 38016, f306e07a2e86c82a8cc1333be3812326 +0, 9000, 38016, 4ffd6065ef6af716fdb7388479cf300e +0, 12000, 38016, e776c698ae335107d5794c02cf00d3ee +0, 15000, 38016, c0043e3283b96a4aa58d2265b007e67e +0, 18000, 38016, 235dd358e6adb3e144d7d957458e74a0 +0, 21000, 38016, 4d34b966a406e7c2d5cef029ddc76021 +0, 24000, 38016, 65f9eb823a63e17710b111892c415b70 +0, 27000, 38016, 84d4a1d510d1c1aa8f3e7232d574ba9d +0, 30000, 38016, f3218df364f0e283df56b5d4a9cdfca9 +0, 33000, 38016, 3079d93a140b51fe3e7b4889fd5fdd24 +0, 36000, 38016, 4b76d7f904960792b78378c95453b77a +0, 39000, 38016, 26cdd39f9cd862b383352bf769d212a0 +0, 42000, 38016, d98dbe7d7b8a5ccc50cb3a2e3dcacec8 +0, 45000, 38016, a931f142064062d7d2d1245278c6edd9 +0, 48000, 38016, 0c6dae06c59c040801be386d7e883f52 +0, 51000, 38016, cec4a68182fb14185360f57de81e73cb +0, 54000, 38016, 7e819d1d928f974f25d45023a89a6765 +0, 57000, 38016, 6d9a9fd28212940497f881ef4886d756 +0, 60000, 38016, f22969fc06edc0c9190cae8bb22243ae +0, 63000, 38016, 2fcd676dbf66f842e91649a3d6c80f50 +0, 66000, 38016, ce16e8920e91ec208dfb241addfc612b +0, 69000, 38016, 3a205f364751ff5e72d7da20e5713f53 +0, 72000, 38016, 2305bcde500197d7697eec4ba89f1533 +0, 75000, 38016, 23712ae207ea2381f886ed038ec3852b +0, 78000, 38016, 7197e717541573be07f9cda50ba524a9 +0, 81000, 38016, 3f3e3ec6d1d6f49021affbadb75c1fda +0, 84000, 38016, 424fe8391a419b005a6f142ec65d802b diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-014 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-014 new file mode 100644 index 000000000..5ce3cef0b --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-014 @@ -0,0 +1,49 @@ +0, 0, 37697, 7a0356dc950e79744d79c98e391ebee9 +0, 3000, 37697, 96e221e75c290dd847b8e55865073366 +0, 6000, 37697, 67638290841837c90f180a01094f9191 +0, 9000, 37697, 93c8e234e123f7a641c5eb44903b75ab +0, 12000, 37697, b4fa5ce6089221863002019d99ae7f9d +0, 15000, 37697, 5d3b48fbb681ef2b6a0a5e60c03ee5bd +0, 18000, 37697, 26635956a9ed343428b36947723b4b94 +0, 21000, 37697, 18e9b11e10350ab20b89482c5d1c5cea +0, 24000, 37697, 44fe40a7ce85552ccf95a451c5732e57 +0, 27000, 37697, f38758bf6d522023961d08719e92d3ce +0, 30000, 37697, 28a2a9ebb3633a0822c9a283ab1ddea6 +0, 33000, 37697, 4b4485c9419710ad6d3e6aa11fe3a91b +0, 36000, 37697, e3f6850a934c6e3e2fed3026e1e53066 +0, 39000, 37697, 4acff1abe788a4944474b82d10af172d +0, 42000, 37697, 4cbfcc008923e8303df170d4e7b1cf34 +0, 45000, 37697, dde5de0c676f60b4cea26bbf024bbfb7 +0, 48000, 37697, fe1b0890eef18cd4989d251dbc3b7ef2 +0, 51000, 37697, 462303741de9904a13bd46534010f588 +0, 54000, 37697, 7ab2068505dbccdf522a08a65373b6b6 +0, 57000, 37697, cb63092b6880bbdbaa40b40d738aa4dd +0, 60000, 37697, dca7556869370de600afbda82bb45fae +0, 63000, 37697, 5f5cae9db9e3aa3f300706ebc3874987 +0, 66000, 37697, eaf7ba4f48eb5722c09420f2be4bc5f3 +0, 69000, 37697, dd5b43b72c8b9c3ad53afef0f8869a68 +0, 72000, 37697, f5d81cadb4b1f69e9700293e38ea36a2 +0, 75000, 37697, 1e56a6becf3099db71fbc7a996c4fbba +0, 78000, 37697, 7e0676c4af74b59d9560d8b42d400de2 +0, 81000, 37697, 6717c3c344b45e9e202e808d19c9baa8 +0, 84000, 37697, 42b92f6fbd4cc5d4cf4f9b364a8a7741 +0, 87000, 37697, 6caca9fcc03e8b9d326aec18eaaae928 +0, 90000, 37697, cfa2798d156cabe81160c00939102d90 +0, 93000, 37697, 5d018cfac7da660819da2e5d25e8126e +0, 96000, 37697, 761b7b2b64b22abadb89c58ab294520b +0, 99000, 37697, 4e066fa627d4dbf3635148eb6b2a0477 +0, 102000, 37697, e0d6dd242cb99c7bc9826a05895344c5 +0, 105000, 37697, 84e7beedcba6da53feb722f30211d2f8 +0, 108000, 37697, af49b3fcc56b02ca746792b1d3bbe1c8 +0, 111000, 37697, cdd9f17b4501bc7f7bedb70f2e33f282 +0, 114000, 37697, 69d853dfd9b09d299faec521acb4e765 +0, 117000, 37697, c3497292359c1a1de81cd5fb062e5175 +0, 120000, 37697, 0e3994e4a62d8c922dbde51186615ea7 +0, 123000, 37697, 86bc5561c72bd17e7473f54f6b6311f1 +0, 126000, 37697, 0c747481e3dc575c6aad4507f8e62d8e +0, 129000, 37697, 6779dfe5b6a7d4ba5ae5355058f54bc9 +0, 132000, 37697, d7d4e85f48d38c1106a031bd9b57d909 +0, 135000, 37697, a0ab20a38891925fd77ac2b075f0046f +0, 138000, 37697, 88655045ce8c5cb4c4aa3a5071f1beba +0, 141000, 37697, 7e849d493185a8f782b53a71151bae26 +0, 144000, 37697, a5b9a0cbfac73d2227118c0718cf9d14 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-015 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-015 new file mode 100644 index 000000000..7e97342f7 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-015 @@ -0,0 +1,260 @@ +0, 0, 115200, 6b4c7cc0c6a7218362e43cffef6618c9 +0, 3000, 115200, e132a7b1bb4fb15b1019092aedc0e599 +0, 6000, 115200, b36975db60f24088d95385ff7e8b7b8a +0, 9000, 115200, 4ae6a13ae0435afb2eac66f15a07b143 +0, 12000, 115200, d1de33515e29053171c9fbe969a33fa1 +0, 15000, 115200, cf01450481865c10765995a3b92b440f +0, 18000, 115200, 274461d33aeab30885b23bf2818ad150 +0, 21000, 115200, cb434c5a829b3d6d15a6e76f05abd51f +0, 24000, 115200, 512019fa16b1cd6bf308c91d6577cf2a +0, 27000, 115200, 2d1174741c144b2162806373d0092739 +0, 30000, 115200, 8ec38a17566342a35598bd5ab6d290d5 +0, 33000, 115200, 262b71c9874cc7a5138b12b294575572 +0, 36000, 115200, bfe5e37095dc450dc717fda5ef77b6fe +0, 39000, 115200, 7fbcdb00872206a597bb69ebe9221b03 +0, 42000, 115200, b599ac8568b6780dec25de4211e071ef +0, 45000, 115200, 797085b07f4c1e4f4b0116d329403cf8 +0, 48000, 115200, a0d0821365658bee14767698877cc066 +0, 51000, 115200, 286a917e787d474eb78b4797a0909a5e +0, 54000, 115200, 3548a320f6954c40a00ddf2e4ee212bd +0, 57000, 115200, 80af737ca733afa28fdae06421b3cf8d +0, 60000, 115200, f31a2b62cb69bc680b314a033f91881b +0, 63000, 115200, 02e4a780b3a0d83a8897988ef17b548c +0, 66000, 115200, 844929e7492b389fc520c5f75d37aa77 +0, 69000, 115200, 558ac4c1c11da425baf832a73e1ac2da +0, 72000, 115200, 41b21109a7aa5f163ac0967ecd11f792 +0, 75000, 115200, a2a050c04eaa97db43a5a0a96d20a143 +0, 78000, 115200, 18d1881d44ab9dc959c34d92c0cabd36 +0, 81000, 115200, 53618af318cd187b4fcd5a3c22d3ab79 +0, 84000, 115200, 8028e6a6a6dadc8331e39cff1ba2b899 +0, 87000, 115200, 2c32a58d68595ff4100cec4fc1637c55 +0, 90000, 115200, 8ecc02d32f36edd167cabe2a7bc66683 +0, 93000, 115200, 7caa9ce69ac9f71170a69fbcef4c4b34 +0, 96000, 115200, df06a6a8a81979c39f2c3546eb03a3c2 +0, 99000, 115200, 2bfd578fa08335e975d498e11eadc8bc +0, 102000, 115200, 0d78c5656d56e423ff31cab09855a335 +0, 105000, 115200, 7152d9e35748a7ec2e8da37f0b943325 +0, 108000, 115200, eb9e0e5cba76f0819da6256136ffd4e3 +0, 111000, 115200, c4e5ef875132c06a80f0afb3ee894684 +0, 114000, 115200, d2feb49297dd2f0a532479341d607e64 +0, 117000, 115200, d092d165608f405161fbf73a19df26ca +0, 120000, 115200, cb228940384c3021af42b0ab81c65d7a +0, 123000, 115200, 426decfbf29a025a7a5e376951c34b83 +0, 126000, 115200, 42c25e24bfd048bde0f9105d934cb81e +0, 129000, 115200, 4bf37f8ccb2c4f42fa64a52a4699883f +0, 132000, 115200, 5a00d85407910d4170d11511f03cc3a7 +0, 135000, 115200, 032072b8713a2cd7434b5be706a8667d +0, 138000, 115200, e729c561b318aa14d7dbf96299c4675d +0, 141000, 115200, e7e1d71c1c59bb759c89f15c6e8970f0 +0, 144000, 115200, 9c04011f4d92257a6dc112c5acad0f59 +0, 147000, 115200, ca7c7cbf52dd7af9a62212f3a9bd1f74 +0, 150000, 115200, 3cc9c4d3857d692e0dbfee682d63d32c +0, 153000, 115200, 1188fc9620cf0d23af21d8823c127b80 +0, 156000, 115200, c614690b8d4d3bea47f1b236ff32d1d8 +0, 159000, 115200, d6ccde3360e6a05b61013e85f96de9e9 +0, 162000, 115200, 7f11cacc42d14121aeab487975ec190b +0, 165000, 115200, cdd8b538ff107f88c5f0dc7128bc331e +0, 168000, 115200, f43a387e9bb2f4db387d3f44da16457b +0, 171000, 115200, b7ba01b86fce2252105f99848e2ac95c +0, 174000, 115200, 094200f775b6ced838d0c37e0d0b34e6 +0, 177000, 115200, b2d2fa96666b96b7cb624133cf404b09 +0, 180000, 115200, d935644161a2b06f0efc75dc6d0fcf46 +0, 183000, 115200, 2a3be6460f313d7fdd6f6f9c70092a50 +0, 186000, 115200, f8254b6469b807ce0e9a1ea4b98a59db +0, 189000, 115200, 43639a3293ec640b203e0c8a97e6f45e +0, 192000, 115200, 055762cccc279c8dd27450ec1d512d5f +0, 195000, 115200, a90dac910f3cdd216293bebc46b36501 +0, 198000, 115200, 3531ef2a4a59271f89ca0972b65d06aa +0, 201000, 115200, 1f87adde14795639105be714247d0bd0 +0, 204000, 115200, e991cdd7912266937ca6f0d59199645b +0, 207000, 115200, 5b98019db0fca644da5ee73e0160c7c5 +0, 210000, 115200, 6276f3907e4bb87885d21e11150d044d +0, 213000, 115200, 985785d7a788dcc07bd5fb72d3dc758e +0, 216000, 115200, 3379548a573d068d47d5f54aaf79c8a9 +0, 219000, 115200, a2b36848e7d19383cfabf8bdcabd241a +0, 222000, 115200, 0aeda76888a5a2426ae3b390e38aba52 +0, 225000, 115200, 2c652e7850ccc10cbc7a3266f1fb6c00 +0, 228000, 115200, 5dfc9e4dce69f1f644fad5b69c0b4008 +0, 231000, 115200, da775fc1469012a0c717ebe5dc940e26 +0, 234000, 115200, 6185a863f7d023ddb2b049e265aab1bb +0, 237000, 115200, 7a56397397191ab1b7c93a4bdc9b57c1 +0, 240000, 115200, 3e95a3f2c2660dc28ec64efef29615f0 +0, 243000, 115200, b9ba03bd7c09224174368a60af389b9c +0, 246000, 115200, bfd23a13e077843506a01e44adb27c04 +0, 249000, 115200, 9025dff58a57abcc25da69fd233e312a +0, 252000, 115200, ba4b91b0fe4d36f77b62ec3fe7b10a96 +0, 255000, 115200, 7955419ff2bc42b703dfc976576a5bd4 +0, 258000, 115200, 36d6a723ebb35c45128bfa8a7bba0d49 +0, 261000, 115200, 77503cc79e3cb0fc74745bac967fee1d +0, 264000, 115200, a05af40cb4fc009fe94be6dbf148b453 +0, 267000, 115200, 35bc39585679f7c07f1b196879719ce6 +0, 270000, 115200, 48831c2e2212134ab192a123e847c157 +0, 273000, 115200, c09c37f9fd929185452a8beb3c61b839 +0, 276000, 115200, c534a38d586f3cac998240a7013c636c +0, 279000, 115200, b598c6999442cf0c53ed6a19d1215eb8 +0, 282000, 115200, c639685c8f4af3d006df1833950943aa +0, 285000, 115200, 351e1c089ba5b9024de6e311c4a4afd3 +0, 288000, 115200, 67d8ea902179548d0b01544249b2411f +0, 291000, 115200, 3717ddf0edbb2020a5b974678d358d25 +0, 294000, 115200, 85f7c6861241e3f43fc63c397c8c3c37 +0, 297000, 115200, c5b23b4d3d141d8cfbc5354ca1cfd34d +0, 300000, 115200, c2e42fa6b11cdc3abcf3ee0c3f75a459 +0, 303000, 115200, 34df411aa928d5df3628644d9a38c768 +0, 306000, 115200, a768b448b6c894d9b927bc880249079a +0, 309000, 115200, a2e9ad0d0ad733b8ccacf0379b05f6f9 +0, 312000, 115200, 4b485e9496ab4d417b8cffaf8754f5cb +0, 315000, 115200, 47007fabfacd9e9c5a3997fb70d45895 +0, 318000, 115200, 4962433241c7509801b46bea70f38269 +0, 321000, 115200, 7b4593b45606650e78aec67722cfc2bf +0, 324000, 115200, 882bcbf7d2c12e93df2fbebc6ac19dd8 +0, 327000, 115200, a2998a9c648817236bfffdae454f9fa1 +0, 330000, 115200, 56775760fa99e9a9b7293ddc78a44ece +0, 333000, 115200, bb245d095424c28dd2ace22a5a511d6a +0, 336000, 115200, 598c54d2b207190ed549dec7390a4190 +0, 339000, 115200, c73f16b2709527fce3d725ade5aab2fc +0, 342000, 115200, 32dcad6eb17bee583884029fe18c07a7 +0, 345000, 115200, a1297c404a0d22e0e8e1e4ef67696606 +0, 348000, 115200, 2fef1ac7becf9b8c9f3ac2310f444e3b +0, 351000, 115200, 0f03614ed3daec6c37c5b564ad24f595 +0, 354000, 115200, 9b175a6353ec377da408b0cf03388081 +0, 357000, 115200, 37b991b4a216a4847d0768a3b878284a +0, 360000, 115200, faafcd544080a6a4f87a0d0a393ba37b +0, 363000, 115200, 43ede087f37c1b0392829bbc668242fc +0, 366000, 115200, b7ed1274016c4d1810d8999d495b7370 +0, 369000, 115200, 22af7bfc83c6e1f2eff2ae26e115b446 +0, 372000, 115200, 969b22455f3be057036ddd5a329b1de3 +0, 375000, 115200, 63c24b8a3d6c3a4c2fd47c48860abff9 +0, 378000, 115200, b407ddc89c538d7b6fb70e48493f872c +0, 381000, 115200, 5de69fb9e1cd425cd3931116803f5391 +0, 384000, 115200, 07fc7a5cb360edae97db999c2a8d2716 +0, 387000, 115200, 602a17c58cac811e6e71e33448931ce5 +0, 390000, 115200, 44087725484198c8e846d112583e574b +0, 393000, 115200, 0d81da0d23d196ff972894878bd17b73 +0, 396000, 115200, b3cd65f1bd2274895e54da99bb4c4f07 +0, 399000, 115200, ae8ca35672d8352af49f37f5174c8fbd +0, 402000, 115200, 9eea1ff900cf680e8208cd5d07a4d284 +0, 405000, 115200, 5a47f272dfda3fe61955875f761a71f2 +0, 408000, 115200, 544558333008db01451c886ac0b62c47 +0, 411000, 115200, 5f8e4f3b11d7f5a28ff5cd9f3a6853bb +0, 414000, 115200, e9bc3da7060457f2d52a5bf6fe3bb515 +0, 417000, 115200, 6aea6851a092260ae6594c6d9170ea8e +0, 420000, 115200, 38e7fa5bea809a984a5f810940ca0e49 +0, 423000, 115200, 9e8a23ac9067a1acf8472d7aa3b9811e +0, 426000, 115200, 6f25f5873afd5c341ca6b3eb284be809 +0, 429000, 115200, 40c3240e6cde94aae793a52cb46487da +0, 432000, 115200, b7f1f13842fbf0c6e085280eb89b956f +0, 435000, 115200, 1f059372d8bf4dadf78d8e215bbf9786 +0, 438000, 115200, 50c1d6b76930e765bff5ecbaaae686fe +0, 441000, 115200, 5bd8cb05ebc034192e08ca8ce18a7964 +0, 444000, 115200, ffc0c20b07e26857dc4f2c079a2ad675 +0, 447000, 115200, 5dafb6ac0953c254182dba124e213c07 +0, 450000, 115200, c774ed25712a38603fe2e224802768cb +0, 453000, 115200, de549cc803a6138d483be15b28ef2286 +0, 456000, 115200, c963d9bc79c1dd2a47f7f8424c56239e +0, 459000, 115200, 9df993e0bef1bedbce1a6b596f2c64f4 +0, 462000, 115200, 875792bde0f45358009b506840be68e1 +0, 465000, 115200, 7f8c57083d2df08db6287cb025260788 +0, 468000, 115200, 47eb13bc0942b5cafeea324fc5bf5cd5 +0, 471000, 115200, d89129c7528ff7372f23d1191c75e336 +0, 474000, 115200, bdd14e38b00075d8da485d1517dbbd65 +0, 477000, 115200, 0e8e21a50a5dd1ac6fc881ad38ec38bd +0, 480000, 115200, a0fce98c23a053b4073715c554b9dc44 +0, 483000, 115200, 18bda80360c72d04c60016682b1f6c8d +0, 486000, 115200, 306d7556c18dcf58c8183959d1c34c2a +0, 489000, 115200, 7ada9d23b96ef41322497d1077b00c4d +0, 492000, 115200, d7df0508be4bd0c3e83f346f0b9a1868 +0, 495000, 115200, 749725f425f6fd4a79269bca900d09ae +0, 498000, 115200, ed30973158a576e2919e2fcfd00987fc +0, 501000, 115200, 2486d8b742ccc50cf8683af7f4502aec +0, 504000, 115200, bdfb21e4236c904aeacd7b094fcffe98 +0, 507000, 115200, df2ef3e452731053ade82506c013164e +0, 510000, 115200, 4695bfd9aa8e5667572f8f2142c6e538 +0, 513000, 115200, 649f5315cff1d28f0183144bf4d4eea4 +0, 516000, 115200, 450e987b9d6075d32e21d030bc385833 +0, 519000, 115200, 7aec79b25dabfcc2eb2f32e7dbff85f2 +0, 522000, 115200, c9c2a96239ad556a2ee496d7c4c965c1 +0, 525000, 115200, 3a038e48aa1238b62d431823653bc45a +0, 528000, 115200, 6d5c8de6a281dbce68998b2c38063f33 +0, 531000, 115200, 045032f57d6a50ae148f4372f5083a62 +0, 534000, 115200, 5f39172951e083e712c3b1c528e61a4f +0, 537000, 115200, 5a49eea76b6a86e305fb207fc1479264 +0, 540000, 115200, 33ca5fb5f3e4ff3a24235da71c5730d5 +0, 543000, 115200, 81f231d20426c5cbd02a85a425f5d0b8 +0, 546000, 115200, 302d94aa9a8d3828cf74c8b2b7e7fdd5 +0, 549000, 115200, c56f4f0c32b0f2c409b64ed10216a40a +0, 552000, 115200, 9cf7f51e1527f11c38c395bac94849d9 +0, 555000, 115200, 0f17e427d14db658131eb0ccdc2a97ef +0, 558000, 115200, 2624dd6b8e4e95770f132d90aa6f6119 +0, 561000, 115200, 9ddabfd5f803014443c2a0686869c546 +0, 564000, 115200, 0170cb86a377d791d7cbee2af0836db7 +0, 567000, 115200, f43a7c63bcafb51ead65e2831610612c +0, 570000, 115200, e7000913b11bdeb74ba4eca110df8470 +0, 573000, 115200, a4208c5fcd101ceb5a976838ae9a811f +0, 576000, 115200, 8ddcb546ac632c967e879fb5101afa24 +0, 579000, 115200, 547007771194373dd246586744130f7c +0, 582000, 115200, 3608a46fee2731341ae9f71d3a80918a +0, 585000, 115200, 758692e173552eb3439a572c953dda0f +0, 588000, 115200, 481f456d6c6ac2e0325acba5eeabcd26 +0, 591000, 115200, c749a3ef8641d5ec4f25c611ffad1000 +0, 594000, 115200, 93f089f7f1e78b1a4185c0b0d99875fb +0, 597000, 115200, 1159712bb4dbaed38d2a7558335f4037 +0, 600000, 115200, e8dab85a977f525d4d9b448e4278a34b +0, 603000, 115200, 780055af1414e7693777a18428b20a07 +0, 606000, 115200, 59252515451fd96ca3f1194d5aadc3a7 +0, 609000, 115200, 0a977d6db761c149316417988657610a +0, 612000, 115200, ed81d3a10369c12543f9bb6822a249b6 +0, 615000, 115200, 341e844231f6b55ee3c1eb22ca1bac8e +0, 618000, 115200, d0a180c7d15e30a71e297fda0452c153 +0, 621000, 115200, 58d6f2522ecd8e5fea34cc9f10da2a88 +0, 624000, 115200, dc8f96811577f4fd3e6624abae42f449 +0, 627000, 115200, 3624a2e95f94a0a4413e464f4bf93dcd +0, 630000, 115200, cb0deeb5f2d570ca23e3be3ab9231fe9 +0, 633000, 115200, 5080848626a52e30eb0f64f234ca3e57 +0, 636000, 115200, a31c9fe4255318d86e7855f01588220f +0, 639000, 115200, 6c25fd8d1f0e898f6078decc4220d47d +0, 642000, 115200, 77e52da08ab57ba5784ce42872cc01cb +0, 645000, 115200, b4a87059745b3b862ef7431a9630f16a +0, 648000, 115200, 1dadc814514ef00f11010df21d8a9494 +0, 651000, 115200, 5c816a0bbc8ed8fca166aa454093cb59 +0, 654000, 115200, 10320c174423d1712d9ce812701bcaf9 +0, 657000, 115200, 279c9398657af129e072165f41e0fb8c +0, 660000, 115200, 49d88374bc4d965d3cee3274c7cd9906 +0, 663000, 115200, 48871e22f635f50569dea1bd5ca40d5c +0, 666000, 115200, 3b8396580f8fbd99daca4df13662f1fc +0, 669000, 115200, 569245e1bf3cb42aa95f765a8449980f +0, 672000, 115200, c5cab497d244447df0ab832dcc9c5968 +0, 675000, 115200, 0a98ca4f1d771c4bc0286b825d085955 +0, 678000, 115200, e4a55f175c3933f02ccf74ccf2961da2 +0, 681000, 115200, 462dca7f377d708e753ef0bbde19a090 +0, 684000, 115200, 6f1680f498b0ed6f89a834b5700cc48a +0, 687000, 115200, 996414e2e3a4bac5868ceeb25b84e6e4 +0, 690000, 115200, 6ecb4d4b857578d32f716c56dc7e6be9 +0, 693000, 115200, e05c8e33157e20c8e8f255e937d6b6cb +0, 696000, 115200, 6542744da147d16533e41dad287a54fc +0, 699000, 115200, bb4b6921d2855025fbcaff4c12299d02 +0, 702000, 115200, 6bc3e605759725012f7e44f1285b0899 +0, 705000, 115200, 0be37ecb7cec0cf8a0f9bbc3c590ba98 +0, 708000, 115200, 4f1103e5923ba8dea3e99c8b75eaed3c +0, 711000, 115200, 220a8fb0409112c4f4ee769880717fea +0, 714000, 115200, e4c612263cfbc0f41283fd1e88e2ff52 +0, 717000, 115200, ede2bc67ad87cd78191b742dd56419b5 +0, 720000, 115200, ded6a1d0690603aea233e4d624aa60a9 +0, 723000, 115200, 59c8b53e47ebdab696547a887163b272 +0, 726000, 115200, 985f8afbc6df2d64d601d2fdc93571d7 +0, 729000, 115200, e595f0aa7b6b62094f0ad84252105f55 +0, 732000, 115200, c2fe4382a1740bcfc2f4c3573c6c3176 +0, 735000, 115200, 880d8c906a8b39a61b68eb0ada857e5f +0, 738000, 115200, 9a3ca55d2d75e3c41a86aea2ec87ff76 +0, 741000, 115200, f800751663dbefa61c33c3ebbd5430b4 +0, 744000, 115200, d904333c0c76235c8ffdfc81dffddb46 +0, 747000, 115200, 6a633a9a7686a9a02bd252ec8bcff4fc +0, 750000, 115200, 930d06ecc252a911a60c2d9d4f2618e6 +0, 753000, 115200, bb146a4410c34bba74883d8ae478f47b +0, 756000, 115200, be8ab9fc95685ebec64ff1f8129afa35 +0, 759000, 115200, d1f871ea3ceb38bf2b6d00ebfc38187a +0, 762000, 115200, ba33366e050a5f5abbf8202e0afbb9e8 +0, 765000, 115200, f706356e12cf4082337bb8f7a5a10673 +0, 768000, 115200, 6e8200d3c1cccc0f810985ea2a2030f6 +0, 771000, 115200, caafdc1810556197df6f42336edcc07b +0, 774000, 115200, 5321ff525f5bb5063443a3dc43fc42af +0, 777000, 115200, c24bdd3b935f7ca6e9e105b1ae8504db diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-016 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-016 new file mode 100644 index 000000000..1a8214559 --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-016 @@ -0,0 +1,29 @@ +0, 0, 38016, 905a823da31f71f9c25ebb8dfc9ddd3c +0, 3000, 38016, 9a1b97859b2f774954dbf96f45a22a0a +0, 6000, 38016, f0f5651b32577549dc2e6e3050125229 +0, 9000, 38016, 9edf800d31dc653a23ed71d0f3fc32e4 +0, 12000, 38016, 78dd1fa96e63c177f2b90d702c92f48c +0, 15000, 38016, e1cec336383c4ea63ccaff8bfa5c8e24 +0, 18000, 38016, e8b5a454e178ab7ba9b83dfc10b4171e +0, 21000, 38016, 572dbaaf319f1681749135c49940c64e +0, 24000, 38016, b0e8313de033cc75a78532789bb6a3cb +0, 27000, 38016, ffc5581d83ff67b549d63c7de1a1e8cb +0, 30000, 38016, 8ae3fcd3d74947d434b7c5f9ee08bbbf +0, 33000, 38016, 3adff74d92ae0a463dddc6f89965f706 +0, 36000, 38016, f08355430fdf5bb16a91eef05f03186b +0, 39000, 38016, d477eb8150a1a94dd6af7f067e8c0429 +0, 42000, 38016, f860f225e27871a17060373b79007ec6 +0, 45000, 38016, 22a25c07ac5e7c67df793e0d3169386c +0, 48000, 38016, a96f9cef4efe74db0cce039c85c03c4d +0, 51000, 38016, ff9c93cbc364976044144ee631f89bd2 +0, 54000, 38016, 3a6b43090adb6c8b5188d544a08295a8 +0, 57000, 38016, 7f41a10ada80865d24585860065aa5e4 +0, 60000, 38016, 099847f606672fd065e6841000cafcb3 +0, 63000, 38016, fbf543c12ce48633e6d10717862c35a7 +0, 66000, 38016, 1b9956d8a6c45e39d219da33ff7c334a +0, 69000, 38016, 911eb8f478485c0f4eef1d03f53aa80b +0, 72000, 38016, b801570a437439ce12c5037df0235742 +0, 75000, 38016, 8d231805d741abe79670a0e9f13712ea +0, 78000, 38016, 87bfcc2c88c4471067c07fbcf635870d +0, 81000, 38016, d51b6999afde880bc77597063b58d28f +0, 84000, 38016, c69c07a34bfad3b5a95b19a84e991c13 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-017 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-017 new file mode 100644 index 000000000..c461420bd --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/vp8-test-vector-017 @@ -0,0 +1,29 @@ +0, 0, 38016, 905a823da31f71f9c25ebb8dfc9ddd3c +0, 3000, 38016, f0f411dd067bff05d5d9c64e3f52a4b1 +0, 6000, 38016, c8696f8fa56b4adf18f3db0c384d968f +0, 9000, 38016, 5772aa26a95092b4a8a117e97d6dde49 +0, 12000, 38016, fc52254ea1cbcc2e7a5b126d8c44a023 +0, 15000, 38016, bf6208554657f568ad69d5c60f692fdb +0, 18000, 38016, 3a68eef642b250177592455f4aa925d9 +0, 21000, 38016, 98102b7bd56cbe456d86c93e8cdd48eb +0, 24000, 38016, 59d54b7d97600b2890c8abab2af9a7dc +0, 27000, 38016, ba4b4bb534ee2a00f418828b9723d996 +0, 30000, 38016, feb1115136fa96d5e9425ac18261de7c +0, 33000, 38016, ef7eb6dc656c2bd7447c7d8f650108c1 +0, 36000, 38016, 89ec385a0d34c8fd5b1334d8756c96b9 +0, 39000, 38016, 27bc439dd8e6d50c3c7a6e0b390e7418 +0, 42000, 38016, ec36c065d8b668fabb6b16ecc01eea0a +0, 45000, 38016, 5c94f9b441fc70f62856c835f9e9ad50 +0, 48000, 38016, 4b6c1bd876b00052b39e6ca91cad9c05 +0, 51000, 38016, 1099121afd681cf3218dffb9714a0fd7 +0, 54000, 38016, d0c1de888fab35f33c1148dc80494d20 +0, 57000, 38016, 745941ea768d06ea27c3fbca782e3591 +0, 60000, 38016, 09f85054f188da6f7260debf6b71bbb1 +0, 63000, 38016, 2bdd642a7551681f1ca9680a0d9183a8 +0, 66000, 38016, 054aba9db9790a0f1c79db491a6cac6d +0, 69000, 38016, fa4b52162f6da0c15100f4382d92d7e4 +0, 72000, 38016, 88c589535811dd394bd1723172329629 +0, 75000, 38016, c11cc1a30199d46db048120969dc4118 +0, 78000, 38016, c61207280f40620f8cd5e962f3aa160f +0, 81000, 38016, 8a721ecbad0b2f17aabb2d06e27c00aa +0, 84000, 38016, da32f1d272e065cd31415b23f86837cc diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/yop b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/yop new file mode 100644 index 000000000..782fd471c --- /dev/null +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/fate/yop @@ -0,0 +1,7 @@ +0, 0, 302760, 0x78939253 +0, 7500, 302760, 0x534f5253 +0, 15000, 302760, 0xe991aa82 +0, 22500, 302760, 0xc34b20bd +0, 30000, 302760, 0x461d29a1 +0, 37500, 302760, 0x45abca02 +0, 45000, 302760, 0xb05448b9 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavf/mxf b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavf/mxf index 84d7a09e8..ac556f5c5 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavf/mxf +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavf/mxf @@ -1,4 +1,4 @@ -8e120da0ccd70c4475fdee13fc5f3d0b *./tests/data/lavf/lavf.mxf +785e38ddd2466046f30aa36399b8f8fa *./tests/data/lavf/lavf.mxf 525881 ./tests/data/lavf/lavf.mxf ./tests/data/lavf/lavf.mxf CRC=0xb6aa0849 b3174e2db508564c1cce0b5e3c1bc1bd *./tests/data/lavf/lavf.mxf_d10 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/crop_scale b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/crop_scale index 48a0734f6..b7ad1a975 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/crop_scale +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/crop_scale @@ -1,2 +1,2 @@ -4ffe30abe99931bc9989f40ae65654b7 *./tests/data/lavfi/crop_scale.nut +0a3d45d58b805b8c47416b9239535f94 *./tests/data/lavfi/crop_scale.nut 8941454 ./tests/data/lavfi/crop_scale.nut diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/crop_scale_vflip b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/crop_scale_vflip index 314f407b8..bd573a34a 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/crop_scale_vflip +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/crop_scale_vflip @@ -1,2 +1,2 @@ -3b1c81bb6ce7575f5ee3088ea165dbe7 *./tests/data/lavfi/crop_scale_vflip.nut +e88a4dfb960d0bb28ee875567bedde5d *./tests/data/lavfi/crop_scale_vflip.nut 750727 ./tests/data/lavfi/crop_scale_vflip.nut diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/scale200 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/scale200 index 115e250d0..6bbe88b31 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/scale200 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/scale200 @@ -1,2 +1,2 @@ -f7325609fdb8992bcea0cf3712ea2afc *./tests/data/lavfi/scale200.nut +aebdc1c3e08da2a925ba7212b1fadee0 *./tests/data/lavfi/scale200.nut 3001204 ./tests/data/lavfi/scale200.nut diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/scale500 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/scale500 index c8ba15b2a..52e84955d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/scale500 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/lavfi/scale500 @@ -1,2 +1,2 @@ -7e194861897fb42e20771711fe1aace3 *./tests/data/lavfi/scale500.nut +ef865c51156e55ce1ce38c8f90a709e6 *./tests/data/lavfi/scale500.nut 18751503 ./tests/data/lavfi/scale500.nut diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/asv1 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/asv1 index 15ba70b2a..10c1b0376 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/asv1 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/asv1 @@ -1,4 +1,4 @@ b4ce4698764ef2328346badb7227ecbe *./tests/data/vsynth1/asv1.avi 1489656 ./tests/data/vsynth1/asv1.avi 2dfc5dfc2c1cbbc2543257cd3d2df6af *./tests/data/asv1.vsynth1.out.yuv -stddev: 20.00 PSNR: 22.11 bytes: 7603200/ 7603200 +stddev: 20.00 PSNR: 22.11 MAXDIFF: 158 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/asv2 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/asv2 index 4ac42e1c5..14b0d1cd7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/asv2 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/asv2 @@ -1,4 +1,4 @@ dfba6eaf58e515e324c2b370bfcd9158 *./tests/data/vsynth1/asv2.avi 1456056 ./tests/data/vsynth1/asv2.avi d451be09793cd0f35b6d91fc36e2571a *./tests/data/asv2.vsynth1.out.yuv -stddev: 18.82 PSNR: 22.63 bytes: 7603200/ 7603200 +stddev: 18.82 PSNR: 22.63 MAXDIFF: 131 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dnxhd_1080i b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dnxhd_1080i index 7429b7d91..2be782f46 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dnxhd_1080i +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dnxhd_1080i @@ -1,4 +1,4 @@ cd1489f18d2186a49ab23c61ed33bce7 *./tests/data/vsynth1/dnxhd-1080i.mov 3031875 ./tests/data/vsynth1/dnxhd-1080i.mov 0c651e840f860592f0d5b66030d9fa32 *./tests/data/dnxhd_1080i.vsynth1.out.yuv -stddev: 6.29 PSNR: 32.15 bytes: 760320/ 7603200 +stddev: 6.29 PSNR: 32.15 MAXDIFF: 64 bytes: 760320/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dnxhd_720p b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dnxhd_720p index 490a9ea64..263843df5 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dnxhd_720p +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dnxhd_720p @@ -1,4 +1,4 @@ 81f5be451dc18cf8a1d333c7885de60b *./tests/data/vsynth1/dnxhd-720p.dnxhd 2293760 ./tests/data/vsynth1/dnxhd-720p.dnxhd 94b21e5e68ccf9471eff74afd0ebe319 *./tests/data/dnxhd_720p.vsynth1.out.yuv -stddev: 6.32 PSNR: 32.11 bytes: 760320/ 7603200 +stddev: 6.32 PSNR: 32.11 MAXDIFF: 183 bytes: 760320/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dnxhd_720p_rd b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dnxhd_720p_rd index f18ae2da1..e77c725a4 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dnxhd_720p_rd +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dnxhd_720p_rd @@ -1,4 +1,4 @@ 1dc6e95925c4f3a230848ec17c02abed *./tests/data/vsynth1/dnxhd-720p-rd.dnxhd 2293760 ./tests/data/vsynth1/dnxhd-720p-rd.dnxhd 02972d2aec120ec1577ec9053d68ae0f *./tests/data/dnxhd_720p_rd.vsynth1.out.yuv -stddev: 6.26 PSNR: 32.19 bytes: 760320/ 7603200 +stddev: 6.26 PSNR: 32.19 MAXDIFF: 65 bytes: 760320/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dv b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dv index 7b6f1f962..cb0427c55 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dv +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dv @@ -1,8 +1,8 @@ 27ade3031b17214cf81c19cbf70f37d7 *./tests/data/vsynth1/dv.dv 7200000 ./tests/data/vsynth1/dv.dv 02ac7cdeab91d4d5621e7ce96dddc498 *./tests/data/dv.vsynth1.out.yuv -stddev: 6.90 PSNR: 31.34 bytes: 7603200/ 7603200 +stddev: 6.90 PSNR: 31.34 MAXDIFF: 76 bytes: 7603200/ 7603200 bd67f2431db160d4bb6dcd791cea6efd *./tests/data/vsynth1/dv411.dv 7200000 ./tests/data/vsynth1/dv411.dv b6640a3a572353f51284acb746eb00c4 *./tests/data/dv.vsynth1.out.yuv -stddev: 30.76 PSNR: 18.37 bytes: 7603200/ 7603200 +stddev: 30.76 PSNR: 18.37 MAXDIFF: 205 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dv50 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dv50 index 1e6454d9b..9ae338527 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dv50 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/dv50 @@ -1,4 +1,4 @@ 26dba84f0ea895b914ef5b333d8394ac *./tests/data/vsynth1/dv50.dv 14400000 ./tests/data/vsynth1/dv50.dv a2ff093e93ffed10f730fa21df02fc50 *./tests/data/dv50.vsynth1.out.yuv -stddev: 1.72 PSNR: 43.38 bytes: 7603200/ 7603200 +stddev: 1.72 PSNR: 43.38 MAXDIFF: 29 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/error b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/error index 6b8a49e50..c3543f9d3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/error +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/error @@ -1,4 +1,4 @@ 7416dfd319f04044d4575dc9d1b406e1 *./tests/data/vsynth1/error-mpeg4-adv.avi 756836 ./tests/data/vsynth1/error-mpeg4-adv.avi ef8bfcd6e0883daba95d0f32486ebe2d *./tests/data/error.vsynth1.out.yuv -stddev: 18.05 PSNR: 23.00 bytes: 7603200/ 7603200 +stddev: 18.05 PSNR: 23.00 MAXDIFF: 245 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/ffv1 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/ffv1 index e888d96e7..bf909153c 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/ffv1 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/ffv1 @@ -1,4 +1,4 @@ 67ddc7edde5cca49290245d881787890 *./tests/data/vsynth1/ffv1.avi 2655376 ./tests/data/vsynth1/ffv1.avi c5ccac874dbf808e9088bc3107860042 *./tests/data/ffv1.vsynth1.out.yuv -stddev: 0.00 PSNR:999.99 bytes: 7603200/ 7603200 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/flashsv b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/flashsv index 6d76e9a65..7920193aa 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/flashsv +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/flashsv @@ -1,4 +1,4 @@ 97894502b4cb57aca1105b6333f72dae *./tests/data/vsynth1/flashsv.flv 14681925 ./tests/data/vsynth1/flashsv.flv 947cb24ec45a453348ae6fe3fa278071 *./tests/data/flashsv.vsynth1.out.yuv -stddev: 2.85 PSNR: 39.03 bytes: 7603200/ 7603200 +stddev: 2.85 PSNR: 39.03 MAXDIFF: 49 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/flv b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/flv index 04e22eb87..17f565608 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/flv +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/flv @@ -1,4 +1,4 @@ d6a80659cedee7698aefe9c4a8285fa4 *./tests/data/vsynth1/flv.flv 636269 ./tests/data/vsynth1/flv.flv 5ab46d8dd01dbb1d63df2a84858a4b05 *./tests/data/flv.vsynth1.out.yuv -stddev: 8.02 PSNR: 30.04 bytes: 7603200/ 7603200 +stddev: 8.02 PSNR: 30.04 MAXDIFF: 105 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/h261 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/h261 index 2be985578..36d04f173 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/h261 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/h261 @@ -1,4 +1,4 @@ d155470b713aeebacb85980b0d5f2ce3 *./tests/data/vsynth1/h261.avi 707588 ./tests/data/vsynth1/h261.avi 716e83cb51afb1246bfaa80967df48ea *./tests/data/h261.vsynth1.out.yuv -stddev: 9.11 PSNR: 28.93 bytes: 7603200/ 7603200 +stddev: 9.11 PSNR: 28.93 MAXDIFF: 113 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/h263 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/h263 index 5703029c2..6351adc7a 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/h263 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/h263 @@ -1,4 +1,4 @@ fb4dc9b9eac2628c56cb82cf332e1f58 *./tests/data/vsynth1/h263.avi 659686 ./tests/data/vsynth1/h263.avi 1a1ba9a3a63ec1a1a9585fded0a7c954 *./tests/data/h263.vsynth1.out.yuv -stddev: 8.03 PSNR: 30.03 bytes: 7603200/ 7603200 +stddev: 8.03 PSNR: 30.03 MAXDIFF: 103 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/h263p b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/h263p index 6ca658f6d..93df5497b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/h263p +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/h263p @@ -1,4 +1,4 @@ bbcadeceba295e1dad148aea1e57c370 *./tests/data/vsynth1/h263p.avi 2328348 ./tests/data/vsynth1/h263p.avi 9554cda00c3487ab3ffda2c3ea22fa2f *./tests/data/h263p.vsynth1.out.yuv -stddev: 2.06 PSNR: 41.83 bytes: 7603200/ 7603200 +stddev: 2.06 PSNR: 41.83 MAXDIFF: 20 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/huffyuv b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/huffyuv index f84eee437..fefc84a3b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/huffyuv +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/huffyuv @@ -1,4 +1,4 @@ ace2536fa169d835d0fb332abde28d51 *./tests/data/vsynth1/huffyuv.avi 7933800 ./tests/data/vsynth1/huffyuv.avi c5ccac874dbf808e9088bc3107860042 *./tests/data/huffyuv.vsynth1.out.yuv -stddev: 0.00 PSNR:999.99 bytes: 7603200/ 7603200 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/jpegls b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/jpegls index 4e26ec621..636f7fc55 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/jpegls +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/jpegls @@ -1,4 +1,4 @@ 519e26bb1ac0f3db8f90b36537f2f760 *./tests/data/vsynth1/jpegls.avi 9089812 ./tests/data/vsynth1/jpegls.avi 947cb24ec45a453348ae6fe3fa278071 *./tests/data/jpegls.vsynth1.out.yuv -stddev: 2.85 PSNR: 39.03 bytes: 7603200/ 7603200 +stddev: 2.85 PSNR: 39.03 MAXDIFF: 49 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/ljpeg b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/ljpeg index 3202bfcf9..01d59e71c 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/ljpeg +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/ljpeg @@ -1,4 +1,4 @@ 9092f306f165b98ab0bb4f576f198ad5 *./tests/data/vsynth1/ljpeg.avi 6312936 ./tests/data/vsynth1/ljpeg.avi c5ccac874dbf808e9088bc3107860042 *./tests/data/ljpeg.vsynth1.out.yuv -stddev: 0.00 PSNR:999.99 bytes: 7603200/ 7603200 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mjpeg b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mjpeg index fe54d6f97..63a0ff032 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mjpeg +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mjpeg @@ -1,4 +1,4 @@ 8bbf9513b1822945539f27a6eff3c7fa *./tests/data/vsynth1/mjpeg.avi 1516140 ./tests/data/vsynth1/mjpeg.avi c6ae81b5b896e4d05ff584311aebdb18 *./tests/data/mjpeg.vsynth1.out.yuv -stddev: 7.87 PSNR: 30.21 bytes: 7603200/ 7603200 +stddev: 7.87 PSNR: 30.21 MAXDIFF: 63 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg index 882486b70..7ae92f10e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg @@ -1,4 +1,4 @@ 1428744c6d5835f27506e69be4f837f4 *./tests/data/vsynth1/mpeg1.mpg 712006 ./tests/data/vsynth1/mpeg1.mpg 58f0c332bf689117b57fa629a2bc0d2b *./tests/data/mpeg.vsynth1.out.yuv -stddev: 7.62 PSNR: 30.48 bytes: 7603200/ 7603200 +stddev: 7.62 PSNR: 30.48 MAXDIFF: 84 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg1b b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg1b index 913515eb3..897a0ce8f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg1b +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg1b @@ -1,4 +1,4 @@ 777639666b449ab0a7ef260511e40532 *./tests/data/vsynth1/mpeg1b.mpg 1030337 ./tests/data/vsynth1/mpeg1b.mpg 91a7fce732b34748e7bf753ebabe2483 *./tests/data/mpeg1b.vsynth1.out.yuv -stddev: 6.30 PSNR: 32.13 bytes: 7603200/ 7603200 +stddev: 6.30 PSNR: 32.13 MAXDIFF: 75 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg2 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg2 index 726908051..e6d404dc0 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg2 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg2 @@ -1,20 +1,20 @@ fbddea2368cd2028fc8db4dfd4682e94 *./tests/data/vsynth1/mpeg2.mpg 728044 ./tests/data/vsynth1/mpeg2.mpg b41ca49c1a02e66ce64d262e2cdaec15 *./tests/data/mpeg2.vsynth1.out.yuv -stddev: 7.65 PSNR: 30.45 bytes: 7603200/ 7603200 +stddev: 7.65 PSNR: 30.45 MAXDIFF: 84 bytes: 7603200/ 7603200 8f6b20714918e6443e0c03716ed06f0d *./tests/data/vsynth1/mpeg2ivlc-qprd.mpg 783552 ./tests/data/vsynth1/mpeg2ivlc-qprd.mpg 98eb9da15f880978e7f2ee1e7ce476ef *./tests/data/mpeg2.vsynth1.out.yuv -stddev: 10.07 PSNR: 28.06 bytes: 7603200/ 7603200 +stddev: 10.07 PSNR: 28.06 MAXDIFF: 165 bytes: 7603200/ 7603200 af0cb75451aaa807beb5102707a98823 *./tests/data/vsynth1/mpeg2_422.mpg 728200 ./tests/data/vsynth1/mpeg2_422.mpg 29b518282493203e83b27a939795dc3a *./tests/data/mpeg2.vsynth1.out.yuv -stddev: 63.33 PSNR: 12.10 bytes: 10137600/ 7603200 +stddev: 63.33 PSNR: 12.10 MAXDIFF: 242 bytes: 10137600/ 7603200 4c067397b504d65532d7779cd36f3f88 *./tests/data/vsynth1/mpeg2.mpg 725668 ./tests/data/vsynth1/mpeg2.mpg 9f7b065f98d57cdecf90e6f7a2524eb5 *./tests/data/mpeg2.vsynth1.out.yuv -stddev: 7.65 PSNR: 30.45 bytes: 7603200/ 7603200 +stddev: 7.65 PSNR: 30.45 MAXDIFF: 81 bytes: 7603200/ 7603200 ec3f6713c88a2b41f6c369fd64341077 *./tests/data/vsynth1/mpeg2i.mpg 737473 ./tests/data/vsynth1/mpeg2i.mpg 97615390fdd69abfcbc7e02df863a7d2 *./tests/data/mpeg2.vsynth1.out.yuv -stddev: 7.67 PSNR: 30.43 bytes: 7603200/ 7603200 +stddev: 7.67 PSNR: 30.43 MAXDIFF: 84 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg2thread b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg2thread index c2e2c4f1f..470c2e91b 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg2thread +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg2thread @@ -1,12 +1,12 @@ ecd183706688bd977c9994c3d1b23d61 *./tests/data/vsynth1/mpeg2thread.mpg 801313 ./tests/data/vsynth1/mpeg2thread.mpg d1658911ca83f5616c1d32abc40750de *./tests/data/mpeg2thread.vsynth1.out.yuv -stddev: 7.63 PSNR: 30.48 bytes: 7603200/ 7603200 +stddev: 7.63 PSNR: 30.48 MAXDIFF: 110 bytes: 7603200/ 7603200 23d600b026222253c2340e23300a4c02 *./tests/data/vsynth1/mpeg2threadivlc.mpg 791773 ./tests/data/vsynth1/mpeg2threadivlc.mpg d1658911ca83f5616c1d32abc40750de *./tests/data/mpeg2thread.vsynth1.out.yuv -stddev: 7.63 PSNR: 30.48 bytes: 7603200/ 7603200 +stddev: 7.63 PSNR: 30.48 MAXDIFF: 110 bytes: 7603200/ 7603200 d119fe917dd81d1ff758b4ce684a8d9d *./tests/data/vsynth1/mpeg2reuse.mpg 2074636 ./tests/data/vsynth1/mpeg2reuse.mpg 92ced6afe8c02304943c400cce51a5f4 *./tests/data/mpeg2thread.vsynth1.out.yuv -stddev: 7.66 PSNR: 30.44 bytes: 7603200/ 7603200 +stddev: 7.66 PSNR: 30.44 MAXDIFF: 111 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4 index 3156fed8c..76b390488 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4 @@ -1,4 +1,4 @@ fd83f2ef5887a62b4d755d7cb5f0ac59 *./tests/data/vsynth1/odivx.mp4 540144 ./tests/data/vsynth1/odivx.mp4 8828a375448dc5c2215163ba70656f89 *./tests/data/mpeg4.vsynth1.out.yuv -stddev: 7.97 PSNR: 30.10 bytes: 7603200/ 7603200 +stddev: 7.97 PSNR: 30.10 MAXDIFF: 105 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4adv b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4adv index bbd996b0b..d61431028 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4adv +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4adv @@ -1,16 +1,16 @@ 7d8eb01fd68d83d62a98585757704d47 *./tests/data/vsynth1/mpeg4-adv.avi 589716 ./tests/data/vsynth1/mpeg4-adv.avi f8b226876b1b2c0b98fd6928fd9adbd8 *./tests/data/mpeg4adv.vsynth1.out.yuv -stddev: 6.98 PSNR: 31.25 bytes: 7603200/ 7603200 +stddev: 6.98 PSNR: 31.25 MAXDIFF: 84 bytes: 7603200/ 7603200 d6b7e724a6ad66ab5e4c5a499218b40d *./tests/data/vsynth1/mpeg4-qprd.avi 710944 ./tests/data/vsynth1/mpeg4-qprd.avi e65f4c7f343fe2bad1cac44b7da5f7c4 *./tests/data/mpeg4adv.vsynth1.out.yuv -stddev: 9.79 PSNR: 28.31 bytes: 7603200/ 7603200 +stddev: 9.79 PSNR: 28.31 MAXDIFF: 176 bytes: 7603200/ 7603200 2d870c0da9ab2231ab5fc06981e70399 *./tests/data/vsynth1/mpeg4-adap.avi 403456 ./tests/data/vsynth1/mpeg4-adap.avi fa2049396479b5f170aa764fed5b2a31 *./tests/data/mpeg4adv.vsynth1.out.yuv -stddev: 14.05 PSNR: 25.17 bytes: 7603200/ 7603200 +stddev: 14.05 PSNR: 25.17 MAXDIFF: 184 bytes: 7603200/ 7603200 3bf17c3d04f52988386ce106a2a58976 *./tests/data/vsynth1/mpeg4-Q.avi 860678 ./tests/data/vsynth1/mpeg4-Q.avi 756928496245ecc701f79eebeec8e5e6 *./tests/data/mpeg4adv.vsynth1.out.yuv -stddev: 5.63 PSNR: 33.12 bytes: 7603200/ 7603200 +stddev: 5.63 PSNR: 33.12 MAXDIFF: 70 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4nr b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4nr index 24ed8de28..c82149030 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4nr +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4nr @@ -1,4 +1,4 @@ c02f54157ba08ca12ad979c6308212ad *./tests/data/vsynth1/mpeg4-nr.avi 675638 ./tests/data/vsynth1/mpeg4-nr.avi d2b89d5958fb7331f6c9e5b7ecaaa5b6 *./tests/data/mpeg4nr.vsynth1.out.yuv -stddev: 6.99 PSNR: 31.23 bytes: 7603200/ 7603200 +stddev: 6.99 PSNR: 31.23 MAXDIFF: 86 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4thread b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4thread index d8e06fe5d..d04f43685 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4thread +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/mpeg4thread @@ -1,4 +1,4 @@ 4f4ea04faad7212374919aa1ec7ff994 *./tests/data/vsynth1/mpeg4-thread.avi 774760 ./tests/data/vsynth1/mpeg4-thread.avi 64b96cddf5301990e118978b3a3bcd0d *./tests/data/mpeg4thread.vsynth1.out.yuv -stddev: 10.13 PSNR: 28.02 bytes: 7603200/ 7603200 +stddev: 10.13 PSNR: 28.02 MAXDIFF: 183 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/msmpeg4 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/msmpeg4 index 46b72f12d..b4e903ac1 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/msmpeg4 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/msmpeg4 @@ -1,4 +1,4 @@ d437c6ab3775c50fdec00fa744bb5add *./tests/data/vsynth1/msmpeg4.avi 624718 ./tests/data/vsynth1/msmpeg4.avi 5ca72c39e3fc5df8e62f223c869589f5 *./tests/data/msmpeg4.vsynth1.out.yuv -stddev: 7.98 PSNR: 30.09 bytes: 7603200/ 7603200 +stddev: 7.98 PSNR: 30.09 MAXDIFF: 104 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/msmpeg4v2 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/msmpeg4v2 index 69bd62f07..dde152d81 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/msmpeg4v2 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/msmpeg4v2 @@ -1,4 +1,4 @@ 88957e35efcc718bce0307627ad3298d *./tests/data/vsynth1/msmpeg4v2.avi 623788 ./tests/data/vsynth1/msmpeg4v2.avi c6ff1041a0ef62c2a2e5ef519e5e94c4 *./tests/data/msmpeg4v2.vsynth1.out.yuv -stddev: 7.97 PSNR: 30.10 bytes: 7603200/ 7603200 +stddev: 7.97 PSNR: 30.10 MAXDIFF: 105 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/rc b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/rc index cf852a8bd..be5095207 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/rc +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/rc @@ -1,4 +1,4 @@ 1c6dadf75f60f4ba59a0fe0b6eaedf57 *./tests/data/vsynth1/mpeg4-rc.avi 830160 ./tests/data/vsynth1/mpeg4-rc.avi 4d95e340db9bc57a559162c039f3784e *./tests/data/rc.vsynth1.out.yuv -stddev: 10.24 PSNR: 27.92 bytes: 7603200/ 7603200 +stddev: 10.24 PSNR: 27.92 MAXDIFF: 196 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/roq b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/roq index 086ae1ce7..42456e4e3 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/roq +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/roq @@ -1,4 +1,4 @@ cf8b7b0e539bab3169c234ca63d71dd8 *./tests/data/vsynth1/roqav.roq 101671 ./tests/data/vsynth1/roqav.roq 0ad983c291b1ed373645c5b12a108c61 *./tests/data/roq.vsynth1.out.yuv -stddev: 7.74 PSNR: 30.35 bytes: 760320/ 7603200 +stddev: 7.74 PSNR: 30.35 MAXDIFF: 89 bytes: 760320/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/rv10 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/rv10 index 7cd50d14d..9e0ceec2f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/rv10 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/rv10 @@ -1,4 +1,4 @@ 4d7e82de72a83905cf84b8abc3e70b8f *./tests/data/vsynth1/rv10.rm 653905 ./tests/data/vsynth1/rv10.rm 1a1ba9a3a63ec1a1a9585fded0a7c954 *./tests/data/rv10.vsynth1.out.yuv -stddev: 8.03 PSNR: 30.03 bytes: 7603200/ 7603200 +stddev: 8.03 PSNR: 30.03 MAXDIFF: 103 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/rv20 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/rv20 index d8cc2ccea..19e4474db 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/rv20 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/rv20 @@ -1,4 +1,4 @@ 49f656b3a84bd7173ca219fae310750c *./tests/data/vsynth1/rv20.rm 627450 ./tests/data/vsynth1/rv20.rm a94d2babdc506b95951977cb55642981 *./tests/data/rv20.vsynth1.out.yuv -stddev: 8.24 PSNR: 29.81 bytes: 7603200/ 7603200 +stddev: 8.24 PSNR: 29.81 MAXDIFF: 108 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/snow b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/snow index 917811513..ac3476078 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/snow +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/snow @@ -1,4 +1,4 @@ d593b3c1a9729ce6dd1721f58fa93712 *./tests/data/vsynth1/snow.avi 136088 ./tests/data/vsynth1/snow.avi 91021b7d6d7908648fe78cc1975af8c4 *./tests/data/snow.vsynth1.out.yuv -stddev: 22.77 PSNR: 20.98 bytes: 7603200/ 7603200 +stddev: 22.77 PSNR: 20.98 MAXDIFF: 172 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/snowll b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/snowll index 0246038de..427e52de5 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/snowll +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/snowll @@ -1,4 +1,4 @@ 6d29e8c06a645cdee45073c4f3d0004e *./tests/data/vsynth1/snow53.avi 3419980 ./tests/data/vsynth1/snow53.avi c5ccac874dbf808e9088bc3107860042 *./tests/data/snowll.vsynth1.out.yuv -stddev: 0.00 PSNR:999.99 bytes: 7603200/ 7603200 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/svq1 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/svq1 index b6c95ea6c..8c647c787 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/svq1 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/svq1 @@ -1,4 +1,4 @@ 595fc4e38734521356b60e67b813f0fa *./tests/data/vsynth1/svq1.mov 1334367 ./tests/data/vsynth1/svq1.mov 9cc35c54b2c77d36bd7e308b393c1f81 *./tests/data/svq1.vsynth1.out.yuv -stddev: 9.58 PSNR: 28.50 bytes: 7603200/ 7603200 +stddev: 9.58 PSNR: 28.50 MAXDIFF: 210 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/wmv1 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/wmv1 index 891c88be8..8c32ea80c 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/wmv1 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/wmv1 @@ -1,4 +1,4 @@ 4f3461315776e5118866fa3819cff9b6 *./tests/data/vsynth1/wmv1.avi 626908 ./tests/data/vsynth1/wmv1.avi 5182edba5b5e0354b39ce4f3604b62da *./tests/data/wmv1.vsynth1.out.yuv -stddev: 7.97 PSNR: 30.09 bytes: 7603200/ 7603200 +stddev: 7.97 PSNR: 30.09 MAXDIFF: 110 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/wmv2 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/wmv2 index 2e72290fa..8e1e88d6f 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/wmv2 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth1/wmv2 @@ -1,4 +1,4 @@ 13efda9d3811345aadc0632fc9a9332b *./tests/data/vsynth1/wmv2.avi 659852 ./tests/data/vsynth1/wmv2.avi 5182edba5b5e0354b39ce4f3604b62da *./tests/data/wmv2.vsynth1.out.yuv -stddev: 7.97 PSNR: 30.09 bytes: 7603200/ 7603200 +stddev: 7.97 PSNR: 30.09 MAXDIFF: 110 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/asv1 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/asv1 index a584645a9..1d0385c94 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/asv1 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/asv1 @@ -1,4 +1,4 @@ 4eb34d2de25f67a2706456e999338fe9 *./tests/data/vsynth2/asv1.avi 832512 ./tests/data/vsynth2/asv1.avi c96ff7fd17c52f99ddb7922a4cb9168f *./tests/data/asv1.vsynth2.out.yuv -stddev: 10.47 PSNR: 27.73 bytes: 7603200/ 7603200 +stddev: 10.47 PSNR: 27.73 MAXDIFF: 98 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/asv2 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/asv2 index b8984204d..21ce40aab 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/asv2 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/asv2 @@ -1,4 +1,4 @@ 9649a4b68fb1107bad13e8a7574cc72d *./tests/data/vsynth2/asv2.avi 789072 ./tests/data/vsynth2/asv2.avi 74a78015b64b2cf8cb9da2e44f508a69 *./tests/data/asv2.vsynth2.out.yuv -stddev: 10.28 PSNR: 27.89 bytes: 7603200/ 7603200 +stddev: 10.28 PSNR: 27.89 MAXDIFF: 95 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dnxhd_1080i b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dnxhd_1080i index 6ab7fbbbf..69ec10cc5 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dnxhd_1080i +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dnxhd_1080i @@ -1,4 +1,4 @@ 1a4594983ae91f41907b89fe3174c527 *./tests/data/vsynth2/dnxhd-1080i.mov 3031875 ./tests/data/vsynth2/dnxhd-1080i.mov 3c559af629ae0a8fb1a9a0e4b4da7733 *./tests/data/dnxhd_1080i.vsynth2.out.yuv -stddev: 1.31 PSNR: 45.77 bytes: 760320/ 7603200 +stddev: 1.31 PSNR: 45.77 MAXDIFF: 23 bytes: 760320/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dnxhd_720p b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dnxhd_720p index cbf3f3757..eab04c609 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dnxhd_720p +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dnxhd_720p @@ -1,4 +1,4 @@ 58e07cc6ae0a2d36787044d0e82708a6 *./tests/data/vsynth2/dnxhd-720p.dnxhd 2293760 ./tests/data/vsynth2/dnxhd-720p.dnxhd ab601eaafef74d80d3d20b780dddd836 *./tests/data/dnxhd_720p.vsynth2.out.yuv -stddev: 1.36 PSNR: 45.45 bytes: 760320/ 7603200 +stddev: 1.36 PSNR: 45.45 MAXDIFF: 127 bytes: 760320/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dnxhd_720p_rd b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dnxhd_720p_rd index e92249522..2d5c4d550 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dnxhd_720p_rd +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dnxhd_720p_rd @@ -1,4 +1,4 @@ 092ffb7b8cf3c11556bb05dbb8b476ac *./tests/data/vsynth2/dnxhd-720p-rd.dnxhd 2293760 ./tests/data/vsynth2/dnxhd-720p-rd.dnxhd 33547ca318acff9448cba719cb99296d *./tests/data/dnxhd_720p_rd.vsynth2.out.yuv -stddev: 1.32 PSNR: 45.66 bytes: 760320/ 7603200 +stddev: 1.32 PSNR: 45.66 MAXDIFF: 22 bytes: 760320/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dv b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dv index 72e4350ce..676b209c5 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dv +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dv @@ -1,8 +1,8 @@ bfa766f89bfeabc0ae1044f3954bed52 *./tests/data/vsynth2/dv.dv 7200000 ./tests/data/vsynth2/dv.dv 7ec62bd3350a6848364669e6e1e4b9cc *./tests/data/dv.vsynth2.out.yuv -stddev: 1.71 PSNR: 43.47 bytes: 7603200/ 7603200 +stddev: 1.71 PSNR: 43.47 MAXDIFF: 33 bytes: 7603200/ 7603200 00a9d8683ac6826af41bcf7223fb0389 *./tests/data/vsynth2/dv411.dv 7200000 ./tests/data/vsynth2/dv411.dv 7f9fa421028aabb11eaf4c6513a5a843 *./tests/data/dv.vsynth2.out.yuv -stddev: 10.09 PSNR: 28.05 bytes: 7603200/ 7603200 +stddev: 10.09 PSNR: 28.05 MAXDIFF: 60 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dv50 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dv50 index 79c25a8b8..7e0083bfc 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dv50 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/dv50 @@ -1,4 +1,4 @@ 61e31c79e8949b25c849753a0785b0d7 *./tests/data/vsynth2/dv50.dv 14400000 ./tests/data/vsynth2/dv50.dv af3f2dd5ab62c1a1d98b07d4aeb6852f *./tests/data/dv50.vsynth2.out.yuv -stddev: 0.82 PSNR: 49.82 bytes: 7603200/ 7603200 +stddev: 0.82 PSNR: 49.82 MAXDIFF: 12 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/error b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/error index b273e002c..4181b2d29 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/error +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/error @@ -1,4 +1,4 @@ 90e65096aa9ebafa3fe3f44a5a47cdc4 *./tests/data/vsynth2/error-mpeg4-adv.avi 176588 ./tests/data/vsynth2/error-mpeg4-adv.avi 9fe1082179f80179439953c7397a46ef *./tests/data/error.vsynth2.out.yuv -stddev: 9.00 PSNR: 29.04 bytes: 7603200/ 7603200 +stddev: 9.00 PSNR: 29.04 MAXDIFF: 168 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/ffv1 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/ffv1 index f7dd8e9f8..d251af557 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/ffv1 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/ffv1 @@ -1,4 +1,4 @@ d72b0960e162d4998b9acbabb07e99ab *./tests/data/vsynth2/ffv1.avi 3525804 ./tests/data/vsynth2/ffv1.avi dde5895817ad9d219f79a52d0bdfb001 *./tests/data/ffv1.vsynth2.out.yuv -stddev: 0.00 PSNR:999.99 bytes: 7603200/ 7603200 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/flashsv b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/flashsv index b5f0bcee3..bfbb9e1c0 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/flashsv +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/flashsv @@ -1,4 +1,4 @@ 0667077971e0cb63b5f49c580006e90e *./tests/data/vsynth2/flashsv.flv 12368953 ./tests/data/vsynth2/flashsv.flv 592b3321994e26a990deb3a0a1415de9 *./tests/data/flashsv.vsynth2.out.yuv -stddev: 0.65 PSNR: 51.84 bytes: 7603200/ 7603200 +stddev: 0.65 PSNR: 51.84 MAXDIFF: 14 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/flv b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/flv index 7fa57db9e..716177fb9 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/flv +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/flv @@ -1,4 +1,4 @@ 2edc92093d36506bcc0a5c0e17e86113 *./tests/data/vsynth2/flv.flv 131360 ./tests/data/vsynth2/flv.flv 8999c8264fb0941561f64c4a736e9d88 *./tests/data/flv.vsynth2.out.yuv -stddev: 5.33 PSNR: 33.59 bytes: 7603200/ 7603200 +stddev: 5.33 PSNR: 33.59 MAXDIFF: 80 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/h261 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/h261 index ef9454cd1..07c29ab67 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/h261 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/h261 @@ -1,4 +1,4 @@ dfd005d4c9030a0dc889c828a6408b9c *./tests/data/vsynth2/h261.avi 191086 ./tests/data/vsynth2/h261.avi db7ceff174823b98834faa2320ca89ac *./tests/data/h261.vsynth2.out.yuv -stddev: 6.37 PSNR: 32.03 bytes: 7603200/ 7603200 +stddev: 6.37 PSNR: 32.03 MAXDIFF: 77 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/h263 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/h263 index 739ba5292..7e3fd3344 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/h263 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/h263 @@ -1,4 +1,4 @@ 9a368687ab34c48079f11a202839a6bc *./tests/data/vsynth2/h263.avi 160106 ./tests/data/vsynth2/h263.avi 61213b91b359697ebcefb9e0a53ac54a *./tests/data/h263.vsynth2.out.yuv -stddev: 5.43 PSNR: 33.42 bytes: 7603200/ 7603200 +stddev: 5.43 PSNR: 33.42 MAXDIFF: 77 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/h263p b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/h263p index 3c26eb053..314726fd7 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/h263p +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/h263p @@ -1,4 +1,4 @@ c7644d40e9f40bbd98e5a978f9f94bb4 *./tests/data/vsynth2/h263p.avi 868018 ./tests/data/vsynth2/h263p.avi 4b0ee791f280029dc03c528f76f195d4 *./tests/data/h263p.vsynth2.out.yuv -stddev: 1.91 PSNR: 42.50 bytes: 7603200/ 7603200 +stddev: 1.91 PSNR: 42.50 MAXDIFF: 19 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/huffyuv b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/huffyuv index e0e7277ed..740862aba 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/huffyuv +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/huffyuv @@ -1,4 +1,4 @@ 56cd44907a48990e06bd065e189ff461 *./tests/data/vsynth2/huffyuv.avi 6455232 ./tests/data/vsynth2/huffyuv.avi dde5895817ad9d219f79a52d0bdfb001 *./tests/data/huffyuv.vsynth2.out.yuv -stddev: 0.00 PSNR:999.99 bytes: 7603200/ 7603200 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/jpegls b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/jpegls index 3f87fd2fd..e7fa2df46 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/jpegls +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/jpegls @@ -1,4 +1,4 @@ 4fc53937f048c900ae6d50fda9dba206 *./tests/data/vsynth2/jpegls.avi 8334630 ./tests/data/vsynth2/jpegls.avi 592b3321994e26a990deb3a0a1415de9 *./tests/data/jpegls.vsynth2.out.yuv -stddev: 0.65 PSNR: 51.84 bytes: 7603200/ 7603200 +stddev: 0.65 PSNR: 51.84 MAXDIFF: 14 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/ljpeg b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/ljpeg index aec9b5672..54c1d864d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/ljpeg +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/ljpeg @@ -1,4 +1,4 @@ 554a4a6a5a9058c588f8bf2de405bc70 *./tests/data/vsynth2/ljpeg.avi 4766914 ./tests/data/vsynth2/ljpeg.avi dde5895817ad9d219f79a52d0bdfb001 *./tests/data/ljpeg.vsynth2.out.yuv -stddev: 0.00 PSNR:999.99 bytes: 7603200/ 7603200 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mjpeg b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mjpeg index 0b501f9f4..adee32805 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mjpeg +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mjpeg @@ -1,4 +1,4 @@ 89df32b46c977fb4cb140ec6c489dd76 *./tests/data/vsynth2/mjpeg.avi 673224 ./tests/data/vsynth2/mjpeg.avi a96a4e15ffcb13e44360df642d049496 *./tests/data/mjpeg.vsynth2.out.yuv -stddev: 4.32 PSNR: 35.40 bytes: 7603200/ 7603200 +stddev: 4.32 PSNR: 35.40 MAXDIFF: 49 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg index 1f995eb0f..5a051c8a6 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg @@ -1,4 +1,4 @@ 73ca6f1deab02d1d67a0e8495c026a9e *./tests/data/vsynth2/mpeg1.mpg 192783 ./tests/data/vsynth2/mpeg1.mpg 56147e94b12f08df7213e610e177823d *./tests/data/mpeg.vsynth2.out.yuv -stddev: 4.95 PSNR: 34.22 bytes: 7603200/ 7603200 +stddev: 4.95 PSNR: 34.22 MAXDIFF: 57 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg1b b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg1b index 626fbd017..f51aa3fd6 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg1b +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg1b @@ -1,4 +1,4 @@ e026a2fef80c9679776d2b5c8be09338 *./tests/data/vsynth2/mpeg1b.mpg 225198 ./tests/data/vsynth2/mpeg1b.mpg 1150495f4bd487486ee53326c42d0bb8 *./tests/data/mpeg1b.vsynth2.out.yuv -stddev: 4.10 PSNR: 35.86 bytes: 7603200/ 7603200 +stddev: 4.10 PSNR: 35.86 MAXDIFF: 59 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg2 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg2 index f4a1c9658..a6ab3f6b9 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg2 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg2 @@ -1,20 +1,20 @@ 2d55ce623a7be4e8136f80266e487678 *./tests/data/vsynth2/mpeg2.mpg 198667 ./tests/data/vsynth2/mpeg2.mpg b7cae8a1f751b821cddcbe4d5dbc518c *./tests/data/mpeg2.vsynth2.out.yuv -stddev: 4.96 PSNR: 34.20 bytes: 7603200/ 7603200 +stddev: 4.96 PSNR: 34.20 MAXDIFF: 59 bytes: 7603200/ 7603200 1ba5efeb53fab7b4b71edc96d86f6c91 *./tests/data/vsynth2/mpeg2ivlc-qprd.mpg 244694 ./tests/data/vsynth2/mpeg2ivlc-qprd.mpg b26e21599dee48a174bdbc40b2817e55 *./tests/data/mpeg2.vsynth2.out.yuv -stddev: 4.15 PSNR: 35.76 bytes: 7603200/ 7603200 +stddev: 4.15 PSNR: 35.76 MAXDIFF: 74 bytes: 7603200/ 7603200 2c8e33c2d2efab86fc16a195f6877682 *./tests/data/vsynth2/mpeg2_422.mpg 356124 ./tests/data/vsynth2/mpeg2_422.mpg de44597c6c470f3e7019b31245a3ff69 *./tests/data/mpeg2.vsynth2.out.yuv -stddev: 54.55 PSNR: 13.39 bytes: 10137600/ 7603200 +stddev: 54.55 PSNR: 13.39 MAXDIFF: 201 bytes: 10137600/ 7603200 f979bcca866e6e4cad5dc6cb06e56cfb *./tests/data/vsynth2/mpeg2.mpg 198041 ./tests/data/vsynth2/mpeg2.mpg f6d9bf24ff8676a7f6076c05cd2c81a3 *./tests/data/mpeg2.vsynth2.out.yuv -stddev: 4.97 PSNR: 34.19 bytes: 7603200/ 7603200 +stddev: 4.97 PSNR: 34.19 MAXDIFF: 58 bytes: 7603200/ 7603200 f90197a8b6e62ae25f82625337f27240 *./tests/data/vsynth2/mpeg2i.mpg 204579 ./tests/data/vsynth2/mpeg2i.mpg ea5057b60146c06d40449cdfc686bf13 *./tests/data/mpeg2.vsynth2.out.yuv -stddev: 4.98 PSNR: 34.18 bytes: 7603200/ 7603200 +stddev: 4.98 PSNR: 34.18 MAXDIFF: 65 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg2thread b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg2thread index 9253d7f3d..3c9c0d016 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg2thread +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg2thread @@ -1,12 +1,12 @@ 889c754a42d7689b228853e1ece6d345 *./tests/data/vsynth2/mpeg2thread.mpg 179650 ./tests/data/vsynth2/mpeg2thread.mpg 8c6a7ed2eb73bd18fd2bb9829464100d *./tests/data/mpeg2thread.vsynth2.out.yuv -stddev: 4.72 PSNR: 34.65 bytes: 7603200/ 7603200 +stddev: 4.72 PSNR: 34.65 MAXDIFF: 72 bytes: 7603200/ 7603200 10b900e32809758857c596d56746e00e *./tests/data/vsynth2/mpeg2threadivlc.mpg 178801 ./tests/data/vsynth2/mpeg2threadivlc.mpg 8c6a7ed2eb73bd18fd2bb9829464100d *./tests/data/mpeg2thread.vsynth2.out.yuv -stddev: 4.72 PSNR: 34.65 bytes: 7603200/ 7603200 +stddev: 4.72 PSNR: 34.65 MAXDIFF: 72 bytes: 7603200/ 7603200 864d6bf2982a61e510003a518be65a2d *./tests/data/vsynth2/mpeg2reuse.mpg 383419 ./tests/data/vsynth2/mpeg2reuse.mpg bb20fa080cfd2b0a687ea7376ff4f902 *./tests/data/mpeg2thread.vsynth2.out.yuv -stddev: 4.73 PSNR: 34.63 bytes: 7603200/ 7603200 +stddev: 4.73 PSNR: 34.63 MAXDIFF: 72 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4 index c24cbd0d8..9a6158c67 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4 @@ -1,4 +1,4 @@ 47de227982e77830a2db278214a08773 *./tests/data/vsynth2/odivx.mp4 119797 ./tests/data/vsynth2/odivx.mp4 90a3577850239083a9042bef33c50e85 *./tests/data/mpeg4.vsynth2.out.yuv -stddev: 5.34 PSNR: 33.57 bytes: 7603200/ 7603200 +stddev: 5.34 PSNR: 33.57 MAXDIFF: 83 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4adv b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4adv index 89d21ac84..f8568c782 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4adv +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4adv @@ -1,16 +1,16 @@ dee7be19486a76d96c88d18eefba8f86 *./tests/data/vsynth2/mpeg4-adv.avi 141546 ./tests/data/vsynth2/mpeg4-adv.avi 3f3a21e9db85a9c0f7022f557a5374c1 *./tests/data/mpeg4adv.vsynth2.out.yuv -stddev: 4.94 PSNR: 34.25 bytes: 7603200/ 7603200 +stddev: 4.94 PSNR: 34.25 MAXDIFF: 69 bytes: 7603200/ 7603200 fd5ab0f55dbc959316e32923e86290df *./tests/data/vsynth2/mpeg4-qprd.avi 231458 ./tests/data/vsynth2/mpeg4-qprd.avi de8a883865e2dff7a51f66da6c48df48 *./tests/data/mpeg4adv.vsynth2.out.yuv -stddev: 3.71 PSNR: 36.72 bytes: 7603200/ 7603200 +stddev: 3.71 PSNR: 36.72 MAXDIFF: 61 bytes: 7603200/ 7603200 547e1849dcf910935ff6383ca49e5706 *./tests/data/vsynth2/mpeg4-adap.avi 198510 ./tests/data/vsynth2/mpeg4-adap.avi 4affb83f6adc94f31024b4f9e0168945 *./tests/data/mpeg4adv.vsynth2.out.yuv -stddev: 3.75 PSNR: 36.65 bytes: 7603200/ 7603200 +stddev: 3.75 PSNR: 36.65 MAXDIFF: 71 bytes: 7603200/ 7603200 7680d2e7d34399dfdfb8a49cf1e10239 *./tests/data/vsynth2/mpeg4-Q.avi 163688 ./tests/data/vsynth2/mpeg4-Q.avi 26dc7c78955fa678fbf150e236eb5627 *./tests/data/mpeg4adv.vsynth2.out.yuv -stddev: 3.97 PSNR: 36.14 bytes: 7603200/ 7603200 +stddev: 3.97 PSNR: 36.14 MAXDIFF: 54 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4nr b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4nr index 1f9499fc7..ec36d27bd 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4nr +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4nr @@ -1,4 +1,4 @@ c41187c99588fb7229ad330b2f80d28b *./tests/data/vsynth2/mpeg4-nr.avi 155044 ./tests/data/vsynth2/mpeg4-nr.avi f7fc191308679f709405e62271f5c65f *./tests/data/mpeg4nr.vsynth2.out.yuv -stddev: 4.73 PSNR: 34.63 bytes: 7603200/ 7603200 +stddev: 4.73 PSNR: 34.63 MAXDIFF: 64 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4thread b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4thread index c881aa4db..63f355ba1 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4thread +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/mpeg4thread @@ -1,4 +1,4 @@ ba30d10ff70d46e7c5b7fa859ea1faa4 *./tests/data/vsynth2/mpeg4-thread.avi 250140 ./tests/data/vsynth2/mpeg4-thread.avi 5355deb8c7609a3f1ff2173aab1dee70 *./tests/data/mpeg4thread.vsynth2.out.yuv -stddev: 3.69 PSNR: 36.78 bytes: 7603200/ 7603200 +stddev: 3.69 PSNR: 36.78 MAXDIFF: 65 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/msmpeg4 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/msmpeg4 index d77a4549e..75ec82cd4 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/msmpeg4 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/msmpeg4 @@ -1,4 +1,4 @@ 3069f95f2ffca1f20c8ea36e2625fabc *./tests/data/vsynth2/msmpeg4.avi 127680 ./tests/data/vsynth2/msmpeg4.avi 0e1c6e25c71c6a8fa8e506e3d97ca4c9 *./tests/data/msmpeg4.vsynth2.out.yuv -stddev: 5.33 PSNR: 33.59 bytes: 7603200/ 7603200 +stddev: 5.33 PSNR: 33.59 MAXDIFF: 78 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/msmpeg4v2 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/msmpeg4v2 index 3bfd83934..9fe913d62 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/msmpeg4v2 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/msmpeg4v2 @@ -1,4 +1,4 @@ c09815e40a9d260628e1ebad8b2b3774 *./tests/data/vsynth2/msmpeg4v2.avi 129918 ./tests/data/vsynth2/msmpeg4v2.avi 8920194f8bf8f9cdd6c65b3df9e1a292 *./tests/data/msmpeg4v2.vsynth2.out.yuv -stddev: 5.33 PSNR: 33.59 bytes: 7603200/ 7603200 +stddev: 5.33 PSNR: 33.59 MAXDIFF: 80 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rc b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rc index d6eab6932..14d9a6ce0 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rc +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rc @@ -1,4 +1,4 @@ c25ede9e268b834a09a63f5136cd1b95 *./tests/data/vsynth2/mpeg4-rc.avi 226332 ./tests/data/vsynth2/mpeg4-rc.avi 2b34e606af895b62a250de98749a19b0 *./tests/data/rc.vsynth2.out.yuv -stddev: 4.23 PSNR: 35.60 bytes: 7603200/ 7603200 +stddev: 4.23 PSNR: 35.60 MAXDIFF: 85 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rgb/rgb.vsynth2.regression b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rgb/rgb.vsynth2.regression deleted file mode 100644 index 4dae1053b..000000000 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rgb/rgb.vsynth2.regression +++ /dev/null @@ -1,4 +0,0 @@ -f2e9c419023c743bf99aa5b2e55ad233 *./tests/data/vsynth2/rgb.avi -15213260 ./tests/data/vsynth2/rgb.avi -b2418e0e3a9a8619b31219cbcf24dc82 *./tests/data/rgb.vsynth2.out.yuv -stddev: 1.26 PSNR: 46.06 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/roq b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/roq index f82f6409e..a9650deef 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/roq +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/roq @@ -1,4 +1,4 @@ b46f899b2363065c60f3782ba1f8b7bd *./tests/data/vsynth2/roqav.roq 92786 ./tests/data/vsynth2/roqav.roq e69fca960dd0911e9b8d589c13e11dc1 *./tests/data/roq.vsynth2.out.yuv -stddev: 3.81 PSNR: 36.49 bytes: 760320/ 7603200 +stddev: 3.81 PSNR: 36.49 MAXDIFF: 54 bytes: 760320/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rv10 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rv10 index c71d0dbbc..75b92652d 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rv10 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rv10 @@ -1,4 +1,4 @@ b1467b0e8d8cad730e36d1e8ab49d573 *./tests/data/vsynth2/rv10.rm 154310 ./tests/data/vsynth2/rv10.rm 61213b91b359697ebcefb9e0a53ac54a *./tests/data/rv10.vsynth2.out.yuv -stddev: 5.43 PSNR: 33.42 bytes: 7603200/ 7603200 +stddev: 5.43 PSNR: 33.42 MAXDIFF: 77 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rv20 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rv20 index d029e5037..45150cc0e 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rv20 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/rv20 @@ -1,4 +1,4 @@ d864475aa16d84dd99de13e65003672a *./tests/data/vsynth2/rv20.rm 132734 ./tests/data/vsynth2/rv20.rm c66afdcc0daac2f1b4167b9811968877 *./tests/data/rv20.vsynth2.out.yuv -stddev: 5.42 PSNR: 33.45 bytes: 7603200/ 7603200 +stddev: 5.42 PSNR: 33.45 MAXDIFF: 81 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/snow b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/snow index 521d56388..922110bfa 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/snow +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/snow @@ -1,4 +1,4 @@ af651d8ef0a66257ac8b2ef8b229f27b *./tests/data/vsynth2/snow.avi 57700 ./tests/data/vsynth2/snow.avi 8890189af71a0dd3447c4e8424c9a76b *./tests/data/snow.vsynth2.out.yuv -stddev: 10.47 PSNR: 27.72 bytes: 7603200/ 7603200 +stddev: 10.47 PSNR: 27.72 MAXDIFF: 119 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/snowll b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/snowll index 111a2f223..0eb494513 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/snowll +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/snowll @@ -1,4 +1,4 @@ a8fccf278bbb17d37a756ecf11672b09 *./tests/data/vsynth2/snow53.avi 2721758 ./tests/data/vsynth2/snow53.avi dde5895817ad9d219f79a52d0bdfb001 *./tests/data/snowll.vsynth2.out.yuv -stddev: 0.00 PSNR:999.99 bytes: 7603200/ 7603200 +stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/svq1 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/svq1 index 2a391c3ea..7c54c74ac 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/svq1 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/svq1 @@ -1,4 +1,4 @@ 7f9fbe4890bc1df67867bf03803dca48 *./tests/data/vsynth2/svq1.mov 766851 ./tests/data/vsynth2/svq1.mov aa03471dac3f49455a33a2b19fda1098 *./tests/data/svq1.vsynth2.out.yuv -stddev: 3.23 PSNR: 37.93 bytes: 7603200/ 7603200 +stddev: 3.23 PSNR: 37.93 MAXDIFF: 61 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/wmv1 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/wmv1 index 3339a95e2..12c3f5765 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/wmv1 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/wmv1 @@ -1,4 +1,4 @@ 1011e26e7d351c96d7bbfe106d831b69 *./tests/data/vsynth2/wmv1.avi 129530 ./tests/data/vsynth2/wmv1.avi 81eee429b665254d19a06607463c0b5e *./tests/data/wmv1.vsynth2.out.yuv -stddev: 5.33 PSNR: 33.60 bytes: 7603200/ 7603200 +stddev: 5.33 PSNR: 33.60 MAXDIFF: 77 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/wmv2 b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/wmv2 index 61bb5a5c6..27fcd1287 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/wmv2 +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/wmv2 @@ -1,4 +1,4 @@ 1f6598e9776ed00aebdc44cc8d48cb7c *./tests/data/vsynth2/wmv2.avi 129860 ./tests/data/vsynth2/wmv2.avi 81eee429b665254d19a06607463c0b5e *./tests/data/wmv2.vsynth2.out.yuv -stddev: 5.33 PSNR: 33.60 bytes: 7603200/ 7603200 +stddev: 5.33 PSNR: 33.60 MAXDIFF: 77 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/yuv/yuv.vsynth2.regression b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/yuv/yuv.vsynth2.regression deleted file mode 100644 index 7bf5cae89..000000000 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/ref/vsynth2/yuv/yuv.vsynth2.regression +++ /dev/null @@ -1,4 +0,0 @@ -30a400773ab26f2c83e469198b156f1d *./tests/data/vsynth2/yuv.avi -7610060 ./tests/data/vsynth2/yuv.avi -dde5895817ad9d219f79a52d0bdfb001 *./tests/data/yuv.vsynth2.out.yuv -stddev: 0.00 PSNR:999.99 bytes: 7603200/ 7603200 diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/regression-funcs.sh b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/regression-funcs.sh index 8fd17abd0..678965045 100755 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/regression-funcs.sh +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/regression-funcs.sh @@ -14,7 +14,8 @@ datadir="./tests/data" target_datadir="${target_path}/${datadir}" this="$test.$test_ref" -logfile="$datadir/$this.regression" +logdir="$datadir/regression/$test_ref" +logfile="$logdir/$test" outfile="$datadir/$test_ref/" errfile="$datadir/$this.err" @@ -35,6 +36,7 @@ target_crcfile="$target_datadir/$this.crc" mkdir -p "$datadir" mkdir -p "$outfile" +mkdir -p "$logdir" [ "${V-0}" -gt 0 ] && echov=echo || echov=: [ "${V-0}" -gt 1 ] || exec 2>$errfile diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/seek-regression.sh b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/seek-regression.sh index ae0ef6767..cde4fd756 100755 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/seek-regression.sh +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/seek-regression.sh @@ -12,6 +12,9 @@ target_path=$3 refdir="$src_path/tests/ref/seek" datadir="tests/data" +logdir="$datadir/regression/seek" + +mkdir -p "$logdir" list=$(ls -1 $datadir/vsynth2/* $datadir/acodec/* $datadir/lavf/*) imgs=$(for i in $datadir/images/*; do echo "$i/%02d.${i##*/}"; done) @@ -19,7 +22,7 @@ err=0 for i in $list $imgs; do base=$(basename $i) - logfile="$datadir/$base.seek.regression" + logfile="$logdir/$base" reffile="$refdir/$base.ref" echo "TEST SEEK $base" $echov $target_exec $target_path/tests/seek_test $target_path/$i diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/tiny_psnr.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/tiny_psnr.c index f8d1b7bfa..512d47bb8 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/tiny_psnr.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tests/tiny_psnr.c @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -113,21 +114,41 @@ int main(int argc,char* argv[]){ int skip_bytes = argc<6 ? 0 : atoi(argv[5]); int size0=0; int size1=0; + int maxdist = 0; if(argc<3){ printf("tiny_psnr [ [ []]]\n"); - printf("For WAV files use the following:\n"); - printf("./tiny_psnr file1.wav file2.wav 2 0 44 to skip the header.\n"); - return -1; + printf("WAV headers are skipped automatically.\n"); + return 1; } f[0]= fopen(argv[1], "rb"); f[1]= fopen(argv[2], "rb"); if(!f[0] || !f[1]){ fprintf(stderr, "Could not open input files.\n"); - return -1; + return 1; } - fseek(f[shift<0], shift < 0 ? -shift : shift, SEEK_SET); + + for (i = 0; i < 2; i++) { + uint8_t *p = buf[i]; + if (fread(p, 1, 12, f[i]) != 12) + return 1; + if (!memcmp(p, "RIFF", 4) && + !memcmp(p+8, "WAVE", 4)) { + if (fread(p, 1, 8, f[i]) != 8) + return 1; + while (memcmp(p, "data", 4)) { + int s = p[4] | p[5]<<8 | p[6]<<16 | p[7]<<24; + fseek(f[i], s, SEEK_CUR); + if (fread(p, 1, 8, f[i]) != 8) + return 1; + } + } else { + fseek(f[i], -12, SEEK_CUR); + } + } + + fseek(f[shift<0], abs(shift), SEEK_CUR); fseek(f[0],skip_bytes,SEEK_CUR); fseek(f[1],skip_bytes,SEEK_CUR); @@ -139,11 +160,14 @@ int main(int argc,char* argv[]){ for(j=0; j maxdist) maxdist = dist; } size0 += s0; size1 += s1; @@ -159,9 +183,10 @@ int main(int argc,char* argv[]){ else psnr= 1000*F-1; //floating point free infinity :) - printf("stddev:%5d.%02d PSNR:%3d.%02d bytes:%9d/%9d\n", + printf("stddev:%5d.%02d PSNR:%3d.%02d MAXDIFF:%5d bytes:%9d/%9d\n", (int)(dev/F), (int)(dev%F), (int)(psnr/F), (int)(psnr%F), + maxdist, size0, size1); return 0; } diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tools/patcheck b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tools/patcheck index a6923c4c3..4bb023687 100755 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tools/patcheck +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tools/patcheck @@ -42,6 +42,7 @@ hiegrep '/\*[-<\* ]*\*/' 'empty comment' $* hiegrep 'for *\( *'"$ERE_PRITYP"' ' 'not gcc 2.95 compatible' $* hiegrep '(static|inline|const) *\1' 'duplicate word' $* hiegrep 'INIT_VLC_USE_STATIC' 'forbidden ancient vlc type' $* +hiegrep '=[-+\*\&] ' 'looks like compound assignment' $* hiegrep2 '(int|unsigned|static|void)[a-zA-Z0-9 _]*(init|end)[a-zA-Z0-9 _]*\(.*[^;]$' '(av_cold|:\+[^a-zA-Z_])' 'These functions may need av_cold, please review the whole patch for similar functions needing av_cold' $* @@ -70,6 +71,7 @@ hiegrep '(\( *[0-9] *(&&|\|\|)|(&&|\|\|) *[0-9] *\))' 'overriding condition' $* hiegrep '(:\+|,|;)( *|static|\*)*'"$ERE_PRITYP"' *\*( |\*)*(src|source|input|in[^a-z])' 'missing const?' $* hiegrep '(:\+|,|;)( *|static|\*)*'"$ERE_PRITYP"' *(src|source|input|in)([0-9A-Z_][0-9A-Za-z_]*){1,} *\[' 'missing const (test2)?' $* hiegrep ' *static *'"$ERE_FUNCS"'[^)]*\);' 'static prototype, maybe you should reorder your functions' $* +hiegrep '@file: *[a-zA-Z0-9_]' 'doxy filetag with filename can in the future cause problems when forgotten during a rename' $* hiegrep2 '\.long_name *=' 'NULL_IF_CONFIG_SMAL' 'missing NULL_IF_CONFIG_SMAL' $* hiegrep2 '\.pix_fmts *= *\(' 'const' 'missing const for pix_fmts array' $* @@ -112,7 +114,7 @@ for i in \ ; do echo $i | grep '^NULL$' && continue egrep $i' *(\+|-|\*|/|\||&|%|)=[^=]' $* >/dev/null || echo "possibly never written:"$i >> $TMP - egrep '(=|\(|return).*'$i'[^=]*$' $* >/dev/null || echo "possibly never read :"$i >> $TMP + egrep '(=|\(|return).*'$i'(==|[^=])*$' $* >/dev/null || echo "possibly never read :"$i >> $TMP egrep -o $i' *((\+|-|\*|/|\||&|%|)=[^=]|\+\+|--) *(0x|)[0-9]*(;|)' $* |\ egrep -v $i' *= *(0x|)[0-9]{1,};'>/dev/null || echo "possibly constant :"$i >> $TMP done diff --git a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tools/qt-faststart.c b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tools/qt-faststart.c index 7bcd5b72b..ace4c113c 100644 --- a/xbmc/cores/dvdplayer/Codecs/ffmpeg/tools/qt-faststart.c +++ b/xbmc/cores/dvdplayer/Codecs/ffmpeg/tools/qt-faststart.c @@ -27,6 +27,7 @@ #include #include #include +#include #ifdef __MINGW32__ #define fseeko(x,y,z) fseeko64(x,y,z) @@ -98,6 +99,11 @@ int main(int argc, char *argv[]) return 0; } + if (!strcmp(argv[1], argv[2])) { + fprintf(stderr, "input and output files need to be different\n"); + return 1; + } + infile = fopen(argv[1], "rb"); if (!infile) { perror(argv[1]);